Index: branches/features/purchaseOrders/grails-app/domain/InventoryItemPurchase.groovy
===================================================================
--- branches/features/purchaseOrders/grails-app/domain/InventoryItemPurchase.groovy	(revision 889)
+++ branches/features/purchaseOrders/grails-app/domain/InventoryItemPurchase.groovy	(revision 891)
@@ -14,5 +14,5 @@
 
     Integer quantity
-    String purchaseOrderNumber = ''
+    PurchaseOrder purchaseOrder
     BigDecimal orderValueAmount
     Currency orderValueCurrency
@@ -25,24 +25,24 @@
 //     hasMany = []
 
-    static belongsTo = [InventoryItem]
+    static belongsTo = [InventoryItem, PurchaseOrder]
 
     static constraints = {
         quantity(min:0)
-        purchaseOrderNumber(blank:false, maxSize:50, validator: {val, obj ->
-            // For orders the purchaseOrderNumber must be unique for an inventoryItem.
-            if(obj.inventoryItemPurchaseType.id == 1L) {
-                def list = InventoryItemPurchase.withCriteria {
-                    eq('inventoryItem', obj.inventoryItem)
-                    eq('purchaseOrderNumber', obj.purchaseOrderNumber)
-                    eq('inventoryItemPurchaseType', obj.inventoryItemPurchaseType)
-                    if(obj.id)
-                        notEqual('id', obj.id)
-                }
-                if(list.size() > 0)
-                    return 'not.unique.for.inventory.item.order'
-            }
-            // Success.
-            return true
-        })
+//        purchaseOrderNumber(blank:false, maxSize:50, validator: {val, obj ->
+//            // For orders the purchaseOrderNumber must be unique for an inventoryItem.
+//            if(obj.inventoryItemPurchaseType.id == 1L) {
+//                def list = InventoryItemPurchase.withCriteria {
+//                    eq('inventoryItem', obj.inventoryItem)
+//                    eq('purchaseOrderNumber', obj.purchaseOrderNumber)
+//                    eq('inventoryItemPurchaseType', obj.inventoryItemPurchaseType)
+//                    if(obj.id)
+//                        notEqual('id', obj.id)
+//                }
+//                if(list.size() > 0)
+//                    return 'not.unique.for.inventory.item.order'
+//            }
+//            // Success.
+//            return true
+//        })
         invoiceNumber(maxSize:50)
         orderValueAmount(max: new BigDecimal(1000000000000))
@@ -56,3 +56,8 @@
     }
 
+    static transients = [ 'purchaseOrderNumber' ]
+
+    String getPurchaseOrderNumber() {
+        return purchaseOrder?.purchaseOrderNumber?.value
+    }
 }
Index: branches/features/purchaseOrders/grails-app/domain/PurchaseOrder.groovy
===================================================================
--- branches/features/purchaseOrders/grails-app/domain/PurchaseOrder.groovy	(revision 891)
+++ branches/features/purchaseOrders/grails-app/domain/PurchaseOrder.groovy	(revision 891)
@@ -0,0 +1,16 @@
+
+class PurchaseOrder {
+    String comments
+    Supplier supplier
+    Date ordered
+    static hasMany = [inventoryItemPurchases: InventoryItemPurchase]
+
+    static belongsTo = [purchaseOrderNumber: PurchaseOrderNumber]
+
+
+    static constraints = {
+        comments(nullable:true)
+        ordered(nullable:true)
+    }
+
+}
Index: branches/features/purchaseOrders/grails-app/domain/PurchaseOrderNumber.groovy
===================================================================
--- branches/features/purchaseOrders/grails-app/domain/PurchaseOrderNumber.groovy	(revision 891)
+++ branches/features/purchaseOrders/grails-app/domain/PurchaseOrderNumber.groovy	(revision 891)
@@ -0,0 +1,26 @@
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: John
+ * Date: 18/04/2011
+ * Time: 3:01:53 PM
+ * To change this template use File | Settings | File Templates.
+ */
+class PurchaseOrderNumber {
+    String value
+    PurchaseOrder purchaseOrder
+
+    static transients = ['description']
+
+    static constraints = {
+        purchaseOrder(nullable:true)
+    }
+
+    String getDescription() {
+        if (!purchaseOrder) {
+        return value + " - new"
+        } else {
+            return "${value} for ${purchaseOrder.supplier}"
+        }
+    }
+}
