@extends('layouts.app') @section('title', 'Location-wise Profit & Loss') @section('content')

Location-wise Profit & Loss Compare Performance Across Locations

@component('components.widget', ['class' => 'box-primary'])
{!! Form::label('start_date', __('accounting-reports::lang.start_date') . ':') !!} {!! Form::text('start_date', @format_date($startDate ?? now()->startOfMonth()), ['class' => 'form-control date-picker', 'readonly', 'id' => 'start_date']) !!}
{!! Form::label('end_date', __('accounting-reports::lang.end_date') . ':') !!} {!! Form::text('end_date', @format_date($endDate ?? now()->endOfMonth()), ['class' => 'form-control date-picker', 'readonly', 'id' => 'end_date']) !!}

@endcomponent

Location Performance Comparison

@forelse($locationPL ?? [] as $item) @php $pl = $item['pl_data']['summary'] ?? []; $revenue = $pl['total_revenue'] ?? 0; $cogs = $pl['total_cogs'] ?? 0; $grossProfit = $pl['gross_profit'] ?? 0; $expenses = $pl['total_indirect_expenses'] ?? 0; $netProfit = $pl['net_profit'] ?? 0; $grossMargin = $revenue > 0 ? ($grossProfit / $revenue * 100) : 0; $netMargin = $revenue > 0 ? ($netProfit / $revenue * 100) : 0; @endphp @empty @endforelse @if(isset($locationPL) && count($locationPL) > 0) @php $totalRevenue = array_sum(array_column(array_column($locationPL, 'pl_data'), 'summary')); $totalRevenue = collect($locationPL)->sum(function($item) { return $item['pl_data']['summary']['total_revenue'] ?? 0; }); $totalCOGS = collect($locationPL)->sum(function($item) { return $item['pl_data']['summary']['total_cogs'] ?? 0; }); $totalGrossProfit = collect($locationPL)->sum(function($item) { return $item['pl_data']['summary']['gross_profit'] ?? 0; }); $totalExpenses = collect($locationPL)->sum(function($item) { return $item['pl_data']['summary']['total_indirect_expenses'] ?? 0; }); $totalNetProfit = collect($locationPL)->sum(function($item) { return $item['pl_data']['summary']['net_profit'] ?? 0; }); $totalGrossMargin = $totalRevenue > 0 ? ($totalGrossProfit / $totalRevenue * 100) : 0; $totalNetMargin = $totalRevenue > 0 ? ($totalNetProfit / $totalRevenue * 100) : 0; @endphp @endif
Location Revenue COGS Gross Profit Gross Margin % Expenses Net Profit Net Margin % Action
{{ $item['location']->name ?? 'N/A' }} @format_currency($revenue) @format_currency($cogs) @format_currency($grossProfit) {{ number_format($grossMargin, 2) }}% @format_currency($expenses) @format_currency($netProfit) {{ number_format($netMargin, 2) }}% View Details
No location data available for the selected period.
Total @format_currency($totalRevenue) @format_currency($totalCOGS) @format_currency($totalGrossProfit) {{ number_format($totalGrossMargin, 2) }}% @format_currency($totalExpenses) @format_currency($totalNetProfit) {{ number_format($totalNetMargin, 2) }}%
@endsection @section('javascript') @endsection