Step 00 — Squelette + intégration naïve
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
This commit is contained in:
30
src/Invoicing/Domain/Model/InvoiceLine.php
Normal file
30
src/Invoicing/Domain/Model/InvoiceLine.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user