you can now import from yodlee, automatically trigger rules, and have it show up on the ledger.

This commit is contained in:
Bryce Covert
2019-05-15 22:37:53 -07:00
parent 31aee76e61
commit ac5ffd26fe
2 changed files with 30 additions and 6 deletions

View File

@@ -196,6 +196,14 @@
(assoc transaction (assoc transaction
:transaction/matched-rule (:db/id top-match) :transaction/matched-rule (:db/id top-match)
:transaction/approval-status (:transaction-rule/transaction-approval-status top-match) :transaction/approval-status (:transaction-rule/transaction-approval-status top-match)
:transaction/accounts (map
(fn [tra]
{:transaction-account/account (:db/id (:transaction-rule-account/account tra))
:transaction-account/amount (Math/abs (* (:transaction-rule-account/percentage tra)
(:transaction/amount transaction)))
:transaction-account/location (:transaction-rule-account/location tra)}
)
(:transaction-rule/accounts top-match))
:transaction/vendor (:db/id (:transaction-rule/vendor top-match))) :transaction/vendor (:db/id (:transaction-rule/vendor top-match)))
transaction))))) transaction)))))

View File

@@ -143,23 +143,39 @@
(let [apply-rules (sut/rule-applying-fn [{:db/id 1 (let [apply-rules (sut/rule-applying-fn [{:db/id 1
:transaction-rule/description "XXX039" :transaction-rule/description "XXX039"
:transaction-rule/transaction-approval-status :transaction-approval-status/approved :transaction-rule/transaction-approval-status :transaction-approval-status/approved
:transaction-rule/vendor {:db/id 123}} :transaction-rule/vendor {:db/id 123}
:transaction-rule/accounts [{:transaction-rule-account/account {:db/id 9}
:transaction-rule-account/location "Z"
:transaction-rule-account/percentage 1.0}]}
{:db/id 2 {:db/id 2
:transaction-rule/description "OtherMatch" :transaction-rule/description "OtherMatch"
:transaction-rule/transaction-approval-status :transaction-approval-status/requires-feedback :transaction-rule/transaction-approval-status :transaction-approval-status/requires-feedback
:transaction-rule/vendor {:db/id 456}}])] :transaction-rule/vendor {:db/id 456}
:transaction-rule/accounts [{:transaction-rule-account/account {:db/id 9}
:transaction-rule-account/location "Z"
:transaction-rule-account/percentage 1.0}]}])]
(t/is (= {:transaction/description-original "Hello XXX039", (t/is (= {:transaction/description-original "Hello XXX039",
:transaction/vendor 123 :transaction/vendor 123
:transaction/approval-status :transaction-approval-status/approved :transaction/approval-status :transaction-approval-status/approved
:transaction/matched-rule 1} :transaction/accounts [{:transaction-account/account 9
(-> {:transaction/description-original "Hello XXX039"} :transaction-account/amount 30.0
:transaction-account/location "Z"}]
:transaction/matched-rule 1
:transaction/amount 30.0}
(-> {:transaction/description-original "Hello XXX039"
:transaction/amount 30.0}
apply-rules))) apply-rules)))
(t/is (= {:transaction/description-original "OtherMatch", (t/is (= {:transaction/description-original "OtherMatch",
:transaction/approval-status :transaction-approval-status/requires-feedback :transaction/approval-status :transaction-approval-status/requires-feedback
:transaction/vendor 456 :transaction/vendor 456
:transaction/matched-rule 2} :transaction/amount 30.0
(-> {:transaction/description-original "OtherMatch"} :transaction/matched-rule 2
:transaction/accounts [{:transaction-account/account 9
:transaction-account/amount 30.0
:transaction-account/location "Z"}]}
(-> {:transaction/description-original "OtherMatch"
:transaction/amount 30.0}
apply-rules))) apply-rules)))
(t/is (= {:transaction/description-original "Hello Not match"} (t/is (= {:transaction/description-original "Hello Not match"}