source: branches/features/taskProcedureRework/grails-app/domain/InventoryItem.groovy @ 790

Last change on this file since 790 was 726, checked in by gav, 14 years ago

Possible domain change, due to new min (reorderQuantity no longer nullable) and max (suppliersPartNumber) values on InventoryItem.

File size: 3.0 KB
Line 
1class  InventoryItem {
2    InventoryGroup inventoryGroup
3    InventoryType inventoryType
4    UnitOfMeasure unitOfMeasure
5    InventoryLocation inventoryLocation
6    Picture picture
7    Supplier preferredSupplier
8    String name
9    String description = ""
10    String comment = ""
11    BigDecimal estimatedUnitPriceAmount
12    Currency estimatedUnitPriceCurrency
13    String suppliersPartNumber
14    Integer unitsInStock = 0
15    Integer reorderPoint = 0
16    Integer reorderQuantity = 1
17    boolean isActive = true
18    boolean isObsolete = false
19    boolean enableReorderListing = true
20
21    static mapping = {
22        picture cascade: 'all-delete-orphan', lazy: true, inverse: true
23    }
24
25    static hasMany = [spareFor: Asset,
26                                    inventoryMovements: InventoryMovement,
27                                    alternateSuppliers: Supplier]
28
29//     static belongsTo = []
30
31    static constraints = {
32        picture(nullable:true)
33        name(unique:true, blank:false, maxSize:50)
34        description(maxSize:255)
35        comment(maxSize:500)
36        unitsInStock(min:0)
37        unitOfMeasure()
38        inventoryLocation()
39        inventoryGroup()
40        inventoryType()
41        isActive()
42        isObsolete()
43        enableReorderListing()
44        reorderPoint(min:0)
45        reorderQuantity(min:1)
46        estimatedUnitPriceAmount(nullable:true, max: new BigDecimal(1000000000000))
47        estimatedUnitPriceCurrency(nullable:true)
48        suppliersPartNumber(blank:true, nullable:true, maxSize:50)
49        preferredSupplier(nullable:true)
50    }
51
52    String toString() {"${this.name}"}
53
54    static searchable = {
55        only = ['name', 'description', 'comment', 'isActive', 'isObsolete', 'inventoryLocation', 'inventoryGroup', 'spareFor']
56        //name boost: 1.5
57        inventoryLocation component: true
58        inventoryGroup component: true
59        spareFor component: true
60    }
61
62    //  This additional setter is used to convert the checkBoxList string or string array
63    //  of ids selected to the corresponding domain objects.
64    public void setAlternateSuppliersFromCheckBoxList(ids) {
65        def idList = []
66        if(ids instanceof String) {
67                if(ids.isInteger())
68                    idList << ids.toLong()
69        }
70        else {
71            ids.each() {
72                if(it.isInteger())
73                    idList << it.toLong()
74            }
75        }
76        this.alternateSuppliers = idList.collect { Supplier.get( it ) }
77    }
78
79    //  This additional setter is used to convert the checkBoxList string or string array
80    //  of ids selected to the corresponding domain objects.
81    public void setSpareForFromCheckBoxList(ids) {
82        def idList = []
83        if(ids instanceof String) {
84                if(ids.isInteger())
85                    idList << ids.toLong()
86        }
87        else {
88            ids.each() {
89                if(it.isInteger())
90                    idList << it.toLong()
91            }
92        }
93        this.spareFor = idList.collect { Asset.get( it ) }
94    }
95
96}
Note: See TracBrowser for help on using the repository browser.