source: branches/features/purchaseOrders/grails-app/domain/InventoryItem.groovy @ 920

Last change on this file since 920 was 920, checked in by gav, 13 years ago

Svn merge -r874:r919 trunk/ into branches/features/purchaseOrders.
This brings the purchaseOrder branch fully up to date.

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