Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
12 / 12 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| TaxSummaryEntry | |
100.00% |
11 / 11 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toArray | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** @license For full copyright and license information, please see the LICENSE.md file. */ |
| 6 | |
| 7 | namespace App\Modules\Tax\Domain\ValueObject; |
| 8 | |
| 9 | defined('AMMONLY_APP') || exit('Direct script access is forbidden.'); |
| 10 | |
| 11 | /** |
| 12 | * Value Object representing a single aggregated row in the document tax summary table. |
| 13 | */ |
| 14 | final readonly class TaxSummaryEntry |
| 15 | { |
| 16 | /** |
| 17 | * TaxSummaryEntry constructor. |
| 18 | * |
| 19 | * @param string $taxCode Unique tax rate identifier code |
| 20 | * @param string $taxName Display name of tax rate |
| 21 | * @param float $ratePercent Percentage rate |
| 22 | * @param TaxStatus $taxStatus Legal tax status |
| 23 | * @param float $netBase Total net tax base for this tax rate |
| 24 | * @param float $taxAmount Total tax amount for this tax rate |
| 25 | * @param float $grossAmount Total gross amount for this tax rate |
| 26 | * @param string|null $legalClause Legal note or reference to legal act |
| 27 | */ |
| 28 | public function __construct( |
| 29 | public string $taxCode, |
| 30 | public string $taxName, |
| 31 | public float $ratePercent, |
| 32 | public TaxStatus $taxStatus, |
| 33 | public float $netBase, |
| 34 | public float $taxAmount, |
| 35 | public float $grossAmount, |
| 36 | public ?string $legalClause = null, |
| 37 | ) { |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Convert TaxSummaryEntry to associative array. |
| 42 | * |
| 43 | * @return array<string, mixed> |
| 44 | */ |
| 45 | public function toArray(): array |
| 46 | { |
| 47 | return [ |
| 48 | 'tax_code' => $this->taxCode, |
| 49 | 'tax_name' => $this->taxName, |
| 50 | 'rate_percent' => $this->ratePercent, |
| 51 | 'tax_status' => $this->taxStatus->value, |
| 52 | 'net_base' => $this->netBase, |
| 53 | 'tax_amount' => $this->taxAmount, |
| 54 | 'gross_amount' => $this->grossAmount, |
| 55 | 'legal_clause' => $this->legalClause, |
| 56 | ]; |
| 57 | } |
| 58 | } |