Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
deletecashboxesondisabledfiscalization.php
1<?php
2
4
6
8{
10 private $service;
12 private $kkmId;
13
14 public function __construct(Sale\PaySystem\Service $service, string $kkmId)
15 {
16 $this->service = $service;
17 $this->kkmId = $kkmId;
18 }
19
27 public function executeEvent(): Sale\Result
28 {
29 $result = new Sale\Result();
30
31 if (!$this->service || !$this->service->isSupportPrintCheck())
32 {
33 return $result;
34 }
35
36 $cashboxList = Sale\Cashbox\Manager::getList([
37 'select' => ['ID', 'KKM_ID'],
38 'filter' => [
39 '=HANDLER' => $this->service->getCashboxClass(),
40 '=KKM_ID' => $this->kkmId,
41 ],
42 ]);
43 foreach ($cashboxList as $cashboxItem)
44 {
45 $cashboxId = $cashboxItem['ID'];
46 $serviceCashbox = Sale\Cashbox\Manager::getObjectById($cashboxId);
47 if (Sale\Cashbox\Manager::isCashboxChecksExist($cashboxId))
48 {
49 Sale\Cashbox\Manager::deactivateCashbox($cashboxId);
50 }
51 else
52 {
53 $deleteResult = Sale\Cashbox\Manager::delete($cashboxId);
54 if ($deleteResult->isSuccess())
55 {
56 AddEventToStatFile('sale', 'deleteCashbox', '', $serviceCashbox::getCode());
57 }
58 else
59 {
60 $result->addErrors($deleteResult->getErrors());
61 }
62 }
63 }
64
65 return $result;
66 }
67}