Fix bill payment forms to use major currency units.
Deploy Ladill Care / deploy (push) Successful in 56s
Deploy Ladill Care / deploy (push) Successful in 56s
Cashiers saw pesewa integers (e.g. 4000) while history showed GHS 40.00; accept and prefill major amounts and convert to minor on record/checkout. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -78,11 +78,18 @@
|
||||
@endif
|
||||
|
||||
@if ($canPay && $bill->balance_minor > 0 && $bill->status !== \App\Models\Bill::STATUS_VOID)
|
||||
@php
|
||||
$balanceMajor = number_format($bill->balance_minor / 100, 2, '.', '');
|
||||
$currency = config('care.billing.currency');
|
||||
@endphp
|
||||
<section class="rounded-2xl border border-slate-200 bg-white p-6">
|
||||
<h2 class="text-sm font-semibold uppercase text-slate-500">Record payment</h2>
|
||||
<form method="POST" action="{{ route('care.bills.payments.store', $bill) }}" class="mt-4 space-y-3">
|
||||
@csrf
|
||||
<input type="number" name="amount_minor" value="{{ $bill->balance_minor }}" min="1" required class="w-full rounded-lg border-slate-300 text-sm">
|
||||
<label class="block text-sm text-slate-600">
|
||||
Amount ({{ $currency }})
|
||||
<input type="number" name="amount" value="{{ old('amount', $balanceMajor) }}" min="0.01" step="0.01" max="{{ $balanceMajor }}" required class="mt-1 w-full rounded-lg border-slate-300 text-sm tabular-nums">
|
||||
</label>
|
||||
<select name="method" class="w-full rounded-lg border-slate-300 text-sm">@foreach ($manualPaymentMethods as $k => $v)<option value="{{ $k }}">{{ $v }}</option>@endforeach</select>
|
||||
<input type="text" name="reference" placeholder="Reference" class="w-full rounded-lg border-slate-300 text-sm">
|
||||
<button type="submit" class="btn-primary w-full">Record payment</button>
|
||||
@@ -101,7 +108,10 @@
|
||||
@if ($gatewayConfigured)
|
||||
<form method="POST" action="{{ route('care.bills.payments.gateway', $bill) }}" class="mt-4 space-y-3">
|
||||
@csrf
|
||||
<input type="number" name="amount_minor" value="{{ $bill->balance_minor }}" min="1" max="{{ $bill->balance_minor }}" required class="w-full rounded-lg border-slate-300 text-sm" aria-label="Amount (minor units)">
|
||||
<label class="block text-sm text-slate-600">
|
||||
Amount ({{ $currency }})
|
||||
<input type="number" name="amount" value="{{ old('amount', $balanceMajor) }}" min="0.01" step="0.01" max="{{ $balanceMajor }}" required class="mt-1 w-full rounded-lg border-slate-300 text-sm tabular-nums" aria-label="Amount ({{ $currency }})">
|
||||
</label>
|
||||
<button type="submit" class="btn-primary w-full">Open checkout</button>
|
||||
</form>
|
||||
@else
|
||||
|
||||
Reference in New Issue
Block a user