-
Notifications
You must be signed in to change notification settings - Fork 154
[FIX] l10n_ar_payment_bundle: linked payments honor forced main counterpart rate #1019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -161,6 +161,17 @@ def _compute_counterpart_rate(self): | |||||||||||||||||
| for rec in self.filtered(lambda x: x.main_payment_id and x.currency_id == x.company_currency_id): | ||||||||||||||||||
| rec.counterpart_rate = rec.main_payment_id.counterpart_rate | ||||||||||||||||||
|
|
||||||||||||||||||
| @api.depends("main_payment_id") | ||||||||||||||||||
| def _compute_accounting_rate(self): | ||||||||||||||||||
| super(AccountPayment, self)._compute_accounting_rate() | ||||||||||||||||||
|
Comment on lines
+164
to
+166
|
||||||||||||||||||
| for rec in self.filtered(lambda x: x.main_payment_id and x.currency_id == x.counterpart_currency_id): | ||||||||||||||||||
| # Si B = C en ambos pagos, tomamos la tasa forzada del main como | ||||||||||||||||||
| # fuente de verdad para mantener counterpart_rate alineado. | ||||||||||||||||||
| if rec.main_payment_id.counterpart_rate and rec.accounting_rate != rec.main_payment_id.counterpart_rate: | ||||||||||||||||||
|
Comment on lines
+168
to
+170
|
||||||||||||||||||
| # Si B = C en ambos pagos, tomamos la tasa forzada del main como | |
| # fuente de verdad para mantener counterpart_rate alineado. | |
| if rec.main_payment_id.counterpart_rate and rec.accounting_rate != rec.main_payment_id.counterpart_rate: | |
| # Si B = C en ambos pagos, tomamos la tasa del main como fuente de | |
| # verdad para mantener counterpart_rate alineado. Si el main tiene | |
| # counterpart_rate, debe prevalecer siempre; si no, usamos su | |
| # accounting_rate como fallback consistente. | |
| if rec.main_payment_id.counterpart_rate: |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -365,6 +365,53 @@ def test_b3_bundle_deuda_usd_linked_mixtos(self): | |||||
| # Pago intencional parcial: 500+500+30 = 1030 USD de 1210 USD total | ||||||
| self.assertEqual(invoice.payment_state, "partial", "1030 USD pagados de 1210 USD → debe quedar parcial") | ||||||
|
|
||||||
| def test_b3_linked_usd_uses_forced_main_counterpart_rate(self): | ||||||
| """B.3.x · Main con deuda USD y counterpart rate forzado. | ||||||
|
|
||||||
| Caso de regresión: | ||||||
| - Main: A=ARS, B=USD, se fuerza user_counterpart_rate=1400 (en vez de tasa vigente) | ||||||
|
||||||
| - Main: A=ARS, B=USD, se fuerza user_counterpart_rate=1400 (en vez de tasa vigente) | |
| - Main: A=ARS, B=USD, se fuerza counterpart_rate=1/1400 (equivalente a user rate 1400) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acá capaz agregar el rate del main en el depends, por si cambia el rate que no quede el anterior?