Resets the database, now using real locations for each vendor, and matching against those locations.
This commit is contained in:
@@ -20,7 +20,9 @@
|
||||
n))))
|
||||
|
||||
(defn assoc-company-code [i]
|
||||
(assoc i :company-code (first (str/split (:location i) #"-" ))))
|
||||
(-> i
|
||||
(assoc :company-code (first (str/split (:location i) #"-" )))
|
||||
(assoc :default-location (second (str/split (:location i) #"-" )))))
|
||||
|
||||
(defn parse-company [{:keys [company-code company]} companies]
|
||||
(if-let [id (:id (or (companies company-code)
|
||||
@@ -111,12 +113,14 @@
|
||||
|
||||
all-companies (companies/get-all)
|
||||
all-companies (merge (by :code all-companies) (by :name all-companies))
|
||||
|
||||
|
||||
rows (->> (str/split excel-rows #"\n" )
|
||||
(map #(str/split % #"\t"))
|
||||
(map #(into {} (map (fn [c k] [k c] ) % columns)))
|
||||
(map reset-id)
|
||||
(map assoc-company-code)
|
||||
|
||||
(map (parse-or-error :company-id #(parse-company % all-companies)))
|
||||
(map (parse-or-error :vendor-id #(parse-vendor % all-vendors)))
|
||||
(map (parse-or-error :invoice-number parse-invoice-number))
|
||||
@@ -129,9 +133,10 @@
|
||||
(map :vendor-name)
|
||||
set)
|
||||
insert-rows (vec (->> (filter #(not (seq (:errors %))) rows)
|
||||
(map (fn [{:keys [vendor-id total company-id amount date invoice-number]}]
|
||||
(map (fn [{:keys [vendor-id total company-id amount date invoice-number default-location]}]
|
||||
{:vendor-id vendor-id
|
||||
:company-id company-id
|
||||
:default-location default-location
|
||||
:total total
|
||||
:outstanding-balance total
|
||||
:imported true
|
||||
|
||||
Reference in New Issue
Block a user