Changeset 677 for trunk/grails-app/services/InventoryReportService.groovy
- Timestamp:
- Oct 4, 2010, 6:45:47 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/InventoryReportService.groovy
r676 r677 238 238 } // for 239 239 240 /// @todo: This protects against a bug in the report layout, remove when solved. 241 if(result.inventoryTypes.size() > 4) 242 result.inventoryTypes = [[name:'More than 4']] 243 244 if(result.inventoryGroups.size() > 4) 245 result.inventoryGroups = [[name:'More than 4']] 246 240 247 // Success. 241 248 return result … … 287 294 namedParams.siteId = result.site.id 288 295 and 'inventoryStore.site.id = :siteId' 296 namedParams.groupIds = result.inventoryGroups.collect {it.id} 297 and 'inventoryItem.inventoryGroup.id in(:groupIds)' 298 namedParams.typeIds = result.inventoryTypes.collect {it.id} 299 and 'inventoryItem.inventoryType.id in(:typeIds)' 289 300 } 290 301 def baseWhereLogic = new ArrayList(q.whereClauseTerms) … … 292 303 // Count the inventoryItems. 293 304 q.select = 'count(distinct inventoryItem)' 294 result.inventoryItemCount = InventoryItem.executeQuery(q.query, q.namedParams , q.paginateParams)[0]305 result.inventoryItemCount = InventoryItem.executeQuery(q.query, q.namedParams)[0] 295 306 296 307 // Get the first currency found on this site. … … 308 319 309 320 // Get values for each group. 310 q.and 'inventoryItem.inventoryGroup.id = :groupId'311 321 def tempGroups = [] 312 322 result.inventoryGroups.each() { group -> 313 q.namedParams.groupId = group.id323 q.namedParams.groupIds = [group.id] 314 324 def groupValue = InventoryItem.executeQuery(q.query, q.namedParams)[0] ?: 0 315 325 tempGroups << [name: group.name, value: groupValue] 316 326 } 317 318 // Cleanup and reset query. 319 q.namedParams.remove('groupId') 320 q.whereClauseTerms = baseWhereLogic 327 q.namedParams.groupIds = result.inventoryGroups.collect {it.id} // reset. 321 328 result.inventoryGroups = tempGroups 322 329 323 330 // Get values for each type. 324 q.and 'inventoryItem.inventoryType.id = :typeId'325 331 def tempTypes = [] 326 332 result.inventoryTypes.each() { type -> 327 q.namedParams.typeId = type.id333 q.namedParams.typeIds = [type.id] 328 334 def typeValue = InventoryItem.executeQuery(q.query, q.namedParams)[0] ?: 0 329 335 tempTypes << [name: type.name, value: typeValue] 330 336 } 331 332 // Cleanup and reset query.333 q.namedParams.remove('typeId')334 q.whereClauseTerms = baseWhereLogic335 337 result.inventoryTypes = tempTypes 336 338 339 /// @todo: This protects against a bug in the report layout, remove when solved. 340 if(result.inventoryTypes.size() > 4) 341 result.inventoryTypes = [[name:'More than 4', value: 0]] 342 343 if(result.inventoryGroups.size() > 4) 344 result.inventoryGroups = [[name:'More than 4', value: 0]] 345 346 // Check all currency is the same. 337 347 if(currencyCount != 1) 338 348 fail(code:'report.error.multiple.currency.found') // No return, populate errors but continue report.
Note: See TracChangeset
for help on using the changeset viewer.