Payment against invoices where party not specified
Conflicts: erpnext/accounts/doctype/gl_entry/gl_entry.py
This commit is contained in:
parent
d387dd3bc6
commit
96bb070781
@ -4,7 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import flt, fmt_money, getdate, formatdate, cstr
|
from frappe.utils import flt, fmt_money, getdate, formatdate
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
@ -124,12 +124,18 @@ def check_freezing_date(posting_date, adv_adj=False):
|
|||||||
frappe.throw(_("You are not authorized to add or update entries before {0}").format(formatdate(acc_frozen_upto)))
|
frappe.throw(_("You are not authorized to add or update entries before {0}").format(formatdate(acc_frozen_upto)))
|
||||||
|
|
||||||
def update_outstanding_amt(account, party_type, party, against_voucher_type, against_voucher, on_cancel=False):
|
def update_outstanding_amt(account, party_type, party, against_voucher_type, against_voucher, on_cancel=False):
|
||||||
|
if party_type and party:
|
||||||
|
party_condition = " and ifnull(party_type, '')='{0}' and ifnull(party, '')='{1}'"\
|
||||||
|
.format(frappe.db.escape(party_type), frappe.db.escape(party))
|
||||||
|
else:
|
||||||
|
party_condition = ""
|
||||||
|
|
||||||
# get final outstanding amt
|
# get final outstanding amt
|
||||||
bal = flt(frappe.db.sql("""select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
bal = flt(frappe.db.sql("""select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||||
from `tabGL Entry`
|
from `tabGL Entry`
|
||||||
where against_voucher_type=%s and against_voucher=%s
|
where against_voucher_type=%s and against_voucher=%s
|
||||||
and account = %s and ifnull(party_type, '')=%s and ifnull(party, '')=%s""",
|
and account = %s {0}""".format(party_condition),
|
||||||
(against_voucher_type, against_voucher, account, party_type, party))[0][0] or 0.0)
|
(against_voucher_type, against_voucher, account))[0][0] or 0.0)
|
||||||
|
|
||||||
if against_voucher_type == 'Purchase Invoice':
|
if against_voucher_type == 'Purchase Invoice':
|
||||||
bal = -bal
|
bal = -bal
|
||||||
@ -137,9 +143,8 @@ def update_outstanding_amt(account, party_type, party, against_voucher_type, aga
|
|||||||
against_voucher_amount = flt(frappe.db.sql("""
|
against_voucher_amount = flt(frappe.db.sql("""
|
||||||
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||||
from `tabGL Entry` where voucher_type = 'Journal Entry' and voucher_no = %s
|
from `tabGL Entry` where voucher_type = 'Journal Entry' and voucher_no = %s
|
||||||
and account = %s and ifnull(party_type, '')=%s and ifnull(party, '')=%s
|
and account = %s and ifnull(against_voucher, '') = '' {0}"""
|
||||||
and ifnull(against_voucher, '') = ''""",
|
.format(party_condition), (against_voucher, account))[0][0])
|
||||||
(against_voucher, account, cstr(party_type), cstr(party)))[0][0])
|
|
||||||
|
|
||||||
if not against_voucher_amount:
|
if not against_voucher_amount:
|
||||||
frappe.throw(_("Against Journal Entry {0} is already adjusted against some other voucher")
|
frappe.throw(_("Against Journal Entry {0} is already adjusted against some other voucher")
|
||||||
|
@ -59,7 +59,6 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({
|
|||||||
// journal entry
|
// journal entry
|
||||||
if(jvd.reference_type==="Journal Entry") {
|
if(jvd.reference_type==="Journal Entry") {
|
||||||
frappe.model.validate_missing(jvd, "account");
|
frappe.model.validate_missing(jvd, "account");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
query: "erpnext.accounts.doctype.journal_entry.journal_entry.get_against_jv",
|
query: "erpnext.accounts.doctype.journal_entry.journal_entry.get_against_jv",
|
||||||
filters: {
|
filters: {
|
||||||
@ -69,24 +68,33 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// against party
|
|
||||||
|
|
||||||
frappe.model.validate_missing(jvd, "party_type");
|
|
||||||
frappe.model.validate_missing(jvd, "party");
|
|
||||||
|
|
||||||
var out = {
|
var out = {
|
||||||
filters: [
|
filters: [
|
||||||
[jvd.reference_type, jvd.reference_type.indexOf("Sales")===0 ? "customer" : "supplier", "=", jvd.party],
|
[jvd.reference_type, "docstatus", "=", 1]
|
||||||
[jvd.reference_type, "docstatus", "=", 1],
|
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
if(in_list(["Sales Invoice", "Purchase Invoice"], jvd.reference_type)) {
|
if(in_list(["Sales Invoice", "Purchase Invoice"], jvd.reference_type)) {
|
||||||
out.filters.push([jvd.reference_type, "outstanding_amount", "!=", 0]);
|
out.filters.push([jvd.reference_type, "outstanding_amount", "!=", 0]);
|
||||||
|
|
||||||
|
// account filter
|
||||||
|
frappe.model.validate_missing(jvd, "account");
|
||||||
|
|
||||||
|
party_account_field = jvd.reference_type==="Sales Invoice" ? "debit_to": "credit_to";
|
||||||
|
out.filters.push([jvd.reference_type, party_account_field, "=", jvd.account]);
|
||||||
} else {
|
} else {
|
||||||
|
// party_type and party mandatory
|
||||||
|
frappe.model.validate_missing(jvd, "party_type");
|
||||||
|
frappe.model.validate_missing(jvd, "party");
|
||||||
|
|
||||||
out.filters.push([jvd.reference_type, "per_billed", "<", 100]);
|
out.filters.push([jvd.reference_type, "per_billed", "<", 100]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(jvd.party_type && jvd.party) {
|
||||||
|
out.filters.push([jvd.reference_type,
|
||||||
|
(jvd.reference_type.indexOf("Sales")===0 ? "customer" : "supplier"), "=", jvd.party]);
|
||||||
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user