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

Last change on this file since 896 was 892, checked in by gav, 14 years ago

Formatting only, no domain change.

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