- Timestamp:
- Apr 21, 2011, 3:29:47 PM (14 years ago)
- Location:
- branches/features/purchaseOrders
- Files:
-
- 5 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/features/purchaseOrders/grails-app/controllers/InventoryItemPurchaseDetailedController.groovy
r717 r891 11 11 def dateUtilService 12 12 def inventoryPurchaseService 13 def purchaseOrderService 13 14 14 15 def index = { … … 280 281 def costCodes = inventoryPurchaseService.getCostCodesByPerson() 281 282 283 def purchaseOrderNumbers = [purchaseOrderService.findNextUnusedPurchaseOrderNumber()] 284 purchaseOrderNumbers += purchaseOrderService.findDraftPurchaseOrderNumbers() 285 282 286 return ['inventoryItemPurchaseInstance': inventoryItemPurchaseInstance, 283 'costCodes': costCodes ]287 'costCodes': costCodes, purchaseOrderNumbers:purchaseOrderNumbers] 284 288 } 285 289 -
branches/features/purchaseOrders/grails-app/domain/InventoryItemPurchase.groovy
r609 r891 14 14 15 15 Integer quantity 16 String purchaseOrderNumber = ''16 PurchaseOrder purchaseOrder 17 17 BigDecimal orderValueAmount 18 18 Currency orderValueCurrency … … 25 25 // hasMany = [] 26 26 27 static belongsTo = [InventoryItem ]27 static belongsTo = [InventoryItem, PurchaseOrder] 28 28 29 29 static constraints = { 30 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 true46 })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 47 invoiceNumber(maxSize:50) 48 48 orderValueAmount(max: new BigDecimal(1000000000000)) … … 56 56 } 57 57 58 static transients = [ 'purchaseOrderNumber' ] 59 60 String getPurchaseOrderNumber() { 61 return purchaseOrder?.purchaseOrderNumber?.value 62 } 58 63 } -
branches/features/purchaseOrders/grails-app/services/CreateDataService.groovy
r848 r891 89 89 createBaseEntryTypes() 90 90 91 91 92 // Record that data has been created. 92 93 appConfigService.set("baseDataCreated") … … 144 145 // createDemoMaintenanceActions() 145 146 createDemoTaskRecurringSchedules() 147 148 // PurchaseOrderNumbers 149 createDemoPurchaseOrderNumbers() 146 150 147 151 // Record that data has been created. … … 1736 1740 } 1737 1741 1742 def createDemoPurchaseOrderNumbers() { 1743 for (int i=10000; i<10100; i++) { 1744 saveAndTest(new PurchaseOrderNumber(value:"P${i}")) 1745 } 1746 } 1747 1738 1748 /** 1739 1749 * SearchableIndex and mirroring is disabled at startup. -
branches/features/purchaseOrders/grails-app/services/InventoryItemService.groovy
r727 r891 63 63 } 64 64 else { 65 order('purchaseOrder Number', 'desc')65 order('purchaseOrder', 'desc') 66 66 order('id', 'asc') 67 67 } -
branches/features/purchaseOrders/grails-app/services/InventoryPurchaseService.groovy
r717 r891 6 6 def dateUtilService 7 7 def inventoryMovementService 8 def purchaseOrderService 8 9 9 10 /** … … 23 24 result.totalReceivedAmount = 0 24 25 result.totalPaymentApproved = 0 25 InventoryItemPurchase.withCriteria { 26 eq("inventoryItem", order.inventoryItem) 27 eq("purchaseOrderNumber", order.purchaseOrderNumber) 28 }.each() { 26 def purchaseOrder = order.purchaseOrder 27 def relevantLineItems = purchaseOrder.inventoryItemPurchases.findAll{it.inventoryItem == order.inventoryItem} 28 // InventoryItemPurchase.withCriteria { 29 // eq("inventoryItem", order.inventoryItem) 30 // eq("purchaseOrderNumber", order.purchaseOrderNumber) 31 // }.each() { 32 relevantLineItems.each { 29 33 if(it.inventoryItemPurchaseType.id == 1L) { // Orders. 30 34 result.totalOrdered += it.quantity … … 77 81 78 82 namedParams.inventoryItem = inventoryItemPurchase.inventoryItem 79 namedParams.purchaseOrder Number = inventoryItemPurchase.purchaseOrderNumber83 namedParams.purchaseOrder = inventoryItemPurchase.purchaseOrder 80 84 namedParams.orderPlaced = InventoryItemPurchaseType.read(1) 81 85 82 86 def order = InventoryItemPurchase.find("from InventoryItemPurchase as p \ 83 87 where( p.inventoryItem = :inventoryItem \ 84 and p.purchaseOrder Number = :purchaseOrderNumber \88 and p.purchaseOrder = :purchaseOrder \ 85 89 and p.inventoryItemPurchaseType = :orderPlaced )", 86 90 namedParams) … … 322 326 323 327 result.inventoryItemPurchaseInstance = new InventoryItemPurchase(params) 324 result.inventoryItemPurchaseInstance.purchaseOrder Number = result.inventoryItemPurchaseInstance.purchaseOrderNumber.trim()328 result.inventoryItemPurchaseInstance.purchaseOrder = purchaseOrderService.getOrCreatePurchaseOrder(params) 325 329 result.inventoryItemPurchaseInstance.enteredBy = authService.currentUser 326 330 result.inventoryItemPurchaseInstance.inventoryItemPurchaseType = InventoryItemPurchaseType.read(1) // Order … … 344 348 345 349 } // end withTransaction 346 } // save()350 } // save() 347 351 348 352 def receiveSave(params) { … … 363 367 result.orderId = order.id 364 368 369 def purchaseOrderNumber = PurchaseOrderNumber.findByValue(order.purchaseOrderNumber) 370 def purchaseOrder = purchaseOrderNumber.purchaseOrder 371 365 372 result.inventoryItemPurchaseInstance = new InventoryItemPurchase(params) 366 373 result.inventoryItemPurchaseInstance.enteredBy = authService.currentUser 367 result.inventoryItemPurchaseInstance.purchaseOrder Number = order.purchaseOrderNumber374 result.inventoryItemPurchaseInstance.purchaseOrder = purchaseOrder 368 375 result.inventoryItemPurchaseInstance.costCode = order.costCode 369 376 result.inventoryItemPurchaseInstance.orderValueCurrency = order.orderValueCurrency … … 438 445 result.inventoryItemPurchaseInstance = new InventoryItemPurchase(params) 439 446 result.inventoryItemPurchaseInstance.enteredBy = authService.currentUser 440 result.inventoryItemPurchaseInstance.purchaseOrder Number = order.purchaseOrderNumber447 result.inventoryItemPurchaseInstance.purchaseOrder = order.purchaseOrder 441 448 result.inventoryItemPurchaseInstance.costCode = order.costCode 442 449 result.inventoryItemPurchaseInstance.orderValueCurrency = order.orderValueCurrency -
branches/features/purchaseOrders/grails-app/views/inventoryItemPurchaseDetailed/create.gsp
r633 r891 48 48 <tr class="prop"> 49 49 <td valign="top" class="name"> 50 <label for="purchaseOrderNumber ">Purchase Order #:</label>50 <label for="purchaseOrderNumber.id">Purchase Order #:</label> 51 51 </td> 52 52 <td valign="top" class="value ${hasErrors(bean:inventoryItemPurchaseInstance,field:'purchaseOrderNumber','errors')}"> 53 <input type="text" maxlength="50" id="purchaseOrderNumber" name="purchaseOrderNumber" value="${fieldValue(bean:inventoryItemPurchaseInstance,field:'purchaseOrderNumber')}"/> 53 <g:select from="${purchaseOrderNumbers}" 54 optionKey="id" 55 optionValue="description" 56 name="purchaseOrderNumber.id" 57 value="${inventoryItemPurchaseInstance?.purchaseOrder?.purchaseOrderNumber?.id}" 58 noSelection="['null':/${g.message(code:'default.please.select.text')}/]"> 59 </g:select> 54 60 <g:helpBalloon code="inventoryItemPurchase.purchaseOrderNumber" /> 55 61 </td>
Note: See TracChangeset
for help on using the changeset viewer.