43 public static function addByType(array $entities, $type, array $relatedEntities = array())
54 if (!$check instanceof
Check)
60 $check->setEntities($entities);
61 $check->setRelatedEntities($relatedEntities);
65 $entity = reset($entities);
66 $order = self::getOrder($entity);
70 $dbRes = CashboxTable::getList(array(
'filter' => array(
'ACTIVE' =>
'Y')));
77 $check->setAvailableCashbox($cashboxList);
79 $registry = Sale\Registry::getInstance($check->getField(
"ENTITY_REGISTRY_TYPE"));
81 $validateResult = $check->validate();
82 if (!$validateResult->isSuccess())
84 if (Main\Loader::includeModule(
'crm'))
86 \Bitrix\Crm\Timeline\OrderCheckController::getInstance()->onCheckFailure(
88 'ORDER_FIELDS' => $order->getFieldValues(),
93 'BINDINGS' => \
Bitrix\Crm\
Order\BindingsMaker\TimelineBindingsMaker::makeByOrder($order),
98 $notifyClassName = $registry->getNotifyClassName();
100 $result->addErrors($validateResult->getErrors());
102 $event =
new Main\Event(
'sale', self::EVENT_ON_CHECK_VALIDATION_ERROR, $check->getDataForCheck());
108 $saveResult = $check->save();
109 if ($saveResult->isSuccess())
111 $checkId = $saveResult->getId();
112 $order->addPrintedCheck($check);
114 $enabledImmediateCashboxList = array();
115 foreach ($cashboxList as $item)
117 if ($item[
'ENABLED'] ===
'Y')
122 $enabledImmediateCashboxList[$item[
'ID']] = $cashbox;
127 if ($enabledImmediateCashboxList)
131 $cashbox = $enabledImmediateCashboxList[$cashboxId];
133 CashboxCheckTable::update(
138 'CASHBOX_ID' => $cashbox->getField(
'ID')
142 $printResult = $cashbox->printImmediately($check);
143 if ($printResult->isSuccess())
145 $data = $printResult->getData();
148 CashboxCheckTable::update($checkId, [
'EXTERNAL_UUID' => $data[
'UUID']]);
153 self::savePrintResult(
158 'TYPE' => Errors\Error::TYPE,
159 'MESSAGE' => implode(
"\n", $printResult->getErrorMessages())
165 $result->setId($checkId);
170 global $CACHE_MANAGER;
171 foreach ($cashboxList as $cashbox)
173 $CACHE_MANAGER->Read(CACHED_b_sale_order,
'sale_checks_'.$cashbox[
'ID']);
174 $CACHE_MANAGER->SetImmediate(
'sale_checks_'.$cashbox[
'ID'],
true);
179 $result->addErrors($saveResult->getErrors());
192 if ($item[
'ACTIVE'] !==
'Y')
198 if ($cashbox && $cashbox->isCorrection())
207 public static function addCorrection($type, $cashboxId, array $correction)
211 if (!self::isAvailableCorrection())
213 return $result->addError(
228 $check->setField(
'CASHBOX_ID', $cashboxId);
229 $check->setAvailableCashbox([
233 $check->setCorrectionFields($correction);
238 $result->setId($check->getField(
'ID'));
241 if ($cashbox->isCorrection())
243 CashboxCheckTable::update(
244 $check->getField(
'ID'),
246 'STATUS' =>
'P',
'DATE_PRINT_START' =>
new Type\DateTime()
250 $printResult = $cashbox->printCorrectionImmediately($check);
251 if ($printResult->isSuccess())
253 $data = $printResult->getData();
254 CashboxCheckTable::update($check->getField(
'ID'), [
'EXTERNAL_UUID' => $data[
'UUID']]);
258 self::savePrintResult(
259 $check->getField(
'ID'),
261 'ID' => $check->getField(
'ID'),
263 'TYPE' => Errors\Error::TYPE,
264 'MESSAGE' => implode(
"\n", $printResult->getErrorMessages())
270 global $CACHE_MANAGER;
271 $CACHE_MANAGER->Read(CACHED_b_sale_order,
'sale_checks_'.$cashboxId);
272 $CACHE_MANAGER->SetImmediate(
'sale_checks_'.$cashboxId,
true);
277 $result->addErrors($r->getErrors());
294 public static function savePrintResult($checkId, array $data)
296 $result =
new Result();
308 $dbRes =
self::getList(array(
'select' => array(
'*'),
'filter' => array(
'ID' => $checkId)));
309 $check = $dbRes->fetch();
312 $result->addError(
new Error(
Loc::getMessage(
'SALE_CASHBOX_ERROR_CHECK_NOT_FOUND', array(
'#CHECK_ID#' => $checkId))));
316 if ($check[
'STATUS'] ===
'Y')
319 $registry = Sale\Registry::getInstance($check[
'ENTITY_REGISTRY_TYPE']);
321 if ($check[
'ORDER_ID'] > 0)
324 $orderClassName = $registry->getOrderClassName();
325 $order = $orderClassName::load($check[
'ORDER_ID']);
332 $paymentCollection = $order->getPaymentCollection();
333 if ($check[
'PAYMENT_ID'] > 0)
335 $payment = $paymentCollection->getItemById($check[
'PAYMENT_ID']);
336 if ($payment ===
null)
343 $shipmentCollection = $order->getShipmentCollection();
344 if ($check[
'SHIPMENT_ID'] > 0)
346 $shipment = $shipmentCollection->getItemById($check[
'SHIPMENT_ID']);
347 if ($shipment ===
null)
355 if (isset($data[
'ERROR']))
357 $errorMessage =
Loc::getMessage(
'SALE_CASHBOX_ERROR_CHECK_PRINT', array(
'#CHECK_ID#' => $checkId));
358 if ($data[
'ERROR'][
'MESSAGE'])
359 $errorMessage .=
': '.$data[
'ERROR'][
'MESSAGE'];
363 if ($check[
'CNT_FAIL_PRINT'] >= 3)
365 $data[
'ERROR'][
'TYPE'] = Errors\Error::TYPE;
369 CashboxCheckTable::update($checkId, array(
'CNT_FAIL_PRINT' => $check[
'CNT_FAIL_PRINT'] + 1));
370 $result->addError(
new Errors\
Warning($errorMessage));
375 if ($data[
'ERROR'][
'TYPE'] === Errors\Error::TYPE)
379 'DATE_PRINT_END' =>
new Main\Type\DateTime(),
380 'ERROR_MESSAGE' => $data[
'ERROR'][
'MESSAGE']
382 if ((
int)$check[
'CNT_FAIL_PRINT'] === 0)
383 $updatedFields[
'CNT_FAIL_PRINT'] = 1;
385 CashboxCheckTable::update($checkId, $updatedFields);
388 self::addTimelineCheckEntryOnCreateToOrder($order, $checkId, [
'PRINTED' =>
'N']);
393 || $shipment !==
null
398 $errorCode = isset($data[
'ERROR'][
'CODE']) ? $data[
'ERROR'][
'CODE'] : 0;
399 $r->addWarning(
new Main\
Error($errorMessage, $errorCode));
402 $markerClassName = $registry->getEntityMarkerClassName();
404 if ($payment !==
null)
406 $markerClassName::addMarker($order, $payment, $r);
407 $payment->setField(
'MARKED',
'Y');
410 $notifyClassName = $registry->getNotifyClassName();
413 elseif ($shipment !==
null)
415 $markerClassName::addMarker($order, $shipment, $r);
416 $shipment->setField(
'MARKED',
'Y');
419 $notifyClassName = $registry->getNotifyClassName();
426 $error =
new Errors\Error($errorMessage);
431 $error =
new Errors\Warning($errorMessage);
435 $event =
new Main\Event(
'sale', self::EVENT_ON_CHECK_PRINT_ERROR, array($data));
438 $result->addError($error);
444 'LINK_PARAMS' => $data[
'LINK_PARAMS'],
445 'DATE_PRINT_END' =>
new Main\Type\DateTime(),
448 if (isset($data[
'EXTERNAL_UUID']))
450 $updateParams[
'EXTERNAL_UUID'] = $data[
'EXTERNAL_UUID'];
453 $updateResult = CashboxCheckTable::update($checkId, $updateParams);
455 if ($updateResult->isSuccess())
457 self::addStatisticOnSuccessCheckPrint($checkId);
459 self::addTimelineCheckEntryOnCreateToOrder($order, $checkId, [
'PRINTED' =>
'Y']);
462 $event =
new Main\Event(
464 self::EVENT_ON_CHECK_PRINT_SEND,
465 array(
'PAYMENT' => $payment,
'SHIPMENT' => $shipment,
'CHECK' => $check)
469 $eventResults = $event->getResults();
471 foreach($eventResults as $eventResult)
473 if($eventResult->getType() == Main\EventResult::SUCCESS)
479 if ($payment !==
null)
482 $notifyClassName = $registry->getNotifyClassName();
485 elseif ($shipment !==
null)
488 $notifyClassName = $registry->getNotifyClassName();
495 $result->addErrors($updateResult->getErrors());
502 private static function addStatisticOnSuccessCheckPrint($checkId)
509 AddEventToStatFile(
'sale',
'checkPrint', $checkId, $cashbox::getCode());
513 private static function addTimelineCheckEntryOnCreateToOrder($order, $checkId, $params)
515 if ($order && Main\Loader::includeModule(
'crm'))
517 \Bitrix\Crm\Timeline\OrderCheckController::getInstance()->onPrintCheck(
520 'ORDER_FIELDS' => $order->getFieldValues(),
521 'SETTINGS' => $params,
522 'BINDINGS' => \
Bitrix\Crm\Order\BindingsMaker\TimelineBindingsMaker::makeByOrder($order),
534 public static function delete($id)
536 $r = CashboxCheckTable::delete($id);
539 $dbRes = Sale\Cashbox\Internals\Check2CashboxTable::query()
541 ->where(
'CHECK_ID', $id);
543 while ($link = $dbRes->fetchObject())
554 public static function addChecks(array $entities)
558 $map = self::collateDocuments($entities);
559 foreach ($map as $check)
563 $event =
new Main\Event(
'sale', self::EVENT_ON_BEFORE_CHECK_ADD_VERIFY, array($check));
566 if ($event->getResults())
569 foreach ($event->getResults() as $eventResult)
571 if ($eventResult->getType() !== Main\EventResult::ERROR)
573 $isCorrect = (bool)$eventResult->getParameters();
580 $addResult = self::addByType($check[
"ENTITIES"], $check[
"TYPE"], $check[
"RELATED_ENTITIES"]);
581 if (!$addResult->isSuccess())
583 $result->addErrors($addResult->getErrors());
596 public static function getOrder($entity)
600 if ($entity instanceof
Sale\Payment)
603 $col = $entity->getCollection();
604 $order = $col->getOrder();
606 elseif ($entity instanceof
Sale\Shipment)
609 $col = $entity->getCollection();
610 $order = $col->getOrder();
614 throw new Main\ArgumentTypeException(
"entities");
623 private static function getBuildInCheckList()
626 '\Bitrix\Sale\Cashbox\SellCheck',
627 '\Bitrix\Sale\Cashbox\SellReturnCashCheck',
628 '\Bitrix\Sale\Cashbox\SellReturnCheck'
631 if (Manager::isSupportedFFD105())
633 $checkList = array_merge(
636 '\Bitrix\Sale\Cashbox\CorrectionSellCheck',
637 '\Bitrix\Sale\Cashbox\CorrectionBuyCheck',
638 '\Bitrix\Sale\Cashbox\AdvancePaymentCheck',
639 '\Bitrix\Sale\Cashbox\AdvanceReturnCheck',
640 '\Bitrix\Sale\Cashbox\AdvanceReturnCashCheck',
641 '\Bitrix\Sale\Cashbox\CreditPaymentCheck',
642 '\Bitrix\Sale\Cashbox\CreditPaymentReturnCheck',
643 '\Bitrix\Sale\Cashbox\CreditPaymentReturnCashCheck',
644 '\Bitrix\Sale\Cashbox\CreditCheck',
645 '\Bitrix\Sale\Cashbox\CreditReturnCheck',
646 '\Bitrix\Sale\Cashbox\PrepaymentCheck',
647 '\Bitrix\Sale\Cashbox\PrepaymentReturnCheck',
648 '\Bitrix\Sale\Cashbox\PrepaymentReturnCashCheck',
649 '\Bitrix\Sale\Cashbox\FullPrepaymentCheck',
650 '\Bitrix\Sale\Cashbox\FullPrepaymentReturnCheck',
651 '\Bitrix\Sale\Cashbox\FullPrepaymentReturnCashCheck',
662 private static function getUserCheckList()
664 $checkList = array();
666 $event =
new Main\Event(
'sale', self::EVENT_ON_GET_CUSTOM_CHECK);
668 $resultList = $event->getResults();
670 if (is_array($resultList) && !empty($resultList))
672 foreach ($resultList as $eventResult)
675 if ($eventResult->getType() === Main\EventResult::SUCCESS)
677 $params = $eventResult->getParameters();
678 if (!empty($params) && is_array($params))
679 $checkList = array_merge($checkList, $params);
692 static $isInit =
false;
694 if ($isInit ===
false)
696 $handlers = self::getUserCheckList();
697 Main\Loader::registerAutoLoadClasses(
null, $handlers);
707 static $checkList = array();
710 $checkList = array_merge(
711 self::getBuildInCheckList(),
712 array_keys(self::getUserCheckList())
722 self::getCheckList(),
725 return is_subclass_of($value, Check::class);
733 public static function getCheckTypeMap()
741 foreach ($checkMap as $className)
743 if (class_exists($className))
745 $result[$className::getType()] = $className;
760 $typeMap = self::getCheckTypeMap();
761 $handler = $typeMap[$type];
771 public static function collateDocuments(array $entities)
775 $event =
new Main\Event(
'sale', self::EVENT_ON_CHECK_COLLATE_DOCUMENTS, [
776 'ENTITIES' => $entities
779 $eventResults = $event->getResults();
780 if ($eventResults !=
null)
782 foreach ($eventResults as $eventResult)
784 if ($eventResult->getType() === Main\EventResult::SUCCESS)
786 $d = $eventResult->getParameters();
790 $map = array_merge($map, $d);
792 else if ($eventResult->getType() === Main\EventResult::ERROR)
804 $existingChecks =
null;
808 foreach ($entities as $entity)
811 if ($existingChecks ===
null)
813 $existingChecks = [];
814 $order = self::getOrder($entity);
817 'ORDER_ID' => $order->getId(),
818 'ENTITY_REGISTRY_TYPE' => $entity::getRegistryType()
820 if ($entity instanceof
Sale\Payment)
822 $filter[
"PAYMENT_ID"] = $entity->getId();
824 elseif ($entity instanceof
Sale\Shipment)
826 $filter[
"SHIPMENT_ID"] = $entity->getId();
831 "select" => [
"ID",
"PAYMENT_ID",
"SHIPMENT_ID",
"TYPE",
"STATUS"]
833 while ($ar = $db->fetch())
835 if (intval($ar[
"PAYMENT_ID"]) > 0)
837 $existingChecks[
"P"][ $ar[
"PAYMENT_ID"] ][] = $ar;
840 if (intval($ar[
"SHIPMENT_ID"]) > 0)
842 $existingChecks[
"S"][ $ar[
"SHIPMENT_ID"] ][] = $ar;
849 if (count($existingChecks) <= 0)
851 if (self::isAutomaticEnabled($order))
853 if (Manager::isSupportedFFD105())
857 $result = self::collatePaySystemWithFFD105($entity);
861 $result = self::collateWithFFD105($entity);
866 $result = self::collate($entity);
871 $map = array_merge($map, $result);
886 private static function isAutomaticEnabled(
Sale\Order $order)
888 $shipmentCollection = $order->getShipmentCollection();
891 $shipmentCollection->count() > 2
892 && $shipmentCollection->isExistsSystemShipment()
896 $shipmentCollection->count() > 1
897 && !$shipmentCollection->isExistsSystemShipment()
904 $paymentCollection = $order->getPaymentCollection();
907 $paymentCollection->isExistsInnerPayment()
908 && $paymentCollection->count() > 2
912 !$paymentCollection->isExistsInnerPayment()
913 && $paymentCollection->count() > 1
930 private static function collate($entity)
934 if ($entity instanceof
Sale\Payment)
936 $order = self::getOrder($entity);
939 $service = $entity->getPaySystem();
940 if ($entity->isPaid() &&
941 ($service->getField(
"CAN_PRINT_CHECK") ==
"Y") &&
942 ($entity->getSum() == $order->getPrice())
945 $checkEntities[] = $entity;
947 $shipmentCollection = $order->getShipmentCollection();
949 foreach ($shipmentCollection as $shipment)
951 if (!$shipment->isSystem())
952 $checkEntities[] = $shipment;
955 $map[] = array(
"TYPE" =>
SellCheck::getType(),
"ENTITIES" => $checkEntities,
"RELATED_ENTITIES" => array());
971 private static function collateWithFFD105($entity)
975 $order = self::getOrder($entity);
976 if (!self::canPrintCheck($order))
982 $relatedEntities = array();
983 if ($entity instanceof
Sale\Payment)
985 if ($entity->isInner() || !$entity->isPaid())
988 $service = $entity->getPaySystem();
990 $entities[$type] = $entity;
992 $fields = $order->getFields();
993 $originalFields = $fields->getOriginalValues();
994 if (!isset($originalFields[
'DEDUCTED']))
995 $originalFields[
'DEDUCTED'] = $order->getField(
'DEDUCTED');
997 $paymentCollection = $order->getPaymentCollection();
998 if ($order->getField(
'DEDUCTED') ===
'Y' && $originalFields[
'DEDUCTED'] ===
'Y')
1000 if ($paymentCollection->isExistsInnerPayment())
1009 $option = Main\Config\Option::get(
'sale',
'check_type_on_pay',
'sell');
1010 if ($option ===
'prepayment')
1014 $shipmentCollection = $order->getShipmentCollection()->getNotSystemItems();
1016 foreach ($shipmentCollection as $shipment)
1021 $map[] = array(
"TYPE" => $checkType,
"ENTITIES" => $entities,
"RELATED_ENTITIES" => $relatedEntities);
1023 elseif ($option ===
'advance')
1029 if ($paymentCollection->isExistsInnerPayment())
1035 $shipmentCollection = $order->getShipmentCollection()->getNotSystemItems();
1037 foreach ($shipmentCollection as $shipment)
1042 $map[] = array(
"TYPE" =>
SellCheck::getType(),
"ENTITIES" => $entities,
"RELATED_ENTITIES" => $relatedEntities);
1047 elseif ($entity instanceof
Sale\Shipment)
1049 if ($entity->getField(
'DEDUCTED') !==
'Y')
1052 $entities[] = $entity;
1053 if ($order->isPaid())
1055 if (Main\
Config\Option::get(
'sale',
'check_type_on_pay',
'sell') ===
'sell')
1060 $paymentCollection = $order->getPaymentCollection();
1061 foreach ($paymentCollection as $payment)
1066 $map[] = array(
"TYPE" =>
SellCheck::getType(),
"ENTITIES" => $entities,
"RELATED_ENTITIES" => $relatedEntities);
1070 $map[] = array(
"TYPE" =>
CreditCheck::getType(),
"ENTITIES" => $entities,
"RELATED_ENTITIES" => $relatedEntities);
1075 throw new Main\NotSupportedException();
1088 private static function collatePaySystemWithFFD105($entity): array
1092 $relatedEntities = [];
1095 $option = Main\Config\Option::get(
'sale',
'check_type_on_pay',
'sell');
1097 if ($entity instanceof
Sale\Payment)
1099 $fields = $entity->getFields();
1100 $originalFields = $fields->getOriginalValues();
1101 if ($originalFields[
'PAID'] ===
'Y' || $fields->get(
'IS_RETURN') ===
'Y')
1106 $order = $entity->getOrder();
1108 $entities[] = $entity;
1112 foreach ($order->getShipmentCollection()->getNotSystemItems() as $shipment)
1114 $isShipped = $shipment->isShipped();
1117 $relatedEntities = [];
1126 $order = $entity->getOrder();
1127 if ($option ===
'prepayment')
1129 $type = (Sale\PriceMaths::roundPrecision($entity->getSum()) === Sale\PriceMaths::roundPrecision($order->getPrice()))
1133 $shipmentCollection = $order->getShipmentCollection()->getNotSystemItems();
1135 foreach ($shipmentCollection as $shipment)
1140 elseif ($option ===
'advance')
1146 $shipmentCollection = $order->getShipmentCollection()->getNotSystemItems();
1148 foreach ($shipmentCollection as $shipment)
1155 elseif ($entity instanceof
Sale\Shipment)
1157 $fields = $entity->getFields();
1158 $originalFields = $fields->getOriginalValues();
1159 if ($originalFields[
'DEDUCTED'] ===
'Y' || $fields->get(
'DEDUCTED') !==
'Y')
1164 $order = $entity->getOrder();
1165 if ($order->isPaid() && $entity->isShipped())
1167 if ($option ===
'sell')
1172 $entities[] = $entity;
1175 foreach ($order->getPaymentCollection() as $payment)
1177 if ($payment->isInner())
1191 'ENTITIES' => $entities,
1192 'RELATED_ENTITIES' => $relatedEntities,
1203 private static function canPrintCheck(
Sale\Order $order)
1205 $paymentCollection = $order->getPaymentCollection();
1206 if ($paymentCollection->isEmpty())
1212 foreach ($paymentCollection as $payment)
1214 if ($payment->isInner())
1217 $service = $payment->getPaySystem();
1218 if ($service ===
null
1219 || $service->getField(
"CAN_PRINT_CHECK") !==
'Y'
1239 public static function getPrintableChecks(array $cashboxIds, array $orderIds = array())
1243 $con = Main\Application::getConnection();
1244 $dbLocRes = $con->query(
"SELECT GET_LOCK('get_check_list', 0) as L");
1245 $locResult = $dbLocRes->fetch();
1246 if ($locResult[
"L"] ==
"0")
1252 'LINK_PARAMS' =>
'',
1253 'CHECK2CASHBOX.CASHBOX_ID' => $cashboxIds,
1258 'DATE_PRINT_START' =>
''
1262 '<MAX_DT_REPEAT_CHECK' =>
new Type\DateTime()
1269 $filter[
'ORDER_ID'] = $orderIds;
1275 'select' => array(
'*',
'AVAILABLE_CASHBOX_ID' =>
'CHECK2CASHBOX.CASHBOX_ID'),
1276 'filter' => $filter,
1279 new Main\Entity\ExpressionField(
1280 'MAX_DT_REPEAT_CHECK',
1281 'DATE_ADD(DATE_PRINT_START, INTERVAL '.self::CHECK_RESENDING_TIME.
' MINUTE)',
1284 'data_type' =>
'datetime'
1291 if ($data = $dbRes->fetch())
1296 if (!isset($result[$data[
'ID']]))
1299 if ($i > self::CHECK_LIMIT_RECORDS)
1302 $result[$data[
'ID']] = $data;
1303 $result[$data[
'ID']][
'CASHBOX_LIST'] = array();
1306 $result[$data[
'ID']][
'CASHBOX_LIST'][] = $data[
'AVAILABLE_CASHBOX_ID'];
1308 while ($data = $dbRes->fetch());
1310 foreach ($result as $checkId => $item)
1312 if ($item[
'STATUS'] ===
'P')
1315 $nowTs = $now->getTimestamp();
1318 $dateStartPrint = $item[
'DATE_PRINT_START'];
1319 $dateStartPrintTs = $dateStartPrint->getTimestamp();
1321 if ($nowTs - $dateStartPrintTs > self::MIN_TIME_FOR_SWITCH_CASHBOX)
1323 $availableCashboxIds = array_diff($item[
'CASHBOX_LIST'], array($item[
'CASHBOX_ID']));
1324 if ($availableCashboxIds)
1327 CashboxCheckTable::update($checkId, array(
'CASHBOX_ID' => $result[$checkId][
'CASHBOX_ID']));
1332 if ($item[
'CASHBOX_ID'] > 0 && !in_array($item[
'CASHBOX_ID'], $cashboxIds))
1333 unset($result[$checkId]);
1340 CashboxCheckTable::update($checkId, array(
'STATUS' =>
'P',
'DATE_PRINT_START' =>
new Type\DateTime(),
'CASHBOX_ID' => $result[$checkId][
'CASHBOX_ID']));
1344 $con->query(
"SELECT RELEASE_LOCK('get_check_list')");
1353 public static function create(array $settings)
1357 $check->init($settings);
1371 if ($entity->getId() > 0)
1375 $filter[
'ENTITY_REGISTRY_TYPE'] = $entity::getRegistryType();
1376 $filter[
'PAYMENT_ID'] = $entity->getId();
1380 $filter[
'ENTITY_REGISTRY_TYPE'] = $entity::getRegistryType();
1381 $filter[
'SHIPMENT_ID'] = $entity->getId();
1384 return self::collectInfo($filter);
1406 'ENTITY_REGISTRY_TYPE' => $entity::getRegistryType()
1410 $filter[
'PAYMENT_ID'] = $entity->getId();
1414 $filter[
'SHIPMENT_ID'] = $entity->getId();
1419 'select' => array(
'*'),
1420 'filter' => $filter,
1421 'order' => array(
'DATE_PRINT_END' =>
'DESC'),
1426 if ($data = $dbRes->fetch())
1429 if (!empty($data[
'LINK_PARAMS']))
1433 $data[
'LINK'] = $cashbox->getCheckLink($data[
'LINK_PARAMS']);
1448 public static function collectInfo(array $filter = array())
1452 $typeMap = CheckManager::getCheckTypeMap();
1456 'select' => array(
'*'),
1461 while ($data = $dbRes->fetch())
1464 if (!empty($data[
'LINK_PARAMS']))
1469 $data[
'LINK'] = $cashbox->getCheckLink($data[
'LINK_PARAMS']);
1474 $type = $typeMap[$data[
'TYPE']];
1475 if (class_exists($type))
1477 $data[
'TYPE_NAME'] = $type::getName();
1480 $result[$data[
'ID']] = $data;
1493 $dbRes =
self::getList(array(
'filter' => array(
'EXTERNAL_UUID' => $uuid)));
1494 return $dbRes->fetch();
1509 $dbRes = CashboxCheckTable::getById($id);
1510 if ($checkInfo = $dbRes->fetch())
1515 $check->init($checkInfo);
1528 public static function getList(array $parameters = array())
1530 return CashboxCheckTable::getList($parameters);
1546 if ($check ===
null)
1551 $registry = Sale\Registry::getInstance($registryType);
1553 $paymentClassName = $registry->getPaymentClassName();
1555 $dbRes = $paymentClassName::getList(array(
1556 'select' => array(
'ORDER_ID'),
1557 'filter' => array(
'=ID' => $paymentId)
1560 $paymentData = $dbRes->fetch();
1570 if (Manager::isSupportedFFD105())
1572 $dbRes = $paymentClassName::getList(array(
1573 'select' => array(
'ID',
'ACCOUNT_NUMBER',
'SUM',
'CURRENCY',
'NAME' =>
'PAY_SYSTEM.NAME'),
1575 '!ID' => $paymentId,
1576 '=ORDER_ID' => $paymentData[
'ORDER_ID']
1580 while ($data = $dbRes->fetch())
1582 $data[
'PAYMENT_TYPES'] = array(
1593 $result[
'PAYMENTS'][$data[
'ID']] = $data;
1602 $shipmentClassName = $registry->getShipmentClassName();
1603 $dbRes = $shipmentClassName::getList(array(
1604 'select' => array(
'ID',
'ACCOUNT_NUMBER',
'PRICE_DELIVERY',
'CURRENCY',
'NAME' =>
'DELIVERY.NAME'),
1606 '=ORDER_ID' => $paymentData[
'ORDER_ID'],
1611 while ($data = $dbRes->fetch())
1613 $result[
'SHIPMENTS'][$data[
'ID']] = $data;
1632 if (!Manager::isSupportedFFD105())
1638 if ($check ===
null)
1640 throw new Main\ArgumentTypeException($checkType);
1643 $registry = Sale\Registry::getInstance($registryType);
1645 $shipmentClassName = $registry->getShipmentClassName();
1647 $dbRes = $shipmentClassName::getList(array(
1648 'select' => array(
'ORDER_ID'),
1649 'filter' => array(
'=ID' => $shipmentId)
1652 $shipmentData = $dbRes->fetch();
1662 $dbRes = $shipmentClassName::getList(array(
1663 'select' => array(
'ID',
'ACCOUNT_NUMBER',
'PRICE_DELIVERY',
'CURRENCY',
'NAME' =>
'DELIVERY.NAME'),
1665 '!ID' => $shipmentId,
1666 '=ORDER_ID' => $shipmentData[
'ORDER_ID'],
1671 while ($data = $dbRes->fetch())
1673 $result[
'SHIPMENTS'][$data[
'ID']] = $data;
1682 $paymentClassName = $registry->getPaymentClassName();
1683 $dbRes = $paymentClassName::getList(array(
1684 'select' => array(
'ID',
'ACCOUNT_NUMBER',
'SUM',
'CURRENCY',
'NAME' =>
'PAY_SYSTEM.NAME'),
1686 '=ORDER_ID' => $shipmentData[
'ORDER_ID']
1690 while ($data = $dbRes->fetch())
1692 $data[
'PAYMENT_TYPES'] = array(
1703 $result[
'PAYMENTS'][$data[
'ID']] = $data;
1720 $entities = $check->getEntities();
1721 foreach ($entities as $entity)
1731 $relatedEntities = $check->getRelatedEntities();
1732 foreach ($relatedEntities as $relatedEntityCollection)
1734 foreach ($relatedEntityCollection as $relatedEntity)
1738 $payment = $relatedEntity;