working on UI.

This commit is contained in:
Bryce Covert
2021-01-09 00:09:52 -08:00
parent c6dd929c86
commit d3232c70b2
8 changed files with 242 additions and 117 deletions

View File

@@ -174,6 +174,8 @@
(:transaction/approval-status transaction-tx))
(str "Should have approved transaction " transaction-tx))
(t/is (= #:payment{:status :payment-status/cleared
:type :payment-type/debit
:date (:transaction/date transaction-tx)
:client client-id
:bank-account bank-account-id
:vendor vendor-id
@@ -437,7 +439,7 @@
:transaction/matched-rule))))))))
(t/deftest match-transaction-to-unfulfilled-payments
(t/deftest match-transaction-to-single-unfulfilled-payments
(t/testing "Auto-pay Invoices"
(let [{:strs [vendor1-id vendor2-id]} (->> [#:vendor {:name "Autopay vendor 1"
:db/id "vendor1-id"}
@@ -458,7 +460,7 @@
(d/transact (d/connect uri))
deref
:tempids)
invoices-matches (sut/match-transaction-to-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)))
))
@@ -473,7 +475,7 @@
(d/transact (d/connect uri))
deref
:tempids)
invoices-matches (sut/match-transaction-to-unfulfilled-autopayments -30.0 client-id)]
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
(t/is (= [] invoices-matches))))
@@ -489,7 +491,7 @@
(d/transact (d/connect uri))
deref
:tempids)
invoices-matches (sut/match-transaction-to-unfulfilled-autopayments -30.0 client-id)]
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0 client-id)]
(t/is (= [] invoices-matches))))
@@ -508,7 +510,7 @@
(d/transact (d/connect uri))
deref
:tempids)
invoices-matches (sut/match-transaction-to-unfulfilled-autopayments -30.0
invoices-matches (sut/match-transaction-to-single-unfulfilled-autopayments -30.0
client-id)]
(t/is (= [] invoices-matches))))
(t/testing "Should match multiple invoices for same vendor that total to transaction amount"
@@ -530,7 +532,7 @@
(d/transact (d/connect uri))
deref
:tempids)
invoices-matches (sut/match-transaction-to-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))
(str "Expected " (vec invoices-matches) " to have a singular match of two invoices."))))
(t/testing "Should not match if there are multiple candidate matches"
@@ -552,7 +554,7 @@
(d/transact (d/connect uri))
deref
:tempids)
invoices-matches (sut/match-transaction-to-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))
(str "Expected " (vec invoices-matches) " to not match due to multiple possibilities."))))
@@ -575,7 +577,7 @@
(d/transact (d/connect uri))
deref
:tempids)
invoices-matches (sut/match-transaction-to-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))
(str "Expected " (vec invoices-matches) " to only consider invoices for the same vendor."))))
@@ -605,7 +607,7 @@
(d/transact (d/connect uri))
deref
:tempids)]
(t/is (= 2 (count (sut/match-transaction-to-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."))
(t/is (= [] (sut/match-transaction-to-unfulfilled-autopayments -31.0 client-id))
(t/is (= [] (sut/match-transaction-to-single-unfulfilled-autopayments -31.0 client-id))
(str "Expected to not match, because there is invoice-3 is between invoice-1 and invoice-2.")))))))