Skip to content

OBPIH-6472 Reintroduce shipment events tab in stock movement UI#4947

Merged
awalkowiak merged 10 commits intodevelopfrom
OBPIH-6472-2
Nov 25, 2024
Merged

OBPIH-6472 Reintroduce shipment events tab in stock movement UI#4947
awalkowiak merged 10 commits intodevelopfrom
OBPIH-6472-2

Conversation

@alannadolny
Copy link
Collaborator

@alannadolny alannadolny commented Nov 19, 2024

📷 Screenshots & Recordings (optional)

If this PR contains a UI change, consider adding one or more screenshots here or link to a screen recording to help reviewers visualize the change. Otherwise, you can remove this section.
image

@alannadolny alannadolny self-assigned this Nov 19, 2024
@github-actions github-actions bot added domain: frontend Changes or discussions relating to the frontend UI domain: backend Changes or discussions relating to the backend server domain: l10n Changes or discussions relating to localization & Internationalization labels Nov 19, 2024
@codecov
Copy link

codecov bot commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 0% with 21 lines in your changes missing coverage. Please review.

Project coverage is 7.62%. Comparing base (96e3580) to head (86ae66c).
Report is 5 commits behind head on develop.

Files with missing lines Patch % Lines
...-app/domain/org/pih/warehouse/core/Location.groovy 0.00% 8 Missing ⚠️
...warehouse/inventory/StockMovementController.groovy 0.00% 4 Missing ⚠️
...app/domain/org/pih/warehouse/core/EventType.groovy 0.00% 4 Missing ⚠️
.../domain/org/pih/warehouse/shipping/Shipment.groovy 0.00% 4 Missing ⚠️
...g/pih/warehouse/shipping/ShipmentController.groovy 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

<g:select id="eventLocation.id"
name="eventLocation.id"
noSelection="['': warehouse.message(code: 'default.selectOne.label')]"
from='${Location.list()}'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional question - should this be required? On the old event tab, it looks like it is preselected with origin and cannot be cleared.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be required? Or is later set with the current datetime if empty?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This picker cannot be empty on form submission. It's preset with the current date.

}

def events() {
StockMovement stockMovement = getStockMovement(params.id)
Copy link
Collaborator

@kchelstowski kchelstowski Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use the stockMovementService's method to be consistent with the show/view page.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
    }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a titbit, that you probably didn't have to parse it to list, since you have the .findAll method available also for the Set.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually what about partially_received events?

Copy link
Collaborator

@kchelstowski kchelstowski Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(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).

and {
eq('active', true)
not {
'in'('locationType.locationTypeCode', [LocationTypeCode.INTERNAL, LocationTypeCode.BIN_LOCATION])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use LocationTypeCode.listInternalTypeCodes() here.

@awalkowiak awalkowiak merged commit c9f0bf3 into develop Nov 25, 2024
@awalkowiak awalkowiak deleted the OBPIH-6472-2 branch November 25, 2024 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: backend Changes or discussions relating to the backend server domain: frontend Changes or discussions relating to the frontend UI domain: l10n Changes or discussions relating to localization & Internationalization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants