Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16][FIX] account_reconcile_oca : Fix multi currency management #1

Merged

Conversation

florian-dacosta
Copy link

Hi @etobella
This is work in progress, I try to fix the missing cases.

Your PR already fixes (Maybe there is still an issue about the screen showed after reconciliation, not sure) : OCA#692

With this PR, It try to fixes reconciliation in case of bank statement line with a foreign_currency_id

The 2 main cases I am trying to fix right now are the following :
On a journal in company currency, reconcile a line for which we have a foreign_currency_id
On a journal in a currency different than company currency, reconcile a line which have a foreign_currency. (for example : company_currency : USD
On a bank account which is in EUR, try to reconcile the line which is a payment for a CNY invoice)

Copy link
Author

@florian-dacosta florian-dacosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I comment my own PR to try to give information about why I make these changes

@@ -233,6 +233,7 @@ def _recompute_suspense_line(self, data, reconcile_auxiliary_id, manual_referenc
new_data = []
suspense_line = False
counterparts = []
suspense_currency = self.foreign_currency_id or self.currency_id
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suspense currency should always be the foreign_currency if set (at least it is the case on enterprise)

line["kind"] == "liquidity"
and line["line_currency_id"] != suspense_currency.id
):
currency_amount += self.amount_currency
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case where we have company currency in USD, but the journal/bank account is in EURO, and we make a payment of an invoice in a foreign different currency (like CNY), the liquidity line is in journal currency, euro, so the amount_currency is in euro, but the currency of the suspense line should be in CNY since we have a foreign currency = CNY.
To avoid a convertion between euro and CNY, we take directly the amount_currency of the statement line (or we will have issues of conversion)

line.get("currency_amount")
and line.get("line_currency_id") == suspense_currency.id
):
currency_amount += line.get("currency_amount")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid conversion if we already have an amount_currency in the same currency of our suspense line

if vals.get("kind") not in ("suspense", "liquidity"):
reconcile_auxiliary_id, rate = self._compute_exchange_rate(
vals, line, reconcile_auxiliary_id
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of payment with a foreign currency, the real rate, applied by the bank can't be the Odoo one.
So, Odoo tries to create a exchange line even before reconciliation. I don't think it make sense, so we avoid this logic for liquidity/suspense line.

I believe that before starting reconciliation, we always should have 1 liquidity line and one suspense line, not a third line which would make a mess during reconciliation.

self.company_id,
self.date,
)
to_amount = self.company_id.currency_id.round(to_amount_company_currency)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of a foreign currency, we want to take the real rate (the one applied by the bank) instead of the one defined in Odoo. So we by pass the currency._convert in this case.

@florian-dacosta florian-dacosta force-pushed the 16-fix-multi-currency_management branch 2 times, most recently from 65d398c to abf3255 Compare September 23, 2024 07:40
Fix the case of payment with a foreign currency set on bank statement line
@etobella etobella merged commit 43080b7 into dixmit:16.0-fix-mcurr Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants