简体   繁体   English

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

[英]QBO/.NET SDK [Quickbooks Online] - How to remove empty invoice line item?

I have a new issue with quickbooks invoice. 我有一个关于quickbooks发票的新问题。 Upon creation of an invoice I get all items I added plus one extra line item in my invoice. 创建发票后,我会收到我添加的所有商品以及发票中的一个额外订单项。

How do I filter, remove, prevent this line from appearing? 如何过滤,删除,阻止此行显示?

Here is what I have tried. 这是我尝试过的。

//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++;
    }

Removal Code 删除代码

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);

Related question: 相关问题:

Quickbooks Online Accounting - How to add multiple line items in an invoice? Quickbooks在线会计 - 如何在发票中添加多个行项目?

Check that extra line item's Detail Type, It must be SubTotalLineDetail. 检查额外的行项目的详细信息类型,它必须是SubTotalLineDetail。 It's SubTotal of all line items. 这是所有订单项的小计。 Then you can skip it on it's enum type. 然后你可以跳过它的枚举类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 QuickBooks Online(QBO)通过C#中的v2 IPP .NET SDK写入发票上的自定义字段 - QuickBooks Online (QBO) write to Custom Fields on Invoice via v2 IPP .NET SDK in C# 如何为QBO IPP .NET SDK V3的发票行项目指定产品/服务? - How can I specify Product/Service for an Invoice Line Item for QBO IPP .NET SDK V3? 使用.NET IPP QBOV3 SDK在线将发票添加到快速簿 - Adding invoice to quickbooks online using .NET IPP QBOV3 SDK 在发票专列项中的在线Quickbooks中创建产品/服务 - Creating product/Service in Quickbooks Online in an Invoice line item Quickbooks在线会计-如何在发票中添加多个订单项? - Quickbooks Online Accounting - How to add multiple line items in an invoice? 访问当前发票并在Quickbooks中添加订单项 - Access current invoice and add line item in Quickbooks QBO IPP API - 如何将付款链接到发票 - QBO IPP API - how to link a payment to an invoice 用于QuickBooks v3.0的IPP .NET SDK创建发票错误 - 错误请求 - IPP .NET SDK for QuickBooks v3.0 Create Invoice Error - Bad Request Quickbooks Online API - 提供发票 ID 时付款“未应用” - Quickbooks Online API - Payment 'Unapplied' when Invoice ID provided 使用QuickBooks Online(QBO)Intuit合作伙伴平台(IPP)DevKit查询所有未结余额发票 - Query for All Invoices With Open Balances using QuickBooks Online (QBO) Intuit Partner Platform (IPP) DevKit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM