Implementa regras de investimento por empresa com dupla aprovacao

This commit is contained in:
2026-10-28 16:57:45 +02:00
parent 153ba2c1af
commit 95dd2cc1ed
37 changed files with 1418 additions and 28 deletions
@@ -0,0 +1,47 @@
<?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::create('investment_policies', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained()->restrictOnDelete();
$table->foreignId('created_by')->constrained('users')->restrictOnDelete();
$table->unsignedInteger('revision');
$table->string('status')->default('pending');
$table->string('mode');
$table->string('scope');
$table->string('currency', 3);
$table->bigInteger('ceiling_minor');
$table->boolean('includes_tax');
$table->date('valid_from');
$table->date('valid_until');
$table->text('reason');
$table->timestamp('decided_at')->nullable();
$table->timestamps();
$table->unique(['tenant_id', 'revision']);
});
Schema::create('investment_policy_reviews', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained()->restrictOnDelete();
$table->foreignId('investment_policy_id')->constrained()->restrictOnDelete();
$table->foreignId('reviewed_by')->constrained('users')->restrictOnDelete();
$table->string('decision');
$table->text('reason');
$table->timestamp('created_at');
$table->unique(['investment_policy_id', 'reviewed_by']);
});
Schema::table('budgets', fn (Blueprint $table) => $table->string('kind')->default('operating'));
Schema::table('purchase_awards', fn (Blueprint $table) => $table->json('investment_snapshot')->nullable());
}
public function down(): void
{
throw new LogicException('Preservar regras e decisões de investimento.');
}
};