a number of nice fixes.

This commit is contained in:
Bryce Covert
2020-09-15 21:24:29 -07:00
parent f944a2e90f
commit 80efc14d3a
4 changed files with 166 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
(ns auto-ap.graphql.transaction-rules
(:require [auto-ap.datomic
:refer
[audit-transact merge-query remove-nils replace-nils-with-retract uri]]
[audit-transact merge-query remove-nils replace-nils-with-retract uri conn]]
[auto-ap.datomic.transaction-rules :as tr]
[auto-ap.datomic.transactions :as d-transactions]
[auto-ap.graphql.utils
@@ -74,6 +74,19 @@
(nil? yodlee_merchant_id))
(let [error (str "You must provide a description or a yodlee merchant")]
(throw (ex-info error {:validation-error error}))))
_ (doseq [a accounts
:let [{:keys [:account/location :account/name] :as account} (d/entity (d/db conn) (:account_id a))
client (d/entity (d/db conn) client_id)
]]
(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 (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 " location)]
(throw (ex-info err {:validation-error err}) )))
)
rule-id (if id
id
"transaction-rule")
@@ -116,7 +129,7 @@
])]
:in ['$ ]
:where []}
:args [(d/db (d/connect uri))]}
:args [(d/db conn)]}
(limited-clients id)
(merge-query {:query {:in ['[?xx ...]]