fixes in payment reconciliation
This commit is contained in:
parent
92a0218091
commit
8e4a772a35
@ -30,19 +30,43 @@ 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 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 (ifnull(against_voucher_type, '') = '' or \
|
||||||
|
// (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});
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
cur_frm.fields_dict.voucher_no.get_query = function(doc) {
|
cur_frm.fields_dict.voucher_no.get_query = function(doc) {
|
||||||
if (!doc.account) msgprint("Please select Account first");
|
if (!doc.account) msgprint("Please select Account first");
|
||||||
else {
|
else {
|
||||||
return repl("select gle.voucher_no, gle.posting_date \
|
return repl("select gle.voucher_no, gle.posting_date, gle.%(account_type)s \
|
||||||
from `tabGL Entry` gle where gle.account = '%(acc)s' \
|
from `tabGL Entry` gle \
|
||||||
and gle.voucher_type = '%(dt)s' \
|
where gle.account = '%(acc)s' \
|
||||||
and gle.voucher_no LIKE '%s' \
|
and gle.voucher_type = '%(dt)s' \
|
||||||
and ifnull(gle.is_cancelled, 'No') = 'No'\
|
and gle.voucher_no like '%s' \
|
||||||
and (select sum(debit) - sum(credit) from `tabGL Entry` \
|
and ifnull(gle.is_cancelled, 'No') = 'No' \
|
||||||
where against_voucher_type = '%(dt)s' and against_voucher = gle.voucher_no \
|
and (ifnull(gle.against_voucher, '') = '' \
|
||||||
and ifnull(is_cancelled, 'No') = 'No') != 0 \
|
or ifnull(gle.against_voucher, '') = gle.voucher_no ) \
|
||||||
ORDER BY gle.posting_date DESC, gle.voucher_no DESC LIMIT 50 \
|
and ifnull(gle.%(account_type)s, 0) > 0 \
|
||||||
", {dt:doc.voucher_type, acc:doc.account});
|
and (select ifnull(abs(sum(debit) - sum(credit)), 0) from `tabGL Entry` \
|
||||||
|
where against_voucher_type = '%(dt)s' \
|
||||||
|
and against_voucher = gle.voucher_no \
|
||||||
|
and voucher_no != gle.voucher_no \
|
||||||
|
and ifnull(is_cancelled, 'No') = 'No') != \
|
||||||
|
abs(ifnull(gle.debit, 0) - ifnull(gle.credit, 0)) \
|
||||||
|
ORDER BY gle.posting_date DESC, gle.voucher_no DESC LIMIT 50",
|
||||||
|
{dt:doc.voucher_type, acc:doc.account, account_type: doc.account_type});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,3 +74,12 @@ cur_frm.cscript.voucher_no =function(doc, cdt, cdn) {
|
|||||||
get_server_fields('get_voucher_details', '', '', doc, cdt, cdn, 1)
|
get_server_fields('get_voucher_details', '', '', doc, cdt, cdn, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.account = function(doc, cdt, cdn) {
|
||||||
|
wn.call({
|
||||||
|
doc: this.frm.doc,
|
||||||
|
method: "set_account_type",
|
||||||
|
callback: function(r) {
|
||||||
|
if(!r.exc) refresh_field("account_type");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -27,32 +27,32 @@ class DocType:
|
|||||||
def __init__(self, doc, doclist):
|
def __init__(self, doc, doclist):
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
self.doclist = doclist
|
self.doclist = doclist
|
||||||
self.acc_type = self.doc.account and webnotes.conn.sql("""select debit_or_credit
|
|
||||||
from `tabAccount` where name = %s""", self.doc.account)[0][0].lower() or ''
|
def set_account_type(self):
|
||||||
self.dt = {
|
self.doc.account_type = self.doc.account and \
|
||||||
'Sales Invoice': 'Sales Invoice',
|
webnotes.conn.get_value("Account", self.doc.account, "debit_or_credit").lower() or ""
|
||||||
'Purchase Invoice': 'Purchase Invoice',
|
|
||||||
'Journal Voucher': 'Journal Voucher'
|
|
||||||
}
|
|
||||||
|
|
||||||
def get_voucher_details(self):
|
def get_voucher_details(self):
|
||||||
tot_amt = webnotes.conn.sql("""
|
total_amount = webnotes.conn.sql("""select %s from `tabGL Entry`
|
||||||
select sum(%s) from `tabGL Entry` where
|
where voucher_type = %s and voucher_no = %s
|
||||||
voucher_type = %s and voucher_no = %s
|
|
||||||
and account = %s and ifnull(is_cancelled, 'No') = 'No'""" %
|
and account = %s and ifnull(is_cancelled, 'No') = 'No'""" %
|
||||||
(self.acc_type, '%s', '%s', '%s'),
|
(self.doc.account_type, '%s', '%s', '%s'),
|
||||||
(self.dt[self.doc.voucher_type], self.doc.voucher_no, self.doc.account))
|
(self.doc.voucher_type, self.doc.voucher_no, self.doc.account))
|
||||||
|
|
||||||
|
total_amount = total_amount and flt(total_amount[0][0]) or 0
|
||||||
|
|
||||||
outstanding = webnotes.conn.sql("""
|
reconciled_payment = webnotes.conn.sql("""
|
||||||
select sum(%s) - sum(%s) from `tabGL Entry` where
|
select sum(%s) - sum(%s) from `tabGL Entry` where
|
||||||
against_voucher = %s and voucher_no != %s
|
against_voucher = %s and voucher_no != %s
|
||||||
and account = %s and ifnull(is_cancelled, 'No') = 'No'""" %
|
and account = %s and ifnull(is_cancelled, 'No') = 'No'""" %
|
||||||
((self.acc_type == 'debit' and 'credit' or 'debit'), self.acc_type, '%s', '%s', '%s'),
|
((self.doc.account_type == 'debit' and 'credit' or 'debit'), self.doc.account_type,
|
||||||
(self.doc.voucher_no, self.doc.voucher_no, self.doc.account))
|
'%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 = {
|
ret = {
|
||||||
'total_amount': flt(tot_amt[0][0]) or 0,
|
'total_amount': total_amount,
|
||||||
'pending_amt_to_reconcile': flt(tot_amt[0][0]) - flt(outstanding[0][0]) or 0
|
'pending_amt_to_reconcile': total_amount - reconciled_payment
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
@ -69,7 +69,7 @@ class DocType:
|
|||||||
|
|
||||||
def get_gl_entries(self):
|
def get_gl_entries(self):
|
||||||
self.validate_mandatory()
|
self.validate_mandatory()
|
||||||
dc = self.acc_type == 'debit' and 'credit' or 'debit'
|
dc = self.doc.account_type == 'debit' and 'credit' or 'debit'
|
||||||
|
|
||||||
cond = self.doc.from_date and " and t1.posting_date >= '" + self.doc.from_date + "'" or ""
|
cond = self.doc.from_date and " and t1.posting_date >= '" + self.doc.from_date + "'" or ""
|
||||||
cond += self.doc.to_date and " and t1.posting_date <= '" + self.doc.to_date + "'"or ""
|
cond += self.doc.to_date and " and t1.posting_date <= '" + self.doc.to_date + "'"or ""
|
||||||
@ -97,7 +97,7 @@ class DocType:
|
|||||||
'Payment to Invoice Matching Tool Detail', self.doclist)
|
'Payment to Invoice Matching Tool Detail', self.doclist)
|
||||||
ch.voucher_no = d.get('voucher_no')
|
ch.voucher_no = d.get('voucher_no')
|
||||||
ch.posting_date = d.get('posting_date')
|
ch.posting_date = d.get('posting_date')
|
||||||
ch.amt_due = self.acc_type == 'debit' and flt(d.get('amt_due')) \
|
ch.amt_due = self.doc.account_type == 'debit' and flt(d.get('amt_due')) \
|
||||||
or -1*flt(d.get('amt_due'))
|
or -1*flt(d.get('amt_due'))
|
||||||
ch.total_amt = flt(d.get('total_amt'))
|
ch.total_amt = flt(d.get('total_amt'))
|
||||||
ch.against_account = d.get('against_account')
|
ch.against_account = d.get('against_account')
|
||||||
@ -116,7 +116,7 @@ class DocType:
|
|||||||
3. submit payment voucher
|
3. submit payment voucher
|
||||||
"""
|
"""
|
||||||
if not self.doc.voucher_no or not webnotes.conn.sql("""select name from `tab%s`
|
if not self.doc.voucher_no or not webnotes.conn.sql("""select name from `tab%s`
|
||||||
where name = %s""" % (self.dt[self.doc.voucher_type], '%s'), self.doc.voucher_no):
|
where name = %s""" % (self.doc.voucher_type, '%s'), self.doc.voucher_no):
|
||||||
msgprint("Please select valid Voucher No to proceed", raise_exception=1)
|
msgprint("Please select valid Voucher No to proceed", raise_exception=1)
|
||||||
|
|
||||||
lst = []
|
lst = []
|
||||||
@ -125,11 +125,11 @@ class DocType:
|
|||||||
args = {
|
args = {
|
||||||
'voucher_no' : d.voucher_no,
|
'voucher_no' : d.voucher_no,
|
||||||
'voucher_detail_no' : d.voucher_detail_no,
|
'voucher_detail_no' : d.voucher_detail_no,
|
||||||
'against_voucher_type' : self.dt[self.doc.voucher_type],
|
'against_voucher_type' : self.doc.voucher_type,
|
||||||
'against_voucher' : self.doc.voucher_no,
|
'against_voucher' : self.doc.voucher_no,
|
||||||
'account' : self.doc.account,
|
'account' : self.doc.account,
|
||||||
'is_advance' : 'No',
|
'is_advance' : 'No',
|
||||||
'dr_or_cr' : self.acc_type=='debit' and 'credit' or 'debit',
|
'dr_or_cr' : self.doc.account_type=='debit' and 'credit' or 'debit',
|
||||||
'unadjusted_amt' : flt(d.amt_due),
|
'unadjusted_amt' : flt(d.amt_due),
|
||||||
'allocated_amt' : flt(d.amt_to_be_reconciled)
|
'allocated_amt' : flt(d.amt_to_be_reconciled)
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"creation": "2013-01-21 18:19:17",
|
"creation": "2013-01-23 12:23:46",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-01-22 14:56:41",
|
"modified": "2013-01-23 12:26:49",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@ -31,7 +31,7 @@
|
|||||||
"parenttype": "DocType",
|
"parenttype": "DocType",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"report": 0,
|
||||||
"submit": 0,
|
"submit": 0,
|
||||||
"write": 1
|
"write": 1
|
||||||
},
|
},
|
||||||
@ -47,6 +47,14 @@
|
|||||||
"options": "Account",
|
"options": "Account",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "account_type",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Account Type",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "voucher_type",
|
"fieldname": "voucher_type",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user