Skip to content

Commit

Permalink
Split location into location-eori and location-name
Browse files Browse the repository at this point in the history
  • Loading branch information
Remco van 't Veer committed Jun 26, 2024
1 parent 3018ca1 commit 8c5bac8
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 42 deletions.
32 changes: 16 additions & 16 deletions src/dil_demo/erp/web.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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"]]]))
Expand Down Expand Up @@ -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)])]]
Expand All @@ -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)]
"."]
Expand Down Expand Up @@ -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
Expand Down
43 changes: 28 additions & 15 deletions src/dil_demo/otm.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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/and
(s/keys :req-un [::date (or ::location-name ::location-eori)]
:opt-un [::remark])
#(not (and (:location-name %) (:location-eori %)))))

(s/def ::load ::action)
(s/def ::unload ::action)
Expand Down Expand Up @@ -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
Expand Down
23 changes: 12 additions & 11 deletions src/dil_demo/tms/web.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.."])
Expand Down Expand Up @@ -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"]]])])

Expand Down Expand Up @@ -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)])]]])
Expand Down

0 comments on commit 8c5bac8

Please sign in to comment.