[fix] journal entry get_query

This commit is contained in:
Rushabh Mehta 2015-08-12 14:33:46 +05:30
parent 3131c732ff
commit 207b3efed7
3 changed files with 17 additions and 9 deletions

View File

@ -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");
return {
var out = {
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, "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;
});

View File

@ -118,7 +118,7 @@ class JournalEntry(AccountsController):
def validate_against_jv(self):
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")
if account_root_type == "Asset" and flt(d.debit) > 0:
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`
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)
if not against_entries:
@ -163,8 +163,8 @@ class JournalEntry(AccountsController):
for d in self.get("accounts"):
if not d.reference_type:
d.reference_name = None
if not d.reference_type:
d.reference_name = None
if not d.reference_name:
d.reference_type = None
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") \
else "debit"

View File

@ -2,10 +2,10 @@ import frappe
def execute():
for doctype, fieldname in (
("Sales Invoice", "against_invoice"),
("Purchase Invoice", "against_voucher"),
("Sales Order", "against_sales_order"),
("Purchase Order", "against_purchase_order"),
("Sales Invoice", "against_invoice"),
("Purchase Invoice", "against_voucher"),
("Journal Entry", "against_jv"),
("Expense Claim", "against_expense_claim"),
):