From 8637c68a94d32780f9344d4c03ab0447e72049b4 Mon Sep 17 00:00:00 2001 From: white-lukas Date: Wed, 24 Jul 2024 10:54:41 +0200 Subject: [PATCH] cast to float instead of int --- CHANGELOG.md | 6 ++++++ src/controllers/CodesController.php | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3942b2..3e4e741 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixed + +- Fixed saving a code with a decimal value being cast to an int ([#131](https://github.com/verbb/gift-voucher/issues/131)) + ## 4.0.2 - 2024-07-21 ### Fixed diff --git a/src/controllers/CodesController.php b/src/controllers/CodesController.php index ce21aae..c2f3d1d 100755 --- a/src/controllers/CodesController.php +++ b/src/controllers/CodesController.php @@ -110,8 +110,8 @@ public function actionSave(): ?Response $code->id = (int)$this->request->getBodyParam('codeId'); $code->enabled = (bool)$this->request->getBodyParam('enabled'); - $code->originalAmount = $this->request->getBodyParam('originalAmount'); - $code->currentAmount = (int)$this->request->getBodyParam('currentAmount'); + $code->originalAmount = (float)$this->request->getBodyParam('originalAmount'); + $code->currentAmount = (float)$this->request->getBodyParam('currentAmount'); $code->expiryDate = (($date = $this->request->getParam('expiryDate')) !== false ? (DateTimeHelper::toDateTime($date) ?: null) : $code->expiryDate); if (!$code->originalAmount) {