[fix] Fetch debit/credit from reference journal entry
This commit is contained in:
parent
a5e9c71397
commit
1be94efcfa
@ -109,7 +109,7 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({
|
|||||||
|
|
||||||
against_jv: function(doc, cdt, cdn) {
|
against_jv: function(doc, cdt, cdn) {
|
||||||
var d = frappe.get_doc(cdt, cdn);
|
var d = frappe.get_doc(cdt, cdn);
|
||||||
if (d.against_jv && d.party && !flt(d.credit) && !flt(d.debit)) {
|
if (d.against_jv && !flt(d.credit) && !flt(d.debit)) {
|
||||||
this.get_outstanding('Journal Entry', d.against_jv, d);
|
this.get_outstanding('Journal Entry', d.against_jv, d);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -119,7 +119,8 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({
|
|||||||
var args = {
|
var args = {
|
||||||
"doctype": doctype,
|
"doctype": doctype,
|
||||||
"docname": docname,
|
"docname": docname,
|
||||||
"party": child.party
|
"party": child.party,
|
||||||
|
"account": child.account
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.frm.call({
|
return this.frm.call({
|
||||||
|
@ -545,12 +545,14 @@ def get_against_jv(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_outstanding(args):
|
def get_outstanding(args):
|
||||||
args = eval(args)
|
args = eval(args)
|
||||||
if args.get("doctype") == "Journal Entry" and args.get("party"):
|
if args.get("doctype") == "Journal Entry":
|
||||||
|
condition = " and party=%(party)s" if args.get("party") else ""
|
||||||
|
|
||||||
against_jv_amount = frappe.db.sql("""
|
against_jv_amount = frappe.db.sql("""
|
||||||
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||||
from `tabJournal Entry Account` where parent=%s and party=%s
|
from `tabJournal Entry Account` where parent=%(docname)s and account=%(account)s {0}
|
||||||
and ifnull(against_invoice, '')='' and ifnull(against_voucher, '')=''
|
and ifnull(against_invoice, '')='' and ifnull(against_voucher, '')=''
|
||||||
and ifnull(against_jv, '')=''""", (args['docname'], args['party']))
|
and ifnull(against_jv, '')=''""".format(condition), args)
|
||||||
|
|
||||||
against_jv_amount = flt(against_jv_amount[0][0]) if against_jv_amount else 0
|
against_jv_amount = flt(against_jv_amount[0][0]) if against_jv_amount else 0
|
||||||
if against_jv_amount > 0:
|
if against_jv_amount > 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user