Merge pull request #17194 from rmehta/dashboard-refactor
fix(dashboard): as per new features
This commit is contained in:
commit
44b0cb6383
@ -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
|
||||
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
|
||||
from erpnext.accounts.report.general_ledger.general_ledger import execute
|
||||
|
||||
@ -13,14 +11,19 @@ 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, from_date = None, to_date = None):
|
||||
chart = frappe.get_doc('Dashboard Chart', chart_name)
|
||||
timespan = chart.timespan
|
||||
timegrain = chart.time_interval
|
||||
filters = json.loads(chart.filters_json)
|
||||
|
||||
account = filters.get("account")
|
||||
company = filters.get("company")
|
||||
|
||||
from_date = get_from_date_from_timespan(timespan)
|
||||
to_date = nowdate()
|
||||
if not from_date:
|
||||
from_date = get_from_date_from_timespan(to_date, timespan)
|
||||
if not to_date:
|
||||
to_date = nowdate()
|
||||
|
||||
# fetch dates to plot
|
||||
dates = get_dates_from_timegrain(from_date, to_date, timegrain)
|
||||
@ -80,19 +83,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 +95,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
|
||||
|
@ -74,7 +74,7 @@ website_generators = ["Item Group", "Item", "BOM", "Sales Partner",
|
||||
|
||||
website_context = {
|
||||
"favicon": "/assets/erpnext/images/favicon.png",
|
||||
"splash_image": "/assets/erpnext/images/erp-icon.svg"
|
||||
"splash_image": "/assets/erpnext/images/erpnext-12.svg"
|
||||
}
|
||||
|
||||
website_route_rules = [
|
||||
|
26
erpnext/public/images/erpnext-12.svg
Normal file
26
erpnext/public/images/erpnext-12.svg
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="165px" height="88px" viewBox="0 0 165 88" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 44.1 (41455) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>version-12</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs></defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="version-12" transform="translate(-2.000000, -2.000000)">
|
||||
<g id="erp-icon" fill-rule="nonzero">
|
||||
<g id="g1422-7-2" transform="translate(0.025630, 0.428785)" fill="#5E64FF">
|
||||
<g id="g1418-4-6" transform="translate(0.268998, 0.867736)">
|
||||
<g id="g1416-4-9" transform="translate(0.749997, 0.000000)">
|
||||
<path d="M14.1845844,0.703479866 L75.0387175,0.703479866 C82.3677094,0.703479866 88.2679029,6.60367875 88.2679029,13.9326374 L88.2679029,74.7868158 C88.2679029,82.1157744 82.3677094,88.0159833 75.0387175,88.0159833 L14.1845844,88.0159833 C6.85569246,88.0159833 0.955398949,82.1157744 0.955398949,74.7868158 L0.955398949,13.9326374 C0.955398949,6.60367875 6.85569246,0.703479866 14.1845844,0.703479866 L14.1845844,0.703479866 Z" id="path1414-3-4"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="g1444-6-7" transform="translate(27.708247, 23.320960)" fill="#FFFFFF">
|
||||
<path d="M4.06942472,0.507006595 C3.79457554,0.507006595 3.52673783,0.534925429 3.26792241,0.587619847 C3.00908052,0.640314265 2.75926093,0.717948309 2.52171801,0.818098395 C2.40292009,0.868173438 2.28745592,0.924056085 2.17495509,0.985013441 C1.94997987,1.10692286 1.73828674,1.24983755 1.54244215,1.41134187 C0.661062132,2.13811791 0.100674618,3.23899362 0.100674618,4.4757567 L0.100674618,4.71760174 L0.100674618,39.9531653 L0.100674618,40.1945182 C0.100674618,42.3932057 1.87073716,44.1632683 4.06942472,44.1632683 L31.8263867,44.1632683 C34.0250742,44.1632683 35.7951368,42.3932057 35.7951368,40.1945182 L35.7951368,39.9531653 C35.7951368,37.7544777 34.0250742,35.9844152 31.8263867,35.9844152 L8.28000399,35.9844152 L8.28000399,26.0992376 L25.7874571,26.0992376 C27.9861447,26.0992376 29.7562072,24.3291751 29.7562072,22.1304875 L29.7562072,21.8891611 C29.7562072,19.6904735 27.9861447,17.920411 25.7874571,17.920411 L8.28000399,17.920411 L8.28000399,8.68635184 L31.8263867,8.68635184 C34.0250742,8.68635184 35.7951368,6.9162893 35.7951368,4.71760174 L35.7951368,4.4757567 C35.7951368,2.27706914 34.0250742,0.507006595 31.8263867,0.507006595 L4.06942472,0.507006595 Z" id="rect1436-8-4"></path>
|
||||
</g>
|
||||
</g>
|
||||
<text id="12" font-family="SourceSansPro-Regular, Source Sans Pro" font-size="72" font-weight="normal" letter-spacing="-0.386831313" fill="#D1D8DD">
|
||||
<tspan x="99" y="71">12</tspan>
|
||||
</text>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.9 KiB |
Loading…
Reference in New Issue
Block a user