Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Max Mecklin
/
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 4c45791b
authored
Nov 19, 2016
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sort number for discounts.
1 parent
c41cb319
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
49 additions
and
1 deletions
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/DiscountBean.java
code/moya-database/src/main/java/fi/codecrew/moya/model/Discount.java
code/moya-database/src/main/java/fi/codecrew/moya/model/Product.java
code/moya-web/WebContent/resources/cditools/products/manageDiscount.xhtml
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/shop/ProductView.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 @
4c45791
...
...
@@ -421,6 +421,10 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbUpdates
.
add
(
new
String
[]
{
"ALTER TABLE products ADD COLUMN min_buy_count INTEGER default 0;"
});
dbUpdates
.
add
(
new
String
[]
{
"ALTER TABLE discounts ADD COLUMN sort INTEGER NOT NULL default 10;"
});
}
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/DiscountBean.java
View file @
4c45791
...
...
@@ -80,6 +80,7 @@ public class DiscountBean implements DiscountBeanLocal {
}
}
}
ret
.
sort
(
Discount
.
SORT_COMPARATOR
);
return
ret
;
}
...
...
code/moya-database/src/main/java/fi/codecrew/moya/model/Discount.java
View file @
4c45791
...
...
@@ -21,6 +21,7 @@ package fi.codecrew.moya.model;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -42,12 +43,26 @@ import javax.persistence.TemporalType;
@Entity
@Table
(
name
=
"discounts"
)
public
class
Discount
extends
GenericEntity
{
public
static
final
String
SORT_FIELD
=
"sort"
;
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
String
EVENT_ID
=
"event_id"
;
private
static
final
BigDecimal
SCALE4_ZERO
=
BigDecimal
.
ZERO
.
setScale
(
4
,
RoundingMode
.
HALF_UP
);
private
static
final
BigDecimal
SCALE6_ZERO
=
BigDecimal
.
ZERO
.
setScale
(
6
,
RoundingMode
.
HALF_UP
);
public
static
Comparator
<
Discount
>
SORT_COMPARATOR
=
new
Comparator
<
Discount
>(){
@Override
public
int
compare
(
Discount
o1
,
Discount
o2
)
{
return
Integer
.
compare
(
o1
.
getSort
(),
o2
.
getSort
());
}
};
@Column
(
name
=
SORT_FIELD
,
nullable
=
false
)
private
int
sort
=
10
;
@ManyToOne
()
@JoinColumn
(
name
=
EVENT_ID
,
nullable
=
false
)
private
LanEvent
event
;
...
...
@@ -61,6 +76,7 @@ public class Discount extends GenericEntity {
@Temporal
(
TemporalType
.
TIMESTAMP
)
@Column
(
name
=
"valid_from"
)
private
Date
validFrom
;
@Temporal
(
TemporalType
.
TIMESTAMP
)
@Column
(
name
=
"valid_to"
)
private
Date
validTo
;
...
...
@@ -240,4 +256,12 @@ public class Discount extends GenericEntity {
this
.
validFrom
=
validFrom
;
}
public
int
getSort
()
{
return
sort
;
}
public
void
setSort
(
int
sort
)
{
this
.
sort
=
sort
;
}
}
code/moya-database/src/main/java/fi/codecrew/moya/model/Product.java
View file @
4c45791
...
...
@@ -40,6 +40,7 @@ import javax.persistence.Lob;
import
javax.persistence.ManyToMany
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.OneToMany
;
import
javax.persistence.OrderBy
;
import
javax.persistence.Table
;
import
javax.persistence.Transient
;
import
javax.persistence.UniqueConstraint
;
...
...
@@ -127,6 +128,7 @@ public class Product extends GenericEntity {
joinColumns
=
{
@JoinColumn
(
name
=
PRODUCTFLAG_TABLE_PRODUCTID
,
referencedColumnName
=
Product
.
ID_COLUMN
)
})
@OrderBy
(
Discount
.
SORT_FIELD
+
" ASC"
)
private
List
<
Discount
>
discounts
;
@Column
(
name
=
"vat"
,
nullable
=
false
,
precision
=
4
,
scale
=
Bill
.
VAT_SCALE
)
...
...
code/moya-web/WebContent/resources/cditools/products/manageDiscount.xhtml
View file @
4c45791
...
...
@@ -16,6 +16,14 @@
<f:param
name=
"productid"
value=
"#{productView.product.id}"
/>
</h:link>
<h:panelGrid
columns=
"3"
>
<h:outputLabel
for=
"id"
value=
"#{i18n['discount.id']}:"
/>
<h:outputText
id=
"id"
value=
"#{productView.discount.id}"
/>
<h:message
for=
"id"
/>
<h:outputLabel
for=
"sort"
value=
"#{i18n['discount.sort']}:"
/>
<h:inputText
id=
"sort"
value=
"#{productView.discount.sort}"
/>
<h:message
for=
"sort"
/>
<h:outputLabel
for=
"shortdesc"
value=
"#{i18n['discount.shortdesc']}:"
/>
<h:inputText
id=
"shortdesc"
value=
"#{productView.discount.shortdesc}"
/>
<h:message
for=
"shortdesc"
/>
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/shop/ProductView.java
View file @
4c45791
...
...
@@ -190,7 +190,9 @@ public class ProductView extends GenericCDIView {
public
ListDataModel
<
Discount
>
getProductDiscounts
()
{
productDiscounts
=
new
ListDataModel
<
Discount
>(
product
.
getDiscounts
());
List
<
Discount
>
discs
=
product
.
getDiscounts
();
discs
.
sort
(
Discount
.
SORT_COMPARATOR
);
productDiscounts
=
new
ListDataModel
<
Discount
>(
discs
);
return
productDiscounts
;
}
...
...
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n.properties
View file @
4c45791
...
...
@@ -149,6 +149,9 @@ create = Luo
delete
=
Poista
discount.id
=
ID
discount.sort
=
Sort nr.
edit
=
Muokkaa
error
=
Virhe
...
...
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_en.properties
View file @
4c45791
...
...
@@ -341,6 +341,7 @@ discount.code = Discount code
discount.create
=
Create new
discount.details
=
Details
discount.edit
=
Edit
discount.id
=
ID
discount.maxNum
=
Max no of discounts
discount.perUser
=
Discounts per user
discount.percentage
=
Discount multiplier
...
...
@@ -348,6 +349,7 @@ discount.products = Products
discount.role
=
Role discount
discount.save
=
Save
discount.shortdesc
=
Description
discount.sort
=
Sort nr.
discount.validFrom
=
Valid from
discount.validTo
=
Valid until
...
...
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_fi.properties
View file @
4c45791
...
...
@@ -342,6 +342,7 @@ discount.code = Alennuskoodi
discount.create
=
Luo uusi
discount.details
=
Tiedot
discount.edit
=
Muokkaa
discount.id
=
ID
discount.maxNum
=
Alennusten enimm
\u
00E4islkm
discount.perUser
=
Alennuksia per k
\u
00E4ytt
\u
00E4j
\u
00E4
discount.percentage
=
Alennuskerroin
...
...
@@ -349,6 +350,7 @@ discount.products = Tuotteet
discount.role
=
Roolialennus
discount.save
=
Tallenna
discount.shortdesc
=
Kuvaus
discount.sort
=
J
\u
00E4rjestysnumero
discount.validFrom
=
Voimassa alkaen
discount.validTo
=
Voimassa asti
...
...
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