Browse Source

Correctif arrondi prix

develop
Fabien Normand 2 years ago
parent
commit
34af215b8c
1 changed files with 26 additions and 10 deletions
  1. +26
    -10
      Resources/assets/functions/prices.js

+ 26
- 10
Resources/assets/functions/prices.js View File

@@ -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);
}
}

Loading…
Cancel
Save