Skip to content

OBGM-471 Fix revising items on outbound stock movements#4117

Merged
kchelstowski merged 1 commit intofeature/upgrade-to-grails-3.3.10from
OBGM-471
Jun 21, 2023
Merged

OBGM-471 Fix revising items on outbound stock movements#4117
kchelstowski merged 1 commit intofeature/upgrade-to-grails-3.3.10from
OBGM-471

Conversation

@awalkowiak
Copy link
Collaborator

  • bring back checking if there is need to undo previous changes
  • fix requisition refresh
  • minor NPE fix

- bring back checking if there is need to undo previous changes
- fix requisition refresh
- minor NPE fix
@jmiranda
Copy link
Member

I am looking forward to hearing more about this one.


Set<RequisitionItem> getSubstitutionItems() {
return requisitionItems.findAll {
return requisitionItems?.findAll { RequisitionItem it ->
Copy link
Member

Choose a reason for hiding this comment

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

I'm ok with these changes but can you explain why both of these were necessary?

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 think the latter was required in the end. I was getting NullPointerException here locally, and this was a fix to it.

removeShipmentAndPicklistItemsForModifiedRequisitionItem(requisitionItem)
requisitionItem.undoChanges()
if (requisitionItem.isChanged() || requisitionItem.isCanceled()) {
requisitionItem.undoChanges()
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

?


void createMissingShipmentItems(StockMovement stockMovement) {
Requisition requisition = stockMovement.requisition.refresh()
Requisition requisition = Requisition.get(stockMovement.id)
Copy link
Member

Choose a reason for hiding this comment

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

I assume we're getting this requisition from the session so we should be getting the same object. Curious why we used refresh in the first place (https://pihemr.atlassian.net/browse/OBPIH-1257).

As such, I wonder if this

Requisition requisition = stockMovement.requisition

would suffice.

One worry I have is with stockMovement.id which could potentially represent another object like order, shipment, etc. Would that ever be the case? And if not, we should be explicit about handling these cases i.e. throw an exception.

Copy link
Member

Choose a reason for hiding this comment

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

But that could be done as a post-migration refactoring.

I'm not a big fan of these methods, in general. For one, they are too generically named and should be part of a more specific to the work we're trying to accomplish i.e.

void refreshPicklist(RequisitionItem requisitionItem)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Currently, this one is only used for Requisition-based movements (outbound), but true since stock movement could represent various things, this could be indicated better. I definitely agree with you, on your second comment. This definitely could be something for post-migration refactoring.

I'll check locally how looks:

Requisition requisition = stockMovement.requisition

after revising, and let you know.

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 checked locally the stockMovement.requisition and looks like I had weird glitch or whatever, because all versions:

stockmovement.requisition
stockmovement.requisition.refresh()
Requisition.get(stockmovement.id)

now all return the same state of requisitionItems. 🤔
I'll change it to the stockmovement.requisition and push within my next PR.

Copy link
Member

@jmiranda jmiranda left a comment

Choose a reason for hiding this comment

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

Btw, I'm ok with these changes so feel free to merge if you get an approval.


void createMissingShipmentItems(StockMovement stockMovement) {
Requisition requisition = stockMovement.requisition.refresh()
Requisition requisition = Requisition.get(stockMovement.id)
Copy link
Collaborator

Choose a reason for hiding this comment

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

@jmiranda I assume the refresh() (now the fetch) is done to "undo" any changes introduced to requisition object, but it needs to be confirmed by @awalkowiak
Since code LGTM, I will merge this one, so that it could be tested before the end of the sprint, and we can discuss your doubts later if it sounds OK.

@kchelstowski kchelstowski merged commit 60a7154 into feature/upgrade-to-grails-3.3.10 Jun 21, 2023
@kchelstowski kchelstowski deleted the OBGM-471 branch June 21, 2023 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants