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

Production Batch: {{ $production->batch_no }}

Print Edit Costs Back
@if(session('success'))
{{ session('success') }}
@endif
{{ $production->batch_no }}
{{ $production->date->format('d-M-Y') }}
{{ $production->machine ?? '-' }}
{{ ucfirst($production->status) }}
@php $totalRawWeight = $production->inputItems->sum('quantity'); $totalFinishWeight = $production->outputItems->sum('quantity'); $totalWastageWeight = $production->wastageItems ? $production->wastageItems->sum('quantity') : 0; $totalFinishAmount = $production->outputItems->sum('amount'); $wastagePercent = $totalRawWeight > 0 ? ($totalWastageWeight / $totalRawWeight) * 100 : 0; // Calculate wastage weight (input - output) $actualWastage = $totalRawWeight - $totalFinishWeight; // Calculate wastage cost (proportional cost of wasted material) $wastageCost = $totalRawWeight > 0 ? ($actualWastage / $totalRawWeight) * $production->raw_material_cost : 0; // Wastage cost per unit of output $wastePerUnit = $totalFinishWeight > 0 ? $wastageCost / $totalFinishWeight : 0; // Wastage percentage of output $wastageOutputPercent = $totalRawWeight > 0 ? (($totalRawWeight - $totalFinishWeight) / $totalRawWeight) * 100 : 0; @endphp

RAW MATERIAL

@foreach($production->inputItems as $item) @php $percentage = $totalRawWeight > 0 ? ($item->quantity / $totalRawWeight) * 100 : 0; @endphp @endforeach {{-- Empty rows to match Excel style --}} @for($i = $production->inputItems->count(); $i < 8; $i++) @endfor @if($totalWastageWeight > 0) @endif
Description Total Weight % Rate Amount
{{ $item->item->name ?? '-' }} {{ number_format($item->quantity, 0) }} {{ number_format($percentage, 2) }} {{ number_format($item->rate, 2) }} {{ number_format($item->amount, 0) }}
  0
Panjee (Wastage) {{ number_format($totalWastageWeight, 0) }} {{ number_format($wastagePercent, 2) }}
TOTAL {{ number_format($totalRawWeight, 0) }} 100.00 {{ number_format($production->raw_material_cost, 0) }}

FINISH MATERIAL

@foreach($production->outputItems as $item) @endforeach {{-- Empty rows to match Excel style --}} @for($i = $production->outputItems->count(); $i < 8; $i++) @endfor
Description Total Weight Rate Amount
{{ $item->item->name ?? '-' }} {{ number_format($item->quantity, 0) }} {{ number_format($item->rate, 2) }} {{ number_format($item->amount, 0) }}
  0
Panjee {{ number_format($totalRawWeight, 0) }}
TOTAL {{ number_format($totalFinishWeight, 0) }} {{ number_format($totalFinishAmount, 0) }}
Raw Material Cost
Rs. {{ number_format($production->raw_material_cost, 0) }}
Total Output Weight
{{ number_format($totalFinishWeight, 0) }} KG
Finish Material Value
Rs. {{ number_format($totalFinishAmount, 0) }}
Avg Cost Per KG
Rs. {{ number_format($production->cost_per_unit, 2) }}
Input Weight
{{ number_format($totalRawWeight, 0) }} KG
Output Weight
{{ number_format($totalFinishWeight, 0) }} KG
=
Wastage Weight
{{ number_format($actualWastage, 0) }} KG
|
Wastage %
{{ number_format($wastageOutputPercent, 2) }}%
|
Wastage Cost
Rs. {{ number_format($wastageCost, 0) }}
|
Waste Per Unit
Rs. {{ number_format($wastePerUnit, 2) }}/KG

Production Costs Breakdown

@if($production->other_expenses_description) @endif
Raw Material Cost: Rs. {{ number_format($production->raw_material_cost, 2) }}
Agent Commission: Rs. {{ number_format($production->agent_commission, 2) }}
Transportation Cost: Rs. {{ number_format($production->transportation_cost, 2) }}
Labor Cost: Rs. {{ number_format($production->labor_cost, 2) }}
Electricity Cost: Rs. {{ number_format($production->electricity_cost, 2) }}
Other Expenses: Rs. {{ number_format($production->other_expenses, 2) }}
{{ $production->other_expenses_description }}
TOTAL COST: Rs. {{ number_format($production->total_cost, 2) }}

Cost Per Unit Calculation

Total Production Cost
Rs. {{ number_format($production->total_cost, 2) }}
÷ Output Quantity
{{ number_format($production->output_quantity, 3) }} KG
COST PER UNIT
Rs. {{ number_format($production->cost_per_unit, 2) }}
per KG
@if($production->narration)
{{ $production->narration }}
@endif
Created by: {{ $production->creator->name ?? 'System' }} | Created: {{ $production->created_at->format('d-M-Y h:i A') }} @if($production->updated_at != $production->created_at) | Updated: {{ $production->updated_at->format('d-M-Y h:i A') }} @endif
@endsection