Skip to content

Commit

Permalink
instrument insurance: Expose the Insurer ID field
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramblurr committed Jul 2, 2024
1 parent 533f4ea commit bb36e3d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions resources/lang/en.edn
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 5 additions & 2 deletions src/clj/app/insurance/controller.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 8 additions & 5 deletions src/clj/app/insurance/views.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -1161,18 +1162,20 @@ 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])
(ui/money (:instrument.coverage/value coverage) :EUR))
(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]
Expand Down

0 comments on commit bb36e3d

Please sign in to comment.