mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 10:09:35 +01:00
feat(inventory): Reservierung bestätigen – Material entnehmen (US-4.3)
Allokierte Mengen werden physisch aus den Chargen abgezogen, StockMovements erzeugt und die Reservation entfernt. MovementType wird aus ReferenceType abgeleitet (PRODUCTION_ORDER→PRODUCTION_CONSUMPTION, SALE_ORDER→SALE).
This commit is contained in:
parent
19f1cf16a1
commit
0b6028b967
11 changed files with 773 additions and 2 deletions
|
|
@ -125,6 +125,34 @@ public final class InventoryScenario {
|
|||
);
|
||||
}
|
||||
|
||||
public static ChainBuilder reserveAndConfirmStock() {
|
||||
return exec(session -> {
|
||||
var stockIds = LoadTestDataSeeder.stockIds();
|
||||
if (stockIds == null || stockIds.isEmpty()) return session;
|
||||
String id = stockIds.get(ThreadLocalRandom.current().nextInt(stockIds.size()));
|
||||
return session
|
||||
.set("reserveStockId", id)
|
||||
.set("reserveRefId", "LT-PO-%06d".formatted(ThreadLocalRandom.current().nextInt(999999)));
|
||||
}).doIf(session -> session.contains("reserveStockId")).then(
|
||||
exec(
|
||||
http("Reservierung anlegen")
|
||||
.post("/api/inventory/stocks/#{reserveStockId}/reservations")
|
||||
.header("Authorization", "Bearer #{accessToken}")
|
||||
.body(StringBody("""
|
||||
{"referenceType":"PRODUCTION_ORDER","referenceId":"#{reserveRefId}","quantityAmount":"1","quantityUnit":"KILOGRAM","priority":"NORMAL"}"""))
|
||||
.check(status().in(201, 409))
|
||||
.check(jsonPath("$.id").optional().saveAs("reservationId"))
|
||||
).doIf(session -> session.contains("reservationId")).then(
|
||||
exec(
|
||||
http("Reservierung bestätigen")
|
||||
.post("/api/inventory/stocks/#{reserveStockId}/reservations/#{reservationId}/confirm")
|
||||
.header("Authorization", "Bearer #{accessToken}")
|
||||
.check(status().in(200, 404))
|
||||
).exec(session -> session.remove("reservationId"))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static ChainBuilder recordStockMovement() {
|
||||
return exec(session -> {
|
||||
var rnd = ThreadLocalRandom.current();
|
||||
|
|
@ -170,7 +198,8 @@ public final class InventoryScenario {
|
|||
percent(5.0).then(listStockMovementsByStock()),
|
||||
percent(5.0).then(listStockMovementsByBatch()),
|
||||
percent(5.0).then(listStockMovementsByDateRange()),
|
||||
percent(15.0).then(recordStockMovement())
|
||||
percent(8.0).then(reserveAndConfirmStock()),
|
||||
percent(7.0).then(recordStockMovement())
|
||||
).pause(1, 3)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue