我在quickbooks发票上遇到了新问题。创建发票后,我会收到我添加的所有商品以及发票中的一个额外订单项。
如何过滤,删除,阻止此行出现?
以下是我的尝试。
//Find Item
var itemQueryService = new QueryService<Item>(qboContextoAuth);
Item item = itemQueryService.ExecuteIdsQuery("Select * From Item StartPosition 1 MaxResults 1").FirstOrDefault();
int idx = 0;
var lines = new List<Line>();
foreach (var orderItem in orderItems)
{
//Line
Line invoiceLine = new Line();
//Line Description
invoiceLine.Description = itemRepository.Get(i => i.ItemID == orderItem.ItemID).First().FullDescription;
//Line Amount
invoiceLine.Amount = orderItem.Price * orderItem.Quantity;
invoiceLine.AmountSpecified = true;
//Line Detail Type
invoiceLine.DetailType = LineDetailTypeEnum.SalesItemLineDetail;
invoiceLine.DetailTypeSpecified = true;
//Line Sales Item Line Detail
SalesItemLineDetail lineSalesItemLineDetail = new SalesItemLineDetail();
//Line Sales Item Line Detail - ItemRef
lineSalesItemLineDetail.ItemRef = new ReferenceType()
{
name = itemRepository.Get(i => i.ItemID == orderItem.ItemID).First().FullDescription,
Value = item.Id
};
//Line Sales Item Line Detail - UnitPrice
lineSalesItemLineDetail.AnyIntuitObject = orderItem.Price; //33m;
lineSalesItemLineDetail.ItemElementName = ItemChoiceType.UnitPrice;
//Line Sales Item Line Detail - Qty
lineSalesItemLineDetail.Qty = orderItem.Quantity; //10;
lineSalesItemLineDetail.QtySpecified = true;
//Line Sales Item Line Detail - TaxCodeRef
//For US companies, this can be 'TAX' or 'NON
/* lineSalesItemLineDetail.TaxCodeRef = new ReferenceType()
{
Value = "TAX"
};*/
//Line Sales Item Line Detail - ServiceDate
lineSalesItemLineDetail.ServiceDate = DateTime.Now.Date;
lineSalesItemLineDetail.ServiceDateSpecified = true;
//Assign Sales Item Line Detail to Line Item
invoiceLine.AnyIntuitObject = lineSalesItemLineDetail;
//Assign Line Item to Invoice
//invoice.Line = new Line[] { invoiceLine };
lines.Add(invoiceLine);
//TxnTaxDetail
/*TxnTaxDetail txnTaxDetail = new TxnTaxDetail();
txnTaxDetail.TxnTaxCodeRef = new ReferenceType()
{
name = stateTaxCode.Name,
Value = stateTaxCode.Id
};
Line taxLine = new Line();
taxLine.DetailType = LineDetailTypeEnum.TaxLineDetail;
TaxLineDetail taxLineDetail = new TaxLineDetail();
//Assigning the fist Tax Rate in this Tax Code
taxLineDetail.TaxRateRef = stateTaxCode.SalesTaxRateList.TaxRateDetail[0].TaxRateRef;
taxLine.AnyIntuitObject = taxLineDetail;
txnTaxDetail.TaxLine = new Line[] { taxLine };
invoice.TxnTaxDetail = txnTaxDetail;
*/
idx++;
}
删除代码
Item item2 = itemQueryService.ExecuteIdsQuery("Select * From Item StartPosition 2 MaxResults 1").FirstOrDefault();
//Line Sales Item Line Detail - ItemRef
SalesItemLineDetail lineDetail = new SalesItemLineDetail();
Line removeLine = new Line();
lineDetail.ItemRef = new ReferenceType()
{
Value = item2.Id
};
removeLine.AnyIntuitObject = lineDetail;
lines.RemoveAt(1);
相关问题:
Quickbooks Online Accounting - How to add multiple line items in an invoice?
答案 0 :(得分:2)
检查额外的订单项的详细信息类型,必须是SubTotalLineDetail。它是所有订单项的小计。然后你可以跳过它的枚举类型。