feat: add sous-devis generation from commandes
From a commande, users can now create one or more sub-quotes (sous-devis) to ventilate purchases across communes for approval. - Add parent_devis_id and commande_id FKs on devis table - Order model: sousDevis() hasMany relation - Devis model: commande() and parent() relations - DevisController: createFromCommande / storeFromCommande methods - OrderController: load and pass sous_devis on show - Commandes/Show: "Créer un sous-devis" button + ventilation panel - Devis/CreateFromCommande: form pre-loaded with commande context - Devis/Index: badge "Sous-devis · CMD-XXXX" on linked quotes - Devis/Show: back-link to originating commande Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
7312c7640b
commit
8d51f4de3e
@@ -0,0 +1,27 @@
|
||||
<?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('devis', function (Blueprint $table) {
|
||||
$table->foreignId('parent_devis_id')
|
||||
->nullable()
|
||||
->after('id')
|
||||
->constrained('devis')
|
||||
->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('devis', function (Blueprint $table) {
|
||||
$table->dropForeignIdFor(\App\Models\Devis::class, 'parent_devis_id');
|
||||
$table->dropColumn('parent_devis_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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('devis', function (Blueprint $table) {
|
||||
$table->foreignId('commande_id')
|
||||
->nullable()
|
||||
->after('parent_devis_id')
|
||||
->constrained('orders')
|
||||
->nullOnDelete();
|
||||
$table->string('commande_number')->nullable()->after('commande_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('devis', function (Blueprint $table) {
|
||||
$table->dropForeignIdFor(\App\Models\Order::class, 'commande_id');
|
||||
$table->dropColumn(['commande_id', 'commande_number']);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user