account tests.

This commit is contained in:
2023-03-24 15:34:43 -07:00
parent bfa04ef83f
commit eb7394b42b
4 changed files with 31 additions and 29 deletions

View File

@@ -617,7 +617,6 @@
:count (count results)})
(defn audit-transact-batch [txes id]
(println "transacting batch")
(let [batch-id (.toString (java.util.UUID/randomUUID))]
(reduce
(fn [full-tx batch]
@@ -637,8 +636,7 @@
true (update :tempids merge (:tempids tx-result)))))
{}
(partition-all 200 txes)))
(println "done"))
(partition-all 200 txes))))
(defn audit-transact [txes id]
(dc/transact conn {:tx-data (conj txes {:db/id "datomic.tx"

View File

@@ -2,6 +2,7 @@
(:require
[auto-ap.datomic :refer [audit-transact conn]]
[auto-ap.datomic.accounts :as d-accounts]
[iol-ion.tx :refer [upsert-entity]]
[auto-ap.graphql.utils
:refer [->graphql
<-graphql
@@ -46,26 +47,27 @@
(throw (ex-info (str "Account set " account-set " already has an account for code " numeric-code)
{} ))))
(let [result (audit-transact [`(upsert-entity
~{:db/id (or id "new-account")
:account/name name
:account/search-terms name
:account/type (keyword "account-type" (clojure.core/name type))
:account/applicability (or (enum->keyword applicability "account-applicability")
:account-applicability/global)
:account/invoice-allowance (some-> invoice-allowance (enum->keyword "allowance"))
:account/vendor-allowance (some-> vendor-allowance (enum->keyword "allowance"))
:account/default-allowance :allowance/allowed
:account/account-set account-set
:account/location location
:account/numeric-code numeric-code
:account/code (str numeric-code)
:account/client-overrides (mapv
(fn [client-override]
{:db/id (:id client-override)
:account-client-override/client (:client-id client-override)
:account-client-override/name (:name client-override)
:account-client-override/search-terms (:name client-override)})
client-overrides)})]
~(cond-> {:db/id (or id "new-account")
:account/name name
:account/search-terms name
:account/type (keyword "account-type" (clojure.core/name type))
:account/applicability (or (enum->keyword applicability "account-applicability")
:account-applicability/global)
:account/invoice-allowance (some-> invoice-allowance (enum->keyword "allowance"))
:account/vendor-allowance (some-> vendor-allowance (enum->keyword "allowance"))
:account/default-allowance :allowance/allowed
:account/account-set account-set
:account/location location
:account/numeric-code numeric-code
:account/code (str numeric-code)
:account/client-overrides (mapv
(fn [client-override]
{:db/id (:id client-override)
:account-client-override/client (:client-id client-override)
:account-client-override/name (:name client-override)
:account-client-override/search-terms (:name client-override)})
client-overrides)}
id (dissoc :account/numeric-code :account/code)))]
(:id context))]
(->graphql
(d-accounts/get-by-id (or id (get-in result [:tempids "new-account"])))))))