source: branches/features/taskProcedureRework/grails-app/domain/InventoryItemPurchase.groovy @ 796

Last change on this file since 796 was 609, checked in by gav, 15 years ago

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

File size: 1.8 KB
Line 
1class InventoryItemPurchase {
2
3    Person enteredBy
4    Person lastUpdatedBy
5    InventoryItem inventoryItem
6    CostCode costCode
7    InventoryItemPurchaseType inventoryItemPurchaseType
8    Supplier supplier
9    TaskBudgetStatus taskBudgetStatus
10
11    Date date = new Date()
12    Date lastUpdated // autoTimestamp
13    Date dateCreated // autoTimestamp
14
15    Integer quantity
16    String purchaseOrderNumber = ''
17    BigDecimal orderValueAmount
18    Currency orderValueCurrency
19    String invoiceNumber = ''
20    String comment = ""
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)
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        })
47        invoiceNumber(maxSize:50)
48        orderValueAmount(max: new BigDecimal(1000000000000))
49        orderValueCurrency()
50        comment(maxSize:255)
51        lastUpdatedBy(nullable: true)
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.