Validate Bank name in Setup wizard on the same slide (#12968)
* validate bank name before moving on to next slide * Update setup_wizard.js
This commit is contained in:
parent
1e0ae07bff
commit
441a1e1b8a
@ -175,4 +175,22 @@ def build_account_tree(tree, parent, all_accounts):
|
|||||||
tree[child.account_name]["root_type"] = child.root_type
|
tree[child.account_name]["root_type"] = child.root_type
|
||||||
|
|
||||||
# call recursively to build a subtree for current account
|
# call recursively to build a subtree for current account
|
||||||
build_account_tree(tree[child.account_name], child, all_accounts)
|
build_account_tree(tree[child.account_name], child, all_accounts)
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def validate_bank_account(coa, bank_account):
|
||||||
|
accounts = []
|
||||||
|
chart = get_chart(coa)
|
||||||
|
|
||||||
|
if chart:
|
||||||
|
def _get_account_names(account_master):
|
||||||
|
for account_name, child in account_master.items():
|
||||||
|
if account_name not in ["account_number", "account_type",
|
||||||
|
"root_type", "is_group", "tax_rate"]:
|
||||||
|
accounts.append(account_name)
|
||||||
|
|
||||||
|
_get_account_names(child)
|
||||||
|
|
||||||
|
_get_account_names(chart)
|
||||||
|
|
||||||
|
return (bank_account in accounts)
|
@ -137,11 +137,35 @@ erpnext.setup.slides_settings = [
|
|||||||
},
|
},
|
||||||
|
|
||||||
validate: function () {
|
validate: function () {
|
||||||
|
let me = this;
|
||||||
|
let exist;
|
||||||
|
|
||||||
// validate fiscal year start and end dates
|
// validate fiscal year start and end dates
|
||||||
if (this.values.fy_start_date == 'Invalid date' || this.values.fy_end_date == 'Invalid date') {
|
if (this.values.fy_start_date == 'Invalid date' || this.values.fy_end_date == 'Invalid date') {
|
||||||
frappe.msgprint(__("Please enter valid Financial Year Start and End Dates"));
|
frappe.msgprint(__("Please enter valid Financial Year Start and End Dates"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate bank name
|
||||||
|
if(me.values.bank_account){
|
||||||
|
frappe.call({
|
||||||
|
async: false,
|
||||||
|
method: "erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts.validate_bank_account",
|
||||||
|
args: {
|
||||||
|
"coa": me.values.chart_of_accounts,
|
||||||
|
"bank_account": me.values.bank_account
|
||||||
|
},
|
||||||
|
callback: function (r) {
|
||||||
|
if(r.message){
|
||||||
|
exist = r.message;
|
||||||
|
me.get_field("bank_account").set_value("");
|
||||||
|
frappe.msgprint(__(`Account ${me.values.bank_account} already exists, enter a different name for your bank account`));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return !exist; // Return False if exist = true
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user