From fa1830b3f78d56121314ffc43d02b2a6ce21488c Mon Sep 17 00:00:00 2001 From: Pascal Neub <p.neub@adito.de> Date: Mon, 5 Jul 2021 08:13:41 +0000 Subject: [PATCH] [Projekt: xRM-Sales][TicketNr.: 1081333][Firma Preiskondition wird nicht korrekt validiert] --- .../entityfields/pricelist/documentation.adoc | 3 +- entity/Productprice_entity/onValidation.js | 1 + process/Product_lib/process.js | 70 ------------------- 3 files changed, 3 insertions(+), 71 deletions(-) diff --git a/entity/Productprice_entity/entityfields/pricelist/documentation.adoc b/entity/Productprice_entity/entityfields/pricelist/documentation.adoc index 1ebd4759eaf..4d5baf63b72 100644 --- a/entity/Productprice_entity/entityfields/pricelist/documentation.adoc +++ b/entity/Productprice_entity/entityfields/pricelist/documentation.adoc @@ -7,12 +7,13 @@ Field indicates the type of the price list. == onValidation There's a **verficiation** for current pricelist whether an **identical price list already exists** for product. -The following criteria will be checked in function _ProductUtils.checkForIndenticalPriceLists()_: +The following criteria will be checked in the validation process of ProductPrice: * Identical price list type * Identical from quantity * Identical currency * Identical purchase price/sales price * Identical Valid from and valid to OR +* Identical relationId If all criteria are fulfilled, price list can not be saved. \ No newline at end of file diff --git a/entity/Productprice_entity/onValidation.js b/entity/Productprice_entity/onValidation.js index e1091b42457..de8f835701b 100644 --- a/entity/Productprice_entity/onValidation.js +++ b/entity/Productprice_entity/onValidation.js @@ -62,6 +62,7 @@ if(vars.getString("$param.IgnoreOnValidation_param") != "true") 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) { if(currPriceList["validFrom"] > validFrom && ((validTo == undefined || validTo == "") || diff --git a/process/Product_lib/process.js b/process/Product_lib/process.js index 8f909b545f2..ffd18f6e59a 100644 --- a/process/Product_lib/process.js +++ b/process/Product_lib/process.js @@ -374,76 +374,6 @@ ProductUtils.getProductDetails = function(pid, pPriceListFilter, pAdditionalProd } } } -/** - * Checks if there is already an existing price list identical to the passed price list - * - * @param {String} pid ProductID - * @param {Object} priceList { <br> - * priceList: "keyvalue of keyword 'PRICELIST'" <br> - * validFrom: TIMESTAMP, <br> - * validTo: TIMESTAMP, <br> - * buySell: "SP" / "PP", <br> - * vat: Number, <br> - * fromQuantity: "fromquantity", <br> - * currency: "keyvalue of keyword 'CURRENCY'" <br> - * } - * - * @example //Productprice_entity, Field: PRICELIST, Process: onValidation - * var pUtils = new ProductUtils(); - * var priceList = { - * priceList: vars.get("$field.PRICELIST"), - * priceListId: vars.get("$field.PRODUCTPRICEID"), - * fromQuantity: vars.get("$field.FROMQUANTITY"), - * buySell: vars.get("$field.BUYSELL"), - * vat: vars.get("$field.VAT"), - * currency: vars.get("$field.CURRENCY"), - * validFrom: vars.get("$field.VALID_FROM"), - * validTo: vars.get("$field.VALID_TO") - * }; - * - * var identicalPriceList = pUtils.checkForIndenticalPriceLists(vars.get("$field.PRODUCT_ID"), priceList); - * if (identicalPriceList != null) - * { - * result.string(translate.text("Identical price list found!")); - * } - * - * @return {Object | null} null if no identical price list was found, otherwise the found price list - */ -ProductUtils.checkForIndenticalPriceLists = function(pid, priceList) { - var PriceLists = this.getProductDetails(pid).PriceLists; - - for (var pricelist in PriceLists) { - //different pricelist id - //equal price list - //equal fromquantity - //equal currency - //equal pp/sp - //equal vat - if (priceList.priceListId != PriceLists[pricelist].priceListId - && priceList.priceList == PriceLists[pricelist].priceList - && parseFloat(priceList.fromQuantity) == parseFloat(PriceLists[pricelist].fromQuantity) - && priceList.buySell == PriceLists[pricelist].buySell - && parseFloat(priceList.vat) == parseFloat(PriceLists[pricelist].vat) - && priceList.currency == PriceLists[pricelist].currency) { - - //identical validFrom & validTo - // OR NOT [ validFrom_new <= validFrom & validTo_new <= validTo - // OR validFrom_new >= validFrom & validTo_new >= validTo - // OR validFrom_new < validFrom & validTo_new > validTo - // ] - if (priceList.validFrom == PriceLists[pricelist].validFrom && priceList.validTo == PriceLists[pricelist].validTo - || ! (priceList.validFrom <= PriceLists[pricelist].validFrom && priceList.validTo <= PriceLists[pricelist].validTo - || priceList.validFrom >= PriceLists[pricelist].validFrom && priceList.validTo >= PriceLists[pricelist].validTo - || priceList.validFrom < PriceLists[pricelist].validFrom && priceList.validTo > PriceLists[pricelist].validTo)) { - //identical price list found - return PriceLists[pricelist]; - } - } - } - - //no identical price list found - return null; -} /** * returns the image for a product -- GitLab