Datenmodell Kern: Projekt, PFA, Vertrag, LV, Nachtrag, Dokument
- Mandant, Auftragnehmer, Projekt mit Suchreihenfolge, Abschnitt (PFA), Vertrag, Leistungsverzeichnis, Nachtrag (MKA nur als Bezug), Nachtragsposition, Dokument - Projektmitglieder mit Projektrolle, Freigaben für vertrauliche Dokumente - Mandant, Land und Projekt werden vom übergeordneten Datensatz übernommen; Fehlzuordnungen über Mandanten oder Projekte hinweg werden abgewiesen - Feste Morph-Map, Factories, Demodaten (Musterbahn, PFA 1–4, N14/N16/N21), Tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ca09d23a78
commit
6aac8b0a16
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Abschnitt;
|
||||
use App\Models\Projekt;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Abschnitt>
|
||||
*/
|
||||
class AbschnittFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'projekt_id' => Projekt::factory(),
|
||||
'bezeichnung' => 'PFA '.fake()->unique()->numberBetween(1, 999999),
|
||||
'sortierung' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\Land;
|
||||
use App\Models\Auftragnehmer;
|
||||
use App\Models\Mandant;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Auftragnehmer>
|
||||
*/
|
||||
class AuftragnehmerFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'mandant_id' => Mandant::factory(),
|
||||
'land' => Land::DE,
|
||||
'name' => fake()->unique()->company(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\DokumentKategorie;
|
||||
use App\Models\Dokument;
|
||||
use App\Models\Projekt;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<Dokument>
|
||||
*/
|
||||
class DokumentFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$uuid = (string) Str::uuid();
|
||||
|
||||
return [
|
||||
'projekt_id' => Projekt::factory(),
|
||||
'kategorie' => DokumentKategorie::Sonstiges,
|
||||
'dateiname' => 'beispiel.pdf',
|
||||
'pfad' => 'dokumente/'.$uuid.'.pdf',
|
||||
'mime_type' => 'application/pdf',
|
||||
'groesse' => fake()->numberBetween(10_000, 5_000_000),
|
||||
'sha256' => hash('sha256', $uuid),
|
||||
'vertraulich' => false,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Dokument zu einem LV, Nachtrag oder Vertrag; Projekt, Mandant und Land kommen von dort.
|
||||
*/
|
||||
public function zu(Model $dokumentable, DokumentKategorie $kategorie): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'projekt_id' => null,
|
||||
'dokumentable_type' => $dokumentable->getMorphClass(),
|
||||
'dokumentable_id' => $dokumentable->getKey(),
|
||||
'kategorie' => $kategorie,
|
||||
]);
|
||||
}
|
||||
|
||||
public function vertraulich(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => ['vertraulich' => true]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\VerarbeitungStatus;
|
||||
use App\Models\Leistungsverzeichnis;
|
||||
use App\Models\Vertrag;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Leistungsverzeichnis>
|
||||
*/
|
||||
class LeistungsverzeichnisFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'vertrag_id' => Vertrag::factory(),
|
||||
'bezeichnung' => sprintf('LV %02d %s', fake()->numberBetween(1, 35), fake()->randomElement([
|
||||
'Baustelleneinrichtung', 'Oberbau', 'Entwässerung', 'Kabeltiefbau', 'Erdbau',
|
||||
])),
|
||||
'import_status' => VerarbeitungStatus::Wartet,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Mandant;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Mandant>
|
||||
*/
|
||||
class MandantFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->unique()->company(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\NachtragStatus;
|
||||
use App\Models\Nachtrag;
|
||||
use App\Models\Vertrag;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Nachtrag>
|
||||
*/
|
||||
class NachtragFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'vertrag_id' => Vertrag::factory(),
|
||||
'nummer' => 'N'.fake()->unique()->numberBetween(1, 999999),
|
||||
'eingang_am' => fake()->dateTimeBetween('-3 months'),
|
||||
'betreff' => fake()->sentence(4),
|
||||
'mka_bezug' => ['MKA '.fake()->numberBetween(1, 200)],
|
||||
'status' => NachtragStatus::Eingegangen,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Nachtrag;
|
||||
use App\Models\Nachtragsposition;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Nachtragsposition>
|
||||
*/
|
||||
class NachtragspositionFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'nachtrag_id' => Nachtrag::factory(),
|
||||
'oz' => sprintf('01.%07d', fake()->unique()->numberBetween(1, 9999999)),
|
||||
'kurztext' => fake()->sentence(5),
|
||||
'langtext' => fake()->paragraph(),
|
||||
'menge' => fake()->randomFloat(3, 1, 2000),
|
||||
'einheit' => fake()->randomElement(['m', 'm²', 'm³', 'St', 'psch']),
|
||||
'einheitspreis' => fake()->randomFloat(2, 1, 500),
|
||||
'sortierung' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\Land;
|
||||
use App\Enums\ProjektStatus;
|
||||
use App\Enums\Vertragsgrundlage;
|
||||
use App\Models\Mandant;
|
||||
use App\Models\Projekt;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Projekt>
|
||||
*/
|
||||
class ProjektFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'mandant_id' => Mandant::factory(),
|
||||
'land' => Land::DE,
|
||||
'name' => 'Elektrifizierung '.fake()->city(),
|
||||
'nummer' => fake()->numerify('P-####'),
|
||||
'auftraggeber' => 'DB InfraGO AG',
|
||||
'vertragsgrundlage' => Vertragsgrundlage::VobB,
|
||||
'abschnitt_bezeichnung' => 'PFA',
|
||||
'status' => ProjektStatus::Aktiv,
|
||||
];
|
||||
}
|
||||
|
||||
public function archiviert(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => ['status' => ProjektStatus::Archiviert]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Abschnitt;
|
||||
use App\Models\Auftragnehmer;
|
||||
use App\Models\Vertrag;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Vertrag>
|
||||
*/
|
||||
class VertragFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'abschnitt_id' => Abschnitt::factory(),
|
||||
// Auftragnehmer im selben Mandanten und Land wie der Abschnitt
|
||||
'auftragnehmer_id' => function (array $attributes) {
|
||||
$abschnitt = Abschnitt::query()->whereKey($attributes['abschnitt_id'])->firstOrFail();
|
||||
|
||||
return Auftragnehmer::factory()->state([
|
||||
'mandant_id' => $abschnitt->mandant_id,
|
||||
'land' => $abschnitt->land,
|
||||
]);
|
||||
},
|
||||
'bezeichnung' => fake()->randomElement(['Gleisbau', 'Tunnelbau', 'Oberleitung', 'Kabeltiefbau']),
|
||||
'vertragsnummer' => fake()->numerify('V-#####'),
|
||||
'vertrag_vom' => fake()->dateTimeBetween('-2 years', '-1 month'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Kern des Datenmodells: Mandant → Projekt → Abschnitt (PFA) → Vertrag → LVs und Nachträge.
|
||||
* Beschreibung in docs/datenmodell.md.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('mandanten', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->foreignId('mandant_id')->nullable()->after('id')->constrained('mandanten')->restrictOnDelete();
|
||||
});
|
||||
|
||||
Schema::create('auftragnehmer', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('mandant_id')->constrained('mandanten')->restrictOnDelete();
|
||||
$table->char('land', 2);
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['mandant_id', 'land', 'name']);
|
||||
});
|
||||
|
||||
Schema::create('projekte', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('mandant_id')->constrained('mandanten')->restrictOnDelete();
|
||||
$table->char('land', 2);
|
||||
$table->string('name');
|
||||
$table->string('nummer', 100)->nullable();
|
||||
$table->string('auftraggeber');
|
||||
$table->string('vertragsgrundlage', 20)->default('vob_b');
|
||||
$table->string('abschnitt_bezeichnung', 50)->default('PFA');
|
||||
$table->string('status', 20)->default('aktiv');
|
||||
$table->boolean('suche_andere_vertraege_im_abschnitt')->default(false);
|
||||
$table->boolean('suche_andere_abschnitte')->default(true);
|
||||
$table->boolean('suche_nur_gleicher_auftragnehmer')->default(false);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['mandant_id', 'land', 'status']);
|
||||
});
|
||||
|
||||
Schema::create('projekt_mitglieder', function (Blueprint $table) {
|
||||
$table->foreignId('projekt_id')->constrained('projekte')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
|
||||
$table->string('rolle', 20);
|
||||
$table->timestamps();
|
||||
|
||||
$table->primary(['projekt_id', 'user_id']);
|
||||
});
|
||||
|
||||
Schema::create('abschnitte', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('mandant_id')->constrained('mandanten')->restrictOnDelete();
|
||||
$table->char('land', 2);
|
||||
$table->foreignId('projekt_id')->constrained('projekte')->restrictOnDelete();
|
||||
$table->string('bezeichnung', 100);
|
||||
$table->unsignedSmallInteger('sortierung')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['projekt_id', 'bezeichnung']);
|
||||
});
|
||||
|
||||
Schema::create('vertraege', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('mandant_id')->constrained('mandanten')->restrictOnDelete();
|
||||
$table->char('land', 2);
|
||||
$table->foreignId('projekt_id')->constrained('projekte')->restrictOnDelete();
|
||||
$table->foreignId('abschnitt_id')->constrained('abschnitte')->restrictOnDelete();
|
||||
$table->foreignId('auftragnehmer_id')->constrained('auftragnehmer')->restrictOnDelete();
|
||||
$table->string('bezeichnung', 150);
|
||||
$table->string('vertragsnummer', 100)->nullable();
|
||||
$table->date('vertrag_vom')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('leistungsverzeichnisse', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('mandant_id')->constrained('mandanten')->restrictOnDelete();
|
||||
$table->char('land', 2);
|
||||
$table->foreignId('projekt_id')->constrained('projekte')->restrictOnDelete();
|
||||
$table->foreignId('vertrag_id')->constrained('vertraege')->restrictOnDelete();
|
||||
$table->string('bezeichnung');
|
||||
$table->string('import_status', 20)->default('wartet');
|
||||
$table->text('import_fehler')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('nachtraege', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('mandant_id')->constrained('mandanten')->restrictOnDelete();
|
||||
$table->char('land', 2);
|
||||
$table->foreignId('projekt_id')->constrained('projekte')->restrictOnDelete();
|
||||
$table->foreignId('vertrag_id')->constrained('vertraege')->restrictOnDelete();
|
||||
$table->string('nummer', 50);
|
||||
$table->date('eingang_am');
|
||||
$table->string('betreff');
|
||||
$table->json('mka_bezug')->nullable();
|
||||
$table->string('status', 20)->default('eingegangen');
|
||||
$table->foreignId('zugewiesen_an')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['vertrag_id', 'nummer']);
|
||||
$table->index(['projekt_id', 'status']);
|
||||
});
|
||||
|
||||
Schema::create('nachtragspositionen', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('mandant_id')->constrained('mandanten')->restrictOnDelete();
|
||||
$table->char('land', 2);
|
||||
$table->foreignId('projekt_id')->constrained('projekte')->restrictOnDelete();
|
||||
$table->foreignId('nachtrag_id')->constrained('nachtraege')->cascadeOnDelete();
|
||||
$table->string('oz', 50);
|
||||
$table->string('kurztext', 500);
|
||||
$table->text('langtext')->nullable();
|
||||
$table->decimal('menge', 15, 3)->nullable();
|
||||
$table->string('einheit', 20)->nullable();
|
||||
$table->decimal('einheitspreis', 15, 2)->nullable();
|
||||
$table->unsignedInteger('sortierung')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['nachtrag_id', 'oz']);
|
||||
});
|
||||
|
||||
Schema::create('dokumente', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('mandant_id')->constrained('mandanten')->restrictOnDelete();
|
||||
$table->char('land', 2);
|
||||
$table->foreignId('projekt_id')->nullable()->constrained('projekte')->restrictOnDelete();
|
||||
$table->nullableMorphs('dokumentable');
|
||||
$table->string('kategorie', 40);
|
||||
$table->string('dateiname');
|
||||
$table->string('pfad', 500);
|
||||
$table->string('mime_type', 150);
|
||||
$table->unsignedBigInteger('groesse');
|
||||
$table->char('sha256', 64);
|
||||
$table->boolean('vertraulich')->default(false);
|
||||
$table->foreignId('hochgeladen_von')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['projekt_id', 'kategorie']);
|
||||
$table->index('sha256');
|
||||
});
|
||||
|
||||
Schema::create('dokument_freigaben', function (Blueprint $table) {
|
||||
$table->foreignId('dokument_id')->constrained('dokumente')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
|
||||
$table->timestamps();
|
||||
|
||||
$table->primary(['dokument_id', 'user_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('dokument_freigaben');
|
||||
Schema::dropIfExists('dokumente');
|
||||
Schema::dropIfExists('nachtragspositionen');
|
||||
Schema::dropIfExists('nachtraege');
|
||||
Schema::dropIfExists('leistungsverzeichnisse');
|
||||
Schema::dropIfExists('vertraege');
|
||||
Schema::dropIfExists('abschnitte');
|
||||
Schema::dropIfExists('projekt_mitglieder');
|
||||
Schema::dropIfExists('projekte');
|
||||
Schema::dropIfExists('auftragnehmer');
|
||||
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('mandant_id');
|
||||
});
|
||||
|
||||
Schema::dropIfExists('mandanten');
|
||||
}
|
||||
};
|
||||
@@ -21,5 +21,9 @@ class DatabaseSeeder extends Seeder
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
]);
|
||||
|
||||
if (app()->isLocal()) {
|
||||
$this->call(DemoSeeder::class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Enums\Land;
|
||||
use App\Enums\NachtragStatus;
|
||||
use App\Enums\Projektrolle;
|
||||
use App\Enums\VerarbeitungStatus;
|
||||
use App\Models\Abschnitt;
|
||||
use App\Models\Auftragnehmer;
|
||||
use App\Models\Mandant;
|
||||
use App\Models\Nachtrag;
|
||||
use App\Models\Projekt;
|
||||
use App\Models\User;
|
||||
use App\Models\Vertrag;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
/**
|
||||
* Erfundene Beispieldaten für Entwicklung und Vorführung (dieselben wie in der
|
||||
* Rückmeldung an Claude Design). Keine echten Kundendaten.
|
||||
*/
|
||||
class DemoSeeder extends Seeder
|
||||
{
|
||||
public const PROJEKT = 'Elektrifizierung Musterbahn';
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
if (Projekt::query()->where('name', self::PROJEKT)->exists()) {
|
||||
$this->command->info('Demodaten sind schon vorhanden.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$mandant = Mandant::query()->firstOrCreate(['name' => 'Demo-Mandant']);
|
||||
|
||||
$projekt = Projekt::query()->create([
|
||||
'mandant_id' => $mandant->id,
|
||||
'land' => Land::DE,
|
||||
'name' => self::PROJEKT,
|
||||
'nummer' => 'P-2025-01',
|
||||
'auftraggeber' => 'DB InfraGO AG',
|
||||
]);
|
||||
|
||||
$an = fn (string $name) => Auftragnehmer::query()->firstOrCreate(
|
||||
['mandant_id' => $mandant->id, 'land' => Land::DE, 'name' => $name],
|
||||
);
|
||||
$arge = $an('ARGE Musterbau');
|
||||
$tunnel = $an('Tunnelbau Beispiel GmbH');
|
||||
$oberleitung = $an('Oberleitung Nord GmbH');
|
||||
|
||||
$abschnitte = [];
|
||||
foreach ([1, 2, 3, 4] as $nr) {
|
||||
$abschnitte[$nr] = Abschnitt::query()->create([
|
||||
'projekt_id' => $projekt->id,
|
||||
'bezeichnung' => 'PFA '.$nr,
|
||||
'sortierung' => $nr,
|
||||
]);
|
||||
}
|
||||
|
||||
$vertrag = fn (Abschnitt $abschnitt, Auftragnehmer $auftragnehmer, string $bezeichnung) => Vertrag::query()->create([
|
||||
'abschnitt_id' => $abschnitt->id,
|
||||
'auftragnehmer_id' => $auftragnehmer->id,
|
||||
'bezeichnung' => $bezeichnung,
|
||||
'vertrag_vom' => '2025-03-01',
|
||||
]);
|
||||
|
||||
$vertrag($abschnitte[1], $oberleitung, 'Oberleitung');
|
||||
$vertrag($abschnitte[2], $oberleitung, 'Oberleitung');
|
||||
$gleisbauPfa3 = $vertrag($abschnitte[3], $arge, 'Gleisbau');
|
||||
$vertrag($abschnitte[3], $tunnel, 'Tunnelbau');
|
||||
$vertrag($abschnitte[3], $oberleitung, 'Oberleitung');
|
||||
$gleisbauPfa4 = $vertrag($abschnitte[4], $arge, 'Gleisbau');
|
||||
$vertrag($abschnitte[4], $tunnel, 'Tunnelbau');
|
||||
$vertrag($abschnitte[4], $oberleitung, 'Oberleitung');
|
||||
|
||||
foreach (['LV 01 Baustelleneinrichtung', 'LV 03 Oberbau', 'LV 05 Entwässerung', 'LV 07 Kabeltiefbau'] as $bezeichnung) {
|
||||
$gleisbauPfa4->leistungsverzeichnisse()->create(['bezeichnung' => $bezeichnung, 'import_status' => VerarbeitungStatus::Wartet]);
|
||||
$gleisbauPfa3->leistungsverzeichnisse()->create(['bezeichnung' => $bezeichnung, 'import_status' => VerarbeitungStatus::Wartet]);
|
||||
}
|
||||
|
||||
$this->nachtrag($gleisbauPfa4, 'N14', 'Lieferung besohlter Schwellen', '2026-09-29', ['MKA 112'], [
|
||||
['N14.0010', 'Schwelle B70 mit Besohlung liefern', 420, 'St', 137.50],
|
||||
['N14.0020', 'Zulage Verlegen besohlter Schwellen', 420, 'St', 12.40],
|
||||
]);
|
||||
$this->nachtrag($gleisbauPfa4, 'N16', 'Kamerabefahrung und Spülen der Entwässerungsleitungen', '2026-09-15', ['MKA 98'], [
|
||||
['N16.0010', 'Kamerabefahrung Leitungen DN 160', 850, 'm', 3.20],
|
||||
['N16.0020', 'Leitungen DN 160 spülen', 850, 'm', 2.10],
|
||||
]);
|
||||
$this->nachtrag($gleisbauPfa4, 'N21', 'Kabelschutzrohr DN 110 verlegen', '2026-10-01', ['MKA 131', 'MKA 133'], [
|
||||
['N21.0010', 'Kabelschutzrohr DN 110 verlegen', 1200, 'm', 36.80],
|
||||
]);
|
||||
|
||||
$testbenutzer = User::query()->where('email', 'test@example.com')->first();
|
||||
if ($testbenutzer !== null) {
|
||||
$testbenutzer->mandant()->associate($mandant)->save();
|
||||
$projekt->mitglieder()->attach($testbenutzer, ['rolle' => Projektrolle::Projektleiter->value]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $mka
|
||||
* @param list<array{0: string, 1: string, 2: int|float, 3: string, 4: float}> $positionen
|
||||
*/
|
||||
private function nachtrag(Vertrag $vertrag, string $nummer, string $betreff, string $eingang, array $mka, array $positionen): Nachtrag
|
||||
{
|
||||
$nachtrag = $vertrag->nachtraege()->create([
|
||||
'nummer' => $nummer,
|
||||
'betreff' => $betreff,
|
||||
'eingang_am' => $eingang,
|
||||
'mka_bezug' => $mka,
|
||||
'status' => NachtragStatus::Eingegangen,
|
||||
]);
|
||||
|
||||
foreach ($positionen as $i => [$oz, $kurztext, $menge, $einheit, $ep]) {
|
||||
$nachtrag->positionen()->create([
|
||||
'oz' => $oz,
|
||||
'kurztext' => $kurztext,
|
||||
'menge' => $menge,
|
||||
'einheit' => $einheit,
|
||||
'einheitspreis' => $ep,
|
||||
'sortierung' => $i,
|
||||
]);
|
||||
}
|
||||
|
||||
return $nachtrag;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user