Commit de41a5c1 by Tuomas Riihimäki

Add possibility to reserve places to a free event

* added new event property which allows empty bills to be marked paid
* Add functionality to billbean which will mark zero-sum bill automatically paid
* Prevent online-payment buttons from being show if bill is already paid.
1 parent 0e601340
Pipeline #11 passed
in 0 seconds
...@@ -33,6 +33,7 @@ import javax.ejb.EJBAccessException; ...@@ -33,6 +33,7 @@ import javax.ejb.EJBAccessException;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import fi.codecrew.moya.model.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -46,14 +47,6 @@ import fi.codecrew.moya.facade.BillFacade; ...@@ -46,14 +47,6 @@ 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;
import fi.codecrew.moya.facade.PlaceSlotFacade; 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.SearchResult;
import fi.codecrew.moya.utilities.moyamessage.MoyaEventType; import fi.codecrew.moya.utilities.moyamessage.MoyaEventType;
...@@ -234,7 +227,7 @@ public class BillBean implements BillBeanLocal { ...@@ -234,7 +227,7 @@ public class BillBean implements BillBeanLocal {
/** /**
* We will mark bill paid in different transaction. That's because we don't * We will mark bill paid in different transaction. That's because we don't
* wont it to fail if something other fails. * wont it to fail if something other fails.
* *
* @param bill * @param bill
* @param when * @param when
* @param useCredits * @param useCredits
...@@ -278,12 +271,20 @@ public class BillBean implements BillBeanLocal { ...@@ -278,12 +271,20 @@ public class BillBean implements BillBeanLocal {
billFacade.create(bill); billFacade.create(bill);
generateBillNumber(bill); generateBillNumber(bill);
createPlaceslots(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; return bill;
} }
/** /**
* Create place slots for the bill * Create place slots for the bill
* *
* @param bill * @param bill
*/ */
private void createPlaceslots(Bill bill) { private void createPlaceslots(Bill bill) {
......
...@@ -60,7 +60,8 @@ public enum LanEventPropertyKey { ...@@ -60,7 +60,8 @@ public enum LanEventPropertyKey {
/** /**
* ISO 4217 code of currency. * 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 { public enum Type {
......
...@@ -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.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
...@@ -78,12 +79,12 @@ public class BillEditView extends GenericCDIView { ...@@ -78,12 +79,12 @@ public class BillEditView extends GenericCDIView {
public boolean isCheckoutFiAvailable() public boolean isCheckoutFiAvailable()
{ {
return checkoutbean.isPaymentEnabled(); return bill != null && !bill.isPaid() && checkoutbean.isPaymentEnabled();
} }
public boolean isVerkkomaksuFiAvailable() public boolean isVerkkomaksuFiAvailable()
{ {
return vmbean.isSvmEnabled(); return bill != null && !bill.isPaid() && vmbean.isSvmEnabled();
} }
public List<CheckoutBank> getCheckoutFiToken() 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!