Return stock of cancelled maintenance, throttle the PIN page's password
Cancelling a maintenance record now reverses the stock it used, through Inventory's new ReverseMaintenanceStockUse behind the MaintenanceMaterials port, in the same transaction as the cancellation. The PIN page allows 5 wrong current passwords a minute per user, as the login form does, so a signed-in session cannot be used to guess the password. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -13,4 +13,9 @@ interface MaintenanceMaterials
|
||||
* @return bool False when the stock could not be recorded (e.g. the item is out of use).
|
||||
*/
|
||||
public function use(int $stockItemId, int $quantityMilli, int $machineId, int $maintenanceRecordId, int $userId): bool;
|
||||
|
||||
/**
|
||||
* Returns the stock a cancelled maintenance record used.
|
||||
*/
|
||||
public function returnUseOf(int $maintenanceRecordId, int $userId): void;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ use App\Modules\Users\Application\Contracts\Clock;
|
||||
* management; counter usage and maintenance done are recorded by
|
||||
* anyone using the machine. A maintenance record starts the item's
|
||||
* intervals again and uses up its stock item; a mistaken record is
|
||||
* cancelled by management, never deleted.
|
||||
* cancelled by management, never deleted, and its stock use reversed.
|
||||
*/
|
||||
final class MachineMaintenance
|
||||
{
|
||||
@@ -169,6 +169,7 @@ final class MachineMaintenance
|
||||
}
|
||||
|
||||
$this->maintenance->cancelRecord($recordId, $actorUserId, $this->clock->now());
|
||||
$this->materials->returnUseOf($recordId, $actorUserId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,17 +4,22 @@ namespace App\Modules\Machines\Infrastructure\Adapters;
|
||||
|
||||
use App\Modules\Inventory\Application\DTOs\StockUseData;
|
||||
use App\Modules\Inventory\Application\UseCases\RecordStockUse;
|
||||
use App\Modules\Inventory\Application\UseCases\ReverseMaintenanceStockUse;
|
||||
use App\Modules\Inventory\Domain\ValueObjects\StockQuantity;
|
||||
use App\Modules\Machines\Application\Contracts\MaintenanceMaterials;
|
||||
use App\Modules\Shared\Domain\Exceptions\DomainException;
|
||||
|
||||
/**
|
||||
* Records stock used at machine maintenance through the Inventory module.
|
||||
* A failure (e.g. the item is out of use) does not undo the maintenance.
|
||||
* Records stock used at machine maintenance through the Inventory module,
|
||||
* and returns it when the maintenance record is cancelled. A failure to
|
||||
* record (e.g. the item is out of use) does not undo the maintenance.
|
||||
*/
|
||||
class StockForMachines implements MaintenanceMaterials
|
||||
{
|
||||
public function __construct(private RecordStockUse $recordUse) {}
|
||||
public function __construct(
|
||||
private RecordStockUse $recordUse,
|
||||
private ReverseMaintenanceStockUse $reverseUse,
|
||||
) {}
|
||||
|
||||
public function use(int $stockItemId, int $quantityMilli, int $machineId, int $maintenanceRecordId, int $userId): bool
|
||||
{
|
||||
@@ -31,4 +36,9 @@ class StockForMachines implements MaintenanceMaterials
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function returnUseOf(int $maintenanceRecordId, int $userId): void
|
||||
{
|
||||
$this->reverseUse->execute($maintenanceRecordId, $userId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user