Minor fixes.

This commit is contained in:
2022-01-11 17:07:40 -08:00
parent 6c9a3d7ece
commit 4d6b3b1e2e
4 changed files with 76 additions and 11 deletions

View File

@@ -66,10 +66,12 @@
(header-row "City1")
(header-row "City2")])
matching-client (or (and account-number
(parse/best-match clients account-number 0.0))
(and customer-identifier
(parse/best-match clients customer-identifier)))
matching-client (and account-number
(parse/best-match clients account-number 0.0))
_ (when-not matching-client
(throw (ex-info "cannot find matching client"
{:account-number account-number
:name customer-identifier})))
total (Double/parseDouble (summary-row "TotalExtendedPrice"))
tax (Double/parseDouble (summary-row "TotalTaxAmount"))
date (t/parse
@@ -133,10 +135,13 @@
(log/infof "Found %d sysco invoice to import: %s" (count keys) (pr-str keys))
(let [result @(d/transact conn (mapv (fn [k]
(-> k
read-sysco-csv
(extract-invoice-details clients sysco-vendor)
))
(try
(-> k
read-sysco-csv
(extract-invoice-details clients sysco-vendor))
(catch Exception e
(log/error e)
[])))
keys))]
(log/infof "Imported %d invoices" (/ (count (:tempids result)) 2)))
(doseq [k keys]

View File

@@ -8,6 +8,7 @@
[auto-ap.routes.invoices :as invoices]
[auto-ap.routes.queries :as queries]
[auto-ap.routes.yodlee :as yodlee]
[auto-ap.routes.yodlee2 :as yodlee2]
[bidi.bidi :as bidi]
[buddy.auth.backends.token :refer [jws-backend]]
[buddy.auth.middleware :refer [wrap-authentication wrap-authorization]]
@@ -55,6 +56,7 @@
(context "/api" []
exports/export-routes
yodlee/routes
yodlee2/routes
queries/query2-routes
invoices/routes
graphql/routes

View File

@@ -21,7 +21,7 @@
(namespaces "invoice-expense-account" ) [[:invoice (:db/id (:invoice/_expense-accounts entity))]]
(namespaces "transaction-account" ) [[:transaction (:db/id (:transaction/_accounts entity))]]
(namespaces "transaction" ) [[:transaction e]]
(namespaces "expected-deposit" ) [[:expected-deposit e]]
#_#_(namespaces "expected-deposit" ) [[:expected-deposit e]]
:else nil)))
@@ -34,7 +34,7 @@
(cond (namespaces "invoice" ) :invoice
(namespaces "invoice-expense-account" ) :invoice-expense-account
(namespaces "transaction-account" ) :transaction-account
(namespaces "expected-deposit" ) :expected-deposit
#_#_(namespaces "expected-deposit" ) :expected-deposit
:else nil)))
(defmulti entity-change->ledger (fn [_ [type]]
@@ -126,7 +126,7 @@
:journal-entry/cleared true})))))
(defmethod entity-change->ledger :expected-deposit
#_(defmethod entity-change->ledger :expected-deposit
[db [type id]]
(let [{:expected-deposit/keys [total client date]} (d/pull db '[:expected-deposit/total :expected-deposit/client :expected-deposit/date] id)]
#:journal-entry

View File

@@ -0,0 +1,58 @@
(ns auto-ap.routes.yodlee2
(:require
[auto-ap.yodlee.core2 :as yodlee]
[auto-ap.graphql.utils :refer [assert-admin]]
[auto-ap.routes.utils :refer [wrap-secure]]
[compojure.core :refer [GET POST context defroutes wrap-routes]]
[config.core :refer [env]]
[clojure.tools.logging :as log]
[auto-ap.datomic.clients :as d-clients]))
(defroutes routes
(wrap-routes
(context "/yodlee2" []
(GET "/fastlink" {:keys [query-params identity] :as request}
(assert-admin identity)
(let [token (yodlee/get-access-token (get query-params "client"))]
{:status 200
:headers {"Content-Type" "application/edn"}
:body (pr-str {:token token
:url (:yodlee2-fastlink env)}) }))
(POST "/provider-accounts/refresh/" {:keys [query-params identity edn-params]
{:keys [id]} :route-params
:as request}
(assert-admin identity)
(log/info "refreshing " edn-params)
(try
(yodlee/refresh-provider-account (-> (:client-id edn-params)
Long/parseLong
d-clients/get-by-id
:client/code)
(:provider-account-id edn-params))
{:status 200
:headers {"Content-Type" "application/edn"}
:body "{}" }
(catch Exception e
(log/error e)
{:status 400
:headers {"Content-Type" "application/edn"}
:body (pr-str {:message (.getMessage e)
:error (.toString e)})})))
(POST "/provider-accounts/delete/" {:keys [edn-params identity] {:keys [id]} :route-params :as request}
(assert-admin identity)
(try
(yodlee/delete-provider-account (-> (:client-id edn-params)
Long/parseLong
d-clients/get-by-id
:client/code)
(:provider-account-id edn-params))
{:status 200
:headers {"Content-Type" "application/edn"}
:body (pr-str {}) }
(catch Exception e
(log/error e)
{:status 400
:headers {"Content-Type" "application/edn"}
:body (pr-str {:message (.getMessage e)
:error (.toString e)})}))))
wrap-secure))