42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Inventory\Application\DTOs;
|
|
|
|
use App\Modules\Inventory\Domain\Enums\StockUnit;
|
|
|
|
/**
|
|
* An item on a stock count's list: its current balance and, once counted,
|
|
* the counted quantity and the book balance at the moment of counting.
|
|
* The unit cost is the one stored at confirmation, or the current average
|
|
* cost while the count is open.
|
|
*/
|
|
final readonly class InventoryCountLine
|
|
{
|
|
public function __construct(
|
|
public int $itemId,
|
|
public string $itemName,
|
|
public ?string $code,
|
|
public int $groupId,
|
|
public string $groupName,
|
|
public StockUnit $unit,
|
|
public int $currentBalanceMilli,
|
|
public ?int $bookMilli,
|
|
public ?int $countedMilli,
|
|
public int $unitCostHundredths,
|
|
public ?string $countedByName,
|
|
public ?string $countedAt,
|
|
) {}
|
|
|
|
public function isCounted(): bool
|
|
{
|
|
return $this->countedMilli !== null;
|
|
}
|
|
|
|
public function differenceMilli(): ?int
|
|
{
|
|
return $this->countedMilli === null || $this->bookMilli === null ? null : $this->countedMilli - $this->bookMilli;
|
|
}
|
|
}
|