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

View File

@@ -59,13 +59,15 @@
[:table {:class "table", :style {:width "100%"}}
[:thead
[:tr
[:th "Vendor"]
[:th "Customer"]
[:th "Invoice #"]
[:th "Date"]
[:th "Amount"]]]
[:tbody (for [{:keys [customer-identifier invoice-number date total id] :as i} @invoices]
[:tbody (for [{:keys [customer-identifier invoice-number date total id vendor] :as i} @invoices]
^{:key (str customer-identifier "-" invoice-number "-" date "-" total "-" id)}
[:tr
[:td vendor]
[:td customer-identifier]
[:td invoice-number]
[:td date]
@@ -106,13 +108,15 @@
[:table {:class "table", :style {:width "100%"}}
[:thead
[:tr
[:th "Vendor"]
[:th "Customer"]
[:th "Invoice #"]
[:th "Date"]
[:th "Amount"]]]
[:tbody (for [{:keys [customer-identifier invoice-number date total id] :as i} @invoices]
[:tbody (for [{:keys [vendor customer-identifier invoice-number date total id] :as i} @invoices]
^{:key (str customer-identifier "-" invoice-number "-" date "-" total "-" id)}
[:tr
[:td vendor]
[:td customer-identifier]
[:td invoice-number]
[:td date]
@@ -139,6 +143,16 @@
[:div {:class "inbox-messages"}
[:form
[:h1.title "New Invoice"]
[:div.field
[:label.label "Vendor"]
[:div.control
[:input.input {:type "text"
:placeholder "CINTAS"
:value (:vendor @form-data)
:on-change (fn [e]
(re-frame/dispatch [::events/change-form-state
[:new-invoice :vendor]
(.. e -target -value)]))}]]]
[:div.field
[:label.label "Customer"]
[:div.control
@@ -181,13 +195,14 @@
(.. e -target -value)]))}]]]
[:div.control
[:submit.button.is-large.is-primary {
:disabled (if (and (:total @form-data) (:date @form-data) (:customer-identifier @form-data) (:invoice-number @form-data))
""
"disabled")
:disabled (if (and (:total @form-data) (:date @form-data) (:customer-identifier @form-data) (:invoice-number @form-data)
(:vendor @form-data))
""
"disabled")
:on-click
(fn [x]
(.preventDefault x)
(re-frame/dispatch [::events/submit-new-invoice @form-data]))}
(fn [x]
(.preventDefault x)
(re-frame/dispatch [::events/submit-new-invoice @form-data]))}
[:span
(when (:loading? @form-data)
[:i.fa.fa-spin.fa-spinner])