From a42abf40bb20adb097e3c73036c84bced7f3010d Mon Sep 17 00:00:00 2001 From: Sally Fancen Date: Wed, 17 Sep 2025 16:24:31 +0400 Subject: [PATCH 1/5] add CashboxHandler and tests; run tests; add to changelog --- CHANGELOG.md | 6 + Makefile | 5 + phpunit.xml.dist | 3 + .../Result/CashboxHandlerItemResult.php | 34 +++ .../Result/CashboxHandlersResult.php | 37 +++ .../CashboxHandler/Service/CashboxHandler.php | 143 ++++++++++ src/Services/Sale/SaleServiceBuilder.php | 16 ++ .../Service/CashboxHandlerTest.php | 258 ++++++++++++++++++ 8 files changed, 502 insertions(+) create mode 100644 src/Services/Sale/CashboxHandler/Result/CashboxHandlerItemResult.php create mode 100644 src/Services/Sale/CashboxHandler/Result/CashboxHandlersResult.php create mode 100644 src/Services/Sale/CashboxHandler/Service/CashboxHandler.php create mode 100644 tests/Integration/Services/Sale/CashboxHandler/Service/CashboxHandlerTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 0400c512..d92f9d50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,12 @@ - `list` returns a list of payments - `delete` deletes a payment - `getFields` returns the fields and settings for payments +- Added service `Services\Sale\CashboxHandler\Service\CashboxHandler` with support methods, + see [sale.cashbox.handler.* methods](https://github.com/bitrix24/b24phpsdk/issues/258): + - `add` adds a REST cashbox handler + - `update` updates the data of the REST cashbox handler + - `list` returns a list of available REST cashbox handlers + - `delete` deletes the REST cashbox handler ## 1.6.0 – 2025.09.01 diff --git a/Makefile b/Makefile index 5c93b5ac..57ef7b3b 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,7 @@ help: @echo "" @echo "test-unit - run unit tests" @echo "test-integration-sale-basket-property - run BasketProperty integration tests" + @echo "test-integration-sale-cashbox-handler - run CashboxHandler integration tests" .PHONY: docker-init @@ -211,6 +212,10 @@ test-integration-sale-basket: .PHONY: test-integration-sale-order test-integration-sale-order: docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_sale_order + +.PHONY: test-integration-sale-cashbox-handler +test-integration-sale-cashbox-handler: + docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_sale_cashbox_handler .PHONY: test-integration-scope-crm test-integration-scope-crm: diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d69753c3..8fcdfc7b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -136,6 +136,9 @@ ./tests/Integration/Services/Sale/Order/ + + ./tests/Integration/Services/Sale/CashboxHandler/ + diff --git a/src/Services/Sale/CashboxHandler/Result/CashboxHandlerItemResult.php b/src/Services/Sale/CashboxHandler/Result/CashboxHandlerItemResult.php new file mode 100644 index 00000000..260361ea --- /dev/null +++ b/src/Services/Sale/CashboxHandler/Result/CashboxHandlerItemResult.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the MIT-LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Bitrix24\SDK\Services\Sale\CashboxHandler\Result; + +use Bitrix24\SDK\Core\Result\AbstractItem; + +/** + * Class CashboxHandlerItemResult + * + * @property-read int|null $ID + * @property-read string|null $NAME + * @property-read string|null $CODE + * @property-read int|null $SORT + * @property-read array|null $SETTINGS + * @property-read string|null $SETTINGS.PRINT_URL + * @property-read string|null $SETTINGS.CHECK_URL + * @property-read string|null $SETTINGS.HTTP_VERSION + * @property-read array|null $SETTINGS.CONFIG + * @property-read string|null $SETTINGS.SUPPORTS_FFD105 + */ +class CashboxHandlerItemResult extends AbstractItem +{ +} \ No newline at end of file diff --git a/src/Services/Sale/CashboxHandler/Result/CashboxHandlersResult.php b/src/Services/Sale/CashboxHandler/Result/CashboxHandlersResult.php new file mode 100644 index 00000000..68bf26dc --- /dev/null +++ b/src/Services/Sale/CashboxHandler/Result/CashboxHandlersResult.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the MIT-LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Bitrix24\SDK\Services\Sale\CashboxHandler\Result; + +use Bitrix24\SDK\Core\Exceptions\BaseException; +use Bitrix24\SDK\Core\Result\AbstractResult; + +/** + * Result for sale.cashbox.handler.list + */ +class CashboxHandlersResult extends AbstractResult +{ + /** + * @return CashboxHandlerItemResult[] + * @throws BaseException + */ + public function getCashboxHandlers(): array + { + $result = []; + foreach ($this->getCoreResponse()->getResponseData()->getResult() as $item) { + $result[] = new CashboxHandlerItemResult($item); + } + + return $result; + } +} \ No newline at end of file diff --git a/src/Services/Sale/CashboxHandler/Service/CashboxHandler.php b/src/Services/Sale/CashboxHandler/Service/CashboxHandler.php new file mode 100644 index 00000000..de3b3441 --- /dev/null +++ b/src/Services/Sale/CashboxHandler/Service/CashboxHandler.php @@ -0,0 +1,143 @@ + + * + * For the full copyright and license information, please view the MIT-LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Bitrix24\SDK\Services\Sale\CashboxHandler\Service; + +use Bitrix24\SDK\Attributes\ApiEndpointMetadata; +use Bitrix24\SDK\Attributes\ApiServiceMetadata; +use Bitrix24\SDK\Core\Contracts\CoreInterface; +use Bitrix24\SDK\Core\Credentials\Scope; +use Bitrix24\SDK\Core\Exceptions\BaseException; +use Bitrix24\SDK\Core\Exceptions\TransportException; +use Bitrix24\SDK\Core\Result\AddedItemResult; +use Bitrix24\SDK\Core\Result\DeletedItemResult; +use Bitrix24\SDK\Core\Result\UpdatedItemResult; +use Bitrix24\SDK\Services\AbstractService; +use Bitrix24\SDK\Services\Sale\CashboxHandler\Result\CashboxHandlersResult; +use Psr\Log\LoggerInterface; + +#[ApiServiceMetadata(new Scope(['sale', 'cashbox']))] +class CashboxHandler extends AbstractService +{ + public function __construct(CoreInterface $core, LoggerInterface $logger) + { + parent::__construct($core, $logger); + } + + /** + * Adds a REST cashbox handler. + * + * @link https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-handler-add.html + * + * @param string $code Unique code of the REST handler + * @param string $name Name of the REST handler + * @param array $settings Handler settings including PRINT_URL, CHECK_URL, CONFIG + * @param int $sort Sorting order (default: 100) + * @param string $supportsFFD105 Support for fiscal data format 1.05 (Y/N, default: N) + * + * @throws BaseException + * @throws TransportException + */ + #[ApiEndpointMetadata( + 'sale.cashbox.handler.add', + 'https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-handler-add.html', + 'Adds a REST cashbox handler.' + )] + public function add( + string $code, + string $name, + array $settings, + int $sort = 100, + string $supportsFFD105 = 'N' + ): AddedItemResult { + return new AddedItemResult( + $this->core->call('sale.cashbox.handler.add', [ + 'CODE' => $code, + 'NAME' => $name, + 'SORT' => $sort, + 'SUPPORTS_FFD105' => $supportsFFD105, + 'SETTINGS' => $settings, + ]) + ); + } + + /** + * Updates the data of the REST cashbox handler. + * + * @link https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-handler-update.html + * + * @param int $id Identifier of the handler being updated + * @param array $fields Values of the fields to be updated (NAME, SORT, SETTINGS) + * + * @throws BaseException + * @throws TransportException + */ + #[ApiEndpointMetadata( + 'sale.cashbox.handler.update', + 'https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-handler-update.html', + 'Updates the data of the REST cashbox handler.' + )] + public function update(int $id, array $fields): UpdatedItemResult + { + return new UpdatedItemResult( + $this->core->call('sale.cashbox.handler.update', [ + 'ID' => $id, + 'FIELDS' => $fields, + ]) + ); + } + + /** + * Returns a list of available REST cashbox handlers. + * + * @link https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-handler-list.html + * + * @throws BaseException + * @throws TransportException + */ + #[ApiEndpointMetadata( + 'sale.cashbox.handler.list', + 'https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-handler-list.html', + 'Returns a list of available REST cashbox handlers.' + )] + public function list(): CashboxHandlersResult + { + return new CashboxHandlersResult( + $this->core->call('sale.cashbox.handler.list') + ); + } + + /** + * Deletes the REST cashbox handler. + * + * @link https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-handler-delete.html + * + * @param int $id Identifier of the cashbox handler to be deleted + * + * @throws BaseException + * @throws TransportException + */ + #[ApiEndpointMetadata( + 'sale.cashbox.handler.delete', + 'https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-handler-delete.html', + 'Deletes the REST cashbox handler.' + )] + public function delete(int $id): DeletedItemResult + { + return new DeletedItemResult( + $this->core->call('sale.cashbox.handler.delete', [ + 'ID' => $id, + ]) + ); + } +} \ No newline at end of file diff --git a/src/Services/Sale/SaleServiceBuilder.php b/src/Services/Sale/SaleServiceBuilder.php index e42412ed..8ce9bfa2 100644 --- a/src/Services/Sale/SaleServiceBuilder.php +++ b/src/Services/Sale/SaleServiceBuilder.php @@ -23,6 +23,7 @@ use Bitrix24\SDK\Services\Sale\StatusLang\Service\StatusLang; use Bitrix24\SDK\Services\Sale\PersonTypeStatus\Service\PersonTypeStatus; use Bitrix24\SDK\Services\Sale\BasketProperty\Service\BasketProperty; +use Bitrix24\SDK\Services\Sale\CashboxHandler\Service\CashboxHandler; /** * Class SaleServiceBuilder @@ -203,4 +204,19 @@ public function basketProperty(): BasketProperty return $this->serviceCache[__METHOD__]; } + + /** + * Cash register handlers service (sale.cashbox.handler.*) + */ + public function cashboxHandler(): CashboxHandler + { + if (!isset($this->serviceCache[__METHOD__])) { + $this->serviceCache[__METHOD__] = new CashboxHandler( + $this->core, + $this->log + ); + } + + return $this->serviceCache[__METHOD__]; + } } diff --git a/tests/Integration/Services/Sale/CashboxHandler/Service/CashboxHandlerTest.php b/tests/Integration/Services/Sale/CashboxHandler/Service/CashboxHandlerTest.php new file mode 100644 index 00000000..d3757dac --- /dev/null +++ b/tests/Integration/Services/Sale/CashboxHandler/Service/CashboxHandlerTest.php @@ -0,0 +1,258 @@ + + * + * For the full copyright and license information, please view the MIT-LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Bitrix24\SDK\Tests\Integration\Services\Sale\CashboxHandler\Service; + +use Bitrix24\SDK\Core\Exceptions\BaseException; +use Bitrix24\SDK\Core\Exceptions\TransportException; +use Bitrix24\SDK\Services\Sale\CashboxHandler\Service\CashboxHandler; +use Bitrix24\SDK\Tests\Integration\Fabric; +use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\TestCase; + +/** + * Class CashboxHandlerTest + * + * @package Bitrix24\SDK\Tests\Integration\Services\Sale\CashboxHandler\Service + */ +#[CoversMethod(CashboxHandler::class, 'add')] +#[CoversMethod(CashboxHandler::class, 'update')] +#[CoversMethod(CashboxHandler::class, 'list')] +#[CoversMethod(CashboxHandler::class, 'delete')] +#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\Sale\CashboxHandler\Service\CashboxHandler::class)] +class CashboxHandlerTest extends TestCase +{ + protected CashboxHandler $cashboxHandlerService; + + protected function setUp(): void + { + $this->cashboxHandlerService = Fabric::getServiceBuilder()->getSaleScope()->cashboxHandler(); + } + + /** + * Generate test settings for cashbox handler + */ + protected function getTestSettings(): array + { + return [ + 'PRINT_URL' => 'https://example.com/print_receipt.php', + 'CHECK_URL' => 'https://example.com/check_receipt.php', + 'HTTP_VERSION' => '1.1', + 'CONFIG' => [ + 'AUTH' => [ + 'LABEL' => 'Authorization', + 'ITEMS' => [ + 'LOGIN' => [ + 'TYPE' => 'STRING', + 'LABEL' => 'Login', + 'REQUIRED' => 'Y' + ], + 'PASSWORD' => [ + 'TYPE' => 'STRING', + 'LABEL' => 'Password', + 'REQUIRED' => 'Y' + ] + ] + ], + 'COMPANY' => [ + 'LABEL' => 'Company Information', + 'ITEMS' => [ + 'INN' => [ + 'TYPE' => 'STRING', + 'LABEL' => 'Company INN', + 'REQUIRED' => 'Y' + ] + ] + ], + 'INTERACTION' => [ + 'LABEL' => 'Cashbox Interaction Settings', + 'ITEMS' => [ + 'MODE' => [ + 'TYPE' => 'ENUM', + 'LABEL' => 'Cashbox Operating Mode', + 'OPTIONS' => [ + 'ACTIVE' => 'live', + 'TEST' => 'test' + ] + ] + ] + ] + ] + ]; + } + + /** + * @throws BaseException + * @throws TransportException + */ + public function testAdd(): void + { + $code = 'test_cashbox_handler_' . time(); + $name = 'Test Cashbox Handler'; + $settings = $this->getTestSettings(); + + $addResult = $this->cashboxHandlerService->add( + $code, + $name, + $settings, + 100, + 'N' + ); + + $handlerId = $addResult->getId(); + self::assertGreaterThan(0, $handlerId); + + // Clean up + $this->cashboxHandlerService->delete($handlerId); + } + + /** + * @throws BaseException + * @throws TransportException + */ + public function testUpdate(): void + { + // Create a cashbox handler + $code = 'test_cashbox_handler_' . time(); + $name = 'Test Cashbox Handler'; + $settings = $this->getTestSettings(); + + $addResult = $this->cashboxHandlerService->add( + $code, + $name, + $settings, + 100, + 'N' + ); + + $handlerId = $addResult->getId(); + + // Update the handler + $updateFields = [ + 'NAME' => 'Updated Test Cashbox Handler', + 'SORT' => 200 + ]; + + $updateResult = $this->cashboxHandlerService->update($handlerId, $updateFields); + self::assertTrue($updateResult->isSuccess()); + + // Verify the update by listing handlers + $listResult = $this->cashboxHandlerService->list(); + $handlers = $listResult->getCashboxHandlers(); + + $found = false; + foreach ($handlers as $handler) { + if ((int)$handler->ID === $handlerId) { + self::assertEquals('Updated Test Cashbox Handler', $handler->NAME); + self::assertEquals(200, (int)$handler->SORT); + $found = true; + break; + } + } + + self::assertTrue($found, 'Updated handler not found in list'); + + // Clean up + $this->cashboxHandlerService->delete($handlerId); + } + + /** + * @throws BaseException + * @throws TransportException + */ + public function testList(): void + { + // Create a cashbox handler + $code = 'test_cashbox_handler_' . time(); + $name = 'Test List Cashbox Handler'; + $settings = $this->getTestSettings(); + + $addResult = $this->cashboxHandlerService->add( + $code, + $name, + $settings, + 100, + 'N' + ); + + $handlerId = $addResult->getId(); + + // List handlers + $listResult = $this->cashboxHandlerService->list(); + $handlers = $listResult->getCashboxHandlers(); + + self::assertIsArray($handlers); + self::assertGreaterThan(0, count($handlers)); + + // Verify our handler is in the list + $found = false; + foreach ($handlers as $handler) { + if ((int)$handler->ID === $handlerId) { + self::assertEquals($code, $handler->CODE); + self::assertEquals($name, $handler->NAME); + self::assertIsArray($handler->SETTINGS); + self::assertEquals('https://example.com/print_receipt.php', $handler->SETTINGS['PRINT_URL']); + self::assertEquals('https://example.com/check_receipt.php', $handler->SETTINGS['CHECK_URL']); + self::assertEquals('1.1', $handler->SETTINGS['HTTP_VERSION']); + self::assertIsArray($handler->SETTINGS['CONFIG']); + $found = true; + break; + } + } + + self::assertTrue($found, 'Created handler not found in list'); + + // Clean up + $this->cashboxHandlerService->delete($handlerId); + } + + /** + * @throws BaseException + * @throws TransportException + */ + public function testDelete(): void + { + // Create a cashbox handler + $code = 'test_cashbox_handler_' . time(); + $name = 'Test Delete Cashbox Handler'; + $settings = $this->getTestSettings(); + + $addResult = $this->cashboxHandlerService->add( + $code, + $name, + $settings, + 100, + 'N' + ); + + $handlerId = $addResult->getId(); + + // Delete the handler + $deleteResult = $this->cashboxHandlerService->delete($handlerId); + self::assertTrue($deleteResult->isSuccess()); + + // Verify handler no longer exists in the list + $listResult = $this->cashboxHandlerService->list(); + $handlers = $listResult->getCashboxHandlers(); + + $found = false; + foreach ($handlers as $handler) { + if ((int)$handler->ID === $handlerId) { + $found = true; + break; + } + } + + self::assertFalse($found, 'Deleted handler still found in list'); + } +} \ No newline at end of file From ba63d630038331ee011414e235e625199733b776 Mon Sep 17 00:00:00 2001 From: Sally Fancen Date: Wed, 17 Sep 2025 16:28:29 +0400 Subject: [PATCH 2/5] run linters --- .../Result/CashboxHandlerItemResult.php | 2 +- .../Result/CashboxHandlersResult.php | 2 +- .../CashboxHandler/Service/CashboxHandler.php | 2 +- .../Service/CashboxHandlerTest.php | 36 +++++++++---------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Services/Sale/CashboxHandler/Result/CashboxHandlerItemResult.php b/src/Services/Sale/CashboxHandler/Result/CashboxHandlerItemResult.php index 260361ea..8b3a2a23 100644 --- a/src/Services/Sale/CashboxHandler/Result/CashboxHandlerItemResult.php +++ b/src/Services/Sale/CashboxHandler/Result/CashboxHandlerItemResult.php @@ -31,4 +31,4 @@ */ class CashboxHandlerItemResult extends AbstractItem { -} \ No newline at end of file +} diff --git a/src/Services/Sale/CashboxHandler/Result/CashboxHandlersResult.php b/src/Services/Sale/CashboxHandler/Result/CashboxHandlersResult.php index 68bf26dc..e67eba8a 100644 --- a/src/Services/Sale/CashboxHandler/Result/CashboxHandlersResult.php +++ b/src/Services/Sale/CashboxHandler/Result/CashboxHandlersResult.php @@ -34,4 +34,4 @@ public function getCashboxHandlers(): array return $result; } -} \ No newline at end of file +} diff --git a/src/Services/Sale/CashboxHandler/Service/CashboxHandler.php b/src/Services/Sale/CashboxHandler/Service/CashboxHandler.php index de3b3441..188912c2 100644 --- a/src/Services/Sale/CashboxHandler/Service/CashboxHandler.php +++ b/src/Services/Sale/CashboxHandler/Service/CashboxHandler.php @@ -140,4 +140,4 @@ public function delete(int $id): DeletedItemResult ]) ); } -} \ No newline at end of file +} diff --git a/tests/Integration/Services/Sale/CashboxHandler/Service/CashboxHandlerTest.php b/tests/Integration/Services/Sale/CashboxHandler/Service/CashboxHandlerTest.php index d3757dac..31d8b603 100644 --- a/tests/Integration/Services/Sale/CashboxHandler/Service/CashboxHandlerTest.php +++ b/tests/Integration/Services/Sale/CashboxHandler/Service/CashboxHandlerTest.php @@ -101,7 +101,7 @@ public function testAdd(): void $name = 'Test Cashbox Handler'; $settings = $this->getTestSettings(); - $addResult = $this->cashboxHandlerService->add( + $addedItemResult = $this->cashboxHandlerService->add( $code, $name, $settings, @@ -109,7 +109,7 @@ public function testAdd(): void 'N' ); - $handlerId = $addResult->getId(); + $handlerId = $addedItemResult->getId(); self::assertGreaterThan(0, $handlerId); // Clean up @@ -127,7 +127,7 @@ public function testUpdate(): void $name = 'Test Cashbox Handler'; $settings = $this->getTestSettings(); - $addResult = $this->cashboxHandlerService->add( + $addedItemResult = $this->cashboxHandlerService->add( $code, $name, $settings, @@ -135,7 +135,7 @@ public function testUpdate(): void 'N' ); - $handlerId = $addResult->getId(); + $handlerId = $addedItemResult->getId(); // Update the handler $updateFields = [ @@ -143,12 +143,12 @@ public function testUpdate(): void 'SORT' => 200 ]; - $updateResult = $this->cashboxHandlerService->update($handlerId, $updateFields); - self::assertTrue($updateResult->isSuccess()); + $updatedItemResult = $this->cashboxHandlerService->update($handlerId, $updateFields); + self::assertTrue($updatedItemResult->isSuccess()); // Verify the update by listing handlers - $listResult = $this->cashboxHandlerService->list(); - $handlers = $listResult->getCashboxHandlers(); + $cashboxHandlersResult = $this->cashboxHandlerService->list(); + $handlers = $cashboxHandlersResult->getCashboxHandlers(); $found = false; foreach ($handlers as $handler) { @@ -177,7 +177,7 @@ public function testList(): void $name = 'Test List Cashbox Handler'; $settings = $this->getTestSettings(); - $addResult = $this->cashboxHandlerService->add( + $addedItemResult = $this->cashboxHandlerService->add( $code, $name, $settings, @@ -185,11 +185,11 @@ public function testList(): void 'N' ); - $handlerId = $addResult->getId(); + $handlerId = $addedItemResult->getId(); // List handlers - $listResult = $this->cashboxHandlerService->list(); - $handlers = $listResult->getCashboxHandlers(); + $cashboxHandlersResult = $this->cashboxHandlerService->list(); + $handlers = $cashboxHandlersResult->getCashboxHandlers(); self::assertIsArray($handlers); self::assertGreaterThan(0, count($handlers)); @@ -227,7 +227,7 @@ public function testDelete(): void $name = 'Test Delete Cashbox Handler'; $settings = $this->getTestSettings(); - $addResult = $this->cashboxHandlerService->add( + $addedItemResult = $this->cashboxHandlerService->add( $code, $name, $settings, @@ -235,15 +235,15 @@ public function testDelete(): void 'N' ); - $handlerId = $addResult->getId(); + $handlerId = $addedItemResult->getId(); // Delete the handler - $deleteResult = $this->cashboxHandlerService->delete($handlerId); - self::assertTrue($deleteResult->isSuccess()); + $deletedItemResult = $this->cashboxHandlerService->delete($handlerId); + self::assertTrue($deletedItemResult->isSuccess()); // Verify handler no longer exists in the list - $listResult = $this->cashboxHandlerService->list(); - $handlers = $listResult->getCashboxHandlers(); + $cashboxHandlersResult = $this->cashboxHandlerService->list(); + $handlers = $cashboxHandlersResult->getCashboxHandlers(); $found = false; foreach ($handlers as $handler) { From 531fc84f19ea9acae8127c4cadca04b761218c80 Mon Sep 17 00:00:00 2001 From: Sally Fancen Date: Wed, 17 Sep 2025 17:03:39 +0400 Subject: [PATCH 3/5] add Cashbox and tests; run tests --- CHANGELOG.md | 7 + Makefile | 5 + phpunit.xml.dist | 3 + .../Sale/Cashbox/Result/CashboxItemResult.php | 35 ++ .../Sale/Cashbox/Result/CashboxesResult.php | 37 ++ src/Services/Sale/Cashbox/Service/Cashbox.php | 165 +++++++++ src/Services/Sale/SaleServiceBuilder.php | 16 + .../Sale/Cashbox/Service/CashboxTest.php | 317 ++++++++++++++++++ 8 files changed, 585 insertions(+) create mode 100644 src/Services/Sale/Cashbox/Result/CashboxItemResult.php create mode 100644 src/Services/Sale/Cashbox/Result/CashboxesResult.php create mode 100644 src/Services/Sale/Cashbox/Service/Cashbox.php create mode 100644 tests/Integration/Services/Sale/Cashbox/Service/CashboxTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index d92f9d50..f8a5d833 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,13 @@ - `update` updates the data of the REST cashbox handler - `list` returns a list of available REST cashbox handlers - `delete` deletes the REST cashbox handler +- Added service `Services\Sale\Cashbox\Service\Cashbox` with support methods, + see [sale.cashbox.* methods](https://github.com/bitrix24/b24phpsdk/issues/258): + - `add` adds a new cash register + - `update` updates an existing cash register + - `list` returns a list of configured cash registers + - `delete` deletes a cash register + - `checkApply` saves the result of printing the receipt ## 1.6.0 – 2025.09.01 diff --git a/Makefile b/Makefile index 57ef7b3b..b9df8f1e 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,7 @@ help: @echo "test-unit - run unit tests" @echo "test-integration-sale-basket-property - run BasketProperty integration tests" @echo "test-integration-sale-cashbox-handler - run CashboxHandler integration tests" + @echo "test-integration-sale-cashbox - run Cashbox integration tests" .PHONY: docker-init @@ -216,6 +217,10 @@ test-integration-sale-order: .PHONY: test-integration-sale-cashbox-handler test-integration-sale-cashbox-handler: docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_sale_cashbox_handler + +.PHONY: test-integration-sale-cashbox +test-integration-sale-cashbox: + docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_sale_cashbox .PHONY: test-integration-scope-crm test-integration-scope-crm: diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8fcdfc7b..ab90bf1b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -139,6 +139,9 @@ ./tests/Integration/Services/Sale/CashboxHandler/ + + ./tests/Integration/Services/Sale/Cashbox/ + diff --git a/src/Services/Sale/Cashbox/Result/CashboxItemResult.php b/src/Services/Sale/Cashbox/Result/CashboxItemResult.php new file mode 100644 index 00000000..a97eef8b --- /dev/null +++ b/src/Services/Sale/Cashbox/Result/CashboxItemResult.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the MIT-LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Bitrix24\SDK\Services\Sale\Cashbox\Result; + +use Bitrix24\SDK\Core\Result\AbstractItem; + +/** + * Class CashboxItemResult + * + * @property-read int|null $ID + * @property-read string|null $NAME + * @property-read string|null $REST_CODE + * @property-read string|null $EMAIL + * @property-read string|null $OFD + * @property-read array|null $OFD_SETTINGS + * @property-read string|null $NUMBER_KKM + * @property-read string|null $ACTIVE + * @property-read int|null $SORT + * @property-read string|null $USE_OFFLINE + * @property-read array|null $SETTINGS + */ +class CashboxItemResult extends AbstractItem +{ +} \ No newline at end of file diff --git a/src/Services/Sale/Cashbox/Result/CashboxesResult.php b/src/Services/Sale/Cashbox/Result/CashboxesResult.php new file mode 100644 index 00000000..ccf2ce0d --- /dev/null +++ b/src/Services/Sale/Cashbox/Result/CashboxesResult.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the MIT-LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Bitrix24\SDK\Services\Sale\Cashbox\Result; + +use Bitrix24\SDK\Core\Exceptions\BaseException; +use Bitrix24\SDK\Core\Result\AbstractResult; + +/** + * Result for sale.cashbox.list + */ +class CashboxesResult extends AbstractResult +{ + /** + * @return CashboxItemResult[] + * @throws BaseException + */ + public function getCashboxes(): array + { + $result = []; + foreach ($this->getCoreResponse()->getResponseData()->getResult() as $item) { + $result[] = new CashboxItemResult($item); + } + + return $result; + } +} \ No newline at end of file diff --git a/src/Services/Sale/Cashbox/Service/Cashbox.php b/src/Services/Sale/Cashbox/Service/Cashbox.php new file mode 100644 index 00000000..4bd7d0e2 --- /dev/null +++ b/src/Services/Sale/Cashbox/Service/Cashbox.php @@ -0,0 +1,165 @@ + + * + * For the full copyright and license information, please view the MIT-LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Bitrix24\SDK\Services\Sale\Cashbox\Service; + +use Bitrix24\SDK\Attributes\ApiEndpointMetadata; +use Bitrix24\SDK\Attributes\ApiServiceMetadata; +use Bitrix24\SDK\Core\Contracts\CoreInterface; +use Bitrix24\SDK\Core\Credentials\Scope; +use Bitrix24\SDK\Core\Exceptions\BaseException; +use Bitrix24\SDK\Core\Exceptions\TransportException; +use Bitrix24\SDK\Core\Result\AddedItemResult; +use Bitrix24\SDK\Core\Result\DeletedItemResult; +use Bitrix24\SDK\Core\Result\UpdatedItemResult; +use Bitrix24\SDK\Services\AbstractService; +use Bitrix24\SDK\Services\Sale\Cashbox\Result\CashboxesResult; +use Psr\Log\LoggerInterface; + +#[ApiServiceMetadata(new Scope(['sale', 'cashbox']))] +class Cashbox extends AbstractService +{ + public function __construct(CoreInterface $core, LoggerInterface $logger) + { + parent::__construct($core, $logger); + } + + /** + * Adds a new cash register. + * + * @link https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-add.html + * + * @param array $fields Fields for cash register creation (NAME*, REST_CODE*, EMAIL*, OFD, OFD_SETTINGS, NUMBER_KKM, ACTIVE, SORT, USE_OFFLINE, SETTINGS) + * + * @throws BaseException + * @throws TransportException + */ + #[ApiEndpointMetadata( + 'sale.cashbox.add', + 'https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-add.html', + 'Adds a new cash register.' + )] + public function add(array $fields): AddedItemResult + { + return new AddedItemResult( + $this->core->call('sale.cashbox.add', $fields) + ); + } + + /** + * Updates an existing cash register. + * + * @link https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-update.html + * + * @param int $id Identifier of the cash register + * @param array $fields Fields to update (NAME, EMAIL, OFD, OFD_SETTINGS, NUMBER_KKM, ACTIVE, SORT, USE_OFFLINE, SETTINGS) + * + * @throws BaseException + * @throws TransportException + */ + #[ApiEndpointMetadata( + 'sale.cashbox.update', + 'https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-update.html', + 'Updates an existing cash register.' + )] + public function update(int $id, array $fields): UpdatedItemResult + { + return new UpdatedItemResult( + $this->core->call('sale.cashbox.update', [ + 'ID' => $id, + 'FIELDS' => $fields, + ]) + ); + } + + /** + * Returns a list of configured cash registers. + * + * @link https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-list.html + * + * @param array|null $select Fields to select + * @param array|null $filter Filter conditions + * @param array|null $order Sorting parameters + * + * @throws BaseException + * @throws TransportException + */ + #[ApiEndpointMetadata( + 'sale.cashbox.list', + 'https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-list.html', + 'Returns a list of configured cash registers.' + )] + public function list(?array $select = null, ?array $filter = null, ?array $order = null): CashboxesResult + { + $params = []; + if ($select !== null) { + $params['SELECT'] = $select; + } + if ($filter !== null) { + $params['FILTER'] = $filter; + } + if ($order !== null) { + $params['ORDER'] = $order; + } + + return new CashboxesResult( + $this->core->call('sale.cashbox.list', $params) + ); + } + + /** + * Deletes a cash register. + * + * @link https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-delete.html + * + * @param int $id Identifier of the cash register to be deleted + * + * @throws BaseException + * @throws TransportException + */ + #[ApiEndpointMetadata( + 'sale.cashbox.delete', + 'https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-delete.html', + 'Deletes a cash register.' + )] + public function delete(int $id): DeletedItemResult + { + return new DeletedItemResult( + $this->core->call('sale.cashbox.delete', [ + 'ID' => $id, + ]) + ); + } + + /** + * Saves the result of printing the receipt. + * + * @link https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-check-apply.html + * + * @param array $fields Fields for receipt result (UUID*, PRINT_END_TIME, REG_NUMBER_KKT, FISCAL_DOC_ATTR, FISCAL_DOC_NUMBER, FISCAL_RECEIPT_NUMBER, FN_NUMBER, SHIFT_NUMBER) + * + * @throws BaseException + * @throws TransportException + */ + #[ApiEndpointMetadata( + 'sale.cashbox.check.apply', + 'https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-check-apply.html', + 'Saves the result of printing the receipt.' + )] + public function checkApply(array $fields): UpdatedItemResult + { + return new UpdatedItemResult( + $this->core->call('sale.cashbox.check.apply', $fields) + ); + } +} \ No newline at end of file diff --git a/src/Services/Sale/SaleServiceBuilder.php b/src/Services/Sale/SaleServiceBuilder.php index 8ce9bfa2..3e1e79a8 100644 --- a/src/Services/Sale/SaleServiceBuilder.php +++ b/src/Services/Sale/SaleServiceBuilder.php @@ -24,6 +24,7 @@ use Bitrix24\SDK\Services\Sale\PersonTypeStatus\Service\PersonTypeStatus; use Bitrix24\SDK\Services\Sale\BasketProperty\Service\BasketProperty; use Bitrix24\SDK\Services\Sale\CashboxHandler\Service\CashboxHandler; +use Bitrix24\SDK\Services\Sale\Cashbox\Service\Cashbox; /** * Class SaleServiceBuilder @@ -219,4 +220,19 @@ public function cashboxHandler(): CashboxHandler return $this->serviceCache[__METHOD__]; } + + /** + * Cash registers service (sale.cashbox.*) + */ + public function cashbox(): Cashbox + { + if (!isset($this->serviceCache[__METHOD__])) { + $this->serviceCache[__METHOD__] = new Cashbox( + $this->core, + $this->log + ); + } + + return $this->serviceCache[__METHOD__]; + } } diff --git a/tests/Integration/Services/Sale/Cashbox/Service/CashboxTest.php b/tests/Integration/Services/Sale/Cashbox/Service/CashboxTest.php new file mode 100644 index 00000000..a8f6c4e8 --- /dev/null +++ b/tests/Integration/Services/Sale/Cashbox/Service/CashboxTest.php @@ -0,0 +1,317 @@ + + * + * For the full copyright and license information, please view the MIT-LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Bitrix24\SDK\Tests\Integration\Services\Sale\Cashbox\Service; + +use Bitrix24\SDK\Core\Exceptions\BaseException; +use Bitrix24\SDK\Core\Exceptions\TransportException; +use Bitrix24\SDK\Services\Sale\Cashbox\Service\Cashbox; +use Bitrix24\SDK\Services\Sale\CashboxHandler\Service\CashboxHandler; +use Bitrix24\SDK\Tests\Integration\Fabric; +use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\TestCase; + +/** + * Class CashboxTest + * + * @package Bitrix24\SDK\Tests\Integration\Services\Sale\Cashbox\Service + */ +#[CoversMethod(Cashbox::class, 'add')] +#[CoversMethod(Cashbox::class, 'update')] +#[CoversMethod(Cashbox::class, 'list')] +#[CoversMethod(Cashbox::class, 'delete')] +#[CoversMethod(Cashbox::class, 'checkApply')] +#[\PHPUnit\Framework\Attributes\CoversClass(\Bitrix24\SDK\Services\Sale\Cashbox\Service\Cashbox::class)] +class CashboxTest extends TestCase +{ + protected Cashbox $cashboxService; + protected CashboxHandler $cashboxHandlerService; + + protected function setUp(): void + { + $this->cashboxService = Fabric::getServiceBuilder()->getSaleScope()->cashbox(); + $this->cashboxHandlerService = Fabric::getServiceBuilder()->getSaleScope()->cashboxHandler(); + } + + /** + * Generate test settings for cashbox handler + */ + protected function getTestHandlerSettings(): array + { + return [ + 'PRINT_URL' => 'https://example.com/print_receipt.php', + 'CHECK_URL' => 'https://example.com/check_receipt.php', + 'HTTP_VERSION' => '1.1', + 'CONFIG' => [ + 'AUTH' => [ + 'LABEL' => 'Authorization', + 'ITEMS' => [ + 'LOGIN' => [ + 'TYPE' => 'STRING', + 'LABEL' => 'Login', + 'REQUIRED' => 'Y' + ], + 'PASSWORD' => [ + 'TYPE' => 'STRING', + 'LABEL' => 'Password', + 'REQUIRED' => 'Y' + ] + ] + ] + ] + ]; + } + + /** + * Create a cashbox handler and return its code + */ + protected function createTestCashboxHandler(): array + { + $code = 'test_cashbox_handler_' . time(); + $name = 'Test Cashbox Handler'; + $settings = $this->getTestHandlerSettings(); + + $addedItemResult = $this->cashboxHandlerService->add( + $code, + $name, + $settings, + 100, + 'N' + ); + + return [ + 'id' => $addedItemResult->getId(), + 'code' => $code + ]; + } + + /** + * Generate test fields for cashbox creation + */ + protected function getTestCashboxFields(string $restCode): array + { + return [ + 'NAME' => 'Test Cash Register ' . time(), + 'REST_CODE' => $restCode, + 'EMAIL' => 'test@example.com', + 'ACTIVE' => 'Y', + 'SORT' => 100, + 'USE_OFFLINE' => 'N', + 'SETTINGS' => [ + 'TEST_MODE' => 'Y', + 'TIMEOUT' => 30 + ] + ]; + } + + /** + * @throws BaseException + * @throws TransportException + */ + public function testAdd(): void + { + // Create a cashbox handler first + $handlerData = $this->createTestCashboxHandler(); + $fields = $this->getTestCashboxFields($handlerData['code']); + + $addedItemResult = $this->cashboxService->add($fields); + + $cashboxId = $addedItemResult->getId(); + self::assertGreaterThan(0, $cashboxId); + + // Clean up + $this->cashboxService->delete($cashboxId); + $this->cashboxHandlerService->delete($handlerData['id']); + } + + /** + * @throws BaseException + * @throws TransportException + */ + public function testUpdate(): void + { + // Create a cashbox handler first + $handlerData = $this->createTestCashboxHandler(); + $fields = $this->getTestCashboxFields($handlerData['code']); + + $addedItemResult = $this->cashboxService->add($fields); + $cashboxId = $addedItemResult->getId(); + + // Update the cashbox + $updateFields = [ + 'NAME' => 'Updated Test Cash Register', + 'ACTIVE' => 'N', + 'SORT' => 200 + ]; + + $updatedItemResult = $this->cashboxService->update($cashboxId, $updateFields); + self::assertTrue($updatedItemResult->isSuccess()); + + // Verify the update by listing cashboxes + $cashboxesResult = $this->cashboxService->list(); + $cashboxes = $cashboxesResult->getCashboxes(); + + $found = false; + foreach ($cashboxes as $cashbox) { + if ((int)$cashbox->ID === $cashboxId) { + self::assertEquals('Updated Test Cash Register', $cashbox->NAME); + self::assertEquals('N', $cashbox->ACTIVE); + self::assertEquals(200, (int)$cashbox->SORT); + $found = true; + break; + } + } + + self::assertTrue($found, 'Updated cashbox not found in list'); + + // Clean up + $this->cashboxService->delete($cashboxId); + $this->cashboxHandlerService->delete($handlerData['id']); + } + + /** + * @throws BaseException + * @throws TransportException + */ + public function testList(): void + { + // Create a cashbox handler first + $handlerData = $this->createTestCashboxHandler(); + $fields = $this->getTestCashboxFields($handlerData['code']); + + $addedItemResult = $this->cashboxService->add($fields); + $cashboxId = $addedItemResult->getId(); + + // List cashboxes + $cashboxesResult = $this->cashboxService->list(); + $cashboxes = $cashboxesResult->getCashboxes(); + + self::assertIsArray($cashboxes); + self::assertGreaterThan(0, count($cashboxes)); + + // Verify our cashbox is in the list + $found = false; + foreach ($cashboxes as $cashbox) { + if ((int)$cashbox->ID === $cashboxId) { + self::assertEquals($fields['NAME'], $cashbox->NAME); + self::assertEquals($fields['EMAIL'], $cashbox->EMAIL); + self::assertEquals($fields['ACTIVE'], $cashbox->ACTIVE); + self::assertEquals($fields['SORT'], (int)$cashbox->SORT); + self::assertEquals($fields['USE_OFFLINE'], $cashbox->USE_OFFLINE); + // Note: REST_CODE is not returned by the API in list response + $found = true; + break; + } + } + + self::assertTrue($found, 'Created cashbox not found in list'); + + // Clean up + $this->cashboxService->delete($cashboxId); + $this->cashboxHandlerService->delete($handlerData['id']); + } + + /** + * @throws BaseException + * @throws TransportException + */ + public function testListWithFilters(): void + { + // Create a cashbox handler first + $handlerData = $this->createTestCashboxHandler(); + $fields = $this->getTestCashboxFields($handlerData['code']); + $fields['ACTIVE'] = 'N'; + + $addedItemResult = $this->cashboxService->add($fields); + $cashboxId = $addedItemResult->getId(); + + // List only inactive cashboxes + $cashboxesResult = $this->cashboxService->list( + ['ID', 'NAME', 'ACTIVE'], + ['ACTIVE' => 'N'], + ['ID' => 'DESC'] + ); + $cashboxes = $cashboxesResult->getCashboxes(); + + self::assertIsArray($cashboxes); + + // Verify filtering worked + foreach ($cashboxes as $cashbox) { + self::assertEquals('N', $cashbox->ACTIVE); + } + + // Clean up + $this->cashboxService->delete($cashboxId); + $this->cashboxHandlerService->delete($handlerData['id']); + } + + /** + * @throws BaseException + * @throws TransportException + */ + public function testDelete(): void + { + // Create a cashbox handler first + $handlerData = $this->createTestCashboxHandler(); + $fields = $this->getTestCashboxFields($handlerData['code']); + + $addedItemResult = $this->cashboxService->add($fields); + $cashboxId = $addedItemResult->getId(); + + // Delete the cashbox + $deletedItemResult = $this->cashboxService->delete($cashboxId); + self::assertTrue($deletedItemResult->isSuccess()); + + // Verify cashbox no longer exists in the list + $cashboxesResult = $this->cashboxService->list(); + $cashboxes = $cashboxesResult->getCashboxes(); + + $found = false; + foreach ($cashboxes as $cashbox) { + if ((int)$cashbox->ID === $cashboxId) { + $found = true; + break; + } + } + + self::assertFalse($found, 'Deleted cashbox still found in list'); + + // Clean up handler + $this->cashboxHandlerService->delete($handlerData['id']); + } + + /** + * @throws BaseException + * @throws TransportException + */ + public function testCheckApply(): void + { + $checkApplyFields = [ + 'UUID' => 'test_receipt_' . time(), + 'PRINT_END_TIME' => (string)time(), + 'REG_NUMBER_KKT' => '1234567891011121', + 'FISCAL_DOC_ATTR' => '1234567890', + 'FISCAL_DOC_NUMBER' => '12345', + 'FISCAL_RECEIPT_NUMBER' => '123', + 'FN_NUMBER' => '1234567891011121', + 'SHIFT_NUMBER' => '1' + ]; + + // This test expects an error since we're using a non-existent receipt UUID + // In a real scenario, the receipt would be created first through the print process + $this->expectException(\Bitrix24\SDK\Core\Exceptions\BaseException::class); + $this->expectExceptionMessage('check not found'); + + $this->cashboxService->checkApply($checkApplyFields); + } +} \ No newline at end of file From e96882dd1918f3cd4d7265ad04bbf437d1546856 Mon Sep 17 00:00:00 2001 From: Sally Fancen Date: Wed, 17 Sep 2025 17:06:25 +0400 Subject: [PATCH 4/5] run linters --- src/Services/Sale/Cashbox/Result/CashboxItemResult.php | 2 +- src/Services/Sale/Cashbox/Result/CashboxesResult.php | 2 +- src/Services/Sale/Cashbox/Service/Cashbox.php | 4 +++- .../Integration/Services/Sale/Cashbox/Service/CashboxTest.php | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Services/Sale/Cashbox/Result/CashboxItemResult.php b/src/Services/Sale/Cashbox/Result/CashboxItemResult.php index a97eef8b..48cbd624 100644 --- a/src/Services/Sale/Cashbox/Result/CashboxItemResult.php +++ b/src/Services/Sale/Cashbox/Result/CashboxItemResult.php @@ -32,4 +32,4 @@ */ class CashboxItemResult extends AbstractItem { -} \ No newline at end of file +} diff --git a/src/Services/Sale/Cashbox/Result/CashboxesResult.php b/src/Services/Sale/Cashbox/Result/CashboxesResult.php index ccf2ce0d..d2e006b3 100644 --- a/src/Services/Sale/Cashbox/Result/CashboxesResult.php +++ b/src/Services/Sale/Cashbox/Result/CashboxesResult.php @@ -34,4 +34,4 @@ public function getCashboxes(): array return $result; } -} \ No newline at end of file +} diff --git a/src/Services/Sale/Cashbox/Service/Cashbox.php b/src/Services/Sale/Cashbox/Service/Cashbox.php index 4bd7d0e2..aa175cbb 100644 --- a/src/Services/Sale/Cashbox/Service/Cashbox.php +++ b/src/Services/Sale/Cashbox/Service/Cashbox.php @@ -105,9 +105,11 @@ public function list(?array $select = null, ?array $filter = null, ?array $order if ($select !== null) { $params['SELECT'] = $select; } + if ($filter !== null) { $params['FILTER'] = $filter; } + if ($order !== null) { $params['ORDER'] = $order; } @@ -162,4 +164,4 @@ public function checkApply(array $fields): UpdatedItemResult $this->core->call('sale.cashbox.check.apply', $fields) ); } -} \ No newline at end of file +} diff --git a/tests/Integration/Services/Sale/Cashbox/Service/CashboxTest.php b/tests/Integration/Services/Sale/Cashbox/Service/CashboxTest.php index a8f6c4e8..ea9b95f2 100644 --- a/tests/Integration/Services/Sale/Cashbox/Service/CashboxTest.php +++ b/tests/Integration/Services/Sale/Cashbox/Service/CashboxTest.php @@ -35,6 +35,7 @@ class CashboxTest extends TestCase { protected Cashbox $cashboxService; + protected CashboxHandler $cashboxHandlerService; protected function setUp(): void @@ -311,7 +312,7 @@ public function testCheckApply(): void // In a real scenario, the receipt would be created first through the print process $this->expectException(\Bitrix24\SDK\Core\Exceptions\BaseException::class); $this->expectExceptionMessage('check not found'); - + $this->cashboxService->checkApply($checkApplyFields); } } \ No newline at end of file From c6ab5a5abc198b6fb08dc09a12bbfeda18097eda Mon Sep 17 00:00:00 2001 From: Sally Fancen Date: Mon, 6 Oct 2025 11:37:35 +0400 Subject: [PATCH 5/5] run linters --- src/Services/Sale/SaleServiceBuilder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Services/Sale/SaleServiceBuilder.php b/src/Services/Sale/SaleServiceBuilder.php index f082b94a..a2d296bb 100644 --- a/src/Services/Sale/SaleServiceBuilder.php +++ b/src/Services/Sale/SaleServiceBuilder.php @@ -324,7 +324,7 @@ public function cashboxHandler(): CashboxHandler return $this->serviceCache[__METHOD__]; } - + /** * DeliveryHandler service (sale.delivery.handler.*) */ @@ -354,7 +354,7 @@ public function cashbox(): Cashbox return $this->serviceCache[__METHOD__]; } - + /** * Delivery service (sale.delivery.*) */