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 cc094030
authored
Dec 16, 2014
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enforce product limits in user shop
1 parent
f01b1260
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
code/moya-web/src/main/java/fi/codecrew/moya/web/helper/ProductShopItemHelper.java
code/moya-web/src/main/java/fi/codecrew/moya/web/helper/ProductShopItemHelper.java
View file @
cc09403
...
@@ -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
.
isOverrideUnitPrice
())
{
if
(
item
.
isOverrideUnitPrice
())
{
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
()));
...
@@ -63,7 +63,6 @@ public class ProductShopItemHelper extends GenericCDIView {
...
@@ -63,7 +63,6 @@ public class ProductShopItemHelper extends GenericCDIView {
}
}
}
}
}
}
public
void
setProductShopItemCount
(
ProductShopItem
item
,
BigDecimal
count
)
{
public
void
setProductShopItemCount
(
ProductShopItem
item
,
BigDecimal
count
)
{
...
@@ -78,10 +77,13 @@ public class ProductShopItemHelper extends GenericCDIView {
...
@@ -78,10 +77,13 @@ public class ProductShopItemHelper extends GenericCDIView {
}
}
public
boolean
updateProductShopItemLimit
(
ProductShopItem
item
,
BigDecimal
limitValue
)
{
public
boolean
updateProductShopItemLimit
(
ProductShopItem
item
,
BigDecimal
limitValue
)
{
BigDecimal
productsLeft
=
null
;
if
(
limitValue
!=
null
&&
limitValue
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
if
(
limitValue
!=
null
)
{
{
productsLeft
=
limitValue
.
subtract
(
item
.
getCount
());
this
.
setProductShopItemCount
(
item
,
item
.
getCount
().
add
(
limitValue
));
if
(
productsLeft
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
this
.
setProductShopItemCount
(
item
,
limitValue
);
if
(
item
.
getCount
().
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
if
(
item
.
getCount
().
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
this
.
setProductShopItemCount
(
item
,
BigDecimal
.
ZERO
);
this
.
setProductShopItemCount
(
item
,
BigDecimal
.
ZERO
);
...
@@ -89,8 +91,8 @@ public class ProductShopItemHelper extends GenericCDIView {
...
@@ -89,8 +91,8 @@ public class ProductShopItemHelper extends GenericCDIView {
item
.
setLimit
(
BigDecimal
.
ZERO
);
item
.
setLimit
(
BigDecimal
.
ZERO
);
return
true
;
return
true
;
}
}
item
.
setLimit
(
limitValue
);
}
item
.
setLimit
(
productsLeft
);
return
false
;
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