From 8170585faf3204b815d2a7770892509aaaac6052 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 18 Apr 2019 15:13:18 +0530 Subject: [PATCH] fix: Don't fetch already discounted invoice --- .../doctype/invoice_discounting/invoice_discounting.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py index 64aa4e4af6..d1ede67ed4 100644 --- a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py +++ b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py @@ -190,9 +190,11 @@ def get_invoices(filters): customer, posting_date, outstanding_amount - from `tabSales Invoice` + from `tabSales Invoice` si where docstatus = 1 and outstanding_amount > 0 %s + and not exists(select di.name from `tabDiscounted Invoice` di + where di.docstatus=1 and di.sales_invoice=si.name) """ % where_condition, filters, as_dict=1) \ No newline at end of file