prepare dashboard

This commit is contained in:
2024-04-26 22:42:32 -07:00
parent c8f438f616
commit 3e4a2b7322
3 changed files with 52 additions and 2 deletions

View File

@@ -14,7 +14,8 @@
[digest :as di]
[manifold.deferred :as de]
[manifold.executor :as ex]
[clojure.string :as str]))
[clojure.string :as str]
[auto-ap.ezcater.core :as e]))
(defn get-plaid-accounts
([db]
@@ -84,6 +85,30 @@
{"id" (:db/id result)
"name" (:plaid-merchant/name result)}))))
(defn upsert-accounts []
(try
(doseq [[bank-account-id client-id external-id access-token] (get-plaid-accounts (dc/db conn))
]
(try
(let [accounts (p/get-accounts access-token)]
@(dc/transact
conn
(for [a (:accounts accounts)]
{:plaid-account/external-id (:account_id a)
:plaid-account/balance (or (some-> a
:balances
:current
double)
0.0) }))
)
(catch Exception e
(alog/warn ::couldnt-upsert-account :error e))))
(catch Exception e
(alog/warn ::couldnt-upsert-accounts :error e))))
(defn import-plaid-int []
(let [import-batch (t/start-import-batch :import-source/plaid "Automated plaid user")
end (atime/local-now)