From 21414cc8e9c42a2c2a880eb7d75dfae2f481f1a7 Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Thu, 25 Jun 2020 20:01:49 +0100 Subject: [PATCH] + Fix bugs on currency rounding --- app/Http/Controllers/iLinkTransactionController.php | 2 +- app/Traits/Helper.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/iLinkTransactionController.php b/app/Http/Controllers/iLinkTransactionController.php index 203938d..c3aadd7 100755 --- a/app/Http/Controllers/iLinkTransactionController.php +++ b/app/Http/Controllers/iLinkTransactionController.php @@ -649,7 +649,7 @@ class iLinkTransactionController extends Controller $data['destinataire'] = $destinataire ? $destinataire->lastname . ' ' . $destinataire->firstname : $request->id_destinataire; $data['frais'] = $frais + $taxe; $data['montant_net_init'] = $request->montant - $frais - $taxe; - $data['montant_net_final'] = $this->toMoneyWithCurrency($request->montant - $frais - $taxe, $init_country ,$request->final_country ); + $data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country ,$request->final_country ); return $this->successResponse($data); break; case 2: //User - Envoi de wallet à carte diff --git a/app/Traits/Helper.php b/app/Traits/Helper.php index b6e7625..b4a2083 100644 --- a/app/Traits/Helper.php +++ b/app/Traits/Helper.php @@ -90,7 +90,7 @@ trait Helper $converter = new CurrencyConverter($provider); $init_country = Country::findOrFail($init_country); $final_country = Country::findOrFail($final_country); - $init_money = Money::of(round($amount, 2),$init_country->currency->code,new CustomContext(2)); + $init_money = Money::of(round(str_replace(',' , '',number_format($amount,2)), 2),$init_country->currency->code,new CustomContext(2)); return $converter->convert($init_money, $final_country->currency->code, RoundingMode::DOWN); }