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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user