added new types.
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
(defn determine
|
(defn determine
|
||||||
[[header :as z]]
|
[[header :as z]]
|
||||||
|
(log/info "Importing with header" header)
|
||||||
(let [csv-type (cond (str/includes? (second header) "Customer's PO No.")
|
(let [csv-type (cond (str/includes? (second header) "Customer's PO No.")
|
||||||
:mama-lus
|
:mama-lus
|
||||||
|
|
||||||
@@ -22,6 +23,10 @@
|
|||||||
(str/includes? (str header) "Document Number")
|
(str/includes? (str header) "Document Number")
|
||||||
:philz
|
:philz
|
||||||
|
|
||||||
|
|
||||||
|
(str/includes? (str header) "DISCOUNT_MESSAGE")
|
||||||
|
:wismettac
|
||||||
|
|
||||||
:else
|
:else
|
||||||
nil)]
|
nil)]
|
||||||
(log/info "csv type was determined to be" csv-type)
|
(log/info "csv type was determined to be" csv-type)
|
||||||
@@ -140,6 +145,22 @@
|
|||||||
[]
|
[]
|
||||||
(drop 1 rows)))
|
(drop 1 rows)))
|
||||||
|
|
||||||
|
(defmethod parse-csv :wismettac
|
||||||
|
[rows]
|
||||||
|
(transduce
|
||||||
|
(comp
|
||||||
|
(map (fn [[inv_number inv_dt total :as row]]
|
||||||
|
{:vendor-code "Wismettac"
|
||||||
|
:invoice-number inv_number
|
||||||
|
:date (some-> inv_dt not-empty (parse-date-fallover ["MM/dd/yyyy"]))
|
||||||
|
:total (str/replace total #"," "")
|
||||||
|
:text (str/join " " row)
|
||||||
|
:full-text (str/join " " row)}))
|
||||||
|
)
|
||||||
|
conj
|
||||||
|
[]
|
||||||
|
(drop 1 rows)))
|
||||||
|
|
||||||
(defmethod parse-csv nil
|
(defmethod parse-csv nil
|
||||||
[rows]
|
[rows]
|
||||||
nil)
|
nil)
|
||||||
|
|||||||
@@ -380,6 +380,28 @@
|
|||||||
:parser {:date [:clj-time "MM/dd/yyyy"]
|
:parser {:date [:clj-time "MM/dd/yyyy"]
|
||||||
:total [:trim-commas-and-negate nil]}}
|
:total [:trim-commas-and-negate nil]}}
|
||||||
|
|
||||||
|
;; American Provisions
|
||||||
|
{:vendor "American Paper & Provisions"
|
||||||
|
:keywords [#"imperialdade"]
|
||||||
|
:extract {:date #"([0-9]+/[0-9]+/[0-9]+)"
|
||||||
|
:customer-identifier #"Bill To.*\n\s*(.*?)\s{2,}"
|
||||||
|
:invoice-number #"INVOICE\n(?:.*?)(\s{2,}\d+)"
|
||||||
|
:total #"AMOUNT DUE:\s+([\d\.,\-]+)"}
|
||||||
|
:parser {:date [:clj-time "MM/dd/yyyy"]
|
||||||
|
:total [:trim-commas-and-negate nil]}}
|
||||||
|
|
||||||
|
;; Ocean Queen statement
|
||||||
|
{:vendor "Ocean Queen"
|
||||||
|
:keywords [#"Ocean Queen USA" #"Statement"]
|
||||||
|
:extract {:date #"^([0-9]+/[0-9]+/[0-9]+)"
|
||||||
|
:customer-identifier #"To:.*\n\s*(.*?)\s{2,}"
|
||||||
|
:invoice-number #"INV #(\d+)"
|
||||||
|
:total #" ([\d\.,\-]+)"}
|
||||||
|
:multi #"\n"
|
||||||
|
:multi-match? #"^([0-9]+/[0-9]+/[0-9]+).*INV"
|
||||||
|
:parser {:date [:clj-time "MM/dd/yyyy"]
|
||||||
|
:total [:trim-commas-and-negate nil]}}
|
||||||
|
|
||||||
;; Ocean Queen
|
;; Ocean Queen
|
||||||
{:vendor "Ocean Queen"
|
{:vendor "Ocean Queen"
|
||||||
:keywords [#"Ocean Queen USA"]
|
:keywords [#"Ocean Queen USA"]
|
||||||
|
|||||||
@@ -304,7 +304,7 @@
|
|||||||
[]
|
[]
|
||||||
imports)]
|
imports)]
|
||||||
(when-not (seq transactions)
|
(when-not (seq transactions)
|
||||||
(throw (ex-info "No invoices found."
|
(throw (ex-info "No new invoices found."
|
||||||
{:imports (str imports)})))
|
{:imports (str imports)})))
|
||||||
(log/info "creating invoice" transactions)
|
(log/info "creating invoice" transactions)
|
||||||
@(d/transact (d/connect uri) (vec (set transactions))))))
|
@(d/transact (d/connect uri) (vec (set transactions))))))
|
||||||
|
|||||||
Reference in New Issue
Block a user