lol, dunno what

1 parent d6e5b3f7
......@@ -336,6 +336,10 @@ public class Bill extends GenericEntity {
}
public void addProduct(Product product, BigDecimal count) {
this.addProduct(product, count, null);
}
public void addProduct(Product product, BigDecimal count, FoodWave foodwave) {
// If bill number > 0 bill has been sent and extra privileges are needed
// to modify.
// if (!iscurrent || billnr != null) {
......@@ -346,7 +350,7 @@ public class Bill extends GenericEntity {
if (this.billLines == null) {
billLines = new ArrayList<BillLine>();
}
this.getBillLines().add(new BillLine(this, product, count));
this.getBillLines().add(new BillLine(this, product, count, foodwave));
for (Discount disc : product.getActiveDiscounts(count, sentDate)) {
......
......@@ -102,7 +102,12 @@ 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) {
super();
this.bill = bill2;
this.lineProduct = product;
......@@ -111,8 +116,20 @@ public class BillLine extends GenericEntity {
this.setQuantity(count);
this.setUnitPrice(product.getPrice().abs());
this.setVat(product.getVat());
this.setFoodwave(foodwave);
}
/**
* Discounttia luotaessa lasketaan productin hinnasta jokin kiva miinuspuolinen rivi discountin mukaan?
*
* Kommentteja plz!
*
* @param bill2
* @param product
* @param disc
* @param count
*/
public BillLine(Bill bill2, Product product, Discount disc, BigDecimal count) {
super();
this.bill = bill2;
......
......@@ -85,7 +85,13 @@
</h:dataTable>
<h:commandButton action="#{foodWaveFoodView.buyFromCounter}" value="#{i18n['foodshop.buyFromCounter']}" />
<h:commandButton action="#{foodWaveFoodView.buyFromCounter}" value="#{i18n['foodshop.buyFromCounter']}" >
</h:commandButton>
<h:commandButton action="#{foodWaveFoodView.buyFromInternet}" value="#{i18n['foodshop.buyFromInternet']}" >
</h:commandButton>
</h:form>
......
......@@ -10,10 +10,12 @@ import javax.inject.Inject;
import javax.inject.Named;
import fi.insomnia.bortal.beans.AccountEventBeanLocal;
import fi.insomnia.bortal.beans.BillBeanLocal;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.FoodWaveBeanLocal;
import fi.insomnia.bortal.beans.ProductBeanLocal;
import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.model.AccountEvent;
import fi.insomnia.bortal.model.Bill;
import fi.insomnia.bortal.model.EventUser;
import fi.insomnia.bortal.model.FoodWave;
import fi.insomnia.bortal.model.Product;
......@@ -34,8 +36,14 @@ public class FoodWaveFoodView extends GenericCDIView {
private FoodWaveBeanLocal foodWaveBean;
@EJB
EventBeanLocal eventBean;
@EJB
private AccountEventBeanLocal accountEventBean;
@EJB
private BillBeanLocal billBean;
private FoodWave foodWave = null;
@EJB
......@@ -45,6 +53,9 @@ public class FoodWaveFoodView extends GenericCDIView {
@SelectedUser
private EventUser user;
@Inject
private BillEditView billEditView;
private Integer foodwaveid = 0;
private ListDataModel<Product> products;
......@@ -94,34 +105,6 @@ public class FoodWaveFoodView extends GenericCDIView {
public void setFoodWave(FoodWave foodWave) {
this.foodWave = foodWave;
}
////////////////////////////////////////////
/*
public void initBillView() {
if (requirePermissions(ShopPermission.LIST_USERPRODUCTS)
&& getShoppingcart() == null) {
setShoppingcart(new ListDataModel<ProductShopItem>(
ProductShopItem.productList(productBean
.listUserShoppableProducts())));
updateCartLimits(null);
logger.debug("Initialized billing shoppingcart to {}", getShoppingcart());
this.beginConversation();
}
}*/
/*
public void initShopView() {
setShoppingcart(new ListDataModel<ProductShopItem>(
ProductShopItem.productGTList( getFoodWave().getTemplate().getProducts() )));
this.beginConversation();
}
*/
public String add(Integer count) {
ProductShopItem item = getShoppingcart().getRowData();
......@@ -140,16 +123,6 @@ public class FoodWaveFoodView extends GenericCDIView {
return add(-1);
}
/*
public BigDecimal getAccountBalance() {
BigDecimal ret = user.getAccountBalance();
ret = ret.add(getCash());
ret = ret.subtract(getTotalPrice());
return ret;
}*/
public BigDecimal getTotalPrice() {
BigDecimal ret = BigDecimal.ZERO;
for (ProductShopItem cart : getShoppingcart()) {
......@@ -158,72 +131,47 @@ public class FoodWaveFoodView extends GenericCDIView {
return ret;
}
/*
public String commitBillCart() {
if (!productsInCart()) {
super.addFaceMessage("productshop.noItemsInCart");
return null;
}
Bill bill = new Bill(eventbean.getCurrentEvent(), user);
bill.setOurReference(eventbean.getCurrentEvent().getName());
for (ProductShopItem shopitem : getShoppingcart()) {
if (shopitem.getCount().compareTo(BigDecimal.ZERO) > 0) {
bill.addProduct(shopitem.getProduct(), shopitem.getCount());
}
}
billbean.createBill(bill);
addFaceMessage("productshop.billCreated");
cash = BigDecimal.ZERO;
setShoppingcart(null);
billEditView.setBill(bill);
return "showCreatedBill";
}*/
/**
* When we buy stuff from counter, we actually just create accountevents with zero price,
* and add them to foodWave.
*
* Just create bills, they are nice
* <insert picture of bill gates here>
* @return
*/
public String buyFromCounter() {
public Bill createBillFromShoppingcart() {
for (ProductShopItem shopitem : getShoppingcart()) {
Bill bill = new Bill(eventBean.getCurrentEvent(), user);
bill.setOurReference(eventBean.getCurrentEvent().getName());
for (ProductShopItem shopitem : shoppingcart) {
if (shopitem.getCount().compareTo(BigDecimal.ZERO) > 0) {
AccountEvent ae = productBean.createAccountEvent(shopitem.getProduct(), shopitem.getCount(), user);
ae.setUnitPrice(new BigDecimal(0));
ae.setFoodWave(foodWave);
accountEventBean.merge(ae);
bill.addProduct(shopitem.getProduct(), shopitem.getCount(), getFoodWave());
}
}
return "/foodWave/ThanksForOrderingFromCounter.";
billBean.createBill(bill);
return bill;
}
public String buyFromCounter() {
createBillFromShoppingcart();
return "/foodwave/ThanksForOrderingFromCounter";
}
public String commitShoppingCart() {
/* EventUser retuser = null;
for (ProductShopItem shopitem : getShoppingcart()) {
if (shopitem.getCount().compareTo(BigDecimal.ZERO) > 0) {
retuser = productBean.createAccountEvent(shopitem.getProduct(), shopitem.getCount(), user).getUser();
}
}
if (cash != null && cash.compareTo(BigDecimal.ZERO) != 0) {
Product credProd = productBean.findCreditProduct();
retuser = productBean.createAccountEvent(credProd, cash, user).getUser();
}
if (user != null) {
user = retuser;
public String buyFromInternet() {
Bill bill = createBillFromShoppingcart();
if(bill != null) {
getBillEditView().setBillid(bill.getId());
return "/bill/showBill?faces-redirect=true&IncludeViewParams=true";
}
setShoppingcart(null);
cash = BigDecimal.ZERO;*/
return null;
}
public void setUser(EventUser user) {
this.user = user;
......@@ -251,38 +199,20 @@ public class FoodWaveFoodView extends GenericCDIView {
return false;
}
/*
public BillListView getBillListView() {
return billListView;
}
public void setBillListView(BillListView billListView) {
this.billListView = billListView;
}
public BigDecimal getCash() {
if (payInstant) {
cash = getTotalPrice();
logger.info("Getting instantcash as {}", cash);
}
if (cash == null) {
cash = BigDecimal.ZERO;
}
return cash;
}
public void setCash(BigDecimal cash) {
this.cash = cash;
public BillEditView getBillEditView() {
return billEditView;
}
public boolean isHasLimits() {
return hasLimits;
}
public void setHasLimits(boolean hasLimits) {
this.hasLimits = hasLimits;
public void setBillEditView(BillEditView billEditView) {
this.billEditView = billEditView;
}
*/
}
......@@ -209,7 +209,7 @@ public class ProductShopView extends GenericCDIView {
Product credProd = productBean.findCreditProduct();
retuser = productBean.createAccountEvent(credProd, cash, user).getUser();
}
if (user != null) {
if (retuser != null) {
user = retuser;
}
shoppingcart = null;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!