{{ $formatted_date }} : @lang('lang.date')
@foreach ($expense_payments as $expense_payment) @php $totalCredit = $expense_payment->total_credit_match; $totalDebit = $expense_payment->total_debit_match; $previousBalance = $expense_payment->expenses->previous_balance; // if both greater than 0 if ($totalCredit > 0 && $totalDebit > 0) { $balance = $previousBalance + $totalCredit; $balance = $balance - $totalDebit; } elseif ($totalCredit >= 0 || $totalDebit >= 0) { $balance = $previousBalance + $totalCredit; $balance = $balance - $totalDebit; } @endphp {{-- @dd($balance); --}} @endforeach
S.no @lang('lang.name') @lang('lang.previous_balance') @lang('lang.credit_payment') @lang('lang.debit_payment') @lang('lang.balance')
{{ $loop->iteration }} {{ $expense_payment->expenses->name }} {{ $previousBalance }} {{ $totalCredit }} {{ $totalDebit }} {{ $balance }}