Setting Invoice Taxes

In order to set taxes for an invoice, I have been doing the following:

/* BEGIN CODE */
Guid id;
Invoice invoice = null;

id = Guid.Parse (InvoiceID);
invoice = Invoice.GetInvoice (id, true);

rate = (invoice.TotalTaxable != 0 ) ? ( Tax ) * ( 1 / invoice.TotalTaxable ) : 0 ;

invoice.JobTax1Rate = (double) rate * 100;
invoice.RecalculateInvoiceTotals();
invoice.Save();

/* END CODE */

My question is, is there another way to set the taxes? I tried using the invoice.TotalJobTax1 variable without setting the JobTax1Rate, but it did not change any values.

Please advise.

Hi Mario. To do this you’ll want to set the ID for the tax rate on the invoice, JobTax1ID and JobTax2ID. These are from the tax object, which you’ll need to create/load separately.

// Get tax rate by name - you can also fetch by ID
TaxRate tax = TaxRate.GetTaxRate(“rate name”);

// When the ID is set on the invoice the amounts are recalculated
invoice.JobTax1ID = tax.TaxRateID;

// There is also a reference to the tax rate object once the ID is there
System.Diagnostics.Debug.Print(invoice.JobTax1.Name);

Taxes are also specified on the job and the invoice uses them by default when it’s created.

Depending on your needs, you can set the tax rates on the job then you won’t have to worry about it on the invoice as it’ll use it by default. Also note that there options on the jobsite to tax on consumables, and there’s a boolean on each UnitPrice (additional charge) to specify whether each individual item is taxable.

One other thing to note. When an invoice is created or modified the tax rate and amount are saved in the invoice. This allows you to change the TaxRate.Rate and have the existing invoices still use the old rate. Any newly created invoices will use the new rate, old ones still keep the old rate.

Thanks for the reply. I was hoping there would be a way of me setting the tax amount and/or rate and have Avontus set it “verbatim”. The reason behind this is that the taxes are being calculated in Avalara in another system and then sent back to Avontus via the API.

What I have since figured out is that (from what I can tell) the TotalJob1Tax amount from the database is being “ignored” and the value is being calculated “on the fly” every time you open the invoice.

I was able to confirm this by doing a test in a DEV environment. The invoice tax rate is 7.01% which in turn produced a tax amount of $5.72. I went into the database and updated it to 7%, which in fact made it 7% in the Avontus UI, but now the tax amount showed as $5.71, even when the value was $5.72 in the database.

Hello Mario. This shouldn’t be an issue if you set up the job to have the current and accurate tax rate as the invoices will use this rate when they’re created. Or, you could ignore taxes completely in Quantify and add them to the invoices in your accounting software as you’re adding them.

We’ll take a look at the calculation bug. It’s not appearing in the UI, could be something with the API only.