Adds ability to find expected deposits and link them
This commit is contained in:
@@ -135,6 +135,65 @@
|
||||
(t/is (= nil
|
||||
(:transaction/payment result)))))))
|
||||
|
||||
(t/testing "Should match expected-deposits"
|
||||
(let [{:strs [bank-account-id client-id expected-deposit-id]} (->> [#:expected-deposit {:client "client-id"
|
||||
:date #inst "2021-07-01T00:00:00-08:00"
|
||||
:total 100.0
|
||||
:location "MF"
|
||||
:status :expected-deposit-status/pending
|
||||
:db/id "expected-deposit-id"}
|
||||
#:bank-account {:name "Bank account"
|
||||
:db/id "bank-account-id"}
|
||||
#:client {:name "Client"
|
||||
:db/id "client-id"
|
||||
:locations ["MF"]
|
||||
:bank-accounts ["bank-account-id"]}]
|
||||
(d/transact (d/connect uri))
|
||||
deref
|
||||
:tempids)]
|
||||
|
||||
|
||||
(t/testing "Should match within 10 days"
|
||||
(let [[[transaction-result]] (sut/transactions->txs [(assoc base-transaction
|
||||
:date "2021-07-03"
|
||||
:amount {:amount -100.0}
|
||||
:bank-account {:db/id bank-account-id
|
||||
:client/_bank-accounts {:db/id client-id
|
||||
:client/locations ["MF"]}})]
|
||||
:bank-account
|
||||
noop-rule
|
||||
#{})]
|
||||
(t/is (= expected-deposit-id
|
||||
(sut/find-expected-deposit client-id 100.0 (clj-time.coerce/to-date-time #inst "2021-07-03T00:00:00-08:00"))))
|
||||
|
||||
(t/is (= {:db/id expected-deposit-id
|
||||
:expected-deposit/status :expected-deposit-status/cleared}
|
||||
(:transaction/expected-deposit transaction-result)))))
|
||||
|
||||
(t/testing "Should not match old expected deposits"
|
||||
(let [[[transaction-result]] (sut/transactions->txs [(assoc base-transaction
|
||||
:date "2021-07-13"
|
||||
:amount {:amount -100.0}
|
||||
:bank-account {:db/id bank-account-id
|
||||
:client/_bank-accounts {:db/id client-id
|
||||
:client/locations ["MF"]}})]
|
||||
:bank-account
|
||||
noop-rule
|
||||
#{})]
|
||||
(t/is (not (:transaction/expected-deposit transaction-result)))))
|
||||
|
||||
(t/testing "Should only match exact."
|
||||
(let [[[transaction-result]] (sut/transactions->txs [(assoc base-transaction
|
||||
:date "2021-07-03"
|
||||
:amount {:amount -100.01}
|
||||
:bank-account {:db/id bank-account-id
|
||||
:client/_bank-accounts {:db/id client-id
|
||||
:client/locations ["MF"]}})]
|
||||
:bank-account
|
||||
noop-rule
|
||||
#{})]
|
||||
(t/is (not (:transaction/expected-deposit transaction-result)))))))
|
||||
|
||||
#_(t/testing "Auto-pay Invoices"
|
||||
(t/testing "Should match paid invoice that doesn't have a payment yet"
|
||||
(let [{:strs [bank-account-id client-id invoice1-id invoice2-id vendor-id]} (->> [#:invoice {:status :invoice-status/paid
|
||||
|
||||
Reference in New Issue
Block a user