@php use App\Models\Inventory; use App\Models\Item; @endphp @extends('layouts.backend.index') @section('title', $label) @section('content')
@csrf @method('PUT')
@if (Auth::user()->entity->is_barang) @else @endif
@if (Auth::user()->entity->is_barang) @else @endif @php $old = old('items', []); $old_items = json_decode($invoice->items, true); $subtotal = 0; $ppn = 0; $pph = 0; $costShipping = str_replace('.', '', old('shipping_cost', $invoice->shipping_cost)); $total = 0; $ppn_percent = old('ppn_percent', $invoice->ppn_percent); $pph_percent = old('pph_percent', $invoice->pph_percent); @endphp @if (empty($old)) @isset($old_items) @foreach ($old_items as $index => $i) @php if (Auth::user()->entity->is_barang) { $goods = Inventory::select('id', 'id_item', 'stock') ->with([ 'item' => function ($query) { $query->select('id', 'id_category', 'name', 'uom')->with([ 'uomData' => function ($qt) { $qt->select('id', 'name'); }, 'category' => function ($qc) { $qc->select('id', 'name'); }, ]); }, ]) ->whereId($i['id']) ->withTrashed() ->first(); $id = $i['id']; $price = $i['price']; $qty = $i['qty']; $total_item = $price * $qty; $subtotal += $total_item; $itemName = @$goods->item->name; $itemStock = @$goods->stock ?? 0; } else { $goods = Inventory::select('id', 'id_item') ->with([ 'item' => function ($query) { $query->select('id', 'name'); }, ]) ->whereId($i['id']) ->withTrashed() ->first(); $id = $i['id']; $price = $i['price']; $qty = $i['qty']; $total_item = $price * $qty; $subtotal += $total_item; $itemName = @$goods->item->name; $itemStock = null; } @endphp @isset($itemStock) @endisset @endforeach @endisset @php $ppn = ($subtotal * $ppn_percent) / 100; $pph = ($subtotal * $pph_percent) / 100; $ppn = round($ppn); $pph = round($pph); $total = $subtotal + $ppn - $pph; @endphp @else @foreach ($old['id'] as $index => $i) @php $price = empty($old['price'][$index]) ? 0 : str_replace('.', '', $old['price'][$index]); $qty = empty($old['qty'][$index]) ? 0 : str_replace('.', '', $old['qty'][$index]); $total_item = $price * $qty; $subtotal += $total_item; @endphp @if (Auth::user()->entity->is_barang) @endif @endforeach @php $ppn = ($subtotal * $ppn_percent) / 100; $pph = ($subtotal * $pph_percent) / 100; $total = $subtotal + $ppn - $pph + $costShipping; @endphp @endif
Bahan StokNama JasaHarga Satuan Jumlah Total #
@if ($index > 0) @endif
@if ($index > 0) @endif
ADD

@php $ppnChekced = $invoice->ppn_percent > 0 ? 'ppn' : null; $pphChekced = $invoice->pph_percent > 0 ? 'pph' : null; @endphp
Sub Total : Rp {{ number_format($subtotal, 0, '', '.') }}
PPN : Rp {{ number_format($ppn, 0, '', '.') }}
PPH : Rp {{ number_format($ppn, 0, '', '.') }}
Biaya Pengiriman : Rp {{ number_format($costShipping, 0, ',', '.') }}

Total : Rp {{ number_format($total, 0, '', '.') }}
@endsection @push('styles') @endpush @push('scripts') @endpush