several fixes.

This commit is contained in:
Bryce Covert
2020-04-25 08:33:37 -07:00
parent b6696c8c45
commit a8736f351e
5 changed files with 45 additions and 48 deletions

View File

@@ -36,19 +36,22 @@
(defmethod parse-csv :sysco
[rows]
(println "Importing Sysco")
(transduce
(comp (drop 1)
(map (fn [[invoice-number invoice-date _ amount :as row]]
{:vendor-code "Sysco"
:customer-identifier nil
:invoice-number invoice-number
:date (parse-date-fallover invoice-date ["M/d/yyyy"])
:total (str/replace amount #"[,\$]" "")
:text (str/join " " row)
:full-text (str/join " " row)})))
conj
[]
rows))
(let [header (first rows)]
(transduce
(comp (drop 1)
(map (fn [row]
(into {} (map vector header row))))
(map (fn [row]
{:vendor-code "Sysco"
:customer-identifier nil
:invoice-number (get row "Inv #")
:date (parse-date-fallover (get row "Invoice Date") ["M/d/yyyy"])
:total (str/replace (get row "Orig Amt") #"[,\$]" "")
:text (str/join " " (vals row))
:full-text (str/join " " (vals row))})))
conj
[]
rows)))
(defmethod parse-csv :mama-lus
[rows]

View File

@@ -111,11 +111,11 @@
:extract {:date #"([0-9]+/[0-9]+/[0-9]+)"
:customer-identifier #"Bill To:(?:.*?(?=\s{2,}))(.*)-"
:invoice-number #"Invoice\s+([0-9]+)"
:total #"\$([0-9\.,]+)"}
:total #"([0-9\.,]+)$"}
:parser {:date [:clj-time "MM/dd/yyyy"]
:total [:trim-commas nil]}
:multi #"\n"
:multi-match? #"^ [0-9]+"}
:multi-match? #"^\s{1,2}[0-9]+"}
;; Royal Hawaiian
{:vendor "Royal Hawaiian"