Skip to content

Commit

Permalink
Merge pull request #21 from kellerkinderDE/feature/KLARNASUPPORT-551
Browse files Browse the repository at this point in the history
[KLARNASUPPORT-551] Fix compatibility to PHP 8.0
  • Loading branch information
Jan-Erik Spreng authored Apr 5, 2022
2 parents 132542a + 9a86daa commit 43cdeed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
### Fixed
- Fixed a missing auth header during customer token generation
- Fixed the config reader to return the correct value when falsy values are configured (e.g. 0, 'false')
- Fixed compatibility to PHP 8.0
### Added
- Allowed manual and individual adding of positions which are not related to an article

Expand Down
10 changes: 7 additions & 3 deletions src/Components/Transformer/LineItemTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,14 @@ public function createShippingLineItem($shippingCostsWithTax, $shippingCostsNet,
*/
public function getUnitPriceWithTax(array $lineItem): float
{
$netPriceIsShown = isset($lineItem['amountWithTax']) ? true : false;
$netPrice = $lineItem['amountWithTax'] ?? null;

if ($netPriceIsShown) {
return round(str_replace(',', '.', $lineItem['amountWithTax']) / $lineItem['quantity'], 2);
if ($netPrice !== null) {
if (is_string($netPrice)) {
$netPrice = (float) str_replace(',', '.', $lineItem['amountWithTax']);
}

return round($netPrice / $lineItem['quantity'], 2);
}

return (float) $lineItem['priceNumeric'];
Expand Down

0 comments on commit 43cdeed

Please sign in to comment.