laudis/fiscal 问题修复 & 功能扩展

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

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

laudis/fiscal

Composer 安装命令:

composer require laudis/fiscal

包简介

library for common fiscal operations

README 文档

README

Latest Stable Version Total Downloads Monthly Downloads Maintainability Test Coverage MIT License

Installation

Install via composer:

composer require laudis/fiscal

General usage

Laudis fiscal library is essentially a client which pulls fiscal information from a database and provides classes to translate it into business logic.

Initializing the repository

Everything starts from the repository:

$repository = new \Laudis\Fiscal\FiscalRepository(new PDO(getenv('PDO_DSN'), getenv('USERNAME'), getenv('PASSWORD')));

Loading indexed values

Indexed values a values that change over a period in time. Laudis fiscal interprets indexed values as essentially ranges of dates with a value and some identifying information.

// The date argument can either be a string in the Y-m-d format, an integer representing a timestamp, or an object implementing \DateTimeInterface.
$values = $repository->loadIndexedValuesWithSlugs('2010-01-01', ['cpi', 'euribor', 'protected-property-car-amount-AUS']);

$euribor = $values->get('euribor'); // Returns the euribor of that day
$cpi = $values->get('cpi'); // Throws OutOfBoundsException if it wasn't found for that day
$protected = $values->get('protected-property-car-amount-AUS', null); // Will return null instead of throwing when it wasn't found on that day.

Loading scales

Scales are a combination of ranges composed by rules which in turn will apply a factor on the value of each of these rules.

Example:

Scale personal tax Belgium taxation year 2020 (yes this is real):

from until fixed percentage
0.00 13 250.00 0.00 25.00%
13 250.00 23 390.00 3 312.50 40.00%
23 390.00 40 480.00 7 368.50 45.00%
40 480.00 ... 15 059.00 50.00%

Laudis fiscal understands this logic which they can be loaded like this:

$scale = $repository->loadScaleWithSlugs(DateTime::createFromFormat('Y-m-d', '2020-01-01'), ['personal-tax'])->first();

echo $scale->calculate(50000); // echos 13 250.00
echo $scale->calculate(8000); // echos 2000

Scales can further be exploited to fully explain the logic they are doing:

$explanation = $scale->explain(50000);

Fiscal Feature Support

Feature Supported?
Indexed Values Read
Scales Read
Mysql support Yes

Requirements

  • PHP >= 7.4
  • A mariadb/mysql database
  • ext-json
  • ext-pdo
  • ext-pdo_mysql

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-12-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固