source: branches/features/purchaseOrders/grails-app/domain/InventoryItemPurchase.groovy @ 914

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

Formatting only, no domain change.

File size: 2.0 KB
Line 
1class InventoryItemPurchase {
2
3    PurchaseOrder purchaseOrder
4    Person enteredBy
5    Person lastUpdatedBy
6    InventoryItem inventoryItem
7    CostCode costCode
8    InventoryItemPurchaseType inventoryItemPurchaseType
9    Supplier supplier
10    TaskBudgetStatus taskBudgetStatus
11
12    Date date = new Date()
13    Date lastUpdated // autoTimestamp
14    Date dateCreated // autoTimestamp
15
16    Integer quantity
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, PurchaseOrder]
28
29    static constraints = {
30        quantity(min:0)
31        /// @todo: check constraints.
32//        purchaseOrderNumber(blank:false, maxSize:50, validator: {val, obj ->
33//            // For orders the purchaseOrderNumber must be unique for an inventoryItem.
34//            if(obj.inventoryItemPurchaseType.id == 1L) {
35//                def list = InventoryItemPurchase.withCriteria {
36//                    eq('inventoryItem', obj.inventoryItem)
37//                    eq('purchaseOrderNumber', obj.purchaseOrderNumber)
38//                    eq('inventoryItemPurchaseType', obj.inventoryItemPurchaseType)
39//                    if(obj.id)
40//                        notEqual('id', obj.id)
41//                }
42//                if(list.size() > 0)
43//                    return 'not.unique.for.inventory.item.order'
44//            }
45//            // Success.
46//            return true
47//        })
48        invoiceNumber(maxSize:50)
49        orderValueAmount(max: new BigDecimal(1000000000000))
50        orderValueCurrency()
51        comment(maxSize:255)
52        lastUpdatedBy(nullable: true)
53    }
54
55    String toString() {
56        "${this.quantity} x ${inventoryItem} - ${this.inventoryItemPurchaseType} "
57    }
58
59    static transients = [ 'purchaseOrderNumber' ]
60
61    String getPurchaseOrderNumber() {
62        return purchaseOrder?.purchaseOrderNumber?.value
63    }
64}
Note: See TracBrowser for help on using the repository browser.