diff --git a/src/dil_demo/erp/web.clj b/src/dil_demo/erp/web.clj index db899dd..fa78312 100644 --- a/src/dil_demo/erp/web.clj +++ b/src/dil_demo/erp/web.clj @@ -30,7 +30,7 @@ [:header [:div.status (otm/status-titles status)] [:div.ref-date ref " / " (:date load)] - [:div.from-to (-> load :location eori->name) " → " (:location unload)]] + [:div.from-to (-> load :location-eori eori->name) " → " (:location-name unload)]] [:div.goods goods] [:div.carrier (-> carrier :eori eori->name)] @@ -64,26 +64,26 @@ [:section (w/field {:name "load[date]", :type "date", :label "Ophaaldatum", :value (:date load)}) - (w/field {:name "load[location]", :value (:location load), ;; EORIs?! - :label "Ophaaladres", :type "select", - :list warehouses, :required true}) + (w/field {:name "load[location-eori]", :value (:location-eori load), ;; EORIs?! + :label "Ophaaladres", :type "select", + :list warehouses, :required true}) (w/field {:name "load[remarks]", :value (:remarks load), - :label "Opmerkingen", :type "textarea"})] + :label "Opmerkingen", :type "textarea"})] [:section - (w/field {:name "unload[date]", :value (:date unload), + (w/field {:name "unload[date]", :value (:date unload), :label "Afleverdatum", :type "date"}) - (w/field {:name "unload[location]", :value (:location unload), + (w/field {:name "unload[location-name]", :value (:location-name unload), :label "Afleveradres", :type "text", :list (keys d/locations), :required true}) (w/field {:name "unload[remarks]", :value (:remarks unload), - :label "Opmerkingen", :type "textarea"})] + :label "Opmerkingen", :type "textarea"})] [:section (w/field {:name "goods", :value goods, :label "Goederen", :type "text", :list d/goods, :required true}) (w/field {:name "carrier[eori]", :value (:eori carrier), - :label "Vervoerder", :type "select", - :list carriers, :required true})] + :label "Vervoerder", :type "select", + :list carriers, :required true})] [:section.actions [:button {:type "submit"} "Opslaan"] [:a.button {:href "."} "Annuleren"]]])) @@ -121,15 +121,15 @@ [:section.trip [:fieldset.load-location [:legend "Ophaaladres"] - [:h3 (-> load :location eori->name)] - (when-let [address (-> load :location warehouse-addresses)] + [:h3 (-> load :location-eori eori->name)] + (when-let [address (-> load :location-eori warehouse-addresses)] [:pre address]) (when-not (string/blank? (:remarks load)) [:blockquote.remarks (:remarks load)])] [:fieldset.unload-location [:legend "Afleveradres"] - [:h3 (:location unload)] - (when-let [address (-> unload :location d/locations)] + [:h3 (:location-name unload)] + (when-let [address (-> unload :location-name d/locations)] [:pre address]) (when-not (string/blank? (:remarks unload)) [:blockquote.remarks (:remarks unload)])]] @@ -149,7 +149,7 @@ [:div [:section [:p "Transportopdracht verstuurd naar locatie " - [:q (-> consignment :load :location eori->name)] + [:q (-> consignment :load :location-eori eori->name)] " en vervoerder " [:q (-> consignment :carrier :eori eori->name)] "."] @@ -271,7 +271,7 @@ (assoc ::store/commands [[:put! :consignments consignment] [:publish! ;; to warehouse WMS :transport-orders - (-> consignment :load :location) ;; this is an eori for load locations + (-> consignment :load :location-eori) transport-order] [:publish! ;; to carrier TMS :trips diff --git a/src/dil_demo/otm.clj b/src/dil_demo/otm.clj index 0d823be..f5f2616 100644 --- a/src/dil_demo/otm.clj +++ b/src/dil_demo/otm.clj @@ -73,10 +73,13 @@ (s/and string? #(re-matches #"\d{4}-\d{2}-\d{2}" %))) +(s/def ::location-eori ::eori) + (s/def ::action - (s/keys :req-un [::date - ::location] - :opt-un [::remarks])) + (s/keys :req-un [::date] + :opt-un [::location-name ;; TODO require either not both + ::location-eori + ::remarks])) (s/def ::load ::action) (s/def ::unload ::action) @@ -153,18 +156,28 @@ external-attributes (assoc-in [:entity :external-attributes] external-attributes))) -(defn ->action [{:keys [action-type date location remarks]} - _master-data] - (cond-> - {:association-type association-type-inline - :entity - {:action-type action-type - :start-time date - :location {:association-type association-type-inline - :entity {:name location - :type location-type-warehouse - :geo-reference {}}}}} - remarks (assoc-in [:entity :remarks] remarks))) +(defn ->action [{:keys [action-type date location-eori location-name remarks]} + {:keys [eori->name]}] + (let [location-name (or location-name (eori->name location-eori))] + (cond-> + {:association-type association-type-inline + :entity + {:action-type action-type + :start-time date + :location {:association-type association-type-inline + :entity + {:name location-name + :type location-type-warehouse + :geo-reference {} + :contact-details [{:type contact-details-type-name + :value location-name}]}}}} + location-eori + (update-in [:entity :location :entity :contact-details] conj + {:type contact-details-type-eori + :value location-eori}) + + remarks + (assoc-in [:entity :remarks] remarks)))) (defn ->vehicle [{:keys [license-plate]}] {:association-type association-type-inline diff --git a/src/dil_demo/tms/web.clj b/src/dil_demo/tms/web.clj index 8a051a3..add4bd7 100644 --- a/src/dil_demo/tms/web.clj +++ b/src/dil_demo/tms/web.clj @@ -14,7 +14,7 @@ [dil-demo.web-utils :as w] [ring.util.response :refer [redirect]])) -(defn list-trips [trips master-data] +(defn list-trips [trips {:keys [eori->name]}] [:main (when-not (seq trips) [:article.empty @@ -26,10 +26,9 @@ [:div.status (otm/status-titles status)] [:div.ref-date ref " / " (:date load)] [:div.from-to - (get (:warehouses master-data) - (-> load :location)) + (-> load :location-eori eori->name) " → " - (:location unload)]] + (:location-name unload)]] (cond (and driver-id-digits license-plate) [:p.assigned @@ -41,8 +40,7 @@ (and (= otm/status-outsourced status) (-> carriers last :eori)) [:p.outsourced "Uitbesteed aan " - [:q (get (:carriers master-data) - (-> carriers last :eori))]] + [:q (-> carriers last :eori eori->name)]] :else [:em "Nog niet toegewezen.."]) @@ -73,7 +71,10 @@ [:article [:header [:div.ref-date ref " / " (:date load)]] - [:div.from-to (-> load :location eori->name) " → " (:location unload)] + [:div.from-to + (-> load :location-eori eori->name) + " → " + (:location-name unload)] [:footer.actions [:a.button.primary {:href (str "trip-" id)} "Tonen"]]])]) @@ -114,15 +115,15 @@ [:section.trip [:fieldset.load-location [:legend "Ophaaladres"] - [:h3 (-> load :location eori->name)] - (when-let [address (-> load :location warehouse-addresses)] + [:h3 (-> load :location-eori eori->name)] + (when-let [address (-> load :location-eori warehouse-addresses)] [:pre address]) (when-not (string/blank? (:remarks load)) [:blockquote.remarks (:remarks load)])] [:fieldset.unload-location [:legend "Afleveradres"] - [:h3 (:location unload)] - (when-let [address (-> unload :location d/locations)] + [:h3 (:location-name unload)] + (when-let [address (-> unload :location-name d/locations)] [:pre address]) (when-not (string/blank? (:remarks unload)) [:blockquote.remarks (:remarks unload)])]]])