Changeset 596 for trunk/grails-app
- Timestamp:
- Jun 11, 2010, 2:00:04 PM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/InventoryItemPurchaseDetailedController.groovy
r595 r596 285 285 def calcQuantities = inventoryPurchaseService.calcQuantities(inventoryItemPurchaseInstance) 286 286 inventoryItemPurchaseInstance.quantity = calcQuantities.thisOrderRemaining 287 inventoryItemPurchaseInstance.orderValueAmount = calcQuantities.thisOrderRemainingAmount 287 288 return ['inventoryItemPurchaseInstance':inventoryItemPurchaseInstance, 288 289 'orderId': inventoryItemPurchaseInstance.id] -
trunk/grails-app/services/InventoryPurchaseService.groovy
r441 r596 10 10 * Calulates the quantities for an inventoryItem and purchaseOrderNumber. 11 11 * @param order An inventory puchase that was the source of the order. 12 * @returns A result map contianing the totalOrdered, totalReceived, totalRemaining, thisOrderRemaining. 12 * @returns A result map containing the totalOrdered, totalReceived, totalRemaining, thisOrderRemaining, 13 * totalOrderedAmount, totalReceivedAmount, totalRemainingAmount, thisOrderRemainingAmount. 13 14 */ 14 15 def calcQuantities(order) { … … 17 18 18 19 result.totalOrdered = 0 20 result.totalOrderedAmount = 0 19 21 InventoryItemPurchase.withCriteria { 20 22 eq("inventoryItem", order.inventoryItem) … … 25 27 }.each() { 26 28 result.totalOrdered += it.quantity 29 result.totalOrderedAmount += it.orderValueAmount 27 30 } 28 31 29 32 result.totalReceived = 0 33 result.totalReceivedAmount = 0 30 34 InventoryItemPurchase.withCriteria { 31 35 eq("inventoryItem", order.inventoryItem) … … 39 43 }.each() { 40 44 result.totalReceived += it.quantity 45 result.totalReceivedAmount += it.orderValueAmount 41 46 } 42 47 … … 47 52 result.totalRemaining = 0 48 53 54 result.totalRemainingAmount 55 if(result.totalOrderedAmount > result.totalReceivedAmount) 56 result.totalRemainingAmount = result.totalOrderedAmount - result.totalReceivedAmount 57 else 58 result.totalRemainingAmount = 0 59 49 60 result.thisOrderRemaining 50 61 if(result.totalRemaining > order.quantity) … … 52 63 else 53 64 result.thisOrderRemaining = result.totalRemaining 65 66 result.thisOrderRemainingAmount 67 if(result.totalRemainingAmount > order.orderValueAmount) 68 result.thisOrderRemainingAmount = order.orderValueAmount 69 else 70 result.thisOrderRemainingAmount = result.totalRemainingAmount 54 71 55 72 return result … … 254 271 if(result.inventoryItemPurchaseInstance.quantity) 255 272 calcQuantities.totalReceived += result.inventoryItemPurchaseInstance.quantity 273 if(result.inventoryItemPurchaseInstance.orderValueAmount) 274 calcQuantities.totalReceivedAmount += result.inventoryItemPurchaseInstance.orderValueAmount 256 275 257 276 if(calcQuantities.totalReceived >= calcQuantities.totalOrdered) {
Note: See TracChangeset
for help on using the changeset viewer.