Forces location matching.

This commit is contained in:
Bryce Covert
2019-03-21 11:30:28 -07:00
parent d270ca89f9
commit 4e72c00895

View File

@@ -29,10 +29,18 @@
(not client-code) (update :errors conj {:info "No client code found"}) (not client-code) (update :errors conj {:info "No client code found"})
(not default-location) (update :errors conj {:info "No default location found"})))) (not default-location) (update :errors conj {:info "No default location found"}))))
(defn parse-client [{:keys [client-code client]} clients] (defn parse-client [{:keys [client-code client default-location]} clients]
(if-let [id (:db/id (or (clients client-code) (if-let [id (:db/id (or (clients client-code)
(clients client)))] (clients client)))]
id (do
(println "FOUND CLIENT" (or (clients client-code)
(clients client)))
(when (not ((set (:client/locations (or (clients client-code)
(clients client))))
default-location))
(throw (Exception. (str "Location '" default-location "' not found for client '" client-code "'.")))
)
id)
(throw (Exception. (str "Client code '" client-code "' and client named '" client "' not found."))))) (throw (Exception. (str "Client code '" client-code "' and client named '" client "' not found.")))))
(defn parse-invoice-number [{:keys [invoice-number]}] (defn parse-invoice-number [{:keys [invoice-number]}]
@@ -109,7 +117,7 @@
(map (parse-or-error :total parse-amount)) (map (parse-or-error :total parse-amount))
(map (parse-or-error :date parse-date)))] (map (parse-or-error :date parse-date)))]
(println "ROWS" rows)
rows)) rows))
(defn invoice-rows->transaction [rows] (defn invoice-rows->transaction [rows]