[FIX] account_payment_pro: sync amount when all to_pay lines are removed - #1054
Open
jjscarafia wants to merge 1 commit into
Open
[FIX] account_payment_pro: sync amount when all to_pay lines are removed#1054jjscarafia wants to merge 1 commit into
jjscarafia wants to merge 1 commit into
Conversation
Contributor
skywardodoo
pushed a commit
to skywardodoo/account-payment
that referenced
this pull request
May 12, 2026
…ayment_bundle: apply upstream fixes from PRs ingadhoc#1055, ingadhoc#1054, ingadhoc#1051, ingadhoc#1049 - account_payment_pro_receiptbook: enforce receiptbook prefix in _get_next_sequence_format (PR ingadhoc#1055): replaces previous _get_last_sequence_domain approach; now detects prefix mismatch after _get_last_sequence() and falls back to direct SQL filtered by correct sequence_prefix, preventing PAY-prefixed orphan sequences from propagating. - account_payment_pro: sync amount when all to_pay lines removed (PR ingadhoc#1054); add _onchange_amount to keep amount in sync with to_pay_amount on line changes (PR ingadhoc#1049). - l10n_ar_payment_bundle: wrap action_post unlink/validation in for-rec loop and filter draft_linked by parent non-draft state to fix batch posting (PR ingadhoc#1051). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Extiende `_onchange_to_pay_lines_adjust_amount` para cubrir el caso en el que se remueven todas las líneas de deuda (sin retenciones), donde `amount` quedaba stale respecto de `to_pay_amount`. - Mantiene la lógica existente de ajuste por `payment_difference` cuando hay líneas y diferencia por tasa de hoy. - Evita un segundo onchange paralelo sobre `to_pay_move_line_ids` (alternativa al PR ingadhoc#1049, que introducía solapamiento de orden no determinístico con este onchange). **Change note:** Al quitar todas las líneas de deuda en una orden de pago, el importe del pago ahora se actualiza a 0 (o al monto pendiente sin reconciliar) en lugar de quedar con el valor anterior. Antes este caso solo se corregía manualmente por el usuario. Closes-Same-Issue-As: ingadhoc#1049 Related-Ticket: 115891
cav-adhoc
force-pushed
the
19.0-h-115891-jjs
branch
from
May 29, 2026 14:48
3d8d5a1 to
5766c78
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.

Contexto
Alternativa al #1049 (FW directo de #1040 a 19.0).
En 19.0 ya existe
_onchange_to_pay_lines_adjust_amount(introducido ena2c84339, parte de #1000) que también triggerea porto_pay_move_line_ids. El FW #1049 agregaba un segundo onchange_onchange_amountparalelo, lo que genera dos efectos:abs(to_pay_amount) + diff_in_aoabs(to_pay_amount)(perdiendo el ajuste por tasa que el refactor de 19.0 t 64401 rov #1000 vino a aplicar)._onchange_amounttriggerea por líneas, no por amount) y falta de filtrostate == 'draft'.Approach
Consolidar el caso del ticket dentro del onchange existente, con dos ramas según haya o no líneas:
amountquedó stale respecto deabs(to_pay_amount), sincronizar. Cubre el caso del ticket #115891 (proveedor AFIP/SICORE: borran todas las líneas de deuda, sin retenciones, y el importe quedaba con el valor anterior).amountporpayment_differencea la tasa de hoy.Un único onchange como fuente de verdad sobre
to_pay_move_line_ids → amount. Sin solapamiento.Test plan
amountpasa a 0.amountse ajusta pordiff_in_a(regresión del refactor 19.0 t 64401 rov #1000 — debe seguir andando).amountse ajusta porpayment_difference.use_payment_pro→ onchange no hace nada.Referencias
a2c84339