gpt4 book ai didi

c# - QBO/.NET SDK [Quickbooks Online] - 如何删除空发票行项目?

转载 作者:太空狗 更新时间:2023-10-29 17:57:52 33 4
gpt4 key购买 nike

我有一个关于 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?

最佳答案

检查额外行项目的详细信息类型,它必须是 SubTotalLineDetail。它是所有行项目的小计。然后你可以跳过它的枚举类型。

关于c# - QBO/.NET SDK [Quickbooks Online] - 如何删除空发票行项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45422328/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com