@extends('layouts/base_view') @section('title') {!! $variables['header_routes'] !!} @endsection @section('content')

Stock Opname

@csrf
User : {{ $logged_name }} ( {{ $logged_role_name }}) Status : @if(isset($data->id) && $data->status) {{ $data->status }} @else - @endif Notes :
Store : @if(session('store_selected')) {{ $store_name }} @else No Store Selected @endif LSM Date : @php $hariIndo = ['Sunday'=>'Minggu','Monday'=>'Senin','Tuesday'=>'Selasa','Wednesday'=>'Rabu','Thursday'=>'Kamis','Friday'=>'Jumat','Saturday'=>'Sabtu']; $soDate = $data->so_date ?? now(); $namaHari = $hariIndo[$soDate->format('l')] ?? $soDate->format('l'); @endphp {{ $namaHari }}, {{ $soDate->format('d M Y') }}

Informasi

Rumus Perhitungan SPB
Tipe Formula Kondisi SPB Muncul Catatan Khusus
DO HARIAN
Shipment DC(Tipe: Harian)
(Fc H+1 + Fc H+2 + TSM H+2) - LSM - Open SPB H+2 jatuh di delivery day Pakai TSM
Forecast 2 hari (besok & lusa)
DO PERIODIK
Shipment DC(Tipe: Periodik)
Total Fc (Coverage) - LSM - Open SPB H+2 jatuh di delivery day TIDAK pakai TSM
Forecast coverage (H+3 s/d shipment berikutnya, INCLUSIVE)
PR SAYURAN
Shipment Suppliers (Sesuai shipment RM)
Formula DO HARIAN H+1 (Hari SPB) bukan libur purchasing
H+2 jatuh di shift day
Cek libur di H+1 (Hari SPB)
Pakai TSM
Forecast 2 hari (besok & lusa)
PR PERIODIK
Shipment Suppliers (Sesuai shipment RM)
Formula PR PERIODIK H+1 (Hari SPB) bukan libur purchasing
H+2 jatuh di shift day
Cek libur di H+1 (Hari SPB)
TIDAK pakai TSM
Forecast coverage (H+3 s/d shipment berikutnya, INCLUSIVE)
Multiple Usulan SPB (PR Items Only)
Usulan Untuk Hari Formula Open SPB Catatan Khusus
Usulan 1 H+1 (besok)
Muncul jika H+1 bukan libur
(Fc H+1 + Fc H+2 + TSM H+2) - LSM - Open SPB Open SPB Sebelumnya TSM menggunakan H+2
Forecast 2 hari (H+1 & H+2)
Selalu muncul jika H+1 bukan libur
Usulan 2 H+2 (lusa)
Muncul jika H+2 adalah libur
(Fc H+1 + Fc H+2 + Fc H+3 + TSM H+3) - LSM - Open SPB Suggest Usulan 1 TSM menggunakan H+3
Forecast 3 hari (H+1, H+2, H+3)
Open SPB (Hasil dari suggest Usulan 1)
Jika tidak muncul, usulan 3 tidak dicek
Usulan 3 H+3
Muncul jika H+3 adalah libur
(Fc H+1 + Fc H+2 + Fc H+3 + Fc H+4 + TSM H+4) - LSM - Open SPB Suggest Usulan 1 + Usulan 2 TSM menggunakan H+4
Forecast 4 hari (H+1, H+2, H+3, H+4)
Open SPB cumulative (Usulan 1 + Usulan 2)
Hanya dicek jika usulan 2 muncul
Catatan Konversi & Pembulatan:
Hasil dalam UOM Pakai dikonversi ke UOM Kirim
Konversi: Pakai Utuh Kirim
Smart Rounding: Sisa % SPB ROP bulatkan ke atas
Order Constraints: Minimal order & Multiple order diterapkan setelah konversi
Libur Purchasing:
PR Periodik: Sabtu, Minggu, Libur Nasional
PR Sayuran: Minggu, Libur Nasional
Cek libur dilakukan di H+1, H+2, H+3 (hari SPB dibuat)
Jika H+X libur SPB harus dibuat hari ini (H)
@if($data->id > 0) @endif
Suggested 0 items
Adjusted 0 items
Confirmed 0 items
Slot SPB 0 usulan
@foreach($variables['raw_materials'] as $index => $rm) @php $existingDetail = null; if(isset($data->details)) { $existingDetail = $data->details->where('raw_material_id', $rm->id)->first(); } // Get conversion data $hasConversion = $rm->conversion_factor_utuh_pakai && $rm->conversion_factor_utuh_pakai > 0; $conversionFactor = $hasConversion ? $rm->conversion_factor_utuh_pakai : 1; $uomUtuh = $rm->uom_utuh ?? $rm->uom; $uomPakai = $rm->uom_pakai ?? $rm->uom; // Get store raw material mapping for SPB suggestions $mapping = $variables['mappings']->get($rm->id); $hasMapping = $mapping && $mapping->is_active; $showSPB = $hasMapping && ($mapping->spb_flag ?? false); @endphp {{-- Adjustment Modal for this item --}} @if($hasAnyAdjustment) @endif {{-- FSTR Sub-lines: Display FSTR components (WIP items) for this RM --}} @php // Get all FSTR components (WIP items) that belong to this RM // Example: DRY0048 (parent) has WIP0029, WIP0030, WIP0031 (components) // Filter only components with input_lsm_flag = true to show in LSM input $fstrComponents = $rm->components() ->where('delete_flag', 0) ->where('input_lsm_flag', true) ->with('component') ->get() ->filter(function($comp) { return $comp->component !== null; // Remove components with null component }); @endphp @foreach($fstrComponents as $fstrComponent) @php $fstr = $fstrComponent->component; // Changed from parent to component // Skip if component is null (filtered out) if (!$fstr) continue; $componentQtyPerUnit = $fstrComponent->qty; // Check if this FSTR is also a FSTR (has components) $isFSTR = $fstr->components()->where('delete_flag', 0)->exists(); // Get existing FSTR qty_pakai from SO detail if exists $existingFstrQty = 0; if ($existingDetail && $existingDetail->fstr_qty_pakai) { $fstrQtyData = is_string($existingDetail->fstr_qty_pakai) ? json_decode($existingDetail->fstr_qty_pakai, true) : $existingDetail->fstr_qty_pakai; $existingFstrQty = $fstrQtyData[$fstr->id] ?? 0; } @endphp @endforeach @endforeach {{-- SUB Sub-lines: item substitusi yang dimiliki RM ini --}} @foreach($rm->substitutions->where('delete_flag', false) as $subRelation) @php $subItem = $subRelation->substitution; if (!$subItem) continue; $existingSubQty = 0; if ($existingDetail && $existingDetail->fstr_qty_pakai) { $fstrQtyData = is_string($existingDetail->fstr_qty_pakai) ? json_decode($existingDetail->fstr_qty_pakai, true) : $existingDetail->fstr_qty_pakai; $existingSubQty = $fstrQtyData['sub_' . $subItem->id] ?? 0; } @endphp @endforeach
No Item Previous Stock Sisa Utuh Sisa Pakai Adj LSM Aktual Status Stok SPB 1 / - SPB 2 / - SPB 3 / - X
Final Qty Saran Qty Final Qty Saran Qty Final Qty Saran Qty
{{ $index + 1 }} @if(!$hasConversion)
@endif
{{ $rm->code }} | {{ $rm->name }}
UOM: {{ $uomPakai }} @if($hasConversion) (1 {{ $uomUtuh }} = {{ number_format($conversionFactor, 2, '.', '') }} {{ $uomPakai }}) @endif @if($hasMapping && $mapping->period) | {{ $mapping->tipe_dokumen.' '. $mapping->period->code }} @endif @if(!$hasConversion)
Tidak ada mapping @endif
-
@if($showSPB)
Open SPB : 0.00
@endif
@php $mapping = $variables['mappings']->get($rm->id); $hasRestan = $rm->adj_restan_flag; $hasExtras = $rm->adj_extras_flag; $hasRingkas = $rm->adj_ringkas_flag; $hasSelisih = $rm->adj_selisih_flag; $hasAnyAdjustment = $hasRestan || $hasExtras || $hasRingkas || $hasSelisih; // Calculate total adjustment $totalAdj = 0; if ($existingDetail) { $totalAdj = ($existingDetail->adj_ekstra ?? 0) + ($existingDetail->adj_restan ?? 0) + ($existingDetail->adj_ringkas ?? 0) + ($existingDetail->adj_selisih ?? 0); } @endphp @if($hasAnyAdjustment) @else @endif
{{ $existingDetail ? number_format($existingDetail->lsm_aktual, 2, '.', '') : '0.00' }}
@if($showSPB) - @else - @endif @if($showSPB) X @else @endif @if($showSPB) @else @endif @if($showSPB) X @else - @endif @if($showSPB) @else X @endif @if($showSPB) X @else - @endif @if($showSPB) @else @endif
FSTR: {{ $fstr->code }} - {{ $fstr->name }} - {{ $fstr->uom_pakai ?? $fstr->uom; }} {{-- FSTR qty_pakai input --}}
SUB: {{ $subItem->code }} - {{ $subItem->name }} - {{ $subItem->uom_pakai ?? $subItem->uom }}
Kembali @if(!isset($data->id) || $data->status == 'Draft') @endif
@endsection