@if (isset($groupedDates))
@forelse($groupedDates as $key => $data)
@php
$userBranchId = auth()->user()->branch_id;
$filterBranchId = session('branch_filter_id', null);
if ($userBranchId == 1) {
if ($filterBranchId) {
$sale_amount = App\Models\Invoice::where(
'branch_id',
$filterBranchId,
)
->whereMonth('date', '=', date('m', strtotime($key)))
->whereYear('date', '=', date('Y', strtotime($key)))
->sum('total_amount');
$purchase_amount = App\Models\InvoiceItem::where(
'branch_id',
$filterBranchId,
)
->whereMonth('date', '=', date('m', strtotime($key)))
->whereYear('date', '=', date('Y', strtotime($key)))
->sum('pur_subtotal');
$expense = App\Models\Expense::where('branch_id', $filterBranchId)
->whereMonth('date', '=', date('m', strtotime($key)))
->whereYear('date', '=', date('Y', strtotime($key)))
->sum('amount');
} else {
$sale_amount = App\Models\Invoice::whereMonth(
'date',
'=',
date('m', strtotime($key)),
)
->whereYear('date', '=', date('Y', strtotime($key)))
->sum('total_amount');
$purchase_amount = App\Models\InvoiceItem::whereMonth(
'date',
'=',
date('m', strtotime($key)),
)
->whereYear('date', '=', date('Y', strtotime($key)))
->sum('pur_subtotal');
$expense = App\Models\Expense::whereMonth(
'date',
'=',
date('m', strtotime($key)),
)
->whereYear('date', '=', date('Y', strtotime($key)))
->sum('amount');
}
} else {
$sale_amount = App\Models\Invoice::where(
'branch_id',
$userBranchId,
)
->whereMonth('date', '=', date('m', strtotime($key)))
->whereYear('date', '=', date('Y', strtotime($key)))
->sum('total_amount');
$purchase_amount = App\Models\InvoiceItem::where(
'branch_id',
$userBranchId,
)
->whereMonth('date', '=', date('m', strtotime($key)))
->whereYear('date', '=', date('Y', strtotime($key)))
->sum('pur_subtotal');
$expense = App\Models\Expense::where('branch_id', $userBranchId)
->whereMonth('date', '=', date('m', strtotime($key)))
->whereYear('date', '=', date('Y', strtotime($key)))
->sum('amount');
}
$profit = $sale_amount - $purchase_amount;
$net_profit = (float) ($profit - $expense);
@endphp
| {{ date('F Y', strtotime($key)) }} |
{{ number_format($sale_amount, 2) }}
{{ empty(get_setting('com_currency')) ?: get_setting('com_currency') }}
|
{{ number_format($purchase_amount, 2) }}
{{ empty(get_setting('com_currency')) ?: get_setting('com_currency') }}
|
{{ number_format($profit, 2) }}
{{ empty(get_setting('com_currency')) ?: get_setting('com_currency') }}
|
{{ number_format($expense, 2) }}
{{ empty(get_setting('com_currency')) ?: get_setting('com_currency') }}
|
{{ $net_profit >= 0 ? number_format($net_profit, 2) : '(' . number_format(abs($net_profit), 2) . ')' }}
{{ empty(get_setting('com_currency')) ?: get_setting('com_currency') }}
|
@empty
| No Data Found
|
@endforelse
@else
Please Select Start and End
Month
@endif