Why am I getting wrong Montant HT with tax-included

Hi everyone,

I’m having a rounding/precision issue on Sales Invoices when using tax-included pricing with TND (Tunisian Currency) and 19% TVA or 7% VAT.

Setup

  • Currency: TND

  • VAT: 19%

  • Tax configuration:

    • Tax 1: 19%, “Is this tax included in basic rate” = YES

    • Tax 2: 1.000 TND (timbre fiscal), type = Actual

  • Item price:

    • Price List Rate (TTC): 79.000 TND per unit
  • Quantity: 12

What ERPNext shows

On the invoice, ERPNext displays:

  • PU HT (net_rate): 66.387

  • Montant HT (net_amount): 796.639

But (expected Montant HT) 796.644 DT:

66.387 × 12 = 796.644   

item

Am I doing something wrong in my settings/configuration (currency precision, tax setup, “tax included in rate”, etc.) that causes this behavior?

Or is this actually a bug in how ERPNext calculates and rounds net_rate / net_amount when tax is included in the rate

Thanks in advance to anyone who can help or share their experience.

Can you clarify if you really need 3 precision in your invoice?

Yes, I really need 3-decimal precision in my invoices and accounting:

  • Currency: TND, which is divided into 1000 millimes

  • Supplier invoices and our internal accounting are all done with 3 decimals, so ERPNext must be able to match these values exactly.