18 protected function convert(array $documents)
20 $documentOrder = $this->getDocumentByTypeId(DocumentType::ORDER, $documents);
25 $documentShipment = $this->getDocumentByTypeId(DocumentType::SHIPMENT, $documents);
26 if($documentShipment ==
null)
28 $fieldsOrder = $documentOrder->getFieldValues();
29 $items = $this->getProductsItems($fieldsOrder);
31 if($this->deliveryServiceExists($items))
33 $shipment[
'ID_1C'] = $documentOrder->getField(
'ID_1C');
34 $shipment[
'VERSION_1C'] = $documentOrder->getField(
'VERSION_1C');
35 $shipment[
'ITEMS'] = $items;
39 $documentShipment->setFields($shipment);
40 $documents[] = $documentShipment;
45 foreach($documents as $document)
49 $paymentFields = $document->getFieldValues();
50 $paymentFields[
'REK_VALUES'][
'PAY_SYSTEM_ID_DEFAULT'] = $this->
getDefaultPaySystem($documentOrder);
51 $document->setFields($paymentFields);
56 $shimpentFields = $document->getFieldValues();
58 $document->setFields($shimpentFields);
66 if($settingsShipment->canCreateOrder(static::getShipmentEntityTypeId())==
'Y')
68 $documentShipment = $this->getDocumentByTypeId(DocumentType::SHIPMENT, $documents);
69 if($documentShipment !==
null)
71 $order[
'ID_1C'] = $documentShipment->getField(
'ID_1C');
72 $order[
'VERSION_1C'] = $documentShipment->getField(
'VERSION_1C');
73 $order[
'AMOUNT'] = $documentShipment->getField(
'AMOUNT');
74 $order[
'ITEMS'] = $documentShipment->getField(
'ITEMS');
75 $order[
'TAXES'] = $documentShipment->getField(
'TAXES');
76 $order[
'AGENT'] = $documentShipment->getField(
'AGENT');
79 $documentOrder->setFields(
$order);
80 $documents[] = $documentOrder;
85 return parent::convert($documents);