lots of new fixes.

This commit is contained in:
Bryce Covert
2020-06-19 10:05:55 -07:00
parent ef843ac9a2
commit d4559a7c2d
23 changed files with 451 additions and 56 deletions

View File

@@ -201,14 +201,29 @@
:where ['[?e :account/name]]}
:args [(d/db conn)]})))
_ (if-let [bad-rows (seq (->> rows
(group-by (fn [[_ account]]
account))
vals
(filter #(> (count %) 1))
(filter (fn [duplicates]
(apply not= (map rest duplicates))))
#_(map (fn [[[_ account]]]
account))
))]
(throw (Exception. (str "These accounts are duplicated:" (str bad-rows)))))
rows (vec (set (map rest rows)))
txes (transduce
(comp
(filter (fn [[_ account _ override-name]]
(filter (fn [[account _ override-name]]
(and
(not (str/blank? override-name))
(not (str/blank? account)))))
(map (fn parse-map [[_ account account-name override-name _ type]]
(map (fn parse-map [[account account-name override-name _ type]]
(let [code (Integer/parseInt account)
existing-id (:db/id (code->existing-account code))]
(cond-> {:account/client-overrides [{:account-client-override/client client-id
@@ -219,11 +234,15 @@
:account/account-set "default"
:account/numeric-code code
:account/code (str code)
:account/type (keyword "account-type" (str/lower-case type))))))))
:account/type (if (str/blank? type)
:account-type/expense
(keyword "account-type" (str/lower-case type)))))))))
conj
[]
rows)]
#_txes
@(d/transact conn txes)))