Attached Files | RDSProdCharPosterminalProposed.diff [^] (12,746 bytes) 2014-08-27 10:59 [Show Content] [Hide Content]diff --git a/src/org/openbravo/retail/posterminal/ApplicationCacheComponent.java b/src/org/openbravo/retail/posterminal/ApplicationCacheComponent.java
--- a/src/org/openbravo/retail/posterminal/ApplicationCacheComponent.java
+++ b/src/org/openbravo/retail/posterminal/ApplicationCacheComponent.java
@@ -77,6 +77,10 @@
.add("../../org.openbravo.client.kernel/OBMOBC_Main/ClientModel?entity=PricingAdjustmentProduct&modelName=DiscountFilterProduct&source=org.openbravo.retail.posterminal.master.DiscountFilterProduct");
resources
.add("../../org.openbravo.client.kernel/OBMOBC_Main/ClientModel?entity=PricingAdjustmentProductCategory&modelName=DiscountFilterProductCategory&source=org.openbravo.retail.posterminal.master.DiscountFilterProductCategory");
+ resources
+ .add("../../org.openbravo.client.kernel/OBMOBC_Main/ClientModel?entity=PricingAdjustmentCharacteristic&modelName=DiscountFilterCharacteristic&source=org.openbravo.retail.posterminal.master.DiscountFilterCharacteristic");
+ resources
+ .add("../../org.openbravo.client.kernel/OBMOBC_Main/ClientModel?entity=ProductCharacteristicValue&modelName=ProductCharacteristicValue&source=org.openbravo.retail.posterminal.master.ProductProductChValue");
// default print templates
resources.add("../../web/org.openbravo.retail.posterminal/res/printcashup.xml");
diff --git a/src/org/openbravo/retail/posterminal/master/DiscountFilterCharacteristic.java b/src/org/openbravo/retail/posterminal/master/DiscountFilterCharacteristic.java
new file mode 100644
--- /dev/null
+++ b/src/org/openbravo/retail/posterminal/master/DiscountFilterCharacteristic.java
@@ -0,0 +1,25 @@
+package org.openbravo.retail.posterminal.master;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+
+public class DiscountFilterCharacteristic extends Discount {
+
+ @Override
+ protected List<String> prepareQuery(JSONObject jsonsent) throws JSONException {
+ String hql = "select c.id || cvl.characteristicValue.id as id, c.active, c.creationDate, c.createdBy, ";
+ hql += " c.updated, c.updatedBy, c.client.id as client, c.organization.id as organization, c.characteristic.id as characteristic, cvl.characteristicValue.id as chValue, c.offer.id as offer ";
+
+ hql += " from PricingAdjustmentCharacteristic c ";
+ hql += " left join c.characteristic.productCharacteristicValueList cvl ";
+ hql += " where c.active = true ";
+ hql += " and m_isparent_ch_value(cvl.characteristicValue.id, c.chValue.id, c.characteristic.id) != -1 ";
+ hql += " and exists (select 1 " + getPromotionsHQL(jsonsent);
+ hql += " and c.offer = p)";
+
+ return Arrays.asList(new String[] { hql });
+ }
+}
diff --git a/src/org/openbravo/retail/posterminal/master/ProductChValue.java b/src/org/openbravo/retail/posterminal/master/ProductChValue.java
--- a/src/org/openbravo/retail/posterminal/master/ProductChValue.java
+++ b/src/org/openbravo/retail/posterminal/master/ProductChValue.java
@@ -26,6 +26,9 @@
import org.openbravo.retail.posterminal.POSUtils;
import org.openbravo.retail.posterminal.ProcessHQLQuery;
+/*
+ * This class fills the m_ch_value table in WebSQL even if it is called productChValue.
+ */
public class ProductChValue extends ProcessHQLQuery {
public static final String productChValuePropertyExtension = "OBPOS_ProductChValueExtension";
diff --git a/src/org/openbravo/retail/posterminal/master/ProductProductChValue.java b/src/org/openbravo/retail/posterminal/master/ProductProductChValue.java
new file mode 100644
--- /dev/null
+++ b/src/org/openbravo/retail/posterminal/master/ProductProductChValue.java
@@ -0,0 +1,61 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2014 Openbravo S.L.U.
+ * Licensed under the Openbravo Commercial License version 1.0
+ * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
+ * or in the legal folder of this module distribution.
+ ************************************************************************************
+ */
+package org.openbravo.retail.posterminal.master;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.client.kernel.ComponentProvider.Qualifier;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.mobile.core.model.HQLPropertyList;
+import org.openbravo.mobile.core.model.ModelExtension;
+import org.openbravo.mobile.core.model.ModelExtensionUtils;
+import org.openbravo.retail.config.OBRETCOProductList;
+import org.openbravo.retail.posterminal.POSUtils;
+import org.openbravo.retail.posterminal.ProcessHQLQuery;
+
+/*
+ * This class fills the m_product_ch_value table in WebSQL it is called productProductChValue because the one that
+ * fills m_ch_cvalue is called ProductChValue.
+ */
+public class ProductProductChValue extends ProcessHQLQuery {
+ public static final String productChValuePropertyExtension = "OBPOS_ProductCharacteristicValueExtension";
+
+ @Inject
+ @Any
+ @Qualifier(productChValuePropertyExtension)
+ private Instance<ModelExtension> extensions;
+
+ @Override
+ protected List<String> getQuery(JSONObject jsonsent) throws JSONException {
+ String orgId = OBContext.getOBContext().getCurrentOrganization().getId();
+ final OBRETCOProductList productList = POSUtils.getProductListByOrgId(orgId);
+ List<String> hqlQueries = new ArrayList<String>();
+
+ HQLPropertyList regularProductsCharacteristicHQLProperties = ModelExtensionUtils
+ .getPropertyExtensions(extensions);
+
+ hqlQueries
+ .add("select "
+ + regularProductsCharacteristicHQLProperties.getHqlSelect()
+ + "from ProductCharacteristicValue pcv "
+ + "where pcv.product.id in (select product.id from OBRETCO_Prol_Product assort where obretcoProductlist.id= '"
+ + productList.getId()
+ + "') "
+ + "and $naturalOrgCriteria and $readableClientCriteria and ($incrementalUpdateCriteria)");
+
+ return hqlQueries;
+ }
+}
\ No newline at end of file
diff --git a/src/org/openbravo/retail/posterminal/master/ProductProductChValueProperties.java b/src/org/openbravo/retail/posterminal/master/ProductProductChValueProperties.java
new file mode 100644
--- /dev/null
+++ b/src/org/openbravo/retail/posterminal/master/ProductProductChValueProperties.java
@@ -0,0 +1,35 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2014 Openbravo S.L.U.
+ * Licensed under the Openbravo Commercial License version 1.0
+ * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
+ * or in the legal folder of this module distribution.
+ ************************************************************************************
+ */
+package org.openbravo.retail.posterminal.master;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.openbravo.client.kernel.ComponentProvider.Qualifier;
+import org.openbravo.mobile.core.model.HQLProperty;
+import org.openbravo.mobile.core.model.ModelExtension;
+
+@Qualifier(ProductProductChValue.productChValuePropertyExtension)
+public class ProductProductChValueProperties extends ModelExtension {
+
+ @Override
+ public List<HQLProperty> getHQLProperties(Object params) {
+ ArrayList<HQLProperty> list = new ArrayList<HQLProperty>() {
+ private static final long serialVersionUID = 1L;
+ {
+ add(new HQLProperty("pcv.id", "id"));
+ add(new HQLProperty("pcv.product.id", "product"));
+ add(new HQLProperty("pcv.characteristic.id", "characteristic"));
+ add(new HQLProperty("pcv.characteristicValue.id", "characteristicValue"));
+ add(new HQLProperty("pcv.characteristic.name", "_identifier"));
+ }
+ };
+ return list;
+ }
+}
diff --git a/web/org.openbravo.retail.posterminal/js/model/discounts.js b/web/org.openbravo.retail.posterminal/js/model/discounts.js
--- a/web/org.openbravo.retail.posterminal/js/model/discounts.js
+++ b/web/org.openbravo.retail.posterminal/js/model/discounts.js
@@ -296,6 +296,23 @@
+ " AND P.M_PRODUCT_ID = ?" //
+ " AND OP.M_PRODUCT_CATEGORY_ID = P.M_PRODUCT_CATEGORY_ID" //
+ " ))) " //
+ + " AND ((CHARACTERISTICS_SELECTION = 'Y'"
+ + " AND NOT EXISTS"
+ + " (SELECT 1"
+ + " FROM M_OFFER_CHARACTERISTIC C, M_PRODUCT_CH_VALUE V"
+ + " WHERE C.M_OFFER_ID = M_OFFER.M_OFFER_ID"
+ + " AND V.M_PRODUCT_ID = ?"
+ + " AND V.M_CH_VALUE_ID = C.M_CH_VALUE_ID"
+ + " ))"
+ + " OR(CHARACTERISTICS_SELECTION = 'N'"
+ + " AND EXISTS"
+ + " (SELECT 1"
+ + " FROM M_OFFER_CHARACTERISTIC C, M_PRODUCT_CH_VALUE V"
+ + " WHERE C.M_OFFER_ID = M_OFFER.M_OFFER_ID"
+ + " AND V.M_PRODUCT_ID = ?"
+ + " AND V.M_CH_VALUE_ID = C.M_CH_VALUE_ID"
+ + " ))"
+ + " )"
};
// Price Adjustment
diff --git a/web/org.openbravo.retail.posterminal/js/model/executor.js b/web/org.openbravo.retail.posterminal/js/model/executor.js
--- a/web/org.openbravo.retail.posterminal/js/model/executor.js
+++ b/web/org.openbravo.retail.posterminal/js/model/executor.js
@@ -136,7 +136,7 @@
OB.Model.DiscountsExecutor = OB.Model.Executor.extend({
// parameters that will be used in the SQL to get promotions, in case this SQL is extended,
// these parameters might be required to be extended too
- criteriaParams: ['bpId', 'bpId', 'bpId', 'bpId', 'productId', 'productId', 'productId', 'productId'],
+ criteriaParams: ['bpId', 'bpId', 'bpId', 'bpId', 'productId', 'productId', 'productId', 'productId', 'productId', 'productId'],
// defines the property each of the parameters in criteriaParams is translated to, in case of
// different parameters than standard ones this should be extended
diff --git a/web/org.openbravo.retail.posterminal/js/model/promotions.js b/web/org.openbravo.retail.posterminal/js/model/promotions.js
--- a/web/org.openbravo.retail.posterminal/js/model/promotions.js
+++ b/web/org.openbravo.retail.posterminal/js/model/promotions.js
@@ -1,6 +1,6 @@
/*
************************************************************************************
- * Copyright (C) 2013 Openbravo S.L.U.
+ * Copyright (C) 2013 - 2014 Openbravo S.L.U.
* Licensed under the Openbravo Commercial License version 1.0
* You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
* or in the legal folder of this module distribution.
@@ -52,10 +52,26 @@
source: 'org.openbravo.retail.posterminal.master.DiscountFilterRole'
});
+ var promotionsCharacteristics = Backbone.Model.extend({
+ modelName: 'DiscountFilterCharacteristic',
+ generatedStructure: true,
+ entityName: 'PricingAdjustmentCharacteristic',
+ source: 'org.openbravo.retail.posterminal.master.DiscountFilterCharacteristic'
+ });
+
+ var promotionsCharacteristicValue = Backbone.Model.extend({
+ modelName: 'ProductCharacteristicValue',
+ generatedStructure: true,
+ entityName: 'ProductCharacteristicValue',
+ source: 'org.openbravo.retail.posterminal.master.ProductProductChValue'
+ });
+
OB.Data.Registry.registerModel(promotions);
OB.Data.Registry.registerModel(promotionsBP);
OB.Data.Registry.registerModel(promotionsBPCategory);
OB.Data.Registry.registerModel(promotionsProduct);
OB.Data.Registry.registerModel(promotionsProductCategory);
OB.Data.Registry.registerModel(promotionsRole);
+ OB.Data.Registry.registerModel(promotionsCharacteristics);
+ OB.Data.Registry.registerModel(promotionsCharacteristicValue);
}());
\ No newline at end of file
diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js b/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
@@ -41,6 +41,12 @@
}, {
generatedModel: true,
modelName: 'DiscountFilterRole'
+ }, {
+ generatedModel: true,
+ modelName: 'DiscountFilterCharacteristic'
+ }, {
+ generatedModel: true,
+ modelName: 'ProductCharacteristicValue'
},
OB.Model.CurrencyPanel, OB.Model.SalesRepresentative, OB.Model.ProductCharacteristic, OB.Model.Brand, OB.Model.ProductChValue, OB.Model.ReturnReason, OB.Model.CashUp, OB.Model.OfflinePrinter, OB.Model.PaymentMethodCashUp, OB.Model.TaxCashUp],
|