Supports forcing vendor

This commit is contained in:
Bryce Covert
2020-05-11 19:21:48 -07:00
parent 8f66aac170
commit 55960888cf
5 changed files with 118 additions and 25 deletions

View File

@@ -10,8 +10,12 @@
(doto (cond (str/includes? (second header) "Customer's PO No.")
:mama-lus
(str/includes? (str header) "Ship-To Number")
:sysco-style-2
(str/includes? (str header) "Closed Date")
:sysco
:sysco-style-1
:else
nil)
@@ -33,16 +37,16 @@
(first))]
(u/parse-value :clj-time valid-fmt d)))
(defmethod parse-csv :sysco
(defmethod parse-csv :sysco-style-1
[rows]
(println "Importing Sysco")
(println "Importing Sysco-styled 1")
(let [header (first rows)]
(transduce
(comp (drop 1)
(map (fn [row]
(into {} (map vector header row))))
(map (fn [row]
{:vendor-code "Sysco"
{:vendor-code nil
:customer-identifier nil
:invoice-number (get row "Inv #")
:date (parse-date-fallover (get row "Invoice Date") ["M/d/yyyy"])
@@ -53,6 +57,28 @@
[]
rows)))
(defmethod parse-csv :sysco-style-2
[rows]
(println "Importing Sysco-styled 1")
(let [header (first rows)]
(doto
(transduce
(comp (drop 1)
(map (fn [row]
(into {} (map vector header row))))
(map (fn [row]
{:vendor-code nil
:customer-identifier (get row "Ship-To Name")
:invoice-number (str/trim (get row "Invoice Number"))
:date (parse-date-fallover (get row "Invoice Date") ["yyyy-MM-dd"])
:total (str/replace (get row "Original Amount") #"[,\$]" "")
:text (str/join " " (vals row))
:full-text (str/join " " (vals row))})))
conj
[]
rows)
println)))
(defmethod parse-csv :mama-lus
[rows]
(println "MAMA LU4")

View File

@@ -173,7 +173,7 @@
;; WINE WAREHOUSE
{:vendor "Wine Warehouse"
:keywords [#"WINE WAREHOUSE"]
:keywords [#"WINE WAREHOUSE" #"Bottle prices include"]
:extract {:date #"INVOICE DATE\s+([0-9]+/[0-9]+/[0-9]+)"
:customer-identifier #"SHIP-TO-PARTY.*\n(.*?)(?=\s{2,})"
:invoice-number #"INV #\s+(\d+)"
@@ -181,6 +181,26 @@
:parser {:date [:clj-time "MM/dd/yyyy"]
:total [:trim-commas nil]}}
;; WINE WAREHOUSE 3
{:vendor "Wine Warehouse"
:keywords [#"Wine Warehouse" #"PLEASE APPLY CREDIT"]
:extract {:date #"Credit Memo Number/Date\s+\d+\s+([0-9]+/[0-9]+/[0-9]+)"
:customer-identifier #"Ship-To-Party.*\n(.*?)\s{2,}"
:invoice-number #"Credit Memo Number/Date\s+(\d+)"
:total #"Total\s+([0-9]+\.[0-9]{2}-)"}
:parser {:date [:clj-time "MM/dd/yyyy"]
:total [:trim-commas-and-negate nil]}}
;; WINE WAREHOUSE 2
{:vendor "Wine Warehouse"
:keywords [#"WINE WAREHOUSE" #"Bill-to-Party"]
:extract {:date #"Invoice date\s+([0-9]+/[0-9]+/[0-9]+)"
:customer-identifier #"Bill-to-Party.*\n(.*?)\s{2,}"
:invoice-number #"Invoice number\s+(\d+)"
:total #"Gross\s+([0-9]+\.[0-9]{2})"}
:parser {:date [:clj-time "MM/dd/yyyy"]
:total [:trim-commas nil]}}
;; REGAL
{:vendor "Regal Wine Co"
:keywords [#"REGAL WINE"]
@@ -295,6 +315,16 @@
:parser {:date [:clj-time "MM/dd/yyyy"]
:total [:trim-commas-and-negate nil]}}
;; Ocean Queen
{:vendor "Ocean Queen"
:keywords [#"Ocean Queen USA"]
:extract {:date #"([0-9]+/[0-9]+/[0-9]+)"
:customer-identifier #"Bill To.*\n\s*(.*?)\s{2,}"
:invoice-number #"Invoice #\n.*\n.*?(\d+)\n"
:total #"Total\s+\$([\d\.,\-]+)"}
:parser {:date [:clj-time "MM/dd/yyyy"]
:total [:trim-commas-and-negate nil]}}
;; CHEF's CHOICE
{:vendor "Chef's Choice Produce Co"
:keywords [#"(2170 MARTIN AVENUE|213-3886)"]