Skip to content
Snippets Groups Projects
Commit 50b62685 authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

add VAT to identical pricelist validation

parent 85783109
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
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
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
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
......
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