Warenwirtschaft: F-16 — fachliche Vorbedingungen innerhalb der Sperre prüfen
- Statusservice: Vorbedingung (Ausgangsstatus, Zahlungsfreigabe) wird nach lockForUpdate erneut geprüft (Board übergibt sie als Closure). - Wareneingang: Transaktion + Sperre, „offen“ wird innerhalb der Sperre geprüft. - Ausschuss: betroffene Wareneingänge sperren und Restbestand in der Transaktion erneut prüfen. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
c2a17835ef
commit
731b2461e2
7 changed files with 170 additions and 36 deletions
|
|
@ -12,10 +12,12 @@ use App\Models\ShoppingPayment;
|
|||
use App\Models\ShoppingUser;
|
||||
use App\Models\UserAccount;
|
||||
use App\Services\Invoice;
|
||||
use App\Services\OrderStatusService;
|
||||
use App\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Tests\TestCase;
|
||||
|
||||
uses(TestCase::class, RefreshDatabase::class);
|
||||
|
|
@ -455,3 +457,18 @@ test('F-10: ohne zahlungsfreigabe kein versandabschluss ueber das board, konfekt
|
|||
expect((int) $order->fresh()->shipped)->toBe(2)
|
||||
->and(ProductStockMovement::query()->where('product_id', $product->id)->count())->toBe(1);
|
||||
});
|
||||
|
||||
test('F-16: statusservice prueft die vorbedingung innerhalb der sperre erneut', function () {
|
||||
$order = ofMakeOrder([], ['shipped' => 0]);
|
||||
|
||||
expect(fn () => app(OrderStatusService::class)->setShipped(
|
||||
$order->id, 2, null, true, fn (ShoppingOrder $o) => __('abgelehnt')
|
||||
))->toThrow(ValidationException::class);
|
||||
|
||||
expect((int) $order->fresh()->shipped)->toBe(0)
|
||||
->and($order->fresh()->shipped_status_locked)->toBeFalsy();
|
||||
|
||||
// Ohne Fehler aus der Vorbedingung läuft der Wechsel wie gehabt.
|
||||
app(OrderStatusService::class)->setShipped($order->id, 1, null, true, fn (ShoppingOrder $o) => null);
|
||||
expect((int) $order->fresh()->shipped)->toBe(1);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue