@extends('layouts.app') @section('content')
{{ isset($sale) ? 'Edit Sale Invoice ' . $sale->invoice_no : 'New Sale (Batch-Wise)' }}
List Sales
@if (session('error'))
{{ session('error') }}
@endif
@csrf @if (isset($sale)) @method('PUT') @endif {{-- Invoice Header Information (Salesman Selection) --}}
Invoice Date: {{ isset($sale) ? $sale->created_at->format('d M, Y') : date('d M, Y') }}
{{-- Desktop Headers --}}
Products
Cartons / Boxes / Pieces
Unit Price
Total Price
Commission (Tk)
Free Item
Action
{{-- Saved invoice rows or the blank create row --}} @foreach (isset($sale) ? $sale->details : [null] as $detail) @php $medicine = $detail?->medicine; $perBox = max(1, (int) ($medicine?->pieces_per_box ?? 1)); $perCarton = $perBox * max(1, (int) ($medicine?->boxes_per_carton ?? 1)); $usesBoxes = ($medicine?->package_type ?: 'carton_box_pcs') === 'carton_box_pcs'; $savedQty = (float) ($detail?->quantity ?? 0); $isKg = ($medicine?->unit ?: 'pcs') === 'kg'; $cartonSize = $usesBoxes ? $perCarton : $perBox; $cartons = !$isKg ? (int) floor($savedQty / $cartonSize) : 0; $leftPieces = !$isKg ? (int) $savedQty % $cartonSize : 0; $boxes = (!$isKg && $usesBoxes) ? (int) floor($leftPieces / $perBox) : 0; $pieces = (!$isKg && $usesBoxes) ? $leftPieces % $perBox : $leftPieces; @endphp
{{-- Product Selection --}}
@if (isset($sale) && $detail)@endif
{{-- Quantity --}}
{{-- Fixed Unit Price (Readonly) --}}
{{-- Row Total Price --}}
{{-- Flat commission amount for this sale row --}}
{{-- Free Item Quantity --}}
Non-billed
{{-- Action Button --}}
@endforeach
Grand Total (after commission):

৳0.00

{{-- Scripts --}} @endsection