Merge branch 'master' into clauding

This commit is contained in:
2026-02-08 07:57:52 -08:00
15 changed files with 2274 additions and 51 deletions

View File

@@ -5,7 +5,6 @@
[clojure.string :as str]
[auto-ap.time :as atime]))
(def pdf-templates
[;; CHEF's WAREHOUSE
{:vendor "CHFW"
@@ -45,8 +44,7 @@
:parser {:date [:clj-time "MM/dd/yy"]}
:multi #"\f\f"}
;; IMPACT PAPER
;; IMPACT PAPER
{:vendor "Impact Paper & Ink LTD"
:keywords [#"650-692-5598"]
:extract {:total #"Total Amount\s+\$([\d\.\,\-]+)"
@@ -369,8 +367,7 @@
:parser {:date [:clj-time "MM/dd/yyyy"]
:total [:trim-commas nil]}}
;; Breakthru Bev
;; Breakthru Bev
{:vendor "Wine Warehouse"
:keywords [#"BREAKTHRU BEVERAGE"]
:extract {:date #"Invoice Date:\s+([0-9]+/[0-9]+/[0-9]+)"
@@ -686,13 +683,13 @@
;; TODO DISABLING TO FOCUS ON STATEMENT
#_{:vendor "Reel Produce"
:keywords [#"reelproduce.com"]
:extract {:date #"([0-9]+/[0-9]+/[0-9]+)"
:customer-identifier #"Bill To(?:.*?)\n\n\s+(.*?)\s{2,}"
:invoice-number #"Invoice #\n.*?\n.*?([\d\-]+)\n"
:total #"Total\s*\n\s+\$([\d\-,]+\.\d{2,2}+)"}
:parser {:date [:clj-time "MM/dd/yy"]
:total [:trim-commas-and-negate nil]}}
:keywords [#"reelproduce.com"]
:extract {:date #"([0-9]+/[0-9]+/[0-9]+)"
:customer-identifier #"Bill To(?:.*?)\n\n\s+(.*?)\s{2,}"
:invoice-number #"Invoice #\n.*?\n.*?([\d\-]+)\n"
:total #"Total\s*\n\s+\$([\d\-,]+\.\d{2,2}+)"}
:parser {:date [:clj-time "MM/dd/yy"]
:total [:trim-commas-and-negate nil]}}
{:vendor "Eddie's Produce"
:keywords [#"Eddie's Produce"]
@@ -754,7 +751,30 @@
:parser {:date [:clj-time "MM/dd/yyyy"]
:total [:trim-commas-and-negate nil]}
:multi #"\n"
:multi-match? #"INV #"}])
:multi-match? #"INV #"}
;; Bonanza Produce
{:vendor "Bonanza Produce"
:keywords [#"530-544-4136"]
:extract {:invoice-number #"NO\s+(\d{8,})\s+\d{2}/\d{2}/\d{2}"
:date #"NO\s+\d{8,}\s+(\d{2}/\d{2}/\d{2})"
:customer-identifier #"(?s)I\s+([A-Z][A-Z\s]+?)\s{2,}.*?L\s+([0-9][A-Z0-9\s]+?)(?=\s{2,}|\n)"
:account-number #"(?s)L\s+([0-9][A-Z0-9\s]+?)(?=\s{2,}|\n)"
:total #"SHIPPED\s+[\d\.]+\s+TOTAL\s+([\d\.]+)"}
:parser {:date [:clj-time "MM/dd/yy"]
:total [:trim-commas nil]}}
;; Bonanza Produce Statement (multi-invoice)
{:vendor "Bonanza Produce"
:keywords [#"The perishable agricultural commodities" #"SPARKS, NEVADA"]
:extract {:invoice-number #"^\s+[0-9]{2}/[0-9]{2}/[0-9]{2}\s+([0-9]+)\s+INVOICE"
:customer-identifier #"(.*?)\s+RETURN"
:date #"^\s+([0-9]{2}/[0-9]{2}/[0-9]{2})"
:total #"^\s+[0-9]{2}/[0-9]{2}/[0-9]{2}\s+[0-9]+\s+INVOICE\s+([\d.]+)"}
:parser {:date [:clj-time "MM/dd/yy"]
:total [:trim-commas nil]}
:multi #"\n"
:multi-match? #"\s+[0-9]{2}/[0-9]{2}/[0-9]{2}\s+[0-9]+\s+INVOICE"}])
(def excel-templates
[{:vendor "Mama Lu's Foods"
@@ -784,43 +804,41 @@
{:vendor "Daylight Foods"
:keywords [#"CUSTNO"]
:extract (fn [sheet vendor]
(alog/peek ::daylight-invoices
(transduce (comp
(drop 1)
(filter
(fn [r]
(and
(seq r)
(->> r first not-empty))))
(map
(fn [[customer-number _ _ _ invoice-number date amount :as row]]
(println "DAT E is" date)
{:customer-identifier customer-number
:text (str/join " " row)
:full-text (str/join " " row)
:date (try (or (u/parse-value :clj-time "MM/dd/yyyy" (str/trim date))
(try
(atime/as-local-time
(time/plus (time/date-time 1900 1 1)
(time/days (dec (dec (Integer/parseInt "45663"))))))
(catch Exception e
nil)
))
(catch Exception e
(try
(atime/as-local-time
(time/plus (time/date-time 1900 1 1)
(time/days (dec (dec (Integer/parseInt "45663"))))))
(catch Exception e
nil)
)
))
:invoice-number invoice-number
:total (str amount)
:vendor-code vendor})))
conj
[]
sheet)))}])
(alog/peek ::daylight-invoices
(transduce (comp
(drop 1)
(filter
(fn [r]
(and
(seq r)
(->> r first not-empty))))
(map
(fn [[customer-number _ _ _ invoice-number date amount :as row]]
(println "DAT E is" date)
{:customer-identifier customer-number
:text (str/join " " row)
:full-text (str/join " " row)
:date (try (or (u/parse-value :clj-time "MM/dd/yyyy" (str/trim date))
(try
(atime/as-local-time
(time/plus (time/date-time 1900 1 1)
(time/days (dec (dec (Integer/parseInt "45663"))))))
(catch Exception e
nil)))
(catch Exception e
(try
(atime/as-local-time
(time/plus (time/date-time 1900 1 1)
(time/days (dec (dec (Integer/parseInt "45663"))))))
(catch Exception e
nil))))
:invoice-number invoice-number
:total (str amount)
:vendor-code vendor})))
conj
[]
sheet)))}])