Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
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 af57bbd5
authored
Oct 26, 2012
by
Tuukka Kivilahti, TKffTK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bills for foodwaves
1 parent
ab9d6a3c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
91 additions
and
36 deletions
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/BillBean.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/BillBeanLocal.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/Bill.java
code/LanBortalWeb/WebContent/foodmanager/listOrders.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/FoodWaveView.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/BillBean.java
View file @
af57bbd
...
@@ -200,7 +200,7 @@ public class BillBean implements BillBeanLocal {
...
@@ -200,7 +200,7 @@ public class BillBean implements BillBeanLocal {
@Override
@Override
@RolesAllowed
({
BillPermission
.
S_WRITE_ALL
,
@RolesAllowed
({
BillPermission
.
S_WRITE_ALL
,
SpecialPermission
.
S_VERKKOMAKSU_CHECK
})
SpecialPermission
.
S_VERKKOMAKSU_CHECK
})
public
void
markPaid
(
Bill
bill
,
Calendar
when
)
{
public
Bill
markPaid
(
Bill
bill
,
Calendar
when
)
{
if
(
bill
.
getAccountEvent
()
!=
null
||
bill
.
getPaidDate
()
!=
null
)
{
if
(
bill
.
getAccountEvent
()
!=
null
||
bill
.
getPaidDate
()
!=
null
)
{
throw
new
EJBException
(
"Bill already marked paid!"
);
throw
new
EJBException
(
"Bill already marked paid!"
);
...
@@ -249,17 +249,20 @@ public class BillBean implements BillBeanLocal {
...
@@ -249,17 +249,20 @@ public class BillBean implements BillBeanLocal {
utilbean
.
sendMail
(
msg
);
utilbean
.
sendMail
(
msg
);
eventUserFacade
.
flush
();
eventUserFacade
.
flush
();
eventUserFacade
.
evict
(
bill
.
getUser
());
eventUserFacade
.
evict
(
bill
.
getUser
());
return
bill
;
}
}
@Override
@Override
@RolesAllowed
({
BillPermission
.
S_CREATE_BILL
,
BillPermission
.
S_WRITE_ALL
})
@RolesAllowed
({
BillPermission
.
S_CREATE_BILL
,
BillPermission
.
S_WRITE_ALL
})
public
void
createBill
(
Bill
bill
)
{
public
Bill
createBill
(
Bill
bill
)
{
if
(!
permbean
.
isCurrentUser
(
bill
.
getUser
())
&&
!
permbean
.
hasPermission
(
BillPermission
.
WRITE_ALL
))
{
if
(!
permbean
.
isCurrentUser
(
bill
.
getUser
())
&&
!
permbean
.
hasPermission
(
BillPermission
.
WRITE_ALL
))
{
loggingBean
.
logMessage
(
SecurityLogType
.
permissionDenied
,
permbean
.
getCurrentUser
(),
"Not enought rights to create bill for user "
);
loggingBean
.
logMessage
(
SecurityLogType
.
permissionDenied
,
permbean
.
getCurrentUser
(),
"Not enought rights to create bill for user "
);
throw
new
EJBAccessException
(
"Could not create bill for another user"
);
throw
new
EJBAccessException
(
"Could not create bill for another user"
);
}
}
billFacade
.
create
(
bill
);
billFacade
.
create
(
bill
);
generateBillNumber
(
bill
);
generateBillNumber
(
bill
);
return
bill
;
}
}
@RolesAllowed
({
BillPermission
.
S_WRITE_ALL
})
@RolesAllowed
({
BillPermission
.
S_WRITE_ALL
})
...
...
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/BillBeanLocal.java
View file @
af57bbd
...
@@ -26,11 +26,11 @@ public interface BillBeanLocal {
...
@@ -26,11 +26,11 @@ public interface BillBeanLocal {
Collection
<
BillSummary
>
getBillLineSummary
();
Collection
<
BillSummary
>
getBillLineSummary
();
void
markPaid
(
Bill
bill
,
Calendar
when
);
Bill
markPaid
(
Bill
bill
,
Calendar
when
);
void
getPdfBillStream
(
Bill
bill
,
OutputStream
ostream
);
void
getPdfBillStream
(
Bill
bill
,
OutputStream
ostream
);
void
createBill
(
Bill
bill
);
Bill
createBill
(
Bill
bill
);
Bill
save
(
Bill
bill
);
Bill
save
(
Bill
bill
);
...
...
code/LanBortalDatabase/src/fi/insomnia/bortal/model/Bill.java
View file @
af57bbd
...
@@ -160,6 +160,10 @@ public class Bill extends GenericEntity {
...
@@ -160,6 +160,10 @@ public class Bill extends GenericEntity {
}
}
return
total
;
return
total
;
}
}
public
BigDecimal
getTotalPrice
()
{
return
this
.
totalPrice
();
}
/**
/**
* Commodity function to calculate the total price of the bill.
* Commodity function to calculate the total price of the bill.
...
...
code/LanBortalWeb/WebContent/foodmanager/listOrders.xhtml
View file @
af57bbd
<!DOCTYPE html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:h=
"http://java.sun.com/jsf/html"
...
@@ -25,14 +23,14 @@
...
@@ -25,14 +23,14 @@
</ui:define>
</ui:define>
<ui:define
name=
"content"
>
<ui:define
name=
"content"
>
<p:dataTable
styleClass=
"bordertable"
<h:form>
value=
"#{foodWaveView.unpaidBill
s}"
var=
"bill_line"
>
<p:dataTable
styleClass=
"bordertable"
value=
"#{foodWaveView.billLine
s}"
var=
"bill_line"
>
<f:facet
name=
"header"
>
<f:facet
name=
"header"
>
${i18n['foodWave.billLines']}
<h:outputLabel
value=
"#{i18n['foodWave.billLines']}"
/>
</f:facet>
</f:facet>
<p:column>
<p:column>
<f:facet
name=
"header"
>
<f:facet
name=
"header"
>
<h:outputLabel
id=
"name"
value=
"$
{i18n['billLine.time']}"
/>
<h:outputLabel
value=
"#
{i18n['billLine.time']}"
/>
</f:facet>
</f:facet>
<h:outputText
value=
"#{bill_line.bill.sentDate.getTime()}"
>
<h:outputText
value=
"#{bill_line.bill.sentDate.getTime()}"
>
<f:convertDateTime
pattern=
"hh:mm d/M/yy"
/>
<f:convertDateTime
pattern=
"hh:mm d/M/yy"
/>
...
@@ -40,19 +38,19 @@
...
@@ -40,19 +38,19 @@
</p:column>
</p:column>
<p:column>
<p:column>
<f:facet
name=
"header"
>
<f:facet
name=
"header"
>
<h:outputLabel
id=
"name"
value=
"$
{i18n['billLine.quantity']}"
/>
<h:outputLabel
value=
"#
{i18n['billLine.quantity']}"
/>
</f:facet>
</f:facet>
<h:outputText
value=
"#{bill_line.quantity}"
/>
<h:outputText
value=
"#{bill_line.quantity}"
/>
</p:column>
</p:column>
<p:column>
<p:column>
<f:facet
name=
"header"
>
<f:facet
name=
"header"
>
<h:outputLabel
id=
"name"
value=
"$
{i18n['billLine.product']}"
/>
<h:outputLabel
value=
"#
{i18n['billLine.product']}"
/>
</f:facet>
</f:facet>
<h:outputText
value=
"#{bill_line.name}"
/>
<h:outputText
value=
"#{bill_line.name}"
/>
</p:column>
</p:column>
<p:column>
<p:column>
<f:facet
name=
"header"
>
<f:facet
name=
"header"
>
<h:outputLabel
id=
"name"
value=
"
$
{i18n['billLine.eventuser']}"
/>
<h:outputLabel
id=
"name"
value=
"
#
{i18n['billLine.eventuser']}"
/>
</f:facet>
</f:facet>
<h:link
outcome=
"/useradmin/edit"
<h:link
outcome=
"/useradmin/edit"
value=
"#{bill_line.bill.user.wholeName}"
>
value=
"#{bill_line.bill.user.wholeName}"
>
...
@@ -61,19 +59,35 @@
...
@@ -61,19 +59,35 @@
</p:column>
</p:column>
<p:column>
<p:column>
<f:facet
name=
"header"
>
<f:facet
name=
"header"
>
<h:outputLabel
id=
"name"
value=
"$
{i18n['billLine.price']}"
/>
<h:outputLabel
value=
"#
{i18n['billLine.price']}"
/>
</f:facet>
</f:facet>
<h:outputText
value=
"#{bill_line.linePrice}"
/>
<h:outputText
value=
"#{bill_line.linePrice}"
/>
</p:column>
</p:column>
</p:dataTable>
<br/>
<p:column>
<br/>
<f:facet
name=
"header"
>
<h:outputLabel
value=
"#{i18n['bill.totalprice']}"
/>
</f:facet>
<h:outputText
value=
"#{bill_line.bill.totalPrice}"
/>
</p:column>
<p:column>
<h:commandButton
value=
"#{i18n['bill.markPaid']}"
action=
"#{foodWaveView.markBillPaid}"
/>
</p:column>
<!--
<p:column>
<h:commandButton value="#{i18n['bill.remove']}" action="foodWaveView.markBillRemoved" />
</p:column> -->
</p:dataTable>
<br
/>
<br
/>
<!--
<p:dataTable styleClass="bordertable"
<p:dataTable styleClass="bordertable"
value="#{foodWaveView.accountEventLines}" var="acc_lines">
value="#{foodWaveView.accountEventLines}" var="acc_lines">
<f:facet name="header">
<f:facet name="header">
${i18n['foodWave.accountevents']}
<h:outputLabel value="#{i18n['foodWave.accountevents']}" />
</f:facet>
</f:facet>
<p:column>
<p:column>
<f:facet name="header">
<f:facet name="header">
<h:outputLabel id="name" value="${i18n['acc_lines.time']}" />
<h:outputLabel id="name" value="${i18n['acc_lines.time']}" />
...
@@ -111,7 +125,9 @@
...
@@ -111,7 +125,9 @@
</p:column>
</p:column>
</p:dataTable>
</p:dataTable>
-->
</h:form>
</ui:define>
</ui:define>
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/FoodWaveView.java
View file @
af57bbd
...
@@ -3,7 +3,6 @@ package fi.insomnia.bortal.web.cdiview.shop;
...
@@ -3,7 +3,6 @@ package fi.insomnia.bortal.web.cdiview.shop;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.TreeSet
;
import
java.util.TreeSet
;
...
@@ -13,11 +12,14 @@ import javax.faces.model.ListDataModel;
...
@@ -13,11 +12,14 @@ import javax.faces.model.ListDataModel;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
fi.insomnia.bortal.beans.BillBeanLocal
;
import
fi.insomnia.bortal.beans.EventBeanLocal
;
import
fi.insomnia.bortal.beans.EventBeanLocal
;
import
fi.insomnia.bortal.beans.FoodWaveBeanLocal
;
import
fi.insomnia.bortal.beans.FoodWaveBeanLocal
;
import
fi.insomnia.bortal.beans.ProductBeanLocal
;
import
fi.insomnia.bortal.beans.ProductBeanLocal
;
import
fi.insomnia.bortal.enums.apps.BillPermission
;
import
fi.insomnia.bortal.enums.apps.ShopPermission
;
import
fi.insomnia.bortal.enums.apps.ShopPermission
;
import
fi.insomnia.bortal.model.AccountEvent
;
import
fi.insomnia.bortal.model.AccountEvent
;
import
fi.insomnia.bortal.model.Bill
;
import
fi.insomnia.bortal.model.BillLine
;
import
fi.insomnia.bortal.model.BillLine
;
import
fi.insomnia.bortal.model.FoodWave
;
import
fi.insomnia.bortal.model.FoodWave
;
import
fi.insomnia.bortal.model.FoodWaveTemplate
;
import
fi.insomnia.bortal.model.FoodWaveTemplate
;
...
@@ -42,6 +44,8 @@ public class FoodWaveView extends GenericCDIView {
...
@@ -42,6 +44,8 @@ public class FoodWaveView extends GenericCDIView {
private
EventBeanLocal
eventbean
;
private
EventBeanLocal
eventbean
;
@EJB
@EJB
private
ProductBeanLocal
productbeanlocal
;
private
ProductBeanLocal
productbeanlocal
;
@EJB
private
BillBeanLocal
billbean
;
private
FoodWave
selectedFoodWave
=
null
;
private
FoodWave
selectedFoodWave
=
null
;
...
@@ -49,7 +53,7 @@ public class FoodWaveView extends GenericCDIView {
...
@@ -49,7 +53,7 @@ public class FoodWaveView extends GenericCDIView {
private
Product
currentProduct
;
private
Product
currentProduct
;
private
ListDataModel
<
BillLine
>
billLines
;
private
ListDataModel
<
BillLine
>
billLines
;
private
List
<
BillLine
>
unpaidBills
;
//
private List<BillLine> unpaidBills;
private
Integer
foodWaveId
;
private
Integer
foodWaveId
;
private
ListDataModel
<
AccountEvent
>
accountEventLines
;
private
ListDataModel
<
AccountEvent
>
accountEventLines
;
...
@@ -162,21 +166,43 @@ public class FoodWaveView extends GenericCDIView {
...
@@ -162,21 +166,43 @@ public class FoodWaveView extends GenericCDIView {
// ListDataModel<FoodWave>(foodWaveBean.getEventFoodWaves());
// ListDataModel<FoodWave>(foodWaveBean.getEventFoodWaves());
// }
// }
public
String
markBillPaid
()
{
if
(
permbean
.
hasPermission
(
BillPermission
.
WRITE_ALL
)
&&
getBillLines
().
isRowAvailable
())
{
Bill
b
=
getBillLines
().
getRowData
().
getBill
();
b
=
getBillbean
().
markPaid
(
b
,
Calendar
.
getInstance
());
}
return
null
;
}
public
String
markBillRemoved
()
{
if
(
permbean
.
hasPermission
(
BillPermission
.
WRITE_ALL
)
&&
getBillLines
().
isRowAvailable
())
{
Bill
b
=
getBillLines
().
getRowData
().
getBill
();
getBillbean
().
markPaid
(
b
,
Calendar
.
getInstance
());
}
return
null
;
}
public
void
initFoodWaveOrderList
()
{
public
void
initFoodWaveOrderList
()
{
if
(
super
.
requirePermissions
(
ShopPermission
.
MANAGE_FOODWAVES
)
&&
selectedFoodWave
==
null
)
{
if
(
super
.
requirePermissions
(
ShopPermission
.
MANAGE_FOODWAVES
)
&&
selectedFoodWave
==
null
)
{
selectedFoodWave
=
foodWaveBean
.
findFoodwave
(
foodWaveId
);
selectedFoodWave
=
foodWaveBean
.
findFoodwave
(
foodWaveId
);
billLines
=
new
ListDataModel
<
BillLine
>(
selectedFoodWave
.
getBillLines
());
this
.
setAccountEventLines
(
new
ListDataModel
<
AccountEvent
>(
selectedFoodWave
.
getAccountEvents
()));
this
.
setAccountEventLines
(
new
ListDataModel
<
AccountEvent
>(
selectedFoodWave
.
getAccountEvents
()));
setUnpaidBills
(
new
ArrayList
<
BillLine
>());
List
<
BillLine
>
tmpLines
=
new
ArrayList
<
BillLine
>();
Iterator
<
BillLine
>
biterator
=
billLines
.
iterator
();
while
(
biterator
.
hasNext
())
{
for
(
BillLine
line
:
selectedFoodWave
.
getBillLines
())
{
BillLine
unpaidBill
=
biterator
.
next
();
if
(
line
.
getBill
().
isPaid
())
{
if
(
unpaidBill
.
getBill
().
isPaid
())
tmpLines
.
add
(
line
);
this
.
getUnpaidBills
().
add
(
unpaidBill
);
}
}
}
setBillLines
(
new
ListDataModel
<
BillLine
>(
tmpLines
));
super
.
beginConversation
();
super
.
beginConversation
();
}
}
...
@@ -261,13 +287,19 @@ public class FoodWaveView extends GenericCDIView {
...
@@ -261,13 +287,19 @@ public class FoodWaveView extends GenericCDIView {
public
void
setAccountEventLines
(
ListDataModel
<
AccountEvent
>
accountEventLines
)
{
public
void
setAccountEventLines
(
ListDataModel
<
AccountEvent
>
accountEventLines
)
{
this
.
accountEventLines
=
accountEventLines
;
this
.
accountEventLines
=
accountEventLines
;
}
}
/*
* public List<BillLine> getUnpaidBills() { return unpaidBills; }
*
* public void setUnpaidBills(List<BillLine> unpaidBills) { this.unpaidBills
* = unpaidBills; }
*/
public
List
<
BillLine
>
getUnpaidBills
()
{
public
BillBeanLocal
getBillbean
()
{
return
unpaidBills
;
return
billbean
;
}
}
public
void
set
UnpaidBills
(
List
<
BillLine
>
unpaidBills
)
{
public
void
set
Billbean
(
BillBeanLocal
billbean
)
{
this
.
unpaidBills
=
unpaidBills
;
this
.
billbean
=
billbean
;
}
}
}
}
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