eventix/eu-vat
Composer 安装命令:
composer require eventix/eu-vat
包简介
Eu VAT formatting and validation Laravel package
README 文档
README
This Laravel package enables the formatting and validation of (EU) VAT numbers.
For validation it uses the endpoints of the European Commission's VAT Information Exchange Service (VIES)
Table of Contents
Installation
Via Composer
$ composer require eventix/eu-vat
Usage
When the package is included in a Laravel project, composer autoload functionality has automatically discovered a Service Provider. This will extend the Laravel Validator with a validation rule (vat_number).
Also an alias for a Facade is registered. This facade (EuVat) will enable manual formatting and validation for vat numbers.
Supported countries
EuVat::codes(): array; // List of supported country codes EuVat::supports(string $countryCode): bool; // Determines if a given country code is supported EuVat::name(string $countryCode): ?string; // Returns the (english) name associated with a country code if it is supported) EuVat::inferCountry(string $vatNumber): ?string; // (Try to) guess the country of a vat number.
Vat Numbers
EuVat::format(string $vatNumber, ?string $countryCode = null): ?string // (Try to) format a vat number by the formatting rules of a given country, or a guessed country EuVat::validate(string $vatNumber, ?string $countryCode = null): ?string // (Try to) validate a vat number by the formatting rules of a given country, or a guessed country
Validator
Validates the vat number by inferring its country
$data = [ 'vat_nr' => 'NL123456789B01', ]; $validator = Validator::make($data, [ 'vat_nr' => 'required|vat_number', ]);
Validates the vat number for a given country
$data = [ 'vat_nr' => 'NL123456789B01', ]; $validator = Validator::make($data, [ 'vat_nr' => 'required|vat_number:NL', ]);
Validates the vat number for a country determined by another field
$data = [ 'country' => 'NL', 'vat_nr' => 'NL123456789B01', ]; $validator = Validator::make($data, [ 'vat_nr' => 'required|vat_number:country', ]);
Validation ONLY when the vat number changes
If the value does not change... it should already be valid. This will reduce the calls to VIES. Note: The validation rule needs the original value for this to work.
Validates a changed vat number for an inferred country
$data = [ 'vat_nr' => 'NL123456789B01', ]; $validator = Validator::make($data, [ 'vat_nr' => 'required|vat_number:NULL,NL123456789B01', ]);
Validates a changed vat number for a country determined by another field
$data = [ 'country' => 'NL', 'vat_nr' => 'NL123456789B01', ]; $validator = Validator::make($data, [ 'vat_nr' => 'required|vat_number:country,NL123456789B01', ]);
Validates a changed vat number for a given country
$data = [ 'vat_nr' => 'NL123456789B01', ]; $validator = Validator::make($data, [ 'vat_nr' => 'required|vat_number:NL,NL123456789B01', ]);
Testing
Note, for testing the project needs to be cloned and all dependencies installed first.
$ cd /packages/directory
$ git clone git@github.com:Eventix/eu-vat.git
$ composer install
$ composer test
License
Please see License File.
No liability, implementor is responsible for reviewing code!
Issues
Please open an issue.
Contributing
Please contribute using Github Flow. Fork the project, create a branch, add commits, and open a pull request.
Opportunities
- Test coverage is not a 100% yet.
Potentials
- Opportunities for localized country names
- Opportunities for 3 char country codes
- Opportunities for country/ies outside the EU
eventix/eu-vat 适用场景与选型建议
eventix/eu-vat 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 08 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「vat」 「vies」 「eu」 「eventix」 「laravel-validation-rules」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 eventix/eu-vat 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 eventix/eu-vat 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 eventix/eu-vat 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Library to format data from VIES service (http://ec.europa.eu/taxation_customs/vies/?locale=en)
A VAT number check (Web Service) Plugin for CakePHP
Validate the format of EU vat numbers.
PHP VAT checker based on the European Commission web service
EU VAT (BTW) validator for Laravel — VIES with automatic fallbacks (controleerbtwnummer.eu, btw-opzoeken.be), 24h cache, address parsing.
A Laravel package for interacting with the VIES (VAT Information Exchange System) REST API, allowing validation of VAT numbers within the European Union.
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-28