fix(api)
This commit is contained in:
parent
c066bbde06
commit
1c2eb51a91
@ -3,9 +3,10 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe, json
|
import frappe, json
|
||||||
from frappe.core.page.dashboard.dashboard import cache_source, get_from_date_from_timespan
|
from frappe.utils import add_to_date, date_diff, getdate, nowdate, get_last_day
|
||||||
from frappe.utils import add_to_date, date_diff, getdate, nowdate
|
|
||||||
from erpnext.accounts.report.general_ledger.general_ledger import execute
|
from erpnext.accounts.report.general_ledger.general_ledger import execute
|
||||||
|
from frappe.core.page.dashboard.dashboard import cache_source, get_from_date_from_timespan
|
||||||
|
from frappe.desk.doctype.dashboard_chart.dashboard_chart import get_period_beginning, get_period_ending
|
||||||
|
|
||||||
from frappe.utils.nestedset import get_descendants_of
|
from frappe.utils.nestedset import get_descendants_of
|
||||||
|
|
||||||
@ -23,13 +24,14 @@ def get(chart_name=None, from_date = None, to_date = None):
|
|||||||
if not to_date:
|
if not to_date:
|
||||||
to_date = nowdate()
|
to_date = nowdate()
|
||||||
if not from_date:
|
if not from_date:
|
||||||
|
if timegrain in ('Monthly', 'Quarterly'):
|
||||||
from_date = get_from_date_from_timespan(to_date, timespan)
|
from_date = get_from_date_from_timespan(to_date, timespan)
|
||||||
|
|
||||||
# fetch dates to plot
|
# fetch dates to plot
|
||||||
dates = get_dates_from_timegrain(from_date, to_date, timegrain)
|
dates = get_dates_from_timegrain(from_date, to_date, timegrain)
|
||||||
|
|
||||||
# get all the entries for this account and its descendants
|
# get all the entries for this account and its descendants
|
||||||
gl_entries = get_gl_entries(account, to_date)
|
gl_entries = get_gl_entries(account, get_period_ending(to_date, timegrain))
|
||||||
|
|
||||||
# compile balance values
|
# compile balance values
|
||||||
result = build_result(account, dates, gl_entries)
|
result = build_result(account, dates, gl_entries)
|
||||||
@ -94,7 +96,8 @@ def get_dates_from_timegrain(from_date, to_date, timegrain):
|
|||||||
elif "Quarterly" == timegrain:
|
elif "Quarterly" == timegrain:
|
||||||
months = 3
|
months = 3
|
||||||
|
|
||||||
dates = [from_date]
|
dates = [get_period_ending(from_date, timegrain)]
|
||||||
while getdate(dates[-1]) <= getdate(to_date):
|
while getdate(dates[-1]) < getdate(to_date):
|
||||||
dates.append(add_to_date(dates[-1], years=years, months=months, days=days))
|
date = get_period_ending(add_to_date(dates[-1], years=years, months=months, days=days), timegrain)
|
||||||
|
dates.append(date)
|
||||||
return dates
|
return dates
|
||||||
|
Loading…
x
Reference in New Issue
Block a user