Commit d8aa668e by Tuomas Riihimäki

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

2 parents 3900e062 e788d87d
Showing with 575 additions and 120 deletions
......@@ -27,6 +27,7 @@ import java.util.List;
import javax.ejb.Local;
import fi.codecrew.moya.bortal.views.BillSummary;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.FoodWave;
......@@ -47,7 +48,7 @@ public interface BillBeanLocal {
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);
......
/*
* 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;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
......@@ -33,6 +32,8 @@ import javax.ejb.EJBAccessException;
import javax.ejb.EJBException;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -42,6 +43,9 @@ import fi.codecrew.moya.bortal.views.BillSummary;
import fi.codecrew.moya.enums.apps.BillPermission;
import fi.codecrew.moya.enums.apps.ShopPermission;
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.BillLineFacade;
import fi.codecrew.moya.facade.EventUserFacade;
......@@ -52,10 +56,8 @@ import fi.codecrew.moya.model.Discount;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.FoodWave;
import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.LanEventPropertyKey;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.model.ProductFlag;
import fi.codecrew.moya.util.MailMessage;
/**
* Session Bean implementation class BillBean
......@@ -102,7 +104,7 @@ public class BillBean implements BillBeanLocal {
* Default constructor.
*/
public BillBean() {
// TODO Auto-generated constructor stub
}
@Override
......@@ -227,41 +229,75 @@ public class BillBean implements BillBeanLocal {
return ret;
}
/**
* 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);
if (bill.getAccountEvent() != null || bill.getPaidDate() != null) {
logbean.logMessage(SecurityLogType.bill, permbean.getCurrentUser(), "Trying to doublemark bill paid", bill.getId());
throw new BillExceptionAlreadyPaid("Trying to mark bill paid, already paid, BillID: "+bill.getId());
}
Product creditproduct = productBean.findCreditProduct();
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);
logger.info("Created creditentry. {}, userproducts {}", ac, user.getAccountEvents().size());
ac.setEventTime(when);
ac.setBill(bill);
ac.setSeller(permbean.getCurrentUser());
bill.setAccountEvent(ac);
}
bill.setPaidDate(when.getTime());
return bill;
}
@Override
@RolesAllowed({ BillPermission.S_WRITE_ALL,
SpecialPermission.S_VERKKOMAKSU_CHECK })
public Bill markPaid(Bill bill, Calendar when) {
public Bill markPaid(Bill bill, Calendar when, boolean useCredits) throws BillException {
bill = markPaidSafeTransaction(bill, when,useCredits);
EventUser user = bill.getUser();
bill = billFacade.reload(bill);
if (bill.getAccountEvent() != null || bill.getPaidDate() != null) {
logbean.logMessage(SecurityLogType.bill, permbean.getCurrentUser(), "Trying to doublemark bill paid");
throw new EJBException("Bill already marked paid!");
}
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();
EventUser user = bill.getUser();
AccountEvent ac = productBean.createAccountEvent(creditproduct, bill.totalPrice(), user);
logger.info("Created creditentry. {}, userproducts {}", ac, user.getAccountEvents().size());
// Used in foodwave. Should be null!
// ac.setDelivered(when);
ac.setEventTime(when);
ac.setBill(bill);
ac.setSeller(permbean.getCurrentUser());
bill.setAccountEvent(ac);
bill.setPaidDate(when.getTime());
// bill = billFacade.merge(bill);
......@@ -278,9 +314,10 @@ public class BillBean implements BillBeanLocal {
ac2.setSeller(permbean.getCurrentUser());
}
}
billFacade.flush();
/*
MailMessage msg = new MailMessage();
......
......@@ -27,6 +27,7 @@ import javax.ejb.Stateless;
import fi.codecrew.moya.beans.BillBeanLocal;
import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.Bill;
@Stateless
......@@ -38,7 +39,12 @@ public class VerkkomaksuRunner {
private BillBeanLocal billbean;
public void markPaid(Bill bill, Calendar when) {
billbean.markPaid(bill, when);
try {
billbean.markPaid(bill, when, false);
} catch (BillException x) {
throw new RuntimeException(x);
}
}
}
......@@ -428,6 +428,16 @@ public class Bill extends GenericEntity {
public void setSentDate(Calendar sentDate) {
this.sentDate = sentDate;
}
public boolean isFoodwaveBill() {
for (BillLine bl : billLines)
{
if (bl.getFoodwave() != null) {
return true;
}
}
return false;
}
public boolean isFoowavePaymentOver() {
for (BillLine bl : billLines)
......@@ -473,7 +483,7 @@ public class Bill extends GenericEntity {
if(l == null || l.getQuantity() == null)
continue;
total.add(l.getQuantity());
total = total.add(l.getQuantity());
}
return total;
......
......@@ -225,12 +225,11 @@ public class FoodWave extends GenericEntity {
public Integer getUnpaidCount() {
Integer ret = 0;
for (BillLine line : getBillLines()) {
if (!line.getBill().isPaid()) {
if (!line.getBill().isPaid() && !line.getBill().isExpired()) {
ret += line.getQuantity().intValue();
}
}
return ret;
}
public Integer getOrderedCount() {
......
......@@ -24,6 +24,22 @@
<param-value>Development</param-value>
</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>
<display-name>PrimefacesFileupload</display-name>
<filter-name>PrimefacesFileupload</filter-name>
......@@ -53,19 +69,11 @@
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<!--
<servlet>
<servlet-name>ViewStatusMessages</servlet-name>
<servlet-class>ch.qos.logback.classic.ViewStatusMessagesServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ViewStatusMessages</servlet-name>
<url-pattern>/logback</url-pattern>
</servlet-mapping>
-->
<!-- <servlet> <servlet-name>ViewStatusMessages</servlet-name> <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-timeout>120</session-timeout>
</session-config>
......
......@@ -62,6 +62,10 @@
</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}">
<h:form>
<p:commandButton id="cancelbtn" actionListener="#{billEditView.expireBill()}" onerror="location.reload(true);" value="#{i18n['bill.cancel']}" update=":billPanel">
......@@ -70,6 +74,13 @@
</h:form>
</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>
</ui:define>
......
......@@ -8,6 +8,7 @@
<h:body>
<!-- <c:if test="#{sessionHandler.isInDevelopmentMode() eq false}"> -->
<h1>#{i18n['error.error']}</h1>
<h2>#{errorPageView.message}</h2>
<p>${i18n['error.contact']}
<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}" /> -->
......
......@@ -37,7 +37,8 @@
<f:facet name="header">
<h:outputLabel value="#{i18n['acc_line.product']}" />
</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 sortBy="#{acc_line.user.wholeName}">
<f:facet name="header">
......@@ -50,7 +51,7 @@
<h:outputLabel value="#{i18n['acc_line.nick']}" />
</f:facet>
<h:link outcome="/useradmin/edit" value="#{acc_line.user.nick}">
<f:param name="userid" value="#{acc_line.user.user.id}" />
<f:param name="userid" value="#{acc_line.user.user.id}" />
</h:link>
</p:column>
<p:column sortBy="#{acc_line.eventDelivered}">
......@@ -67,7 +68,10 @@
<br></br>
<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">
<h:outputLabel value="#{i18n['foodWave.billLines']}" />
</f:facet>
......@@ -97,9 +101,7 @@
<f:facet name="header">
<h:outputLabel value="#{i18n['billLine.eventuser']}" />
</f:facet>
<h:link outcome="/useradmin/edit" value="#{bill.user.wholeName}">
<f:param name="userid" value="#{bill.user.user.id}" />
</h:link>
<h:outputText outcome="/useradmin/edit" value="#{bill.user.wholeName}" />
</p:column>
<p:column sortBy="#{bill.user.user.id}">
<f:facet name="header">
......@@ -117,51 +119,74 @@
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText>
</p:column>
<p:column>
<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:commandButton value="#{i18n['bill.markPaid']}" actionListener="#{foodWaveView.markBillPaid}" update=":billList :accountEventList" />
<p:commandButton rendered="#{not bill.expired}" id="removeBill" value="#{i18n['foodwave.cancelOrder']}" actionListener="#{foodWaveView.markBillExpired}" update=":billList :accountEventList">
<p:confirm header="Confirmation" message="#{i18n['confirmation.message']}" icon="ui-icon-alert" />
</p:commandButton>
</p:column>
<!--
<p:column>
<h:commandButton value="#{i18n['bill.remove']}" action="foodWaveView.markBillRemoved" />
</p:column> -->
</p:dataTable>
</h:form>
<br /><br /><br />
<br />
<br />
<br />
<h2>#{i18n['foodwave.summaryView']}</h2>
<p:panelGrid columns="2">
<h:outputLabel value="#{i18n['foodwave.price']}: " />
<h:outputText value="#{foodWaveView.foodwavePrice}" style="font-weight: bold" >
<f:convertNumber minFractionDigits="0"/>
<h:outputText value="#{foodWaveView.foodwavePrice}" style="font-weight: bold">
<f:convertNumber minFractionDigits="0" />
</h:outputText>
<h:outputLabel value="#{i18n['foodwave.foodwaveBuyInPrice']}: " />
<h:outputText value="#{foodWaveView.foodwaveBuyInPrice}" style="font-weight: bold" >
<f:convertNumber minFractionDigits="0"/>
<h:outputText value="#{foodWaveView.foodwaveBuyInPrice}" style="font-weight: bold">
<f:convertNumber minFractionDigits="0" />
</h:outputText>
<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}" />
</h:outputText>
<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}" />
</h:outputText>
</p:panelGrid>
<p:dataTable var="summ" value="#{foodWaveView.productSummaries}">
<p:column>
<f:facet name="header">
<h:outputLabel value="#{i18n['product.name']}" />
</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>
<f:facet name="header">
......
......@@ -23,8 +23,7 @@
<ui:define name="content">
<!-- products:shop commitaction="#{foodWaveFoodView.commitShoppingCart()}" items="#{foodWaveFoodView.shoppingcart}" commitValue="#{i18n['productshop.commit']}" /-->
<foodwave:listFoods selectaction="#{foodWaveFoodView.buyFromCounter()}"
items="#{foodWaveFoodView.shoppingcart}" commitValue="foodshop.buyFromCounter"/>
<foodwave:listFoods selectaction="#{foodWaveFoodView.buyFromInternet()}" items="#{foodWaveFoodView.shoppingcart}" commitValue="foodshop.buyProceedToPay"/>
</ui:define>
......
......@@ -28,10 +28,7 @@
<h1>Shop to user: #{userView.selectedUser.user.nick}</h1>
<br /><br />
<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>
......
......@@ -34,7 +34,7 @@
<h:outputText value="${i18n['bill.sentDate']}" />
</f:facet>
<h:outputText value="#{bill.sentDateTime}">
<f:convertDateTime pattern="#{sessionHandler.dateFormat}" timeZone="#{sessionHandler.timezone}" />
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</p:column>
<p:column>
......
......@@ -15,13 +15,14 @@
<composite:attribute name="items" required="true" />
<!-- <composite:attribute name="selectValue" 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:implementation>
<h:outputScript library="primefaces" name="jquery/jquery.js" />
<h:form>
<h:form styleClass="foodformselector">
<p:dataTable columnClasses="nowrap,numalign,numalign,nowrap,numalign"
styleClass="bordertable" value="#{cc.attrs.items}" var="cart">
<!-- p:column>
......@@ -54,6 +55,17 @@
</p:column>
<p:column>
<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']}" />
</f:facet>
<h:outputText id="price" value="#{cart.product.price.abs()}">
......@@ -73,28 +85,30 @@
<h:outputText id="count" value="${i18n['product.cart.count']}" />
</f:facet>
<h:commandButton action="#{foodWaveFoodView.addMinusOne}"
value="#{i18n['productshop.minusOne']}">
<f:ajax render="@form" />
</h:commandButton>
<p:commandButton actionListener="#{foodWaveFoodView.addMinusOne}" update="@(.foodformselector)"
value="#{i18n['productshop.minusOne']}" />
<h:inputText size="4" id="cartcount" value="#{cart.count}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="0" />
</h:inputText>
<h:commandButton action="#{foodWaveFoodView.addOne}"
value="#{i18n['productshop.plusOne']}">
<f:ajax render="@form" />
</h:commandButton>
<p:commandButton actionListener="#{foodWaveFoodView.addOne}" update="@(.foodformselector)"
value="#{i18n['productshop.plusOne']}" />
</p:column>
</p:dataTable>
<div>
<h:outputLabel for="total" value="#{i18n['foodshop.total']}: "/>
<h:outputText id="total" value="#{foodWaveFoodView.totalPrice}" >
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</h:outputText>
<div>
<h:outputLabel for="total" value="#{i18n['foodshop.total']}: "/>
<h:outputText id="total" value="#{foodWaveFoodView.totalPrice}" style="font-weight: bold;" >
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</h:outputText>
</div>
<h:commandButton action="#{cc.attrs.selectaction}" value="#{i18n[cc.attrs.commitValue]}" />
<h:commandButton action="#{foodWaveFoodView.buyFromInternet}" value="#{i18n['foodshop.buyFromInternet']}" />
<br />
<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>
......
......@@ -186,6 +186,10 @@ a.shopItem:active {
color: red;
}
.notify {
color: red;
}
.success {
color: #006600;
}
......
......@@ -26,8 +26,8 @@
<ui:define name="content">
<!-- 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>
......
......@@ -12,7 +12,7 @@
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<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>
</plugin>
</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
bill.cancel = Cancel bill
bill.expires = Expires
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.notes.title = Lis\u00E4tietoja
bill.products = Tuotteet
......@@ -119,6 +122,8 @@ cardTemplate.emptyCardTemplate = ----
code.inputfield = Sy\u00F6t\u00E4 viivakoodi
confirmation.message = Oletko varma?
create = Luo
delete = Poista
......@@ -163,8 +168,14 @@ foodWave.closeNow = Close now
foodWave.deliveredCount = Luovutetut
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.ordersBefore = Tilaukset ennen
foodwave.ordersBefore = Tilaukset ennen
foodwave.template.waitPaymentsMinutes = Verkkomaksujen odotusaika
game.active = Aktiivinen
......@@ -319,9 +330,10 @@ poll.edit = edit
print = Print
product.description = Kuvaus
product.providedRole = Product defines role
product.returnProductEdit = Return to product:
product.saved = Product saved
product.saved = Product saved
productshop.minusOne = -1
productshop.minusTen = -10
......
......@@ -77,6 +77,9 @@ bill.expires = Expires
bill.isExpired = Bill is expired
bill.isPaid = 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.markedPaid = Bill marked paid
bill.notes = Notes
......@@ -305,6 +308,8 @@ compofile.shaChecksum = SHA checksum
compofile.upload = Upload file
compofile.uploadTime = Upload time
confirmation.message = Are you sure?
content.showContentEditLinks = Show content edit links
create = Create
......@@ -427,11 +432,16 @@ foodWave.unconfirmedOrders = Unconfirmed
foodadmin.editTemplate = Edit
foodshop.buyAndPay = Buy and Pay
foodshop.buyAndPayWithCredits = Reserve and buy with credits
foodshop.buyFromCounter = Pay at info
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
foodwave.buyInPrice = Buy In Price
foodwave.cancelOrder = Cancel
foodwave.closed = Foodwave is closed
foodwave.foodwaveBuyInPrice = Total buy in price
foodwave.foodwaveLastBillPayTime = Last payments time
foodwave.markPaid = Foodwave marked paid
......@@ -941,6 +951,7 @@ product.color = Color in UI
product.create = Create product
product.createDiscount = Add volumediscount
product.createLimit = Create product limitation
product.description = Description
product.edit = edit
product.inventoryQuantity = Inventory count
product.name = Name of product
......
......@@ -77,6 +77,9 @@ bill.expires = Vanhentuu
bill.isExpired = Lasku on vanhentunut
bill.isPaid = 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.markedPaid = Lasku merkitty maksetuksi.
bill.notes = Huomioita
......@@ -306,6 +309,8 @@ compofile.shaChecksum = SHA tarkistesumma
compofile.upload = L\u00E4het\u00E4 tiedosto
compofile.uploadTime = Tallennusaika
confirmation.message = Oletko varma?
content.showContentEditLinks = N\u00E4yt\u00E4 sis\u00E4ll\u00F6nmuokkauslinkit
create = Luo
......@@ -428,11 +433,16 @@ foodWave.unconfirmedOrders = Vahvistamattomia
foodadmin.editTemplate = Muokkaa
foodshop.buyAndPay = Varaa ja maksa
foodshop.buyAndPayWithCredits = Varaa ja maksa krediiteill\u00E4
foodshop.buyFromCounter = Maksa infossa
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
foodwave.buyInPrice = Sis\u00E4\u00E4nostohinta
foodwave.cancelOrder = Peruuta
foodwave.closed = Ruokatilaus on suljettu
foodwave.foodwaveBuyInPrice = Sis\u00E4\u00E4nostohinta
foodwave.foodwaveLastBillPayTime = Maksut viimeist\u00E4\u00E4n
foodwave.markPaid = Merkitty maksetuksi
......@@ -924,6 +934,7 @@ product.color = V\u00E4ri k\u00E4ytt\u00F6liittym\u00E4ss\u00E4
product.create = Luo tuote
product.createDiscount = Lis\u00E4\u00E4 m\u00E4\u00E4r\u00E4alennus
product.createLimit = Luo tuoterajoite
product.description = Kuvaus
product.edit = Muokkaa
product.inventoryQuantity = Varastotilanne
product.name = Tuotteen nimi
......
......@@ -46,8 +46,8 @@ public class ErrorPageView implements Serializable {
// private static final long serialVersionUID = -2179309061036632342L;
String trace;
// @Inject
// private transient FacesContext context;
// @Inject
// private transient FacesContext context;
@SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(ErrorPageView.class);
......@@ -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() {
FacesContext context = FacesContext.getCurrentInstance();
......
......@@ -18,6 +18,7 @@
*/
package fi.codecrew.moya.web.cdiview.shop;
import java.util.Calendar;
import java.util.List;
import javax.ejb.EJB;
......@@ -30,6 +31,7 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.BillBeanLocal;
import fi.codecrew.moya.beans.CheckoutFiBeanLocal;
import fi.codecrew.moya.beans.VerkkomaksutFiBeanLocal;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.util.CheckoutBank;
import fi.codecrew.moya.util.VerkkomaksutReturnEntry;
......@@ -138,5 +140,15 @@ public class BillEditView extends GenericCDIView {
public void expireBill() {
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;
import javax.faces.model.ListDataModel;
import javax.inject.Inject;
import javax.inject.Named;
import javax.management.RuntimeErrorException;
import fi.codecrew.moya.beans.BillBeanLocal;
import fi.codecrew.moya.bortal.views.BillSummary;
import fi.codecrew.moya.enums.apps.BillPermission;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.web.annotations.SelectedUser;
......@@ -95,7 +97,11 @@ public class BillListView extends GenericCDIView {
public String markPaid() {
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");
} else {
......
......@@ -36,6 +36,7 @@ import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.FoodWaveBeanLocal;
import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.enums.apps.ShopPermission;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.FoodWave;
import fi.codecrew.moya.model.LanEventPropertyKey;
......@@ -169,11 +170,31 @@ public class FoodWaveFoodView extends GenericCDIView {
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()
{
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");
return "/useradmin/edit";
}
......
......@@ -42,6 +42,7 @@ import fi.codecrew.moya.beans.FoodWaveBeanLocal;
import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.enums.apps.BillPermission;
import fi.codecrew.moya.enums.apps.ShopPermission;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.AccountEvent;
import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.BillLine;
......@@ -109,12 +110,11 @@ public class FoodWaveView extends GenericCDIView {
if (super.requirePermissions(ShopPermission.MANAGE_FOODWAVES))
{
if (foodWaves == null) {
super.beginConversation();
foodWaves = new ListDataModel<FoodWave>(foodWaveBean.getEventFoodWaves());
}
}
foodWaves = new ListDataModel<FoodWave>(foodWaveBean.getEventFoodWaves());
}
public String createFoodwave() {
......@@ -251,11 +251,52 @@ public class FoodWaveView extends GenericCDIView {
// 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() {
if (permbean.hasPermission(BillPermission.WRITE_ALL) && bills != null && bills.isRowAvailable()) {
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();
selectedFoodWave = null;
......
<?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">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout>
</appender>
<!--
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>moya.log</file>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${com.sun.aas.instanceRoot}/logs/server.log</file>
<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>
<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>
-->
<logger name="fi.codecrew" level="TRACE" />
<logger name="fi.codecrew" level="DEBUG" />
<root level="DEBUG">
<appender-ref ref="console" />
<!-- <appender-ref ref="FILE" /> -->
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</configuration>
handlers = org.slf4j.bridge.SLF4JBridgeHandler
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.logtoConsole=false
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!