diff --git a/src/clj/auto_ap/routes/invoices.clj b/src/clj/auto_ap/routes/invoices.clj index d922f108..ac54ac60 100644 --- a/src/clj/auto_ap/routes/invoices.clj +++ b/src/clj/auto_ap/routes/invoices.clj @@ -29,10 +29,18 @@ (not client-code) (update :errors conj {:info "No client code 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) (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."))))) (defn parse-invoice-number [{:keys [invoice-number]}] @@ -109,7 +117,7 @@ (map (parse-or-error :total parse-amount)) (map (parse-or-error :date parse-date)))] - (println "ROWS" rows) + rows)) (defn invoice-rows->transaction [rows]