source: trunk/grails-app/domain/CostCode.groovy @ 964

Last change on this file since 964 was 633, checked in by gav, 14 years ago

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

File size: 840 bytes
RevLine 
[441]1class CostCode {
[633]2
3    PurchasingGroup purchasingGroup
4
[441]5    String name
6    String description = ""
7    boolean isActive = true
8
9    static hasMany = [inventoryItemPurchases: InventoryItemPurchase]
10
11    static constraints = {
[633]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        })
[441]25        description(maxSize:100)
26    }
27
28    String toString() {
[633]29        "${this.name}.${this.purchasingGroup}"
[441]30    }
[633]31
[441]32}
Note: See TracBrowser for help on using the repository browser.