allows editing all vendors.

This commit is contained in:
Bryce
2023-05-25 09:44:30 -07:00
parent c5838e5e3a
commit ab4db8c9ff

View File

@@ -12,10 +12,7 @@
[datomic.api :as dc]
[hiccup2.core :as hiccup]))
(defn cannot-overwrite? [vendor]
(some? (or (:vendor/legal-entity-1099-type vendor)
(:vendor/legal-entity-tin vendor)
(:vendor/legal-entity-tin-type vendor))))
(defn get-1099-companies [user session]
(let [clients (->> (dc/q '[:find ?c
@@ -179,14 +176,12 @@
(-> vendor :vendor/address :address/zip)
[:td "$" (Math/round amount)]
[:td
(if (cannot-overwrite? vendor)
[:a {:href "mailto:ben@integreatconsult.com"} "Contact Integreat"]
[:button.button {:hx-get (bidi/path-for ssr-routes/only-routes
:company-1099-vendor-dialog
:vendor-id (:db/id vendor))
:hx-target "#modal-holder"
:hx-swap "innerHTML"}
[:span.icon [:i.fa.fa-pencil ]]])]]])]]
[:button.button {:hx-get (bidi/path-for ssr-routes/only-routes
:company-1099-vendor-dialog
:vendor-id (:db/id vendor))
:hx-target "#modal-holder"
:hx-swap "innerHTML"}
[:span.icon [:i.fa.fa-pencil ]]]]]])]]
[:div.container.htmx-indicator
[:div.column.is-4.is-offset-4.has-text-centered
[:div.loader.is-loading.is-active.big.is-centered]]]])
@@ -214,12 +209,11 @@
:else k))
(defn vendor-save [{:keys [form-params identity route-params] :as request}]
(when-not (cannot-overwrite? (dc/pull (dc/db conn) '[*] (Long/parseLong (:vendor-id route-params))))
@(dc/transact conn [(remove-nils
(-> (form-data->map form-params)
(assoc :db/id (Long/parseLong (:vendor-id route-params)))
(update :vendor/legal-entity-1099-type #(some->> % not-empty (keyword "legal-entity-1099-type")))
(update :vendor/legal-entity-tin-type #(some->> % not-empty (keyword "legal-entity-tin-type")))))]))
@(dc/transact conn [(remove-nils
(-> (form-data->map form-params)
(assoc :db/id (Long/parseLong (:vendor-id route-params)))
(update :vendor/legal-entity-1099-type #(some->> % not-empty (keyword "legal-entity-1099-type")))
(update :vendor/legal-entity-tin-type #(some->> % not-empty (keyword "legal-entity-tin-type")))))])
(html-response
(table request :flash-id (Long/parseLong (:vendor-id route-params)))))