Commit d8aa668e by Tuomas Riihimäki

Merge branch 'insomnia_2014' of gitlab.codecrew.fi:codecrew/moya into ins16

2 parents 3900e062 e788d87d
Showing with 549 additions and 94 deletions
...@@ -27,6 +27,7 @@ import java.util.List; ...@@ -27,6 +27,7 @@ import java.util.List;
import javax.ejb.Local; import javax.ejb.Local;
import fi.codecrew.moya.bortal.views.BillSummary; import fi.codecrew.moya.bortal.views.BillSummary;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.Bill; import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.FoodWave; import fi.codecrew.moya.model.FoodWave;
...@@ -47,7 +48,7 @@ public interface BillBeanLocal { ...@@ -47,7 +48,7 @@ public interface BillBeanLocal {
Collection<BillSummary> getBillLineSummary(); Collection<BillSummary> getBillLineSummary();
Bill markPaid(Bill bill, Calendar when); Bill markPaid(Bill bill, Calendar when, boolean useCredits) throws BillException;
void getPdfBillStream(Bill bill, OutputStream ostream); void getPdfBillStream(Bill bill, OutputStream ostream);
......
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package fi.codecrew.moya.exceptions;
public class BillException extends Exception {
public BillException(String x) {
super(x);
}
/**
*
*/
private static final long serialVersionUID = 4744284457862674051L;
}
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package fi.codecrew.moya.exceptions;
public class BillExceptionAlreadyPaid extends BillException {
public BillExceptionAlreadyPaid(String ex) {
super(ex);
}
/**
*
*/
private static final long serialVersionUID = 4744284457862674051L;
}
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package fi.codecrew.moya.exceptions;
public class BillExceptionNotEnoughtCredits extends BillException {
public BillExceptionNotEnoughtCredits(String x) {
super(x);
}
/**
*
*/
private static final long serialVersionUID = 4744284457862674051L;
}
...@@ -20,7 +20,6 @@ package fi.codecrew.moya.beans; ...@@ -20,7 +20,6 @@ package fi.codecrew.moya.beans;
import java.io.OutputStream; import java.io.OutputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
...@@ -33,6 +32,8 @@ import javax.ejb.EJBAccessException; ...@@ -33,6 +32,8 @@ import javax.ejb.EJBAccessException;
import javax.ejb.EJBException; import javax.ejb.EJBException;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -42,6 +43,9 @@ import fi.codecrew.moya.bortal.views.BillSummary; ...@@ -42,6 +43,9 @@ import fi.codecrew.moya.bortal.views.BillSummary;
import fi.codecrew.moya.enums.apps.BillPermission; import fi.codecrew.moya.enums.apps.BillPermission;
import fi.codecrew.moya.enums.apps.ShopPermission; import fi.codecrew.moya.enums.apps.ShopPermission;
import fi.codecrew.moya.enums.apps.SpecialPermission; import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.exceptions.BillExceptionAlreadyPaid;
import fi.codecrew.moya.exceptions.BillExceptionNotEnoughtCredits;
import fi.codecrew.moya.facade.BillFacade; import fi.codecrew.moya.facade.BillFacade;
import fi.codecrew.moya.facade.BillLineFacade; import fi.codecrew.moya.facade.BillLineFacade;
import fi.codecrew.moya.facade.EventUserFacade; import fi.codecrew.moya.facade.EventUserFacade;
...@@ -52,10 +56,8 @@ import fi.codecrew.moya.model.Discount; ...@@ -52,10 +56,8 @@ import fi.codecrew.moya.model.Discount;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.FoodWave; import fi.codecrew.moya.model.FoodWave;
import fi.codecrew.moya.model.LanEvent; import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.LanEventPropertyKey;
import fi.codecrew.moya.model.Product; import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.model.ProductFlag; import fi.codecrew.moya.model.ProductFlag;
import fi.codecrew.moya.util.MailMessage;
/** /**
* Session Bean implementation class BillBean * Session Bean implementation class BillBean
...@@ -102,7 +104,7 @@ public class BillBean implements BillBeanLocal { ...@@ -102,7 +104,7 @@ public class BillBean implements BillBeanLocal {
* Default constructor. * Default constructor.
*/ */
public BillBean() { public BillBean() {
// TODO Auto-generated constructor stub
} }
@Override @Override
...@@ -227,42 +229,76 @@ public class BillBean implements BillBeanLocal { ...@@ -227,42 +229,76 @@ public class BillBean implements BillBeanLocal {
return ret; return ret;
} }
@Override
@RolesAllowed({ BillPermission.S_WRITE_ALL,
SpecialPermission.S_VERKKOMAKSU_CHECK })
public Bill markPaid(Bill bill, Calendar when) {
/**
* We will mark bill paid in different transaction. That's because we don't wont it to fail if something other fails.
*
* @param bill
* @param when
* @param useCredits
* @return
* @throws BillException
*/
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
private Bill markPaidSafeTransaction(Bill bill, Calendar when, boolean useCredits) throws BillException {
bill = billFacade.reload(bill); bill = billFacade.reload(bill);
if (bill.getAccountEvent() != null || bill.getPaidDate() != null) { if (bill.getAccountEvent() != null || bill.getPaidDate() != null) {
logbean.logMessage(SecurityLogType.bill, permbean.getCurrentUser(), "Trying to doublemark bill paid"); logbean.logMessage(SecurityLogType.bill, permbean.getCurrentUser(), "Trying to doublemark bill paid", bill.getId());
throw new EJBException("Bill already marked paid!"); throw new BillExceptionAlreadyPaid("Trying to mark bill paid, already paid, BillID: "+bill.getId());
}
if (bill.isFoowavePaymentOver() && !permbean.hasPermission(ShopPermission.MANAGE_FOODWAVES))
{
logbean.logMessage(SecurityLogType.bill, permbean.getCurrentUser(), "FoodwaveClosed and marking bill for it paid");
throw new EJBException("Trying to mark paid a closed or left foodwave");
} }
Product creditproduct = productBean.findCreditProduct(); Product creditproduct = productBean.findCreditProduct();
EventUser user = bill.getUser(); EventUser user = bill.getUser();
if(useCredits) {
// check if there is enought credits
if(bill.getUser().getAccountBalance().compareTo(bill.getTotalPrice()) < 1) {
logbean.logMessage(SecurityLogType.bill, permbean.getCurrentUser(), "Trying to pay bill with accountevents, and there is no saldo, billid: ", bill.getId());
throw new BillExceptionNotEnoughtCredits("There is not enought credits to pay. , BillID: "+bill.getId());
}
} else {
AccountEvent ac = productBean.createAccountEvent(creditproduct, bill.totalPrice(), user); AccountEvent ac = productBean.createAccountEvent(creditproduct, bill.totalPrice(), user);
logger.info("Created creditentry. {}, userproducts {}", ac, user.getAccountEvents().size()); logger.info("Created creditentry. {}, userproducts {}", ac, user.getAccountEvents().size());
// Used in foodwave. Should be null!
// ac.setDelivered(when);
ac.setEventTime(when); ac.setEventTime(when);
ac.setBill(bill); ac.setBill(bill);
ac.setSeller(permbean.getCurrentUser()); ac.setSeller(permbean.getCurrentUser());
bill.setAccountEvent(ac); bill.setAccountEvent(ac);
}
bill.setPaidDate(when.getTime()); bill.setPaidDate(when.getTime());
return bill;
}
@Override
@RolesAllowed({ BillPermission.S_WRITE_ALL,
SpecialPermission.S_VERKKOMAKSU_CHECK })
public Bill markPaid(Bill bill, Calendar when, boolean useCredits) throws BillException {
bill = markPaidSafeTransaction(bill, when,useCredits);
EventUser user = bill.getUser();
if (bill.isFoowavePaymentOver() && !permbean.hasPermission(ShopPermission.MANAGE_FOODWAVES))
{
logbean.logMessage(SecurityLogType.bill, permbean.getCurrentUser(), "FoodwaveClosed and marking bill for it paid");
throw new EJBException("Trying to mark paid a closed or left foodwave");
}
// bill = billFacade.merge(bill); // bill = billFacade.merge(bill);
for (BillLine bl : bill.getBillLines()) { for (BillLine bl : bill.getBillLines()) {
...@@ -278,9 +314,10 @@ public class BillBean implements BillBeanLocal { ...@@ -278,9 +314,10 @@ public class BillBean implements BillBeanLocal {
ac2.setSeller(permbean.getCurrentUser()); ac2.setSeller(permbean.getCurrentUser());
} }
} }
billFacade.flush();
/* /*
MailMessage msg = new MailMessage(); MailMessage msg = new MailMessage();
......
...@@ -27,6 +27,7 @@ import javax.ejb.Stateless; ...@@ -27,6 +27,7 @@ import javax.ejb.Stateless;
import fi.codecrew.moya.beans.BillBeanLocal; import fi.codecrew.moya.beans.BillBeanLocal;
import fi.codecrew.moya.enums.apps.SpecialPermission; import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.Bill; import fi.codecrew.moya.model.Bill;
@Stateless @Stateless
...@@ -38,7 +39,12 @@ public class VerkkomaksuRunner { ...@@ -38,7 +39,12 @@ public class VerkkomaksuRunner {
private BillBeanLocal billbean; private BillBeanLocal billbean;
public void markPaid(Bill bill, Calendar when) { public void markPaid(Bill bill, Calendar when) {
billbean.markPaid(bill, when); try {
billbean.markPaid(bill, when, false);
} catch (BillException x) {
throw new RuntimeException(x);
}
} }
} }
...@@ -429,6 +429,16 @@ public class Bill extends GenericEntity { ...@@ -429,6 +429,16 @@ public class Bill extends GenericEntity {
this.sentDate = sentDate; this.sentDate = sentDate;
} }
public boolean isFoodwaveBill() {
for (BillLine bl : billLines)
{
if (bl.getFoodwave() != null) {
return true;
}
}
return false;
}
public boolean isFoowavePaymentOver() { public boolean isFoowavePaymentOver() {
for (BillLine bl : billLines) for (BillLine bl : billLines)
{ {
...@@ -473,7 +483,7 @@ public class Bill extends GenericEntity { ...@@ -473,7 +483,7 @@ public class Bill extends GenericEntity {
if(l == null || l.getQuantity() == null) if(l == null || l.getQuantity() == null)
continue; continue;
total.add(l.getQuantity()); total = total.add(l.getQuantity());
} }
return total; return total;
......
...@@ -225,12 +225,11 @@ public class FoodWave extends GenericEntity { ...@@ -225,12 +225,11 @@ public class FoodWave extends GenericEntity {
public Integer getUnpaidCount() { public Integer getUnpaidCount() {
Integer ret = 0; Integer ret = 0;
for (BillLine line : getBillLines()) { for (BillLine line : getBillLines()) {
if (!line.getBill().isPaid()) { if (!line.getBill().isPaid() && !line.getBill().isExpired()) {
ret += line.getQuantity().intValue(); ret += line.getQuantity().intValue();
} }
} }
return ret; return ret;
} }
public Integer getOrderedCount() { public Integer getOrderedCount() {
......
...@@ -24,6 +24,22 @@ ...@@ -24,6 +24,22 @@
<param-value>Development</param-value> <param-value>Development</param-value>
</context-param> </context-param>
<!-- Add req.remoteHost, req.xForwardedFor, req.requestURI, req.requestURL,
req.queryString and req.userAgent to logger MDC -->
<filter>
<filter-name>MDCInsertingServletFilter</filter-name>
<filter-class>fi.codecrew.moya.RobustFilterProxy</filter-class>
<init-param>
<param-name>wrapped-class</param-name>
<param-value>ch.qos.logback.classic.helpers.MDCInsertingServletFilter
</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>MDCInsertingServletFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter> <filter>
<display-name>PrimefacesFileupload</display-name> <display-name>PrimefacesFileupload</display-name>
<filter-name>PrimefacesFileupload</filter-name> <filter-name>PrimefacesFileupload</filter-name>
...@@ -54,17 +70,9 @@ ...@@ -54,17 +70,9 @@
<url-pattern>*.jsf</url-pattern> <url-pattern>*.jsf</url-pattern>
</servlet-mapping> </servlet-mapping>
<!-- <!-- <servlet> <servlet-name>ViewStatusMessages</servlet-name> <servlet-class>ch.qos.logback.classic.ViewStatusMessagesServlet
<servlet> </servlet-class> </servlet> <servlet-mapping> <servlet-name>ViewStatusMessages</servlet-name>
<servlet-name>ViewStatusMessages</servlet-name> <url-pattern>/logback</url-pattern> </servlet-mapping> -->
<servlet-class>ch.qos.logback.classic.ViewStatusMessagesServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ViewStatusMessages</servlet-name>
<url-pattern>/logback</url-pattern>
</servlet-mapping>
-->
<session-config> <session-config>
<session-timeout>120</session-timeout> <session-timeout>120</session-timeout>
......
...@@ -62,6 +62,10 @@ ...@@ -62,6 +62,10 @@
</ui:fragment> </ui:fragment>
<p:outputPanel rendered="#{billEditView.bill.foodwaveBill}">
<span class="notify"><h:outputText value="#{i18n['foodshop.canBuyToCounter']}" /></span>
</p:outputPanel>
<br />
<p:outputPanel rendered="#{!billEditView.bill.paid and !billEditView.bill.expired}"> <p:outputPanel rendered="#{!billEditView.bill.paid and !billEditView.bill.expired}">
<h:form> <h:form>
<p:commandButton id="cancelbtn" actionListener="#{billEditView.expireBill()}" onerror="location.reload(true);" value="#{i18n['bill.cancel']}" update=":billPanel"> <p:commandButton id="cancelbtn" actionListener="#{billEditView.expireBill()}" onerror="location.reload(true);" value="#{i18n['bill.cancel']}" update=":billPanel">
...@@ -70,6 +74,13 @@ ...@@ -70,6 +74,13 @@
</h:form> </h:form>
</p:outputPanel> </p:outputPanel>
<p:outputPanel rendered="#{billEditView.bill.user.accountBalance ge billEditView.bill.totalPrice}">
<h:form>
<p:commandButton id="buyCreditsButton" actionListener="#{billEditView.buyWithCredits()}" onerror="location.reload(true);" value="#{i18n['bill.markPaid.credits']}" update=":billPanel">
<p:confirm header="Confirmation" message="Are you sure?" icon="ui-icon-alert" />
</p:commandButton>
</h:form>
</p:outputPanel>
</p:outputPanel> </p:outputPanel>
</ui:define> </ui:define>
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<h:body> <h:body>
<!-- <c:if test="#{sessionHandler.isInDevelopmentMode() eq false}"> --> <!-- <c:if test="#{sessionHandler.isInDevelopmentMode() eq false}"> -->
<h1>#{i18n['error.error']}</h1> <h1>#{i18n['error.error']}</h1>
<h2>#{errorPageView.message}</h2>
<p>${i18n['error.contact']} <p>${i18n['error.contact']}
<br/><h:outputText escape="false" style="color: red;" value="#{errorPageView.time}" /><br/><br/> <br/><h:outputText escape="false" style="color: red;" value="#{errorPageView.time}" /><br/><br/>
<!-- Trail:<br/><h:outputText escape="false" style="color: red;" value="#{errorPageView.trail}" /> --> <!-- Trail:<br/><h:outputText escape="false" style="color: red;" value="#{errorPageView.trail}" /> -->
......
...@@ -37,7 +37,8 @@ ...@@ -37,7 +37,8 @@
<f:facet name="header"> <f:facet name="header">
<h:outputLabel value="#{i18n['acc_line.product']}" /> <h:outputLabel value="#{i18n['acc_line.product']}" />
</f:facet> </f:facet>
<h:outputText value="#{acc_line.product.name}" /> <h:outputText id="foodname" value="#{acc_line.product.name}" />
<p:tooltip rendered="#{acc_line.product.description != null}" for="foodname" value="#{acc_line.product.description}" showEffect="fade" hideEffect="fade" />
</p:column> </p:column>
<p:column sortBy="#{acc_line.user.wholeName}"> <p:column sortBy="#{acc_line.user.wholeName}">
<f:facet name="header"> <f:facet name="header">
...@@ -67,7 +68,10 @@ ...@@ -67,7 +68,10 @@
<br></br> <br></br>
<h:form id="billList"> <h:form id="billList">
<p:dataTable styleClass="bordertable" value="#{foodWaveView.bills}" var="bill" sortBy="#{bill.user.nick}">
<h:outputText rendered="#{foodWaveView.selectedFoodWave.paymentOver}" value="#{i18n['foodwave.closed']}" styleClass="notify" />
<p:dataTable styleClass="bordertable" value="#{foodWaveView.bills}" var="bill" sortBy="#{bill.user.nick}" rowStyleClass="#{bill.expired ? 'expired' : null}">
<f:facet name="header"> <f:facet name="header">
<h:outputLabel value="#{i18n['foodWave.billLines']}" /> <h:outputLabel value="#{i18n['foodWave.billLines']}" />
</f:facet> </f:facet>
...@@ -97,9 +101,7 @@ ...@@ -97,9 +101,7 @@
<f:facet name="header"> <f:facet name="header">
<h:outputLabel value="#{i18n['billLine.eventuser']}" /> <h:outputLabel value="#{i18n['billLine.eventuser']}" />
</f:facet> </f:facet>
<h:link outcome="/useradmin/edit" value="#{bill.user.wholeName}"> <h:outputText outcome="/useradmin/edit" value="#{bill.user.wholeName}" />
<f:param name="userid" value="#{bill.user.user.id}" />
</h:link>
</p:column> </p:column>
<p:column sortBy="#{bill.user.user.id}"> <p:column sortBy="#{bill.user.user.id}">
<f:facet name="header"> <f:facet name="header">
...@@ -117,40 +119,61 @@ ...@@ -117,40 +119,61 @@
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" /> <f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText> </h:outputText>
</p:column> </p:column>
<p:column> <p:column>
<p:commandButton value="#{i18n['bill.markPaid']}" actionListener="#{foodWaveView.markBillPaid}" update=":billList :accountEventList" />
<p:outputPanel rendered="#{bill.user.accountBalance ge bill.totalPrice}">
<p:commandButton rendered="#{not bill.expired and not foodWaveView.selectedFoodWave.paymentOver}" id="buyCreditsButton" onerror="location.reload(true);" value="#{i18n['bill.markPaid.credits']}" actionListener="#{foodWaveView.markBillPaidWithCredits}" update=":billList :accountEventList" />
<p:commandButton rendered="#{bill.expired or foodWaveView.selectedFoodWave.paymentOver}" value="#{i18n['bill.markPaid.credits']}" actionListener="#{foodWaveView.markBillPaidWithCredits}" update=":billList :accountEventList">
<p:confirm header="Confirmation" message="#{i18n['confirmation.message']}" icon="ui-icon-alert" />
</p:commandButton>
</p:outputPanel>
<p:commandButton rendered="#{not bill.expired and not foodWaveView.selectedFoodWave.paymentOver}" value="#{i18n['bill.markPaid.cash']}" actionListener="#{foodWaveView.markBillPaid}" update=":billList :accountEventList" />
<p:commandButton rendered="#{bill.expired or foodWaveView.selectedFoodWave.paymentOver}" value="#{i18n['bill.markPaid.cash']}" actionListener="#{foodWaveView.markBillPaid}" update=":billList :accountEventList">
<p:confirm header="Confirmation" message="#{i18n['confirmation.message']}" icon="ui-icon-alert" />
</p:commandButton>
</p:column> </p:column>
<!--
<p:column> <p:column>
<h:commandButton value="#{i18n['bill.remove']}" action="foodWaveView.markBillRemoved" /> <p:commandButton rendered="#{not bill.expired}" id="removeBill" value="#{i18n['foodwave.cancelOrder']}" actionListener="#{foodWaveView.markBillExpired}" update=":billList :accountEventList">
</p:column> --> <p:confirm header="Confirmation" message="#{i18n['confirmation.message']}" icon="ui-icon-alert" />
</p:commandButton>
</p:column>
</p:dataTable> </p:dataTable>
</h:form> </h:form>
<br /><br /><br /> <br />
<br />
<br />
<h2>#{i18n['foodwave.summaryView']}</h2> <h2>#{i18n['foodwave.summaryView']}</h2>
<p:panelGrid columns="2"> <p:panelGrid columns="2">
<h:outputLabel value="#{i18n['foodwave.price']}: " /> <h:outputLabel value="#{i18n['foodwave.price']}: " />
<h:outputText value="#{foodWaveView.foodwavePrice}" style="font-weight: bold" > <h:outputText value="#{foodWaveView.foodwavePrice}" style="font-weight: bold">
<f:convertNumber minFractionDigits="0"/> <f:convertNumber minFractionDigits="0" />
</h:outputText> </h:outputText>
<h:outputLabel value="#{i18n['foodwave.foodwaveBuyInPrice']}: " /> <h:outputLabel value="#{i18n['foodwave.foodwaveBuyInPrice']}: " />
<h:outputText value="#{foodWaveView.foodwaveBuyInPrice}" style="font-weight: bold" > <h:outputText value="#{foodWaveView.foodwaveBuyInPrice}" style="font-weight: bold">
<f:convertNumber minFractionDigits="0"/> <f:convertNumber minFractionDigits="0" />
</h:outputText> </h:outputText>
<h:outputLabel value="#{i18n['foodwave.ordersBefore']}: " /> <h:outputLabel value="#{i18n['foodwave.ordersBefore']}: " />
<h:outputText value="#{foodWaveView.selectedFoodWave.time}" style="font-weight: bold" > <h:outputText value="#{foodWaveView.selectedFoodWave.time}" style="font-weight: bold">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" />
</h:outputText> </h:outputText>
<h:outputLabel value="#{i18n['foodwave.foodwaveLastBillPayTime']}: " /> <h:outputLabel value="#{i18n['foodwave.foodwaveLastBillPayTime']}: " />
<h:outputText value="#{foodWaveView.selectedFoodWave.lastPaymentTime}" style="font-weight: bold" > <h:outputText value="#{foodWaveView.selectedFoodWave.lastPaymentTime}" style="font-weight: bold">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" />
</h:outputText> </h:outputText>
...@@ -161,7 +184,9 @@ ...@@ -161,7 +184,9 @@
<f:facet name="header"> <f:facet name="header">
<h:outputLabel value="#{i18n['product.name']}" /> <h:outputLabel value="#{i18n['product.name']}" />
</f:facet> </f:facet>
<h:outputText value="#{summ.product.name}" /> <h:outputText id="productName" value="#{summ.product.name}" />
<p:tooltip rendered="#{summ.product.description != null}" for="productName" value="#{summ.product.description}" showEffect="fade" hideEffect="fade" />
</p:column> </p:column>
<p:column> <p:column>
<f:facet name="header"> <f:facet name="header">
......
...@@ -23,8 +23,7 @@ ...@@ -23,8 +23,7 @@
<ui:define name="content"> <ui:define name="content">
<!-- products:shop commitaction="#{foodWaveFoodView.commitShoppingCart()}" items="#{foodWaveFoodView.shoppingcart}" commitValue="#{i18n['productshop.commit']}" /--> <!-- products:shop commitaction="#{foodWaveFoodView.commitShoppingCart()}" items="#{foodWaveFoodView.shoppingcart}" commitValue="#{i18n['productshop.commit']}" /-->
<foodwave:listFoods selectaction="#{foodWaveFoodView.buyFromCounter()}" <foodwave:listFoods selectaction="#{foodWaveFoodView.buyFromInternet()}" items="#{foodWaveFoodView.shoppingcart}" commitValue="foodshop.buyProceedToPay"/>
items="#{foodWaveFoodView.shoppingcart}" commitValue="foodshop.buyFromCounter"/>
</ui:define> </ui:define>
......
...@@ -28,10 +28,7 @@ ...@@ -28,10 +28,7 @@
<h1>Shop to user: #{userView.selectedUser.user.nick}</h1> <h1>Shop to user: #{userView.selectedUser.user.nick}</h1>
<br /><br /> <br /><br />
<foodwave:listFoods selectaction="#{foodWaveFoodView.buyAndPay}" selectCreditsAction="#{foodWaveFoodView.buyAndPayWithCredits}" items="#{foodWaveFoodView.shoppingcart}" commitValue="foodshop.buyAndPay" commitCreditsValue="foodshop.buyAndPayWithCredits"/>
<foodwave:listFoods selectaction="#{foodWaveFoodView.buyAndPay}" items="#{foodWaveFoodView.shoppingcart}" commitValue="foodshop.buyAndPay" />
</ui:define> </ui:define>
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<h:outputText value="${i18n['bill.sentDate']}" /> <h:outputText value="${i18n['bill.sentDate']}" />
</f:facet> </f:facet>
<h:outputText value="#{bill.sentDateTime}"> <h:outputText value="#{bill.sentDateTime}">
<f:convertDateTime pattern="#{sessionHandler.dateFormat}" timeZone="#{sessionHandler.timezone}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText> </h:outputText>
</p:column> </p:column>
<p:column> <p:column>
......
...@@ -15,13 +15,14 @@ ...@@ -15,13 +15,14 @@
<composite:attribute name="items" required="true" /> <composite:attribute name="items" required="true" />
<!-- <composite:attribute name="selectValue" required="true" /> --> <!-- <composite:attribute name="selectValue" required="true" /> -->
<composite:attribute name="selectaction" method-signature="java.lang.String action()" required="true" /> <composite:attribute name="selectaction" method-signature="java.lang.String action()" required="true" />
<composite:attribute name="selectCreditsAction" method-signature="java.lang.String action()" />
</composite:interface> </composite:interface>
<composite:implementation> <composite:implementation>
<h:outputScript library="primefaces" name="jquery/jquery.js" /> <h:outputScript library="primefaces" name="jquery/jquery.js" />
<h:form> <h:form styleClass="foodformselector">
<p:dataTable columnClasses="nowrap,numalign,numalign,nowrap,numalign" <p:dataTable columnClasses="nowrap,numalign,numalign,nowrap,numalign"
styleClass="bordertable" value="#{cc.attrs.items}" var="cart"> styleClass="bordertable" value="#{cc.attrs.items}" var="cart">
<!-- p:column> <!-- p:column>
...@@ -54,6 +55,17 @@ ...@@ -54,6 +55,17 @@
</p:column> </p:column>
<p:column> <p:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="${i18n['product.description']}" />
</f:facet>
<h:outputText id="description" value="#{cart.product.description}" />
<p:tooltip rendered="#{cart.product.name != null}" for="description" value="#{cart.product.name}" showEffect="fade" hideEffect="fade" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="${i18n['product.price']}" /> <h:outputText value="${i18n['product.price']}" />
</f:facet> </f:facet>
<h:outputText id="price" value="#{cart.product.price.abs()}"> <h:outputText id="price" value="#{cart.product.price.abs()}">
...@@ -73,28 +85,30 @@ ...@@ -73,28 +85,30 @@
<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="#{foodWaveFoodView.addMinusOne}" <p:commandButton actionListener="#{foodWaveFoodView.addMinusOne}" update="@(.foodformselector)"
value="#{i18n['productshop.minusOne']}"> value="#{i18n['productshop.minusOne']}" />
<f:ajax render="@form" />
</h:commandButton>
<h:inputText size="4" id="cartcount" value="#{cart.count}"> <h:inputText size="4" id="cartcount" value="#{cart.count}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="0" /> <f:convertNumber maxFractionDigits="2" minFractionDigits="0" />
</h:inputText> </h:inputText>
<h:commandButton action="#{foodWaveFoodView.addOne}" <p:commandButton actionListener="#{foodWaveFoodView.addOne}" update="@(.foodformselector)"
value="#{i18n['productshop.plusOne']}"> value="#{i18n['productshop.plusOne']}" />
<f:ajax render="@form" />
</h:commandButton>
</p:column> </p:column>
</p:dataTable> </p:dataTable>
<div> <div>
<h:outputLabel for="total" value="#{i18n['foodshop.total']}: "/> <h:outputLabel for="total" value="#{i18n['foodshop.total']}: "/>
<h:outputText id="total" value="#{foodWaveFoodView.totalPrice}" > <h:outputText id="total" value="#{foodWaveFoodView.totalPrice}" style="font-weight: bold;" >
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" /> <f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</h:outputText> </h:outputText>
</div> </div>
<h:commandButton action="#{cc.attrs.selectaction}" value="#{i18n[cc.attrs.commitValue]}" /> <br />
<h:commandButton action="#{foodWaveFoodView.buyFromInternet}" value="#{i18n['foodshop.buyFromInternet']}" />
<p:commandButton action="#{cc.attrs.selectaction}" value="#{i18n[cc.attrs.commitValue]}" ajax="false" />
<br />
<p:commandButton rendered="#{foodWaveFoodView.totalPrice le userView.selectedUser.accountBalance and not empty cc.attrs.selectCreditsAction}" action="#{cc.attrs.selectCreditsAction}" value="#{i18n[cc.attrs.commitCreditsValue]}" ajax="false" />
<!-- <h:commandButton action="#{foodWaveFoodView.buyFromInternet}" value="#{i18n['foodshop.buyFromInternet']}" /> -->
</h:form> </h:form>
......
...@@ -186,6 +186,10 @@ a.shopItem:active { ...@@ -186,6 +186,10 @@ a.shopItem:active {
color: red; color: red;
} }
.notify {
color: red;
}
.success { .success {
color: #006600; color: #006600;
} }
......
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
<ui:define name="content"> <ui:define name="content">
<!-- products:shop commitaction="#{foodWaveFoodView.commitShoppingCart()}" items="#{foodWaveFoodView.shoppingcart}" commitValue="#{i18n['productshop.commit']}" /--> <!-- products:shop commitaction="#{foodWaveFoodView.commitShoppingCart()}" items="#{foodWaveFoodView.shoppingcart}" commitValue="#{i18n['productshop.commit']}" /-->
<foodwave:listFoods selectaction="#{foodWaveFoodView.buyAndPay}"
items="#{foodWaveFoodView.shoppingcart}" commitValue="foodshop.buyAndPay"/> <foodwave:listFoods selectaction="#{foodWaveFoodView.buyAndPay}" selectCreditsAction="#{foodWaveFoodView.buyAndPayWithCredits}" items="#{foodWaveFoodView.shoppingcart}" commitValue="foodshop.buyAndPay" commitCreditsValue="foodshop.buyAndPayWithCredits"/>
</ui:define> </ui:define>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<configuration> <configuration>
<warSourceDirectory>WebContent</warSourceDirectory> <warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml> <failOnMissingWebXml>false</failOnMissingWebXml>
<packagingIncludes>WEB-INF/lib/javamelody-core*,WEB-INF/lib/primefaces*,**/*.xml,**/*.xhtml,**/*.properties,**/*.class,**/*.png,**/*.css,**/*.js,resources/*</packagingIncludes> <packagingIncludes>WEB-INF/lib/javamelody-core*,WEB-INF/lib/primefaces*,WEB-INF/lib/*-1.0.8.jar,**/*.xml,**/*.xhtml,**/*.properties,**/*.class,**/*.png,**/*.css,**/*.js,resources/*</packagingIncludes>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
......
package fi.codecrew.moya;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class LoggingContextFilter implements Filter {
public LoggingContextFilter() {
// TODO Auto-generated constructor stub
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
// TODO Auto-generated method stub
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
}
@Override
public void destroy() {
// TODO Auto-generated method stub
}
}
package fi.codecrew.moya;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Allows defining a filter in web.xml so, that deployment doesn't blow up if
* the class is not found. E.g. Logback specific filters when logback is a
* provided dependency.
*
* @author jkj
*
*/
public class RobustFilterProxy implements Filter {
Logger log = LoggerFactory.getLogger(RobustFilterProxy.class);
private Filter wrapped = null;
public RobustFilterProxy() {
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
try {
String filterClassName = filterConfig.getInitParameter("wrapped-class");
if (filterClassName == null) {
throw new ServletException("wrapped-class init-param required");
}
log.info("Wrapped class: " + filterClassName);
Class<?> wrappedFilterClass = this.getClass().getClassLoader().loadClass(filterClassName);
// Class<?> wrapperFilterClass = Class.forName(filterClassName);
log.debug("Wrapped filter class: " + wrappedFilterClass);
wrapped = (Filter) wrappedFilterClass.newInstance();
log.debug("Wrapped filter instance: " + wrapped);
wrapped.init(filterConfig);
} catch (ClassNotFoundException e) {
log.warn("Wrapped filter class not found", e);
} catch (InstantiationException e) {
log.warn("Could not instantiate wrapper filter class", e);
} catch (IllegalAccessException e) {
log.warn("Could not wrap filter", e);
}
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
if (wrapped != null) {
// Use the wrapped filter if available.
wrapped.doFilter(request, response, chain);
} else {
// Otherwise just work as a no-op filter calling the next filter in
// chain.
chain.doFilter(request, response);
}
}
@Override
public void destroy() {
if (wrapped != null) {
wrapped.destroy();
}
wrapped = null;
}
}
...@@ -31,6 +31,9 @@ bill.billNumber = Number ...@@ -31,6 +31,9 @@ bill.billNumber = Number
bill.cancel = Cancel bill bill.cancel = Cancel bill
bill.expires = Expires bill.expires = Expires
bill.isExpired = Bill is expired bill.isExpired = Bill is expired
bill.markPaid.cash = Maksa k\u00E4teisell\u00E4
bill.markPaid.cashOrCredit = K\u00E4teisell\u00E4 vai krediiteill\u00E4?
bill.markPaid.credits = Maksa krediiteill\u00E4
bill.markPaid.show = Show Mark paid -buttons bill.markPaid.show = Show Mark paid -buttons
bill.notes.title = Lis\u00E4tietoja bill.notes.title = Lis\u00E4tietoja
bill.products = Tuotteet bill.products = Tuotteet
...@@ -119,6 +122,8 @@ cardTemplate.emptyCardTemplate = ---- ...@@ -119,6 +122,8 @@ cardTemplate.emptyCardTemplate = ----
code.inputfield = Sy\u00F6t\u00E4 viivakoodi code.inputfield = Sy\u00F6t\u00E4 viivakoodi
confirmation.message = Oletko varma?
create = Luo create = Luo
delete = Poista delete = Poista
...@@ -163,6 +168,12 @@ foodWave.closeNow = Close now ...@@ -163,6 +168,12 @@ foodWave.closeNow = Close now
foodWave.deliveredCount = Luovutetut foodWave.deliveredCount = Luovutetut
foodWave.openNow = Open now foodWave.openNow = Open now
foodshop.buyAndPayWithCredits = Varaa ja maksa krediiteill\u00E4
foodshop.buyProceedToPay = Varaa ja siirry maksamaan
foodshop.canBuyToCounter = Voit maksaa t\u00E4m\u00E4n ruokatilauksen my\u00F6s infotiskille. Mik\u00E4li haluat tehd\u00E4 n\u00E4in, voit sulkea t\u00E4m\u00E4n ikkunan ja tulla infotiskille maksamaan tilauksen.
foodwave.cancelOrder = Peruuta
foodwave.closed = Ruokatilaus on suljettu
foodwave.foodwaveLastBillPayTime = Maksut viimeist\u00E4\u00E4n foodwave.foodwaveLastBillPayTime = Maksut viimeist\u00E4\u00E4n
foodwave.ordersBefore = Tilaukset ennen foodwave.ordersBefore = Tilaukset ennen
foodwave.template.waitPaymentsMinutes = Verkkomaksujen odotusaika foodwave.template.waitPaymentsMinutes = Verkkomaksujen odotusaika
...@@ -319,6 +330,7 @@ poll.edit = edit ...@@ -319,6 +330,7 @@ poll.edit = edit
print = Print print = Print
product.description = Kuvaus
product.providedRole = Product defines role product.providedRole = Product defines role
product.returnProductEdit = Return to product: product.returnProductEdit = Return to product:
product.saved = Product saved product.saved = Product saved
......
...@@ -77,6 +77,9 @@ bill.expires = Expires ...@@ -77,6 +77,9 @@ bill.expires = Expires
bill.isExpired = Bill is expired bill.isExpired = Bill is expired
bill.isPaid = Paid bill.isPaid = Paid
bill.markPaid = Mark paid bill.markPaid = Mark paid
bill.markPaid.cash = Buy with cash
bill.markPaid.cashOrCredit = Cash or credit?
bill.markPaid.credits = Buy with credits
bill.markPaid.show = Show Mark paid -buttons bill.markPaid.show = Show Mark paid -buttons
bill.markedPaid = Bill marked paid bill.markedPaid = Bill marked paid
bill.notes = Notes bill.notes = Notes
...@@ -305,6 +308,8 @@ compofile.shaChecksum = SHA checksum ...@@ -305,6 +308,8 @@ compofile.shaChecksum = SHA checksum
compofile.upload = Upload file compofile.upload = Upload file
compofile.uploadTime = Upload time compofile.uploadTime = Upload time
confirmation.message = Are you sure?
content.showContentEditLinks = Show content edit links content.showContentEditLinks = Show content edit links
create = Create create = Create
...@@ -427,11 +432,16 @@ foodWave.unconfirmedOrders = Unconfirmed ...@@ -427,11 +432,16 @@ foodWave.unconfirmedOrders = Unconfirmed
foodadmin.editTemplate = Edit foodadmin.editTemplate = Edit
foodshop.buyAndPay = Buy and Pay foodshop.buyAndPay = Buy and Pay
foodshop.buyAndPayWithCredits = Reserve and buy with credits
foodshop.buyFromCounter = Pay at info foodshop.buyFromCounter = Pay at info
foodshop.buyFromInternet = Pay at Internet foodshop.buyFromInternet = Pay at Internet
foodshop.buyProceedToPay = Reserve and continue to buy
foodshop.canBuyToCounter = You can buy this bill on infodesk. If you want to buy this order at the infodesk, you can close this window and come to infodesk to buy this order.
foodshop.total = Total foodshop.total = Total
foodwave.buyInPrice = Buy In Price foodwave.buyInPrice = Buy In Price
foodwave.cancelOrder = Cancel
foodwave.closed = Foodwave is closed
foodwave.foodwaveBuyInPrice = Total buy in price foodwave.foodwaveBuyInPrice = Total buy in price
foodwave.foodwaveLastBillPayTime = Last payments time foodwave.foodwaveLastBillPayTime = Last payments time
foodwave.markPaid = Foodwave marked paid foodwave.markPaid = Foodwave marked paid
...@@ -941,6 +951,7 @@ product.color = Color in UI ...@@ -941,6 +951,7 @@ product.color = Color in UI
product.create = Create product product.create = Create product
product.createDiscount = Add volumediscount product.createDiscount = Add volumediscount
product.createLimit = Create product limitation product.createLimit = Create product limitation
product.description = Description
product.edit = edit product.edit = edit
product.inventoryQuantity = Inventory count product.inventoryQuantity = Inventory count
product.name = Name of product product.name = Name of product
......
...@@ -77,6 +77,9 @@ bill.expires = Vanhentuu ...@@ -77,6 +77,9 @@ bill.expires = Vanhentuu
bill.isExpired = Lasku on vanhentunut bill.isExpired = Lasku on vanhentunut
bill.isPaid = Maksettu bill.isPaid = Maksettu
bill.markPaid = Maksettu bill.markPaid = Maksettu
bill.markPaid.cash = Maksa k\u00E4teisell\u00E4
bill.markPaid.cashOrCredit = K\u00E4teisell\u00E4 vai krediiteill\u00E4?
bill.markPaid.credits = Maksa krediiteill\u00E4
bill.markPaid.show = N\u00E4yt\u00E4 Maksettu -napit bill.markPaid.show = N\u00E4yt\u00E4 Maksettu -napit
bill.markedPaid = Lasku merkitty maksetuksi. bill.markedPaid = Lasku merkitty maksetuksi.
bill.notes = Huomioita bill.notes = Huomioita
...@@ -306,6 +309,8 @@ compofile.shaChecksum = SHA tarkistesumma ...@@ -306,6 +309,8 @@ compofile.shaChecksum = SHA tarkistesumma
compofile.upload = L\u00E4het\u00E4 tiedosto compofile.upload = L\u00E4het\u00E4 tiedosto
compofile.uploadTime = Tallennusaika compofile.uploadTime = Tallennusaika
confirmation.message = Oletko varma?
content.showContentEditLinks = N\u00E4yt\u00E4 sis\u00E4ll\u00F6nmuokkauslinkit content.showContentEditLinks = N\u00E4yt\u00E4 sis\u00E4ll\u00F6nmuokkauslinkit
create = Luo create = Luo
...@@ -428,11 +433,16 @@ foodWave.unconfirmedOrders = Vahvistamattomia ...@@ -428,11 +433,16 @@ foodWave.unconfirmedOrders = Vahvistamattomia
foodadmin.editTemplate = Muokkaa foodadmin.editTemplate = Muokkaa
foodshop.buyAndPay = Varaa ja maksa foodshop.buyAndPay = Varaa ja maksa
foodshop.buyAndPayWithCredits = Varaa ja maksa krediiteill\u00E4
foodshop.buyFromCounter = Maksa infossa foodshop.buyFromCounter = Maksa infossa
foodshop.buyFromInternet = Maksa Internetiss\u00E4 foodshop.buyFromInternet = Maksa Internetiss\u00E4
foodshop.buyProceedToPay = Varaa ja siirry maksamaan
foodshop.canBuyToCounter = Voit maksaa t\u00E4m\u00E4n ruokatilauksen my\u00F6s infotiskille. Mik\u00E4li haluat tehd\u00E4 n\u00E4in, voit sulkea t\u00E4m\u00E4n ikkunan ja tulla infotiskille maksamaan tilauksen.
foodshop.total = Yhteens\u00E4 foodshop.total = Yhteens\u00E4
foodwave.buyInPrice = Sis\u00E4\u00E4nostohinta foodwave.buyInPrice = Sis\u00E4\u00E4nostohinta
foodwave.cancelOrder = Peruuta
foodwave.closed = Ruokatilaus on suljettu
foodwave.foodwaveBuyInPrice = Sis\u00E4\u00E4nostohinta foodwave.foodwaveBuyInPrice = Sis\u00E4\u00E4nostohinta
foodwave.foodwaveLastBillPayTime = Maksut viimeist\u00E4\u00E4n foodwave.foodwaveLastBillPayTime = Maksut viimeist\u00E4\u00E4n
foodwave.markPaid = Merkitty maksetuksi foodwave.markPaid = Merkitty maksetuksi
...@@ -924,6 +934,7 @@ product.color = V\u00E4ri k\u00E4ytt\u00F6liittym\u00E4ss\u00E4 ...@@ -924,6 +934,7 @@ product.color = V\u00E4ri k\u00E4ytt\u00F6liittym\u00E4ss\u00E4
product.create = Luo tuote product.create = Luo tuote
product.createDiscount = Lis\u00E4\u00E4 m\u00E4\u00E4r\u00E4alennus product.createDiscount = Lis\u00E4\u00E4 m\u00E4\u00E4r\u00E4alennus
product.createLimit = Luo tuoterajoite product.createLimit = Luo tuoterajoite
product.description = Kuvaus
product.edit = Muokkaa product.edit = Muokkaa
product.inventoryQuantity = Varastotilanne product.inventoryQuantity = Varastotilanne
product.name = Tuotteen nimi product.name = Tuotteen nimi
......
...@@ -68,6 +68,13 @@ public class ErrorPageView implements Serializable { ...@@ -68,6 +68,13 @@ public class ErrorPageView implements Serializable {
} }
public String getMessage() {
FacesContext context = FacesContext.getCurrentInstance();
Map requestMap = context.getExternalContext().getRequestMap();
Throwable ex = (Throwable) requestMap.get("javax.servlet.error.exception");
return ex.getMessage();
}
public String getStackTraceHash() { public String getStackTraceHash() {
FacesContext context = FacesContext.getCurrentInstance(); FacesContext context = FacesContext.getCurrentInstance();
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package fi.codecrew.moya.web.cdiview.shop; package fi.codecrew.moya.web.cdiview.shop;
import java.util.Calendar;
import java.util.List; import java.util.List;
import javax.ejb.EJB; import javax.ejb.EJB;
...@@ -30,6 +31,7 @@ import org.slf4j.LoggerFactory; ...@@ -30,6 +31,7 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.BillBeanLocal; import fi.codecrew.moya.beans.BillBeanLocal;
import fi.codecrew.moya.beans.CheckoutFiBeanLocal; import fi.codecrew.moya.beans.CheckoutFiBeanLocal;
import fi.codecrew.moya.beans.VerkkomaksutFiBeanLocal; import fi.codecrew.moya.beans.VerkkomaksutFiBeanLocal;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.Bill; import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.util.CheckoutBank; import fi.codecrew.moya.util.CheckoutBank;
import fi.codecrew.moya.util.VerkkomaksutReturnEntry; import fi.codecrew.moya.util.VerkkomaksutReturnEntry;
...@@ -139,4 +141,14 @@ public class BillEditView extends GenericCDIView { ...@@ -139,4 +141,14 @@ public class BillEditView extends GenericCDIView {
bill = billbean.expireBill(bill); bill = billbean.expireBill(bill);
} }
public void buyWithCredits() {
try {
bill = billbean.markPaid(bill, Calendar.getInstance(), true);
} catch (BillException e) {
throw new RuntimeException(e);
// TODO: error handling
}
}
} }
...@@ -26,10 +26,12 @@ import javax.enterprise.context.ConversationScoped; ...@@ -26,10 +26,12 @@ import javax.enterprise.context.ConversationScoped;
import javax.faces.model.ListDataModel; import javax.faces.model.ListDataModel;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.management.RuntimeErrorException;
import fi.codecrew.moya.beans.BillBeanLocal; import fi.codecrew.moya.beans.BillBeanLocal;
import fi.codecrew.moya.bortal.views.BillSummary; import fi.codecrew.moya.bortal.views.BillSummary;
import fi.codecrew.moya.enums.apps.BillPermission; import fi.codecrew.moya.enums.apps.BillPermission;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.Bill; import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.web.annotations.SelectedUser; import fi.codecrew.moya.web.annotations.SelectedUser;
...@@ -95,7 +97,11 @@ public class BillListView extends GenericCDIView { ...@@ -95,7 +97,11 @@ public class BillListView extends GenericCDIView {
public String markPaid() { public String markPaid() {
if (permbean.hasPermission(BillPermission.WRITE_ALL)) { if (permbean.hasPermission(BillPermission.WRITE_ALL)) {
billbean.markPaid(bills.getRowData(), Calendar.getInstance()); try {
billbean.markPaid(bills.getRowData(), Calendar.getInstance(), false);
} catch (BillException x) {
throw new RuntimeException(x);
}
this.addFaceMessage("bill.markedPaid"); this.addFaceMessage("bill.markedPaid");
} else { } else {
......
...@@ -36,6 +36,7 @@ import fi.codecrew.moya.beans.EventBeanLocal; ...@@ -36,6 +36,7 @@ import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.FoodWaveBeanLocal; import fi.codecrew.moya.beans.FoodWaveBeanLocal;
import fi.codecrew.moya.beans.ProductBeanLocal; import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.enums.apps.ShopPermission; import fi.codecrew.moya.enums.apps.ShopPermission;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.Bill; import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.FoodWave; import fi.codecrew.moya.model.FoodWave;
import fi.codecrew.moya.model.LanEventPropertyKey; import fi.codecrew.moya.model.LanEventPropertyKey;
...@@ -170,10 +171,30 @@ public class FoodWaveFoodView extends GenericCDIView { ...@@ -170,10 +171,30 @@ public class FoodWaveFoodView extends GenericCDIView {
return bill; return bill;
} }
public String buyAndPayWithCredits() {
Bill b = createBillFromShoppingcart();
try {
billBean.markPaid(b, Calendar.getInstance(), true);
} catch (BillException e) {
throw new RuntimeException(e);
}
super.addFaceMessage("foodwave.markPaid");
return "/useradmin/edit";
}
public String buyAndPay() public String buyAndPay()
{ {
Bill b = createBillFromShoppingcart(); Bill b = createBillFromShoppingcart();
billBean.markPaid(b, Calendar.getInstance());
try {
billBean.markPaid(b, Calendar.getInstance(), false);
} catch (BillException e) {
throw new RuntimeException(e);
}
super.addFaceMessage("foodwave.markPaid"); super.addFaceMessage("foodwave.markPaid");
return "/useradmin/edit"; return "/useradmin/edit";
} }
......
...@@ -42,6 +42,7 @@ import fi.codecrew.moya.beans.FoodWaveBeanLocal; ...@@ -42,6 +42,7 @@ import fi.codecrew.moya.beans.FoodWaveBeanLocal;
import fi.codecrew.moya.beans.ProductBeanLocal; import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.enums.apps.BillPermission; import fi.codecrew.moya.enums.apps.BillPermission;
import fi.codecrew.moya.enums.apps.ShopPermission; import fi.codecrew.moya.enums.apps.ShopPermission;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.AccountEvent; import fi.codecrew.moya.model.AccountEvent;
import fi.codecrew.moya.model.Bill; import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.BillLine; import fi.codecrew.moya.model.BillLine;
...@@ -109,12 +110,11 @@ public class FoodWaveView extends GenericCDIView { ...@@ -109,12 +110,11 @@ public class FoodWaveView extends GenericCDIView {
if (super.requirePermissions(ShopPermission.MANAGE_FOODWAVES)) if (super.requirePermissions(ShopPermission.MANAGE_FOODWAVES))
{ {
if (foodWaves == null) { if (foodWaves == null) {
super.beginConversation(); super.beginConversation();
foodWaves = new ListDataModel<FoodWave>(foodWaveBean.getEventFoodWaves());
} }
} }
foodWaves = new ListDataModel<FoodWave>(foodWaveBean.getEventFoodWaves());
} }
public String createFoodwave() { public String createFoodwave() {
...@@ -251,11 +251,52 @@ public class FoodWaveView extends GenericCDIView { ...@@ -251,11 +251,52 @@ public class FoodWaveView extends GenericCDIView {
// ListDataModel<FoodWave>(foodWaveBean.getEventFoodWaves()); // ListDataModel<FoodWave>(foodWaveBean.getEventFoodWaves());
// } // }
public String markBillExpired() {
if (permbean.hasPermission(BillPermission.WRITE_ALL) && bills != null && bills.isRowAvailable()) {
Bill b = bills.getRowData();
b = billbean.expireBill(b);
foodWaveId = selectedFoodWave.getId();
selectedFoodWave = null;
bills = null;
initFoodWaveOrderList();
}
return null;
}
public String markBillPaid() { public String markBillPaid() {
if (permbean.hasPermission(BillPermission.WRITE_ALL) && bills != null && bills.isRowAvailable()) { if (permbean.hasPermission(BillPermission.WRITE_ALL) && bills != null && bills.isRowAvailable()) {
Bill b = bills.getRowData(); Bill b = bills.getRowData();
b = billbean.markPaid(b, Calendar.getInstance());
try {
b = billbean.markPaid(b, Calendar.getInstance(), false);
} catch (BillException e) {
throw new RuntimeException(e);
}
foodWaveId = selectedFoodWave.getId();
selectedFoodWave = null;
bills = null;
initFoodWaveOrderList();
}
return null;
}
public String markBillPaidWithCredits() {
if (permbean.hasPermission(BillPermission.WRITE_ALL) && bills != null && bills.isRowAvailable()) {
Bill b = bills.getRowData();
try {
b = billbean.markPaid(b, Calendar.getInstance(), true);
} catch (BillException e) {
throw new RuntimeException(e);
}
foodWaveId = selectedFoodWave.getId(); foodWaveId = selectedFoodWave.getId();
selectedFoodWave = null; selectedFoodWave = null;
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true" scan="true"> <configuration debug="true" scan="true" scanPeriod="10 seconds">
<!-- <jmxConfigurator /> --> <jmxConfigurator />
<appender name="console" class="ch.qos.logback.core.ConsoleAppender"> <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout"> <layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern> <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout> </layout>
</appender> </appender>
<!-- <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>${com.sun.aas.instanceRoot}/logs/server.log</file>
<file>moya.log</file>
<layout class="ch.qos.logback.classic.PatternLayout"> <layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern> <Pattern>%d{HH:mm:ss.SSS} %X{req.remoteHost} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout> </layout>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>server.%i{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>32MB</MaxFileSize>
</triggeringPolicy>
</appender> </appender>
-->
<logger name="fi.codecrew" level="TRACE" /> <logger name="fi.codecrew" level="DEBUG" />
<root level="DEBUG"> <root level="INFO">
<appender-ref ref="console" /> <appender-ref ref="CONSOLE" />
<!-- <appender-ref ref="FILE" /> --> <appender-ref ref="FILE" />
</root> </root>
</configuration> </configuration>
handlers = org.slf4j.bridge.SLF4JBridgeHandler handlers = org.slf4j.bridge.SLF4JBridgeHandler
com.sun.enterprise.server.logging.GFFileHandler.flushFrequency=1 com.sun.enterprise.server.logging.GFFileHandler.flushFrequency=1
com.sun.enterprise.server.logging.GFFileHandler.file=${com.sun.aas.instanceRoot}/logs/server.log com.sun.enterprise.server.logging.GFFileHandler.file=${com.sun.aas.instanceRoot}/logs/jul.log
com.sun.enterprise.server.logging.GFFileHandler.rotationTimelimitInMinutes=0 com.sun.enterprise.server.logging.GFFileHandler.rotationTimelimitInMinutes=0
com.sun.enterprise.server.logging.GFFileHandler.logtoConsole=false com.sun.enterprise.server.logging.GFFileHandler.logtoConsole=false
com.sun.enterprise.server.logging.GFFileHandler.rotationLimitInBytes=2000000 com.sun.enterprise.server.logging.GFFileHandler.rotationLimitInBytes=2000000
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!