Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OBPIH-2718: Fix error with already existing location during receiving… #1782

Merged
merged 1 commit into from
Jul 17, 2020

Conversation

awalkowiak
Copy link
Collaborator

… after destination change

@awalkowiak awalkowiak requested a review from jmiranda July 10, 2020 12:38
@@ -41,6 +47,9 @@ class LocationService {
String name = getReceivingLocationName(shipmentNumber)
String[] receivingLocationNames = [name, "Receiving ${shipmentNumber}"]
Location location = findInternalLocation(parentLocation, receivingLocationNames)
if (!location) {
location = findByLocationNumber(locationNumber)
Copy link
Member

Choose a reason for hiding this comment

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

The underlying issue is that the receiving location is created when we go to the partial receiving page when logged into one location.
https://github.com/openboxes/openboxes/blob/develop/grails-app/controllers/org/pih/warehouse/partialReceiving/PartialReceivingController.groovy#L16

And then the user changes the destination and then goes back to the partial receiving page.

It appears as though this doesn't address the issue as it appear that we are changing the parent location of this receiving location. We're just finding it in a different way and then receiving it into another facilities bin location.

Copy link
Member

Choose a reason for hiding this comment

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

In addition, this scares me because I assume let's say something created a parent location using the same naming convention that we're using for receiving location. I don't think the receiving and putaway feature would be happy if instead of a bin location, it was given a facility location.

There's also a case where we partially receive into the receiving location in one facility and then change the destination (can we even do that?) and then receive the rest of the items into another facility.

Let's ask Kelsey how she expects this to behave.

@awalkowiak awalkowiak added the status: work in progress For issues or pull requests that are in progress but not yet completed label Jul 14, 2020
@awalkowiak
Copy link
Collaborator Author

@jmiranda I fixed it according to the request however, there is one thing that I am not sure about. Parent location can't have empty organization. I am not sure what there should be done if there is a case when user will assign destination that has no organization provided (if this is possible), right now there will be an error (due to failOnError during save) but perhaps there is something that I should do better here?

@awalkowiak awalkowiak added awaiting feedback status: work in progress For issues or pull requests that are in progress but not yet completed and removed status: work in progress For issues or pull requests that are in progress but not yet completed labels Jul 16, 2020
@awalkowiak awalkowiak removed awaiting feedback status: work in progress For issues or pull requests that are in progress but not yet completed labels Jul 16, 2020
@awalkowiak
Copy link
Collaborator Author

@jmiranda done

@@ -350,6 +376,20 @@ class StockMovementApiController {
if (packPageItems) {
createPackPageItemsFromJson(stockMovement, packPageItems)
}

if (stockMovement.statusCode == StockMovementStatusCode.DISPATCHED.toString()) {
Location inventoryLocation = Location.findByLocationNumber(stockMovement.identifier)
Copy link
Member

Choose a reason for hiding this comment

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

I still think we want to look this up by both the parent location (stockMovement.destination) and receiving location. And I believe the identifier is only part of the receiving location name. See LocationService.getReceivingLocationName().

Copy link
Member

Choose a reason for hiding this comment

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

Also, why did you decide to add the logic to the bindStockMovement() method? It feels like the updateShipment() method would be a better place.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Reg 1st comment: After binding, I think I won't see the old destination, hence I was looking by the locationNumber which is unique and is assigned during the creation of an internal location while entering receipt. But sure I'll revisit it and try to look for this location with LocationService.getReceivingLocationName() and LocationService.findInternalLocation().
Reg 2nd comment: I do not recall the particular reason, I think that while I was debugging it I stopped there. I think you're right, the updateShipment will be better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Reg Reg 1st I see that requisition and shipment still have this data.

@@ -104,7 +112,13 @@ class StockMovementApiController {
*/
def updateShipment = { //StockMovement stockMovement ->
StockMovement stockMovement = stockMovementService.getStockMovement(params.id)
bindStockMovement(stockMovement, request.JSON)
try {
Copy link
Member

Choose a reason for hiding this comment

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

I don't mind adding these here, but it seems like this would already happen within the ErrorsController since the exception thrown by bindStockMovement would propagate to the ErrorsController and be rendered properly there. Was there something that made you decide to handle the errors within each of the actions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right. I just automaticaly coverd it with try catch, because I forgot about ErrorController.

@awalkowiak
Copy link
Collaborator Author

@jmiranda I got rid of try catches, I am getting the inventory location by parent location and name and I moved logic to StockMovementService.
However, I see that tests are failing on Travis (locally it is ok). The weird part is that the same test failed in a couple of other PRs.

@jmiranda
Copy link
Member

@jmiranda I got rid of try catches, I am getting the inventory location by parent location and name and I moved logic to StockMovementService.
However, I see that tests are failing on Travis (locally it is ok). The weird part is that the same test failed in a couple of other PRs.

Awesome. I'll take a look at the Travis tests.

@jmiranda jmiranda merged commit 6c35392 into develop Jul 17, 2020
@jmiranda jmiranda deleted the OBPIH-2718 branch July 17, 2020 19:12
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.

None yet

2 participants