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 ca833596
authored
Dec 06, 2014
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
now it's possibly to give stuff with zero price
1 parent
380c6c51
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
16 deletions
code/moya-beans/ejbModule/fi/codecrew/moya/beans/ProductPBean.java
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/shop/ProductShopView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/helper/ProductShopItemHelper.java
code/moya-web/src/main/java/fi/codecrew/moya/web/helpers/ProductShopItem.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/ProductPBean.java
View file @
ca83359
...
@@ -108,9 +108,9 @@ public class ProductPBean {
...
@@ -108,9 +108,9 @@ public class ProductPBean {
List
<
Discount
>
discounts
=
new
ArrayList
<>();
List
<
Discount
>
discounts
=
new
ArrayList
<>();
if
(
overriddenUnitPrice
!=
null
&&
BigDecimal
.
ZERO
.
compareTo
(
overriddenUnitPrice
)
<
0
)
{
if
(
overriddenUnitPrice
!=
null
&&
BigDecimal
.
ZERO
.
compareTo
(
overriddenUnitPrice
)
<
=
0
)
{
unitPrice
=
overriddenUnitPrice
;
unitPrice
=
overriddenUnitPrice
.
negate
()
;
lbean
.
sendMessage
(
MoyaEventType
.
ACCOUNTEVENT_INFO
,
permbean
.
getCurrentUser
(),
"User creating accountevent with discount"
);
lbean
.
sendMessage
(
MoyaEventType
.
ACCOUNTEVENT_INFO
,
permbean
.
getCurrentUser
(),
"User creating accountevent with discount"
);
// lbean.logMessage(SecurityLogType.accountEvent, permbean.getCurrentUser(), "User creating accountevent with discount");
// lbean.logMessage(SecurityLogType.accountEvent, permbean.getCurrentUser(), "User creating accountevent with discount");
}
else
{
}
else
{
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/shop/ProductShopView.java
View file @
ca83359
...
@@ -365,7 +365,11 @@ public class ProductShopView extends GenericCDIView {
...
@@ -365,7 +365,11 @@ public class ProductShopView extends GenericCDIView {
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
(),
shopitem
.
getOverriddenUnitPrice
(),
userView
.
getSelectedUser
()).
getUser
();
// retuser = productBean.createAccountEvent(shopitem.getProduct(), shopitem.getCount(), shopitem.getOverriddenUnitPrice(), userView.getSelectedUser()).getUser();
BigDecimal
overriddenPrice
=
(
shopitem
.
isOverrideUnitPrice
())
?
shopitem
.
getOverriddenUnitPrice
()
:
null
;
retuser
=
productBean
.
createAccountEvent
(
shopitem
.
getProduct
(),
shopitem
.
getCount
(),
overriddenPrice
,
userView
.
getSelectedUser
()).
getUser
();
}
}
}
}
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/helper/ProductShopItemHelper.java
View file @
ca83359
...
@@ -46,7 +46,7 @@ public class ProductShopItemHelper extends GenericCDIView {
...
@@ -46,7 +46,7 @@ public class ProductShopItemHelper extends GenericCDIView {
public
void
updateProductShopItemCount
(
ProductShopItem
item
)
{
public
void
updateProductShopItemCount
(
ProductShopItem
item
)
{
// Discounts or overridden price, you cannot get both
// Discounts or overridden price, you cannot get both
if
(
item
.
is
PriceOverridden
())
{
if
(
item
.
is
OverrideUnitPrice
())
{
item
.
setInternalPrice
(
item
.
getOverriddenUnitPrice
().
multiply
(
item
.
getCount
()));
item
.
setInternalPrice
(
item
.
getOverriddenUnitPrice
().
multiply
(
item
.
getCount
()));
}
else
{
}
else
{
item
.
setInternalPrice
(
item
.
getProduct
().
getPrice
().
abs
().
multiply
(
item
.
getCount
()));
item
.
setInternalPrice
(
item
.
getProduct
().
getPrice
().
abs
().
multiply
(
item
.
getCount
()));
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/helpers/ProductShopItem.java
View file @
ca83359
...
@@ -46,6 +46,7 @@ public class ProductShopItem {
...
@@ -46,6 +46,7 @@ public class ProductShopItem {
private
BigDecimal
overriddenUnitPrice
=
BigDecimal
.
ZERO
;
private
BigDecimal
overriddenUnitPrice
=
BigDecimal
.
ZERO
;
private
boolean
overrideUnitPrice
=
false
;
...
@@ -78,12 +79,10 @@ public class ProductShopItem {
...
@@ -78,12 +79,10 @@ public class ProductShopItem {
/**
/**
* Return products that
* Return products that
*
*
* @param findForStaffshop
* @return
*/
*/
public
static
List
<
ProductShopItem
>
productGTList
(
List
<
Product
>
products
,
EventUser
user
)
{
public
static
List
<
ProductShopItem
>
productGTList
(
List
<
Product
>
products
,
EventUser
user
)
{
List
<
ProductShopItem
>
ret
=
new
ArrayList
<
ProductShopItem
>();
List
<
ProductShopItem
>
ret
=
new
ArrayList
<>();
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
,
user
));
ret
.
add
(
new
ProductShopItem
(
prod
,
user
));
...
@@ -94,7 +93,7 @@ public class ProductShopItem {
...
@@ -94,7 +93,7 @@ public class ProductShopItem {
}
}
public
static
List
<
ProductShopItem
>
productList
(
List
<
Product
>
products
,
EventUser
user
)
{
public
static
List
<
ProductShopItem
>
productList
(
List
<
Product
>
products
,
EventUser
user
)
{
List
<
ProductShopItem
>
ret
=
new
ArrayList
<
ProductShopItem
>();
List
<
ProductShopItem
>
ret
=
new
ArrayList
<>();
for
(
Product
prod
:
products
)
{
for
(
Product
prod
:
products
)
{
ret
.
add
(
new
ProductShopItem
(
prod
,
user
));
ret
.
add
(
new
ProductShopItem
(
prod
,
user
));
}
}
...
@@ -124,7 +123,6 @@ public class ProductShopItem {
...
@@ -124,7 +123,6 @@ public class ProductShopItem {
/**
/**
* Price and discounts are only stored so we can show them to user, changing there does not change end price of card
* Price and discounts are only stored so we can show them to user, changing there does not change end price of card
* @param discounts
*/
*/
public
void
setInternalPrice
(
BigDecimal
price
)
{
public
void
setInternalPrice
(
BigDecimal
price
)
{
this
.
price
=
price
;
this
.
price
=
price
;
...
@@ -195,8 +193,13 @@ public class ProductShopItem {
...
@@ -195,8 +193,13 @@ public class ProductShopItem {
public
BigDecimal
getOverriddenUnitPrice
()
{
public
BigDecimal
getOverriddenUnitPrice
()
{
if
(
overriddenUnitPrice
==
null
)
overriddenUnitPrice
=
BigDecimal
.
ZERO
;
if
(!
isOverrideUnitPrice
())
return
getPrice
().
divide
(
getCount
());
// isOverrideUnitPrice shout also check this, but just in case..
if
(
overriddenUnitPrice
==
null
||
overriddenUnitPrice
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
overriddenUnitPrice
=
getPrice
().
divide
(
getCount
());
return
overriddenUnitPrice
;
return
overriddenUnitPrice
;
}
}
...
@@ -209,16 +212,35 @@ public class ProductShopItem {
...
@@ -209,16 +212,35 @@ public class ProductShopItem {
* @param overrideUnitPrice
* @param overrideUnitPrice
*/
*/
public
void
setOverriddenUnitPrice
(
BigDecimal
overrideUnitPrice
)
{
public
void
setOverriddenUnitPrice
(
BigDecimal
overrideUnitPrice
)
{
this
.
overriddenUnitPrice
=
overrideUnitPrice
;
}
public
boolean
isPriceOverridden
()
{
if
(
overrideUnitPrice
!=
getPrice
().
divide
(
getCount
()))
{
return
(
getOverriddenUnitPrice
()
!=
null
&&
getOverriddenUnitPrice
().
compareTo
(
BigDecimal
.
ZERO
)
>
0
);
setOverrideUnitPrice
(
true
);
this
.
overriddenUnitPrice
=
overrideUnitPrice
;
}
else
{
setOverrideUnitPrice
(
false
);
this
.
overriddenUnitPrice
=
null
;
}
}
}
public
BigDecimal
getUnitDiscount
()
{
public
BigDecimal
getUnitDiscount
()
{
return
getPrice
().
divide
(
getCount
()).
subtract
(
getProduct
().
getPrice
());
return
getPrice
().
divide
(
getCount
()).
subtract
(
getProduct
().
getPrice
());
}
}
public
boolean
isOverrideUnitPrice
()
{
if
(
overrideUnitPrice
&&
(
overriddenUnitPrice
==
null
||
overriddenUnitPrice
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
))
{
return
false
;
}
return
overrideUnitPrice
;
}
public
void
setOverrideUnitPrice
(
boolean
overrideUnitPrice
)
{
this
.
overrideUnitPrice
=
overrideUnitPrice
;
}
}
}
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