@extends('master.app') @section('title', 'Edit Retail Invoice') @section('pageCSS') @endsection @section('body')
{{-- ✅ HERO HEADER --}}

Edit Retail Invoice

Invoice # {{ $bill->invoice_number }} • Date: {{ $bill->invoice_date }}
{{ $bill->customer_name }} {{ $bill->customer_phone }} Back
@include('general.valert') {{-- ✅ TOP SUMMARY --}} @php $cur = $bill->currency->title_en ?? ''; $sum_total = ($bill_items->sum('total') == 0) ? ($bill->grand_total ?? 0) : $bill_items->sum('total'); $discount = $bill->discount ?? 0; $received = $bill->received ?? 0; $balance_calc = max(($sum_total - ($discount + $received)), 0); @endphp
Summary
{{ $bill->type_id == 1 ? 'From Stock' : 'Without Stock' }}
Invoice No
{{ $bill->invoice_number }}
Date
{{ $bill->invoice_date }}
Customer
{{ $bill->customer_name }}
Phone
{{ $bill->customer_phone }}
Received By
{{ $bill->received_by ?? '-' }}

You can edit invoice info, update received amount, and manage items.
Financial Overview
Auto recalculated balance
Total
{{ $cur }} {{ number_format($sum_total, 2) }}
Discount
{{ $cur }} {{ number_format($discount, 2) }}
Received
{{ $cur }} {{ number_format($received, 2) }}
Balance
{{ $cur }} {{ number_format($balance_calc, 2) }}
@if(($bill->currency_id ?? 1) != 1 && !empty($bill->ex_rate))
Exchange Rate: {{ $bill->ex_rate }}
@endif
{{-- ✅ ITEMS + EDIT FORM --}}
Items & Invoice Statement
International style • clean & safe
{{-- KEEP YOUR EXISTING ITEM FORMS + TABLES (WORKING) --}} @if ($bill->type_id == 1)
@include('sale.retail_bills.next-header-form')
@include('sale.retail_bills.next-item-table')
@else
@include('sale.retail_bills.no_stock.next-header-form')
@include('sale.retail_bills.no_stock.next-item-table')
@endif
{{-- ✅ EDIT / UPDATE FORM --}}
Invoice Statement
Update invoice info + received. Balance updates automatically.
@method('put') @csrf
{{-- ✅ fixed: removed duplicate value="" --}}
@if ($bdate == 1) @else
@endif
@php $total_for_input = ($bill_items->sum('total') == 0) ? ($bill->grand_total ?? 0) : $bill_items->sum('total'); @endphp
{{-- best practice: keep readonly so total matches items --}}
{{-- your old page had readonly discount; keeping it --}}
{{-- =========================== ✅ PRINT AREA: A4 INVOICE ============================ --}} {{-- =================================== ✅ PRINT AREA: SMALL THERMAL 80mm ==================================== --}}
@endsection @section('pageJs') {{-- keep your existing scripts for stock loading --}} @if ($bill->type_id == 1) @if ($bsload == 1) @include('sale.retail_bills.script') @else @include('sale.retail_bills.stock_load2.script') @endif @else @include('sale.retail_bills.scriptrow') @endif @endsection