odoo/odoo#114801

Created by Bugfix, Séna Serge Nshimiyimana (sesn)
Merged at 4c19af2b4b1af25a7ee0d093e1bc9ae3c8853b69

Statuses:

Linked pull requests
label
odoo-dev:16.0-opw-3112197-is_refund-sesn
head
f2275d91fc739687968607aea7dfc94d200864eb
merged
2 years ago by Accounting, Laurent Smet (las)
odoo/odoo odoo/enterprise
16.0 #114801 #39181
saas-16.1 #117523 #39236
saas-16.2 #117533 #39244
17.0
saas-17.4
18.0
saas-18.1
saas-18.2
saas-18.3
master #118588 #39775

[FIX] account: fix interaction between early payment discount and intra-community taxes

Bug

Currently, creating an intra-community bill and reconciling it with an early payment can break the tax report.

Steps to reproduce

  1. install the Austrian localization (l10n_at)
  2. set Cash Discount Tax Reduction to On early payment
  3. create a €1000 intra-community bill (you can just use the tax called IGE 20%)
  4. set the payment term to2/7 Net 30 and confirm
  5. reconcile the bill with a payment within the discount period (2% discount: €980).
  6. check the Tax Report: line 5.4 of the report should be €196. If you reconciled the bill with a back statement directly, sections Innergemeinschaftliche Erwerb and Bemessungsgrundlage will be wrong as well.

at_tax_report_bug

Cause

Since the intra-community applies here, the bill will produce two tax lines. And because Cash Discount Tax Reduction is set to On early payment, those two tax lines will be reduced when an early payment is made.
However, because of the way the is_refund property of account.move.line field is computed on moves of type entry, one of those tax reduction line will be considered a refund and the other will not. This is because of the following lines in _compute_is_refund: https://github.com/odoo/odoo/blob/cfd71892aabf1510273b28032ff8f2d4cfd4d1f7/addons/account/models/account_move_line.py#L1064-L1065
And because _compute_tax_tag_invert relies on the is_refund property, those two lines will have different values for tax_tag_invert when they should have the same value.

at_epd_entry

opw-3112197

Enterprise PR: odoo/enterprise#39181