Changeset 436 for trunk/grails-app
- Timestamp:
- Mar 8, 2010, 4:37:12 PM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/Manufacturer.groovy
r402 r436 6 6 7 7 static hasMany = [contacts: Contact, 8 addresses: Address, 9 inventoryItems: InventoryItem] 8 addresses: Address] 10 9 11 static belongsTo = [InventoryItem]10 // static belongsTo = [] 12 11 13 12 static constraints = { -
trunk/grails-app/domain/Supplier.groovy
r402 r436 6 6 7 7 static hasMany = [contacts: Contact, 8 addresses: Address, 9 inventoryItems: InventoryItem] 8 addresses: Address] 10 9 11 static belongsTo = [InventoryItem]10 // static belongsTo = [] 12 11 13 12 static constraints = { -
trunk/grails-app/services/InventoryCsvService.groovy
r427 r436 55 55 def line = [] 56 56 def lineNumber = 0 57 def maxNumberOfColumns = 2 357 def maxNumberOfColumns = 25 58 58 def inventoryParams = [:] 59 59 def inventoryProperties = ["name", "description", "comment", "unitsInStock", "reorderPoint", "recommendedReorderPoint", … … 61 61 "enableReorder", "inventoryLocation", "inventoryStore", "site", 62 62 "inventoryGroup", "inventoryType", "averageDeliveryTime", "averageDeliveryPeriod", 63 "suppliersPartNumber", "suppliers", 64 "manufacturersPartNumber", "manufacturers", "alternateItems", "spareFor"] 63 "suppliersPartNumber", "preferredSupplier", "alternateSuppliers", 64 "manufacturersPartNumber", "preferredManufacturer", "alternateManufacturers", 65 "alternateItems", "spareFor"] 65 66 66 67 def siteInstance 67 def supplierInstance 68 def alternateSupplierInstance 69 def preferredSupplierInstance 68 70 def supplierTypeInstance 69 71 def supplierTypeUnknown = SupplierType.get(1) 70 72 def spareForInstance 71 73 def alternateItemInstance 72 def manufacturerInstance 74 def preferredManufacturerInstance 75 def alternateManufacturerInstance 73 76 def manufacturerTypeInstance 74 77 def manufacturerTypeUnknown = ManufacturerType.get(1) … … 81 84 def averageDeliveryPeriodInstance 82 85 83 def tempSuppliers = [] 86 def tempPreferredSupplierItemAndType = '' 87 def tempPreferredSupplierItem = '' 88 def tempPreferredSupplierType = '' 89 90 def tempAlternateSuppliers = [] 84 91 def tempSupplierItem = '' 85 92 def tempSupplierType = '' 86 93 def tempSupplierItemAndType = [] 87 def tempManufacturers = [] 94 95 def tempPreferredManufacturerItemAndType = '' 96 def tempPreferredManufacturerItem = '' 97 def tempPreferredManufacturerType = '' 98 99 def tempAlternateManufacturers = [] 88 100 def tempManufacturerItem = '' 89 101 def tempManufacturerType = '' … … 258 270 } 259 271 260 // Manufacturers. 261 tempManufacturers = parseInputList(inventoryParams.manufacturers) 272 // Preferred Manufacturer 273 if(inventoryParams.preferredManufacturer) { 274 tempPreferredManufacturerItemAndType = parseItemAndType(inventoryParams.preferredManufacturer) 275 tempPreferredManufacturerItem = WordUtils.capitalize(tempPreferredManufacturerItemAndType[0]) 276 277 preferredManufacturerInstance = Manufacturer.findByName(tempPreferredManufacturerItem) 278 if(!preferredManufacturerInstance) { 279 280 // Manufacturer Type. 281 if(tempPreferredManufacturerItemAndType.size == 2) { 282 tempPreferredManufacturerType = WordUtils.capitalizeFully(tempPreferredManufacturerItemAndType[1]) 283 manufacturerTypeInstance = ManufacturerType.findByName(tempPreferredManufacturerType) 284 } 285 else 286 manufacturerTypeInstance = manufacturerTypeUnknown 287 if(!manufacturerTypeInstance) { 288 log.error "Failed to find preferred manufacturer type on line: " + lineNumber 289 return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink]) 290 } 291 292 preferredManufacturerInstance = new Manufacturer(name: tempPreferredManufacturerItem, 293 supplierType: manufacturerTypeInstance) 294 if(!preferredManufacturerInstance.save()) { 295 log.error "Failed to create preferred manufacturer on line: " + lineNumber 296 return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink]) 297 } 298 } 299 } 300 else 301 preferredManufacturerInstance = null 302 303 // Alternate Manufacturers. 304 tempAlternateManufacturers = parseInputList(inventoryParams.manufacturers) 262 305 inventoryParams.manufacturers = [] 263 306 264 for(tempManufacturer in temp Manufacturers) {307 for(tempManufacturer in tempAlternateManufacturers) { 265 308 tempManufacturerItemAndType = parseItemAndType(tempManufacturer) 266 309 tempManufacturerItem = WordUtils.capitalizeFully(tempManufacturerItemAndType[0]) … … 292 335 } 293 336 294 // Suppliers. 295 tempSuppliers = parseInputList(inventoryParams.suppliers) 296 inventoryParams.suppliers = [] 297 298 for(tempSupplier in tempSuppliers) { 337 // Preferred Supplier 338 if(inventoryParams.preferredSupplier) { 339 tempPreferredSupplierItemAndType = parseItemAndType(inventoryParams.preferredSupplier) 340 tempPreferredSupplierItem = WordUtils.capitalize(tempPreferredSupplierItemAndType[0]) 341 342 preferredSupplierInstance = Supplier.findByName(tempPreferredSupplierItem) 343 if(!preferredSupplierInstance) { 344 345 // SupplierType. 346 if(tempPreferredSupplierItemAndType.size == 2) { 347 tempPreferredSupplierType = WordUtils.capitalizeFully(tempPreferredSupplierItemAndType[1]) 348 supplierTypeInstance = SupplierType.findByName(tempPreferredSupplierType) 349 } 350 else 351 supplierTypeInstance = supplierTypeUnknown 352 if(!supplierTypeInstance) { 353 log.error "Failed to find preferred supplier type on line: " + lineNumber 354 return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink]) 355 } 356 357 preferredSupplierInstance = new Supplier(name: tempPreferredSupplierItem, 358 supplierType: supplierTypeInstance) 359 if(!preferredSupplierInstance.save()) { 360 log.error "Failed to create preferred supplier on line: " + lineNumber 361 return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink]) 362 } 363 } 364 } 365 else 366 preferredSupplierInstance = null 367 368 // Alternate Suppliers. 369 tempAlternateSuppliers = parseInputList(inventoryParams.alternateSuppliers) 370 inventoryParams.alternateSuppliers = [] 371 372 for(tempSupplier in tempAlternateSuppliers) { 299 373 tempSupplierItemAndType = parseItemAndType(tempSupplier) 300 374 tempSupplierItem = WordUtils.capitalizeFully(tempSupplierItemAndType[0]) 301 375 302 supplierInstance = Supplier.findByName(tempSupplierItem)303 if(! supplierInstance) {376 alternateSupplierInstance = Supplier.findByName(tempSupplierItem) 377 if(!alternateSupplierInstance) { 304 378 305 379 // SupplierType. … … 311 385 supplierTypeInstance = supplierTypeUnknown 312 386 if(!supplierTypeInstance) { 313 log.error "Failed to find supplier type on line: " + lineNumber314 return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink]) 315 } 316 317 supplierInstance = new Supplier(name: tempSupplierItem,387 log.error "Failed to find alternate supplier type on line: " + lineNumber 388 return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink]) 389 } 390 391 alternateSupplierInstance = new Supplier(name: tempSupplierItem, 318 392 supplierType: supplierTypeInstance) 319 if(! supplierInstance.save()) {320 log.error "Failed to create suppliers on line: " + lineNumber321 return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink]) 322 } 323 } 324 325 inventoryParams.suppliers.add( supplierInstance)393 if(!alternateSupplierInstance.save()) { 394 log.error "Failed to create alternate suppliers on line: " + lineNumber 395 return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink]) 396 } 397 } 398 399 inventoryParams.suppliers.add(alternateSupplierInstance) 326 400 } 327 401 … … 373 447 inventoryParams.unitOfMeasure = unitOfMeasureInstance 374 448 inventoryParams.averageDeliveryPeriod = averageDeliveryPeriodInstance 449 inventoryParams.preferredSupplier = preferredSupplierInstance 450 inventoryParams.preferredManufacturer = preferredManufacturerInstance 375 451 376 452 // Name. … … 469 545 "Consumable", 470 546 "7", "Week(s)", 471 "123", "Multi Distributors1@OEM; Multi Distributors2@Local", 472 "321", "Mega Manufacturer1@OEM;Mega Manufacturer2@Alternate", 547 "123", "Multi Supplier@Local", 548 "Multi Distributors1@OEM; Multi Distributors2@Local", 549 "321", "Master Manufacturer@OEM", 550 "Mega Manufacturer1@OEM;Mega Manufacturer2@Alternate", 473 551 "2204E-2RS", "" 474 552 ] as String[]) … … 483 561 "Consumable", 484 562 "2", "Month(s)", 485 "456KL", "Multi Distributors1; Multi Distributors2", 486 "654OP", "Mega Manufacturer1;Mega Manufacturer2", 563 "456KL", "Multi Supplier", 564 "Multi Distributors1; Multi Distributors2", 565 "654OP", "Master Manufacturer", 566 "Mega Manufacturer1;Mega Manufacturer2", 487 567 "", "" 488 568 ] as String[]) … … 494 574 /** 495 575 * Build complete inventory for export. 496 * @param inventoryItemList The list of inventory items to build. .576 * @param inventoryItemList The list of inventory items to build. 497 577 * @returns The inventory as a String in csv format. 498 578 */ … … 528 608 row.add(inventoryItem.suppliersPartNumber) 529 609 530 row.add( inventoryItem.suppliers.sort { p1, p2 -> 610 if(inventoryItem.preferredSupplier) 611 row.add( inventoryItem.preferredSupplier.name + "@" + inventoryItem.preferredSupplier.supplierType ) 612 else 613 row.add('') 614 615 row.add( inventoryItem.alternateSuppliers.sort { p1, p2 -> 531 616 p1.name.compareToIgnoreCase(p2.name) 532 617 }.collect { it.name + "@" + it.supplierType }.join(';') ) … … 534 619 row.add(inventoryItem.manufacturersPartNumber) 535 620 536 row.add(inventoryItem.manufacturers.sort { p1, p2 -> 621 if(inventoryItem.preferredManufacturer) 622 row.add( inventoryItem.preferredManufacturer.name + "@" + inventoryItem.preferredManufacturer.manufacturerType ) 623 else 624 row.add('') 625 626 row.add(inventoryItem.alternateManufacturers.sort { p1, p2 -> 537 627 p1.name.compareToIgnoreCase(p2.name) 538 628 }.collect { it.name + "@" + it.manufacturerType }.join(';')) … … 556 646 ["Name*", "Description", "Comment", "Units In Stock", "Reorder Point*", "Recommended Reorder Point", "Unit Of Measure*", 557 647 "Estimated Unit Price", "Currency", "Enable Reorder", "Location*", "Store*", "Site*", "Group*", "Type*", 558 " averageDeliveryTime", "averageDeliveryPeriod", "Supplier's Part Number", "Supplier",559 "Manufacturer's Part Number", " Manufacturer", "Alternate Item", "Spare For"]648 "Average Delivery Time", "Average Delivery Period", "Supplier's Part Number", "Preferred Supplier", "Alternate Suppliers", 649 "Manufacturer's Part Number", "Preferred Manufacturer", "Alternate Manufacturers", "Alternate Item", "Spare For"] 560 650 } 561 651 -
trunk/grails-app/views/manufacturerDetailed/edit.gsp
r402 r436 95 95 </td> 96 96 </tr> 97 98 <tr class="prop">99 <td valign="top" class="name">Inventory Items:</td>100 101 <td valign="top" style="text-align:left;" class="value">102 <ul>103 <g:each var="i" in="${manufacturerInstance.inventoryItems}">104 <li><g:link controller="inventoryItemDetailed" action="show" id="${i.id}">${i?.encodeAsHTML()}</g:link></li>105 </g:each>106 </ul>107 </td>108 109 </tr>110 97 111 98 </tbody> -
trunk/grails-app/views/manufacturerDetailed/show.gsp
r402 r436 82 82 83 83 </tr> 84 85 <tr class="prop"> 86 <td valign="top" class="name">Inventory Items:</td> 87 88 <td valign="top" style="text-align:left;" class="value"> 89 <ul> 90 <g:each var="i" in="${manufacturerInstance.inventoryItems}"> 91 <li><g:link controller="inventoryItemDetailed" action="show" id="${i.id}">${i?.encodeAsHTML()}</g:link></li> 92 </g:each> 93 </ul> 94 </td> 95 96 </tr> 97 84 98 85 </tbody> 99 86 </table> -
trunk/grails-app/views/supplierDetailed/edit.gsp
r402 r436 95 95 </td> 96 96 </tr> 97 98 <tr class="prop">99 <td valign="top" class="name">Inventory Items:</td>100 101 <td valign="top" style="text-align:left;" class="value">102 <ul>103 <g:each var="i" in="${supplierInstance.inventoryItems}">104 <li><g:link controller="inventoryItemDetailed" action="show" id="${i.id}">${i?.encodeAsHTML()}</g:link></li>105 </g:each>106 </ul>107 </td>108 109 </tr>110 97 111 98 </tbody> -
trunk/grails-app/views/supplierDetailed/show.gsp
r402 r436 81 81 82 82 </tr> 83 84 <tr class="prop"> 85 <td valign="top" class="name">Inventory Items:</td> 86 87 <td valign="top" style="text-align:left;" class="value"> 88 <ul> 89 <g:each var="i" in="${supplierInstance.inventoryItems}"> 90 <li><g:link controller="inventoryItemDetailed" action="show" id="${i.id}">${i?.encodeAsHTML()}</g:link></li> 91 </g:each> 92 </ul> 93 </td> 94 95 </tr> 96 83 97 84 </tbody> 98 85 </table>
Note: See TracChangeset
for help on using the changeset viewer.