more help.
This commit is contained in:
@@ -128,7 +128,28 @@
|
||||
[:client/locations]
|
||||
(:client_id (:filters args))))
|
||||
all-ids (get-ids-matching-filters args)
|
||||
transactions (d/pull-many (d/db conn) '[:db/id :transaction/amount] (vec all-ids))]
|
||||
transactions (d/pull-many (d/db conn) '[:db/id :transaction/amount] (vec all-ids))
|
||||
account-total (reduce + 0 (map (fn [x] (:percentage x)) (:accounts args)))]
|
||||
(when
|
||||
(and
|
||||
(seq (:accounts args))
|
||||
(not (dollars= 1.0 account-total)))
|
||||
(let [error (str "Account total (" account-total ") does not reach 100%")]
|
||||
(throw (ex-info error {:validation-error error}))))
|
||||
|
||||
(doseq [a (:accounts args)
|
||||
:let [{:keys [:account/location :account/name]} (d/entity (d/db conn) (:account_id a))
|
||||
client (d/entity (d/db conn) (:client_id (:filters args)))]]
|
||||
(when (and location (not= location (:location a)))
|
||||
(let [err (str "Account " name " uses location " (:location a) ", but is supposed to be " location)]
|
||||
(throw (ex-info err {:validation-error err}) )))
|
||||
|
||||
(when (and (not location)
|
||||
(not (get (into #{"Shared"} (:client/locations client))
|
||||
(:location a))))
|
||||
(let [err (str "Account " name " uses location " (:location a) ", but doesn't belong to the client.")]
|
||||
(throw (ex-info err {:validation-error err}) ))))
|
||||
|
||||
(log/info "Bulk coding " (count all-ids) args)
|
||||
(audit-transact-batch
|
||||
(mapcat (fn [i]
|
||||
|
||||
Reference in New Issue
Block a user