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
This commit is contained in:
@@ -6,6 +6,7 @@ import unicodedata
|
||||
import uuid
|
||||
from io import BytesIO
|
||||
from itertools import groupby
|
||||
from operator import attrgetter
|
||||
|
||||
import genshi
|
||||
import genshi.template
|
||||
@@ -218,7 +219,7 @@ class Group(metaclass=PoolMeta):
|
||||
Mandate = pool.get('account.payment.sepa.mandate')
|
||||
assert self.process_method == 'sepa'
|
||||
if self.kind == 'receivable':
|
||||
payments = list(self.payments)
|
||||
payments = sorted(self.payments, key=attrgetter('date', 'id'))
|
||||
mandates = Payment.get_sepa_mandates(payments)
|
||||
Mandate.lock(list(filter(None, mandates)))
|
||||
sequence_types = {}
|
||||
|
||||
Reference in New Issue
Block a user