fix: GL entry validation fix

This commit is contained in:
deepeshgarg007 2019-07-27 19:06:36 +05:30
parent 82661372f7
commit 724be6eca2
3 changed files with 7 additions and 7 deletions

View File

@ -164,8 +164,9 @@ def get_accounting_dimensions(as_list=True):
return accounting_dimensions
def get_checks_for_pl_and_bs_accounts():
dimensions = frappe.db.sql("""SELECT parent, company, mandatory_for_pl, mandatory_for_bs
FROM `tabAccounting Dimension Detail`""", as_dict=1)
dimensions = frappe.db.sql("""SELECT p.label, p.disabled, p.fieldname, c.company, c.mandatory_for_pl, c.mandatory_for_bs
FROM `tabAccounting Dimension`p ,`tabAccounting Dimension Detail` c
WHERE p.name = c.parent""", as_dict=1)
return dimensions

View File

@ -108,7 +108,6 @@ def disable_dimension():
dimension1.save()
dimension2 = frappe.get_doc("Accounting Dimension", "Location")
dimension2.mandatory_for_pl = 0
dimension2.disabled = 1
dimension2.save()

View File

@ -90,15 +90,15 @@ class GLEntry(Document):
if account_type == "Profit and Loss" \
and self.company == dimension.company and dimension.mandatory_for_pl and not dimension.disabled:
if not self.get(frappe.scrub(dimension.parent)):
if not self.get(frappe.scrub(dimension.fieldname)):
frappe.throw(_("Accounting Dimension <b>{0}</b> is required for 'Profit and Loss' account {1}.")
.format(dimension.parent, self.account))
.format(dimension.label, self.account))
if account_type == "Balance Sheet" \
and self.company == dimension.company and dimension.mandatory_for_bs and not dimension.disabled:
if not self.get(frappe.scrub(dimension.parent)):
if not self.get(frappe.scrub(dimension.fieldname)):
frappe.throw(_("Accounting Dimension <b>{0}</b> is required for 'Balance Sheet' account {1}.")
.format(dimension.parent, self.account))
.format(dimension.label, self.account))
def check_pl_account(self):