fix(dashboard): as per new features
This commit is contained in:
parent
0d3986c9f6
commit
bead5b33f4
@ -1,5 +1,7 @@
|
||||
frappe.dashboard_chart_sources["Account Balance Timeline"] = {
|
||||
method_path: "erpnext.accounts.dashboard_chart_source.account_balance_timeline.account_balance_timeline.get",
|
||||
frappe.provide('frappe.dashboards.chart_sources');
|
||||
|
||||
frappe.dashboards.chart_sources["Account Balance Timeline"] = {
|
||||
method: "erpnext.accounts.dashboard_chart_source.account_balance_timeline.account_balance_timeline.get",
|
||||
filters: [
|
||||
{
|
||||
fieldname: "company",
|
||||
@ -16,30 +18,5 @@ frappe.dashboard_chart_sources["Account Balance Timeline"] = {
|
||||
options: "Account",
|
||||
reqd: 1
|
||||
},
|
||||
{
|
||||
fieldname: "timespan",
|
||||
label: __("Period"),
|
||||
fieldtype: "Select",
|
||||
options: [
|
||||
{value: "Last Year", label: __("Last Year")},
|
||||
{value: "Last Quarter", label: __("Last Quarter")},
|
||||
{value: "Last Month", label: __("Last Month")},
|
||||
{value: "Last Week", label: __("Last Week")}
|
||||
],
|
||||
reqd: 1
|
||||
},
|
||||
{
|
||||
fieldname: "timegrain",
|
||||
label: __("Periodicity"),
|
||||
fieldtype: "Select",
|
||||
options: [
|
||||
{value: "Quarterly", label: __("Quarterly")},
|
||||
{value: "Monthly", label: __("Monthly")},
|
||||
{value: "Weekly", label: __("Weekly")},
|
||||
{value: "Daily", label: __("Daily")}
|
||||
],
|
||||
reqd: 1
|
||||
},
|
||||
],
|
||||
is_time_series: true
|
||||
]
|
||||
};
|
@ -1,13 +1,13 @@
|
||||
{
|
||||
"config": "{\n \"method_path\": \"erpnext.accounts.dashboard_chart_source.account_balance_timeline.account_balance_timeline.get\",\n\t\"filters\": [\n\t\t{\n\t\t\t\"fieldname\": \"company\",\n\t\t\t\"label\": \"Company\",\n\t\t\t\"fieldtype\": \"Link\",\n\t\t\t\"options\": \"Company\",\n\t\t\t\"reqd\": 1\n\t\t},\n\t\t{\n\t\t\t\"fieldname\": \"account\",\n\t\t\t\"label\": \"Account\",\n\t\t\t\"fieldtype\": \"Link\",\n\t\t\t\"options\": \"Account\",\n\t\t\t\"reqd\": 1\n\t\t},\n\t\t{\n\t\t\t\"fieldname\": \"timespan\",\n\t\t\t\"label\": \"Period\",\n\t\t\t\"fieldtype\": \"Select\",\n\t\t\t\"options\": [\n\t\t\t\t{\"value\": \"Last Year\", \"label\": \"Last Year\"},\n\t\t\t\t{\"value\": \"Last Quarter\", \"label\": \"Last Quarter\"},\n\t\t\t\t{\"value\": \"Last Month\", \"label\": \"Last Month\"},\n\t\t\t\t{\"value\": \"Last Week\", \"label\": \"Last Week\"}\n\t\t\t],\n\t\t\t\"reqd\": 1\n\t\t},\n\t\t{\n\t\t\t\"fieldname\": \"timegrain\",\n\t\t\t\"label\": \"Periodicity\",\n\t\t\t\"fieldtype\": \"Select\",\n\t\t\t\"options\": [\n\t\t\t\t{\"value\": \"Quarterly\", \"label\": \"Quarterly\"},\n\t\t\t\t{\"value\": \"Monthly\", \"label\": \"Monthly\"},\n\t\t\t\t{\"value\": \"Weekly\", \"label\": \"Weekly\"},\n\t\t\t\t{\"value\": \"Daily\", \"label\": \"Daily\"}\n\t\t\t],\n\t\t\t\"reqd\": 1\n\t\t}\n\t],\n\t\"is_time_series\": true\n}\n",
|
||||
"creation": "2019-02-06 07:57:10.377718",
|
||||
"docstatus": 0,
|
||||
"doctype": "Dashboard Chart Source",
|
||||
"idx": 0,
|
||||
"modified": "2019-03-15 16:14:26.505986",
|
||||
"modified": "2019-04-09 18:30:49.943174",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Account Balance Timeline",
|
||||
"owner": "Administrator",
|
||||
"source_name": "Account Balance Timeline"
|
||||
"source_name": "Account Balance Timeline",
|
||||
"timeseries": 1
|
||||
}
|
@ -2,10 +2,8 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from itertools import groupby
|
||||
from operator import itemgetter
|
||||
import frappe
|
||||
from frappe.core.page.dashboard.dashboard import cache_source
|
||||
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
|
||||
from erpnext.accounts.report.general_ledger.general_ledger import execute
|
||||
|
||||
@ -13,9 +11,11 @@ from frappe.utils.nestedset import get_descendants_of
|
||||
|
||||
@frappe.whitelist()
|
||||
@cache_source
|
||||
def get(filters=None):
|
||||
timespan = filters.get("timespan")
|
||||
timegrain = filters.get("timegrain")
|
||||
def get(chart_name=None, filters=None):
|
||||
chart = frappe.get_doc('Dashboard Chart', chart_name)
|
||||
timespan = chart.timespan
|
||||
timegrain = chart.time_interval
|
||||
|
||||
account = filters.get("account")
|
||||
company = filters.get("company")
|
||||
|
||||
@ -80,19 +80,6 @@ def get_gl_entries(account, to_date):
|
||||
],
|
||||
order_by = 'posting_date asc')
|
||||
|
||||
def get_from_date_from_timespan(timespan):
|
||||
days = months = years = 0
|
||||
if "Last Week" == timespan:
|
||||
days = -7
|
||||
if "Last Month" == timespan:
|
||||
months = -1
|
||||
elif "Last Quarter" == timespan:
|
||||
months = -3
|
||||
elif "Last Year" == timespan:
|
||||
years = -1
|
||||
return add_to_date(None, years=years, months=months, days=days,
|
||||
as_string=True, as_datetime=True)
|
||||
|
||||
def get_dates_from_timegrain(from_date, to_date, timegrain):
|
||||
days = months = years = 0
|
||||
if "Daily" == timegrain:
|
||||
@ -105,6 +92,6 @@ def get_dates_from_timegrain(from_date, to_date, timegrain):
|
||||
months = 3
|
||||
|
||||
dates = [from_date]
|
||||
while dates[-1] <= to_date:
|
||||
while getdate(dates[-1]) <= getdate(to_date):
|
||||
dates.append(add_to_date(dates[-1], years=years, months=months, days=days))
|
||||
return dates
|
||||
|
Loading…
x
Reference in New Issue
Block a user