Skip to content

Commit

Permalink
Fix on 'price' DataFormatterHelper to use currency code (ISO 4217)
Browse files Browse the repository at this point in the history
  • Loading branch information
daverner committed Jan 13, 2022
1 parent 430a350 commit 8eb2dfd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Services/DataFormatterHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ public function format($data, string $format, $pattern = null): string

return number_format((float)$number, 2, ",", " ");
case "price":
$number = $this->format($data, "amount");
// $pattern should contains currency code according to ISO 4217
$pattern = $pattern ?: "EUR";

return "$number";
$numberFormatter = new \NumberFormatter(locale_get_default(), \NumberFormatter::CURRENCY);
return $numberFormatter->formatCurrency((float)$data, $pattern);
case "french_date":
$pattern = is_null($pattern) ? 'l d F à H:i' : $pattern;
$data = $this->toDateTime($data);
Expand Down

0 comments on commit 8eb2dfd

Please # to comment.