Skip to content
Snippets Groups Projects
Commit e82b73f6 authored by Benjamin Ulrich's avatar Benjamin Ulrich :speech_balloon:
Browse files

Merge branch 'sales_pn_1081333_firma_presikonfitionen_nicht_korrekt_validiert' into '2021.1.1'

[Projekt: xRM-Sales][TicketNr.: 1081333][Firma Preiskondition wird nicht korrekt validiert]

See merge request xrm/basic!984
parents 65a74e0c fa1830b3
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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 == "") ||
......
......@@ -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
......
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