Ignore:
Timestamp:
Jul 19, 2010, 8:47:38 AM (14 years ago)
Author:
gav
Message:

Domain change: Add PurchasingGroup?.
Logic and views to suite.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/domain/CostCode.groovy

    r441 r633  
    11class CostCode {
     2
     3    PurchasingGroup purchasingGroup
     4
    25    String name
    36    String description = ""
     
    710
    811    static constraints = {
    9         name(maxSize:50,unique:true,blank:false)
     12        name(blank:false, maxSize:50, validator: {val, obj ->
     13            // Name must be unique for a purchasingGroup.
     14            def list = CostCode.withCriteria {
     15                eq('purchasingGroup', obj.purchasingGroup)
     16                eq('name', obj.name)
     17                if(obj.id)
     18                    notEqual('id', obj.id)
     19            }
     20            if(list.size() > 0)
     21                return 'not.unique.for.purchasing.group'
     22            // Success.
     23            return true
     24        })
    1025        description(maxSize:100)
    1126    }
    1227
    1328    String toString() {
    14         "${this.name}"
     29        "${this.name}.${this.purchasingGroup}"
    1530    }
     31
    1632}
Note: See TracChangeset for help on using the changeset viewer.