Your IP : 216.73.216.86


Current Path : /var/www/homesaver/www/bitrix/modules/fermaofd.ferma/classes/general/
Upload File :
Current File : /var/www/homesaver/www/bitrix/modules/fermaofd.ferma/classes/general/CVatCollection.php

<?php

IncludeModuleLangFile(__DIR__ . '/../index.php');

CVatCollection::$collection = array(
    array(
        'rate' => '0.00',
        'name' => GetMessage('FERMAOFD_VAT_NO'),
        'code' => 'VatNo',
    ), array(
        'rate' => '0.00',
        'name' => GetMessage('FERMAOFD_VAT_0'),
        'code' => 'Vat0',
    ), array(
        'rate' => '10.00',
        'name' => GetMessage('FERMAOFD_VAT_10'),
        'code' => 'Vat10',
    ), array(
        'rate' => '20.00',
        'name' => GetMessage('FERMAOFD_VAT_20'),
        'code' => 'Vat20',
    ), array(
        'rate' => '11.00',
        'name' => GetMessage('FERMAOFD_VAT_CALCULATED_10110'),
        'code' => 'CalculatedVat10110',
    ), array(
        'rate' => '24.00',
        'name' => GetMessage('FERMAOFD_VAT_CALCULATED_20120'),
        'code' => 'CalculatedVat20120',
    ),
);

class CVatCollection
{
    public static $collection;

    /**
     * @param array $vat
     * @return null|string
     */
    public static function determinateVat($vat)
    {
        $rates = array_filter(static::$collection, function ($item) use ($vat) {
            if ($vat['RATE'] === '0.00') {
                // ��� ��� ��� ��� 0%
                return $item['name'] === $vat['NAME'];
            }

            // ������� ������� ���
            return $item['rate'] === $vat['RATE'];
        });

        if (empty($rates)) {
            return null;
        }

        $rate = array_shift($rates);

        return $rate['code'];
    }
}