Ignore:
Timestamp:
07/19/10 08:47:38 (4 years ago)
Author:
gav
Message:

Domain change: Add PurchasingGroup?.
Logic and views to suite.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/InventoryItemPurchaseDetailedController.groovy

    r615 r633  
    226226        params.returnTo = params.returnTo ?: 'inventoryItem' 
    227227 
    228         if(!result.error) 
    229             return [ inventoryItemPurchaseInstance : result.inventoryItemPurchaseInstance ] 
     228        def costCodes = [] 
     229 
     230        if(!result.error) { 
     231            if(inventoryPurchaseService.isPersonInPurchasingGroup(result.inventoryItemPurchaseInstance.costCode.purchasingGroup)) 
     232                costCodes = inventoryPurchaseService.getCostCodesByPerson() 
     233 
     234            return [ inventoryItemPurchaseInstance : result.inventoryItemPurchaseInstance, 
     235                            'costCodes': costCodes ] 
     236        } 
    230237 
    231238        flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 
     
    248255        } 
    249256 
    250         render(view:'edit', model:[inventoryItemPurchaseInstance: result.inventoryItemPurchaseInstance.attach()]) 
     257        result.inventoryItemPurchaseInstance.attach() 
     258        result.inventoryItemPurchaseInstance.costCode.attach() 
     259        result.inventoryItemPurchaseInstance.costCode.purchasingGroup.attach() 
     260 
     261        def costCodes = [] 
     262        if(inventoryPurchaseService.isPersonInPurchasingGroup(result.inventoryItemPurchaseInstance.costCode.purchasingGroup)) 
     263            costCodes = inventoryPurchaseService.getCostCodesByPerson() 
     264 
     265        render(view:'edit', model:[inventoryItemPurchaseInstance: result.inventoryItemPurchaseInstance, 
     266                                                'costCodes': costCodes]) 
    251267    } 
    252268 
     
    262278        } 
    263279 
    264         return ['inventoryItemPurchaseInstance':inventoryItemPurchaseInstance] 
     280        def costCodes = inventoryPurchaseService.getCostCodesByPerson() 
     281 
     282        return ['inventoryItemPurchaseInstance': inventoryItemPurchaseInstance, 
     283                        'costCodes': costCodes] 
    265284    } 
    266285 
     
    282301        } 
    283302 
     303        def costCodes = inventoryPurchaseService.getCostCodesByPerson() 
     304 
    284305        params.errorMessage = g.message(code: result.error.code, args: result.error.args) 
    285         render(view:'create', model:['inventoryItemPurchaseInstance': result.inventoryItemPurchaseInstance]) 
     306        render(view:'create', model:['inventoryItemPurchaseInstance': result.inventoryItemPurchaseInstance, 
     307                                                    'costCodes': costCodes]) 
    286308    } 
    287309 
Note: See TracChangeset for help on using the changeset viewer.