source: trunk/grails-app/domain/InventoryItemPurchase.groovy @ 962

Last change on this file since 962 was 609, checked in by gav, 14 years ago

Domain change, add taskBudgetStatus property to InventoryItemPurchase.
Update views, help balloons and logic to suite.

File size: 1.8 KB
RevLine 
[441]1class InventoryItemPurchase {
2
3    Person enteredBy
[605]4    Person lastUpdatedBy
[441]5    InventoryItem inventoryItem
6    CostCode costCode
7    InventoryItemPurchaseType inventoryItemPurchaseType
[605]8    Supplier supplier
[609]9    TaskBudgetStatus taskBudgetStatus
[441]10
[605]11    Date date = new Date()
12    Date lastUpdated // autoTimestamp
13    Date dateCreated // autoTimestamp
14
[441]15    Integer quantity
16    String purchaseOrderNumber = ''
17    BigDecimal orderValueAmount
18    Currency orderValueCurrency
19    String invoiceNumber = ''
[605]20    String comment = ""
[441]21
22    Boolean receivedComplete = false
23    Boolean invoicePaymentApproved = false
24
25//     hasMany = []
26
27    static belongsTo = [InventoryItem]
28
29    static constraints = {
30        quantity(min:0)
[599]31        purchaseOrderNumber(blank:false, maxSize:50, validator: {val, obj ->
32            // For orders the purchaseOrderNumber must be unique for an inventoryItem.
33            if(obj.inventoryItemPurchaseType.id == 1L) {
34                def list = InventoryItemPurchase.withCriteria {
35                    eq('inventoryItem', obj.inventoryItem)
36                    eq('purchaseOrderNumber', obj.purchaseOrderNumber)
37                    eq('inventoryItemPurchaseType', obj.inventoryItemPurchaseType)
38                    if(obj.id)
39                        notEqual('id', obj.id)
40                }
41                if(list.size() > 0)
42                    return 'not.unique.for.inventory.item.order'
43            }
44            // Success.
45            return true
46        })
[441]47        invoiceNumber(maxSize:50)
48        orderValueAmount(max: new BigDecimal(1000000000000))
49        orderValueCurrency()
[605]50        comment(maxSize:255)
51        lastUpdatedBy(nullable: true)
[441]52    }
53
54    String toString() {
55        "${this.quantity} x ${inventoryItem} - ${this.inventoryItemPurchaseType} "
56    }
57
58}
Note: See TracBrowser for help on using the repository browser.