Skip to content

OBPIH-6341 Fixes for export pick document#4640

Merged
awalkowiak merged 7 commits intodevelopfrom
OBPIH-6341-export-template-for-pick-import
May 28, 2024
Merged

OBPIH-6341 Fixes for export pick document#4640
awalkowiak merged 7 commits intodevelopfrom
OBPIH-6341-export-template-for-pick-import

Conversation

@drodzewicz
Copy link
Collaborator

Include rows for requisition items that don't have picklist items and return quantity 0 for those lines

productCode: picklistItem?.requisitionItem?.product?.productCode ?: "",
productName: picklistItem?.requisitionItem?.product?.name ?: "",
lotNumber: picklistItem?.inventoryItem?.lotNumber ?: "",
expirationDate: picklistItem?.inventoryItem?.expirationDate,
Copy link
Collaborator

Choose a reason for hiding this comment

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

expirationDate doesn't need fallback as the other fields?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

formatPicklistItemPickExport should handle this, actually I should remove these ?: "" from this places since formatPicklistItemPickExport already handles this fallback

render(template: "/picklist/print", model: [requisition: requisition, picklist: picklist, location: location, order: params.order])
}

private Map formatPicklistItemPickExport(Map item) {
Copy link
Member

@jmiranda jmiranda May 27, 2024

Choose a reason for hiding this comment

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

From what I gather, we only need to do the translation once when we generate the CSV column headers. This isn't an expensive operation now that we're using Crowdin, but it would be if we were going to the database every time (with custom translations enabled - g.message does implement database translations but it was intended to).

Either way, I do think this would make more sense at the point of rendering (i.e. generate CSV, generate Excel).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes I understand, but the problem is that this was pretty much the old way of generating csv documents and I just moved this part into it's own function to avoid some dangerous code repetition.

The dataService.generateCsv() takes in the List<Map> and based on the first data entry generates the headings based on keys.

In my previous implementation for csv exporters I had considered generating headings in the generateCSV function, but since we didn't want to proceed with a new the approach for exporters I reverted my changes and used the "old way" using dataService.

So summing up, I do see the problem for calling g.message for each row of List<Map> but I am not sure if we should spend time improving it right now or should we wait for a design (from idea garden ticket) and refactor it then.

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 have updated my appraoch and decided to generate headings before collecting the whole List<Map> and then use that translated string as a key, that way we call g.message once and us that value in the collect.
Check for latest updated files


private Map formatPicklistItemPickExport(Map item) {
return [
"${g.message(code: 'default.id.label')}": item?.id ?: "",
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's add default messages

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure, I was not thinking about it since I just copy pasted the old approach that did not have the default messages

return [
id: picklistItem?.requisitionItem?.id,
productCode: picklistItem?.requisitionItem?.product?.productCode,
productName: picklistItem?.requisitionItem?.product?.name,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm wondering what about synonyms here, if we want to include them or not, so to return displayName ?: name?

"${g.message(code: 'inventoryItem.binLocation.label')}": it?.binLocation?.name ?: "",
"${g.message(code: 'default.quantity.label')}": it?.quantity ?: "",

List<Map> lineItems = pickPageItems.collectMany { pickPageItem ->
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm trying to imagine the use case for the .collectMany here?
From what I understand: https://blog.mrhaki.com/2011/09/groovy-goodness-transform-items-into.html
a basic .collect should also work for you?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

collectMany is for collecting nested lists.
If you look at the first part of the collect I return a list of collected picklists pickPageItem.picklistItems.collect.
So using just a collect will result in a following value eg. [ [a,b,c], [n,c,g] ] if I want to use a simple collect I would need to flatten() at the end

@drodzewicz drodzewicz force-pushed the OBPIH-6341-export-template-for-pick-import branch from ec798e7 to d985862 Compare May 28, 2024 11:32
@awalkowiak awalkowiak merged commit 5732ef2 into develop May 28, 2024
@awalkowiak awalkowiak deleted the OBPIH-6341-export-template-for-pick-import branch May 28, 2024 16:18
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.

5 participants