Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e977367c
authored
Dec 28, 2012
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug hunted from barcodes
1 parent
6d11ea6b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
code/MoyaWeb/WebContent/resources/cditools/shop/shoppingcart.xhtml
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/shop/ProductShopView.java
code/MoyaWeb/WebContent/resources/cditools/shop/shoppingcart.xhtml
View file @
e977367
...
@@ -38,13 +38,11 @@
...
@@ -38,13 +38,11 @@
<h:outputLabel
value=
"#{i18n['shop.barcode']}"
/>
<h:outputLabel
value=
"#{i18n['shop.barcode']}"
/>
<h:inputText
id=
"barcode"
value=
"#{productShopView.barcode}"
/>
<h:inputText
id=
"barcode"
value=
"#{productShopView.barcode}"
/>
<h:commandButton
action=
"#{productShopView.readBarcode}"
onclick=
"blip(); return true;"
value=
"#{i18n['shop.readBarcode']}"
>
<h:commandButton
action=
"#{productShopView.readBarcode}"
value=
"#{i18n['shop.readBarcode']}"
>
<f:ajax
render=
"@form"
onevent=
"barcodeReadEvent"
execute=
"@form"
/>
<f:ajax
render=
"@form"
onevent=
"barcodeReadEvent"
execute=
"@form"
/>
</h:commandButton>
</h:commandButton>
<br
/>
<br
/>
<p:dataTable
id=
"prods"
value=
"#{productShopView.boughtItems}"
var=
"prods"
>
<p:dataTable
id=
"prods"
value=
"#{productShopView.boughtItems}"
var=
"prods"
>
<p:column>
<p:column>
<f:facet
name=
"header"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"#{i18n['shop.count']}"
/>
<h:outputText
value=
"#{i18n['shop.count']}"
/>
...
@@ -138,6 +136,8 @@
...
@@ -138,6 +136,8 @@
function
calc
()
{
function
calc
()
{
$
(
"#returnval"
).
val
(
$
(
"#inputval"
).
val
()
-
$
(
".inputval"
).
text
().
replace
(
","
,
"."
));
$
(
"#returnval"
).
val
(
$
(
"#inputval"
).
val
()
-
$
(
".inputval"
).
text
().
replace
(
","
,
"."
));
}
}
function
barcodeReadEvent
(
data
)
{
function
barcodeReadEvent
(
data
)
{
if
(
data
.
status
==
"success"
)
{
if
(
data
.
status
==
"success"
)
{
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/shop/ProductShopView.java
View file @
e977367
...
@@ -140,7 +140,7 @@ public class ProductShopView extends GenericCDIView {
...
@@ -140,7 +140,7 @@ public class ProductShopView extends GenericCDIView {
Map
<
Integer
,
BigDecimal
>
prodCounts
=
new
HashMap
<
Integer
,
BigDecimal
>();
Map
<
Integer
,
BigDecimal
>
prodCounts
=
new
HashMap
<
Integer
,
BigDecimal
>();
for
(
ProductShopItem
sc
:
shoppingcart
)
{
for
(
ProductShopItem
sc
:
shoppingcart
)
{
prodCounts
.
put
(
sc
.
getProduct
().
getId
(),
sc
.
getCount
());
prodCounts
.
put
(
sc
.
getProduct
().
getId
(),
sc
.
getCount
());
}
}
HashMap
<
Integer
,
BigDecimal
>
limits
=
productBean
.
getProductLimit
(
HashMap
<
Integer
,
BigDecimal
>
limits
=
productBean
.
getProductLimit
(
...
@@ -365,16 +365,25 @@ public class ProductShopView extends GenericCDIView {
...
@@ -365,16 +365,25 @@ public class ProductShopView extends GenericCDIView {
public
String
readBarcode
()
{
public
String
readBarcode
()
{
Product
product
=
productBean
.
findByBarcode
(
this
.
barcode
);
Product
product
=
productBean
.
findByBarcode
(
this
.
barcode
);
this
.
blip
=
false
;
this
.
blip
=
false
;
// find product index, set index and add one
// I don't know why this does not work if you just loop over and change the product count
int
n
=
0
;
for
(
ProductShopItem
a
:
shoppingcart
)
{
for
(
ProductShopItem
a
:
shoppingcart
)
{
if
(
a
.
getProduct
().
equals
(
product
))
{
if
(
a
.
getProduct
().
equals
(
product
))
a
.
setCount
(
a
.
getCount
().
add
(
BigDecimal
.
ONE
));
{
//a.setCount(a.getCount().add(BigDecimal.ONE));
//updateCartLimits(null);
shoppingcart
.
setRowIndex
(
n
);
this
.
addOne
();
setBlip
(
true
);
setBlip
(
true
);
break
;
break
;
}
}
n
++;
}
}
this
.
barcode
=
null
;
this
.
barcode
=
null
;
logger
.
debug
(
"barcode read"
);
logger
.
debug
(
"barcode read"
);
return
null
;
return
"success"
;
}
}
public
boolean
isBlip
()
{
public
boolean
isBlip
()
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment