set the reference document in the payment entry while creating from fees (#11861)

* set the reference document in the payment entry while creating from fees

* allocate the paid amount in the reference document
This commit is contained in:
Manas Solanki
2017-12-06 14:05:39 +05:30
committed by Nabin Hait
parent 7351709980
commit a160879159
4 changed files with 17 additions and 43 deletions

View File

@@ -576,14 +576,13 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
outstanding_invoices = []
precision = frappe.get_precision("Sales Invoice", "outstanding_amount")
if party_type == "Customer":
if party_type == "Customer" or party_type == "Student":
dr_or_cr = "debit_in_account_currency - credit_in_account_currency"
payment_dr_or_cr = "payment_gl_entry.credit_in_account_currency - payment_gl_entry.debit_in_account_currency"
else:
dr_or_cr = "credit_in_account_currency - debit_in_account_currency"
payment_dr_or_cr = "payment_gl_entry.debit_in_account_currency - payment_gl_entry.credit_in_account_currency"
invoice = 'Sales Invoice' if party_type == 'Customer' else 'Purchase Invoice'
invoice_list = frappe.db.sql("""
select
voucher_no, voucher_type, posting_date, ifnull(sum({dr_or_cr}), 0) as invoice_amount, due_date,
@@ -613,7 +612,6 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
having (invoice_amount - payment_amount) > 0.005
order by posting_date, name, due_date""".format(
dr_or_cr=dr_or_cr,
invoice=invoice,
payment_dr_or_cr=payment_dr_or_cr,
condition=condition or ""
), {