Add stock items, groups and movements at a moving average cost
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Inventory\Domain\Entities;
|
||||
|
||||
use App\Modules\Inventory\Domain\ValueObjects\StockName;
|
||||
|
||||
/**
|
||||
* A group of stock items (nimikeryhmä), e.g. Paperit ja kartongit. Groups
|
||||
* are ordered, and never deleted, only taken out of use.
|
||||
*/
|
||||
final class StockItemGroup
|
||||
{
|
||||
private function __construct(
|
||||
private ?int $id,
|
||||
private StockName $name,
|
||||
private int $sortOrder,
|
||||
private bool $active,
|
||||
) {}
|
||||
|
||||
public static function create(StockName $name, int $sortOrder): self
|
||||
{
|
||||
return new self(null, $name, $sortOrder, true);
|
||||
}
|
||||
|
||||
public static function reconstitute(int $id, StockName $name, int $sortOrder, bool $active): self
|
||||
{
|
||||
return new self($id, $name, $sortOrder, $active);
|
||||
}
|
||||
|
||||
public function rename(StockName $name): void
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function activate(): void
|
||||
{
|
||||
$this->active = true;
|
||||
}
|
||||
|
||||
public function deactivate(): void
|
||||
{
|
||||
$this->active = false;
|
||||
}
|
||||
|
||||
public function swapOrderWith(self $other): void
|
||||
{
|
||||
[$this->sortOrder, $other->sortOrder] = [$other->sortOrder, $this->sortOrder];
|
||||
}
|
||||
|
||||
public function id(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function name(): StockName
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function sortOrder(): int
|
||||
{
|
||||
return $this->sortOrder;
|
||||
}
|
||||
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user