improved import

This commit is contained in:
Bryce Covert
2018-04-06 17:54:05 -07:00
parent 401ac6c149
commit 6e573a0a57
3 changed files with 13 additions and 22 deletions

View File

@@ -43,16 +43,7 @@
(filter #(re-find #"application/pdf" (:content-type %)) ))]
(let [filename (str "/tmp/" (UUID/randomUUID) ".pdf")]
(io/copy (:body pdf-stream) (io/file filename))
(invoices/insert-multi!
(for [{:keys [total date invoice-number customer-identifier vendor] :as row}
(parse/parse-file filename filename)]
(do
(println row)
(assoc row
:company (:name (parse/best-match companies customer-identifier))
:imported false
:potential-duplicate false))))
(invoices/import (parse/parse-file filename filename) companies)
(io/delete-file filename))))))
(sqs/delete-message (assoc message :queue-url queue-url )))))