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,37 @@
<?php
declare(strict_types=1);
namespace App\Modules\Inventory\Domain\Contracts;
use App\Modules\Inventory\Domain\Entities\InventoryCount;
use DateTimeImmutable;
interface InventoryCountRepository
{
public function findById(int $id): ?InventoryCount;
/**
* The count, locked until the end of the transaction.
*/
public function lockById(int $id): ?InventoryCount;
public function hasOpen(): bool;
public function save(InventoryCount $count): InventoryCount;
/**
* Stores a counted quantity with the book balance of the moment; a
* recount replaces the line.
*/
public function recordLine(int $countId, int $itemId, int $bookMilli, int $countedMilli, int $userId, DateTimeImmutable $at): void;
public function removeLine(int $countId, int $itemId): void;
/**
* @return list<array{itemId: int, bookMilli: int, countedMilli: int}>
*/
public function lines(int $countId): array;
public function setLineUnitCost(int $countId, int $itemId, int $unitCostHundredths): void;
}
@@ -19,4 +19,9 @@ interface StockItemRepository
public function save(StockItem $item): StockItem;
public function isNameTaken(string $name, ?int $exceptId = null): bool;
/**
* The value of all stock: each item's balance at its average cost.
*/
public function stockValueCents(): int;
}