Compare commits

...

7 Commits

21 changed files with 630 additions and 620 deletions

View File

@ -16,9 +16,9 @@
---
| master | [![CI](https://github.com/anthonyaxenov/atol-online/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/anthonyaxenov/atol-online/actions/workflows/ci.yml) | [![codecov](https://codecov.io/gh/anthonyaxenov/atol-online/branch/master/graph/badge.svg?token=WR2IV7FTF0)](https://codecov.io/gh/anthonyaxenov/atol-online) |
|---|---|---|
| dev | [![CI dev](https://github.com/anthonyaxenov/atol-online/actions/workflows/ci.yml/badge.svg?branch=dev)](https://github.com/anthonyaxenov/atol-online/actions/workflows/ci.yml) | [![codecov dev](https://codecov.io/gh/anthonyaxenov/atol-online/branch/dev/graph/badge.svg?token=WR2IV7FTF0)](https://codecov.io/gh/anthonyaxenov/atol-online) |
| master | [![CI](https://github.com/anthonyaxenov/atol-online/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/anthonyaxenov/atol-online/actions/workflows/ci.yml) | [![codecov](https://codecov.io/gh/anthonyaxenov/atol-online/branch/master/graph/badge.svg?token=WR2IV7FTF0)](https://codecov.io/gh/anthonyaxenov/atol-online) |
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| dev | [![CI dev](https://github.com/anthonyaxenov/atol-online/actions/workflows/ci.yml/badge.svg?branch=dev)](https://github.com/anthonyaxenov/atol-online/actions/workflows/ci.yml) | [![codecov dev](https://codecov.io/gh/anthonyaxenov/atol-online/branch/dev/graph/badge.svg?token=WR2IV7FTF0)](https://codecov.io/gh/anthonyaxenov/atol-online) |
Текущие поддерживаемые версии АТОЛ Онлайн:
@ -92,7 +92,6 @@ composer test-cov # тестирование с покрытием
* **[Документация к библиотеке](/docs/readme.md)**
* Telegram-канал: [@atolonline_php](https://t.me/atolonline_php)
* [Документация АТОЛ Онлайн](https://online.atol.ru/lib/)
* Функционал, находящийся в разработке: [ROADMAP.md](ROADMAP.md)
## Лицензия

View File

@ -1,66 +0,0 @@
# Roadmap
Здесь перечислены реализованные функции и находящиеся в разработке.
Порядок их упоминания здесь может не совпадать с порядком реализации.
Эталонная реализация подразумевает полную поддержку всех методов API и обеих схем документов:
* [Документы прихода, возврата прихода, расхода, возврата расхода](https://online.atol.ru/possystem/v4/schema/sell)
* [Документы коррекции прихода, коррекции расхода](https://online.atol.ru/possystem/v4/schema/correction)
## Общий функционал библиотеки
- [x] Переключение настроек доступа к ККТ при переключении тестового режима
- [x] Тесты для класса налоговой ставки (+ массив)
- [ ] Тесты для класса оплаты (+ массив)
- [x] Тесты для класса предмета расчёта (+ массив)
- [x] Тесты для класса клиента
- [x] Тесты для класса компании
- [ ] Тесты для класса данных коррекций
- [ ] Тесты для класса документа
- [ ] Тесты для класса ответа ККТ
- [ ] Тесты для регистрации документа прихода
- [ ] Тесты для регистрации документа возврата прихода
- [ ] Тесты для регистрации документа коррекции прихода
- [ ] Тесты для регистрации документа расхода
- [ ] Тесты для регистрации документа возврата расхода
- [ ] Тесты для регистрации документа коррекции расхода
- [ ] Вообще все расчёты вообще везде должны быть строго в копейках.
Рубли (дроби) должны быть только в JSON-представлениях
## Поддержка методов API (регистрация документов)
- [x] приход
- [x] расход
- [x] возврат прихода
- [x] возврат расхода
- [x] коррекция прихода
- [x] коррекция расхода
- [x] проверка статуса документа
## Документы прихода, возврата прихода, расхода, возврата расхода
- [x] Пoддержка `receipt.client` (обязательный)
- [x] Пoддержка `receipt.company` (обязательный)
- [x] Пoддержка `receipt.items` (обязательный)
- [x] Пoддержка `receipt.total` (обязательный)
- [x] Пoддержка `receipt.payments` (обязательный)
- [x] Пoддержка `receipt.vats`
- [ ] Пoддержка `receipt.additional_check_props`
- [x] Пoддержка `receipt.cashier`
- [ ] Пoддержка `receipt.additional_user_props`
- [ ] Пoддержка `receipt.agent_info`
- [ ] Пoддержка `receipt.supplier_info`
- [ ] Пoддержка `receipt.items.agent_info`
- [ ] Пoддержка `receipt.items.supplier_info`
- [ ] Пoддержка `receipt.items.nomenclature_code`
- [ ] Пoддержка `receipt.items.excise`
- [ ] Пoддержка `receipt.items.country_code`
- [ ] Пoддержка `receipt.items.declaration_number`
## Документы коррекции прихода, коррекции расхода
- [x] Пoддержка `correction.company` (обязательный)
- [x] Пoддержка `correction.vats` (обязательный)
- [x] Пoддержка `correction.correction_info` (обязательный)
- [x] Пoддержка `correction.cashier`

View File

@ -56,7 +56,8 @@
"psr/log": "^3",
"ramsey/uuid": "^4.2",
"myclabs/php-enum": "^1.8",
"illuminate/collections": "^8.70"
"illuminate/collections": "^8.70",
"jetbrains/phpstorm-attributes": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5"

300
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "b03e06fba2a861f7ce366484ec6421c3",
"content-hash": "4877f27cd59b6558eea01644e2d520ef",
"packages": [
{
"name": "brick/math",
@ -50,6 +50,10 @@
"brick",
"math"
],
"support": {
"issues": "https://github.com/brick/math/issues",
"source": "https://github.com/brick/math/tree/0.9.3"
},
"funding": [
{
"url": "https://github.com/BenMorel",
@ -166,6 +170,10 @@
"rest",
"web service"
],
"support": {
"issues": "https://github.com/guzzle/guzzle/issues",
"source": "https://github.com/guzzle/guzzle/tree/7.4.0"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
@ -246,6 +254,10 @@
"keywords": [
"promise"
],
"support": {
"issues": "https://github.com/guzzle/promises/issues",
"source": "https://github.com/guzzle/promises/tree/1.5.1"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
@ -357,6 +369,10 @@
"uri",
"url"
],
"support": {
"issues": "https://github.com/guzzle/psr7/issues",
"source": "https://github.com/guzzle/psr7/tree/2.1.0"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
@ -375,16 +391,16 @@
},
{
"name": "illuminate/collections",
"version": "v8.70.2",
"version": "v8.74.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/collections.git",
"reference": "05f286ec5fd2dd286e8384577047efc375c8954c"
"reference": "f292b77824b42cd28decc7327e7c2e24c3806371"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/collections/zipball/05f286ec5fd2dd286e8384577047efc375c8954c",
"reference": "05f286ec5fd2dd286e8384577047efc375c8954c",
"url": "https://api.github.com/repos/illuminate/collections/zipball/f292b77824b42cd28decc7327e7c2e24c3806371",
"reference": "f292b77824b42cd28decc7327e7c2e24c3806371",
"shasum": ""
},
"require": {
@ -393,7 +409,7 @@
"php": "^7.3|^8.0"
},
"suggest": {
"symfony/var-dumper": "Required to use the dump method (^5.1.4)."
"symfony/var-dumper": "Required to use the dump method (^5.4)."
},
"type": "library",
"extra": {
@ -421,20 +437,24 @@
],
"description": "The Illuminate Collections package.",
"homepage": "https://laravel.com",
"time": "2021-10-22T18:01:46+00:00"
"support": {
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2021-11-30T14:29:03+00:00"
},
{
"name": "illuminate/contracts",
"version": "v8.70.2",
"version": "v8.74.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/contracts.git",
"reference": "e76f4bce73a2a1656add24bd5210ebc4b8af49c0"
"reference": "b0886ec05a63b204634d64d0b39d5b78a7c06f81"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/contracts/zipball/e76f4bce73a2a1656add24bd5210ebc4b8af49c0",
"reference": "e76f4bce73a2a1656add24bd5210ebc4b8af49c0",
"url": "https://api.github.com/repos/illuminate/contracts/zipball/b0886ec05a63b204634d64d0b39d5b78a7c06f81",
"reference": "b0886ec05a63b204634d64d0b39d5b78a7c06f81",
"shasum": ""
},
"require": {
@ -465,20 +485,24 @@
],
"description": "The Illuminate Contracts package.",
"homepage": "https://laravel.com",
"time": "2021-10-22T18:01:46+00:00"
"support": {
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2021-11-17T15:04:30+00:00"
},
{
"name": "illuminate/macroable",
"version": "v8.70.2",
"version": "v8.74.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/macroable.git",
"reference": "300aa13c086f25116b5f3cde3ca54ff5c822fb05"
"reference": "aed81891a6e046fdee72edd497f822190f61c162"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/macroable/zipball/300aa13c086f25116b5f3cde3ca54ff5c822fb05",
"reference": "300aa13c086f25116b5f3cde3ca54ff5c822fb05",
"url": "https://api.github.com/repos/illuminate/macroable/zipball/aed81891a6e046fdee72edd497f822190f61c162",
"reference": "aed81891a6e046fdee72edd497f822190f61c162",
"shasum": ""
},
"require": {
@ -507,7 +531,53 @@
],
"description": "The Illuminate Macroable package.",
"homepage": "https://laravel.com",
"time": "2020-10-27T15:20:30+00:00"
"support": {
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2021-11-16T13:57:03+00:00"
},
{
"name": "jetbrains/phpstorm-attributes",
"version": "1.0",
"source": {
"type": "git",
"url": "https://github.com/JetBrains/phpstorm-attributes.git",
"reference": "a7a83ae5df4dd3c0875484483de19de8edf60a9f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/JetBrains/phpstorm-attributes/zipball/a7a83ae5df4dd3c0875484483de19de8edf60a9f",
"reference": "a7a83ae5df4dd3c0875484483de19de8edf60a9f",
"shasum": ""
},
"type": "library",
"autoload": {
"psr-4": {
"JetBrains\\PhpStorm\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "JetBrains",
"homepage": "https://www.jetbrains.com"
}
],
"description": "PhpStorm specific attributes",
"keywords": [
"attributes",
"jetbrains",
"phpstorm"
],
"support": {
"issues": "https://youtrack.jetbrains.com/newIssue?project=WI",
"source": "https://github.com/JetBrains/phpstorm-attributes/tree/1.0"
},
"time": "2020-11-17T11:09:47+00:00"
},
{
"name": "myclabs/php-enum",
@ -553,6 +623,10 @@
"keywords": [
"enum"
],
"support": {
"issues": "https://github.com/myclabs/php-enum/issues",
"source": "https://github.com/myclabs/php-enum/tree/1.8.3"
},
"funding": [
{
"url": "https://github.com/mnapoli",
@ -607,6 +681,10 @@
"container-interop",
"psr"
],
"support": {
"issues": "https://github.com/php-fig/container/issues",
"source": "https://github.com/php-fig/container/tree/1.1.2"
},
"time": "2021-11-05T16:50:12+00:00"
},
{
@ -656,6 +734,9 @@
"psr",
"psr-18"
],
"support": {
"source": "https://github.com/php-fig/http-client/tree/master"
},
"time": "2020-06-29T06:28:15+00:00"
},
{
@ -708,6 +789,9 @@
"request",
"response"
],
"support": {
"source": "https://github.com/php-fig/http-factory/tree/master"
},
"time": "2019-04-30T12:38:16+00:00"
},
{
@ -808,6 +892,9 @@
"psr",
"psr-3"
],
"support": {
"source": "https://github.com/php-fig/log/tree/3.0.0"
},
"time": "2021-07-14T16:46:02+00:00"
},
{
@ -856,6 +943,9 @@
"psr-16",
"simple-cache"
],
"support": {
"source": "https://github.com/php-fig/simple-cache/tree/master"
},
"time": "2017-10-23T01:57:42+00:00"
},
{
@ -965,6 +1055,10 @@
"queue",
"set"
],
"support": {
"issues": "https://github.com/ramsey/collection/issues",
"source": "https://github.com/ramsey/collection/tree/1.2.2"
},
"funding": [
{
"url": "https://github.com/ramsey",
@ -1059,6 +1153,10 @@
"identifier",
"uuid"
],
"support": {
"issues": "https://github.com/ramsey/uuid/issues",
"source": "https://github.com/ramsey/uuid/tree/4.2.3"
},
"funding": [
{
"url": "https://github.com/ramsey",
@ -1073,16 +1171,16 @@
},
{
"name": "symfony/deprecation-contracts",
"version": "v2.4.0",
"version": "v2.5.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627"
"reference": "6f981ee24cf69ee7ce9736146d1c57c2780598a8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627",
"reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/6f981ee24cf69ee7ce9736146d1c57c2780598a8",
"reference": "6f981ee24cf69ee7ce9736146d1c57c2780598a8",
"shasum": ""
},
"require": {
@ -1091,7 +1189,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "2.4-dev"
"dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
@ -1119,6 +1217,9 @@
],
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
@ -1133,7 +1234,7 @@
"type": "tidelift"
}
],
"time": "2021-03-23T23:28:01+00:00"
"time": "2021-07-12T14:48:14+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -1195,6 +1296,9 @@
"polyfill",
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
@ -1275,6 +1379,9 @@
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
@ -1351,6 +1458,9 @@
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php81/tree/v1.23.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
@ -1498,16 +1608,16 @@
},
{
"name": "nikic/php-parser",
"version": "v4.13.1",
"version": "v4.13.2",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd"
"reference": "210577fe3cf7badcc5814d99455df46564f3c077"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/63a79e8daa781cac14e5195e63ed8ae231dd10fd",
"reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077",
"reference": "210577fe3cf7badcc5814d99455df46564f3c077",
"shasum": ""
},
"require": {
@ -1546,7 +1656,11 @@
"parser",
"php"
],
"time": "2021-11-03T20:52:16+00:00"
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v4.13.2"
},
"time": "2021-11-30T19:35:32+00:00"
},
{
"name": "phar-io/manifest",
@ -1602,6 +1716,10 @@
}
],
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
"support": {
"issues": "https://github.com/phar-io/manifest/issues",
"source": "https://github.com/phar-io/manifest/tree/2.0.3"
},
"time": "2021-07-20T11:28:43+00:00"
},
{
@ -1759,6 +1877,10 @@
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"support": {
"issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues",
"source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0"
},
"time": "2021-10-19T17:43:47+00:00"
},
{
@ -1805,6 +1927,10 @@
}
],
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"support": {
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.5.1"
},
"time": "2021-10-02T14:08:47+00:00"
},
{
@ -1868,20 +1994,24 @@
"spy",
"stub"
],
"support": {
"issues": "https://github.com/phpspec/prophecy/issues",
"source": "https://github.com/phpspec/prophecy/tree/1.14.0"
},
"time": "2021-09-10T09:02:12+00:00"
},
{
"name": "phpunit/php-code-coverage",
"version": "9.2.8",
"version": "9.2.9",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "cf04e88a2e3c56fc1a65488afd493325b4c1bc3e"
"reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/cf04e88a2e3c56fc1a65488afd493325b4c1bc3e",
"reference": "cf04e88a2e3c56fc1a65488afd493325b4c1bc3e",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f301eb1453c9e7a1bc912ee8b0ea9db22c60223b",
"reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b",
"shasum": ""
},
"require": {
@ -1935,26 +2065,30 @@
"testing",
"xunit"
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.9"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2021-10-30T08:01:38+00:00"
"time": "2021-11-19T15:21:02+00:00"
},
{
"name": "phpunit/php-file-iterator",
"version": "3.0.5",
"version": "3.0.6",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "aa4be8575f26070b100fccb67faabb28f21f66f8"
"reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8",
"reference": "aa4be8575f26070b100fccb67faabb28f21f66f8",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf",
"reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf",
"shasum": ""
},
"require": {
@ -1991,13 +2125,17 @@
"filesystem",
"iterator"
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
"source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-09-28T05:57:25+00:00"
"time": "2021-12-02T12:48:52+00:00"
},
{
"name": "phpunit/php-invoker",
@ -2050,6 +2188,10 @@
"keywords": [
"process"
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-invoker/issues",
"source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -2105,6 +2247,10 @@
"keywords": [
"template"
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-text-template/issues",
"source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -2160,6 +2306,10 @@
"keywords": [
"timer"
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-timer/issues",
"source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -2255,6 +2405,10 @@
"testing",
"xunit"
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.10"
},
"funding": [
{
"url": "https://phpunit.de/donate.html",
@ -2311,6 +2465,10 @@
],
"description": "Library for parsing CLI options",
"homepage": "https://github.com/sebastianbergmann/cli-parser",
"support": {
"issues": "https://github.com/sebastianbergmann/cli-parser/issues",
"source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -2363,6 +2521,10 @@
],
"description": "Collection of value objects that represent the PHP code units",
"homepage": "https://github.com/sebastianbergmann/code-unit",
"support": {
"issues": "https://github.com/sebastianbergmann/code-unit/issues",
"source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -2414,6 +2576,10 @@
],
"description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
"support": {
"issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues",
"source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -2484,6 +2650,10 @@
"compare",
"equality"
],
"support": {
"issues": "https://github.com/sebastianbergmann/comparator/issues",
"source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -2537,6 +2707,10 @@
],
"description": "Library for calculating the complexity of PHP code units",
"homepage": "https://github.com/sebastianbergmann/complexity",
"support": {
"issues": "https://github.com/sebastianbergmann/complexity/issues",
"source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -2599,6 +2773,10 @@
"unidiff",
"unified diff"
],
"support": {
"issues": "https://github.com/sebastianbergmann/diff/issues",
"source": "https://github.com/sebastianbergmann/diff/tree/4.0.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -2658,6 +2836,10 @@
"environment",
"hhvm"
],
"support": {
"issues": "https://github.com/sebastianbergmann/environment/issues",
"source": "https://github.com/sebastianbergmann/environment/tree/5.1.3"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -2731,6 +2913,10 @@
"export",
"exporter"
],
"support": {
"issues": "https://github.com/sebastianbergmann/exporter/issues",
"source": "https://github.com/sebastianbergmann/exporter/tree/4.0.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -2791,6 +2977,10 @@
"keywords": [
"global state"
],
"support": {
"issues": "https://github.com/sebastianbergmann/global-state/issues",
"source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -2844,6 +3034,10 @@
],
"description": "Library for counting the lines of code in PHP source code",
"homepage": "https://github.com/sebastianbergmann/lines-of-code",
"support": {
"issues": "https://github.com/sebastianbergmann/lines-of-code/issues",
"source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -2897,6 +3091,10 @@
],
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
"support": {
"issues": "https://github.com/sebastianbergmann/object-enumerator/issues",
"source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -2948,6 +3146,10 @@
],
"description": "Allows reflection of object attributes, including inherited and non-public ones",
"homepage": "https://github.com/sebastianbergmann/object-reflector/",
"support": {
"issues": "https://github.com/sebastianbergmann/object-reflector/issues",
"source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -3007,6 +3209,10 @@
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"support": {
"issues": "https://github.com/sebastianbergmann/recursion-context/issues",
"source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -3058,6 +3264,10 @@
],
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"support": {
"issues": "https://github.com/sebastianbergmann/resource-operations/issues",
"source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -3110,6 +3320,10 @@
],
"description": "Collection of value objects that represent the types of the PHP type system",
"homepage": "https://github.com/sebastianbergmann/type",
"support": {
"issues": "https://github.com/sebastianbergmann/type/issues",
"source": "https://github.com/sebastianbergmann/type/tree/2.3.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -3159,6 +3373,10 @@
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
"support": {
"issues": "https://github.com/sebastianbergmann/version/issues",
"source": "https://github.com/sebastianbergmann/version/tree/3.0.2"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -3205,6 +3423,10 @@
}
],
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
"support": {
"issues": "https://github.com/theseer/tokenizer/issues",
"source": "https://github.com/theseer/tokenizer/tree/1.2.1"
},
"funding": [
{
"url": "https://github.com/theseer",
@ -3283,5 +3505,5 @@
"ext-mbstring": "*"
},
"platform-dev": [],
"plugin-api-version": "1.1.0"
"plugin-api-version": "2.1.0"
}

View File

@ -19,7 +19,7 @@ use AtolOnline\Exceptions\InvalidEnumValueException;
*
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 26-28
*/
class AgentInfo extends Entity
final class AgentInfo extends Entity
{
/**
* @var string|null Признак агента (1057)
@ -45,21 +45,21 @@ class AgentInfo extends Entity
* Конструктор
*
* @param string|null $type Признак агента (1057)
* @param PayingAgent|null $paying_agent Платёжный агент
* @param ReceivePaymentsOperator|null $receive_payments_operator Оператор по приёму платежей
* @param MoneyTransferOperator|null $money_transfer_operator Оператор перевода
* @param PayingAgent|null $pagent Платёжный агент
* @param ReceivePaymentsOperator|null $rp_operator Оператор по приёму платежей
* @param MoneyTransferOperator|null $mt_operator Оператор перевода
* @throws InvalidEnumValueException
*/
public function __construct(
?string $type = null,
?PayingAgent $paying_agent = null,
?ReceivePaymentsOperator $receive_payments_operator = null,
?MoneyTransferOperator $money_transfer_operator = null,
?PayingAgent $pagent = null,
?ReceivePaymentsOperator $rp_operator = null,
?MoneyTransferOperator $mt_operator = null,
) {
!is_null($type) && $this->setType($type);
!is_null($paying_agent) && $this->setPayingAgent($paying_agent);
!is_null($receive_payments_operator) && $this->setReceivePaymentsOperator($receive_payments_operator);
!is_null($money_transfer_operator) && $this->setMoneyTransferOperator($money_transfer_operator);
!is_null($pagent) && $this->setPayingAgent($pagent);
!is_null($rp_operator) && $this->setReceivePaymentsOperator($rp_operator);
!is_null($mt_operator) && $this->setMoneyTransferOperator($mt_operator);
}
/**
@ -79,7 +79,7 @@ class AgentInfo extends Entity
* @return AgentInfo
* @throws InvalidEnumValueException
*/
public function setType(?string $type): AgentInfo
public function setType(?string $type): self
{
AgentTypes::isValid($type) && $this->type = $type;
return $this;
@ -98,12 +98,12 @@ class AgentInfo extends Entity
/**
* Устанавливает платёжного агента
*
* @param PayingAgent|null $paying_agent
* @param PayingAgent|null $agent
* @return AgentInfo
*/
public function setPayingAgent(?PayingAgent $paying_agent): AgentInfo
public function setPayingAgent(?PayingAgent $agent): self
{
$this->paying_agent = $paying_agent;
$this->paying_agent = $agent;
return $this;
}
@ -120,12 +120,12 @@ class AgentInfo extends Entity
/**
* Устанавливает оператора по приёму платежей
*
* @param ReceivePaymentsOperator|null $receive_payments_operator
* @param ReceivePaymentsOperator|null $operator
* @return AgentInfo
*/
public function setReceivePaymentsOperator(?ReceivePaymentsOperator $receive_payments_operator): AgentInfo
public function setReceivePaymentsOperator(?ReceivePaymentsOperator $operator): self
{
$this->receive_payments_operator = $receive_payments_operator;
$this->receive_payments_operator = $operator;
return $this;
}
@ -142,12 +142,12 @@ class AgentInfo extends Entity
/**
* Устанавливает оператора перевода
*
* @param MoneyTransferOperator|null $money_transfer_operator
* @param MoneyTransferOperator|null $operator
* @return AgentInfo
*/
public function setMoneyTransferOperator(?MoneyTransferOperator $money_transfer_operator): AgentInfo
public function setMoneyTransferOperator(?MoneyTransferOperator $operator): self
{
$this->money_transfer_operator = $money_transfer_operator;
$this->money_transfer_operator = $operator;
return $this;
}

View File

@ -11,54 +11,51 @@ declare(strict_types = 1);
namespace AtolOnline\Entities;
use AtolOnline\{
Constants\Constraints,
Exceptions\InvalidEmailException,
Exceptions\InvalidInnLengthException,
Exceptions\InvalidPhoneException,
Exceptions\TooLongClientContactException,
Exceptions\TooLongClientNameException,
Exceptions\TooLongEmailException};
use AtolOnline\Constants\Constraints;
use AtolOnline\Exceptions\{
InvalidEmailException,
InvalidInnLengthException,
InvalidPhoneException,
TooLongClientNameException,
TooLongEmailException
};
use AtolOnline\Traits\{
HasEmail,
HasInn
};
use JetBrains\PhpStorm\Pure;
/**
* Класс, описывающий покупателя
*
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 17
*/
class Client extends Entity
final class Client extends Entity
{
use HasEmail, HasInn;
/**
* @var string|null Наименование (1227)
*/
protected ?string $name = null;
/**
* @var string|null Email (1008)
*/
protected ?string $email = null;
/**
* @var string|null Телефон (1008)
*/
protected ?string $phone = null;
/**
* @var string|null ИНН (1228)
*/
protected ?string $inn = null;
/**
* Конструктор объекта покупателя
*
* @param string|null $name Наименование (1227)
* @param string|null $phone Email (1008)
* @param string|null $email Телефон (1008)
* @param string|null $phone Email (1008)
* @param string|null $inn ИНН (1228)
* @throws TooLongClientNameException
* @throws TooLongClientContactException
* @throws TooLongEmailException
* @throws InvalidEmailException
* @throws InvalidInnLengthException
* @throws InvalidPhoneException
* @throws TooLongClientNameException
* @throws TooLongEmailException
*/
public function __construct(
?string $name = null,
@ -101,38 +98,6 @@ class Client extends Entity
return $this;
}
/**
* Возвращает установленный email
*
* @return string|null
*/
public function getEmail(): ?string
{
return $this->email;
}
/**
* Устанавливает email
*
* @param string|null $email
* @return $this
* @throws TooLongEmailException Слишком длинный email
* @throws InvalidEmailException Невалидный email
*/
public function setEmail(?string $email): self
{
if (is_string($email)) {
$email = preg_replace('/[\n\r\t]/', '', trim($email));
if (mb_strlen($email) > Constraints::MAX_LENGTH_EMAIL) {
throw new TooLongEmailException($email);
} elseif (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
throw new InvalidEmailException($email);
}
}
$this->email = empty($email) ? null : $email;
return $this;
}
/**
* Возвращает установленный телефон
*
@ -162,38 +127,10 @@ class Client extends Entity
return $this;
}
/**
* Возвращает установленный ИНН
*
* @return string|null
*/
public function getInn(): ?string
{
return $this->inn;
}
/**
* Устанавливает ИНН
*
* @param string|null $inn
* @return $this
* @throws InvalidInnLengthException Некорректная длина ИНН
*/
public function setInn(?string $inn): self
{
if (is_string($inn)) {
$inn = preg_replace('/[^\d]/', '', trim($inn));
if (preg_match_all(Constraints::PATTERN_INN, $inn) === 0) {
throw new InvalidInnLengthException($inn);
}
}
$this->inn = empty($inn) ? null : $inn;
return $this;
}
/**
* @inheritDoc
*/
#[Pure]
public function jsonSerialize(): array
{
$json = [];

View File

@ -14,35 +14,33 @@ namespace AtolOnline\Entities;
use AtolOnline\{
Constants\Constraints,
Enums\SnoTypes,
Exceptions\InvalidEmailException,
Exceptions\InvalidEnumValueException,
Exceptions\InvalidInnLengthException,
Exceptions\InvalidPaymentAddressException,
Exceptions\TooLongEmailException,
Exceptions\TooLongPaymentAddressException};
Traits\HasEmail,
Traits\HasInn
};
use AtolOnline\Exceptions\{
InvalidEmailException,
InvalidEnumValueException,
InvalidInnLengthException,
InvalidPaymentAddressException,
TooLongEmailException,
TooLongPaymentAddressException
};
use JetBrains\PhpStorm\ArrayShape;
/**
* Класс, описывающий сущность компании-продавца
*
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 17
*/
class Company extends Entity
final class Company extends Entity
{
/**
* @var string|null Почта (1117)
*/
protected ?string $email;
use HasEmail, HasInn;
/**
* @var string|null Система налогообложения продавца (1055)
*/
protected ?string $sno;
/**
* @var string|null ИНН (1018)
*/
protected ?string $inn;
/**
* @var string|null Место расчётов (адрес интернет-магазина) (1187)
*/
@ -74,36 +72,6 @@ class Company extends Entity
$this->setPaymentAddress($payment_address);
}
/**
* Возвращает установленный email
*
* @return string
*/
public function getEmail(): string
{
return $this->email;
}
/**
* Устанавливает email
*
* @param string $email
* @return $this
* @throws TooLongEmailException Слишком длинный email
* @throws InvalidEmailException Невалидный email
*/
public function setEmail(string $email): self
{
$email = preg_replace('/[\n\r\t]/', '', trim($email));
if (mb_strlen($email) > Constraints::MAX_LENGTH_EMAIL) {
throw new TooLongEmailException($email);
} elseif (empty($email) || filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
throw new InvalidEmailException($email);
}
$this->email = $email;
return $this;
}
/**
* Возвращает установленный тип налогообложения
*
@ -129,33 +97,6 @@ class Company extends Entity
return $this;
}
/**
* Возвращает установленный ИНН
*
* @return string
*/
public function getInn(): string
{
return $this->inn;
}
/**
* Устанавливает ИНН
*
* @param string $inn
* @return $this
* @throws InvalidInnLengthException
*/
public function setInn(string $inn): self
{
$inn = preg_replace('/[^\d]/', '', trim($inn));
if (empty($inn) || preg_match_all(Constraints::PATTERN_INN, $inn) === 0) {
throw new InvalidInnLengthException($inn);
}
$this->inn = $inn;
return $this;
}
/**
* Возвращает установленный адрес места расчётов
*
@ -193,6 +134,12 @@ class Company extends Entity
* @throws InvalidInnLengthException
* @throws InvalidPaymentAddressException
*/
#[ArrayShape([
'email' => "string",
'sno' => "string",
'inn' => "string",
'payment_address' => "string",
])]
public function jsonSerialize(): array
{
return [

View File

@ -11,26 +11,28 @@ declare(strict_types = 1);
namespace AtolOnline\Entities;
use AtolOnline\{
Constants\Constraints,
Enums\PaymentMethods,
Enums\PaymentObjects,
Enums\VatTypes,
Exceptions\EmptyItemNameException,
Exceptions\InvalidDeclarationNumberException,
Exceptions\InvalidEnumValueException,
Exceptions\InvalidOKSMCodeException,
Exceptions\NegativeItemExciseException,
Exceptions\NegativeItemPriceException,
Exceptions\NegativeItemQuantityException,
Exceptions\TooHighItemQuantityException,
Exceptions\TooHighPriceException,
Exceptions\TooHighSumException,
Exceptions\TooLongItemCodeException,
Exceptions\TooLongItemNameException,
Exceptions\TooLongMeasurementUnitException,
Exceptions\TooLongUserdataException,
Exceptions\TooManyException
use AtolOnline\Constants\Constraints;
use AtolOnline\Enums\{
PaymentMethods,
PaymentObjects,
VatTypes
};
use AtolOnline\Exceptions\{
EmptyItemNameException,
InvalidDeclarationNumberException,
InvalidEnumValueException,
InvalidOKSMCodeException,
NegativeItemExciseException,
NegativeItemPriceException,
NegativeItemQuantityException,
TooHighItemQuantityException,
TooHighPriceException,
TooHighSumException,
TooLongItemCodeException,
TooLongItemNameException,
TooLongMeasurementUnitException,
TooLongUserdataException,
TooManyException
};
/**
@ -38,7 +40,7 @@ use AtolOnline\{
*
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 21-30
*/
class Item extends Entity
final class Item extends Entity
{
/**
* @var string Наименование (1030)
@ -153,7 +155,7 @@ class Item extends Entity
*
* @param string $name Наименование
* @return $this
* @throws TooLongItemNameException Слишком длинное имя/наименование
* @throws TooLongItemNameException
* @throws EmptyItemNameException
*/
public function setName(string $name): self
@ -186,6 +188,7 @@ class Item extends Entity
* @return $this
* @throws NegativeItemPriceException
* @throws TooHighPriceException
* @throws TooHighSumException
*/
public function setPrice(float $rubles): self
{
@ -196,7 +199,7 @@ class Item extends Entity
throw new NegativeItemPriceException($this->getName(), $rubles);
}
$this->price = $rubles;
//$this->calcSum();
$this->getVat()?->setSum($this->getSum());
return $this;
}
@ -217,6 +220,7 @@ class Item extends Entity
* @return $this
* @throws TooHighItemQuantityException
* @throws NegativeItemQuantityException
* @throws TooHighSumException
*/
public function setQuantity(float $quantity): self
{
@ -228,6 +232,7 @@ class Item extends Entity
throw new NegativeItemQuantityException($this->getName(), $quantity);
}
$this->quantity = $quantity;
$this->getVat()?->setSum($this->getSum());
return $this;
}
@ -457,7 +462,7 @@ class Item extends Entity
*
* @param string|null $user_data Дополнительный реквизит
* @return $this
* @throws TooLongUserdataException Слишком длинный дополнительный реквизит
* @throws TooLongUserdataException
*/
public function setUserData(?string $user_data): self
{
@ -485,13 +490,15 @@ class Item extends Entity
* @param float|null $excise
* @return Item
* @throws NegativeItemExciseException
* @throws TooHighSumException
*/
public function setExcise(?float $excise): Item
public function setExcise(?float $excise): self
{
if ($excise < 0) {
throw new NegativeItemExciseException($this->getName(), $excise);
}
$this->excise = $excise;
$this->getVat()?->setSum($this->getSum());
return $this;
}
@ -558,25 +565,6 @@ class Item extends Entity
return $this;
}
/**
* Расчитывает стоимость и размер НДС на неё
*
* @return float
* @throws TooHighPriceException Слишком большая сумма
*/
//public function calcSum(): float
//{
// $sum = $this->quantity * $this->price;
// if (rubles($sum) > 42949672.95) {
// throw new TooHighPriceException($sum, 42949672.95);
// }
// $this->sum = $sum;
// if ($this->vat) {
// $this->vat->setSum(rubles($sum));
// }
// return $this->getSum();
//}
/**
* @inheritDoc
* @throws TooHighSumException

View File

@ -11,14 +11,17 @@ declare(strict_types = 1);
namespace AtolOnline\Entities;
use AtolOnline\Exceptions\EmptyMonitorDataException;
use AtolOnline\Exceptions\NotEnoughMonitorDataException;
use AtolOnline\Exceptions\{
EmptyMonitorDataException,
NotEnoughMonitorDataException
};
use DateTime;
use Exception;
/**
* Класс сущности ККТ, получаемой от монитора
*
* @see https://online.atol.ru/files/API_service_information.pdf Документация, стр 11
* @property string|null serialNumber Заводской номер ККТ
* @property string|null registrationNumber Регистрационный номер машины (РНМ)
* @property string|null deviceNumber Номер автоматического устройства (внутренний идентификатор устройства)
@ -38,14 +41,13 @@ use Exception;
* @property DateTime|string|null firstUnsetDocTimestamp Дата первого неотправленного документа. Указывается, если
* есть неотправленные документы.
* @property int|null networkErrorCode Код ошибки сети
* @see https://online.atol.ru/files/API_service_information.pdf Документация, стр 11
*/
final class Kkt extends Entity
{
/**
* Сопоставление кодов сетевых ошибок ККТ с их описаниями
*/
public const ERROR_CODES = [
public const ERROR_CODES = [
0 => 'Нет ошибок',
1 => 'Отсутствует физический канал связи',
2 => 'Ошибка сетевых настроек или нет соединения с сервером ОФД',
@ -97,7 +99,7 @@ final class Kkt extends Entity
* @throws EmptyMonitorDataException
* @throws NotEnoughMonitorDataException
*/
public function __construct(protected \stdClass $data)
public function __construct(protected object $data)
{
if (empty((array)$data)) {
throw new EmptyMonitorDataException();

View File

@ -11,9 +11,14 @@ declare(strict_types = 1);
namespace AtolOnline\Entities;
use AtolOnline\Constants\Constraints;
use AtolOnline\Exceptions\InvalidInnLengthException;
use AtolOnline\Exceptions\InvalidPhoneException;
use AtolOnline\Exceptions\{
InvalidInnLengthException,
InvalidPhoneException
};
use AtolOnline\Traits\{
HasInn,
HasPhones
};
use Illuminate\Support\Collection;
/**
@ -21,8 +26,10 @@ use Illuminate\Support\Collection;
*
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 28
*/
class MoneyTransferOperator extends Entity
final class MoneyTransferOperator extends Entity
{
use HasInn, HasPhones;
/**
* @var string|null Наименование (1026)
*/
@ -111,69 +118,6 @@ class MoneyTransferOperator extends Entity
return $this;
}
/**
* Возвращает установленные номера телефонов
*
* @todo вытащить в трейт
* @return Collection
*/
public function getPhones(): Collection
{
return $this->phones;
}
/**
* Устанавливает массив номеров телефонов
*
* @todo вытащить в трейт
* @param array|Collection|null $phones
* @return $this
* @throws InvalidPhoneException
*/
public function setPhones(array|Collection|null $phones): self
{
if (!is_null($phones)) {
$phones = is_array($phones) ? collect($phones) : $phones;
$phones->each(function ($phone) {
$phone = preg_replace('/[^\d]/', '', trim($phone));
if (preg_match(Constraints::PATTERN_PHONE, $phone) != 1) {
throw new InvalidPhoneException($phone);
}
});
}
$this->phones = $phones ?? collect();
return $this;
}
/**
* Возвращает установленный ИНН
*
* @return string|null
*/
public function getInn(): ?string
{
return $this->inn;
}
/**
* Устанавливает ИНН
*
* @param string|null $inn
* @return $this
* @throws InvalidInnLengthException Некорректная длина ИНН
*/
public function setInn(?string $inn): self
{
if (is_string($inn)) {
$inn = preg_replace('/[^\d]/', '', trim($inn));
if (preg_match_all(Constraints::PATTERN_INN, $inn) === 0) {
throw new InvalidInnLengthException($inn);
}
}
$this->inn = $inn ?: null;
return $this;
}
/**
* @inheritDoc
*/

View File

@ -12,8 +12,11 @@ declare(strict_types = 1);
namespace AtolOnline\Entities;
use AtolOnline\Constants\Constraints;
use AtolOnline\Exceptions\InvalidPhoneException;
use AtolOnline\Exceptions\TooLongPayingAgentOperationException;
use AtolOnline\Exceptions\{
InvalidPhoneException,
TooLongPayingAgentOperationException
};
use AtolOnline\Traits\HasPhones;
use Illuminate\Support\Collection;
/**
@ -21,18 +24,15 @@ use Illuminate\Support\Collection;
*
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 19
*/
class PayingAgent extends Entity
final class PayingAgent extends Entity
{
use HasPhones;
/**
* @var string|null Наименование операции (1044)
*/
protected ?string $operation = null;
/**
* @var Collection Телефоны платёжного агента (1073)
*/
protected Collection $phones;
/**
* Конструктор
*
@ -78,40 +78,6 @@ class PayingAgent extends Entity
return $this->operation;
}
/**
* Устанавливает массив номеров телефонов
*
* @todo вытащить в трейт
* @param array|Collection|null $phones
* @return $this
* @throws InvalidPhoneException
*/
public function setPhones(array|Collection|null $phones): self
{
if (!is_null($phones)) {
$phones = is_array($phones) ? collect($phones) : $phones;
$phones->each(function ($phone) {
$phone = preg_replace('/[^\d]/', '', trim($phone));
if (preg_match(Constraints::PATTERN_PHONE, $phone) != 1) {
throw new InvalidPhoneException($phone);
}
});
}
$this->phones = empty($phones) ? collect() : $phones;
return $this;
}
/**
* Возвращает установленные номера телефонов
*
* @todo вытащить в трейт
* @return Collection
*/
public function getPhones(): Collection
{
return $this->phones;
}
/**
* @inheritDoc
*/

View File

@ -11,8 +11,8 @@ declare(strict_types = 1);
namespace AtolOnline\Entities;
use AtolOnline\Constants\Constraints;
use AtolOnline\Exceptions\InvalidPhoneException;
use AtolOnline\Traits\HasPhones;
use Illuminate\Support\Collection;
/**
@ -20,12 +20,9 @@ use Illuminate\Support\Collection;
*
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 19-20
*/
class ReceivePaymentsOperator extends Entity
final class ReceivePaymentsOperator extends Entity
{
/**
* @var Collection Телефоны оператора по приёму платежей (1074)
*/
protected Collection $phones;
use HasPhones;
/**
* Конструктор
@ -33,46 +30,11 @@ class ReceivePaymentsOperator extends Entity
* @param array|Collection|null $phones Телефоны оператора по приёму платежей (1074)
* @throws InvalidPhoneException
*/
public function __construct(
array|Collection|null $phones = null,
) {
public function __construct(array|Collection|null $phones = null)
{
$this->setPhones($phones);
}
/**
* Возвращает установленные номера телефонов
*
* @todo вытащить в трейт
* @return Collection
*/
public function getPhones(): Collection
{
return $this->phones;
}
/**
* Устанавливает массив номеров телефонов
*
* @todo вытащить в трейт
* @param array|Collection|null $phones
* @return $this
* @throws InvalidPhoneException
*/
public function setPhones(array|Collection|null $phones): self
{
if (!is_null($phones)) {
$phones = is_array($phones) ? collect($phones) : $phones;
$phones->each(function ($phone) {
$phone = preg_replace('/[^\d]/', '', trim($phone));
if (preg_match(Constraints::PATTERN_PHONE, $phone) != 1) {
throw new InvalidPhoneException($phone);
}
});
}
$this->phones = empty($phones) ? collect() : $phones;
return $this;
}
/**
* @inheritDoc
*/

View File

@ -11,9 +11,14 @@ declare(strict_types = 1);
namespace AtolOnline\Entities;
use AtolOnline\Constants\Constraints;
use AtolOnline\Exceptions\InvalidInnLengthException;
use AtolOnline\Exceptions\InvalidPhoneException;
use AtolOnline\Exceptions\{
InvalidInnLengthException,
InvalidPhoneException
};
use AtolOnline\Traits\{
HasInn,
HasPhones
};
use Illuminate\Support\Collection;
/**
@ -21,23 +26,15 @@ use Illuminate\Support\Collection;
*
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 29
*/
class Supplier extends Entity
final class Supplier extends Entity
{
use HasPhones, HasInn;
/**
* @var string|null Наименование (1225)
*/
protected ?string $name = null;
/**
* @var string|null ИНН (1226)
*/
protected ?string $inn = null;
/**
* @var Collection Телефоны (1171)
*/
protected Collection $phones;
/**
* Конструктор
*
@ -80,69 +77,6 @@ class Supplier extends Entity
return $this;
}
/**
* Возвращает установленные номера телефонов
*
* @todo вытащить в трейт
* @return Collection
*/
public function getPhones(): Collection
{
return $this->phones;
}
/**
* Устанавливает массив номеров телефонов
*
* @todo вытащить в трейт
* @param array|Collection|null $phones
* @return $this
* @throws InvalidPhoneException
*/
public function setPhones(array|Collection|null $phones): self
{
if (!is_null($phones)) {
$phones = is_array($phones) ? collect($phones) : $phones;
$phones->each(function ($phone) {
$phone = preg_replace('/[^\d]/', '', trim($phone));
if (preg_match(Constraints::PATTERN_PHONE, $phone) != 1) {
throw new InvalidPhoneException($phone);
}
});
}
$this->phones = empty($phones) ? collect() : $phones;
return $this;
}
/**
* Возвращает установленный ИНН
*
* @return string|null
*/
public function getInn(): ?string
{
return $this->inn;
}
/**
* Устанавливает ИНН
*
* @param string|null $inn
* @return $this
* @throws InvalidInnLengthException Некорректная длина ИНН
*/
public function setInn(?string $inn): self
{
if (is_string($inn)) {
$inn = preg_replace('/[^\d]/', '', trim($inn));
if (preg_match_all(Constraints::PATTERN_INN, $inn) === 0) {
throw new InvalidInnLengthException($inn);
}
}
$this->inn = empty($inn) ? null : $inn;
return $this;
}
/**
* @inheritDoc
*/

View File

@ -14,13 +14,17 @@ namespace AtolOnline\Entities;
use AtolOnline\Enums\VatTypes;
use AtolOnline\Exceptions\InvalidEnumValueException;
use AtolOnline\Helpers;
use JetBrains\PhpStorm\{
ArrayShape,
Pure
};
/**
* Класс, описывающий ставку НДС
*
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 25, 31
*/
class Vat extends Entity
final class Vat extends Entity
{
/**
* @var string Тип ставки НДС (1199, 1105, 1104, 1103, 1102, 1107, 1106)
@ -37,6 +41,7 @@ class Vat extends Entity
*
* @param string $type Тип ставки НДС (1199, 1105, 1104, 1103, 1102, 1107, 1106)
* @param float $rubles Исходная сумма в рублях, от которой нужно расчитать размер НДС
* @throws InvalidEnumValueException
*/
public function __construct(string $type, float $rubles)
{
@ -99,16 +104,16 @@ class Vat extends Entity
* @see https://glavkniga.ru/situations/k500734
* @see https://www.b-kontur.ru/nds-kalkuljator-online
*/
#[Pure]
public function getCalculated(): float
{
$kopeks = Helpers::toKop($this->sum);
return Helpers::toRub(match ($this->getType()) {
VatTypes::VAT10 => $kopeks * 10 / 100,
VatTypes::VAT18 => $kopeks * 18 / 100,
VatTypes::VAT20 => $kopeks * 20 / 100,
VatTypes::VAT110 => $kopeks * 10 / 110,
VatTypes::VAT118 => $kopeks * 18 / 118,
VatTypes::VAT120 => $kopeks * 20 / 120,
VatTypes::VAT10 => Helpers::toKop($this->sum) * 10 / 100,
VatTypes::VAT18 => Helpers::toKop($this->sum) * 18 / 100,
VatTypes::VAT20 => Helpers::toKop($this->sum) * 20 / 100,
VatTypes::VAT110 => Helpers::toKop($this->sum) * 10 / 110,
VatTypes::VAT118 => Helpers::toKop($this->sum) * 18 / 118,
VatTypes::VAT120 => Helpers::toKop($this->sum) * 20 / 120,
default => 0,
});
}
@ -128,6 +133,8 @@ class Vat extends Entity
/**
* @inheritDoc
*/
#[Pure]
#[ArrayShape(['type' => 'string', 'sum' => 'float'])]
public function jsonSerialize(): array
{
return [

View File

@ -12,9 +12,9 @@ declare(strict_types = 1);
namespace AtolOnline\Entities;
/**
* Класс CorrectionInfo, описывающий данные чек коррекции
* Класс todoCorrectionInfo, описывающий данные чек коррекции
*/
class CorrectionInfo extends Entity
class todoCorrectionInfo extends Entity
{
/**
* @var string Тип коррекции. Тег ФФД - 1173.
@ -32,7 +32,7 @@ class CorrectionInfo extends Entity
protected string $base_number;
/**
* CorrectionInfo constructor.
* todoCorrectionInfo constructor.
*
* @param string|null $type Тип коррекции
* @param string|null $base_date Дата документа
@ -66,7 +66,7 @@ class CorrectionInfo extends Entity
* @param string $number
* @return $this
*/
public function setNumber(string $number): CorrectionInfo
public function setNumber(string $number): todoCorrectionInfo
{
$this->base_number = trim($number);
return $this;
@ -90,7 +90,7 @@ class CorrectionInfo extends Entity
* @param string $date Строка в формате d.m.Y
* @return $this
*/
public function setDate(string $date): CorrectionInfo
public function setDate(string $date): todoCorrectionInfo
{
$this->base_date = $date;
return $this;
@ -114,7 +114,7 @@ class CorrectionInfo extends Entity
* @param string $type
* @return $this
*/
public function setType(string $type): CorrectionInfo
public function setType(string $type): todoCorrectionInfo
{
$this->type = $type;
return $this;

View File

@ -35,7 +35,7 @@ use Exception;
*
* @package AtolOnline\Entities
*/
class Document extends Entity
class todoDocument extends Entity
{
/**
* @var ItemArray Массив предметов расчёта
@ -73,12 +73,12 @@ class Document extends Entity
protected string $cashier;
/**
* @var CorrectionInfo Данные коррекции
* @var todoCorrectionInfo Данные коррекции
*/
protected CorrectionInfo $correction_info;
protected todoCorrectionInfo $correction_info;
/**
* Document constructor.
* todoDocument constructor.
*/
public function __construct()
{
@ -93,7 +93,7 @@ class Document extends Entity
* @return $this
* @throws TooManyVatsException Слишком много ставок НДС
*/
public function clearVats(): Document
public function clearVats(): todoDocument
{
$this->setVats([]);
return $this;
@ -106,7 +106,7 @@ class Document extends Entity
* @return $this
* @throws TooManyVatsException Слишком много ставок НДС
*/
public function addVat(Vat $vat): Document
public function addVat(Vat $vat): todoDocument
{
$this->vats->add($vat);
return $this;
@ -130,7 +130,7 @@ class Document extends Entity
* @throws TooManyVatsException Слишком много ставок НДС
* @throws Exception
*/
public function setVats(array $vats): Document
public function setVats(array $vats): todoDocument
{
$this->vats->set($vats);
return $this;
@ -139,12 +139,12 @@ class Document extends Entity
/**
* Добавляет новую оплату в массив оплат
*
* @param Payment $payment Объект оплаты
* @param todoPayment $payment Объект оплаты
* @return $this
* @throws Exception
* @throws TooManyPaymentsException Слишком много оплат
*/
public function addPayment(Payment $payment): Document
public function addPayment(todoPayment $payment): todoDocument
{
if (count($this->getPayments()) == 0 && !$payment->getSum()) {
$payment->setSum($this->calcTotal());
@ -156,7 +156,7 @@ class Document extends Entity
/**
* Возвращает массив оплат
*
* @return Payment[]
* @return todoPayment[]
*/
public function getPayments(): array
{
@ -166,11 +166,11 @@ class Document extends Entity
/**
* Устанавливает массив оплат
*
* @param Payment[] $payments Массив оплат
* @param todoPayment[] $payments Массив оплат
* @return $this
* @throws TooManyPaymentsException Слишком много оплат
*/
public function setPayments(array $payments): Document
public function setPayments(array $payments): todoDocument
{
$this->payments->set($payments);
return $this;
@ -183,7 +183,7 @@ class Document extends Entity
* @return $this
* @throws TooManyItemsException Слишком много предметов расчёта
*/
public function addItem(Item $item): Document
public function addItem(Item $item): todoDocument
{
$this->items->add($item);
return $this;
@ -206,7 +206,7 @@ class Document extends Entity
* @return $this
* @throws TooManyItemsException Слишком много предметов расчёта
*/
public function setItems(array $items): Document
public function setItems(array $items): todoDocument
{
$this->items->set($items);
return $this;
@ -228,7 +228,7 @@ class Document extends Entity
* @param Client|null $client
* @return $this
*/
public function setClient(?Client $client): Document
public function setClient(?Client $client): todoDocument
{
$this->client = $client;
return $this;
@ -250,7 +250,7 @@ class Document extends Entity
* @param Company|null $company
* @return $this
*/
public function setCompany(?Company $company): Document
public function setCompany(?Company $company): todoDocument
{
$this->company = $company;
return $this;
@ -273,7 +273,7 @@ class Document extends Entity
* @return $this
* @throws TooLongCashierException
*/
public function setCashier(?string $cashier): Document
public function setCashier(?string $cashier): todoDocument
{
if ($cashier !== null) {
$cashier = trim($cashier);
@ -288,9 +288,9 @@ class Document extends Entity
/**
* Возвращает данные коррекции
*
* @return CorrectionInfo|null
* @return todoCorrectionInfo|null
*/
public function getCorrectionInfo(): ?CorrectionInfo
public function getCorrectionInfo(): ?todoCorrectionInfo
{
return $this->correction_info;
}
@ -298,10 +298,10 @@ class Document extends Entity
/**
* Устанавливает данные коррекции
*
* @param CorrectionInfo|null $correction_info
* @param todoCorrectionInfo|null $correction_info
* @return $this
*/
public function setCorrectionInfo(?CorrectionInfo $correction_info): Document
public function setCorrectionInfo(?todoCorrectionInfo $correction_info): todoDocument
{
$this->correction_info = $correction_info;
return $this;
@ -338,7 +338,7 @@ class Document extends Entity
* Собирает объект документа из сырой json-строки
*
* @param string $json
* @return Document
* @return todoDocument
* @throws TooLongEmailException
* @throws InvalidEmailException
* @throws AtolException
@ -355,7 +355,7 @@ class Document extends Entity
* @throws TooLongUserdataException
* @throws Exception
*/
public static function fromRaw(string $json): Document
public static function fromRaw(string $json): todoDocument
{
$array = json_decode($json, true);
if (json_last_error() !== JSON_ERROR_NONE) {
@ -379,7 +379,7 @@ class Document extends Entity
));
}
if (isset($array['correction_info'])) {
$doc->setCorrectionInfo(new CorrectionInfo(
$doc->setCorrectionInfo(new todoCorrectionInfo(
$array['correction_info']['type'] ?? null,
$array['correction_info']['base_date'] ?? null,
$array['correction_info']['base_number'] ?? null,
@ -405,7 +405,7 @@ class Document extends Entity
}
if (isset($array['payments'])) {
foreach ($array['payments'] as $ar_payment) {
$payment = new Payment();
$payment = new todoPayment();
if (isset($ar_payment['type'])) {
$payment->setType($ar_payment['type']);
}

View File

@ -18,30 +18,30 @@ use AtolOnline\Enums\PaymentTypes;
*
* @package AtolOnline\Entities
*/
class Payment extends Entity
class todoPayment extends Entity
{
/**
* @var int Тип оплаты
*/
protected int $type;
/**
* @var float Сумма оплаты
*/
protected float $sum;
/**
* Payment constructor.
* todoPayment constructor.
*
* @param int $payment_type Тип оплаты
* @param float $sum Сумма оплаты
* @param int $payment_type Тип оплаты
* @param float $sum Сумма оплаты
*/
public function __construct(int $payment_type = PaymentTypes::ELECTRON, float $sum = 0.0)
{
$this->setType($payment_type);
$this->setSum($sum);
}
/**
* Возвращает тип оплаты. Тег ФФД - 1031, 1081, 1215, 1216, 1217.
*
@ -51,19 +51,19 @@ class Payment extends Entity
{
return $this->type;
}
/**
* Устанавливает тип оплаты. Тег ФФД - 1031, 1081, 1215, 1216, 1217.
*
* @param int $type
* @return $this
*/
public function setType(int $type): Payment
public function setType(int $type): todoPayment
{
$this->type = $type;
return $this;
}
/**
* Возвращает сумму оплаты
*
@ -73,19 +73,19 @@ class Payment extends Entity
{
return $this->sum;
}
/**
* Устанавливает сумму оплаты
*
* @param float $sum
* @return $this
*/
public function setSum(float $sum): Payment
public function setSum(float $sum): todoPayment
{
$this->sum = $sum;
return $this;
}
/**
* @inheritDoc
*/

57
src/Traits/HasEmail.php Normal file
View File

@ -0,0 +1,57 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
* This code is licensed under MIT.
* Этот код распространяется по лицензии MIT.
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
*/
namespace AtolOnline\Traits;
use AtolOnline\Constants\Constraints;
use AtolOnline\Exceptions\InvalidEmailException;
use AtolOnline\Exceptions\TooLongEmailException;
/**
* Трейт для сущностей, которые могут иметь email
*/
trait HasEmail
{
/**
* @var string|null Email (1008, 1117)
*/
protected ?string $email = null;
/**
* Устанавливает email
*
* @param string|null $email
* @return $this
* @throws TooLongEmailException
* @throws InvalidEmailException
*/
public function setEmail(?string $email): static
{
if (is_string($email)) {
$email = preg_replace('/[\n\r\t]/', '', trim($email));
if (mb_strlen($email) > Constraints::MAX_LENGTH_EMAIL) {
throw new TooLongEmailException($email);
} elseif (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
throw new InvalidEmailException($email);
}
}
$this->email = empty($email) ? null : $email;
return $this;
}
/**
* Возвращает установленный email
*
* @return string|null
*/
public function getEmail(): ?string
{
return $this->email;
}
}

53
src/Traits/HasInn.php Normal file
View File

@ -0,0 +1,53 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
* This code is licensed under MIT.
* Этот код распространяется по лицензии MIT.
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
*/
namespace AtolOnline\Traits;
use AtolOnline\Constants\Constraints;
use AtolOnline\Exceptions\InvalidInnLengthException;
/**
* Трейт для сущностей, которые могут иметь ИНН
*/
trait HasInn
{
/**
* @var string|null ИНН (1226, 1228, 1018)
*/
protected ?string $inn = null;
/**
* Устанавливает ИНН
*
* @param string|null $inn
* @return $this
* @throws InvalidInnLengthException
*/
public function setInn(?string $inn): static
{
if (is_string($inn)) {
$inn = preg_replace('/[^\d]/', '', trim($inn));
if (preg_match_all(Constraints::PATTERN_INN, $inn) === 0) {
throw new InvalidInnLengthException($inn);
}
}
$this->inn = empty($inn) ? null : $inn;
return $this;
}
/**
* Возвращает установленный ИНН
*
* @return string|null
*/
public function getInn(): ?string
{
return $this->inn;
}
}

57
src/Traits/HasPhones.php Normal file
View File

@ -0,0 +1,57 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
* This code is licensed under MIT.
* Этот код распространяется по лицензии MIT.
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
*/
namespace AtolOnline\Traits;
use AtolOnline\Constants\Constraints;
use AtolOnline\Exceptions\InvalidPhoneException;
use Illuminate\Support\Collection;
/**
* Трейт для сущностей, которые могут иметь массив номеров телефонов
*/
trait HasPhones
{
/**
* @var Collection Телефоны платёжного агента (1073), поставщика (1171), оператора по приёму платежей (1074)
*/
protected Collection $phones;
/**
* Устанавливает массив номеров телефонов
*
* @param array|Collection|null $phones
* @return $this
* @throws InvalidPhoneException
*/
public function setPhones(array|Collection|null $phones): static
{
if (!is_null($phones)) {
$phones = is_array($phones) ? collect($phones) : $phones;
$phones->each(function ($phone) {
$phone = preg_replace('/[^\d]/', '', trim($phone));
if (preg_match(Constraints::PATTERN_PHONE, $phone) != 1) {
throw new InvalidPhoneException($phone);
}
});
}
$this->phones = empty($phones) ? collect() : $phones;
return $this;
}
/**
* Возвращает установленные номера телефонов
*
* @return Collection
*/
public function getPhones(): Collection
{
return $this->phones;
}
}

View File

@ -63,9 +63,9 @@ class AgentInfoTest extends BasicTestCase
{
$this->assertAtolable(new AgentInfo(null), []);
$this->assertAtolable(new AgentInfo(AgentTypes::ANOTHER), ['type' => AgentTypes::ANOTHER]);
$this->assertAtolable(new AgentInfo(paying_agent: new PayingAgent()), []);
$this->assertAtolable(new AgentInfo(money_transfer_operator: new MoneyTransferOperator()), []);
$this->assertAtolable(new AgentInfo(receive_payments_operator: new ReceivePaymentsOperator()), []);
$this->assertAtolable(new AgentInfo(pagent: new PayingAgent()), []);
$this->assertAtolable(new AgentInfo(mt_operator: new MoneyTransferOperator()), []);
$this->assertAtolable(new AgentInfo(rp_operator: new ReceivePaymentsOperator()), []);
$this->assertAtolable(new AgentInfo(
AgentTypes::ANOTHER,