multi clients complete.
This commit is contained in:
@@ -70,6 +70,15 @@
|
||||
"ZZZZZZ"
|
||||
x))))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::multi-client?
|
||||
:<- [::forms/form ::form]
|
||||
(fn [db]
|
||||
(> (->> db
|
||||
:data
|
||||
:clients
|
||||
count) 1 )))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::error
|
||||
(fn [db]
|
||||
@@ -130,7 +139,18 @@
|
||||
(transduce
|
||||
(comp
|
||||
(map parse-amounts)
|
||||
(map #(by (juxt :numeric-code :location) (:accounts %))))
|
||||
(map #(->> (:accounts %)
|
||||
(group-by (juxt :numeric-code :location))
|
||||
(map (fn [[k v]]
|
||||
[k
|
||||
(reduce (fn [a n]
|
||||
(-> a
|
||||
(update :count (fn [z] (+ z (:count n))))
|
||||
(update :amount (fn [z] (+ z (:amount n))))))
|
||||
(first v)
|
||||
(rest v))]))
|
||||
|
||||
(into {}))))
|
||||
|
||||
conj
|
||||
[]
|
||||
@@ -181,8 +201,7 @@
|
||||
[(date->str start standard)
|
||||
(date->str end standard)])
|
||||
(:periods (:data db)))
|
||||
:client (select-keys (:client (:data db))
|
||||
[:name :id])}
|
||||
:clients (mapv #(select-keys % [:name :id]) (:clients (:data db))) }
|
||||
:db (dissoc db :report)})))
|
||||
|
||||
|
||||
@@ -429,7 +448,8 @@
|
||||
;; TODO do we need squashing locations?
|
||||
|
||||
(defn grouping [{:keys [header type groupings location periods all-accounts]}]
|
||||
(let [include-deltas @(re-frame/subscribe [::include-deltas])]
|
||||
(let [include-deltas @(re-frame/subscribe [::include-deltas])
|
||||
multi-client? @(re-frame/subscribe [::multi-client?])]
|
||||
[:<>
|
||||
(doall
|
||||
(for [[grouping-name from to] groupings
|
||||
@@ -456,8 +476,11 @@
|
||||
(fn [i]
|
||||
(let [amount (get-in all-accounts [i [numeric-code location] :amount] 0.0)]
|
||||
[:<>
|
||||
[:td.has-text-right [:a {:on-click (dispatch-event [::investigate-clicked location numeric-code numeric-code i :current])}
|
||||
(->$ amount)]]
|
||||
[:td.has-text-right (if multi-client?
|
||||
[:span (->$ amount)]
|
||||
[:a {:on-click (dispatch-event [::investigate-clicked location numeric-code numeric-code i :current])
|
||||
:disabled (boolean multi-client?)}
|
||||
(->$ amount)])]
|
||||
[:td.has-text-right (->% (percent-of-sales amount all-accounts i location))]]))
|
||||
(fn [i]
|
||||
[:td.has-text-right (->$ (- (get-in all-accounts [i [numeric-code location] :amount] 0.0)
|
||||
@@ -471,8 +494,10 @@
|
||||
(fn [i]
|
||||
(let [amount (aggregate-accounts (filter-accounts all-accounts i [from to] location))]
|
||||
[:<>
|
||||
[:th.has-text-right.total [:a {:on-click (dispatch-event [::investigate-clicked location from to i])}
|
||||
(->$ amount)]]
|
||||
[:th.has-text-right.total (if multi-client?
|
||||
[:span (->$ amount)]
|
||||
[:a {:on-click (dispatch-event [::investigate-clicked location from to i])}
|
||||
(->$ amount)])]
|
||||
[:th.has-text-right.total (->% (percent-of-sales amount all-accounts i location))]]))
|
||||
(fn [i]
|
||||
[:th.has-text-right.total (->$ (- (aggregate-accounts (filter-accounts all-accounts i [from to] location))
|
||||
@@ -486,8 +511,8 @@
|
||||
(let [all-accounts @(re-frame/subscribe [::all-accounts])
|
||||
periods @(re-frame/subscribe [::periods])
|
||||
[min-numeric-code max-numeric-code] (ranges type)
|
||||
include-deltas @(re-frame/subscribe [::include-deltas])]
|
||||
|
||||
include-deltas @(re-frame/subscribe [::include-deltas])
|
||||
multi-client? @(re-frame/subscribe [::multi-client?])]
|
||||
[:<>
|
||||
[:tr [:th.is-size-5 title]]
|
||||
|
||||
@@ -501,9 +526,11 @@
|
||||
(fn [i]
|
||||
(let [amount (aggregate-accounts (filter-accounts all-accounts i [min-numeric-code max-numeric-code] location))]
|
||||
[:<>
|
||||
[:th.has-text-right [:a
|
||||
{:on-click (dispatch-event [::investigate-clicked location min-numeric-code max-numeric-code i])}
|
||||
(->$ amount)]]
|
||||
[:th.has-text-right (if multi-client?
|
||||
[:span (->$ amount)]
|
||||
[:a
|
||||
{:on-click (dispatch-event [::investigate-clicked location min-numeric-code max-numeric-code i])}
|
||||
(->$ amount)])]
|
||||
[:th.has-text-right (->% (percent-of-sales amount all-accounts i location))]
|
||||
]))
|
||||
(fn [i]
|
||||
@@ -633,8 +660,8 @@
|
||||
[:div.level-item
|
||||
[buttons/dropdown {:on-click (fn [] (reset! active :clients))}
|
||||
[:span (str "Companies"
|
||||
(when (:client data)
|
||||
(str " (" (:name (:client data)) ")")))]]
|
||||
(when-let [clients (:clients data)]
|
||||
(str " (" (str/join ", " (map :name clients)) ")")))]]
|
||||
[report-control-detail {:active active :box !box :which :clients}
|
||||
[:div {:style {:width "20em"}}
|
||||
[:h4.subtitle "Companies"]
|
||||
@@ -890,10 +917,9 @@
|
||||
(fn [dt]
|
||||
(str->date dt standard))
|
||||
period))))
|
||||
:client (or (:client qp)
|
||||
(some-> @(re-frame/subscribe [::subs/client]) (select-keys [:name :id])))
|
||||
:clients [(or (:client qp)
|
||||
(some-> @(re-frame/subscribe [::subs/client]) (select-keys [:name :id])))]
|
||||
|
||||
:clients (or (:clients qp)
|
||||
[(some-> @(re-frame/subscribe [::subs/client]) (select-keys [:name :id]))])
|
||||
:include-deltas true})
|
||||
::track/register {:id ::ledger-params
|
||||
:subscription [::data-page/params ::ledger]
|
||||
|
||||
Reference in New Issue
Block a user