From 2bc30ab9e89641e60d2ffbe62f502cc283b242ef Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 7 Mar 2025 17:11:15 -0300 Subject: [PATCH] Formatear porcentajes menores a 1 --- app/src/Service/Format.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/Service/Format.php b/app/src/Service/Format.php index 69bde98..4e6d4f8 100644 --- a/app/src/Service/Format.php +++ b/app/src/Service/Format.php @@ -21,9 +21,9 @@ class Format { return number_format($number, $decimal_places, ',', '.'); } - public function percent(float|string $number, int $decimal_places = 2): string + public function percent(float|string $number, int $decimal_places = 2, bool $multiply = false): string { - return "{$this->number($number, $decimal_places)}%"; + return "{$this->number(($multiply) ? $number * 100 : $number, $decimal_places)}%"; } public function pesos(string $valor, int $decimal_places = 0): string {