https://github.com/turanjanin/serbian-fiscal-receipts-parser
PHP library for parsing Serbian fiscal receipts.
https://github.com/turanjanin/serbian-fiscal-receipts-parser
bills fiscal receipts serbia
Last synced: 13 days ago
JSON representation
PHP library for parsing Serbian fiscal receipts.
- Host: GitHub
- URL: https://github.com/turanjanin/serbian-fiscal-receipts-parser
- Owner: turanjanin
- License: mit
- Created: 2023-01-12T16:23:40.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-01-17T15:33:56.000Z (3 months ago)
- Last Synced: 2025-04-11T13:53:42.087Z (15 days ago)
- Topics: bills, fiscal, receipts, serbia
- Language: PHP
- Homepage:
- Size: 312 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Serbian Fiscal Receipts Parser - PHP library
This library allows you to parse the contents of URLs encoded within QR codes on Serbian fiscal receipts.
## Installation
You can install the package via composer:
```bash
composer require turanjanin/serbian-fiscal-receipts-parser
```This package requires PHP 8.1 or newer.
It depends on PSR-7 compatible HTTP client for making HTTP requests. If not explicitly provided,
the package will try to detect and instantiate already existing client class.## Usage
```php
$url = 'https://suf.purs.gov.rs/v/?vl=A1ZCTUhYOVNYVzZVQlBaTzCyKwEA%2FmgAAMDh5AAAAAAAAAABhXchESoAAAAP3tYiO2%2BdI6Z5y2v4eC5wJTxirHDeiB1hqaKpgb%2FGvUy6yLkMNgZNqKxLqR40mK2cAfqZmKQ3%2BuCcTbec%2BQ3%2F9YY5EhTDP5HxDNhG%2FugU849FmvrVzP0sKecosSNL10dFtlH8Wgor2A2DDs8sHlmfmpokJnVcm24b%2BCz2bSCSl3HtzGRJ1w4Sw9hhdzsQ4WuPo%2FMEGMlmV8a%2Ffc7X05cWsDCHZoA5uPNWfN%2Bre8%2By5JETDJgRwNDFipYIdh0k62TMp5P0%2FzbCueIJJjas5IxAS9iIdpoTAIIl3eKwUZUWvEwtbGz5nkz52hw5%2Bmg50Uczx1SRifYq%2FEDt79xNkcceS0llpMyNdQ12TSYyL0UjMNymgGX4WPajSzPkQuFBcGLB%2BNLOn2AKLPJXa3B8b87eESXrcIbilNXS3zyr3eg4DIqcTVLXwHwcSh1WDmWKI2TFSu%2Bc6iORB11ln1kYbsEsuCoUegxRJR3RW4%2BkQz45%2Bbm4O5qWTCkDlZ73XHATWPn%2BpPfHP2Fh0Y0QK8gGxNiqrdbob3u0l8uaxKcEDaX%2F4HXnhMezvLEEwBNgWXDMn29uWYx9SWEvPrxV%2FLsIULQbE%2FlcvPeYIla63NhCyuEuGLIlwB2p%2B9O8x7sxD53fTMC7EKKRFUV13WBJS2N5%2BLUh33joYo8Qrc%2BNV2CqrtChYTftFukoKbQvCUKOYYIW0%2FA%3D';$fetcher = new \Turanjanin\FiscalReceipts\Fetcher();
// Get receipt from the given URL by parsing a web page.
$receipt = $fetcher->fetchFromUrl($url);// Get receipt from the given URL by fetching the JSON API.
$receipt = $fetcher->fetchFromApi($url);// Or, if you already have URL content stored in $html variable:
$receipt = $fetcher->fetchFromHtml($html);
```If you already have a plain text version of the receipt, you can call the Parser class directly:
```php
$parser = new \Turanjanin\FiscalReceipts\Parser();
$receipt = $parser->parseJournal($receiptContent);
```Receipt class will give you access to the following receipt elements:
- Store data
- Receipt number, counter and type
- List of receipt items
- List of all taxes
- Total amountAlternatively, you can decode receipt URL and extract some of the data offline, without the need for HTTP calls:
```php
$payload = \Turanjanin\FiscalReceipts\UrlDecoder::decode($url);$payload->getTotalAmount();
$payload->getBuyerId();
$payload->getReceiptNumber();
$payload->getReceiptCounter();
$payload->getReceiptDate();
```## Author
- [Jovan Turanjanin](https://github.com/turanjanin)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.