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]>
This commit is contained in:
2026-11-29 10:05:02 +02:00
co-authored by Claude Sonnet 5.5
parent 32c33e2a64
commit 6692396a63
14 changed files with 139 additions and 12 deletions
@@ -155,6 +155,21 @@ it('suggests the hours booked as the usage of the machine\'s hour counter and le
expect(MachineCounterReadingModel::query()->sole()->reading_milli)->toBe(1_500);
});
it('saves hours written as ",5" without a counter suggestion it cannot read', function () {
$hours = MachineCounterModel::query()->create(['machine_id' => $this->machine->id, 'name' => 'Käyttötunnit', 'unit' => 'hour', 'sort_order' => 1]);
console($this)
->call('selectRow', MachineQueueEntryModel::query()->sole()->id)
->set('hours', ',5')
->call('saveHours')
->assertHasNoErrors()
->assertSet('hours', '')
->assertSet('usage', []);
expect(TimeEntryModel::query()->sole()->hours)->toEqual(0.5)
->and(MachineCounterReadingModel::query()->where('machine_counter_id', $hours->id)->exists())->toBeFalse();
});
it('changes the console\'s user with a PIN code', function () {
$console = route('machines.console', $this->machine->id);
$other = User::factory()->employee()->create(['name' => 'Olli Operaattori', 'pin_hash' => Hash::make('2468')]);