prepare dashboard
This commit is contained in:
@@ -14,7 +14,8 @@
|
|||||||
[digest :as di]
|
[digest :as di]
|
||||||
[manifold.deferred :as de]
|
[manifold.deferred :as de]
|
||||||
[manifold.executor :as ex]
|
[manifold.executor :as ex]
|
||||||
[clojure.string :as str]))
|
[clojure.string :as str]
|
||||||
|
[auto-ap.ezcater.core :as e]))
|
||||||
|
|
||||||
(defn get-plaid-accounts
|
(defn get-plaid-accounts
|
||||||
([db]
|
([db]
|
||||||
@@ -84,6 +85,30 @@
|
|||||||
{"id" (:db/id result)
|
{"id" (:db/id result)
|
||||||
"name" (:plaid-merchant/name 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 []
|
(defn import-plaid-int []
|
||||||
(let [import-batch (t/start-import-batch :import-source/plaid "Automated plaid user")
|
(let [import-batch (t/start-import-batch :import-source/plaid "Automated plaid user")
|
||||||
end (atime/local-now)
|
end (atime/local-now)
|
||||||
|
|||||||
@@ -24,7 +24,9 @@
|
|||||||
{:bank-account/intuit-bank-account [:intuit-bank-account/current-balance
|
{:bank-account/intuit-bank-account [:intuit-bank-account/current-balance
|
||||||
[ :intuit-bank-account/last-synced :xform clj-time.coerce/from-date]]}
|
[ :intuit-bank-account/last-synced :xform clj-time.coerce/from-date]]}
|
||||||
{:bank-account/yodlee-account [:yodlee-account/available-balance
|
{:bank-account/yodlee-account [:yodlee-account/available-balance
|
||||||
[:yodlee-account/last-synced :xform clj-time.coerce/from-date]]}]}]
|
[:yodlee-account/last-synced :xform clj-time.coerce/from-date]]}
|
||||||
|
{:bank-account/plaid-account [:plaid-account/balance
|
||||||
|
#_[:yodlee-account/last-synced :xform clj-time.coerce/from-date]]}]}]
|
||||||
(:db/id c)))]
|
(:db/id c)))]
|
||||||
[:div.flex.flex-col.p-4.border-l-2
|
[:div.flex.flex-col.p-4.border-l-2
|
||||||
[:div (:client/name c)]
|
[:div (:client/name c)]
|
||||||
@@ -35,6 +37,7 @@
|
|||||||
(#(str "Synced " %))) ]
|
(#(str "Synced " %))) ]
|
||||||
[:div.inline-flex.justify-between [:div "Source Balance"] (format "$%,.2f" (or (-> b :bank-account/intuit-bank-account :intuit-bank-account/current-balance)
|
[:div.inline-flex.justify-between [:div "Source Balance"] (format "$%,.2f" (or (-> b :bank-account/intuit-bank-account :intuit-bank-account/current-balance)
|
||||||
(-> b :bank-account/yodlee-account :yodlee-account/available-balance)
|
(-> b :bank-account/yodlee-account :yodlee-account/available-balance)
|
||||||
|
(-> b :bank-account/plaid-account :plaid-account/balance)
|
||||||
0.0))]
|
0.0))]
|
||||||
[:div.inline-flex.justify-end.text-xs.text-gray-400.it (or (some-> (:bank-account/intuit-bank-account b)
|
[:div.inline-flex.justify-end.text-xs.text-gray-400.it (or (some-> (:bank-account/intuit-bank-account b)
|
||||||
(:intuit-bank-account/last-synced)
|
(:intuit-bank-account/last-synced)
|
||||||
|
|||||||
@@ -367,3 +367,25 @@
|
|||||||
(ffirst (dc/q '[:find ?v :where [?v :vendor/name "CCP Doordash"]] db))))
|
(ffirst (dc/q '[:find ?v :where [?v :vendor/name "CCP Doordash"]] db))))
|
||||||
:separator \tab)
|
:separator \tab)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(def taptelis-clients (->> (dc/q '[:find ?c
|
||||||
|
:where [?u :user/name ?n]
|
||||||
|
[?u :user/clients ?c]
|
||||||
|
[?c :client/code ?cc]
|
||||||
|
[(clojure.string/includes? ?n "Nick Taptelis")]]
|
||||||
|
(dc/db conn))
|
||||||
|
(map first)
|
||||||
|
set))
|
||||||
|
|
||||||
|
(clojure.data.csv/write-csv *out* (dc/q '[:find ?v ?cnt
|
||||||
|
:in $ [?c ...]
|
||||||
|
:where [?vu :vendor-usage/vendor ?v]
|
||||||
|
[?vu :vendor-usage/client ?c]
|
||||||
|
[?vu :vendor-usage/count ?cnt]
|
||||||
|
[(> ?cnt 0)]]
|
||||||
|
(dc/db conn)
|
||||||
|
taptelis-clients)
|
||||||
|
:separator \tab)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user