[fix] journal entry get_query
This commit is contained in:
parent
3131c732ff
commit
207b3efed7
@ -77,13 +77,21 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({
|
|||||||
|
|
||||||
frappe.model.validate_missing(jvd, "party_type");
|
frappe.model.validate_missing(jvd, "party_type");
|
||||||
frappe.model.validate_missing(jvd, "party");
|
frappe.model.validate_missing(jvd, "party");
|
||||||
return {
|
|
||||||
|
var out = {
|
||||||
filters: [
|
filters: [
|
||||||
[jvd.reference_type, jvd.reference_type.indexOf("Sales")==1 ? "customer" : "supplier", "=", jvd.party],
|
[jvd.reference_type, jvd.reference_type.indexOf("Sales")===0 ? "customer" : "supplier", "=", jvd.party],
|
||||||
[jvd.reference_type, "docstatus", "=", 1],
|
[jvd.reference_type, "docstatus", "=", 1],
|
||||||
[jvd.reference_type, "outstanding_amount", "!=", 0]
|
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(in_list(["Sales Invoice", "Purchase Invoice"], jvd.reference_type)) {
|
||||||
|
out.filters.push([jvd.reference_type, "outstanding_amount", "!=", 0]);
|
||||||
|
} else {
|
||||||
|
out.filters.push([jvd.reference_type, "per_billed", "<", 100]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -118,7 +118,7 @@ class JournalEntry(AccountsController):
|
|||||||
|
|
||||||
def validate_against_jv(self):
|
def validate_against_jv(self):
|
||||||
for d in self.get('accounts'):
|
for d in self.get('accounts'):
|
||||||
if d.reference_type=="Journal Voucher":
|
if d.reference_type=="Journal Entry":
|
||||||
account_root_type = frappe.db.get_value("Account", d.account, "root_type")
|
account_root_type = frappe.db.get_value("Account", d.account, "root_type")
|
||||||
if account_root_type == "Asset" and flt(d.debit) > 0:
|
if account_root_type == "Asset" and flt(d.debit) > 0:
|
||||||
frappe.throw(_("For {0}, only credit accounts can be linked against another debit entry")
|
frappe.throw(_("For {0}, only credit accounts can be linked against another debit entry")
|
||||||
@ -132,7 +132,7 @@ class JournalEntry(AccountsController):
|
|||||||
|
|
||||||
against_entries = frappe.db.sql("""select * from `tabJournal Entry Account`
|
against_entries = frappe.db.sql("""select * from `tabJournal Entry Account`
|
||||||
where account = %s and docstatus = 1 and parent = %s
|
where account = %s and docstatus = 1 and parent = %s
|
||||||
and ifnull(reference_type, '') = '' and ifnull(reference_name, '') = ''
|
and ifnull(reference_type, '') in ("", "Sales Order", "Purchase Order")
|
||||||
""", (d.account, d.reference_name), as_dict=True)
|
""", (d.account, d.reference_name), as_dict=True)
|
||||||
|
|
||||||
if not against_entries:
|
if not against_entries:
|
||||||
@ -163,8 +163,8 @@ class JournalEntry(AccountsController):
|
|||||||
for d in self.get("accounts"):
|
for d in self.get("accounts"):
|
||||||
if not d.reference_type:
|
if not d.reference_type:
|
||||||
d.reference_name = None
|
d.reference_name = None
|
||||||
if not d.reference_type:
|
if not d.reference_name:
|
||||||
d.reference_name = None
|
d.reference_type = None
|
||||||
if d.reference_type and d.reference_name and (d.reference_type in field_dict.keys()):
|
if d.reference_type and d.reference_name and (d.reference_type in field_dict.keys()):
|
||||||
dr_or_cr = "credit" if d.reference_type in ("Sales Order", "Sales Invoice") \
|
dr_or_cr = "credit" if d.reference_type in ("Sales Order", "Sales Invoice") \
|
||||||
else "debit"
|
else "debit"
|
||||||
|
|||||||
@ -2,10 +2,10 @@ import frappe
|
|||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
for doctype, fieldname in (
|
for doctype, fieldname in (
|
||||||
("Sales Invoice", "against_invoice"),
|
|
||||||
("Purchase Invoice", "against_voucher"),
|
|
||||||
("Sales Order", "against_sales_order"),
|
("Sales Order", "against_sales_order"),
|
||||||
("Purchase Order", "against_purchase_order"),
|
("Purchase Order", "against_purchase_order"),
|
||||||
|
("Sales Invoice", "against_invoice"),
|
||||||
|
("Purchase Invoice", "against_voucher"),
|
||||||
("Journal Entry", "against_jv"),
|
("Journal Entry", "against_jv"),
|
||||||
("Expense Claim", "against_expense_claim"),
|
("Expense Claim", "against_expense_claim"),
|
||||||
):
|
):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user