adding more validation.

This commit is contained in:
BC
2018-07-31 17:55:57 -07:00
parent 271185690a
commit 2cc193a66f
5 changed files with 18 additions and 9 deletions

View File

@@ -5,6 +5,8 @@ services:
ports: ports:
- "80:80" - "80:80"
- "443:443" - "443:443"
labels:
- com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
- /opt/integreat/prod/certs/:/etc/nginx/certs:ro - /opt/integreat/prod/certs/:/etc/nginx/certs:ro

View File

@@ -71,7 +71,7 @@
:plugins [[lein-figwheel "0.5.13"] :plugins [[lein-figwheel "0.5.13"]
[lein-pdo "0.1.1"] [lein-pdo "0.1.1"]
[cider/cider-nrepl "0.16.0"]] [cider/cider-nrepl "0.16.0"]]
:jvm-opts ["-Dconfig=config/dev.edn" #_#_"--add-modules" "java.xml.bind"]} :jvm-opts ["-Dconfig=config/dev.edn" "--add-modules" "java.xml.bind"]}
:uberjar {:prep-tasks [["cljsbuild" "once" "min"] "compile"]} :uberjar {:prep-tasks [["cljsbuild" "once" "min"] "compile"]}
:provided {:dependencies [[org.clojure/clojurescript "1.10.238"] :provided {:dependencies [[org.clojure/clojurescript "1.10.238"]
[reagent "0.7.0"] [reagent "0.7.0"]

View File

@@ -16,9 +16,11 @@
(when (seq (invoices/find-conflicting {:invoice-number invoice_number (when (seq (invoices/find-conflicting {:invoice-number invoice_number
:vendor-id vendor_id :vendor-id vendor_id
:company-id company_id})) :company-id company_id}))
(throw (ex-info "that invoice already exists" {:invoice-number invoice_number}))) (throw (ex-info (str "Invoice '" invoice_number "' already exists.") {:invoice-number invoice_number})))
(let [vendor (-create-or-get-vendor vendor_id vendor_name) (let [vendor (-create-or-get-vendor vendor_id vendor_name)
_ (assert-can-see-company (:id context) company_id) _ (assert-can-see-company (:id context) company_id)
_ (when-not (:default-expense-account vendor)
(throw (ex-info (str "Vendor '" (:name vendor) "' does not have a default expense acount.") {:vendor-id vendor_id} )))
company (companies/get-by-id company_id) company (companies/get-by-id company_id)
[invoice] (invoices/insert-multi! [{:invoice-number invoice_number [invoice] (invoices/insert-multi! [{:invoice-number invoice_number
@@ -44,7 +46,7 @@
:invoice-number invoice_number :invoice-number invoice_number
:vendor-id (:vendor-id invoice) :vendor-id (:vendor-id invoice)
:company-id (:company-id invoice)})) :company-id (:company-id invoice)}))
(throw (ex-info "that invoice already exists" {:invoice-number invoice_number}))) (throw (ex-info (str "Invoice '" invoice_number "' already exists.") {:invoice-number invoice_number})))
paid-amount (- (:total invoice) (:outstanding-balance invoice)) paid-amount (- (:total invoice) (:outstanding-balance invoice))
_ (assert-can-see-company (:id context) (:company-id invoice)) _ (assert-can-see-company (:id context) (:company-id invoice))
updated-invoice (invoices/update (-> in updated-invoice (invoices/update (-> in

View File

@@ -16,9 +16,14 @@
(when (= "none" (:role (:identity r))) (when (= "none" (:role (:identity r)))
(throw-unauthorized)) (throw-unauthorized))
(let [variables (some-> (query-params "variables") (try
edn/read-string)] (let [variables (some-> (query-params "variables")
{:status 200 edn/read-string)]
:body (pr-str (ql/query (:identity r) (query-params "query") variables )) {:status 200
:headers {"Content-Type" "application/edn"}}))) :body (pr-str (ql/query (:identity r) (query-params "query") variables ))
:headers {"Content-Type" "application/edn"}})
(catch Exception e
{:status 400
:body (pr-str {:data (merge {:message (.getMessage e)} (ex-data e))})
:headers {"Content-Type" "application/edn"}}))))
wrap-secure)) wrap-secure))

View File

@@ -344,7 +344,7 @@
(re-frame/reg-event-fx (re-frame/reg-event-fx
::invoice-create-failed ::invoice-create-failed
(fn [{:keys [db]} [_ data]] (fn [{:keys [db]} [_ data]]
{:dispatch [::events/modal-failed ::new-invoice "That invoice already exists."]})) {:dispatch [::events/modal-failed ::new-invoice (:message data)]}))
(re-frame/reg-event-fx (re-frame/reg-event-fx
::invoice-created ::invoice-created