fix failing test case
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index 195a27f..14310f8 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -762,29 +762,20 @@
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 60be20d..af6d785 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 @@
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")