@php function formatNumber($number) { // Check if the number has a decimal part if (floor($number) == $number) { // If it's a whole number, format without decimals return number_format($number, 0); } else { // If it has a decimal part, format with 2 decimal places return number_format($number, 2); } } @endphp

Trial Balance

Date: {{ \Carbon\Carbon::now()->format('d-m-Y') }}

@if ($trialBalanceData->isEmpty())

No trial balance data available for the selected period.

@else @php $currentAccountType = ''; $totalDebit = 0; $totalCredit = 0; @endphp @foreach ($trialBalanceData as $data) @if ($data->account_sub_type !== $currentAccountType) @php $currentAccountType = $data->account_sub_type; @endphp @endif @php $totalDebit += $data->debit; $totalCredit += $data->credit; @endphp @endforeach
Account Debit Credit
{{ $currentAccountType }}
{{ $data->account }} {{ formatNumber($data->debit, 2) }} {{ formatNumber($data->credit, 2) }}
Total {{ formatNumber($totalDebit, 2) }} {{ formatNumber($totalCredit, 2) }}
@endif