(cloud) fixes issues encountered in testing.
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
(:require
|
||||
[auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.integration.util
|
||||
:refer [setup-test-data test-invoice wrap-setup apply-tx]]
|
||||
[clojure.test :as t :refer [deftest is use-fixtures testing]]
|
||||
:refer [apply-tx setup-test-data test-invoice test-transaction wrap-setup]]
|
||||
[clojure.test :as t :refer [deftest is testing use-fixtures]]
|
||||
[datomic.client.api :as dc]
|
||||
[iol-ion.tx :as sut]))
|
||||
|
||||
@@ -82,3 +82,55 @@
|
||||
(is (= nil
|
||||
(dc/pull db-after journal-pull
|
||||
[:journal-entry/original-entity invoice-id])))))))))
|
||||
|
||||
(deftest upsert-transaction []
|
||||
(testing "should upsert transaction"
|
||||
(let [{:strs [test-client-id
|
||||
test-bank-account-id
|
||||
test-account-id
|
||||
test-vendor-id
|
||||
test-transaction-id
|
||||
test-import-batch-id
|
||||
]} (setup-test-data
|
||||
[(test-transaction :db/id "test-transaction-id"
|
||||
)
|
||||
{:db/id "test-import-batch-id"
|
||||
:import-batch/date #inst "2022-01-01"}])
|
||||
update (sut/upsert-transaction (dc/db conn) {:db/id test-transaction-id
|
||||
:transaction/id "hello"
|
||||
:transaction/bank-account test-bank-account-id
|
||||
:transaction/amount 500.00
|
||||
:transaction/client test-client-id
|
||||
:transaction/date #inst "2022-01-01"
|
||||
:transaction/vendor test-vendor-id
|
||||
:transaction/approval-status :transaction-approval-status/approved
|
||||
:transaction/accounts [
|
||||
{:db/id "account"
|
||||
:transaction-account/account test-account-id
|
||||
:transaction-account/location "A"
|
||||
:transaction-account/amount 500.00}]})]
|
||||
|
||||
(is (nil? (:db/id (dc/pull (dc/db conn) journal-pull
|
||||
[:journal-entry/original-entity test-transaction-id]))))
|
||||
(let [db-after (apply-tx update)]
|
||||
(testing "should create journal entry"
|
||||
(is (= #:journal-entry{:date #inst "2022-01-01T00:00:00.000-00:00",
|
||||
:original-entity #:db{:id test-transaction-id},
|
||||
:client #:db{:id test-client-id},
|
||||
:source "transaction",
|
||||
:cleared true,
|
||||
:amount 500.0,
|
||||
:vendor #:db{:id test-vendor-id},
|
||||
:line-items
|
||||
[#:journal-entry-line{:location "A",
|
||||
:dirty true,
|
||||
:debit 500.0}
|
||||
#:journal-entry-line{:account
|
||||
#:account{:name "Account"},
|
||||
:location "A",
|
||||
:credit 500.0,
|
||||
:dirty true}]}
|
||||
(dc/pull db-after journal-pull
|
||||
[:journal-entry/original-entity test-transaction-id])))))
|
||||
|
||||
)))
|
||||
|
||||
Reference in New Issue
Block a user