Commit 97d4f159 by Tuomas Riihimäki

Change Bill.sentDate from Calendar to Date

1 parent 83c14b71
...@@ -20,6 +20,7 @@ package fi.codecrew.moya.beans; ...@@ -20,6 +20,7 @@ package fi.codecrew.moya.beans;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.ejb.Local; import javax.ejb.Local;
...@@ -33,6 +34,6 @@ public interface DiscountBeanLocal { ...@@ -33,6 +34,6 @@ public interface DiscountBeanLocal {
Discount save(Discount discount); Discount save(Discount discount);
public List<Discount> getActiveDiscountsByProduct(Product product, BigDecimal quantity, Calendar time, EventUser user); public List<Discount> getActiveDiscountsByProduct(Product product, BigDecimal quantity, Date time, EventUser user);
} }
...@@ -20,6 +20,7 @@ package fi.codecrew.moya.beans; ...@@ -20,6 +20,7 @@ package fi.codecrew.moya.beans;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -67,7 +68,7 @@ public interface ProductBeanLocal { ...@@ -67,7 +68,7 @@ public interface ProductBeanLocal {
Discount save(Discount discount); Discount save(Discount discount);
BigDecimal calculateTotal(Product product, BigDecimal quantity, Calendar date, EventUser user); BigDecimal calculateTotal(Product product, BigDecimal quantity, Date date, EventUser user);
HashMap<Integer, BigDecimal> getProductLimit(Map<Integer, BigDecimal> prodCounts, EventUser user); HashMap<Integer, BigDecimal> getProductLimit(Map<Integer, BigDecimal> prodCounts, EventUser user);
......
...@@ -264,7 +264,7 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal { ...@@ -264,7 +264,7 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal {
final StringBuilder stamp = new StringBuilder(); final StringBuilder stamp = new StringBuilder();
stamp.append(bill.getId()); stamp.append(bill.getId());
stamp.append(STAMP_SPLITCHAR); stamp.append(STAMP_SPLITCHAR);
stamp.append(bill.getSentDate().getTimeInMillis() / 1000); stamp.append(bill.getSentDate().getTime() / 1000);
return stamp.toString(); return stamp.toString();
} }
......
...@@ -21,6 +21,7 @@ package fi.codecrew.moya.beans; ...@@ -21,6 +21,7 @@ package fi.codecrew.moya.beans;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.ejb.EJB; import javax.ejb.EJB;
...@@ -58,7 +59,7 @@ public class DiscountBean implements DiscountBeanLocal { ...@@ -58,7 +59,7 @@ public class DiscountBean implements DiscountBeanLocal {
} }
@Override @Override
public List<Discount> getActiveDiscountsByProduct(Product product, BigDecimal quantity, Calendar time, EventUser user) { public List<Discount> getActiveDiscountsByProduct(Product product, BigDecimal quantity, Date time, EventUser user) {
ArrayList<Discount> ret = new ArrayList<Discount>(); ArrayList<Discount> ret = new ArrayList<Discount>();
for (Discount d : product.getDiscounts()) { for (Discount d : product.getDiscounts()) {
...@@ -84,21 +85,4 @@ public class DiscountBean implements DiscountBeanLocal { ...@@ -84,21 +85,4 @@ public class DiscountBean implements DiscountBeanLocal {
} }
// @Override
// public Discount create(String discountdesc) {
// LanEvent ev = eventbean.getCurrentEvent();
// Discount ret = new Discount(ev);
// ret.setShortdesc(discountdesc);
// ev.getDiscounts().add(ret);
// discountfacade.flush();
//
// // discountfacade.create(ret);
// // eventfacade.evict(eventbean.getCurrentEvent());
//
// return ret;
//
// }
} }
...@@ -176,7 +176,7 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -176,7 +176,7 @@ public class PlaceBean implements PlaceBeanLocal {
BigDecimal total = Bill.BILL_SCALED_ZERO_PRICE; BigDecimal total = Bill.BILL_SCALED_ZERO_PRICE;
Calendar now = Calendar.getInstance(); Date now = new Date();
for (Entry<Product, Integer> entry : mockmap.entrySet()) { for (Entry<Product, Integer> entry : mockmap.entrySet()) {
logger.debug("Adding to price {} of {}", entry.getValue(), entry.getKey().getName()); logger.debug("Adding to price {} of {}", entry.getValue(), entry.getKey().getName());
if (entry.getKey() != null) { if (entry.getKey() != null) {
...@@ -350,7 +350,7 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -350,7 +350,7 @@ public class PlaceBean implements PlaceBeanLocal {
} }
for (Entry<Product, Integer> line : getPlaceProductcount(places).entrySet()) { for (Entry<Product, Integer> line : getPlaceProductcount(places).entrySet()) {
productPBean.createAccountEvent(line.getKey(), new BigDecimal(line.getValue()), user, Calendar.getInstance()); productPBean.createAccountEvent(line.getKey(), new BigDecimal(line.getValue()), user, new Date());
} }
} }
PlaceGroup pg = new PlaceGroup(event, Calendar.getInstance(), Calendar.getInstance(), true); PlaceGroup pg = new PlaceGroup(event, Calendar.getInstance(), Calendar.getInstance(), true);
......
...@@ -22,6 +22,7 @@ import java.math.BigDecimal; ...@@ -22,6 +22,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
...@@ -417,7 +418,7 @@ public class ProductBean implements ProductBeanLocal { ...@@ -417,7 +418,7 @@ public class ProductBean implements ProductBeanLocal {
} }
@Override @Override
public BigDecimal calculateTotal(Product product, BigDecimal quantity, Calendar date, EventUser user) { public BigDecimal calculateTotal(Product product, BigDecimal quantity, Date date, EventUser user) {
if (product == null || quantity == null) { if (product == null || quantity == null) {
throw new RuntimeException("Some parameter is null!"); throw new RuntimeException("Some parameter is null!");
} }
...@@ -478,7 +479,7 @@ public class ProductBean implements ProductBeanLocal { ...@@ -478,7 +479,7 @@ public class ProductBean implements ProductBeanLocal {
@Override @Override
public AccountEvent createAccountEvent(Product product, BigDecimal quantity, EventUser user) { public AccountEvent createAccountEvent(Product product, BigDecimal quantity, EventUser user) {
user = eventUserFacade.reload(user); user = eventUserFacade.reload(user);
AccountEvent ret = productPBean.createAccountEvent(product, quantity, user, Calendar.getInstance()); AccountEvent ret = productPBean.createAccountEvent(product, quantity, user, new Date());
cardTemplateBean.checkPrintedCard(user); cardTemplateBean.checkPrintedCard(user);
return ret; return ret;
} }
...@@ -487,7 +488,7 @@ public class ProductBean implements ProductBeanLocal { ...@@ -487,7 +488,7 @@ public class ProductBean implements ProductBeanLocal {
public AccountEvent createAccountEvent(Product product, BigDecimal overriddenUnitPrice, BigDecimal quantity, EventUser user) { public AccountEvent createAccountEvent(Product product, BigDecimal overriddenUnitPrice, BigDecimal quantity, EventUser user) {
user = eventUserFacade.reload(user); user = eventUserFacade.reload(user);
AccountEvent ret = productPBean.createAccountEvent(product, overriddenUnitPrice, quantity, user, Calendar.getInstance(), null); AccountEvent ret = productPBean.createAccountEvent(product, overriddenUnitPrice, quantity, user, new Date(), null);
cardTemplateBean.checkPrintedCard(user); cardTemplateBean.checkPrintedCard(user);
return ret; return ret;
} }
......
...@@ -21,6 +21,7 @@ package fi.codecrew.moya.beans; ...@@ -21,6 +21,7 @@ package fi.codecrew.moya.beans;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.ejb.*; import javax.ejb.*;
...@@ -73,7 +74,7 @@ public class ProductPBean { ...@@ -73,7 +74,7 @@ public class ProductPBean {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
public AccountEvent createAccountEvent(Product product, BigDecimal quantity, EventUser user, Calendar date) { public AccountEvent createAccountEvent(Product product, BigDecimal quantity, EventUser user, Date date) {
return this.createAccountEvent(product, null, quantity, user, date, null); return this.createAccountEvent(product, null, quantity, user, date, null);
} }
...@@ -94,7 +95,7 @@ public class ProductPBean { ...@@ -94,7 +95,7 @@ public class ProductPBean {
* AccountEvent creation time * AccountEvent creation time
* @return The created AccountEvent entity * @return The created AccountEvent entity
*/ */
public AccountEvent createAccountEvent(Product product, BigDecimal overriddenUnitPrice, BigDecimal quantity, EventUser user, Calendar date, FoodWave foodwave) { public AccountEvent createAccountEvent(Product product, BigDecimal overriddenUnitPrice, BigDecimal quantity, EventUser user, Date date, FoodWave foodwave) {
if (!accounteventfacade.isAttached(product)) { if (!accounteventfacade.isAttached(product)) {
product = productFacade.reload(product); product = productFacade.reload(product);
......
...@@ -80,10 +80,9 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -80,10 +80,9 @@ public class ReaderBean implements ReaderBeanLocal {
private static final Logger logger = LoggerFactory.getLogger(ReaderBean.class); private static final Logger logger = LoggerFactory.getLogger(ReaderBean.class);
@Override @Override
public ReaderEvent checkCode(String code) { public ReaderEvent checkCode(String code) {
return checkCode(ReaderType.BARCODE.toString()+":handheld_reader_via_browser", code); return checkCode(ReaderType.BARCODE.toString() + ":handheld_reader_via_browser", code);
} }
@Override @Override
...@@ -109,8 +108,8 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -109,8 +108,8 @@ public class ReaderBean implements ReaderBeanLocal {
/** /**
* Some of rfid-readers adds zeros to start, some to end * Some of rfid-readers adds zeros to start, some to end
* *
* Also, under 16 char -rdid (the smaller one) should be 16 character long, * Also, under 16 char -rdid (the smaller one) should be 16 character
* with zeros on beginning. * long, with zeros on beginning.
*/ */
if (ReaderType.RFID.equals(reader.getType())) { if (ReaderType.RFID.equals(reader.getType())) {
...@@ -126,7 +125,6 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -126,7 +125,6 @@ public class ReaderBean implements ReaderBeanLocal {
code = sb.toString(); code = sb.toString();
} }
ReaderEvent event = new ReaderEvent(new Date(), reader, code); ReaderEvent event = new ReaderEvent(new Date(), reader, code);
// first, check if dublicate, there is 30s timeout for dublicates, // first, check if dublicate, there is 30s timeout for dublicates,
...@@ -189,7 +187,7 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -189,7 +187,7 @@ public class ReaderBean implements ReaderBeanLocal {
if (reader.isAutoproduct()) { if (reader.isAutoproduct()) {
EventUser eu = userbean.getEventUser(card.getUser().getUser(), false); EventUser eu = userbean.getEventUser(card.getUser().getUser(), false);
if (eu != null) { if (eu != null) {
AccountEvent createAc = productPBean.createAccountEvent(reader.getAutomaticProduct(), reader.getAutomaticProductCount(), eu, Calendar.getInstance()); AccountEvent createAc = productPBean.createAccountEvent(reader.getAutomaticProduct(), reader.getAutomaticProductCount(), eu, new Date());
readerfacade.flush(); readerfacade.flush();
logger.info("Creating new accountevent from autoproduct {}", createAc); logger.info("Creating new accountevent from autoproduct {}", createAc);
event.setNotes("Created automatic account event from reader. " + createAc); event.setNotes("Created automatic account event from reader. " + createAc);
...@@ -208,13 +206,10 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -208,13 +206,10 @@ public class ReaderBean implements ReaderBeanLocal {
// you can select between this and flushCache. // you can select between this and flushCache.
card = cardfacade.reload(card); card = cardfacade.reload(card);
CardCode code = new CardCode(card, readerEvent.getReader().getType(), readerEvent.getValue(), eventbean.getCurrentEvent()); CardCode code = new CardCode(card, readerEvent.getReader().getType(), readerEvent.getValue(), eventbean.getCurrentEvent());
cardCodeFacade.create(code); cardCodeFacade.create(code);
card.getCardCodes().add(code); card.getCardCodes().add(code);
return readerEvent; return readerEvent;
......
...@@ -77,7 +77,7 @@ public class CheckoutFiBeanTest { ...@@ -77,7 +77,7 @@ public class CheckoutFiBeanTest {
bill.setAddr2("Hervannantie 1"); bill.setAddr2("Hervannantie 1");
bill.setAddr3("33600 Tampere"); bill.setAddr3("33600 Tampere");
bill.setAddr4("FINLAND"); bill.setAddr4("FINLAND");
bill.setSentDateTime(d); bill.setSentDate(d);
Product prod = new Product(); Product prod = new Product();
prod.setName("Hurr"); prod.setName("Hurr");
prod.setPrice(BigDecimal.valueOf(111.11).setScale(4, RoundingMode.HALF_UP)); prod.setPrice(BigDecimal.valueOf(111.11).setScale(4, RoundingMode.HALF_UP));
......
...@@ -120,7 +120,7 @@ public class Bill extends GenericEntity { ...@@ -120,7 +120,7 @@ public class Bill extends GenericEntity {
@Column(nullable = false, name = "sent_time") @Column(nullable = false, name = "sent_time")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar sentDate = Calendar.getInstance(); private Date sentDate = new Date();
@Column(name = "payment_time", nullable = false) @Column(name = "payment_time", nullable = false)
private Integer paymentTime = 0; private Integer paymentTime = 0;
...@@ -265,12 +265,12 @@ public class Bill extends GenericEntity { ...@@ -265,12 +265,12 @@ public class Bill extends GenericEntity {
this.expires = new Date(System.currentTimeMillis() + 14 * 24 * 60 * 60 * 1000); // 2vk this.expires = new Date(System.currentTimeMillis() + 14 * 24 * 60 * 60 * 1000); // 2vk
} }
public Calendar getDueDate() { public Date getDueDate() {
Calendar dueDate = Calendar.getInstance(); Calendar dueDate = Calendar.getInstance();
dueDate.setTime(this.getSentDate().getTime()); dueDate.setTime(this.getSentDate());
dueDate.add(Calendar.DATE, this.getPaymentTime()); dueDate.add(Calendar.DATE, this.getPaymentTime());
return dueDate; return dueDate.getTime();
} }
public String getNotes() { public String getNotes() {
...@@ -420,35 +420,11 @@ public class Bill extends GenericEntity { ...@@ -420,35 +420,11 @@ public class Bill extends GenericEntity {
this.paidDate = paidDate; this.paidDate = paidDate;
} }
public Date getSentDateTime() public Date getSentDate() {
{
Date ret = null;
if (sentDate != null)
{
ret = sentDate.getTime();
}
return ret;
}
public void setSentDateTime(Date date)
{
if (date == null)
{
sentDate = null;
} else {
if (sentDate == null)
{
sentDate = Calendar.getInstance();
}
sentDate.setTime(date);
}
}
public Calendar getSentDate() {
return sentDate; return sentDate;
} }
public void setSentDate(Calendar sentDate) { public void setSentDate(Date sentDate) {
this.sentDate = sentDate; this.sentDate = sentDate;
} }
......
...@@ -21,7 +21,6 @@ package fi.codecrew.moya.model; ...@@ -21,7 +21,6 @@ package fi.codecrew.moya.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -61,10 +60,10 @@ public class Discount extends GenericEntity { ...@@ -61,10 +60,10 @@ public class Discount extends GenericEntity {
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
@Column(name = "valid_from") @Column(name = "valid_from")
private Calendar validFrom; private Date validFrom;
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
@Column(name = "valid_to") @Column(name = "valid_to")
private Calendar validTo; private Date validTo;
@Lob @Lob
@Column(name = "details") @Column(name = "details")
...@@ -225,65 +224,19 @@ public class Discount extends GenericEntity { ...@@ -225,65 +224,19 @@ public class Discount extends GenericEntity {
this.event = event; this.event = event;
} }
public Date getValidToTime() public Date getValidTo() {
{
Date ret = null;
if (validTo != null) {
ret = validTo.getTime();
}
return ret;
}
public void setValidToTime(Date date)
{
if (date == null)
{
validTo = null;
} else {
if (validTo == null) {
validTo = Calendar.getInstance();
}
validTo.setTime(date);
}
}
public Date getValidFromTime()
{
Date ret = null;
if (validFrom != null) {
ret = validFrom.getTime();
}
return ret;
}
public void setValidFromTime(Date date)
{
if (date == null)
{
validFrom = null;
} else {
if (validFrom == null) {
validFrom = Calendar.getInstance();
}
validFrom.setTime(date);
}
}
public Calendar getValidTo() {
return validTo; return validTo;
} }
public void setValidTo(Calendar validTo) { public void setValidTo(Date validTo) {
this.validTo = validTo; this.validTo = validTo;
} }
public Calendar getValidFrom() { public Date getValidFrom() {
return validFrom; return validFrom;
} }
public void setValidFrom(Calendar validFrom) { public void setValidFrom(Date validFrom) {
this.validFrom = validFrom; this.validFrom = validFrom;
} }
......
<!DOCTYPE html <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:users="http://java.sun.com/jsf/composite/tools/user" xmlns:c="http://java.sun.com/jsp/jstl/core"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:users="http://java.sun.com/jsf/composite/tools/user" xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body> <h:body>
<ui:composition template="#{sessionHandler.template}"> <ui:composition template="#{sessionHandler.template}">
<f:metadata> <f:metadata>
...@@ -43,9 +44,11 @@ ...@@ -43,9 +44,11 @@
<h:inputText id="addr5" value="#{billEditView.bill.addr5}" /> <h:inputText id="addr5" value="#{billEditView.bill.addr5}" />
<h:outputLabel for="sentDate" value="#{i18n['bill.sentDate']}:" /> <h:outputLabel for="sentDate" value="#{i18n['bill.sentDate']}:" />
<h:inputText id="sentDate" value="#{billEditView.bill.sentDateTime}"> <p:calendar id="sentDate" value="#{billEditView.bill.sentDate}" pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:inputText>
<h:outputLabel for="expires" value="#{i18n['bill.expires']}:" />
<p:calendar id="expires" value="#{billEditView.bill.expires}" pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
<h:outputLabel for="paymenttime" value="#{i18n['bill.paymentTime']}:" /> <h:outputLabel for="paymenttime" value="#{i18n['bill.paymentTime']}:" />
<h:inputText id="paymenttime" value="#{billEditView.bill.paymentTime}" /> <h:inputText id="paymenttime" value="#{billEditView.bill.paymentTime}" />
......
...@@ -78,11 +78,11 @@ ...@@ -78,11 +78,11 @@
<f:facet name="header"> <f:facet name="header">
<h:outputLabel value="#{i18n['foodWave.billLines']}" /> <h:outputLabel value="#{i18n['foodWave.billLines']}" />
</f:facet> </f:facet>
<p:column sortBy="#{bill.sentDate.getTime()}"> <p:column sortBy="#{bill.sentDate}">
<f:facet name="header"> <f:facet name="header">
<h:outputLabel value="#{i18n['billLine.time']}" /> <h:outputLabel value="#{i18n['billLine.time']}" />
</f:facet> </f:facet>
<h:outputText value="#{bill.sentDate.getTime()}"> <h:outputText value="#{bill.sentDate}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText> </h:outputText>
</p:column> </p:column>
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
</h:outputText> </h:outputText>
<h:outputLabel for="sentDate" value="#{i18n['bill.sentDate']}:" /> <h:outputLabel for="sentDate" value="#{i18n['bill.sentDate']}:" />
<h:outputText id="sentDate" value="#{cc.attrs.bill.sentDateTime}"> <h:outputText id="sentDate" value="#{cc.attrs.bill.sentDate}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText> </h:outputText>
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<h:outputText rendered="{!cc.attrs.bill.expired and sessionHandler.isEventBoolProperty('ALLOW_BILLING')}" id="noticetime" value="#{cc.attrs.bill.noticetime}" /> <h:outputText rendered="{!cc.attrs.bill.expired and sessionHandler.isEventBoolProperty('ALLOW_BILLING')}" id="noticetime" value="#{cc.attrs.bill.noticetime}" />
<h:outputLabel rendered="#{cc.attrs.bill != null}" for="expires" value="#{i18n['bill.expires']}:" /> <h:outputLabel rendered="#{cc.attrs.bill != null}" for="expires" value="#{i18n['bill.expires']}:" />
<h:outputText rendered="#{cc.attrs.bill != null}" id="expires" value="#{cc.attrs.bill.expires.time}"> <h:outputText rendered="#{cc.attrs.bill != null}" id="expires" value="#{cc.attrs.bill.expires}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText> </h:outputText>
......
...@@ -50,11 +50,11 @@ ...@@ -50,11 +50,11 @@
<h:message for="maxnum" /> <h:message for="maxnum" />
<h:outputLabel for="validFrom" value="#{i18n['discount.validFrom']}:" /> <h:outputLabel for="validFrom" value="#{i18n['discount.validFrom']}:" />
<p:calendar id="validFrom" value="#{productView.discount.validFromTime}" style="simple" pattern="#{sessionHandler.datetimeFormat}" /> <p:calendar id="validFrom" value="#{productView.discount.validFrom}" style="simple" pattern="#{sessionHandler.datetimeFormat}" />
<h:message for="validFrom" /> <h:message for="validFrom" />
<h:outputLabel for="validTo" value="#{i18n['discount.validTo']}:" /> <h:outputLabel for="validTo" value="#{i18n['discount.validTo']}:" />
<p:calendar id="validTo" value="#{productView.discount.validToTime}" style="simple" pattern="#{sessionHandler.datetimeFormat}" /> <p:calendar id="validTo" value="#{productView.discount.validTo}" style="simple" pattern="#{sessionHandler.datetimeFormat}" />
<h:message for="validTo" /> <h:message for="validTo" />
<h:outputLabel for="active" value="#{i18n['discount.active']}" /> <h:outputLabel for="active" value="#{i18n['discount.active']}" />
......
...@@ -17,25 +17,21 @@ import javax.ws.rs.core.MediaType; ...@@ -17,25 +17,21 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder; import javax.ws.rs.core.Response.ResponseBuilder;
import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.enums.apps.UserPermission;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.PermissionBeanLocal; import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.beans.PlaceBeanLocal; import fi.codecrew.moya.beans.PlaceBeanLocal;
import fi.codecrew.moya.beans.map.QueueBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal; import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.beans.map.QueueBeanLocal;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.EventMap; import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Place; import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.User;
import fi.codecrew.moya.rest.PojoUtils; import fi.codecrew.moya.rest.PojoUtils;
import fi.codecrew.moya.rest.pojo.placemap.v1.IntegerRoot; import fi.codecrew.moya.rest.pojo.placemap.v1.IntegerRoot;
import fi.codecrew.moya.rest.pojo.placemap.v1.PlacemapMapRootPojo; import fi.codecrew.moya.rest.pojo.placemap.v1.PlacemapMapRootPojo;
import fi.codecrew.moya.rest.pojo.placemap.v1.SimplePlacePojo;
import fi.codecrew.moya.rest.pojo.placemap.v1.SimplePlacelistRoot; import fi.codecrew.moya.rest.pojo.placemap.v1.SimplePlacelistRoot;
import fi.codecrew.moya.web.annotations.SelectedUser;
import fi.codecrew.moya.web.cdiview.user.UserView; import fi.codecrew.moya.web.cdiview.user.UserView;
@RequestScoped @RequestScoped
...@@ -102,14 +98,14 @@ public class PlacemapRestViewV1 { ...@@ -102,14 +98,14 @@ public class PlacemapRestViewV1 {
{ {
EventMap map = placebean.findMap(mapId); EventMap map = placebean.findMap(mapId);
if (!permbean.hasPermission(UserPermission.VIEW_ALL)) { if(!permbean.hasPermission(UserPermission.VIEW_ALL)) {
return Response.status(Response.Status.FORBIDDEN).entity("Try to login first!").build(); return Response.status(Response.Status.FORBIDDEN).entity("Try to login first!").build();
} }
EventUser user = userbean.findByUserId(userId, false); EventUser user = userbean.findByUserId(userId,false);
if (user == null) { if (user == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("No User found for id: " + userId).build(); return Response.status(Response.Status.BAD_REQUEST).entity("No User found for id: "+userId).build();
} }
return Response.ok(PojoUtils.parseSimplePlaces(map.getPlaces(), user, permbean.hasPermission(UserPermission.VIEW_ALL), true)).build(); return Response.ok(PojoUtils.parseSimplePlaces(map.getPlaces(), user, permbean.hasPermission(UserPermission.VIEW_ALL), true)).build();
......
...@@ -20,6 +20,7 @@ package fi.codecrew.moya.web.helper; ...@@ -20,6 +20,7 @@ package fi.codecrew.moya.web.helper;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import javax.ejb.EJB; import javax.ejb.EJB;
...@@ -51,7 +52,7 @@ public class ProductShopItemHelper extends GenericCDIView { ...@@ -51,7 +52,7 @@ public class ProductShopItemHelper extends GenericCDIView {
} else { } else {
item.setInternalPrice(item.getProduct().getPrice().abs().multiply(item.getCount())); item.setInternalPrice(item.getProduct().getPrice().abs().multiply(item.getCount()));
item.setInternalDiscounts(discountBean.getActiveDiscountsByProduct(item.getProduct(), item.getCount(), Calendar.getInstance(), item.getUser())); item.setInternalDiscounts(discountBean.getActiveDiscountsByProduct(item.getProduct(), item.getCount(), new Date(), item.getUser()));
item.setInternalDiscountValues(new HashMap<Integer, BigDecimal>()); item.setInternalDiscountValues(new HashMap<Integer, BigDecimal>());
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!