@extends('layouts.master') @section('title', 'Lignes budgétaires') @section('content')
{{-- Informations générales du budget --}}
@php $premiereLigne = $lignes->first(); @endphp
Exercice
{{ optional(optional($premiereLigne)->besoinbudgetaire)->exercice ?? '-' }}
Direction
{{ optional($premiereLigne->direction)->code ?? '-' }} - {{ optional($premiereLigne->direction)->libelle ?? '' }}
Centre de responsabilité
{{ optional($premiereLigne->centrerespo)->code ?? '-' }} - {{ optional($premiereLigne->centrerespo)->libelle_long ?? '' }}
Nombre de lignes
{{ $totalLignes }}
Déjà engagées
{{ $lignesEngagees }}
Restantes
{{ $lignesRestantes }}
Liste des lignes budgétaires
{{-- --}} {{-- --}} {{-- --}} {{-- --}} {{-- --}} {{-- --}} @forelse($lignes as $ligne) @php /* |-------------------------------------------------------------------------- | MONTANT BUDGÉTAIRE |-------------------------------------------------------------------------- */ $montantBudgetaire = (float) ($ligne->montant ?? 0); /* |-------------------------------------------------------------------------- | MONTANT RÉELLEMENT CONSOLIDÉ |-------------------------------------------------------------------------- | | On récupère uniquement les montants réellement consommés | sur cette ligne budgétaire. | */ $montantEngage = \App\Models\Consolidation::where( 'budgetdepense_id', $ligne->id )->sum('montant_ligne'); /* |-------------------------------------------------------------------------- | SOLDE |-------------------------------------------------------------------------- */ $solde = max( 0, $montantBudgetaire - $montantEngage ); /* |-------------------------------------------------------------------------- | DERNIER ENGAGEMENT |-------------------------------------------------------------------------- */ $dernierEngagement = $ligne->engagementdepenses ->sortByDesc('created_at') ->first(); /* |-------------------------------------------------------------------------- | EXISTENCE D'UN BROUILLON |-------------------------------------------------------------------------- */ $brouillon = $ligne->engagementdepenses ->where('status', 'brouillon') ->sortByDesc('created_at') ->first(); /* |-------------------------------------------------------------------------- | LIGNE ÉPUISÉE |-------------------------------------------------------------------------- */ $ligneEpuisee = $solde <= 0; @endphp {{-- ===================================================== N° ====================================================== --}} {{-- ===================================================== CODE BUDGET ====================================================== --}} {{-- ===================================================== NOM BUDGET ====================================================== --}} {{-- ===================================================== ACTIVITÉ ====================================================== --}} {{-- ===================================================== COMPTE SYSCOHADA ====================================================== --}} {{-- ===================================================== MONTANT BUDGÉTAIRE ====================================================== --}} {{-- ===================================================== SOLDE DISPONIBLE ====================================================== --}} {{-- ===================================================== ACTION ====================================================== --}} @empty @endforelse
N°ExerciceCode Budget Nom du BudgetDirectionCentre de responsabilitéPoste de gestionActivité Compte SYSCOHADANature de la dépenseMontant budgetaireMontant engagéSolde disponible Action
{{ $loop->iteration }} {{ optional($ligne->besoinbudgetaire)->code_budget ?? '-' }} {{ optional($ligne->besoinbudgetaire)->nom_budget ?? '-' }} {{ $ligne->activite ?? '-' }} {{ optional($ligne->comptesyscohada)->code ?? '-' }} - {{ optional($ligne->comptesyscohada)->libelle ?? '' }} {{ number_format( $montantBudgetaire, 0, ',', ' ' ) }} FCFA @if($solde > 0) {{ number_format( $solde, 0, ',', ' ' ) }} FCFA @else Épuisée @endif {{-- ================================================= CAS 1 : LIGNE ÉPUISÉE ================================================== --}} @if($ligneEpuisee) Budget épuisé {{-- ================================================= CAS 2 : BROUILLON EXISTANT ================================================== --}} @elseif($brouillon) Brouillon
Continuer {{-- ================================================= CAS 3 : SOLDE DISPONIBLE ================================================== --}} @else {{-- --------------------------------------------- BOUTON NOUVEL ENGAGEMENT ---------------------------------------------- --}} Nouvel engagement {{-- --------------------------------------------- SI UN ANCIEN ENGAGEMENT EXISTE ---------------------------------------------- --}} @if($dernierEngagement)
{{ number_format( $montantEngage, 0, ',', ' ' ) }} FCFA déjà engagé @endif @endif
Aucune ligne budgétaire disponible
@endsection