@php
$debitTotal = 0;
$creditTotal = 0;
@endphp
| Particulars |
Debit |
Credit |
@foreach ($groups as $group)
@php
$group->drAmount = 0;
$group->crAmount = 0;
@endphp
@foreach ($group->descendantsAndSelf as $subGroup)
@php
$subGroup->drAmount = 0;
$subGroup->crAmount = 0;
$subLedgers = $subGroup->ledgers->pluck('id');
$exists = $transactions->whereIn('ledger_id', $subLedgers);
if ($exists->count() > 0) {
$drExists = $exists->where('debitAmtTotal', '>', 0);
$crExists = $exists->where('creditAmtTotal', '>', 0);
if ($drExists->count() > 0 || $crExists->count() > 0) {
foreach ($subGroup->ledgers as $subLedger) {
$subLedger->drAmount = 0;
$subLedger->crAmount = 0;
$subDrExists = clone $drExists;
$subDrExists = $drExists->where('ledger_id', $subLedger->id);
$subCrExists = clone $crExists;
$subCrExists = $crExists->where('ledger_id', $subLedger->id);
if ($subDrExists->count() > 0) {
$subLedger->drAmount = $subDrExists->sum('debitAmtTotal');
$subGroup->drAmount += $subLedger->drAmount;
$group->drAmount += $subLedger->drAmount;
$debitTotal += $subDrExists->sum('debitAmtTotal');
}
if ($subCrExists->count() > 0) {
$subLedger->crAmount = $subCrExists->sum('creditAmtTotal');
$subGroup->crAmount += $subLedger->crAmount;
$group->crAmount += $subLedger->crAmount;
$creditTotal += $subCrExists->sum('creditAmtTotal');
}
}
}
}
@endphp
@endforeach
@if ($group->drAmount > 0 || $group->crAmount > 0)
| {{ $group->name }} |
{{ $group->drAmount == 0 ? '' : number_format($group->drAmount, 2) }}
|
{{ $group->crAmount == 0 ? '' : number_format($group->crAmount, 2) }}
|
@foreach ($group->descendantsAndSelf as $subGroup)
@if ($group->id != $subGroup->id)
@if ($subGroup->drAmount > 0 || $subGroup->crAmount > 0)
|
{{ $subGroup->name }} |
{{ $subGroup->drAmount == 0 ? '' : number_format($subGroup->drAmount, 2) }}
|
{{ $subGroup->crAmount == 0 ? '' : number_format($subGroup->crAmount, 2) }}
|
@foreach ($subGroup->ledgers as $subLedger)
@if ($subLedger->drAmount > 0 || $subLedger->crAmount > 0)
|
{{ $subLedger->name }} |
{{ $subLedger->drAmount == 0 ? '' : number_format($subLedger->drAmount, 2) }}
|
{{ $subLedger->crAmount == 0 ? '' : number_format($subLedger->crAmount, 2) }}
|
@endif
@endforeach
@endif
@else
@if ($group->id == $subGroup->id)
@foreach ($subGroup->ledgers as $subLedger)
@if ($subLedger->drAmount > 0 || $subLedger->crAmount > 0)
| {{ $subLedger->name }} |
{{ $subLedger->drAmount == 0 ? '' : number_format($subLedger->drAmount, 2) }}
|
{{ $subLedger->crAmount == 0 ? '' : number_format($subLedger->crAmount, 2) }}
|
@endif
@endforeach
@endif
@endif
@endforeach
@endif
@endforeach
| Total |
{{ number_format($debitTotal, 2) }} |
{{ number_format($creditTotal, 2) }} |