supports grouping rules by priority.
This commit is contained in:
@@ -36,7 +36,8 @@
|
||||
(let [result (sut/transactions->txs [base-transaction]
|
||||
:client-id
|
||||
:bank-account-id
|
||||
identity)]
|
||||
identity
|
||||
#{})]
|
||||
(t/is (= [#:transaction {:amount -12.0
|
||||
:date #inst "2014-01-02T08:00:00.000-00:00"
|
||||
:bank-account 456
|
||||
@@ -52,11 +53,22 @@
|
||||
:description-simple "simple-description"}]
|
||||
result))))
|
||||
|
||||
(t/testing "Should not reimport an existing transaction"
|
||||
(let [result (sut/transactions->txs [base-transaction]
|
||||
:client-id
|
||||
:bank-account-id
|
||||
identity
|
||||
#{"6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b"})]
|
||||
(t/is (= []
|
||||
result))))
|
||||
|
||||
|
||||
(t/testing "Should skip transaction if no client is found"
|
||||
(let [result (sut/transactions->txs [(assoc base-transaction :client-id nil)]
|
||||
:client-id
|
||||
:bank-account-id
|
||||
identity)]
|
||||
identity
|
||||
#{})]
|
||||
(t/is (= [] result))))
|
||||
|
||||
(t/testing "Should match an uncleared check"
|
||||
@@ -85,7 +97,8 @@
|
||||
:bank-account-id bank-account-id)]
|
||||
:client-id
|
||||
:bank-account-id
|
||||
identity)]
|
||||
identity
|
||||
#{})]
|
||||
|
||||
(t/is (= {:db/id payment-id
|
||||
:payment/status :payment-status/cleared}
|
||||
@@ -102,7 +115,8 @@
|
||||
:bank-account-id bank-account-id)]
|
||||
:client-id
|
||||
:bank-account-id
|
||||
identity)]
|
||||
identity
|
||||
#{})]
|
||||
|
||||
(t/is (= nil
|
||||
(:transaction/payment result)))))))
|
||||
@@ -135,7 +149,8 @@
|
||||
:client-id
|
||||
:bank-account-id
|
||||
(sut/rule-applying-fn [{:transaction-rule/description "XXX039"
|
||||
:transaction-rule/transaction-approval-status :transaction-approval-status/approved}]))]
|
||||
:transaction-rule/transaction-approval-status :transaction-approval-status/approved}])
|
||||
#{})]
|
||||
|
||||
(t/is (= :transaction-approval-status/approved
|
||||
(:transaction/approval-status result)))))
|
||||
@@ -266,6 +281,8 @@
|
||||
:transaction-rule/amount-gte 5.0}
|
||||
{:db/id 1
|
||||
:transaction-rule/description "Hello"}
|
||||
{:db/id 0
|
||||
:transaction-rule/description "Hello"}
|
||||
{:db/id 3
|
||||
:transaction-rule/description "Hello"
|
||||
:transaction-rule/client {:db/id 789}}
|
||||
@@ -295,6 +312,15 @@
|
||||
:transaction/description-original "Hello"}
|
||||
apply-rules
|
||||
:transaction/matched-rule)))
|
||||
|
||||
(t/testing "Should only apply if there is a single rule at that specificity level"
|
||||
(t/is (nil?
|
||||
(-> {:transaction/bank-account 3
|
||||
:transaction/client 1
|
||||
:transaction/description-original "Hello"
|
||||
:transaction/amount 0.0}
|
||||
apply-rules
|
||||
:transaction/matched-rule))))
|
||||
#_(t/is (nil?
|
||||
(-> {:transaction/bank-account 89}
|
||||
apply-rules
|
||||
|
||||
Reference in New Issue
Block a user