Pārlūkot izejas kodu

Correctif prix

feature/symfony6.1
Guillaume pirms 2 gadiem
vecāks
revīzija
71092c7c84
1 mainītis faili ar 26 papildinājumiem un 10 dzēšanām
  1. +26
    -10
      Resources/assets/functions/prices.js

+ 26
- 10
Resources/assets/functions/prices.js Parādīt failu

@@ -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(2);
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(2);
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(2);
let priceWithReduction = parseFloat(price * (percentage / 100 + 1));
if(round ==false){
return priceWithReduction;
}
return priceWithReduction.toFixed(2);
}
}

Notiek ielāde…
Atcelt
Saglabāt