Makes yodlee edit work again

This commit is contained in:
Bryce
2023-08-10 22:04:05 -07:00
parent e2e43534d7
commit a8ce1c1ed7
6 changed files with 2524 additions and 2431 deletions

View File

@@ -79,38 +79,37 @@
:quote? (constantly true))))
(defn write-inference []
(with-open [f (io/writer "~/dev/transaction-training/input/inference.csv")]
(csv/write-csv f
(into [["transaction" "client" "bank" "bank_type" "description" "date" "amount"]]
(->>
(dc/q '[:find ?t ?c ?bn ?bt2 ?do ?d ?amt
:in $ ?start
:where
[?t :transaction/date ?d]
[(>= ?d ?start)]
[?t :transaction/approval-status :transaction-approval-status/unapproved]
(not [?t :transaction/matched-rule])
(not [?t :transaction/payment])
[?t :transaction/client ?c]
[?c :client/code ?code]
(not [?t :transaction/vendor])
(not [?t :transaction/accounts])
[?t :transaction/description-original ?do]
[?t :transaction/amount ?amt]
[?t :transaction/bank-account ?b]
(csv/write-csv *out*
(into [["transaction" "client" "bank" "bank_type" "description" "date" "amount"]]
(->>
(dc/q '[:find ?t ?c ?bn ?bt2 ?do ?d ?amt
:in $ ?start
:where
[?t :transaction/date ?d]
[(>= ?d ?start)]
[?t :transaction/approval-status :transaction-approval-status/unapproved]
(not [?t :transaction/matched-rule])
(not [?t :transaction/payment])
[?t :transaction/client ?c]
[?c :client/code ?code]
(not [?t :transaction/vendor])
(not [?t :transaction/accounts])
[?t :transaction/description-original ?do]
[?t :transaction/amount ?amt]
[?t :transaction/bank-account ?b]
[?b :bank-account/name ?bn]
[?b :bank-account/type ?bat]
[?bat :db/ident ?bt]
[(name ?bt) ?bt2]
]
(dc/db auto-ap.datomic/conn)
#inst "2023-01-01")
(map (fn [[t code bn bat d date amt]]
[t code bn bat d (auto-ap.time/unparse-local (clj-time.coerce/to-date-time date) auto-ap.time/iso-date) amt]))
))
:quote? (constantly true))))
[?b :bank-account/name ?bn]
[?b :bank-account/type ?bat]
[?bat :db/ident ?bt]
[(name ?bt) ?bt2]
]
(dc/db auto-ap.datomic/conn)
#inst "2023-01-01")
(map (fn [[t code bn bat d date amt]]
[t code bn bat d (auto-ap.time/unparse-local (clj-time.coerce/to-date-time date) auto-ap.time/iso-date) amt]))
))
:quote? (constantly true)))

File diff suppressed because it is too large Load Diff

View File

@@ -14,7 +14,8 @@
[bidi.bidi :as bidi]
[config.core :refer [env]]
[datomic.api :as dc]
[hiccup2.core :as hiccup]))
[hiccup2.core :as hiccup]
[auto-ap.datomic :refer [pull-attr]]))
(def default-read '[:db/id
:yodlee-provider-account/last-updated
@@ -47,6 +48,35 @@ fastlink.open({fastLinkURL: '%s',
]
[:div]))))
(defn reauthenticate [{:keys [session form-params]}]
(html-response
(com/modal
{}
(com/modal-card
{}
[:div.flex [:div.p-2 "Yodlee Fastlink"] ]
[:div
[:div#fa-spot]
[:script {:lang "text/javascript"}
(hiccup/raw
(format "
fastlink.open({fastLinkURL: '%s',
accessToken: '%s',
params: {'configName': 'Aggregation',
'providerAccountId': %d,
'flow': 'edit'}},
'fa-spot');
"
(:yodlee2-fastlink env)
(yodlee/get-access-token (-> (pull-attr (dc/db conn)
{:yodlee-provider-account/client [:client/code]}
(Long/parseLong (get form-params "id")))
:yodlee-provider-account/client
:client/code))
(pull-attr (dc/db conn) :yodlee-provider-account/id (Long/parseLong (get form-params "id")))))]]
[:div]))))
(def grid-page {:id "yodlee-table"
:nav (com/company-aside-nav)
:id-fn :db/id
@@ -71,7 +101,13 @@ fastlink.open({fastLinkURL: '%s',
(com/button-icon {} svg/refresh)
"Link new account")])
:row-buttons (fn [user e]
[(when (is-admin? user)
[
(com/button {:hx-put (bidi/path-for ssr-routes/only-routes
:company-yodlee-provider-account-reauthenticate)
:color :primary
:hx-target "#modal-holder"}
"Reauthenticate")
(when (is-admin? user)
(com/icon-button {:hx-put (bidi/path-for ssr-routes/only-routes
:company-yodlee-provider-account-refresh)
:hx-target "closest tr"}

View File

@@ -7,7 +7,7 @@
(defn button- [params & children]
[:button (update params
:class #(cond-> %
true (str " text-white focus:ring-4 font-bold rounded-lg text-sm px-5 py-2.5 text-center mr-2 inline-flex items-center hover:scale-105 transition duration-100 justify-center")
true (str " text-white focus:ring-4 font-bold rounded-lg text-xs p-3 text-center mr-2 inline-flex items-center hover:scale-105 transition duration-100 justify-center")
(= :secondary (:color params)) (str " bg-blue-500 hover:bg-blue-600 focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700")
(= :primary (:color params)) (str " bg-green-500 hover:bg-green-600 focus:ring-green-300 dark:bg-green-600 dark:hover:bg-green-700 ")))
[:div.htmx-indicator.flex.items-center

View File

@@ -37,6 +37,7 @@
:company-yodlee-table (wrap-client-redirect-unauthenticated (wrap-secure company-yodlee/table))
:company-yodlee-fastlink-dialog (wrap-client-redirect-unauthenticated (wrap-secure company-yodlee/fastlink-dialog))
:company-yodlee-provider-account-refresh (wrap-client-redirect-unauthenticated (wrap-admin company-yodlee/refresh-provider-account))
:company-yodlee-provider-account-reauthenticate (wrap-client-redirect-unauthenticated (wrap-admin company-yodlee/reauthenticate))
:company-reports (wrap-client-redirect-unauthenticated (wrap-secure company-reports/page))
:company-reports-table (wrap-client-redirect-unauthenticated (wrap-secure company-reports/table))
:company-reports-delete (wrap-client-redirect-unauthenticated (wrap-admin company-reports/delete-report))

View File

@@ -32,7 +32,8 @@
"/yodlee" {"" {:get :company-yodlee}
"/table" {:get :company-yodlee-table}
"/fastlink" {:get :company-yodlee-fastlink-dialog}
"/refresh" {:put :company-yodlee-provider-account-refresh}}
"/refresh" {:put :company-yodlee-provider-account-refresh}
"/reauthenticate" {:put :company-yodlee-provider-account-reauthenticate}}
"/plaid" {"" {:get :company-plaid}
"/table" {:get :company-plaid-table}