From c601bd62e546600937e58252b2563c19eb2caaf2 Mon Sep 17 00:00:00 2001 From: Benjamin Ulrich <b.ulrich@adito.de> Date: Thu, 30 Sep 2021 21:29:08 +0000 Subject: [PATCH] =?UTF-8?q?[Projekt:=20xRM-Sales][TicketNr.:=201085733][G?= =?UTF-8?q?=C3=BCltigkeit=20von=20Preisen=20->=20zwei=20Preise=20mit=20gle?= =?UTF-8?q?icher=20Preisliste=20und=20gleicher=20St=C3=BCckzahl=20gleichze?= =?UTF-8?q?itig=20m=C3=B6glich]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entity/Productprice_entity/onValidation.js | 48 +++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/entity/Productprice_entity/onValidation.js b/entity/Productprice_entity/onValidation.js index de8f835701..bc32d44d44 100644 --- a/entity/Productprice_entity/onValidation.js +++ b/entity/Productprice_entity/onValidation.js @@ -1,3 +1,4 @@ +import("Util_lib"); import("system.datetime"); import("system.eMath"); import("system.translate"); @@ -28,11 +29,26 @@ if(vars.getString("$param.IgnoreOnValidation_param") != "true") // (A) |-------| -> |-----| // (B) |---------| -> |---------| // - //There is another case we cannot handle as easy: - // if priceB's validFrom is after the validFrom of priceA and it's validTo is also before the validTo of priceA - // -> catch this case in the onValidation, since the only solution would be to delete priceB + // + //There are four other cases we cannot handle as easy: + //-If priceB's validFrom is after the validFrom of priceA and it's validTo is also before the validTo of priceA // (A) |----| -> handle in onValidation // (B) |-------------| -> handle in onValidation + // + //-If priceB's validFrom is the same as the validFrom of priceA (no matter what their validTo values are) + // (A) |----| -> handle in onValidation + // (B) |-------------| -> handle in onValidation + // + //-If priceB's validTo is the same as the validTo of priceA (no matter what their validFrom values are) + // (A) |----| -> handle in onValidation + // (B) |-------------| -> handle in onValidation + // + //-If priceB's validFrom is the same as the validFrom of priceA and priceB's validTo is the same as the validTo of priceA + // (A) |-------| -> handle in onValidation + // (B) |-------| -> handle in onValidation + // + //-> catch those case in the onValidation, since the only solution would be to delete priceA + // else if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) { var priceList = vars.get("$field.PRICELIST"); @@ -56,36 +72,20 @@ if(vars.getString("$param.IgnoreOnValidation_param") != "true") var priceListsToReplace1 = []; var priceListsToReplace2 = []; - var showMessage = false; for (var valPriceList in priceListsToPotentiallyReplace) { var currPriceList = priceListsToPotentiallyReplace[valPriceList]; if(currPriceList["priceList"] == priceList && currPriceList["buySell"] == buySell && Number.parseInt(currPriceList["fromQuantity"]) == Number.parseInt(quantity) && - currPriceList["relationId"] == vars.get("$param.ContactId_param") && - currPriceList["currency"] == currency) + (currPriceList["relationId"] == vars.get("$param.ContactId_param") + || Utils.isNullOrEmptyString(currPriceList["relationId"]) && Utils.isNullOrEmptyString(vars.get("$param.ContactId_param"))) + && currPriceList["currency"] == currency) { - if(currPriceList["validFrom"] > validFrom && ((validTo == undefined || validTo == "") || - (currPriceList["validTo"] != undefined && currPriceList["validTo"] != "" && currPriceList["validTo"] < validTo))) - { - showMessage = true; - break; - } - else if(eMath.addInt(currPriceList["validFrom"], datetime.ONE_DAY) == currPriceList["validTo"]) + if(currPriceList["validFrom"] <= validFrom && (validTo >= currPriceList["validTo"] || Utils.isNotNullOrEmptyString(currPriceList["validTo"]))) { - showMessage = true; - break; - } - else if(currPriceList["validFrom"] == validFrom && validTo == currPriceList["validTo"]) - { - showMessage = true; - break; + result.string(translate.withArguments("There already exists a %0 price with the same type of pricelist, quantity and currency in the defined range.", [vars.get("$field.BUYSELL")])); } } } - if(showMessage) - { - result.string(translate.withArguments("There already exists a %0 price with the same type of pricelist, quantity and currency in the defined range.", [vars.get("$field.BUYSELL")])); - } } } \ No newline at end of file -- GitLab