Commit 4bde9b5e by Tuukka Kivilahti

Merge branch 'automark-zero-bill-paid' into 'master'

Add possibility to reserve places to a free event

See merge request !376
2 parents 524058c2 de41a5c1
......@@ -33,6 +33,7 @@ import javax.ejb.EJBAccessException;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import fi.codecrew.moya.model.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -46,14 +47,6 @@ import fi.codecrew.moya.facade.BillFacade;
import fi.codecrew.moya.facade.BillLineFacade;
import fi.codecrew.moya.facade.EventUserFacade;
import fi.codecrew.moya.facade.PlaceSlotFacade;
import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.BillLine;
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.PlaceSlot;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.utilities.SearchResult;
import fi.codecrew.moya.utilities.moyamessage.MoyaEventType;
......@@ -234,7 +227,7 @@ public class BillBean implements BillBeanLocal {
/**
* 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
......@@ -278,12 +271,20 @@ public class BillBean implements BillBeanLocal {
billFacade.create(bill);
generateBillNumber(bill);
createPlaceslots(bill);
// If we allow bills with zero price
// we will mark them immediately as paid.
if (bill.getTotalPrice().compareTo(BigDecimal.ZERO) == 0
&& eventbean.getPropertyBoolean(LanEventPropertyKey.ALLOW_FREE_BILLS)) {
bill = billpbean.markPaid(bill, Calendar.getInstance(), false);
}
return bill;
}
/**
* Create place slots for the bill
*
*
* @param bill
*/
private void createPlaceslots(Bill bill) {
......
......@@ -60,7 +60,8 @@ public enum LanEventPropertyKey {
/**
* ISO 4217 code of currency.
*/
EVENT_CURRENCY_CODE(Type.TEXT, "EUR");
EVENT_CURRENCY_CODE(Type.TEXT, "EUR"),
ALLOW_FREE_BILLS(Type.BOOL),
;
public enum Type {
......
......@@ -18,6 +18,7 @@
*/
package fi.codecrew.moya.web.cdiview.shop;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
......@@ -78,12 +79,12 @@ public class BillEditView extends GenericCDIView {
public boolean isCheckoutFiAvailable()
{
return checkoutbean.isPaymentEnabled();
return bill != null && !bill.isPaid() && checkoutbean.isPaymentEnabled();
}
public boolean isVerkkomaksuFiAvailable()
{
return vmbean.isSvmEnabled();
return bill != null && !bill.isPaid() && vmbean.isSvmEnabled();
}
public List<CheckoutBank> getCheckoutFiToken()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!