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 48917962
authored
Dec 14, 2014
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 'master'
Master autoproduct for user See merge request !165
2 parents
a392afcb
865f949a
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
80 additions
and
22 deletions
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BillBean.java
code/moya-database/src/main/java/fi/codecrew/moya/model/Product.java
code/moya-database/src/main/java/fi/codecrew/moya/model/ProductFlag.java
code/moya-web/WebContent/resources/cditools/products/shop.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/helpers/ProductShopItem.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/BillBean.java
View file @
4891796
...
@@ -263,6 +263,25 @@ public class BillBean implements BillBeanLocal {
...
@@ -263,6 +263,25 @@ public class BillBean implements BillBeanLocal {
loggingBean
.
sendMessage
(
MoyaEventType
.
BILL_ERROR
,
permbean
.
getCurrentUser
(),
"Not enought rights to create bill for user: "
,
bill
.
getUser
());
loggingBean
.
sendMessage
(
MoyaEventType
.
BILL_ERROR
,
permbean
.
getCurrentUser
(),
"Not enought rights to create bill for user: "
,
bill
.
getUser
());
throw
new
EJBAccessException
(
"Could not create bill for another user"
);
throw
new
EJBAccessException
(
"Could not create bill for another user"
);
}
}
// if there is autoproducts, check that they exists in bill
for
(
Product
product
:
productBean
.
listUserShoppableProducts
())
{
if
(
product
.
isUsershopAutoproduct
())
{
boolean
containsAutoproduct
=
false
;
for
(
BillLine
line
:
bill
.
getBillLines
())
{
if
(
line
.
getLineProduct
()
!=
null
&&
line
.
getLineProduct
().
equals
(
product
)
&&
line
.
getQuantity
().
compareTo
(
BigDecimal
.
ONE
)
>=
0
)
{
containsAutoproduct
=
true
;
}
}
if
(!
containsAutoproduct
)
{
BillLine
line
=
new
BillLine
(
bill
,
product
,
BigDecimal
.
ONE
);
bill
.
getBillLines
().
add
(
line
);
}
}
}
billFacade
.
create
(
bill
);
billFacade
.
create
(
bill
);
generateBillNumber
(
bill
);
generateBillNumber
(
bill
);
createPlaceslots
(
bill
);
createPlaceslots
(
bill
);
...
...
code/moya-database/src/main/java/fi/codecrew/moya/model/Product.java
View file @
4891796
...
@@ -360,4 +360,9 @@ public class Product extends GenericEntity {
...
@@ -360,4 +360,9 @@ public class Product extends GenericEntity {
this
.
licenseTargets
=
licenseTargets
;
this
.
licenseTargets
=
licenseTargets
;
}
}
public
boolean
isUsershopAutoproduct
()
{
return
getProductFlags
().
contains
(
ProductFlag
.
USERSHOP_AUTOPRODUCT
);
}
}
}
code/moya-database/src/main/java/fi/codecrew/moya/model/ProductFlag.java
View file @
4891796
...
@@ -54,7 +54,13 @@ public enum ProductFlag {
...
@@ -54,7 +54,13 @@ public enum ProductFlag {
/**
/**
* Käyttäjän itse kaupasta ostettavissa oleva tuote.
* Käyttäjän itse kaupasta ostettavissa oleva tuote.
*/
*/
USER_SHOPPABLE
;
USER_SHOPPABLE
,
/**
* Tuote joka lisätään jokaisen käyttäjäkaupasta tehtyyn tilaukseen automaattisesti
*/
USERSHOP_AUTOPRODUCT
;
private
static
final
String
KEY_PREFIX
=
"productFlag."
;
private
static
final
String
KEY_PREFIX
=
"productFlag."
;
private
final
String
key
;
private
final
String
key
;
...
@@ -65,7 +71,6 @@ public enum ProductFlag {
...
@@ -65,7 +71,6 @@ public enum ProductFlag {
public
String
getI18nkey
()
public
String
getI18nkey
()
{
{
return
key
;
return
key
;
}
}
...
...
code/moya-web/WebContent/resources/cditools/products/shop.xhtml
View file @
4891796
...
@@ -23,8 +23,7 @@
...
@@ -23,8 +23,7 @@
<!-- <h:outputScript target="head" library="script" name="shopscript.js" /> -->
<!-- <h:outputScript target="head" library="script" name="shopscript.js" /> -->
<h:outputScript
library=
"primefaces"
name=
"jquery/jquery.js"
/>
<h:outputScript
library=
"primefaces"
name=
"jquery/jquery.js"
/>
<p:dataTable
columnClasses=
"nowrap,numalign,numalign,numalign,nowrap"
<p:dataTable
columnClasses=
"nowrap,numalign,numalign,numalign,nowrap"
id=
"billcart"
value=
"#{cc.attrs.items}"
var=
"cart"
>
id=
"billcart"
value=
"#{cc.attrs.items}"
var=
"cart"
>
<p:column>
<p:column>
<f:facet
name=
"header"
>
<f:facet
name=
"header"
>
<h:outputText
id=
"name"
value=
"${i18n['shop.product.name']}"
/>
<h:outputText
id=
"name"
value=
"${i18n['shop.product.name']}"
/>
...
@@ -45,20 +44,26 @@
...
@@ -45,20 +44,26 @@
<h:outputText
id=
"count"
value=
"${i18n['product.cart.count']}"
/>
<h:outputText
id=
"count"
value=
"${i18n['product.cart.count']}"
/>
</f:facet>
</f:facet>
<h:commandButton
action=
"#{productShopView.addMinusOne}"
<p:outputPanel
rendered=
"#{cart.product.usershopAutoproduct}"
>
value=
"#{i18n['productshop.minusOne']}"
>
<h:outputText
value=
"#{cart.count}"
/>
<f:ajax
render=
"@form"
/>
</p:outputPanel>
</h:commandButton>
<p:inputText
size=
"2"
id=
"cartcount"
escape=
"false"
<p:outputPanel
rendered=
"#{!cart.product.usershopAutoproduct}"
>
value=
"#{cart.count}"
>
<h:commandButton
action=
"#{productShopView.addMinusOne}"
<f:ajax
render=
"@form"
value=
"#{i18n['productshop.minusOne']}"
>
listener=
"#{productShopView.countChangeListener}"
/>
<f:ajax
render=
"@form"
/>
<f:convertNumber
maxFractionDigits=
"2"
minFractionDigits=
"0"
/>
</h:commandButton>
</p:inputText>
<p:inputText
size=
"2"
id=
"cartcount"
escape=
"false"
<h:commandButton
action=
"#{productShopView.addOne}"
value=
"#{cart.count}"
>
value=
"#{i18n['productshop.plusOne']}"
>
<f:ajax
render=
"@form"
<f:ajax
render=
"@form"
/>
listener=
"#{productShopView.countChangeListener}"
/>
</h:commandButton>
<f:convertNumber
maxFractionDigits=
"2"
minFractionDigits=
"0"
/>
</p:inputText>
<h:commandButton
action=
"#{productShopView.addOne}"
value=
"#{i18n['productshop.plusOne']}"
>
<f:ajax
render=
"@form"
/>
</h:commandButton>
</p:outputPanel>
</p:column>
</p:column>
<p:column
rendered=
"#{productShopView.hasLimits}"
>
<p:column
rendered=
"#{productShopView.hasLimits}"
>
<f:facet
name=
"header"
>
<f:facet
name=
"header"
>
...
@@ -84,7 +89,7 @@
...
@@ -84,7 +89,7 @@
</p:column>
</p:column>
<p:column>
<p:column>
<f:facet
name=
"header"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"
$
{i18n['product.totalPrice']}"
/>
<h:outputText
value=
"
#
{i18n['product.totalPrice']}"
/>
</f:facet>
</f:facet>
<h:outputText
id=
"total"
value=
"#{cart.price}"
>
<h:outputText
id=
"total"
value=
"#{cart.price}"
>
<f:convertNumber
maxFractionDigits=
"2"
minFractionDigits=
"2"
currencyCode=
"EUR"
type=
"currency"
locale=
"#{sessionHandler.locale}"
/>
<f:convertNumber
maxFractionDigits=
"2"
minFractionDigits=
"2"
currencyCode=
"EUR"
type=
"currency"
locale=
"#{sessionHandler.locale}"
/>
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/shop/ProductShopView.java
View file @
4891796
...
@@ -120,9 +120,13 @@ public class ProductShopView extends GenericCDIView {
...
@@ -120,9 +120,13 @@ 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
(),
userView
.
getSelectedUser
()));
shoppingcart
=
new
ListDataModel
<
ProductShopItem
>(
ProductShopItem
.
productList
(
productBean
.
listUserShoppableProducts
(),
userView
.
getSelectedUser
()));
for
(
ProductShopItem
item
:
shoppingcart
)
{
psiHelper
.
updateProductShopItemCount
(
item
);
}
updateCartLimits
(
null
);
updateCartLimits
(
null
);
logger
.
debug
(
"Initialized billing shoppingcart to {}"
,
shoppingcart
);
logger
.
debug
(
"Initialized billing shoppingcart to {}"
,
shoppingcart
);
this
.
beginConversation
();
this
.
beginConversation
();
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/helpers/ProductShopItem.java
View file @
4891796
...
@@ -24,6 +24,8 @@ import java.util.ArrayList;
...
@@ -24,6 +24,8 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
fi.codecrew.moya.model.ProductFlag
;
import
fi.codecrew.moya.web.helper.ProductShopItemHelper
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -92,10 +94,23 @@ public class ProductShopItem {
...
@@ -92,10 +94,23 @@ public class ProductShopItem {
return
ret
;
return
ret
;
}
}
/**
* NOTE: Remember to update count with ProductShopItemHelper afther calling this function
* (this logic really need's to be rewritten)
*
* @param products
* @param user
* @return
*/
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
<>();
List
<
ProductShopItem
>
ret
=
new
ArrayList
<>();
for
(
Product
prod
:
products
)
{
for
(
Product
prod
:
products
)
{
ret
.
add
(
new
ProductShopItem
(
prod
,
user
));
ProductShopItem
i
=
new
ProductShopItem
(
prod
,
user
);
if
(
prod
.
getProductFlags
().
contains
(
ProductFlag
.
USERSHOP_AUTOPRODUCT
))
{
i
.
setCount
(
BigDecimal
.
ONE
);
}
ret
.
add
(
i
);
}
}
return
ret
;
return
ret
;
...
...
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n.properties
View file @
4891796
...
@@ -468,3 +468,6 @@ usercart.showoverview = Vie tarkastusn\u00E4kym\u00E4\u00E4n
...
@@ -468,3 +468,6 @@ usercart.showoverview = Vie tarkastusn\u00E4kym\u00E4\u00E4n
viewlectures.title
=
Kurssit ja luennot
viewlectures.title
=
Kurssit ja luennot
yes
=
Kyll
\u
00E4
yes
=
Kyll
\u
00E4
productFlag.USERSHOP_AUTOPRODUCT
=
Tuote lis
\u
00E4t
\u
00E4
\u
00E4n k
\u
00E4ytt
\u
00E4j
\u
00E4n tilaukseen
acc_line.eventuser
=
mapView.productcount.productcount
=
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_en.properties
View file @
4891796
...
@@ -1674,3 +1674,4 @@ voting.create.voteEnd = Voting close
...
@@ -1674,3 +1674,4 @@ voting.create.voteEnd = Voting close
voting.create.voteStart
=
Voting start
voting.create.voteStart
=
Voting start
yes
=
Yes
yes
=
Yes
productFlag.USERSHOP_AUTOPRODUCT
=
Product will be added to user order
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_fi.properties
View file @
4891796
...
@@ -1656,3 +1656,4 @@ voting.create.voteEnd = \u00C4\u00E4nestys kiinni
...
@@ -1656,3 +1656,4 @@ voting.create.voteEnd = \u00C4\u00E4nestys kiinni
voting.create.voteStart
=
\u
00C4
\u
00E4nestys auki
voting.create.voteStart
=
\u
00C4
\u
00E4nestys auki
yes
=
Kyll
\u
00E4
yes
=
Kyll
\u
00E4
productFlag.USERSHOP_AUTOPRODUCT
=
Tuote lis
\u
00E4t
\u
00E4
\u
00E4n k
\u
00E4ytt
\u
00E4j
\u
00E4n tilaukseen
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