OBPIH-6472 Reintroduce shipment events tab in stock movement UI#4947
OBPIH-6472 Reintroduce shipment events tab in stock movement UI#4947awalkowiak merged 10 commits intodevelopfrom
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4947 +/- ##
============================================
+ Coverage 7.61% 7.62% +0.01%
- Complexity 810 818 +8
============================================
Files 600 600
Lines 42243 42270 +27
Branches 10268 10275 +7
============================================
+ Hits 3216 3224 +8
- Misses 38564 38581 +17
- Partials 463 465 +2 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
5e2687a to
936e2c9
Compare
| <g:select id="eventLocation.id" | ||
| name="eventLocation.id" | ||
| noSelection="['': warehouse.message(code: 'default.selectOne.label')]" | ||
| from='${Location.list()}' |
There was a problem hiding this comment.
Ooof, that Location.list() might be an overkill. On obdev3 this gives us 51646 options with all locations in the system (even inactive). What should be a potential location to choose here? Depots, Wards, Internal Locations? Can we somehow narrow this or do an async select?
There was a problem hiding this comment.
Additional question - should this be required? On the old event tab, it looks like it is preselected with origin and cannot be cleared.
There was a problem hiding this comment.
AND the Location field selects the value “null” by default
| </label> | ||
| </td> | ||
| <td valign="top" class="value ${hasErrors(bean: eventInstance, field: 'eventDate', 'errors')}"> | ||
| <g:datePicker name="eventDate" value="${eventInstance?.eventDate}" precision="minute"/> |
There was a problem hiding this comment.
Should this be required? Or is later set with the current datetime if empty?
There was a problem hiding this comment.
This picker cannot be empty on form submission. It's preset with the current date.
| } | ||
|
|
||
| def events() { | ||
| StockMovement stockMovement = getStockMovement(params.id) |
There was a problem hiding this comment.
I would use the stockMovementService's method to be consistent with the show/view page.
There was a problem hiding this comment.
actually see how the logic is handled for the def show() , I would use the same snippet here:
// Pull Outbound Stock movement (Requisition based) or Outbound or Inbound Return (Order based)
def stockMovement = outboundStockMovementService.getStockMovement(params.id)
// For inbound stockMovement only
if (!stockMovement) {
stockMovement = stockMovementService.getStockMovement(params.id)
}
There was a problem hiding this comment.
I would leave the code as is here, the getStockMovement method was introduced not that long ago, and I can see there is an additional logic inside
// Used by SM show page 'tabs' actions - packing list, documents and receipts
def getStockMovement(String stockMovementId) {
def stockMovement
// Pull stock movement in "old fashion" way to bump up performance a bit (instead of getting OutboundStockMovement) for Non-Returns
def order = Order.get(stockMovementId)
if (order) {
stockMovement = outboundStockMovementService.getStockMovement(stockMovementId)
} else {
stockMovement = stockMovementService.getStockMovement(stockMovementId)
}
return stockMovement
}
There was a problem hiding this comment.
ok, if this method is used for other tabs as well, I'm fine with that
|
|
||
| def events() { | ||
| StockMovement stockMovement = getStockMovement(params.id) | ||
| List<HistoryItem> historyItems = stockMovement.shipment.getHistory() |
There was a problem hiding this comment.
don't we need nullsafes here?
| events?.collect({ | ||
| it.eventType?.eventCode | ||
| })?.unique({ a, b -> a <=> b })?.size() == events?.size() | ||
| List<Event> systemEvents = events.toList().findAll { |
There was a problem hiding this comment.
a titbit, that you probably didn't have to parse it to list, since you have the .findAll method available also for the Set.
There was a problem hiding this comment.
When I am removing the .toList() I am getting:
Cannot cast object '[Shipped|fr:Exp Rwinkwavu Pharmacy Warehouse on 2024-08-23 16:02:22.0]' with class 'java.util.TreeSet' to class 'java.util.List' due to: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.util.List(org.pih.warehouse.core.Event)
There was a problem hiding this comment.
Isn’t it due to the fact that you declared the returned type as List?
|
|
||
| // a shipment can't have two events with the same event code (this should be the case for the current event codes: CREATED, SHIPPED, RECEIVED) | ||
| // we may want to change this in the future? | ||
| // a shipment can't have two system events with the same event code |
There was a problem hiding this comment.
actually what about partially_received events?
There was a problem hiding this comment.
For now I guess it doesn't matter, because we build history items for partially_received events looking at the receipts, not the `events.
Just loud thinking
|
|
||
| Comment comment | ||
|
|
||
| User createdBy |
There was a problem hiding this comment.
(my bad) I can see redundant identifier in this domain (it was moved to the ReferenceDocument).
Could you please remove the identifier from the HistoryItem and the assignments of it (Shipment domain, Receipt domain, Event domain).
5f6c8f9 to
8175267
Compare
| and { | ||
| eq('active', true) | ||
| not { | ||
| 'in'('locationType.locationTypeCode', [LocationTypeCode.INTERNAL, LocationTypeCode.BIN_LOCATION]) |
There was a problem hiding this comment.
you could use LocationTypeCode.listInternalTypeCodes() here.
📷 Screenshots & Recordings (optional)