ttbooking/fiscal-registrar
Composer 安装命令:
composer require ttbooking/fiscal-registrar
包简介
Fiscal Registrar service.
README 文档
README
This Laravel package intended to make, store and process 54FZ-compatible receipts accepted by the Tax Service of Russian Federation through Fiscal Data Operators (FDO, ru ОФД). For the time being it supports most of the Fiscal Data Format (FDF, ru ФФД) 1.05 tags and ATOL Online service API v4 via supplemented driver.
2. Requirements
- PHP 8.2 or greater;
- Laravel Framework 12 or greater;
- Highly recommended: RDBMS with JSON column support;
- ATOL Online & FDO contracts and connection requisites (not needed for testing purposes).
3. Installation
Installation process is simple and straightforward as for almost any Laravel package.
You can install Fiscal Registrar package via Composer:
composer require ttbooking/fiscal-registrar
Package service provider and facade aliases will be automatically registered in your application if package discovery is configured for your project.
Next, you'll need to publish package configuration file (required) and database migration (optional, if you need to change table name or add columns, etc):
# Publish configuration php artisan vendor:publish --provider=TTBooking\FiscalRegistrar\FiscalRegistrarServiceProvider --tag=config # Publish migration php artisan vendor:publish --provider=TTBooking\FiscalRegistrar\FiscalRegistrarServiceProvider --tag=migrations # Publish everything package-related php artisan vendor:publish --provider=TTBooking\FiscalRegistrar\FiscalRegistrarServiceProvider
Then, if you've published migration, you'll need to make needed changes to it before proceeding to the next step. In a default Laravel installation, look it up here: {/database/migrations/blahblah_receipts.php}.
Finally, you should apply database migration, which will create table for receipt storage:
php artisan migrate
4. Configuration
4.1. Using customizable receipt model
First, if you made changes to the database migration (especially table name) during package installation, this step is mandatory.
Otherwise, it is completely optional.
Create Eloquent model in your application's Models namespace (or somewhere else), say (App\Models\Receipt), and extend it from
the package supplemented default implementation (TTBooking\FiscalRegistrar\Models\Receipt). Final result will look like this:
<?php namespace App\Models; use TTBooking\FiscalRegistrar\Models\Receipt as BaseReceipt; class Receipt extends BaseReceipt { protected $table = 'custom_receipts'; }
Note the $table property - it should point to the actual receipt table.
Of course, you may customize this model as you wish, just don't break what already works :)
4.2. Configuring options
You will find Fiscal Registrar configuration file (published in the installation step) here: {/config/fiscal-registrar.php}.
Main options are:
path- path onto (under) which the routes (API & UI) will be mounted (grouped).middleware- middleware to append to the package's routes.model- register your custom receipt model here, and it will replace default model globally (package-wise).connection- default connection instance with its own driver and configuration options. (Better use environment variable, see below)connections- per-connection configurations, will be passed to the driver instances.connections.<name>.driver- driver used for connection; if omitted, will try to resolve driver by connection's name.connections.<name>.callback- callback URL, if supported by the provider and driver. By default, callback URL is autogenerated and doesn't need to be explicitly defined. In order to disable this behavior, you may define callback URL manually or disable callback at all, passing (assigning)false(in)to the option.connections.<name>.*- other driver-specific options.
Also, there is FR_CONNECTION environment variable, which you may use in your project's .env file to choose default connection.
5. General Usage
The most straightforward way of usage in a client code is dependency injection using TTBooking\FiscalRegistrar\Contracts\FiscalRegistrar interface.
This interface has two methods:
public function register(Operation $operation, string $externalId, Receipt $data): string
Register receipt described with Receipt DTO ($data argument) using $operation registration method.
You must also provide unique identifier of the receipt in your system using $externalId argument.
In the simplest case you may use Str::uuid() helper function to generate this identifier.
The return value of this method will be the unique receipt identifier on the provider side.
The Receipt DTO mostly resembles similar structure described in ATOL Online documentation.
public function report(string $id): ?Result
Check out current receipt status using identifier, returned by register method.
ttbooking/fiscal-registrar 适用场景与选型建议
ttbooking/fiscal-registrar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 186 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 02 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「receipt」 「kkm」 「atol」 「fz54」 「54FZ」 「fiscal registrar」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ttbooking/fiscal-registrar 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ttbooking/fiscal-registrar 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ttbooking/fiscal-registrar 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Use OpenAI to extract structured receipt and invoice data from Text, Html, Images and PDFs.
ATOL PHP API Client. Данная библиотека предназначена для работы с сервисом АТОЛ Онлайн
Check atol gateway for Omnipay
Szamlazz.hu PHP integration, package version
Szamlazz.hu integration for Laravel
PHP receipt validator for Apple iTunes, Google Play and Amazon App Store
统计信息
- 总下载量: 186
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-02-26