Fix a decimal problem reported by kexin

This commit is contained in:
Dillon Ngo
2023-12-06 13:37:45 +08:00
parent c7c7ee8c0c
commit 1212ec37b8
@@ -44,10 +44,16 @@ class ValidateVoucherLogic extends AbstractControllerLogic
{
$booking = Booking::find($request->input('itemId'));
$employee = $booking->company->employees()->first();
$amount = $this->floatvalue($request->input('amount'));
$validateVoucherifyVoucherObject = new ValidateVoucherifyVoucherObject($booking->company_id, $request->input('voucherCode'), $request->input('amount'), $employee);
$validateVoucherifyVoucherObject = new ValidateVoucherifyVoucherObject($booking->company_id, $request->input('voucherCode'), $amount, $employee);
$result = $this->validatesVoucherifyVoucher->execute($validateVoucherifyVoucherObject);
return $this->response(['data' => $result]);
}
private function floatvalue($val){
$val = str_replace(",",".",$val);
$val = preg_replace('/\.(?=.*\.)/', '', $val);
return floatval($val);
}
}