Skip to content

Commit

Permalink
* Agrego la posibilidad de sacar la moneda
Browse files Browse the repository at this point in the history
 * Agrego un test para probar si la moneda se incluye
  • Loading branch information
enfoqueNativo committed Sep 5, 2016
1 parent 9770000 commit 44d365a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Numbers/Words.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function toAccountable($num, $locale = 'en_US', $intCurr = '', $decimalPoint = n
$num = $obj->normalizeNumber($num, $decimalPoint);

if (strpos($num, $decimalPoint) === false) {
return trim($obj->toAccountableWords($intCurr, $num));
return trim($obj->toAccountableWords($intCurr, $num, false, false, ($intCurr == '')));
}

$currency = explode($decimalPoint, $num, 2);
Expand Down Expand Up @@ -296,7 +296,7 @@ function toAccountable($num, $locale = 'en_US', $intCurr = '', $decimalPoint = n
}
}

return trim($obj->toAccountableWords($intCurr, $currency[0], $currency[1], false));
return trim($obj->toAccountableWords($intCurr, $currency[0], $currency[1], false, ($intCurr == '')));
}
// }}}

Expand Down
24 changes: 21 additions & 3 deletions tests/SpanishArTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,26 @@ function testThousands()

function testDecimal()
{
$thousands = array('1000.1' => 'Pesos mil con 10/100',
'1001.25' => 'Pesos mil uno con 25/100',
$thousands = array('1000.1' => 'mil con 10/100',
'1001.25' => 'mil uno con 25/100',
'1097.34' => 'mil noventa y siete con 34/100',
'1104.74' => 'mil ciento cuatro con 74/100',
'1243.78' => 'mil doscientos cuarenta y tres con 78/100',
'2385.46' => 'dos mil trescientos ochenta y cinco con 46/100',
'3766.66' => 'tres mil setecientos sesenta y seis con 66/100',
'4196.13' => 'cuatro mil ciento noventa y seis con 13/100',
'5846.14' => 'cinco mil ochocientos cuarenta y seis con 14/100',
'6459.0' => 'seis mil cuatrocientos cincuenta y nueve con 00/100',
);
foreach ($thousands as $number => $word) {
$this->assertEquals($word, $this->handle->toAccountable($number, 'es_AR'));
}
}

function testDecimalCurrency()
{
$thousands = array('1000.01' => 'Pesos mil con 01/100',
'1001.2' => 'Pesos mil uno con 20/100',
'1097.34' => 'Pesos mil noventa y siete con 34/100',
'1104.74' => 'Pesos mil ciento cuatro con 74/100',
'1243.78' => 'Pesos mil doscientos cuarenta y tres con 78/100',
Expand All @@ -146,7 +164,7 @@ function testDecimal()
'6459.0' => 'Pesos seis mil cuatrocientos cincuenta y nueve con 00/100',
);
foreach ($thousands as $number => $word) {
$this->assertEquals($word, $this->handle->toAccountable($number, 'es_AR'));
$this->assertEquals($word, $this->handle->toAccountable($number, 'es_AR', 'ARS'));
}
}
}

0 comments on commit 44d365a

Please sign in to comment.