OBPIH-6341 Fixes for export pick document#4640
Conversation
| productCode: picklistItem?.requisitionItem?.product?.productCode ?: "", | ||
| productName: picklistItem?.requisitionItem?.product?.name ?: "", | ||
| lotNumber: picklistItem?.inventoryItem?.lotNumber ?: "", | ||
| expirationDate: picklistItem?.inventoryItem?.expirationDate, |
There was a problem hiding this comment.
expirationDate doesn't need fallback as the other fields?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?: "", |
There was a problem hiding this comment.
let's add default messages
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 -> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
ec798e7 to
d985862
Compare
Include rows for requisition items that don't have picklist items and return quantity 0 for those lines