improved import
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
(ns auto-ap.db.invoices
|
||||
(:require [clojure.java.jdbc :as j]
|
||||
[auto-ap.parse :as parse]
|
||||
[auto-ap.db.utils :refer [clj->db db->clj get-conn]]))
|
||||
|
||||
(defn insert-multi! [rows]
|
||||
@@ -26,3 +27,13 @@
|
||||
(if company
|
||||
(map db->clj (j/query (get-conn) ["SELECT * FROM invoices WHERE (imported=false or imported is null) AND company_id = ?" (Integer/parseInt company)]))
|
||||
(map db->clj (j/query (get-conn) "SELECT * FROM invoices WHERE imported=false or imported is null"))))
|
||||
|
||||
(defn import [parsed-invoices companies]
|
||||
(insert-multi!
|
||||
(for [{:keys [total date invoice-number customer-identifier vendor] :as row} parsed-invoices]
|
||||
(do
|
||||
(println row)
|
||||
(assoc row
|
||||
:company (:name (parse/best-match companies customer-identifier))
|
||||
:imported false
|
||||
:potential-duplicate false)))))
|
||||
|
||||
Reference in New Issue
Block a user