chore: Add missing validations
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 005a2f1..92906c1 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -51,13 +51,25 @@
@frappe.whitelist()
def get_fiscal_year(
- date=None, fiscal_year=None, label="Date", verbose=1, company=None, as_dict=False
+ date=None, fiscal_year=None, label="Date", verbose=1, company=None, as_dict=False, boolean=False
):
- return get_fiscal_years(date, fiscal_year, label, verbose, company, as_dict=as_dict)[0]
+ fiscal_years = get_fiscal_years(
+ date, fiscal_year, label, verbose, company, as_dict=as_dict, boolean=boolean
+ )
+ if boolean:
+ return fiscal_years
+ else:
+ return fiscal_years[0]
def get_fiscal_years(
- transaction_date=None, fiscal_year=None, label="Date", verbose=1, company=None, as_dict=False
+ transaction_date=None,
+ fiscal_year=None,
+ label="Date",
+ verbose=1,
+ company=None,
+ as_dict=False,
+ boolean=False,
):
fiscal_years = frappe.cache().hget("fiscal_years", company) or []
@@ -121,8 +133,12 @@
if company:
error_msg = _("""{0} for {1}""").format(error_msg, frappe.bold(company))
+ if boolean:
+ return False
+
if verbose == 1:
frappe.msgprint(error_msg)
+
raise FiscalYearError(error_msg)