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")