fixes in payemnt reconciliation

This commit is contained in:
Nabin Hait 2013-02-12 15:17:25 +05:30
parent 9b051db7d6
commit 945b39f984
2 changed files with 3 additions and 4 deletions

View File

@ -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 \

View File

@ -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