support for new templates.
This commit is contained in:
@@ -139,7 +139,7 @@
|
|||||||
:customer-identifier #"Bill To[^\n]+\n([A-Za-z ']+)"
|
:customer-identifier #"Bill To[^\n]+\n([A-Za-z ']+)"
|
||||||
:invoice-number #"\n\s+[0-9/]+\s+(\d+)"
|
:invoice-number #"\n\s+[0-9/]+\s+(\d+)"
|
||||||
:total #"Balance Due\s+\$([0-9\.]+)"}
|
:total #"Balance Due\s+\$([0-9\.]+)"}
|
||||||
:parser {#_#_:date [:clj-time "MM/dd/yyyy"]}}
|
:parser {:date [:clj-time "MM/dd/yyyy"]}}
|
||||||
|
|
||||||
|
|
||||||
;; PFG - ROMA
|
;; PFG - ROMA
|
||||||
@@ -150,7 +150,29 @@
|
|||||||
:invoice-number #"INVOICE NO.\s+ ([\d]+)"
|
:invoice-number #"INVOICE NO.\s+ ([\d]+)"
|
||||||
:total #"([\d\.,]+)\s+INVOICE TOTAL"}
|
:total #"([\d\.,]+)\s+INVOICE TOTAL"}
|
||||||
:parser {:date [:clj-time "MM/dd/yy"]
|
: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]
|
(defn offset [c x y]
|
||||||
(.toString (CellAddress. (+ y (.getRow (.getAddress c))) (+ x (.getColumn (.getAddress c))) )))
|
(.toString (CellAddress. (+ y (.getRow (.getAddress c))) (+ x (.getColumn (.getAddress c))) )))
|
||||||
|
|||||||
@@ -14,6 +14,17 @@
|
|||||||
(str/replace value #"," "")
|
(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
|
(defmethod parse-value :clj-time
|
||||||
[_ format value]
|
[_ format value]
|
||||||
(time/from-time-zone (f/parse (f/formatter format) value)
|
(time/from-time-zone (f/parse (f/formatter format) value)
|
||||||
|
|||||||
@@ -161,7 +161,6 @@
|
|||||||
|
|
||||||
(defn import-uploaded-invoice [imports]
|
(defn import-uploaded-invoice [imports]
|
||||||
(let [clients (d-clients/get-all)
|
(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}]
|
transactions (reduce (fn [result {:keys [invoice-number customer-identifier total date vendor-code text full-text] :as info}]
|
||||||
(println "searching for" vendor-code)
|
(println "searching for" vendor-code)
|
||||||
|
|||||||
Reference in New Issue
Block a user