webhub/vat 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

webhub/vat

Composer 安装命令:

composer require webhub/vat

包简介

kdeldycke's VAT rates wrapped in a PHP library

README 文档

README

Build Status codecov Latest Stable Version Total Downloads License

This is a wrapper of kdeldycke/vat-rates.

🛠 Usage

Installation

composer require webhub/vat

Basic use

use Webhub\Vat\Rates;

$rate = (new Rates)->in('NL')->current()->get();

$rate->rate(); // 0.21
$rate->currencyCode(); // 'EUR'

$rate = (new Rates)->in('BE')->at('1990-01-01')->get();
$rate->rate(); // 0.12

Rates

A Rates instance is a collection of rates.

Rates can be filtered:

  • ->in(string $territory) a territory like DE or NL
  • ->at(string|Carbon $when) a date like 2018-01-05, supports Carbon
  • ->current() alias for ->at(Carbon::now())
  • ->type(string $type) rate type, currently the database only contains standard rates.

When one rate remains, the ->get() : Rate method retrieves it, otherwise it throws. Obtain all rates through ->all() : array.

Rate

A Rate has:

  • ->rate() : string decimal fraction representation of the rate, e.g. '0.20' for 20%
  • ->rateType() : string type of the rate, currently standard.
  • ->(start|stop)Date() : Carbon Carbon date instance of first valid day and subsequent first not-valid day.
  • ->currencyCode() : string currency like SEK or EUR
  • ->description() : ?string optional description of the rate

Rates proxies method calls to the underlying Rate if it exists and is unique.

// with ->get()
(new Rates)->in('DE')->current()->get()->rate();
// equals shorter:
(new Rates)->in('DE')->current()->rate();

// non unique
(new Rates)->in('FR')->rate();  // throws AmbiguousResultException
(new Rates)->in('XX')->get();   // throws NoResultException

Rate array access

A Rate implements ArrayAccess, so when using with for example Laravel's Collection, this is perfectly possible:

collect((new Rates)->in('NL')->all())
  ->sortBy('start_date')
  ->pluck('rate', 'start_date');

📝 Compiling a new dataset

Data is obtained from kdeldycke/vat-rates and written to a PHP file data.php that is included in Rates.

composer install
composer run build  // runs Generator::generate()

🇪🇺

统计信息

  • 总下载量: 121
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固