feat: Journal Entry Template
This commit is contained in:
parent
d124581044
commit
7bbb77e66f
@ -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": "JE Template Account",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1
|
||||
}
|
@ -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 JETemplateAccount(Document):
|
||||
pass
|
@ -12,8 +12,10 @@ frappe.ui.form.on("Journal Entry", {
|
||||
|
||||
refresh: function(frm) {
|
||||
erpnext.toggle_naming_series();
|
||||
frm.cscript.voucher_type(frm.doc);
|
||||
|
||||
// frm.cscript.voucher_type(frm.doc);
|
||||
cur_frm.set_df_property("cheque_no", "reqd", frm.doc.voucher_type=="Bank Entry");
|
||||
cur_frm.set_df_property("cheque_date", "reqd", frm.doc.voucher_type=="Bank Entry");
|
||||
|
||||
if(frm.doc.docstatus==1) {
|
||||
frm.add_custom_button(__('Ledger'), function() {
|
||||
frappe.route_options = {
|
||||
@ -120,6 +122,32 @@ frappe.ui.form.on("Journal Entry", {
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
from_template: function(frm){
|
||||
var update_jv_details = function(doc, r) {
|
||||
frappe.model.clear_table(frm.doc, "accounts");
|
||||
$.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 (frm.doc.from_template){
|
||||
frappe.db.get_doc("Journal Entry Template", frm.doc.from_template)
|
||||
.then((doc) => {
|
||||
frm.set_value("company",doc.company);
|
||||
frm.set_value("voucher_type", doc.voucher_type);
|
||||
frm.set_value("naming_series", doc.je_naming_series);
|
||||
frm.set_value("is_opening", doc.is_opening);
|
||||
update_jv_details(frm.doc, doc.accounts);
|
||||
})
|
||||
.catch((err)=>{
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
{
|
||||
"actions": [],
|
||||
"allow_import": 1,
|
||||
"autoname": "naming_series:",
|
||||
"creation": "2013-03-25 10:53:52",
|
||||
@ -10,6 +11,7 @@
|
||||
"title",
|
||||
"voucher_type",
|
||||
"naming_series",
|
||||
"from_template",
|
||||
"column_break1",
|
||||
"posting_date",
|
||||
"company",
|
||||
@ -484,12 +486,19 @@
|
||||
"options": "Journal Entry",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "from_template",
|
||||
"fieldtype": "Link",
|
||||
"label": "From Template",
|
||||
"options": "Journal Entry Template"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-file-text",
|
||||
"idx": 176,
|
||||
"is_submittable": 1,
|
||||
"modified": "2020-01-16 13:05:30.634226",
|
||||
"links": [],
|
||||
"modified": "2020-04-25 02:02:04.017198",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Journal Entry",
|
||||
|
@ -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
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
// Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on("Journal Entry Template", {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
setup: function(frm) {
|
||||
frm.set_query("account" ,"accounts", () => {
|
||||
return {
|
||||
filters: {
|
||||
"company": frm.doc.company==undefined ? null: frm.doc.company,
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
onload_post_render: function(frm){
|
||||
// frm.get_field("accounts").grid.set_multiple_add("account");
|
||||
},
|
||||
all_accounts: function(frm) {
|
||||
frm.trigger("clear_child");
|
||||
},
|
||||
voucher_type: function(frm) {
|
||||
var add_accounts = function(doc, r) {
|
||||
$.each(r, function(i, d) {
|
||||
var row = frappe.model.add_child(doc, "JE Template Account", "accounts");
|
||||
row.account = d.account;
|
||||
});
|
||||
refresh_field("accounts");
|
||||
}
|
||||
frm.trigger("clear_child");
|
||||
switch(frm.doc.voucher_type){
|
||||
case "Opening Entry":
|
||||
if(frm.doc.company == undefined){
|
||||
frappe.throw("Please select Company!");
|
||||
}
|
||||
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) {
|
||||
add_accounts(frm.doc, [r.message]);
|
||||
}
|
||||
}
|
||||
})
|
||||
break;
|
||||
default:
|
||||
frm.trigger("clear_child");
|
||||
}
|
||||
},
|
||||
clear_child: function(frm){
|
||||
frappe.model.clear_table(frm.doc, "accounts");
|
||||
refresh_field("accounts");
|
||||
}
|
||||
});
|
@ -0,0 +1,114 @@
|
||||
{
|
||||
"actions": [],
|
||||
"autoname": "naming_series:",
|
||||
"creation": "2020-04-09 01:32:51.332301",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"section_break_1",
|
||||
"voucher_type",
|
||||
"company",
|
||||
"column_break_3",
|
||||
"je_naming_series",
|
||||
"is_opening",
|
||||
"section_break_2",
|
||||
"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,
|
||||
"label": "Company",
|
||||
"options": "Company",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_3",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"default": "ACC-JV-.YYYY.-",
|
||||
"fieldname": "je_naming_series",
|
||||
"fieldtype": "Data",
|
||||
"label": "Naming Series"
|
||||
},
|
||||
{
|
||||
"default": "No",
|
||||
"fieldname": "is_opening",
|
||||
"fieldtype": "Select",
|
||||
"label": "Is Opening",
|
||||
"options": "No\nYes"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_2",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "accounts",
|
||||
"fieldtype": "Table",
|
||||
"label": "Accounting Entries",
|
||||
"options": "JE Template Account"
|
||||
}
|
||||
],
|
||||
"links": [],
|
||||
"modified": "2020-04-25 02:14:35.185062",
|
||||
"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": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"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
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
# -*- 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
|
||||
from erpnext.accounts.utils import get_balance_on
|
||||
|
||||
class JournalEntryTemplate(Document):
|
||||
def autoname(self):
|
||||
self.name = self.voucher_type + ' - ' + frappe.get_value('Company', self.company, 'abbr')
|
||||
|
@ -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
|
Loading…
x
Reference in New Issue
Block a user