{{-- resources/views/purchase/bills/edit.blade.php --}} @extends('master.app') @section('title', 'Edit Supplier Invoice') @section('body')
Edit Purchase Invoice
One-page invoice (Add to List + Update)
@include('general.valert')
@csrf @method('PUT') {{-- Invoice Header --}}
Invoice Info
Header
@if(isset($bdate) && $bdate == 1) @else
@endif
Upload only if you want to replace old file
{{-- Add Items --}}
Add Items
Select type then add items
Items
{{-- RAW --}} {{-- FIN --}}
{{-- Items List --}}
Items List
List
# Item Unit Qty Price Total Action
No items added yet.
{{-- Hidden inputs for items --}}
{{-- Checkout --}}
Checkout
Update
Back
@endsection @section('pageJs') @php // ✅ FIX: build PHP array first, then json it (prevents "Unclosed '[' ... does not match ')'") $preloadItems = (((int)$bill->type_id === 1) || is_null($bill->type_id)) ? $bill_items->map(function($it){ return [ 'label' => 'Cat #'.$it->cat_id, 'subLabel' => $it->scat_id ? ('SCAT #'.$it->scat_id) : '', 'unitLabel' => 'Unit #'.$it->unit_id, 'qty' => (float) $it->qty, 'price' => (float) $it->cpi, 'total' => (float) $it->total, 'payload' => [ 'mode' => 'raw', 'cat_id' => $it->cat_id, 'scat_id' => $it->scat_id ?? '', 'unit_id' => $it->unit_id, 'cpi' => (float) $it->cpi, 'spi' => (float) $it->spi, 'qty' => (float) $it->qty, ], ]; })->values() : $bill_items->map(function($it){ return [ 'label' => 'Cat #'.$it->cat_id.' - Sub #'.$it->sub_cat_id, 'subLabel' => 'Weight #'.$it->weight_id.' | Location #'.$it->location_id, 'unitLabel' => 'Unit #'.$it->unit_id, 'qty' => (float) $it->qty, 'price' => (float) $it->price, 'total' => (float) $it->total, 'payload' => [ 'mode' => 'fin', 'cat_id' => $it->cat_id, 'sub_cat_id' => $it->sub_cat_id, 'unit_id' => $it->unit_id, 'weight_id' => $it->weight_id, 'location_id' => $it->location_id, 'price' => (float) $it->price, 'qty' => (float) $it->qty, 'spi' => (float) ($it->spi ?? 0), ], ]; })->values(); @endphp @endsection