yodlee and invoice.
This commit is contained in:
@@ -48,7 +48,6 @@
|
|||||||
:full-text full-text}))])))
|
:full-text full-text}))])))
|
||||||
|
|
||||||
(defn parse [text]
|
(defn parse [text]
|
||||||
(info-event "Parsing pdf text" {:raw text})
|
|
||||||
(reset! last-text text)
|
(reset! last-text text)
|
||||||
(->> t/pdf-templates
|
(->> t/pdf-templates
|
||||||
(filter (partial template-applies? text))
|
(filter (partial template-applies? text))
|
||||||
@@ -134,6 +133,8 @@
|
|||||||
|
|
||||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn dbg-parse [v]
|
(defn dbg-parse [v]
|
||||||
|
(println v)
|
||||||
(map
|
(map
|
||||||
(fn [x] (dissoc x :full-text :text))
|
(fn [x] (dissoc x :full-text :text))
|
||||||
(parse v)))
|
(parse v)))
|
||||||
|
|
||||||
|
|||||||
@@ -162,13 +162,13 @@
|
|||||||
:keywords [#"WORLDWIDE PRODUCE"]
|
:keywords [#"WORLDWIDE PRODUCE"]
|
||||||
:extract {:date #"([0-9]+/[0-9]+/[0-9]+)"
|
:extract {:date #"([0-9]+/[0-9]+/[0-9]+)"
|
||||||
:customer-identifier #"Bill to.*\n\s*(.*?(?=(\s{2,}|\()))"
|
:customer-identifier #"Bill to.*\n\s*(.*?(?=(\s{2,}|\()))"
|
||||||
:invoice-number #"Invoice No\.\s+(\d+)"
|
:invoice-number #"(?:Invoice|Adjustment) No\.\s+(\d+)"
|
||||||
:total #"Total\s+([0-9\.,]+)"
|
:total #"Total \S*\s+([0-9\.,\-]+)"
|
||||||
:account-number #"Customer No.\s+(.*?)\s{2}"}
|
:account-number #"Customer No.\s+(.*?)\s{2}"}
|
||||||
:parser {:date [:clj-time "MM/dd/yy"]
|
:parser {:date [:clj-time "MM/dd/yy"]
|
||||||
:total [:trim-commas nil]}
|
:total [:trim-commas nil]}
|
||||||
:multi (. java.util.regex.Pattern (compile (-> \formfeed str) java.util.regex.Pattern/CASE_INSENSITIVE))
|
: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
|
;; AUTO-CHLOR
|
||||||
|
|||||||
@@ -230,7 +230,7 @@
|
|||||||
|
|
||||||
(defn import-uploaded-invoice [user imports]
|
(defn import-uploaded-invoice [user imports]
|
||||||
(lc/with-context {:area "upload-invoice"}
|
(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)
|
(let [clients (d-clients/get-all)
|
||||||
potential-invoices (->> imports
|
potential-invoices (->> imports
|
||||||
(mapv #(import->invoice % clients))
|
(mapv #(import->invoice % clients))
|
||||||
@@ -240,7 +240,7 @@
|
|||||||
(mapv (fn [i] [:propose-invoice i])))]
|
(mapv (fn [i] [:propose-invoice i])))]
|
||||||
(when-not (seq potential-invoices)
|
(when-not (seq potential-invoices)
|
||||||
(throw (ex-info "No new invoices found."
|
(throw (ex-info "No new invoices found."
|
||||||
{:imports (str (vec imports))})))
|
{})))
|
||||||
(log/info "creating invoice" potential-invoices)
|
(log/info "creating invoice" potential-invoices)
|
||||||
@(d/transact (d/connect uri) potential-invoices))))
|
@(d/transact (d/connect uri) potential-invoices))))
|
||||||
|
|
||||||
@@ -425,7 +425,7 @@
|
|||||||
:headers {"Content-Type" "application/edn"}}
|
:headers {"Content-Type" "application/edn"}}
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
(log/warn e)
|
(log/warn e)
|
||||||
{:status 500
|
{:status 400
|
||||||
:body (pr-str {:message (.getMessage e)
|
:body (pr-str {:message (.getMessage e)
|
||||||
:error (.toString e)
|
:error (.toString e)
|
||||||
:data (ex-data e)})
|
:data (ex-data e)})
|
||||||
|
|||||||
@@ -57,7 +57,9 @@
|
|||||||
(log/info "logging in as " client-code)
|
(log/info "logging in as " client-code)
|
||||||
(-> (str (:yodlee2-base-url env) "/auth/token")
|
(-> (str (:yodlee2-base-url env) "/auth/token")
|
||||||
(client/post (merge {:headers (assoc base-headers
|
(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")
|
"Content-Type" "application/x-www-form-urlencoded")
|
||||||
:body (str "clientId=" (:yodlee2-client-id env) " &secret=" (:yodlee2-client-secret env))
|
:body (str "clientId=" (:yodlee2-client-id env) " &secret=" (:yodlee2-client-secret env))
|
||||||
:as :json}
|
:as :json}
|
||||||
|
|||||||
Reference in New Issue
Block a user