From c7e3a09cfb55ed41cde3c6deafa1cf2b92c2de3d Mon Sep 17 00:00:00 2001 From: tunde Date: Wed, 28 Jun 2017 13:05:40 +0100 Subject: [PATCH 1/3] adds if statement for `reference_type` === "Asset" --- erpnext/accounts/doctype/journal_entry/journal_entry.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index 4880224c24..65f5230c58 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -125,7 +125,11 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ var 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 if(jvd.reference_type === 'Asset'){ + frappe.model.validate_missing(jvd, "account"); + } + else { // party_type and party mandatory frappe.model.validate_missing(jvd, "party_type"); frappe.model.validate_missing(jvd, "party"); From 1ee534889f736f6c98d20dcbf572142fbc53a06f Mon Sep 17 00:00:00 2001 From: tunde Date: Mon, 17 Jul 2017 13:27:59 +0100 Subject: [PATCH 2/3] Revert "adds if statement for `reference_type` === "Asset"" This reverts commit c7e3a09cfb55ed41cde3c6deafa1cf2b92c2de3d. --- erpnext/accounts/doctype/journal_entry/journal_entry.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index 65f5230c58..4880224c24 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -125,11 +125,7 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ var party_account_field = jvd.reference_type==="Sales Invoice" ? "debit_to": "credit_to"; out.filters.push([jvd.reference_type, party_account_field, "=", jvd.account]); - } - else if(jvd.reference_type === 'Asset'){ - frappe.model.validate_missing(jvd, "account"); - } - else { + } else { // party_type and party mandatory frappe.model.validate_missing(jvd, "party_type"); frappe.model.validate_missing(jvd, "party"); From 78d2f542d0db6398a53f216ebc30c7bc1d01f747 Mon Sep 17 00:00:00 2001 From: tunde Date: Mon, 17 Jul 2017 15:00:45 +0100 Subject: [PATCH 3/3] code fix as per review --- erpnext/accounts/doctype/journal_entry/journal_entry.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index 4880224c24..5dc3ba4080 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -122,10 +122,11 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ // account filter frappe.model.validate_missing(jvd, "account"); - var party_account_field = jvd.reference_type==="Sales Invoice" ? "debit_to": "credit_to"; out.filters.push([jvd.reference_type, party_account_field, "=", jvd.account]); - } else { + } + + if(in_list(["Sales Order", "Purchase Order"], jvd.reference_type)) { // party_type and party mandatory frappe.model.validate_missing(jvd, "party_type"); frappe.model.validate_missing(jvd, "party");