Sort SEPA payments by date

In order to compute the proper sequence type, the payments must be ordered by
ascending date in case there are many payments for a first used mandate.

Closes #12614
(grafted from 2c9566afb532ea96c728c16b9c3fe965fffa93e7)

--HG--
branch : 6.0
This commit is contained in:
Cédric Krier committed 2025-01-18 12:57:41 +01:00
1 parent bbaf46ecf2
commit f511dd33b4
1 file changed
+3 -1
+3 -1
View File
@@ -5,6 +5,7 @@ import os
import unicodedata
from itertools import groupby
from io import BytesIO
from operator import attrgetter
import genshi
import genshi.template
@@ -208,8 +209,9 @@ class Group(metaclass=PoolMeta):
pool = Pool()
Payment = pool.get('account.payment')
if self.kind == 'receivable':
payments = sorted(self.payments, key=attrgetter('date', 'id'))
mandates = Payment.get_sepa_mandates(self.payments)
for payment, mandate in zip(self.payments, mandates):
for payment, mandate in zip(payments, mandates):
if not mandate:
raise ProcessError(
gettext('account_payment_sepa'