Files
Toiminnanohjaus/app/Modules/Machines/Domain/Contracts/MaintenanceRepository.php
T
petriandClaude Sonnet 5.5 6692396a63 Fix console hours, sign-in landing and counter usage races
- Hours the counter reading cannot parse (",5") no longer fail after
  they are saved; they just get no hour counter suggestion.
- The console's sign-in falls back to a console machine list
  (machines::console-picker at /console/machines) instead of /machines,
  so it stays in the console's own session.
- Recording counter usage locks the counter first, so usage saved at
  the same time from two devices is not lost.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-29 10:05:02 +02:00

48 lines
1.3 KiB
PHP

<?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;
/**
* Locks the counter until the transaction ends, so usage recorded at
* the same time is added one after the other.
*
* @return bool Whether the counter exists.
*/
public function lockCounter(int $counterId): bool;
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;
}