class PurchaseOrderNumber {

    PurchaseOrder purchaseOrder

    String value

    static transients = ['description']

    static constraints = {
        value(unique:true, blank:false, maxSize:25)
        purchaseOrder(nullable:true)
    }

    String getDescription() {
        if (!purchaseOrder)
            return "${value} - new"
        else
            return "${value} for ${purchaseOrder.supplier}"
    }
}
