From 3f411ba0102752e21d98c6ed770f95a429be1fa4 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Sun, 24 Nov 2019 23:39:22 +0530 Subject: [PATCH] fix: Refactor Dashboard - Move charts to separate components --- src/pages/Dashboard/Cashflow.vue | 87 +++++ src/pages/Dashboard/Dashboard.vue | 366 +----------------- src/pages/Dashboard/Expenses.vue | 118 ++++++ src/pages/Dashboard/ProfitAndLoss.vue | 77 ++++ src/pages/Dashboard/UnpaidInvoices.vue | 107 +++++ src/pages/Dashboard/getDatesAndPeriodicity.js | 33 ++ src/styles/index.css | 4 + 7 files changed, 438 insertions(+), 354 deletions(-) create mode 100644 src/pages/Dashboard/Cashflow.vue create mode 100644 src/pages/Dashboard/Expenses.vue create mode 100644 src/pages/Dashboard/ProfitAndLoss.vue create mode 100644 src/pages/Dashboard/UnpaidInvoices.vue create mode 100644 src/pages/Dashboard/getDatesAndPeriodicity.js diff --git a/src/pages/Dashboard/Cashflow.vue b/src/pages/Dashboard/Cashflow.vue new file mode 100644 index 00000000..8dc32d32 --- /dev/null +++ b/src/pages/Dashboard/Cashflow.vue @@ -0,0 +1,87 @@ + + diff --git a/src/pages/Dashboard/Dashboard.vue b/src/pages/Dashboard/Dashboard.vue index 3bc587d0..e18cfa53 100644 --- a/src/pages/Dashboard/Dashboard.vue +++ b/src/pages/Dashboard/Dashboard.vue @@ -8,104 +8,16 @@
-
-
-
{{ _('Cash Flow') }}
-
-
- - {{ _('Inflow') }} -
-
- - {{ _('Outflow') }} -
-
- -
-
-
+
-
-
- - - - -
-
- {{ frappe.format(invoice.paid, 'Currency') }} - {{ _('Paid') }} -
-
- {{ frappe.format(invoice.unpaid, 'Currency') }} - {{ _('Unpaid') }} -
-
-
-
-
-
-
-
+
- - - - -
+
- - - - -
-
-
-
-
-
{{ d.account }}
-
-
{{ frappe.format(d.total, 'Currency') }}
-
-
-
-
+
@@ -113,276 +25,22 @@ - diff --git a/src/pages/Dashboard/Expenses.vue b/src/pages/Dashboard/Expenses.vue new file mode 100644 index 00000000..8b1e2d81 --- /dev/null +++ b/src/pages/Dashboard/Expenses.vue @@ -0,0 +1,118 @@ + + + diff --git a/src/pages/Dashboard/ProfitAndLoss.vue b/src/pages/Dashboard/ProfitAndLoss.vue new file mode 100644 index 00000000..bbb09f94 --- /dev/null +++ b/src/pages/Dashboard/ProfitAndLoss.vue @@ -0,0 +1,77 @@ + + diff --git a/src/pages/Dashboard/UnpaidInvoices.vue b/src/pages/Dashboard/UnpaidInvoices.vue new file mode 100644 index 00000000..ac8066ef --- /dev/null +++ b/src/pages/Dashboard/UnpaidInvoices.vue @@ -0,0 +1,107 @@ + + diff --git a/src/pages/Dashboard/getDatesAndPeriodicity.js b/src/pages/Dashboard/getDatesAndPeriodicity.js new file mode 100644 index 00000000..da50edcc --- /dev/null +++ b/src/pages/Dashboard/getDatesAndPeriodicity.js @@ -0,0 +1,33 @@ +import frappe from 'frappejs'; +import { DateTime } from 'luxon'; + +export async function getDatesAndPeriodicity(period) { + let fromDate, toDate; + let periodicity = 'Monthly'; + let accountingSettings = await frappe.getSingle('AccountingSettings'); + + if (period === 'This Year') { + fromDate = accountingSettings.fiscalYearStart; + toDate = accountingSettings.fiscalYearEnd; + } else if (period === 'This Quarter') { + fromDate = DateTime.local() + .startOf('quarter') + .toISODate(); + toDate = DateTime.local() + .endOf('quarter') + .toISODate(); + } else if (period === 'This Month') { + fromDate = DateTime.local() + .startOf('month') + .toISODate(); + toDate = DateTime.local() + .endOf('month') + .toISODate(); + } + + return { + fromDate, + toDate, + periodicity + }; +} diff --git a/src/styles/index.css b/src/styles/index.css index 8de63b9b..33371408 100644 --- a/src/styles/index.css +++ b/src/styles/index.css @@ -30,3 +30,7 @@ html { .grid { display: grid; } + +.frappe-chart .chart-legend { + display: none; +}