|
|
@@ -1,12 +1,20 @@ |
|
|
|
|
|
|
|
export class SovPrices { |
|
|
|
|
|
|
|
static getPrice(priceWithTax, taxRate) { |
|
|
|
return parseFloat(parseFloat(priceWithTax) / ((taxRate/100) + 1)).toFixed(4); |
|
|
|
static getPrice(priceWithTax, taxRate,round) { |
|
|
|
let price = parseFloat(parseFloat(priceWithTax) / ((taxRate/100) + 1)); |
|
|
|
if(round ==false){ |
|
|
|
return price; |
|
|
|
} |
|
|
|
return price.toFixed(4); |
|
|
|
} |
|
|
|
|
|
|
|
static getPriceWithTax(priceWithoutTax, taxRate) { |
|
|
|
return parseFloat(parseFloat(priceWithoutTax) * ((taxRate/100) + 1)).toFixed(4); |
|
|
|
static getPriceWithTax(priceWithoutTax, taxRate, round) { |
|
|
|
let priceWithTax = parseFloat(parseFloat(priceWithoutTax) * ((taxRate/100) + 1)); |
|
|
|
if(round ==false){ |
|
|
|
return priceWithTax; |
|
|
|
} |
|
|
|
return priceWithTax.toFixed(2); |
|
|
|
} |
|
|
|
|
|
|
|
static getMargin(price, buyingPrice){ |
|
|
@@ -17,18 +25,26 @@ export class SovPrices { |
|
|
|
return parseFloat(((price - buyingPrice) / price) * 100).toFixed(2); |
|
|
|
} |
|
|
|
|
|
|
|
static applyReductionPercent(price, percentage) |
|
|
|
static applyReductionPercent(price, percentage, round) |
|
|
|
{ |
|
|
|
return this.applyPercent(price, -percentage); |
|
|
|
return this.applyPercent(price, -percentage,round); |
|
|
|
} |
|
|
|
|
|
|
|
static applyReductionAmount(price, amount) |
|
|
|
static applyReductionAmount(price, amount, round) |
|
|
|
{ |
|
|
|
return parseFloat(price - amount).toFixed(4); |
|
|
|
let priceWithReduction = parseFloat(price - amount); |
|
|
|
if(round ==false){ |
|
|
|
return priceWithReduction; |
|
|
|
} |
|
|
|
return priceWithReduction.toFixed(2); |
|
|
|
} |
|
|
|
|
|
|
|
static applyPercent(price, percentage) |
|
|
|
static applyPercent(price, percentage, round) |
|
|
|
{ |
|
|
|
return parseFloat(price * (percentage / 100 + 1)).toFixed(4); |
|
|
|
let priceWithReduction = parseFloat(price * (percentage / 100 + 1)); |
|
|
|
if(round ==false){ |
|
|
|
return priceWithReduction; |
|
|
|
} |
|
|
|
return priceWithReduction.toFixed(2); |
|
|
|
} |
|
|
|
} |