Kaynağa Gözat

feat(unit-financial): default ROI/FNM charge flags to true

Column default flips to true and existing rows are backfilled, since the flags were never read by any calculation before.
ebagabee 1 ay önce
ebeveyn
işleme
20bac4a57c

+ 34 - 0
database/migrations/2026_06_18_000004_default_charge_flags_true_on_unit_financials.php

@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    public function up(): void
+    {
+        // Cobrança de ROI/FNM passa a ser ativa por padrão; quem quiser desativar
+        // faz isso na tab Financeiro da unidade.
+        Schema::table('unit_financials', function (Blueprint $table) {
+            $table->boolean('charge_roi')->default(true)->change();
+            $table->boolean('charge_fnm')->default(true)->change();
+        });
+
+        // Os flags nunca foram lidos no cálculo, então os valores atuais são apenas
+        // o default antigo (false). Alinha tudo com "cobrança ligada por padrão".
+        DB::table('unit_financials')->update([
+            'charge_roi' => true,
+            'charge_fnm' => true,
+        ]);
+    }
+
+    public function down(): void
+    {
+        Schema::table('unit_financials', function (Blueprint $table) {
+            $table->boolean('charge_roi')->default(false)->change();
+            $table->boolean('charge_fnm')->default(false)->change();
+        });
+    }
+};