|
@@ -0,0 +1,58 @@
|
|
|
|
|
+<?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('tbr_calculations', function (Blueprint $table) {
|
|
|
|
|
+ $table->id();
|
|
|
|
|
+ $table->foreignId('unit_id')->constrained('units');
|
|
|
|
|
+ $table->decimal('revenue_value', 12, 2);
|
|
|
|
|
+ $table->unsignedInteger('contract_month_reference');
|
|
|
|
|
+ $table->decimal('tbr_value', 10, 2);
|
|
|
|
|
+
|
|
|
|
|
+ $table->foreignId('fnm_bracket_id')->constrained('franchisee_fnm_brackets');
|
|
|
|
|
+ $table->decimal('fnm_bracket_percentage', 5, 4);
|
|
|
|
|
+ $table->decimal('fnm_bracket_value', 10, 2);
|
|
|
|
|
+
|
|
|
|
|
+ $table->foreignId('maintenance_bracket_id')->constrained('franchisee_maintenance_brackets');
|
|
|
|
|
+ $table->decimal('maintenance_bracket_percentage', 5, 4);
|
|
|
|
|
+ $table->decimal('maintenance_bracket_value', 10, 2);
|
|
|
|
|
+
|
|
|
|
|
+ $table->foreignId('royalties_bracket_id')->constrained('franchisee_royalties_brackets');
|
|
|
|
|
+ $table->decimal('royalties_bracket_percentage', 5, 4);
|
|
|
|
|
+ $table->decimal('royalties_bracket_value', 10, 2);
|
|
|
|
|
+
|
|
|
|
|
+ $table->decimal('fnm_effective_percentage', 5, 4);
|
|
|
|
|
+ $table->decimal('fnm_effective_value', 10, 2);
|
|
|
|
|
+
|
|
|
|
|
+ $table->decimal('royalties_effective_percentage', 5, 4);
|
|
|
|
|
+ $table->decimal('royalties_effective_value', 10, 2);
|
|
|
|
|
+
|
|
|
|
|
+ $table->decimal('maintenance_effective_percentage', 5, 4);
|
|
|
|
|
+ $table->decimal('maintenance_effective_value', 10, 2);
|
|
|
|
|
+
|
|
|
|
|
+ $table->decimal('bracket_subtotal', 10, 2);
|
|
|
|
|
+ $table->decimal('subtotal', 10, 2);
|
|
|
|
|
+ $table->decimal('final_value', 10, 2);
|
|
|
|
|
+
|
|
|
|
|
+ $table->foreignId('user_id')->constrained('users');
|
|
|
|
|
+ $table->enum('royalties_applied_criteria', ['tbr_fixo', 'percentual_faturamento']);
|
|
|
|
|
+ $table->boolean('receivable_generated')->default(false);
|
|
|
|
|
+
|
|
|
|
|
+ $table->timestamps();
|
|
|
|
|
+
|
|
|
|
|
+ $table->index('unit_id');
|
|
|
|
|
+ $table->index('user_id');
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function down(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ Schema::dropIfExists('tbr_calculations');
|
|
|
|
|
+ }
|
|
|
|
|
+};
|