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

Product_lib refactoring

parent 663110c8
No related branches found
No related tags found
No related merge requests found
......@@ -10,10 +10,9 @@ if(pid != "")
var curr = vars.exists("$param.Currency_param") ? vars.get("$param.Currency_param") : "";
var relid = vars.exists("$param.RelationId_param") ? vars.get("$param.RelationId_param") : "";
var pUtils = new ProductUtils();
var PriceListFilter = { currency: curr, quantity: vars.get("$field.QUANTITY"), relationId: relid };
var ProductDetails = pUtils.getProductDetails(pid, PriceListFilter);
var ProductDetails = ProductUtils.getProductDetails(pid, PriceListFilter);
if(ProductDetails.productId != undefined)
{
......
......@@ -11,10 +11,9 @@ if(pid != "" && newQuantity != "")
var curr = vars.exists("$param.Currency_param") ? vars.get("$param.Currency_param") : "";
var relid = vars.exists("$param.RelationId_param") ? vars.get("$param.RelationId_param") : "";
var pUtils = new ProductUtils();
var PriceListFilter = { currency: curr, quantity: newQuantity, relationId: relid };
var ProductDetails = pUtils.getProductDetails(pid, PriceListFilter);
var ProductDetails = ProductUtils.getProductDetails(pid, PriceListFilter);
if(ProductDetails.productId != undefined && ProductDetails.PriceListToUse != null)
{
......
......@@ -4,7 +4,5 @@ import("Product_lib");
if(vars.exists("$param.ProductId_param") && vars.get("$param.ProductId_param") != "")
{
var ProductUtils = new ProductUtils();
result.string( ProductUtils.getCurrentProductPrice(vars.get("$param.ProductId_param"), "PP") );
}
\ No newline at end of file
......@@ -4,7 +4,5 @@ import("Product_lib");
if(vars.exists("$param.ProductId_param") && vars.get("$param.ProductId_param") != "")
{
var ProductUtils = new ProductUtils();
result.string( ProductUtils.getCurrentProductPrice(vars.get("$param.ProductId_param"), "SP") );
}
\ No newline at end of file
......@@ -5,7 +5,6 @@ import("Product_lib");
import("Util_lib");
import("Entity_lib");
var pUtils = new ProductUtils();
var priceList = {
priceList: ProcessHandlingUtils.getOnValidationValue(vars.get("$field.PRICELIST"))
, fromQuantity: vars.get("$field.FROMQUANTITY")
......@@ -15,7 +14,7 @@ var priceList = {
, validTo: vars.get("$field.VALID_TO")
};
var identicalPriceList = pUtils.checkForIndenticalPriceLists(vars.get("$field.PRODUCT_ID"), priceList);
var identicalPriceList = ProductUtils.checkForIndenticalPriceLists(vars.get("$field.PRODUCT_ID"), priceList);
if(identicalPriceList != null)
{
result.string(translate.text("Identical price list found!"));
......
......@@ -4,7 +4,5 @@ import("Product_lib");
if(vars.exists("$param.ProductId_param") && vars.get("$param.ProductId_param") != "")
{
var pUtils = new ProductUtils();
result.string( pUtils.getStockCount(vars.get("$param.ProductId_param")) );
result.string( ProductUtils.getStockCount(vars.get("$param.ProductId_param")) );
}
\ No newline at end of file
......@@ -135,6 +135,15 @@ SqlCondition.prototype.and = function(cond){<5>
}
----
=== private functions ===
Private functions would be possible but make everything much more complicate.
So just start your functions / methods name with a _ if you need private methods.
--> do not use functions which start with a _ outside of the class!
----
<1> JS-Doc comment: http://usejsdoc.org/
<2> use the correct form for optional/required parameters: http://usejsdoc.org/tags-param.html
<3> examples are useful on more complex functions
......
......@@ -398,9 +398,7 @@ ItemUtils.prototype.insertPartsList = function(columns, table, productId, assign
var rootProdId = productId;
if(rootProdId != "")
{
var pUtils = new ProductUtils();
{
var p2pUtils = new Prod2ProdUtils(rootProdId);
var partsList = p2pUtils.getPartsListObject();
......@@ -428,7 +426,7 @@ ItemUtils.prototype.insertPartsList = function(columns, table, productId, assign
var p2pid = partsListObj.ids[i];
var P2pObject = partsList[p2pid];
var prodid = partsList[p2pid].sourceid;
var ProductDetails = pUtils.getProductDetails(prodid, { currency: currency, quantity: P2pObject.quantity, relationId: relationId } )
var ProductDetails = ProductUtils.getProductDetails(prodid, { currency: currency, quantity: P2pObject.quantity, relationId: relationId } )
var price = "";
var vat = "";
......
This diff is collapsed.
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