[IMP] account: Adding a method to allow the change of amount_mnt var

used to fetch debit & credit recorded in Tax Cash Basis Journal Entries

Main
-

By allowing to change the `amount_mnt` var we will be able to change the
values recorded in Tax Cash Basis Journal Entries, i.e, debit & credit
values.

Explanation
-
We want to keep the `amount` just the way it has been computed because
that is right. We don't want to change that.

Our issue is the`rounded_amt` which is the value that is passed to the
debit and credit downwards.

We have only hooked a new method to allow us later inherit that method
and make our own computations regarding the `rounded_amt` which is the
main subject of this PR and later pass it down to the debit & credit
fields as need for localizations that could be facing the problem of
having the computation of taxes at date of invoicing instead of date of
payment.

`amount` var is used here:

`
'amount_currency': self.amount_currency and
line.currency_id.round(-line.amount_currency * amount / line.balance) or
0.0,`

and we are not intending to change that because the value written to the
`amount_currency` field is right.

What we intend is to compute the values for debit and credit fields
which were computed in this method at invoice date, some l18n need them
at payment date, e.g, l18n_mx.

Be aware
-

Do not be mislead by the fact that `rounded_amt` var is the one taken to
do those computations. It is just a mean to the final goal. Rounding is
not an issue and has never been.

Background
-

By allowing this merge to flow we will be able to address the following issues:
https://github.com/odoo/odoo/issues/25057
https://github.com/odoo/odoo/pull/17196
https://github.com/odoo/odoo/issues/9972

Final Goal
-
Being able to perform the computation of the debits and credits
according to l10n_mx in odoo/enterprise#3137

closes odoo/odoo#28991
This commit is contained in:
Humberto Arocha
2018-12-06 19:39:16 +00:00
parent 8db7d70776
commit 9d2d539a16
+4 -1
View File
@@ -1701,6 +1701,9 @@ class AccountPartialReconcile(models.Model):
'''
return line.account_id
def _get_amount_tax_cash_basis(self, amount, line):
return line.company_id.currency_id.round(amount)
def create_tax_cash_basis_entry(self, percentage_before_rec):
self.ensure_one()
move_date = self.debit_move_id.date
@@ -1717,7 +1720,7 @@ class AccountPartialReconcile(models.Model):
percentage_after = line._get_matched_percentage()[move.id]
#amount is the current cash_basis amount minus the one before the reconciliation
amount = line.balance * percentage_after - line.balance * percentage_before
rounded_amt = line.company_id.currency_id.round(amount)
rounded_amt = self._get_amount_tax_cash_basis(amount, line)
if float_is_zero(rounded_amt, precision_rounding=line.company_id.currency_id.rounding):
continue
if line.tax_line_id and line.tax_line_id.tax_exigibility == 'on_payment':