inverting plaid account settings, adding check numbers

This commit is contained in:
Bryce
2023-07-31 16:17:19 -07:00
parent bc57978ceb
commit 205c132b7c

View File

@@ -14,7 +14,8 @@
[digest :as di]
[manifold.deferred :as de]
[manifold.executor :as ex]
[unilog.context :as lc]))
[unilog.context :as lc]
[clojure.string :as str]))
(defn get-plaid-accounts [db]
(-> (dc/q '[:find ?ba ?c ?external-id ?t
@@ -36,12 +37,13 @@
:id #_{:clj-kondo/ignore [:unresolved-var]}
(di/sha-256 (:transaction_id t))
:amount (if (= "credit" (:type (:account t)))
(- (double (:amount t)))
(double (:amount t)))
(double (:amount t))
(- (double (:amount t))))
:date (coerce/to-date (atime/parse (or (:authorized_date t) (:date t)) atime/iso-date))
:status "POSTED"}
(:merchant_name t) (assoc :transaction/plaid-merchant {:plaid-merchant/name (:merchant_name t)
:db/id (random-tempid)})
(not (str/blank? (:check_number t))) (assoc :transaction/check-number (Integer/parseInt (:check_number t)))
(plaid-merchant->vendor-id (:merchant_name t)) (assoc :transaction/default-vendor
(plaid-merchant->vendor-id (:merchant_name t)))))