Commit a445e5ef by Tuomas Riihimäki

Merge branch 'master' into 'master'

Laskujen voimassaoloaika konffittavaksi

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