Warenwirtschaft: Review-Fix — Stichtags-Schutz als unveränderliches Flag (sale_stock_exempt)
Der Schutz historischer Bestellungen hing an shipped_at, das der OrderStatusService beim Status-Toggle nullt und neu stempelt — Storno + erneutes Versenden einer Alt-Bestellung hätte rückwirkend vom heutigen Bestand abgezogen. Migration mit einmaligem Backfill (shipped_at vor 16.07.2026), Guard prüft nur noch das Flag. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
e6af987237
commit
3eb14762e7
6 changed files with 70 additions and 11 deletions
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* AP-13-Stichtag, unveränderlich (Review 20.07.2026): Der Schutz historischer
|
||||
* Bestellungen hing bisher an `shipped_at` — das nullt der OrderStatusService
|
||||
* aber bei jedem Wechsel weg von versendet/abgeschlossen und stempelt beim
|
||||
* Zurückwechseln neu. Ein Status-Toggle einer Alt-Bestellung hätte dadurch
|
||||
* rückwirkend vom heutigen Bestand abgezogen. Das Flag wird einmalig für alle
|
||||
* vor dem Stichtag versendeten Bestellungen gesetzt und danach nie verändert.
|
||||
*/
|
||||
private const SALE_STOCK_SINCE = '2026-07-16';
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('shopping_orders', function (Blueprint $table) {
|
||||
$table->boolean('sale_stock_exempt')->default(false)->after('shipped_status_locked');
|
||||
});
|
||||
|
||||
// Backfill: shipped_at vor dem Stichtag ⇒ physisch vor Einführung versendet,
|
||||
// im Anfangsbestand also bereits nicht mehr enthalten — nie abziehen.
|
||||
DB::table('shopping_orders')
|
||||
->whereNotNull('shipped_at')
|
||||
->where('shipped_at', '<', self::SALE_STOCK_SINCE)
|
||||
->update(['sale_stock_exempt' => true]);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('shopping_orders', function (Blueprint $table) {
|
||||
$table->dropColumn('sale_stock_exempt');
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue