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 53eebb01
authored
Oct 28, 2016
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'minBuyCount' into 'master'
added minium buy count See merge request
!349
2 parents
618c744f
029e6386
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
39 additions
and
4 deletions
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
code/moya-database/src/main/java/fi/codecrew/moya/model/Product.java
code/moya-web/WebContent/resources/cditools/products/edit.xhtml
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/resources/fi/codecrew/moya/resources/i18n.properties
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_en.properties
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_fi.properties
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
View file @
53eebb0
...
@@ -417,6 +417,12 @@ public class BootstrapBean implements BootstrapBeanLocal {
...
@@ -417,6 +417,12 @@ public class BootstrapBean implements BootstrapBeanLocal {
});
});
dbUpdates
.
add
(
new
String
[]
{
"ALTER TABLE products ADD COLUMN min_buy_count INTEGER default 0;"
});
}
}
public
BootstrapBean
()
{
public
BootstrapBean
()
{
...
...
code/moya-database/src/main/java/fi/codecrew/moya/model/Product.java
View file @
53eebb0
...
@@ -84,6 +84,9 @@ public class Product extends GenericEntity {
...
@@ -84,6 +84,9 @@ public class Product extends GenericEntity {
@Column
(
name
=
"barcode"
)
@Column
(
name
=
"barcode"
)
private
String
barcode
;
private
String
barcode
;
@Column
(
name
=
"min_buy_count"
)
private
int
minBuyCount
;
@OneToMany
(
cascade
=
CascadeType
.
ALL
,
mappedBy
=
"product"
)
@OneToMany
(
cascade
=
CascadeType
.
ALL
,
mappedBy
=
"product"
)
private
List
<
LicenseTarget
>
licenseTargets
;
private
List
<
LicenseTarget
>
licenseTargets
;
...
@@ -424,4 +427,11 @@ public class Product extends GenericEntity {
...
@@ -424,4 +427,11 @@ public class Product extends GenericEntity {
return
productOptionGroups
!=
null
&&
productOptionGroups
.
size
()
>
0
;
return
productOptionGroups
!=
null
&&
productOptionGroups
.
size
()
>
0
;
}
}
public
int
getMinBuyCount
()
{
return
minBuyCount
;
}
public
void
setMinBuyCount
(
int
minBuyCount
)
{
this
.
minBuyCount
=
minBuyCount
;
}
}
}
code/moya-web/WebContent/resources/cditools/products/edit.xhtml
View file @
53eebb0
...
@@ -44,9 +44,9 @@
...
@@ -44,9 +44,9 @@
<h:inputText
id=
"barcode"
value=
"#{productView.product.barcode}"
/>
<h:inputText
id=
"barcode"
value=
"#{productView.product.barcode}"
/>
<h:message
for=
"barcode"
/>
<h:message
for=
"barcode"
/>
<h:outputLabel
for=
"
color"
value=
"#{i18n['product.color
']}:"
/>
<h:outputLabel
for=
"
minCount"
value=
"#{i18n['product.minBuyCount
']}:"
/>
<h:inputText
id=
"
color"
value=
"#{productView.product.color
}"
/>
<h:inputText
id=
"
minCount"
value=
"#{productView.product.minBuyCount
}"
/>
<h:message
for=
"
color
"
/>
<h:message
for=
"
minCount
"
/>
<h:outputLabel
for=
"provides"
value=
"#{i18n['product.providedRole']}"
/>
<h:outputLabel
for=
"provides"
value=
"#{i18n['product.providedRole']}"
/>
<h:selectOneMenu
id=
"provides"
layout=
"pageDirection"
value=
"#{productView.product.provides}"
converter=
"#{roleConverter}"
>
<h:selectOneMenu
id=
"provides"
layout=
"pageDirection"
value=
"#{productView.product.provides}"
converter=
"#{roleConverter}"
>
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/shop/ProductShopView.java
View file @
53eebb0
...
@@ -189,7 +189,19 @@ public class ProductShopView extends GenericCDIView {
...
@@ -189,7 +189,19 @@ public class ProductShopView extends GenericCDIView {
public
String
add
(
Integer
count
)
{
public
String
add
(
Integer
count
)
{
ProductShopItem
item
=
shoppingcart
.
getRowData
();
ProductShopItem
item
=
shoppingcart
.
getRowData
();
psiHelper
.
setProductShopItemCount
(
item
,
item
.
getCount
().
add
(
BigDecimal
.
valueOf
(
count
)));
Integer
realCount
=
count
;
if
(
item
.
getProduct
().
getMinBuyCount
()
>
0
)
{
// remove all
if
(
item
.
getCount
().
intValue
()
==
item
.
getProduct
().
getMinBuyCount
()
&&
count
<
0
)
{
realCount
=
item
.
getCount
().
intValue
()
*
-
1
;
}
else
if
(
item
.
getCount
().
equals
(
BigDecimal
.
ZERO
)
&&
count
>
0
)
{
realCount
=
item
.
getProduct
().
getMinBuyCount
();
}
}
psiHelper
.
setProductShopItemCount
(
item
,
item
.
getCount
().
add
(
BigDecimal
.
valueOf
(
realCount
)));
updateCartLimits
(
item
);
updateCartLimits
(
item
);
return
null
;
return
null
;
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/helper/ProductShopItemHelper.java
View file @
53eebb0
...
@@ -70,7 +70,11 @@ public class ProductShopItemHelper extends GenericCDIView {
...
@@ -70,7 +70,11 @@ public class ProductShopItemHelper extends GenericCDIView {
if
(
count
==
null
||
count
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
if
(
count
==
null
||
count
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
{
count
=
BigDecimal
.
ZERO
;
count
=
BigDecimal
.
ZERO
;
}
else
if
(
item
.
getProduct
().
getMinBuyCount
()
>
0
&&
count
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
&&
count
.
compareTo
(
BigDecimal
.
valueOf
(
item
.
getProduct
().
getMinBuyCount
()))
<
0
)
{
count
=
BigDecimal
.
valueOf
(
item
.
getProduct
().
getMinBuyCount
());
}
}
item
.
setCount
(
count
);
item
.
setCount
(
count
);
updateProductShopItemCount
(
item
);
updateProductShopItemCount
(
item
);
...
...
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n.properties
View file @
53eebb0
...
@@ -1571,3 +1571,4 @@ productOptionGroup.title=Product feature
...
@@ -1571,3 +1571,4 @@ productOptionGroup.title=Product feature
productOptionGroup.default
=
Default option
productOptionGroup.default
=
Default option
option.setAsDefault
=
set as default
option.setAsDefault
=
set as default
place.reservetime
=
Reservetime
place.reservetime
=
Reservetime
product.minBuyCount
=
Minium buy count
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_en.properties
View file @
53eebb0
...
@@ -1847,3 +1847,4 @@ productOptionGroup.title=Product feature
...
@@ -1847,3 +1847,4 @@ productOptionGroup.title=Product feature
productOptionGroup.default
=
Default option
productOptionGroup.default
=
Default option
option.setAsDefault
=
set as default
option.setAsDefault
=
set as default
place.reservetime
=
Reservetime
place.reservetime
=
Reservetime
product.minBuyCount
=
Minium buy count
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_fi.properties
View file @
53eebb0
...
@@ -1834,3 +1834,4 @@ productOptionGroup.title=Tuotevaihtoehto
...
@@ -1834,3 +1834,4 @@ productOptionGroup.title=Tuotevaihtoehto
productOptionGroup.default
=
Oletusvaihtoehto
productOptionGroup.default
=
Oletusvaihtoehto
option.setAsDefault
=
Aseta oletukseksi
option.setAsDefault
=
Aseta oletukseksi
place.reservetime
=
Varaamisaika
place.reservetime
=
Varaamisaika
product.minBuyCount
=
Ostettava v
\u
00E4hint
\u
00E4
\u
00E4n
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