diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php index 5a908aa513..728167f426 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -2037,7 +2037,7 @@ public static function TBILLEQ($settlement, $maturity, $discount) return Functions::VALUE(); } - if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) { + if (Functions::getCompatibilityMode() === Functions::COMPATIBILITY_OPENOFFICE) { ++$maturity; $daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity) * 360; } else { @@ -2076,7 +2076,7 @@ public static function TBILLPRICE($settlement, $maturity, $discount) return Functions::NAN(); } - if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) { + if (Functions::getCompatibilityMode() === Functions::COMPATIBILITY_OPENOFFICE) { ++$maturity; $daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity) * 360; if (!is_numeric($daysBetweenSettlementAndMaturity)) { @@ -2087,7 +2087,7 @@ public static function TBILLPRICE($settlement, $maturity, $discount) $daysBetweenSettlementAndMaturity = (DateTime::getDateValue($maturity) - DateTime::getDateValue($settlement)); } - if ($daysBetweenSettlementAndMaturity > 360) { + if ($daysBetweenSettlementAndMaturity > self::daysPerYear(DateTime::YEAR($maturity), 1)) { return Functions::NAN(); } diff --git a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php index e80ef35b66..d6135a466d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php @@ -13,134 +13,6 @@ protected function setUp(): void Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } - /** - * @dataProvider providerAMORDEGRC - * - * @param mixed $expectedResult - */ - public function testAMORDEGRC($expectedResult, ...$args): void - { - $result = Financial::AMORDEGRC(...$args); - self::assertEqualsWithDelta($expectedResult, $result, 1E-8); - } - - public function providerAMORDEGRC() - { - return require 'tests/data/Calculation/Financial/AMORDEGRC.php'; - } - - /** - * @dataProvider providerAMORLINC - * - * @param mixed $expectedResult - */ - public function testAMORLINC($expectedResult, ...$args): void - { - $result = Financial::AMORLINC(...$args); - self::assertEqualsWithDelta($expectedResult, $result, 1E-8); - } - - public function providerAMORLINC() - { - return require 'tests/data/Calculation/Financial/AMORLINC.php'; - } - - /** - * @dataProvider providerCOUPDAYBS - * - * @param mixed $expectedResult - */ - public function testCOUPDAYBS($expectedResult, ...$args): void - { - $result = Financial::COUPDAYBS(...$args); - self::assertEqualsWithDelta($expectedResult, $result, 1E-8); - } - - public function providerCOUPDAYBS() - { - return require 'tests/data/Calculation/Financial/COUPDAYBS.php'; - } - - /** - * @dataProvider providerCOUPDAYS - * - * @param mixed $expectedResult - */ - public function testCOUPDAYS($expectedResult, ...$args): void - { - $result = Financial::COUPDAYS(...$args); - self::assertEqualsWithDelta($expectedResult, $result, 1E-8); - } - - public function providerCOUPDAYS() - { - return require 'tests/data/Calculation/Financial/COUPDAYS.php'; - } - - /** - * @dataProvider providerCOUPDAYSNC - * - * @param mixed $expectedResult - */ - public function testCOUPDAYSNC($expectedResult, ...$args): void - { - $result = Financial::COUPDAYSNC(...$args); - self::assertEqualsWithDelta($expectedResult, $result, 1E-8); - } - - public function providerCOUPDAYSNC() - { - return require 'tests/data/Calculation/Financial/COUPDAYSNC.php'; - } - - /** - * @dataProvider providerCOUPNCD - * - * @param mixed $expectedResult - */ - public function testCOUPNCD($expectedResult, ...$args): void - { - $result = Financial::COUPNCD(...$args); - self::assertEqualsWithDelta($expectedResult, $result, 1E-8); - } - - public function providerCOUPNCD() - { - return require 'tests/data/Calculation/Financial/COUPNCD.php'; - } - - /** - * @dataProvider providerCOUPNUM - * - * @param mixed $expectedResult - */ - public function testCOUPNUM($expectedResult, ...$args): void - { - $result = Financial::COUPNUM(...$args); - self::assertEqualsWithDelta($expectedResult, $result, 1E-8); - } - - public function providerCOUPNUM() - { - return require 'tests/data/Calculation/Financial/COUPNUM.php'; - } - - /** - * @dataProvider providerCOUPPCD - * - * @param mixed $expectedResult - */ - public function testCOUPPCD($expectedResult, ...$args): void - { - $result = Financial::COUPPCD(...$args); - self::assertEqualsWithDelta($expectedResult, $result, 1E-8); - } - - public function providerCOUPPCD() - { - return require 'tests/data/Calculation/Financial/COUPPCD.php'; - } - /** * @dataProvider providerCUMIPMT * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AmorDegRcTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AmorDegRcTest.php new file mode 100644 index 0000000000..5d0cb8efba --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AmorDegRcTest.php @@ -0,0 +1,31 @@ +