{{-- 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
$ledgerNameWithCode = in_array($voucherInfo->debitAcc, $ledgerIdArr) ? $ledgersInfo[$voucherInfo->creditAcc] : $ledgersInfo[$voucherInfo->debitAcc];
@endphp
{{-- if both 'debitAcc' and 'creditAcc' are in '$ledgerIdArr' then we need to print twice --}}
@if (in_array($voucherInfo->debitAcc, $ledgerIdArr) &&
in_array($voucherInfo->creditAcc, $ledgerIdArr) &&
$voucherInfo->voucherCode != 'Opening Transaction')
@for ($i = 0; $i < 2; $i++)
@php
// let '$i = 0' for debit
if ($i == 0) {
$ledgerNameWithCode = $ledgersInfo[$voucherInfo->creditAcc];
$debitAmount = $voucherInfo->amount;
$creditAmount = 0;
$totalDebit += $voucherInfo->amount;
$balanceAmount += $voucherInfo->amount;
} else {
$ledgerNameWithCode = $ledgersInfo[$voucherInfo->debitAcc];
$debitAmount = 0;
$creditAmount = $voucherInfo->amount;
$totalCredit += $voucherInfo->amount;
$balanceAmount -= $voucherInfo->amount;
}
$balanceType = $balanceAmount < 0 ? 'Cr' : 'Dr';
@endphp
| {{ $sl++ }} |
{{ Carbon\Carbon::parse($voucherInfo->voucherDate)->format('d-m-Y') }} |
{{ $voucherInfo->voucherCode }} |
{{ $ledgerNameWithCode }} |
{{ $voucherInfo->globalNarration }} |
{{ number_format($debitAmount, 2) }} |
{{ number_format($creditAmount, 2) }} |
{{ number_format(abs($balanceAmount), 2) }} |
{{ $balanceType }} |
@endfor
@else
@php
if ($voucherInfo->voucherCode == 'Opening Transaction') {
// $balanceAmount = $voucherInfo->amount;
$debitAmount = 0;
$creditAmount = 0;
} else {
// debit and credit amount
if (in_array($voucherInfo->debitAcc, $ledgerIdArr) && $voucherInfo->debitAcc != $voucherInfo->creditAcc) {
$debitAmount = $voucherInfo->amount;
$creditAmount = 0;
$totalDebit += $voucherInfo->amount;
$balanceAmount += $voucherInfo->amount;
}
if (in_array($voucherInfo->creditAcc, $ledgerIdArr) && $voucherInfo->debitAcc != $voucherInfo->creditAcc) {
$debitAmount = 0;
$creditAmount = $voucherInfo->amount;
$totalCredit += $voucherInfo->amount;
$balanceAmount -= $voucherInfo->amount;
}
if ($voucherInfo->debitAcc == $voucherInfo->creditAcc) {
$debitAmount = $voucherInfo->amount;
$creditAmount = $voucherInfo->amount;
$totalDebit += $voucherInfo->amount;
$totalCredit += $voucherInfo->amount;
}
}
if ($debitAmount == 0 && $creditAmount == 0) {
continue;
}
// balance type(dr/cr)
$balanceType = $balanceAmount == 0 ? '' : ($balanceAmount < 0 ? 'Cr' : 'Dr');
@endphp
| {{ $sl++ }} |
{{ Carbon\Carbon::parse($voucherInfo->voucherDate)->format('d-m-Y') }} |
{{ $voucherInfo->voucherCode }} |
{{ $ledgerNameWithCode }} |
{{ $voucherInfo->globalNarration }} |
{{ number_format($debitAmount, 2) }} |
{{ number_format($creditAmount, 2) }} |
{{ number_format(abs($balanceAmount), 2) }} |
{{ $balanceType }} |
@endif
@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
|