Commit dffe4d34 by Juho Juopperi

Merge branch 'billexpire' into 'master'

Bill temporal fields

Initially I was suppose to just add edit field for Bill.expires, but ended up refactoring all Calendar datatypes from Bill to Date...

See merge request !290
2 parents 09c6ff98 d25a066f
...@@ -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;
...@@ -53,7 +54,7 @@ public interface ProductBeanLocal { ...@@ -53,7 +54,7 @@ public interface ProductBeanLocal {
AccountEvent createAccountEvent(Product product, BigDecimal quantity, EventUser user); AccountEvent createAccountEvent(Product product, BigDecimal quantity, EventUser user);
AccountEvent createAccountEvent(Product product, BigDecimal overriddenUnitPrice, BigDecimal quantity, EventUser user); AccountEvent createAccountEvent(Product product, BigDecimal overriddenUnitPrice, BigDecimal quantity, EventUser user);
// List<Discount> getActiveDiscounts(Product product, BigDecimal quantity); // List<Discount> getActiveDiscounts(Product product, BigDecimal quantity);
...@@ -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;
...@@ -42,7 +43,7 @@ public class DiscountBean implements DiscountBeanLocal { ...@@ -42,7 +43,7 @@ public class DiscountBean implements DiscountBeanLocal {
@EJB @EJB
private DiscountFacade discountfacade; private DiscountFacade discountfacade;
@EJB @EJB
private UserBean userBean; private UserBean userBean;
...@@ -58,47 +59,30 @@ public class DiscountBean implements DiscountBeanLocal { ...@@ -58,47 +59,30 @@ 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>();
for (Discount d : product.getDiscounts()) {
if (d.isActive() &&
(d.getValidTo() == null || d.getValidTo().after(time)) &&
(d.getValidFrom() == null || d.getValidFrom().before(time)) &&
(d.getAmountMax().compareTo(BigDecimal.ZERO) == 0 || quantity.compareTo(d.getAmountMax()) <= 0) &&
(d.getAmountMin().compareTo(BigDecimal.ZERO) == 0 || quantity.compareTo(d.getAmountMin()) >= 0)) {
// plaah, there is role, must do stuff ArrayList<Discount> ret = new ArrayList<Discount>();
if (d.getRole() != null) { for (Discount d : product.getDiscounts()) {
for (Role role : userBean.localFindUsersRoles(user)) { if (d.isActive() &&
if (d.getRole().equals(role)) { (d.getValidTo() == null || d.getValidTo().after(time)) &&
ret.add(d); (d.getValidFrom() == null || d.getValidFrom().before(time)) &&
} (d.getAmountMax().compareTo(BigDecimal.ZERO) == 0 || quantity.compareTo(d.getAmountMax()) <= 0) &&
} (d.getAmountMin().compareTo(BigDecimal.ZERO) == 0 || quantity.compareTo(d.getAmountMin()) >= 0)) {
} else {
ret.add(d);
}
}
}
return ret;
}
// @Override // plaah, there is role, must do stuff
// public Discount create(String discountdesc) { if (d.getRole() != null) {
// LanEvent ev = eventbean.getCurrentEvent(); for (Role role : userBean.localFindUsersRoles(user)) {
// Discount ret = new Discount(ev); if (d.getRole().equals(role)) {
// ret.setShortdesc(discountdesc); ret.add(d);
// ev.getDiscounts().add(ret); }
// discountfacade.flush(); }
// } else {
// // discountfacade.create(ret); ret.add(d);
// // eventfacade.evict(eventbean.getCurrentEvent()); }
// }
// return ret; }
// 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
...@@ -101,7 +100,7 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -101,7 +100,7 @@ public class ReaderBean implements ReaderBeanLocal {
if (reader == null || code == null || code.isEmpty()) { if (reader == null || code == null || code.isEmpty()) {
return null; return null;
} }
logger.info("got code from reader {}", code); logger.info("got code from reader {}", code);
code = code.replace("\"\b", ""); code = code.replace("\"\b", "");
...@@ -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);
...@@ -204,16 +202,13 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -204,16 +202,13 @@ public class ReaderBean implements ReaderBeanLocal {
@Override @Override
public ReaderEvent assocCodeToCard(ReaderEvent readerEvent, PrintedCard card) { public ReaderEvent assocCodeToCard(ReaderEvent readerEvent, PrintedCard card) {
// 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);
......
...@@ -20,6 +20,7 @@ package fi.codecrew.moya.facade; ...@@ -20,6 +20,7 @@ package fi.codecrew.moya.facade;
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;
...@@ -142,10 +143,10 @@ public class PlaceSlotFacade extends IntegerPkGenericFacade<PlaceSlot> { ...@@ -142,10 +143,10 @@ public class PlaceSlotFacade extends IntegerPkGenericFacade<PlaceSlot> {
preds.add(cb.isNotNull(bill.get(Bill_.paidDate))); preds.add(cb.isNotNull(bill.get(Bill_.paidDate)));
} else { } else {
// If expire is null or has not passed, count it // If expire is null or has not passed, count it
Path<Calendar> billexp = bill.get(Bill_.expires); Path<Date> billexp = bill.get(Bill_.expires);
preds.add(cb.or( preds.add(cb.or(
cb.isNull(billexp), cb.isNull(billexp),
cb.greaterThan(billexp, Calendar.getInstance()) cb.greaterThan(billexp, new Date())
)); ));
} }
...@@ -181,10 +182,10 @@ public class PlaceSlotFacade extends IntegerPkGenericFacade<PlaceSlot> { ...@@ -181,10 +182,10 @@ public class PlaceSlotFacade extends IntegerPkGenericFacade<PlaceSlot> {
if (paidOnly) { if (paidOnly) {
preds.add(cb.isNotNull(bill.get(Bill_.paidDate))); preds.add(cb.isNotNull(bill.get(Bill_.paidDate)));
} else { } else {
Path<Calendar> billexp = bill.get(Bill_.expires); Path<Date> billexp = bill.get(Bill_.expires);
preds.add(cb.or( preds.add(cb.or(
cb.isNull(billexp), cb.isNull(billexp),
cb.greaterThan(billexp, Calendar.getInstance()) cb.greaterThan(billexp, new Date())
)); ));
} }
......
...@@ -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,10 +120,11 @@ public class Bill extends GenericEntity { ...@@ -120,10 +120,11 @@ 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;
@Column(name = "notice_days", nullable = false) @Column(name = "notice_days", nullable = false)
private String noticetime = "8 vrk"; private String noticetime = "8 vrk";
@Column(name = "their_reference", nullable = false) @Column(name = "their_reference", nullable = false)
...@@ -137,7 +138,7 @@ public class Bill extends GenericEntity { ...@@ -137,7 +138,7 @@ public class Bill extends GenericEntity {
@Column(name = "expires", nullable = true) @Column(name = "expires", nullable = true)
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar expires = null; private Date expires = null;
/** /**
* Notes for the event organisators about the bill. * Notes for the event organisators about the bill.
...@@ -237,7 +238,7 @@ public class Bill extends GenericEntity { ...@@ -237,7 +238,7 @@ public class Bill extends GenericEntity {
return total; return total;
} }
public Bill(LanEvent event, EventUser user, Calendar expires) { public Bill(LanEvent event, EventUser user, Date expires) {
this(event, expires); 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());
...@@ -245,35 +246,31 @@ public class Bill extends GenericEntity { ...@@ -245,35 +246,31 @@ public class Bill extends GenericEntity {
this.setAddr3(user.getUser().getZip() + " " + user.getUser().getTown()); this.setAddr3(user.getUser().getZip() + " " + user.getUser().getTown());
} }
public Bill(LanEvent event, Calendar expires) { public Bill(LanEvent event, Date expires) {
this(); this();
this.expires = expires; this.expires = expires;
this.event = event; this.event = event;
} }
public Bill(LanEvent event, EventUser user, long expireTimeHours) { public Bill(LanEvent event, EventUser user, long expireTimeHours) {
this(event, user, Calendar.getInstance()); this(event, user, new Date(System.currentTimeMillis() + (expireTimeHours * 60 * 60 * 1000)));
this.expires.setTimeInMillis((System.currentTimeMillis() + (expireTimeHours * 60 * 60 * 1000)));
} }
public Bill(LanEvent event, long expireTimeHours) { public Bill(LanEvent event, long expireTimeHours) {
this(event, Calendar.getInstance()); this(event, new Date(System.currentTimeMillis() + (expireTimeHours * 60 * 60 * 1000)));
this.expires.setTimeInMillis((System.currentTimeMillis() + (expireTimeHours * 60 * 60 * 1000)));
} }
public Bill() { public Bill() {
super(); super();
this.expires = new Date(System.currentTimeMillis() + 14 * 24 * 60 * 60 * 1000); // 2vk
this.expires = Calendar.getInstance();
this.expires.setTimeInMillis((System.currentTimeMillis() + 1209600000)); // 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() {
...@@ -423,35 +420,11 @@ public class Bill extends GenericEntity { ...@@ -423,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;
} }
...@@ -479,11 +452,11 @@ public class Bill extends GenericEntity { ...@@ -479,11 +452,11 @@ public class Bill extends GenericEntity {
return false; return false;
} }
public Calendar getExpires() { public Date getExpires() {
return expires; return expires;
} }
public void setExpires(Calendar expires) { public void setExpires(Date expires) {
this.expires = expires; this.expires = expires;
} }
...@@ -491,14 +464,14 @@ public class Bill extends GenericEntity { ...@@ -491,14 +464,14 @@ public class Bill extends GenericEntity {
if (isPaid() || expires == null) if (isPaid() || expires == null)
return false; return false;
return Calendar.getInstance().after(expires); return new Date().after(expires);
} }
public void markExpired() { public void markExpired() {
if (isExpired() || isPaid()) if (isExpired() || isPaid())
return; return;
expires = Calendar.getInstance(); expires = new Date();
} }
@Transient @Transient
......
<!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>
...@@ -15,15 +16,19 @@ ...@@ -15,15 +16,19 @@
<h:form id="billform"> <h:form id="billform">
<p:panelGrid columns="2"> <p:panelGrid columns="2">
<h:outputLabel for="billid" value="#{i18n['bill.id']}:" /> <h:outputLabel for="billid" value="#{i18n['bill.id']}:" />
<h:inputText id="billid" value="#{billEditView.bill.id}" /> <h:inputText id="billid" value="#{billEditView.bill.id}" />
<h:outputLabel for="sentDate" value="#{i18n['bill.sentDate']}:" />
<p:calendar id="sentDate" value="#{billEditView.bill.sentDate}" pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
<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="paidDate" value="#{i18n['bill.paidDate']}:" /> <h:outputLabel for="paidDate" value="#{i18n['bill.paidDate']}:" />
<h:inputText id="paidDate" value="#{billEditView.bill.paidDate}"> <p:calendar id="paidDate" value="#{billEditView.bill.paidDate}" pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:inputText>
<h:outputLabel for="billnr" value="#{i18n['bill.billNumber']}:" /> <h:outputLabel for="billnr" value="#{i18n['bill.billNumber']}:" />
<h:inputText id="billnr" value="#{billEditView.bill.billNumber}" /> <h:inputText id="billnr" value="#{billEditView.bill.billNumber}" />
...@@ -42,10 +47,6 @@ ...@@ -42,10 +47,6 @@
<h:outputLabel for="addr5" value="#{i18n['bill.addr5']}:" /> <h:outputLabel for="addr5" value="#{i18n['bill.addr5']}:" />
<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:inputText id="sentDate" value="#{billEditView.bill.sentDateTime}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:inputText>
<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,17 +98,17 @@ public class PlacemapRestViewV1 { ...@@ -102,17 +98,17 @@ 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();
} }
@GET @GET
......
...@@ -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!