makes import check for accoutns

This commit is contained in:
Bryce Covert
2019-08-31 07:08:57 -07:00
parent c88840c719
commit 96ec3b1cf5
2 changed files with 16 additions and 13 deletions

View File

@@ -3,17 +3,20 @@
[auto-ap.graphql.utils :refer [->graphql]]
[auto-ap.datomic :refer [uri merge-query]]))
(defn get-accounts [args]
(let [query (cond-> {:query {:find ['(pull ?e [* {:account/type [:db/ident :db/id]}])]
:in ['$]
:where [['?e :account/name]]}
:args [(d/db (d/connect uri))]}
(:account-set args) (merge-query {:query {:in ['?account-set]
:where [['?e :account/account-set '?account-set]]}
:args [(:account-set args)]}))]
(->>
(d/query query)
(map first))))
(defn get-accounts
([]
(get-accounts {}))
([args]
(let [query (cond-> {:query {:find ['(pull ?e [* {:account/type [:db/ident :db/id]}])]
:in ['$]
:where [['?e :account/name]]}
:args [(d/db (d/connect uri))]}
(:account-set args) (merge-query {:query {:in ['?account-set]
:where [['?e :account/account-set '?account-set]]}
:args [(:account-set args)]}))]
(->>
(d/query query)
(map first)))))
(defn get-account-by-numeric-code-and-sets [numeric-code sets]
(let [query (cond-> {:query {:find ['(pull ?e [* {:account/type [:db/ident :db/id]}])]

View File

@@ -167,8 +167,8 @@
{}
(:entries args))
all-vendors (into all-vendors new-hidden-vendors)
all-accounts (transduce (map :account/code) conj #{} (a/get-accounts))
transaction (doall (map
(assoc-error (fn [entry]
(let [entry (-> entry
(update :amount #(Double/parseDouble %))
@@ -207,7 +207,7 @@
(:location ea))
(throw (Exception. (str "Location '" (:location ea) "' not found."))))
(when (and (not (re-matches #"^[0-9]+$" (:account_identifier ea)))
(when (and (not (all-accounts (:account_identifier ea)))
(not (get
(get all-client-bank-accounts (:client_code entry))
(:account_identifier ea))))