@extends('layouts.app') @section('title','#'.$sale->sale_number) @section('page_title','Sale Details') @section('content') @php $hasDirectItemDiscounts = $sale->items->contains(fn ($item) => $item->directDiscountAmount() > 0); @endphp @if($justCompleted)
{{ $sale->isPaymentPending() ? 'Sale saved — Payment Pending' : 'Sale completed successfully' }}Invoice reference: #{{ $sale->sale_number }}@if($sale->isPaymentPending()) · Stock has been deducted; revenue waits for payment confirmation.@endif
@if($invoiceEnabled) View Invoice Download PDF @if($receiptEnabled)Print Receipt@endif @endif New Sale
@endif

#{{ $sale->sale_number }}

{{ $sale->isVoid()?'Void / Fully Returned':($sale->isPartiallyReturned()?'Partially Returned':'Completed') }}{{ $sale->paymentProgressLabel() }}
@if($invoiceEnabled)Invoice@if($receiptEnabled)Receipt@endif @endif Back to Sales
@if(session('status') && !$justCompleted)
{{ session('status') }}
@endif @if($errors->any())
{{ $errors->first() }}
@endif

Sale Summary

Invoice#{{ $sale->sale_number }}
Date{{ $sale->completed_at?->format('d M Y, H:i') }}
Cashier{{ $sale->user?->name ?? '-' }}
Payment Status{{ $sale->paymentProgressLabel() }}
@if($sale->isPaid() || $sale->hasPartialPayment())
Payment Method{{ $sale->paymentMethodLabel() }}
@endif @if($sale->customer_name || $sale->customer_phone)
Customer{{ $sale->customer_name ?: 'Name not provided' }}@if($sale->customer_phone) · {{ $sale->customer_phone }}@endif
@endif @if($sale->isPaid() && $sale->payment_confirmed_at)
Payment Confirmed{{ $sale->payment_confirmed_at->format('d M Y, H:i') }}@if($sale->paymentConfirmedBy) · {{ $sale->paymentConfirmedBy->displayName() }}@endif
@endif
Products{{ $sale->items->count() }} line(s)
SubtotalTZS {{ tzs_amount($sale->subtotal) }}
@if($sale->directItemDiscountTotal()>0)
Direct Item DiscountsTZS {{ tzs_amount($sale->directItemDiscountTotal()) }}
@endif
Overall DiscountTZS {{ tzs_amount($sale->overallDiscountTotal()) }}
Sale TotalTZS {{ tzs_amount($sale->total_amount) }}
RefundedTZS {{ tzs_amount($sale->refund_amount) }}
Amount PaidTZS {{ tzs_amount($sale->paidAmount()) }}
@unless($sale->isVoid())
Balance DueTZS {{ tzs_amount($sale->balanceDue()) }}
@endunless
{{ $sale->isPaid() ? 'Net Sale' : 'Sale Amount' }}TZS {{ tzs_amount($sale->netTotal()) }}@if($sale->isPaymentPending()) · Not recognized yet @endif
@unless(auth()->user()->isCashier())
{{ $sale->isPaid() ? 'Net Gross Profit' : 'Projected Gross Profit' }}TZS {{ tzs_amount($sale->netGrossProfit()) }}@if($sale->isPaymentPending()) · Not recognized yet @endif
@endunless
Sync{{ ucwords(str_replace('_',' ',$sale->sync_status)) }}
Returns{{ $sale->returns->count() }} event(s)
Note{{ $sale->note ?: '—' }}
@if($sale->isPaymentPending() && !$sale->isVoid() && in_array(auth()->user()->role,['owner','manager'],true))
@csrf
{{ $sale->hasPartialPayment() ? 'Partially Paid' : 'Payment Pending' }}

Record Payment

Enter only the amount received. The balance will remain pending until fully paid.

Remaining BalanceTZS {{ tzs_amount($sale->balanceDue()) }}
Maximum: TZS {{ tzs_amount($sale->balanceDue()) }}
Add payment noteOptional reference or collection detail
@endif
@if($sale->isVoid())

Void Information

Reason: {{ $sale->void_reason }}

Voided by: {{ $sale->voidedBy?->name ?? '-' }}

Voided at: {{ $sale->voided_at?->format('d M Y, H:i') }}

@elseif(in_array(auth()->user()->role,['owner','manager'],true))
Cancel Remaining SaleOpen only when you need to cancel the remaining sale.
@csrf
@endif
@if($sale->payments->isNotEmpty())

Payment History

Payments recorded against this sale.

{{ $sale->balanceDue() > 0 ? 'Balance TZS '.tzs_amount($sale->balanceDue()) : 'Fully Paid' }}
@foreach($sale->payments as $payment)
{{ $payment->source === \App\Models\SalePayment::SOURCE_INITIAL ? '✓' : '+' }}
TZS {{ tzs_amount($payment->amount) }}{{ $payment->paymentMethodLabel() }}@if($payment->note && trim($payment->note) !== 'Payment received at checkout.')

{{ $payment->note }}

@endif
{{ $payment->source === \App\Models\SalePayment::SOURCE_INITIAL ? 'Initial payment' : 'Payment collected' }}Recorded by {{ $payment->user?->displayName() ?? $sale->user?->displayName() ?? '-' }}
@endforeach
@endif

Sale Items

@if($hasDirectItemDiscounts)@endif@unless(auth()->user()->isCashier())@endunless @foreach($sale->items as $item) @if($hasDirectItemDiscounts)@endif @unless(auth()->user()->isCashier())@endunless @endforeach
ProductSelling TypeSourceQuantityReturnedUnit PriceItem DiscountTotalProfit
{{ $item->product_name }}@if(!$item->product_id)Manual outside item@endif {{ $item->sellingTypeLabel() }} {{ ucwords(str_replace('_',' ',$item->source)) }}@if($item->source_shop_name)From {{ $item->source_shop_name }}@endif {{ number_format($item->quantity) }} {{ $item->unitName() }} {{ number_format($item->returnedQuantity()) }} / {{ number_format($item->quantity) }} TZS {{ tzs_amount($item->unit_price) }} / {{ $item->unit_singular }}{{ $item->directDiscountAmount() > 0 ? 'TZS '.tzs_amount($item->directDiscountAmount()) : '—' }}TZS {{ tzs_amount($item->total_price) }}TZS {{ tzs_amount($item->profit) }}
@foreach($sale->items as $item)
{{ strtoupper(substr($item->product_name,0,1)) }}

{{ $item->product_name }}

{{ $item->sellingTypeLabel() }} · {{ ucwords(str_replace('_',' ',$item->source)) }}@if($item->source_shop_name) · From {{ $item->source_shop_name }}@endif
{{ number_format($item->quantity) }} {{ $item->unitName() }}TZS {{ tzs_amount($item->total_price) }}
TZS {{ tzs_amount($item->unit_price) }} / {{ $item->unit_singular }}@if($item->directDiscountAmount() > 0)Item discount: TZS {{ tzs_amount($item->directDiscountAmount()) }}@endif @if($item->returnedQuantity() > 0)Returned: {{ number_format($item->returnedQuantity()) }}@endif
@unless(auth()->user()->isCashier())
•••
Profit: TZS {{ tzs_amount($item->profit) }}
@endunless
@endforeach
@if($returnItemsEnabled && !$sale->isVoid() && in_array(auth()->user()->role,['owner','manager'],true))
Return ItemsChoose products and quantities only when a customer brings items back.
@csrf
@foreach($sale->items as $item) @if($item->returnableQuantity() > 0)
{{ $item->product_name }}{{ $item->sellingTypeLabel() }} · {{ $item->returnableQuantity() }} {{ $item->returnableQuantity()===1?$item->unit_singular:$item->unit_plural }} returnable
@endif @endforeach
@endif @if($sale->returns->isNotEmpty())

Return History

@foreach($sale->returns->sortByDesc('created_at') as $return)
TZS {{ tzs_amount($return->refund_amount) }} refunded{{ $return->created_at->format('d M Y, H:i') }} · {{ $return->user?->name ?? 'Unknown user' }}

{{ $return->reason }}

@foreach($return->items as $returnItem){{ $returnItem->saleItem?->product_name }}: {{ $returnItem->quantity }} {{ $returnItem->quantity===1?$returnItem->saleItem?->unit_singular:$returnItem->saleItem?->unit_plural }}@if(!$loop->last), @endif @endforeach
@endforeach
@endif @endsection