Changeset 690


Ignore:
Timestamp:
Oct 11, 2010, 11:57:58 AM (9 years ago)
Author:
gav
Message:

Fix for ticket #85, Null pointer bug on inventory reports.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/services/InventoryReportService.groovy

    r677 r690  
    184184        result.site = Site.get(params.site.id.toLong())
    185185
    186         if(params.inventoryTypes) {
     186        result.inventoryTypes = []
     187        if(params.inventoryTypes instanceof String)
     188            result.inventoryTypes << InventoryType.get(params.inventoryTypes.toInteger())
     189        else if(params.inventoryTypes)
    187190            result.inventoryTypes = params.inventoryTypes.collect { InventoryType.get(it.toInteger()) }
    188         }
    189191        else
    190192            result.inventoryTypes = InventoryType.findAllByIsActive(true, [max:254, sort:'name'])
    191193
    192         if(params.inventoryGroups) {
     194        result.inventoryGroups = []
     195        if(params.inventoryGroups instanceof String)
     196            result.inventoryGroups << InventoryGroup.get(params.inventoryGroups.toInteger())
     197        else if(params.inventoryGroups)
    193198            result.inventoryGroups = params.inventoryGroups.collect { InventoryGroup.get(it.toInteger()) }
    194         }
    195199        else
    196200            result.inventoryGroups = InventoryGroup.findAllByIsActive(true, [max:254, sort:'name'])
     
    267271        result.site = Site.get(params.site.id.toLong())
    268272
    269         if(params.inventoryTypes)
     273        result.inventoryTypes = []
     274        if(params.inventoryTypes instanceof String)
     275            result.inventoryTypes << InventoryType.get(params.inventoryTypes.toInteger())
     276        else if(params.inventoryTypes)
    270277            result.inventoryTypes = params.inventoryTypes.collect { InventoryType.get(it.toInteger()) }
    271278        else
    272279            result.inventoryTypes = InventoryType.findAllByIsActive(true, [max:254, sort:'name'])
    273280
    274         if(params.inventoryGroups)
     281        result.inventoryGroups = []
     282        if(params.inventoryGroups instanceof String)
     283            result.inventoryGroups << InventoryGroup.get(params.inventoryGroups.toInteger())
     284        else if(params.inventoryGroups)
    275285            result.inventoryGroups = params.inventoryGroups.collect { InventoryGroup.get(it.toInteger()) }
    276286        else
     
    345355
    346356        // Check all currency is the same.
    347         if(currencyCount != 1)
     357        if(currencyCount > 1)
    348358            fail(code:'report.error.multiple.currency.found') // No return, populate errors but continue report.
    349359
Note: See TracChangeset for help on using the changeset viewer.