changeset 7bf36298ce19 in modules/account_payment:default
details:
https://hg.tryton.org/modules/account_payment?cmd=changeset&node=7bf36298ce19
description:
Add the payment amount to invoice's amount_to_pay when the payment line
is unreconciled
issue10757
review371951002
diffstat:
CHANGELOG | 2 ++
account.py | 9 ++++-----
payment.py | 10 ++++++++++
3 files changed, 16 insertions(+), 5 deletions(-)
diffs (47 lines):
diff -r fb95a592c17b -r 7bf36298ce19 CHANGELOG
--- a/CHANGELOG Mon Nov 01 17:17:56 2021 +0100
+++ b/CHANGELOG Sun Nov 28 18:56:16 2021 +0100
@@ -1,3 +1,5 @@
+* Add amount_line_paid property on payments
+
Version 6.2.0 - 2021-11-01
* Bug fixes (see mercurial logs for details)
* Add wizard to create direct debit for configured parties
diff -r fb95a592c17b -r 7bf36298ce19 account.py
--- a/account.py Mon Nov 01 17:17:56 2021 +0100
+++ b/account.py Sun Nov 28 18:56:16 2021 +0100
@@ -557,10 +557,9 @@
continue
payment_amount = Decimal(0)
for payment in line.payments:
- if payment.state != 'failed':
- with Transaction().set_context(date=payment.date):
- payment_amount += Currency.compute(
- payment.currency, payment.amount,
- invoice.currency)
+ with Transaction().set_context(date=payment.date):
+ payment_amount += Currency.compute(
+ payment.currency, payment.amount_line_paid,
+ invoice.currency)
amounts[invoice.id] -= payment_amount
return amounts
diff -r fb95a592c17b -r 7bf36298ce19 payment.py
--- a/payment.py Mon Nov 01 17:17:56 2021 +0100
+++ b/payment.py Sun Nov 28 18:56:16 2021 +0100
@@ -363,6 +363,16 @@
('failed', 'Failed'),
], 'State', readonly=True, select=True)
+ @property
+ def amount_line_paid(self):
+ if self.state != 'failed':
+ if self.line.second_currency:
+ payment_amount = abs(self.line.amount_second_currency)
+ else:
+ payment_amount = abs(self.line.credit - self.line.debit)
+ return max(min(self.amount, payment_amount), 0)
+ return Decimal(0)
+
@classmethod
def __setup__(cls):
super(Payment, cls).__setup__()