1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
vatcalculator.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Sale\Tax;
4
5
use Bitrix\Sale\PriceMaths;
6
16
class
VatCalculator
17
{
18
private
float
$rate;
19
24
public
function
__construct
(
float
$rate)
25
{
26
$this->rate = $rate;
27
}
28
37
public
function
calc
(
float
$price,
bool
$isVatInPrice,
bool
$withRound =
true
): float
38
{
39
if
($this->rate === 0.0)
40
{
41
return
0.0;
42
}
43
elseif
($isVatInPrice)
44
{
45
$vat
= $price * $this->rate / ($this->rate + 1);
46
}
47
else
48
{
49
$vat
= $price * $this->rate;
50
}
51
52
return
$withRound ?
PriceMaths::roundPrecision
(
$vat
) :
$vat
;
53
}
54
63
public
function
allocate
(
float
$price,
bool
$withRound =
true
): float
64
{
65
if
($this->rate === 0.0)
66
{
67
return
$price;
68
}
69
70
$rate = $this->rate * 100;
71
$vat
= $price * $rate / ($rate + 100);
72
$priceWithoutVat = $price -
$vat
;
73
74
return
$withRound ?
PriceMaths::roundPrecision
($priceWithoutVat) : $priceWithoutVat;
75
}
76
85
public
function
accrue
(
float
$price,
bool
$withRound =
true
): float
86
{
87
$priceWithVat = $price * (1 + $this->rate);
88
89
return
$withRound ?
PriceMaths::roundPrecision
($priceWithVat) : $priceWithVat;
90
}
91
}
Bitrix\Sale\PriceMaths\roundPrecision
static roundPrecision($value)
Определения
pricemaths.php:16
Bitrix\Sale\Tax\VatCalculator
Определения
vatcalculator.php:17
Bitrix\Sale\Tax\VatCalculator\accrue
accrue(float $price, bool $withRound=true)
Определения
vatcalculator.php:85
Bitrix\Sale\Tax\VatCalculator\__construct
__construct(float $rate)
Определения
vatcalculator.php:24
Bitrix\Sale\Tax\VatCalculator\calc
calc(float $price, bool $isVatInPrice, bool $withRound=true)
Определения
vatcalculator.php:37
Bitrix\Sale\Tax\VatCalculator\allocate
allocate(float $price, bool $withRound=true)
Определения
vatcalculator.php:63
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$vat
$vat
Определения
template.php:273
bitrix
modules
sale
lib
tax
vatcalculator.php
Создано системой
1.14.0