diff --git a/entity/Offer_entity/Offer_entity.aod b/entity/Offer_entity/Offer_entity.aod index 7d50bb201efe2da592a08cc3f99c5e8e03a6544e..854e5e7e7cf896ac0ed312e022ae51ee651eed44 100644 --- a/entity/Offer_entity/Offer_entity.aod +++ b/entity/Offer_entity/Offer_entity.aod @@ -1072,6 +1072,7 @@ <onValueChangeTypes> <element>MASK</element> </onValueChangeTypes> + <onValidation>%aditoprj%/entity/Offer_entity/entityfields/discount/onValidation.js</onValidation> </entityField> <entityField> <name>DISCOUNTED_NET</name> diff --git a/entity/Offer_entity/entityfields/discount/onValidation.js b/entity/Offer_entity/entityfields/discount/onValidation.js new file mode 100644 index 0000000000000000000000000000000000000000..595a5d9aae549242aaa2246e2e4b6e6d602249a0 --- /dev/null +++ b/entity/Offer_entity/entityfields/discount/onValidation.js @@ -0,0 +1,10 @@ +import("system.result"); +import("system.vars"); +import("Util_lib"); +import("Entity_lib"); + +var value = vars.get("local.value"); +var validationResult = NumberUtils.validateIsBetweenFloat("Discount", value, 0, 100); + +if (validationResult) + result.string(validationResult); \ No newline at end of file diff --git a/entity/Offer_entity/recordcontainers/db/onDBInsert.js b/entity/Offer_entity/recordcontainers/db/onDBInsert.js index 30cc525485c381c1261eb01db1d3b81ad47670bd..c7d3c3336eadfb5bc6b41deaec997081f23c491b 100644 --- a/entity/Offer_entity/recordcontainers/db/onDBInsert.js +++ b/entity/Offer_entity/recordcontainers/db/onDBInsert.js @@ -13,7 +13,7 @@ if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) { var offerId = vars.get("$local.uid"); var discount = rowdata["OFFER.DISCOUNT"]; - if (vars.exists("$param.OfferOriginal_Id_param")) + if (vars.exists("$param.OfferOriginal_Id_param") && vars.get("$param.OfferOriginal_Id_param")) OfferUtils.copyOfferItems(vars.getString("$param.OfferOriginal_Id_param"), offerId, discount); var activityId = vars.get("$param.ActivityId_param"); diff --git a/process/Offer_lib/process.js b/process/Offer_lib/process.js index d2385a6adbd3297dab0cef30faefa111afcba0a1..a33f0a530adf69c04278a2115f508f44c67c1257 100644 --- a/process/Offer_lib/process.js +++ b/process/Offer_lib/process.js @@ -609,6 +609,7 @@ OfferItemUtils.prototype.reOrgItems = function() { OfferItemUtils.getDiscountedNet = function(pExcludedIs, pOfferId, pDiscount, pExcludedProductgroups){ + pDiscount = pDiscount ? pDiscount : 0; var ret; var sum = 0; var sumExcluded = 0;