[IMP] account_payment_order_grouped_output: Maturity date in grouped moves

For propagating maturity dates from the individual payment moves to the
grouped ones, 2 actions are taken:

- For the counterpart that will neutralize each payment, we put the
  maturity date according to the same logic as the payment one.
- For the grouped AR/AP, we put the first payment date  of all the
  grouped payments, as all of them should be the same after grouping
  by this criterium in _prepare_trf_moves.

TT50671
This commit is contained in:
Pedro M. Baeza
2024-09-02 15:04:21 +02:00
parent c3aaae42e5
commit 009f3b4926
2 changed files with 16 additions and 0 deletions

View File

@@ -149,6 +149,8 @@ class AccountPaymentOrder(models.Model):
),
"currency_id": payment.currency_id.id,
"amount_currency": payment.amount * sign,
# Same logic as the individual payments
"date_maturity": payment.payment_line_ids[0].date,
}
return vals
@@ -181,6 +183,8 @@ class AccountPaymentOrder(models.Model):
),
"currency_id": payments[0].currency_id.id,
"amount_currency": amount_payment_currency * sign,
# All the lines should have the same date following _prepare_trf_moves
"date_maturity": payments.payment_line_ids[:1].date,
}
return vals

View File

@@ -1,6 +1,9 @@
# Copyright 2022 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from freezegun import freeze_time
from odoo import fields
from odoo.tests.common import tagged
from odoo.addons.account_payment_order.tests.test_payment_order_inbound import (
@@ -10,9 +13,12 @@ from odoo.addons.account_payment_order.tests.test_payment_order_inbound import (
@tagged("post_install", "-at_install")
class TestPaymentOrderInbound(TestPaymentOrderInboundBase):
@freeze_time("2024-04-01")
def test_grouped_output(self):
self.inbound_mode.generate_move = True
self.inbound_mode.post_move = True
self.inbound_order.date_prefered = "fixed"
self.inbound_order.date_scheduled = "2024-08-01"
self.inbound_order.draft2open()
self.inbound_order.open2generated()
self.inbound_order.generated2uploaded()
@@ -35,3 +41,9 @@ class TestPaymentOrderInbound(TestPaymentOrderInboundBase):
grouped_moves = self.inbound_order.grouped_move_ids
self.assertTrue(grouped_moves)
self.assertTrue(grouped_moves.line_ids[0].reconciled)
self.assertTrue(
all(
x.date_maturity == fields.Date.from_string("2024-08-01")
for x in grouped_moves.line_ids
)
)