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

OBAM-172 First page of the bin replenishment wizard #2650

Merged
merged 4 commits into from
Sep 17, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
OBAM-172 Deal with inventory level duplications
  • Loading branch information
awalkowiak committed Sep 16, 2021
commit 3cb53d4447f716089032ec875ef626a31d68f84f
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,26 @@ class ReplenishmentService {
boolean transactional = true

def getRequirements(Location location, InventoryLevelStatus inventoryLevelStatus) {
return Requirement.createCriteria().list() {
List<Requirement> requirements = []
Requirement.createCriteria().list() {
eq("location", location)
eq("status", inventoryLevelStatus)
product {
order("productCode", "asc")
order("name", "asc")
}.collect { Requirement requirement ->
Copy link
Contributor

Choose a reason for hiding this comment

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

why are you using collect here instead of findAll?

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 thought it will be an easier and cleaner way of getting rid of duplicates.

Copy link
Contributor

Choose a reason for hiding this comment

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

in this case unique() should be fine

Copy link
Member

Choose a reason for hiding this comment

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

Agree with @pmuchowski. Seems like each (iterate) would be better than collect (transform), but unique seems like the better option.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

if (requirements.find {
it.product == requirement.product &&
it.location == requirement.location &&
it.binLocation == requirement.binLocation
}) {
return
}
binLocation {
order("zone", "asc")
order("name", "asc")
}
order("quantityInBin", "asc")
requirements << requirement
}
return requirements.findAll { it != null }.sort { a, b ->
a.product.productCode <=> b.product.productCode ?:
a.binLocation.zone.name <=> b.binLocation.zone.name ?:
a.binLocation.name <=> b.binLocation.name ?:
a.quantityInBin <=> b.quantityInBin
}
}

Order createOrUpdateOrderFromReplenishment(Replenishment replenishment) {
Expand Down