yodlee and invoice.

This commit is contained in:
2022-01-15 10:43:48 -08:00
parent 3ec3718548
commit 1f96868ee1
4 changed files with 11 additions and 8 deletions

View File

@@ -48,7 +48,6 @@
:full-text full-text}))])))
(defn parse [text]
(info-event "Parsing pdf text" {:raw text})
(reset! last-text text)
(->> t/pdf-templates
(filter (partial template-applies? text))
@@ -134,6 +133,8 @@
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn dbg-parse [v]
(println v)
(map
(fn [x] (dissoc x :full-text :text))
(parse v)))

View File

@@ -162,13 +162,13 @@
:keywords [#"WORLDWIDE PRODUCE"]
:extract {:date #"([0-9]+/[0-9]+/[0-9]+)"
:customer-identifier #"Bill to.*\n\s*(.*?(?=(\s{2,}|\()))"
:invoice-number #"Invoice No\.\s+(\d+)"
:total #"Total\s+([0-9\.,]+)"
:invoice-number #"(?:Invoice|Adjustment) No\.\s+(\d+)"
:total #"Total \S*\s+([0-9\.,\-]+)"
:account-number #"Customer No.\s+(.*?)\s{2}"}
:parser {:date [:clj-time "MM/dd/yy"]
:total [:trim-commas nil]}
:multi (. java.util.regex.Pattern (compile (-> \formfeed str) java.util.regex.Pattern/CASE_INSENSITIVE))
:multi-match? #"Total\s+[0-9\.]+"
:multi-match? #"(Total\s+[0-9\.]+|Total Order)"
}
;; AUTO-CHLOR

View File

@@ -230,7 +230,7 @@
(defn import-uploaded-invoice [user imports]
(lc/with-context {:area "upload-invoice"}
(log/info "Number of invoices to import is" (count imports) "sample: " (first imports))
(log/info "Number of invoices to import is" (count imports) )
(let [clients (d-clients/get-all)
potential-invoices (->> imports
(mapv #(import->invoice % clients))
@@ -240,7 +240,7 @@
(mapv (fn [i] [:propose-invoice i])))]
(when-not (seq potential-invoices)
(throw (ex-info "No new invoices found."
{:imports (str (vec imports))})))
{})))
(log/info "creating invoice" potential-invoices)
@(d/transact (d/connect uri) potential-invoices))))
@@ -425,7 +425,7 @@
:headers {"Content-Type" "application/edn"}}
(catch Exception e
(log/warn e)
{:status 500
{:status 400
:body (pr-str {:message (.getMessage e)
:error (.toString e)
:data (ex-data e)})

View File

@@ -57,7 +57,9 @@
(log/info "logging in as " client-code)
(-> (str (:yodlee2-base-url env) "/auth/token")
(client/post (merge {:headers (assoc base-headers
"loginName" client-code
"loginName" (if (<= (count client-code) 3)
(str client-code client-code)
client-code)
"Content-Type" "application/x-www-form-urlencoded")
:body (str "clientId=" (:yodlee2-client-id env) " &secret=" (:yodlee2-client-secret env))
:as :json}