@extends('dashboard.layouts.app') @section('content')
Period Comparison (Two Columns)
Period B (Left)
Period A (Right)
@if (($fromA && $toA) || ($fromB && $toB)) @php $incomeA = collect($dailyA ?? [])->sum('income'); $expenseA = collect($dailyA ?? [])->sum('expense'); $totalA = $incomeA - $expenseA; $incomeB = collect($dailyB ?? [])->sum('income'); $expenseB = collect($dailyB ?? [])->sum('expense'); $totalB = $incomeB - $expenseB; $difference = $totalA - $totalB; $percentage = $totalB != 0 ? ($difference / $totalB) * 100 : ($difference == 0 ? 0 : ($difference > 0 ? 999999 : -999999)); @endphp
Comparison Summary
@if($difference > 0)

Period A is {{ number_format($difference, 2) }} EGP higher than Period B.

@elseif($difference < 0)

Period A is {{ number_format(abs($difference), 2) }} EGP lower than Period B.

@else

Both periods have the same net profit/loss.

@endif

Percentage Change: {{ $percentage >= 0 ? '+' : '' }}{{ number_format($percentage, 2) }}%

@endif
@include('dashboard.profit_loss.period-column', [ 'period' => 'B', 'title' => 'Period B (Left)', 'daily' => $dailyB ?? [], 'from' => $fromB, 'to' => $toB, 'chartId' => 'chartB', 'borderColor' => 'border-primary-subtle' ])
@include('dashboard.profit_loss.period-column', [ 'period' => 'A', 'title' => 'Period A (Right)', 'daily' => $dailyA ?? [], 'from' => $fromA, 'to' => $toA, 'chartId' => 'chartA', 'borderColor' => 'border-success-subtle' ])
@endsection @push('scripts') @endpush