- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/tax.php
- Класс: BitrixSaleTax
- Вызов: Tax::checkModifyTaxList
protected function checkModifyTaxList(array $taxList)
{
$oldTaxList = $this->loadList();
$taxIndexList = array();
if (!empty($oldTaxList) && is_array($oldTaxList))
{
$oldTaxIndexList = array();
foreach ($oldTaxList as $taxOldKey => $taxOldValue)
{
$oldTaxIndexList[$taxOldValue['NAME']."|".$taxOldValue['CODE']] = $taxOldKey;
}
foreach ($taxList as $taxValue)
{
if (array_key_exists($taxValue['NAME']."|".$taxValue['CODE'], $oldTaxIndexList))
{
$taxIndexList[$taxValue['NAME']."|".$taxValue['CODE']] = $oldTaxIndexList[$taxValue['NAME']."|".$taxValue['CODE']];
}
}
}
if (!empty($taxList) && is_array($taxList))
{
foreach ($taxList as $taxKey => $taxValue)
{
$taxCode = $taxValue['NAME']."|".$taxValue['CODE'];
if (isset($taxIndexList[$taxCode]))
{
$oldTaxKey = $taxIndexList[$taxCode];
$oldTaxValueDat = $oldTaxList[$oldTaxKey];
foreach($taxValue as $key => $value)
{
if (array_key_exists($key, $oldTaxValueDat))
{
if ($oldTaxValueDat[$key] != $value)
{
$oldTaxList[$oldTaxKey][$key] = $value;
if (!in_array($taxCode, $this->changedValues))
{
$this->changedValues[$taxCode] = true;
}
}
}
else
{
$oldTaxList[$oldTaxKey][$key] = $value;
if (!in_array($taxCode, $this->changedValues))
{
$this->changedValues[$taxCode] = true;
}
}
}
}
else
{
$oldTaxList[] = array(
'NAME' => $taxValue['NAME'],
'IS_PERCENT' => $taxValue['IS_PERCENT'],
'VALUE' => $taxValue['VALUE'],
'VALUE_MONEY' => $taxValue['VALUE_MONEY'],
'APPLY_ORDER' => $taxValue['APPLY_ORDER'],
'IS_IN_PRICE' => $taxValue['IS_IN_PRICE'],
'TAX_VAL' => $taxValue['TAX_VAL'],
'CODE' => $taxValue['CODE'],
);
// if (!in_array($taxCode, $this->changedValues))
// {
// $this->changedValues[$taxCode] = true;
// }
}
}
// one tax to order
$taxListModify1C = array();
foreach($oldTaxList as $taxOrder)
{
if($taxOrder['CODE'] == 'VAT1C')
{
$taxListModify1C[] = $taxOrder;
}
}
if(count($taxListModify1C)>0)
{
$oldTaxList = $taxListModify1C;
}
}
else
{
$oldTaxList = array();
}
return $oldTaxList;
}