Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0032038Openbravo ERP09. Financial managementpublic2016-01-28 12:172016-03-17 10:56
maite 
nonofrancisco 
urgentmajoralways
closedfixed 
5
 
3.0PR16Q2 
vmromanos
Core
No
0032038: "Price Adjustment" promotion defined for the future is applied today
"Price Adjustment" promotion defined for the future is applied today
1. Define new "Price Adjustment" promotion type as:
  * Date from: tomorrow
  * Date to: tomorrow
  * Included Product: only those defined --> add any product in Products tab
  * Discount %: 5
2. Create new Purchase Order for today. Add line for defined product and realize that discount is applied
Problem seems to be in src/org/openbravo/erpCommon/businessUtility/PriceAdjustment.java, which is not considering "Date From" but only "Date To" value
No tags attached.
Issue History
2016-01-28 12:17maiteNew Issue
2016-01-28 12:17maiteAssigned To => Triage Finance
2016-01-28 12:17maiteModules => Core
2016-01-28 12:17maiteResolution time => 1456268400
2016-01-28 12:17maiteTriggers an Emergency Pack => No
2016-01-28 12:17maiteIssue Monitored: networkb
2016-02-01 17:22nonofranciscoAssigned ToTriage Finance => nonofrancisco
2016-02-01 17:23nonofranciscoStatusnew => scheduled
2016-02-02 15:07nonofranciscoNote Added: 0083853
2016-02-10 17:16hgbotCheckin
2016-02-10 17:16hgbotNote Added: 0084086
2016-02-10 17:16hgbotStatusscheduled => resolved
2016-02-10 17:16hgbotResolutionopen => fixed
2016-02-10 17:16hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/dbc7082479bb2a309cbeb054eef10768f95a8c9e [^]
2016-02-10 17:16hgbotCheckin
2016-02-10 17:16hgbotNote Added: 0084087
2016-02-10 17:17vmromanosReview Assigned To => vmromanos
2016-02-10 17:17vmromanosNote Added: 0084088
2016-02-10 17:17vmromanosStatusresolved => closed
2016-03-17 10:56hudsonbotCheckin
2016-03-17 10:56hudsonbotNote Added: 0085125
2016-03-17 10:56hudsonbotCheckin
2016-03-17 10:56hudsonbotNote Added: 0085126

Notes
(0083853)
nonofrancisco   
2016-02-02 15:07   
Test Plan

As Openbravo / F&B International Group Admin

Create a new Discount and Promotion
  Type: Price Adjustment
  Discount %: 5
  Date from: tomorrow
  Date to: tomorrow
  Included products: Only those defined
  Save
  In Product tab
    Add Ale Beer
    Save
    
Realize Ale Beer has a of 1.36 in Happy Drinks Price List.

Create a new Purchase Order
  Business Partner: Happy Drinks, Inc.
  Order date: today
  Save
  Create a new Line
    Product: Ale Beer

Realize the net unit price is 1.36

Go to the Discount and Promotion window
  Change the staring date of the promotion previously created to today date
  Save

Go to Purchase Order window
  In the line, select product Ale Beer again in product combo.
  
Realize the price is adjusted to 1.29
(0084086)
hgbot   
2016-02-10 17:16   
Repository: erp/devel/pi
Changeset: dbc7082479bb2a309cbeb054eef10768f95a8c9e
Author: Nono Carballo <f.carballo <at> nectus.com>
Date: Mon Feb 01 16:54:12 2016 -0500
URL: http://code.openbravo.com/erp/devel/pi/rev/dbc7082479bb2a309cbeb054eef10768f95a8c9e [^]

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) ";

---
M src/org/openbravo/erpCommon/businessUtility/PriceAdjustment.java
---
(0084087)
hgbot   
2016-02-10 17:16   
Repository: erp/devel/pi
Changeset: f8d4bab7045bfb0370cc14461f09ddcea330f47c
Author: Víctor Martínez Romanos <victor.martinez <at> openbravo.com>
Date: Wed Feb 10 17:08:23 2016 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/f8d4bab7045bfb0370cc14461f09ddcea330f47c [^]

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.

---
M src/org/openbravo/erpCommon/businessUtility/PriceAdjustment.java
---
(0084088)
vmromanos   
2016-02-10 17:17   
Code review + testing OK
(0085125)
hudsonbot   
2016-03-17 10:56   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/b22fb0500156 [^]
Maturity status: Test
(0085126)
hudsonbot   
2016-03-17 10:56   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/b22fb0500156 [^]
Maturity status: Test