trimming down profit and loss considerably.
This commit is contained in:
@@ -100,14 +100,14 @@
|
||||
first))
|
||||
|
||||
(defn filter-client [pnl-data client]
|
||||
(-> pnl-data
|
||||
(-> pnl-data
|
||||
(update :data (fn [data]
|
||||
((group-by :client-id data) client)))
|
||||
(update :filters (fn [f]
|
||||
(assoc f :client-id client)))))
|
||||
|
||||
(defn filter-location [pnl-data location]
|
||||
(-> pnl-data
|
||||
(-> pnl-data
|
||||
(update :data (fn [data]
|
||||
((group-by :location data) location)))
|
||||
(update :filters (fn [f]
|
||||
@@ -115,8 +115,8 @@
|
||||
|
||||
(defn filter-categories [pnl-data categories]
|
||||
(update pnl-data :data (fn [data]
|
||||
(mapcat identity
|
||||
((apply juxt categories)
|
||||
(mapcat identity
|
||||
((apply juxt categories)
|
||||
(group-by best-category data))))))
|
||||
|
||||
(defn filter-period [pnl-data period]
|
||||
@@ -157,14 +157,16 @@
|
||||
(defn subtotal-row [pnl-data title & [cell-args]]
|
||||
(into [{:value title
|
||||
:bold true
|
||||
:filters (:filters pnl-data)}]
|
||||
:filters (when (:from-numeric-code (:filters pnl-data)) ;; don't allow filtering when you don't at least filter numeric codes
|
||||
(:filters pnl-data))}]
|
||||
(map
|
||||
(fn [p]
|
||||
(let [data (filter-period pnl-data p)]
|
||||
(merge
|
||||
{:format :dollar
|
||||
:value (aggregate-accounts data)
|
||||
:filters (:filters data)}
|
||||
:filters (when (:from-numeric-code (:filters pnl-data)) ;; don't allow filtering when you don't at least filter numeric codes
|
||||
(:filters pnl-data))}
|
||||
cell-args)))
|
||||
(-> pnl-data :args :periods))))
|
||||
|
||||
@@ -278,11 +280,13 @@
|
||||
(into [{:value name}]
|
||||
(map
|
||||
(fn [p]
|
||||
{:format :dollar
|
||||
:value (-> pnl-data
|
||||
(filter-numeric-code numeric-code numeric-code)
|
||||
(filter-period p)
|
||||
(aggregate-accounts))})
|
||||
(let [pnl-data (-> pnl-data
|
||||
(filter-numeric-code numeric-code numeric-code)
|
||||
(filter-period p)
|
||||
)]
|
||||
{:format :dollar
|
||||
:filters (:filters pnl-data)
|
||||
:value (aggregate-accounts pnl-data)}))
|
||||
|
||||
(-> pnl-data :args :periods)))))
|
||||
(conj (subtotal-row pnl-data "" {:border [:top]})))]
|
||||
@@ -339,7 +343,7 @@
|
||||
(location-summary-table (-> pnl-data
|
||||
(filter-client client-id)
|
||||
(filter-location location))
|
||||
(str (-> pnl-data :clients-by-id (get client-id) :client/name) " (" location ") Summary")))
|
||||
(str (-> pnl-data :clients-by-id (get client-id)) " (" location ") Summary")))
|
||||
:details (for [[client-id location] (locations (:data pnl-data))]
|
||||
(location-detail-table (-> pnl-data
|
||||
(filter-client client-id)
|
||||
@@ -347,9 +351,9 @@
|
||||
(assoc :prefix location))
|
||||
(-> pnl-data
|
||||
(filter-client client-id))
|
||||
(str (-> pnl-data :clients-by-id (get client-id) :client/name) " (" location ") Detail")))})
|
||||
(str (-> pnl-data :clients-by-id (get client-id)) " (" location ") Detail")))})
|
||||
|
||||
|
||||
|
||||
|
||||
(defrecord PNLData [args data clients-by-id])
|
||||
(defrecord PNLData [args data client-names])
|
||||
|
||||
Reference in New Issue
Block a user