Корректировка получения НДС товаров в каталоге
This commit is contained in:
parent
f87c07e2e1
commit
a012f48a20
@ -1,3 +1,6 @@
|
||||
## 2022-08-22 v.6.1.5
|
||||
- Корректировка получения НДС товаров в каталоге
|
||||
|
||||
## 2022-07-21 v.6.1.4
|
||||
- Исправление ошибки при записи товаров в HL блок лояльности
|
||||
|
||||
|
@ -1 +1 @@
|
||||
- Исправление ошибки при записи товаров в HL блок лояльности
|
||||
- Корректировка получения НДС товаров в каталоге
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$arModuleVersion = [
|
||||
'VERSION' => '6.1.4',
|
||||
'VERSION_DATE' => '2022-07-21 12:00:00'
|
||||
'VERSION' => '6.1.5',
|
||||
'VERSION_DATE' => '2022-08-22 11:00:00'
|
||||
];
|
||||
|
@ -57,6 +57,7 @@ class QueryParamsMolder
|
||||
'CATALOG_GROUP_' . $basePriceId,
|
||||
'ID',
|
||||
'LID',
|
||||
'VAT_ID',
|
||||
];
|
||||
|
||||
return $params;
|
||||
|
@ -6,6 +6,7 @@ use Bitrix\Highloadblock\HighloadBlockTable;
|
||||
use CCatalog;
|
||||
use CCatalogGroup;
|
||||
use CCatalogSku;
|
||||
use CCatalogVat;
|
||||
use CIBlock;
|
||||
use Intaro\RetailCrm\Service\Hl;
|
||||
use RetailcrmConfigProvider;
|
||||
@ -79,12 +80,17 @@ class SettingsService
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $setupProfileName = '';
|
||||
public $setupProfileName = '';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $priceTypes = [];
|
||||
public $priceTypes = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $vatRates = [];
|
||||
|
||||
/**
|
||||
* @var \Intaro\RetailCrm\Icml\SettingsService|null
|
||||
@ -110,6 +116,7 @@ class SettingsService
|
||||
= $this->getSingleSetting('SETUP_PROFILE_NAME') ?? GetMessage('PROFILE_NAME_EXAMPLE');
|
||||
|
||||
$this->getPriceTypes();
|
||||
$this->getVatRates();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,6 +143,15 @@ class SettingsService
|
||||
}
|
||||
}
|
||||
|
||||
public function getVatRates()
|
||||
{
|
||||
$dbVatRate = CCatalogVat::GetListEx(['SORT' => 'ASC'], ['ACTIVE' => 'Y'], false, false, ['ID', 'NAME', 'RATE']);
|
||||
|
||||
while ($arVatRate = $dbVatRate->Fetch()) {
|
||||
$this->vatRates[$arVatRate['ID']] = $arVatRate;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $selected
|
||||
* @param string $key
|
||||
|
@ -4,6 +4,7 @@ namespace Intaro\RetailCrm\Icml;
|
||||
|
||||
use Bitrix\Catalog\ProductTable;
|
||||
use Bitrix\Main\ArgumentException;
|
||||
use Intaro\RetailCrm\Component\ServiceLocator;
|
||||
use Intaro\RetailCrm\Icml\Utils\IcmlUtils;
|
||||
use Intaro\RetailCrm\Model\Bitrix\Orm\CatalogIblockInfo;
|
||||
use Intaro\RetailCrm\Model\Bitrix\Xml\OfferParam;
|
||||
@ -82,11 +83,17 @@ class XmlOfferBuilder
|
||||
* @var \Intaro\RetailCrm\Model\Bitrix\Xml\XmlOffer
|
||||
*/
|
||||
private $xmlOffer;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $categories;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $vatRates;
|
||||
|
||||
/**
|
||||
* IcmlDataManager constructor.
|
||||
*
|
||||
@ -100,6 +107,9 @@ class XmlOfferBuilder
|
||||
{
|
||||
$this->setup = $setup;
|
||||
$this->purchasePriceNull = RetailcrmConfigProvider::getCrmPurchasePrice();
|
||||
/** @var \Intaro\RetailCrm\Icml\SettingsService $settingsService */
|
||||
$settingsService = ServiceLocator::get(SettingsService::class);
|
||||
$this->vatRates = $settingsService->vatRates;
|
||||
$this->measures = $this->prepareMeasures($measure);
|
||||
$this->defaultServerName = $defaultServerName;
|
||||
}
|
||||
@ -240,7 +250,7 @@ class XmlOfferBuilder
|
||||
$this->xmlOffer->name = $item['NAME'];
|
||||
$this->xmlOffer->xmlId = $item['EXTERNAL_ID'] ?? '';
|
||||
$this->xmlOffer->productName = $item['NAME'];
|
||||
$this->xmlOffer->vatRate = $item['CATALOG_VAT'] ?? 'none';
|
||||
$this->xmlOffer->vatRate = $this->getVatRate($item);
|
||||
$this->xmlOffer->unitCode = $this->getUnitCode($item['CATALOG_MEASURE'], $item['ID']);
|
||||
}
|
||||
|
||||
@ -267,6 +277,25 @@ class XmlOfferBuilder
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает значение активной ставки НДС, если она указана в товаре
|
||||
*
|
||||
* @param array $product
|
||||
* @return string
|
||||
*/
|
||||
private function getVatRate(array $product): string
|
||||
{
|
||||
if (!empty($product['VAT_ID']) && array_key_exists($product['VAT_ID'], $this->vatRates)) {
|
||||
return $this->vatRates[$product['VAT_ID']]['RATE'];
|
||||
}
|
||||
|
||||
if (!empty($product['CATALOG_VAT_ID']) && array_key_exists($product['CATALOG_VAT_ID'], $this->vatRates)) {
|
||||
return $this->vatRates[$product['CATALOG_VAT_ID']]['RATE'];
|
||||
}
|
||||
|
||||
return 'none';
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает массив обычных свойств
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user