Commit 4877a108 by Tuukka Kivilahti

merge

2 parents e5216936 91e1b5b3
......@@ -202,13 +202,13 @@ public class MenuBean implements MenuBeanLocal {
MenuNavigation foodnavi = adminnavi.addPage(null, null);
foodnavi.setKey("topnavi.foodwave");
foodnavi.addPage(menuitemfacade.findOrCreate("/foodadmin/createTemplate"), ShopPermission.MANAGE_FOODWAVES);
foodnavi.addPage(menuitemfacade.findOrCreate("/foodadmin/listTemplates"), ShopPermission.MANAGE_FOODWAVES);
foodnavi.addPage(menuitemfacade.findOrCreate("/foodadmin/editTemplate"), ShopPermission.MANAGE_FOODWAVES).setVisible(false);
foodnavi.addPage(menuitemfacade.findOrCreate("/foodmanager/listFoodwaves"), ShopPermission.MANAGE_FOODWAVES);
foodnavi.addPage(menuitemfacade.findOrCreate("/foodmanager/listOrders"), ShopPermission.MANAGE_FOODWAVES).setVisible(false);
foodnavi.addPage(menuitemfacade.findOrCreate("/foodadmin/listTemplates"), ShopPermission.MANAGE_FOODWAVES);
foodnavi.addPage(menuitemfacade.findOrCreate("/foodadmin/createTemplate"), ShopPermission.MANAGE_FOODWAVES);
foodnavi.addPage(menuitemfacade.findOrCreate("/foodadmin/editTemplate"), ShopPermission.MANAGE_FOODWAVES).setVisible(false);
}
@Override
......
......@@ -357,9 +357,7 @@ public class Bill extends GenericEntity {
this.getBillLines().add(new BillLine(this, product, count, foodwave));
for (Discount disc : product.getActiveDiscounts(count, sentDate)) {
this.getBillLines().add(new BillLine(this, product, disc, count));
}
}
......
......@@ -7,6 +7,7 @@ package fi.insomnia.bortal.model;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import javax.persistence.Column;
import javax.persistence.Entity;
......@@ -102,12 +103,11 @@ public class BillLine extends GenericEntity {
super();
}
public BillLine(Bill bill2, Product product, BigDecimal count) {
this(bill2, product, count, null);
}
public BillLine(Bill bill2, Product product, BigDecimal count, FoodWave foodwave) {
public BillLine(Bill bill2, Product product, BigDecimal count, FoodWave foodwave) {
super();
this.bill = bill2;
this.lineProduct = product;
......@@ -117,13 +117,20 @@ public class BillLine extends GenericEntity {
this.setUnitPrice(product.getPrice().abs());
this.setVat(product.getVat());
this.setFoodwave(foodwave);
if (foodwave != null) {
if (foodwave.getBillLines() == null) {
foodwave.setBillLines(new ArrayList<BillLine>());
}
if (!foodwave.getBillLines().contains(this)) {
foodwave.getBillLines().add(this);
}
}
}
/**
* Discounttia luotaessa lasketaan productin hinnasta jokin kiva miinuspuolinen rivi discountin mukaan?
/**
* Discounttia luotaessa lasketaan productin hinnasta jokin kiva
* miinuspuolinen rivi discountin mukaan?
*
* Kommentteja plz!
*
......
......@@ -21,8 +21,6 @@ import javax.persistence.TemporalType;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
import com.sun.istack.internal.logging.Logger;
/**
*
*/
......
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<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:foodwave="http://java.sun.com/jsf/composite/cditools/foodwave"
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">
<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:foodwave="http://java.sun.com/jsf/composite/cditools/foodwave" 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>
<ui:composition
template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:event type="preRenderView"
listener="#{foodWaveView.initFoodwaveManagerList}" />
<f:event type="preRenderView" listener="#{foodWaveView.initFoodwaveManagerList}" />
</f:metadata>
<ui:define name="title">
......@@ -22,14 +13,13 @@
</ui:define>
<ui:define name="content">
<p:dataTable styleClass="bordertable"
value="#{foodWaveView.foodWaves}" var="foodwave">
<p:dataTable styleClass="bordertable" value="#{foodWaveView.foodWaves}" var="foodwave">
<p:column>
<f:facet name="header">
<h:outputText value="${i18n['foodWave.time']}" />
</f:facet>
<h:outputText value="#{foodwave.time.time}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</p:column>
<p:column>
......@@ -61,15 +51,14 @@
<f:facet name="header">
<h:outputText value="${i18n['foodWave.totalReserved']}" />
</f:facet>
<h:outputText value="#{foodwave.reservedCount}" /> / <h:outputText
value="#{foodwave.maximumFoods}" />
<h:outputText value="#{foodwave.reservedCount}" /> / <h:outputText value="#{foodwave.maximumFoods}" />
</p:column>
<p:column>
<h:link outcome="/foodmanager/listOrders"
value="#{i18n['foodWave.show']}">
<h:link outcome="/foodmanager/listOrders" value="#{i18n['foodWave.show']}">
<f:param name="foodwaveid" value="#{foodwave.id}" />
</h:link>
</p:column><!--
</p:column>
<!--
<p:column>
<h:outputText value="#{foodwave.closed.toString()}" />
<p:commandButton rendered="#{foodwave.closed}"
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<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:foodwave="http://java.sun.com/jsf/composite/cditools/foodwave"
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">
<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:foodwave="http://java.sun.com/jsf/composite/cditools/foodwave" 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>
<ui:composition
template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:viewParam name="foodwaveid" value="#{foodWaveView.foodWaveId}" />
<f:event type="preRenderView"
listener="#{foodWaveView.initFoodWaveOrderList}" />
<f:event type="preRenderView" listener="#{foodWaveView.initFoodWaveOrderList}" />
<!-- <f:event type="preRenderView" listener="#{foodWaveView.initFoodwaveAccountEventList}" /> -->
</f:metadata>
......@@ -22,8 +13,7 @@
</ui:define>
<ui:define name="content">
<h:form>
<p:dataTable styleClass="bordertable"
value="#{foodWaveView.accountEventLines}" var="acc_line">
<p:dataTable styleClass="bordertable" value="#{foodWaveView.accountEventLines}" var="acc_line">
<f:facet name="header">
<h:outputLabel value="#{i18n['foodWave.accountevents']}" />
</f:facet>
......@@ -31,8 +21,7 @@
<f:facet name="header">
<h:outputLabel value="#{i18n['acc_line.time']}" />
</f:facet>
<h:outputText style="text-align: center;"
value="#{acc_line.eventTime.getTime()}">
<h:outputText style="text-align: center;" value="#{acc_line.eventTime.getTime()}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</p:column>
......@@ -40,8 +29,7 @@
<f:facet name="header">
<h:outputLabel value="#{i18n['acc_line.quantity']}" />
</f:facet>
<h:outputText style="text-align: center;"
value="#{acc_line.quantity}">
<h:outputText style="text-align: center;" value="#{acc_line.quantity}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText>
</p:column>
......@@ -55,8 +43,7 @@
<f:facet name="header">
<h:outputLabel value="#{i18n['acc_line.eventuser']}" />
</f:facet>
<h:link outcome="/useradmin/edit"
value="#{acc_line.user.wholeName}">
<h:link outcome="/useradmin/edit" value="#{acc_line.user.wholeName}">
<f:param value="#{acc_line.user.id}" />
</h:link>
</p:column>
......@@ -72,11 +59,8 @@
<f:facet name="header">
<h:outputLabel value="#{i18n['accountEvent.delivered']}" />
</f:facet>
<h:outputText rendered="#{acc_line.eventDelivered}"
value="#{i18n['accountEvent.delivered']}" />
<h:commandButton rendered="#{not acc_line.eventDelivered}"
value="#{i18n['accountEvent.deliver']}"
action="#{foodWaveView.deliverAccountEvent}" />
<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:column>
</p:dataTable>
......@@ -93,8 +77,7 @@
<br></br>
<h:form>
<p:dataTable styleClass="bordertable"
value="#{foodWaveView.billLines}" var="bill_line">
<p:dataTable styleClass="bordertable" value="#{foodWaveView.billLines}" var="bill_line">
<f:facet name="header">
<h:outputLabel value="#{i18n['foodWave.billLines']}" />
</f:facet>
......@@ -110,8 +93,7 @@
<f:facet name="header">
<h:outputLabel value="#{i18n['billLine.quantity']}" />
</f:facet>
<h:outputText style="text-align: center;"
value="#{bill_line.quantity}">
<h:outputText style="text-align: center;" value="#{bill_line.quantity}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText>
</p:column>
......@@ -125,8 +107,7 @@
<f:facet name="header">
<h:outputLabel value="#{i18n['billLine.eventuser']}" />
</f:facet>
<h:link outcome="/useradmin/edit"
value="#{bill_line.bill.user.wholeName}">
<h:link outcome="/useradmin/edit" value="#{bill_line.bill.user.wholeName}">
<f:param name="userid" value="#{bill_line.bill.user.id}" />
</h:link>
</p:column>
......@@ -134,8 +115,7 @@
<f:facet name="header">
<h:outputLabel value="#{i18n['billLine.nick']}" />
</f:facet>
<h:link outcome="/useradmin/edit"
value="#{bill_line.bill.user.nick}">
<h:link outcome="/useradmin/edit" value="#{bill_line.bill.user.nick}">
<f:param name="userid" value="#{bill_line.bill.user.id}" />
</h:link>
</p:column>
......@@ -143,8 +123,7 @@
<f:facet name="header">
<h:outputLabel value="#{i18n['billLine.price']}" />
</f:facet>
<h:outputText style="text-align: center;"
value="#{bill_line.linePrice}">
<h:outputText style="text-align: center;" value="#{bill_line.linePrice}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText>
</p:column>
......@@ -153,15 +132,13 @@
<f:facet name="header">
<h:outputLabel value="#{i18n['bill.totalprice']}" />
</f:facet>
<h:outputText style="text-align: center;"
value="#{bill_line.bill.totalPrice}">
<h:outputText style="text-align: center;" value="#{bill_line.bill.totalPrice}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText>
</p:column>
<p:column>
<h:commandButton value="#{i18n['bill.markPaid']}"
action="#{foodWaveView.markBillPaid}" />
<h:commandButton value="#{i18n['bill.markPaid']}" action="#{foodWaveView.markBillPaid}" />
</p:column>
<!--
<p:column>
......@@ -171,13 +148,55 @@
</p:dataTable>
</h:form>
<h2>#{i18n['foodwave.summaryView']}</h2>
<div>
<h:outputLabel value="#{i18n['foodwave.price']}: " />
<h:outputText value="#{foodWaveView.foodwavePrice}" />
</div>
<div>
<h:outputLabel value="#{i18n['foodwave.foodwaveBuyInPrice']}: " />
<h:outputText value="#{foodWaveView.foodwaveBuyInPrice}" />
</div>
<p:dataTable var="summ" value="#{foodWaveView.productSummaries}">
<p:column>
<f:facet name="header">
<h:outputLabel value="#{i18n['product.name']}" />
</f:facet>
<h:outputText value="#{summ.product.name}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputLabel value="#{i18n['foodwave.totalCount']}" />
</f:facet>
<h:outputText value="#{summ.count}">
<f:convertNumber minFractionDigits="0" />
</h:outputText>
</p:column>
<p:column>
<f:facet name="header">
<h:outputLabel value="#{i18n['foodwave.totalPrice']}" />
</f:facet>
<h:outputText value="#{summ.summaryPrice}">
<f:convertNumber minFractionDigits="0" />
</h:outputText>
</p:column>
<p:column>
<f:facet name="header">
<h:outputLabel value="#{i18n['foodwave.buyInPrice']}" />
</f:facet>
<h:outputText value="#{summ.buyInPrice}">
<f:convertNumber minFractionDigits="0" />
</h:outputText>
</p:column>
</p:dataTable>
<foodwave:summary foodwaveProductSummaries="#{foodWaveView.productSummaries}" foodwave="#{foodWaveView.selectedFoodWave}"/>
<!-- <foodwave:summary foodwaveProductSummaries="#{foodWaveView.productSummaries}" foodwave="#{foodWaveView.selectedFoodWave}"/>
-->
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
</html>
......@@ -218,7 +218,11 @@ foodshop.buyFromCounter = Pay at info
foodshop.buyFromInternet = Pay at Internet
foodshop.total = Total
foodwave.foodwaveBuyInPrice = Total buy in price
foodwave.markPaid = Foodwave marked paid
foodwave.orders = Foodwave Orders
foodwave.price = Foodwave price
foodwave.summaryView = Foodwave summary
foodwave.template.basicinfo = Template Information
foodwave.template.description = Description
foodwave.template.edit.title = Foodwave Template Editor
......
......@@ -216,7 +216,10 @@ foodshop.buyFromCounter = Maksa infossa
foodshop.buyFromInternet = Maksa Internetiss\u00E4
foodshop.total = Yhteens\u00E4
foodwave.foodwaveBuyInPrice = Sis\u00E4\u00E4nostohinta
foodwave.markPaid = Merkitty maksetuksi
foodwave.orders = Maksetut Tilaukset
foodwave.price = Tilausten kokonaishinta
foodwave.template.basicinfo = Template Infot
foodwave.template.description = Kuvaus
foodwave.template.edit.title = Foodwave Template Editori
......
......@@ -141,6 +141,7 @@ public class FoodWaveFoodView extends GenericCDIView {
bill.addProduct(shopitem.getProduct(), shopitem.getCount(), getFoodWave());
}
}
billBean.createBill(bill);
return bill;
......
......@@ -154,7 +154,7 @@ public class FoodWaveView extends GenericCDIView {
for (AccountEvent ae : getSelectedFoodWave().getAccountEvents()) {
if (!pmap.containsKey(ae.getProduct())) {
pmap.put(ae.getProduct(), new FoodwaveProductSummary(ae.getProduct(), new BigDecimal(0), new BigDecimal(0)));
pmap.put(ae.getProduct(), new FoodwaveProductSummary(ae.getProduct()));
}
System.out.println("..");
......@@ -186,17 +186,17 @@ public class FoodWaveView extends GenericCDIView {
this.currentProduct = currentProduct;
}
public BigDecimal getFoodWavePrice()
public BigDecimal getFoodwavePrice()
{
BigDecimal ret = BigDecimal.ZERO;
for (AccountEvent ac : selectedFoodWave.getAccountEvents())
{
ret = ret.add(ac.getTotal());
}
return ret;
return ret.negate();
}
public BigDecimal getBuyInPrice()
public BigDecimal getFoodwaveBuyInPrice()
{
BigDecimal ret = BigDecimal.ZERO;
for (AccountEvent ac : selectedFoodWave.getAccountEvents())
......
......@@ -10,11 +10,13 @@ public class FoodwaveProductSummary {
private Product product;
private BigDecimal count;
private BigDecimal summaryPrice;
private BigDecimal buyInPrice;
public FoodwaveProductSummary(Product product, BigDecimal count, BigDecimal summaryPrice) {
public FoodwaveProductSummary(Product product) {
setProduct(product);
setCount(count);
setSummaryPrice(summaryPrice);
setCount(BigDecimal.ZERO);
setSummaryPrice(BigDecimal.ZERO);
buyInPrice = BigDecimal.ZERO;
}
public Product getProduct() {
......@@ -43,8 +45,20 @@ public class FoodwaveProductSummary {
public void add(AccountEvent ae) {
setCount(getCount().add(ae.getQuantity()));
setSummaryPrice(getSummaryPrice().add((ae.getTotal().negate())));
if (product.getBuyInPrice() != null)
{
buyInPrice = buyInPrice.add(getProduct().getBuyInPrice());
}
}
public BigDecimal getBuyInPrice() {
return buyInPrice;
}
public void setBuyInPrice(BigDecimal buyInPrice) {
this.buyInPrice = buyInPrice;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!