3 Bounded Contexts (Sales, Invoicing, LegacyFulfillment) avec : - Domaines complets (agrégats, VOs, événements, invariants) - Couche application (commands, queries, ports) - Infrastructure in-memory (repos, gateway fake) - Controllers HTTP Symfony - Couplage naïf synchrone entre BC via NaiveSalesEventPublisher - 20 tests unitaires et d'intégration passants
31 lines
706 B
PHP
31 lines
706 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace MiniShop\Invoicing\Domain\Model;
|
|
|
|
final readonly class InvoiceLine
|
|
{
|
|
public function __construct(
|
|
public string $description,
|
|
public int $quantity,
|
|
public int $unitPriceInCents,
|
|
public string $currency,
|
|
public TaxRate $taxRate,
|
|
) {
|
|
if ($quantity <= 0) {
|
|
throw new \InvalidArgumentException('Quantity must be positive.');
|
|
}
|
|
}
|
|
|
|
public function lineTotalExclTax(): int
|
|
{
|
|
return $this->quantity * $this->unitPriceInCents;
|
|
}
|
|
|
|
public function lineTotalInclTax(): int
|
|
{
|
|
return (int) round($this->lineTotalExclTax() * (1 + $this->taxRate->rate));
|
|
}
|
|
}
|