Commit 8a39062e authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fix: POS print receipt now shows partial payment correctly

The print receipt was always showing only the total amount,
even when the transaction was a partial payment (deposit).
Now shows paid amount, remaining balance, and a "مدفوع جزئياً"
badge when the linked invoice has outstanding balance.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 72f10f27
...@@ -9,7 +9,7 @@ class ReceiptController extends Controller ...@@ -9,7 +9,7 @@ class ReceiptController extends Controller
{ {
public function posPrint(POSTransaction $transaction) public function posPrint(POSTransaction $transaction)
{ {
$transaction->load(['items', 'participant.person', 'branch', 'processedBy']); $transaction->load(['items', 'participant.person', 'branch', 'processedBy', 'invoice']);
return view('print.pos-receipt', compact('transaction')); return view('print.pos-receipt', compact('transaction'));
} }
......
...@@ -210,6 +210,8 @@ ...@@ -210,6 +210,8 @@
<span class="amount">{{ format_money($transaction->total_amount) }}</span> <span class="amount">{{ format_money($transaction->total_amount) }}</span>
</div> </div>
@php @php
$invoice = $transaction->invoice;
$isPartial = $invoice && $invoice->paid_amount > 0 && $invoice->due_amount > 0;
$methodLabels = [ $methodLabels = [
'cash' => 'نقدي', 'cash' => 'نقدي',
'card' => 'بطاقة', 'card' => 'بطاقة',
...@@ -222,6 +224,20 @@ ...@@ -222,6 +224,20 @@
]; ];
$methodValue = $transaction->payment_method?->value ?? $transaction->payment_method ?? ''; $methodValue = $transaction->payment_method?->value ?? $transaction->payment_method ?? '';
@endphp @endphp
@if($isPartial)
<div class="total-row" style="color: #16a34a; margin-top: 6px;">
<span>{{ __('المدفوع') }}</span>
<span class="amount">{{ format_money($invoice->paid_amount) }}</span>
</div>
<div class="total-row" style="color: #ea580c;">
<span>{{ __('المتبقي') }}</span>
<span class="amount">{{ format_money($invoice->due_amount) }}</span>
</div>
<div class="total-row" style="margin-top: 4px;">
<span></span>
<span style="font-size: 11px; background: #fef3c7; color: #92400e; padding: 2px 8px; border-radius: 4px;">{{ __('مدفوع جزئياً') }}</span>
</div>
@endif
<div class="total-row" style="margin-top: 8px;"> <div class="total-row" style="margin-top: 8px;">
<span>{{ __('طريقة الدفع') }}</span> <span>{{ __('طريقة الدفع') }}</span>
<span class="value">{{ $methodLabels[$methodValue] ?? $methodValue }}</span> <span class="value">{{ $methodLabels[$methodValue] ?? $methodValue }}</span>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment