added validation
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
[auto-ap.datomic.transactions :as t]
|
||||
[datomic.api :as d]
|
||||
[auto-ap.datomic :refer [remove-nils uri merge-query]]
|
||||
[auto-ap.utils :refer [dollars=]]
|
||||
[auto-ap.graphql.utils :refer [->graphql <-graphql limited-clients assert-admin result->page]]
|
||||
[clj-time.coerce :as c]
|
||||
[clojure.set :as set])
|
||||
@@ -33,6 +34,10 @@
|
||||
#_(assert-admin (:id context))
|
||||
(let [existing-transaction (tr/get-by-id id)
|
||||
deleted (deleted-accounts existing-transaction accounts)
|
||||
account-total (reduce + 0 (map (fn [x] (:percentage x)) accounts))
|
||||
_ (when-not (dollars= 1.0 account-total)
|
||||
(let [error (str "Account total (" account-total ") does not reach 100%")]
|
||||
(throw (ex-info error {:validation-error error}))))
|
||||
transaction [(remove-nils #:transaction-rule {:db/id (if id
|
||||
id
|
||||
"transaction-rule")
|
||||
|
||||
Reference in New Issue
Block a user