Index: /trunk/grails-app/controllers/InventoryItemPurchaseDetailedController.groovy
===================================================================
--- /trunk/grails-app/controllers/InventoryItemPurchaseDetailedController.groovy	(revision 595)
+++ /trunk/grails-app/controllers/InventoryItemPurchaseDetailedController.groovy	(revision 596)
@@ -285,4 +285,5 @@
         def calcQuantities = inventoryPurchaseService.calcQuantities(inventoryItemPurchaseInstance)
         inventoryItemPurchaseInstance.quantity = calcQuantities.thisOrderRemaining
+        inventoryItemPurchaseInstance.orderValueAmount = calcQuantities.thisOrderRemainingAmount
         return ['inventoryItemPurchaseInstance':inventoryItemPurchaseInstance,
                         'orderId': inventoryItemPurchaseInstance.id]
Index: /trunk/grails-app/services/InventoryPurchaseService.groovy
===================================================================
--- /trunk/grails-app/services/InventoryPurchaseService.groovy	(revision 595)
+++ /trunk/grails-app/services/InventoryPurchaseService.groovy	(revision 596)
@@ -10,5 +10,6 @@
     * Calulates the quantities for an inventoryItem and purchaseOrderNumber.
     * @param order An inventory puchase that was the source of the order.
-    * @returns A result map contianing the totalOrdered, totalReceived, totalRemaining, thisOrderRemaining.
+    * @returns A result map containing the totalOrdered, totalReceived, totalRemaining, thisOrderRemaining,
+    *                 totalOrderedAmount, totalReceivedAmount, totalRemainingAmount, thisOrderRemainingAmount.
     */
     def calcQuantities(order) {
@@ -17,4 +18,5 @@
 
         result.totalOrdered = 0
+        result.totalOrderedAmount = 0
         InventoryItemPurchase.withCriteria {
             eq("inventoryItem", order.inventoryItem)
@@ -25,7 +27,9 @@
         }.each() {
             result.totalOrdered += it.quantity
+            result.totalOrderedAmount += it.orderValueAmount
         }
 
         result.totalReceived = 0
+        result.totalReceivedAmount = 0
         InventoryItemPurchase.withCriteria {
             eq("inventoryItem", order.inventoryItem)
@@ -39,4 +43,5 @@
         }.each() {
             result.totalReceived += it.quantity
+            result.totalReceivedAmount += it.orderValueAmount
         }
 
@@ -47,4 +52,10 @@
             result.totalRemaining = 0
 
+        result.totalRemainingAmount
+        if(result.totalOrderedAmount > result.totalReceivedAmount)
+            result.totalRemainingAmount = result.totalOrderedAmount - result.totalReceivedAmount
+        else
+            result.totalRemainingAmount = 0
+
         result.thisOrderRemaining
         if(result.totalRemaining > order.quantity)
@@ -52,4 +63,10 @@
         else
             result.thisOrderRemaining = result.totalRemaining
+
+        result.thisOrderRemainingAmount
+        if(result.totalRemainingAmount > order.orderValueAmount)
+            result.thisOrderRemainingAmount = order.orderValueAmount
+        else
+            result.thisOrderRemainingAmount = result.totalRemainingAmount
 
         return result
@@ -254,4 +271,6 @@
             if(result.inventoryItemPurchaseInstance.quantity)
                 calcQuantities.totalReceived += result.inventoryItemPurchaseInstance.quantity
+            if(result.inventoryItemPurchaseInstance.orderValueAmount)
+                calcQuantities.totalReceivedAmount += result.inventoryItemPurchaseInstance.orderValueAmount
 
             if(calcQuantities.totalReceived >= calcQuantities.totalOrdered) {
