mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 15:49:35 +01:00
fix(inventory): Stock-Existenz-Check bei Lagerort-Deaktivierung
DeactivateStorageLocation prüft jetzt via StockRepository ob Bestände am Lagerort existieren bevor deaktiviert wird (Story 1.2 Akzeptanzkriterium). 5 Unit Tests und 1 Integrationstest für den neuen Check.
This commit is contained in:
parent
42c9ca9d19
commit
792d5f0d97
2 changed files with 153 additions and 5 deletions
|
|
@ -9,9 +9,11 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
public class DeactivateStorageLocation {
|
||||
|
||||
private final StorageLocationRepository storageLocationRepository;
|
||||
private final StockRepository stockRepository;
|
||||
|
||||
public DeactivateStorageLocation(StorageLocationRepository storageLocationRepository) {
|
||||
public DeactivateStorageLocation(StorageLocationRepository storageLocationRepository, StockRepository stockRepository) {
|
||||
this.storageLocationRepository = storageLocationRepository;
|
||||
this.stockRepository = stockRepository;
|
||||
}
|
||||
|
||||
public Result<StorageLocationError, StorageLocation> execute(String storageLocationId, ActorId performedBy) {
|
||||
|
|
@ -29,16 +31,24 @@ public class DeactivateStorageLocation {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Stock-Existenz prüfen, wenn Stock BC implementiert ist
|
||||
// Akzeptanzkriterium: Deaktivierung schlägt fehl, wenn Stock am Lagerort existiert
|
||||
// 2. Stock-Existenz prüfen
|
||||
switch (stockRepository.findAllByStorageLocationId(locationId)) {
|
||||
case Result.Failure(var err) ->
|
||||
{ return Result.failure(new StorageLocationError.RepositoryFailure(err.message())); }
|
||||
case Result.Success(var stocks) -> {
|
||||
if (!stocks.isEmpty()) {
|
||||
return Result.failure(new StorageLocationError.StockExistsAtLocation(storageLocationId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Deaktivieren
|
||||
// 3. Deaktivieren
|
||||
switch (location.deactivate()) {
|
||||
case Result.Failure(var err) -> { return Result.failure(err); }
|
||||
case Result.Success(var ignored) -> { }
|
||||
}
|
||||
|
||||
// 3. Speichern
|
||||
// 4. Speichern
|
||||
switch (storageLocationRepository.save(location)) {
|
||||
case Result.Failure(var err) ->
|
||||
{ return Result.failure(new StorageLocationError.RepositoryFailure(err.message())); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue