Commit 8d71ba5f by Tuukka Kivilahti

Merge branch 'dependant-products' into 'master'

Add product dependecy possibility

This allows products do depend on other products, ie you must buy
computerplace to buy vip lounge entrances

See merge request !364
2 parents b70320be 9c07bb3c
...@@ -93,4 +93,6 @@ public interface ProductBeanLocal { ...@@ -93,4 +93,6 @@ public interface ProductBeanLocal {
void deleteProductOptionGroup(ProductOptionGroup group); void deleteProductOptionGroup(ProductOptionGroup group);
Product reload(Product product); Product reload(Product product);
Product delete(ProductDependency dep);
} }
...@@ -424,20 +424,24 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -424,20 +424,24 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbUpdates.add(new String[] { dbUpdates.add(new String[] {
"ALTER TABLE discounts ADD COLUMN sort INTEGER NOT NULL default 10;" "ALTER TABLE discounts ADD COLUMN sort INTEGER NOT NULL default 10;"
}); });
dbUpdates.add(new String[] { dbUpdates.add(new String[] {
"CREATE TABLE map_queue_rules (id SERIAL NOT NULL, meta json, reserving_size INTEGER, default_timeout_min INTEGER, minium_slots_in_queue INTEGER, map_id INTEGER NOT NULL , PRIMARY KEY (id))", "CREATE TABLE map_queue_rules (id SERIAL NOT NULL, meta json, reserving_size INTEGER, default_timeout_min INTEGER, minium_slots_in_queue INTEGER, map_id INTEGER NOT NULL , PRIMARY KEY (id))",
"ALTER TABLE map_queue_rules ADD CONSTRAINT FK_map_queue_rules_map_id FOREIGN KEY (map_id) REFERENCES maps (id)", "ALTER TABLE map_queue_rules ADD CONSTRAINT FK_map_queue_rules_map_id FOREIGN KEY (map_id) REFERENCES maps (id)",
}); });
dbUpdates.add(new String[] { dbUpdates.add(new String[] {
"ALTER TABLE map_queue_rules ADD COLUMN biggest_first BOOLEAN default false", "ALTER TABLE map_queue_rules ADD COLUMN biggest_first BOOLEAN default false",
}); });
dbUpdates.add(new String[]{
"CREATE TABLE product_dependencies (id SERIAL NOT NULL, dependency_type TEXT NOT NULL, meta json, multiplier DECIMAL(24,6) NOT NULL, priority INTEGER NOT NULL, dependant_id INTEGER NOT NULL, supporter_id INTEGER NOT NULL, PRIMARY KEY (id))",
"ALTER TABLE product_dependencies ADD CONSTRAINT FK_product_dependencies_dependant_id FOREIGN KEY (dependant_id) REFERENCES products (id)",
"ALTER TABLE product_dependencies ADD CONSTRAINT FK_product_dependencies_supporter_id FOREIGN KEY (supporter_id) REFERENCES products (id)",
});
}
}
public BootstrapBean() { public BootstrapBean() {
} }
......
...@@ -660,5 +660,12 @@ public class ProductBean implements ProductBeanLocal { ...@@ -660,5 +660,12 @@ public class ProductBean implements ProductBeanLocal {
return productFacade.reload(product); return productFacade.reload(product);
} }
@Override
public Product delete(ProductDependency dep) {
Product prod = productFacade.reload(dep.getDependant());
prod.getProductDependencies().remove(dep);
return prod;
}
} }
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
package fi.codecrew.moya.model; package fi.codecrew.moya.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -48,7 +49,7 @@ import javax.persistence.UniqueConstraint; ...@@ -48,7 +49,7 @@ import javax.persistence.UniqueConstraint;
import org.eclipse.persistence.annotations.PrivateOwned; import org.eclipse.persistence.annotations.PrivateOwned;
/** /**
* *
*/ */
@Entity @Entity
@Table(name = "products") @Table(name = "products")
...@@ -151,6 +152,10 @@ public class Product extends GenericEntity { ...@@ -151,6 +152,10 @@ public class Product extends GenericEntity {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "product") @OneToMany(cascade = CascadeType.ALL, mappedBy = "product")
private List<ProductOptionGroup> productOptionGroups; private List<ProductOptionGroup> productOptionGroups;
@OneToMany(cascade = CascadeType.ALL, mappedBy ="dependant")
@PrivateOwned
@OrderBy("priority")
private List<ProductDependency> productDependencies = new ArrayList<>();
public Product() { public Product() {
super(); super();
...@@ -237,7 +242,7 @@ public class Product extends GenericEntity { ...@@ -237,7 +242,7 @@ public class Product extends GenericEntity {
/** /**
* Get product price, includes vat * Get product price, includes vat
* *
* @return * @return
*/ */
public BigDecimal getPrice() { public BigDecimal getPrice() {
...@@ -246,7 +251,7 @@ public class Product extends GenericEntity { ...@@ -246,7 +251,7 @@ public class Product extends GenericEntity {
/** /**
* Set price, including vat * Set price, including vat
* *
* @param price * @param price
*/ */
public void setPrice(BigDecimal price) { public void setPrice(BigDecimal price) {
...@@ -303,7 +308,7 @@ public class Product extends GenericEntity { ...@@ -303,7 +308,7 @@ public class Product extends GenericEntity {
/** /**
* Set product vat-%, value between 0 and 1 * Set product vat-%, value between 0 and 1
* *
* @param vat * @param vat
*/ */
public void setVat(BigDecimal vat) { public void setVat(BigDecimal vat) {
...@@ -312,7 +317,7 @@ public class Product extends GenericEntity { ...@@ -312,7 +317,7 @@ public class Product extends GenericEntity {
/** /**
* Get product vat-%, value between 0 and 1 * Get product vat-%, value between 0 and 1
* *
* @return * @return
*/ */
public BigDecimal getVat() { public BigDecimal getVat() {
...@@ -436,4 +441,12 @@ public class Product extends GenericEntity { ...@@ -436,4 +441,12 @@ public class Product extends GenericEntity {
public void setMinBuyCount(int minBuyCount) { public void setMinBuyCount(int minBuyCount) {
this.minBuyCount = minBuyCount; this.minBuyCount = minBuyCount;
} }
public List<ProductDependency> getProductDependencies() {
return productDependencies;
}
public void setProductDependencies(List<ProductDependency> productDependencies) {
this.productDependencies = productDependencies;
}
} }
package fi.codecrew.moya.model;
import javax.persistence.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
@Entity
@Table(name = "product_dependencies")
public class ProductDependency extends GenericEntity {
public static final String DEPENDANT_COLUMN = "dependant_id" ;
private static final BigDecimal SCALE6_ONE = BigDecimal.ONE.setScale(6, RoundingMode.HALF_UP);
public static enum DependencyType {
// Dependant product can be bought maximum of supported product number of times
MAX_SUPPORTED_COUNT,
;
public String getI18nKey() {
return "product.dependency." + name();
}
}
@Enumerated(EnumType.STRING)
@Column(nullable = false, name="dependency_type")
private DependencyType dependencyType;
// Order, in which dependencies will be parsed
@Column(nullable = false, name="priority")
private int priority = 1000;
@Column(name = "multiplier", nullable = false, precision = 24, scale = 6)
private BigDecimal multiplier = SCALE6_ONE;
@ManyToOne
@JoinColumn(nullable = false, name=DEPENDANT_COLUMN)
private Product dependant;
// product which is required when purhchasing the dependant product
@ManyToOne
@JoinColumn(nullable = false, name="supporter_id")
private Product supporter;
public DependencyType getDependencyType() {
return dependencyType;
}
public void setDependencyType(DependencyType dependencyType) {
this.dependencyType = dependencyType;
}
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
public Product getDependant() {
return dependant;
}
public void setDependant(Product dependant) {
this.dependant = dependant;
}
public Product getSupporter() {
return supporter;
}
public void setSupporter(Product supporter) {
this.supporter = supporter;
}
public BigDecimal getMultiplier() {
return multiplier;
}
public void setMultiplier(BigDecimal multiplier) {
this.multiplier = multiplier;
}
}
<!DOCTYPE html <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:products="http://java.sun.com/jsf/composite/cditools/products" xmlns:p="http://primefaces.org/ui"> xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:products="http://java.sun.com/jsf/composite/cditools/products"
xmlns:p="http://primefaces.org/ui">
<h:head> <h:head>
<title></title> <title></title>
...@@ -13,114 +15,170 @@ ...@@ -13,114 +15,170 @@
<f:viewParam name="productid" value="#{productView.productId}" /> <f:viewParam name="productid" value="#{productView.productId}" />
<f:event type="preRenderView" listener="#{productView.initEditView}" /> <f:event type="preRenderView" listener="#{productView.initEditView}" />
</f:metadata> </f:metadata>
<ui:param name="thispage" value="page.product.edit" />
<ui:define name="content"> <ui:define name="content">
<products:edit commitaction="#{productView.saveProduct()}" commitvalue="#{i18n['products.save']}" /> <products:edit commitaction="#{productView.saveProduct()}" commitvalue="#{i18n['products.save']}" />
<hr/>
<hr />
<button onclick="$(this).hide(); $('#newProductDeps').show()">#{i18n['product.dependency.add']}</button>
<h:form id="discounts"> <div id="newProductDeps" style="display: none">
<h:commandButton rendered="#{!empty productView.product.id}" action="#{productView.initCreateDiscount()}" value="#{i18n['product.createDiscount']}"> <h:form id="newdep">
</h:commandButton> <h:selectOneMenu id="supporter" layout="pageDirection" value="#{productView.dependency.supporter}" converter="#{productConverter}">
<h:dataTable border="1" id="discount" value="#{productView.productDiscounts}" var="discount" rendered="#{!empty productView.product.id and !empty productView.product.discounts}"> <f:selectItem itemLabel="---"/>
<h:column> <f:selectItems var="prod" itemLabel="#{prod.name}" value="#{productView.products}"/>
<f:facet name="header"> </h:selectOneMenu>
<h:outputText value="${i18n['discount.percentage']}" /> <h:selectOneMenu id="type" layout="pageDirection" value="#{productView.dependency.dependencyType}">
</f:facet> <f:selectItems var="type" itemLabel="#{i18n[type.i18nKey]}" value="#{productView.dependencyTypes}"/>
<h:outputText value="#{discount.percentage}" /> </h:selectOneMenu>
</h:column>
<h:column> <p:commandButton action="#{productView.createProductDependency()}" value="#{i18n['product.dependency.create']}" update=":dependencies"/>
<f:facet name="header"> </h:form>
<h:outputText value="${i18n['discount.code']}" /> </div>
</f:facet>
<h:outputText value="#{discount.code}" /> <h:form id="dependencies">
</h:column> <h:dataTable border="1" var="dependency" value="#{productView.productDependencies}" rendered="#{!empty productView.product.productDependencies}">
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="${i18n['discount.details']}" /> <h:outputText value="#{i18n['product.dependency.supporter']}"/>
</f:facet> </f:facet>
<h:outputText value="#{discount.details}" /> <h:outputText value="#{dependency.supporter.name}"/>
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="${i18n['discount.shortdesc']}" /> <h:outputText value="#{i18n['product.dependency.type']}"/>
</f:facet> </f:facet>
<h:outputText value="#{discount.shortdesc}" /> <h:outputText value="#{i18n[dependency.dependencyType.i18nKey]}"/>
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="${i18n['discount.amountMin']}" /> <h:outputText value="#{i18n['product.dependency.priority']}"/>
</f:facet> </f:facet>
<h:outputText value="#{discount.amountMin}" /> <h:outputText value="#{dependency.priority}"/>
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <p:commandButton action="#{productView.deleteProductDependency}" value="#{i18n['productDependency.delete']}" update=":dependencies"/>
<h:outputText value="${i18n['discount.amountMax']}" />
</f:facet> </h:column>
<h:outputText value="#{discount.amountMax}" /> <!-- Not yet in use.
</h:column> <h:column>
<h:column> <f:facet name="header">
<f:facet name="header"> <h:outputText value="#{i18n['product.dependency.multiplier']}"/>
<h:outputText value="${i18n['discount.maxNum']}" /> </f:facet>
</f:facet> <h:outputText value="#{dependency.multiplier}"/>
<h:outputText value="#{discount.maxNum}" /> </h:column>
</h:column> -->
<h:column> </h:dataTable>
<f:facet name="header"> </h:form>
<h:outputText value="${i18n['discount.perUser']}" /> <hr/>
</f:facet>
<h:outputText value="#{discount.perUser}" /> <h:form id="discounts">
</h:column> <p:commandButton rendered="#{!empty productView.product.id}" action="#{productView.initCreateDiscount()}" value="#{i18n['product.createDiscount']}">
<h:column> </p:commandButton>
<h:commandButton action="#{productView.editDiscount()}" value="#{i18n['discount.edit']}" /> <h:dataTable border="1" id="discount" value="#{productView.productDiscounts}" var="discount" rendered="#{!empty productView.product.id and !empty productView.product.discounts}">
</h:column> <h:column>
<f:facet name="header">
</h:dataTable> <h:outputText value="${i18n['discount.percentage']}"/>
</h:form> </f:facet>
<hr /> <h:outputText value="#{discount.percentage}"/>
<h:form id="limits"> </h:column>
<h:commandButton rendered="#{!empty productView.product.id}" action="#{productView.initCreateLimit()}" value="#{i18n['product.createLimit']}"> <h:column>
</h:commandButton> <f:facet name="header">
<p:dataTable border="1" id="limit" value="#{productView.productLimits}" var="limit" rendered="#{!empty productView.product.id and !empty productView.product.productLimits}"> <h:outputText value="${i18n['discount.code']}"/>
<p:column rowHeader="#{i18n['productLimit.name']}"> </f:facet>
<h:outputText value="#{limit.name}" /> <h:outputText value="#{discount.code}"/>
</p:column> </h:column>
<p:column rowHeader="#{i18n['productLimit.type']}"> <h:column>
<h:outputText value="#{limit.type}" /> <f:facet name="header">
</p:column> <h:outputText value="${i18n['discount.details']}"/>
<p:column rowHeader="#{i18n['productLimit.upperLimit']}"> </f:facet>
<h:outputText value="#{limit.lowerLimit}" /> <h:outputText value="#{discount.details}"/>
</p:column> </h:column>
<p:column> <h:column>
<p:commandButton ajax="false" action="#{productView.editLimit()}" value="#{i18n['productLimit.edit']}" /> <f:facet name="header">
</p:column> <h:outputText value="${i18n['discount.shortdesc']}"/>
</p:dataTable> </f:facet>
<h:outputText value="#{discount.shortdesc}"/>
</h:form> </h:column>
<hr /> <h:column>
<f:facet name="header">
<h:form id="options"> <h:outputText value="${i18n['discount.amountMin']}"/>
<h:commandButton rendered="#{!empty productView.product.id}" action="#{productView.initCreateProductOptionGroup()}" value="#{i18n['product.createProductOptionGroup']}"><br /><br /> </f:facet>
</h:commandButton> <h:outputText value="#{discount.amountMin}"/>
</h:column>
<p:dataTable border="1" id="optiongroups" value="#{productView.productOptionGroups}" var="group" rendered="#{!empty productView.product.id and !empty productView.product.productOptionGroups}"> <h:column>
<p:column rowHeader="#{i18n['name']}"> <f:facet name="header">
<h:outputText value="#{group.name}" /> <h:outputText value="${i18n['discount.amountMax']}"/>
</p:column> </f:facet>
<p:column> <h:outputText value="#{discount.amountMax}"/>
<p:commandButton ajax="false" action="#{productView.editProductOptionGroup}" value="#{i18n['edit']}" /> </h:column>
</p:column> <h:column>
<p:column> <f:facet name="header">
<p:commandButton ajax="false" action="#{productView.deleteProductOptionGroup}" value="#{i18n['delete']}" /> <h:outputText value="${i18n['discount.maxNum']}"/>
</p:column> </f:facet>
</p:dataTable> <h:outputText value="#{discount.maxNum}"/>
</h:column>
</h:form> <h:column>
<f:facet name="header">
</ui:define> <h:outputText value="${i18n['discount.perUser']}"/>
</ui:composition> </f:facet>
<h:outputText value="#{discount.perUser}"/>
</h:column>
<h:column>
<h:commandButton action="#{productView.editDiscount()}" value="#{i18n['discount.edit']}"/>
</h:column>
</h:dataTable>
</h:form>
<hr/>
<h:form id="limits">
<p:commandButton rendered="#{!empty productView.product.id}" action="#{productView.initCreateLimit()}" value="#{i18n['product.createLimit']}">
</p:commandButton>
<p:dataTable border="1" id="limit" value="#{productView.productLimits}" var="limit" rendered="#{!empty productView.product.id and !empty productView.product.productLimits}">
<p:column rowHeader="#{i18n['productLimit.name']}">
<h:outputText value="#{limit.name}"/>
</p:column>
<p:column rowHeader="#{i18n['productLimit.type']}">
<h:outputText value="#{limit.type}"/>
</p:column>
<p:column rowHeader="#{i18n['productLimit.upperLimit']}">
<h:outputText value="#{limit.lowerLimit}"/>
</p:column>
<p:column>
<p:commandButton ajax="false" action="#{productView.editLimit()}" value="#{i18n['productLimit.edit']}"/>
</p:column>
</p:dataTable>
</h:form>
<hr/>
<h:form id="options">
<p:commandButton rendered="#{!empty productView.product.id}"
action="#{productView.initCreateProductOptionGroup()}"
value="#{i18n['product.createProductOptionGroup']}"><br/><br/>
</p:commandButton>
<p:dataTable border="1" id="optiongroups" value="#{productView.productOptionGroups}"
var="group"
rendered="#{!empty productView.product.id and !empty productView.product.productOptionGroups}">
<p:column rowHeader="#{i18n['name']}">
<h:outputText value="#{group.name}"/>
</p:column>
<p:column>
<p:commandButton ajax="false" action="#{productView.editProductOptionGroup}"
value="#{i18n['edit']}"/>
</p:column>
<p:column>
<p:commandButton ajax="false" action="#{productView.deleteProductOptionGroup}"
value="#{i18n['delete']}"/>
</p:column>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body> </h:body>
</html> </html>
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<!-- <h:outputScript target="head" library="script" name="shopscript.js" /> --> <!-- <h:outputScript target="head" library="script" name="shopscript.js" /> -->
<h:outputScript library="primefaces" name="jquery/jquery.js" /> <h:outputScript library="primefaces" name="jquery/jquery.js" />
<p:dataTable columnClasses="nowrap,numalign,numalign,numalign,nowrap" id="billcart" value="#{cc.attrs.items}" var="cart" expandedRow="true"> <p:dataTable columnClasses="nowrap,numalign,numalign,numalign,nowrap" id="billcart" value="#{cc.attrs.items}" var="cart" expandedRow="#{cart.count > 0}">
<p:column style="width:16px"> <p:column style="width:16px">
<p:rowToggler rendered="#{cart.product.containsProductOptionGroups}" /> <p:rowToggler rendered="#{cart.product.containsProductOptionGroups}" />
</p:column> </p:column>
......
...@@ -274,6 +274,7 @@ public class ProductShopView extends GenericCDIView { ...@@ -274,6 +274,7 @@ public class ProductShopView extends GenericCDIView {
} }
} }
// Update all other items
for (ProductShopItem n : shoppingcart) { for (ProductShopItem n : shoppingcart) {
BigDecimal l = limits.get(n.getProduct().getId()); BigDecimal l = limits.get(n.getProduct().getId());
if (l != null) { if (l != null) {
...@@ -283,6 +284,11 @@ public class ProductShopView extends GenericCDIView { ...@@ -283,6 +284,11 @@ public class ProductShopView extends GenericCDIView {
psiHelper.updateProductShopItemLimit(n, l); psiHelper.updateProductShopItemLimit(n, l);
} }
//Update product dependencies last...
for (ProductShopItem n : shoppingcart) {
n.updateProductDependencies(shoppingcart);
}
} }
public String removeBought() { public String removeBought() {
......
...@@ -61,9 +61,11 @@ public class ProductView extends GenericCDIView { ...@@ -61,9 +61,11 @@ public class ProductView extends GenericCDIView {
private ListDataModel<ProductLimitation> productLimits; private ListDataModel<ProductLimitation> productLimits;
private ListDataModel<ProductOptionGroup> productOptionGroups; private ListDataModel<ProductOptionGroup> productOptionGroups;
private ListDataModel<ProductDependency> productDependencies;
private ProductOption productOption = null; private ProductOption productOption = null;
private ProductDependency dependency = new ProductDependency();
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(ProductView.class); private static final Logger logger = LoggerFactory.getLogger(ProductView.class);
...@@ -76,6 +78,29 @@ public class ProductView extends GenericCDIView { ...@@ -76,6 +78,29 @@ public class ProductView extends GenericCDIView {
} }
} }
public List<Product> getProducts(){
return prodbean.getProducts();
}
public void createProductDependency(){
product.getProductDependencies().add(dependency);
dependency.setDependant(product);
dependency = new ProductDependency();
product = prodbean.mergeChanges(product);
productDependencies = null;
}
public void deleteProductDependency(){
ProductDependency dep = getProductDependencies().getRowData();
product = prodbean.delete(dep);
productDependencies = null;
}
public ProductDependency.DependencyType[] getDependencyTypes(){
return ProductDependency.DependencyType.values();
}
public void initCreateView() { public void initCreateView() {
if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS)) { if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS)) {
setProduct(new Product(eventbean.getCurrentEvent())); setProduct(new Product(eventbean.getCurrentEvent()));
...@@ -270,4 +295,19 @@ public class ProductView extends GenericCDIView { ...@@ -270,4 +295,19 @@ public class ProductView extends GenericCDIView {
if(option != null) if(option != null)
productOptionGroup.setDefaultOption(option); productOptionGroup.setDefaultOption(option);
} }
public ProductDependency getDependency() {
return dependency;
}
public void setDependency(ProductDependency dependency) {
this.dependency = dependency;
}
public ListDataModel<ProductDependency> getProductDependencies(){
if(productDependencies == null && product != null){
productDependencies = new ListDataModel<>(product.getProductDependencies());
}
return productDependencies;
}
} }
...@@ -125,13 +125,13 @@ public class ProductShopItem { ...@@ -125,13 +125,13 @@ public class ProductShopItem {
/** /**
* DO NOT USE THIS. * DO NOT USE THIS.
* *
* Use ProductShopIteHelper.setProductShopItemCount instead. * Use ProductShopIteHelper.setProductShopItemCount instead.
* *
* p.s. This still needs to exist because we want to set count from jsf, but * p.s. This still needs to exist because we want to set count from jsf, but
* this value needs to be updated with * this value needs to be updated with
* ProductShopIteHelper.updateProductShopItemCount * ProductShopIteHelper.updateProductShopItemCount
* *
* @param count * @param count
*/ */
public void setCount(BigDecimal count) { public void setCount(BigDecimal count) {
...@@ -315,4 +315,23 @@ public class ProductShopItem { ...@@ -315,4 +315,23 @@ public class ProductShopItem {
} }
public void updateProductDependencies(ListDataModel<ProductShopItem> shoppingcart) {
if (product.getProductDependencies() == null || product.getProductDependencies().isEmpty()) {
return;
}
BigDecimal limitCnt = BigDecimal.ZERO;
for (ProductDependency dep : product.getProductDependencies()) {
for (ProductShopItem item : shoppingcart) {
if (dep.getSupporter().equals(item.getProduct())) {
limitCnt = limitCnt.add(item.getCount());
break;
}
}
}
if (limitCnt.compareTo(count) < 0) {
this.count = limitCnt;
}
setLimit(limitCnt);
}
} }
...@@ -1589,3 +1589,11 @@ reservequeue.reservingTimeIsUpAlert=Timeslot for your place reservation has time ...@@ -1589,3 +1589,11 @@ reservequeue.reservingTimeIsUpAlert=Timeslot for your place reservation has time
mapView.reserveTimeLeft=Time to reserve places mapView.reserveTimeLeft=Time to reserve places
queuemgmt.queueEnabled=Queue is ENABLED queuemgmt.queueEnabled=Queue is ENABLED
queuemgmt.queueDisabled=Queue is DISABLED (enable from Edit event -page) queuemgmt.queueDisabled=Queue is DISABLED (enable from Edit event -page)
product.dependency.add=Add product dependency
product.dependency.create=Create
product.dependency.supporter=Depended product
product.dependency.type=Dependency type
product.dependency.priority=Priority
productDependency.delete=Delete
product.dependency.multiplier=Multiplier
product.dependency.MAX_SUPPORTED_COUNT=Only up to same number of products can be bought
...@@ -1867,3 +1867,11 @@ reservequeue.reservingTimeIsUpAlert=Timeslot for your place reservation has time ...@@ -1867,3 +1867,11 @@ reservequeue.reservingTimeIsUpAlert=Timeslot for your place reservation has time
mapView.reserveTimeLeft=Time to reserve places mapView.reserveTimeLeft=Time to reserve places
queuemgmt.queueEnabled=Queue is ENABLED queuemgmt.queueEnabled=Queue is ENABLED
queuemgmt.queueDisabled=Queue is DISABLED (enable from Edit event -page) queuemgmt.queueDisabled=Queue is DISABLED (enable from Edit event -page)
product.dependency.add=Add product dependency
product.dependency.create=Create
product.dependency.supporter=Depended product
product.dependency.type=Dependency type
product.dependency.priority=Priority
productDependency.delete=Delete
product.dependency.multiplier=Multiplier
product.dependency.MAX_SUPPORTED_COUNT=Only up to same number of products can be bought
...@@ -1854,3 +1854,11 @@ reservequeue.reservingTimeIsUpAlert=Sinulle varattu varausauka on kulunut loppuu ...@@ -1854,3 +1854,11 @@ reservequeue.reservingTimeIsUpAlert=Sinulle varattu varausauka on kulunut loppuu
mapView.reserveTimeLeft=Aikaa varata paikkasi mapView.reserveTimeLeft=Aikaa varata paikkasi
queuemgmt.queueEnabled=Varausjono ON k\u00E4yt\u00F6ss\u00E4 queuemgmt.queueEnabled=Varausjono ON k\u00E4yt\u00F6ss\u00E4
queuemgmt.queueDisabled=K\u00E4ytt\u00E4j\u00E4jono EI OLE k\u00E4yt\u00F6ss\u00E4 (ota k\u00E4yttoon tapahtuman tiedot -sivulta) queuemgmt.queueDisabled=K\u00E4ytt\u00E4j\u00E4jono EI OLE k\u00E4yt\u00F6ss\u00E4 (ota k\u00E4yttoon tapahtuman tiedot -sivulta)
product.dependency.add=Lis\u00E4\u00E4 tuoteriippuvuus
product.dependency.create=Luo uusi
product.dependency.supporter=Tuote josta on riippuvuus
product.dependency.type=Riippuvuuden tyyppi
product.dependency.priority=Prioriteetti
productDependency.delete=Poista
product.dependency.multiplier=Kerroin
product.dependency.MAX_SUPPORTED_COUNT=Tuotteita voi ostaa enint\u00E4\u00E4n saman m\u00E4\u00E4r\u00E4n
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!