Search code examples
c#quickbooksintuit-partner-platform

How i can see the products (or items) from a SaleItemLineDetail from Quick Books?


I've been looking for a way to watch for the product that have a sales tax from a sale receipt or a invoice in QuickBooks. I found the property of Salestaxitems, but how i can implement in C# after connecting my app to my company sandbox. sorry if the question was not very clear and thanks for reading.


Solution

  • Here is the link for creating Invoice with sales tax in C#- https://gist.github.com/IntuitDeveloperRelations/6500373

    I believe you are getting confused with various line details. Please read this docs for more information n each linedetail type- https://developer.intuit.com/docs/api/accounting ->Complex Types

    Important points to note is that Invoice will have 2 different line for tax and for items. For Taxes, you need to refer TxnTaxDetail line. For items, you need to refer SalesItemLineDetail line.

    Now SalesItemLinDetail will have a taxCodeRef value of TAX for US companies. When you do a read for an Invoice, loop through the SalesItemLineDetail tag and see if taxCodeRef= TAX is set, then read the corresponding ItemRef value.

    The following code can be used to read SalesItemLineDetail-

    QueryService<Invoice> bill1QueryService = new QueryService<Invoice>(context);
    Invoice bill11 = bill1QueryService.ExecuteIdsQuery("select * from Invoice").FirstOrDefault<Invoice>();
    
    
     SalesItemLineDetail a1 = (SalesItemLineDetail)bill11.Line[0].AnyIntuitObject;
    
                            if(a1.TaxCodeRef.Value=="TAX")
                            {
                                string taxCodeid = a1.ItemRef.Value;
                                object unitprice = a1.AnyIntuitObject;
                                decimal quantity = a1.Qty;
                            }