From 32730ef82b4a491c5ea6ec633f199f090b16cb50 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Fri, 24 Nov 2017 08:49:10 +0100 Subject: [PATCH] [FIX] account: reconciliation widget tax included Before this commit, when reconciling with a tax included line, the journal entries were wrong as the amount taken into account was the one that was **already** computed with tax e.g: TAX: 20% amount of the line (tax included): 1 tax amount: 0.17 base amount: 0.83 what was sent to the server was the basea amount, and since python re-computes the taxes it reapplied tax included 20% on 0.83 instead of 1 After this commit, we send the right amount to the server, at the small price of semantics change in the meaning of "amount" OPW 783933 closes #21189 --- addons/account/models/account.py | 1 + .../static/src/js/reconciliation/reconciliation_model.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index b81fd23cdda..cde4781888e 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -779,6 +779,7 @@ class AccountTax(models.Model): 'account_id': tax.account_id.id, 'refund_account_id': tax.refund_account_id.id, 'analytic': tax.analytic, + 'price_include': tax.price_include, }) return { diff --git a/addons/account/static/src/js/reconciliation/reconciliation_model.js b/addons/account/static/src/js/reconciliation/reconciliation_model.js index 11116fab070..36c855111f7 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_model.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_model.js @@ -770,6 +770,8 @@ var StatementModel = BasicModel.extend({ '__focus': false }); + prop.computed_with_tax = tax.price_include + prop.tax_amount = tax.amount prop.amount = tax.base; prop.amount_str = field_utils.format.monetary(Math.abs(prop.amount), {}, formatOptions); prop.invalid = !self._isValid(prop); @@ -1040,7 +1042,8 @@ var StatementModel = BasicModel.extend({ * @returns {object} */ _formatToProcessReconciliation: function (line, prop) { - var amount = -prop.amount; + // Do not forward port in master. @CSN will change this + var amount = prop.computed_with_tax && -prop.base_amount || -prop.amount; if (prop.partial_reconcile === true) { amount = -line.st_line.amount; } @@ -1048,6 +1051,10 @@ var StatementModel = BasicModel.extend({ name : prop.label, debit : amount > 0 ? amount : 0, credit : amount < 0 ? -amount : 0, + // This one isn't usefull for the server, + // But since we need to change the amount (and thus its semantics) into base_amount + // It might be useful to have a trace in the RPC for debugging purposes + computed_with_tax: prop.computed_with_tax, }; if (!isNaN(prop.id)) { result.counterpart_aml_id = prop.id;