made cloud tests work again.
This commit is contained in:
@@ -68,6 +68,7 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
(defn upsert-invoice [db invoice]
|
(defn upsert-invoice [db invoice]
|
||||||
|
(println invoice)
|
||||||
(let [upserted-entity [[:upsert-entity invoice]]
|
(let [upserted-entity [[:upsert-entity invoice]]
|
||||||
with-invoice (dc/with db upserted-entity)
|
with-invoice (dc/with db upserted-entity)
|
||||||
invoice-id (or (-> with-invoice :tempids (get (:db/id invoice)))
|
invoice-id (or (-> with-invoice :tempids (get (:db/id invoice)))
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
(update-in [:query :where] conj where))]
|
(update-in [:query :where] conj where))]
|
||||||
(reduce #(update-in %1 [:query :where] conj %2) query rest)))
|
(reduce #(update-in %1 [:query :where] conj %2) query rest)))
|
||||||
|
|
||||||
(def default-read '(pull ?e [* {:client/_bank-accounts [:db/id]}]))
|
(def default-read '[* {:client/_bank-accounts [:db/id]}])
|
||||||
|
|
||||||
(defn <-datomic [x]
|
(defn <-datomic [x]
|
||||||
(->> x
|
(->> x
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
|
|
||||||
(defn get-by-id [id]
|
(defn get-by-id [id]
|
||||||
(->> [(dc/pull (dc/db conn default-read id))]
|
(->> [(dc/pull (dc/db conn ) default-read id)]
|
||||||
(<-datomic)
|
(<-datomic)
|
||||||
(first)))
|
(first)))
|
||||||
|
|
||||||
|
|||||||
@@ -311,7 +311,7 @@
|
|||||||
:invoice/total 0.0
|
:invoice/total 0.0
|
||||||
:invoice/outstanding-balance 0.0
|
:invoice/outstanding-balance 0.0
|
||||||
:invoice/status :invoice-status/voided
|
:invoice/status :invoice-status/voided
|
||||||
:invoice/expense-accounts (map
|
:invoice/expense-accounts (mapv
|
||||||
(fn [iea]
|
(fn [iea]
|
||||||
{:db/id (:db/id iea)
|
{:db/id (:db/id iea)
|
||||||
:invoice-expense-account/amount 0.0})
|
:invoice-expense-account/amount 0.0})
|
||||||
@@ -342,7 +342,7 @@
|
|||||||
:invoice/total total
|
:invoice/total total
|
||||||
:invoice/status original-status
|
:invoice/status original-status
|
||||||
:invoice/outstanding-balance original-outstanding)
|
:invoice/outstanding-balance original-outstanding)
|
||||||
(update :invoice/expense-accounts conj {:db/id expense-account :invoice-expense-account/amount expense-account-amount})))
|
(update :invoice/expense-accounts (fnil conj []) {:db/id expense-account :invoice-expense-account/amount expense-account-amount})))
|
||||||
{}))]]
|
{}))]]
|
||||||
(:id context))
|
(:id context))
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
(def known-order
|
(def known-order
|
||||||
{:uuid "9ab05fee-a9c5-483b-a7f2-14debde4b7a8",
|
{:uuid "9ab05fee-a9c5-483b-a7f2-14debde4b7a8",
|
||||||
:client-code "ABC", :client-location "DT"
|
:client-code "ABC", :client-location "DT"
|
||||||
|
:orderNumber "ZX7156"
|
||||||
:orderSourceType "MARKETPLACE",
|
:orderSourceType "MARKETPLACE",
|
||||||
:caterer
|
:caterer
|
||||||
{:name "Nick The Greek",
|
{:name "Nick The Greek",
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
(t/deftest transaction->txs
|
(t/deftest transaction->txs
|
||||||
(t/testing "Should import and code transactions"
|
(t/testing "Should import and code transactions"
|
||||||
(t/testing "Should import one transaction"
|
(t/testing "Should import one transaction"
|
||||||
(let [{:strs [bank-account-id client-id]} (:tempids (dc/transact conn
|
(let [{:strs [bank-account-id client-id]} (:tempids @(dc/transact conn
|
||||||
[{:db/id "bank-account-id"
|
[{:db/id "bank-account-id"
|
||||||
:bank-account/code "TEST-1"}
|
:bank-account/code "TEST-1"}
|
||||||
{:db/id "client-id"
|
{:db/id "client-id"
|
||||||
@@ -107,6 +107,7 @@
|
|||||||
:db/id "client-id"
|
:db/id "client-id"
|
||||||
:bank-accounts ["bank-account-id"]}]
|
:bank-accounts ["bank-account-id"]}]
|
||||||
(dc/transact conn)
|
(dc/transact conn)
|
||||||
|
deref
|
||||||
:tempids)]
|
:tempids)]
|
||||||
|
|
||||||
(let [transaction-result (sut/transaction->txs (assoc base-transaction
|
(let [transaction-result (sut/transaction->txs (assoc base-transaction
|
||||||
@@ -132,7 +133,7 @@
|
|||||||
(:transaction/payment transaction-result)))))
|
(:transaction/payment transaction-result)))))
|
||||||
|
|
||||||
(t/testing "Should not match an already matched check"
|
(t/testing "Should not match an already matched check"
|
||||||
(dc/transact conn [{:db/id payment-id :payment/status :payment-status/cleared}])
|
@(dc/transact conn [{:db/id payment-id :payment/status :payment-status/cleared}])
|
||||||
(let [result (sut/transaction->txs (assoc base-transaction
|
(let [result (sut/transaction->txs (assoc base-transaction
|
||||||
:transaction/description-original "CHECK 10001"
|
:transaction/description-original "CHECK 10001"
|
||||||
:transaction/amount -30.0)
|
:transaction/amount -30.0)
|
||||||
@@ -158,6 +159,7 @@
|
|||||||
:locations ["MF"]
|
:locations ["MF"]
|
||||||
:bank-accounts ["bank-account-id"]}]
|
:bank-accounts ["bank-account-id"]}]
|
||||||
(dc/transact conn)
|
(dc/transact conn)
|
||||||
|
deref
|
||||||
:tempids)]
|
:tempids)]
|
||||||
|
|
||||||
|
|
||||||
@@ -255,6 +257,7 @@
|
|||||||
#:vendor {:name "Autopay vendor 2"
|
#:vendor {:name "Autopay vendor 2"
|
||||||
:db/id "vendor2-id"}]
|
:db/id "vendor2-id"}]
|
||||||
(dc/transact conn)
|
(dc/transact conn)
|
||||||
|
deref
|
||||||
:tempids)]
|
:tempids)]
|
||||||
(t/testing "Should find a single invoice that matches exactly"
|
(t/testing "Should find a single invoice that matches exactly"
|
||||||
(let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/paid
|
(let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/paid
|
||||||
@@ -266,6 +269,7 @@
|
|||||||
:db/id "invoice-id"}
|
:db/id "invoice-id"}
|
||||||
#:client {:name "Client" :db/id "client-id"}]
|
#:client {:name "Client" :db/id "client-id"}]
|
||||||
(dc/transact conn)
|
(dc/transact conn)
|
||||||
|
deref
|
||||||
:tempids)
|
:tempids)
|
||||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
||||||
(t/is (= 1 (count invoices-matches)))
|
(t/is (= 1 (count invoices-matches)))
|
||||||
@@ -280,6 +284,7 @@
|
|||||||
:db/id "invoice-id"}
|
:db/id "invoice-id"}
|
||||||
#:client {:name "Client" :db/id "client-id"}]
|
#:client {:name "Client" :db/id "client-id"}]
|
||||||
(dc/transact conn)
|
(dc/transact conn)
|
||||||
|
deref
|
||||||
:tempids)
|
:tempids)
|
||||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
||||||
|
|
||||||
@@ -295,6 +300,7 @@
|
|||||||
:db/id "invoice-id"}
|
:db/id "invoice-id"}
|
||||||
#:client {:name "Client" :db/id "client-id"}]
|
#:client {:name "Client" :db/id "client-id"}]
|
||||||
(dc/transact conn)
|
(dc/transact conn)
|
||||||
|
deref
|
||||||
:tempids)
|
:tempids)
|
||||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
||||||
|
|
||||||
@@ -313,6 +319,7 @@
|
|||||||
#:client {:name "Client"
|
#:client {:name "Client"
|
||||||
:db/id "client-id"}]
|
:db/id "client-id"}]
|
||||||
(dc/transact conn)
|
(dc/transact conn)
|
||||||
|
deref
|
||||||
:tempids)
|
:tempids)
|
||||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0
|
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0
|
||||||
client-id)]
|
client-id)]
|
||||||
@@ -334,6 +341,7 @@
|
|||||||
:db/id "invoice2-id"}
|
:db/id "invoice2-id"}
|
||||||
#:client {:name "Client" :db/id "client-id"}]
|
#:client {:name "Client" :db/id "client-id"}]
|
||||||
(dc/transact conn)
|
(dc/transact conn)
|
||||||
|
deref
|
||||||
:tempids)
|
:tempids)
|
||||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
||||||
(t/is (= 2 (count invoices-matches))
|
(t/is (= 2 (count invoices-matches))
|
||||||
@@ -355,6 +363,7 @@
|
|||||||
:db/id "invoice2-id"}
|
:db/id "invoice2-id"}
|
||||||
#:client {:name "Client" :db/id "client-id"}]
|
#:client {:name "Client" :db/id "client-id"}]
|
||||||
(dc/transact conn)
|
(dc/transact conn)
|
||||||
|
deref
|
||||||
:tempids)
|
:tempids)
|
||||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
||||||
(t/is (= 0 (count invoices-matches))
|
(t/is (= 0 (count invoices-matches))
|
||||||
@@ -377,6 +386,7 @@
|
|||||||
:db/id "invoice2-id"}
|
:db/id "invoice2-id"}
|
||||||
#:client {:name "Client" :db/id "client-id"}]
|
#:client {:name "Client" :db/id "client-id"}]
|
||||||
(dc/transact conn)
|
(dc/transact conn)
|
||||||
|
deref
|
||||||
:tempids)
|
:tempids)
|
||||||
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
|
||||||
(t/is (= 0 (count invoices-matches))
|
(t/is (= 0 (count invoices-matches))
|
||||||
@@ -406,6 +416,7 @@
|
|||||||
:db/id "invoice3-id"}
|
:db/id "invoice3-id"}
|
||||||
#:client {:name "Client" :db/id "client-id"}]
|
#:client {:name "Client" :db/id "client-id"}]
|
||||||
(dc/transact conn)
|
(dc/transact conn)
|
||||||
|
deref
|
||||||
:tempids)]
|
:tempids)]
|
||||||
(t/is (= 2 (count (sut/match-transaction-to-single-unfulfilled-autopayments -40.0 client-id)))
|
(t/is (= 2 (count (sut/match-transaction-to-single-unfulfilled-autopayments -40.0 client-id)))
|
||||||
(str "Expected to match with the chronologically adjacent invoice-1 and invoice-3."))
|
(str "Expected to match with the chronologically adjacent invoice-1 and invoice-3."))
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
(use-fixtures :each wrap-setup)
|
(use-fixtures :each wrap-setup)
|
||||||
(deftest transaction-page
|
(deftest transaction-page
|
||||||
(testing "transaction page"
|
(testing "transaction page"
|
||||||
(dc/transact conn
|
@(dc/transact conn
|
||||||
[(new-client {:db/id "client"})
|
[(new-client {:db/id "client"})
|
||||||
(new-transaction {:transaction/client "client"})])
|
(new-transaction {:transaction/client "client"})])
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
(deftest invoice-page
|
(deftest invoice-page
|
||||||
(testing "invoice page"
|
(testing "invoice page"
|
||||||
(dc/transact conn
|
@(dc/transact conn
|
||||||
[(new-client {:db/id "client"})
|
[(new-client {:db/id "client"})
|
||||||
(new-invoice {:invoice/client "client"
|
(new-invoice {:invoice/client "client"
|
||||||
:invoice/status :invoice-status/paid})])
|
:invoice/status :invoice-status/paid})])
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
|
|
||||||
(deftest upsert-transaction-rule
|
(deftest upsert-transaction-rule
|
||||||
(let [{:strs [vendor-id account-id yodlee-merchant-id]} (->
|
(let [{:strs [vendor-id account-id yodlee-merchant-id]} (->
|
||||||
(dc/transact
|
@(dc/transact
|
||||||
conn
|
conn
|
||||||
[{:vendor/name "Bryce's Meat Co"
|
[{:vendor/name "Bryce's Meat Co"
|
||||||
:db/id "vendor-id"}
|
:db/id "vendor-id"}
|
||||||
@@ -190,7 +190,7 @@
|
|||||||
|
|
||||||
(deftest test-transaction-rule
|
(deftest test-transaction-rule
|
||||||
(testing "it should match rules"
|
(testing "it should match rules"
|
||||||
(let [matching-transaction (dc/transact conn
|
(let [matching-transaction @(dc/transact conn
|
||||||
[{:transaction/description-original "matching-desc"
|
[{:transaction/description-original "matching-desc"
|
||||||
:transaction/date #inst "2019-01-05T00:00:00.000-08:00"
|
:transaction/date #inst "2019-01-05T00:00:00.000-08:00"
|
||||||
:transaction/client {:client/name "1"
|
:transaction/client {:client/name "1"
|
||||||
@@ -248,7 +248,7 @@
|
|||||||
|
|
||||||
(deftest test-match-transaction-rule
|
(deftest test-match-transaction-rule
|
||||||
(testing "it should apply a rules"
|
(testing "it should apply a rules"
|
||||||
(let [{:strs [transaction-id transaction-rule-id uneven-transaction-rule-id]} (-> (dc/transact conn
|
(let [{:strs [transaction-id transaction-rule-id uneven-transaction-rule-id]} (-> @(dc/transact conn
|
||||||
[{:transaction/description-original "matching-desc"
|
[{:transaction/description-original "matching-desc"
|
||||||
:transaction/date #inst "2019-01-05T00:00:00.000-08:00"
|
:transaction/date #inst "2019-01-05T00:00:00.000-08:00"
|
||||||
:transaction/client {:client/name "1"
|
:transaction/client {:client/name "1"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
(deftest test-account-search
|
(deftest test-account-search
|
||||||
(testing "It should find matching account names"
|
(testing "It should find matching account names"
|
||||||
(dc/transact conn [{:account/name "Food Research"
|
@(dc/transact conn [{:account/name "Food Research"
|
||||||
:db/ident :client-specific-account
|
:db/ident :client-specific-account
|
||||||
:account/numeric-code 51100
|
:account/numeric-code 51100
|
||||||
:account/search-terms "Food Research"
|
:account/search-terms "Food Research"
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
))
|
))
|
||||||
1)))
|
1)))
|
||||||
(testing "It should filter out accounts that are not allowed for clients"
|
(testing "It should filter out accounts that are not allowed for clients"
|
||||||
(dc/transact conn [{:account/name "CLIENT SPECIFIC"
|
@(dc/transact conn [{:account/name "CLIENT SPECIFIC"
|
||||||
:db/ident :client-specific-account
|
:db/ident :client-specific-account
|
||||||
:account/numeric-code 99999
|
:account/numeric-code 99999
|
||||||
:account/search-terms "CLIENTSPECIFIC"
|
:account/search-terms "CLIENTSPECIFIC"
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
)))
|
)))
|
||||||
|
|
||||||
(testing "It should show up for the client specific version"
|
(testing "It should show up for the client specific version"
|
||||||
(let [client-id (-> (dc/transact conn [{:client/name "CLIENT"
|
(let [client-id (-> @(dc/transact conn [{:client/name "CLIENT"
|
||||||
:db/id "client"}
|
:db/id "client"}
|
||||||
{:db/ident :client-specific-account
|
{:db/ident :client-specific-account
|
||||||
:account/client-overrides [{:account-client-override/client "client"
|
:account/client-overrides [{:account-client-override/client "client"
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
nil))))))
|
nil))))))
|
||||||
|
|
||||||
(testing "It should hide accounts that arent applicable"
|
(testing "It should hide accounts that arent applicable"
|
||||||
(dc/transact conn [{:account/name "DENIED"
|
@(dc/transact conn [{:account/name "DENIED"
|
||||||
:db/ident :denied-account
|
:db/ident :denied-account
|
||||||
:account/numeric-code 99998
|
:account/numeric-code 99998
|
||||||
:account/search-terms "DENIED"
|
:account/search-terms "DENIED"
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
nil)))))
|
nil)))))
|
||||||
|
|
||||||
(testing "It should warn when using a warn account"
|
(testing "It should warn when using a warn account"
|
||||||
(dc/transact conn [{:account/name "WARNING"
|
@(dc/transact conn [{:account/name "WARNING"
|
||||||
:db/ident :warn-account
|
:db/ident :warn-account
|
||||||
:account/numeric-code 99997
|
:account/numeric-code 99997
|
||||||
:account/search-terms "WARNING"
|
:account/search-terms "WARNING"
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
:allowance :vendor}
|
:allowance :vendor}
|
||||||
nil))))))
|
nil))))))
|
||||||
(testing "It should only include admin accounts for admins"
|
(testing "It should only include admin accounts for admins"
|
||||||
(dc/transact conn [{:account/name "ADMINONLY"
|
@(dc/transact conn [{:account/name "ADMINONLY"
|
||||||
:db/ident :warn-account
|
:db/ident :warn-account
|
||||||
:account/numeric-code 99997
|
:account/numeric-code 99997
|
||||||
:account/search-terms "ADMINONLY"
|
:account/search-terms "ADMINONLY"
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
nil)))))
|
nil)))))
|
||||||
|
|
||||||
(testing "It should allow searching for vendor accounts for invoices"
|
(testing "It should allow searching for vendor accounts for invoices"
|
||||||
(let [vendor-id (-> (dc/transact conn [{:account/name "VENDORONLY"
|
(let [vendor-id (-> @(dc/transact conn [{:account/name "VENDORONLY"
|
||||||
:db/id "vendor-only"
|
:db/id "vendor-only"
|
||||||
:db/ident :vendor-only
|
:db/ident :vendor-only
|
||||||
:account/numeric-code 99996
|
:account/numeric-code 99996
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
|
|
||||||
(deftest get-graphql
|
(deftest get-graphql
|
||||||
(testing "should retrieve a single account"
|
(testing "should retrieve a single account"
|
||||||
(dc/transact conn [{:account/numeric-code 1
|
@(dc/transact conn [{: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"
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
(deftest get-payment-page
|
(deftest get-payment-page
|
||||||
(testing "Should list payments"
|
(testing "Should list payments"
|
||||||
(let [{{:strs [bank-id check-id client-id]} :tempids} (d/transact conn [{:bank-account/code "bank"
|
(let [{{:strs [bank-id check-id client-id]} :tempids} @(d/transact conn [{:bank-account/code "bank"
|
||||||
:db/id "bank-id"}
|
:db/id "bank-id"}
|
||||||
{:client/code "client"
|
{:client/code "client"
|
||||||
:db/id "client-id"}
|
:db/id "client-id"}
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
|
|
||||||
(deftest void-payment
|
(deftest void-payment
|
||||||
(testing "Should void payments"
|
(testing "Should void payments"
|
||||||
(let [{{:strs [bank-id check-id client-id]} :tempids} (d/transact conn [{:bank-account/code "bank"
|
(let [{{:strs [bank-id check-id client-id]} :tempids} @(d/transact conn [{:bank-account/code "bank"
|
||||||
:db/id "bank-id"}
|
:db/id "bank-id"}
|
||||||
{:client/code "client"
|
{:client/code "client"
|
||||||
:db/id "client-id"}
|
:db/id "client-id"}
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
:db/ident)))))
|
:db/ident)))))
|
||||||
|
|
||||||
(testing "Should not void payments if account is locked"
|
(testing "Should not void payments if account is locked"
|
||||||
(let [{{:strs [check-id]} :tempids} (d/transact conn [{:bank-account/code "bank"
|
(let [{{:strs [check-id]} :tempids} @(d/transact conn [{:bank-account/code "bank"
|
||||||
:db/id "bank-id"}
|
:db/id "bank-id"}
|
||||||
{:client/code "client"
|
{:client/code "client"
|
||||||
:db/id "client-id"
|
:db/id "client-id"
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
(deftest void-payments
|
(deftest void-payments
|
||||||
(testing "bulk void"
|
(testing "bulk void"
|
||||||
(testing "Should bulk void payments if account is not locked"
|
(testing "Should bulk void payments if account is not locked"
|
||||||
(let [{{:strs [check-id]} :tempids} (d/transact conn [{:bank-account/code "bank"
|
(let [{{:strs [check-id]} :tempids} @(d/transact conn [{:bank-account/code "bank"
|
||||||
:db/id "bank-id"}
|
:db/id "bank-id"}
|
||||||
{:client/code "client-new"
|
{:client/code "client-new"
|
||||||
:db/id "client-id"}
|
:db/id "client-id"}
|
||||||
@@ -123,7 +123,7 @@
|
|||||||
:db/ident)))))
|
:db/ident)))))
|
||||||
|
|
||||||
(testing "Should only void a payment if it matches filter criteria"
|
(testing "Should only void a payment if it matches filter criteria"
|
||||||
(let [{{:strs [check-id]} :tempids} (d/transact conn [{:bank-account/code "bank"
|
(let [{{:strs [check-id]} :tempids} @(d/transact conn [{:bank-account/code "bank"
|
||||||
:db/id "bank-id"}
|
:db/id "bank-id"}
|
||||||
{:client/code "client-new"
|
{:client/code "client-new"
|
||||||
:db/id "client-id"}
|
:db/id "client-id"}
|
||||||
@@ -136,7 +136,7 @@
|
|||||||
:db/ident)))))
|
:db/ident)))))
|
||||||
|
|
||||||
(testing "Should not bulk void payments if account is locked"
|
(testing "Should not bulk void payments if account is locked"
|
||||||
(let [{{:strs [check-id]} :tempids} (d/transact conn [{:bank-account/code "bank"
|
(let [{{:strs [check-id]} :tempids} @(d/transact conn [{:bank-account/code "bank"
|
||||||
:db/id "bank-id"}
|
:db/id "bank-id"}
|
||||||
{:client/code "client"
|
{:client/code "client"
|
||||||
:db/id "client-id"
|
:db/id "client-id"
|
||||||
@@ -150,7 +150,7 @@
|
|||||||
:db/ident)))))
|
:db/ident)))))
|
||||||
|
|
||||||
(testing "Only admins should be able to bulk void"
|
(testing "Only admins should be able to bulk void"
|
||||||
(let [{{:strs [check-id]} :tempids} (d/transact conn [{:bank-account/code "bank"
|
(let [{{:strs [check-id]} :tempids} @(d/transact conn [{:bank-account/code "bank"
|
||||||
:db/id "bank-id"}
|
:db/id "bank-id"}
|
||||||
{:client/code "client"
|
{:client/code "client"
|
||||||
:db/id "client-id"}
|
:db/id "client-id"}
|
||||||
@@ -163,7 +163,7 @@
|
|||||||
(deftest print-checks
|
(deftest print-checks
|
||||||
(testing "Print checks"
|
(testing "Print checks"
|
||||||
(testing "Should allow 'printing' cash checks"
|
(testing "Should allow 'printing' cash checks"
|
||||||
(let [{{:strs [invoice-id client-id bank-id]} :tempids} (d/transact conn [{:client/code "client"
|
(let [{{:strs [invoice-id client-id bank-id]} :tempids} @(d/transact conn [{:client/code "client"
|
||||||
:db/id "client-id"
|
:db/id "client-id"
|
||||||
:client/locked-until #inst "2030-01-01"
|
:client/locked-until #inst "2030-01-01"
|
||||||
:client/bank-accounts [{:bank-account/code "bank"
|
:client/bank-accounts [{:bank-account/code "bank"
|
||||||
@@ -211,7 +211,7 @@
|
|||||||
:id))))))))
|
:id))))))))
|
||||||
|
|
||||||
(testing "Should allow 'printing' debit checks"
|
(testing "Should allow 'printing' debit checks"
|
||||||
(let [{{:strs [invoice-id client-id bank-id]} :tempids} (d/transact conn [{:client/code "client"
|
(let [{{:strs [invoice-id client-id bank-id]} :tempids} @(d/transact conn [{:client/code "client"
|
||||||
:db/id "client-id"
|
:db/id "client-id"
|
||||||
:client/bank-accounts [{:bank-account/code "bank"
|
:client/bank-accounts [{:bank-account/code "bank"
|
||||||
:db/id "bank-id"}]}
|
:db/id "bank-id"}]}
|
||||||
@@ -258,7 +258,7 @@
|
|||||||
:id)))))))))
|
:id)))))))))
|
||||||
|
|
||||||
(testing "Should allow printing checks"
|
(testing "Should allow printing checks"
|
||||||
(let [{{:strs [invoice-id client-id bank-id]} :tempids} (d/transact conn [{:client/code "client"
|
(let [{{:strs [invoice-id client-id bank-id]} :tempids} @(d/transact conn [{:client/code "client"
|
||||||
:db/id "client-id"
|
:db/id "client-id"
|
||||||
:client/bank-accounts [{:bank-account/code "bank"
|
:client/bank-accounts [{:bank-account/code "bank"
|
||||||
:bank-account/type :bank-account-type/check
|
:bank-account/type :bank-account-type/check
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
line-2-1
|
line-2-1
|
||||||
line-2-2
|
line-2-2
|
||||||
line-3-1
|
line-3-1
|
||||||
line-3-2]} (:tempids (d/transact conn [{:db/id "test-account-1"
|
line-3-2]} (:tempids @(d/transact conn [{:db/id "test-account-1"
|
||||||
:account/type :account-type/asset}
|
:account/type :account-type/asset}
|
||||||
{:db/id "test-account-2"
|
{:db/id "test-account-2"
|
||||||
:account/type :account-type/equity}
|
:account/type :account-type/equity}
|
||||||
|
|||||||
@@ -15,12 +15,12 @@
|
|||||||
(testing "should allow editing a user"
|
(testing "should allow editing a user"
|
||||||
|
|
||||||
|
|
||||||
(let [{{:strs [user-id] } :tempids} (d/transact conn [{:db/id "user-id" :user/name "Bryce"}])
|
(let [{{:strs [user-id] } :tempids} @(d/transact conn [{:db/id "user-id" :user/name "Bryce"}])
|
||||||
result (sut/edit-user {:id (admin-token)} {:edit_user {:role :power_user :id user-id}} nil)]
|
result (sut/edit-user {:id (admin-token)} {:edit_user {:role :power_user :id user-id}} nil)]
|
||||||
(is (some? (:id result))
|
(is (some? (:id result))
|
||||||
(= :power_user (:role result)))
|
(= :power_user (:role result)))
|
||||||
(testing "Should allow adding clients"
|
(testing "Should allow adding clients"
|
||||||
(let [{{:strs [client-id] } :tempids} (d/transact conn [{:db/id "client-id" :client/name "Bryce"}])
|
(let [{{:strs [client-id] } :tempids} @(d/transact conn [{:db/id "client-id" :client/name "Bryce"}])
|
||||||
result (sut/edit-user {:id (admin-token)} {:edit_user {:role :power_user
|
result (sut/edit-user {:id (admin-token)} {:edit_user {:role :power_user
|
||||||
:id user-id
|
:id user-id
|
||||||
:clients [(str client-id)]}} nil)]
|
:clients [(str client-id)]}} nil)]
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
:invoice/outstanding-balance 39.88
|
:invoice/outstanding-balance 39.88
|
||||||
}]
|
}]
|
||||||
(map #(dissoc % :invoice/expense-accounts :db/id)
|
(map #(dissoc % :invoice/expense-accounts :db/id)
|
||||||
(sut/extract-invoice-details "ntg-invoices/Cintas/123"
|
(sut/extract-invoice-details "ntg-invoices/Cintas/123.zcic"
|
||||||
(io/input-stream (io/resource "test-cintas/o.zcic.230310093903"))
|
(io/input-stream (io/resource "test-cintas/o.zcic.230310093903"))
|
||||||
[client]))))))
|
[client]))))))
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
(ns auto-ap.integration.util
|
(ns auto-ap.integration.util
|
||||||
(:require [datomic.api :as dc]
|
(:require [datomic.api :as dc]
|
||||||
[auto-ap.datomic :refer [conn transact-schema]]
|
[auto-ap.datomic :refer [conn transact-schema install-functions]]
|
||||||
[clj-time.core :as time]))
|
[clj-time.core :as time]))
|
||||||
|
|
||||||
(defn wrap-setup
|
(defn wrap-setup
|
||||||
[f]
|
[f]
|
||||||
(with-redefs [auto-ap.datomic/uri "datomic:mem://test"]
|
(with-redefs [auto-ap.datomic/uri "datomic:mem://test"]
|
||||||
(dc/create-database auto-ap.datomic/uri)
|
(dc/create-database auto-ap.datomic/uri)
|
||||||
(with-redefs [auto-ap.datomic/conn auto-ap.datomic/uri]
|
(with-redefs [auto-ap.datomic/conn (dc/connect auto-ap.datomic/uri)]
|
||||||
(transact-schema conn)
|
(transact-schema conn)
|
||||||
|
(install-functions)
|
||||||
(f)
|
(f)
|
||||||
(dc/delete-database auto-ap.datomic/uri))))
|
(dc/delete-database auto-ap.datomic/uri))))
|
||||||
|
|
||||||
@@ -100,7 +101,7 @@
|
|||||||
(dissoc x :id))
|
(dissoc x :id))
|
||||||
|
|
||||||
(defn setup-test-data [data]
|
(defn setup-test-data [data]
|
||||||
(:tempids (dc/transact conn (into data
|
(:tempids @(dc/transact conn (into data
|
||||||
[(test-account :db/id "test-account-id")
|
[(test-account :db/id "test-account-id")
|
||||||
(test-client :db/id "test-client-id"
|
(test-client :db/id "test-client-id"
|
||||||
:client/bank-accounts [(test-bank-account :db/id "test-bank-account-id")])
|
:client/bank-accounts [(test-bank-account :db/id "test-bank-account-id")])
|
||||||
@@ -112,4 +113,4 @@
|
|||||||
:account/account-set "default"}]))))
|
:account/account-set "default"}]))))
|
||||||
|
|
||||||
(defn apply-tx [data]
|
(defn apply-tx [data]
|
||||||
(:db-after (dc/transact conn data)))
|
(:db-after @(dc/transact conn data)))
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
(t/deftest import-uploaded-invoices
|
(t/deftest import-uploaded-invoices
|
||||||
(t/testing "It should import one"
|
(t/testing "It should import one"
|
||||||
(dc/transact conn [client expense-account vendor])
|
@(dc/transact conn [client expense-account vendor])
|
||||||
(rebuild-search-index)
|
(rebuild-search-index)
|
||||||
|
|
||||||
(t/is (= 0 (invoice-count-for-client [:client/code "ABC"])))
|
(t/is (= 0 (invoice-count-for-client [:client/code "ABC"])))
|
||||||
@@ -60,14 +60,14 @@
|
|||||||
:location-override "DE"
|
:location-override "DE"
|
||||||
:customer-identifier "ABC"
|
:customer-identifier "ABC"
|
||||||
:invoice-number "789")])
|
:invoice-number "789")])
|
||||||
(t/is (= [["DE"]] (dc/q '[:find ?l
|
(t/is (= #{["DE"]} (dc/q '[:find ?l
|
||||||
:where [?i :invoice/invoice-number "789"]
|
:where [?i :invoice/invoice-number "789"]
|
||||||
[?i :invoice/expense-accounts ?ea]
|
[?i :invoice/expense-accounts ?ea]
|
||||||
[?ea :invoice-expense-account/location ?l]]
|
[?ea :invoice-expense-account/location ?l]]
|
||||||
(dc/db conn)))))
|
(dc/db conn)))))
|
||||||
|
|
||||||
(t/testing "Should code invoice"
|
(t/testing "Should code invoice"
|
||||||
(let [{{:strs [my-default-account coded-vendor]} :tempids} (dc/transact conn
|
(let [{{:strs [my-default-account coded-vendor]} :tempids} @(dc/transact conn
|
||||||
[{:vendor/name "Coded"
|
[{:vendor/name "Coded"
|
||||||
:db/id "coded-vendor"
|
:db/id "coded-vendor"
|
||||||
:vendor/terms 12
|
:vendor/terms 12
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
:refer [apply-tx setup-test-data test-invoice test-transaction wrap-setup]]
|
:refer [apply-tx setup-test-data test-invoice test-transaction wrap-setup]]
|
||||||
[clojure.test :as t :refer [deftest is testing use-fixtures]]
|
[clojure.test :as t :refer [deftest is testing use-fixtures]]
|
||||||
[datomic.api :as dc]
|
[datomic.api :as dc]
|
||||||
[iol-ion.tx :as sut]))
|
[iol-ion.tx.upsert-invoice :as sut-i]
|
||||||
|
[iol-ion.tx.upsert-transaction :as sut-t]))
|
||||||
|
|
||||||
(use-fixtures :each wrap-setup)
|
(use-fixtures :each wrap-setup)
|
||||||
|
|
||||||
@@ -36,8 +37,8 @@
|
|||||||
|
|
||||||
(is (nil? (:db/id (dc/pull (dc/db conn) journal-pull
|
(is (nil? (:db/id (dc/pull (dc/db conn) journal-pull
|
||||||
[:journal-entry/original-entity invoice-id]))))
|
[:journal-entry/original-entity invoice-id]))))
|
||||||
(let [db-after (apply-tx (sut/upsert-invoice
|
(let [db-after (apply-tx (sut-i/upsert-invoice
|
||||||
(dc/with-db conn)
|
(dc/db conn)
|
||||||
{:db/id invoice-id
|
{:db/id invoice-id
|
||||||
:invoice/import-status :import-status/imported}))]
|
:invoice/import-status :import-status/imported}))]
|
||||||
|
|
||||||
@@ -64,8 +65,8 @@
|
|||||||
[:journal-entry/original-entity invoice-id])))
|
[:journal-entry/original-entity invoice-id])))
|
||||||
|
|
||||||
(testing "voiding an invoice should remove the journal entry"
|
(testing "voiding an invoice should remove the journal entry"
|
||||||
(let [db-after (apply-tx (sut/upsert-invoice
|
(let [db-after (apply-tx (sut-i/upsert-invoice
|
||||||
(dc/with-db conn)
|
(dc/db conn)
|
||||||
{:db/id invoice-id
|
{:db/id invoice-id
|
||||||
:invoice/status :invoice-status/voided}))]
|
:invoice/status :invoice-status/voided}))]
|
||||||
|
|
||||||
@@ -73,7 +74,7 @@
|
|||||||
(dc/pull db-after journal-pull
|
(dc/pull db-after journal-pull
|
||||||
[:journal-entry/original-entity invoice-id])))))
|
[:journal-entry/original-entity invoice-id])))))
|
||||||
(testing "invoice should remove the journal entry"
|
(testing "invoice should remove the journal entry"
|
||||||
(let [db-after (apply-tx (sut/upsert-invoice
|
(let [db-after (apply-tx (sut-i/upsert-invoice
|
||||||
(dc/db conn)
|
(dc/db conn)
|
||||||
{:db/id invoice-id
|
{:db/id invoice-id
|
||||||
:invoice/status :invoice-status/unpaid
|
:invoice/status :invoice-status/unpaid
|
||||||
@@ -96,7 +97,7 @@
|
|||||||
)
|
)
|
||||||
{:db/id "test-import-batch-id"
|
{:db/id "test-import-batch-id"
|
||||||
:import-batch/date #inst "2022-01-01"}])
|
:import-batch/date #inst "2022-01-01"}])
|
||||||
update (sut/upsert-transaction (dc/db conn) {:db/id test-transaction-id
|
update (sut-t/upsert-transaction (dc/db conn) {:db/id test-transaction-id
|
||||||
:transaction/id "hello"
|
:transaction/id "hello"
|
||||||
:transaction/bank-account test-bank-account-id
|
:transaction/bank-account test-bank-account-id
|
||||||
:transaction/amount 500.00
|
:transaction/amount 500.00
|
||||||
|
|||||||
Reference in New Issue
Block a user