Commit 5e39268b by Tuukka Kivilahti

configurable bill expire time

1 parent 1d4beab5
......@@ -187,6 +187,22 @@ public class EventBean implements EventBeanLocal {
public LanEventProperty getProperty(LanEventPropertyKey property) {
return eventPropertyFacade.find(getCurrentEvent(), property);
}
@Override
public long getPropertyLong(LanEventPropertyKey property)
{
LanEventProperty retProp = eventPropertyFacade.find(getCurrentEvent(), property);
long ret = 0;
if (retProp == null) {
ret = Long.parseLong(property.getDefaultvalue());
} else {
ret = retProp.getLongValue();
}
return ret;
}
@Override
public String getPropertyString(LanEventPropertyKey property)
......
......@@ -35,5 +35,7 @@ public interface EventBeanLocal {
List<LanEventPrivateProperty> getPrivateProperties();
LanEventPrivateProperty saveOrCreatePrivateProperty(LanEventPrivateProperty privateProperty);
long getPropertyLong(LanEventPropertyKey property);
}
......@@ -195,24 +195,35 @@ public class Bill extends GenericEntity {
return total;
}
public Bill(LanEvent event, EventUser user) {
this(event);
public Bill(LanEvent event, EventUser user, Calendar expires) {
this(event, expires);
this.setUser(user);
this.setAddr1(user.getUser().getFirstnames() + " " + user.getUser().getLastname());
this.setAddr2(user.getUser().getAddress());
this.setAddr3(user.getUser().getZip() + " " + user.getUser().getTown());
}
public Bill(LanEvent event) {
public Bill(LanEvent event, Calendar expires) {
this();
this.expires = expires;
this.event = event;
}
public Bill(LanEvent event, EventUser user, long expireTimeHours) {
this(event, user, Calendar.getInstance());
this.expires.setTimeInMillis((System.currentTimeMillis() + (expireTimeHours*60*60 * 1000 )));
}
public Bill(LanEvent event, long expireTimeHours) {
this(event, Calendar.getInstance());
this.expires.setTimeInMillis((System.currentTimeMillis() + (expireTimeHours*60*60 * 1000 )));
}
public Bill() {
super();
this.expires = Calendar.getInstance();
this.expires.setTimeInMillis((System.currentTimeMillis() + 1814400000l)); // 3vk
this.expires.setTimeInMillis((System.currentTimeMillis() + 1209600000)); // 2vk
}
public Calendar getDueDate() {
......
......@@ -17,6 +17,7 @@ public enum LanEventPropertyKey {
CHECK_BILL_STATS_PERMISSION(Type.BOOL, null),
GATHER_OTHER_BILL_INFO(Type.BOOL, null),
ALLOW_BILLING(Type.BOOL, null),
BILL_EXPIRE_HOURS(Type.LONG, "168"),
TEMPLATE_PROPERTY1(Type.TEXT, null),
TEMPLATE_PROPERTY2(Type.TEXT, null),
TEMPLATE_PROPERTY3(Type.TEXT, null),
......@@ -26,7 +27,7 @@ public enum LanEventPropertyKey {
;
private enum Type {
TEXT, DATE, DATA, BOOL
TEXT, DATE, DATA, BOOL, LONG
};
private final String defaultvalue;
......@@ -47,6 +48,10 @@ public enum LanEventPropertyKey {
public boolean isBoolean() {
return Type.BOOL.equals(type);
}
public boolean isLong() {
return Type.LONG.equals(type);
}
private LanEventPropertyKey(Type t, String def)
{
......
......@@ -130,6 +130,12 @@
<h:outputLabel rendered="#{eventPropertyView.property.key.boolean}" for="booleanval" value="#{i18n['lanEventProperty.booleanValue']}" />
<h:selectBooleanCheckbox rendered="#{eventPropertyView.property.key.boolean}" id="booleanval" value="#{eventPropertyView.property.booleanValue}" />
<h:message rendered="#{eventPropertyView.property.key.boolean}" for="booleanval" />
<h:outputLabel rendered="#{eventPropertyView.property.key.long}" for="longval" value="#{i18n['lanEventProperty.longValue']}" />
<h:inputText rendered="#{eventPropertyView.property.key.long}" id="longval" value="#{eventPropertyView.property.longValue}" >
<f:convertNumber type="number" />
</h:inputText>
<h:message rendered="#{eventPropertyView.property.key.long}" for="longval" />
</h:panelGrid>
<h:commandButton action="#{eventPropertyView.saveProperty}" value="#{i18n['lanEventProperty.save']}" />
......
......@@ -20,6 +20,7 @@ import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.enums.apps.ShopPermission;
import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.FoodWave;
import fi.codecrew.moya.model.LanEventPropertyKey;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.user.UserView;
......@@ -133,7 +134,7 @@ public class FoodWaveFoodView extends GenericCDIView {
* @return
*/
public Bill createBillFromShoppingcart() {
Bill bill = new Bill(eventBean.getCurrentEvent(), userview.getSelectedUser());
Bill bill = new Bill(eventBean.getCurrentEvent(), userview.getSelectedUser(), eventBean.getPropertyLong(LanEventPropertyKey.BILL_EXPIRE_HOURS));
bill.setOurReference(eventBean.getCurrentEvent().getName());
for (ProductShopItem shopitem : shoppingcart) {
......
......@@ -296,7 +296,7 @@ public class ProductShopView extends GenericCDIView {
return null;
}
Bill bill = new Bill(eventbean.getCurrentEvent(), user);
Bill bill = new Bill(eventbean.getCurrentEvent(), user, eventbean.getPropertyLong(LanEventPropertyKey.BILL_EXPIRE_HOURS));
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!