Adds new expense report, with ability to break down by vendor
This commit is contained in:
@@ -21,6 +21,14 @@
|
||||
[vimsical.re-frame.cofx.inject :as inject]
|
||||
[auto-ap.status :as status]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::client
|
||||
:<- [::subs/clients]
|
||||
:<- [::subs/client]
|
||||
(fn [[ clients client]]
|
||||
(or client
|
||||
(first clients))))
|
||||
|
||||
(def pie-chart (r/adapt-react-class recharts/PieChart))
|
||||
(def pie (r/adapt-react-class recharts/Pie))
|
||||
(def bar-chart (r/adapt-react-class recharts/BarChart))
|
||||
@@ -239,8 +247,8 @@
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::mounted
|
||||
[(re-frame/inject-cofx ::inject/sub [::subs/client])]
|
||||
(fn [{:keys [db] ::subs/keys [client]} _]
|
||||
[(re-frame/inject-cofx ::inject/sub [::client]) ]
|
||||
(fn [{:keys [db] ::keys [client]} _]
|
||||
(cond->
|
||||
{:db (assoc db ::top-expense-categories nil
|
||||
::cash-flow nil
|
||||
@@ -302,14 +310,19 @@
|
||||
[grid/cell {:class "has-text-right"} (->$ amount)]])]]]))
|
||||
|
||||
(defn home-content []
|
||||
(let [client-id (-> @(re-frame/subscribe [::subs/client]) :id)
|
||||
(let [client @(re-frame/subscribe [::client])
|
||||
client-id (-> client :id)
|
||||
one-client (not (-> @(re-frame/subscribe [::subs/client]) :id))
|
||||
chart-options @(re-frame/subscribe [::chart-options])
|
||||
state @(re-frame/subscribe [::status/single ::page])]
|
||||
^{:key client-id}
|
||||
[side-bar-layout {:side-bar [:div]
|
||||
:main [:div [:h1.title "Home"]
|
||||
(if client-id
|
||||
(if (= :loading (:state state))
|
||||
(when one-client
|
||||
|
||||
[:h2.title.is-6 "Note: these reports are for "
|
||||
(:name client) ". Please choose a specific customer for their report."])
|
||||
(if (= :loading (:state state))
|
||||
[:div.loader.is-loading.big.is-centered]
|
||||
|
||||
[:<>
|
||||
@@ -350,17 +363,16 @@
|
||||
(make-cash-flow-chart {:width 800 :height 500
|
||||
:data (clj->js @(re-frame/subscribe [::cash-flow]))})
|
||||
|
||||
[cash-flow-grid]])
|
||||
[:h2.title.is-6 "Please select a customer to see reports."])]}]))
|
||||
[cash-flow-grid]])]}]))
|
||||
|
||||
|
||||
(defn home-page []
|
||||
(let [client-id (-> @(re-frame/subscribe [::subs/client]) :id)]
|
||||
(let [client-id (-> @(re-frame/subscribe [::client]) :id)]
|
||||
(re-frame/dispatch [::mounted])
|
||||
^{:key client-id} [home-content]))
|
||||
|
||||
(defn home-page-with-vendor []
|
||||
(let [client-id (-> @(re-frame/subscribe [::subs/client]) :id)
|
||||
(let [client-id (-> @(re-frame/subscribe [::client]) :id)
|
||||
user @(re-frame/subscribe [::subs/user])]
|
||||
(re-frame/dispatch [::mounted])
|
||||
(when (p/can? user {:subject :vendor
|
||||
|
||||
Reference in New Issue
Block a user