changeset 05a3dd4ca183 in modules/account:default
details: https://hg.tryton.org/modules/account?cmd=changeset&node=05a3dd4ca183
description:
Sort lines by maturity date to reconcile older first
issue10291
review357811003
diffstat:
move.py | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diffs (26 lines):
diff -r 9ca8eb48bd78 -r 05a3dd4ca183 move.py
--- a/move.py Sun May 16 17:50:48 2021 +0200
+++ b/move.py Sun May 16 17:58:08 2021 +0200
@@ -1768,7 +1768,11 @@
('party', '=',
self.show.party.id if self.show.party else None),
('reconciliation', '=', None),
- ])
+ ],
+ order=[])
+
+ def _line_sort_key(self, line):
+ return [line.maturity_date or line.date]
def _default_lines(self):
'Return the larger list of lines which can be reconciled'
@@ -1784,7 +1788,8 @@
chunk = config.getint('account', 'reconciliation_chunk', default=10)
# Combination is exponential so it must be limited to small number
default = []
- for lines in grouped_slice(self._all_lines(), chunk):
+ for lines in grouped_slice(
+ sorted(self._all_lines(), key=self._line_sort_key), chunk):
lines = list(lines)
best = None
for n in range(len(lines), 1, -1):