Is it possible to create invoice line items with an auto lookup tax type using the Xero accounting API? - invoice

I have an Item set up with Tax rate: Auto Look Up
But when I create in invoice via the API containing line item with this item code, the tax is not looked up.
I've tried retrieving my Items from the Items API, to see its TaxType. It is set to "AVALARA".
I've tried overriding the TaxType on my line item to AVALARA. This is accepted by the API, but invoice does not appear to show the looked-up rate.

Related

Business Central API | Find $Expand property name

Let's say I wanted to retrieve the sales headers along with their lines, I would use the following URL:
https://api.businesscentral.dynamics.com/v2.0/{GUID}/Sandbox/ODataV4/Company('{CompanyName}')/SalesInvoice?$expand=SalesInvoiceSalesLines
And if I wanted to retrieve the Purchase Invoice, I would use this one:
https://api.businesscentral.dynamics.com/v2.0/{GUID}/Sandbox/ODataV4/Company('{CompanyName}')/PurchaseInvoice?$expand=PurchaseInvoicePurchLines
So, for the sales, the expand property has the value SalesInvoiceSalesLines while for the purchases, the value is PurchaseInvoicePurchLines.
Is there some logic or a documentation that can help me find what the expand property's value needs to be if I want to expand, say, the SalesCreditMemo lines ?
You should be able to deduct that from the metadata of the endpoint in question e.g.:
https://api.businesscentral.dynamics.com/v2.0/{GUID}/Sandbox/ODataV4/$metadata#Company('{CompanyName}')/SalesCreditMemo
Then search for "Line" in the the returned XML document.

QBXML Item Sales Tax vs VAT

Hi I'm having an infuriating problem with QuickBooks UK. I am doing an InvoidceAddRq and sending ItemSalesTaxRef:FullName. I have "EGS" in my Item List as a VAT item. I also have EGS in my VAT code list after creating an item for testing. I cannot get it to post as it says:
'There is an invalid reference to QuickBooks Item Sales Tax "EGS" in the Invoice.
QuickBooks UK doesn't use Sales Tax - it uses VAT - nowhere can I find to enter a Sales Tax other than VAT. What do I need to do here to get my invoice posting?
Use the below sample code for sales tax
<SalesTaxCodeRef>
<FullName>Standard Sales</FullName>
</SalesTaxCodeRef>
For non-US versions of QuickBooks for Windows, you do not use ItemSalesTaxRef at all.
Instead, you just use SalesTaxCodeRef.
You should be specifying SalesTaxCodeRef for every single line item. Do not specify ItemSalesTaxRef at all.

Detect VOIDed invoices from quickbooks

Our system pulls lots of data from quickbooks using the QBWC/QBXML.
We also poll TxnDeletedQuery to get a list of deleted invoices, etc...
How do I query for or detect a 'Voided' invoice? I don't see anything in the InvoiceQueryRs schema that would indicate a voided invoice.
Does quickbooks do anything but zero-out the line item quantities?
Thanks!
The only thing QuickBooks does when voiding is:
sets the quantities/rates to zero
adds a "VOID" string to the Memo field
To detect it, you'd have to parse the Memo field and look at the rates/quantities. There's no way to filter by it in a query unfortunately.

DELPHI: Put calculated value into a master detail where details are in a grid

I have created a master-detail relation using ClientDataSets (Service & Addons). The Services are displayed in a DBLookupComboBox (cboServices) and once a service is selected the Addons are displayed in DBGrid (grdMain).
The Addons has a checkbox to indicate the Addon is selected, a name field, a quantities field that the user can change, a unit price field and a total price field.
I have created a OnQuantityChange method to update the total price using the unit price and quantity but how do I get the actual data from the row to do the updating? How do I reference the various fields in order to do something like the following:
grdMain.GetActiveRow.Column['TotalPrice'] :=
grdMain.GetActiveRow.Column['UnitPrice'] * grdMain.GetActiveRow.Column['Quantity'];
You can do that easily using calculated fields. I suggest you look at the following article for a detailed example with client dataset. Just search the article for calculated fields, you will find what you need.
TClientDataset example

Quickbooks: Adding a negative value to an invoice using the QBDSK

Is there any way to add a line item containing a negative amount to an existing invoice?
I'm using QBSDK7 and QB Enterprise. (and if it matters .Net 3.5)
What we're attempting to do is automate the way we're creating invoices. We're already pulling in employee's time and applying it to the correct invoices, but when we go to add credits (just a negative amount on a line item on the invoice) using
InvoiceLineMod.Amount.SetValue(-1234)
it fails with the error "Transaction must be positive"
I've also tried adding a Service Item with a negative amount and giving it a positive quantity and I get the same result.
This seems like such a no-brainer as we have been doing this manually for the last 10 years. I'm guessing there is artificial restriction on this.
Some things to consider:
Credit Memos are no good as we need to display exact details of the reduction on the same page.
We don't have payments to apply yet in most cases.
This need to be done before any retainers are applied.
Any help would be greatly appreciated.
Can you show the complete code you're using to modify the invoice? Can you also show the exact error message you're getting?
It is possible, though to do you need to make sure that you're using a Discount Item as your ItemRef type (a Service Item will not work), and you need to make sure that the transaction as a whole is for a positive amount.
Sometimes our app has to adjust an invoice down with a negative number. I have been able to add negative line items using the following code. I have to set a quantity and a rate, instead of setting the amount.
IInvoiceLineAdd ila = ia.ORInvoiceLineAddList.Append().InvoiceLineAdd;
ila.ItemRef.ListID.SetValue(GetQBID(JobKey));
ila.Desc.SetValue("Adjustment");
ila.Quantity.SetValue(1);
ila.ORRatePriceLevel.Rate.SetValue(-1.00);
Quickbooks doesn't allow you to post an invoice with a negative balance. If you try to do it through the UI, it prompts you to create a credit memo instead. (And vice-versa if you try it with a credit memo.)
You can enter negative quantities and/or prices into the line items, but the total of the invoice has to be >= 0 or it won't post (i.e., add other line items that offset the negative amounts).
The solution is to use credit memos. Your client-side processing will be more complicated, but it's the only choice with Quickbooks.

Resources