70 lines
1.8 KiB
PHP
70 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Domain\Models\ValueObjects;
|
|
|
|
use Money\Money;
|
|
|
|
final readonly class ProductPricing
|
|
{
|
|
public function __construct(
|
|
private Money $basePriceHt,
|
|
private Money $basePriceTtc,
|
|
private Money $discountAmountHt,
|
|
private Money $discountedPriceHt,
|
|
private Money $discountedPriceTtc,
|
|
private Money $priceKgTtc,
|
|
public DiscountRate $discountRate,
|
|
public bool $hasDiscount
|
|
) {
|
|
if ($basePriceHt->isNegative()) {
|
|
throw new \DomainException('basePriceHt cannot be negative');
|
|
}
|
|
if ($basePriceTtc->isNegative()) {
|
|
throw new \DomainException('basePriceTtc cannot be negative');
|
|
}
|
|
if ($discountAmountHt->isNegative()) {
|
|
throw new \DomainException('discountAmountHt cannot be negative');
|
|
}
|
|
if ($discountedPriceHt->isNegative()) {
|
|
throw new \DomainException('discountedPriceHt cannot be negative');
|
|
}
|
|
if ($discountedPriceTtc->isNegative()) {
|
|
throw new \DomainException('discountedPriceTtc cannot be negative');
|
|
}
|
|
if ($priceKgTtc->isNegative()) {
|
|
throw new \DomainException('priceKgTtc cannot be negative');
|
|
}
|
|
}
|
|
|
|
public function basePriceHt(): Money
|
|
{
|
|
return $this->basePriceHt;
|
|
}
|
|
|
|
public function basePriceTtc(): Money
|
|
{
|
|
return $this->basePriceTtc;
|
|
}
|
|
|
|
public function discountAmountHt(): Money
|
|
{
|
|
return $this->discountAmountHt;
|
|
}
|
|
|
|
public function discountedPriceHt(): Money
|
|
{
|
|
return $this->discountedPriceHt;
|
|
}
|
|
|
|
public function discountedPriceTtc(): Money
|
|
{
|
|
return $this->discountedPriceTtc;
|
|
}
|
|
|
|
public function priceKgTtc(): Money
|
|
{
|
|
return $this->priceKgTtc;
|
|
}
|
|
}
|