27 if(!$this->hasDocumentByTypeId(
Exchange\
OneC\DocumentType::ORDER, $documents))
33 $documentOrder = $this->getDocumentByTypeId(
Exchange\
OneC\DocumentType::ORDER, $documents);
35 if(!$this->hasDocumentByTypeId(
Exchange\
OneC\DocumentType::PAYMENT_CASH, $documents) &&
36 !$this->hasDocumentByTypeId(
Exchange\
OneC\DocumentType::PAYMENT_CASH_LESS, $documents) &&
37 !$this->hasDocumentByTypeId(
Exchange\
OneC\DocumentType::PAYMENT_CARD_TRANSACTION, $documents))
39 $result->addError(
new Error(
GetMessage(
'CRM_PACKAGE_NOT_FOUND_PAYMENT',
array(
'#XML_1C_DOCUMENT_ID#'=>$documentOrder->getExternalId())),
'CRM_PACKAGE_NOT_FOUND_PAYMENT'));
43 foreach ($documents as $document)
45 if($document->getTypeId() ==
Exchange\
OneC\DocumentType::SHIPMENT)
53 $result->addError(
new Error(
GetMessage(
'CRM_PACKAGE_PARTIAL_SHIPMENT_NOT_SUPPORTED',
array(
'#XML_1C_DOCUMENT_ID#'=>$documentOrder->getExternalId())),
'CRM_PACKAGE_NOT_FOUND_PAYMENT'));
72 $traits = $item->getField(
'TRAITS');
74 $invoice = new \CCrmInvoice(
false);
75 if (!$invoice->SetStatus($item->getId(), $traits[
'STATUS_ID']))
83 $result = parent::modifyEntity($item);
96 $isNew = !($orderImport->getId()>0);
102 if($orderImport->getId()>0)
104 InvoiceStatusHistoryEntry::register($orderImport->getId(),
null,
array(
'IS_NEW' => $isNew));
105 InvoiceSumStatisticEntry::register($orderImport->getId(),
null);
117 return ConverterFactory::create($typeId);
129 $documentShipment = $this->getDocumentByTypeId(
Exchange\
OneC\DocumentType::SHIPMENT, $documents);
131 if($documentShipment !==
null)
140 $documentShipment->getTypeId()
143 $fields = $convertor->resolveParams($documentShipment);
145 $shipmentPrice =
$fields[
'TRAITS'][
'BASE_PRICE_DELIVERY'];
149 $documentOrder = $this->getDocumentByTypeId(
Exchange\
OneC\DocumentType::ORDER, $documents);
150 $fieldsOrder = $documentOrder->getFieldValues();
151 $items = $this->getProductsItems($fieldsOrder);
153 if(!$this->deliveryServiceExists(
$items))
155 $fieldsOrder[
'ITEMS'][][self::DELIVERY_SERVICE_XMLID] =
array(
156 'ID' => self::DELIVERY_SERVICE_XMLID,
157 'NAME' =>
GetMessage(
'CRM_PACKAGE_DELIVERY_SERVICE_ITEM'),
158 'PRICE' => $shipmentPrice,
159 'PRICE_ONE' => $shipmentPrice,
162 'MEASURE_CODE' => 796,
163 'MEASURE_NAME' =>
GetMessage(
'CRM_PACKAGE_DELIVERY_SERVICE_ITEM_MEASURE_796'),
166 $documentOrder->setFields($fieldsOrder);
170 foreach ($documents as
$k=>$document)
172 if($document->getTypeId() == Exchange\OneC\DocumentType::SHIPMENT)
174 unset($documents[
$k]);
179 $result = parent::convert($documents);
185 $personTypes = \CCrmPaySystem::getPersonTypeIDs();
188 $entityItems =
$result->getData();
189 foreach ($entityItems as $entityItem)
194 $personTypeId = $entityItem->isFiz()? (int)$personTypes[
'CONTACT']:(int)$personTypes[
'COMPANY'];
201 $billList = \CCrmPaySystem::GetPaySystemsListItems($personTypeId);
202 foreach($billList as $billId => $billName)
204 $paySystemId = $billId;
212 foreach ($entityItems as $entityItem)
219 $traits = $entityItem->getFieldValues()[
'TRAITS'];
220 $traits[
'PAY_SYSTEM_ID'] = $paySystemId;
221 $entityItem->setField(
'TRAITS', $traits);
223 $list[] = $entityItem;
237 parent::configuration();
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)