Closed chard1988 closed 1 year ago
I used this package for a project and noticed that the converted amount is being rounded up.
`function monetize($amount) {
// Get current location $ip = request()->ip(); $geoData = geoip($ip); // Get currency symbol $dbCurrency = Currency::where('code', $geoData['currency'])->first(); // Strip "," symbol $stripped = str_replace(',', '', number_format($amount/100, 2)); if ($amount != 0) { $retval = CurrencyConverter::convert() ->from('PHP') ->to($geoData['currency']) ->amount($stripped) ->round(2) ->get(); } else { $retval = number_format($amount/100, 2); } $retval = $dbCurrency->symbol . ' ' . $retval; $decimal = substr($retval, strpos($retval, '.') + 1); $cur = strtok($retval, '.'); return __(':cur<small>.:decimal</small>', ['cur' => $cur, 'decimal' => $decimal]); }`
is there any way to prevent this from happening?
Kind regards,
Remove the ->round(2) from your call
->round(2)
I used this package for a project and noticed that the converted amount is being rounded up.
`function monetize($amount) {
is there any way to prevent this from happening?
Kind regards,