(ns auto-ap.parse.templates)


(def pdf-templates
  [{: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]+)"}
    :parser {:date [:clj-time "MM/dd/yyyy"]}}

   {:vendor "Golden Gate Meat Company, Inc"
    :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]+)"}
    :parser {:date [:clj-time "MM/dd/yyyy"]
             :total [:trim-commas nil]}}

   {: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]+)"
              :total #"INVOICE TOTAL\s+([0-9.]+)"}
    :parser {:date [:clj-time "MM/dd/yy"]}
    :multi #"\f\f"}

   {:vendor "Carbonic Service Inc"
    :keywords [#"CARBONIC SERVICE INC"]
    :extract {:invoice-number #"Invoice #\s*\n\s*[\w\.]+\s+[\w\./]+(.*)\s*\n"
              :customer-identifier #"Bill To[^\n]+\n[^\n]*\n([\w ]+)\s{2,}"
              :date #"Invoice #\s*\n\s*[\w\.]+\s+([\w\./]+)"
              :total #"Total\s+\$([0-9.]+)"}
    :parser {:date [:clj-time "MM/dd/yy"]}}])

(def excel-templates
  [{:vendor "Isp Productions"
    :keywords [#"ISP PRODUCTIONS"]
    :extract {:customer-identifier [#"SERVICES PROVIDED TO" 1 0]
              :total [#"PAY THIS" -1 0]
              :date [#"INVOICE DATE" 0 1]
              :invoice-number [#"INVOICE NUMBER" 0 1]}}
   {:vendor "SWO"
    :keywords [#"Please note that the total invoice amount may"]
    :extract {:customer-identifier [#"Customer #" 1 0]
              :total [#"Total Invoice" 0 5]
              :date [#"Date" 0 0 #"Date: (.*)"]
              :invoice-number [#"Invoice #" 0 0  #"Invoice #: (.*)"]}}])
