fix: tests

This commit is contained in:
Saqib Ansari
2020-04-02 22:17:41 +05:30
parent 04201028d1
commit de9c73c5cd

View File

@@ -23,19 +23,20 @@ class AssetCategory(Document):
account_type_map = {
'fixed_asset_account': { 'account_type': 'Fixed Asset' },
'accumulated_depreciation_account': { 'account_type': 'Accumulated Depreciation' },
'depreciation_expense_account': { 'account_type': 'Expense' },
'depreciation_expense_account': { 'root_type': 'Expense' },
'capital_work_in_progress_account': { 'account_type': 'Capital Work in Progress' }
}
for d in self.accounts:
for fieldname in account_type_map.keys():
if d.get(fieldname):
selected_account = d.get(fieldname)
selected_account_type = frappe.db.get_value('Account', selected_account, 'account_type')
expected_account_type = account_type_map[fieldname]['account_type']
key_to_match = account_type_map[fieldname].keys()[0]
selected_key_type = frappe.db.get_value('Account', selected_account, key_to_match)
expected_key_type = account_type_map[fieldname][key_to_match]
if selected_account_type != expected_account_type:
frappe.throw(_("Row #{}: Account Type of {} should be {}. Please modify the account type or select a different account."
.format(d.idx, frappe.bold(selected_account), frappe.bold(expected_account_type))),
if selected_key_type != expected_key_type:
frappe.throw(_("Row #{}: {} of {} should be {}. Please modify the account or select a different account."
.format(d.idx, frappe.unscrub(key_to_match), frappe.bold(selected_account), frappe.bold(expected_key_type))),
title=_("Invalid Account"))