- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/exchange/importonecpackagecrm.php
- Класс: BitrixSaleExchangeImportOneCPackageCRM
- Вызов: ImportOneCPackageCRM::checkDocuments
protected function checkDocuments(array $documents)
{
$result = new Result();
if(!$this->hasDocumentByTypeId(ExchangeOneCDocumentType::ORDER, $documents))
{
$result->addError(new Error(GetMessage('CRM_PACKAGE_NOT_FOUND_ORDER'), 'CRM_PACKAGE_NOT_FOUND_ORDER'));
}
else
{
$documentOrder = $this->getDocumentByTypeId(ExchangeOneCDocumentType::ORDER, $documents);
if(!$this->hasDocumentByTypeId(ExchangeOneCDocumentType::PAYMENT_CASH, $documents) &&
!$this->hasDocumentByTypeId(ExchangeOneCDocumentType::PAYMENT_CASH_LESS, $documents) &&
!$this->hasDocumentByTypeId(ExchangeOneCDocumentType::PAYMENT_CARD_TRANSACTION, $documents))
{
$result->addError(new Error(GetMessage('CRM_PACKAGE_NOT_FOUND_PAYMENT', array('#XML_1C_DOCUMENT_ID#'=>$documentOrder->getExternalId())), 'CRM_PACKAGE_NOT_FOUND_PAYMENT'));
}
$countShipment = 0;
foreach ($documents as $document)
{
if($document->getTypeId() == ExchangeOneCDocumentType::SHIPMENT)
{
$countShipment++;
}
}
if($countShipment>=2)
{
$result->addError(new Error(GetMessage('CRM_PACKAGE_PARTIAL_SHIPMENT_NOT_SUPPORTED', array('#XML_1C_DOCUMENT_ID#'=>$documentOrder->getExternalId())), 'CRM_PACKAGE_NOT_FOUND_PAYMENT'));
}
}
return $result;
}