Skip to content
Snippets Groups Projects
Commit c601bd62 authored by Benjamin Ulrich's avatar Benjamin Ulrich :speech_balloon: Committed by Sebastian Pongratz
Browse files

[Projekt: xRM-Sales][TicketNr.: 1085733][Gültigkeit von Preisen -> zwei Preise...

[Projekt: xRM-Sales][TicketNr.: 1085733][Gültigkeit von Preisen -> zwei Preise mit gleicher Preisliste und gleicher Stückzahl gleichzeitig möglich]
parent c216d5fc
No related branches found
No related tags found
No related merge requests found
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
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