adding vendor.

This commit is contained in:
Bryce Covert
2017-12-10 08:26:42 -08:00
parent 59a0c40beb
commit 6f9a497061
2 changed files with 30 additions and 12 deletions

View File

@@ -4,19 +4,22 @@
[clojure.java.shell :as sh]))
(def templates
[{:keywords [#"CHEF'S WAREHOUSE"]
[{:vendor "CHFW"
:keywords [#"CHEF'S WAREHOUSE"]
:extract {:total #"2 WKS C\.C\.\s+([\d.,]+)"
:customer-identifier #"\n([A-Z][A-Z ]+)\s{2,}"
:date #"\s+([0-9]+/[0-9]+/[0-9]+)"
:invoice-number #"\s+[0-9]+/[0-9]+/[0-9]+\s+([0-9]+)"}}
{:keywords [#"Golden Gate Meat"]
{:vendor "GGM"
:keywords [#"Golden Gate Meat"]
:extract {:total #"Invoice Total\:\s+\$([\d.,]+)"
:customer-identifier #"Bill To\s*:\s*([\w ]+)\s{2,}"
:date #"Printed:\s+([0-9]+/[0-9]+/[0-9]+)"
:invoice-number #"Invoice\s+[^\n]+\n[^\n]+\n\s+([0-9]+)"}}
{:keywords [#"CINTAS CORPORATION"]
{:vendor "CINTAS"
:keywords [#"CINTAS CORPORATION"]
:extract {:invoice-number #"INVOICE\s#\s+([\d.,]+)"
:customer-identifier #"BILL TO\s*:\s{2,}([\w ]+)\s{2,}"
:date #"INVOICE DATE\s*\n.*\s+([0-9]+/[0-9]+/[0-9]+)"
@@ -38,7 +41,7 @@
(fn [result k v]
(assoc result k (some-> (first (map second (re-seq v text)))
str/trim )))
{}))]))
{:vendor (:vendor template)}))]))
(defn parse [text]
(->> templates