承接 addeeandra/vat-calculator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

addeeandra/vat-calculator

最新稳定版本:1.0.0

Composer 安装命令:

composer require addeeandra/vat-calculator

包简介

VAT Calculator

README 文档

README

VAT Calculator

Configurable VAT Rate & Calculator

GitHub Workflow Status (main) Latest Stable Version

Vat Calculator ID

This library is a simple VAT calculator.

What's in this library?

  • VAT Rule 11%
  • VAT Rule 12% with custom base (e.g. 11/12)
  • VAT Calculator, when given VAT Rule, you can
    • Calculate VAT of an amount (e.g. AmountExclVat=100_000 => 11_000)
    • Extract VAT from an amount (e.g. AmountInclVat=111_000 => 11_000)
    • Get total amount include VAT (e.g. AmountExclVat=100_000 => 111_000)
    • Get amount exclude VAT from (e.g. AmountInclVat=111_000 => 100_000)

Installation

You can install this package by simply running composer require addeeandra/vat-calculator

How to use

To use this library is simple.

use \Addeeandra\VatCalculator\Rules;
use \Addeeandra\VatCalculator\Builders;

# To use PPN 11% Rule
$rule = new Rules\Vat12Rule();
$rule->calculate(100_000); // 11_000 (float)
$rule->calculator()->vatInAmount(111_000); // 11_000 (float)

# To use PPN 12% Rule
$rule = new Rules\Vat12Rule();
$rule->calculate(100_000); // 11_000 (float)
$rule->calculator()->vatInAmount(111_000); // 11_000 (float)

See VatRuleTest and VatCalculatorTest for more examples.

Need Custom VAT Rule?

You can make custom VAT Rule using VatRuleBuilder considering how fluid is our country's regulation.

image

// new VAT Rate 12% without base 11/12
$newVatRule = \Addeeandra\VatCalculator\Builders\VatRuleBuilder::make()
    ->rate(12) // 12%
    ->build();

// new VAT Rate 12% with base 15/12 which equals to 15%
$newVatRule = \Addeeandra\VatCalculator\Builders\VatRuleBuilder::make()
    ->rate(12) // 12%
    ->base(fn (int|float $amount) => $amount * 15 / 12) // whoops, it's actually 15% :)
    ->build();

License

MIT License

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-11