Skip to content

OBPIH-6193 Fix the bin locations report export#4547

Merged
awalkowiak merged 3 commits intofeature/upgrade-to-grails-3.3.10from
OBPIH-6193
Mar 19, 2024
Merged

OBPIH-6193 Fix the bin locations report export#4547
awalkowiak merged 3 commits intofeature/upgrade-to-grails-3.3.10from
OBPIH-6193

Conversation

@kchelstowski
Copy link
Collaborator

No description provided.

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.

Other than the comments below, I wanted to ask whether this export would ever be used for importing data at any time? If so, we have a potential problem if that unitCost should be updated since we'd be setting the value to NULL.

I don't think that's an issue here, but we need to be careful when performing redactions in other exports like the Export Products CSV and then use the export as input to the Import Products feature. It might be better to have a special value (an enum?) that represents a redacted data element. NULL should not be used for this purpose since it's already used to mean "data was not provided".

But this is probably a topic for discussion on the ticket since we'll need Manon and Kelsey to weigh in.

unitCost : formatNumber(number: it.unitCost),
totalValue : formatNumber(number: it.totalValue)
unitCost : hasRoleFinance ? formatNumber(number: unitCost) : null,
totalValue : hasRoleFinance ? formatNumber(number: it.quantity * unitCost) : null
Copy link
Member

Choose a reason for hiding this comment

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

I would recommend keeping the logic hidden behind these convenience methods.

unitCost      : hasRoleFinance ? formatNumber(number: it.unitCost) : null,
totalValue    : hasRoleFinance ? formatNumber(number: it.totalValue) : null

Copy link
Member

Choose a reason for hiding this comment

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

Or justify the switch to moving the logic here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good point

def products = binLocations.collect { it.product.productCode }.unique()
binLocations = binLocations.collect {
List<BinLocationItem> binLocations = inventoryService.getQuantityByBinLocation(location)
List<String> products = binLocations.collect { it.product.productCode }.unique()
Copy link
Member

Choose a reason for hiding this comment

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

I was so confused by these two lines. I thought the unique products were then going to be used to manipulate the binLocations somehow and was going to suggest creating another service method to return the result.

Then I realized products is only used to return a productCount. So I would recommend just returning the count here and setting a default value.

int productCount = binLocations.collect { it.product.productCode }.unique()?.size() ?: 0

There's gotta be a more Groovier way of doing this ^^ no? I spend a few minutes and couldn't find what I was looking for, but it feels like something we should be able to do more succinctly.

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 agree with you, initially I didn't pay much attention to that, since I did only a cosmetic change (def -> type) for that line.
I think I can try something with .groupBy.

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 went with the .groupBy approach. I hope it's cleaner now.

@kchelstowski kchelstowski requested a review from jmiranda March 18, 2024 10:29
Copy link
Collaborator

@awalkowiak awalkowiak left a comment

Choose a reason for hiding this comment

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

Please remove one unnecessary import, other than that lgtm

import grails.plugins.csv.CSVWriter
import grails.plugins.quartz.GrailsJobClassConstants
import org.apache.commons.lang.StringEscapeUtils
import org.grails.buffer.StreamCharBuffer
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this one used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, I'm sorry, forgot to remove it

@awalkowiak awalkowiak merged commit 330bae5 into feature/upgrade-to-grails-3.3.10 Mar 19, 2024
@awalkowiak awalkowiak deleted the OBPIH-6193 branch March 19, 2024 15: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.

3 participants