mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
chart of account fixes, added delete, rename
This commit is contained in:
@@ -23,6 +23,11 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
// Refresh
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
if(doc.__islocal) {
|
||||
msgprint("Please create new account from Chart of Accounts.");
|
||||
throw "cannot create";
|
||||
}
|
||||
|
||||
cur_frm.toggle_display('account_name', doc.__islocal);
|
||||
|
||||
// hide fields if group
|
||||
@@ -34,7 +39,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
'is_pl_account', 'company'], false);
|
||||
|
||||
// read-only for root accounts
|
||||
root_acc = ['Application of Funds (Assets)','Expenses','Income','Source of Funds (Liabilities)'];
|
||||
root_acc = doc.parent ? false : true;
|
||||
if(in_list(root_acc, doc.account_name)) {
|
||||
cur_frm.perm = [[1,0,0], [1,0,0]];
|
||||
cur_frm.set_intro("This is a root account and cannot be edited.");
|
||||
@@ -48,7 +53,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.account_type(doc, cdt, cdn);
|
||||
|
||||
// show / hide convert buttons
|
||||
cur_frm.cscript.hide_unhide_group_ledger(doc);
|
||||
cur_frm.cscript.add_toolbar_buttons(doc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +81,10 @@ cur_frm.cscript.account_type = function(doc, cdt, cdn) {
|
||||
|
||||
// Hide/unhide group or ledger
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.hide_unhide_group_ledger = function(doc) {
|
||||
cur_frm.cscript.add_toolbar_buttons = function(doc) {
|
||||
cur_frm.add_custom_button('Chart of Accounts',
|
||||
function() { wn.set_route("Accounts Browser", "Account"); }, 'icon-list')
|
||||
|
||||
if (cstr(doc.group_or_ledger) == 'Group') {
|
||||
cur_frm.add_custom_button('Convert to Ledger',
|
||||
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet')
|
||||
|
||||
@@ -61,10 +61,13 @@ class DocType:
|
||||
elif par and not self.doc.is_pl_account:
|
||||
self.doc.is_pl_account = par[0][2]
|
||||
self.doc.debit_or_credit = par[0][3]
|
||||
elif self.doc.account_name not in ['Income','Source of Funds (Liabilities)',\
|
||||
'Expenses','Application of Funds (Assets)']:
|
||||
msgprint("Parent Account is mandatory", raise_exception=1)
|
||||
|
||||
def validate_max_root_accounts(self):
|
||||
if webnotes.conn.sql("""select count(*) from tabAccount where
|
||||
company=%s and ifnull(parent_account,'')='' and docstatus != 2""",
|
||||
self.doc.company)[0][0] > 4:
|
||||
webnotes.msgprint("One company cannot have more than 4 root Accounts",
|
||||
raise_exception=1)
|
||||
|
||||
# Account name must be unique
|
||||
def validate_duplicate_account(self):
|
||||
@@ -74,21 +77,10 @@ class DocType:
|
||||
|
||||
def validate_root_details(self):
|
||||
#does not exists parent
|
||||
if self.doc.account_name in ['Income','Source of Funds', 'Expenses','Application of Funds'] and self.doc.parent_account:
|
||||
msgprint("You can not assign parent for root account", raise_exception=1)
|
||||
|
||||
# Debit / Credit
|
||||
if self.doc.account_name in ['Income','Source of Funds']:
|
||||
self.doc.debit_or_credit = 'Credit'
|
||||
elif self.doc.account_name in ['Expenses','Application of Funds']:
|
||||
self.doc.debit_or_credit = 'Debit'
|
||||
|
||||
# Is PL Account
|
||||
if self.doc.account_name in ['Income','Expenses']:
|
||||
self.doc.is_pl_account = 'Yes'
|
||||
elif self.doc.account_name in ['Source of Funds','Application of Funds']:
|
||||
self.doc.is_pl_account = 'No'
|
||||
|
||||
if webnotes.conn.exists("Account", self.doc.name):
|
||||
if not self.doc.get_value("Account", self.doc.name, "parent_account"):
|
||||
webnotes.msgprint("Root cannot be edited.", raise_exception=1)
|
||||
|
||||
def convert_group_to_ledger(self):
|
||||
if self.check_if_child_exists():
|
||||
msgprint("Account: %s has existing child. You can not convert this account to ledger" % (self.doc.name), raise_exception=1)
|
||||
@@ -144,6 +136,7 @@ class DocType:
|
||||
|
||||
def on_update(self):
|
||||
# update nsm
|
||||
self.validate_max_root_accounts()
|
||||
self.update_nsm_model()
|
||||
|
||||
# Check user role for approval process
|
||||
|
||||
Reference in New Issue
Block a user