You can now add clients manually.

This commit is contained in:
BC
2019-02-12 11:16:01 -08:00
parent 5fa181465c
commit b85ba810b3
3 changed files with 22 additions and 6 deletions

View File

@@ -58,7 +58,6 @@
:check_number {:type 'Int}
:name {:type 'String}
:bank_code {:type 'String}
:routing {:type 'String}
:bank_name {:type 'String}
:yodlee_account_id {:type 'Int}}}
:address
@@ -521,5 +520,8 @@
(try
(time (simplify (execute schema q v {:id id})))
(catch Exception e
(println e)
(if-let [v (:validation-error (ex-data e))]
(println "validation error" v)
(println e))
(throw e)))))

View File

@@ -9,11 +9,21 @@
":admin" :user-role/admin
":user" :user-role/user})
(defn assert-client-code-is-unique [code]
(when (seq (d/query {:query {:find '[?id]
:in ['$ '?code]
:where ['[?id :client/code ?code]]}
:args [(d/db (d/connect uri)) code]}))
(throw (ex-info "Client is not unique" {:validation-error "Client is not unique"}))))
(defn edit-client [context {:keys [edit_client new_bank_accounts] :as args} value]
(assert-admin (:id context))
(when-not (:id edit_client)
(assert-client-code-is-unique (:code edit_client)))
(let [client (when (:id edit_client) (d-clients/get-by-id (:id edit_client)))
id (or (:db/id client) "new-client")
_ (println id)
transactions [(remove-nils {:db/id id
:client/code (if (str/blank? (:client/code client))
(:code edit_client)