Add products module #46

This commit is contained in:
2025-11-26 10:05:43 +01:00
parent 155f0d3525
commit 83dd8e9ecb
21 changed files with 607 additions and 50 deletions
-37
View File
@@ -1,37 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up()
{
Schema::create('customers', function (Blueprint $table) {
$table->id();
$table->enum('type', ['private', 'business']);
$table->string('company_name', 100)->nullable();
$table->string('vat_id', 50)->nullable();
$table->string('tax_id', 50)->nullable(); // Tax identification number
$table->string('global_id', 50)->nullable(); // Global Location Number (GLN)
$table->string('legal_registration_id', 50)->nullable(); // Legal registration ID
$table->string('email', 100)->unique();
$table->string('phone', 20)->nullable();
$table->json('billing_address'); // Structured as per ZUGFeRD standard
$table->integer('payment_terms')->default(14);
$table->enum('status', ['active', 'inactive', 'prospect'])->default('active');
$table->text('notes')->nullable();
$table->timestamps();
// $table->index('email');
});
}
public function down()
{
Schema::dropIfExists('customers');
}
};
@@ -19,7 +19,7 @@ public function up(): void
$table->string('title')->nullable();
$table->string('description')->nullable();
$table->integer('quantity')->default(1);
$table->string('unit')->default('Stunden');
$table->foreignId('unit_id')->nullable()->constrained()->nullOnDelete();
$table->decimal('price', 10, 2)->nullable();
$table->timestamps();
});
@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->string('title', 64);
$table->text('description')->nullable();
$table->text('notes')->nullable();
$table->string('vendor_url', 100)->nullable();
$table->foreignId('category_id')->constrained()->nullOnDelete()->nullable();
$table->decimal('price', 10, 2)->nullable();
$table->decimal('margin', 2, 2)->default(0.2);
$table->foreignId('unit_id')->nullable()->constrained()->nullOnDelete();
$table->string('image')->nullable();
$table->timestamps();
$table->index(['title', 'description']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('products');
}
};
@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('product_categories', function (Blueprint $table) {
$table->id();
$table->string('name', 64);
$table->timestamps();
$table->index(['name']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('product_categories');
}
};
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
public function up(): void
{
Schema::create('units', function (Blueprint $table) {
$table->id();
$table->string('name', 50)->unique();
$table->string('symbol', 10)->nullable();
$table->timestamps();
});
// Füge Standard-Einheiten hinzu
DB::table('units')->insert([
['name' => 'Stück', 'symbol' => 'Stk'],
['name' => 'Stunden', 'symbol' => 'h'],
['name' => 'Tage', 'symbol' => 'd'],
['name' => 'pauschal', 'symbol' => 'p'],
]);
}
public function down(): void
{
Schema::dropIfExists('units');
}
};