Преглед изворни кода

Correctif arrondi prix

develop
Fabien Normand пре 2 година
родитељ
комит
34af215b8c
1 измењених фајлова са 26 додато и 10 уклоњено
  1. +26
    -10
      Resources/assets/functions/prices.js

+ 26
- 10
Resources/assets/functions/prices.js Прегледај датотеку

@@ -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…
Откажи
Сачувај