chore: initial commit of existing codebase

This commit is contained in:
ghassan committed 2026-05-19 12:40:08 +03:00
commit 11e94889b2
292 files changed
+38586

No files matched your search

@@ -0,0 +1,112 @@
@extends('layouts.app')
@section('title', 'New Supplier Invoice')
@section('content')
<div class="mb-6">
<h1 class="page-title">New Supplier Invoice</h1>
<p class="page-subtitle"><a href="{{ route('purchase.invoices.index') }}" class="text-blue-600 hover:underline">Supplier Invoices</a> / New</p>
</div>
@if($errors->any())
<div class="mb-4 px-4 py-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700">
<ul class="list-disc list-inside space-y-1">
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<div class="card card-body max-w-2xl">
<form action="{{ route('purchase.invoices.store') }}" method="POST">
@csrf
<div class="grid grid-cols-1 gap-5 sm:grid-cols-2">
<div>
<label class="form-label">Invoice Number <span class="text-red-500">*</span></label>
<input type="text" name="invoice_number" value="{{ old('invoice_number') }}" required class="form-input">
</div>
<div>
<label class="form-label">Supplier <span class="text-red-500">*</span></label>
<select name="supplier_id" required class="form-select">
<option value="">-- Select Supplier --</option>
@foreach($suppliers as $supplier)
<option value="{{ $supplier->id }}" {{ old('supplier_id') == $supplier->id ? 'selected' : '' }}>
{{ $supplier->name }}
</option>
@endforeach
</select>
</div>
<div>
<label class="form-label">Purchase Order</label>
<select name="purchase_order_id" class="form-select">
<option value="">-- None --</option>
@foreach($purchaseOrders as $po)
<option value="{{ $po->id }}" {{ old('purchase_order_id') == $po->id ? 'selected' : '' }}>
{{ $po->po_number ?? 'PO-' . str_pad($po->id, 5, '0', STR_PAD_LEFT) }}
</option>
@endforeach
</select>
</div>
<div>
<label class="form-label">GRN</label>
<select name="goods_receipt_note_id" class="form-select">
<option value="">-- None --</option>
@foreach($grns as $grn)
<option value="{{ $grn->id }}" {{ old('goods_receipt_note_id') == $grn->id ? 'selected' : '' }}>
{{ $grn->grn_number ?? 'GRN-' . str_pad($grn->id, 5, '0', STR_PAD_LEFT) }}
</option>
@endforeach
</select>
</div>
<div>
<label class="form-label">Invoice Date <span class="text-red-500">*</span></label>
<input type="date" name="invoice_date" value="{{ old('invoice_date', date('Y-m-d')) }}" required class="form-input">
</div>
<div>
<label class="form-label">Due Date</label>
<input type="date" name="due_date" value="{{ old('due_date') }}" class="form-input">
</div>
<div>
<label class="form-label">Subtotal <span class="text-red-500">*</span></label>
<input type="number" name="subtotal" id="subtotal" value="{{ old('subtotal') }}"
min="0" step="0.01" required onchange="calcInvoiceTotal()" class="form-input">
</div>
<div>
<label class="form-label">VAT Amount</label>
<input type="number" name="vat_amount" id="vat_amount" value="{{ old('vat_amount', 0) }}"
min="0" step="0.01" onchange="calcInvoiceTotal()" class="form-input">
</div>
<div class="sm:col-span-2">
<label class="form-label">Total Amount</label>
<input type="number" name="total_amount" id="total_amount" value="{{ old('total_amount') }}"
readonly
class="w-full border border-gray-200 bg-gray-50 rounded-lg px-3 py-2 text-sm font-semibold text-gray-800">
</div>
</div>
<div class="mt-6 flex items-center gap-3">
<button type="submit" class="btn-primary">Save Invoice</button>
<a href="{{ route('purchase.invoices.index') }}" class="btn-secondary">Cancel</a>
</div>
</form>
</div>
<script>
function calcInvoiceTotal() {
var subtotal = parseFloat(document.getElementById('subtotal').value) || 0;
var vat = parseFloat(document.getElementById('vat_amount').value) || 0;
document.getElementById('total_amount').value = (subtotal + vat).toFixed(2);
}
</script>
@endsection
@@ -0,0 +1,86 @@
@extends('layouts.app')
@section('title', 'Edit Supplier Invoice')
@section('content')
<div class="mb-6">
<h1 class="page-title">Edit Supplier Invoice</h1>
<p class="page-subtitle"><a href="{{ route('purchase.invoices.index') }}" class="text-blue-600 hover:underline">Supplier Invoices</a> / Edit</p>
</div>
@if($errors->any())
<div class="mb-4 px-4 py-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700">
<ul class="list-disc list-inside space-y-1">
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<div class="card card-body max-w-2xl">
<form action="{{ route('purchase.invoices.update', $invoice) }}" method="POST">
@csrf
@method('PUT')
<div class="grid grid-cols-1 gap-5 sm:grid-cols-2">
<div>
<label class="form-label">Invoice Number <span class="text-red-500">*</span></label>
<input type="text" name="invoice_number" value="{{ old('invoice_number', $invoice->invoice_number) }}" required class="form-input">
</div>
<div>
<label class="form-label">Invoice Date <span class="text-red-500">*</span></label>
<input type="date" name="invoice_date" value="{{ old('invoice_date', $invoice->invoice_date ? \Carbon\Carbon::parse($invoice->invoice_date)->format('Y-m-d') : '') }}" required class="form-input">
</div>
<div>
<label class="form-label">Due Date</label>
<input type="date" name="due_date" value="{{ old('due_date', $invoice->due_date ? \Carbon\Carbon::parse($invoice->due_date)->format('Y-m-d') : '') }}" class="form-input">
</div>
<div>
<label class="form-label">Subtotal</label>
<input type="number" name="subtotal" id="edit-subtotal" value="{{ old('subtotal', $invoice->subtotal) }}"
min="0" step="0.01" onchange="calcPurchaseEditTotal()" class="form-input">
</div>
<div>
<label class="form-label">VAT Amount</label>
<input type="number" name="vat_amount" id="edit-vat" value="{{ old('vat_amount', $invoice->vat_amount) }}"
min="0" step="0.01" onchange="calcPurchaseEditTotal()" class="form-input">
</div>
<div>
<label class="form-label">Total Amount</label>
<input type="number" name="total_amount" id="edit-total" value="{{ old('total_amount', $invoice->total_amount) }}"
readonly
class="w-full border border-gray-200 bg-gray-50 rounded-lg px-3 py-2 text-sm font-semibold text-gray-800">
</div>
<div>
<label class="form-label">Status</label>
<select name="status" class="form-select">
<option value="unpaid" {{ old('status', $invoice->status) === 'unpaid' ? 'selected' : '' }}>Unpaid</option>
<option value="partial" {{ old('status', $invoice->status) === 'partial' ? 'selected' : '' }}>Partial</option>
<option value="paid" {{ old('status', $invoice->status) === 'paid' ? 'selected' : '' }}>Paid</option>
</select>
</div>
</div>
<div class="mt-6 flex items-center gap-3">
<button type="submit" class="btn-primary">Update Invoice</button>
<a href="{{ route('purchase.invoices.index') }}" class="btn-secondary">Cancel</a>
</div>
</form>
</div>
<script>
function calcPurchaseEditTotal() {
var sub = parseFloat(document.getElementById('edit-subtotal').value) || 0;
var vat = parseFloat(document.getElementById('edit-vat').value) || 0;
document.getElementById('edit-total').value = (sub + vat).toFixed(2);
}
</script>
@endsection
@@ -0,0 +1,78 @@
@extends('layouts.app')
@section('title', 'Supplier Invoices')
@section('content')
<div class="page-header">
<div>
<h1 class="page-title">Supplier Invoices</h1>
<p class="page-subtitle">Track and manage supplier invoices</p>
</div>
<a href="{{ route('purchase.invoices.create') }}" class="btn-primary">
+ New Invoice
</a>
</div>
<div class="table-wrapper overflow-x-auto">
<table class="table-base">
<thead>
<tr>
<th>Invoice #</th>
<th>Supplier</th>
<th>PO #</th>
<th>Date</th>
<th class="text-right">Total</th>
<th class="text-right">Paid</th>
<th class="text-right">Outstanding</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@forelse($invoices as $invoice)
@php $outstanding = $invoice->total_amount - $invoice->paid_amount; @endphp
<tr>
<td class="font-mono text-gray-700">{{ $invoice->invoice_number }}</td>
<td class="text-gray-800">{{ $invoice->supplier->name ?? '' }}</td>
<td class="font-mono text-gray-600">{{ $invoice->purchaseOrder->po_number ?? '-' }}</td>
<td>{{ $invoice->invoice_date ? \Carbon\Carbon::parse($invoice->invoice_date)->format('d M Y') : '' }}</td>
<td class="text-right text-gray-800">{{ number_format($invoice->total_amount, 2) }}</td>
<td class="text-right text-green-700">{{ number_format($invoice->paid_amount, 2) }}</td>
<td class="text-right {{ $outstanding > 0 ? 'text-red-600 font-semibold' : 'text-gray-500' }}">{{ number_format($outstanding, 2) }}</td>
<td>
@php
$badgeClass = match($invoice->status ?? 'unpaid') {
'unpaid' => 'badge-red',
'partial' => 'badge-yellow',
'paid' => 'badge-green',
default => 'badge-gray',
};
@endphp
<span class="{{ $badgeClass }}">{{ ucfirst($invoice->status ?? 'unpaid') }}</span>
</td>
<td>
<div class="flex items-center gap-2">
<a href="{{ route('purchase.payments.create', ['invoice_id' => $invoice->id]) }}" class="btn-success btn-sm">Pay</a>
<a href="{{ route('purchase.invoices.edit', $invoice) }}" class="btn-secondary btn-sm">Edit</a>
<form action="{{ route('purchase.invoices.destroy', $invoice) }}" method="POST"
onsubmit="confirmDelete(this,'Delete this invoice?','This invoice will be permanently removed.'); return false;">
@csrf
@method('DELETE')
<button type="submit" class="btn-danger btn-sm">Delete</button>
</form>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="9" class="px-4 py-8 text-center text-gray-400">No invoices found.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@if($invoices->hasPages())
<div class="mt-4">{{ $invoices->links() }}</div>
@endif
@endsection