From 35c84fe4f20a77381266eddd80ea52ba7bc1357c Mon Sep 17 00:00:00 2001 From: tunde Date: Wed, 20 Sep 2017 12:26:19 +0100 Subject: [PATCH] fix failing test case --- .../doctype/payment_entry/payment_entry.py | 33 +++++++------------ .../payment_entry/test_payment_entry.py | 2 +- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 195a27f69a..14310f8001 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -762,29 +762,20 @@ def get_payment_entry(dt, dn, party_amount=None, bank_account=None, bank_amount= pe.received_amount = received_amount pe.allocate_payment_amount = 1 pe.letter_head = doc.get("letter_head") + args = { + 'party_account': party_account, 'company': pe.company, 'party_type': pe.party_type, + 'party': pe.party, 'posting_date': pe.posting_date + } + references = get_outstanding_reference_documents(args=args) - if doc.get("payment_schedule"): - for d in doc.get("payment_schedule"): - invoice_amount = d.payment_amount * doc.conversion_rate \ - if party_account_currency == doc.company_currency else d.payment_amount - paid_amount = get_paid_amount(dt, dn, party_type, pe.party, party_account, d.due_date) - outstanding_amount = invoice_amount - paid_amount - pe.append("references", { - "reference_doctype": dt, - "reference_name": dn, - "due_date": d.due_date, - "total_amount": invoice_amount, - "outstanding_amount": outstanding_amount, - "allocated_amount": outstanding_amount - }) - else: + for reference in references: pe.append("references", { - "reference_doctype": dt, - "reference_name": dn, - "due_date": doc.get("due_date"), - "total_amount": grand_total, - "outstanding_amount": outstanding_amount, - "allocated_amount": outstanding_amount + 'reference_doctype': reference.voucher_type, + 'reference_name': reference.voucher_no, + 'due_date': reference.due_date, + 'total_amount': reference.invoice_amount, + 'outstanding_amount': reference.outstanding_amount, + 'allocated_amount': reference.outstanding_amount }) pe.setup_party_account_field() diff --git a/erpnext/accounts/doctype/payment_entry/test_payment_entry.py b/erpnext/accounts/doctype/payment_entry/test_payment_entry.py index 60be20dd89..af6d785dbc 100644 --- a/erpnext/accounts/doctype/payment_entry/test_payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/test_payment_entry.py @@ -212,7 +212,7 @@ class TestPaymentEntry(unittest.TestCase): self.assertRaises(InvalidPaymentEntry, pe1.validate) - si1 = create_sales_invoice() + si1 = create_sales_invoice() # create full payment entry against si1 pe2 = get_payment_entry("Sales Invoice", si1.name, bank_account="_Test Cash - _TC")