<?php
namespace App\Services\Accounting;
use App\Support\Decimal;
final class TaxCalculator
{
    public function exclusive(string $net,string $rate): array { $tax=Decimal::divide(Decimal::multiply($net,$rate),'100'); return ['net'=>Decimal::scale($net),'tax'=>$tax,'gross'=>Decimal::add($net,$tax)]; }
    public function inclusive(string $gross,string $rate): array { $divisor=Decimal::add('100',$rate); $net=Decimal::divide(Decimal::multiply($gross,'100'),$divisor); return ['net'=>$net,'tax'=>Decimal::subtract($gross,$net),'gross'=>Decimal::scale($gross)]; }
}
