Count stock and correct the differences on confirmation

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
2026-11-26 16:34:08 +02:00
co-authored by Claude Sonnet 5.5
parent bca1eed166
commit 0de0e332b2
27 changed files with 1568 additions and 0 deletions
@@ -0,0 +1,41 @@
<?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;
}
}
@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace App\Modules\Inventory\Application\DTOs;
/**
* A stock count as listed. $groupNames is empty for the whole stock;
* $confirmedAt is "Y-m-d H:i" in the company's time zone.
*/
final readonly class InventoryCountSummary
{
/**
* @param list<string> $groupNames
*/
public function __construct(
public int $id,
public string $countedOn,
public bool $isConfirmed,
public array $groupNames,
public string $startedByName,
public ?string $confirmedByName,
public ?string $confirmedAt,
public int $countedItems,
public ?int $valueBeforeCents,
public ?int $valueAfterCents,
) {}
}