Permalink
Browse files

[FIX] account: Reconciling multi-currency lines with fx difference

journal items does not create Tax Cash Basis Journal Entries.
[IMP] Test Case for Fully reconciling multi-currency lines and one or
more are Exchange Rate Differences which are not creating Tax Cash
Basis Journal Entries if there were any Taxed line.

Main
-

Tax Cash Basis Journal Entry creation shall not be prompted by the
reconciliation of exchange rate difference journal items.

Explanation
-

    Company's Currency EUR

    Having issued an invoice at date Nov-21-2018 as:

    Accounts         Amount Currency         Debit(EUR)       Credit(EUR)
    ---------------------------------------------------------------------
    Expenses            5,301.00 USD         106,841.65              0.00
    Taxes                 848.16 USD          17,094.66              0.00
        Payables       -6,149.16 USD               0.00        123,936.31

    On Dec-20-2018 user issues an FX Journal Entry as:

    Accounts         Amount Currency         Debit(EUR)       Credit(EUR)
    ---------------------------------------------------------------------
    Payables                0.00 USD             167.86             0.00
        FX Gains            0.00 USD               0.00           167.86

    On Same day user records a payment for:

    Accounts         Amount Currency         Debit(EUR)       Credit(EUR)
    ---------------------------------------------------------------------
    Payables            6,149.16 USD         123,768.45              0.00
        Bank           -6,149.16 USD               0.00        123,768.45

    And then reconciles the Payables Items which shall render only one Tax
    Cash Basis Journal Entry because of the actual payment, i.e.
    amount_currency != 0:

    Accounts         Amount Currency         Debit(EUR)       Credit(EUR)
    ---------------------------------------------------------------------
    Tax Base Acc.           0.00 USD         106,841.65              0.00
        Tax Base Acc.       0.00 USD               0.00        106,841.65
    Creditable Taxes      848.16 USD          17,094.66              0.00
        Taxes            -848.16 USD               0.00         17,094.66

closes #30130
  • Loading branch information...
hbto committed Jan 19, 2019
1 parent 1bec017 commit 785e5f149c055a0c6f58b6c86973be52a0491fc6
Showing with 378 additions and 3 deletions.
  1. +14 −2 addons/account/models/account_move.py
  2. +364 −1 addons/account/tests/test_reconciliation.py
@@ -823,13 +823,15 @@ def _reconcile_lines(self, debit_moves, credit_moves, field):
to_create = []
cash_basis = debit_moves and debit_moves[0].account_id.internal_type in ('receivable', 'payable') or False
cash_basis_percentage_before_rec = {}
dc_vals ={}
while (debit_moves and credit_moves):
debit_move = debit_moves[0]
credit_move = credit_moves[0]
company_currency = debit_move.company_id.currency_id
# We need those temporary value otherwise the computation might be wrong below
temp_amount_residual = min(debit_move.amount_residual, -credit_move.amount_residual)
temp_amount_residual_currency = min(debit_move.amount_residual_currency, -credit_move.amount_residual_currency)
dc_vals[(debit_move.id, credit_move.id)] = (debit_move, credit_move, temp_amount_residual_currency)
amount_reconcile = min(debit_move[field], -credit_move[field])

#Remove from recordset the one(s) that will be totally reconciled
@@ -867,11 +869,21 @@ def _reconcile_lines(self, debit_moves, credit_moves, field):
'currency_id': currency,
})

cash_basis_subjected = []
part_rec = self.env['account.partial.reconcile']
with self.env.norecompute():
for partial_rec_dict in to_create:
new_rec = self.env['account.partial.reconcile'].create(partial_rec_dict)
part_rec += new_rec
debit_move, credit_move, amount_residual_currency = dc_vals[partial_rec_dict['debit_move_id'], partial_rec_dict['credit_move_id']]
# /!\ NOTE: Exchange rate differences shouldn't create cash basis entries
# i. e: we don't really receive/give money in a customer/provider fashion
# Since those are not subjected to cash basis computation we process them first
if not amount_residual_currency and debit_move.currency_id and credit_move.currency_id:
part_rec.create(partial_rec_dict)
else:
cash_basis_subjected.append(partial_rec_dict)

for after_rec_dict in cash_basis_subjected:
new_rec = part_rec.create(after_rec_dict)
if cash_basis:
new_rec.create_tax_cash_basis_entry(cash_basis_percentage_before_rec)
self.recompute()
Oops, something went wrong.

0 comments on commit 785e5f1

Please sign in to comment.