{{-- opening balance row --}}
|
|
|
Opening Balance |
|
{{ number_format(0, 2, '.', ',') }} |
{{ number_format(0, 2, '.', ',') }} |
{{ number_format(abs($openingBalance), 2, '.', ',') }} |
@if ($openingBalance == 0)
{{ '' }}
@elseif($openingBalance < 0)
{{ 'Cr' }}
@else
{{ 'Dr' }}
@endif
|
@php
$sl = 1;
$totalDebit = 0;
$totalCredit = 0;
$balanceAmount = $openingBalance;
@endphp
@foreach ($voucherInfos as $voucherInfo)
@php
// if it is opening balance as transaction
if ($voucherInfo->voucherCode == 'Opening Transaction') {
$ledgerNameWithCode = $ledgersInfo[$voucherInfo->debitAcc];
$balanceAmount = $voucherInfo->amount;
$debitAmount = 0;
$creditAmount = 0;
} else {
// account head
if (!in_array($voucherInfo->debitAcc,$ledgerId)) {
$ledgerNameWithCode = $ledgersInfo[$voucherInfo->debitAcc];
} elseif (!in_array($voucherInfo->creditAcc,$ledgerId)) {
$ledgerNameWithCode = $ledgersInfo[$voucherInfo->creditAcc];
} elseif ($voucherInfo->debitAcc == $voucherInfo->creditAcc) {
$ledgerNameWithCode = $ledgersInfo[$voucherInfo->debitAcc];
}
// debit and credit amount
if (in_array($voucherInfo->debitAcc,$ledgerId) && $voucherInfo->debitAcc != $voucherInfo->creditAcc) {
$debitAmount = $voucherInfo->amount;
$creditAmount = 0;
$totalDebit += $voucherInfo->amount;
$balanceAmount += $voucherInfo->amount;
} elseif (in_array($voucherInfo->creditAcc,$ledgerId) && $voucherInfo->debitAcc != $voucherInfo->creditAcc) {
$debitAmount = 0;
$creditAmount = $voucherInfo->amount;
$totalCredit += $voucherInfo->amount;
$balanceAmount -= $voucherInfo->amount;
} elseif ($voucherInfo->debitAcc == $voucherInfo->creditAcc) {
$debitAmount = $voucherInfo->amount;
$creditAmount = $voucherInfo->amount;
$totalDebit += $voucherInfo->amount;
$totalCredit += $voucherInfo->amount;
}
}
// balance type(dr/cr)
$balanceType = $balanceAmount < 0 ? 'Cr' : 'Dr';
@endphp
| {{ $sl++ }} |
{{ Carbon\Carbon::parse($voucherInfo->voucherDate)->format('d-m-Y') }} |
{{ $voucherInfo->voucherCode }} |
{{ $ledgerNameWithCode }} |
{{ $voucherInfo->globalNarration }} |
{{ number_format($debitAmount ?? 0, 2) }} |
{{ number_format($creditAmount ?? 0, 2) }} |
{{ number_format(abs($balanceAmount), 2) }} |
{{ $balanceType }} |
@endforeach
{{-- sub-total --}}
| Sub Total |
{{ number_format($totalDebit, 2, '.', ',') }} |
{{ number_format($totalCredit, 2, '.', ',') }} |
{{ number_format(abs($balanceAmount), 2, '.', ',') }} |
@if ($balanceAmount < 0)
{{ 'Cr' }}
@else
{{ 'Dr' }}
@endif
|
{{-- total --}}
| Total |
{{ number_format($totalDebit, 2, '.', ',') }} |
{{ number_format($totalCredit, 2, '.', ',') }} |
{{ number_format(abs($balanceAmount), 2, '.', ',') }} |
@if ($balanceAmount < 0)
{{ 'Cr' }}
@else
{{ 'Dr' }}
@endif
|