+ Fix bugs on currency rounding v2
This commit is contained in:
parent
21414cc8e9
commit
befa624dd4
|
@ -6,6 +6,7 @@ namespace App\Traits;
|
||||||
|
|
||||||
use App\Models\CountriesCurrency;
|
use App\Models\CountriesCurrency;
|
||||||
use App\Models\Country;
|
use App\Models\Country;
|
||||||
|
use Brick\Money\Context\AutoContext;
|
||||||
use Brick\Money\Context\CustomContext;
|
use Brick\Money\Context\CustomContext;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
@ -90,7 +91,7 @@ trait Helper
|
||||||
$converter = new CurrencyConverter($provider);
|
$converter = new CurrencyConverter($provider);
|
||||||
$init_country = Country::findOrFail($init_country);
|
$init_country = Country::findOrFail($init_country);
|
||||||
$final_country = Country::findOrFail($final_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);
|
return $converter->convert($init_money, $final_country->currency->code, RoundingMode::DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue