Add the payment amount to invoice's amount_to_pay when the payment line is unreconciled
issue10757 review371951002
This commit is contained in:
1 parent
b57b3adc6f
commit
56fa7a078b
3 files changed
+16
-5
No files matched your search
@@ -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
|
||||
|
||||
+4
-5
@@ -557,10 +557,9 @@ class Invoice(metaclass=PoolMeta):
|
||||
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
|
||||
+10
@@ -363,6 +363,16 @@ class Payment(Workflow, ModelSQL, ModelView):
|
||||
('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__()
|
||||
|
||||
Reference in new issue
Block a user