Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 3d49424b
authored
Feb 28, 2014
by
Liv Haapala
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.codecrew.fi:codecrew/moya
2 parents
24f62b44
f689b093
Hide whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
457 additions
and
187 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BillBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/DiscountBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/EventBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PermissionBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/ProductBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/ProductPBean.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/BillBeanLocal.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/DiscountBeanLocal.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/EventBeanLocal.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/ProductBeanLocal.java
code/MoyaDatabase/src/fi/codecrew/moya/model/Bill.java
code/MoyaDatabase/src/fi/codecrew/moya/model/LanEventPropertyKey.java
code/MoyaDatabase/src/fi/codecrew/moya/model/Product.java
code/MoyaEar/.settings/org.eclipse.wst.common.component
code/MoyaEar/EarContent/META-INF/application.xml
code/MoyaEar/pom.xml
code/MoyaEventMgmtWeb/.settings/org.eclipse.wst.common.component
code/MoyaTerminalWeb/WebContent/WEB-INF/web.xml
code/MoyaTerminalWeb/pom.xml
code/MoyaTerminalWeb/src/fi/codecrew/moya/terminal/handler/SessionHandler.java
code/MoyaTerminalWeb/src/fi/codecrew/moya/terminal/view/RedirectView.java
code/MoyaTerminalWeb/src/fi/codecrew/moya/terminal/view/TestView.java
code/MoyaUtilities/src/main/java/fi/codecrew/moya/enums/apps/TerminalPermission.java
code/MoyaWeb/.classpath
code/MoyaWeb/WebContent/eventorg/editEvent.xhtml
code/MoyaWeb/WebContent/resources/cditools/products/manageDiscount.xhtml
code/MoyaWeb/WebContent/resources/cditools/products/shop.xhtml
code/MoyaWeb/WebContent/resources/cditools/shop/shoppingcart.xhtml
code/MoyaWeb/WebContent/resources/templates/template1/css/style.css
code/MoyaWeb/WebContent/resources/templates/template1/template.xhtml
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/shop/FoodWaveFoodView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/shop/ProductShopView.java
code/MoyaWeb/src/fi/codecrew/moya/web/helper/ProductShopItemHelper.java
code/MoyaWeb/src/fi/codecrew/moya/web/helpers/ProductShopItem.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BillBean.java
View file @
3d49424
package
fi
.
codecrew
.
moya
.
beans
;
package
fi
.
codecrew
.
moya
.
beans
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.math.BigDecimal
;
import
java.text.MessageFormat
;
import
java.text.MessageFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
...
@@ -27,7 +29,9 @@ import fi.codecrew.moya.facade.EventUserFacade;
...
@@ -27,7 +29,9 @@ import fi.codecrew.moya.facade.EventUserFacade;
import
fi.codecrew.moya.model.AccountEvent
;
import
fi.codecrew.moya.model.AccountEvent
;
import
fi.codecrew.moya.model.Bill
;
import
fi.codecrew.moya.model.Bill
;
import
fi.codecrew.moya.model.BillLine
;
import
fi.codecrew.moya.model.BillLine
;
import
fi.codecrew.moya.model.Discount
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.FoodWave
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.LanEventPropertyKey
;
import
fi.codecrew.moya.model.LanEventPropertyKey
;
import
fi.codecrew.moya.model.Product
;
import
fi.codecrew.moya.model.Product
;
...
@@ -68,6 +72,9 @@ public class BillBean implements BillBeanLocal {
...
@@ -68,6 +72,9 @@ public class BillBean implements BillBeanLocal {
private
EventUserFacade
eventUserFacade
;
private
EventUserFacade
eventUserFacade
;
@EJB
@EJB
private
ProductPBean
productPBean
;
private
ProductPBean
productPBean
;
@EJB
private
DiscountBean
discountBean
;
/**
/**
* Default constructor.
* Default constructor.
...
@@ -304,5 +311,38 @@ public class BillBean implements BillBeanLocal {
...
@@ -304,5 +311,38 @@ public class BillBean implements BillBeanLocal {
bill
.
markExpired
();
bill
.
markExpired
();
return
bill
;
return
bill
;
}
}
@Override
public
Bill
addProductToBill
(
Bill
bill
,
Product
product
,
BigDecimal
count
)
{
return
this
.
addProductToBill
(
bill
,
product
,
count
,
null
);
}
@Override
public
Bill
addProductToBill
(
Bill
bill
,
Product
product
,
BigDecimal
count
,
FoodWave
foodwave
)
{
// If bill number > 0 bill has been sent and extra privileges are needed
// to modify.
// if (!iscurrent || billnr != null) {
// permbean.fatalPermission(BillPermission.WRITE_ALL,
// "User tried to modify bill ", bill,
// "without sufficient permissions");
// }
if
(
bill
.
getBillLines
()
==
null
)
{
bill
.
setBillLines
(
new
ArrayList
<
BillLine
>());
}
bill
.
getBillLines
().
add
(
new
BillLine
(
bill
,
product
,
count
,
foodwave
));
for
(
Discount
disc
:
discountBean
.
getActiveDiscountsByProduct
(
product
,
count
,
bill
.
getSentDate
(),
bill
.
getUser
()))
{
bill
.
getBillLines
().
add
(
new
BillLine
(
bill
,
product
,
disc
,
count
));
}
return
bill
;
}
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
View file @
3d49424
...
@@ -35,6 +35,9 @@ public class BootstrapBean implements BootstrapBeanLocal {
...
@@ -35,6 +35,9 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbUpdates
.
add
(
new
String
[]
{
"ALTER TABLE site_page_content ADD COLUMN locale varchar(10)"
});
dbUpdates
.
add
(
new
String
[]
{
"ALTER TABLE site_page_content ADD COLUMN locale varchar(10)"
});
dbUpdates
.
add
(
new
String
[]
{
"ALTER TABLE products ALTER COLUMN vat TYPE NUMERIC(4,3)"
});
dbUpdates
.
add
(
new
String
[]
{
"ALTER TABLE products ALTER COLUMN vat TYPE NUMERIC(4,3)"
});
dbUpdates
.
add
(
new
String
[]
{
"ALTER TABLE actionlog_messages DROP COLUMN crew"
});
dbUpdates
.
add
(
new
String
[]
{
"ALTER TABLE actionlog_messages DROP COLUMN crew"
});
dbUpdates
.
add
(
new
String
[]
{
"delete from application_permissions where application ilike '%terminal%'"
});
}
}
@EJB
@EJB
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/DiscountBean.java
View file @
3d49424
package
fi
.
codecrew
.
moya
.
beans
;
package
fi
.
codecrew
.
moya
.
beans
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
javax.ejb.Stateless
;
import
fi.codecrew.moya.facade.DiscountFacade
;
import
fi.codecrew.moya.facade.DiscountFacade
;
import
fi.codecrew.moya.facade.EventFacade
;
import
fi.codecrew.moya.facade.ProductFacade
;
import
fi.codecrew.moya.beans.DiscountBeanLocal
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.model.Discount
;
import
fi.codecrew.moya.model.Discount
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.Product
;
import
fi.codecrew.moya.model.Role
;
/**
/**
* Session Bean implementation class DiscountBean
* Session Bean implementation class DiscountBean
*/
*/
@Stateless
@Stateless
@LocalBean
public
class
DiscountBean
implements
DiscountBeanLocal
{
public
class
DiscountBean
implements
DiscountBeanLocal
{
@EJB
@EJB
private
DiscountFacade
discountfacade
;
private
DiscountFacade
discountfacade
;
@EJB
@EJB
private
EventBeanLocal
eventbean
;
private
UserBean
userBean
;
@EJB
private
ProductFacade
productfacade
;
@EJB
private
EventFacade
eventfacade
;
public
DiscountBean
()
{
public
DiscountBean
()
{
}
}
...
@@ -36,6 +39,35 @@ public class DiscountBean implements DiscountBeanLocal {
...
@@ -36,6 +39,35 @@ public class DiscountBean implements DiscountBeanLocal {
return
ret
;
return
ret
;
}
}
@Override
public
List
<
Discount
>
getActiveDiscountsByProduct
(
Product
product
,
BigDecimal
quantity
,
Calendar
time
,
EventUser
user
)
{
ArrayList
<
Discount
>
ret
=
new
ArrayList
<
Discount
>();
for
(
Discount
d
:
product
.
getDiscounts
())
{
if
(
d
.
isActive
()
&&
(
d
.
getValidTo
()
==
null
||
d
.
getValidTo
().
after
(
time
))
&&
(
d
.
getValidFrom
()
==
null
||
d
.
getValidFrom
().
before
(
time
))
&&
(
d
.
getAmountMax
().
compareTo
(
BigDecimal
.
ZERO
)
==
0
||
quantity
.
compareTo
(
d
.
getAmountMax
())
<=
0
)
&&
(
d
.
getAmountMin
().
compareTo
(
BigDecimal
.
ZERO
)
==
0
||
quantity
.
compareTo
(
d
.
getAmountMin
())
>=
0
))
{
// plaah, there is role, must do stuff
if
(
d
.
getRole
()
!=
null
)
{
for
(
Role
role
:
userBean
.
localFindUsersRoles
(
user
))
{
if
(
d
.
getRole
().
equals
(
role
))
{
ret
.
add
(
d
);
}
}
}
else
{
ret
.
add
(
d
);
}
}
}
return
ret
;
}
// @Override
// @Override
// public Discount create(String discountdesc) {
// public Discount create(String discountdesc) {
// LanEvent ev = eventbean.getCurrentEvent();
// LanEvent ev = eventbean.getCurrentEvent();
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/EventBean.java
View file @
3d49424
...
@@ -187,6 +187,22 @@ public class EventBean implements EventBeanLocal {
...
@@ -187,6 +187,22 @@ public class EventBean implements EventBeanLocal {
public
LanEventProperty
getProperty
(
LanEventPropertyKey
property
)
{
public
LanEventProperty
getProperty
(
LanEventPropertyKey
property
)
{
return
eventPropertyFacade
.
find
(
getCurrentEvent
(),
property
);
return
eventPropertyFacade
.
find
(
getCurrentEvent
(),
property
);
}
}
@Override
public
long
getPropertyLong
(
LanEventPropertyKey
property
)
{
LanEventProperty
retProp
=
eventPropertyFacade
.
find
(
getCurrentEvent
(),
property
);
long
ret
=
0
;
if
(
retProp
==
null
)
{
ret
=
Long
.
parseLong
(
property
.
getDefaultvalue
());
}
else
{
ret
=
retProp
.
getLongValue
();
}
return
ret
;
}
@Override
@Override
public
String
getPropertyString
(
LanEventPropertyKey
property
)
public
String
getPropertyString
(
LanEventPropertyKey
property
)
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PermissionBean.java
View file @
3d49424
...
@@ -81,9 +81,9 @@ import fi.codecrew.moya.model.User;
...
@@ -81,9 +81,9 @@ import fi.codecrew.moya.model.User;
SpecialPermission
.
S_USER
,
SpecialPermission
.
S_USER
,
SpecialPermission
.
S_ANONYMOUS
,
SpecialPermission
.
S_ANONYMOUS
,
TerminalPermission
.
S_
CASHIER
_TERMINAL
,
TerminalPermission
.
S_
INFO
_TERMINAL
,
TerminalPermission
.
S_
CUSTOM
ER_TERMINAL
,
TerminalPermission
.
S_
US
ER_TERMINAL
,
TerminalPermission
.
S_
SELFHELP
_TERMINAL
,
TerminalPermission
.
S_
ADMIN
_TERMINAL
,
CompoPermission
.
S_MANAGE
,
CompoPermission
.
S_MANAGE
,
CompoPermission
.
S_VOTE
,
CompoPermission
.
S_VOTE
,
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
View file @
3d49424
...
@@ -151,7 +151,7 @@ public class PlaceBean implements PlaceBeanLocal {
...
@@ -151,7 +151,7 @@ public class PlaceBean implements PlaceBeanLocal {
for
(
Entry
<
Product
,
Integer
>
entry
:
mockmap
.
entrySet
())
{
for
(
Entry
<
Product
,
Integer
>
entry
:
mockmap
.
entrySet
())
{
logger
.
debug
(
"Adding to price {} of {}"
,
entry
.
getValue
(),
entry
.
getKey
().
getName
());
logger
.
debug
(
"Adding to price {} of {}"
,
entry
.
getValue
(),
entry
.
getKey
().
getName
());
if
(
entry
.
getKey
()
!=
null
)
{
if
(
entry
.
getKey
()
!=
null
)
{
total
=
total
.
add
(
productBean
.
calculateTotal
(
entry
.
getKey
(),
new
BigDecimal
(
entry
.
getValue
()),
now
));
total
=
total
.
add
(
productBean
.
calculateTotal
(
entry
.
getKey
(),
new
BigDecimal
(
entry
.
getValue
()),
now
,
user
));
}
}
}
}
return
total
;
return
total
;
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/ProductBean.java
View file @
3d49424
...
@@ -91,6 +91,7 @@ public class ProductBean implements ProductBeanLocal {
...
@@ -91,6 +91,7 @@ public class ProductBean implements ProductBeanLocal {
private
EventBeanLocal
eventbean
;
private
EventBeanLocal
eventbean
;
@EJB
@EJB
private
BillLineFacade
billLineFacade
;
private
BillLineFacade
billLineFacade
;
@EJB
@EJB
private
ProductPBean
productPBean
;
private
ProductPBean
productPBean
;
...
@@ -99,6 +100,9 @@ public class ProductBean implements ProductBeanLocal {
...
@@ -99,6 +100,9 @@ public class ProductBean implements ProductBeanLocal {
@EJB
@EJB
private
PlaceBean
placebean
;
private
PlaceBean
placebean
;
@EJB
private
DiscountBean
discountBean
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ProductBean
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ProductBean
.
class
);
...
@@ -285,12 +289,12 @@ public class ProductBean implements ProductBeanLocal {
...
@@ -285,12 +289,12 @@ public class ProductBean implements ProductBeanLocal {
}
}
@Override
@Override
public
BigDecimal
calculateTotal
(
Product
product
,
BigDecimal
quantity
,
Calendar
date
)
{
public
BigDecimal
calculateTotal
(
Product
product
,
BigDecimal
quantity
,
Calendar
date
,
EventUser
user
)
{
if
(
product
==
null
||
quantity
==
null
)
{
if
(
product
==
null
||
quantity
==
null
)
{
throw
new
RuntimeException
(
"Some parameter is null!"
);
throw
new
RuntimeException
(
"Some parameter is null!"
);
}
}
BigDecimal
total
=
product
.
getPrice
();
BigDecimal
total
=
product
.
getPrice
();
for
(
Discount
d
:
product
.
getActiveDiscounts
(
quantity
,
date
))
{
for
(
Discount
d
:
discountBean
.
getActiveDiscountsByProduct
(
product
,
quantity
,
date
,
user
))
{
total
=
total
.
multiply
(
d
.
getPercentage
());
total
=
total
.
multiply
(
d
.
getPercentage
());
}
}
return
total
.
setScale
(
2
,
RoundingMode
.
HALF_UP
).
multiply
(
quantity
);
return
total
.
setScale
(
2
,
RoundingMode
.
HALF_UP
).
multiply
(
quantity
);
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/ProductPBean.java
View file @
3d49424
...
@@ -30,6 +30,9 @@ public class ProductPBean {
...
@@ -30,6 +30,9 @@ public class ProductPBean {
@EJB
@EJB
private
PermissionBean
permbean
;
private
PermissionBean
permbean
;
@EJB
private
DiscountBean
discountBean
;
@EJB
@EJB
private
AccountEventFacade
accounteventfacade
;
private
AccountEventFacade
accounteventfacade
;
private
static
final
Logger
logger
=
LoggerFactory
private
static
final
Logger
logger
=
LoggerFactory
...
@@ -73,7 +76,7 @@ public class ProductPBean {
...
@@ -73,7 +76,7 @@ public class ProductPBean {
}
}
BigDecimal
unitPrice
=
product
.
getPrice
().
negate
();
BigDecimal
unitPrice
=
product
.
getPrice
().
negate
();
List
<
Discount
>
discounts
=
product
.
getActiveDiscounts
(
quantity
,
date
);
List
<
Discount
>
discounts
=
discountBean
.
getActiveDiscountsByProduct
(
product
,
quantity
,
date
,
user
);
for
(
Discount
d
:
discounts
)
{
for
(
Discount
d
:
discounts
)
{
unitPrice
=
unitPrice
.
multiply
(
d
.
getPercentage
());
unitPrice
=
unitPrice
.
multiply
(
d
.
getPercentage
());
}
}
...
...
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/BillBeanLocal.java
View file @
3d49424
package
fi
.
codecrew
.
moya
.
beans
;
package
fi
.
codecrew
.
moya
.
beans
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.math.BigDecimal
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
...
@@ -10,6 +11,8 @@ import javax.ejb.Local;
...
@@ -10,6 +11,8 @@ import javax.ejb.Local;
import
fi.codecrew.moya.bortal.views.BillSummary
;
import
fi.codecrew.moya.bortal.views.BillSummary
;
import
fi.codecrew.moya.model.Bill
;
import
fi.codecrew.moya.model.Bill
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.FoodWave
;
import
fi.codecrew.moya.model.Product
;
@Local
@Local
public
interface
BillBeanLocal
{
public
interface
BillBeanLocal
{
...
@@ -37,5 +40,9 @@ public interface BillBeanLocal {
...
@@ -37,5 +40,9 @@ public interface BillBeanLocal {
List
<
Bill
>
find
(
EventUser
user
);
List
<
Bill
>
find
(
EventUser
user
);
Bill
expireBill
(
Bill
bill
);
Bill
expireBill
(
Bill
bill
);
Bill
addProductToBill
(
Bill
bill
,
Product
product
,
BigDecimal
count
,
FoodWave
foodwave
);
Bill
addProductToBill
(
Bill
bill
,
Product
product
,
BigDecimal
count
);
}
}
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/DiscountBeanLocal.java
View file @
3d49424
package
fi
.
codecrew
.
moya
.
beans
;
package
fi
.
codecrew
.
moya
.
beans
;
import
java.math.BigDecimal
;
import
java.util.Calendar
;
import
java.util.List
;
import
javax.ejb.Local
;
import
javax.ejb.Local
;
import
fi.codecrew.moya.model.Discount
;
import
fi.codecrew.moya.model.Discount
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.Product
;
@Local
@Local
public
interface
DiscountBeanLocal
{
public
interface
DiscountBeanLocal
{
Discount
save
(
Discount
discount
);
Discount
save
(
Discount
discount
);
public
List
<
Discount
>
getActiveDiscountsByProduct
(
Product
product
,
BigDecimal
quantity
,
Calendar
time
,
EventUser
user
);
}
}
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/EventBeanLocal.java
View file @
3d49424
...
@@ -35,5 +35,7 @@ public interface EventBeanLocal {
...
@@ -35,5 +35,7 @@ public interface EventBeanLocal {
List
<
LanEventPrivateProperty
>
getPrivateProperties
();
List
<
LanEventPrivateProperty
>
getPrivateProperties
();
LanEventPrivateProperty
saveOrCreatePrivateProperty
(
LanEventPrivateProperty
privateProperty
);
LanEventPrivateProperty
saveOrCreatePrivateProperty
(
LanEventPrivateProperty
privateProperty
);
long
getPropertyLong
(
LanEventPropertyKey
property
);
}
}
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/ProductBeanLocal.java
View file @
3d49424
...
@@ -47,7 +47,7 @@ public interface ProductBeanLocal {
...
@@ -47,7 +47,7 @@ public interface ProductBeanLocal {
Discount
save
(
Discount
discount
);
Discount
save
(
Discount
discount
);
BigDecimal
calculateTotal
(
Product
product
,
BigDecimal
quantity
,
Calendar
date
);
BigDecimal
calculateTotal
(
Product
product
,
BigDecimal
quantity
,
Calendar
date
,
EventUser
user
);
HashMap
<
Integer
,
BigDecimal
>
getProductLimit
(
Map
<
Integer
,
BigDecimal
>
prodCounts
,
EventUser
user
);
HashMap
<
Integer
,
BigDecimal
>
getProductLimit
(
Map
<
Integer
,
BigDecimal
>
prodCounts
,
EventUser
user
);
...
...
code/MoyaDatabase/src/fi/codecrew/moya/model/Bill.java
View file @
3d49424
...
@@ -195,24 +195,35 @@ public class Bill extends GenericEntity {
...
@@ -195,24 +195,35 @@ public class Bill extends GenericEntity {
return
total
;
return
total
;
}
}
public
Bill
(
LanEvent
event
,
EventUser
user
)
{
public
Bill
(
LanEvent
event
,
EventUser
user
,
Calendar
expires
)
{
this
(
event
);
this
(
event
,
expires
);
this
.
setUser
(
user
);
this
.
setUser
(
user
);
this
.
setAddr1
(
user
.
getUser
().
getFirstnames
()
+
" "
+
user
.
getUser
().
getLastname
());
this
.
setAddr1
(
user
.
getUser
().
getFirstnames
()
+
" "
+
user
.
getUser
().
getLastname
());
this
.
setAddr2
(
user
.
getUser
().
getAddress
());
this
.
setAddr2
(
user
.
getUser
().
getAddress
());
this
.
setAddr3
(
user
.
getUser
().
getZip
()
+
" "
+
user
.
getUser
().
getTown
());
this
.
setAddr3
(
user
.
getUser
().
getZip
()
+
" "
+
user
.
getUser
().
getTown
());
}
}
public
Bill
(
LanEvent
event
)
{
public
Bill
(
LanEvent
event
,
Calendar
expires
)
{
this
();
this
();
this
.
expires
=
expires
;
this
.
event
=
event
;
this
.
event
=
event
;
}
}
public
Bill
(
LanEvent
event
,
EventUser
user
,
long
expireTimeHours
)
{
this
(
event
,
user
,
Calendar
.
getInstance
());
this
.
expires
.
setTimeInMillis
((
System
.
currentTimeMillis
()
+
(
expireTimeHours
*
60
*
60
*
1000
)));
}
public
Bill
(
LanEvent
event
,
long
expireTimeHours
)
{
this
(
event
,
Calendar
.
getInstance
());
this
.
expires
.
setTimeInMillis
((
System
.
currentTimeMillis
()
+
(
expireTimeHours
*
60
*
60
*
1000
)));
}
public
Bill
()
{
public
Bill
()
{
super
();
super
();
this
.
expires
=
Calendar
.
getInstance
();
this
.
expires
=
Calendar
.
getInstance
();
this
.
expires
.
setTimeInMillis
((
System
.
currentTimeMillis
()
+
1814400000
l
));
// 3
vk
this
.
expires
.
setTimeInMillis
((
System
.
currentTimeMillis
()
+
1209600000
));
// 2
vk
}
}
public
Calendar
getDueDate
()
{
public
Calendar
getDueDate
()
{
...
@@ -347,28 +358,6 @@ public class Bill extends GenericEntity {
...
@@ -347,28 +358,6 @@ public class Bill extends GenericEntity {
return
delayIntrest
;
return
delayIntrest
;
}
}
public
void
addProduct
(
Product
product
,
BigDecimal
count
)
{
this
.
addProduct
(
product
,
count
,
null
);
}
public
void
addProduct
(
Product
product
,
BigDecimal
count
,
FoodWave
foodwave
)
{
// If bill number > 0 bill has been sent and extra privileges are needed
// to modify.
// if (!iscurrent || billnr != null) {
// permbean.fatalPermission(BillPermission.WRITE_ALL,
// "User tried to modify bill ", bill,
// "without sufficient permissions");
// }
if
(
this
.
billLines
==
null
)
{
billLines
=
new
ArrayList
<
BillLine
>();
}
this
.
getBillLines
().
add
(
new
BillLine
(
this
,
product
,
count
,
foodwave
));
for
(
Discount
disc
:
product
.
getActiveDiscounts
(
count
,
sentDate
))
{
this
.
getBillLines
().
add
(
new
BillLine
(
this
,
product
,
disc
,
count
));
}
}
public
void
setBillNumber
(
Integer
billNumber
)
{
public
void
setBillNumber
(
Integer
billNumber
)
{
this
.
billNumber
=
billNumber
;
this
.
billNumber
=
billNumber
;
}
}
...
...
code/MoyaDatabase/src/fi/codecrew/moya/model/LanEventPropertyKey.java
View file @
3d49424
...
@@ -17,6 +17,7 @@ public enum LanEventPropertyKey {
...
@@ -17,6 +17,7 @@ public enum LanEventPropertyKey {
CHECK_BILL_STATS_PERMISSION
(
Type
.
BOOL
,
null
),
CHECK_BILL_STATS_PERMISSION
(
Type
.
BOOL
,
null
),
GATHER_OTHER_BILL_INFO
(
Type
.
BOOL
,
null
),
GATHER_OTHER_BILL_INFO
(
Type
.
BOOL
,
null
),
ALLOW_BILLING
(
Type
.
BOOL
,
null
),
ALLOW_BILLING
(
Type
.
BOOL
,
null
),
BILL_EXPIRE_HOURS
(
Type
.
LONG
,
"168"
),
TEMPLATE_PROPERTY1
(
Type
.
TEXT
,
null
),
TEMPLATE_PROPERTY1
(
Type
.
TEXT
,
null
),
TEMPLATE_PROPERTY2
(
Type
.
TEXT
,
null
),
TEMPLATE_PROPERTY2
(
Type
.
TEXT
,
null
),
TEMPLATE_PROPERTY3
(
Type
.
TEXT
,
null
),
TEMPLATE_PROPERTY3
(
Type
.
TEXT
,
null
),
...
@@ -26,7 +27,7 @@ public enum LanEventPropertyKey {
...
@@ -26,7 +27,7 @@ public enum LanEventPropertyKey {
;
;
private
enum
Type
{
private
enum
Type
{
TEXT
,
DATE
,
DATA
,
BOOL
TEXT
,
DATE
,
DATA
,
BOOL
,
LONG
};
};
private
final
String
defaultvalue
;
private
final
String
defaultvalue
;
...
@@ -47,6 +48,10 @@ public enum LanEventPropertyKey {
...
@@ -47,6 +48,10 @@ public enum LanEventPropertyKey {
public
boolean
isBoolean
()
{
public
boolean
isBoolean
()
{
return
Type
.
BOOL
.
equals
(
type
);
return
Type
.
BOOL
.
equals
(
type
);
}
}
public
boolean
isLong
()
{
return
Type
.
LONG
.
equals
(
type
);
}
private
LanEventPropertyKey
(
Type
t
,
String
def
)
private
LanEventPropertyKey
(
Type
t
,
String
def
)
{
{
...
...
code/MoyaDatabase/src/fi/codecrew/moya/model/Product.java
View file @
3d49424
...
@@ -162,21 +162,6 @@ public class Product extends GenericEntity {
...
@@ -162,21 +162,6 @@ public class Product extends GenericEntity {
return
tot
;
return
tot
;
}
}
// TODO: alennukset lasketaan täällä. HUOMHUOM!!
public
List
<
Discount
>
getActiveDiscounts
(
BigDecimal
quantity
,
Calendar
time
)
{
ArrayList
<
Discount
>
ret
=
new
ArrayList
<
Discount
>();
for
(
Discount
d
:
getDiscounts
())
{
if
(
d
.
isActive
()
&&
(
d
.
getValidTo
()
==
null
||
d
.
getValidTo
().
after
(
time
))
&&
(
d
.
getValidFrom
()
==
null
||
d
.
getValidFrom
().
before
(
time
))
&&
quantity
.
compareTo
(
d
.
getAmountMax
())
<=
0
&&
quantity
.
compareTo
(
d
.
getAmountMin
())
>=
0
)
{
ret
.
add
(
d
);
}
}
return
ret
;
}
public
BigDecimal
getInventoryCount
()
{
public
BigDecimal
getInventoryCount
()
{
BigDecimal
ret
=
new
BigDecimal
(
0
);
BigDecimal
ret
=
new
BigDecimal
(
0
);
...
...
code/MoyaEar/.settings/org.eclipse.wst.common.component
View file @
3d49424
...
@@ -74,5 +74,8 @@
...
@@ -74,5 +74,8 @@
<dependent-module
archiveName=
"commons-logging-1.1.1.jar"
deploy-path=
"/lib"
handle=
"module:/classpath/var/M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"
>
<dependent-module
archiveName=
"commons-logging-1.1.1.jar"
deploy-path=
"/lib"
handle=
"module:/classpath/var/M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"
>
<dependency-type>
uses
</dependency-type>
<dependency-type>
uses
</dependency-type>
</dependent-module>
</dependent-module>
<dependent-module
archiveName=
"moya-terminal-web-0.2.0.war"
deploy-path=
"/"
handle=
"module:/resource/MoyaTerminalWeb/MoyaTerminalWeb"
>
<dependency-type>
uses
</dependency-type>
</dependent-module>
</wb-module>
</wb-module>
</project-modules>
</project-modules>
code/MoyaEar/EarContent/META-INF/application.xml
View file @
3d49424
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<application
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
<application
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation=
"http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd"
version=
"7"
>
xmlns=
"http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation=
"http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd"
version=
"7"
>
<display-name>
moya-ear
</display-name>
<display-name>
moya-ear
</display-name>
<module>
<module>
<ejb>
moya-beans-0.2.0.jar
</ejb>
<ejb>
moya-beans-0.2.0.jar
</ejb>
...
@@ -19,5 +16,13 @@
...
@@ -19,5 +16,13 @@
<context-root>
/EventMgmt
</context-root>
<context-root>
/EventMgmt
</context-root>
</web>
</web>
</module>
</module>
<module>
<web>
<web-uri>
moya-terminal-web-0.2.0.war
</web-uri>
<context-root>
/MoyaTerminalWeb
</context-root>
</web>
</module>
<library-directory>
lib
</library-directory>
<library-directory>
lib
</library-directory>
</application>
</application>
\ No newline at end of file
code/MoyaEar/pom.xml
View file @
3d49424
...
@@ -97,6 +97,12 @@
...
@@ -97,6 +97,12 @@
<artifactId>
commons-digester
</artifactId>
<artifactId>
commons-digester
</artifactId>
<version>
2.1
</version>
<version>
2.1
</version>
</dependency>
</dependency>
<dependency>
<groupId>
fi.codecrew.moya
</groupId>
<artifactId>
moya-terminal-web
</artifactId>
<version>
0.2.0
</version>
<type>
war
</type>
</dependency>
</dependencies>
</dependencies>
<repositories>
<repositories>
...
...
code/MoyaEventMgmtWeb/.settings/org.eclipse.wst.common.component
View file @
3d49424
...
@@ -5,6 +5,6 @@
...
@@ -5,6 +5,6 @@
<wb-resource
deploy-path=
"/WEB-INF/classes"
source-path=
"/src"
/>
<wb-resource
deploy-path=
"/WEB-INF/classes"
source-path=
"/src"
/>
<property
name=
"java-output-path"
value=
"/MoyaEventMgmtWeb/build/classes"
/>
<property
name=
"java-output-path"
value=
"/MoyaEventMgmtWeb/build/classes"
/>
<property
name=
"context-root"
value=
"moya-mgmt-web"
/>
<property
name=
"context-root"
value=
"moya-mgmt-web"
/>
<property
name=
"component.inclusion.patterns"
value=
"WEB-INF/lib/javamelody-core*,WEB-INF/lib/primefaces*,**/*.xml,**/*.xhtml,**/*.properties,**/*.class,**/*.png,**/*.css,**/*.js,resources/*"
/>
<property
name=
"component.inclusion.patterns"
value=
"WEB-INF/lib/
prettyfaces-core*,WEB-INF/lib/
javamelody-core*,WEB-INF/lib/primefaces*,**/*.xml,**/*.xhtml,**/*.properties,**/*.class,**/*.png,**/*.css,**/*.js,resources/*"
/>
</wb-module>
</wb-module>
</project-modules>
</project-modules>
code/MoyaTerminalWeb/WebContent/WEB-INF/web.xml
View file @
3d49424
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://java.sun.com/xml/ns/javaee"
xmlns:web=
"http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id=
"WebApp_ID"
version=
"3.0"
>
<web-app
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://java.sun.com/xml/ns/javaee"
xmlns:web=
"http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id=
"WebApp_ID"
version=
"3.0"
>
<display-name>
MoyaTerminalWeb
</display-name>
<display-name>
MoyaTerminalWeb
</display-name>
<context-param>
<param-name>
javax.faces.FACELETS_SKIP_COMMENTS
</param-name>
<param-value>
true
</param-value>
</context-param>
<welcome-file-list>
<welcome-file-list>
<welcome-file>
index.html
</welcome-file>
<welcome-file>
index.html
</welcome-file>
<welcome-file>
index.
wt
f
</welcome-file>
<welcome-file>
index.
js
f
</welcome-file>
</welcome-file-list>
</welcome-file-list>
<session-config>
<session-config>
<session-timeout>
30
</session-timeout>
<session-timeout>
30
</session-timeout>
</session-config>
</session-config>
...
@@ -13,11 +19,12 @@
...
@@ -13,11 +19,12 @@
<servlet-class>
javax.faces.webapp.FacesServlet
</servlet-class>
<servlet-class>
javax.faces.webapp.FacesServlet
</servlet-class>
<load-on-startup>
1
</load-on-startup>
<load-on-startup>
1
</load-on-startup>
</servlet>
</servlet>
<servlet-mapping>
<servlet-mapping>
<servlet-name>
Faces Servlet
</servlet-name>
<servlet-name>
Faces Servlet
</servlet-name>
<url-pattern>
*.wtf
</url-pattern>
<url-pattern>
*.jsf
</url-pattern>
<url-pattern>
/faces/*
</url-pattern>
</servlet-mapping>
</servlet-mapping>
<context-param>
<context-param>
<param-name>
javax.faces.PROJECT_STAGE
</param-name>
<param-name>
javax.faces.PROJECT_STAGE
</param-name>
<param-value>
Development
</param-value>
<param-value>
Development
</param-value>
...
@@ -26,25 +33,63 @@
...
@@ -26,25 +33,63 @@
<param-name>
javax.faces.FACELETS_SKIP_COMMENTS
</param-name>
<param-name>
javax.faces.FACELETS_SKIP_COMMENTS
</param-name>
<param-value>
true
</param-value>
<param-value>
true
</param-value>
</context-param>
</context-param>
<filter>
<display-name>
PrimefacesFileupload
</display-name>
<!--
<filter-name>
PrimeFacesFileupload
</filter-name>
<filter>
<filter-class>
org.primefaces.webapp.filter.FileUploadFilter
</filter-class>
<display-name>PrimefacesFileupload</display-name>
</filter>
<filter-name>PrimefacesFileupload</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-mapping>
<filter-name>
Prime
F
acesFileupload
</filter-name>
<filter-name>Prime
f
acesFileupload</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
</filter-mapping>
-->
<login-config>
<login-config>
<auth-method>
CLIENT-CERT
</auth-method>
<auth-method>
CLIENT-CERT
</auth-method>
<realm-name>
certificate
</realm-name>
<realm-name>
certificate
</realm-name>
</login-config>
</login-config>
<security-constraint>
<display-name>
Forbidden resource
</display-name>
<web-resource-collection>
<web-resource-name>
Forbidden
</web-resource-name>
<url-pattern>
*.xhtml
</url-pattern>
<url-pattern>
/layout/*
</url-pattern>
<url-pattern>
/resources/tools/*
</url-pattern>
</web-resource-collection>
<auth-constraint>
<description>
Thou shall not read the sources or use utils directly
</description>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>
CONFIDENTIAL
</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<display-name>
Resource that needs cert auth
</display-name>
<web-resource-collection>
<web-resource-name>
Forbidden
</web-resource-name>
<url-pattern>
/info/*
</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>
TERMINAL/INFO
</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>
CONFIDENTIAL
</transport-guarantee>
</user-data-constraint>
</security-constraint>
<!--
<security-constraint>
<security-constraint>
<display-name>Resource that needs cert auth</display-name>
<display-name>Resource that needs cert auth</display-name>
<web-resource-collection>
<web-resource-collection>
<web-resource-name>BortalTerminalWebResource</web-resource-name>
<web-resource-name>BortalTerminalWebResource</web-resource-name>
<url-pattern>/faces/*</url-pattern>
<url-pattern>/faces/*</url-pattern>
<url-pattern>
*.
wt
f
</url-pattern>
<url-pattern>*.
js
f</url-pattern>
</web-resource-collection>
</web-resource-collection>
<auth-constraint>
<auth-constraint>
<role-name>TERMINAL</role-name>
<role-name>TERMINAL</role-name>
...
@@ -52,7 +97,9 @@
...
@@ -52,7 +97,9 @@
<user-data-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</user-data-constraint>
</security-constraint>
</security-constraint> -->
<persistence-unit-ref>
<persistence-unit-ref>
<persistence-unit-ref-name>
BortalEMF
</persistence-unit-ref-name>
<persistence-unit-ref-name>
BortalEMF
</persistence-unit-ref-name>
</persistence-unit-ref>
</persistence-unit-ref>
...
...
code/MoyaTerminalWeb/pom.xml
View file @
3d49424
...
@@ -39,5 +39,15 @@
...
@@ -39,5 +39,15 @@
<artifactId>
moya-beans-client
</artifactId>
<artifactId>
moya-beans-client
</artifactId>
<version>
0.2.0
</version>
<version>
0.2.0
</version>
</dependency>
</dependency>
<dependency>
<groupId>
commons-fileupload
</groupId>
<artifactId>
commons-fileupload
</artifactId>
<version>
1.3
</version>
</dependency>
<dependency>
<groupId>
org.primefaces
</groupId>
<artifactId>
primefaces
</artifactId>
<version>
4.0
</version>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
code/MoyaTerminalWeb/src/fi/codecrew/moya/terminal/handler/SessionHandler.java
View file @
3d49424
...
@@ -17,7 +17,7 @@ import fi.codecrew.moya.clientutils.BortalLocalContextHolder;
...
@@ -17,7 +17,7 @@ import fi.codecrew.moya.clientutils.BortalLocalContextHolder;
import
fi.codecrew.moya.enums.apps.IAppPermission
;
import
fi.codecrew.moya.enums.apps.IAppPermission
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.EventUser
;
@Named
()
@Named
(
value
=
"terminalSessionHandler"
)
@RequestScoped
@RequestScoped
public
class
SessionHandler
{
public
class
SessionHandler
{
...
...
code/MoyaTerminalWeb/src/fi/codecrew/moya/terminal/view/RedirectView.java
View file @
3d49424
package
fi
.
codecrew
.
moya
.
terminal
.
view
;
package
fi
.
codecrew
.
moya
.
terminal
.
view
;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.context.FacesContext
;
import
javax.faces.context.FacesContext
;
import
javax.inject.Named
;
import
javax.inject.Named
;
...
@@ -8,10 +9,11 @@ import fi.codecrew.moya.beans.PermissionBeanLocal;
...
@@ -8,10 +9,11 @@ import fi.codecrew.moya.beans.PermissionBeanLocal;
import
fi.codecrew.moya.enums.apps.TerminalPermission
;
import
fi.codecrew.moya.enums.apps.TerminalPermission
;
@Named
@Named
@RequestScoped
public
class
RedirectView
{
public
class
RedirectView
{
@EJB
@EJB
PermissionBeanLocal
permissionBean
;
private
PermissionBeanLocal
permissionBean
;
public
void
redirectByPermissions
()
throws
Exception
{
public
void
redirectByPermissions
()
throws
Exception
{
FacesContext
fcont
=
FacesContext
.
getCurrentInstance
();
FacesContext
fcont
=
FacesContext
.
getCurrentInstance
();
...
@@ -27,4 +29,4 @@ public class RedirectView {
...
@@ -27,4 +29,4 @@ public class RedirectView {
}
}
}
}
}
}
code/MoyaTerminalWeb/src/fi/codecrew/moya/terminal/view/TestView.java
deleted
100644 → 0
View file @
24f62b4
package
fi
.
codecrew
.
moya
.
terminal
.
view
;
import
java.io.Serializable
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.inject.Named
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
@Named
@RequestScoped
public
class
TestView
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
2872232867536069020L
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
TestView
.
class
);
@EJB
private
transient
PermissionBeanLocal
permissionBean
;
public
String
getPrincipal
()
{
logger
.
debug
(
"PermissionBean: {}"
,
permissionBean
);
return
permissionBean
.
getPrincipal
();
}
}
code/MoyaUtilities/src/main/java/fi/codecrew/moya/enums/apps/TerminalPermission.java
View file @
3d49424
...
@@ -11,16 +11,16 @@ import fi.codecrew.moya.enums.BortalApplication;
...
@@ -11,16 +11,16 @@ import fi.codecrew.moya.enums.BortalApplication;
*/
*/
public
enum
TerminalPermission
implements
IAppPermission
{
public
enum
TerminalPermission
implements
IAppPermission
{
CASHIER
,
// ("Access cashier terminal functions")
,
INFO
,
CUSTOMER
,
// ("Access client terminal functions"),
USER
,
SELFHELP
,
// ("Self help terminal")
ADMIN
,
;
;
// public static final String S_TERMINAL = "TERMINAL";
// public static final String S_TERMINAL = "TERMINAL";
public
static
final
String
S_
CASHIER_TERMINAL
=
"TERMINAL/CASHIER
"
;
public
static
final
String
S_
INFO_TERMINAL
=
"TERMINAL/INFO
"
;
public
static
final
String
S_
CUSTOMER_TERMINAL
=
"TERMINAL/CUSTOM
ER"
;
public
static
final
String
S_
USER_TERMINAL
=
"TERMINAL/US
ER"
;
public
static
final
String
S_
SELFHELP_TERMINAL
=
"TERMINAL/SELFHELP
"
;
public
static
final
String
S_
ADMIN_TERMINAL
=
"TERMINAL/ADMIN
"
;
private
final
String
fullName
;
private
final
String
fullName
;
private
final
String
key
;
private
final
String
key
;
...
...
code/MoyaWeb/.classpath
View file @
3d49424
...
@@ -22,6 +22,5 @@
...
@@ -22,6 +22,5 @@
<attribute
name=
"owner.project.facets"
value=
"jst.web"
/>
<attribute
name=
"owner.project.facets"
value=
"jst.web"
/>
</attributes>
</attributes>
</classpathentry>
</classpathentry>
<classpathentry
kind=
"con"
path=
"org.eclipse.jst.j2ee.internal.web.container"
/>
<classpathentry
kind=
"output"
path=
"target/classes"
/>
<classpathentry
kind=
"output"
path=
"target/classes"
/>
</classpath>
</classpath>
code/MoyaWeb/WebContent/eventorg/editEvent.xhtml
View file @
3d49424
...
@@ -80,6 +80,7 @@
...
@@ -80,6 +80,7 @@
<h:outputText
rendered=
"#{prop.key.text}"
value=
"#{prop.textvalue}"
/>
<h:outputText
rendered=
"#{prop.key.text}"
value=
"#{prop.textvalue}"
/>
<h:outputText
rendered=
"#{prop.key.boolean and prop.booleanValue}"
value=
"true"
/>
<h:outputText
rendered=
"#{prop.key.boolean and prop.booleanValue}"
value=
"true"
/>
<h:outputText
rendered=
"#{prop.key.boolean and ( not prop.booleanValue)}"
value=
"false"
/>
<h:outputText
rendered=
"#{prop.key.boolean and ( not prop.booleanValue)}"
value=
"false"
/>
<h:outputText
rendered=
"#{prop.key.long}"
value=
"#{prop.longValue}"
/>
<h:outputText
rendered=
"#{prop.key.date}"
value=
"#{prop.dateValue}"
>
<h:outputText
rendered=
"#{prop.key.date}"
value=
"#{prop.dateValue}"
>
<f:convertDateTime
pattern=
"#{sessionHandler.datetimeFormat}"
timeZone=
"#{sessionHandler.timezone}"
/>
<f:convertDateTime
pattern=
"#{sessionHandler.datetimeFormat}"
timeZone=
"#{sessionHandler.timezone}"
/>
</h:outputText>
</h:outputText>
...
@@ -130,6 +131,12 @@
...
@@ -130,6 +131,12 @@
<h:outputLabel
rendered=
"#{eventPropertyView.property.key.boolean}"
for=
"booleanval"
value=
"#{i18n['lanEventProperty.booleanValue']}"
/>
<h:outputLabel
rendered=
"#{eventPropertyView.property.key.boolean}"
for=
"booleanval"
value=
"#{i18n['lanEventProperty.booleanValue']}"
/>
<h:selectBooleanCheckbox
rendered=
"#{eventPropertyView.property.key.boolean}"
id=
"booleanval"
value=
"#{eventPropertyView.property.booleanValue}"
/>
<h:selectBooleanCheckbox
rendered=
"#{eventPropertyView.property.key.boolean}"
id=
"booleanval"
value=
"#{eventPropertyView.property.booleanValue}"
/>
<h:message
rendered=
"#{eventPropertyView.property.key.boolean}"
for=
"booleanval"
/>
<h:message
rendered=
"#{eventPropertyView.property.key.boolean}"
for=
"booleanval"
/>
<h:outputLabel
rendered=
"#{eventPropertyView.property.key.long}"
for=
"longval"
value=
"#{i18n['lanEventProperty.longValue']}"
/>
<h:inputText
rendered=
"#{eventPropertyView.property.key.long}"
id=
"longval"
value=
"#{eventPropertyView.property.longValue}"
>
<f:convertNumber
type=
"number"
/>
</h:inputText>
<h:message
rendered=
"#{eventPropertyView.property.key.long}"
for=
"longval"
/>
</h:panelGrid>
</h:panelGrid>
<h:commandButton
action=
"#{eventPropertyView.saveProperty}"
value=
"#{i18n['lanEventProperty.save']}"
/>
<h:commandButton
action=
"#{eventPropertyView.saveProperty}"
value=
"#{i18n['lanEventProperty.save']}"
/>
...
...
code/MoyaWeb/WebContent/resources/cditools/products/manageDiscount.xhtml
View file @
3d49424
...
@@ -31,6 +31,12 @@
...
@@ -31,6 +31,12 @@
<h:inputText
id=
"code"
value=
"#{productView.discount.code}"
/>
<h:inputText
id=
"code"
value=
"#{productView.discount.code}"
/>
<h:message
for=
"code"
/>
<h:message
for=
"code"
/>
<h:outputLabel
for=
"role"
value=
"#{i18n['discount.role']}:"
/>
<h:selectOneMenu
id=
"role"
value=
"#{productView.discount.role}"
converter=
"#{roleConverter}"
>
<f:selectItems
var=
"role"
itemLabel=
"#{role.name}"
value=
"#{roleDataView.rolesWithEmpty}"
/>
</h:selectOneMenu>
<h:message
for=
"role"
/>
<h:outputLabel
for=
"amountMin"
value=
"#{i18n['discount.amountMin']}:"
/>
<h:outputLabel
for=
"amountMin"
value=
"#{i18n['discount.amountMin']}:"
/>
<h:inputText
id=
"amountMin"
value=
"#{productView.discount.amountMin}"
required=
"true"
/>
<h:inputText
id=
"amountMin"
value=
"#{productView.discount.amountMin}"
required=
"true"
/>
<h:message
for=
"amountMin"
/>
<h:message
for=
"amountMin"
/>
...
@@ -54,6 +60,8 @@
...
@@ -54,6 +60,8 @@
<h:outputLabel
for=
"active"
value=
"#{i18n['discount.active']}"
/>
<h:outputLabel
for=
"active"
value=
"#{i18n['discount.active']}"
/>
<h:selectBooleanCheckbox
id=
"active"
value=
"#{productView.discount.active}"
/>
<h:selectBooleanCheckbox
id=
"active"
value=
"#{productView.discount.active}"
/>
<h:message
for=
"active"
/>
<h:message
for=
"active"
/>
</h:panelGrid>
</h:panelGrid>
...
...
code/MoyaWeb/WebContent/resources/cditools/products/shop.xhtml
View file @
3d49424
...
@@ -40,10 +40,9 @@
...
@@ -40,10 +40,9 @@
<h:commandButton
action=
"#{productShopView.addMinusOne}"
value=
"#{i18n['productshop.minusOne']}"
>
<h:commandButton
action=
"#{productShopView.addMinusOne}"
value=
"#{i18n['productshop.minusOne']}"
>
<f:ajax
render=
"@form"
/>
<f:ajax
render=
"@form"
/>
</h:commandButton>
</h:commandButton>
<h:
inputText
size=
"4"
id=
"cartcount"
value=
"#{cart.count}
"
>
<h:
outputText
id=
"cartcount"
escape=
"false"
value=
" #{cart.count}
"
>
<f:convertNumber
maxIntegerDigits=
"2"
minFractionDigits=
"0"
/>
<f:convertNumber
maxIntegerDigits=
"2"
minFractionDigits=
"0"
/>
<f:ajax
render=
"@form"
event=
"valueChange"
listener=
"#{productShopView.updateAllCartLimits()}"
/>
</h:outputText>
</h:inputText>
<h:commandButton
action=
"#{productShopView.addOne}"
value=
"#{i18n['productshop.plusOne']}"
>
<h:commandButton
action=
"#{productShopView.addOne}"
value=
"#{i18n['productshop.plusOne']}"
>
<f:ajax
render=
"@form"
/>
<f:ajax
render=
"@form"
/>
</h:commandButton>
</h:commandButton>
...
...
code/MoyaWeb/WebContent/resources/cditools/shop/shoppingcart.xhtml
View file @
3d49424
...
@@ -45,10 +45,9 @@
...
@@ -45,10 +45,9 @@
<h:outputText
value=
"#{i18n['shop.count']}"
/>
<h:outputText
value=
"#{i18n['shop.count']}"
/>
</f:facet>
</f:facet>
<p:inplace>
<p:inplace>
<p:inputText
value=
"#{prods.count}"
size=
"4"
>
<h:outputText
value=
"#{prods.count}"
size=
"4"
>
<f:ajax
event=
"valueChange"
render=
"@form"
/>
<f:convertNumber
minFractionDigits=
"0"
maxFractionDigits=
"2"
/>
<f:convertNumber
minFractionDigits=
"0"
maxFractionDigits=
"2"
/>
</
p:in
putText>
</
h:out
putText>
</p:inplace>
</p:inplace>
</p:column>
</p:column>
...
...
code/MoyaWeb/WebContent/resources/templates/template1/css/style.css
View file @
3d49424
...
@@ -148,6 +148,9 @@ h1 {
...
@@ -148,6 +148,9 @@ h1 {
width
:
200px
;
width
:
200px
;
}
}
nav
{
nav
{
min-width
:
200px
;
min-width
:
200px
;
background
:
white
;
background
:
white
;
...
@@ -193,3 +196,13 @@ aside {
...
@@ -193,3 +196,13 @@ aside {
th
,
td
{
th
,
td
{
padding
:
5px
;
padding
:
5px
;
}
}
#header_center
{
position
:
relative
;
text-align
:
right
;
}
#selectLanguage
{
padding-left
:
10px
;
padding-top
:
10px
;
}
code/MoyaWeb/WebContent/resources/templates/template1/template.xhtml
View file @
3d49424
...
@@ -79,21 +79,15 @@
...
@@ -79,21 +79,15 @@
</h:link>
</h:link>
</div>
</div>
<div
id=
"header_center"
class=
"flex1"
>
<div
id=
"header_center"
class=
"flex1"
>
<div>
<h:form
id=
"selectLanguage"
>
<p:selectOneButton
id=
"langselect"
styleClass=
"languageSelector"
value=
"#{sessionStore.locale}"
onchange=
"this.form.submit()"
converter=
"#{localeConverter}"
>
<f:selectItems
value=
"#{localeSelectorView.availableLocales}"
var=
"loc"
itemValue=
"#{loc.locale}"
itemLabel=
"#{loc.locale.displayName}"
/>
</p:selectOneButton>
</h:form>
</div>
<ui:fragment
rendered=
"#{layoutView.canManageContent}"
>
<ui:fragment
rendered=
"#{layoutView.canManageContent}"
>
<div>
<div>
<h:form>
<h:form>
<h:outputLabel
for=
"manageBtn"
value=
"#{i18n['content.showContentEditLinks']}"
/>
<h:outputLabel
for=
"manageBtn"
value=
"#{i18n['content.showContentEditLinks']}"
/>
<h:selectBooleanCheckbox
value=
"#{sessionStore.manageContentLinks}"
onclick=
"this.form.submit()"
/>
<h:selectBooleanCheckbox
value=
"#{sessionStore.manageContentLinks}"
onclick=
"this.form.submit()"
/>
</h:form>
</h:form>
</div>
</div>
</ui:fragment>
</ui:fragment>
</div>
</div>
<div
id=
"header_right"
>
<div
id=
"header_right"
>
...
@@ -115,6 +109,14 @@
...
@@ -115,6 +109,14 @@
</nav>
</nav>
<section
id=
"main"
class=
"flex2"
>
<section
id=
"main"
class=
"flex2"
>
<div
class=
"container top"
>
<div
class=
"container top"
>
<h:form
id=
"selectLanguage"
>
<p:selectOneButton
id=
"langselect"
styleClass=
"languageSelector"
value=
"#{sessionStore.locale}"
onchange=
"this.form.submit()"
converter=
"#{localeConverter}"
>
<f:selectItems
value=
"#{localeSelectorView.availableLocales}"
var=
"loc"
itemValue=
"#{loc.locale}"
itemLabel=
"#{loc.locale.displayName}"
/>
</p:selectOneButton>
</h:form>
<h:link
rendered=
"#{layoutView.manageContent}"
styleClass=
"editorlink"
value=
"#{i18n['layout.editTop']}"
outcome=
"/pages/manage"
>
<h:link
rendered=
"#{layoutView.manageContent}"
styleClass=
"editorlink"
value=
"#{i18n['layout.editTop']}"
outcome=
"/pages/manage"
>
<f:param
name=
"pagename"
value=
"#{layoutView.pagepath}:top"
/>
<f:param
name=
"pagename"
value=
"#{layoutView.pagepath}:top"
/>
</h:link>
</h:link>
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/shop/FoodWaveFoodView.java
View file @
3d49424
...
@@ -20,9 +20,11 @@ import fi.codecrew.moya.beans.ProductBeanLocal;
...
@@ -20,9 +20,11 @@ import fi.codecrew.moya.beans.ProductBeanLocal;
import
fi.codecrew.moya.enums.apps.ShopPermission
;
import
fi.codecrew.moya.enums.apps.ShopPermission
;
import
fi.codecrew.moya.model.Bill
;
import
fi.codecrew.moya.model.Bill
;
import
fi.codecrew.moya.model.FoodWave
;
import
fi.codecrew.moya.model.FoodWave
;
import
fi.codecrew.moya.model.LanEventPropertyKey
;
import
fi.codecrew.moya.model.Product
;
import
fi.codecrew.moya.model.Product
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
import
fi.codecrew.moya.web.cdiview.user.UserView
;
import
fi.codecrew.moya.web.cdiview.user.UserView
;
import
fi.codecrew.moya.web.helper.ProductShopItemHelper
;
import
fi.codecrew.moya.web.helpers.ProductShopItem
;
import
fi.codecrew.moya.web.helpers.ProductShopItem
;
@Named
@Named
...
@@ -36,6 +38,9 @@ public class FoodWaveFoodView extends GenericCDIView {
...
@@ -36,6 +38,9 @@ public class FoodWaveFoodView extends GenericCDIView {
@EJB
@EJB
private
FoodWaveBeanLocal
foodWaveBean
;
private
FoodWaveBeanLocal
foodWaveBean
;
@Inject
private
ProductShopItemHelper
psiHelper
;
@EJB
@EJB
EventBeanLocal
eventBean
;
EventBeanLocal
eventBean
;
...
@@ -66,7 +71,7 @@ public class FoodWaveFoodView extends GenericCDIView {
...
@@ -66,7 +71,7 @@ public class FoodWaveFoodView extends GenericCDIView {
foodWave
=
foodWaveBean
.
findFoodwave
(
getFoodwaveid
());
foodWave
=
foodWaveBean
.
findFoodwave
(
getFoodwaveid
());
logger
.
debug
(
"Foodwave {}"
,
foodWave
);
logger
.
debug
(
"Foodwave {}"
,
foodWave
);
shoppingcart
=
new
ListDataModel
<
ProductShopItem
>(
ProductShopItem
.
productGTList
(
foodWave
.
getTemplate
().
getProducts
()));
shoppingcart
=
new
ListDataModel
<
ProductShopItem
>(
ProductShopItem
.
productGTList
(
foodWave
.
getTemplate
().
getProducts
()
,
userview
.
getUser
()
));
this
.
beginConversation
();
this
.
beginConversation
();
}
}
...
@@ -99,7 +104,8 @@ public class FoodWaveFoodView extends GenericCDIView {
...
@@ -99,7 +104,8 @@ public class FoodWaveFoodView extends GenericCDIView {
public
String
add
(
Integer
count
)
{
public
String
add
(
Integer
count
)
{
ProductShopItem
item
=
getShoppingcart
().
getRowData
();
ProductShopItem
item
=
getShoppingcart
().
getRowData
();
item
.
setCount
(
item
.
getCount
().
add
(
BigDecimal
.
valueOf
(
count
)));
psiHelper
.
setProductShopItemCount
(
item
,
item
.
getCount
().
add
(
BigDecimal
.
valueOf
(
count
)));
System
.
out
.
println
(
"foobar"
+
item
.
getCount
());
System
.
out
.
println
(
"foobar"
+
item
.
getCount
());
return
null
;
return
null
;
}
}
...
@@ -128,12 +134,12 @@ public class FoodWaveFoodView extends GenericCDIView {
...
@@ -128,12 +134,12 @@ public class FoodWaveFoodView extends GenericCDIView {
* @return
* @return
*/
*/
public
Bill
createBillFromShoppingcart
()
{
public
Bill
createBillFromShoppingcart
()
{
Bill
bill
=
new
Bill
(
eventBean
.
getCurrentEvent
(),
userview
.
getSelectedUser
());
Bill
bill
=
new
Bill
(
eventBean
.
getCurrentEvent
(),
userview
.
getSelectedUser
()
,
eventBean
.
getPropertyLong
(
LanEventPropertyKey
.
BILL_EXPIRE_HOURS
)
);
bill
.
setOurReference
(
eventBean
.
getCurrentEvent
().
getName
());
bill
.
setOurReference
(
eventBean
.
getCurrentEvent
().
getName
());
for
(
ProductShopItem
shopitem
:
shoppingcart
)
{
for
(
ProductShopItem
shopitem
:
shoppingcart
)
{
if
(
shopitem
.
getCount
().
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
if
(
shopitem
.
getCount
().
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
bill
.
addProduct
(
shopitem
.
getProduct
(),
shopitem
.
getCount
(),
getFoodWave
());
bill
Bean
.
addProductToBill
(
bill
,
shopitem
.
getProduct
(),
shopitem
.
getCount
(),
getFoodWave
());
}
}
}
}
logger
.
warn
(
"Committing shoppingcart for user {}. Cart prize: {}"
,
userview
.
getSelectedUser
().
getWholeName
(),
bill
.
getTotalPrice
());
logger
.
warn
(
"Committing shoppingcart for user {}. Cart prize: {}"
,
userview
.
getSelectedUser
().
getWholeName
(),
bill
.
getTotalPrice
());
...
@@ -198,4 +204,12 @@ public class FoodWaveFoodView extends GenericCDIView {
...
@@ -198,4 +204,12 @@ public class FoodWaveFoodView extends GenericCDIView {
this
.
billEditView
=
billEditView
;
this
.
billEditView
=
billEditView
;
}
}
public
ProductShopItemHelper
getPsiHelper
()
{
return
psiHelper
;
}
public
void
setPsiHelper
(
ProductShopItemHelper
psiHelper
)
{
this
.
psiHelper
=
psiHelper
;
}
}
}
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/shop/ProductShopView.java
View file @
3d49424
...
@@ -31,6 +31,7 @@ import fi.codecrew.moya.web.annotations.SelectedUser;
...
@@ -31,6 +31,7 @@ import fi.codecrew.moya.web.annotations.SelectedUser;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
import
fi.codecrew.moya.web.cdiview.reader.ReaderView
;
import
fi.codecrew.moya.web.cdiview.reader.ReaderView
;
import
fi.codecrew.moya.web.cdiview.user.UserView
;
import
fi.codecrew.moya.web.cdiview.user.UserView
;
import
fi.codecrew.moya.web.helper.ProductShopItemHelper
;
import
fi.codecrew.moya.web.helpers.ProductShopItem
;
import
fi.codecrew.moya.web.helpers.ProductShopItem
;
@Named
@Named
...
@@ -53,6 +54,8 @@ public class ProductShopView extends GenericCDIView {
...
@@ -53,6 +54,8 @@ public class ProductShopView extends GenericCDIView {
@EJB
@EJB
private
transient
EventBeanLocal
eventbean
;
private
transient
EventBeanLocal
eventbean
;
public
void
cashChanged
()
public
void
cashChanged
()
{
{
payInstant
=
false
;
payInstant
=
false
;
...
@@ -78,6 +81,18 @@ public class ProductShopView extends GenericCDIView {
...
@@ -78,6 +81,18 @@ public class ProductShopView extends GenericCDIView {
@Inject
@Inject
private
BillEditView
billEditView
;
private
BillEditView
billEditView
;
@Inject
private
ProductShopItemHelper
psiHelper
;
public
ProductShopItemHelper
getPsiHelper
()
{
return
psiHelper
;
}
public
void
setPsiHelper
(
ProductShopItemHelper
psiHelper
)
{
this
.
psiHelper
=
psiHelper
;
}
private
boolean
hasLimits
=
false
;
private
boolean
hasLimits
=
false
;
private
boolean
blip
=
false
;
private
boolean
blip
=
false
;
private
ListDataModel
<
ProductShopItem
>
boughtItems
;
private
ListDataModel
<
ProductShopItem
>
boughtItems
;
...
@@ -94,7 +109,7 @@ public class ProductShopView extends GenericCDIView {
...
@@ -94,7 +109,7 @@ public class ProductShopView extends GenericCDIView {
public
void
initBillView
()
{
public
void
initBillView
()
{
if
(
requirePermissions
(
ShopPermission
.
LIST_USERPRODUCTS
)
if
(
requirePermissions
(
ShopPermission
.
LIST_USERPRODUCTS
)
&&
shoppingcart
==
null
)
{
&&
shoppingcart
==
null
)
{
shoppingcart
=
new
ListDataModel
<
ProductShopItem
>(
ProductShopItem
.
productList
(
productBean
.
listUserShoppableProducts
()));
shoppingcart
=
new
ListDataModel
<
ProductShopItem
>(
ProductShopItem
.
productList
(
productBean
.
listUserShoppableProducts
()
,
user
));
updateCartLimits
(
null
);
updateCartLimits
(
null
);
logger
.
debug
(
"Initialized billing shoppingcart to {}"
,
shoppingcart
);
logger
.
debug
(
"Initialized billing shoppingcart to {}"
,
shoppingcart
);
this
.
beginConversation
();
this
.
beginConversation
();
...
@@ -137,7 +152,7 @@ public class ProductShopView extends GenericCDIView {
...
@@ -137,7 +152,7 @@ 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
==
null
)
{
shoppingcart
=
new
ListDataModel
<
ProductShopItem
>(
ProductShopItem
.
productGTList
(
productBean
.
findForStaffshop
()));
shoppingcart
=
new
ListDataModel
<
ProductShopItem
>(
ProductShopItem
.
productGTList
(
productBean
.
findForStaffshop
()
,
user
));
updateCartLimits
(
null
);
updateCartLimits
(
null
);
LanEventProperty
cashdefault
=
eventbean
.
getProperty
(
LanEventPropertyKey
.
SHOP_DEFAULT_CASH
);
LanEventProperty
cashdefault
=
eventbean
.
getProperty
(
LanEventPropertyKey
.
SHOP_DEFAULT_CASH
);
...
@@ -151,7 +166,8 @@ public class ProductShopView extends GenericCDIView {
...
@@ -151,7 +166,8 @@ public class ProductShopView extends GenericCDIView {
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
)));
psiHelper
.
setProductShopItemCount
(
item
,
item
.
getCount
().
add
(
BigDecimal
.
valueOf
(
count
)));
updateCartLimits
(
item
);
updateCartLimits
(
item
);
return
null
;
return
null
;
...
@@ -196,7 +212,7 @@ public class ProductShopView extends GenericCDIView {
...
@@ -196,7 +212,7 @@ public class ProductShopView extends GenericCDIView {
// Update the updated cart first
// Update the updated cart first
if
(
item
!=
null
)
{
if
(
item
!=
null
)
{
BigDecimal
l
=
limits
.
get
(
item
.
getProduct
().
getId
());
BigDecimal
l
=
limits
.
get
(
item
.
getProduct
().
getId
());
if
(
item
.
updateLimit
(
l
))
{
if
(
psiHelper
.
updateProductShopItemLimit
(
item
,
l
))
{
updateCartLimits
(
null
);
updateCartLimits
(
null
);
return
;
return
;
}
}
...
@@ -207,14 +223,16 @@ public class ProductShopView extends GenericCDIView {
...
@@ -207,14 +223,16 @@ public class ProductShopView extends GenericCDIView {
if
(
l
!=
null
)
{
if
(
l
!=
null
)
{
hasLimits
=
true
;
hasLimits
=
true
;
}
}
n
.
updateLimit
(
l
);
psiHelper
.
updateProductShopItemLimit
(
n
,
l
);
}
}
}
}
public
String
removeBought
()
{
public
String
removeBought
()
{
ProductShopItem
row
=
boughtItems
.
getRowData
();
ProductShopItem
row
=
boughtItems
.
getRowData
();
row
.
setCount
(
row
.
getCount
().
subtract
(
BigDecimal
.
ONE
));
psiHelper
.
setProductShopItemCount
(
row
,
row
.
getCount
().
subtract
(
BigDecimal
.
ONE
));
updateCartLimits
(
row
);
updateCartLimits
(
row
);
return
null
;
return
null
;
...
@@ -278,13 +296,13 @@ public class ProductShopView extends GenericCDIView {
...
@@ -278,13 +296,13 @@ public class ProductShopView extends GenericCDIView {
return
null
;
return
null
;
}
}
Bill
bill
=
new
Bill
(
eventbean
.
getCurrentEvent
(),
user
);
Bill
bill
=
new
Bill
(
eventbean
.
getCurrentEvent
(),
user
,
eventbean
.
getPropertyLong
(
LanEventPropertyKey
.
BILL_EXPIRE_HOURS
)
);
bill
.
setNotes
(
otherInfo
);
bill
.
setNotes
(
otherInfo
);
bill
.
setOurReference
(
eventbean
.
getCurrentEvent
().
getName
());
bill
.
setOurReference
(
eventbean
.
getCurrentEvent
().
getName
());
for
(
ProductShopItem
shopitem
:
shoppingcart
)
{
for
(
ProductShopItem
shopitem
:
shoppingcart
)
{
if
(
shopitem
.
getCount
().
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
if
(
shopitem
.
getCount
().
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
bill
.
addProduct
(
shopitem
.
getProduct
(),
shopitem
.
getCount
());
bill
bean
.
addProductToBill
(
bill
,
shopitem
.
getProduct
(),
shopitem
.
getCount
());
}
}
}
}
billbean
.
createBill
(
bill
);
billbean
.
createBill
(
bill
);
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/helper/ProductShopItemHelper.java
0 → 100644
View file @
3d49424
package
fi
.
codecrew
.
moya
.
web
.
helper
;
import
java.math.BigDecimal
;
import
java.util.Calendar
;
import
java.util.HashMap
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.inject.Named
;
import
fi.codecrew.moya.beans.DiscountBeanLocal
;
import
fi.codecrew.moya.model.Discount
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
import
fi.codecrew.moya.web.helpers.ProductShopItem
;
@Named
@ConversationScoped
public
class
ProductShopItemHelper
extends
GenericCDIView
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
@EJB
private
DiscountBeanLocal
discountBean
;
public
void
setProductShopItemCount
(
ProductShopItem
item
,
BigDecimal
count
)
{
if
(
count
==
null
||
count
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
count
=
BigDecimal
.
ZERO
;
}
item
.
setInternalCount
(
count
);
item
.
setInternalPrice
(
item
.
getProduct
().
getPrice
().
abs
().
multiply
(
count
));
item
.
setInternalDiscounts
(
discountBean
.
getActiveDiscountsByProduct
(
item
.
getProduct
(),
count
,
Calendar
.
getInstance
(),
item
.
getUser
())
);
item
.
setInternalDiscountValues
(
new
HashMap
<
Integer
,
BigDecimal
>());
for
(
Discount
d
:
item
.
getDiscounts
())
{
BigDecimal
newprice
=
item
.
getPrice
().
multiply
(
d
.
getPercentage
());
item
.
getInternalDiscountValues
().
put
(
d
.
getId
(),
item
.
getPrice
().
subtract
(
newprice
));
item
.
setInternalPrice
(
newprice
);
}
}
public
boolean
updateProductShopItemLimit
(
ProductShopItem
item
,
BigDecimal
limitValue
)
{
if
(
limitValue
!=
null
&&
limitValue
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
this
.
setProductShopItemCount
(
item
,
item
.
getCount
().
add
(
limitValue
));
if
(
item
.
getCount
().
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
this
.
setProductShopItemCount
(
item
,
BigDecimal
.
ZERO
);
}
item
.
setLimit
(
BigDecimal
.
ZERO
);
return
true
;
}
item
.
setLimit
(
limitValue
);
return
false
;
}
}
code/MoyaWeb/src/fi/codecrew/moya/web/helpers/ProductShopItem.java
View file @
3d49424
...
@@ -2,8 +2,6 @@ package fi.codecrew.moya.web.helpers;
...
@@ -2,8 +2,6 @@ package fi.codecrew.moya.web.helpers;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -11,6 +9,7 @@ import org.slf4j.Logger;
...
@@ -11,6 +9,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.model.Discount
;
import
fi.codecrew.moya.model.Discount
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.Product
;
import
fi.codecrew.moya.model.Product
;
public
class
ProductShopItem
{
public
class
ProductShopItem
{
...
@@ -23,6 +22,7 @@ public class ProductShopItem {
...
@@ -23,6 +22,7 @@ public class ProductShopItem {
private
Map
<
Integer
,
BigDecimal
>
discountValues
;
private
Map
<
Integer
,
BigDecimal
>
discountValues
;
private
BigDecimal
price
;
private
BigDecimal
price
;
private
BigDecimal
limit
;
private
BigDecimal
limit
;
private
EventUser
user
;
public
BigDecimal
getCreditPrice
()
public
BigDecimal
getCreditPrice
()
{
{
...
@@ -42,12 +42,13 @@ public class ProductShopItem {
...
@@ -42,12 +42,13 @@ public class ProductShopItem {
return
BigDecimal
.
ZERO
;
return
BigDecimal
.
ZERO
;
}
}
public
ProductShopItem
(
Product
prod
)
{
public
ProductShopItem
(
Product
prod
,
EventUser
user
)
{
super
();
super
();
this
.
user
=
user
;
this
.
product
=
prod
;
this
.
product
=
prod
;
id
=
this
.
product
.
getId
();
id
=
this
.
product
.
getId
();
setCount
(
BigDecimal
.
ZERO
);
set
Internal
Count
(
BigDecimal
.
ZERO
);
setInternalPrice
(
BigDecimal
.
ZERO
);
}
}
/**
/**
...
@@ -56,21 +57,21 @@ public class ProductShopItem {
...
@@ -56,21 +57,21 @@ public class ProductShopItem {
* @param findForStaffshop
* @param findForStaffshop
* @return
* @return
*/
*/
public
static
List
<
ProductShopItem
>
productGTList
(
List
<
Product
>
products
)
{
public
static
List
<
ProductShopItem
>
productGTList
(
List
<
Product
>
products
,
EventUser
user
)
{
List
<
ProductShopItem
>
ret
=
new
ArrayList
<
ProductShopItem
>();
List
<
ProductShopItem
>
ret
=
new
ArrayList
<
ProductShopItem
>();
for
(
Product
prod
:
products
)
{
for
(
Product
prod
:
products
)
{
if
(
prod
.
getPrice
().
compareTo
(
BigDecimal
.
ZERO
)
>=
0
)
{
if
(
prod
.
getPrice
().
compareTo
(
BigDecimal
.
ZERO
)
>=
0
)
{
ret
.
add
(
new
ProductShopItem
(
prod
));
ret
.
add
(
new
ProductShopItem
(
prod
,
user
));
}
}
}
}
return
ret
;
return
ret
;
}
}
public
static
List
<
ProductShopItem
>
productList
(
List
<
Product
>
products
)
{
public
static
List
<
ProductShopItem
>
productList
(
List
<
Product
>
products
,
EventUser
user
)
{
List
<
ProductShopItem
>
ret
=
new
ArrayList
<
ProductShopItem
>();
List
<
ProductShopItem
>
ret
=
new
ArrayList
<
ProductShopItem
>();
for
(
Product
prod
:
products
)
{
for
(
Product
prod
:
products
)
{
ret
.
add
(
new
ProductShopItem
(
prod
));
ret
.
add
(
new
ProductShopItem
(
prod
,
user
));
}
}
return
ret
;
return
ret
;
...
@@ -80,36 +81,35 @@ public class ProductShopItem {
...
@@ -80,36 +81,35 @@ public class ProductShopItem {
return
this
.
product
;
return
this
.
product
;
}
}
public
void
setCount
(
BigDecimal
count
)
{
/**
* DO NOT USE THIS.
if
(
count
==
null
||
count
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
*
{
* Use ProductShopIteHelper.setProductShopItemCount instead.
count
=
BigDecimal
.
ZERO
;
* @param count
}
*/
public
void
setInternalCount
(
BigDecimal
count
)
{
this
.
count
=
count
;
this
.
count
=
count
;
price
=
product
.
getPrice
().
abs
().
multiply
(
count
);
discounts
=
product
.
getActiveDiscounts
(
count
,
Calendar
.
getInstance
());
discountValues
=
new
HashMap
<
Integer
,
BigDecimal
>();
for
(
Discount
d
:
discounts
)
{
BigDecimal
newprice
=
price
.
multiply
(
d
.
getPercentage
());
discountValues
.
put
(
d
.
getId
(),
price
.
subtract
(
newprice
));
price
=
newprice
;
}
}
}
public
void
setInternalPrice
(
BigDecimal
price
)
{
this
.
price
=
price
;
}
public
List
<
Discount
>
getDiscounts
()
public
List
<
Discount
>
getDiscounts
()
{
{
return
discounts
;
return
discounts
;
}
}
public
void
setInternalDiscounts
(
List
<
Discount
>
discounts
)
{
this
.
discounts
=
discounts
;
}
public
BigDecimal
getDiscount
(
Integer
discId
)
public
BigDecimal
getDiscount
(
Integer
discId
)
{
{
return
discountValues
.
get
(
discId
);
return
discountValues
.
get
(
discId
);
}
}
public
BigDecimal
getPrice
()
public
BigDecimal
getPrice
()
{
{
return
price
;
return
price
;
...
@@ -138,19 +138,19 @@ public class ProductShopItem {
...
@@ -138,19 +138,19 @@ public class ProductShopItem {
return
limit
;
return
limit
;
}
}
public
boolean
updateLimit
(
BigDecimal
limitValue
)
{
public
EventUser
getUser
()
{
return
user
;
}
if
(
limitValue
!=
null
&&
limitValue
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
public
void
setUser
(
EventUser
user
)
{
{
this
.
user
=
user
;
logger
.
info
(
"product limit {}, count {}"
,
limitValue
,
count
);
}
setCount
(
getCount
().
add
(
limitValue
));
if
(
count
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
public
Map
<
Integer
,
BigDecimal
>
getInternalDiscountValues
()
{
setCount
(
BigDecimal
.
ZERO
);
return
discountValues
;
}
}
limit
=
BigDecimal
.
ZERO
;
return
true
;
public
void
setInternalDiscountValues
(
Map
<
Integer
,
BigDecimal
>
discountValues
)
{
}
this
.
discountValues
=
discountValues
;
limit
=
limitValue
;
return
false
;
}
}
}
}
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