Changeset 891 for branches/features/purchaseOrders/grails-app/services/InventoryPurchaseService.groovy
- Timestamp:
- Apr 21, 2011, 3:29:47 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.