Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0037390Openbravo ERP00. Application dictionarypublic2017-11-27 12:332018-01-03 12:39
gorkaion 
alostale 
highminoralways
closedfixed 
5
 
3.0PR18Q1 
caristu
Core
No
0037390: < and > operators fail when comparing negative values in Display Logic
"<" and ">" are not properly managed by DynamicExpressionParser and produces a wrong javascript code when comparing with negative values.

When creating a Display Logic like:
@grandTotalAmount@ < - 5

It is translated to:
OB.Utilities.getValue(currentValues,'grandTotalAmount') < !== 5

This is caused because the "<" is not considered as a comparator and the "-" sign is considered instead. In this case it replaces the "-" with "!==" which results in a wrong js code.
On Sales Invoice window.

Create some invoices with negative and positive total amounts.

On the Application Dictionary modify the Display Logic of the "APRM Process Invoice" field to "@GrandTotal@ > - 5". So it only shows the "Complete" button if the total amount of the invoice is higher than "-5".

Try to open the Sales Invoice tab and it fails. If you check the browser's console you see a javascript error with the wrong displayIf function.
Add the "<", ">", "<=" and ">=" to the array of "COMPARATIONS" in DynamicExpressionParser. So the negative number is considered as the right part of the expression and the "-" sign is not replaced by "!==".
No tags attached.
Issue History
2017-11-27 12:33gorkaionNew Issue
2017-11-27 12:33gorkaionAssigned To => platform
2017-11-27 12:33gorkaionModules => Core
2017-11-27 12:33gorkaionTriggers an Emergency Pack => No
2017-11-28 09:35alostaleStatusnew => scheduled
2017-11-28 09:35alostaleAssigned Toplatform => alostale
2017-11-28 09:57hgbotCheckin
2017-11-28 09:57hgbotNote Added: 0100754
2017-11-28 09:57hgbotStatusscheduled => resolved
2017-11-28 09:57hgbotResolutionopen => fixed
2017-11-28 09:57hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/6a9db69516b2560f153d3390235b88d447af4d7e [^]
2017-11-28 09:57alostaleReview Assigned To => caristu
2017-11-28 19:34caristuNote Added: 0100800
2017-11-28 19:34caristuStatusresolved => closed
2017-11-28 19:34caristuFixed in Version => 3.0PR18Q1
2018-01-03 12:39hudsonbotCheckin
2018-01-03 12:39hudsonbotNote Added: 0101465

Notes
(0100754)
hgbot   
2017-11-28 09:57   
Repository: erp/devel/pi
Changeset: 6a9db69516b2560f153d3390235b88d447af4d7e
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Tue Nov 28 09:48:01 2017 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/6a9db69516b2560f153d3390235b88d447af4d7e [^]

fixed bug 37390: can't compare gt or lt with negative values in display logic

  When comparing negative values with gt (>), lt (>), ge (>=) or le (>=) the
  generated JavaScript expression was incorrect.

  Those operators were not properly parsed because they were not declared in
  DynamicExpressionParser.

---
M modules/org.openbravo.client.application/src-test/org/openbravo/client/application/test/DynamicExpressionParserTest.java
M modules/org.openbravo.client.application/src/org/openbravo/client/application/DynamicExpressionParser.java
---
(0100800)
caristu   
2017-11-28 19:34   
Code reviewed + tested OK.
(0101465)
hudsonbot   
2018-01-03 12:39   
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/c81e0d3cbab5 [^]
Maturity status: Test