[IMP] account_internal_transfer: sync amounts and rates for cross-cur…#934
Open
cav-adhoc wants to merge 2 commits into
Open
[IMP] account_internal_transfer: sync amounts and rates for cross-cur…#934cav-adhoc wants to merge 2 commits into
cav-adhoc wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Este PR mejora la sincronización entre pagos emparejados de transferencias internas cuando intervienen diarios con distintas monedas, incorporando sincronización de montos y tasas (incluyendo la inversión de tasa en el pago espejo) y soporte opcional para integración con payment_pro.
Changes:
- Extiende
write()para sincronizaramountycounterpart_currency_amounten pagos emparejados, contemplando escenarios multi-moneda. - Sincroniza
counterpart_rateen el pago emparejado usando la tasa inversa. - Activa la lógica “avanzada” bajo una bandera
use_payment_pro.
f9d77e3 to
fb4e9f9
Compare
5abb2fd to
b5b5ec5
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
account_internal_transfer/models/account_payment.py:284
- En la sincronización payment_pro se hace
updates["counterpart_currency_amount"] = source_amountsin verificar que el campo exista enpaired_payment._fields. Si el módulo/versión que aporta ese campo no está presente (o quedó deshabilitado)write()puede fallar con campo desconocido. Sugerencia: condicionar esa asignación a"counterpart_currency_amount" in paired_payment._fields(similar a lo que ya se hace conamount_exact/counterpart_rate).
if "amount_exact" in paired_payment._fields:
updates["amount_exact"] = converted_amount
if source_amount != getattr(paired_payment, "counterpart_currency_amount", 0):
updates["counterpart_currency_amount"] = source_amount
# Set rate: use inverted rate if explicitly set, otherwise calculate from amounts
if converted_amount and "counterpart_rate" in paired_payment._fields:
account_internal_transfer/models/account_payment.py:276
counterpart_currency_amountse evalúa conif counterpart_amount:; esto ignora explícitamente el caso 0.0. Si el usuario pone 0 (o se llega por redondeo) no se sincroniza ni elamountni la tasa calculada, dejando el pago emparejado desalineado. Sugerencia: usar una comprobación que distingaFalse/Nonede0.0(p. ej.is not None) y permitir sincronizar a 0 cuando corresponda.
if amount_fields_changed and use_payment_pro:
counterpart_amount = getattr(payment, "counterpart_currency_amount", False)
if counterpart_amount:
converted_amount = abs(counterpart_amount)
source_amount = getattr(payment, "amount_exact", False) or payment.amount
d4f93e7 to
29e3d73
Compare
84cff00 to
e82706b
Compare
…yments Add synchronization logic for paired internal transfer payments: - Sync counterpart_currency_amount between paired payments for cross-currency transfers - Sync amounts when counterpart_currency_amount or rate fields change - Sync journal changes (swapped relationship between payment and paired) - Preserve exact manual rates by using inverted rate (1/rate) instead of calculating from rounded amounts - Add comprehensive test suite covering amount sync, rate sync, and edge cases - Prevent recursion with skip_paired_payment_update context flag Technical details: - Enhanced write() method to detect paired payment changes - Support for payment_pro module fields (counterpart_rate, amount_exact, etc.) - Use float_compare for rate comparison to handle floating-point precision - Handle both payment_pro enabled/disabled scenarios Change note: Se implementó la sincronización automática de montos y tipos de cambio en transferencias internas entre cuentas con diferentes monedas. Cuando se modifica el monto convertido o el tipo de cambio en un pago, el sistema ahora actualiza automáticamente el pago pareado con los valores correspondientes. Además, cuando se establece un tipo de cambio manual (ej. 1500 ARS/USD), ambos movimientos muestran exactamente la misma tasa, evitando valores con decimales generados por redondeo.
e82706b to
d3ddbf9
Compare
…ents When an internal transfer uses payment_pro with counterpart_rate, sync the inverted rate to the paired payment to preserve exact rate values. This fixes visual inconsistencies where manually set rates appear with unexpected decimal places due to rounding. Example: rate 1500 now displays as 1500 instead of 1499.25
d3ddbf9 to
2c04fc5
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.

…rency transfers
Change note: Ahora cuando modificas el monto o la tasa de cambio en una transferencia interna entre diarios con diferentes monedas, el sistema sincroniza automáticamente estos valores en el pago emparejado (aplicando la tasa inversa cuando corresponde), asegurando que ambos pagos mantengan montos equivalentes sin errores de redondeo.