Skip to content

Commit

Permalink
Release 0.2.0 (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
shoman4eg authored Apr 10, 2022
1 parent 306901e commit 9f91fdc
Show file tree
Hide file tree
Showing 44 changed files with 1,810 additions and 126 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
max-parallel: 10
matrix:
php: [ '7.4', '8.0' ]
php: [ '7.4', '8.0', '8.1' ]

steps:
- name: Set up PHP
Expand All @@ -21,7 +21,7 @@ jobs:
uses: actions/checkout@v2

- name: Download dependencies
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v2

- name: Run tests
run: ./vendor/bin/phpunit
Expand All @@ -42,7 +42,7 @@ jobs:
- name: Download dependencies
with:
dependency-versions: "lowest"
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v2

- name: Run tests
run: ./vendor/bin/phpunit
6 changes: 3 additions & 3 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
with:
php-version: 8.0
coverage: none
tools: phpstan:0.12.92, cs2pr
tools: phpstan:1.4, cs2pr

- name: Download dependencies
uses: ramsey/composer-install@v1
Expand All @@ -36,7 +36,7 @@ jobs:
with:
php-version: 8.0
coverage: none
tools: php-cs-fixer:2.19.0, cs2pr
tools: php-cs-fixer:3.8.0, cs2pr

- name: PHP-CS-Fixer
run: php-cs-fixer fix --dry-run --format=checkstyle | cs2pr
Expand All @@ -53,7 +53,7 @@ jobs:
with:
php-version: 8.0
coverage: none
tools: vimeo/psalm:4.8.1
tools: vimeo/psalm:4.18.1

- name: Download dependencies
uses: ramsey/composer-install@v1
Expand Down
27 changes: 26 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,32 @@
All notable changes to this project will be documented in this file.
<!--- END HEADER -->

## [0.1.0](https://github.com/shoman4eg/moy-nalog/compare/...v0.1.0) (2022-02-01)
## [0.2.0](https://github.com/shoman4eg/moy-nalog/compare/v0.1.0...v0.2.0) (2022-04-09)
### Features
* Add Payment type methods
* Add Cancel income method
* Add custom client for create income
* Add custom client for create income

### Tests
* Add tests
* Add test for api client with custom access token
* Add test for create income
* Add test validation for income
* Add test for cancel income
* Add test for get paymentType

### Documentation
* Update Create api client
* Update Create income
* Update Get receipt
* Update Get user info
* Add Cancel income
* Add References

---

## [0.1.0](https://github.com/shoman4eg/moy-nalog/compare/306901e41d3ae4d4a4913f6da9606213f9d9a11d...v0.1.0) (2022-02-01)

---
Initial release
87 changes: 84 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unofficial MoyNalog API client

![Php version](https://img.shields.io/packagist/php-v/shoman4eg/moy-nalog?style=flat-square)
[![Latest Version](https://img.shields.io/github/release/shoman4eg/moy-nalog.svg?style=flat-square)](https://github.com/shoman4eg/moy-nalog/releases)
[![Total Downloads](https://img.shields.io/packagist/dt/shoman4eg/moy-nalog.svg?style=flat-square)](https://packagist.org/packages/shoman4eg/moy-nalog)

Expand All @@ -9,26 +10,106 @@ An unofficial wrapper client for lknpd.nalog.ru API

Via Composer

``` bash
```bash
$ composer require shoman4eg/moy-nalog
```

## Usage

``` php
### Settings
```php
// If need set timezone use this
date_default_timezone_set('Europe/Kaliningrad');
// or set timezone through new DateTimeZone
$operationTime = new DateTimeImmutable('now', new DateTimeZone('Europe/Kaliningrad'))
```
### Authorization
```php
$apiClient = ApiClient::create();

// If known accessToken skip this step
$accessToken = $apiClient->createNewAccessToken($username, $password);

// Access token MUST contains all json response from method createNewAccessToken()
$accessToken = '...';
$apiClient->authenticate($accessToken);
```

### Create income with default client
```php
$name = 'Предоставление информационных услуг #970/2495';
$amount = 1800.30;
$quantity = 1;
$amount = 1;
$operationTime = new DateTimeImmutable('2020-12-31 12:12:00');
$createdIncome = $apiClient->income()->create($name, $amount, $quantity, $operationTime);
```

### Create income with custom client
```php
$name = 'Предоставление информационных услуг #970/2495';
$amount = 1800.30;
$quantity = 1;
$operationTime = new DateTimeImmutable('2020-12-31 12:12:00');

$client = new Shoman4eg\Nalog\DTO\IncomeClient(); // Default. All fields are empty IncomeType is FROM_INDIVIDUAL
// or
$client = new Shoman4eg\Nalog\DTO\IncomeClient('+79009000000', 'Вася Пупкин', \Shoman4eg\Nalog\Enum\IncomeType::INDIVIDUAL, '390000000000');
// or
$client = new Shoman4eg\Nalog\DTO\IncomeClient(null, 'Facebook Inc.', \Shoman4eg\Nalog\Enum\IncomeType::FOREIGN_AGENCY, '390000000000');
// or
$client = new Shoman4eg\Nalog\DTO\IncomeClient(null, 'ИП Вася Пупкин Валерьевич', \Shoman4eg\Nalog\Enum\IncomeType::LEGAL_ENTITY, '7700000000');
$createdIncome = $apiClient->income()->create($name, $amount, $quantity, $operationTime, $client);
```

### Cancel income
```php
$receiptUuid = "20hykdxbp8"
$comment = \Shoman4eg\Nalog\Enum\CancelCommentType::CANCEL;
$partnerCode = null; // Default null
$operationTime = new DateTimeImmutable('now'); //Default 'now'
$requestTime = new DateTimeImmutable('now'); //Default 'now'
$incomeInfo = $apiClient->income()->cancel($receiptUuid, $comment, $partnerCode, $operationTime, $requestTime);
```

### Create Invoice
```php
// todo
```

### Cancel Invoice
```php
// todo
```

### Change payment type in Invoice
```php
// todo
```

### Get user info
```php
$userInfo = $apiClient->user()->get();
```

### Get receipt info
```php
// $receiptUuid = $createdincome->getApprovedReceiptUuid();

// Get print url
$receipt = $apiClient->receipt()->printUrl($receiptUuid);

// Json data
$receipt = $apiClient->receipt()->json($receiptUuid);
```

## References
[Автоматизация для самозанятых: как интегрировать налог с IT проектом](https://habr.com/ru/post/436656/)

JS lib [alexstep/moy-nalog](https://github.com/alexstep/moy-nalog)

## Changelog
[Changelog](CHANGELOG.md): A complete changelog

## License

The MIT License (MIT). Please see [License File](LICENSE) for more information.
Loading

0 comments on commit 9f91fdc

Please sign in to comment.