33 if (!$this->service || !$this->service->isSupportPrintCheck())
39 !isset($this->oldFields[
'ACTIVE'], $this->newFields[
'ACTIVE'])
42 isset($this->oldFields[
'ACTIVE'], $this->newFields[
'ACTIVE'])
43 && $this->oldFields[
'ACTIVE'] === $this->newFields[
'ACTIVE']
50 $newStatus = $this->newFields[
'ACTIVE'];
53 $cashboxClass = $this->service->getCashboxClass();
55 $kkmId = $this->getKkmID();
57 if ($this->isCashboxUsedByOtherPaySystems())
62 $cashboxList = Sale\Cashbox\Manager::getList([
63 'select' => [
'ID',
'KKM_ID'],
65 '=HANDLER' => $cashboxClass,
69 foreach ($cashboxList as $cashboxItem)
71 $updateResult = Sale\Cashbox\Manager::update($cashboxItem[
'ID'], [
'ACTIVE' => $newStatus]);
72 if (!$updateResult->isSuccess())
74 $result->addErrors($updateResult->getErrors());
81 private function isCashboxUsedByOtherPaySystems(): bool
83 $cashboxClass = $this->service->getCashboxClass();
85 $paySystemIterator = Sale\PaySystem\Manager::getList([
88 '!=ID' => $this->service->getField(
'ID'),
92 $kkmId = $this->getKkmId();
93 $paySystemCodeForKkm = $cashboxClass::getPaySystemCodeForKkm();
95 while ($paySystemItem = $paySystemIterator->fetch())
97 $paySystemService =
new Sale\PaySystem\Service($paySystemItem);
99 $paySystemService->isSupportPrintCheck()
100 && $paySystemService->getCashboxClass() === $cashboxClass
111 private function getKkmId(): array
113 $cashboxClass = $this->service->getCashboxClass();
114 $paySystemCodeForKkm = $cashboxClass::getPaySystemCodeForKkm();
116 return Sale\BusinessValue::getValuesByCode($this->service->getConsumerName(), $paySystemCodeForKkm);