Payment Reconciliation based on party
This commit is contained in:
parent
894a1b539a
commit
034ac6b00b
@ -7,24 +7,32 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext
|
|||||||
|
|
||||||
onload: function() {
|
onload: function() {
|
||||||
var me = this
|
var me = this
|
||||||
this.frm.set_query('party_account', function() {
|
this.frm.set_query('party_type', function() {
|
||||||
if(!me.frm.doc.company) {
|
return {
|
||||||
msgprint(__("Please select company first"));
|
filters: {
|
||||||
|
"name": ["in", ["Customer", "Supplier"]]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
this.frm.set_query('receivable_payable_account', function() {
|
||||||
|
if(!me.frm.doc.company || !me.frm.doc.party_type) {
|
||||||
|
msgprint(__("Please select Company and Party Type first"));
|
||||||
} else {
|
} else {
|
||||||
return{
|
return{
|
||||||
filters:[
|
filters: {
|
||||||
['Account', 'company', '=', me.frm.doc.company],
|
"company": me.frm.doc.company,
|
||||||
['Account', 'group_or_ledger', '=', 'Ledger'],
|
"group_or_ledger": "Ledger",
|
||||||
['Account', 'master_type', 'in', ['Customer', 'Supplier']]
|
"account_type": (me.frm.doc.party_type == "Customer" ? "Receivable" : "Payable")
|
||||||
]
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.frm.set_query('bank_cash_account', function() {
|
this.frm.set_query('bank_cash_account', function() {
|
||||||
if(!me.frm.doc.company) {
|
if(!me.frm.doc.company) {
|
||||||
msgprint(__("Please select company first"));
|
msgprint(__("Please select Company first"));
|
||||||
} else {
|
} else {
|
||||||
return{
|
return{
|
||||||
filters:[
|
filters:[
|
||||||
@ -40,7 +48,26 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext
|
|||||||
'<ul>' + __("If you are unable to match the exact amount, then amend your Journal Voucher and split rows such that payment amount match the invoice amount.") + '</ul>';
|
'<ul>' + __("If you are unable to match the exact amount, then amend your Journal Voucher and split rows such that payment amount match the invoice amount.") + '</ul>';
|
||||||
this.frm.set_value("reconcile_help", help_content);
|
this.frm.set_value("reconcile_help", help_content);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
party: function() {
|
||||||
|
var me = this
|
||||||
|
if(!me.frm.doc.receivable_payable_account && me.frm.doc.party_type && me.frm.doc.party) {
|
||||||
|
return frappe.call({
|
||||||
|
method: "erpnext.accounts.party.get_party_account",
|
||||||
|
args: {
|
||||||
|
company: me.frm.doc.company,
|
||||||
|
party_type: me.frm.doc.party_type,
|
||||||
|
party: me.frm.doc.party
|
||||||
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
if(!r.exc && r.message) {
|
||||||
|
me.frm.set_value("receivable_payable_account", r.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
get_unreconciled_entries: function() {
|
get_unreconciled_entries: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
return this.frm.call({
|
return this.frm.call({
|
||||||
@ -48,12 +75,12 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext
|
|||||||
method: 'get_unreconciled_entries',
|
method: 'get_unreconciled_entries',
|
||||||
callback: function(r, rt) {
|
callback: function(r, rt) {
|
||||||
var invoices = [];
|
var invoices = [];
|
||||||
|
|
||||||
$.each(me.frm.doc.payment_reconciliation_invoices || [], function(i, row) {
|
$.each(me.frm.doc.payment_reconciliation_invoices || [], function(i, row) {
|
||||||
if (row.invoice_number && !inList(invoices, row.invoice_number))
|
if (row.invoice_number && !inList(invoices, row.invoice_number))
|
||||||
invoices.push(row.invoice_number);
|
invoices.push(row.invoice_number);
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.meta.get_docfield("Payment Reconciliation Payment", "invoice_number",
|
frappe.meta.get_docfield("Payment Reconciliation Payment", "invoice_number",
|
||||||
me.frm.doc.name).options = invoices.join("\n");
|
me.frm.doc.name).options = invoices.join("\n");
|
||||||
|
|
||||||
@ -78,5 +105,3 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext
|
|||||||
});
|
});
|
||||||
|
|
||||||
$.extend(cur_frm.cscript, new erpnext.accounts.PaymentReconciliationController({frm: cur_frm}));
|
$.extend(cur_frm.cscript, new erpnext.accounts.PaymentReconciliationController({frm: cur_frm}));
|
||||||
|
|
||||||
cur_frm.add_fetch('party_account', 'master_type', 'party_type')
|
|
||||||
@ -15,26 +15,35 @@
|
|||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "",
|
"fieldname": "party_type",
|
||||||
"fieldname": "party_account",
|
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"hidden": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Party Account",
|
"label": "Party Type",
|
||||||
"options": "Account",
|
"options": "DocType",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "",
|
||||||
|
"fieldname": "party",
|
||||||
|
"fieldtype": "Dynamic Link",
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Party",
|
||||||
|
"options": "party_type",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"search_index": 0
|
"search_index": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "party_type",
|
"fieldname": "receivable_payable_account",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Link",
|
||||||
"hidden": 1,
|
"label": "Receivable / Payable Account",
|
||||||
"in_list_view": 1,
|
"options": "Account",
|
||||||
"label": "Party Type",
|
|
||||||
"options": "\nCustomer\nSupplier",
|
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1,
|
"precision": "",
|
||||||
"reqd": 0
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "bank_cash_account",
|
"fieldname": "bank_cash_account",
|
||||||
@ -130,7 +139,7 @@
|
|||||||
"hide_toolbar": 1,
|
"hide_toolbar": 1,
|
||||||
"icon": "icon-resize-horizontal",
|
"icon": "icon-resize-horizontal",
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"modified": "2014-07-31 05:43:03.410832",
|
"modified": "2014-09-12 12:18:15.956283",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Payment Reconciliation",
|
"name": "Payment Reconciliation",
|
||||||
|
|||||||
@ -26,13 +26,14 @@ class PaymentReconciliation(Document):
|
|||||||
|
|
||||||
jv_entries = frappe.db.sql("""
|
jv_entries = frappe.db.sql("""
|
||||||
select
|
select
|
||||||
t1.name as voucher_no, t1.posting_date, t1.remark, t2.account,
|
t1.name as voucher_no, t1.posting_date, t1.remark,
|
||||||
t2.name as voucher_detail_no, {dr_or_cr} as payment_amount, t2.is_advance
|
t2.name as voucher_detail_no, {dr_or_cr} as payment_amount, t2.is_advance
|
||||||
from
|
from
|
||||||
`tabJournal Voucher` t1, `tabJournal Voucher Detail` t2
|
`tabJournal Voucher` t1, `tabJournal Voucher Detail` t2
|
||||||
where
|
where
|
||||||
t1.name = t2.parent and t1.docstatus = 1 and t2.docstatus = 1
|
t1.name = t2.parent and t1.docstatus = 1 and t2.docstatus = 1
|
||||||
and t2.account = %(party_account)s and {dr_or_cr} > 0
|
and t2.party_type = %(party_type)s and t2.party = %(party)s
|
||||||
|
and t2.account = %(account)s and {dr_or_cr} > 0
|
||||||
and ifnull(t2.against_voucher, '')='' and ifnull(t2.against_invoice, '')=''
|
and ifnull(t2.against_voucher, '')='' and ifnull(t2.against_invoice, '')=''
|
||||||
and ifnull(t2.against_jv, '')='' {cond}
|
and ifnull(t2.against_jv, '')='' {cond}
|
||||||
and (CASE
|
and (CASE
|
||||||
@ -45,7 +46,9 @@ class PaymentReconciliation(Document):
|
|||||||
"cond": cond,
|
"cond": cond,
|
||||||
"bank_account_condition": bank_account_condition,
|
"bank_account_condition": bank_account_condition,
|
||||||
}), {
|
}), {
|
||||||
"party_account": self.party_account,
|
"party_type": self.party_type,
|
||||||
|
"party": self.party,
|
||||||
|
"account": self.receivable_payable_account,
|
||||||
"bank_cash_account": "%%%s%%" % self.bank_cash_account
|
"bank_cash_account": "%%%s%%" % self.bank_cash_account
|
||||||
}, as_dict=1)
|
}, as_dict=1)
|
||||||
|
|
||||||
@ -75,12 +78,17 @@ class PaymentReconciliation(Document):
|
|||||||
from
|
from
|
||||||
`tabGL Entry`
|
`tabGL Entry`
|
||||||
where
|
where
|
||||||
account = %s and {dr_or_cr} > 0 {cond}
|
party_type = %(party_type)s and party = %(party)s
|
||||||
|
and account = %(account)s and {dr_or_cr} > 0 {cond}
|
||||||
group by voucher_type, voucher_no
|
group by voucher_type, voucher_no
|
||||||
""".format(**{
|
""".format(**{
|
||||||
"cond": cond,
|
"cond": cond,
|
||||||
"dr_or_cr": dr_or_cr
|
"dr_or_cr": dr_or_cr
|
||||||
}), (self.party_account), as_dict=True)
|
}), {
|
||||||
|
"party_type": self.party_type,
|
||||||
|
"party": self.party,
|
||||||
|
"account": self.receivable_payable_account,
|
||||||
|
}, as_dict=True)
|
||||||
|
|
||||||
for d in invoice_list:
|
for d in invoice_list:
|
||||||
payment_amount = frappe.db.sql("""
|
payment_amount = frappe.db.sql("""
|
||||||
@ -89,10 +97,17 @@ class PaymentReconciliation(Document):
|
|||||||
from
|
from
|
||||||
`tabGL Entry`
|
`tabGL Entry`
|
||||||
where
|
where
|
||||||
account = %s and {0} > 0
|
party_type = %(party_type)s and party = %(party)s
|
||||||
and against_voucher_type = %s and ifnull(against_voucher, '') = %s
|
and account = %(account)s and {0} > 0
|
||||||
""".format("credit" if self.party_type == "Customer" else "debit"),
|
and against_voucher_type = %(against_voucher_type)s
|
||||||
(self.party_account, d.voucher_type, d.voucher_no))
|
and ifnull(against_voucher, '') = %(against_voucher)s
|
||||||
|
""".format("credit" if self.party_type == "Customer" else "debit"), {
|
||||||
|
"party_type": self.party_type,
|
||||||
|
"party": self.party,
|
||||||
|
"account": self.receivable_payable_account,
|
||||||
|
"against_voucher_type": d.voucher_type,
|
||||||
|
"against_voucher": d.voucher_no
|
||||||
|
})
|
||||||
|
|
||||||
payment_amount = payment_amount[0][0] if payment_amount else 0
|
payment_amount = payment_amount[0][0] if payment_amount else 0
|
||||||
|
|
||||||
@ -130,7 +145,9 @@ class PaymentReconciliation(Document):
|
|||||||
'voucher_detail_no' : e.voucher_detail_number,
|
'voucher_detail_no' : e.voucher_detail_number,
|
||||||
'against_voucher_type' : e.invoice_type,
|
'against_voucher_type' : e.invoice_type,
|
||||||
'against_voucher' : e.invoice_number,
|
'against_voucher' : e.invoice_number,
|
||||||
'account' : self.party_account,
|
'account' : self.receivable_payable_account,
|
||||||
|
'party_type': self.party_type,
|
||||||
|
'party': self.party,
|
||||||
'is_advance' : e.is_advance,
|
'is_advance' : e.is_advance,
|
||||||
'dr_or_cr' : dr_or_cr,
|
'dr_or_cr' : dr_or_cr,
|
||||||
'unadjusted_amt' : flt(e.amount),
|
'unadjusted_amt' : flt(e.amount),
|
||||||
@ -144,7 +161,7 @@ class PaymentReconciliation(Document):
|
|||||||
self.get_unreconciled_entries()
|
self.get_unreconciled_entries()
|
||||||
|
|
||||||
def check_mandatory_to_fetch(self):
|
def check_mandatory_to_fetch(self):
|
||||||
for fieldname in ["company", "party_account"]:
|
for fieldname in ["company", "party_type", "party", "receivable_payable_account"]:
|
||||||
if not self.get(fieldname):
|
if not self.get(fieldname):
|
||||||
frappe.throw(_("Please select {0} first").format(self.meta.get_label(fieldname)))
|
frappe.throw(_("Please select {0} first").format(self.meta.get_label(fieldname)))
|
||||||
|
|
||||||
|
|||||||
@ -95,7 +95,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2014-07-21 16:53:56.206169",
|
"modified": "2014-09-12 13:05:57.839280",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Payment Reconciliation Payment",
|
"name": "Payment Reconciliation Payment",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user