[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
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user