Commit 6228cb68 by Tuomas Riihimäki

Merge branch 'master' of codecrew.fi:bortal

2 parents 8ee9667b 6f12b1bb
......@@ -4,10 +4,9 @@
*/
package fi.insomnia.bortal.model;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
import javax.persistence.Column;
import javax.persistence.Entity;
......@@ -54,7 +53,7 @@ public class FoodWave extends GenericEntity {
@OneToMany(mappedBy = "foodwave")
private List<BillLine> billLines;
@OneToMany(mappedBy = "foodwave")
private List<BillLine> unpaidBills;
......@@ -152,9 +151,26 @@ public class FoodWave extends GenericEntity {
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() {
return maximumFoods;
}
......@@ -176,6 +192,7 @@ public class FoodWave extends GenericEntity {
return retval;
}
public void setMaximumFoods(Integer maximumFoods) {
this.maximumFoods = maximumFoods;
}
......
......@@ -83,6 +83,7 @@ public class FoodWaveTemplate extends GenericEntity {
public List<Product> getProducts() {
return products;
}
/**
* @param products
......
......@@ -46,7 +46,7 @@
<div id="actionlog">
<h:form id="refresh">
<p:poll interval="1" update="actionlogtable" />
<p:dataTable styleClass="bordertable" id="actionlogtable" value="#{actionLogMessageView.messages}" var="message" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
<p:dataTable2styleClass="bordertable" id="actionlogtable" value="#{actionLogMessageView.messages}" var="message" paginator="true" rows="30" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="10,20,30,50,100">
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['actionlog.time']}" />
......
......@@ -137,6 +137,14 @@
</p:dataTable>
</h:form>
<br />
<br />
<br />
<br />
<foodwave:summary foodwaveProductSummaries="#{foodWaveView.productSummaries}" foodwave="#{foodWaveView.selectedFoodWave}"/>
</ui:define>
......
package fi.insomnia.bortal.web.cdiview.shop;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.TreeSet;
......@@ -12,6 +14,8 @@ import javax.faces.model.ListDataModel;
import javax.inject.Inject;
import javax.inject.Named;
import com.sun.xml.rpc.processor.schema.UnimplementedFeatureException;
import fi.insomnia.bortal.beans.AccountEventBeanLocal;
import fi.insomnia.bortal.beans.BillBeanLocal;
import fi.insomnia.bortal.beans.EventBeanLocal;
......@@ -27,6 +31,7 @@ import fi.insomnia.bortal.model.FoodWaveTemplate;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.ProductFlag;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
import fi.insomnia.bortal.web.helpers.FoodwaveProductSummary;
@Named
@ConversationScoped
......@@ -137,6 +142,23 @@ public class FoodWaveView extends GenericCDIView {
super.beginConversation();
}
}
public List<FoodwaveProductSummary> getProductSummaries() {
System.out.println("..asdfasdf");
HashMap<Product, FoodwaveProductSummary> pmap = new HashMap<Product, FoodwaveProductSummary>();
for(AccountEvent ae : getSelectedFoodWave().getAccountEvents()) {
if(!pmap.containsKey(ae.getProduct())) {
pmap.put(ae.getProduct(), new FoodwaveProductSummary(ae.getProduct(), new BigDecimal(0), new BigDecimal(0)));
}
System.out.println("..");
pmap.get(ae.getProduct()).add(ae);
}
System.out.println("::"+pmap.values().size());
return new ArrayList<FoodwaveProductSummary>(pmap.values());
}
private void createNewProductSkeleton() {
TreeSet<ProductFlag> ts = new TreeSet<ProductFlag>();
......@@ -199,7 +221,7 @@ public class FoodWaveView extends GenericCDIView {
public void initFoodWaveOrderList() {
if (super.requirePermissions(ShopPermission.MANAGE_FOODWAVES) && selectedFoodWave == null) {
System.out.println("Testiä");
selectedFoodWave = foodWaveBean.findFoodwave(foodWaveId);
this.setAccountEventLines(new ListDataModel<AccountEvent>(selectedFoodWave.getAccountEvents()));
......@@ -242,6 +264,7 @@ public class FoodWaveView extends GenericCDIView {
}
public FoodWave getSelectedFoodWave() {
System.out.println("APOFKASFASFASFASFASFASFASFASFASFKJIOJIO");
return selectedFoodWave;
}
......
package fi.insomnia.bortal.web.helpers;
import java.math.BigDecimal;
import fi.insomnia.bortal.model.AccountEvent;
import fi.insomnia.bortal.model.Product;
public class FoodwaveProductSummary {
private Product product;
private BigDecimal count;
private BigDecimal summaryPrice;
public FoodwaveProductSummary(Product product, BigDecimal count, BigDecimal summaryPrice) {
setProduct(product);
setCount(count);
setSummaryPrice(summaryPrice);
}
public Product getProduct() {
return product;
}
public void setProduct(Product product) {
this.product = product;
}
public BigDecimal getCount() {
return count;
}
public void setCount(BigDecimal count) {
this.count = count;
}
public BigDecimal getSummaryPrice() {
return summaryPrice;
}
public void setSummaryPrice(BigDecimal summaryPrice) {
this.summaryPrice = summaryPrice;
}
public void add(AccountEvent ae) {
setCount(getCount().add(ae.getQuantity()));
setSummaryPrice(getSummaryPrice().add((ae.getTotal().negate())));
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!