Track machine counters and maintenance with counter and time intervals

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
2026-11-26 16:52:49 +02:00
co-authored by Claude Sonnet 5.5
parent aac579257a
commit 3e1c671949
53 changed files with 2636 additions and 6 deletions
@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace App\Modules\Machines\Domain\Contracts;
use App\Modules\Machines\Domain\Entities\MaintenanceItem;
use DateTimeImmutable;
/**
* Maintenance items, maintenance records and counter readings.
*/
interface MaintenanceRepository
{
public function findItem(int $id): ?MaintenanceItem;
public function saveItem(MaintenanceItem $item): MaintenanceItem;
/**
* The machine a counter belongs to, or null when there is no such counter.
*/
public function machineOfCounter(int $counterId): ?int;
public function latestReading(int $counterId): ?int;
public function addReading(int $counterId, int $readingMilli, int $userId, DateTimeImmutable $at): void;
/**
* @return int The record's id.
*/
public function addRecord(int $itemId, DateTimeImmutable $performedAt, int $userId, ?int $readingMilli, ?string $note): int;
/**
* @return array{id: int, itemId: int, cancelled: bool}|null
*/
public function findRecord(int $id): ?array;
public function cancelRecord(int $id, int $userId, DateTimeImmutable $at): void;
}