bills for foodwaves

1 parent ab9d6a3c
......@@ -200,7 +200,7 @@ public class BillBean implements BillBeanLocal {
@Override
@RolesAllowed({ BillPermission.S_WRITE_ALL,
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) {
throw new EJBException("Bill already marked paid!");
......@@ -249,17 +249,20 @@ public class BillBean implements BillBeanLocal {
utilbean.sendMail(msg);
eventUserFacade.flush();
eventUserFacade.evict(bill.getUser());
return bill;
}
@Override
@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)) {
loggingBean.logMessage(SecurityLogType.permissionDenied, permbean.getCurrentUser(), "Not enought rights to create bill for user ");
throw new EJBAccessException("Could not create bill for another user");
}
billFacade.create(bill);
generateBillNumber(bill);
return bill;
}
@RolesAllowed({ BillPermission.S_WRITE_ALL })
......
......@@ -26,11 +26,11 @@ public interface BillBeanLocal {
Collection<BillSummary> getBillLineSummary();
void markPaid(Bill bill, Calendar when);
Bill markPaid(Bill bill, Calendar when);
void getPdfBillStream(Bill bill, OutputStream ostream);
void createBill(Bill bill);
Bill createBill(Bill bill);
Bill save(Bill bill);
......
......@@ -160,6 +160,10 @@ public class Bill extends GenericEntity {
}
return total;
}
public BigDecimal getTotalPrice() {
return this.totalPrice();
}
/**
* Commodity function to calculate the total price of the bill.
......
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html 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"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
......@@ -25,14 +23,14 @@
</ui:define>
<ui:define name="content">
<p:dataTable styleClass="bordertable"
value="#{foodWaveView.unpaidBills}" var="bill_line">
<h:form>
<p:dataTable styleClass="bordertable" value="#{foodWaveView.billLines}" var="bill_line">
<f:facet name="header">
${i18n['foodWave.billLines']}
</f:facet>
<h:outputLabel value="#{i18n['foodWave.billLines']}" />
</f:facet>
<p:column>
<f:facet name="header">
<h:outputLabel id="name" value="${i18n['billLine.time']}" />
<h:outputLabel value="#{i18n['billLine.time']}" />
</f:facet>
<h:outputText value="#{bill_line.bill.sentDate.getTime()}">
<f:convertDateTime pattern="hh:mm d/M/yy" />
......@@ -40,19 +38,19 @@
</p:column>
<p:column>
<f:facet name="header">
<h:outputLabel id="name" value="${i18n['billLine.quantity']}" />
<h:outputLabel value="#{i18n['billLine.quantity']}" />
</f:facet>
<h:outputText value="#{bill_line.quantity}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputLabel id="name" value="${i18n['billLine.product']}" />
<h:outputLabel value="#{i18n['billLine.product']}" />
</f:facet>
<h:outputText value="#{bill_line.name}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputLabel id="name" value="${i18n['billLine.eventuser']}" />
<h:outputLabel id="name" value="#{i18n['billLine.eventuser']}" />
</f:facet>
<h:link outcome="/useradmin/edit"
value="#{bill_line.bill.user.wholeName}">
......@@ -61,19 +59,35 @@
</p:column>
<p:column>
<f:facet name="header">
<h:outputLabel id="name" value="${i18n['billLine.price']}" />
<h:outputLabel value="#{i18n['billLine.price']}" />
</f:facet>
<h:outputText value="#{bill_line.linePrice}" />
</p:column>
</p:dataTable>
<br/>
<br/>
<p:column>
<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"
value="#{foodWaveView.accountEventLines}" var="acc_lines">
<f:facet name="header">
${i18n['foodWave.accountevents']}
</f:facet>
<h:outputLabel value="#{i18n['foodWave.accountevents']}" />
</f:facet>
<p:column>
<f:facet name="header">
<h:outputLabel id="name" value="${i18n['acc_lines.time']}" />
......@@ -111,7 +125,9 @@
</p:column>
</p:dataTable>
-->
</h:form>
</ui:define>
......
......@@ -3,7 +3,6 @@ package fi.insomnia.bortal.web.cdiview.shop;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.TreeSet;
......@@ -13,11 +12,14 @@ import javax.faces.model.ListDataModel;
import javax.inject.Inject;
import javax.inject.Named;
import fi.insomnia.bortal.beans.BillBeanLocal;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.FoodWaveBeanLocal;
import fi.insomnia.bortal.beans.ProductBeanLocal;
import fi.insomnia.bortal.enums.apps.BillPermission;
import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.model.AccountEvent;
import fi.insomnia.bortal.model.Bill;
import fi.insomnia.bortal.model.BillLine;
import fi.insomnia.bortal.model.FoodWave;
import fi.insomnia.bortal.model.FoodWaveTemplate;
......@@ -42,6 +44,8 @@ public class FoodWaveView extends GenericCDIView {
private EventBeanLocal eventbean;
@EJB
private ProductBeanLocal productbeanlocal;
@EJB
private BillBeanLocal billbean;
private FoodWave selectedFoodWave = null;
......@@ -49,7 +53,7 @@ public class FoodWaveView extends GenericCDIView {
private Product currentProduct;
private ListDataModel<BillLine> billLines;
private List<BillLine> unpaidBills;
// private List<BillLine> unpaidBills;
private Integer foodWaveId;
private ListDataModel<AccountEvent> accountEventLines;
......@@ -162,21 +166,43 @@ public class FoodWaveView extends GenericCDIView {
// 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() {
if (super.requirePermissions(ShopPermission.MANAGE_FOODWAVES) && selectedFoodWave == null) {
selectedFoodWave = foodWaveBean.findFoodwave(foodWaveId);
billLines = new ListDataModel<BillLine>(selectedFoodWave.getBillLines());
this.setAccountEventLines(new ListDataModel<AccountEvent>(selectedFoodWave.getAccountEvents()));
setUnpaidBills(new ArrayList<BillLine>());
Iterator<BillLine> biterator = billLines.iterator();
while (biterator.hasNext()) {
BillLine unpaidBill = biterator.next();
if (unpaidBill.getBill().isPaid())
this.getUnpaidBills().add(unpaidBill);
}
List<BillLine> tmpLines = new ArrayList<BillLine>();
for (BillLine line : selectedFoodWave.getBillLines()) {
if (line.getBill().isPaid()) {
tmpLines.add(line);
}
}
setBillLines(new ListDataModel<BillLine>(tmpLines));
super.beginConversation();
}
......@@ -261,13 +287,19 @@ public class FoodWaveView extends GenericCDIView {
public void setAccountEventLines(ListDataModel<AccountEvent> accountEventLines) {
this.accountEventLines = accountEventLines;
}
/*
* public List<BillLine> getUnpaidBills() { return unpaidBills; }
*
* public void setUnpaidBills(List<BillLine> unpaidBills) { this.unpaidBills
* = unpaidBills; }
*/
public List<BillLine> getUnpaidBills() {
return unpaidBills;
public BillBeanLocal getBillbean() {
return billbean;
}
public void setUnpaidBills(List<BillLine> unpaidBills) {
this.unpaidBills = unpaidBills;
public void setBillbean(BillBeanLocal billbean) {
this.billbean = billbean;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!