Ignore:
Timestamp:
Oct 29, 2009, 8:30:58 PM (15 years ago)
Author:
gav
Message:

Substantial refactor of the Inventory domain.
InventoryItems can now be added to tasks, no quantity adjustments done yet.
Removed StoredItem and with it the ability to store an inventoryItem in multiple places, just too complex right now.
Svn move StoreLocation to InventoryLocation.

Location:
trunk/grails-app/controllers
Files:
1 added
2 deleted
5 edited
2 moved

Legend:

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

    r116 r175  
    2727        if(inventoryItemInstance) {
    2828            try {
    29                 inventoryItemInstance.delete()
     29                inventoryItemInstance.delete(flush:true)
    3030                flash.message = "InventoryItem ${params.id} deleted"
    3131                redirect(action:list)
     
    7777        else {
    7878            flash.message = "InventoryItem not found with id ${params.id}"
    79             redirect(action:edit,id:params.id)
     79            redirect(action:list)
    8080        }
    8181    }
  • trunk/grails-app/controllers/InventoryItemDetailedController.groovy

    r156 r175  
    4848        if(inventoryItemInstance) {
    4949            try {
    50                 inventoryItemInstance.delete()
     50                inventoryItemInstance.delete(flush:true)
    5151                flash.message = "InventoryItem ${params.id} deleted"
    5252                redirect(action:search)
     
    103103        else {
    104104            flash.message = "InventoryItem not found with id ${params.id}"
    105             redirect(action:edit,id:params.id)
     105            redirect(action:search)
    106106        }
    107107    }
  • trunk/grails-app/controllers/InventoryLocationController.groovy

    r162 r175  
    11import org.codehaus.groovy.grails.plugins.springsecurity.Secured
    22
    3 class StoreLocationController extends BaseAppAdminController {
     3class InventoryLocationController extends BaseAppAdminController {
    44   
    55    def index = { redirect(action:list,params:params) }
     
    1010    def list = {
    1111        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
    12         [ storeLocationInstanceList: StoreLocation.list( params ), storeLocationInstanceTotal: StoreLocation.count() ]
     12        [ inventoryLocationInstanceList: InventoryLocation.list( params ), inventoryLocationInstanceTotal: InventoryLocation.count() ]
    1313    }
    1414
    1515    def show = {
    16         def storeLocationInstance = StoreLocation.get( params.id )
     16        def inventoryLocationInstance = InventoryLocation.get( params.id )
    1717
    18         if(!storeLocationInstance) {
    19             flash.message = "StoreLocation not found with id ${params.id}"
     18        if(!inventoryLocationInstance) {
     19            flash.message = "InventoryLocation not found with id ${params.id}"
    2020            redirect(action:list)
    2121        }
    22         else { return [ storeLocationInstance : storeLocationInstance ] }
     22        else { return [ inventoryLocationInstance : inventoryLocationInstance ] }
    2323    }
    2424
    2525    def delete = {
    26         def storeLocationInstance = StoreLocation.get( params.id )
    27         if(storeLocationInstance) {
     26        def inventoryLocationInstance = InventoryLocation.get( params.id )
     27        if(inventoryLocationInstance) {
    2828            try {
    29                 storeLocationInstance.delete()
    30                 flash.message = "StoreLocation ${params.id} deleted"
     29                inventoryLocationInstance.delete(flush:true)
     30                flash.message = "InventoryLocation ${params.id} deleted"
    3131                redirect(action:list)
    3232            }
    3333            catch(org.springframework.dao.DataIntegrityViolationException e) {
    34                 flash.message = "StoreLocation ${params.id} could not be deleted"
     34                flash.message = "InventoryLocation ${params.id} could not be deleted"
    3535                redirect(action:show,id:params.id)
    3636            }
    3737        }
    3838        else {
    39             flash.message = "StoreLocation not found with id ${params.id}"
     39            flash.message = "InventoryLocation not found with id ${params.id}"
    4040            redirect(action:list)
    4141        }
     
    4343
    4444    def edit = {
    45         def storeLocationInstance = StoreLocation.get( params.id )
     45        def inventoryLocationInstance = InventoryLocation.get( params.id )
    4646
    47         if(!storeLocationInstance) {
    48             flash.message = "StoreLocation not found with id ${params.id}"
     47        if(!inventoryLocationInstance) {
     48            flash.message = "InventoryLocation not found with id ${params.id}"
    4949            redirect(action:list)
    5050        }
    5151        else {
    52             return [ storeLocationInstance : storeLocationInstance ]
     52            return [ inventoryLocationInstance : inventoryLocationInstance ]
    5353        }
    5454    }
    5555
    5656    def update = {
    57         def storeLocationInstance = StoreLocation.get( params.id )
    58         if(storeLocationInstance) {
     57        def inventoryLocationInstance = InventoryLocation.get( params.id )
     58        if(inventoryLocationInstance) {
    5959            if(params.version) {
    6060                def version = params.version.toLong()
    61                 if(storeLocationInstance.version > version) {
     61                if(inventoryLocationInstance.version > version) {
    6262                   
    63                     storeLocationInstance.errors.rejectValue("version", "storeLocation.optimistic.locking.failure", "Another user has updated this StoreLocation while you were editing.")
    64                     render(view:'edit',model:[storeLocationInstance:storeLocationInstance])
     63                    inventoryLocationInstance.errors.rejectValue("version", "inventoryLocation.optimistic.locking.failure", "Another user has updated this InventoryLocation while you were editing.")
     64                    render(view:'edit',model:[inventoryLocationInstance:inventoryLocationInstance])
    6565                    return
    6666                }
    6767            }
    68             storeLocationInstance.properties = params
    69             if(!storeLocationInstance.hasErrors() && storeLocationInstance.save()) {
    70                 flash.message = "StoreLocation ${params.id} updated"
    71                 redirect(action:show,id:storeLocationInstance.id)
     68            inventoryLocationInstance.properties = params
     69            if(!inventoryLocationInstance.hasErrors() && inventoryLocationInstance.save()) {
     70                flash.message = "InventoryLocation ${params.id} updated"
     71                redirect(action:show,id:inventoryLocationInstance.id)
    7272            }
    7373            else {
    74                 render(view:'edit',model:[storeLocationInstance:storeLocationInstance])
     74                render(view:'edit',model:[inventoryLocationInstance:inventoryLocationInstance])
    7575            }
    7676        }
    7777        else {
    78             flash.message = "StoreLocation not found with id ${params.id}"
    79             redirect(action:edit,id:params.id)
     78            flash.message = "InventoryLocation not found with id ${params.id}"
     79            redirect(action:list)
    8080        }
    8181    }
    8282
    8383    def create = {
    84         def storeLocationInstance = new StoreLocation()
    85         storeLocationInstance.properties = params
    86         return ['storeLocationInstance':storeLocationInstance]
     84        def inventoryLocationInstance = new InventoryLocation()
     85        inventoryLocationInstance.properties = params
     86        return ['inventoryLocationInstance':inventoryLocationInstance]
    8787    }
    8888
    8989    def save = {
    90         def storeLocationInstance = new StoreLocation(params)
    91         if(!storeLocationInstance.hasErrors() && storeLocationInstance.save()) {
    92             flash.message = "StoreLocation ${storeLocationInstance.id} created"
    93             redirect(action:show,id:storeLocationInstance.id)
     90        def inventoryLocationInstance = new InventoryLocation(params)
     91        if(!inventoryLocationInstance.hasErrors() && inventoryLocationInstance.save()) {
     92            flash.message = "InventoryLocation ${inventoryLocationInstance.id} created"
     93            redirect(action:show,id:inventoryLocationInstance.id)
    9494        }
    9595        else {
    96             render(view:'create',model:[storeLocationInstance:storeLocationInstance])
     96            render(view:'create',model:[inventoryLocationInstance:inventoryLocationInstance])
    9797        }
    9898    }
  • trunk/grails-app/controllers/InventoryLocationDetailedController.groovy

    r162 r175  
    11import org.codehaus.groovy.grails.plugins.springsecurity.Secured
    22
    3 class StoreLocationDetailedController extends BaseController {
     3class InventoryLocationDetailedController extends BaseController {
    44   
    55    def index = { redirect(action:list,params:params) }
     
    1010    def list = {
    1111        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
    12         [ storeLocationInstanceList: StoreLocation.list( params ), storeLocationInstanceTotal: StoreLocation.count() ]
     12        [ inventoryLocationInstanceList: InventoryLocation.list( params ), inventoryLocationInstanceTotal: InventoryLocation.count() ]
    1313    }
    1414
    1515    def show = {
    16         def storeLocationInstance = StoreLocation.get( params.id )
     16        def inventoryLocationInstance = InventoryLocation.get( params.id )
    1717
    18         if(!storeLocationInstance) {
    19             flash.message = "StoreLocation not found with id ${params.id}"
     18        if(!inventoryLocationInstance) {
     19            flash.message = "InventoryLocation not found with id ${params.id}"
    2020            redirect(action:list)
    2121        }
    22         else { return [ storeLocationInstance : storeLocationInstance ] }
     22        else { return [ inventoryLocationInstance : inventoryLocationInstance ] }
    2323    }
    2424
    2525    def delete = {
    26         def storeLocationInstance = StoreLocation.get( params.id )
    27         if(storeLocationInstance) {
     26        def inventoryLocationInstance = InventoryLocation.get( params.id )
     27        if(inventoryLocationInstance) {
    2828            try {
    29                 storeLocationInstance.delete()
    30                 flash.message = "StoreLocation ${params.id} deleted"
     29                inventoryLocationInstance.delete(flush:true)
     30                flash.message = "InventoryLocation ${params.id} deleted"
    3131                redirect(action:list)
    3232            }
    3333            catch(org.springframework.dao.DataIntegrityViolationException e) {
    34                 flash.message = "StoreLocation ${params.id} could not be deleted"
     34                flash.message = "InventoryLocation ${params.id} could not be deleted"
    3535                redirect(action:show,id:params.id)
    3636            }
    3737        }
    3838        else {
    39             flash.message = "StoreLocation not found with id ${params.id}"
     39            flash.message = "InventoryLocation not found with id ${params.id}"
    4040            redirect(action:list)
    4141        }
     
    4343
    4444    def edit = {
    45         def storeLocationInstance = StoreLocation.get( params.id )
     45        def inventoryLocationInstance = InventoryLocation.get( params.id )
    4646
    47         if(!storeLocationInstance) {
    48             flash.message = "StoreLocation not found with id ${params.id}"
     47        if(!inventoryLocationInstance) {
     48            flash.message = "InventoryLocation not found with id ${params.id}"
    4949            redirect(action:list)
    5050        }
    5151        else {
    52             return [ storeLocationInstance : storeLocationInstance ]
     52            return [ inventoryLocationInstance : inventoryLocationInstance ]
    5353        }
    5454    }
    5555
    5656    def update = {
    57         def storeLocationInstance = StoreLocation.get( params.id )
    58         if(storeLocationInstance) {
     57        def inventoryLocationInstance = InventoryLocation.get( params.id )
     58        if(inventoryLocationInstance) {
    5959            if(params.version) {
    6060                def version = params.version.toLong()
    61                 if(storeLocationInstance.version > version) {
     61                if(inventoryLocationInstance.version > version) {
    6262                   
    63                     storeLocationInstance.errors.rejectValue("version", "storeLocation.optimistic.locking.failure", "Another user has updated this StoreLocation while you were editing.")
    64                     render(view:'edit',model:[storeLocationInstance:storeLocationInstance])
     63                    inventoryLocationInstance.errors.rejectValue("version", "inventoryLocation.optimistic.locking.failure", "Another user has updated this InventoryLocation while you were editing.")
     64                    render(view:'edit',model:[inventoryLocationInstance:inventoryLocationInstance])
    6565                    return
    6666                }
    6767            }
    68             storeLocationInstance.properties = params
    69             if(!storeLocationInstance.hasErrors() && storeLocationInstance.save()) {
    70                 flash.message = "StoreLocation ${params.id} updated"
    71                 redirect(action:show,id:storeLocationInstance.id)
     68            inventoryLocationInstance.properties = params
     69            if(!inventoryLocationInstance.hasErrors() && inventoryLocationInstance.save()) {
     70                flash.message = "InventoryLocation ${params.id} updated"
     71                redirect(action:show,id:inventoryLocationInstance.id)
    7272            }
    7373            else {
    74                 render(view:'edit',model:[storeLocationInstance:storeLocationInstance])
     74                render(view:'edit',model:[inventoryLocationInstance:inventoryLocationInstance])
    7575            }
    7676        }
    7777        else {
    78             flash.message = "StoreLocation not found with id ${params.id}"
    79             redirect(action:edit,id:params.id)
     78            flash.message = "InventoryLocation not found with id ${params.id}"
     79            redirect(action:list)
    8080        }
    8181    }
    8282
    8383    def create = {
    84         def storeLocationInstance = new StoreLocation()
    85         storeLocationInstance.properties = params
    86         return ['storeLocationInstance':storeLocationInstance]
     84        def inventoryLocationInstance = new InventoryLocation()
     85        inventoryLocationInstance.properties = params
     86        return ['inventoryLocationInstance':inventoryLocationInstance]
    8787    }
    8888
    8989    def save = {
    90         def storeLocationInstance = new StoreLocation(params)
    91         if(!storeLocationInstance.hasErrors() && storeLocationInstance.save()) {
    92             flash.message = "StoreLocation ${storeLocationInstance.id} created"
    93             redirect(action:show,id:storeLocationInstance.id)
     90        def inventoryLocationInstance = new InventoryLocation(params)
     91        if(!inventoryLocationInstance.hasErrors() && inventoryLocationInstance.save()) {
     92            flash.message = "InventoryLocation ${inventoryLocationInstance.id} created"
     93            redirect(action:show,id:inventoryLocationInstance.id)
    9494        }
    9595        else {
    96             render(view:'create',model:[storeLocationInstance:storeLocationInstance])
     96            render(view:'create',model:[inventoryLocationInstance:inventoryLocationInstance])
    9797        }
    9898    }
  • trunk/grails-app/controllers/InventoryMovementController.groovy

    r116 r175  
    2727        if(inventoryMovementInstance) {
    2828            try {
    29                 inventoryMovementInstance.delete()
     29                inventoryMovementInstance.delete(flush:true)
    3030                flash.message = "InventoryMovement ${params.id} deleted"
    3131                redirect(action:list)
     
    7777        else {
    7878            flash.message = "InventoryMovement not found with id ${params.id}"
    79             redirect(action:edit,id:params.id)
     79            redirect(action:list)
    8080        }
    8181    }
  • trunk/grails-app/controllers/InventoryStoreController.groovy

    r116 r175  
    2727        if(inventoryStoreInstance) {
    2828            try {
    29                 inventoryStoreInstance.delete()
     29                inventoryStoreInstance.delete(flush:true)
    3030                flash.message = "InventoryStore ${params.id} deleted"
    3131                redirect(action:list)
     
    7777        else {
    7878            flash.message = "InventoryStore not found with id ${params.id}"
    79             redirect(action:edit,id:params.id)
     79            redirect(action:list)
    8080        }
    8181    }
  • trunk/grails-app/controllers/TaskDetailedController.groovy

    r169 r175  
    182182
    183183                        def subTaskInstanceList = Task.findAllByParentTask(taskInstance, params)
    184                         def subTaskInstanceTotal = Task.countByParentTask(taskInstance)                                 
     184                        def subTaskInstanceTotal = Task.countByParentTask(taskInstance)
    185185            def showTaskTab = new String("true")
     186
     187            def inventoryMovementList = InventoryMovement.findAllByTask(taskInstance, [max:100, sort:"id", order:"desc", offset:0])
    186188
    187189            def taskProcedureInstance = TaskProcedure.get(taskInstance.taskProcedure?.id)
     
    190192                taskProcedureExits = false
    191193            }
    192 //                      else {
    193                                 params.order = "asc"
    194                                 params.sort = "procedureStepNumber"
    195                                 def maintenanceActionList = MaintenanceAction.findAllByTaskProcedure(taskProcedureInstance, params)
    196 //                      }
    197                                                
     194
     195            params.order = "asc"
     196            params.sort = "procedureStepNumber"
     197            def maintenanceActionList = MaintenanceAction.findAllByTaskProcedure(taskProcedureInstance, params)
     198
    198199            def taskRecurringScheduleInstance = TaskRecurringSchedule.get(taskInstance.taskRecurringSchedule?.id)
    199200            def taskRecurringScheduleExits= new Boolean("true")
    200                         if(!taskRecurringScheduleInstance) {
     201            if(!taskRecurringScheduleInstance) {
    201202                taskRecurringScheduleExits = false
    202203            }
     
    213214                                                        maintenanceActionList: maintenanceActionList,
    214215                                                        taskRecurringScheduleInstance: taskRecurringScheduleInstance,
    215                                                         taskRecurringScheduleExits: taskRecurringScheduleExits]
     216                                                        taskRecurringScheduleExits: taskRecurringScheduleExits,
     217                            inventoryMovementList: inventoryMovementList]
    216218        }
    217219    }
Note: See TracChangeset for help on using the changeset viewer.