Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
orderimport.php
1<?php
3
10use Bitrix\Main;
11
18{
19 private static $FIELD_INFOS = null;
20
21 public function __construct($parentEntityContext = null)
22 {
23 if($parentEntityContext instanceof Internals\Entity)
24 {
25 throw new Main\ArgumentException('The parentEntityContext is not supported in current context.');
26 }
27
28 parent::__construct(null);
29 }
30
34 public function getOwnerTypeId()
35 {
36 return EntityType::ORDER;
37 }
38
39 protected function createEntity(array $fileds)
40 {
41 $registry = Sale\Registry::getInstance(Sale\Registry::REGISTRY_TYPE_ORDER);
43 $orderClass = $registry->getOrderClassName();
44
45 return $orderClass::create($this->settings->getSiteId(), $fileds['USER_ID'], $this->settings->getCurrency());
46 }
51 public function setEntity(Internals\Entity $entity)
52 {
53 if(!($entity instanceof Order))
54 throw new Main\ArgumentException("Entity must be instanceof Order");
55
56 $this->entity = $entity;
57 }
58
63 protected function checkFields(array $fields)
64 {
65 return new Sale\Result();
66 }
67
71 public function save()
72 {
74 $entity = $this->getEntity();
75 return $entity->save();
76 }
77
78 public static function getFieldsInfo()
79 {
80 if(!static::$FIELD_INFOS)
81 {
82 static::$FIELD_INFOS = array(
83 "LID",
84 "PERSON_TYPE_ID",
85 "PAYED",
86 "CANCELED",
87 "STATUS_ID",
88 "PRICE",
89 "CURRENCY",
90 "COMMENTS"
91 );
92 }
93 return static::$FIELD_INFOS;
94 }
95
101 public function add(array $params)
102 {
103 $result = new Sale\Result();
104
105 $fields = $params['TRAITS'];
106 $basketItems = $params['ITEMS'];
107 $taxes = $params['TAXES'];
108
109 $userId = $fields['USER_ID'];
110 $personalTypeId = $fields['PERSON_TYPE_ID'];
111
112 $propertyFields = '';
113 if(isset($fields['ORDER_PROP']))
114 {
115 $propertyFields = $fields['ORDER_PROP'];
116 unset($fields['ORDER_PROP']);
117 }
118
119 if(empty($personalTypeId))
120 {
121 $result->addError(new Main\Error('Person type is not load'));
122 }
123
124 if(empty($userId))
125 {
126 $result->addError(new Main\Error('User id is not load'));
127 }
128 if(!$result->isSuccess())
129 {
130 return $result;
131 }
132
134 $entity = $this->createEntity(['USER_ID'=>$userId]);
135 $entity->setPersonTypeId($personalTypeId);
136
137 $result = $this->fillProperty($entity, $propertyFields);
138 if(!$result->isSuccess())
139 {
140 return $result;
141 }
142
143 $registry = Sale\Registry::getInstance($entity::getRegistryType());
144 $basketClassName = $registry->getBasketClassName();
145
146 $basket = $basketClassName::create($entity->getSiteId());
147
148 $result = $this->fillBasket($basket, $basketItems);
149 if($result->isSuccess())
150 {
151 $entity->setBasket($basket);
152 $items = $result->getData();
153 $this->fillTax($entity, $taxes, $items['modifyTaxList']);
154 }
155 else
156 {
157 return $result;
158 }
159
160 $entity->setFields($fields);
161
163 $result = $entity->doFinalAction(true);
164 if ($result->isSuccess())
165 {
166 $this->setEntity($entity);
167 }
168
169 return $result;
170 //static::transformationLocation($order);
171 }
172
177 public function update(array $params)
178 {
179 $result = new Sale\Result();
180
181 $criterion = $this->getCurrentCriterion($this->getEntity());
182
184 $order = $this->getEntity();
185
186 $fields = $params['TRAITS'];
187 $basketItems = $params['ITEMS'];
188 $taxes = $params['TAXES'];
189
190 $propertyFields = '';
191 if(isset($fields['ORDER_PROP']))
192 {
193 $propertyFields = $fields['ORDER_PROP'];
194 unset($fields['ORDER_PROP']);
195 }
196
197 if($criterion->equals($fields))
198 {
199 $result = $this->fillProperty($order, $propertyFields);
200 if(!$result->isSuccess())
201 {
202 return $result;
203 }
204
205 $basket = $order->getBasket();
206
207 $result = $this->fillBasket($basket, $basketItems);
208 if($result->isSuccess())
209 {
210 $items = $result->getData();
211 $this->fillTax($order, $taxes, $items['modifyTaxList']);
212 }
213 else
214 {
215 return $result;
216 }
217
218 $result = $order->doFinalAction(true);
219 if(!$result->isSuccess())
220 {
221 return $result;
222 }
223
224 foreach ($fields as $k =>$field)
225 {
226 if(!in_array($k, $order::getAvailableFields()))
227 unset($fields[$k]);
228 }
229
230 $result = $order->setFields($fields);
231 }
232
233 return $result;
234 }
235
240 public function delete(array $params = null)
241 {
242 return new Sale\Result();
243 }
244
248 protected function getExternalFieldName()
249 {
250 return 'EXTERNAL_ORDER';
251 }
252
257 public function load(array $fields)
258 {
259 $result = $this->checkFields($fields);
260
261 if($result->isSuccess())
262 {
263 if(!empty($fields['ID']))
264 {
265 $order = $this->loadParentEntity($fields);
266 }
267
269 if(!empty($order))
270 {
271 $this->setEntity($order);
272 }
273 else
274 {
275 $this->setExternal();
276 }
277 }
278
279 return $result;
280 }
281
285 public function markedEntityCollisions($collisions)
286 {
288 $entity = $this->getEntity();
289
290 foreach($collisions as $collision)
291 {
292 $entity->setField('MARKED', 'Y');
293
295 $result = new Sale\Result();
296 $result->addWarning(new Sale\ResultError(EntityCollisionType::getDescription($collision->getTypeId()).($collision->getMessage() != null ? " ".$collision->getMessage():'' ), $collision->getTypeName()));
297
298 $this->addMarker($entity, $entity, $result);
299 }
300 }
301
302 private static function prepareFieldsBasketProperty($item)
303 {
304 $result = array();
305
306 if(!empty($item['ATTRIBUTES']))
307 {
308 foreach($item['ATTRIBUTES'] as $id => $value)
309 {
310 $result[] = array(
311 'NAME' => $id,
312 'CODE' => $id,
313 'VALUE' => $value
314 );
315 }
316 }
317 return $result;
318 }
319
320 private function prepareFieldsBasketItem($productXML_ID, $item)
321 {
323 $settings = $this->getSettings();
324
325 $code = $this->getCodeAfterDelimiter($productXML_ID);
326 $product = $code<>'' ? static::getProduct($code):array();
327
328 if(empty($product))
329 $product = static::getProduct($productXML_ID);
330
331 if(!empty($product))
332 {
333 $result = array(
334 "PRODUCT_ID" => $product["ID"],
335 "NAME" => $product["NAME"],
336 "MODULE" => "catalog",
337 "PRODUCT_PROVIDER_CLASS" => '\Bitrix\Catalog\Product\CatalogProvider',
338 "CATALOG_XML_ID" => $product["IBLOCK_XML_ID"],
339 "DETAIL_PAGE_URL" => $product["DETAIL_PAGE_URL"],
340 "WEIGHT" => $product["WEIGHT"],
341 "NOTES" => $product["CATALOG_GROUP_NAME"]
342 );
343 }
344 else
345 {
346 $ri = new Main\Type\RandomSequence($productXML_ID);
347 $result = array(
348 "PRODUCT_ID" => $ri->rand(1000000, 9999999),
349 "NAME" => $item["NAME"],
350 "MODULE" => "1c_exchange",
351 "PRODUCT_PROVIDER_CLASS" => false,
352 "CATALOG_XML_ID" => "1c_exchange",
353 "DISCOUNT_PRICE" => $item['DISCOUNT']['PRICE'],
354 "MEASURE_CODE" => $item["MEASURE_CODE"],
355 "MEASURE_NAME" => $item["MEASURE_NAME"]
356 );
357 }
358
359 $result["CURRENCY"] = $settings->getCurrency();
360 $result["LID"] = $settings->getSiteId();
361 $result["QUANTITY"] = $item["QUANTITY"];
362 $result["DELAY"] = "N";
363 $result["CAN_BUY"] = "Y";
364 $result["IGNORE_CALLBACK_FUNC"] = "Y";
365 $result["PRODUCT_XML_ID"] = $productXML_ID;
366 $result["MARKING_CODE_GROUP"] = $item['MARKING_GROUP'];
367
368 return $result;
369 }
370
371
372 private function prepareFieldsTax($fields)
373 {
374 return array(
375 array(
376 "NAME" => $fields["NAME"],
377 "VALUE" => $fields["VALUE"],
378 "IS_PERCENT" => "Y",
379 "IS_IN_PRICE" => $fields["IN_PRICE"],
380 "VALUE_MONEY" => $fields["SUMM"],
381 "CODE" => "VAT1C",
382 "APPLY_ORDER" => "100"
383 )
384 );
385 }
386
391 protected function getCodeAfterDelimiter($code)
392 {
393 $result = '';
394
395 if(mb_strpos($code, '#') !== false)
396 {
397 $code = explode('#', $code);
398 $result = $code[1];
399 }
400 return $result;
401 }
402
403 private static function getProduct($code)
404 {
405 $result = array();
406
407 $r = \CIBlockElement::GetList(array(),
408 array("=XML_ID" => $code, "ACTIVE" => "Y", "CHECK_PERMISSIONS" => "Y"),
409 false,
410 false,
411 array("ID", "IBLOCK_ID", "XML_ID", "NAME", "DETAIL_PAGE_URL")
412 );
413 if($ar = $r->GetNext())
414 {
415 $result = $ar;
416 $product = \CCatalogProduct::GetByID($ar["ID"]);
417
418 $result["WEIGHT"] = $product["WEIGHT"];
419 $result["CATALOG_GROUP_NAME"] = $product["CATALOG_GROUP_NAME"];
420
421 $productIBlock = static::getIBlockProduct($ar["IBLOCK_ID"]);
422 $result["IBLOCK_XML_ID"] = $productIBlock[$ar["IBLOCK_ID"]]["XML_ID"];
423 }
424
425 return $result;
426 }
427
433 static public function getBasketItemByItem(Sale\BasketBase $basket, array $item)
434 {
435 foreach($basket as $basketItem)
436 {
438 if($item['ID'] == $basketItem->getField('PRODUCT_XML_ID'))
439 {
440 $fieldsBasketProperty = static::prepareFieldsBasketProperty($item);
441
442 $propertyBasketItem = array();
444 if($basketPropertyCollection = $basketItem->getPropertyCollection())
445 $propertyBasketItem = $basketPropertyCollection->getPropertyValues();
446
447 if(!empty($fieldsBasketProperty) && is_array($fieldsBasketProperty))
448 {
449 if($basketPropertyCollection->isPropertyAlreadyExists($fieldsBasketProperty))
450 {
451 return $basketItem;
452 }
453 }
454 elseif(count($propertyBasketItem)<=0)
455 {
456 return $basketItem;
457 }
458 }
459 else
460 continue;
461 }
462 return false;
463 }
464
469 static public function getGroupItemsBasketFields($fields)
470 {
471 $result = array();
472
473 if(is_array($fields))
474 {
475 foreach($fields as $k=>$items)
476 {
477 foreach($items as $productXML_ID => $item)
478 {
480 continue;
481
482 if($item['TYPE'] == Exchange\ImportBase::ITEM_ITEM)
483 {
484 $result[$k][$productXML_ID] = $item;
485 }
486 }
487 }
488 }
489
490 return $result;
491 }
492
498 private function fillBasket(Sale\BasketBase $basket, array $basketItems)
499 {
500 $result = new Sale\Result();
501
502 $taxListModify = array();
503 $basketItemsIndexList = array();
504
506 foreach ($basket as $basketItem)
507 {
508 $basketItemsIndexList[$basketItem->getId()] = $basketItem->getQuantity();
509 }
510
511 $basketItems = static::getGroupItemsBasketFields($basketItems);
512
513 if(!empty($basketItems))
514 {
515 $sort = 100;
516 foreach($basketItems as $items)
517 {
518 foreach($items as $productXML_ID => $item)
519 {
520 $fieldsBasket = array();
521 if($basketItem = static::getBasketItemByItem($basket, $item))
522 {
524 $criterionBasketItems = $this->getCurrentCriterion($basket->getOrder());
525
526 if($criterionBasketItems->equalsBasketItem($basketItem, $item))
527 {
528 if($item['MARKING_GROUP'] != $basketItem->getMarkingCodeGroup())
529 $fieldsBasket['MARKING_CODE_GROUP'] = $item['MARKING_GROUP'];
530
531 if($item['PRICE'] != $basketItem->getPrice())
532 $basketItem->setPrice($item['PRICE'], true);
533
534 if($item['QUANTITY'] != $basketItem->getQuantity())
535 $fieldsBasket['QUANTITY'] = $item['QUANTITY'];
536
538 $criterionBasketItemsTax = $this->getCurrentCriterion($basket->getOrder());
539
540 if($criterionBasketItemsTax->equalsBasketItemTax($basketItem, $item))
541 {
542 $taxListModify[$basketItem->getBasketCode()] = $item['TAX'];
543 }
544
546 $criterionBasketItemsDiscount = $this->getCurrentCriterion($basket->getOrder());
547
548 if($criterionBasketItemsDiscount->equalsBasketItemDiscount($basketItem, $item))
549 {
550 $fieldsBasket['DISCOUNT_PRICE'] = $item['DISCOUNT']['PRICE'];
551 }
552 }
553
554 if (isset($basketItemsIndexList[$basketItem->getId()]))
555 unset($basketItemsIndexList[$basketItem->getId()]);
556 }
557 else
558 {
559
560 $fieldsBasket = $this->prepareFieldsBasketItem($productXML_ID, $item);
561 $fieldsCurrency = $this->convertCurrency($item);
562
563 $fieldsBasket['CURRENCY'] = $fieldsCurrency['CURRENCY'];
564 $fieldsBasket['SORT'] = $sort;
565 $sort += 100;
566
567 $basketItem = $basket->createItem($fieldsBasket['MODULE'], $fieldsBasket['PRODUCT_ID']);
568
569 $basketItem->setPrice($fieldsCurrency['PRICE'], true);
570
571 unset($fieldsBasket['MODULE'], $fieldsBasket['PRODUCT_ID']);
572
573 $taxListModify[$basketItem->getBasketCode()] = $item['TAX'];
574 }
575
576 if(!empty($fieldsBasket))
577 {
578 $r = $basketItem->setFields($fieldsBasket);
579 if ($r->isSuccess())
580 {
581 $fieldsBasketProperty = static::prepareFieldsBasketProperty($item);
582 if(!empty($fieldsBasketProperty))
583 {
585 if ($propertyCollection = $basketItem->getPropertyCollection())
586 {
587 $propertyCollection->setProperty($fieldsBasketProperty);
588 }
589 }
590 }
591 else
592 {
593 $result->addErrors($r->getErrors());
594 }
595 }
596 }
597 }
598 }
599
600 if($result->isSuccess())
601 {
602 $result->setData(array('modifyTaxList'=>$taxListModify));
603
604 $r = $this->synchronizeQuantityBasketItems($basketItemsIndexList);
605 if($r->isSuccess())
606 {
607 if(!empty($basketItemsIndexList) && is_array($basketItemsIndexList))
608 {
609 foreach ($basketItemsIndexList as $basketIndexId => $basketIndexValue)
610 {
612 if ($foundedBasketItem = $basket->getItemById($basketIndexId))
613 {
614 $resultDelete = $foundedBasketItem->delete();
615 if($resultDelete->isSuccess() == false)
616 {
617 $result->addErrors($resultDelete->getErrors());
618 }
619 }
620 }
621 }
622 }
623 else
624 {
625 $result->addErrors($r->getErrors());
626 }
627 }
628
629 return $result;
630 }
631
636 protected function convertCurrency(array $item)
637 {
638 $result = array();
639 $result['CURRENCY'] = $this->settings->getCurrency();
640
642 $order = $this->getEntity();
643
644 if($this->getEntityId()>0 && $order->getCurrency() <> $this->settings->getCurrency())
645 {
646 $item['PRICE'] = \CCurrencyRates::ConvertCurrency($item['PRICE'], $this->settings->getCurrency(), $order->getCurrency());
648 $result['CURRENCY'] = $order->getCurrency();
649 }
650
651 $result['PRICE'] = $item['PRICE'];
652
653 return $result;
654 }
655
661 private static function getProductsVatRate(Sale\Basket $basket)
662 {
663 $result = array();
664 static $vatFields = null;
665
666 foreach($basket as $basketItem)
667 {
668 if($provider = $basketItem->getProvider())
669 {
670 $vatRate = 0.0;
671 if($vatFields[$basketItem->getProductId()] === null)
672 {
673 $rsVAT = \CCatalogProduct::GetVATInfo($basketItem->getProductId());
674 if ($arVAT = $rsVAT->Fetch())
675 $vatFields[$basketItem->getProductId()] = $arVAT['RATE'];
676 }
677
678
679 if (isset($vatFields[$basketItem->getProductId()]))
680 $vatRate = (float)$vatFields[$basketItem->getProductId()] * 0.01;
681
682 $result[$basketItem->getBasketCode()] = array('VAT_RATE'=>$vatRate);
683 }
684 else
685 {
686 continue;
687 }
688 }
689 return $result;
690 }
691
697 private function fillTax(Order $order, array $fields, $modifyTaxList)
698 {
699 if(isset($modifyTaxList))
700 {
702 $tax = $order->getTax();
703 $tax->resetTaxList();
704
706 $basket = $order->getBasket();
707 $productVatData = static::getProductsVatRate($basket);
708
710 foreach($basket as $basketItem)
711 {
712 $code = $basketItem->getBasketCode();
713 if(isset($modifyTaxList[$code]))
714 {
715 /*if($basketItem->getId()>0)
716 {
717 $this->setCollisions(EntityCollisionType::OrderBasketItemTaxValueError, $this->getEntity(), $basketItem->getField('NAME'));
718 }
719 else
720 {*/
721 $productVatFields = $productVatData[$basketItem->getBasketCode()];
722 if(!empty($productVatFields))
723 {
724 if($productVatFields['VAT_RATE'] <> $modifyTaxList[$code]['VAT_RATE'])
725 {
726 $this->setCollisions(EntityCollisionType::OrderBasketItemTaxValueError, $order, $basketItem->getField('NAME'));
727 }
728 }
729 //}
730
731 $basketItem->setField('VAT_RATE', $modifyTaxList[$code]['VAT_RATE']);
732 $basketItem->setField('VAT_INCLUDED', $modifyTaxList[$code]['VAT_INCLUDED']);
733 }
734 }
735
736 $tax->initTaxList($this->prepareFieldsTax($fields));
737 $order->refreshVat();
738 }
739 }
740
741 private function fillProperty(Order $order, $fieldsOrderProperty)
742 {
743 $result = new Sale\Result();
744
746 $propCollection = $order->getPropertyCollection();
747
748 if (!empty($fieldsOrderProperty) && is_array($fieldsOrderProperty))
749 {
750 $fields['PROPERTIES'] = $fieldsOrderProperty;
751
753 $r = $propCollection->setValuesFromPost($fields, $_FILES);
754 if (!$r->isSuccess())
755 {
756 $result->addErrors($r->getErrors());
757 return $result;
758 }
759 }
760 return $result;
761 }
762
763 public function refreshData(array $fields)
764 {
765 }
766
772 public static function resolveEntityTypeId(Internals\Entity $order)
773 {
774 if(!($order instanceof Order))
775 throw new Main\ArgumentException("Entity must be instanceof Order");
776
777 return EntityType::ORDER;
778 }
779
780 private static function getIBlockProduct($iblockId)
781 {
782 static $iblock_fields = null;
783
784 if($iblock_fields[$iblockId] == null)
785 {
786 $r = \CIBlock::GetList(array(), array("ID" => $iblockId));
787 if ($ar = $r->Fetch())
788 $iblock_fields[$iblockId] = $ar;
789 }
790 return $iblock_fields;
791 }
792
799 public function calculateDeltaQuantity(Sale\Basket $basket, array $basketItems)
800 {
801 $basketItemsIndexQuantityList = array();
802
804 foreach ($basket as $basketItem)
805 {
806 $basketItemsIndexQuantityList[$basketItem->getId()] = $basketItem->getQuantity();
807 }
808
809 if(!empty($basketItems) && is_array($basketItems))
810 {
811 foreach($basketItems as $items)
812 {
813 foreach($items as $productXML_ID => $item)
814 {
815 if($basketItem = static::getBasketItemByItem($basket, $item))
816 {
817 if(isset($basketItemsIndexQuantityList[$basketItem->getId()]))
818 {
819 if($basketItemsIndexQuantityList[$basketItem->getId()] <= $item['QUANTITY'])
820 {
821 unset($basketItemsIndexQuantityList[$basketItem->getId()]);
822 }
823 else
824 {
825 $basketItemsIndexQuantityList[$basketItem->getId()] -= $item['QUANTITY'];
826 }
827 }
828 }
829 }
830 }
831 }
832
833 return $basketItemsIndexQuantityList;
834 }
835
843 public function synchronizeQuantityBasketItems(array $basketItemsIndex)
844 {
845 $result = new Sale\Result();
846
848 $order = $this->getEntity();
849 if(empty($order))
850 return $result;
851
852 $basket = $order->getBasket();
853
854 $shipmentCollection = $order->getShipmentCollection();
856 $systemShipment = $shipmentCollection->getSystemShipment();
857
858 if(!empty($basketItemsIndex) && is_array($basketItemsIndex))
859 {
860 foreach ($basketItemsIndex as $basketIndexId => $basketIndexQuantity)
861 {
863 if ($foundedBasketItem = $basket->getItemById($basketIndexId))
864 {
865 $systemBasketQuantity = $systemShipment->getBasketItemQuantity($foundedBasketItem);
866
867 if($basketIndexQuantity>$systemBasketQuantity)
868 {
869 $needQuantity = $basketIndexQuantity-$systemBasketQuantity;
870
872 $shipmentImport = $this->entityCreateByFactory($this->getShipmentTypeId());
873 Exchange\ManagerImport::configure($shipmentImport);
874 $shipmentImport->setParentEntity($order);
875
876 $r = $shipmentImport->synchronizeQuantityShipmentItems($foundedBasketItem, $needQuantity);
877 if($r->isSuccess())
878 {
880 }
881 else
882 {
883 $this->setCollisions(EntityCollisionType::OrderSynchronizeBasketItemsModifyError, $order, implode(',', $result->getErrorMessages()));
884 $result->addErrors($r->getErrors());
885 }
886 }
887 }
888 }
889 }
890 return $result;
891 }
892
897 protected function getShipmentTypeId()
898 {
900 }
901
906 protected function entityCreateByFactory($typeId)
907 {
908 return EntityImportFactory::create($typeId);
909 }
910
911 public function initFields()
912 {
913 $this->setFields(
914 array(
915 'TRAITS'=>$this->getFieldsTraits(),
916 'ITEMS'=>$this->getFieldsItems(),
917 'TAXES'=>$this->getFieldsTaxes(),
918 'CASH_BOX_CHECKS'=>$this->getCashBoxChecks()
919 )
920 );
921 }
922
927 protected function getFieldsItems()
928 {
929 $result = array();
930 $order = $this->getEntity();
931 if($order instanceof Order)
932 {
934 $basketItems = $order->getBasket();
935 foreach ($basketItems as $basket)
936 {
937 $attributes = array();
938 $attributeFields = static::getAttributesItem($basket);
939 if(count($attributeFields)>0)
940 $attributes['ATTRIBUTES'] = $attributeFields;
941
942 $result[] = array_merge($basket->getFieldValues(), $attributes);
943 }
944 }
945
946 return $result;
947 }
948
953 static public function getAttributesItem(Sale\BasketItem $basket)
954 {
955 $result = array();
957 $propertyItems = $basket->getPropertyCollection();
958 foreach ($propertyItems as $property)
959 {
960 $result[] = $property->getFieldValues();
961 }
962 return $result;
963 }
964
969 protected function getFieldsTaxes()
970 {
971 $result = array();
972 $order = $this->getEntity();
973 if($order instanceof Order)
974 {
975 $res = \CSaleOrderTax::GetList(
976 array(),
977 array("ORDER_ID" => $order->getId()),
978 false,
979 false,
980 array("ID", "TAX_NAME", "VALUE", "VALUE_MONEY", "CODE", "IS_IN_PRICE")
981 );
982 while ($tax = $res->Fetch())
983 {
984 $result[] = $tax;
985 }
986 }
987 return $result;
988 }
989
993 protected function getCashBoxChecks()
994 {
995 $result = array();
996 $cashBoxOneCId = \Bitrix\Sale\Cashbox\Cashbox1C::getId();
997 $order = $this->getEntity();
998 if($order instanceof Order)
999 {
1000 if($cashBoxOneCId>0)
1001 {
1002 $result = \Bitrix\Sale\Cashbox\CheckManager::getPrintableChecks(array($cashBoxOneCId), array($order->getId()));
1003 }
1004 }
1005 return $result;
1006 }
1007
1013 {
1014 if(!($entity instanceof Order))
1015 throw new Main\ArgumentException("entity must be instanceof Order");
1016
1017 return $entity;
1018 }
1019}
static create($entityTypeID, $parentEntityContext=null)
setCollisions($tipeId, Sale\Internals\Entity $entity, $message=null)
static getBusinessValueOrderProvider(Sale\IBusinessValueProvider $entity)
__construct($parentEntityContext=null)
static resolveEntityTypeId(Internals\Entity $order)
setEntity(Internals\Entity $entity)