From 5aaf163e8ead384377c1f9469b90ddaf369bf768 Mon Sep 17 00:00:00 2001 From: Pascal Neub <p.neub@adito.de> Date: Wed, 21 Jul 2021 13:59:37 +0000 Subject: [PATCH] [Projekt: xRM-Sales][TicketNr.: 1081943][Feld "Tage inaktiv" - Wert wird negativ eingegeben ] --- .../recordfieldmappings/inactivetime.value/expression.js | 1 + process/Sql_lib/process.js | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/entity/Salesproject_entity/recordcontainers/db/recordfieldmappings/inactivetime.value/expression.js b/entity/Salesproject_entity/recordcontainers/db/recordfieldmappings/inactivetime.value/expression.js index b590c9b4aae..c63e4f2ad0b 100644 --- a/entity/Salesproject_entity/recordcontainers/db/recordfieldmappings/inactivetime.value/expression.js +++ b/entity/Salesproject_entity/recordcontainers/db/recordfieldmappings/inactivetime.value/expression.js @@ -5,6 +5,7 @@ import("ActivityTask_lib"); var maskingUtils = new SqlMaskingUtils(); var dateDiff = maskingUtils.dayDateDifference( + "current_date", SqlUtils.nullableWithDefault( ActivityUtils.getLastActivityDateSql("SALESPROJECT.SALESPROJECTID"), "SALESPROJECT.DATE_NEW" diff --git a/process/Sql_lib/process.js b/process/Sql_lib/process.js index 0e72ac6f216..ca7e8e08ddb 100644 --- a/process/Sql_lib/process.js +++ b/process/Sql_lib/process.js @@ -3337,10 +3337,11 @@ SqlMaskingUtils.prototype.modulo = function(pField1, pField2) /** * Returns an sql expression resolving into the diffrence between 2 dates in days - * Notet that pDate2Field is optional it will default to the current date + * The expression is a s follows: first_date - second_date + * So if the first date is smaller than the second date you will get a negative value returned * * @param {string|SqlBuilder} pDateField1 the first date - * @param {string|SqlBuilder} pDateField2 the optional second date, defaults to the current date + * @param {string|SqlBuilder} pDateField2 the second date * * @returns the diffrence between the two dates in days */ @@ -3349,13 +3350,13 @@ SqlMaskingUtils.prototype.dayDateDifference = function(pDateField1, pDateField2) var maskingUtils = new SqlMaskingUtils(); var date1 = maskingUtils.cast("(" + pDateField1.toString() + ")", SQLTYPES.DATE); - var date2 = pDateField2 ? maskingUtils.cast("(" + pDateField2.toString() + ")", SQLTYPES.DATE) : "current_date"; + var date2 = maskingUtils.cast("(" + pDateField2.toString() + ")", SQLTYPES.DATE); switch(this.dbType) { case db.DBTYPE_DERBY10: // JDBC escape systax is required for timestampdiff - return "{fn timestampdiff(SQL_TSI_DAY, " + date1 + ", " + date2 + ")}"; + return "{fn timestampdiff(SQL_TSI_DAY, " + date2 + ", " + date1 + ")}"; case db.DBTYPE_POSTGRESQL8: case db.DBTYPE_SQLSERVER2000: return "datediff(day, " + date1 + ", " + date2 + ")"; -- GitLab