|
|
@@ -8,6 +8,7 @@
|
|
|
use App\Models\InhabitantClassification;
|
|
|
use App\Models\Tbr;
|
|
|
use App\Models\TbrCalculation;
|
|
|
+use App\Models\UnitFinancial;
|
|
|
use Carbon\Carbon;
|
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
@@ -251,6 +252,23 @@ private function buildPreview(FranchiseeContract $contract, int $referenceYear,
|
|
|
$fnmBracketValue,
|
|
|
);
|
|
|
|
|
|
+ // Respeita os flags de cobrança da unidade: se desativado, zera o respectivo
|
|
|
+ // componente e ele não entra no total. Sem registro financeiro => cobra (padrão).
|
|
|
+ $financial = UnitFinancial::where('unit_id', $contract->unit_id)->first();
|
|
|
+ $chargeRoi = $financial ? (bool) $financial->charge_roi : true;
|
|
|
+ $chargeFnm = $financial ? (bool) $financial->charge_fnm : true;
|
|
|
+
|
|
|
+ if (!$chargeRoi) {
|
|
|
+ $royaltiesEffectiveValue = 0.0;
|
|
|
+ $royaltiesEffectivePercentage = 0.0;
|
|
|
+ $royaltiesAppliedCriteria = 'nao_cobrado';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!$chargeFnm) {
|
|
|
+ $fnmEffectiveValue = 0.0;
|
|
|
+ $fnmEffectivePercentage = 0.0;
|
|
|
+ }
|
|
|
+
|
|
|
$maintenanceEffectiveValue = $maintenanceBracketValue;
|
|
|
$maintenanceEffectivePercentage = $maintenancePercentage;
|
|
|
|