Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Linnea Samila
/
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 0f1ab868
authored
Sep 09, 2012
by
Petri Järvisalo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
barcode reader for shopToUser + sound effects
1 parent
3bdb6c29
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
208 additions
and
102 deletions
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/ProductBean.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/ProductFacade.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/ProductBeanLocal.java
code/LanBortalWeb/WebContent/resources/media/blip.mp3
code/LanBortalWeb/WebContent/shop/shopToUser.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/resources/i18n.properties
code/LanBortalWeb/src/fi/insomnia/bortal/resources/i18n_en.properties
code/LanBortalWeb/src/fi/insomnia/bortal/resources/i18n_fi.properties
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/ProductShopView.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/ProductBean.java
View file @
0f1ab86
...
@@ -356,4 +356,12 @@ public class ProductBean implements ProductBeanLocal {
...
@@ -356,4 +356,12 @@ public class ProductBean implements ProductBeanLocal {
public
AccountEvent
createAccountEvent
(
Product
product
,
BigDecimal
quantity
,
EventUser
user
)
{
public
AccountEvent
createAccountEvent
(
Product
product
,
BigDecimal
quantity
,
EventUser
user
)
{
return
createAccountEvent
(
product
,
quantity
,
user
,
Calendar
.
getInstance
());
return
createAccountEvent
(
product
,
quantity
,
user
,
Calendar
.
getInstance
());
}
}
@Override
//@RolesAllowed(ShopPermission.S_LIST_ALL_PRODUCTS)
public
Product
findByBarcode
(
String
barcode
)
{
return
productFacade
.
findProductByBarcode
(
barcode
);
}
}
}
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/ProductFacade.java
View file @
0f1ab86
...
@@ -65,5 +65,18 @@ public class ProductFacade extends IntegerPkGenericFacade<Product> {
...
@@ -65,5 +65,18 @@ public class ProductFacade extends IntegerPkGenericFacade<Product> {
return
getEm
().
createQuery
(
cq
).
getResultList
();
return
getEm
().
createQuery
(
cq
).
getResultList
();
}
}
public
Product
findProductByBarcode
(
String
barcode
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
Product
>
cq
=
cb
.
createQuery
(
Product
.
class
);
Root
<
Product
>
root
=
cq
.
from
(
Product
.
class
);
cq
.
where
(
cb
.
equal
(
root
.
get
(
Product_
.
barcode
),
barcode
)
);
return
super
.
getSingleNullableResult
(
getEm
().
createQuery
(
cq
));
}
}
}
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/ProductBeanLocal.java
View file @
0f1ab86
...
@@ -36,7 +36,9 @@ public interface ProductBeanLocal {
...
@@ -36,7 +36,9 @@ public interface ProductBeanLocal {
// List<Discount> getActiveDiscounts(Product product, BigDecimal quantity);
// List<Discount> getActiveDiscounts(Product product, BigDecimal quantity);
Product
findById
(
int
parseInt
);
Product
findById
(
int
parseInt
);
Product
findByBarcode
(
String
barcode
);
List
<
Product
>
findForStaffshop
();
List
<
Product
>
findForStaffshop
();
Discount
findDiscount
(
Integer
discountid
);
Discount
findDiscount
(
Integer
discountid
);
...
...
code/LanBortalWeb/WebContent/resources/media/blip.mp3
0 → 100644
View file @
0f1ab86
No preview for this file type
code/LanBortalWeb/WebContent/shop/shopToUser.xhtml
View file @
0f1ab86
<!DOCTYPE html
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:products=
"http://java.sun.com/jsf/composite/cditools/products"
xmlns:users=
"http://java.sun.com/jsf/composite/cditools/user"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:products=
"http://java.sun.com/jsf/composite/cditools/products"
xmlns:p=
"http://primefaces.org/ui"
xmlns:users=
"http://java.sun.com/jsf/composite/cditools/user"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<h:body>
<h:body>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<f:metadata>
<f:metadata>
<f:viewParam
name=
"userid"
value=
"#{userView.userid}"
/>
<f:viewParam
name=
"userid"
value=
"#{userView.userid}"
/>
<f:event
type=
"preRenderView"
listener=
"#{userView.initView}"
/>
<f:event
type=
"preRenderView"
listener=
"#{userView.initView}"
/>
<f:event
type=
"preRenderView"
listener=
"#{productShopView.initShopView}"
/>
<f:event
type=
"preRenderView"
listener=
"#{productShopView.initShopView}"
/>
</f:metadata>
</f:metadata>
<ui:define
name=
"title"
>
<ui:define
name=
"title"
>
...
@@ -17,38 +25,75 @@
...
@@ -17,38 +25,75 @@
</ui:define>
</ui:define>
<ui:define
name=
"content"
>
<ui:define
name=
"content"
>
<h:form
id=
"shoppingcartform"
>
<h:form
id=
"shoppingcartform"
>
<h:panelGrid
columns=
"2"
>
<h:panelGrid
columns=
"2"
>
<h:outputLabel
value=
"#{i18n['shop.accountBalance']}"
/>
<h:outputText
value=
"#{productShopView.accountBalance}"
>
<f:convertNumber
/>
</h:outputText>
<h:outputLabel
value=
"#{i18n['shop.totalPrice']}"
/>
<h:outputText
value=
"#{productShopView.totalPrice}"
>
<f:convertNumber
/>
</h:outputText>
<h:outputLabel
value=
"#{i18n['shop.cash']}"
/>
<h:inputText
value=
"#{productShopView.cash}"
>
<f:ajax
render=
"@form"
event=
"valueChange"
/>
<f:convertNumber
/>
</h:inputText>
</h:panelGrid>
<h:panelGrid
columns=
"2"
>
<h:outputLabel
value=
"#{i18n['shop.accountBalance']}"
/>
<h:outputText
value=
"#{productShopView.accountBalance}"
>
<f:convertNumber
/>
</h:outputText>
<h:outputLabel
value=
"#{i18n['shop.totalPrice']}"
/>
<h:outputText
value=
"#{productShopView.totalPrice}"
>
<f:convertNumber
/>
</h:outputText>
<h:outputLabel
value=
"#{i18n['shop.cash']}"
/>
<h:inputText
value=
"#{productShopView.cash}"
>
<f:ajax
render=
"@form"
event=
"valueChange"
/>
<f:convertNumber
/>
</h:inputText>
</h:panelGrid>
<h:panelGroup>
<h:outputLabel
value=
"#{i18n['shop.readBarcode']}"
/>
<h:inputText
id=
"barcode"
value=
"#{productShopView.barcode}"
/>
<h:commandButton
action=
"#{productShopView.readBarcode}"
onclick=
"blip(); return true;"
value=
"#{i18n['productShopView.readBarcode']}"
>
<f:ajax
render=
"@form"
onevent=
"barcodeReadEvent"
execute=
"@form"
/>
</h:commandButton>
</h:panelGroup>
</h:panelGrid>
<h:outputText
value=
"#{i18n['product.shopInstant']}"
/>
<h:outputText
value=
"#{i18n['product.shopInstant']}"
/>
<h:selectBooleanCheckbox
value=
"#{productShopView.payInstant}"
>
<h:selectBooleanCheckbox
value=
"#{productShopView.payInstant}"
>
<f:ajax
render=
"@form"
execute=
"@form"
/>
<f:ajax
render=
"@form"
execute=
"@form"
/>
</h:selectBooleanCheckbox>
</h:selectBooleanCheckbox>
<products:shop
commitaction=
"#{productShopView.commitShoppingCart()}"
items=
"#{productShopView.shoppingcart}"
commitValue=
"#{i18n['productshop.commit']}"
/>
<products:shop
commitaction=
"#{productShopView.commitShoppingCart()}"
items=
"#{productShopView.shoppingcart}"
commitValue=
"#{i18n['productshop.commit']}"
/>
</h:form>
</h:form>
<script>
var
blipSnd
=
new
Audio
(
"#{request.contextPath}/resources/media/blip.mp3"
)
$
(
function
()
{
$
(
"#shoppingcartform\\:barcode"
).
focus
();
})
function
blip
()
{
blipSnd
.
play
();
}
function
barcodeReadEvent
(
data
)
{
if
(
data
.
status
==
"success"
)
{
$
(
"#shoppingcartform\\:barcode"
).
focus
();
}
}
</script>
</ui:define>
</ui:define>
</ui:composition>
</ui:composition>
</h:body>
</h:body>
</html>
</html>
\ No newline at end of file
code/LanBortalWeb/src/fi/insomnia/bortal/resources/i18n.properties
View file @
0f1ab86
...
@@ -63,7 +63,7 @@ httpsession.creationTime = Luotu
...
@@ -63,7 +63,7 @@ httpsession.creationTime = Luotu
#Bill number
#Bill number
# Validationmessages
# Validationmessages
map.id
=
#
map.id
=
#
navi.auth.login
=
frontpage
navi.auth.login
=
frontpage
navi.auth.loginerror
=
frontpage
navi.auth.loginerror
=
frontpage
...
@@ -75,9 +75,9 @@ placegroupview.toptext = \
...
@@ -75,9 +75,9 @@ placegroupview.toptext = \
poll.edit
=
edit
poll.edit
=
edit
product.providedRole
=
Tuote tarjoaa roolin
product.providedRole
=
Tuote tarjoaa roolin
product.returnProductEdit
=
Palaa tuotteeseen:
product.returnProductEdit
=
Palaa tuotteeseen:
product.saved
=
Tuote tallennettu
product.saved
=
Tuote tallennettu
productshop.minusOne
=
-1
productshop.minusOne
=
-1
productshop.minusTen
=
-10
productshop.minusTen
=
-10
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/resources/i18n_en.properties
View file @
0f1ab86
...
@@ -381,26 +381,28 @@ poll.end = Close poll
...
@@ -381,26 +381,28 @@ poll.end = Close poll
poll.name
=
Poll name
poll.name
=
Poll name
poll.save
=
Send answers
poll.save
=
Send answers
product.barcode
=
Barcode
product.barcode
=
Barcode
product.billed
=
Billed
product.billed
=
Billed
product.boughtTotal
=
Products billed
product.boughtTotal
=
Products billed
product.cart.count
=
To shoppingcart
product.cart.count
=
To shoppingcart
product.cashed
=
Cashpaid
product.cashed
=
Cashpaid
product.color
=
Color in UI
product.color
=
Color in UI
product.create
=
Create product
product.create
=
Create product
product.createDiscount
=
Add volumediscount
product.createDiscount
=
Add volumediscount
product.edit
=
edit
product.edit
=
edit
product.name
=
Name of product
product.name
=
Name of product
product.paid
=
Paid
product.paid
=
Paid
product.prepaid
=
Prepaid
product.prepaid
=
Prepaid
product.prepaidInstant
=
Created when prepaid is paid
product.prepaidInstant
=
Created when prepaid is paid
product.price
=
Price of product
product.price
=
Price of product
product.save
=
Save
product.save
=
Save
product.shopInstant
=
Create automatic cashpayment
product.shopInstant
=
Create automatic cashpayment
product.sort
=
Sort nr
product.sort
=
Sort nr
product.totalPrice
=
Total
product.totalPrice
=
Total
product.unitName
=
Unit name
product.unitName
=
Unit name
product.vat
=
VAT
product.vat
=
VAT
productShopView.readBarcode
=
Read
products.save
=
Save
products.save
=
Save
...
@@ -449,6 +451,7 @@ sendPicture.header = S
...
@@ -449,6 +451,7 @@ sendPicture.header = S
shop.accountBalance
=
Account balance
shop.accountBalance
=
Account balance
shop.cash
=
Cash deposit
shop.cash
=
Cash deposit
shop.readBarcode
=
Read viivakoodi
shop.totalPrice
=
Price of products
shop.totalPrice
=
Price of products
shop.user
=
Selling to
shop.user
=
Selling to
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/resources/i18n_fi.properties
View file @
0f1ab86
...
@@ -370,26 +370,28 @@ poll.end = Sulje kysely
...
@@ -370,26 +370,28 @@ poll.end = Sulje kysely
poll.name
=
Kyselyn nimi
poll.name
=
Kyselyn nimi
poll.save
=
L
\u
00E4het
\u
00E4 vastauksesi
poll.save
=
L
\u
00E4het
\u
00E4 vastauksesi
product.barcode
=
Viivakoodi
product.barcode
=
Viivakoodi
product.billed
=
Laskutettu
product.billed
=
Laskutettu
product.boughtTotal
=
Tuotteita laskutettu
product.boughtTotal
=
Tuotteita laskutettu
product.cart.count
=
Ostoskoriin
product.cart.count
=
Ostoskoriin
product.cashed
=
Ostettu k
\u
00E4teisell
\u
00E4
product.cashed
=
Ostettu k
\u
00E4teisell
\u
00E4
product.color
=
V
\u
00E4ri k
\u
00E4ytt
\u
00F6liittym
\u
00E4ss
\u
00E4
product.color
=
V
\u
00E4ri k
\u
00E4ytt
\u
00F6liittym
\u
00E4ss
\u
00E4
product.create
=
Luo tuote
product.create
=
Luo tuote
product.createDiscount
=
Lis
\u
00E4
\u
00E4 m
\u
00E4
\u
00E4r
\u
00E4alennus
product.createDiscount
=
Lis
\u
00E4
\u
00E4 m
\u
00E4
\u
00E4r
\u
00E4alennus
product.edit
=
Muokkaa
product.edit
=
Muokkaa
product.name
=
Tuotteen nimi
product.name
=
Tuotteen nimi
product.paid
=
Maksettu
product.paid
=
Maksettu
product.prepaid
=
Prepaid
product.prepaid
=
Prepaid
product.prepaidInstant
=
Luodaan kun prepaid maksetaan
product.prepaidInstant
=
Luodaan kun prepaid maksetaan
product.price
=
Tuotteen hinta
product.price
=
Tuotteen hinta
product.save
=
Tallenna
product.save
=
Tallenna
product.shopInstant
=
Luo k
\u
00E4teismaksu tuotteille
product.shopInstant
=
Luo k
\u
00E4teismaksu tuotteille
product.sort
=
J
\u
00E4rjestys luku
product.sort
=
J
\u
00E4rjestys luku
product.totalPrice
=
Summa
product.totalPrice
=
Summa
product.unitName
=
Tuoteyksikk
\u
00F6
product.unitName
=
Tuoteyksikk
\u
00F6
product.vat
=
ALV
product.vat
=
ALV
productShopView.readBarcode
=
Lue
products.save
=
Tallenna
products.save
=
Tallenna
...
@@ -436,6 +438,7 @@ sendPicture.header = L\u00E4het\u00E4 kuva
...
@@ -436,6 +438,7 @@ sendPicture.header = L\u00E4het\u00E4 kuva
shop.accountBalance
=
Tilin saldo
shop.accountBalance
=
Tilin saldo
shop.cash
=
K
\u
00E4teispano
shop.cash
=
K
\u
00E4teispano
shop.readBarcode
=
Lue viivakoodi
shop.totalPrice
=
Tuotteiden hinta
shop.totalPrice
=
Tuotteiden hinta
shop.user
=
Myyd
\u
00E4
\u
00E4n
shop.user
=
Myyd
\u
00E4
\u
00E4n
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/ProductShopView.java
View file @
0f1ab86
...
@@ -29,7 +29,8 @@ import fi.insomnia.bortal.web.helpers.ProductShopItem;
...
@@ -29,7 +29,8 @@ import fi.insomnia.bortal.web.helpers.ProductShopItem;
@ConversationScoped
@ConversationScoped
public
class
ProductShopView
extends
GenericCDIView
{
public
class
ProductShopView
extends
GenericCDIView
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ProductShopView
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ProductShopView
.
class
);
/**
/**
*
*
*/
*/
...
@@ -50,6 +51,7 @@ public class ProductShopView extends GenericCDIView {
...
@@ -50,6 +51,7 @@ public class ProductShopView extends GenericCDIView {
private
boolean
payInstant
;
private
boolean
payInstant
;
private
BigDecimal
cash
=
BigDecimal
.
ZERO
;
private
BigDecimal
cash
=
BigDecimal
.
ZERO
;
private
String
barcode
;
private
transient
ListDataModel
<
ProductShopItem
>
shoppingcart
;
private
transient
ListDataModel
<
ProductShopItem
>
shoppingcart
;
@Inject
@Inject
...
@@ -58,11 +60,14 @@ public class ProductShopView extends GenericCDIView {
...
@@ -58,11 +60,14 @@ public class ProductShopView extends GenericCDIView {
@Inject
@Inject
private
BillEditView
billEditView
;
private
BillEditView
billEditView
;
private
boolean
hasLimits
=
false
;
private
boolean
hasLimits
=
false
;
private
boolean
blip
=
false
;
public
void
initBillView
()
{
public
void
initBillView
()
{
if
(
requirePermissions
(
ShopPermission
.
LIST_USERPRODUCTS
)
&&
shoppingcart
==
null
)
{
if
(
requirePermissions
(
ShopPermission
.
LIST_USERPRODUCTS
)
shoppingcart
=
new
ListDataModel
<
ProductShopItem
>(
ProductShopItem
.
productList
(
productBean
.
listUserShoppableProducts
()));
&&
shoppingcart
==
null
)
{
shoppingcart
=
new
ListDataModel
<
ProductShopItem
>(
ProductShopItem
.
productList
(
productBean
.
listUserShoppableProducts
()));
updateCartLimits
();
updateCartLimits
();
logger
.
debug
(
"Initialized billing shoppingcart to {}"
,
shoppingcart
);
logger
.
debug
(
"Initialized billing shoppingcart to {}"
,
shoppingcart
);
this
.
beginConversation
();
this
.
beginConversation
();
...
@@ -72,17 +77,18 @@ public class ProductShopView extends GenericCDIView {
...
@@ -72,17 +77,18 @@ public class ProductShopView extends GenericCDIView {
public
void
initShopView
()
{
public
void
initShopView
()
{
if
(
requirePermissions
(
ShopPermission
.
SHOP_TO_OTHERS
)
&&
shoppingcart
==
null
)
{
if
(
requirePermissions
(
ShopPermission
.
SHOP_TO_OTHERS
)
shoppingcart
=
new
ListDataModel
<
ProductShopItem
>(
ProductShopItem
.
productGTList
(
productBean
.
findForStaffshop
()));
&&
shoppingcart
==
null
)
{
shoppingcart
=
new
ListDataModel
<
ProductShopItem
>(
ProductShopItem
.
productGTList
(
productBean
.
findForStaffshop
()));
updateCartLimits
();
updateCartLimits
();
logger
.
debug
(
"Initialized shoppingcart to {}"
,
shoppingcart
);
logger
.
debug
(
"Initialized shoppingcart to {}"
,
shoppingcart
);
this
.
beginConversation
();
this
.
beginConversation
();
}
}
}
}
public
String
add
(
Integer
count
)
public
String
add
(
Integer
count
)
{
{
ProductShopItem
item
=
shoppingcart
.
getRowData
();
ProductShopItem
item
=
shoppingcart
.
getRowData
();
item
.
setCount
(
item
.
getCount
().
add
(
BigDecimal
.
valueOf
(
count
)));
item
.
setCount
(
item
.
getCount
().
add
(
BigDecimal
.
valueOf
(
count
)));
...
@@ -94,15 +100,14 @@ public class ProductShopView extends GenericCDIView {
...
@@ -94,15 +100,14 @@ public class ProductShopView extends GenericCDIView {
public
void
updateCartLimits
()
{
public
void
updateCartLimits
()
{
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
(
prodCounts
,
user
);
HashMap
<
Integer
,
BigDecimal
>
limits
=
productBean
.
getProductLimit
(
prodCounts
,
user
);
for
(
ProductShopItem
n
:
shoppingcart
)
for
(
ProductShopItem
n
:
shoppingcart
)
{
{
BigDecimal
l
=
limits
.
get
(
n
.
getProduct
().
getId
());
BigDecimal
l
=
limits
.
get
(
n
.
getProduct
().
getId
());
if
(
l
!=
null
)
{
if
(
l
!=
null
)
{
hasLimits
=
true
;
hasLimits
=
true
;
...
@@ -111,22 +116,19 @@ public class ProductShopView extends GenericCDIView {
...
@@ -111,22 +116,19 @@ public class ProductShopView extends GenericCDIView {
}
}
}
}
public
BigDecimal
getAccountBalance
()
public
BigDecimal
getAccountBalance
()
{
{
BigDecimal
ret
=
user
.
getAccountBalance
();
BigDecimal
ret
=
user
.
getAccountBalance
();
ret
=
ret
.
add
(
getCash
());
ret
=
ret
.
add
(
getCash
());
ret
=
ret
.
subtract
(
getTotalPrice
());
ret
=
ret
.
subtract
(
getTotalPrice
());
logger
.
info
(
"User accountbalance {}, cash{}, total {}. retBalance {}"
,
new
Object
[]
{
logger
.
info
(
"User accountbalance {}, cash{}, total {}. retBalance {}"
,
user
.
getAccountBalance
(),
getCash
(),
getTotalPrice
(),
ret
new
Object
[]
{
user
.
getAccountBalance
(),
getCash
(),
});
getTotalPrice
(),
ret
});
return
ret
;
return
ret
;
}
}
public
BigDecimal
getTotalPrice
()
public
BigDecimal
getTotalPrice
()
{
{
BigDecimal
ret
=
BigDecimal
.
ZERO
;
BigDecimal
ret
=
BigDecimal
.
ZERO
;
for
(
ProductShopItem
cart
:
shoppingcart
)
for
(
ProductShopItem
cart
:
shoppingcart
)
{
{
ret
=
ret
.
add
(
cart
.
getPrice
());
ret
=
ret
.
add
(
cart
.
getPrice
());
}
}
return
ret
;
return
ret
;
...
@@ -159,22 +161,21 @@ public class ProductShopView extends GenericCDIView {
...
@@ -159,22 +161,21 @@ public class ProductShopView extends GenericCDIView {
}
}
public
String
commitShoppingCart
()
public
String
commitShoppingCart
()
{
{
EventUser
retuser
=
null
;
EventUser
retuser
=
null
;
for
(
ProductShopItem
shopitem
:
shoppingcart
)
{
for
(
ProductShopItem
shopitem
:
shoppingcart
)
{
if
(
shopitem
.
getCount
().
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
if
(
shopitem
.
getCount
().
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
retuser
=
productBean
.
createAccountEvent
(
shopitem
.
getProduct
(),
shopitem
.
getCount
(),
user
).
getUser
();
retuser
=
productBean
.
createAccountEvent
(
shopitem
.
getProduct
(),
shopitem
.
getCount
(),
user
).
getUser
();
}
}
}
}
if
(
cash
!=
null
&&
cash
.
compareTo
(
BigDecimal
.
ZERO
)
!=
0
)
if
(
cash
!=
null
&&
cash
.
compareTo
(
BigDecimal
.
ZERO
)
!=
0
)
{
{
Product
credProd
=
productBean
.
findCreditProduct
();
Product
credProd
=
productBean
.
findCreditProduct
();
retuser
=
productBean
.
createAccountEvent
(
credProd
,
cash
,
user
).
getUser
();
retuser
=
productBean
.
createAccountEvent
(
credProd
,
cash
,
user
)
.
getUser
();
}
}
if
(
user
!=
null
)
if
(
user
!=
null
)
{
{
user
=
retuser
;
user
=
retuser
;
}
}
shoppingcart
=
null
;
shoppingcart
=
null
;
...
@@ -209,8 +210,7 @@ public class ProductShopView extends GenericCDIView {
...
@@ -209,8 +210,7 @@ public class ProductShopView extends GenericCDIView {
}
}
public
void
setPayInstant
(
boolean
payInstant
)
{
public
void
setPayInstant
(
boolean
payInstant
)
{
if
(
payInstant
)
if
(
payInstant
)
{
{
getCash
();
getCash
();
}
}
this
.
payInstant
=
payInstant
;
this
.
payInstant
=
payInstant
;
...
@@ -250,4 +250,35 @@ public class ProductShopView extends GenericCDIView {
...
@@ -250,4 +250,35 @@ public class ProductShopView extends GenericCDIView {
public
void
setHasLimits
(
boolean
hasLimits
)
{
public
void
setHasLimits
(
boolean
hasLimits
)
{
this
.
hasLimits
=
hasLimits
;
this
.
hasLimits
=
hasLimits
;
}
}
public
String
getBarcode
()
{
return
barcode
;
}
public
void
setBarcode
(
String
barcode
)
{
this
.
barcode
=
barcode
;
}
public
void
readBarcode
()
{
Product
product
=
productBean
.
findByBarcode
(
this
.
barcode
);
this
.
blip
=
false
;
for
(
ProductShopItem
a
:
shoppingcart
)
{
if
(
a
.
getProduct
().
equals
(
product
))
{
a
.
setCount
(
a
.
getCount
().
add
(
BigDecimal
.
ONE
));
setBlip
(
true
);
break
;
}
}
this
.
barcode
=
null
;
logger
.
debug
(
"barcode read"
);
}
public
boolean
isBlip
()
{
return
blip
;
}
public
void
setBlip
(
boolean
blip
)
{
this
.
blip
=
blip
;
}
}
}
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