- Timestamp:
- Nov 24, 2010, 12:57:45 PM (14 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/InventoryItemPurchaseDetailedController.groovy
r633 r717 350 350 } 351 351 352 // Prevent lazy initialization error. 353 result.inventoryItemPurchaseInstance.costCode.attach() 354 352 355 render(view:'receive', 353 356 model:['inventoryItemPurchaseInstance': result.inventoryItemPurchaseInstance, … … 394 397 } 395 398 399 // Prevent lazy initialization error. 400 result.inventoryItemPurchaseInstance.costCode.attach() 401 396 402 render(view:'approveInvoicePayment', 397 403 model:['inventoryItemPurchaseInstance': result.inventoryItemPurchaseInstance, -
trunk/grails-app/services/InventoryPurchaseService.groovy
r633 r717 9 9 /** 10 10 * Calulates the quantities for an inventoryItem and purchaseOrderNumber. 11 * @param order An inventory pu chase that was the source of the order.11 * @param order An inventory purchase that was the source of the order. 12 12 * @returns A result map containing the totalOrdered, totalReceived, totalRemaining, thisOrderRemaining, 13 13 * totalOrderedAmount, totalReceivedAmount, totalRemainingAmount, thisOrderRemainingAmount, … … 265 265 } 266 266 267 def originalPaymentApprovedAmount = result.inventoryItemPurchaseInstance.orderValueAmount 268 267 269 result.inventoryItemPurchaseInstance.properties = params 268 270 result.inventoryItemPurchaseInstance.purchaseOrderNumber = result.inventoryItemPurchaseInstance.purchaseOrderNumber.trim() 271 result.inventoryItemPurchaseInstance.invoiceNumber = result.inventoryItemPurchaseInstance.invoiceNumber.trim() 269 272 result.inventoryItemPurchaseInstance.lastUpdatedBy = authService.currentUser 273 274 // Fetch to prevent lazy initialization error. 275 result.inventoryItemPurchaseInstance.inventoryItem.unitOfMeasure 276 277 // If processing an Invoice Approved. 278 if(result.inventoryItemPurchaseInstance.inventoryItemPurchaseType.id == 4L) { 279 if(!result.inventoryItemPurchaseInstance.invoiceNumber) 280 return fail(field:"invoiceNumber", code:"inventoryItemPurchase.invoiceNumber.required") 281 } 270 282 271 283 if(result.inventoryItemPurchaseInstance.hasErrors() || !result.inventoryItemPurchaseInstance.save()) 272 284 return fail(code:"default.update.failure") 285 286 // If processing an Invoice Approved. 287 if(result.inventoryItemPurchaseInstance.inventoryItemPurchaseType.id == 4L) { 288 289 def order = getOriginalOrder(result.inventoryItemPurchaseInstance) 290 if(!order) 291 return fail(code:"default.not.found") 292 293 // Update orderValueAmount if receivedComplete. 294 if(order.receivedComplete) { 295 296 def calcQuantities = calcQuantities(order) 297 order.orderValueAmount = calcQuantities.totalPaymentApproved 298 299 if(order.hasErrors() || !order.save()) 300 return fail(code:"default.create.failure") 301 } 302 303 } 273 304 274 305 // Success. … … 281 312 InventoryItemPurchase.withTransaction { status -> 282 313 def result = [:] 314 283 315 def fail = { Map m -> 284 316 status.setRollbackOnly()
Note: See TracChangeset
for help on using the changeset viewer.