Skip to content

[IMP] account_internal_transfer: sync amounts and rates for cross-cur…#934

Open
cav-adhoc wants to merge 2 commits into
ingadhoc:19.0from
adhoc-dev:19.0-t-65829-cav
Open

[IMP] account_internal_transfer: sync amounts and rates for cross-cur…#934
cav-adhoc wants to merge 2 commits into
ingadhoc:19.0from
adhoc-dev:19.0-t-65829-cav

Conversation

@cav-adhoc

Copy link
Copy Markdown
Contributor

…rency transfers

  • Enhanced write() method to sync counterpart_currency_amount between paired payments
  • Added rate synchronization with inverted counterpart_rate for paired payment
  • Handle rate fields: user_accounting_rate, user_counterpart_rate, accounting_rate, counterpart_rate
  • Support for payment_pro module integration (use_payment_pro check)
  • Improved cross-currency conversion accuracy when syncing paired 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.

Copilot AI review requested due to automatic review settings April 14, 2026 17:21
@roboadhoc

Copy link
Copy Markdown
Contributor

Pull request status dashboard

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 sincronizar amount y counterpart_currency_amount en pagos emparejados, contemplando escenarios multi-moneda.
  • Sincroniza counterpart_rate en el pago emparejado usando la tasa inversa.
  • Activa la lógica “avanzada” bajo una bandera use_payment_pro.

Comment thread account_internal_transfer/models/account_payment.py Outdated
Comment thread account_internal_transfer/models/account_payment.py
Comment thread account_internal_transfer/models/account_payment.py Outdated
Comment thread account_internal_transfer/models/account_payment.py Outdated
@cav-adhoc cav-adhoc force-pushed the 19.0-t-65829-cav branch 3 times, most recently from 5abb2fd to b5b5ec5 Compare May 20, 2026 18:34
@cav-adhoc cav-adhoc requested a review from Copilot May 20, 2026 18:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_amount sin verificar que el campo exista en paired_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 con amount_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_amount se evalúa con if counterpart_amount:; esto ignora explícitamente el caso 0.0. Si el usuario pone 0 (o se llega por redondeo) no se sincroniza ni el amount ni la tasa calculada, dejando el pago emparejado desalineado. Sugerencia: usar una comprobación que distinga False/None de 0.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

Comment thread account_internal_transfer/models/account_payment.py
Comment thread account_internal_transfer/tests/test_account_payment.py Outdated
@cav-adhoc cav-adhoc force-pushed the 19.0-t-65829-cav branch 3 times, most recently from d4f93e7 to 29e3d73 Compare May 20, 2026 19:30
@cav-adhoc cav-adhoc requested a review from Copilot May 20, 2026 19:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread account_internal_transfer/models/account_payment.py Outdated
Comment thread account_internal_transfer/models/account_payment.py Outdated
Comment thread account_internal_transfer/tests/test_account_payment.py Outdated
@cav-adhoc cav-adhoc force-pushed the 19.0-t-65829-cav branch 4 times, most recently from 84cff00 to e82706b Compare May 20, 2026 21:04
…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.
…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
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.

3 participants