Skip to content

Commit

Permalink
[IMP] account: Adding a method to allow the change of amount_mnt var
Browse files Browse the repository at this point in the history
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:
#25057
#17196
#9972

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

closes #28991
  • Loading branch information
hbto committed Dec 6, 2018
1 parent 8db7d70 commit 9d2d539
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion addons/account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -1701,6 +1701,9 @@ def _get_tax_cash_basis_base_account(self, line, tax):
'''
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
Expand All @@ -1717,7 +1720,7 @@ def create_tax_cash_basis_entry(self, percentage_before_rec):
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':
Expand Down

0 comments on commit 9d2d539

Please sign in to comment.