13-05-2026 Waren Wirtschaft

This commit is contained in:
Kevin Adametz 2026-05-13 18:09:20 +02:00
parent 9ce711d6b2
commit ca3eb663fe
40 changed files with 1000 additions and 189 deletions

View file

@ -81,25 +81,9 @@ class StockEntryFactory extends Factory
});
}
public function label(): static
public function shipping(): static
{
return $this->state(function () {
$supplier = Supplier::factory()->create();
$item = PackagingItem::factory()->create([
'supplier_id' => $supplier->id,
'category' => 'label',
]);
return [
'entry_type' => 'label',
'ingredient_id' => null,
'packaging_item_id' => $item->id,
'supplier_id' => $supplier->id,
'unit' => 'piece',
'price_per_kg' => null,
'price_total' => $this->faker->randomFloat(4, 5, 800),
];
});
return $this->shippingOffice();
}
public function shippingOffice(): static
@ -108,11 +92,11 @@ class StockEntryFactory extends Factory
$supplier = Supplier::factory()->create();
$item = PackagingItem::factory()->create([
'supplier_id' => $supplier->id,
'category' => 'shipping_office',
'category' => 'shipping',
]);
return [
'entry_type' => 'shipping_office',
'entry_type' => 'shipping',
'ingredient_id' => null,
'packaging_item_id' => $item->id,
'supplier_id' => $supplier->id,

View file

@ -13,7 +13,7 @@ return new class extends Migration
{
Schema::table('product_ingredients', function (Blueprint $table) {
$table->unsignedSmallInteger('pos')->default(0)->after('ingredient_id');
$table->decimal('gram', 12, 2)->nullable()->after('pos');
$table->decimal('gram', 12, 6)->nullable()->after('pos');
$table->decimal('factor', 4, 2)->default(1.10)->after('gram');
});
}

View file

@ -13,7 +13,7 @@ return new class extends Migration
$table->foreignId('packaging_material_id')->constrained('packaging_materials');
$table->foreignId('supplier_id')->nullable()->constrained('suppliers')->nullOnDelete();
$table->string('name');
$table->enum('category', ['packaging', 'label', 'shipping_office']);
$table->enum('category', ['packaging', 'shipping']);
$table->decimal('weight_grams', 10, 2)->default(0);
$table->unsignedInteger('min_stock_alert')->nullable();
$table->unsignedInteger('product_id')->nullable();

View file

@ -10,7 +10,7 @@ return new class extends Migration
{
Schema::create('stock_entries', function (Blueprint $table) {
$table->id();
$table->enum('entry_type', ['ingredient', 'packaging', 'label', 'shipping_office']);
$table->enum('entry_type', ['ingredient', 'packaging', 'shipping']);
$table->unsignedInteger('ingredient_id')->nullable();
$table->foreign('ingredient_id')->references('id')->on('ingredients')->nullOnDelete();
$table->foreignId('packaging_item_id')->nullable()->constrained('packaging_items')->nullOnDelete();

View file

@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
public function up(): void
{
$driver = DB::getDriverName();
if ($driver === 'sqlite') {
DB::table('packaging_items')
->whereIn('category', ['label', 'shipping_office'])
->update(['category' => 'shipping']);
DB::table('stock_entries')
->whereIn('entry_type', ['label', 'shipping_office'])
->update(['entry_type' => 'shipping']);
return;
}
DB::statement("ALTER TABLE packaging_items MODIFY category ENUM('packaging','label','shipping_office','shipping') NOT NULL");
DB::table('packaging_items')
->whereIn('category', ['label', 'shipping_office'])
->update(['category' => 'shipping']);
DB::statement("ALTER TABLE packaging_items MODIFY category ENUM('packaging','shipping') NOT NULL");
DB::statement("ALTER TABLE stock_entries MODIFY entry_type ENUM('ingredient','packaging','label','shipping_office','shipping') NOT NULL");
DB::table('stock_entries')
->whereIn('entry_type', ['label', 'shipping_office'])
->update(['entry_type' => 'shipping']);
DB::statement("ALTER TABLE stock_entries MODIFY entry_type ENUM('ingredient','packaging','shipping') NOT NULL");
}
public function down(): void
{
$driver = DB::getDriverName();
if ($driver === 'sqlite') {
return;
}
DB::statement("ALTER TABLE packaging_items MODIFY category ENUM('packaging','label','shipping_office') NOT NULL DEFAULT 'packaging'");
DB::statement("ALTER TABLE stock_entries MODIFY entry_type ENUM('ingredient','packaging','label','shipping_office') NOT NULL");
}
};

View file

@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('product_ingredients', function (Blueprint $table) {
$table->decimal('gram', 12, 6)->nullable()->change();
});
}
public function down(): void
{
Schema::table('product_ingredients', function (Blueprint $table) {
$table->decimal('gram', 12, 2)->nullable()->change();
});
}
};

View file

@ -171,7 +171,7 @@ class InventoryStammdatenTestSeeder extends Seeder
[
'packaging_material_id' => $materialPappe->id,
'supplier_id' => $supplierLogistik->id,
'category' => 'shipping_office',
'category' => 'shipping',
'weight_grams' => 95,
'min_stock_alert' => 300,
'product_id' => null,
@ -183,7 +183,7 @@ class InventoryStammdatenTestSeeder extends Seeder
[
'packaging_material_id' => $materialPappe->id,
'supplier_id' => $supplierOele->id,
'category' => 'label',
'category' => 'shipping',
'weight_grams' => 1.2,
'min_stock_alert' => 5000,
'product_id' => null,