diff --git a/entity/Productprice_entity/Productprice_entity.aod b/entity/Productprice_entity/Productprice_entity.aod index e45c613aa87e47a9393c254cfb4abfb07fa67268..e85fa3d4f251f41a2f073fe09c3a6b3ab0f93d9c 100644 --- a/entity/Productprice_entity/Productprice_entity.aod +++ b/entity/Productprice_entity/Productprice_entity.aod @@ -100,7 +100,6 @@ <titleProcess>%aditoprj%/entity/Productprice_entity/entityfields/pricelist/titleProcess.js</titleProcess> <valueProcess>%aditoprj%/entity/Productprice_entity/entityfields/pricelist/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/Productprice_entity/entityfields/pricelist/displayValueProcess.js</displayValueProcess> - <onValidation>%aditoprj%/entity/Productprice_entity/entityfields/pricelist/onValidation.js</onValidation> </entityField> <entityParameter> <name>ProductId_param</name> diff --git a/entity/Productprice_entity/entityfields/pricelist/onValidation.js b/entity/Productprice_entity/entityfields/pricelist/onValidation.js deleted file mode 100644 index 4aacd1ac134be1b8fd4f486e3b195092776ee618..0000000000000000000000000000000000000000 --- a/entity/Productprice_entity/entityfields/pricelist/onValidation.js +++ /dev/null @@ -1,22 +0,0 @@ -import("system.translate"); -import("system.result"); -import("system.vars"); -import("Product_lib"); -import("Util_lib"); -import("Entity_lib"); - -var priceList = { - priceList: ProcessHandlingUtils.getOnValidationValue(vars.get("$field.PRICELIST")) - , priceListId: vars.get("$field.PRODUCTPRICEID") - , fromQuantity: vars.get("$field.FROMQUANTITY") - , buySell: vars.get("$field.BUYSELL") - , currency: vars.get("$field.CURRENCY") - , validFrom: vars.get("$field.VALID_FROM") - , validTo: vars.get("$field.VALID_TO") - }; - -var identicalPriceList = ProductUtils.checkForIndenticalPriceLists(vars.get("$field.PRODUCT_ID"), priceList); -if(identicalPriceList != null) -{ - result.string(translate.text("Identical price list found!")); -} \ No newline at end of file diff --git a/entity/Productprice_entity/onValidation.js b/entity/Productprice_entity/onValidation.js index 6e3b8b5612c52a2218472d4336494029991dd648..fddde143c2d4bb6186ae78d6032f09866ff77610 100644 --- a/entity/Productprice_entity/onValidation.js +++ b/entity/Productprice_entity/onValidation.js @@ -1,9 +1,35 @@ +import("Product_lib"); +import("system.translate"); import("system.result"); import("Date_lib"); import("system.vars"); +var messages = ""; + var startDate = vars.get("$field.VALID_FROM"); var endDate = vars.get("$field.VALID_TO"); if (!DateUtils.validateBeginnBeforeEnd(startDate, endDate)) - result.string(DateUtils.getValidationFailString()); \ No newline at end of file + messages += DateUtils.getValidationFailString(); + +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 = ProductUtils.checkForIndenticalPriceLists(vars.get("$field.PRODUCT_ID"), priceList); +if(identicalPriceList != null) +{ + if (messages) + messages += "\n"; + messages += translate.text("Identical price list found!"); +} + +if (messages) + result.string(messages) \ No newline at end of file diff --git a/process/Product_lib/process.js b/process/Product_lib/process.js index 4d5c93b08c4cce458a872e93c6955c99207d1d51..83d5c5066d2d815d081c613e2593082890aa487a 100644 --- a/process/Product_lib/process.js +++ b/process/Product_lib/process.js @@ -1,3 +1,4 @@ +import("system.logging"); import("system.util"); import("system.SQLTYPES"); import("system.datetime"); @@ -299,22 +300,25 @@ ProductUtils.getProductDetails = function(pid, priceListFilter, additionalProduc * @param {String} pid ProductID * @param {Object} priceList { <br> * priceList: "keyvalue of keyword 'PRICELIST'" <br> - * , validFrom: TIMESTAMP <br> - * , validTo: TIMESTAMP <br> - * , buySell: "SP" / "PP" <br> - * , fromQuantity: "fromquantity" <br> - * , currency: "keyvalue of keyword 'CURRENCY'" <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: ProcessHandlingUtils.getOnValidationValue(vars.get("$field.PRICELIST")) - * , fromQuantity: vars.get("$field.FROMQUANTITY") - * , buySell: vars.get("$field.BUYSELL") - * , currency: vars.get("$field.CURRENCY") - * , validFrom: vars.get("$field.VALID_FROM") - * , validTo: vars.get("$field.VALID_TO") + * 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); @@ -328,16 +332,20 @@ ProductUtils.getProductDetails = function(pid, priceListFilter, additionalProduc ProductUtils.checkForIndenticalPriceLists = function(pid, priceList) { var PriceLists = this.getProductDetails(pid).PriceLists; + logging.log("PL: " + JSON.stringify(priceList, null, "\t")) for (var pricelist in PriceLists) { //different pricelist id //equal price list //equal fromquantity //equal currency //equal pp/sp + //equal vat + logging.log(JSON.stringify(PriceLists[pricelist], null, "\t")) 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