support for new templates.

This commit is contained in:
Bryce Covert
2019-11-30 18:07:27 -08:00
parent 94cc8f0f9a
commit 8cdc91d057
3 changed files with 35 additions and 3 deletions

View File

@@ -139,7 +139,7 @@
:customer-identifier #"Bill To[^\n]+\n([A-Za-z ']+)"
:invoice-number #"\n\s+[0-9/]+\s+(\d+)"
:total #"Balance Due\s+\$([0-9\.]+)"}
:parser {#_#_:date [:clj-time "MM/dd/yyyy"]}}
:parser {:date [:clj-time "MM/dd/yyyy"]}}
;; PFG - ROMA
@@ -150,7 +150,29 @@
:invoice-number #"INVOICE NO.\s+ ([\d]+)"
:total #"([\d\.,]+)\s+INVOICE TOTAL"}
:parser {:date [:clj-time "MM/dd/yy"]
:total [:trim-commas nil]}}])
:total [:trim-commas nil]}}
;; PFG - ROMA LOOK 1
{:vendor "Performance Food Group - ROMA"
:keywords [#"inquiries call 1-800-233-6211"]
:extract {:date #"([0-9]+/[0-9]+/[0-9]+)"
:customer-identifier #"BILL TO:\s+([\S ]+?)(?=\s{2,})"
:invoice-number #"^\s+([\dA-Z]+)"
:total #"([\d\.,\-]+\.[\d\-]+)"}
:parser {:date [:clj-time "MM/dd/yyyy"]
:total [:trim-commas-and-negate nil]}
:multi #"\n"
:multi-match? #"^\s+[\d]{6,8}\s+\d+"}
;; JFC
{:vendor "JFC International"
:keywords [#"48490 MILMONT DRIVE"]
:extract {:date #"([0-9]+/[0-9]+/[0-9]+)"
:customer-identifier #"SOLD\s+([\S ]+?)(?=(\s{2,}|\n))"
:invoice-number #"(\S+)\s+(?=[0-9]+/[0-9]+/[0-9]+)"
:total #"(?:INVOICE|TOTAL)\s+([\d\.,\-]+\.[\d\-]+( CR)?)"}
:parser {:date [:clj-time "MM/dd/yyyy"]
:total [:trim-commas-and-negate nil]}}])
(defn offset [c x y]
(.toString (CellAddress. (+ y (.getRow (.getAddress c))) (+ x (.getColumn (.getAddress c))) )))

View File

@@ -14,6 +14,17 @@
(str/replace value #"," "")
)
(defmethod parse-value :trim-commas-and-negate
[_ _ value]
(let [[_ raw-value] (re-find #"([\d\.]+)"
(-> value
(str/replace #"," "")
(str/replace #"-" "")))]
(if (or (str/includes? value "-")
(str/includes? value "CR"))
(str (- (Double/parseDouble raw-value)))
(str raw-value))))
(defmethod parse-value :clj-time
[_ format value]
(time/from-time-zone (f/parse (f/formatter format) value)

View File

@@ -161,7 +161,6 @@
(defn import-uploaded-invoice [imports]
(let [clients (d-clients/get-all)
_ (clojure.pprint/pprint imports)
transactions (reduce (fn [result {:keys [invoice-number customer-identifier total date vendor-code text full-text] :as info}]
(println "searching for" vendor-code)