nsommer89 / php-taxsum
一个用于计算进销项税的PHP库
v1.2.3
2023-02-19 11:46 UTC
Requires (Dev)
- phpunit/phpunit: ^10.0
README
关于
一个用于计算进销项税的PHP库。可以计算价格中的增值税额,也可以计算已包含增值税的价格中的增值税额。
需求
最低版本 >= php8.0
使用Composer安装
composer require nsommer89/php-taxsum
.. 或者 GitHub 页面: https://github.com/nsommer89/php-taxsum
库的使用
<?php
require_once __DIR__ . '/path/to/autoload.php';
use Nsommer89\PhpTaxsum\Taxsum;
$taxsum = new Taxsum(25.00); // VAT percent in Denmark is 25% on purchases
// Add VAT to a price and get the price including 25% VAT
echo 250.00 + $taxsum->forth(250.00); // 250.00 + 62.50 = 312.50
// Calculate the VAT back to the price without VAT
echo 312.50 - $taxsum->back(312.50); // 312.50 - 62.50 = 250.00
向构造函数添加选项
// ...
$taxsum = new Taxsum(25.00, [
'currency' => 'DKK', //
'currency_space' => true
'decimals' => 2,
'currency_position' => 'before', // before or after
'decimal_separator' => ',',
'thousands_separator' => '.',
]);
// ...
选项说明
currency
€|$|£|DKK|NOK|SEK等等。使用 null
表示禁用
currency_space
在货币和金额之间添加空格
decimals
输出的位数
currency_position
在金额之前或之后添加货币
decimal_separator
分离小数和数字的字符
thousands_separator
表示千位的字符
CLI 使用
总体使用
$ ./vendor/bin/taxsum <method> <tax> <amount>
<result>
计算进项
$ ./vendor/bin/taxsum forth 25 250.00
62.50
计算销项
$ ./vendor/bin/taxsum back 25 312.50
62.50
由 nsommer89 用 ♡ 制作