Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Financial::COUPNCD and Google Tables different results #2116

Closed
ElShapovalov opened this issue May 25, 2021 · 1 comment
Closed

Financial::COUPNCD and Google Tables different results #2116

ElShapovalov opened this issue May 25, 2021 · 1 comment

Comments

@ElShapovalov
Copy link

cpnNextAt = 30.09.2021
maturityAt = 31.03.2022
cpnFreq = 2
dayCntDes = 0

Financial::COUPNCD = 30.09.2021
Google Tables = 31.03.2022

@oleibman
Copy link
Collaborator

Problem is caused because code subtracts 6 months from a PHP DateTime, say, 2022-03-31, which results in 2021-10-01 rather than 2021-09-30. Fixing that is a little messy, but doable, but then there are all sorts of regression possibilities. I am looking into it.

oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue May 26, 2021
See issue PHPOffice#2116. Code for handling end of month (method couponFirstPeriodDate) needed a fix. Fixed it, confirmed it covered the reported issue with no regression problems. Then added some extra similar tests to all the callers of couponFirstPeriodDate, and ...

One new test, in COUPDAYSNC, does not agree with Excel. It also does not agree with LibreOffice. It does, however, agree with Gnumeric, and with my (hardly guaranteed) hand calculation of what the result should be. So, I'm going with it (and have added an appropriate comment to the test data). I'm glad to discuss the matter with anyone more familiar than I with how this is supposed to work - those 360-day years are killers.
@oleibman oleibman mentioned this issue May 26, 2021
5 tasks
MarkBaker pushed a commit that referenced this issue May 29, 2021
See issue #2116. Code for handling end of month (method couponFirstPeriodDate) needed a fix. Fixed it, confirmed it covered the reported issue with no regression problems. Then added some extra similar tests to all the callers of couponFirstPeriodDate, and ...

One new test, in COUPDAYSNC, does not agree with Excel. It also does not agree with LibreOffice. It does, however, agree with Gnumeric, and with my (hardly guaranteed) hand calculation of what the result should be. So, I'm going with it (and have added an appropriate comment to the test data). I'm glad to discuss the matter with anyone more familiar than I with how this is supposed to work - those 360-day years are killers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants