total column
This commit is contained in:
@@ -177,8 +177,9 @@
|
||||
(conj [:paragraph {:color [128 0 0] :size 9} (:warning report)])
|
||||
(conj
|
||||
(table->pdf report
|
||||
(cond-> (into [30 ] (repeat client-count 13))
|
||||
(:include-comparison args) (into (repeat (* 2 client-count) 13))))))
|
||||
(cond-> (into [30 ] (repeat client-count 13))
|
||||
(:include-comparison args) (into (repeat (* 2 client-count) 13))
|
||||
(and (> client-count 1) (not (:include-comparison args))) (conj 13)))))
|
||||
output-stream)
|
||||
(.toByteArray output-stream)))
|
||||
|
||||
|
||||
@@ -120,7 +120,8 @@
|
||||
(list
|
||||
[:div.text-2xl.font-bold.text-gray-600 (str "Balance Sheet - " (str/join ", " (map :client/name client))) ]
|
||||
(rtable/table {:widths (cond-> (into [30 ] (repeat 13 client-count))
|
||||
(> (count date) 1) (into (repeat 13 (* 2 client-count (dec (count date))))))
|
||||
(> (count date) 1) (into (repeat 13 (* 2 client-count (dec (count date)))))
|
||||
(and (> client-count 1) (= (count date) 1)) (conj 13))
|
||||
:investigate-url (bidi.bidi/path-for ssr-routes/only-routes ::route/investigate)
|
||||
:table report
|
||||
:warning (not-empty (str/join "\n " (filter not-empty [warning (:warning report)])))} ))))])
|
||||
@@ -201,8 +202,9 @@
|
||||
(conj [:paragraph {:color [128 0 0] :size 9} (:warning report)])
|
||||
(conj
|
||||
(table->pdf report
|
||||
(cond-> (into [30 ] (repeat client-count 13))
|
||||
(> (count date) 1) (into (repeat (* 2 client-count (dec (count date))) 13 ))))))
|
||||
(cond-> (into [30 ] (repeat client-count 13))
|
||||
(> (count date) 1) (into (repeat (* 2 client-count (dec (count date))) 13 ))
|
||||
(and (> client-count 1) (= (count date) 1)) (conj 13)))))
|
||||
output-stream)
|
||||
(.toByteArray output-stream)))
|
||||
|
||||
|
||||
@@ -798,30 +798,34 @@
|
||||
|
||||
|
||||
(defn balance-sheet-headers [pnl-data]
|
||||
(let [period-count (count (:periods (:args pnl-data)))]
|
||||
(let [period-count (count (:periods (:args pnl-data)))
|
||||
client-ids (set (map :client-id (:data pnl-data)))
|
||||
client-count (count client-ids)
|
||||
show-total? (and (> client-count 1) (= 1 period-count))]
|
||||
(cond-> []
|
||||
(> (count (set (map :client-id (:data pnl-data)))) 1)
|
||||
(conj (into [{:value "Client"}]
|
||||
(> client-count 1)
|
||||
(conj (cond-> (into [{:value "Client"}]
|
||||
(mapcat identity
|
||||
(for [client client-ids]
|
||||
(cond-> [{:value (str (-> pnl-data :client-codes (get client)))}]
|
||||
(> period-count 1)
|
||||
(into (apply concat (repeat (dec period-count) ["" ""])))))))
|
||||
show-total? (conj {:value "Total" :bold true :border [:left]})))
|
||||
|
||||
(mapcat identity
|
||||
(for [client (set (map :client-id (:data pnl-data))) ]
|
||||
(cond-> [{:value (str (-> pnl-data :client-codes (get client)))}]
|
||||
|
||||
(> period-count 1)
|
||||
(into (apply concat (repeat (dec period-count) ["" ""]))))))))
|
||||
true
|
||||
(conj (into [{:value "Period Ending"}]
|
||||
(for [client (set (map :client-id (:data pnl-data)))
|
||||
(conj (cond-> (into [{:value "Period Ending"}]
|
||||
(for [client client-ids
|
||||
[index p] (map vector (range) (:periods (:args pnl-data)))
|
||||
:let [is-first? (= 0 index)
|
||||
period-date (date->str p)
|
||||
period-headers (if (or is-first?
|
||||
(not (:include-deltas (:args pnl-data))))
|
||||
[{:value period-date}]
|
||||
[{:value period-date}
|
||||
{:value "+/-"}])]
|
||||
[{:value period-date}]
|
||||
[{:value period-date}
|
||||
{:value "+/-"}])]
|
||||
header period-headers]
|
||||
header))))))
|
||||
header))
|
||||
show-total? (conj {:value (date->str (first (:periods (:args pnl-data)))) :border [:left]}))))))
|
||||
|
||||
(defn append-deltas [table]
|
||||
(->> table
|
||||
@@ -890,12 +894,33 @@
|
||||
:rows table})))
|
||||
)
|
||||
|
||||
(defn add-total-border [rows]
|
||||
(map (fn [row]
|
||||
(let [last-idx (dec (count row))]
|
||||
(map-indexed
|
||||
(fn [i cell]
|
||||
(if (= i last-idx)
|
||||
(let [borders (or (:border cell) [])]
|
||||
(assoc cell :border (conj borders :left)))
|
||||
cell))
|
||||
row)))
|
||||
rows))
|
||||
|
||||
(defn summarize-balance-sheet [pnl-data]
|
||||
(let [pnl-datas (for [client-id (set (map :client-id (:data pnl-data)))
|
||||
p (:periods (:args pnl-data))]
|
||||
(-> pnl-data
|
||||
(filter-client client-id)
|
||||
(filter-period p)))]
|
||||
(let [client-ids (set (map :client-id (:data pnl-data)))
|
||||
client-count (count client-ids)
|
||||
period-count (count (:periods (:args pnl-data)))
|
||||
show-total? (and (> client-count 1) (= 1 period-count))
|
||||
pnl-datas (for [client-id client-ids
|
||||
p (:periods (:args pnl-data))]
|
||||
(-> pnl-data
|
||||
(filter-client client-id)
|
||||
(filter-period p)))
|
||||
total-data (when show-total?
|
||||
(-> pnl-data
|
||||
(filter-period (first (:periods (:args pnl-data))))
|
||||
(assoc :cell-args {:bold true})))
|
||||
pnl-datas (concat pnl-datas (when total-data [total-data]))]
|
||||
(let [table (-> []
|
||||
(into (detail-rows pnl-datas
|
||||
:assets
|
||||
@@ -912,10 +937,11 @@
|
||||
(negate #{:cogs :payroll :controllable :fixed-overhead :ownership-controllable}))
|
||||
pnl-datas)
|
||||
"Retained Earnings")))
|
||||
table (if (and (> (count (:periods (:args pnl-data))) 1)
|
||||
table (if (and (> period-count 1)
|
||||
(:include-deltas (:args pnl-data)))
|
||||
(append-deltas table)
|
||||
table)]
|
||||
(append-deltas table)
|
||||
table)
|
||||
table (if show-total? (add-total-border table) table)]
|
||||
{:warning (warning-message pnl-data)
|
||||
:header (balance-sheet-headers pnl-data)
|
||||
:rows table}))
|
||||
|
||||
@@ -265,7 +265,8 @@ NOTE: Please review the transactions we may have question for you here: https://
|
||||
[:div.notification.is-warning.is-light
|
||||
(:warning report)])
|
||||
[rtable/table {:widths (cond-> (into [30 ] (repeat 13 client-count))
|
||||
(:include-comparison args) (into (repeat 13 (* 2 client-count))))
|
||||
(:include-comparison args) (into (repeat 13 (* 2 client-count)))
|
||||
(and (> client-count 1) (not (:include-comparison args))) (conj 13))
|
||||
:click-event ::investigate-clicked
|
||||
:table report}]]))
|
||||
|
||||
|
||||
@@ -1,5 +1,2 @@
|
||||
#!/bin/bash
|
||||
sudo docker run --rm -ti -v ~/dev/integreat/data/solr:/var/solr --network=bridge -p 8983:8983 bryce-solr
|
||||
#sudo podman container run --user 1000 --privileged --volume /home/notid/dev/integreat/data/solr:/var/solr -p 8983:8983 bryce-solr
|
||||
|
||||
|
||||
sudo docker run --rm -ti -v ~/dev/integreat/data/solr:/var/solr --network=bridge -p 8983:8983 679918342773.dkr.ecr.us-east-1.amazonaws.com/integreat-solr
|
||||
|
||||
Reference in New Issue
Block a user