diff --git a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js index 868e59aeff..3bbadcb635 100644 --- a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js +++ b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js @@ -33,12 +33,15 @@ cur_frm.cscript.refresh = function(doc) { cur_frm.fields_dict.voucher_no.get_query = function(doc) { if (!doc.account) msgprint("Please select Account first"); else { - return repl("select voucher_no, posting_date \ - from `tabGL Entry` where ifnull(is_cancelled, 'No') = 'No'\ - and account = '%(acc)s' \ - and voucher_type = '%(dt)s' \ - and voucher_no LIKE '%s' \ - ORDER BY posting_date DESC, voucher_no DESC LIMIT 50 \ + return repl("select gle.voucher_no, gle.posting_date \ + from `tabGL Entry` gle where gle.account = '%(acc)s' \ + and gle.voucher_type = '%(dt)s' \ + and gle.voucher_no LIKE '%s' \ + and ifnull(gle.is_cancelled, 'No') = 'No'\ + and (select sum(debit) - sum(credit) from `tabGL Entry` \ + where against_voucher_type = '%(dt)s' and against_voucher = gle.voucher_no \ + and ifnull(is_cancelled, 'No') = 'No') > 0 \ + ORDER BY gle.posting_date DESC, gle.voucher_no DESC LIMIT 50 \ ", {dt:doc.voucher_type, acc:doc.account}); } } diff --git a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.txt b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.txt index 91d2613561..d1442543c0 100644 --- a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.txt +++ b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.txt @@ -2,9 +2,9 @@ { "owner": "Administrator", "docstatus": 0, - "creation": "2012-07-03 13:30:46", + "creation": "2013-01-16 14:48:54", "modified_by": "Administrator", - "modified": "2012-12-31 10:34:43" + "modified": "2013-01-21 11:52:11" }, { "issingle": 1, @@ -25,7 +25,9 @@ "name": "__common__", "parent": "Payment to Invoice Matching Tool", "read": 1, + "submit": 0, "doctype": "DocPerm", + "report": 0, "parenttype": "DocType", "parentfield": "permissions" }, @@ -197,8 +199,11 @@ "permlevel": 0 }, { + "amend": 0, + "create": 0, "doctype": "DocPerm", "role": "All", + "cancel": 0, "permlevel": 1 } ] \ No newline at end of file