From 1212ec37b8997002e1ac3c65aac0f5341eecfdf6 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 6 Dec 2023 13:37:45 +0800 Subject: [PATCH] Fix a decimal problem reported by kexin --- .../Vouchers/ControllersLogic/ValidateVoucherLogic.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/Vouchers/ControllersLogic/ValidateVoucherLogic.php b/app/Classes/Modules/Vouchers/ControllersLogic/ValidateVoucherLogic.php index 4b820eb1..30e7fe12 100644 --- a/app/Classes/Modules/Vouchers/ControllersLogic/ValidateVoucherLogic.php +++ b/app/Classes/Modules/Vouchers/ControllersLogic/ValidateVoucherLogic.php @@ -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); + } }