details:   https://code.openbravo.com/erp/devel/pi/rev/dbc7082479bb
changeset: 28589:dbc7082479bb
user:      Nono Carballo <f.carballo <at> nectus.com>
date:      Mon Feb 01 16:54:12 2016 -0500
summary:   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) ";

details:   https://code.openbravo.com/erp/devel/pi/rev/f8d4bab7045b
changeset: 28590:f8d4bab7045b
user:      Víctor Martínez Romanos <victor.martinez <at> openbravo.com>
date:      Wed Feb 10 17:08:23 2016 +0100
summary:   Related to issue 32038: code review improvements

* startingDate is a mandatory column, so there is no need to validate whether 
it's null or not
* The promotion is applied for the period of time between the Starting and 
Ending Dates (both inclusive). For example, for a promotion available only in a 
concrete date, the starting and ending dates must be equal.
The date received as parameter to this query might have a time 
(hours/minutes/seconds). To control that situation the comparation is 
truncating the promotion starting and ending date (that should already be 
truncated because it's linked to a Date reference), it adds 1 day to the 
promotion ending date and removes the equal clause. Thus we can properly 
control the scenario of a one-day promotion with a datetime parameter.

diffstat:

 src/org/openbravo/erpCommon/businessUtility/PriceAdjustment.java |  5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diffs (22 lines):

diff -r ae93510d847c -r f8d4bab7045b 
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  Wed Feb 
10 17:08:23 2016 +0100
@@ -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 trunc(endingDate) + 1 > :date) ";
+    hql += "and trunc(startingDate)<=:date ";
     hql += "and p.discountType.id = '5D4BAF6BB86D4D2C9ED3D5A6FC051579' ";
     hql += "and (minQuantity is null or minQuantity <= :qty) ";
     hql += "and (maxQuantity is null or maxQuantity >= :qty) ";

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to