autepos/tax

laravel 的税务包

dev-main 2023-04-09 07:08 UTC

This package is auto-updated.

Last update: 2024-09-09 09:57:13 UTC


README

此包是针对喜欢其界面的 Laravel 税务计算器。

要求

  • PHP 8.0+
  • Laravel 9.x+

安装

使用 composer 安装包

composer require autepos/tax

php artisan migrate

简单用法

use Autepos\Tax\Contracts\TaxableDevice;
use Autepos\Tax\Contracts\TaxCalculatorFactory;

class Order implements TaxableDevice{
    //... Implementation of certain methods require other interfaces to be implemented
}

$order = new Order();
$taxCalculator = app(TaxCalculatorFactory::class);
$taxCalculator->addTaxableDevice($order);
$taxLineList=$taxCalculator->calculate();

$totalTax=$taxLineList->totalAmount();// To be displayed as a total tax
$exclusiveTax=$taxLineList->exclusiveAmount();// To be added to the order subtotal
$inclusiveTax=$taxLineList->inclusiveAmount(); // Already included in the order subtotal