Prevents loading all data
This commit is contained in:
@@ -365,63 +365,68 @@
|
|||||||
error @(re-frame/subscribe [::error])
|
error @(re-frame/subscribe [::error])
|
||||||
params @(re-frame/subscribe [::params])]
|
params @(re-frame/subscribe [::params])]
|
||||||
|
|
||||||
[:div
|
(if-not current-client
|
||||||
[:h1.title "Profit and Loss"]
|
[:div
|
||||||
[:h2.title.is-4 "Range"]
|
[:h1.title "Profit and Loss"]
|
||||||
[:div
|
[:h2.title.is-4 "Please choose a client first"]]
|
||||||
[:div.field.is-grouped
|
|
||||||
[:p.control
|
[:div
|
||||||
[:a.button
|
[:h1.title "Profit and Loss"]
|
||||||
{:class (when (= (:selected params) "Last week") "is-active")
|
[:h2.title.is-4 "Range"]
|
||||||
:on-click (dispatch-event [::range-selected
|
[:div
|
||||||
(date->str (t/minus (local-now) (t/period :days 7)) standard)
|
[:div.field.is-grouped
|
||||||
(date->str (local-now) standard)
|
[:p.control
|
||||||
"Last week"])}
|
[:a.button
|
||||||
"Last week"]]
|
{:class (when (= (:selected params) "Last week") "is-active")
|
||||||
[:p.control
|
:on-click (dispatch-event [::range-selected
|
||||||
[:a.button
|
(date->str (t/minus (local-now) (t/period :days 7)) standard)
|
||||||
{:class (when (= (:selected params) "Week to date") "is-active")
|
(date->str (local-now) standard)
|
||||||
:on-click (dispatch-event [::range-selected
|
"Last week"])}
|
||||||
(date->str (loop [current (local-now)]
|
"Last week"]]
|
||||||
(if (= 7 (t/day-of-week current))
|
[:p.control
|
||||||
current
|
[:a.button
|
||||||
(recur (t/minus current (t/period :days 1)))))
|
{:class (when (= (:selected params) "Week to date") "is-active")
|
||||||
standard)
|
:on-click (dispatch-event [::range-selected
|
||||||
(date->str (local-now) standard)
|
(date->str (loop [current (local-now)]
|
||||||
"Week to date"])}
|
(if (= 7 (t/day-of-week current))
|
||||||
"Week to date"]]
|
current
|
||||||
[:p.control
|
(recur (t/minus current (t/period :days 1)))))
|
||||||
[:a.button
|
standard)
|
||||||
{:class (when (= (:selected params) "Month to date") "is-active")
|
(date->str (local-now) standard)
|
||||||
:on-click (dispatch-event [::range-selected
|
"Week to date"])}
|
||||||
(date->str (t/local-date (t/year (local-now))
|
"Week to date"]]
|
||||||
(t/month (local-now))
|
[:p.control
|
||||||
1)
|
[:a.button
|
||||||
standard)
|
{:class (when (= (:selected params) "Month to date") "is-active")
|
||||||
(date->str (local-now) standard)
|
:on-click (dispatch-event [::range-selected
|
||||||
"Month to date"])}
|
(date->str (t/local-date (t/year (local-now))
|
||||||
"Month to date"]]
|
(t/month (local-now))
|
||||||
[:p.control
|
1)
|
||||||
[:a.button
|
standard)
|
||||||
{:class (when (= (:selected params) "Year to date") "is-active")
|
(date->str (local-now) standard)
|
||||||
:on-click (dispatch-event [::range-selected
|
"Month to date"])}
|
||||||
(date->str (t/local-date (t/year (local-now))
|
"Month to date"]]
|
||||||
1
|
[:p.control
|
||||||
1)
|
[:a.button
|
||||||
standard)
|
{:class (when (= (:selected params) "Year to date") "is-active")
|
||||||
(date->str (local-now) standard)
|
:on-click (dispatch-event [::range-selected
|
||||||
"Year to date"])}
|
(date->str (t/local-date (t/year (local-now))
|
||||||
"Year to date"]]
|
1
|
||||||
[:p.control
|
1)
|
||||||
[:a.button
|
standard)
|
||||||
{:class (when (= (:selected params) "Full year") "is-active")
|
(date->str (local-now) standard)
|
||||||
:on-click (dispatch-event [::range-selected
|
"Year to date"])}
|
||||||
(date->str (t/minus (local-now) (t/period :years 1))
|
"Year to date"]]
|
||||||
standard)
|
[:p.control
|
||||||
(date->str (local-now) standard)
|
[:a.button
|
||||||
"Full year"])}
|
{:class (when (= (:selected params) "Full year") "is-active")
|
||||||
"Full year"]]]]
|
:on-click (dispatch-event [::range-selected
|
||||||
[:div.field.is-grouped
|
(date->str (t/minus (local-now) (t/period :years 1))
|
||||||
|
standard)
|
||||||
|
(date->str (local-now) standard)
|
||||||
|
"Full year"])}
|
||||||
|
"Full year"]]]]
|
||||||
|
[:div.field.is-grouped
|
||||||
[:p.control
|
[:p.control
|
||||||
[:p.help "From"]
|
[:p.help "From"]
|
||||||
[bind-field
|
[bind-field
|
||||||
@@ -453,35 +458,35 @@
|
|||||||
:event [::date-picked]
|
:event [::date-picked]
|
||||||
:popper-props (clj->js {:placement "right"})
|
:popper-props (clj->js {:placement "right"})
|
||||||
:subscription params}]]]]
|
:subscription params}]]]]
|
||||||
(cond
|
(cond
|
||||||
error
|
error
|
||||||
[:div.notification.is-warning error]
|
[:div.notification.is-warning error]
|
||||||
|
|
||||||
@(re-frame/subscribe [::loading])
|
@(re-frame/subscribe [::loading])
|
||||||
[:div [:i.icon.fa.fa-spin.fa-spinner]]
|
[:div [:i.icon.fa.fa-spin.fa-spinner]]
|
||||||
|
|
||||||
:else
|
:else
|
||||||
[:div
|
[:div
|
||||||
[:table.table.compact.balance-sheet
|
[:table.table.compact.balance-sheet
|
||||||
(list
|
(list
|
||||||
[:tr
|
[:tr
|
||||||
[:td.has-text-right "Period ending"]
|
[:td.has-text-right "Period ending"]
|
||||||
[:td.has-text-right (date->str (str->date (:to-date params) standard))]
|
[:td.has-text-right (date->str (str->date (:to-date params) standard))]
|
||||||
[:td.has-text-right (when (:to-date params)
|
[:td.has-text-right (when (:to-date params)
|
||||||
(date->str (t/minus (str->date (:to-date params) standard) (t/years 1))))]
|
(date->str (t/minus (str->date (:to-date params) standard) (t/years 1))))]
|
||||||
[:td]]
|
[:td]]
|
||||||
(for [location @(re-frame/subscribe [::locations])]
|
(for [location @(re-frame/subscribe [::locations])]
|
||||||
(list
|
(list
|
||||||
(overall-grouping :sales (str location " Sales") location)
|
(overall-grouping :sales (str location " Sales") location)
|
||||||
(overall-grouping :cogs (str location " COGS") location)
|
(overall-grouping :cogs (str location " COGS") location)
|
||||||
(overall-grouping :payroll (str location " Payroll") location)
|
(overall-grouping :payroll (str location " Payroll") location)
|
||||||
(subtotal [:payroll :cogs] #{} (str location " Prime Costs") location)
|
(subtotal [:payroll :cogs] #{} (str location " Prime Costs") location)
|
||||||
(subtotal [:sales :payroll :cogs] #{:payroll :cogs} (str location " Gross Profits") location)
|
(subtotal [:sales :payroll :cogs] #{:payroll :cogs} (str location " Gross Profits") location)
|
||||||
(overall-grouping :controllable (str location " Controllable Expenses") location)
|
(overall-grouping :controllable (str location " Controllable Expenses") location)
|
||||||
(overall-grouping :noncontrollable (str location " Noncontrallable Expenses") location)
|
(overall-grouping :noncontrollable (str location " Noncontrallable Expenses") location)
|
||||||
(subtotal [:controllable :noncontrollable] #{} (str location " Overhead") location)
|
(subtotal [:controllable :noncontrollable] #{} (str location " Overhead") location)
|
||||||
(subtotal [:sales :cogs :payroll :controllable :noncontrollable] #{:cogs :payroll :controllable :noncontrollable} (str location " Net Income") location)
|
(subtotal [:sales :cogs :payroll :controllable :noncontrollable] #{:cogs :payroll :controllable :noncontrollable} (str location " Net Income") location)
|
||||||
(subtotal [:sales :cogs :payroll :controllable :noncontrollable] #{:cogs :payroll :controllable :noncontrollable} "Net Income" nil))))]])]))
|
(subtotal [:sales :cogs :payroll :controllable :noncontrollable] #{:cogs :payroll :controllable :noncontrollable} "Net Income" nil))))]])])))
|
||||||
{:component-will-mount #(re-frame/dispatch-sync [::params-change {:from-date (date->str (t/minus (local-now) (t/period :years 1)) standard)
|
{:component-will-mount #(re-frame/dispatch-sync [::params-change {:from-date (date->str (t/minus (local-now) (t/period :years 1)) standard)
|
||||||
:to-date (date->str (local-now) standard)}]) }))
|
:to-date (date->str (local-now) standard)}]) }))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user