makes import check for accoutns
This commit is contained in:
@@ -3,17 +3,20 @@
|
|||||||
[auto-ap.graphql.utils :refer [->graphql]]
|
[auto-ap.graphql.utils :refer [->graphql]]
|
||||||
[auto-ap.datomic :refer [uri merge-query]]))
|
[auto-ap.datomic :refer [uri merge-query]]))
|
||||||
|
|
||||||
(defn get-accounts [args]
|
(defn get-accounts
|
||||||
(let [query (cond-> {:query {:find ['(pull ?e [* {:account/type [:db/ident :db/id]}])]
|
([]
|
||||||
:in ['$]
|
(get-accounts {}))
|
||||||
:where [['?e :account/name]]}
|
([args]
|
||||||
:args [(d/db (d/connect uri))]}
|
(let [query (cond-> {:query {:find ['(pull ?e [* {:account/type [:db/ident :db/id]}])]
|
||||||
(:account-set args) (merge-query {:query {:in ['?account-set]
|
:in ['$]
|
||||||
:where [['?e :account/account-set '?account-set]]}
|
:where [['?e :account/name]]}
|
||||||
:args [(:account-set args)]}))]
|
:args [(d/db (d/connect uri))]}
|
||||||
(->>
|
(:account-set args) (merge-query {:query {:in ['?account-set]
|
||||||
(d/query query)
|
:where [['?e :account/account-set '?account-set]]}
|
||||||
(map first))))
|
:args [(:account-set args)]}))]
|
||||||
|
(->>
|
||||||
|
(d/query query)
|
||||||
|
(map first)))))
|
||||||
|
|
||||||
(defn get-account-by-numeric-code-and-sets [numeric-code sets]
|
(defn get-account-by-numeric-code-and-sets [numeric-code sets]
|
||||||
(let [query (cond-> {:query {:find ['(pull ?e [* {:account/type [:db/ident :db/id]}])]
|
(let [query (cond-> {:query {:find ['(pull ?e [* {:account/type [:db/ident :db/id]}])]
|
||||||
|
|||||||
@@ -167,8 +167,8 @@
|
|||||||
{}
|
{}
|
||||||
(:entries args))
|
(:entries args))
|
||||||
all-vendors (into all-vendors new-hidden-vendors)
|
all-vendors (into all-vendors new-hidden-vendors)
|
||||||
|
all-accounts (transduce (map :account/code) conj #{} (a/get-accounts))
|
||||||
transaction (doall (map
|
transaction (doall (map
|
||||||
|
|
||||||
(assoc-error (fn [entry]
|
(assoc-error (fn [entry]
|
||||||
(let [entry (-> entry
|
(let [entry (-> entry
|
||||||
(update :amount #(Double/parseDouble %))
|
(update :amount #(Double/parseDouble %))
|
||||||
@@ -207,7 +207,7 @@
|
|||||||
(:location ea))
|
(:location ea))
|
||||||
(throw (Exception. (str "Location '" (:location ea) "' not found."))))
|
(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
|
(not (get
|
||||||
(get all-client-bank-accounts (:client_code entry))
|
(get all-client-bank-accounts (:client_code entry))
|
||||||
(:account_identifier ea))))
|
(:account_identifier ea))))
|
||||||
|
|||||||
Reference in New Issue
Block a user