When plaid merchant is linked to vendor, automatically code to that vendor.
This commit is contained in:
26
test/clj/auto_ap/import/plaid_test.clj
Normal file
26
test/clj/auto_ap/import/plaid_test.clj
Normal file
@@ -0,0 +1,26 @@
|
||||
(ns auto-ap.import.plaid-test
|
||||
(:require [auto-ap.import.plaid :as sut]
|
||||
[clojure.test :as t]))
|
||||
|
||||
(def base-transaction {:name "This is a bank transaction text"
|
||||
:transaction_id "123"
|
||||
:account {:type "debit"}
|
||||
:amount 123.45
|
||||
:date "2023-01-01"})
|
||||
|
||||
(t/deftest plaid->transaction
|
||||
|
||||
(t/testing "Should invert amount if a credit account"
|
||||
(t/is (= 123.45 (:transaction/amount (sut/plaid->transaction base-transaction {}))))
|
||||
(t/is (= -123.45 (:transaction/amount (sut/plaid->transaction (assoc base-transaction :account {:type "credit"}) {})))))
|
||||
(t/testing "Should assign a plaid merchant if a merchant is found"
|
||||
(t/is (= "Home Depot" (-> (sut/plaid->transaction (assoc base-transaction
|
||||
:merchant_name "Home Depot")
|
||||
{})
|
||||
:transaction/plaid-merchant
|
||||
:plaid-merchant/name))))
|
||||
(t/testing "Should assign a default vendor if a merchant is found, with a matching vendor lookup"
|
||||
(t/is (= 12354 (-> (sut/plaid->transaction (assoc base-transaction
|
||||
:merchant_name "Home Depot")
|
||||
{"Home Depot" 12354})
|
||||
:transaction/default-vendor)))))
|
||||
Reference in New Issue
Block a user