From 978de8779ce0dd03a5b60f6ed0fbe2d851f741cc Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 1 May 2020 18:38:13 +0530 Subject: [PATCH] fix: Add multi currency check and proper account filters --- .../doctype/journal_entry/journal_entry.js | 3 ++- .../journal_entry_template.js | 17 +++++++++++++---- .../journal_entry_template.json | 9 ++++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index ccfdfceadb3..9a832e3c1fe 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -173,7 +173,8 @@ frappe.ui.form.on("Journal Entry", { "company": doc.company, "voucher_type": doc.voucher_type, "naming_series": doc.naming_series, - "is_opening": doc.is_opening + "is_opening": doc.is_opening, + "multi_currency": doc.multi_currency }) update_jv_details(frm.doc, doc.accounts); }); diff --git a/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.js b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.js index bcb3f3a0be7..cbb9fc4b0f9 100644 --- a/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.js +++ b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.js @@ -4,13 +4,22 @@ frappe.ui.form.on("Journal Entry Template", { setup: function(frm) { frappe.model.set_default_values(frm.doc); + frm.set_query("account" ,"accounts", function(){ - return { - filters: { - "company": frm.doc.company, - } + var filters = { + company: frm.doc.company, + is_group: 0 }; + + if(!frm.doc.multi_currency) { + $.extend(filters, { + account_currency: frappe.get_doc(":Company", frm.doc.company).default_currency + }); + } + + return { filters: filters }; }); + frappe.call({ type: "GET", method: "erpnext.accounts.doctype.journal_entry_template.journal_entry_template.get_naming_series", diff --git a/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.json b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.json index c411401a3f7..660ae85cef3 100644 --- a/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.json +++ b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.json @@ -14,6 +14,7 @@ "column_break_3", "company", "is_opening", + "multi_currency", "section_break_3", "accounts" ], @@ -76,10 +77,16 @@ { "fieldname": "section_break_3", "fieldtype": "Section Break" + }, + { + "default": "0", + "fieldname": "multi_currency", + "fieldtype": "Check", + "label": "Multi Currency" } ], "links": [], - "modified": "2020-04-29 10:52:33.526433", + "modified": "2020-05-01 18:32:01.420488", "modified_by": "Administrator", "module": "Accounts", "name": "Journal Entry Template",