More grouping.

This commit is contained in:
Bryce Covert
2019-04-17 23:45:00 -07:00
parent 1b56d7ff0f
commit 4c7cd1ff3e
2 changed files with 38 additions and 36 deletions

View File

@@ -44,14 +44,16 @@
(defn roll-up [results]
(->> results
(mapcat :journal-entry/line-items)
(group-by :journal-entry-line/account)
(reduce-kv (fn [result account line-items]
(group-by (juxt :journal-entry-line/account :journal-entry-line/location))
(reduce-kv (fn [result [account location] line-items]
;; TODO fix
(when-not (or (:bank-account/name account) (:account/name account))
(println "WARNING " account line-items))
(conj result
{:name (or (:bank-account/name account) (:account/name account))
:id (:db/id account)
{:name (str (or (:bank-account/name account) (:account/name account)) (when-not (#{"A" } location)
(str
"-" location)))
:id (str (:db/id account) "-" location)
:numeric-code (or (:account/numeric-code account)
(and (:bank-account/type account)
1100))