lots of new fixes.
This commit is contained in:
@@ -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)))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user