45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Inventory\Application\DTOs;
|
|
|
|
use App\Modules\Inventory\Domain\Enums\StockUnit;
|
|
|
|
/**
|
|
* A stock item with its balance (in thousandths), moving average cost (in
|
|
* hundredths of a cent per unit) and stock value (in cents). Costs and
|
|
* values are shown only to those who may see them.
|
|
*/
|
|
final readonly class StockItemSummary
|
|
{
|
|
public function __construct(
|
|
public int $id,
|
|
public int $groupId,
|
|
public string $groupName,
|
|
public string $name,
|
|
public StockUnit $unit,
|
|
public ?string $code,
|
|
public ?string $supplier,
|
|
public ?int $reorderLevelMilli,
|
|
public int $balanceMilli,
|
|
public int $averageCostHundredths,
|
|
public int $valueCents,
|
|
public bool $hasImage,
|
|
public bool $isActive,
|
|
) {}
|
|
|
|
/**
|
|
* At or below the reorder level: to be ordered (tilattava).
|
|
*/
|
|
public function needsReorder(): bool
|
|
{
|
|
return $this->reorderLevelMilli !== null && $this->balanceMilli <= $this->reorderLevelMilli;
|
|
}
|
|
|
|
public function isNegative(): bool
|
|
{
|
|
return $this->balanceMilli < 0;
|
|
}
|
|
}
|