Commit 9f445e93 by Juho Juopperi

Merge branch 'insomnia_2014' of gitlab.codecrew.fi:codecrew/moya into insomnia_2014

2 parents 72631c69 e9da7339
...@@ -24,5 +24,6 @@ public enum SecurityLogType { ...@@ -24,5 +24,6 @@ public enum SecurityLogType {
genericMessage, genericMessage,
accountEvent, accountEvent,
verkkomaksu, verkkomaksu,
bill,
} }
...@@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory; ...@@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beanutil.PdfPrinter; import fi.codecrew.moya.beanutil.PdfPrinter;
import fi.codecrew.moya.bortal.views.BillSummary; import fi.codecrew.moya.bortal.views.BillSummary;
import fi.codecrew.moya.enums.apps.BillPermission; import fi.codecrew.moya.enums.apps.BillPermission;
import fi.codecrew.moya.enums.apps.ShopPermission;
import fi.codecrew.moya.enums.apps.SpecialPermission; import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.facade.BillFacade; import fi.codecrew.moya.facade.BillFacade;
import fi.codecrew.moya.facade.BillLineFacade; import fi.codecrew.moya.facade.BillLineFacade;
...@@ -93,6 +94,9 @@ public class BillBean implements BillBeanLocal { ...@@ -93,6 +94,9 @@ public class BillBean implements BillBeanLocal {
@EJB @EJB
private DiscountBean discountBean; private DiscountBean discountBean;
@EJB
private LoggingBeanLocal logbean;
/** /**
* Default constructor. * Default constructor.
...@@ -228,16 +232,21 @@ public class BillBean implements BillBeanLocal { ...@@ -228,16 +232,21 @@ public class BillBean implements BillBeanLocal {
SpecialPermission.S_VERKKOMAKSU_CHECK }) SpecialPermission.S_VERKKOMAKSU_CHECK })
public Bill markPaid(Bill bill, Calendar when) { public Bill markPaid(Bill bill, Calendar when) {
bill = billFacade.reload(bill);
if (bill.getAccountEvent() != null || bill.getPaidDate() != null) { if (bill.getAccountEvent() != null || bill.getPaidDate() != null) {
logbean.logMessage(SecurityLogType.bill, permbean.getCurrentUser(), "Trying to doublemark bill paid");
throw new EJBException("Bill already marked paid!"); throw new EJBException("Bill already marked paid!");
} }
if (bill.isFoowavePaymentOver()) if (bill.isFoowavePaymentOver() && !permbean.hasPermission(ShopPermission.MANAGE_FOODWAVES))
{ {
logbean.logMessage(SecurityLogType.bill, permbean.getCurrentUser(), "FoodwaveClosed and marking bill for it paid");
throw new EJBException("Trying to mark paid a closed or left foodwave"); throw new EJBException("Trying to mark paid a closed or left foodwave");
} }
bill = billFacade.reload(bill);
Product creditproduct = productBean.findCreditProduct(); Product creditproduct = productBean.findCreditProduct();
EventUser user = bill.getUser(); EventUser user = bill.getUser();
...@@ -271,6 +280,8 @@ public class BillBean implements BillBeanLocal { ...@@ -271,6 +280,8 @@ public class BillBean implements BillBeanLocal {
} }
} }
/*
MailMessage msg = new MailMessage(); MailMessage msg = new MailMessage();
String subject = MessageFormat.format(eventbean.getPropertyString(LanEventPropertyKey.BILL_PAID_MAIL_SUBJECT), user.getEvent().getName()); String subject = MessageFormat.format(eventbean.getPropertyString(LanEventPropertyKey.BILL_PAID_MAIL_SUBJECT), user.getEvent().getName());
...@@ -280,9 +291,12 @@ public class BillBean implements BillBeanLocal { ...@@ -280,9 +291,12 @@ public class BillBean implements BillBeanLocal {
msg.setMessage(content); msg.setMessage(content);
msg.setTo(bill.getUser().getUser()); msg.setTo(bill.getUser().getUser());
utilbean.sendMail(msg); utilbean.sendMail(msg);
*/
eventUserFacade.flush(); eventUserFacade.flush();
logbean.logMessage(SecurityLogType.bill, permbean.getCurrentUser(), "Marking bill paid, for user: ", bill.getUser().getId(),"BillId: ",bill.getId());
eventUserFacade.evict(bill.getUser()); eventUserFacade.evict(bill.getUser());
return bill; return bill;
} }
......
...@@ -238,8 +238,13 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -238,8 +238,13 @@ public class BootstrapBean implements BootstrapBeanLocal {
// tai saadaan poikkeuksia nyrkillä kurkusta . // tai saadaan poikkeuksia nyrkillä kurkusta .
dbUpdates.add(new String[] { dbUpdates.add(new String[] {
"DELETE FROM product_productflags where productflags = 'PREPAID_INSTANT_CREATE'" "DELETE FROM product_productflags where productflags = 'PREPAID_INSTANT_CREATE'"
}); });
dbUpdates.add(new String[] {
"ALTER TABLE food_wave_templates ADD COLUMN wait_payments_minutes integer DEFAULT null;",
});
} // start_time timestamp without time zone, } // start_time timestamp without time zone,
......
...@@ -36,6 +36,7 @@ import javax.persistence.OrderBy; ...@@ -36,6 +36,7 @@ import javax.persistence.OrderBy;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -52,416 +53,448 @@ import fi.codecrew.moya.utilities.BillUtils; ...@@ -52,416 +53,448 @@ import fi.codecrew.moya.utilities.BillUtils;
@Table(name = "bills", uniqueConstraints = { @UniqueConstraint(columnNames = { Bill.EVENT_ID_COLUMN, "bill_number" }) }) @Table(name = "bills", uniqueConstraints = { @UniqueConstraint(columnNames = { Bill.EVENT_ID_COLUMN, "bill_number" }) })
public class Bill extends GenericEntity { public class Bill extends GenericEntity {
/** /**
* *
*/ */
private static final long serialVersionUID = -6713643278149221869L; private static final long serialVersionUID = -6713643278149221869L;
public static final String EVENT_ID_COLUMN = "event_id"; public static final String EVENT_ID_COLUMN = "event_id";
@ManyToOne() @ManyToOne()
@JoinColumn(name = EVENT_ID_COLUMN, nullable = false) @JoinColumn(name = EVENT_ID_COLUMN, nullable = false)
private LanEvent event; private LanEvent event;
/** /**
* When the bill is due to be paid. * When the bill is due to be paid.
*/ */
// Can be calculated from SentDate + paymentTime // Can be calculated from SentDate + paymentTime
// @Column(name = "due_date") // @Column(name = "due_date")
// @Temporal(TemporalType.TIMESTAMP) // @Temporal(TemporalType.TIMESTAMP)
// private Calendar dueDate; // private Calendar dueDate;
/** /**
* When the money has appeared on the bank account. * When the money has appeared on the bank account.
*/ */
@Column(name = "paid_date") @Column(name = "paid_date")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date paidDate; private Date paidDate;
/** /**
* The bill number from which the reference number will be generated * The bill number from which the reference number will be generated
* *
* @see http://www.fkl.fi/www/page/fk_www_1293 * @see http://www.fkl.fi/www/page/fk_www_1293
* *
*/ */
@Column(name = "bill_number") @Column(name = "bill_number")
private Integer billNumber; private Integer billNumber;
/** /**
* Address where the bill should be sent; * Address where the bill should be sent;
*/ */
private String addr1; private String addr1;
private String addr2; private String addr2;
private String addr3; private String addr3;
private String addr4; private String addr4;
private String addr5; private String addr5;
@Column(nullable = false, name = "sent_time") @Column(nullable = false, name = "sent_time")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar sentDate = Calendar.getInstance(); private Calendar sentDate = Calendar.getInstance();
@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)
private String theirReference = ""; private String theirReference = "";
@Column(name = "our_reference", nullable = false) @Column(name = "our_reference", nullable = false)
private String ourReference = ""; private String ourReference = "";
@Column(name = "delivery_terms", nullable = false) @Column(name = "delivery_terms", nullable = false)
private String deliveryTerms = ""; private String deliveryTerms = "";
@Column(name = "delay_intrest", nullable = false) @Column(name = "delay_intrest", nullable = false)
private Integer delayIntrest = 11; private Integer delayIntrest = 11;
@Column(name = "expires", nullable = true) @Column(name = "expires", nullable = true)
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar expires = null; private Calendar expires = null;
/** /**
* Notes for the event organisators about the bill. * Notes for the event organisators about the bill.
*/ */
@Lob @Lob
@Column(name = "notes") @Column(name = "notes")
private String notes; private String notes;
/** /**
* Bill may have multiple items on multiple rows. * Bill may have multiple items on multiple rows.
*/ */
@OrderBy("id") @OrderBy("id")
// @PrivateOwned // @PrivateOwned
@OneToMany(mappedBy = "bill", cascade = CascadeType.ALL) @OneToMany(mappedBy = "bill", cascade = CascadeType.ALL)
private List<BillLine> billLines = new ArrayList<BillLine>(); private List<BillLine> billLines = new ArrayList<BillLine>();
public boolean isPaid() public boolean isPaid()
{ {
return accountEvent != null || paidDate != null; return accountEvent != null || paidDate != null;
} }
/** /**
* When the bill is paid this AccountEvent is created and this is a * When the bill is paid this AccountEvent is created and this is a
* reference to that accountAction. if this bill * reference to that accountAction. if this bill
*/ */
@JoinColumn(name = "account_event_id", referencedColumnName = "id", updatable = false) @JoinColumn(name = "account_event_id", referencedColumnName = "id", updatable = false)
@OneToOne @OneToOne
private AccountEvent accountEvent; private AccountEvent accountEvent;
/** /**
* User who should pay this bill. * User who should pay this bill.
*/ */
@ManyToOne(optional = false) @ManyToOne(optional = false)
@JoinColumn(updatable = false, name = "eventuser_id") @JoinColumn(updatable = false, name = "eventuser_id")
private EventUser user; private EventUser user;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(Bill.class); private static final Logger logger = LoggerFactory.getLogger(Bill.class);
public Integer getReferenceNumberBase() { public Integer getReferenceNumberBase() {
if (getEvent() != null && getEvent().getReferenceNumberBase() != null && getBillNumber() != null) { if (getEvent() != null && getEvent().getReferenceNumberBase() != null && getBillNumber() != null) {
return getEvent().getReferenceNumberBase() + getBillNumber(); return getEvent().getReferenceNumberBase() + getBillNumber();
} }
return null; return null;
} }
public Integer getReferenceNumber() public Integer getReferenceNumber()
{ {
return BillUtils.createReferenceNumber(getReferenceNumberBase()); return BillUtils.createReferenceNumber(getReferenceNumberBase());
} }
/** /**
* Commodity function to calculate the total price of the bill. * Commodity function to calculate the total price of the bill.
* *
* @return The total sum of the bill ( unitPrice * units * vat ) * @return The total sum of the bill ( unitPrice * units * vat )
*/ */
public BigDecimal totalPrice() { public BigDecimal totalPrice() {
BigDecimal total = BigDecimal.ZERO; BigDecimal total = BigDecimal.ZERO;
for (BillLine line : getBillLines()) { for (BillLine line : getBillLines()) {
total = total.add(line.getLinePrice()); total = total.add(line.getLinePrice());
} }
return total; return total;
} }
public BigDecimal getTotalPrice() { public BigDecimal getTotalPrice() {
return this.totalPrice(); return this.totalPrice();
} }
/** /**
* Commodity function to calculate the total price of the bill. * Commodity function to calculate the total price of the bill.
* *
* @return The total sum of the bill ( unitPrice * units * vat ) * @return The total sum of the bill ( unitPrice * units * vat )
*/ */
public BigDecimal totalVat() { public BigDecimal totalVat() {
BigDecimal total = BigDecimal.ZERO; BigDecimal total = BigDecimal.ZERO;
for (BillLine line : getBillLines()) { for (BillLine line : getBillLines()) {
total = total.add(line.getLineVat()); total = total.add(line.getLineVat());
} }
return total; return total;
} }
/** /**
* Commodity function to return the vatless price of the bill * Commodity function to return the vatless price of the bill
* *
* @return The total VAT-less sum of the bill ( unitPrice * units ) * @return The total VAT-less sum of the bill ( unitPrice * units )
*/ */
public BigDecimal totalPriceVatless() { public BigDecimal totalPriceVatless() {
BigDecimal total = BigDecimal.ZERO; BigDecimal total = BigDecimal.ZERO;
for (BillLine line : getBillLines()) { for (BillLine line : getBillLines()) {
total = total.add(line.getLinePriceVatless()); total = total.add(line.getLinePriceVatless());
} }
return total; return total;
} }
public Bill(LanEvent event, EventUser user, Calendar expires) { public Bill(LanEvent event, EventUser user, Calendar 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());
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, Calendar expires) { public Bill(LanEvent event, Calendar 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, Calendar.getInstance());
this.expires.setTimeInMillis((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, Calendar.getInstance());
this.expires.setTimeInMillis((System.currentTimeMillis() + (expireTimeHours*60*60 * 1000 ))); 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() + 1209600000)); // 2vk this.expires.setTimeInMillis((System.currentTimeMillis() + 1209600000)); // 2vk
} }
public Calendar getDueDate() { public Calendar getDueDate() {
Calendar dueDate = Calendar.getInstance(); Calendar dueDate = Calendar.getInstance();
dueDate.setTime(this.getSentDate().getTime()); dueDate.setTime(this.getSentDate().getTime());
dueDate.add(Calendar.DATE, this.getPaymentTime()); dueDate.add(Calendar.DATE, this.getPaymentTime());
return dueDate; return dueDate;
} }
public String getNotes() { public String getNotes() {
return notes; return notes;
} }
public void setNotes(String notes) { public void setNotes(String notes) {
this.notes = notes; this.notes = notes;
} }
public List<BillLine> getBillLines() { public List<BillLine> getBillLines() {
return billLines; return billLines;
} }
public void setBillLines(List<BillLine> billLineList) { public void setBillLines(List<BillLine> billLineList) {
this.billLines = billLineList; this.billLines = billLineList;
} }
public AccountEvent getAccountEvent() { public AccountEvent getAccountEvent() {
return accountEvent; return accountEvent;
} }
public void setAccountEvent(AccountEvent accoutEventsId) { public void setAccountEvent(AccountEvent accoutEventsId) {
this.accountEvent = accoutEventsId; this.accountEvent = accoutEventsId;
} }
public EventUser getUser() { public EventUser getUser() {
return user; return user;
} }
public void setUser(EventUser usersId) { public void setUser(EventUser usersId) {
this.user = usersId; this.user = usersId;
} }
public Integer getBillNumber() { public Integer getBillNumber() {
return billNumber; return billNumber;
} }
public String getAddr1() { public String getAddr1() {
return addr1; return addr1;
} }
public void setAddr1(String addr1) { public void setAddr1(String addr1) {
this.addr1 = addr1; this.addr1 = addr1;
} }
public String getAddr2() { public String getAddr2() {
return addr2; return addr2;
} }
public void setAddr2(String addr2) { public void setAddr2(String addr2) {
this.addr2 = addr2; this.addr2 = addr2;
} }
public String getAddr3() { public String getAddr3() {
return addr3; return addr3;
} }
public void setAddr3(String addr3) { public void setAddr3(String addr3) {
this.addr3 = addr3; this.addr3 = addr3;
} }
public String getAddr4() { public String getAddr4() {
return addr4; return addr4;
} }
public void setAddr4(String addr4) { public void setAddr4(String addr4) {
this.addr4 = addr4; this.addr4 = addr4;
} }
public String getAddr5() { public String getAddr5() {
return addr5; return addr5;
} }
public void setAddr5(String addr5) { public void setAddr5(String addr5) {
this.addr5 = addr5; this.addr5 = addr5;
} }
public String getNoticetime() { public String getNoticetime() {
return noticetime; return noticetime;
} }
public void setNoticetime(String noticetime) { public void setNoticetime(String noticetime) {
this.noticetime = noticetime; this.noticetime = noticetime;
} }
public String getOurReference() { public String getOurReference() {
return ourReference; return ourReference;
} }
public void setOurReference(String ourReference) { public void setOurReference(String ourReference) {
this.ourReference = ourReference; this.ourReference = ourReference;
} }
public void setTheirReference(String theirReference) { public void setTheirReference(String theirReference) {
this.theirReference = theirReference; this.theirReference = theirReference;
} }
public String getTheirReference() { public String getTheirReference() {
return theirReference; return theirReference;
} }
public void setDeliveryTerms(String deliveryTerms) { public void setDeliveryTerms(String deliveryTerms) {
this.deliveryTerms = deliveryTerms; this.deliveryTerms = deliveryTerms;
} }
public String getDeliveryTerms() { public String getDeliveryTerms() {
return deliveryTerms; return deliveryTerms;
} }
public void setPaymentTime(Integer paymentTime) { public void setPaymentTime(Integer paymentTime) {
this.paymentTime = paymentTime; this.paymentTime = paymentTime;
} }
public Integer getPaymentTime() { public Integer getPaymentTime() {
return paymentTime; return paymentTime;
} }
public void setDelayIntrest(Integer delayIntrest) { public void setDelayIntrest(Integer delayIntrest) {
this.delayIntrest = delayIntrest; this.delayIntrest = delayIntrest;
} }
public Integer getDelayIntrest() { public Integer getDelayIntrest() {
return delayIntrest; return delayIntrest;
} }
public void setBillNumber(Integer billNumber) { public void setBillNumber(Integer billNumber) {
this.billNumber = billNumber; this.billNumber = billNumber;
} }
public LanEvent getEvent() { public LanEvent getEvent() {
return event; return event;
} }
public void setEvent(LanEvent event) { public void setEvent(LanEvent event) {
this.event = event; this.event = event;
} }
public Date getPaidDate() { public Date getPaidDate() {
return paidDate; return paidDate;
} }
public void setPaidDate(Date paidDate) { public void setPaidDate(Date paidDate) {
if(paidDate != null) if (paidDate != null)
expires = null; expires = null;
this.paidDate = paidDate; this.paidDate = paidDate;
} }
public Date getSentDateTime() public Date getSentDateTime()
{ {
Date ret = null; Date ret = null;
if (sentDate != null) if (sentDate != null)
{ {
ret = sentDate.getTime(); ret = sentDate.getTime();
} }
return ret; return ret;
} }
public void setSentDateTime(Date date) public void setSentDateTime(Date date)
{ {
if (date == null) if (date == null)
{ {
sentDate = null; sentDate = null;
} else { } else {
if (sentDate == null) if (sentDate == null)
{ {
sentDate = Calendar.getInstance(); sentDate = Calendar.getInstance();
} }
sentDate.setTime(date); sentDate.setTime(date);
} }
} }
public Calendar getSentDate() { public Calendar getSentDate() {
return sentDate; return sentDate;
} }
public void setSentDate(Calendar sentDate) { public void setSentDate(Calendar sentDate) {
this.sentDate = sentDate; this.sentDate = sentDate;
} }
public boolean isFoowavePaymentOver() { public boolean isFoowavePaymentOver() {
boolean ret = false; for (BillLine bl : billLines)
for (BillLine bl : billLines) {
{ if (bl.getFoodwave() != null) {
if (bl.getFoodwave() != null && (bl.getFoodwave().getClosed() || bl.getFoodwave().getTime().before(new Date())))
{ if (bl.getFoodwave().isPaymentOver())
ret = true; {
break; return true;
} }
} }
return ret; }
} return false;
}
public Calendar getExpires() {
return expires; public Calendar getExpires() {
} return expires;
}
public void setExpires(Calendar expires) {
this.expires = expires; public void setExpires(Calendar expires) {
} this.expires = expires;
}
public boolean isExpired() {
if(expires == null) public boolean isExpired() {
return false; if (expires == null)
return false;
return Calendar.getInstance().after(expires);
} return Calendar.getInstance().after(expires);
}
public void markExpired() {
if(isExpired() || isPaid()) public void markExpired() {
return; if (isExpired() || isPaid())
return;
expires = Calendar.getInstance();
} expires = Calendar.getInstance();
}
@Transient
public BigDecimal getTotalQuantity() {
BigDecimal total = BigDecimal.ZERO;
for(BillLine l : getBillLines()) {
if(l == null || l.getQuantity() == null)
continue;
total.add(l.getQuantity());
}
return total;
}
@Transient
public String getProductSummary() {
String summary = "";
for(BillLine l : getBillLines()) {
if(l == null || l.getQuantity() == null)
continue;
if(!summary.isEmpty()) {
summary += ", ";
}
summary += l.getName();
}
return summary;
}
} }
...@@ -470,7 +503,3 @@ public class Bill extends GenericEntity { ...@@ -470,7 +503,3 @@ public class Bill extends GenericEntity {
...@@ -36,6 +36,7 @@ import javax.persistence.OneToMany; ...@@ -36,6 +36,7 @@ import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.persistence.Transient;
/** /**
* *
...@@ -44,220 +45,246 @@ import javax.persistence.TemporalType; ...@@ -44,220 +45,246 @@ import javax.persistence.TemporalType;
@Table(name = "food_waves") @Table(name = "food_waves")
public class FoodWave extends GenericEntity { public class FoodWave extends GenericEntity {
private static final long serialVersionUID = 9221716203467295049L; private static final long serialVersionUID = 9221716203467295049L;
@Column(name = "wave_name", nullable = false) @Column(name = "wave_name", nullable = false)
private String name; private String name;
@Lob @Lob
@Column(name = "wave_description") @Column(name = "wave_description")
private String description; private String description;
@Column(name = "wave_time") @Column(name = "wave_time")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date time; private Date time;
@Column(name = "max_foods") @Column(name = "max_foods")
private Integer maximumFoods; private Integer maximumFoods;
@Column(name = "wave_closed", nullable = false, columnDefinition = "boolean default false") @Column(name = "wave_closed", nullable = false, columnDefinition = "boolean default false")
private boolean closed = false; private boolean closed = false;
@OneToMany(mappedBy = "foodWave") @OneToMany(mappedBy = "foodWave")
private List<AccountEvent> accountEvents; private List<AccountEvent> accountEvents;
@OneToMany(mappedBy = "foodwave") @OneToMany(mappedBy = "foodwave")
private List<BillLine> billLines; private List<BillLine> billLines;
@ManyToOne @ManyToOne
@JoinColumn(name = "template_id", referencedColumnName = "id", nullable = false) @JoinColumn(name = "template_id", referencedColumnName = "id", nullable = false)
private FoodWaveTemplate template; private FoodWaveTemplate template;
public FoodWave() { public FoodWave() {
super(); super();
} }
public FoodWave(String waveName, boolean waveClosed) { public FoodWave(String waveName, boolean waveClosed) {
super(); super();
this.name = waveName; this.name = waveName;
this.closed = waveClosed; this.closed = waveClosed;
} }
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String waveName) { public void setName(String waveName) {
this.name = waveName; this.name = waveName;
} }
public String getDescription() { public String getDescription() {
return description; return description;
} }
public void setDescription(String waveDescription) { public void setDescription(String waveDescription) {
this.description = waveDescription; this.description = waveDescription;
} }
public Date getTime() { public Date getTime() {
return time; return time;
} }
public void setTime(Date waveTime) { public void setTime(Date waveTime) {
this.time = waveTime; this.time = waveTime;
} }
public boolean getClosed() {
return closed;
}
public boolean isClosed() {
return closed;
}
public void setClosed(boolean waveClosed) {
this.closed = waveClosed;
}
public void toggleClosed() {
this.closed = !isClosed();
}
public List<AccountEvent> getAccountEvents() {
return accountEvents;
}
public void setAccountEvents(List<AccountEvent> accountEventList) {
this.accountEvents = accountEventList;
}
public void setTemplate(FoodWaveTemplate template) {
this.template = template;
}
public FoodWaveTemplate getTemplate() {
return template;
}
public boolean isFull() {
if(getMaximumFoods() <= 0) {
return false;
}
if(getReservedCount() >= getMaximumFoods()) {
return true;
}
return false;
}
/**
* Check if foodwave is orderable
*
* That means that it's not closed, full and it's in future
*
* @return
*/
public boolean isOrderable() {
if (isClosed()) {
return false;
}
if (getTime().before(new Date())) {
return false;
}
if (isFull()) {
return false;
}
return true;
}
public List<Product> getOrderedProducts() {
List<Product> retlist = new ArrayList<Product>();
if (getAccountEvents() != null) {
for (AccountEvent ae : getAccountEvents()) {
if (!retlist.contains(ae.getProduct())) {
retlist.add(ae.getProduct());
}
}
}
return retlist;
}
public List<BillLine> getBillLines() {
return billLines;
}
public Integer getMaximumFoods() {
if(maximumFoods == null) {
return 0;
}
return maximumFoods;
}
public void setBillLines(List<BillLine> billLines) {
this.billLines = billLines;
}
public Integer getReservedCount() {
Integer retval = 0;
retval += getOrderedCount();
retval += getUnpaidCount();
return retval;
}
public void setMaximumFoods(Integer maximumFoods) {
this.maximumFoods = maximumFoods;
}
public Integer getUnpaidCount() {
Integer ret = 0;
for (BillLine line : getBillLines()) {
if (!line.getBill().isPaid()) {
ret += line.getQuantity().intValue();
}
}
return ret;
}
public Integer getOrderedCount() {
Integer ret = 0;
if (getAccountEvents() != null) {
for(AccountEvent ae : getAccountEvents()) {
ret += ae.getQuantity().intValue();
}
}
return ret;
}
public boolean isDelivered() {
if (getAccountEvents() != null && getReservedCount() != 0) {
for(AccountEvent ae : getAccountEvents()) {
if (ae.isEventDelivered()) {
return true;
}
}
return false;
}
return true;
}
}
public boolean getClosed() {
return closed;
}
public boolean isClosed() {
return closed;
}
public void setClosed(boolean waveClosed) {
this.closed = waveClosed;
}
public void toggleClosed() {
this.closed = !isClosed();
}
public List<AccountEvent> getAccountEvents() {
return accountEvents;
}
public void setAccountEvents(List<AccountEvent> accountEventList) {
this.accountEvents = accountEventList;
}
public void setTemplate(FoodWaveTemplate template) {
this.template = template;
}
public FoodWaveTemplate getTemplate() {
return template;
}
public boolean isFull() {
if (getMaximumFoods() <= 0) {
return false;
}
if (getReservedCount() >= getMaximumFoods()) {
return true;
}
return false;
}
/**
* Check if foodwave is orderable
*
* That means that it's not closed, full and it's in future
*
* @return
*/
public boolean isOrderable() {
if (isClosed()) {
return false;
}
if (getTime().before(new Date())) {
return false;
}
if (isFull()) {
return false;
}
return true;
}
public List<Product> getOrderedProducts() {
List<Product> retlist = new ArrayList<Product>();
if (getAccountEvents() != null) {
for (AccountEvent ae : getAccountEvents()) {
if (!retlist.contains(ae.getProduct())) {
retlist.add(ae.getProduct());
}
}
}
return retlist;
}
public List<BillLine> getBillLines() {
return billLines;
}
public Integer getMaximumFoods() {
if (maximumFoods == null) {
return 0;
}
return maximumFoods;
}
public void setBillLines(List<BillLine> billLines) {
this.billLines = billLines;
}
public Integer getReservedCount() {
Integer retval = 0;
retval += getOrderedCount();
retval += getUnpaidCount();
return retval;
}
public void setMaximumFoods(Integer maximumFoods) {
this.maximumFoods = maximumFoods;
}
public Integer getUnpaidCount() {
Integer ret = 0;
for (BillLine line : getBillLines()) {
if (!line.getBill().isPaid()) {
ret += line.getQuantity().intValue();
}
}
return ret;
}
public Integer getOrderedCount() {
Integer ret = 0;
if (getAccountEvents() != null) {
for (AccountEvent ae : getAccountEvents()) {
ret += ae.getQuantity().intValue();
}
}
return ret;
}
public Integer getDeliveredCount() {
Integer delCount = new Integer(0);
if (getAccountEvents() != null && getReservedCount() != 0) {
for (AccountEvent ae : getAccountEvents()) {
if (ae.isEventDelivered()) {
delCount++;
}
}
}
return delCount;
}
public boolean isDelivered() {
if (getAccountEvents() != null && getReservedCount() != 0) {
for (AccountEvent ae : getAccountEvents()) {
if (!ae.isEventDelivered()) {
return false;
}
}
}
return true;
}
@Transient
public Date getLastPaymentTime() {
return new Date(getTime().getTime() + (getTemplate().getWaitPaymentsMinutes().longValue() * 60l * 1000l));
}
public boolean isPaymentOver() {
// add this magical "wait payments this amount of minutes" to foodwave
Date endDate = new Date(getTime().getTime() + (getTemplate().getWaitPaymentsMinutes().longValue() * 60l * 1000l));
if (isClosed() || endDate.before(new Date())) {
return true;
}
return false;
}
}
...@@ -66,6 +66,9 @@ public class FoodWaveTemplate extends GenericEntity { ...@@ -66,6 +66,9 @@ public class FoodWaveTemplate extends GenericEntity {
@Column(name = "max_foods") @Column(name = "max_foods")
private Integer maximumFoods; private Integer maximumFoods;
@Column(name = "wait_payments_minutes")
private Integer waitPaymentsMinutes = 0;
public FoodWaveTemplate() { public FoodWaveTemplate() {
} }
...@@ -135,4 +138,16 @@ public class FoodWaveTemplate extends GenericEntity { ...@@ -135,4 +138,16 @@ public class FoodWaveTemplate extends GenericEntity {
return returnList; return returnList;
} }
public Integer getWaitPaymentsMinutes() {
if(waitPaymentsMinutes == null)
waitPaymentsMinutes = 0;
return waitPaymentsMinutes;
}
public void setWaitPaymentsMinutes(Integer waitPaymentsMinutes) {
this.waitPaymentsMinutes = waitPaymentsMinutes;
}
} }
<!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" <html xmlns="http://www.w3.org/1999/xhtml" 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:products="http://java.sun.com/jsf/composite/cditools/products" xmlns:users="http://java.sun.com/jsf/composite/cditools/user" xmlns:c="http://java.sun.com/jsp/jstl/core" 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:products="http://java.sun.com/jsf/composite/cditools/products"
xmlns:users="http://java.sun.com/jsf/composite/cditools/user"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
<h:body> <h:body>
<ui:composition <ui:composition template="#{sessionHandler.template}">
template="#{sessionHandler.template}">
<f:metadata> <f:metadata>
<f:viewParam name="id" value="#{foodWaveView.templateId}" /> <f:viewParam name="id" value="#{foodWaveView.templateId}" />
<f:event type="preRenderView" <f:event type="preRenderView" listener="#{foodWaveView.initEditTemplate()}" />
listener="#{foodWaveView.initEditTemplate()}" />
</f:metadata> </f:metadata>
<ui:define name="title"> <ui:define name="title">
...@@ -27,58 +18,46 @@ ...@@ -27,58 +18,46 @@
<p:panel header="#{i18n['foodwavetemplate.edit']}"> <p:panel header="#{i18n['foodwavetemplate.edit']}">
<h:form> <h:form>
<h:panelGrid columns="3"> <h:panelGrid columns="3">
<h:outputLabel for="name" <h:outputLabel for="name" value="#{i18n['foodwave.template.name']}" />
value="#{i18n['foodwave.template.name']}" />
<h:inputText id="name" value="#{foodWaveView.template.name}" /> <h:inputText id="name" value="#{foodWaveView.template.name}" />
<h:message for="name" /> <h:message for="name" />
<h:outputLabel for="desc" <h:outputLabel for="desc" value="#{i18n['foodwave.template.description']}" />
value="#{i18n['foodwave.template.description']}" /> <h:inputText id="desc" value="#{foodWaveView.template.description}" />
<h:inputText id="desc"
value="#{foodWaveView.template.description}" />
<h:message for="desc" /> <h:message for="desc" />
<h:outputLabel for="overtime" value="#{i18n['foodwave.template.waitPaymentsMinutes']}" />
<p:spinner id="overtime" value="#{foodWaveView.template.waitPaymentsMinutes}" suffix=" #{i18n['suffix.minutes']}" min="0" />
<h:message for="overtime" />
<h:outputText value=" " /> <h:outputText value=" " />
<h:commandButton action="#{foodWaveView.saveTemplate()}" <h:commandButton action="#{foodWaveView.saveTemplate()}" value="#{i18n['foodwavetemplate.save']}" />
value="#{i18n['foodwavetemplate.save']}" />
</h:panelGrid> </h:panelGrid>
</h:form> </h:form>
<h:form> <h:form>
<h:selectOneMenu value="#{foodWaveView.currentProduct}" <h:selectOneMenu value="#{foodWaveView.currentProduct}" converter="#{productConverter}">
converter="#{productConverter}"> <f:selectItems value="#{foodWaveView.products}" var="product" itemLabel="#{product.name}"></f:selectItems>
<f:selectItems value="#{foodWaveView.products}" var="product"
itemLabel="#{product.name}"></f:selectItems>
</h:selectOneMenu> </h:selectOneMenu>
<p:commandButton value="#{i18n['foodwavetemplate.addproduct']}" <p:commandButton value="#{i18n['foodwavetemplate.addproduct']}" actionListener="#{foodWaveView.addProductToTemplate}" ajax="false" />
actionListener="#{foodWaveView.addProductToTemplate}"
ajax="false" />
</h:form> </h:form>
<h:form> <h:form>
<h:panelGrid columns="4"> <h:panelGrid columns="4">
<h:outputText value="#{i18n['foodwavetemplate.productname']}" /> <h:outputText value="#{i18n['foodwavetemplate.productname']}" />
<h:outputText <h:outputText value="#{i18n['foodwavetemplate.productdescription']}" />
value="#{i18n['foodwavetemplate.productdescription']}" />
<h:outputText value="#{i18n['foodwavetemplate.price']}" /> <h:outputText value="#{i18n['foodwavetemplate.price']}" />
<h:outputText value="&nbsp;" /> <h:outputText value="&nbsp;" />
<h:inputText id="productname" <h:inputText id="productname" value="#{foodWaveView.currentProduct.name}" />
value="#{foodWaveView.currentProduct.name}" /> <h:inputText id="productdescription" value="#{foodWaveView.currentProduct.description}" />
<h:inputText id="productdescription" <h:inputText id="price" value="#{foodWaveView.currentProduct.price}" />
value="#{foodWaveView.currentProduct.description}" />
<h:inputText id="price"
value="#{foodWaveView.currentProduct.price}" />
<p:commandButton value="#{i18n['foodwavetemplate.addproduct']}" <p:commandButton value="#{i18n['foodwavetemplate.addproduct']}" actionListener="#{foodWaveView.addProductToTemplate}" ajax="false" />
actionListener="#{foodWaveView.addProductToTemplate}"
ajax="false" />
</h:panelGrid> </h:panelGrid>
</h:form> </h:form>
<h:form> <h:form>
<p:dataTable name="productTable" id="productTable" <p:dataTable name="productTable" id="productTable" value="#{foodWaveView.template.products}" var="product" editable="true">
value="#{foodWaveView.template.products}" var="product"
editable="true">
<p:ajax event="rowEdit" listener="#{foodWaveView.onEdit}" /> <p:ajax event="rowEdit" listener="#{foodWaveView.onEdit}" />
...@@ -89,20 +68,17 @@ ...@@ -89,20 +68,17 @@
<h:outputText value="#{product.name}" /> <h:outputText value="#{product.name}" />
</f:facet> </f:facet>
<f:facet name="input"> <f:facet name="input">
<p:inputText value="#{product.name}" style="width:100%" <p:inputText value="#{product.name}" style="width:100%" required="true" requiredMessage="Name required" />
required="true" requiredMessage="Name required" />
</f:facet> </f:facet>
</p:cellEditor> </p:cellEditor>
</p:column> </p:column>
<p:column <p:column headerText="#{i18n['foodwavetemplate.productdescription']}">
headerText="#{i18n['foodwavetemplate.productdescription']}">
<p:cellEditor> <p:cellEditor>
<f:facet name="output"> <f:facet name="output">
<h:outputText value="#{product.description}" /> <h:outputText value="#{product.description}" />
</f:facet> </f:facet>
<f:facet name="input"> <f:facet name="input">
<p:inputText value="#{product.description}" style="width:100%" <p:inputText value="#{product.description}" style="width:100%" required="true" requiredMessage="Description required" />
required="true" requiredMessage="Description required" />
</f:facet> </f:facet>
</p:cellEditor> </p:cellEditor>
</p:column> </p:column>
...@@ -112,52 +88,38 @@ ...@@ -112,52 +88,38 @@
<h:outputText value="#{product.price}" /> <h:outputText value="#{product.price}" />
</f:facet> </f:facet>
<f:facet name="input"> <f:facet name="input">
<p:inputText value="#{product.price}" style="width:100%" <p:inputText value="#{product.price}" style="width:100%" required="true" requiredMessage="Price required" />
required="true" requiredMessage="Price required" />
</f:facet> </f:facet>
</p:cellEditor> </p:cellEditor>
</p:column> </p:column>
<p:column headerText="#{i18n['foodwavetemplate.editRow']}" <p:column style="width:20px">
style="width:20px">
<p:rowEditor /> <p:rowEditor />
</p:column> </p:column>
<p:column headerText="#{i18n['foodwavetemplate.actions']}" <p:column style="width:70px">
style="width:20px;"> <p:commandButton value="#{i18n['foodwavetemplate.removeFromList']}" action="#{foodWaveView.removeProductFromList(product)}" update="productTable" />
<p:commandButton
value="#{i18n['foodwavetemplate.removeFromList']}"
action="#{foodWaveView.removeProductFromList(product)}"
update="productTable" />
</p:column> </p:column>
</p:dataTable> </p:dataTable>
<h:commandButton action="#{foodWaveView.saveTemplate()}" <h:commandButton action="#{foodWaveView.saveTemplate()}" value="#{i18n['foodwavetemplate.savetemplate']}" />
value="#{i18n['foodwavetemplate.savetemplate']}" />
<!-- --> <!-- -->
</h:form> </h:form>
</p:panel> </p:panel>
<h:form> <h:form>
<p:panel header="#{i18n['foodwavetemplate.createwave']}"> <p:panel header="#{i18n['foodwavetemplate.createwave']}">
<h:panelGrid columns="3"> <h:panelGrid columns="3">
<h:outputLabel for="waveName" <h:outputLabel for="waveName" value="#{i18n['foodwavetemplate.waveName']}" />
value="#{i18n['foodwavetemplate.waveName']}" /> <h:inputText id="waveName" value="#{foodWaveView.selectedFoodWave.name}" />
<h:inputText id="waveName"
value="#{foodWaveView.selectedFoodWave.name}" />
<h:message for="waveName" /> <h:message for="waveName" />
<h:outputLabel for="waveMaxFoods" <h:outputLabel for="waveMaxFoods" value="#{i18n['foodwavetemplate.maxfoods']}" />
value="#{i18n['foodwavetemplate.maxfoods']}" /> <h:inputText id="waveMaxFoods" value="#{foodWaveView.selectedFoodWave.maximumFoods}" />
<h:inputText id="waveMaxFoods"
value="#{foodWaveView.selectedFoodWave.maximumFoods}" />
<h:message for="waveMaxFoods" /> <h:message for="waveMaxFoods" />
<h:outputLabel for="startTime" <h:outputLabel for="startTime" value="#{i18n['foodwavetemplate.startTime']}" />
value="#{i18n['foodwavetemplate.startTime']}" /> <p:calendar id="startTime" value="#{foodWaveView.startDate}" pattern="dd.MM.yyyy HH:mm" />
<p:calendar id="startTime" value="#{foodWaveView.startDate}"
pattern="dd.MM.yyyy HH:mm" />
<h:message for="startTime" /> <h:message for="startTime" />
</h:panelGrid> </h:panelGrid>
<h:commandButton action="#{foodWaveView.createFoodwave()}" <h:commandButton action="#{foodWaveView.createFoodwave()}" value="#{i18n['foodwavetemplate.createFoodwave']}" />
value="#{i18n['foodwavetemplate.createFoodwave']}" />
</p:panel> </p:panel>
</h:form> </h:form>
</ui:define> </ui:define>
......
...@@ -64,6 +64,13 @@ ...@@ -64,6 +64,13 @@
</f:facet> </f:facet>
<h:outputText value="#{foodwave.unpaidCount}" /> <h:outputText value="#{foodwave.unpaidCount}" />
</p:column> </p:column>
<p:column styleClass="text-center">
<f:facet name="header">
<h:outputText value="${i18n['foodWave.deliveredCount']}" />
</f:facet>
<h:outputText value="#{foodwave.deliveredCount}" />
</p:column>
<p:column> <p:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="${i18n['foodWave.totalReserved']}" /> <h:outputText value="${i18n['foodWave.totalReserved']}" />
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
<h1>#{foodWaveView.selectedFoodWave.name}</h1> <h1>#{foodWaveView.selectedFoodWave.name}</h1>
</ui:define> </ui:define>
<ui:define name="content"> <ui:define name="content">
<h:form> <h:form id="accountEventList">
<p:dataTable styleClass="bordertable" value="#{foodWaveView.accountEventLines}" var="acc_line" sortBy="#{acc_line.user.nick}"> <p:dataTable styleClass="bordertable" value="#{foodWaveView.accountEventLines}" var="acc_line" sortBy="#{acc_line.user.nick}" rowStyleClass="#{acc_line.eventDelivered?'success':null}">
<f:facet name="header"> <f:facet name="header">
<h:outputLabel value="#{i18n['foodWave.accountevents']}" /> <h:outputLabel value="#{i18n['foodWave.accountevents']}" />
</f:facet> </f:facet>
...@@ -43,9 +43,7 @@ ...@@ -43,9 +43,7 @@
<f:facet name="header"> <f:facet name="header">
<h:outputLabel value="#{i18n['acc_line.eventuser']}" /> <h:outputLabel value="#{i18n['acc_line.eventuser']}" />
</f:facet> </f:facet>
<h:link outcome="/useradmin/edit" value="#{acc_line.user.wholeName}"> <h:outputText outcome="/useradmin/edit" value="#{acc_line.user.wholeName}" />
<f:param name="userid" value="#{acc_line.user.id}" />
</h:link>
</p:column> </p:column>
<p:column sortBy="#{acc_line.user.nick}"> <p:column sortBy="#{acc_line.user.nick}">
<f:facet name="header"> <f:facet name="header">
...@@ -60,7 +58,7 @@ ...@@ -60,7 +58,7 @@
<h:outputLabel value="#{i18n['accountEvent.delivered']}" /> <h:outputLabel value="#{i18n['accountEvent.delivered']}" />
</f:facet> </f:facet>
<h:outputText rendered="#{acc_line.eventDelivered}" value="#{i18n['accountEvent.delivered']}" /> <h:outputText rendered="#{acc_line.eventDelivered}" value="#{i18n['accountEvent.delivered']}" />
<h:commandButton rendered="#{not acc_line.eventDelivered}" value="#{i18n['accountEvent.deliver']}" action="#{foodWaveView.deliverAccountEvent}" /> <p:commandButton rendered="#{not acc_line.eventDelivered}" value="#{i18n['accountEvent.deliver']}" actionListener="#{foodWaveView.deliverAccountEvent}" update=":billList :accountEventList" />
</p:column> </p:column>
</p:dataTable> </p:dataTable>
...@@ -68,69 +66,60 @@ ...@@ -68,69 +66,60 @@
<br></br> <br></br>
<br></br> <br></br>
<h:form> <h:form id="billList">
<p:dataTable styleClass="bordertable" value="#{foodWaveView.billLines}" var="bill_line" sortBy="#{bill_line.bill.user.nick}"> <p:dataTable styleClass="bordertable" value="#{foodWaveView.bills}" var="bill" sortBy="#{bill.user.nick}">
<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_line.bill.sentDate.getTime()}"> <p:column sortBy="#{bill.sentDate.getTime()}">
<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_line.bill.sentDate.getTime()}"> <h:outputText value="#{bill.sentDate.getTime()}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" />
</h:outputText> </h:outputText>
</p:column> </p:column>
<p:column sortBy="#{bill_line.quantity}"> <p:column sortBy="#{bill.totalQuantity}">
<f:facet name="header"> <f:facet name="header">
<h:outputLabel value="#{i18n['billLine.quantity']}" /> <h:outputLabel value="#{i18n['billLine.quantity']}" />
</f:facet> </f:facet>
<h:outputText style="text-align: center;" value="#{bill_line.quantity}"> <h:outputText style="text-align: center;" value="#{bill.totalQuantity}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" /> <f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText> </h:outputText>
</p:column> </p:column>
<p:column sortBy="#{bill_line.name}"> <p:column sortBy="#{billLine.eventuser}">
<f:facet name="header"> <f:facet name="header">
<h:outputLabel value="#{i18n['billLine.product']}" /> <h:outputLabel value="#{i18n['bill.products']}" />
</f:facet> </f:facet>
<h:outputText value="#{bill_line.name}" /> <h:outputText value="#{bill.productSummary}" />
</p:column> </p:column>
<p:column sortBy="#{bill_line.bill.user.wholeName}"> <p:column sortBy="#{bill.user.wholeName}">
<f:facet name="header"> <f:facet name="header">
<h:outputLabel value="#{i18n['billLine.eventuser']}" /> <h:outputLabel value="#{i18n['billLine.eventuser']}" />
</f:facet> </f:facet>
<h:link outcome="/useradmin/edit" value="#{bill_line.bill.user.wholeName}"> <h:link outcome="/useradmin/edit" value="#{bill.user.wholeName}">
<f:param name="userid" value="#{bill_line.bill.user.user.id}" /> <f:param name="userid" value="#{bill.user.user.id}" />
</h:link> </h:link>
</p:column> </p:column>
<p:column sortBy="#{bill_line.bill.user.nick}"> <p:column sortBy="#{bill.user.user.id}">
<f:facet name="header"> <f:facet name="header">
<h:outputLabel value="#{i18n['billLine.nick']}" /> <h:outputLabel value="#{i18n['billLine.nick']}" />
</f:facet> </f:facet>
<h:link outcome="/useradmin/edit" value="#{bill_line.bill.user.nick}"> <h:link outcome="/useradmin/edit" value="#{bill.user.nick}">
<f:param name="userid" value="#{bill_line.bill.user.user.id}" /> <f:param name="userid" value="#{bill.user.user.id}" />
</h:link> </h:link>
</p:column> </p:column>
<p:column sortBy="#{bill_line.linePrice}"> <p:column sortBy="#{bill.totalPrice}">
<f:facet name="header">
<h:outputLabel value="#{i18n['billLine.price']}" />
</f:facet>
<h:outputText style="text-align: center;" value="#{bill_line.linePrice}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText>
</p:column>
<p:column sortBy="#{bill_line.bill.totalPrice}">
<f:facet name="header"> <f:facet name="header">
<h:outputLabel value="#{i18n['bill.totalprice']}" /> <h:outputLabel value="#{i18n['bill.totalprice']}" />
</f:facet> </f:facet>
<h:outputText style="text-align: center;" value="#{bill_line.bill.totalPrice}"> <h:outputText style="text-align: center;" value="#{bill.totalPrice}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" /> <f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText> </h:outputText>
</p:column> </p:column>
<p:column> <p:column>
<h:commandButton value="#{i18n['bill.markPaid']}" action="#{foodWaveView.markBillPaid}" /> <p:commandButton value="#{i18n['bill.markPaid']}" actionListener="#{foodWaveView.markBillPaid}" update=":billList :accountEventList" />
</p:column> </p:column>
<!-- <!--
<p:column> <p:column>
...@@ -140,21 +129,33 @@ ...@@ -140,21 +129,33 @@
</p:dataTable> </p:dataTable>
</h:form> </h:form>
<br /><br /><br />
<h2>#{i18n['foodwave.summaryView']}</h2> <h2>#{i18n['foodwave.summaryView']}</h2>
<div> <p:panelGrid columns="2">
<h:outputLabel value="#{i18n['foodwave.price']}: " /> <h:outputLabel value="#{i18n['foodwave.price']}: " />
<h:outputText value="#{foodWaveView.foodwavePrice}" > <h:outputText value="#{foodWaveView.foodwavePrice}" style="font-weight: bold" >
<f:convertNumber minFractionDigits="0"/> <f:convertNumber minFractionDigits="0"/>
</h:outputText> </h:outputText>
</div>
<div>
<h:outputLabel value="#{i18n['foodwave.foodwaveBuyInPrice']}: " /> <h:outputLabel value="#{i18n['foodwave.foodwaveBuyInPrice']}: " />
<h:outputText value="#{foodWaveView.foodwaveBuyInPrice}" > <h:outputText value="#{foodWaveView.foodwaveBuyInPrice}" style="font-weight: bold" >
<f:convertNumber minFractionDigits="0"/> <f:convertNumber minFractionDigits="0"/>
</h:outputText> </h:outputText>
</div>
<h:outputLabel value="#{i18n['foodwave.ordersBefore']}: " />
<h:outputText value="#{foodWaveView.selectedFoodWave.time}" style="font-weight: bold" >
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" />
</h:outputText>
<h:outputLabel value="#{i18n['foodwave.foodwaveLastBillPayTime']}: " />
<h:outputText value="#{foodWaveView.selectedFoodWave.lastPaymentTime}" style="font-weight: bold" >
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" />
</h:outputText>
</p:panelGrid>
<p:dataTable var="summ" value="#{foodWaveView.productSummaries}"> <p:dataTable var="summ" value="#{foodWaveView.productSummaries}">
<p:column> <p:column>
<f:facet name="header"> <f:facet name="header">
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<p:panelGrid columns="1" cellpadding="1"> <p:panelGrid columns="1" cellpadding="1">
<ui:fragment rendered="#{not empty userView.selectedUser.id}"> <ui:fragment rendered="#{not empty userView.selectedUser.id}">
<p:dialog id="chartPanel" for="webcamButton" modal="true" dynamic="true" widgetVar="webcamDialog"> <p:dialog id="chartPanel" for="webcamButton" dynamic="true" widgetVar="webcamDialog">
<p:photoCam widgetVar="pc" listener="#{userView.oncapture}" update="@all" /> <p:photoCam widgetVar="pc" listener="#{userView.oncapture}" update="@all" />
<p:commandButton type="button" value="Capture" onclick="PF('pc').capture()" onerror="location.reload(true);" /> <p:commandButton type="button" value="Capture" onclick="PF('pc').capture()" onerror="location.reload(true);" />
</p:dialog> </p:dialog>
......
...@@ -33,6 +33,7 @@ bill.expires = Expires ...@@ -33,6 +33,7 @@ bill.expires = Expires
bill.isExpired = Bill is expired bill.isExpired = Bill is expired
bill.markPaid.show = Show Mark paid -buttons bill.markPaid.show = Show Mark paid -buttons
bill.notes.title = Lis\u00E4tietoja bill.notes.title = Lis\u00E4tietoja
bill.products = Tuotteet
bill.save = Save bill.save = Save
bill.showPayButtons = Show pay buttons bill.showPayButtons = Show pay buttons
...@@ -159,8 +160,13 @@ eventorg.create = Create ...@@ -159,8 +160,13 @@ eventorg.create = Create
eventorg.title = Tapahtuman tiedot eventorg.title = Tapahtuman tiedot
foodWave.closeNow = Close now foodWave.closeNow = Close now
foodWave.deliveredCount = Luovutetut
foodWave.openNow = Open now foodWave.openNow = Open now
foodwave.foodwaveLastBillPayTime = Maksut viimeist\u00E4\u00E4n
foodwave.ordersBefore = Tilaukset ennen
foodwave.template.waitPaymentsMinutes = Verkkomaksujen odotusaika
game.active = Aktiivinen game.active = Aktiivinen
game.codecount = Avattuja game.codecount = Avattuja
game.codes.available = Lisenssikoodit game.codes.available = Lisenssikoodit
...@@ -361,6 +367,8 @@ subnavi.info = Info ...@@ -361,6 +367,8 @@ subnavi.info = Info
success = Onnistui success = Onnistui
suffix.minutes = min
topnavi.adminlectures = Kurssit ja luennot topnavi.adminlectures = Kurssit ja luennot
topnavi.license = Lisenssikoodit topnavi.license = Lisenssikoodit
topnavi.userlectures = Kurssit ja luennot topnavi.userlectures = Kurssit ja luennot
......
...@@ -88,6 +88,7 @@ bill.payer = Payer ...@@ -88,6 +88,7 @@ bill.payer = Payer
bill.paymentTime = Payment time bill.paymentTime = Payment time
bill.paymentTime.now = Now bill.paymentTime.now = Now
bill.printBill = Print bill bill.printBill = Print bill
bill.products = Products
bill.receiverAddress = Receiver address bill.receiverAddress = Receiver address
bill.referenceNumberBase = Reference number base bill.referenceNumberBase = Reference number base
bill.referencenumber = Reference nr. bill.referencenumber = Reference nr.
...@@ -405,8 +406,9 @@ food = Food ...@@ -405,8 +406,9 @@ food = Food
foodWave.accountevents = Accountevents foodWave.accountevents = Accountevents
foodWave.activeFoodWaves = Active Foodwaves foodWave.activeFoodWaves = Active Foodwaves
foodWave.billLines = Pending Online Payments foodWave.billLines = Pending Payments
foodWave.closeNow = Close now foodWave.closeNow = Close now
foodWave.deliveredCount = Delivered
foodWave.deliveredFoodWaves = Delivered Foodwaves foodWave.deliveredFoodWaves = Delivered Foodwaves
foodWave.description = Foodwave description foodWave.description = Foodwave description
foodWave.list = Active Foodwaves foodWave.list = Active Foodwaves
...@@ -431,8 +433,10 @@ foodshop.total = Total ...@@ -431,8 +433,10 @@ foodshop.total = Total
foodwave.buyInPrice = Buy In Price foodwave.buyInPrice = Buy In Price
foodwave.foodwaveBuyInPrice = Total buy in price foodwave.foodwaveBuyInPrice = Total buy in price
foodwave.foodwaveLastBillPayTime = Last payments time
foodwave.markPaid = Foodwave marked paid foodwave.markPaid = Foodwave marked paid
foodwave.orders = Foodwave Orders foodwave.orders = Foodwave Orders
foodwave.ordersBefore = Orders before
foodwave.price = Foodwave price foodwave.price = Foodwave price
foodwave.summaryView = Foodwave Summary foodwave.summaryView = Foodwave Summary
foodwave.template.basicinfo = Template Information foodwave.template.basicinfo = Template Information
...@@ -441,6 +445,7 @@ foodwave.template.edit.title = Foodwave Template Editor ...@@ -441,6 +445,7 @@ foodwave.template.edit.title = Foodwave Template Editor
foodwave.template.list.title = Foodwave Templates foodwave.template.list.title = Foodwave Templates
foodwave.template.name = Name foodwave.template.name = Name
foodwave.template.selectproducts = Products foodwave.template.selectproducts = Products
foodwave.template.waitPaymentsMinutes = Webpayments waittime
foodwave.totalCount = Amount foodwave.totalCount = Amount
foodwave.totalPrice = Customer Price foodwave.totalPrice = Customer Price
...@@ -1244,6 +1249,8 @@ subnavi.roles = Roles ...@@ -1244,6 +1249,8 @@ subnavi.roles = Roles
success = Success success = Success
suffix.minutes = min
supernavi.admin = Adminview supernavi.admin = Adminview
supernavi.user = Userview supernavi.user = Userview
......
...@@ -88,6 +88,7 @@ bill.payer = Maksaja ...@@ -88,6 +88,7 @@ bill.payer = Maksaja
bill.paymentTime = Maksuehdot bill.paymentTime = Maksuehdot
bill.paymentTime.now = Heti bill.paymentTime.now = Heti
bill.printBill = Tulosta lasku bill.printBill = Tulosta lasku
bill.products = Tuotteet
bill.receiverAddress = Kauppiaan osoite bill.receiverAddress = Kauppiaan osoite
bill.referenceNumberBase = Viitenumeropohja bill.referenceNumberBase = Viitenumeropohja
bill.referencenumber = Viitenumero bill.referencenumber = Viitenumero
...@@ -406,8 +407,9 @@ food = Ruoka ...@@ -406,8 +407,9 @@ food = Ruoka
foodWave.accountevents = Maksetut tilaukset foodWave.accountevents = Maksetut tilaukset
foodWave.activeFoodWaves = Aktiiviset Ruokatilaukset foodWave.activeFoodWaves = Aktiiviset Ruokatilaukset
foodWave.billLines = Maksamattomat Verkkomaksut foodWave.billLines = Maksamattomat maksut
foodWave.closeNow = Sulje nyt foodWave.closeNow = Sulje nyt
foodWave.deliveredCount = Toimitetut
foodWave.deliveredFoodWaves = Toimitetut Ruokatilaukset foodWave.deliveredFoodWaves = Toimitetut Ruokatilaukset
foodWave.description = Ruokatilauksen kuvaus foodWave.description = Ruokatilauksen kuvaus
foodWave.list = Ruokatilaukset foodWave.list = Ruokatilaukset
...@@ -432,8 +434,10 @@ foodshop.total = Yhteens\u00E4 ...@@ -432,8 +434,10 @@ foodshop.total = Yhteens\u00E4
foodwave.buyInPrice = Sis\u00E4\u00E4nostohinta foodwave.buyInPrice = Sis\u00E4\u00E4nostohinta
foodwave.foodwaveBuyInPrice = Sis\u00E4\u00E4nostohinta foodwave.foodwaveBuyInPrice = Sis\u00E4\u00E4nostohinta
foodwave.foodwaveLastBillPayTime = Maksut viimeist\u00E4\u00E4n
foodwave.markPaid = Merkitty maksetuksi foodwave.markPaid = Merkitty maksetuksi
foodwave.orders = Maksetut Tilaukset foodwave.orders = Maksetut Tilaukset
foodwave.ordersBefore = Tilaukset ennen
foodwave.price = Tilausten kokonaishinta foodwave.price = Tilausten kokonaishinta
foodwave.summaryView = Ruokatilauksen Yhteenveto foodwave.summaryView = Ruokatilauksen Yhteenveto
foodwave.template.basicinfo = Template Infot foodwave.template.basicinfo = Template Infot
...@@ -442,6 +446,7 @@ foodwave.template.edit.title = Foodwave Template Editori ...@@ -442,6 +446,7 @@ foodwave.template.edit.title = Foodwave Template Editori
foodwave.template.list.title = Ruokatilaus Templatet foodwave.template.list.title = Ruokatilaus Templatet
foodwave.template.name = Nimi foodwave.template.name = Nimi
foodwave.template.selectproducts = Tuotteet foodwave.template.selectproducts = Tuotteet
foodwave.template.waitPaymentsMinutes = Verkkomaksujen odotusaika
foodwave.totalCount = M\u00E4\u00E4r\u00E4 foodwave.totalCount = M\u00E4\u00E4r\u00E4
foodwave.totalPrice = Asiakkaan Hinta foodwave.totalPrice = Asiakkaan Hinta
...@@ -1227,6 +1232,8 @@ subnavi.roles = Roolit ...@@ -1227,6 +1232,8 @@ subnavi.roles = Roolit
success = Onnistui success = Onnistui
suffix.minutes = min
supernavi.admin = Yll\u00E4piton\u00E4kym\u00E4 supernavi.admin = Yll\u00E4piton\u00E4kym\u00E4
supernavi.user = K\u00E4ytt\u00E4j\u00E4n\u00E4kym\u00E4 supernavi.user = K\u00E4ytt\u00E4j\u00E4n\u00E4kym\u00E4
......
...@@ -23,6 +23,7 @@ import java.util.ArrayList; ...@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.TreeSet; import java.util.TreeSet;
...@@ -76,12 +77,13 @@ public class FoodWaveView extends GenericCDIView { ...@@ -76,12 +77,13 @@ public class FoodWaveView extends GenericCDIView {
private Date startDate; private Date startDate;
private Product currentProduct; private Product currentProduct;
private ListDataModel<BillLine> billLines; //private ListDataModel<BillLine> billLines;
// private List<BillLine> unpaidBills; // private List<BillLine> unpaidBills;
private Integer foodWaveId; private Integer foodWaveId;
private ListDataModel<AccountEvent> accountEventLines; private ListDataModel<AccountEvent> accountEventLines;
private ListDataModel<FoodWave> foodWaves; private ListDataModel<FoodWave> foodWaves;
private ListDataModel<Bill> bills;
private static final Logger logger = LoggerFactory.getLogger(FoodWaveView.class); private static final Logger logger = LoggerFactory.getLogger(FoodWaveView.class);
public List<Product> getProducts() { public List<Product> getProducts() {
...@@ -175,7 +177,7 @@ public class FoodWaveView extends GenericCDIView { ...@@ -175,7 +177,7 @@ public class FoodWaveView extends GenericCDIView {
public List<FoodwaveProductSummary> getProductSummaries() { public List<FoodwaveProductSummary> getProductSummaries() {
System.out.println("..asdfasdf");
HashMap<Product, FoodwaveProductSummary> pmap = new HashMap<Product, FoodwaveProductSummary>(); HashMap<Product, FoodwaveProductSummary> pmap = new HashMap<Product, FoodwaveProductSummary>();
for (AccountEvent ae : getSelectedFoodWave().getAccountEvents()) { for (AccountEvent ae : getSelectedFoodWave().getAccountEvents()) {
...@@ -221,6 +223,10 @@ public class FoodWaveView extends GenericCDIView { ...@@ -221,6 +223,10 @@ public class FoodWaveView extends GenericCDIView {
} }
return ret.negate(); return ret.negate();
} }
public BigDecimal getFoodwaveBuyInPrice() public BigDecimal getFoodwaveBuyInPrice()
{ {
...@@ -246,12 +252,14 @@ public class FoodWaveView extends GenericCDIView { ...@@ -246,12 +252,14 @@ public class FoodWaveView extends GenericCDIView {
// } // }
public String markBillPaid() { public String markBillPaid() {
if (permbean.hasPermission(BillPermission.WRITE_ALL) && getBillLines().isRowAvailable()) { if (permbean.hasPermission(BillPermission.WRITE_ALL) && bills != null && bills.isRowAvailable()) {
Bill b = getBillLines().getRowData().getBill(); Bill b = bills.getRowData();
b = billbean.markPaid(b, Calendar.getInstance()); b = billbean.markPaid(b, Calendar.getInstance());
foodWaveId = selectedFoodWave.getId(); foodWaveId = selectedFoodWave.getId();
selectedFoodWave = null; selectedFoodWave = null;
bills = null;
initFoodWaveOrderList(); initFoodWaveOrderList();
} }
...@@ -259,8 +267,8 @@ public class FoodWaveView extends GenericCDIView { ...@@ -259,8 +267,8 @@ public class FoodWaveView extends GenericCDIView {
} }
public String deliverAccountEvent() { public String deliverAccountEvent() {
if (getAccountEventLines().isRowAvailable()) { if (accountEventLines != null && accountEventLines.isRowAvailable()) {
AccountEvent e = getAccountEventLines().getRowData(); AccountEvent e = accountEventLines.getRowData();
e = productbeanlocal.markDelivered(e, Calendar.getInstance()); e = productbeanlocal.markDelivered(e, Calendar.getInstance());
foodWaveId = selectedFoodWave.getId(); foodWaveId = selectedFoodWave.getId();
selectedFoodWave = null; selectedFoodWave = null;
...@@ -271,27 +279,28 @@ public class FoodWaveView extends GenericCDIView { ...@@ -271,27 +279,28 @@ public class FoodWaveView extends GenericCDIView {
} }
public void initFoodWaveOrderList() { public void initFoodWaveOrderList() {
if (super.requirePermissions(ShopPermission.MANAGE_FOODWAVES) && selectedFoodWave == null) { if (super.requirePermissions(ShopPermission.MANAGE_FOODWAVES) && selectedFoodWave == null) {
selectedFoodWave = foodWaveBean.findFoodwave(foodWaveId); selectedFoodWave = foodWaveBean.findFoodwave(foodWaveId);
logger.debug("Got foodwave {} with id {}", selectedFoodWave, foodWaveId); logger.debug("Got foodwave {} with id {}", selectedFoodWave, foodWaveId);
this.setAccountEventLines(new ListDataModel<AccountEvent>(selectedFoodWave.getAccountEvents())); super.beginConversation();
}
List<BillLine> tmpLines = new ArrayList<BillLine>();
HashSet<Bill> billList = new HashSet<Bill>();
for (BillLine line : selectedFoodWave.getBillLines()) { for (BillLine line : getSelectedFoodWave().getBillLines()) {
if (!line.getBill().isPaid()) { if (!line.getBill().isPaid()) {
tmpLines.add(line); billList.add(line.getBill());
}
} }
setBillLines(new ListDataModel<BillLine>(tmpLines));
setAccountEventLines(new ListDataModel<AccountEvent>(selectedFoodWave.getAccountEvents()));
super.beginConversation();
} }
bills = new ListDataModel<Bill>(new ArrayList<Bill>(billList));
accountEventLines = new ListDataModel<AccountEvent>(getSelectedFoodWave().getAccountEvents());
} }
public String saveTemplate() public String saveTemplate()
...@@ -315,7 +324,6 @@ public class FoodWaveView extends GenericCDIView { ...@@ -315,7 +324,6 @@ public class FoodWaveView extends GenericCDIView {
} }
public FoodWave getSelectedFoodWave() { public FoodWave getSelectedFoodWave() {
// System.out.println("APOFKASFASFASFASFASFASFASFASFASFKJIOJIO");
return selectedFoodWave; return selectedFoodWave;
} }
...@@ -351,13 +359,10 @@ public class FoodWaveView extends GenericCDIView { ...@@ -351,13 +359,10 @@ public class FoodWaveView extends GenericCDIView {
this.foodWaveId = foodWaveId; this.foodWaveId = foodWaveId;
} }
public ListDataModel<BillLine> getBillLines() { public ListDataModel<Bill> getBills() {
return billLines; return bills;
} }
public void setBillLines(ListDataModel<BillLine> billLines) {
this.billLines = billLines;
}
public void setFoodWaves(ListDataModel<FoodWave> foodWaves) { public void setFoodWaves(ListDataModel<FoodWave> foodWaves) {
this.foodWaves = foodWaves; this.foodWaves = foodWaves;
...@@ -366,15 +371,12 @@ public class FoodWaveView extends GenericCDIView { ...@@ -366,15 +371,12 @@ public class FoodWaveView extends GenericCDIView {
public ListDataModel<FoodWave> getFoodWaves() { public ListDataModel<FoodWave> getFoodWaves() {
return foodWaves; return foodWaves;
} }
public ListDataModel<AccountEvent> getAccountEventLines() { public ListDataModel<AccountEvent> getAccountEventLines() {
return accountEventLines; return accountEventLines;
} }
public void setAccountEventLines(ListDataModel<AccountEvent> accountEventLines) {
this.accountEventLines = accountEventLines;
}
/* /*
* public List<BillLine> getUnpaidBills() { return unpaidBills; } * public List<BillLine> getUnpaidBills() { return unpaidBills; }
* *
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!