Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

getting everything working from end-to-ed with backstock

  • Loading branch information...
commit 59f97b3c6cbf4ea094e52af916e0913c4ce13988 1 parent a3a33df
unknown authored
View
55 grails-app/controllers/tgt/BackstockController.groovy
@@ -15,29 +15,68 @@ class BackstockController {
//def item = new Item(sku:sku, description:"Men's Awesome Plaid Pants")
//TODO - replace this with a real item locations lookup based on item sku
- def itemLocations = []
+// def itemLocations = []
+//
+// itemLocations << new ItemLocation(location: new Location(state: 'Open Stock', locId: 'ABC XYZ 123'), quantity: 3)
+// itemLocations << new ItemLocation(location: new Location(state: 'Boxed', locId: 'XYZ ABC 321'), quantity: 4)
+// itemLocations << new ItemLocation(location: new Location(state: 'Open Stock', locId: 'XYA CBZ 456'), quantity: 5)
- itemLocations << new ItemLocation(location: new Location(state: 'Open Stock', locId: 'ABC XYZ 123'), quantity: 3)
- itemLocations << new ItemLocation(location: new Location(state: 'Boxed', locId: 'XYZ ABC 321'), quantity: 4)
- itemLocations << new ItemLocation(location: new Location(state: 'Open Stock', locId: 'XYA CBZ 456'), quantity: 5)
+ session.item = item
- [itemLocations: itemLocations, item: item]
+ [itemLocations: item.itemLocations, item: item]
}
// edit item location
def editItemLocation = {
println "params: $params"
- def itemloc = new ItemLocation(location: new Location(locId: params.txtLocationScan), quantity:3,
- item: new Item(sku:'123123', description:'awesome item', state: 'itemstate'))
+
+ def locId = params.txtLocationScan
+ def item = session.item
+ def location = Location.findByLocId(locId)
+
+ def itemloc = new ItemLocation(location:location, quantity:0, item:item)
+
+ println "loc id: $locId"
+ println "item: $item"
+ println "location: $location"
+ println "item loc: $itemloc"
+
+ session.location = location
+
[itemloc: itemloc]
}
def updateItemLocation = {
println "params: $params"
- def quantity = params.txtItemQty
+ def quantity = params.txtItemQty ? params.int('txtItemQty') : 0
+ def location = session.location
+ def item = session.item
+
+ println "quantity: $quantity"
+ println "location: $location"
+ println "item: $item"
+
+ def itemLocation = ItemLocation.findByLocationAndItem(location, item)
+
+ if(!itemLocation){
+ println "item location does not exist - creating a new one"
+ itemLocation = new ItemLocation(location:location, item:item)
+ }
+
+ itemLocation.quantity += quantity
+
// update itemlocation quantity
+ if(itemLocation.save()){
+ println "successfully updated item location quantity to $itemLocation.quantity"
+ }else{
+ println "failed to update item location: $itemLocation.errors"
+ }
+
+ session.location = null
+ session.item = null
+
[]
View
4 grails-app/views/backstock/editItemLocation.gsp
@@ -10,8 +10,8 @@
"homeURL": "ajax/ajax_Home.chtm",
"toggleURL": "ajax/ajax_Home.chtm",
"line_1": "",
- "line_2": "490581002089",
- "line_3": "Men's Denim Shorts",
+ "line_2": "${itemloc?.item?.sku}",
+ "line_3": "${itemloc?.item?.description}",
"fill_group": "Mens",
"location": "${itemloc?.location?.locId}",
"fieldLabel": "Enter quantity",
View
4 grails-app/views/itemLocation/_form.gsp
@@ -7,7 +7,7 @@
<g:message code="itemLocation.item.label" default="Item" />
<span class="required-indicator">*</span>
</label>
- <g:select id="item" name="item.id" from="${tgt.Item.list()}" optionKey="id" required="" value="${itemLocationInstance?.item?.id}" class="many-to-one"/>
+ <g:select id="item" name="item.sku" from="${tgt.Item.list()}" optionKey="id" required="" value="${itemLocationInstance?.item?.id}" class="many-to-one"/>
</div>
<div class="fieldcontain ${hasErrors(bean: itemLocationInstance, field: 'location', 'error')} required">
@@ -15,7 +15,7 @@
<g:message code="itemLocation.location.label" default="Location" />
<span class="required-indicator">*</span>
</label>
- <g:select id="location" name="location.id" from="${tgt.Location.list()}" optionKey="id" required="" value="${itemLocationInstance?.location?.id}" class="many-to-one"/>
+ <g:select id="location" name="location.locId" from="${tgt.Location.list()}" optionKey="id" required="" value="${itemLocationInstance?.location?.id}" class="many-to-one"/>
</div>
<div class="fieldcontain ${hasErrors(bean: itemLocationInstance, field: 'quantity', 'error')} required">
Please sign in to comment.
Something went wrong with that request. Please try again.