Proteus API, submitting exact VAT/tax amounts, override rounding defaults

I started creating a script to insert supplier invoices through the Proteus client API. I will publish it shortly.

Some of the suppliers are rounding up their VAT amount so that the invoice total is a multiple of 5 or 10 cents. E.g the calculated total is 459.19 but the supplier changes it to 459.20.

This seems quite common with suppliers who accept cash, the smallest coin in circulation is 5 cents (0.05)

I have the following exact values from every supplier: amount_ex, tax_amount, amount_inc

The VAT is 7.7%

Here is an example:

Values on the supplier invoice: 426.36, tax = 32.84, amount_inc = 459.20

If I put those values into Python command line or Tryton, I see the values 426.36, 32.83, amount_inc = 459.19

How can I force Tryton to use the VAT amount from the supplier’s invoice?

This is what I tried.

Invoice = Model.get('account.invoice')
InvoiceLine = Model.get('account.invoice.line')

...

    invoice = Invoice()
    line0 = InvoiceLine()

    line0.unit_price = get_price(invc_params['amount_ex'])
    invoice.lines.append(line0)

    # these are being ignored by Tryton
    invoice.tax_amount = get_price(invc_params['tax'])
    invoice.total_amount = get_price(invc_params['amount'])

    invoice.save()

It is wrong to manage this as a tax correction. Indeed there is an pending issue about that, it is at the reconciliation that the rounding should be managed as profit/lost if the payment was in cash.

I agree that this is annoying

In fact, most of the payments were not cash anyway, they were paid by card but the suppliers still do this rounding sometimes.

On the invoice, the supplier has actually added 0.01 to their tax amount and in this case, the correct thing to do would be to count it as tax. If it is only handled at reconciliation then it won’t get into the tax reports.

Is there any way to force these values into Tryton through Proteus?

It can already be changed manually in the invoice by clicking the row in the tax lines and clicking the edit button.

It was implemented in account_cash_rounding module

This is wrong normally.

Then it is not a cash rounding but just a difference on how taxes are computed. So Tryton manages that as tax line amount can be edited after computation.

So you have the solution.

It would be helpful to eliminate any reliance on a manual process to check or correct the values.

I published the scripts here along with some very trivial sample data so other people can use them. I hope they are a useful demonstration of Proteus but I would welcome any improvements to them.

Any manual action can be one in proteus.

Well you clear the computed tax which will create trouble when posting because it will be recreated.

For some of the products, if I don’t manually set the tax, I see this error:

xmlrpc.client.Fault: <Fault 1: 'The value of the field "Taxes" on "Invoice Line" is not valid according to its domain. - '>

It appears to be choosing a default value that is wrong for that product.

For VAT in Switzerland and some other countries, there are two different VAT codes for a purchase: there is a code for products to resell and there is a different code for products that are operational expenses. Users in those systems would almost certainly need to clear the default taxes and choose the other tax for some of their purchases.