function updateShopperrPriceAlgo( factoryPrice, pweight, suppllierOrigin,  bcdRate = process.env.BCD, igstRate = process.env.GST, swcRate = process.env.SWC, lenght, width, height, mrp, productMargin = 40 , priceInfo = null){
    switch(parseInt(suppllierOrigin)) { 
        // For qnu algo
        case 1: 
            var cifValue = factoryPrice;  
            var landedCost = (cifValue*1/100); 
            cifValue = cifValue + landedCost;
            var getDuty  = cifValue*25/100;  
            var socialWelfareSurcharge = getDuty*10/100;  
            var priceBeforeGst = (cifValue + getDuty + socialWelfareSurcharge); 
            var gst = priceBeforeGst*18/100; 
            var landedPrice = (priceBeforeGst + gst); 
            var shopperrPrice = (landedPrice + (landedPrice*44/100)); 
            var productMrp = shopperrPrice*2;
            shopperrPrice = shopperrPrice.toFixed(2);
            var productPrice = productMrp.toFixed(2);
            var totalCOCGS = landedPrice.toFixed(2); 
            var airPrice = {}
            if(priceInfo == 1){
		    	airPrice = {
		    		'factoryPrice' 		: factoryPrice.toFixed(2),
		    		'duty'				: getDuty.toFixed(2), 
		    		'weight'			: pweight.toFixed(2),  
		    		'landedCost'		: landedCost.toFixed(2),
		    		'cogs'				: totalCOCGS.toFixed(2),
		    		'priceWithoutGst'	: priceBeforeGst.toFixed(2),
		    		'gstImpact'			: gst.toFixed(2),
		    		'gstImpactPer'		: '18.00',
		    		'price'				: shopperrPrice.toFixed(2),  
		    		'markup'			: (landedPrice*44/100).toFixed(2),
		    		'markupPer'			: '44.00', 
		    		'cunsumerPrice'		: productPrice.toFixed(2),
		    		'mrp'				: (getMsrp(productPrice)).toFixed(2)
		    	}
		    }else{  
            	airPrice = {'price' : Math.ceil(shopperrPrice) , 'cogs': Math.ceil(totalCOCGS), 'priceWithoutGst' : Math.ceil(priceBeforeGst) , 'mrp' : Math.ceil(productPrice)}
            }
            var data = {'seaPrice' : airPrice , 'airPrice' : airPrice}
            var dropshipper = dropshipperPrice(factoryPrice , pweight , igstRate , priceInfo);
            var airPriceFinal = airPriceAlgo(factoryPrice , pweight , bcdRate , igstRate , swcRate , lenght , width , height , priceInfo)
            data.dropshipperPrice = dropshipper;
            data.finalAirPrice = airPriceFinal;
        break;
        case 2:
            // For jv algo 
            var sfcProducts = 0;
            if(priceInfo == 1){ 
            	var data = chinaProductsPriceData(factoryPrice , pweight , bcdRate , igstRate , swcRate , lenght , width , height , sfcProducts, parseInt(productMargin), priceInfo);
            }else{  
            	var cogs = chinaProductsCogs(factoryPrice , pweight , bcdRate , igstRate , swcRate , lenght , width , height , sfcProducts , priceInfo);
            	var data = priceForChina(cogs , igstRate , parseInt(productMargin) , priceInfo);
            }
            var dropshipper = dropshipperPrice(factoryPrice , pweight , igstRate , priceInfo);
            var airPriceFinal = airPriceAlgo(factoryPrice , pweight , bcdRate , igstRate , swcRate , lenght , width , height , priceInfo)
            data.dropshipperPrice = dropshipper;
            data.finalAirPrice = airPriceFinal;
        break; 
        case 3: 
            // for lyla and loom tree
            var cogs = factoryPrice;
            var data = priceForDomestic(cogs , igstRate , parseInt(productMargin) , priceInfo);
            var dropshipper = dropshipperPrice(factoryPrice , pweight , igstRate , priceInfo);
            var airPriceFinal = airPriceAlgo(factoryPrice , pweight , bcdRate , igstRate , swcRate , lenght , width , height , priceInfo)
            data.dropshipperPrice = dropshipper; 
            data.finalAirPrice = airPriceFinal;
        break; 
        case 4:
            // For sfc algo
           
            var sfcProducts = 1;
            if(priceInfo == '1'){
            	var data = chinaProductsPriceData(factoryPrice , pweight , bcdRate , igstRate , swcRate , lenght , width , height , sfcProducts, parseInt(productMargin), priceInfo);
            }else{
            	var cogs = chinaProductsCogs(factoryPrice , pweight , bcdRate , igstRate , swcRate , lenght , width , height , sfcProducts , priceInfo);
            	
            	var data = priceForChina(cogs , igstRate , parseInt(productMargin) , priceInfo); 
            	
            }
            var dropshipper = dropshipperPrice(factoryPrice , pweight , igstRate , priceInfo);
           
            var airPriceFinal = airPriceAlgo(factoryPrice , pweight , bcdRate , igstRate , swcRate , lenght , width , height , priceInfo)
            data.dropshipperPrice = dropshipper;
            data.finalAirPrice = airPriceFinal;
        break; 
        case 5:
            // For cld Furnitures algo 
            var data = priceForCldfurnitures(factoryPrice , pweight , bcdRate , igstRate , swcRate , lenght , width , height , parseInt(productMargin) , priceInfo); 
            var dropshipper = dropshipperPrice(factoryPrice , pweight , igstRate , priceInfo);
            var airPriceFinal = airPriceAlgo(factoryPrice , pweight , bcdRate , igstRate , swcRate , lenght , width , height , priceInfo)
            data.dropshipperPrice = dropshipper;
            data.finalAirPrice = airPriceFinal;
        break; 
        default: 
            
            var factoryPrice = factoryPrice;   
            var shopperMargin = (factoryPrice*15/100); 
            var beforeGstPrice = factoryPrice + shopperMargin;
            var getGstRate = (beforeGstPrice*12/100);
            var sellingPrice = (beforeGstPrice+getGstRate).toFixed(2);  
            var product_msrp = (sellingPrice*2.5).toFixed(2);
            var totalCOCGS = beforeGstPrice.toFixed(2);
            var airPrice = {'price' : Math.ceil(sellingPrice) , 'cogs': Math.ceil(totalCOCGS), 'priceWithoutGst' : Math.ceil(beforeGstPrice), 'mrp' : Math.ceil(product_msrp)} 
            var data = {'seaPrice' : airPrice , 'airPrice' : airPrice}
            var dropshipper = dropshipperPrice(factoryPrice , pweight , igstRate , priceInfo); 
            var airPriceFinal = airPriceAlgo(factoryPrice , pweight , bcdRate , igstRate , swcRate , lenght , width , height , priceInfo)
            data.dropshipperPrice = dropshipper;
            data.finalAirPrice = airPriceFinal;
    }
return data; 
}
function priceForDomestic(cogs , igstRate , productMargin , priceInfo = null){
    var retailerPriceWithoutGst = (parseFloat(cogs) + cogs*productMargin/100); 
    var gst = retailerPriceWithoutGst*igstRate/100; 
    var rateWithGst = (retailerPriceWithoutGst + gst).toFixed(2); 
    var customerShownPrice = (rateWithGst*1.55).toFixed(2); 
    var msrp = getMsrp(customerShownPrice);
    var airPrice = {}
    if(priceInfo == '1'){
    	airPrice = {
    		'factoryPrice' 		: cogs, 
    		'cogs'				: cogs,
    		'priceWithoutGst'	: retailerPriceWithoutGst.toFixed(2),
    		'gstImpact'			: gst.toFixed(2),
    		'gstImpactPer'		: igstRate.toFixed(2),
    		'price'				: rateWithGst,  
    		'markup'			: (cogs*productMargin/100).toFixed(2),
    		'markupPer'			: productMargin.toFixed(2), 
    		'cunsumerPrice'		: customerShownPrice,
    		'mrp'				: msrp.toFixed(2)
    	}
    }else{ 
    	airPrice = {'price' : Math.ceil(rateWithGst) , 'cogs': Math.ceil(cogs), 'priceWithoutGst' : Math.ceil(retailerPriceWithoutGst), 'mrp' : Math.ceil(customerShownPrice)};
    }
    var data = {'seaPrice' : airPrice , 'airPrice' : airPrice}       
    return data;
}

function chinaProductsCogs(factoryPrice , pweight , bcdRate , igstRate , swcRate , lenght , width , height , sfcProducts , priceInfo = null){
    /*var lenght = Number(lenght);
    var width = Number(width);
    var height = Number(height);
    var bcdRate = Number(bcdRate); 
    var swcRate = Number(swcRate);
    var igstRate = Number(igstRate);
    var CBM = (lenght*width*height)/948000; 
    var volumetricWeight = (lenght*width*height)/5000; 
    var volumetricWeightingram = volumetricWeight*1000; 
    var deadWeight = pweight;
    var finalWeight = (volumetricWeightingram > deadWeight) ? volumetricWeightingram : deadWeight; 
    finalWeight = finalWeight/1000;
    var seaCbmWithoutGst = 12000;
    var lastmile = 16;
    var sea = seaCbmWithoutGst*deadWeight/500000; 
    var finalLastMile = lastmile*finalWeight; 
    var warehouseCharge = 2;
    if(sfcProducts == 1){
        var factoryPrice = factoryPrice - factoryPrice*10/100; 
    }else{
        var factoryPrice = factoryPrice;
    } 
    var cnfPrice = factoryPrice + sea; 
    var factoryPrice20 = factoryPrice*20/100; 
    var insuranceCost = factoryPrice*0.005/100; 
    var cifPrice = insuranceCost + cnfPrice; 
    var cifActual = (insuranceCost + factoryPrice + sea);  
    var cifOnFob = (factoryPrice + insuranceCost + factoryPrice20); 
    var cifTakenDuty = cnfPrice + insuranceCost;  
    var duty = cifTakenDuty*bcdRate/100; 
    var SWC  = duty*swcRate/100;
    var cogs  = (cifActual + duty + SWC + warehouseCharge).toFixed(2);  
    return cogs;*/
    
    var STK_Shopperr_price 	= factoryPrice;
	var product_weight 		    = (pweight/1000)*1.81;
	var ppPrice 			= STK_Shopperr_price*12*1.22;
	var getDuty 				= (ppPrice*38/100);
	var getLandedCost 			= getDuty+ppPrice;
	var getFrieghtCost 		= (795*product_weight*1.18);
	var chaCost 				= 0;   
	var processingCost 		= 12; 
	var lastMileCost 			= 85;
	var getTotalCOCGS 			= getLandedCost+getFrieghtCost+chaCost+processingCost+lastMileCost;
	var profitAdd15Percent 	= (getTotalCOCGS*15/100)+getTotalCOCGS;
	var gstImpact 				= ((profitAdd15Percent-getTotalCOCGS)*18/100);
	var gst_price 				= profitAdd15Percent+gstImpact;
	
	var FourPercentAddInPrice 	= (gst_price*4)/100;
	var finalShopperrPrice 	= gst_price+FourPercentAddInPrice;
	var product_msrp 			= finalShopperrPrice*2.5;
	
	var GSTPrice = finalShopperrPrice.toFixed(2);
    var productPricemrp = product_msrp.toFixed(2);
    return totalCOCGS = getTotalCOCGS.toFixed(2);
}

function priceForCldfurnituresOld(factoryPrice , pweight , bcdRate , igstRate , swcRate , lenght , width , height , productMargin , priceInfo = null){
    var lenght = Number(lenght);
    var width = Number(width);
    var height = Number(height);
    var bcdRate = Number(bcdRate); 
    var swcRate = Number(swcRate);
    var igstRate = Number(igstRate);
    var productMargin = productMargin;
    var CBM = (lenght*width*height);  
    var seaCbmWithoutGst = 18500;
    var lastmile = 16;
    var sea = seaCbmWithoutGst*CBM;  
    var warehouseCharge = 500; 
    var factoryPrice = factoryPrice;  
    var cnfPrice = factoryPrice + sea; 
    var factoryPrice20 = factoryPrice*20/100; 
    var insuranceCost = factoryPrice*1.125/100;  
    var cifPrice = insuranceCost + cnfPrice;   
    var duty = cifPrice*bcdRate/100; 
    var SWC  = duty*swcRate/100;  
    var cogs = (cifPrice + duty + SWC + warehouseCharge).toFixed(2);  
    var priceToHubPartner = (Number(cogs) + Number(cogs)*11.11/100) 
    var priceToDistibutor = (Number(priceToHubPartner) + Number(priceToHubPartner)*4.168/100) 
    var retailerPriceWithoutGst = (priceToDistibutor + priceToDistibutor*11.111/100);  
    var customerShownPrice = (retailerPriceWithoutGst + retailerPriceWithoutGst*33.336/100).toFixed(2); 
    var gst = retailerPriceWithoutGst*igstRate/100;  
    var retailerPriceWithGst = retailerPriceWithoutGst + gst; 
    var rateWithGst = retailerPriceWithGst.toFixed(2);  
    var msrp = getMsrp(rateWithGst);
    var airPrice = {} 
    if(priceInfo == '1'){
        airPrice = {
            'factoryPrice'      : factoryPrice.toFixed(2),
            'duty'              : duty.toFixed(2), 
            'weight'            : pweight.toFixed(2),  
            'lastMile'          : lastmile.toFixed(2),
            'cogs'              : cogs,
            'priceWithoutGst'   : retailerPriceWithoutGst.toFixed(2),
            'gstImpact'         : gst.toFixed(2),
            'gstImpactPer'      : igstRate.toFixed(2),
            'price'             : rateWithGst, 
            'cnfPrice'          : cnfPrice.toFixed(2),
            'SWC'               : SWC.toFixed(2),
            'markup'            : (cogs*productMargin/100).toFixed(2),
            'markupPer'         : productMargin.toFixed(2), 
            'cunsumerPrice'     : customerShownPrice,
            'mrp'               : msrp.toFixed(2)
        }
    }else{ 
        airPrice = {'price' : Math.ceil(rateWithGst) , 'cogs': Math.ceil(cogs), 'priceWithoutGst' : Math.ceil(retailerPriceWithoutGst), 'mrp' : Math.ceil(customerShownPrice)};
    }
    var data = {'seaPrice' : airPrice , 'airPrice' : airPrice}  
    return data;
}
 
 
function priceForCldfurnitures(factoryPrice , pweight , bcdRate , igstRate , swcRate , lenght , width , height , productMargin , priceInfo = null){
    var lenght          = Number(lenght);
    var width           = Number(width);
    var height          = Number(height);
    var bcdRate         = Number(bcdRate); 
    var swcRate         = Number(swcRate); 
    var igstRate        = Number(igstRate);
    var productMargin   = productMargin;
    var CBM             = (lenght*width*height);
    
    if(CBM > 5){
        CBM = CBM/1000000;
    }
    
    var seaCbmWithoutGst    = 16170;
    var lastmile        = 0;
    var sea             = seaCbmWithoutGst*CBM;   
    var warehouseCharge = 0; 
    var factoryPrice    = factoryPrice; 
    var cnfPrice        = factoryPrice + sea; 
    var factoryPrice20  = factoryPrice*20/100; 
    var insuranceCost   = factoryPrice*1.125/100; 
    var cifPrice        = insuranceCost + cnfPrice; 
    var duty            = cifPrice*bcdRate/100; 
    var SWC             = duty*swcRate/100;  
    var cogs            = (cifPrice + duty + SWC + warehouseCharge).toFixed(2); 
    var retailerPriceWithoutGst = (parseFloat(cogs) + cogs*productMargin/100);
    var gst = retailerPriceWithoutGst*igstRate/100;  
    var rateWithGst         = (retailerPriceWithoutGst + gst).toFixed(2);  
    var customerShownPrice  = (rateWithGst*1.33).toFixed(2);  
    var msrp    = getMsrp(customerShownPrice);
    var airPrice = {}
    if(priceInfo == '1'){
        airPrice = {
            'factoryPrice'      : factoryPrice.toFixed(2),
            'duty'              : duty.toFixed(2), 
            'weight'            : pweight.toFixed(2),  
            'lastMile'          : lastmile.toFixed(2),
            'cogs'              : cogs,
            'priceWithoutGst'   : retailerPriceWithoutGst.toFixed(2),
            'gstImpact'         : gst.toFixed(2),
            'gstImpactPer'      : igstRate.toFixed(2),
            'price'             : rateWithGst, 
            'cnfPrice'          : cnfPrice.toFixed(2),
            'SWC'               : SWC.toFixed(2),
            'markup'            : (cogs*productMargin/100).toFixed(2),
            'markupPer'         : productMargin.toFixed(2), 
            'cunsumerPrice'     : customerShownPrice,
            'mrp'               : msrp.toFixed(2)
        }
    }else{ 
        airPrice = {'price' : Math.ceil(rateWithGst) , 'cogs': Math.ceil(cogs), 'priceWithoutGst' : Math.ceil(retailerPriceWithoutGst), 'mrp' : Math.ceil(customerShownPrice)};
    }
    var data = {'seaPrice' : airPrice , 'airPrice' : airPrice}  
    return data;
}

function chinaProductsPriceData(factoryPrice , pweight , bcdRate , igstRate , swcRate , lenght , width , height , sfcProducts , productMargin, priceInfo = null){
    var lenght = Number(lenght);
    var width = Number(width);
    var height = Number(height);
    var bcdRate = Number(bcdRate); 
    var swcRate = Number(swcRate);
    var igstRate = Number(igstRate);
    var CBM = (lenght*width*height)/948000; 
    var volumetricWeight = (lenght*width*height)/5000; 
    var volumetricWeightingram = volumetricWeight*1000; 
    var deadWeight = pweight;
    var finalWeight = (volumetricWeightingram > deadWeight) ? volumetricWeightingram : deadWeight; 
    finalWeight = finalWeight/1000;
    var seaCbmWithoutGst = 12000;
    var lastmile = 16;
    var sea = seaCbmWithoutGst*deadWeight/500000; 
    var finalLastMile = lastmile*finalWeight; 
    var warehouseCharge = 2;
    if(sfcProducts == 1){
        var factoryPrice = factoryPrice - factoryPrice*10/100; 
    }else{
        var factoryPrice = factoryPrice;
    } 
    var cnfPrice = factoryPrice + sea; 
    var factoryPrice20 = factoryPrice*20/100; 
    var insuranceCost = factoryPrice*0.005/100; 
    var cifPrice = insuranceCost + cnfPrice; 
    var cifActual = (insuranceCost + factoryPrice + sea);  
    var cifOnFob = (factoryPrice + insuranceCost + factoryPrice20); 
    var cifTakenDuty = cnfPrice + insuranceCost;  
    var duty = cifTakenDuty*bcdRate/100; 
    var SWC  = duty*swcRate/100;
    var cogs  = (cifActual + duty + SWC + warehouseCharge).toFixed(2); 
    var retailerPriceWithoutGst = (parseFloat(cogs) + cogs*productMargin/100); 
    var gst = retailerPriceWithoutGst*igstRate/100;  
    var rateWithGst = (retailerPriceWithoutGst + gst).toFixed(2);  
    var customerShownPrice = (rateWithGst*1.55).toFixed(2);   
    var msrp = getMsrp(customerShownPrice); 
	var seaPrice = {
		'factoryPrice' 		: factoryPrice.toFixed(2),
		'duty'				: duty.toFixed(2), 
		'weight'			: pweight.toFixed(2),  
		'lastMile'			: lastmile.toFixed(2),
		'cogs'				: cogs,
		'priceWithoutGst'	: retailerPriceWithoutGst.toFixed(2),
		'gstImpact'			: gst.toFixed(2),
		'gstImpactPer'		: igstRate.toFixed(2),
		'price'				: rateWithGst, 
		'cnfPrice'			: cnfPrice.toFixed(2),
		'SWC'				: SWC.toFixed(2),
		'markup'			: (cogs*productMargin/100).toFixed(2),
		'markupPer'			: productMargin.toFixed(2), 
		'cunsumerPrice'		: customerShownPrice,
		'mrp'				: msrp.toFixed(2) 
	} 
	var data = {'seaPrice' : seaPrice , 'airPrice' : seaPrice}       
    return data; 
}
function priceForChina(cogs , igstRate , productMargin ,  priceInfo = null){ 
    var retailerPriceWithoutGst = (parseFloat(cogs) + cogs*productMargin/100); 
    var gst = retailerPriceWithoutGst*igstRate/100;  
    var rateWithGst = (retailerPriceWithoutGst + gst).toFixed(2);  
    var customerShownPrice = (rateWithGst*1.55).toFixed(2);   
    var msrp = getMsrp(customerShownPrice);
    var airPrice = {'price' : Math.ceil(rateWithGst) , 'cogs': Math.ceil(cogs), 'priceWithoutGst' : Math.ceil(retailerPriceWithoutGst), 'mrp' : Math.ceil(customerShownPrice)};
   	var data = {'seaPrice' : airPrice , 'airPrice' : airPrice}       
    return data;
}

function seaPriceAlgo(factoryPrice , pweight , bcdRate , igstRate , swcRate){
    var STK_factory_price = factoryPrice;  //120
    var insuranceCost = STK_factory_price*1.125/100; 
    var product_weight = pweight/1000; // .005  
    var frieghtCostUsingWeight = (34.12*product_weight);  
    var percentageFrieghtCost = (STK_factory_price*20/100);  
    var cifValueOnWeight = STK_factory_price + insuranceCost + frieghtCostUsingWeight;  
    var percentageCifValue = STK_factory_price + insuranceCost + percentageFrieghtCost;  
    var assessableValue = (cifValueOnWeight < percentageCifValue) ? cifValueOnWeight : percentageCifValue; 
    var bcdRate = bcdRate; 
    var swcRate = swcRate; 
    var igstRate = igstRate; 
    var chaCost = 12;
    var getBcdRate = assessableValue*bcdRate/100; 
    var getSwcRate = (getBcdRate*swcRate/100); 
    var beforeGstPrice = (assessableValue + getBcdRate + getSwcRate + chaCost); 
    var getGstRate = (beforeGstPrice*igstRate/100);
    var getLandedCost = beforeGstPrice + getGstRate; 
    var warehouseCharge = 2;
    var lastMileDeliveryRate = 16;
    var lastMileShiprocket = lastMileDeliveryRate*product_weight; 
    var cogs = (getLandedCost+warehouseCharge+lastMileShiprocket); 
    var shopperMargin = (cogs*35/100); 
    var priceAfterMarkup = cogs+shopperMargin; 
    var gstImpact = (shopperMargin*18/100); 
    var sellingPrice = Math.Math.ceil(priceAfterMarkup+gstImpact); 
    var product_msrp = Math.Math.ceil(sellingPrice*2.5).toFixed(2);
    var totalCOCGS = cogs.toFixed(2);
    var data = {'price' : sellingPrice , 'cogs': totalCOCGS, 'mrp' : product_msrp}  
    return data;
}

function getMsrp(mrp){
    return mrp;
}

function airPriceAlgo(factoryPrice , pweight , bcdRate , igstRate , swcRate , lenght , width , height, priceInfo = null){
    var lenght = Number(lenght);
    var width = Number(width);
    var height = Number(height);
    var bcdRate = Number(bcdRate); 
    var swcRate = Number(swcRate);
    var igstRate = Number(igstRate);
    var productMargin = 15;  
    var warehouseCharge = 2;  
    var airfrienstCost = 795; 
    var lastmile = 16;
    var factory_price = factoryPrice;  
    var factoryPriceInDoller = factory_price/75; 
    var product_weight = pweight/1000; // .005  
    var volumetricWeight = (lenght*width*height)/5000; 
    var volumetricWeightingram = volumetricWeight*1000; 
    var deadWeight = pweight;
    var finalWeightInGram = deadWeight  
    var finalWeightInKg = finalWeightInGram/1000; 
    var finalWeight = finalWeightInKg*1.5;
    var finalWeightingm = finalWeightInKg*1.5*1000; 
    var airFriest = airfrienstCost*finalWeight; 
    var lastMileCast = lastmile*finalWeight; 
    var cnfPrice = factory_price+airFriest; 
    var factoryPrice20 = factoryPrice*20/100; 
    var insuranceCost = factoryPrice*0.005/100; 
    var cifPrice = insuranceCost + cnfPrice;  
    var cifOnFob = (factoryPrice + insuranceCost + factoryPrice20); 
    var cifTakenDuty = cnfPrice + insuranceCost;  
    var duty = cifTakenDuty*bcdRate/100; 
    var SWC  = duty*swcRate/100;  
    var cogs = (cnfPrice + duty + SWC + warehouseCharge).toFixed(2); 
    var retailerPriceWithoutGst = (parseFloat(cogs) + cogs*productMargin/100); 
    var gst = retailerPriceWithoutGst*igstRate/100;  
    var rateWithGst = (retailerPriceWithoutGst + gst).toFixed(2); 
    var customerShownPrice = (rateWithGst*1.55).toFixed(2);  
    var mrp = (customerShownPrice*2).toFixed(2); 
    var finalAirPrice = {}
    if(priceInfo == '1'){
    	finalAirPrice = {
    		'factoryPrice' 		: factoryPrice.toFixed(2),
    		'duty'				: duty.toFixed(2), 
    		'weight'			: finalWeightingm.toFixed(2),
    		'frieghtCost' 		: airFriest.toFixed(2),  
    		'lastMile'			: lastmile.toFixed(2),
    		'cogs'				: cogs,
    		'priceWithoutGst'	: retailerPriceWithoutGst.toFixed(2),
    		'gstImpact'			: gst.toFixed(2),
    		'gstImpactPer'		: igstRate.toFixed(2),
    		'price'				: rateWithGst, 
    		'cnfPrice'			: cnfPrice.toFixed(2),
    		'SWC'				: SWC.toFixed(2),
    		'markup'			: (cogs*productMargin/100).toFixed(2),
    		'markupPer'			: productMargin.toFixed(2), 
    		'cunsumerPrice'		: mrp,
    		'mrp'				: (getMsrp(mrp)).toFixed(2)
    	}
    }else{ 
    	finalAirPrice = {'price' : Math.ceil(rateWithGst) , 'cogs': Math.ceil(cogs), 'priceWithoutGst' : Math.ceil(retailerPriceWithoutGst), 'mrp' : Math.ceil(customerShownPrice) , 'msrp' : mrp}; 
    }
    return finalAirPrice;
}

function dropshipperPrice(exfactory , weight , igst , priceInfo = null){
    /*let exfactoryPrice  = exfactory
    let dutyWithGst     = (exfactoryPrice*38/100) 
    let landedCost      = (exfactoryPrice+dutyWithGst) 
    let productWeightInKg   = (weight/1000)*1.81
    let frieghtCost = 795*productWeightInKg*1.18 
    let chaCost = 0
    let processingCost = 12
    let lastMile = 85
    let gstImpactRate = 18
    let markupRate = 15
    let cogs = landedCost + frieghtCost + chaCost + processingCost + lastMile 
    let markup = cogs*markupRate/100 
    let markupOnCogs = cogs + markup 
    let gstImpact = (markupOnCogs-cogs)*gstImpactRate/100 
    let gstPrice = (markupOnCogs + gstImpact) 
    let markupOnPrice = (gstPrice*4)/100
    let finalPrice = gstPrice + markupOnPrice
    let priceWithoutGst = (Math.ceil(finalPrice)*100)/(100+igst)  
    let msrp = gstPrice*2.5*/
    let markupRate = 15;
    let markup = cogs*markupRate/100 ;
    var STK_Shopperr_price 	= exfactory;
	var product_weight 		    = (weight/1000)*1.81;
	var ppPrice 			= STK_Shopperr_price*12*1.22;
	var getDuty 				= (ppPrice*38/100);
	var getLandedCost 			= getDuty+ppPrice;
	var getFrieghtCost 		= (795*product_weight*1.18);
	var chaCost 				= 0;   
	var processingCost 		= 12; 
	var lastMileCost 			= 85;
	var getTotalCOCGS 			= getLandedCost+getFrieghtCost+chaCost+processingCost+lastMileCost;
	var profitAdd15Percent 	= (getTotalCOCGS*15/100)+getTotalCOCGS;
	var gstImpact 				= ((profitAdd15Percent-getTotalCOCGS)*18/100);
	var gst_price				= profitAdd15Percent+gstImpact;
	var FourPercentAddInPrice 	= ((gst_price * 4)/100);
	var finalShopperrPrice 	= gst_price+FourPercentAddInPrice;
	var product_msrp 			= finalShopperrPrice*2.5;
	var onehalfprice = finalShopperrPrice*1.5; 
	
	var finalPrice = onehalfprice.toFixed(2);
	let priceWithoutGst = (Math.ceil(finalPrice)*100)/(100+igst);
    var msrp = product_msrp.toFixed(2);
    var cogs = getTotalCOCGS.toFixed(2);   
    //console.log(finalPrice+"---------------------"+exfactory);return false;
    let dropShipPrice = {};
    
    if(priceInfo == '1'){
        dropShipPrice = {
            'factoryPrice'      : exfactory.toFixed(2),
            'duty'              : getDuty.toFixed(2),
            'landedCost'        : getLandedCost.toFixed(2),
            'weight'            : weight.toFixed(2),
            'frieghtCost'       : getFrieghtCost.toFixed(2),
            'chaCost'           : chaCost.toFixed(2),
            'processingCost'    : processingCost.toFixed(2),
            'lastMile'          : lastMileCost.toFixed(2),
            'cogs'              : cogs,
            'priceWithoutGst'   : priceWithoutGst.toFixed(2),
            'gstImpact'         : gstImpact.toFixed(2), 
            'gstImpactPer'      : gst_price.toFixed(2),
            'price'             : finalPrice.toFixed(2),
            'cunsumerPrice'     : msrp.toFixed(2),
            'mrp'               : (getMsrp(msrp)).toFixed(2),
            'markup'            : markup.toFixed(2),
            'markupPer'         : markupRate.toFixed(2)
        }
    }else{ 
		//console.log("---------------------"+Math.ceil(finalPrice));return false;
        dropShipPrice = {'price' : Math.ceil(finalPrice) , 'cogs': Math.ceil(cogs), 'priceWithoutGst' : Math.ceil(priceWithoutGst), 'mrp' : Math.ceil(msrp)};
    } 
    //console.log(dropShipPrice);return false;
    return dropShipPrice;
}

function dropshipperPriceOld(exfactory , weight , igst , priceInfo = null){
    let exfactoryPrice  = exfactory
    let dutyWithGst     = (exfactoryPrice*38/100)
    let landedCost      = (exfactoryPrice+dutyWithGst)
    let productWeightInKg   = (weight/1000)*1.81
    let frieghtCost = 600*productWeightInKg*1.18
    let chaCost = 0
    let processingCost = 12
    let lastMile = 65
    let gstImpactRate = 18
    let markupRate = 15
    let cogs = landedCost + frieghtCost + chaCost + processingCost + lastMile
    let markup = cogs*markupRate/100
    let markupOnCogs = cogs + markup
    let gstImpact = (markupOnCogs-cogs)*gstImpactRate/100
    let gstPrice = (markupOnCogs + gstImpact)
    let finalPrice = gstPrice + (gstPrice*4/100)
    let priceWithoutGst = (Math.ceil(gstPrice)*100)/(100+igst) 
    let msrp = gstPrice*2.5
    let dropShipPrice = {}
    if(priceInfo == '1'){
      dropShipPrice = {
        'factoryPrice'    : exfactory.toFixed(2),
        'duty'        : dutyWithGst.toFixed(2),
        'landedCost'    : landedCost.toFixed(2),
        'weight'      : weight.toFixed(2),
        'frieghtCost'     : frieghtCost.toFixed(2),
        'chaCost'     : chaCost.toFixed(2),
        'processingCost'  : processingCost.toFixed(2),
        'lastMile'      : lastMile.toFixed(2),
        'cogs'        : cogs,
        'priceWithoutGst' : priceWithoutGst.toFixed(2),
        'gstImpact'     : gstImpact.toFixed(2), 
        'gstImpactPer'    : gstImpactRate.toFixed(2),
        'price'       : finalPrice.toFixed(2),
        'cunsumerPrice'   : msrp.toFixed(2),
        'mrp'       : (getMsrp(msrp)).toFixed(2),
        'markup'      : markup.toFixed(2),
        'markupPer'     : markupRate.toFixed(2)
      }
    }else{ 
      dropShipPrice = {'price' : Math.ceil(finalPrice) , 'cogs': Math.ceil(cogs), 'priceWithoutGst' : Math.ceil(priceWithoutGst), 'mrp' : Math.ceil(msrp)}
    } 
    return dropShipPrice
}

function dropshipperPriceOld(exfactory , weight , igst , priceInfo = null){
    let exfactoryPrice  = exfactory
    let dutyWithGst     = (exfactoryPrice*36/100)
    let landedCost      = (exfactoryPrice+dutyWithGst)
    let productWeightInKg   = (weight/1000)*1.5
    let frieghtCost = 795*productWeightInKg*1.18
    let chaCost = 12
    let processingCost = 12
    let lastMile = 71
    let gstImpactRate = 18
    let markupRate = 15
    let cogs = landedCost + frieghtCost + chaCost + processingCost + lastMile
    let markup = cogs*markupRate/100
    let markupOnCogs = cogs + markup
    let gstImpact = (markupOnCogs-cogs)*gstImpactRate/100
    let gstPrice = (markupOnCogs + gstImpact)
    let priceWithoutGst = (Math.ceil(gstPrice)*100)/(100+igst) 
    let msrp = gstPrice*2.5
    let dropShipPrice = {}
    if(priceInfo == '1'){
    	dropShipPrice = {
    		'factoryPrice' 		: exfactory.toFixed(2),
    		'duty'				: dutyWithGst.toFixed(2),
    		'landedCost'		: landedCost.toFixed(2),
    		'weight'			: weight.toFixed(2),
    		'frieghtCost' 		: frieghtCost.toFixed(2),
    		'chaCost'			: chaCost.toFixed(2),
    		'processingCost' 	: processingCost.toFixed(2),
    		'lastMile'			: lastMile.toFixed(2),
    		'cogs'				: cogs,
    		'priceWithoutGst'	: priceWithoutGst.toFixed(2),
    		'gstImpact'			: gstImpact.toFixed(2), 
    		'gstImpactPer'		: gstImpactRate.toFixed(2),
    		'price'				: gstPrice.toFixed(2),
    		'cunsumerPrice'		: msrp.toFixed(2),
    		'mrp'				: (getMsrp(msrp)).toFixed(2),
    		'markup'			: markup.toFixed(2),
    		'markupPer'			: markupRate.toFixed(2)
    	}
    }else{ 
    	dropShipPrice = {'price' : Math.ceil(gstPrice) , 'cogs': Math.ceil(cogs), 'priceWithoutGst' : Math.ceil(priceWithoutGst), 'mrp' : Math.ceil(msrp)}
    } 
    return dropShipPrice
}

function getGlobalPrice(factoryPrice){    
    // let sea = 12000*Number(pweight)/500000; 
    // factoryPrice = Number(factoryPrice)*1.1;

    // let insuranceCost = factoryPrice*0.005/100; 
    // let cifActual = (insuranceCost + factoryPrice + sea);  
    // let cifTakenDuty = (factoryPrice + /* cnfPrice */ sea /* cnfPrice */) + insuranceCost;  
    // let duty = cifTakenDuty*Number(bcdRate)/100; 
    // let cogs  = (cifActual + duty + /* SWC */ (duty*Number(swcRate)/100) /* SWC */ + 2 /* warehouseCharge */).toFixed(2);  

    // let retailerPriceWithoutGst = (parseFloat(cogs) + cogs*productMargin/100); 
    // let gst = retailerPriceWithoutGst*Number(igstRate)/100;  
    // let customerShownPrice = ((retailerPriceWithoutGst + gst)*1.55).toFixed(2);   
    // return {
    //     duty,
    //     gst,
    //     msrp:getMsrp(customerShownPrice),
    //     price:factoryPrice
    // }
    return Number(factoryPrice)*1.2;
}

function getGlobalPriceD({fp,pw,bcd,swc,pmargin,igst}){    
    let sea = 12000*Number(pw)/500000; 
    fp = getGlobalPrice(fp);

    let insuranceCost = fp*0.005/100; 
    let cifActual = (insuranceCost + fp + sea);  
    let duty = getGlobalDuty({fp,pw,bcd}); 
    let cogs  = (cifActual + duty + /* SWC */ (duty*Number(swc)/100) /* SWC */ + 2 /* warehouseCharge */).toFixed(2);  

    let retailerPriceWithoutGst = (parseFloat(cogs) + cogs*pmargin/100); 
    let gst = retailerPriceWithoutGst*Number(igst)/100;  
    let customerShownPrice = ((retailerPriceWithoutGst + gst)*1.55).toFixed(2);   
    return {
        duty,
        gst,
        msrp:getMsrp(customerShownPrice),
        price:fp
    }
}

function getGlobalShipping({fp, pw}){    
    //fp  =  Number(fp) || 0;
    return {
        air:(pw*1.5*680)/1000,
        sea:(pw*1.5*12000)/500000,
    };

}

function getGlobalDuty({fp,pw,bcd}){    
    let sea = 12000*Number(pw)/500000; 
    fp = getGlobalPrice(fp);
    let cifTakenDuty = fp + (/* cnfPrice */ sea /* cnfPrice */) + (fp*0.005/100 /* insuranceCost */ );  
    return cifTakenDuty*Number(bcd)/100;   
}

module.exports = { updateShopperrPriceAlgo, getMsrp, seaPriceAlgo,getGlobalPrice,getGlobalPriceD,getGlobalShipping};

