From 945b39f98452541f10e2e2e900a030e7dda93b11 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 12 Feb 2013 15:17:25 +0530 Subject: [PATCH] fixes in payemnt reconciliation --- .../payment_to_invoice_matching_tool.js | 3 ++- .../payment_to_invoice_matching_tool.py | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) 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 06c014cb78..022f900b05 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 @@ -44,7 +44,8 @@ cur_frm.fields_dict.voucher_no.get_query = function(doc) { and (ifnull(gle.against_voucher, '') = '' \ or ifnull(gle.against_voucher, '') = gle.voucher_no ) \ and ifnull(gle.%(account_type)s, 0) > 0 \ - and (select ifnull(abs(sum(debit) - sum(credit)), 0) from `tabGL Entry` \ + and (select ifnull(abs(sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))), 0) \ + from `tabGL Entry` \ where against_voucher_type = '%(dt)s' \ and against_voucher = gle.voucher_no \ and voucher_no != gle.voucher_no \ diff --git a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py index d585ceaefa..b75142b66e 100644 --- a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py +++ b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py @@ -39,16 +39,14 @@ class DocType: (self.doc.voucher_type, self.doc.voucher_no, self.doc.account)) total_amount = total_amount and flt(total_amount[0][0]) or 0 - reconciled_payment = webnotes.conn.sql(""" - select sum(%s) - sum(%s) from `tabGL Entry` where + select sum(ifnull(%s, 0)) - sum(ifnull(%s, 0)) from `tabGL Entry` where against_voucher = %s and voucher_no != %s and account = %s and ifnull(is_cancelled, 'No') = 'No'""" % ((self.doc.account_type == 'debit' and 'credit' or 'debit'), self.doc.account_type, '%s', '%s', '%s'), (self.doc.voucher_no, self.doc.voucher_no, self.doc.account)) reconciled_payment = reconciled_payment and flt(reconciled_payment[0][0]) or 0 - ret = { 'total_amount': total_amount, 'pending_amt_to_reconcile': total_amount - reconciled_payment