Compare commits

..

No commits in common. "05fd25e8104720c2a8bd333ac6ce9c548eca8bc1" and "2a66889e46d92d59768de3b41b07cf55b7742a46" have entirely different histories.

21 changed files with 620 additions and 630 deletions

View File

@ -17,7 +17,7 @@
---
| 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,6 +92,7 @@ composer test-cov # тестирование с покрытием
* **[Документация к библиотеке](/docs/readme.md)**
* Telegram-канал: [@atolonline_php](https://t.me/atolonline_php)
* [Документация АТОЛ Онлайн](https://online.atol.ru/lib/)
* Функционал, находящийся в разработке: [ROADMAP.md](ROADMAP.md)
## Лицензия

66
ROADMAP.md Normal file
View File

@ -0,0 +1,66 @@
# 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,8 +56,7 @@
"psr/log": "^3",
"ramsey/uuid": "^4.2",
"myclabs/php-enum": "^1.8",
"illuminate/collections": "^8.70",
"jetbrains/phpstorm-attributes": "^1.0"
"illuminate/collections": "^8.70"
},
"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": "4877f27cd59b6558eea01644e2d520ef",
"content-hash": "b03e06fba2a861f7ce366484ec6421c3",
"packages": [
{
"name": "brick/math",
@ -50,10 +50,6 @@
"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",
@ -170,10 +166,6 @@
"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",
@ -254,10 +246,6 @@
"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",
@ -369,10 +357,6 @@
"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",
@ -391,16 +375,16 @@
},
{
"name": "illuminate/collections",
"version": "v8.74.0",
"version": "v8.70.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/collections.git",
"reference": "f292b77824b42cd28decc7327e7c2e24c3806371"
"reference": "05f286ec5fd2dd286e8384577047efc375c8954c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/collections/zipball/f292b77824b42cd28decc7327e7c2e24c3806371",
"reference": "f292b77824b42cd28decc7327e7c2e24c3806371",
"url": "https://api.github.com/repos/illuminate/collections/zipball/05f286ec5fd2dd286e8384577047efc375c8954c",
"reference": "05f286ec5fd2dd286e8384577047efc375c8954c",
"shasum": ""
},
"require": {
@ -409,7 +393,7 @@
"php": "^7.3|^8.0"
},
"suggest": {
"symfony/var-dumper": "Required to use the dump method (^5.4)."
"symfony/var-dumper": "Required to use the dump method (^5.1.4)."
},
"type": "library",
"extra": {
@ -437,24 +421,20 @@
],
"description": "The Illuminate Collections package.",
"homepage": "https://laravel.com",
"support": {
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2021-11-30T14:29:03+00:00"
"time": "2021-10-22T18:01:46+00:00"
},
{
"name": "illuminate/contracts",
"version": "v8.74.0",
"version": "v8.70.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/contracts.git",
"reference": "b0886ec05a63b204634d64d0b39d5b78a7c06f81"
"reference": "e76f4bce73a2a1656add24bd5210ebc4b8af49c0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/contracts/zipball/b0886ec05a63b204634d64d0b39d5b78a7c06f81",
"reference": "b0886ec05a63b204634d64d0b39d5b78a7c06f81",
"url": "https://api.github.com/repos/illuminate/contracts/zipball/e76f4bce73a2a1656add24bd5210ebc4b8af49c0",
"reference": "e76f4bce73a2a1656add24bd5210ebc4b8af49c0",
"shasum": ""
},
"require": {
@ -485,24 +465,20 @@
],
"description": "The Illuminate Contracts package.",
"homepage": "https://laravel.com",
"support": {
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2021-11-17T15:04:30+00:00"
"time": "2021-10-22T18:01:46+00:00"
},
{
"name": "illuminate/macroable",
"version": "v8.74.0",
"version": "v8.70.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/macroable.git",
"reference": "aed81891a6e046fdee72edd497f822190f61c162"
"reference": "300aa13c086f25116b5f3cde3ca54ff5c822fb05"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/macroable/zipball/aed81891a6e046fdee72edd497f822190f61c162",
"reference": "aed81891a6e046fdee72edd497f822190f61c162",
"url": "https://api.github.com/repos/illuminate/macroable/zipball/300aa13c086f25116b5f3cde3ca54ff5c822fb05",
"reference": "300aa13c086f25116b5f3cde3ca54ff5c822fb05",
"shasum": ""
},
"require": {
@ -531,53 +507,7 @@
],
"description": "The Illuminate Macroable package.",
"homepage": "https://laravel.com",
"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"
"time": "2020-10-27T15:20:30+00:00"
},
{
"name": "myclabs/php-enum",
@ -623,10 +553,6 @@
"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",
@ -681,10 +607,6 @@
"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"
},
{
@ -734,9 +656,6 @@
"psr",
"psr-18"
],
"support": {
"source": "https://github.com/php-fig/http-client/tree/master"
},
"time": "2020-06-29T06:28:15+00:00"
},
{
@ -789,9 +708,6 @@
"request",
"response"
],
"support": {
"source": "https://github.com/php-fig/http-factory/tree/master"
},
"time": "2019-04-30T12:38:16+00:00"
},
{
@ -892,9 +808,6 @@
"psr",
"psr-3"
],
"support": {
"source": "https://github.com/php-fig/log/tree/3.0.0"
},
"time": "2021-07-14T16:46:02+00:00"
},
{
@ -943,9 +856,6 @@
"psr-16",
"simple-cache"
],
"support": {
"source": "https://github.com/php-fig/simple-cache/tree/master"
},
"time": "2017-10-23T01:57:42+00:00"
},
{
@ -1055,10 +965,6 @@
"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",
@ -1153,10 +1059,6 @@
"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",
@ -1171,16 +1073,16 @@
},
{
"name": "symfony/deprecation-contracts",
"version": "v2.5.0",
"version": "v2.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "6f981ee24cf69ee7ce9736146d1c57c2780598a8"
"reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/6f981ee24cf69ee7ce9736146d1c57c2780598a8",
"reference": "6f981ee24cf69ee7ce9736146d1c57c2780598a8",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627",
"reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627",
"shasum": ""
},
"require": {
@ -1189,7 +1091,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "2.5-dev"
"dev-main": "2.4-dev"
},
"thanks": {
"name": "symfony/contracts",
@ -1217,9 +1119,6 @@
],
"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",
@ -1234,7 +1133,7 @@
"type": "tidelift"
}
],
"time": "2021-07-12T14:48:14+00:00"
"time": "2021-03-23T23:28:01+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -1296,9 +1195,6 @@
"polyfill",
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
@ -1379,9 +1275,6 @@
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
@ -1458,9 +1351,6 @@
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php81/tree/v1.23.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
@ -1608,16 +1498,16 @@
},
{
"name": "nikic/php-parser",
"version": "v4.13.2",
"version": "v4.13.1",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "210577fe3cf7badcc5814d99455df46564f3c077"
"reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077",
"reference": "210577fe3cf7badcc5814d99455df46564f3c077",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/63a79e8daa781cac14e5195e63ed8ae231dd10fd",
"reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd",
"shasum": ""
},
"require": {
@ -1656,11 +1546,7 @@
"parser",
"php"
],
"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"
"time": "2021-11-03T20:52:16+00:00"
},
{
"name": "phar-io/manifest",
@ -1716,10 +1602,6 @@
}
],
"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"
},
{
@ -1877,10 +1759,6 @@
}
],
"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"
},
{
@ -1927,10 +1805,6 @@
}
],
"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"
},
{
@ -1994,24 +1868,20 @@
"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.9",
"version": "9.2.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b"
"reference": "cf04e88a2e3c56fc1a65488afd493325b4c1bc3e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f301eb1453c9e7a1bc912ee8b0ea9db22c60223b",
"reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/cf04e88a2e3c56fc1a65488afd493325b4c1bc3e",
"reference": "cf04e88a2e3c56fc1a65488afd493325b4c1bc3e",
"shasum": ""
},
"require": {
@ -2065,30 +1935,26 @@
"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-11-19T15:21:02+00:00"
"time": "2021-10-30T08:01:38+00:00"
},
{
"name": "phpunit/php-file-iterator",
"version": "3.0.6",
"version": "3.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf"
"reference": "aa4be8575f26070b100fccb67faabb28f21f66f8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf",
"reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8",
"reference": "aa4be8575f26070b100fccb67faabb28f21f66f8",
"shasum": ""
},
"require": {
@ -2125,17 +1991,13 @@
"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": "2021-12-02T12:48:52+00:00"
"time": "2020-09-28T05:57:25+00:00"
},
{
"name": "phpunit/php-invoker",
@ -2188,10 +2050,6 @@
"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",
@ -2247,10 +2105,6 @@
"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",
@ -2306,10 +2160,6 @@
"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",
@ -2405,10 +2255,6 @@
"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",
@ -2465,10 +2311,6 @@
],
"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",
@ -2521,10 +2363,6 @@
],
"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",
@ -2576,10 +2414,6 @@
],
"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",
@ -2650,10 +2484,6 @@
"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",
@ -2707,10 +2537,6 @@
],
"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",
@ -2773,10 +2599,6 @@
"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",
@ -2836,10 +2658,6 @@
"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",
@ -2913,10 +2731,6 @@
"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",
@ -2977,10 +2791,6 @@
"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",
@ -3034,10 +2844,6 @@
],
"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",
@ -3091,10 +2897,6 @@
],
"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",
@ -3146,10 +2948,6 @@
],
"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",
@ -3209,10 +3007,6 @@
],
"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",
@ -3264,10 +3058,6 @@
],
"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",
@ -3320,10 +3110,6 @@
],
"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",
@ -3373,10 +3159,6 @@
],
"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",
@ -3423,10 +3205,6 @@
}
],
"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",
@ -3505,5 +3283,5 @@
"ext-mbstring": "*"
},
"platform-dev": [],
"plugin-api-version": "2.1.0"
"plugin-api-version": "1.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
*/
final class AgentInfo extends Entity
class AgentInfo extends Entity
{
/**
* @var string|null Признак агента (1057)
@ -45,21 +45,21 @@ final class AgentInfo extends Entity
* Конструктор
*
* @param string|null $type Признак агента (1057)
* @param PayingAgent|null $pagent Платёжный агент
* @param ReceivePaymentsOperator|null $rp_operator Оператор по приёму платежей
* @param MoneyTransferOperator|null $mt_operator Оператор перевода
* @param PayingAgent|null $paying_agent Платёжный агент
* @param ReceivePaymentsOperator|null $receive_payments_operator Оператор по приёму платежей
* @param MoneyTransferOperator|null $money_transfer_operator Оператор перевода
* @throws InvalidEnumValueException
*/
public function __construct(
?string $type = null,
?PayingAgent $pagent = null,
?ReceivePaymentsOperator $rp_operator = null,
?MoneyTransferOperator $mt_operator = null,
?PayingAgent $paying_agent = null,
?ReceivePaymentsOperator $receive_payments_operator = null,
?MoneyTransferOperator $money_transfer_operator = null,
) {
!is_null($type) && $this->setType($type);
!is_null($pagent) && $this->setPayingAgent($pagent);
!is_null($rp_operator) && $this->setReceivePaymentsOperator($rp_operator);
!is_null($mt_operator) && $this->setMoneyTransferOperator($mt_operator);
!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);
}
/**
@ -79,7 +79,7 @@ final class AgentInfo extends Entity
* @return AgentInfo
* @throws InvalidEnumValueException
*/
public function setType(?string $type): self
public function setType(?string $type): AgentInfo
{
AgentTypes::isValid($type) && $this->type = $type;
return $this;
@ -98,12 +98,12 @@ final class AgentInfo extends Entity
/**
* Устанавливает платёжного агента
*
* @param PayingAgent|null $agent
* @param PayingAgent|null $paying_agent
* @return AgentInfo
*/
public function setPayingAgent(?PayingAgent $agent): self
public function setPayingAgent(?PayingAgent $paying_agent): AgentInfo
{
$this->paying_agent = $agent;
$this->paying_agent = $paying_agent;
return $this;
}
@ -120,12 +120,12 @@ final class AgentInfo extends Entity
/**
* Устанавливает оператора по приёму платежей
*
* @param ReceivePaymentsOperator|null $operator
* @param ReceivePaymentsOperator|null $receive_payments_operator
* @return AgentInfo
*/
public function setReceivePaymentsOperator(?ReceivePaymentsOperator $operator): self
public function setReceivePaymentsOperator(?ReceivePaymentsOperator $receive_payments_operator): AgentInfo
{
$this->receive_payments_operator = $operator;
$this->receive_payments_operator = $receive_payments_operator;
return $this;
}
@ -142,12 +142,12 @@ final class AgentInfo extends Entity
/**
* Устанавливает оператора перевода
*
* @param MoneyTransferOperator|null $operator
* @param MoneyTransferOperator|null $money_transfer_operator
* @return AgentInfo
*/
public function setMoneyTransferOperator(?MoneyTransferOperator $operator): self
public function setMoneyTransferOperator(?MoneyTransferOperator $money_transfer_operator): AgentInfo
{
$this->money_transfer_operator = $operator;
$this->money_transfer_operator = $money_transfer_operator;
return $this;
}

View File

@ -11,51 +11,54 @@ declare(strict_types = 1);
namespace AtolOnline\Entities;
use AtolOnline\Constants\Constraints;
use AtolOnline\Exceptions\{
InvalidEmailException,
InvalidInnLengthException,
InvalidPhoneException,
TooLongClientNameException,
TooLongEmailException
};
use AtolOnline\Traits\{
HasEmail,
HasInn
};
use JetBrains\PhpStorm\Pure;
use AtolOnline\{
Constants\Constraints,
Exceptions\InvalidEmailException,
Exceptions\InvalidInnLengthException,
Exceptions\InvalidPhoneException,
Exceptions\TooLongClientContactException,
Exceptions\TooLongClientNameException,
Exceptions\TooLongEmailException};
/**
* Класс, описывающий покупателя
*
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 17
*/
final class Client extends Entity
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 $email Телефон (1008)
* @param string|null $phone Email (1008)
* @param string|null $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,
@ -98,6 +101,38 @@ final 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;
}
/**
* Возвращает установленный телефон
*
@ -127,10 +162,38 @@ final 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,33 +14,35 @@ namespace AtolOnline\Entities;
use AtolOnline\{
Constants\Constraints,
Enums\SnoTypes,
Traits\HasEmail,
Traits\HasInn
};
use AtolOnline\Exceptions\{
InvalidEmailException,
InvalidEnumValueException,
InvalidInnLengthException,
InvalidPaymentAddressException,
TooLongEmailException,
TooLongPaymentAddressException
};
use JetBrains\PhpStorm\ArrayShape;
Exceptions\InvalidEmailException,
Exceptions\InvalidEnumValueException,
Exceptions\InvalidInnLengthException,
Exceptions\InvalidPaymentAddressException,
Exceptions\TooLongEmailException,
Exceptions\TooLongPaymentAddressException};
/**
* Класс, описывающий сущность компании-продавца
*
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 17
*/
final class Company extends Entity
class Company extends Entity
{
use HasEmail, HasInn;
/**
* @var string|null Почта (1117)
*/
protected ?string $email;
/**
* @var string|null Система налогообложения продавца (1055)
*/
protected ?string $sno;
/**
* @var string|null ИНН (1018)
*/
protected ?string $inn;
/**
* @var string|null Место расчётов (адрес интернет-магазина) (1187)
*/
@ -72,6 +74,36 @@ final 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;
}
/**
* Возвращает установленный тип налогообложения
*
@ -97,6 +129,33 @@ final 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;
}
/**
* Возвращает установленный адрес места расчётов
*
@ -134,12 +193,6 @@ final 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

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

View File

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

View File

@ -11,28 +11,26 @@ declare(strict_types = 1);
namespace AtolOnline\Entities;
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
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
};
/**
@ -40,7 +38,7 @@ use AtolOnline\Exceptions\{
*
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 21-30
*/
final class Item extends Entity
class Item extends Entity
{
/**
* @var string Наименование (1030)
@ -155,7 +153,7 @@ final class Item extends Entity
*
* @param string $name Наименование
* @return $this
* @throws TooLongItemNameException
* @throws TooLongItemNameException Слишком длинное имя/наименование
* @throws EmptyItemNameException
*/
public function setName(string $name): self
@ -188,7 +186,6 @@ final class Item extends Entity
* @return $this
* @throws NegativeItemPriceException
* @throws TooHighPriceException
* @throws TooHighSumException
*/
public function setPrice(float $rubles): self
{
@ -199,7 +196,7 @@ final class Item extends Entity
throw new NegativeItemPriceException($this->getName(), $rubles);
}
$this->price = $rubles;
$this->getVat()?->setSum($this->getSum());
//$this->calcSum();
return $this;
}
@ -220,7 +217,6 @@ final class Item extends Entity
* @return $this
* @throws TooHighItemQuantityException
* @throws NegativeItemQuantityException
* @throws TooHighSumException
*/
public function setQuantity(float $quantity): self
{
@ -232,7 +228,6 @@ final class Item extends Entity
throw new NegativeItemQuantityException($this->getName(), $quantity);
}
$this->quantity = $quantity;
$this->getVat()?->setSum($this->getSum());
return $this;
}
@ -462,7 +457,7 @@ final class Item extends Entity
*
* @param string|null $user_data Дополнительный реквизит
* @return $this
* @throws TooLongUserdataException
* @throws TooLongUserdataException Слишком длинный дополнительный реквизит
*/
public function setUserData(?string $user_data): self
{
@ -490,15 +485,13 @@ final class Item extends Entity
* @param float|null $excise
* @return Item
* @throws NegativeItemExciseException
* @throws TooHighSumException
*/
public function setExcise(?float $excise): self
public function setExcise(?float $excise): Item
{
if ($excise < 0) {
throw new NegativeItemExciseException($this->getName(), $excise);
}
$this->excise = $excise;
$this->getVat()?->setSum($this->getSum());
return $this;
}
@ -565,6 +558,25 @@ final 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,17 +11,14 @@ declare(strict_types = 1);
namespace AtolOnline\Entities;
use AtolOnline\Exceptions\{
EmptyMonitorDataException,
NotEnoughMonitorDataException
};
use AtolOnline\Exceptions\EmptyMonitorDataException;
use AtolOnline\Exceptions\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 Номер автоматического устройства (внутренний идентификатор устройства)
@ -41,6 +38,7 @@ 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
{
@ -99,7 +97,7 @@ final class Kkt extends Entity
* @throws EmptyMonitorDataException
* @throws NotEnoughMonitorDataException
*/
public function __construct(protected object $data)
public function __construct(protected \stdClass $data)
{
if (empty((array)$data)) {
throw new EmptyMonitorDataException();

View File

@ -11,14 +11,9 @@ declare(strict_types = 1);
namespace AtolOnline\Entities;
use AtolOnline\Exceptions\{
InvalidInnLengthException,
InvalidPhoneException
};
use AtolOnline\Traits\{
HasInn,
HasPhones
};
use AtolOnline\Constants\Constraints;
use AtolOnline\Exceptions\InvalidInnLengthException;
use AtolOnline\Exceptions\InvalidPhoneException;
use Illuminate\Support\Collection;
/**
@ -26,10 +21,8 @@ use Illuminate\Support\Collection;
*
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 28
*/
final class MoneyTransferOperator extends Entity
class MoneyTransferOperator extends Entity
{
use HasInn, HasPhones;
/**
* @var string|null Наименование (1026)
*/
@ -118,6 +111,69 @@ final 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,11 +12,8 @@ declare(strict_types = 1);
namespace AtolOnline\Entities;
use AtolOnline\Constants\Constraints;
use AtolOnline\Exceptions\{
InvalidPhoneException,
TooLongPayingAgentOperationException
};
use AtolOnline\Traits\HasPhones;
use AtolOnline\Exceptions\InvalidPhoneException;
use AtolOnline\Exceptions\TooLongPayingAgentOperationException;
use Illuminate\Support\Collection;
/**
@ -24,15 +21,18 @@ use Illuminate\Support\Collection;
*
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 19
*/
final class PayingAgent extends Entity
class PayingAgent extends Entity
{
use HasPhones;
/**
* @var string|null Наименование операции (1044)
*/
protected ?string $operation = null;
/**
* @var Collection Телефоны платёжного агента (1073)
*/
protected Collection $phones;
/**
* Конструктор
*
@ -78,6 +78,40 @@ final 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

@ -18,7 +18,7 @@ use AtolOnline\Enums\PaymentTypes;
*
* @package AtolOnline\Entities
*/
class todoPayment extends Entity
class Payment extends Entity
{
/**
* @var int Тип оплаты
@ -31,7 +31,7 @@ class todoPayment extends Entity
protected float $sum;
/**
* todoPayment constructor.
* Payment constructor.
*
* @param int $payment_type Тип оплаты
* @param float $sum Сумма оплаты
@ -58,7 +58,7 @@ class todoPayment extends Entity
* @param int $type
* @return $this
*/
public function setType(int $type): todoPayment
public function setType(int $type): Payment
{
$this->type = $type;
return $this;
@ -80,7 +80,7 @@ class todoPayment extends Entity
* @param float $sum
* @return $this
*/
public function setSum(float $sum): todoPayment
public function setSum(float $sum): Payment
{
$this->sum = $sum;
return $this;

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,9 +20,12 @@ use Illuminate\Support\Collection;
*
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 19-20
*/
final class ReceivePaymentsOperator extends Entity
class ReceivePaymentsOperator extends Entity
{
use HasPhones;
/**
* @var Collection Телефоны оператора по приёму платежей (1074)
*/
protected Collection $phones;
/**
* Конструктор
@ -30,11 +33,46 @@ final 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,14 +11,9 @@ declare(strict_types = 1);
namespace AtolOnline\Entities;
use AtolOnline\Exceptions\{
InvalidInnLengthException,
InvalidPhoneException
};
use AtolOnline\Traits\{
HasInn,
HasPhones
};
use AtolOnline\Constants\Constraints;
use AtolOnline\Exceptions\InvalidInnLengthException;
use AtolOnline\Exceptions\InvalidPhoneException;
use Illuminate\Support\Collection;
/**
@ -26,15 +21,23 @@ use Illuminate\Support\Collection;
*
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 29
*/
final class Supplier extends Entity
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;
/**
* Конструктор
*
@ -77,6 +80,69 @@ final 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,17 +14,13 @@ 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
*/
final class Vat extends Entity
class Vat extends Entity
{
/**
* @var string Тип ставки НДС (1199, 1105, 1104, 1103, 1102, 1107, 1106)
@ -41,7 +37,6 @@ final 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)
{
@ -104,16 +99,16 @@ final 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 => 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,
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,
default => 0,
});
}
@ -133,8 +128,6 @@ final class Vat extends Entity
/**
* @inheritDoc
*/
#[Pure]
#[ArrayShape(['type' => 'string', 'sum' => 'float'])]
public function jsonSerialize(): array
{
return [

View File

@ -1,57 +0,0 @@
<?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;
}
}

View File

@ -1,53 +0,0 @@
<?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;
}
}

View File

@ -1,57 +0,0 @@
<?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(pagent: new PayingAgent()), []);
$this->assertAtolable(new AgentInfo(mt_operator: new MoneyTransferOperator()), []);
$this->assertAtolable(new AgentInfo(rp_operator: new ReceivePaymentsOperator()), []);
$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(
AgentTypes::ANOTHER,