[IMP] account_payment_pro: add amount_exact field to preserve full decimal precision#1016
Closed
rov-adhoc wants to merge 1 commit intoingadhoc:18.0from
Closed
[IMP] account_payment_pro: add amount_exact field to preserve full decimal precision#1016rov-adhoc wants to merge 1 commit intoingadhoc:18.0from
rov-adhoc wants to merge 1 commit intoingadhoc:18.0from
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Este PR mejora la precisión en pagos multi-moneda evitando la pérdida de decimales causada por el redondeo del campo amount (Monetary), introduciendo un campo técnico amount_exact y ajustando las reconversiones/cómputos para usar el valor no redondeado.
Changes:
- Añade
amount_exact(Float) para conservar el monto con precisión completa y lo sincroniza encreate()/write(). - Añade
previous_currency_idpara “round-trip” de la moneda anterior entre llamadas consecutivas deonchange. - Actualiza conversiones/cómputos para usar
amount_exacty seteaamount_exactal pagar automáticamente desdeaccount.move.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| account_payment_pro/views/account_payment_view.xml | Agrega campos técnicos invisibles (previous_currency_id, amount_exact) al formulario para soportar el round-trip del onchange. |
| account_payment_pro/models/account_payment.py | Define amount_exact/previous_currency_id, agrega sync en create/write, implementa onchange(currency_id) y usa amount_exact en conversiones. |
| account_payment_pro/models/account_move.py | Setea payment.amount_exact en el flujo de pay_now() para mantener consistencia con el nuevo campo. |
f8428b5 to
956440c
Compare
- Modified `account_payment_pro/models/account_payment.py`: restore minimal write-off branch while making sign explicit; keep original behaviour of computing `amount_currency` by dividing `write_off_amount` by `exchange_rate` when payment and company currencies differ; preserve `currency_id` and compute `balance` in company currency. - Extended `account_payment_pro/tests/test_account_paymet_pro_unit_test.py` with a new test `test_write_off_line_amounts_company_vs_payment_currency` that sets up a scenario with a company in ARS and a payment in USD, then creates and validates a payment with write-off, checking that the write-off line shows the correct amounts in both currencies. Change note: Ahora, al crear y validar un pago con write-off en otra moneda, la línea de write-off muestra correctamente el importe en la moneda del pago (por ejemplo 1000/1300) y el saldo en la moneda de la compañía (por ejemplo 1000). Se añadió una prueba automática que valida este comportamiento para evitar regresiones. closes ingadhoc#1017 Signed-off-by: rov-adhoc <rov@adhoc.com.ar>
956440c to
86968d4
Compare
Contributor
|
@roboadhoc r+ bump |
roboadhoc
pushed a commit
that referenced
this pull request
Apr 24, 2026
- Modified `account_payment_pro/models/account_payment.py`: restore minimal write-off branch while making sign explicit; keep original behaviour of computing `amount_currency` by dividing `write_off_amount` by `exchange_rate` when payment and company currencies differ; preserve `currency_id` and compute `balance` in company currency. - Extended `account_payment_pro/tests/test_account_paymet_pro_unit_test.py` with a new test `test_write_off_line_amounts_company_vs_payment_currency` that sets up a scenario with a company in ARS and a payment in USD, then creates and validates a payment with write-off, checking that the write-off line shows the correct amounts in both currencies. Change note: Ahora, al crear y validar un pago con write-off en otra moneda, la línea de write-off muestra correctamente el importe en la moneda del pago (por ejemplo 1000/1300) y el saldo en la moneda de la compañía (por ejemplo 1000). Se añadió una prueba automática que valida este comportamiento para evitar regresiones. closes #1017 closes #1016 Signed-off-by: rov-adhoc <rov@adhoc.com.ar> Signed-off-by: Filoquin adhoc <maq@adhoc.com.ar>
roboadhoc
added a commit
that referenced
this pull request
Apr 24, 2026
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.

When the payment amount is stored in the Monetary field, it gets rounded to the currency's decimal places. This causes precision loss during currency conversions (e.g. ARS → USD → ARS) where intermediate values lose significant decimals.
Add amount_exact (Float, digits=0) to store the unrounded amount value. This field is automatically synced via create/write overrides and used in:
Also add previous_currency_id to properly track the old currency across consecutive onchange calls without relying on _origin.