changeset 20f623d7aacd in modules/account:default
details: https://hg.tryton.org/modules/account?cmd=changeset;node=20f623d7aacd
description:
Fall-back to move date on aged balance
Putting empty maturity date on the last term does not reflect properly
the
history of the balance. As we consider such line to be paid or received
today,
it is better to use the date at which the move was effective.
issue9294
review305481006
diffstat:
account.py | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diffs (24 lines):
diff -r 6e55eb27f837 -r 20f623d7aacd account.py
--- a/account.py Mon May 04 12:05:50 2020 +0200
+++ b/account.py Tue May 19 18:59:55 2020 +0200
@@ -2128,17 +2128,16 @@
term_values = sorted(
list(terms.values()), key=lambda x: ((x is not None), x or 0))
+ line_date = Coalesce(line.maturity_date, move.date)
for name, value in terms.items():
if value is None or factor is None or date is None:
columns.append(Literal(None).as_(name))
continue
- cond = line.maturity_date <= (date - value * factor)
+ cond = line_date <= (date - value * factor)
idx = term_values.index(value)
if idx + 1 < len(terms):
- cond &= line.maturity_date > (
+ cond &= line_date > (
date - (term_values[idx + 1] or 0) * factor)
- else:
- cond |= line.maturity_date == Null
columns.append(
Sum(Case((cond, line.debit - line.credit), else_=0)).as_(name))