Skip to content
Snippets Groups Projects
Commit 35eb85b4 authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

[Projekt: Entwicklung - Neon][TicketNr.: 1027750][JDito - libray Standard ist...

[Projekt: Entwicklung - Neon][TicketNr.: 1027750][JDito - libray Standard ist komplett definiert und wird in allen libs verwendet]
refactor Date_lib
parent 0f5ece90
No related branches found
No related tags found
No related merge requests found
Showing with 50 additions and 60 deletions
......@@ -5,9 +5,8 @@ import("Date_lib");
import("Util_lib");
import("Entity_lib");
var dateUtils = new DateUtils();
var cDue = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.CONTRACTDUE"));
if (dateUtils.validateBeginnBeforeEnd(vars.get("$field.CONTRACTSTART"), cDue) === false || dateUtils.validateBeginnBeforeEnd(cDue, vars.get("$field.CONTRACTEND")) === false) {
if (DateUtils.validateBeginnBeforeEnd(vars.get("$field.CONTRACTSTART"), cDue) === false || DateUtils.validateBeginnBeforeEnd(cDue, vars.get("$field.CONTRACTEND")) === false) {
result.string(translate.text("The next due date must be after the start of the contract and before the expiry of the contract!"));
}
......@@ -4,9 +4,8 @@ import("Date_lib");
import("Util_lib");
import("Entity_lib");
var dateUtils = new DateUtils();
var cEnd = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.CONTRACTEND"));
var cDue = vars.get("$field.CONTRACTDUE");
if (dateUtils.validateBeginnBeforeEnd(vars.get("$field.CONTRACTSTART"), cEnd) === false)
result.string(dateUtils.getValidationFailString());
\ No newline at end of file
if (DateUtils.validateBeginnBeforeEnd(vars.get("$field.CONTRACTSTART"), cEnd) === false)
result.string(DateUtils.getValidationFailString());
\ No newline at end of file
......@@ -5,9 +5,8 @@ import("Date_lib");
import("Util_lib");
import("Entity_lib");
var dateUtils = new DateUtils();
var cStart = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.CONTRACTSTART"));
var cDue = vars.get("$field.CONTRACTDUE");
if (dateUtils.validateBeginnBeforeEnd(cStart, vars.get("$field.CONTRACTEND")) === false)
result.string(dateUtils.getValidationFailString());
\ No newline at end of file
if (DateUtils.validateBeginnBeforeEnd(cStart, vars.get("$field.CONTRACTEND")) === false)
result.string(DateUtils.getValidationFailString());
\ No newline at end of file
......@@ -5,7 +5,6 @@ import("Date_lib");
if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == "")
{
var DateUtils = new DateUtils();
result.string(DateUtils.getTodayUTC());
}
else
......
......@@ -4,8 +4,7 @@ import("Date_lib");
import("Util_lib");
import("Entity_lib");
var dateUtils = new DateUtils();
var cStart = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.VALID_FROM"));
if (dateUtils.validateBeginnBeforeEnd(cStart, vars.get("$field.VALID_TO")) === false)
result.string(dateUtils.getValidationFailString());
\ No newline at end of file
if (DateUtils.validateBeginnBeforeEnd(cStart, vars.get("$field.VALID_TO")) === false)
result.string(DateUtils.getValidationFailString());
\ No newline at end of file
......@@ -4,8 +4,7 @@ import("Date_lib");
import("Util_lib");
import("Entity_lib");
var dateUtils = new DateUtils();
var cEnd = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.VALID_TO"));
if (dateUtils.validateBeginnBeforeEnd(vars.get("$field.VALID_FROM"), cEnd) === false)
result.string(dateUtils.getValidationFailString());
\ No newline at end of file
if (DateUtils.validateBeginnBeforeEnd(vars.get("$field.VALID_FROM"), cEnd) === false)
result.string(DateUtils.getValidationFailString());
\ No newline at end of file
......@@ -5,7 +5,6 @@ import("Date_lib");
if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == "")
{
var DateUtils = new DateUtils();
result.string(DateUtils.getDateIncrementedByYears(DateUtils.getTodayUTC(), 1));
}
else
......
......@@ -5,7 +5,6 @@ import("Date_lib");
if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == "")
{
var DateUtils = new DateUtils();
result.string(DateUtils.getTodayUTC());
}
else
......
......@@ -5,45 +5,44 @@ import("system.datetime");
* provides methods for interactions with dates
*/
function DateUtils(){
var that = this;
/**
* Validates two date inputs (beginning should always be before the end!)
*
* @param pStart {Number}
* @param pEnd {Number}
*
* @result {Boolean|null} Boolean if it was able to check smth or null if the input values were not valid
*/
this.validateBeginnBeforeEnd = function(pStart, pEnd) {
if (pStart == "" || pStart == null || pEnd == "" || pEnd == null) return null;
return pStart <= pEnd;
}
this.getValidationFailString = function(){
return translate.text("The expiry date must be after the start date!");
}
/**
* Delivers the current date at midnight in UTC
*
* @result {Number}
*/
this.getTodayUTC = function(){
return datetime.today("UTC");
}
/**
* Delivers the passed date incremented by passed years
*
* @param pDate {Number}
* @param pYears {Number}
*
* @result {Number} date incremented by years
*/
this.getDateIncrementedByYears = function(pDate, pYears){
var dateObj = new Date(pDate);
return dateObj.setFullYear(dateObj.getFullYear() + pYears);
}
}
/**
* Validates two date inputs (beginning should always be before the end!)
*
* @param pStart {Number}
* @param pEnd {Number}
*
* @result {Boolean|null} Boolean if it was able to check smth or null if the input values were not valid
*/
DateUtils.validateBeginnBeforeEnd = function(pStart, pEnd) {
if (pStart == "" || pStart == null || pEnd == "" || pEnd == null) return null;
return pStart <= pEnd;
}
DateUtils.getValidationFailString = function(){
return translate.text("The expiry date must be after the start date!");
}
/**
* Delivers the current date at midnight in UTC
*
* @result {Number}
*/
DateUtils.getTodayUTC = function(){
return datetime.today("UTC");
}
/**
* Delivers the passed date incremented by passed years
*
* @param pDate {Number}
* @param pYears {Number}
*
* @result {Number} date incremented by years
*/
DateUtils.getDateIncrementedByYears = function(pDate, pYears){
var dateObj = new Date(pDate);
return dateObj.setFullYear(dateObj.getFullYear() + pYears);
}
\ No newline at end of file
......@@ -269,8 +269,7 @@ CopyModuleUtils.copyModule = function(pInputMapping)
case "OFFER":
{
//andere Values setzen
var dtUtils = new DateUtils();
ModuleRowMapping.ColumnMapping["OFFERDATE"].newValue = dtUtils.getTodayUTC();
ModuleRowMapping.ColumnMapping["OFFERDATE"].newValue = DateUtils.getTodayUTC();
}
break;
case "OFFERITEM":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment