diff --git a/erpnext/accounts/desk_page/accounting/accounting.json b/erpnext/accounts/desk_page/accounting/accounting.json index 8a9a7c58d2c..0d6aca65b16 100644 --- a/erpnext/accounts/desk_page/accounting/accounting.json +++ b/erpnext/accounts/desk_page/accounting/accounting.json @@ -8,7 +8,7 @@ { "hidden": 0, "label": "General Ledger", - "links": "[\n {\n \"description\": \"Accounting journal entries.\",\n \"label\": \"Journal Entry\",\n \"name\": \"Journal Entry\",\n \"type\": \"doctype\"\n },\n {\n \"dependencies\": [\n \"GL Entry\"\n ],\n \"doctype\": \"GL Entry\",\n \"is_query_report\": true,\n \"label\": \"General Ledger\",\n \"name\": \"General Ledger\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Sales Invoice\"\n ],\n \"doctype\": \"Sales Invoice\",\n \"is_query_report\": true,\n \"label\": \"Customer Ledger Summary\",\n \"name\": \"Customer Ledger Summary\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Sales Invoice\"\n ],\n \"doctype\": \"Sales Invoice\",\n \"is_query_report\": true,\n \"label\": \"Supplier Ledger Summary\",\n \"name\": \"Supplier Ledger Summary\",\n \"type\": \"report\"\n }\n]" + "links": "[\n {\n \"description\": \"Accounting journal entries.\",\n \"label\": \"Journal Entry\",\n \"name\": \"Journal Entry\",\n \"type\": \"doctype\"\n },\n {\n \"description\": \"Make journal entries from a template.\",\n \"label\": \"Journal Entry Template\",\n \"name\": \"Journal Entry Template\",\n \"type\": \"doctype\"\n },\n \n {\n \"dependencies\": [\n \"GL Entry\"\n ],\n \"doctype\": \"GL Entry\",\n \"is_query_report\": true,\n \"label\": \"General Ledger\",\n \"name\": \"General Ledger\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Sales Invoice\"\n ],\n \"doctype\": \"Sales Invoice\",\n \"is_query_report\": true,\n \"label\": \"Customer Ledger Summary\",\n \"name\": \"Customer Ledger Summary\",\n \"type\": \"report\"\n },\n {\n \"dependencies\": [\n \"Sales Invoice\"\n ],\n \"doctype\": \"Sales Invoice\",\n \"is_query_report\": true,\n \"label\": \"Supplier Ledger Summary\",\n \"name\": \"Supplier Ledger Summary\",\n \"type\": \"report\"\n }\n]" }, { "hidden": 0, @@ -103,7 +103,7 @@ "idx": 0, "is_standard": 1, "label": "Accounting", - "modified": "2020-04-01 11:28:50.925719", + "modified": "2020-04-29 12:17:34.844397", "modified_by": "Administrator", "module": "Accounts", "name": "Accounting", diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index 3604b60b751..9a832e3c1fe 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -12,7 +12,6 @@ frappe.ui.form.on("Journal Entry", { refresh: function(frm) { erpnext.toggle_naming_series(); - frm.cscript.voucher_type(frm.doc); if(frm.doc.docstatus==1) { frm.add_custom_button(__('Ledger'), function() { @@ -120,9 +119,78 @@ frappe.ui.form.on("Journal Entry", { } } }); + }, + + voucher_type: function(frm){ + + if(!frm.doc.company) return null; + + if((!(frm.doc.accounts || []).length) || ((frm.doc.accounts || []).length === 1 && !frm.doc.accounts[0].account)) { + if(in_list(["Bank Entry", "Cash Entry"], frm.doc.voucher_type)) { + return frappe.call({ + type: "GET", + method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_default_bank_cash_account", + args: { + "account_type": (frm.doc.voucher_type=="Bank Entry" ? + "Bank" : (frm.doc.voucher_type=="Cash Entry" ? "Cash" : null)), + "company": frm.doc.company + }, + callback: function(r) { + if(r.message) { + // If default company bank account not set + if(!$.isEmptyObject(r.message)){ + update_jv_details(frm.doc, [r.message]); + } + } + } + }); + } + else if(frm.doc.voucher_type=="Opening Entry") { + return frappe.call({ + type:"GET", + method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_opening_accounts", + args: { + "company": frm.doc.company + }, + callback: function(r) { + frappe.model.clear_table(frm.doc, "accounts"); + if(r.message) { + update_jv_details(frm.doc, r.message); + } + cur_frm.set_value("is_opening", "Yes"); + } + }); + } + } + }, + + from_template: function(frm){ + if (frm.doc.from_template){ + frappe.db.get_doc("Journal Entry Template", frm.doc.from_template) + .then((doc) => { + frappe.model.clear_table(frm.doc, "accounts"); + frm.set_value({ + "company": doc.company, + "voucher_type": doc.voucher_type, + "naming_series": doc.naming_series, + "is_opening": doc.is_opening, + "multi_currency": doc.multi_currency + }) + update_jv_details(frm.doc, doc.accounts); + }); + } } }); +var update_jv_details = function(doc, r) { + $.each(r, function(i, d) { + var row = frappe.model.add_child(doc, "Journal Entry Account", "accounts"); + row.account = d.account; + row.balance = d.balance; + }); + refresh_field("accounts"); +} + erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ onload: function() { this.load_defaults(); @@ -375,56 +443,6 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){ cur_frm.pformat.print_heading = __("Journal Entry"); } -cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { - cur_frm.set_df_property("cheque_no", "reqd", doc.voucher_type=="Bank Entry"); - cur_frm.set_df_property("cheque_date", "reqd", doc.voucher_type=="Bank Entry"); - - if(!doc.company) return; - - var update_jv_details = function(doc, r) { - $.each(r, function(i, d) { - var row = frappe.model.add_child(doc, "Journal Entry Account", "accounts"); - row.account = d.account; - row.balance = d.balance; - }); - refresh_field("accounts"); - } - - if((!(doc.accounts || []).length) || ((doc.accounts || []).length==1 && !doc.accounts[0].account)) { - if(in_list(["Bank Entry", "Cash Entry"], doc.voucher_type)) { - return frappe.call({ - type: "GET", - method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_default_bank_cash_account", - args: { - "account_type": (doc.voucher_type=="Bank Entry" ? - "Bank" : (doc.voucher_type=="Cash Entry" ? "Cash" : null)), - "company": doc.company - }, - callback: function(r) { - if(r.message) { - update_jv_details(doc, [r.message]); - } - } - }) - } else if(doc.voucher_type=="Opening Entry") { - return frappe.call({ - type:"GET", - method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_opening_accounts", - args: { - "company": doc.company - }, - callback: function(r) { - frappe.model.clear_table(doc, "accounts"); - if(r.message) { - update_jv_details(doc, r.message); - } - cur_frm.set_value("is_opening", "Yes") - } - }) - } - } -} - frappe.ui.form.on("Journal Entry Account", { party: function(frm, cdt, cdn) { var d = frappe.get_doc(cdt, cdn); diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.json b/erpnext/accounts/doctype/journal_entry/journal_entry.json index f5991241a72..9d5063929fd 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.json +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.json @@ -1,4 +1,5 @@ { + "actions": [], "allow_import": 1, "autoname": "naming_series:", "creation": "2013-03-25 10:53:52", @@ -10,10 +11,11 @@ "title", "voucher_type", "naming_series", - "column_break1", - "posting_date", - "company", "finance_book", + "column_break1", + "from_template", + "company", + "posting_date", "2_add_edit_gl_entries", "accounts", "section_break99", @@ -157,6 +159,7 @@ "in_global_search": 1, "in_list_view": 1, "label": "Reference Number", + "mandatory_depends_on": "eval:doc.voucher_type == \"Bank Entry\"", "no_copy": 1, "oldfieldname": "cheque_no", "oldfieldtype": "Data", @@ -166,6 +169,7 @@ "fieldname": "cheque_date", "fieldtype": "Date", "label": "Reference Date", + "mandatory_depends_on": "eval:doc.voucher_type == \"Bank Entry\"", "no_copy": 1, "oldfieldname": "cheque_date", "oldfieldtype": "Date", @@ -484,12 +488,22 @@ "options": "Journal Entry", "print_hide": 1, "read_only": 1 + }, + { + "fieldname": "from_template", + "fieldtype": "Link", + "label": "From Template", + "no_copy": 1, + "options": "Journal Entry Template", + "print_hide": 1, + "report_hide": 1 } ], "icon": "fa fa-file-text", "idx": 176, "is_submittable": 1, - "modified": "2020-01-16 13:05:30.634226", + "links": [], + "modified": "2020-04-29 10:55:28.240916", "modified_by": "Administrator", "module": "Accounts", "name": "Journal Entry", diff --git a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json index 9552e60a857..26c84a6398c 100644 --- a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json +++ b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json @@ -1,4 +1,5 @@ { + "actions": [], "autoname": "hash", "creation": "2013-02-22 01:27:39", "doctype": "DocType", @@ -271,7 +272,8 @@ ], "idx": 1, "istable": 1, - "modified": "2020-01-13 12:41:33.968025", + "links": [], + "modified": "2020-04-25 01:47:49.060128", "modified_by": "Administrator", "module": "Accounts", "name": "Journal Entry Account", @@ -280,4 +282,4 @@ "sort_field": "modified", "sort_order": "DESC", "track_changes": 1 -} +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/journal_entry_template/__init__.py b/erpnext/accounts/doctype/journal_entry_template/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.js b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.js new file mode 100644 index 00000000000..cbb9fc4b0f9 --- /dev/null +++ b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.js @@ -0,0 +1,91 @@ +// Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ui.form.on("Journal Entry Template", { + setup: function(frm) { + frappe.model.set_default_values(frm.doc); + + frm.set_query("account" ,"accounts", function(){ + 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", + callback: function(r){ + if(r.message){ + frm.set_df_property("naming_series", "options", r.message.split("\n")); + frm.set_value("naming_series", r.message.split("\n")[0]); + frm.refresh_field("naming_series"); + } + } + }); + }, + voucher_type: function(frm) { + var add_accounts = function(doc, r) { + $.each(r, function(i, d) { + var row = frappe.model.add_child(doc, "Journal Entry Template Account", "accounts"); + row.account = d.account; + }); + refresh_field("accounts"); + }; + + if(!frm.doc.company) return; + + frm.trigger("clear_child"); + switch(frm.doc.voucher_type){ + case "Opening Entry": + frm.set_value("is_opening", "Yes"); + frappe.call({ + type:"GET", + method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_opening_accounts", + args: { + "company": frm.doc.company + }, + callback: function(r) { + if(r.message) { + add_accounts(frm.doc, r.message); + } + } + }); + break; + case "Bank Entry": + case "Cash Entry": + frappe.call({ + type: "GET", + method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_default_bank_cash_account", + args: { + "account_type": (frm.doc.voucher_type=="Bank Entry" ? + "Bank" : (frm.doc.voucher_type=="Cash Entry" ? "Cash" : null)), + "company": frm.doc.company + }, + callback: function(r) { + if(r.message) { + // If default company bank account not set + if(!$.isEmptyObject(r.message)){ + add_accounts(frm.doc, [r.message]); + } + } + } + }); + break; + default: + frm.trigger("clear_child"); + } + }, + clear_child: function(frm){ + frappe.model.clear_table(frm.doc, "accounts"); + frm.refresh_field("accounts"); + } +}); \ No newline at end of file diff --git a/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.json b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.json new file mode 100644 index 00000000000..660ae85cef3 --- /dev/null +++ b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.json @@ -0,0 +1,134 @@ +{ + "actions": [], + "autoname": "field:template_title", + "creation": "2020-04-09 01:32:51.332301", + "doctype": "DocType", + "document_type": "Document", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "section_break_1", + "template_title", + "voucher_type", + "naming_series", + "column_break_3", + "company", + "is_opening", + "multi_currency", + "section_break_3", + "accounts" + ], + "fields": [ + { + "fieldname": "section_break_1", + "fieldtype": "Section Break" + }, + { + "fieldname": "voucher_type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Journal Entry Type", + "options": "Journal Entry\nInter Company Journal Entry\nBank Entry\nCash Entry\nCredit Card Entry\nDebit Note\nCredit Note\nContra Entry\nExcise Entry\nWrite Off Entry\nOpening Entry\nDepreciation Entry\nExchange Rate Revaluation", + "reqd": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Company", + "options": "Company", + "remember_last_selected_value": 1, + "reqd": 1 + }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break" + }, + { + "default": "No", + "fieldname": "is_opening", + "fieldtype": "Select", + "label": "Is Opening", + "options": "No\nYes" + }, + { + "fieldname": "accounts", + "fieldtype": "Table", + "label": "Accounting Entries", + "options": "Journal Entry Template Account" + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "print_hide": 1, + "reqd": 1, + "set_only_once": 1 + }, + { + "fieldname": "template_title", + "fieldtype": "Data", + "label": "Template Title", + "reqd": 1, + "unique": 1 + }, + { + "fieldname": "section_break_3", + "fieldtype": "Section Break" + }, + { + "default": "0", + "fieldname": "multi_currency", + "fieldtype": "Check", + "label": "Multi Currency" + } + ], + "links": [], + "modified": "2020-05-01 18:32:01.420488", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Journal Entry Template", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "share": 1, + "write": 1 + }, + { + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Auditor", + "share": 1 + } + ], + "search_fields": "voucher_type, company", + "sort_field": "modified", + "sort_order": "DESC", + "title_field": "template_title", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.py b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.py new file mode 100644 index 00000000000..e0b9cbc9193 --- /dev/null +++ b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe.model.document import Document + +class JournalEntryTemplate(Document): + pass + +@frappe.whitelist() +def get_naming_series(): + return frappe.get_meta("Journal Entry").get_field("naming_series").options diff --git a/erpnext/accounts/doctype/journal_entry_template/test_journal_entry_template.py b/erpnext/accounts/doctype/journal_entry_template/test_journal_entry_template.py new file mode 100644 index 00000000000..5f74a2042fd --- /dev/null +++ b/erpnext/accounts/doctype/journal_entry_template/test_journal_entry_template.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +# import frappe +import unittest + +class TestJournalEntryTemplate(unittest.TestCase): + pass diff --git a/erpnext/accounts/doctype/journal_entry_template_account/__init__.py b/erpnext/accounts/doctype/journal_entry_template_account/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/accounts/doctype/journal_entry_template_account/journal_entry_template_account.json b/erpnext/accounts/doctype/journal_entry_template_account/journal_entry_template_account.json new file mode 100644 index 00000000000..eecd87727d4 --- /dev/null +++ b/erpnext/accounts/doctype/journal_entry_template_account/journal_entry_template_account.json @@ -0,0 +1,31 @@ +{ + "actions": [], + "creation": "2020-04-09 01:48:42.783620", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "account" + ], + "fields": [ + { + "fieldname": "account", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Account", + "options": "Account", + "reqd": 1 + } + ], + "istable": 1, + "links": [], + "modified": "2020-04-25 01:15:44.879839", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Journal Entry Template Account", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/journal_entry_template_account/journal_entry_template_account.py b/erpnext/accounts/doctype/journal_entry_template_account/journal_entry_template_account.py new file mode 100644 index 00000000000..48e6abbc284 --- /dev/null +++ b/erpnext/accounts/doctype/journal_entry_template_account/journal_entry_template_account.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +# import frappe +from frappe.model.document import Document + +class JournalEntryTemplateAccount(Document): + pass diff --git a/erpnext/projects/doctype/project_template/project_template.json b/erpnext/projects/doctype/project_template/project_template.json index 8352995face..445ad9f2386 100644 --- a/erpnext/projects/doctype/project_template/project_template.json +++ b/erpnext/projects/doctype/project_template/project_template.json @@ -1,130 +1,52 @@ { - "allow_copy": 0, - "allow_events_in_timeline": 0, - "allow_guest_to_view": 0, - "allow_import": 0, - "allow_rename": 0, + "actions": [], "autoname": "Prompt", - "beta": 0, "creation": "2019-02-18 17:23:11.708371", - "custom": 0, - "docstatus": 0, "doctype": "DocType", - "document_type": "", "editable_grid": 1, "engine": "InnoDB", + "field_order": [ + "project_type", + "tasks" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "project_type", "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, "in_list_view": 1, - "in_standard_filter": 0, "label": "Project Type", - "length": 0, - "no_copy": 0, - "options": "Project Type", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "options": "Project Type" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "tasks", "fieldtype": "Table", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Tasks", - "length": 0, - "no_copy": 0, "options": "Project Template Task", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "reqd": 1 } ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2019-02-18 18:01:26.519832", + "links": [], + "modified": "2020-04-26 02:23:53.990322", "modified_by": "Administrator", "module": "Projects", "name": "Project Template", - "name_case": "", "owner": "Administrator", "permissions": [ { - "amend": 0, - "cancel": 0, "create": 1, "delete": 1, "email": 1, "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, "print": 1, "read": 1, "report": 1, "role": "System Manager", - "set_user_permissions": 0, "share": 1, - "submit": 0, "write": 1 } ], "quick_entry": 1, - "read_only": 0, - "read_only_onload": 0, - "show_name_in_global_search": 0, "sort_field": "modified", "sort_order": "DESC", - "track_changes": 1, - "track_seen": 0, - "track_views": 0 + "track_changes": 1 } \ No newline at end of file