[FIX] account_ux: express leftover residual in secondary currency on reconcile_on_company_currency#977
Open
cav-adhoc wants to merge 1 commit into
Open
[FIX] account_ux: express leftover residual in secondary currency on reconcile_on_company_currency#977cav-adhoc wants to merge 1 commit into
cav-adhoc wants to merge 1 commit into
Conversation
Contributor
40a3ef0 to
196fc4e
Compare
2 tasks
…reconcile_on_company_currency When reconcile_on_company_currency reconciles a company-currency line against a foreign-currency one, the override shadows the secondary currency, reconciles in company currency and then converts the partial_values back to the real secondary currency at the voucher rate. However it left the leftover residual (amount_residual_currency in the returned debit/credit values) expressed in company currency. Downstream consumers of that residual -notably the reconcile/write-off wizard (account.reconcile.wizard)- then read the company-currency magnitude as if it were the secondary currency and multiplied it by the exchange rate, proposing a hugely inflated write-off (e.g. a 624.79 ARS rounding difference shown as 624.79 USD -> 900,010 ARS). Convert the leftover residual to the secondary currency at the same rate used for the partial. Also fixes a latent bug that rounded the debit residual with the credit line currency instead of the debit one. Adds a regression test reproducing the scenario.
196fc4e to
ec4f04e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problema
Con
reconcile_on_company_currencyactivo, al conciliar un apunte en moneda de compañía contra uno en moneda secundaria, el override de_prepare_reconciliation_single_partial:super()conno_exchange_difference=Truepara conciliar en moneda de compañía.partial_values(lo consumido) a la moneda secundaria real a la cotización del comprobante.Pero deja el residual sobrante (
amount_residual_currencyen losdebit_values/credit_valuesdevueltos) expresado en moneda de compañía. Los consumidores de ese residual —en particular el wizard de conciliación/ajuste (account.reconcile.wizard)— interpretan esa magnitud en moneda de compañía como si fuera moneda secundaria y la multiplican por el tipo de cambio, proponiendo un ajuste (write-off) groseramente inflado.Ejemplo: una diferencia de redondeo de 624,79 (moneda de compañía) aparece en el wizard como 624,79 de moneda secundaria y termina convertida a ~900.010 de moneda de compañía.
Solución
Reexpresar el residual sobrante en la moneda secundaria a la misma cotización usada para el
partial. De paso se corrige un bug latente que redondeaba el residual del débito con la moneda del apunte crédito en vez de la del débito (afecta el caso de dos apuntes con moneda secundaria).Test plan
account_ux/tests/test_reconcile_on_company_currency.py: arma el escenario (compañía AR conreconcile_on_company_currency, apunte en moneda de compañía vs. apunte en moneda secundaria con diferencia de redondeo) y verifica que el residual devuelto queda en la moneda secundaria.-0.5 != -500.0) y pasa con el fix.account_uxen verde (6 tests).