Commit e977367c by Tuukka Kivilahti

bug hunted from barcodes

1 parent 6d11ea6b
......@@ -38,13 +38,11 @@
<h:outputLabel value="#{i18n['shop.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" />
</h:commandButton>
<br />
<p:dataTable id="prods" value="#{productShopView.boughtItems}" var="prods">
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['shop.count']}" />
......@@ -138,6 +136,8 @@
function calc() {
$("#returnval").val($("#inputval").val() - $(".inputval").text().replace(",","."));
}
function barcodeReadEvent(data) {
if (data.status == "success") {
......
......@@ -140,7 +140,7 @@ public class ProductShopView extends GenericCDIView {
Map<Integer, BigDecimal> prodCounts = new HashMap<Integer, BigDecimal>();
for (ProductShopItem sc : shoppingcart) {
prodCounts.put(sc.getProduct().getId(), sc.getCount());
prodCounts.put(sc.getProduct().getId(), sc.getCount());
}
HashMap<Integer, BigDecimal> limits = productBean.getProductLimit(
......@@ -365,16 +365,25 @@ public class ProductShopView extends GenericCDIView {
public String readBarcode() {
Product product = productBean.findByBarcode(this.barcode);
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) {
if (a.getProduct().equals(product)) {
a.setCount(a.getCount().add(BigDecimal.ONE));
if (a.getProduct().equals(product))
{
//a.setCount(a.getCount().add(BigDecimal.ONE));
//updateCartLimits(null);
shoppingcart.setRowIndex(n);
this.addOne();
setBlip(true);
break;
}
n++;
}
this.barcode = null;
logger.debug("barcode read");
return null;
return "success";
}
public boolean isBlip() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!