Supports vendors not loading
This commit is contained in:
@@ -3,18 +3,17 @@
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.components.grid :as grid]
|
||||
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
||||
[auto-ap.views.components.typeahead :refer [typeahead-v3]]
|
||||
[auto-ap.history :refer [history]]
|
||||
[cemerick.url :as url]
|
||||
[auto-ap.views.utils
|
||||
:refer
|
||||
[->$ date->str days-until dispatch-event local-now standard]]
|
||||
[bidi.bidi :as bidi]
|
||||
[cljs-time.coerce :as coerce]
|
||||
[cljs-time.core :as t]
|
||||
[clojure.string :as str]
|
||||
[pushy.core :as pushy]
|
||||
[re-frame.core :as re-frame]
|
||||
[recharts]
|
||||
[downshift :as ds :refer [useCombobox]]
|
||||
[reagent.core :as r]
|
||||
[react]))
|
||||
|
||||
@@ -39,7 +38,7 @@
|
||||
:data data
|
||||
:dataKey "value"
|
||||
:inner-radius 20}
|
||||
(map (fn [x y]
|
||||
(map (fn [_ y]
|
||||
^{:key y}
|
||||
[cell {:key y :fill (colors y)}]) data (range))
|
||||
]
|
||||
@@ -57,7 +56,7 @@
|
||||
|
||||
(defn make-cash-flow-chart [{:keys [width height data] }]
|
||||
(let [redirect-fn (fn [x]
|
||||
(pushy/set-token! auto-ap.history/history (str (bidi/path-for routes/routes :unpaid-invoices) "?" (get (js->clj x) "query-params")))
|
||||
(pushy/set-token! history (str (bidi/path-for routes/routes :unpaid-invoices) "?" (get (js->clj x) "query-params")))
|
||||
)]
|
||||
[bar-chart {:width width :height height :data data :fill "#FFFFFF" :stackOffset "sign"}
|
||||
[tool-tip]
|
||||
@@ -161,29 +160,29 @@
|
||||
(fn [[{:keys [effective-balance credits-yesterday] } :as acc] day]
|
||||
(let [invoices-due-today (invoices-due-soon (date->str (t/plus start-date (t/days day))) 0.0)
|
||||
credits-due-today (upcoming-credits (date->str (t/plus start-date (t/days day))) 0.0)
|
||||
debits-due-today (upcoming-debits (date->str (t/plus start-date (t/days day))) 0.0)]
|
||||
(let [today (t/plus start-date (t/days day))]
|
||||
(conj acc
|
||||
{:name (date->str today)
|
||||
:date today
|
||||
:effective-balance (+ (- effective-balance invoices-due-today )
|
||||
debits-due-today
|
||||
credits-yesterday)
|
||||
:credits-yesterday credits-due-today
|
||||
:credits credits-due-today
|
||||
:debits debits-due-today
|
||||
:invoices (- invoices-due-today)
|
||||
:query-params (cemerick.url/map->query {:due-range {:start (date->str today standard)
|
||||
:end (date->str today standard)}})}))))
|
||||
(list {:name (date->str start-date)
|
||||
:date start-date
|
||||
:effective-balance effective-balance
|
||||
:invoices (- (invoices-due-soon (date->str start-date) 0.0))
|
||||
:credits (upcoming-credits (date->str start-date) 0.0)
|
||||
:credits-yesterday (upcoming-credits (date->str start-date) 0.0)
|
||||
:debits (upcoming-debits (date->str start-date) 0.0)
|
||||
debits-due-today (upcoming-debits (date->str (t/plus start-date (t/days day))) 0.0)
|
||||
today (t/plus start-date (t/days day))]
|
||||
(conj acc
|
||||
{:name (date->str today)
|
||||
:date today
|
||||
:effective-balance (+ (- effective-balance invoices-due-today )
|
||||
debits-due-today
|
||||
credits-yesterday)
|
||||
:credits-yesterday credits-due-today
|
||||
:credits credits-due-today
|
||||
:debits debits-due-today
|
||||
:invoices (- invoices-due-today)
|
||||
:query-params (url/map->query {:due-range {:start (date->str today standard)
|
||||
:end (date->str today standard)}})})))
|
||||
(list {:name (date->str start-date)
|
||||
:date start-date
|
||||
:effective-balance effective-balance
|
||||
:invoices (- (invoices-due-soon (date->str start-date) 0.0))
|
||||
:credits (upcoming-credits (date->str start-date) 0.0)
|
||||
:credits-yesterday (upcoming-credits (date->str start-date) 0.0)
|
||||
:debits (upcoming-debits (date->str start-date) 0.0)
|
||||
:outstanding-payments (- outstanding-payments)
|
||||
:query-params (cemerick.url/map->query {:due-range {:end (date->str start-date standard)}})})
|
||||
:query-params (url/map->query {:due-range {:end (date->str start-date standard)}})})
|
||||
(condp = (:cash-flow-range chart-options)
|
||||
:seven-days
|
||||
(range 1 7)
|
||||
@@ -210,9 +209,8 @@
|
||||
::cash-flow-page
|
||||
:<- [::cash-flow-table-params]
|
||||
:<- [::cash-flow-data]
|
||||
:<- [::subs/vendors-by-id]
|
||||
(fn [[params cash-flow-data vendors-by-id]]
|
||||
(let [ {:keys [outstanding-payments invoices-due-soon upcoming-credits upcoming-debits]} cash-flow-data
|
||||
(fn [[params cash-flow-data]]
|
||||
(let [ {:keys [invoices-due-soon upcoming-credits upcoming-debits]} cash-flow-data
|
||||
rows (concat (map (fn [c]
|
||||
{:date (:date c)
|
||||
:days-until (days-until (:date c))
|
||||
@@ -230,7 +228,7 @@
|
||||
{:date (:due c)
|
||||
:days-until (days-until (:due c))
|
||||
:amount (:outstanding-balance c)
|
||||
:name (str (:name (get vendors-by-id (:id (:vendor c)))) " (" (:invoice-number c) ")")
|
||||
:name (str (:name (:vendor c)) " (" (:invoice-number c) ")")
|
||||
:type "Invoice"})
|
||||
invoices-due-soon))]
|
||||
(assoc (grid/virtual-paginate-controls (:start params ) (:per-page params) rows)
|
||||
@@ -253,7 +251,7 @@
|
||||
{:client-id (:id @(re-frame/subscribe [::subs/client]))}
|
||||
[:beginning-balance
|
||||
:outstanding-payments
|
||||
[:invoices-due-soon [:due :outstanding-balance [:vendor [:id]] :invoice-number]]
|
||||
[:invoices-due-soon [:due :outstanding-balance [:vendor [:id :name]] :invoice-number]]
|
||||
[:upcoming-credits [:date :amount :identifier]]
|
||||
[:upcoming-debits [:date :amount :identifier]]]]]}
|
||||
:on-success [::received]}}))
|
||||
@@ -300,8 +298,6 @@
|
||||
|
||||
(defn home-content []
|
||||
(let [client-id (-> @(re-frame/subscribe [::subs/client]) :id)
|
||||
accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id])
|
||||
accounts-index @(re-frame/subscribe [::subs/accounts-index])
|
||||
chart-options @(re-frame/subscribe [::chart-options])]
|
||||
^{:key client-id}
|
||||
[side-bar-layout {:side-bar [:div
|
||||
|
||||
Reference in New Issue
Block a user