OCA / account-reconcile

Odoo account reconciliation modules (statements, data completion...)
https://odoo-community.org/psc-teams/banking-10
GNU Affero General Public License v3.0
143 stars 386 forks source link

[16] account_reconcile_oca : bank account in foreign currency, rounding error for full reconcile #693

Open florian-dacosta opened 2 months ago

florian-dacosta commented 2 months ago

Hello @etobella

Second issue, linked to https://github.com/OCA/account-reconcile/issues/692 I guess : It may be solved with a change on the linked issue, I post it to record it so we can check this case easily then.

Here is the use case (I'll join a shell script at the end allowing to reproduce the issue from a demo database with only account_reconcile_oca installed).

Set up (you can run the shell script)

Then, go to the bank statement reconciliation, and you have this : 1-before-reconcile

The suspense line does not have any currency visible, like in first issue. I think it is confusing already because we are in a account in CNY and the suspense line should reflect the bank line.

Then when I choose the invoice : 2-inv-selection

The currency amount appear now, but it is not the right amount (259199.98 instead of 259200). I guess there is some kind of conversion toward usd and then backtoward CNY.

Therefor the amount is strikethrough which is also confusing because the amount is of the invoice is the same as the amount received. And it let me think that the reconciliation will be partial

Once validated, I check the accounting entry : 3-accounting-entry

I see that the counterpart is not in CNY currency, it has been switched to a full USD line. I expect to have a amount currency of -259200 for the line with account 121000. (same as first linked issue)

Finally on the reconciled invoice : 4-invoice

I see a payment of 0.02 cny which I don't want.

Like I said it may be solved or partially solved by link issue, I still post it now to show all the problems I found for now. And once again, thanks for the job on the matter!

Shell script : ``` usd = env.ref("base.USD") cny = env.ref("base.CNY") cny.write({'active': True}) env["res.currency.rate"].create({ "name": "2024-09-10", "currency_id": cny.id, "inverse_company_rate": 0.125989013758 }) env["res.currency.rate"].create({ "name": "2024-09-09", "currency_id": cny.id, "inverse_company_rate": 0.126225969731 }) cny_journal = env["account.journal"].create({ "name": "Bank CNY", "type": "bank", "currency_id": cny.id, }) cny_statement = env["account.bank.statement"].create({ "name": "TEST 1 CNY", "journal_id": cny_journal.id, "line_ids": [(0, 0, { "date": "2024-09-10", "journal_id": cny_journal.id, "payment_ref": "VIR CUSTOMER", "amount": 259200, "currency_id": usd.id, })], }) inv = self.env['account.move'].create({ "move_type": "out_invoice", "partner_id": env.ref("base.res_partner_12").id, "invoice_date": "2024-09-09", "currency_id": cny.id, "invoice_line_ids": [(0, 0, { "name": "test", "price_unit": "259200", "tax_ids": [(6, 0, [])], })] }) inv.action_post() ```
etobella commented 2 months ago

Can you test the same functionality in EE using runbot? it seems a rounding issue

florian-dacosta commented 2 months ago

Well, it seems to be a rounding issue indeed, but I can't get why we would have to round anything in this case. We have an amount (259200) and it has to be converted in the company currency using the rate. But the inverse conversion is not needed IMHO, that is why I think there is an issue. As if the CNY amount is converted in euro (with rounding then) and the amount in euro is converted back to CNY (once again, with rounding).

I'll test in enterprise version.

florian-dacosta commented 2 months ago

Here with enterprise, all seems ok :

1 default reconciliation screen - no rounding issue 1-enterprise-reconcile

  1. Selection of the invoice : 2-inv-selection

Invoice after reconciliation : 3-reconciled-invoice