diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index c9160508..0b2539f6 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -5,6 +5,8 @@ services: ports: - "80:80" - "443:443" + labels: + - com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true volumes: - /var/run/docker.sock:/tmp/docker.sock:ro - /opt/integreat/prod/certs/:/etc/nginx/certs:ro diff --git a/resources/public/index.html b/resources/public/index.html index 29d8b826..0c71916b 100644 --- a/resources/public/index.html +++ b/resources/public/index.html @@ -55,31 +55,35 @@ @keyframes flashWarning { from { + background-color: #00d1b2; } to { + background-color: inherit; - background-color: #00d1b2; } } @keyframes flashPrimary { from { - transform: translateY(100%); - opacity: 0; + background-color: #00d1b2; } to { - background-color: #00d1b2; + background-color: inherit; + + } } tbody tr.live-removed { animation: flashWarning 1.0s ease both; + animation-fill-mode: forwards; } tbody tr.live-added { animation: flashPrimary 1.0s ease both; + animation-fill-mode: forwards; } .left-nav { width: 300px; diff --git a/src/clj/auto_ap/graphql/invoices.clj b/src/clj/auto_ap/graphql/invoices.clj index ad246094..34d4e827 100644 --- a/src/clj/auto_ap/graphql/invoices.clj +++ b/src/clj/auto_ap/graphql/invoices.clj @@ -16,9 +16,11 @@ (when (seq (invoices/find-conflicting {:invoice-number invoice_number :vendor-id vendor_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) _ (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) [invoice] (invoices/insert-multi! [{:invoice-number invoice_number @@ -44,7 +46,7 @@ :invoice-number invoice_number :vendor-id (:vendor-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)) _ (assert-can-see-company (:id context) (:company-id invoice)) updated-invoice (invoices/update (-> in diff --git a/src/clj/auto_ap/routes/graphql.clj b/src/clj/auto_ap/routes/graphql.clj index 6081d471..be8323e2 100644 --- a/src/clj/auto_ap/routes/graphql.clj +++ b/src/clj/auto_ap/routes/graphql.clj @@ -16,9 +16,14 @@ (when (= "none" (:role (:identity r))) (throw-unauthorized)) - (let [variables (some-> (query-params "variables") - edn/read-string)] - {:status 200 - :body (pr-str (ql/query (:identity r) (query-params "query") variables )) - :headers {"Content-Type" "application/edn"}}))) + (try + (let [variables (some-> (query-params "variables") + edn/read-string)] + {:status 200 + :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)) diff --git a/src/clj/auto_ap/yodlee/import.clj b/src/clj/auto_ap/yodlee/import.clj index fe476f65..0c49ad76 100644 --- a/src/clj/auto_ap/yodlee/import.clj +++ b/src/clj/auto_ap/yodlee/import.clj @@ -34,7 +34,8 @@ nil)) (defn extract-check-number [{{description-original :original} :description}] - (if-let [[_ check-number] (re-find #"(?i)check[^0-9]+([0-9]*)" description-original)] + + (if-let [[_ _ check-number] (re-find #"(?i)check(card|[^0-9]+([0-9]*))" description-original)] (try (Integer/parseInt check-number) (catch NumberFormatException e @@ -98,7 +99,7 @@ (mapcat (fn [transaction-group] (map (fn [index {:keys [date description-original high-level-category amount account-id] :as transaction}] - {:id (str date "-" description-original "-" amount "-" index) + {:id (str date "-" description-original "-" amount "-" index "-" company-id) :bank-account-id account-id :date (time/unparse date "YYYY-MM-dd") :amount {:amount amount} diff --git a/src/cljc/auto_ap/entities/vendors.cljc b/src/cljc/auto_ap/entities/vendors.cljc index c44a0c66..b0805117 100644 --- a/src/cljc/auto_ap/entities/vendors.cljc +++ b/src/cljc/auto_ap/entities/vendors.cljc @@ -29,7 +29,8 @@ (s/def ::code (s/nilable string?)) -(s/def ::vendor (s/keys :req-un [::name] +(s/def ::vendor (s/keys :req-un [::name + ::default-expense-account] :opt-un [::code ::id ::print-as @@ -41,7 +42,7 @@ ::secondary-email ::secondary-phone ::address - ::default-expense-account + ])) diff --git a/src/cljs/auto_ap/views/components/invoice_table.cljs b/src/cljs/auto_ap/views/components/invoice_table.cljs index af1855e4..6cefe61e 100644 --- a/src/cljs/auto_ap/views/components/invoice_table.cljs +++ b/src/cljs/auto_ap/views/components/invoice_table.cljs @@ -169,7 +169,7 @@ :aria-haspopup true :tab-index "0" - :on-blur (delayed-dispatch [::toggle-expense-accounts id]) + #_#_:on-blur (delayed-dispatch [::toggle-expense-accounts id]) :on-focus (dispatch-event [::toggle-expense-accounts id]) } "Accounts"]] [:div.dropdown-menu {:role "menu"} diff --git a/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs b/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs index 485fa9c0..a9d1abcc 100644 --- a/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs +++ b/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs @@ -344,7 +344,7 @@ (re-frame/reg-event-fx ::invoice-create-failed (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 ::invoice-created @@ -531,6 +531,14 @@ (when shown? [modal {:title "Print Checks" :foot [:button.button.is-primary {:on-click (dispatch-event [::advanced-print-checks-submitted]) + :disabled (cond printing? + "disabled" + + (seq (filter #(> (js/parseFloat (:amount %)) (js/parseFloat (:outstanding-balance %))) invoices)) + "disabled" + + :else + "") :class (if printing? "is-loading" "")} [:span "Print"]] :hide-event [::cancel-advanced-print]}