@extends('layouts.app')
@section('title',$note->note_number)
@section('page_title','Adjustment Note')
@section('content')
@php($s=$note->status instanceof \App\Enums\DocumentStatus?$note->status->value:$note->status)
<div class="page-head"><div><h1>{{ $note->note_number }}</h1><p>{{ ucfirst($note->side) }} {{ ucfirst($note->note_type) }} Note · <span class="badge status-{{ $s }}">{{ ucwords(str_replace('_',' ',$s)) }}</span></p></div><div class="actions"><a class="btn btn-secondary" href="{{ route('notes.index') }}">Back</a><a class="btn btn-secondary" target="_blank" href="{{ route('notes.print',$note) }}">Print</a><a class="btn btn-secondary" href="{{ route('notes.pdf',$note) }}">PDF</a>@if(in_array($s,['draft','rejected']))<a class="btn btn-primary" href="{{ route('notes.edit',$note) }}">Edit</a>@endif</div></div>
<div class="grid grid-3"><div class="card metric"><div class="metric-label">Taxable Amount</div><div class="metric-value">AED {{ number_format((float)$note->taxable_total,2) }}</div></div><div class="card metric"><div class="metric-label">VAT Adjustment</div><div class="metric-value">AED {{ number_format((float)$note->vat_total,2) }}</div></div><div class="card metric"><div class="metric-label">Note Total</div><div class="metric-value">AED {{ number_format((float)$note->grand_total,2) }}</div></div></div>
<div class="card" style="margin-top:18px"><div class="card-body"><div class="detail-grid"><div class="detail"><div class="detail-label">Party</div><div class="detail-value">{{ $note->party?->legal_name }}</div></div><div class="detail"><div class="detail-label">Date</div><div class="detail-value">{{ $note->note_date->format('d M Y') }}</div></div><div class="detail"><div class="detail-label">Original Document</div><div class="detail-value">{{ $note->invoice?->invoice_number ?? $note->bill?->bill_number }}</div></div><div class="detail"><div class="detail-label">Reason Code</div><div class="detail-value">{{ ucwords(str_replace('_',' ',$note->reason_code)) }}</div></div><div class="detail" style="grid-column:span 2"><div class="detail-label">Reason</div><div class="detail-value">{{ $note->reason }}</div></div></div></div><div class="table-wrap"><table class="table"><thead><tr><th>Description</th><th>Qty</th><th>Rate</th><th>Taxable</th><th>VAT</th><th>Total</th></tr></thead><tbody>@foreach($note->items as $i)<tr><td>{{ $i->description }}</td><td>{{ $i->quantity }}</td><td>{{ number_format((float)$i->unit_rate,2) }}</td><td>{{ number_format((float)$i->taxable_amount,2) }}</td><td>{{ number_format((float)$i->vat_amount,2) }}</td><td>{{ number_format((float)$i->line_total,2) }}</td></tr>@endforeach</tbody></table></div></div>
@include('components.workflow-actions',['document'=>$note,'routePrefix'=>'notes','permissionPrefix'=>'adjustment_notes','status'=>$s,'postLabel'=>'Post Adjustment'])
@endsection
