Skip to content

Commit f2dcb16

Browse files
author
MarkBaker
committed
Text function array value tests, plus some cleanup
1 parent 5ab3cbc commit f2dcb16

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
4949

5050
### Fixed
5151

52+
- Fix bug with `DOLLARDE()` and `DOLLARFR()` functions when the dollar value is negative [Issue #2578](https://github.com/PHPOffice/PhpSpreadsheet/issues/2578) [PR #]()
5253
- Fix partial function name matching when translating formulae from Russian to English [Issue #2533](https://github.com/PHPOffice/PhpSpreadsheet/issues/2533) [PR #2534](https://github.com/PHPOffice/PhpSpreadsheet/pull/2534)
5354
- Various bugs related to Conditional Formatting Rules, and errors in the Xlsx Writer for Conditional Formatting [PR #2491](https://github.com/PHPOffice/PhpSpreadsheet/pull/2491)
5455
- Xlsx Reader merge range fixes.

src/PhpSpreadsheet/Calculation/Financial/Dollar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static function decimal($fractionalDollar = null, $fraction = 0)
5151
return Functions::DIV0();
5252
}
5353

54-
$dollars = floor($fractionalDollar);
54+
$dollars = ($fractionalDollar < 0.0) ? ceil($fractionalDollar) : floor($fractionalDollar);
5555
$cents = fmod($fractionalDollar, 1);
5656
$cents /= $fraction;
5757
$cents *= 10 ** ceil(log10($fraction));
@@ -87,7 +87,7 @@ public static function fractional($decimalDollar = null, $fraction = 0)
8787
return Functions::DIV0();
8888
}
8989

90-
$dollars = floor($decimalDollar);
90+
$dollars = ($decimalDollar < 0.0) ? ceil($decimalDollar) : floor($decimalDollar);
9191
$cents = fmod($decimalDollar, 1);
9292
$cents *= $fraction;
9393
$cents *= 10 ** (-ceil(log10($fraction)));

tests/data/Calculation/Financial/DOLLARDE.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
// fractional_dollar, fraction, result
44

55
return [
6+
[
7+
2.5,
8+
1.6,
9+
4,
10+
],
11+
[
12+
-2.5,
13+
-1.6,
14+
4,
15+
],
616
[
717
1.125,
818
1.02,

tests/data/Calculation/Financial/DOLLARFR.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
// decimal_dollar, fraction, result
44

55
return [
6+
[
7+
1.24,
8+
1.6,
9+
4,
10+
],
11+
[
12+
-1.24,
13+
-1.6,
14+
4,
15+
],
616
[
717
1.02,
818
1.125,

0 commit comments

Comments
 (0)