Last change
on this file since 351 was
226,
checked in by gav, 15 years ago
|
Complete functionality for inventory movement types other than "Used".
|
File size:
1.7 KB
|
Rev | Line | |
---|
[225] | 1 | /** |
---|
| 2 | * Provides a service class for the InventoryItem domain class. |
---|
| 3 | */ |
---|
| 4 | class InventoryItemService { |
---|
| 5 | |
---|
| 6 | boolean transactional = false |
---|
| 7 | |
---|
| 8 | /** |
---|
| 9 | * Prepare the data for the show view. |
---|
| 10 | * The result can be used to easily construct the model for the show view. |
---|
| 11 | * @param params The incoming params as normally passed to the show view |
---|
| 12 | * primarily including the id of the inventoryItem. |
---|
| 13 | * @returns A map containing result.error=true (if any error) and result.inventoryItemInstance (if available) |
---|
| 14 | * and |
---|
| 15 | */ |
---|
| 16 | def prepareShowData(params) { |
---|
| 17 | def result = [:] |
---|
| 18 | |
---|
| 19 | def fail = { Object[] args -> |
---|
| 20 | if(args.size() == 2) result.errors = [args[0], args[1]] |
---|
| 21 | result.error = true |
---|
| 22 | return result |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | result.showTab = [:] |
---|
| 26 | switch (params.showTab) { |
---|
| 27 | case "showDetailTab": |
---|
| 28 | result.showTab.detail = new String("true") |
---|
| 29 | break |
---|
| 30 | case "showMovementTab": |
---|
| 31 | result.showTab.movement = new String("true") |
---|
| 32 | break |
---|
| 33 | default: |
---|
| 34 | result.showTab.inventory = new String("true") |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | result.inventoryItemInstance = InventoryItem.get( params.id ) |
---|
| 38 | |
---|
| 39 | if(!result.inventoryItemInstance) |
---|
| 40 | return fail("inventoryItem", "inventoryItem.notFound") |
---|
| 41 | |
---|
| 42 | def p = [:] |
---|
| 43 | p.max = result.inventoryMovementListMax = 10 |
---|
| 44 | p.order = "desc" |
---|
| 45 | p.sort = "id" |
---|
| 46 | result.inventoryMovementList = InventoryMovement.findAllByInventoryItem(result.inventoryItemInstance, p) |
---|
| 47 | result.inventoryMovementListTotal = InventoryMovement.countByInventoryItem(result.inventoryItemInstance) |
---|
| 48 | |
---|
| 49 | // Success |
---|
| 50 | return result |
---|
| 51 | |
---|
| 52 | } // end prepareShowData() |
---|
| 53 | |
---|
| 54 | } // end class |
---|
Note: See
TracBrowser
for help on using the repository browser.