account tests.
This commit is contained in:
@@ -617,7 +617,6 @@
|
|||||||
:count (count results)})
|
:count (count results)})
|
||||||
|
|
||||||
(defn audit-transact-batch [txes id]
|
(defn audit-transact-batch [txes id]
|
||||||
(println "transacting batch")
|
|
||||||
(let [batch-id (.toString (java.util.UUID/randomUUID))]
|
(let [batch-id (.toString (java.util.UUID/randomUUID))]
|
||||||
(reduce
|
(reduce
|
||||||
(fn [full-tx batch]
|
(fn [full-tx batch]
|
||||||
@@ -637,8 +636,7 @@
|
|||||||
true (update :tempids merge (:tempids tx-result)))))
|
true (update :tempids merge (:tempids tx-result)))))
|
||||||
|
|
||||||
{}
|
{}
|
||||||
(partition-all 200 txes)))
|
(partition-all 200 txes))))
|
||||||
(println "done"))
|
|
||||||
|
|
||||||
(defn audit-transact [txes id]
|
(defn audit-transact [txes id]
|
||||||
(dc/transact conn {:tx-data (conj txes {:db/id "datomic.tx"
|
(dc/transact conn {:tx-data (conj txes {:db/id "datomic.tx"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
(:require
|
(:require
|
||||||
[auto-ap.datomic :refer [audit-transact conn]]
|
[auto-ap.datomic :refer [audit-transact conn]]
|
||||||
[auto-ap.datomic.accounts :as d-accounts]
|
[auto-ap.datomic.accounts :as d-accounts]
|
||||||
|
[iol-ion.tx :refer [upsert-entity]]
|
||||||
[auto-ap.graphql.utils
|
[auto-ap.graphql.utils
|
||||||
:refer [->graphql
|
:refer [->graphql
|
||||||
<-graphql
|
<-graphql
|
||||||
@@ -46,26 +47,27 @@
|
|||||||
(throw (ex-info (str "Account set " account-set " already has an account for code " numeric-code)
|
(throw (ex-info (str "Account set " account-set " already has an account for code " numeric-code)
|
||||||
{} ))))
|
{} ))))
|
||||||
(let [result (audit-transact [`(upsert-entity
|
(let [result (audit-transact [`(upsert-entity
|
||||||
~{:db/id (or id "new-account")
|
~(cond-> {:db/id (or id "new-account")
|
||||||
:account/name name
|
:account/name name
|
||||||
:account/search-terms name
|
:account/search-terms name
|
||||||
:account/type (keyword "account-type" (clojure.core/name type))
|
:account/type (keyword "account-type" (clojure.core/name type))
|
||||||
:account/applicability (or (enum->keyword applicability "account-applicability")
|
:account/applicability (or (enum->keyword applicability "account-applicability")
|
||||||
:account-applicability/global)
|
:account-applicability/global)
|
||||||
:account/invoice-allowance (some-> invoice-allowance (enum->keyword "allowance"))
|
:account/invoice-allowance (some-> invoice-allowance (enum->keyword "allowance"))
|
||||||
:account/vendor-allowance (some-> vendor-allowance (enum->keyword "allowance"))
|
:account/vendor-allowance (some-> vendor-allowance (enum->keyword "allowance"))
|
||||||
:account/default-allowance :allowance/allowed
|
:account/default-allowance :allowance/allowed
|
||||||
:account/account-set account-set
|
:account/account-set account-set
|
||||||
:account/location location
|
:account/location location
|
||||||
:account/numeric-code numeric-code
|
:account/numeric-code numeric-code
|
||||||
:account/code (str numeric-code)
|
:account/code (str numeric-code)
|
||||||
:account/client-overrides (mapv
|
:account/client-overrides (mapv
|
||||||
(fn [client-override]
|
(fn [client-override]
|
||||||
{:db/id (:id client-override)
|
{:db/id (:id client-override)
|
||||||
:account-client-override/client (:client-id client-override)
|
:account-client-override/client (:client-id client-override)
|
||||||
:account-client-override/name (:name client-override)
|
:account-client-override/name (:name client-override)
|
||||||
:account-client-override/search-terms (:name client-override)})
|
:account-client-override/search-terms (:name client-override)})
|
||||||
client-overrides)})]
|
client-overrides)}
|
||||||
|
id (dissoc :account/numeric-code :account/code)))]
|
||||||
(:id context))]
|
(:id context))]
|
||||||
(->graphql
|
(->graphql
|
||||||
(d-accounts/get-by-id (or id (get-in result [:tempids "new-account"])))))))
|
(d-accounts/get-by-id (or id (get-in result [:tempids "new-account"])))))))
|
||||||
|
|||||||
@@ -146,11 +146,12 @@
|
|||||||
|
|
||||||
(deftest get-graphql
|
(deftest get-graphql
|
||||||
(testing "should retrieve a single account"
|
(testing "should retrieve a single account"
|
||||||
(d/transact conn [{:account/numeric-code 1
|
(dc/transact conn {:tx-data [{:account/numeric-code 1
|
||||||
:account/default-allowance :allowance/allowed
|
:account/default-allowance :allowance/allowed
|
||||||
:account/type :account-type/asset
|
:account/type :account-type/asset
|
||||||
:account/location "A"
|
:account/location "A"
|
||||||
:account/name "Test"}])
|
:account/name "Test"}]})
|
||||||
|
|
||||||
(is (= {:name "Test",
|
(is (= {:name "Test",
|
||||||
:invoice_allowance nil,
|
:invoice_allowance nil,
|
||||||
:numeric_code 1,
|
:numeric_code 1,
|
||||||
|
|||||||
@@ -35,4 +35,5 @@ Sanity checks later:
|
|||||||
|
|
||||||
Future improvements:
|
Future improvements:
|
||||||
Make reports just be based on running-balances
|
Make reports just be based on running-balances
|
||||||
|
get rid of account-groups
|
||||||
|
move to solr
|
||||||
|
|||||||
Reference in New Issue
Block a user