Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
utils.php
1<?php
2
3namespace Bitrix\Conversion;
4
5use CCurrencyLang;
7
8final class Utils
9{
10 public static function convertToBaseCurrency($value, $currency)
11 {
12 static $module, $baseCurrency;
13
14 if (! $module)
15 {
16 $module = Loader::includeModule('currency');
17 $baseCurrency = Config::getBaseCurrency();
18 }
19
20 if ($module && $currency != $baseCurrency)
21 {
22 $value = \CCurrencyRates::ConvertCurrency($value, $currency, $baseCurrency);
23 }
24
25 return $value;
26 }
27
28 public static function formatToBaseCurrency($value, $format = null)
29 {
30 static $module, $baseCurrency;
31
32 if (! $module)
33 {
34 $module = Loader::includeModule('currency');
35 $baseCurrency = Config::getBaseCurrency();
36 }
37
38 if ($module)
39 {
40 $value = \CCurrencyLang::CurrencyFormat($value, $baseCurrency);
41 }
42
43 return $value;
44 }
45
47 public static function getBaseCurrencyUnit() // TODO remove from sale
48 {
49 static $unit;
50
51 if (!$unit)
52 {
53 $unit = Config::getBaseCurrency();
54 if (Loader::includeModule('currency'))
55 {
56 $unit = trim(
57 CCurrencyLang::getPriceControl(' ', $unit)
58 );
59 }
60 }
61
62 return $unit;
63 }
64}
static getBaseCurrencyUnit()
Definition utils.php:47
static formatToBaseCurrency($value, $format=null)
Definition utils.php:28
static convertToBaseCurrency($value, $currency)
Definition utils.php:10