Skip to content

Commit

Permalink
Merge pull request #132 from white-lukas/bugfix/131-amount-typecase
Browse files Browse the repository at this point in the history
cast to float instead of int
  • Loading branch information
engram-design authored Jul 24, 2024
2 parents d460758 + 8637c68 commit 7789fcc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/CodesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7789fcc

Please sign in to comment.