C_InvoiceLine values for TaxAmt and LineTotalAmt wrong in some cases

Description

Checked the values being saved on LineNetAmt, LineTotalAmt and TaxAmt for sales/purchases and pricelist including/not-including tax.

Results are very inconsistent:

Sales - with or without tax included (Azalea with sales price 23.75)
LineNetAmt=23.75
TaxAmt=0
LineTotalAmt=0

Purchase WITH tax included (Azalea with purchase price 15)
LineNetAmt=15
TaxAmt=2.07 (this is wrong tax)
LineTotalAmt=17.07 (this is wrong total)

Purchase WITHOUT tax included (Azalea with purchase price 15)
LineNetAmt=15
TaxAmt=2.4
LineTotalAmt=17.4

These columns apparently are not used for calculations, must be just for reporting purposes, and any report based on these values must be wrong - the only case filling them correctly is "Purchase WITHOUT tax included".

NOTE the C_InvoiceTax records are correctly calculated.

Regards,

Carlos Ruiz

Environment

None

Activity

Show:

Diego Ruiz August 30, 2021 at 10:44 AM

Hi,

I just ran into this same issue today with Purchase Invoice with List price IsTaxIncluded ='Y'.

So, still present in iDempiere 8.2

Martin Schönbeck April 5, 2020 at 8:42 PM

Hi Carlos,

reason is AFAICS line 700 in CalloutInvoice

mTab.setValue("LineTotalAmt", LineNetAmt.add(TaxAmt));

There the correctly calculated TaxAmt is added even if it’s already included in LineNetAmt.
I think replacing it with

if (isTaxIncluded(WindowNo))
{
mTab.setValue("LineTotalAmt", LineNetAmt.add(TaxAmt));
}
else
{
mTab.setValue("LineTotalAmt", LineNetAmt);
}

would do the job.

Regards,
Martin

 

Carlos Ruiz October 19, 2016 at 4:10 PM

More research on this.

  • there is a test case when price include tax - and user change the default tax on the line (the default get from the product), then there is a recalculation of the line amount (which in my opinion is wrong)
    This was integrated on ticket https://sourceforge.net/p/adempiere/bugs/600/
    Commit https://bitbucket.org/idempiere/idempiere/commits/f55b238
    IMHO if the price list says that includes tax - then the buyer expects that the price listed is what is charged - changing the tax must not affect the end price of the order, it must affect just the tax calculation, but the price must be preserved.
    Now, that code just work if the tax is not document level - for document level taxes it keeps working as I mentioned.

  • Another "issue" found - but it makes sense - if the tax is set as Document Level tax - then the taxamt on lines is not filled, you must read it from C_OrderTax in such case and is not associated to a specific line.

Carlos Ruiz October 19, 2016 at 12:24 PM

New note, seems like C_InvoiceTax is also wrong - using "Price List Include Tax" makes the taxes on report "Invoice Detail & Margin" useless.

Details

Assignee

Reporter

Priority

Created September 22, 2016 at 4:40 PM
Updated August 30, 2021 at 10:44 AM