@extends('includes.main') @section('main-container')

Stock Report

{{-- Supply form --}}
Report Filter
@csrf
@if ($grand_total_profit > 0) {{-- Table form --}}
@if (session()->has('type')) @endif @if ($errors->any()) @endif
Stock Report
@php $adjusted_grand_total_profit = 0; // Initialize adjusted grand total $totalProfit = 0; // Initialize adjusted grand total @endphp @foreach ($product_data as $item) @php // Calculate totalLaters using the loop $totalLaters = 0; foreach ($productTotalLaters as $productLater) { if ($productLater['product_id'] == $item->product_id) { $totalLaters = $productLater['total_laters']; break; } } $totalProfit = $item->total_profit - $item->ogra_profit - $item->extra_profit; // Calculate adjusted profit by deducting 0.40 for each 'later' $adjusted_profit = $totalProfit - ($totalLaters - $item->total_ogra_quantity)* 0.4; $adjusted_grand_total_profit += $adjusted_profit; // Add to grand total $adjusted_grand_total_profit += $item->ogra_profit; // Add to grand total @endphp @endforeach @foreach ($profitAndLossByProduct as $profit) @endforeach @if (is_iterable($extraStock)) @php $totalExtraStock = 0; @endphp @foreach ($extraStock as $extra) @php $subtotal = ($extra->quantity ?? 0) * ($extra->sale_price ?? 0); $totalExtraStock += $subtotal; @endphp @endforeach @else @endif @foreach ($expensesByType as $expense) @endforeach
Products Oogra Total Later Oogra Total Profits Total Later Total Profits
{{ $item->title }} {{ $item->total_ogra_quantity }} {{ $item->ogra_profit }} {{ $totalLaters }} {{ number_format($adjusted_profit, 2) }}
Total {{ number_format($adjusted_grand_total_profit, 2) }}
Products Total Profits and Loss
{{ $profit->title }} {{ $profit->total_profit_loss }}
Total Profit and Loss {{ $grandTotalProfitLoss }}
Products Sale Price Quantity Total
@if ($extra->product_id == 1) Petrol @elseif ($extra->product_id == 2) Diesel @else N/A @endif {{ $extra->sale_price ?? 0 }} {{ $extra->quantity ?? 0 }} {{ $subtotal }}
No extra stock available.
Total Extra Stock {{ $totalExtraStock + $grandTotalProfitLoss + $adjusted_grand_total_profit }}
Expense Type Expense Amount
{{ $expense->expense_type_name }} {{ $expense->total_expense }}
Total Expenses {{ $totalExpenses }}
Net Total {{ $adjusted_grand_total_profit + $grandTotalProfitLoss + $totalExtraStock - $totalExpenses }}
@foreach ($product_quantities as $quantity) @php // Extract previous remaining stock for the current product_id $remainingStockPrevious = 0; foreach ($previousMonthStock as $previousStock) { if ($previousStock->product_id == $quantity->product_id) { $remainingStockPrevious = $previousStock->remaining_stock; break; } } // Calculate total stock including previous remaining stock $totalWithPreviousStock = $quantity->total_quantity + $remainingStockPrevious; // Get total sale later for the current product from productTotalLaters $totalLaters = 0; foreach ($productTotalLaters as $productLater) { if ($productLater['product_id'] == $quantity->product_id) { $totalLaters = $productLater['total_laters']; break; } } // Get extra stock for the current product_id $extraStocks = 0; foreach ($extraStock as $extra) { if ($extra->product_id == $quantity->product_id) { $extraStocks = $extra->total_quantity; // Use 'total_quantity' if you need the sum break; } } // Calculate the remaining stock for the current month, including extra stock $remainingStockCurrent = $totalWithPreviousStock - $totalLaters + $extraStocks; @endphp @endforeach
Products Total Stock Coming Old Stock Total Stock Sale Later Remaining Later
{{ $quantity->title }} {{ $quantity->total_quantity }} {{ $remainingStockPrevious }} {{ $totalWithPreviousStock }} {{ $totalLaters }} {{ $remainingStockCurrent }}
Customer Transaction List
@php $totalCredit = 0; $totalDebit = 0; $totalRemaining = 0; @endphp @foreach ($customerTransactions as $transaction) @php $remaining = $transaction->credit - $transaction->debit; $totalCredit += $transaction->credit; $totalDebit += $transaction->debit; $totalRemaining += $remaining; @endphp @endforeach
Customer Name Credit Debit Detail Remaining
{{ $transaction->customer->name }} {{ $transaction->credit }} {{ $transaction->debit }} {{ $transaction->detail }} {{ $remaining }}
Total {{ $totalCredit }} {{ $totalDebit }} {{ $totalRemaining }}
@endif
@endsection