@extends('layouts.main') @section('content')

Cement Stock Movement Report

Filter Report
Reset
@if($purchases->isEmpty() && $production->isEmpty() && $sales->isEmpty())
No data found for the selected filters.
@else
1. Cement Purchases (Bought In)
@foreach($purchases as $purchase) @endforeach
Date Supplier Quantity (Bags) Price per Bag Total Amount
{{ $purchase->created_at->format('d M Y') }} {{ $purchase->supplier->name }} {{ number_format($purchase->total) }} {{ number_format($purchase->bought_price, 2) }} {{ number_format($purchase->bought_price * $purchase->total, 2) }}
Total Purchases {{ number_format($purchases->sum('total')) }} {{ number_format($purchases->sum('bought_price'), 2) }} {{ number_format($purchases->sum(function($item) { return $item->bought_price * $item->total; }), 2) }}
2. Cement Used in Production
@php $totalCement = 0; $totalBricks = 0; @endphp @foreach($production as $prod) @php $stock_bricks = App\Models\StockBrick::where('stock_id', $prod->id)->first(); $bricks_produced = $stock_bricks ? $stock_bricks->total_bricks_without_fault : 0; $status = $stock_bricks && $stock_bricks->expected_output != 0 ? 'Actual Output Not Given' : ''; $totalCement += $prod->total; $totalBricks += $bricks_produced; @endphp @endforeach
Date Cement (Bags) Good Bricks Status
{{ $prod->created_at->format('d M Y') }} {{ number_format($prod->total) }} {{ number_format($bricks_produced) }} {{ $status }}
Total Cement Used: {{ number_format($totalCement) }} bags
Total Good Bricks: {{ number_format($totalBricks) }}
3. Cement Sales ({{ \Carbon\Carbon::parse($startDate)->format('d M Y') }} - {{ \Carbon\Carbon::parse($endDate)->format('d M Y') }})
@php $totalQuantity = 0; $totalAmount = 0; $totalUnitPrice = 0; @endphp @foreach($sales as $sale) @php $unitPrice = str_replace(',', '', $sale->selling_price); $saleAmount = $sale->quantity * $unitPrice; $totalQuantity += $sale->quantity; $totalAmount += $saleAmount; $totalUnitPrice += $unitPrice; @endphp @endforeach
Date Quantity (Bags) Unit Price Total Amount
{{ \Carbon\Carbon::parse($sale->created_at)->format('d M Y') }} {{ number_format($sale->quantity) }} {{ number_format($unitPrice, 2) }} {{ number_format($saleAmount, 2) }}
Total Sales {{ number_format($totalQuantity) }} {{ number_format($totalUnitPrice, 2) }} {{ number_format($totalAmount, 2) }}
4. Current Stock Summary
Stock Movement
Opening Stock (as of {{ $startDate->format('d M Y') }}) {{ number_format($openingStock ?? 0) }} bags
Total Purchased {{ number_format($purchases->sum('total')) }} bags
Total Used in Production {{ number_format($production->sum('total')) }} bags
Total Sold {{ number_format($sales->sum('quantity')) }} bags
Closing Stock (as of {{ $endDate->format('d M Y') }}) {{ number_format($closingStock ?? 0) }} bags
Stock Value
Average Purchase Rate {{ number_format($averageRate ?? 0, 2) }} per bag
Average Sale Rate {{ number_format($averageSaleRate ?? 0, 2) }} per bag
Current Stock Value {{ number_format(($closingStock ?? 0) * ($averageRate ?? 0), 2) }}
@endif
@endsection @section('scripts') @endsection