Index: database/migrations/2025_09_30_194708_add_indexes_to_tables.php
===================================================================
--- database/migrations/2025_09_30_194708_add_indexes_to_tables.php	(revision 1dd045b40a2a8812f3422f2aff59c36bc5417a89)
+++ database/migrations/2025_09_30_194708_add_indexes_to_tables.php	(revision 1dd045b40a2a8812f3422f2aff59c36bc5417a89)
@@ -0,0 +1,53 @@
+<?php
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddIndexesToTables extends Migration
+{
+public function up(): void
+{
+Schema::table('users', function (Blueprint $table) {
+$table->index('email', 'idx_users_email');
+});
+
+Schema::table('clients', function (Blueprint $table) {
+$table->index(['name', 'country'], 'idx_clients_name_country');
+});
+
+Schema::table('batches', function (Blueprint $table) {
+$table->index('batch_code', 'idx_batches_batch_code');
+});
+
+Schema::table('orders', function (Blueprint $table) {
+$table->index('status', 'idx_orders_status');
+});
+
+Schema::table('payments', function (Blueprint $table) {
+$table->index('payment_status', 'idx_payments_payment_status');
+});
+}
+
+public function down(): void
+{
+Schema::table('users', function (Blueprint $table) {
+$table->dropIndex('idx_users_email');
+});
+
+Schema::table('clients', function (Blueprint $table) {
+$table->dropIndex('idx_clients_name_country');
+});
+
+Schema::table('batches', function (Blueprint $table) {
+$table->dropIndex('idx_batches_batch_code');
+});
+
+Schema::table('orders', function (Blueprint $table) {
+$table->dropIndex('idx_orders_status');
+});
+
+Schema::table('payments', function (Blueprint $table) {
+$table->dropIndex('idx_payments_payment_status');
+});
+}
+}
Index: resources/views/pdfs/invoice.blade.php
===================================================================
--- resources/views/pdfs/invoice.blade.php	(revision 715ed4b68b57bdef5a2503bfc72c78f785137c05)
+++ resources/views/pdfs/invoice.blade.php	(revision 1dd045b40a2a8812f3422f2aff59c36bc5417a89)
@@ -66,4 +66,5 @@
             border-radius: 5px;
             margin-bottom: 10px;
+            border: 1px solid #e5e7eb;
         }
         .info-box p {
@@ -156,4 +157,9 @@
         .status-paid { background: #d1fae5; color: #065f46; }
         .status-overdue { background: #fee2e2; color: #991b1b; }
+        .clearfix::after {
+            content: "";
+            clear: both;
+            display: table;
+        }
     </style>
 </head>
@@ -186,7 +192,9 @@
         <div class="section-title">Bill To</div>
         <div class="info-box">
-            <p><strong>{{ $order->buyer->name }}</strong></p>
+            <p><strong>{{ $order->buyer->name ?? 'N/A' }}</strong></p>
             <p>{{ $order->buyer->address ?? 'N/A' }}</p>
-            <p>{{ $order->buyer->city ?? '' }}, {{ $order->buyer->country ?? '' }}</p>
+            <p>
+                {{ $order->buyer->city ?? '' }}{{ $order->buyer->city && $order->buyer->country ? ', ' : '' }}{{ $order->buyer->country ?? '' }}
+            </p>
             <p>Email: {{ $order->buyer->email ?? 'N/A' }}</p>
             <p>Phone: {{ $order->buyer->phone ?? 'N/A' }}</p>
@@ -196,7 +204,9 @@
         <div class="section-title">Ship To</div>
         <div class="info-box">
-            <p><strong>{{ $order->receiver->name }}</strong></p>
+            <p><strong>{{ $order->receiver->name ?? 'N/A' }}</strong></p>
             <p>{{ $order->receiver->address ?? 'N/A' }}</p>
-            <p>{{ $order->receiver->city ?? '' }}, {{ $order->receiver->country ?? '' }}</p>
+            <p>
+                {{ $order->receiver->city ?? '' }}{{ $order->receiver->city && $order->receiver->country ? ', ' : '' }}{{ $order->receiver->country ?? '' }}
+            </p>
             <p>Email: {{ $order->receiver->email ?? 'N/A' }}</p>
             <p>Phone: {{ $order->receiver->phone ?? 'N/A' }}</p>
@@ -219,5 +229,12 @@
         </thead>
         <tbody>
+        @php
+            $subtotal = 0;
+        @endphp
         @foreach($order->batches as $index => $batch)
+            @php
+                $lineTotal = $batch->pivot->quantity * $batch->pivot->price_per_unit;
+                $subtotal += $lineTotal;
+            @endphp
             <tr>
                 <td>{{ $index + 1 }}</td>
@@ -226,5 +243,5 @@
                 <td class="text-center">{{ $batch->pivot->quantity }}</td>
                 <td class="text-right">{{ $currency }} {{ number_format($batch->pivot->price_per_unit, 2) }}</td>
-                <td class="text-right">{{ $currency }} {{ number_format($batch->pivot->total_price, 2) }}</td>
+                <td class="text-right">{{ $currency }} {{ number_format($lineTotal, 2) }}</td>
             </tr>
         @endforeach
@@ -233,16 +250,18 @@
 </div>
 
-<div class="totals-section">
-    <div class="totals-row">
-        <div class="totals-label">Subtotal:</div>
-        <div class="totals-amount">{{ $currency }} {{ $subtotal }}</div>
-    </div>
-    <div class="totals-row">
-        <div class="totals-label">Tax ({{ $taxRate }}%):</div>
-        <div class="totals-amount">{{ $currency }} {{ $taxAmount }}</div>
-    </div>
-    <div class="totals-row total">
-        <div class="totals-label">Total Amount:</div>
-        <div class="totals-amount">{{ $currency }} {{ $totalAmount }}</div>
+<div class="clearfix">
+    <div class="totals-section">
+        <div class="totals-row">
+            <div class="totals-label">Subtotal:</div>
+            <div class="totals-amount">{{ $currency }} {{ number_format($subtotal, 2) }}</div>
+        </div>
+        <div class="totals-row">
+            <div class="totals-label">Tax ({{ $taxRate }}%):</div>
+            <div class="totals-amount">{{ $currency }} {{ number_format($taxAmount, 2) }}</div>
+        </div>
+        <div class="totals-row total">
+            <div class="totals-label">Total Amount:</div>
+            <div class="totals-amount">{{ $currency }} {{ number_format($totalAmount, 2) }}</div>
+        </div>
     </div>
 </div>
@@ -262,4 +281,5 @@
                 <p><strong>Payment Date:</strong> {{ \Carbon\Carbon::parse($order->payment->payment_date)->format('Y-m-d') }}</p>
             @endif
+            <p><strong>Amount Due:</strong> {{ $currency }} {{ number_format($order->payment->amount, 2) }}</p>
         </div>
     @endif
