Commit 71611071 by Tuomas Riihimäki

Merge branch 'bill_expire_from_hours_tos_minutes' into 'master'

Bill expire from hours to minutes

See merge request !433
2 parents d3f8f960 5a98ba61
......@@ -647,6 +647,10 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbUpdates.add(new String[]{
"UPDATE place_slots SET used = now() WHERE used is null AND product_id in (SELECT product_id FROM product_productflags WHERE productflags = 'CREATE_NEW_PLACE_WHEN_BOUGHT')"
});
dbUpdates.add(new String[] {
"UPDATE event_properties SET long_value = (long_value * 60), key = 'BILL_EXPIRE_MINS' WHERE key = 'BILL_EXPIRE_HOURS'"
});
}
......
......@@ -225,7 +225,7 @@ public class ProductBean implements ProductBeanLocal {
ret.put(prod.getId(), BigDecimal.valueOf(freeCount));
} else {
BigDecimal lim = getPrivateProductLimit(prod, user, prodCounts, userroles);
BigDecimal lim = getPrivateProductLimit(prod, user, userroles);
ret.put(prod.getId(), lim);
// logger.info("Added product limit {} to {}", lim, prod);
......@@ -288,19 +288,19 @@ public class ProductBean implements ProductBeanLocal {
{
product = productFacade.reload(product);
HashSet<Role> userroles = new HashSet<Role>(userbean.findUsersRoles(user));
return getPrivateProductLimit(product, user, prodCounts, userroles);
return getPrivateProductLimit(product, user, userroles);
}
/**
* Returns available products to be bought for the user.
*
*
* @param product
* @param user
* @param prodCounts
* @param userroles
* @return Number of buyable products
*/
private BigDecimal getPrivateProductLimit(Product product, EventUser user, Map<Integer, BigDecimal> prodCounts, Set<Role> userroles)
private BigDecimal getPrivateProductLimit(Product product, EventUser user, Set<Role> userroles)
{
BigDecimal ret = null;
if (product != null && product.getProductLimits() != null)
......@@ -308,13 +308,7 @@ public class ProductBean implements ProductBeanLocal {
for (ProductLimitation limit : product.getProductLimits())
{
BigDecimal currentCount = BigDecimal.ZERO;
for (Product p : limit.getProducts())
{
currentCount = currentCount.add(prodCounts.get(p.getId()));
}
// logger.info("Got limit {} for product {}", limit, product);
if (limit.getMatchingRoles() != null && !limit.getMatchingRoles().isEmpty())
{
boolean roleMatched = false;
......@@ -330,8 +324,6 @@ public class ProductBean implements ProductBeanLocal {
}
}
BigDecimal count = currentCount;
switch (limit.getType())
{
case GLOBAL_BILLED: {
......@@ -340,8 +332,7 @@ public class ProductBean implements ProductBeanLocal {
BillSummary globBilledSummary = billLineFacade.getLineSummary(p, eventbean.getCurrentEvent());
globBillTot = globBillTot.add(globBilledSummary.getActive());
}
count = count.add(globBillTot);
ret = limit.getUpperLimit().subtract(count);
ret = limit.getUpperLimit().subtract(globBillTot);
break;
}
case GLOBAL_BILL_PAID:
......@@ -350,22 +341,21 @@ public class ProductBean implements ProductBeanLocal {
BillSummary billPaidSummary = billLineFacade.getLineSummary(p, eventbean.getCurrentEvent());
globBillPaid = globBillPaid.add(billPaidSummary.getPaid());
}
count = count.add(globBillPaid);
ret = limit.getUpperLimit().subtract(count);
ret = limit.getUpperLimit().subtract(globBillPaid);
break;
case GLOBAL_ACCOUNTEVENTS:
BigDecimal globalProductCount = accounteventfacade.getProductCount(limit.getProducts());
if (globalProductCount != null) {
count = count.add(globalProductCount);
if (globalProductCount == null) {
globalProductCount = BigDecimal.ZERO;
}
ret = limit.getUpperLimit().subtract(count);
ret = limit.getUpperLimit().subtract(globalProductCount);
break;
case USER_ACCOUNTEVENTS:
BigDecimal userProductCount = accounteventfacade.getProductCount(limit.getProducts(), user);
if (userProductCount != null) {
count = count.add(userProductCount);
if (userProductCount == null) {
userProductCount = BigDecimal.ZERO;
}
ret = limit.getUpperLimit().subtract(count);
ret = limit.getUpperLimit().subtract(userProductCount);
break;
case USER_BILLED:
BigDecimal userBillTot = BigDecimal.ZERO;
......@@ -373,8 +363,7 @@ public class ProductBean implements ProductBeanLocal {
BillSummary userBilledSummary = billLineFacade.getLineSummary(p, eventbean.getCurrentEvent(), user);
userBillTot = userBillTot.add(userBilledSummary.getActive());
}
count = count.add(userBillTot);
ret = limit.getUpperLimit().subtract(count);
ret = limit.getUpperLimit().subtract(userBillTot);
break;
case USER_BILL_PAID:
BigDecimal userBillPaid = BigDecimal.ZERO;
......@@ -382,8 +371,7 @@ public class ProductBean implements ProductBeanLocal {
BillSummary userPaidSummary = billLineFacade.getLineSummary(p, eventbean.getCurrentEvent(), user);
userBillPaid = userBillPaid.add(userPaidSummary.getPaid());
}
count = count.add(userBillPaid);
ret = limit.getUpperLimit().subtract(count);
ret = limit.getUpperLimit().subtract(userBillPaid);
break;
default:
......
......@@ -254,8 +254,8 @@ public class Bill extends GenericEntity {
this.event = event;
}
public Bill(LanEvent event, EventUser user, long expireTimeHours) {
this(event, user, new Date(System.currentTimeMillis() + (expireTimeHours * 60 * 60 * 1000)));
public Bill(LanEvent event, EventUser user, long expireTimeMins) {
this(event, user, new Date(System.currentTimeMillis() + (expireTimeMins * 60 * 1000)));
}
public Bill(LanEvent event, long expireTimeHours) {
......
......@@ -36,7 +36,7 @@ public enum LanEventPropertyKey {
GATHER_OTHER_BILL_INFO(Type.BOOL),
GATHER_SHIRT_SIZE(Type.BOOL),
ALLOW_BILLING(Type.BOOL),
BILL_EXPIRE_HOURS(Type.LONG, 1l),
BILL_EXPIRE_MINS(Type.LONG, 30l),
TEMPLATE_PROPERTY1(Type.TEXT),
TEMPLATE_PROPERTY2(Type.TEXT),
TEMPLATE_PROPERTY3(Type.TEXT),
......
......@@ -150,7 +150,7 @@ public class FoodWaveFoodView extends GenericCDIView {
* @return
*/
public Bill createBillFromShoppingcart() {
Bill bill = new Bill(eventBean.getCurrentEvent(), userview.getSelectedUser(), eventBean.getPropertyLong(LanEventPropertyKey.BILL_EXPIRE_HOURS));
Bill bill = new Bill(eventBean.getCurrentEvent(), userview.getSelectedUser(), eventBean.getPropertyLong(LanEventPropertyKey.BILL_EXPIRE_MINS));
bill.setOurReference(eventBean.getCurrentEvent().getName());
for (ProductShopItem shopitem : shoppingcart) {
......
......@@ -351,7 +351,7 @@ public class ProductShopView extends GenericCDIView {
return null;
}
Bill bill = new Bill(eventbean.getCurrentEvent(), userView.getSelectedUser(), eventbean.getPropertyLong(LanEventPropertyKey.BILL_EXPIRE_HOURS));
Bill bill = new Bill(eventbean.getCurrentEvent(), userView.getSelectedUser(), eventbean.getPropertyLong(LanEventPropertyKey.BILL_EXPIRE_MINS));
bill.setNotes(otherInfo);
bill.setOurReference(eventbean.getCurrentEvent().getName());
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!