Add HUF as non-decimal currency (#974)

- Fixes #973.
This commit is contained in:
Jay
2017-11-06 11:49:36 -06:00
committed by GitHub
parent 0303e2c0c9
commit 26dadbf879
2 changed files with 4 additions and 3 deletions

View File

@@ -46,10 +46,10 @@ class FormatConverter
public static function formatToPrice($value, $currency = null)
{
$decimals = 2;
$currencyDecimals = array('JPY' => 0, 'TWD' => 0);
$currencyDecimals = array('JPY' => 0, 'TWD' => 0, 'HUF' => 0);
if ($currency && array_key_exists($currency, $currencyDecimals)) {
if (strpos($value, ".") !== false && (floor($value) != $value)) {
//throw exception if it has decimal values for JPY and TWD which does not ends with .00
//throw exception if it has decimal values for JPY, TWD and HUF which does not ends with .00
throw new \InvalidArgumentException("value cannot have decimals for $currency currency");
}
$decimals = $currencyDecimals[$currency];

View File

@@ -38,7 +38,8 @@ class FormatConverterTest extends \PHPUnit_Framework_TestCase
{
return array(
array('JPY'),
array('TWD')
array('TWD'),
array('HUF')
);
}