Parcourir la source

Correctif arrondi prix

develop
Fabien Normand il y a 2 ans
Parent
révision
34af215b8c
1 fichiers modifiés avec 26 ajouts et 10 suppressions
  1. +26
    -10
      Resources/assets/functions/prices.js

+ 26
- 10
Resources/assets/functions/prices.js Voir le fichier

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

Chargement…
Annuler
Enregistrer