@extends('layouts.app')
@section('content')
@php
$normalizeUnit = function ($unit) {
$unit = strtolower(trim((string) $unit));
return match ($unit) {
'm2', 'm²' => 'm2',
'meter', 'm' => 'meter',
'pcs', 'pc', 'piece', 'lembar' => 'lembar',
default => $unit !== '' ? $unit : 'lembar',
};
};
$formatQty = function ($value, $decimals = 2) {
$formatted = number_format((float) $value, $decimals, ',', '.');
$formatted = rtrim($formatted, '0');
$formatted = rtrim($formatted, ',');
return $formatted === '' ? '0' : $formatted;
};
$isItemCancelled = function ($item) {
if (method_exists($item, 'isCancelled')) {
return $item->isCancelled();
}
return (bool) ($item->is_cancelled ?? false);
};
$applyMinimumAndRounding = function ($amount) {
$amount = max((float) $amount, 0);
if ($amount > 0 && $amount < 10000) {
$amount = 10000;
}
$base = floor($amount / 1000) * 1000;
$remainder = round($amount - $base);
if ($remainder == 0 || $remainder == 500) {
return round($amount, 2);
}
return round($remainder < 500 ? ($base + 500) : ($base + 1000), 2);
};
$calculateItemSubtotal = function ($item) use ($normalizeUnit, $applyMinimumAndRounding) {
$qty = max((float) ($item->qty ?? $item->quantity ?? 1), 1);
$sisi = max((int) ($item->sisi ?? 1), 1);
$manualPrice = max((float) ($item->manual_price ?? 0), 0);
if ($manualPrice > 0) {
return round($manualPrice * $qty * $sisi, 2);
}
$storedSubtotal = max((float) ($item->subtotal ?? $item->system_subtotal ?? 0), 0);
if ($storedSubtotal > 0) {
return round($storedSubtotal, 2);
}
$unit = $normalizeUnit($item->size_unit ?? 'lembar');
$basePrice = max((float) ($item->base_price ?? 0), 0);
$sizeValue = max((float) ($item->size_value ?? 1), 0);
if (in_array($unit, ['m2', 'meter'], true)) {
return round($applyMinimumAndRounding($basePrice * $sizeValue * $qty), 2);
}
return round($applyMinimumAndRounding($basePrice * $qty), 2);
};
$activeFilters = collect([
'search' => request('search'),
'status' => request('status'),
'production' => request('production'),
'pickup' => request('pickup'),
'date' => request('date'),
])->filter(fn ($v) => filled($v));
$filtersCount = $activeFilters->count();
$hint = $filtersCount > 0
? "Saat ini ada {$filtersCount} filter aktif. Untuk hasil lebih spesifik, kombinasikan filter seperti Status Bayar + Produksi + Tanggal."
: "Belum ada filter aktif. Untuk memecah data lebih cepat, mulai dari Status Bayar atau Tanggal lalu tambah filter Produksi/Pengambilan.";
$currentUser = auth()->user();
$userRoleName = strtolower((string) (optional(optional($currentUser)->roles ?? collect())->first()->name ?? $currentUser->role ?? ''));
$canPrintNotaWithoutPayment = auth()->check() && (
in_array($userRoleName, ['kasir', 'cashier', 'designer', 'design', 'desain'], true)
|| (method_exists($currentUser, 'isKasir') && $currentUser->isKasir())
|| (method_exists($currentUser, 'isDesigner') && $currentUser->isDesigner())
);
@endphp
{{ $hint }}
| Invoice | Instansi / Pelanggan | Ringkasan Item | Total | Pembayaran | Produksi | Pengambilan | Aksi |
|---|---|---|---|---|---|---|---|
|
{{ $order->invoice_number }}
@if($order->is_credit)
Piutang
@endif
{{ $order->designer->name ?? '-' }}
|
{{ $order->customer_name }}
@if($order->customer_phone)
{{ $order->customer_phone }} @endif |
{{ $summaryFileName }}
{{ $sizeText }} @if($qtyText !== '-') | {{ $qtyText }} @endif @if($extraItemsCount > 0) +{{ $extraItemsCount }} item lagi @endif |
Rp {{ number_format((float) $displayTotal, 0, ',', '.') }}
@if($hasM2Item)
hitung ukuran × harga/m² @endif |
{{ $order->getPaymentStatusLabel() }} | {{ $order->getProductionStatusLabel() }} | {{ $order->getPickupStatusLabel() }} |
|
| Tidak ada data order | |||||||