
# HG changeset patch
# User Adrián Romero <adrianromero@openbravo.com>
# Date 1494414372 -7200
# Node ID 56a44c6486975d33eaa528ec87236e900b9ab4e5
# Parent  f7a5f1337e05e6b37e28be02e4f4fcec1fc88b95
[Cancel and New] Addind field standard price to LoadedProduct queries needed for non assortment products

diff -r f7a5f1337e05 -r 56a44c648697 src/org/openbravo/retail/posterminal/master/LoadedProduct.java
--- a/src/org/openbravo/retail/posterminal/master/LoadedProduct.java	Wed May 03 07:49:25 2017 -0600
+++ b/src/org/openbravo/retail/posterminal/master/LoadedProduct.java	Wed May 10 13:06:12 2017 +0200
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2015 Openbravo S.L.U.
+ * Copyright (C) 2015-2017 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.
@@ -10,6 +10,7 @@
 package org.openbravo.retail.posterminal.master;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -22,9 +23,12 @@
 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.model.pricing.pricelist.PriceListVersion;
+import org.openbravo.retail.posterminal.POSUtils;
 import org.openbravo.retail.posterminal.ProcessHQLQuery;
 
 public class LoadedProduct extends ProcessHQLQuery {
@@ -45,8 +49,9 @@
     HQLPropertyList regularProductsHQLProperties = ModelExtensionUtils.getPropertyExtensions(
         extensions, args);
     regularProductsHQLProperties.addAll(ProductProperties.getMainProductHQLProperties(args));
-    String hql = "select" + regularProductsHQLProperties.getHqlSelect()
-        + "FROM Product product left outer join product.uOM uom where product.id=:productId";
+    String hql = "select"
+        + regularProductsHQLProperties.getHqlSelect()
+        + "FROM Product product left outer join product.uOM uom, PricingProductPrice ppp WHERE ppp.product=product and ppp.priceListVersion.id=:priceListVersionId and product.id=:productId";
     products.add(hql);
     return products;
 
@@ -55,6 +60,9 @@
   @Override
   protected Map<String, Object> getParameterValues(JSONObject jsonsent) throws JSONException {
     Map<String, Object> paramValues = new HashMap<String, Object>();
+    final PriceListVersion priceListVersion = POSUtils.getPriceListVersionByOrgId(OBContext
+        .getOBContext().getCurrentOrganization().getId(), new Date());
+    paramValues.put("priceListVersionId", priceListVersion.getId());
     paramValues.put("productId", jsonsent.getJSONObject("parameters").getJSONObject("productId")
         .getString("value"));
     return paramValues;
diff -r f7a5f1337e05 -r 56a44c648697 src/org/openbravo/retail/posterminal/master/ProductProperties.java
--- a/src/org/openbravo/retail/posterminal/master/ProductProperties.java	Wed May 03 07:49:25 2017 -0600
+++ b/src/org/openbravo/retail/posterminal/master/ProductProperties.java	Wed May 10 13:06:12 2017 +0200
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2013-2016 Openbravo S.L.U.
+ * Copyright (C) 2013-2017 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.
@@ -72,7 +72,6 @@
         add(new HQLProperty("pli.issalediscontinued", "issalediscontinued"));
         add(new HQLProperty("'false'", "ispack"));
         add(new HQLProperty("ppp.listPrice", "listPrice"));
-        add(new HQLProperty("ppp.standardPrice", "standardPrice"));
         add(new HQLProperty("ppp.priceLimit", "priceLimit"));
         add(new HQLProperty("ppp.cost", "cost"));
         Entity ProductPrice = ModelProvider.getInstance().getEntity(ProductPrice.class);
@@ -191,6 +190,7 @@
           add(new HQLProperty("product.quantityRule", "quantityRule"));
           add(new HQLProperty("product.obposPrintservices", "isPrintServices"));
           add(new HQLProperty("product.obposEditablePrice", "obposEditablePrice"));
+          add(new HQLProperty("ppp.standardPrice", "standardPrice"));
           if (multiPriceList) {
             add(new HQLProperty("pp.standardPrice", "currentStandardPrice"));
           }

