allows manually matching rules.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
[auto-ap.yodlee.core :as c]
|
||||
[datomic.api :as d]
|
||||
[auto-ap.datomic :refer [uri]]
|
||||
[auto-ap.rule-matching :as rm]
|
||||
[auto-ap.datomic.migrate :as m]
|
||||
[clojure.test :as t]))
|
||||
|
||||
@@ -143,13 +144,13 @@
|
||||
[result] (sut/transactions->txs [(assoc base-transaction
|
||||
:description {:original "Hello XXX039"
|
||||
:simple ""}
|
||||
:amount {:amount 30.0}
|
||||
:amount {:amount 31.0}
|
||||
:id 789
|
||||
:bank-account {:db/id bank-account-id
|
||||
:client/_bank-accounts {:db/id client-id
|
||||
:client/locations ["A"]}})]
|
||||
:bank-account
|
||||
(sut/rule-applying-fn [{:transaction-rule/description "XXX039"
|
||||
(rm/rule-applying-fn [{:transaction-rule/description "XXX039"
|
||||
:transaction-rule/transaction-approval-status :transaction-approval-status/approved}])
|
||||
#{})]
|
||||
|
||||
@@ -157,7 +158,7 @@
|
||||
(:transaction/approval-status result)))))
|
||||
|
||||
(t/testing "Should apply vendor and approval status"
|
||||
(let [apply-rules (sut/rule-applying-fn [{:db/id 1
|
||||
(let [apply-rules (rm/rule-applying-fn [{:db/id 1
|
||||
:transaction-rule/description "XXX039"
|
||||
:transaction-rule/transaction-approval-status :transaction-approval-status/approved
|
||||
:transaction-rule/vendor {:db/id 123}
|
||||
@@ -200,7 +201,7 @@
|
||||
(apply-rules []))))))
|
||||
|
||||
(t/testing "Should match if day of month matches"
|
||||
(let [apply-rules (sut/rule-applying-fn [{:db/id 123
|
||||
(let [apply-rules (rm/rule-applying-fn [{:db/id 123
|
||||
:transaction-rule/dom-gte 3
|
||||
:transaction-rule/dom-lte 9
|
||||
:transaction-rule/transaction-approval-status :transaction-approval-status/approved
|
||||
@@ -227,7 +228,7 @@
|
||||
:transaction/matched-rule)))))
|
||||
|
||||
(t/testing "Should match if amount matches"
|
||||
(let [apply-rules (sut/rule-applying-fn [{:db/id 123
|
||||
(let [apply-rules (rm/rule-applying-fn [{:db/id 123
|
||||
:transaction-rule/amount-gte 3.0
|
||||
:transaction-rule/amount-lte 9.0
|
||||
:transaction-rule/transaction-approval-status :transaction-approval-status/approved
|
||||
@@ -254,7 +255,7 @@
|
||||
:transaction/matched-rule)))))
|
||||
|
||||
(t/testing "Should match if client matches"
|
||||
(let [apply-rules (sut/rule-applying-fn [{:db/id 123
|
||||
(let [apply-rules (rm/rule-applying-fn [{:db/id 123
|
||||
:transaction-rule/client {:db/id 456}}])]
|
||||
(t/is (= 123
|
||||
(-> {:transaction/client 456}
|
||||
@@ -265,7 +266,7 @@
|
||||
(apply-rules [])
|
||||
:transaction/matched-rule)))))
|
||||
(t/testing "Should match if bank-account matches"
|
||||
(let [apply-rules (sut/rule-applying-fn [{:db/id 123
|
||||
(let [apply-rules (rm/rule-applying-fn [{:db/id 123
|
||||
:transaction-rule/bank-account {:db/id 456}}])]
|
||||
(t/is (= 123
|
||||
(-> {:transaction/bank-account 456}
|
||||
@@ -277,7 +278,7 @@
|
||||
:transaction/matched-rule)))))
|
||||
|
||||
(t/testing "Should prioritize rules"
|
||||
(let [apply-rules (sut/rule-applying-fn (shuffle [{:db/id 2
|
||||
(let [apply-rules (rm/rule-applying-fn (shuffle [{:db/id 2
|
||||
:transaction-rule/description "Hello"
|
||||
:transaction-rule/amount-gte 5.0}
|
||||
{:db/id 1
|
||||
@@ -322,3 +323,5 @@
|
||||
:transaction/amount 0.0}
|
||||
(apply-rules [])
|
||||
:transaction/matched-rule)))))))))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user