Fix bill payment forms to use major currency units.
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:
isaacclad
2026-07-18 23:30:31 +00:00
co-authored by Cursor
parent a34d6579cd
commit e69c7da0d6
4 changed files with 38 additions and 16 deletions
+15 -8
View File
@@ -226,15 +226,20 @@ class BillController extends Controller
$manualMethods = array_keys(collect(config('care.payment_methods', []))->except(['gateway'])->all());
$validated = $request->validate([
'amount' => ['required', 'numeric', 'min:0.01'],
'method' => ['required', 'string', 'in:'.implode(',', $manualMethods)],
'reference' => ['nullable', 'string', 'max:100'],
'notes' => ['nullable', 'string', 'max:500'],
]);
$validated['amount_minor'] = max(1, (int) round(((float) $validated['amount']) * 100));
unset($validated['amount']);
$this->bills->recordPayment(
$bill,
$this->ownerRef($request),
$request->validate([
'amount_minor' => ['required', 'integer', 'min:1'],
'method' => ['required', 'string', 'in:'.implode(',', $manualMethods)],
'reference' => ['nullable', 'string', 'max:100'],
'notes' => ['nullable', 'string', 'max:500'],
]),
$validated,
$this->ownerRef($request),
);
@@ -247,10 +252,12 @@ class BillController extends Controller
$this->authorizeBill($request, $bill);
$validated = $request->validate([
'amount_minor' => ['nullable', 'integer', 'min:1'],
'amount' => ['nullable', 'numeric', 'min:0.01'],
]);
$amount = (int) ($validated['amount_minor'] ?? $bill->balance_minor);
$amount = isset($validated['amount'])
? max(1, (int) round(((float) $validated['amount']) * 100))
: (int) $bill->balance_minor;
try {
$result = $this->bills->startGatewayPayment(