mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-12 14:12:44 +01:00
Improve quantity resolution
This commit is contained in:
parent
15a9e55fc7
commit
980fcb789f
@ -65,6 +65,8 @@ class Number
|
||||
$decimal = $currency->decimal_separator;
|
||||
$precision = $currency->precision;
|
||||
|
||||
$precision = 10;
|
||||
|
||||
return rtrim(rtrim(number_format($value, $precision, $decimal, $thousand), "0"),$decimal);
|
||||
}
|
||||
|
||||
|
@ -78,4 +78,67 @@ class NumberTest extends TestCase
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
public function testRoundingDecimalsTwo()
|
||||
{
|
||||
$currency = Currency::find(1);
|
||||
|
||||
$x = Number::formatValueNoTrailingZeroes(0.05, $currency);
|
||||
|
||||
$this->assertEquals(0.05, $x);
|
||||
}
|
||||
|
||||
public function testRoundingDecimalsThree()
|
||||
{
|
||||
$currency = Currency::find(1);
|
||||
|
||||
$x = Number::formatValueNoTrailingZeroes(0.005, $currency);
|
||||
|
||||
$this->assertEquals(0.005, $x);
|
||||
}
|
||||
|
||||
public function testRoundingDecimalsFour()
|
||||
{
|
||||
$currency = Currency::find(1);
|
||||
|
||||
$x = Number::formatValueNoTrailingZeroes(0.0005, $currency);
|
||||
|
||||
$this->assertEquals(0.0005, $x);
|
||||
}
|
||||
|
||||
public function testRoundingDecimalsFive()
|
||||
{
|
||||
$currency = Currency::find(1);
|
||||
|
||||
$x = Number::formatValueNoTrailingZeroes(0.00005, $currency);
|
||||
|
||||
$this->assertEquals(0.00005, $x);
|
||||
}
|
||||
|
||||
public function testRoundingDecimalsSix()
|
||||
{
|
||||
$currency = Currency::find(1);
|
||||
|
||||
$x = Number::formatValueNoTrailingZeroes(0.000005, $currency);
|
||||
|
||||
$this->assertEquals(0.000005, $x);
|
||||
}
|
||||
|
||||
public function testRoundingDecimalsSeven()
|
||||
{
|
||||
$currency = Currency::find(1);
|
||||
|
||||
$x = Number::formatValueNoTrailingZeroes(0.0000005, $currency);
|
||||
|
||||
$this->assertEquals(0.0000005, $x);
|
||||
}
|
||||
|
||||
public function testRoundingDecimalsEight()
|
||||
{
|
||||
$currency = Currency::find(1);
|
||||
|
||||
$x = Number::formatValueNoTrailingZeroes(0.00000005, $currency);
|
||||
|
||||
$this->assertEquals(0.00000005, $x);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user