From bb36e3da75a05a5e8f87878a5fb1b760be8b88d2 Mon Sep 17 00:00:00 2001 From: Casey Link Date: Tue, 2 Jul 2024 10:11:23 +0200 Subject: [PATCH] instrument insurance: Expose the Insurer ID field --- resources/lang/en.edn | 1 + src/clj/app/insurance/controller.clj | 7 +++++-- src/clj/app/insurance/views.clj | 13 ++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/resources/lang/en.edn b/resources/lang/en.edn index 061450a..5004305 100644 --- a/resources/lang/en.edn +++ b/resources/lang/en.edn @@ -176,6 +176,7 @@ :status "Workflow Status" :coverage-id "Coverage ID" :types "Coverage Types" + :insurer-id "Harmonia ID" :value "Versicherungswert" :value-hint "The estimated market value of the item, i.e., how much it would cost to replace it if lost." :item-count "Item Count" diff --git a/src/clj/app/insurance/controller.clj b/src/clj/app/insurance/controller.clj index 4d71d06..4bda05a 100644 --- a/src/clj/app/insurance/controller.clj +++ b/src/clj/app/insurance/controller.clj @@ -361,13 +361,14 @@ [:coverage-types [:vector {:min 1} :uuid]] [:value [:int {:min 1}]] [:item-count [:int {:min 1}]] + [:insurer-id {:optional true} :string] [:private-band [:enum "band" "private"]]])) (def UpdateInstrumentAndCoverage "This schema describes the http post we receive when updating an instrument and coverage " (mu/merge UpdateInstrument UpdateCoverage)) -(defn update-coverage-txs [policy {:keys [value coverage-types item-count private-band] :as decoded} coverage owner-changed? category-changed?] +(defn update-coverage-txs [policy {:keys [value coverage-types item-count private-band insurer-id] :as decoded} coverage owner-changed? category-changed?] (let [coverage-ref (d/ref coverage) selected-coverage-type-ids (util/remove-dummy-uuid (mapv util.http/ensure-uuid (util/ensure-coll coverage-types))) private? (= "private" private-band) @@ -405,7 +406,9 @@ [:db/add coverage-ref :instrument.coverage/status (if has-upstream-change? :instrument.coverage.status/needs-review (:instrument.coverage/status coverage))] [:db/add coverage-ref :instrument.coverage/change change-status-value] [:db/add coverage-ref :instrument.coverage/private? private?] - [:db/add coverage-ref :instrument.coverage/item-count item-count]]))) + [:db/add coverage-ref :instrument.coverage/item-count item-count]] + (when-not (str/blank? insurer-id) + [[:db/add coverage-ref :instrument.coverage/insurer-id insurer-id]])))) (defn create-coverage-txs [policy {:keys [value coverage-types item-count private-band policy-id instrument-id] :as decoded}] (let [private? (= "private" private-band) diff --git a/src/clj/app/insurance/views.clj b/src/clj/app/insurance/views.clj index d2d0062..bd2bca5 100644 --- a/src/clj/app/insurance/views.clj +++ b/src/clj/app/insurance/views.clj @@ -580,7 +580,7 @@ Mit freundlichen Grüßen, ([req error coverage coverage-types] (coverage-form req error coverage coverage-types {})) ([{:keys [tr]} error coverage coverage-types {:keys [hide-private?] :as opts}] - (let [{:instrument.coverage/keys [value private? instrument item-count types]} coverage + (let [{:instrument.coverage/keys [value private? instrument item-count types insurer-id]} coverage {:instrument/keys [name]} instrument] (list (ui/text-left :type :number :attr {:step 1 :min 1} :label (tr [:insurance/item-count]) :hint (tr [:insurance/item-count-hint]) :id "item-count" :value (or item-count 1) :error error) @@ -609,7 +609,8 @@ Mit freundlichen Grüßen, :checked? (if (= 0 type-idx) true checked?) :disabled? (= 0 type-idx))))) - coverage-types)))))) + coverage-types)) + (ui/text-left :label (tr [:instrument.coverage/insurer-id]) :id "insurer-id" :value (or insurer-id "") :error error :required? false))))) (declare insurance-instrument-coverage-table) @@ -1161,7 +1162,7 @@ document.addEventListener('DOMContentLoaded', function() { :buttons (list (when (controller/policy-editable? policy) (ui/link-button :hx-boost "true" :href (urls/link-coverage-edit coverage) :label (tr [:action/edit]))))} - (ui/dl + [:dl {:class "grid grid-cols-1 gap-x-4 gap-y-8 sm:grid-cols-4"} (ui/dl-item (tr [:insurance/item-count]) (:instrument.coverage/item-count coverage)) (ui/dl-item (tr [:insurance/value]) @@ -1169,10 +1170,12 @@ document.addEventListener('DOMContentLoaded', function() { (ui/dl-item (tr [:band-private]) (if (:instrument.coverage/private? coverage) [:span {:class "text-red-400"} (tr [:private-instrument])] - [:span {:class "text-green-400"} (tr [:band-instrument])]))) + [:span {:class "text-green-400"} (tr [:band-instrument])])) + (ui/dl-item (tr [:instrument.coverage/insurer-id]) + (:instrument.coverage/insurer-id coverage))] [:div {:class "mt-4 max-w-xs"} [:h3 {:class "font-medium text-sm text-gray-500"} (tr [:insurance/coverage-types])] - [:dl {:class "mt-2 border-t border-b border-gray-200"} + [:dl {:class "mt-2 border-t border-gray-200"} (map (fn [{:insurance.coverage.type/keys [cost name]}] [:div {:class "flex justify-between py-3 text-sm font-medium"} [:dt {:class "text-gray-500"} name]