You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
928 B
38 lines
928 B
<?php
|
|
|
|
namespace App\Domains\Billing\DTOs\Invoicing;
|
|
|
|
use App\Domains\System\Support\ValueObjects\Money;
|
|
|
|
readonly class InvoiceItemDTO
|
|
{
|
|
public PricingDTO $pricing;
|
|
|
|
/**
|
|
* @param string $code
|
|
* @param string $name
|
|
* @param float $quantity
|
|
* @param int $product_id
|
|
* @param ?int $coa_id
|
|
* @param ?int $invoice_id
|
|
*/
|
|
public function __construct(
|
|
public string $code,
|
|
public string $name,
|
|
public float $quantity,
|
|
public int $product_id,
|
|
public ?int $coa_id,
|
|
public ?int $invoice_id = null
|
|
) {}
|
|
|
|
public function setPricing(Money $price, ?Money $discount = null): void
|
|
{
|
|
$netAmount = $price->toInt() * $this->quantity;
|
|
|
|
$this->pricing = new PricingDTO(
|
|
gross_amount: $price,
|
|
discount_amount: $discount ?: new Money(0),
|
|
net_amount: new Money($netAmount),
|
|
);
|
|
}
|
|
}
|
|
|