In Dashboard, display a customer friendly error message when the start and end dates
are not within a fiscal year
This commit is contained in:
parent
5245e6547b
commit
3a23a5740e
@ -134,18 +134,26 @@ class DashboardWidget:
|
|||||||
print acc
|
print acc
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
return self.glc.get_as_on_balance(acc, self.get_fiscal_year(start), start, debit_or_credit, lft, rgt)
|
fiscal_year = self.get_fiscal_year(start)
|
||||||
|
if fiscal_year:
|
||||||
|
return self.glc.get_as_on_balance(acc, fiscal_year, start, debit_or_credit, lft, rgt)
|
||||||
|
else:
|
||||||
|
webnotes.msgprint('Please select the START DATE and END DATE such that\
|
||||||
|
they fall within the <b>same fiscal year</b> as defined in\
|
||||||
|
Setup > System > Fiscal Year.', raise_exception=1)
|
||||||
|
|
||||||
|
|
||||||
def get_fiscal_year(self, dt):
|
def get_fiscal_year(self, dt):
|
||||||
"""
|
"""
|
||||||
get fiscal year from date
|
get fiscal year from date
|
||||||
"""
|
"""
|
||||||
import webnotes
|
import webnotes
|
||||||
return webnotes.conn.sql("""
|
fiscal_year = webnotes.conn.sql("""
|
||||||
select name from `tabFiscal Year`
|
select name from `tabFiscal Year`
|
||||||
where year_start_date <= %s and
|
where year_start_date <= %s and
|
||||||
DATE_ADD(year_start_date, INTERVAL 1 YEAR) >= %s
|
DATE_ADD(year_start_date, INTERVAL 1 YEAR) >= %s
|
||||||
""", (dt, dt))[0][0]
|
""", (dt, dt))
|
||||||
|
return fiscal_year and (fiscal_year[0] and fiscal_year[0][0]) or None
|
||||||
|
|
||||||
def get_creation_trend(self, doctype, start, end):
|
def get_creation_trend(self, doctype, start, end):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user