Commit f0988ecb by Tuukka Kivilahti

ruokatilauksien maksu crediiteillä ja laskutauhkaa

1 parent a44542ec
......@@ -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);
......
......@@ -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,42 +229,76 @@ public class BillBean implements BillBeanLocal {
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);
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");
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());
// 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());
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);
for (BillLine bl : bill.getBillLines()) {
......@@ -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);
}
}
}
......@@ -74,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}" /> -->
......
......@@ -68,6 +68,9 @@
<br></br>
<h:form id="billList">
<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']}" />
......@@ -116,13 +119,24 @@
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText>
</p:column>
<p:column>
<p:commandButton rendered="#{not bill.expired and not foodWaveView.selectedFoodWave.paymentOver}" value="#{i18n['bill.markPaid']}" actionListener="#{foodWaveView.markBillPaid}" update=":billList :accountEventList" />
<p:commandButton rendered="#{bill.expired or foodWaveView.selectedFoodWave.paymentOver}" 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>
......@@ -132,30 +146,34 @@
</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>
......
......@@ -23,7 +23,7 @@
<ui:define name="content">
<!-- products:shop commitaction="#{foodWaveFoodView.commitShoppingCart()}" items="#{foodWaveFoodView.shoppingcart}" commitValue="#{i18n['productshop.commit']}" /-->
<foodwave:listFoods selectaction="#{foodWaveFoodView.buyFromInternet()}" items="#{foodWaveFoodView.shoppingcart}" commitValue="foodshop.buyAndPay"/>
<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>
......
......@@ -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>
......@@ -84,17 +85,14 @@
<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>
......@@ -106,7 +104,10 @@
</h:outputText>
</div>
<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>
......
......@@ -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>
......
......@@ -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
......@@ -165,9 +168,12 @@ foodWave.closeNow = Close now
foodWave.deliveredCount = Luovutetut
foodWave.openNow = Open now
foodshop.canBuyToCounter = Huomaathan ett\u00E4 voit maksaa tilauksen my\u00F6s infotiskille.
foodshop.buyAndPayWithCredits = Varaa ja maksa krediiteill\u00E4
foodshop.buyProceedToPay = Varaa ja siirry maksamaan
foodshop.canBuyToCounter = Voit maksaa t\u00E4m\u00E4n ruokatilauksen my\u00F6s infotiskille.
foodwave.cancelOrder = Peruuta
foodwave.closed = Ruokatilaus on suljettu
foodwave.foodwaveLastBillPayTime = Maksut viimeist\u00E4\u00E4n
foodwave.ordersBefore = Tilaukset ennen
foodwave.template.waitPaymentsMinutes = Verkkomaksujen odotusaika
......
......@@ -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
......@@ -429,13 +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.canBuyToCounter = You can also pay food order to infodesk.
foodshop.buyProceedToPay = Reserve and continue to buy
foodshop.canBuyToCounter = You can buy this bill on infodesk.
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
......
......@@ -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
......@@ -430,13 +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.canBuyToCounter = Voit maksaa ruokatilaukset my\u00F6s infotiskille.
foodshop.buyProceedToPay = Varaa ja siirry maksamaan
foodshop.canBuyToCounter = Voit maksaa t\u00E4m\u00E4n ruokatilauksen my\u00F6s infotiskille.
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
......
......@@ -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;
......@@ -139,4 +141,14 @@ public class BillEditView extends GenericCDIView {
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;
......@@ -170,10 +171,30 @@ 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;
......@@ -267,8 +268,35 @@ public class FoodWaveView extends GenericCDIView {
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;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!