@if(isset($data['journalEntries']) )

@lang('reports::reports.Journal Report')

{{$data['companyName']}}

@lang('from') {{$data['dates']['from']}} @lang('to') {{$data['dates']['to']}}

@if(isset($data['cost_center_name']))

@lang('reports::reports.cost_center'): {{$data['cost_center_name']}}

@endif
@if($data['journalEntries']->count()) @foreach ($data['journalEntries'] as $journalEntry) @php $recordsCount = $journalEntry['journalRecords']->count() @endphp {{-- this +1 is for the total debit & credit for single journal entry --}} {{-- if supplier is null then it must be customer, so check if the first operand is null it will get the second --}} {{-- THIS IN THE SERVICE ... COST A NESTED LOOP TO JUST GET THE CREDIT AND DEBIT, why not just do it in the view ??? --}} {{-- --}} {{-- @if($recordsCount > 1) --}} @foreach ($journalEntry['journalRecords'] as $journalRecord) @if ($loop->first) @continue @endif {{-- if supplier is null then it must be customer, so check if the first operand is null it will get the second --}} {{-- THIS IN THE SERVICE ... COST A NESTED LOOP TO JUST GET THE CREDIT AND DEBIT, why not just do it in the view ??? --}} {{-- --}} @endforeach {{-- @endif --}} @endforeach @endif
@lang('reports::reports.journal_report.journal_date') @lang('reports::reports.journal_report.transaction_type') @lang('reports::reports.journal_number') @lang('reports::reports.journal_report.journal_description') @lang('reports::reports.account') @lang('reports::reports.reference_name') @lang('reports::reports.debit') @lang('reports::reports.credit')
{{ $journalEntry['journal_date'] }} {{ $journalEntry['transaction_type'] }} {{ $journalEntry['code'] }} {{ $journalEntry['description'] }} {{ (@$journalEntry['journalRecords'][0]->account) ? $journalEntry['journalRecords'][0]->account->name : ''}} @if(@$journalEntry['journalRecords'][0]->supplier) {{$journalEntry['journalRecords'][0]->supplier->name}} @elseif(@$journalEntry['journalRecords'][0]->customer) {{$journalEntry['journalRecords'][0]->customer->name}} @endif {{ $journalEntry['journalRecords'][0]->description}} {{ number_format(@$journalEntry['journalRecords'][0]->debit ?? 0 ,2)}} {{ number_format(@$journalEntry['journalRecords'][0]->credit ?? 0,2)}}
last) rowspan="2" @endif>{{ ($journalRecord->account)?$journalRecord->account->name:''}} last) rowspan="2" @endif> @if($journalRecord->supplier) {{$journalRecord->supplier->name}} @elseif($journalRecord->customer) {{$journalRecord->customer->name}} @endif last) rowspan="2" @endif>{{ $journalRecord->description}} {{ number_format($journalRecord->debit, 2)}} {{ number_format($journalRecord->credit, 2)}}
{{ $journalEntry['totalDebit'] }} {{ $journalEntry['totalCredit'] }}
@lang('reports::reports.journal_report.total') {{ number_format($data['totalDebit'], 2) }} {{ number_format($data['totalCredit'], 2) }}
@endif