source: trunk/grails-app/domain/InventoryItem.groovy @ 833

Last change on this file since 833 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
RevLine 
[116]1class  InventoryItem {
2    InventoryGroup inventoryGroup
3    InventoryType inventoryType
4    UnitOfMeasure unitOfMeasure
[175]5    InventoryLocation inventoryLocation
[182]6    Picture picture
[435]7    Supplier preferredSupplier
[116]8    String name
9    String description = ""
[422]10    String comment = ""
[405]11    BigDecimal estimatedUnitPriceAmount
12    Currency estimatedUnitPriceCurrency
[116]13    String suppliersPartNumber
[175]14    Integer unitsInStock = 0
[726]15    Integer reorderPoint = 0
16    Integer reorderQuantity = 1
[116]17    boolean isActive = true
18    boolean isObsolete = false
[616]19    boolean enableReorderListing = true
[116]20
[182]21    static mapping = {
22        picture cascade: 'all-delete-orphan', lazy: true, inverse: true
23    }
24
[720]25    static hasMany = [spareFor: Asset,
[116]26                                    inventoryMovements: InventoryMovement,
[435]27                                    alternateSuppliers: Supplier]
[116]28
29//     static belongsTo = []
30
31    static constraints = {
[182]32        picture(nullable:true)
[175]33        name(unique:true, blank:false, maxSize:50)
[422]34        description(maxSize:255)
35        comment(maxSize:500)
[175]36        unitsInStock(min:0)
37        unitOfMeasure()
[726]38        inventoryLocation()
39        inventoryGroup()
40        inventoryType()
41        isActive()
42        isObsolete()
43        enableReorderListing()
44        reorderPoint(min:0)
45        reorderQuantity(min:1)
[416]46        estimatedUnitPriceAmount(nullable:true, max: new BigDecimal(1000000000000))
[405]47        estimatedUnitPriceCurrency(nullable:true)
[726]48        suppliersPartNumber(blank:true, nullable:true, maxSize:50)
[435]49        preferredSupplier(nullable:true)
[116]50    }
51
52    String toString() {"${this.name}"}
[425]53
[562]54    static searchable = {
[566]55        only = ['name', 'description', 'comment', 'isActive', 'isObsolete', 'inventoryLocation', 'inventoryGroup', 'spareFor']
[562]56        //name boost: 1.5
57        inventoryLocation component: true
[566]58        inventoryGroup component: true
[562]59        spareFor component: true
60    }
61
[726]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
[116]96}
Note: See TracBrowser for help on using the repository browser.