Changeset 720 for trunk/grails-app/services
- Timestamp:
- Nov 25, 2010, 9:08:43 AM (14 years ago)
- Location:
- trunk/grails-app/services
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/CreateDataService.groovy
r703 r720 1297 1297 estimatedUnitPriceAmount: 2.50, 1298 1298 estimatedUnitPriceCurrency: currency, 1299 alternateItems: InventoryItem.get(1),1300 1299 unitsInStock: 2, 1301 1300 reorderPoint: 0) -
trunk/grails-app/services/InventoryCsvService.groovy
r719 r720 59 59 "inventoryGroup", "inventoryType", 60 60 "suppliersPartNumber", "preferredSupplier", "alternateSuppliers", 61 " alternateItems", "spareFor"]61 "spareFor"] 62 62 63 63 def siteInstance … … 67 67 def supplierTypeUnknown = SupplierType.get(1) 68 68 def spareForInstance 69 def alternateItemInstance70 69 def inventoryTypeInstance 71 70 def unitOfMeasureInstance … … 85 84 86 85 def tempSpareFor = [] 87 def tempAlternateItems = []88 86 89 87 def nextLine = { … … 289 287 290 288 inventoryParams.alternateSuppliers.add(alternateSupplierInstance) 291 }292 293 // AlternateItems.294 tempAlternateItems = parseInputList(inventoryParams.alternateItems)295 inventoryParams.alternateItems = []296 297 for(tempAlternateItem in tempAlternateItems) {298 tempAlternateItem = WordUtils.capitalize(tempAlternateItem)299 alternateItemInstance = InventoryItem.findByName(tempAlternateItem)300 if(!alternateItemInstance) {301 alternateItemInstance = new InventoryItem(name: tempAlternateItem,302 description: "Generated from alternateItems during import, details may not be correct.",303 reorderPoint: 0,304 inventoryGroup: inventoryGroupInstance,305 inventoryType: inventoryTypeInstance,306 unitOfMeasure: unitOfMeasureInstance,307 inventoryLocation: inventoryLocationInstance)308 if(!alternateItemInstance.save()) {309 log.error "Failed to create alternateItems on line: " + lineNumber310 return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink])311 }312 }313 314 inventoryParams.alternateItems.add(alternateItemInstance)315 289 } 316 290 -
trunk/grails-app/services/InventoryItemService.groovy
r636 r720 13 13 def sessionFactory 14 14 def propertyInstanceMap = org.codehaus.groovy.grails.plugins.DomainClassGrailsPlugin.PROPERTY_INSTANCE_MAP 15 16 /**17 * Prepare a sorted list of possible alternateItems.18 */19 def getPossibleAlternateItems(inventoryItemInstance) {20 def criteria = inventoryItemInstance.createCriteria()21 def possibleAlternateItems = criteria {22 and {23 eq('isActive', true)24 notEqual('id', inventoryItemInstance.id)25 }26 }.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }27 }28 15 29 16 /** … … 129 116 return fail(code:"inventoryMovement.still.associated") 130 117 131 result.inventoryItemInstance.removeReverseAlternateItems()132 133 118 try { 134 119 result.inventoryItemInstance.delete(flush:true) … … 181 166 } 182 167 183 def previousAlternateItems = new ArrayList(result.inventoryItemInstance.alternateItems)184 185 168 result.inventoryItemInstance.properties = params 186 169 187 170 if(result.inventoryItemInstance.hasErrors() || !result.inventoryItemInstance.save()) 188 171 return fail(code:"default.update.failure") 189 190 result.inventoryItemInstance.removeReverseAlternateItems(previousAlternateItems)191 result.inventoryItemInstance.addReverseAlternateItems()192 172 193 173 // Success.
Note: See TracChangeset
for help on using the changeset viewer.