Brick Production, Stock, Sales & Profit Report
From {{ $startDate->format('Y-m-d') }} To {{ $endDate->format('Y-m-d') }} Net Profit {{ number_format($profit, 2) }}

@php $excelTotalDiscount = 0; foreach ($salesDetails as $s) { $sub = (float)($s->subtotal_num ?? 0); $final = (float)($s->amount_num ?? 0); $excelTotalDiscount += max(0, $sub - $final); } @endphp
SUMMARY
Total Produced{{ number_format($totalProduced) }}
Total Sold{{ number_format($totalSold) }}
Total In Stock{{ number_format($totalInStock) }}
Total Revenue{{ number_format($totalRevenue, 2) }}
Total Cost{{ number_format($totalCost, 2) }}
Total Discount{{ number_format($excelTotalDiscount, 2) }}

@forelse($productionRows as $r) @empty @endforelse
1) PRODUCTION
Date Brick Type Actual Output
{{ optional($r->created_at)->format('Y-m-d') }} {{ $r->brickType->name ?? 'Unknown' }} {{ (int)($r->actual_out ?? 0) }}
No production records

@foreach($brickTypes as $t) @endforeach
2) CURRENT STOCK
Brick Type In Stock
{{ $t->name }} {{ (int)($currentStockByType[$t->id] ?? 0) }}

@forelse($salesDetails as $s) @php $brickName = $brickTypes->firstWhere('id', $s->brick_type_id)->name ?? 'Unknown'; $qty = (int)($s->sold_qty ?? 0); $unit = (float)($s->unit_price_num ?? 0); $sub = (float)($s->subtotal_num ?? 0); $final = (float)($s->amount_num ?? 0); $disc = max(0, $sub - $final); @endphp @empty @endforelse
3) SALES DETAILS
Date Brick Type Qty Unit Price Subtotal Final Amount Discount
{{ \Carbon\Carbon::parse($s->item_created_at)->format('Y-m-d') }} {{ $brickName }} {{ $qty }} {{ number_format($unit, 2) }} {{ number_format($sub, 2) }} {{ number_format($final, 2) }} {{ number_format($disc, 2) }}
No sales records