+ Fix bugs on currency rounding v2

This commit is contained in:
Djery-Tom 2020-06-25 20:06:43 +01:00
parent 21414cc8e9
commit befa624dd4
1 changed files with 2 additions and 1 deletions

View File

@ -6,6 +6,7 @@ namespace App\Traits;
use App\Models\CountriesCurrency;
use App\Models\Country;
use Brick\Money\Context\AutoContext;
use Brick\Money\Context\CustomContext;
use DateTime;
use Illuminate\Support\Facades\Mail;
@ -90,7 +91,7 @@ trait Helper
$converter = new CurrencyConverter($provider);
$init_country = Country::findOrFail($init_country);
$final_country = Country::findOrFail($final_country);
$init_money = Money::of(round(str_replace(',' , '',number_format($amount,2)), 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 AutoContext());
return $converter->convert($init_money, $final_country->currency->code, RoundingMode::DOWN);
}