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

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

Formatting only, no domain change.

File size: 2.0 KB
RevLine 
[441]1class InventoryItemPurchase {
2
[892]3    PurchaseOrder purchaseOrder
[441]4    Person enteredBy
[605]5    Person lastUpdatedBy
[441]6    InventoryItem inventoryItem
7    CostCode costCode
8    InventoryItemPurchaseType inventoryItemPurchaseType
[605]9    Supplier supplier
[609]10    TaskBudgetStatus taskBudgetStatus
[441]11
[605]12    Date date = new Date()
13    Date lastUpdated // autoTimestamp
14    Date dateCreated // autoTimestamp
15
[441]16    Integer quantity
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
[891]27    static belongsTo = [InventoryItem, PurchaseOrder]
[441]28
29    static constraints = {
30        quantity(min:0)
[892]31        /// @todo: check constraints.
[891]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//        })
[441]48        invoiceNumber(maxSize:50)
49        orderValueAmount(max: new BigDecimal(1000000000000))
50        orderValueCurrency()
[605]51        comment(maxSize:255)
52        lastUpdatedBy(nullable: true)
[441]53    }
54
55    String toString() {
56        "${this.quantity} x ${inventoryItem} - ${this.inventoryItemPurchaseType} "
57    }
58
[891]59    static transients = [ 'purchaseOrderNumber' ]
60
61    String getPurchaseOrderNumber() {
62        return purchaseOrder?.purchaseOrderNumber?.value
63    }
[892]64}
Note: See TracBrowser for help on using the repository browser.