Fixes Issue 32038: "Price Adjustment" promotion type is applied to a line only
authorNono Carballo <f.carballo@nectus.com>
Mon, 01 Feb 2016 16:54:12 -0500
changeset 28589 dbc7082479bb
parent 28588 ae93510d847c
child 28590 f8d4bab7045b
Fixes Issue 32038: "Price Adjustment" promotion type is applied to a line only
if the order/invoice date falls into the promotion period.

The HQL query was tuned to take into account the starting and ending date of the
promotion when selecting a product for a line in a purchase order/invoice.
The line only gets the promotion if the period encloses the order/invoice date,
start and end date included.
The line hql += "and (endingDate is null or endingDate>:date) "; was replaced with

hql += "and (endingDate is null or endingDate>=:date) ";
hql += "and (startingDate is null or startingDate<=:date) ";
src/org/openbravo/erpCommon/businessUtility/PriceAdjustment.java
--- a/src/org/openbravo/erpCommon/businessUtility/PriceAdjustment.java	Thu Feb 04 12:24:30 2016 +0100
+++ b/src/org/openbravo/erpCommon/businessUtility/PriceAdjustment.java	Mon Feb 01 16:54:12 2016 -0500
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2014-2015 Openbravo SLU 
+ * All portions are Copyright (C) 2014-2016 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -147,7 +147,8 @@
     String hql = "as p ";
     hql += "where active = true ";
     hql += "and client = :client ";
-    hql += "and (endingDate is null or endingDate>:date) ";
+    hql += "and (endingDate is null or endingDate>=:date) ";
+    hql += "and (startingDate is null or startingDate<=:date) ";
     hql += "and p.discountType.id = '5D4BAF6BB86D4D2C9ED3D5A6FC051579' ";
     hql += "and (minQuantity is null or minQuantity <= :qty) ";
     hql += "and (maxQuantity is null or maxQuantity >= :qty) ";