XNPV.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. // result, message, rate, values, dates
  3. return [
  4. [
  5. '#VALUE!',
  6. 'If rate is not numeric, returns the #VALUE! error value',
  7. 'xyz',
  8. [0, 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000],
  9. ['2018-06-30', '2018-12-31', '2019-12-31', '2020-12-31', '2021-12-31', '2022-12-31', '2023-12-31', '2024-12-31', '2025-12-31', '2026-12-31', '2027-12-31'],
  10. ],
  11. [
  12. 1000.0,
  13. 'Okay to specify values and dates as non-array',
  14. 0.10,
  15. 1000.0,
  16. '2018-06-30',
  17. ],
  18. [
  19. '#NUM!',
  20. 'If different number of elements in values and dates, return NUM',
  21. 0.10,
  22. [1000.0, 1000.1],
  23. '2018-06-30',
  24. ],
  25. [
  26. '#NUM!',
  27. 'If minimum value > 0, return NUM',
  28. 0.10,
  29. [1000.0, 1000.1],
  30. ['2018-06-30', '2018-07-30'],
  31. ],
  32. [
  33. '#NUM!',
  34. 'If maximum value < 0, return NUM',
  35. 0.10,
  36. [-1000.0, -1000.1],
  37. ['2018-06-30', '2018-07-30'],
  38. ],
  39. [
  40. '#VALUE!',
  41. 'If any value is non-numeric, return VALUE',
  42. 0.10,
  43. [-1000.0, 1000.1, 'x'],
  44. ['2018-06-30', '2018-07-30', '2018-08-30'],
  45. ],
  46. [
  47. '#VALUE!',
  48. 'If first date is non-numeric, return VALUE',
  49. 0.10,
  50. [-1000.0, 1000.1, 1000.2],
  51. ['2018-06x30', '2018-07-30', '2018-08-30'],
  52. ],
  53. [
  54. '#VALUE!',
  55. 'If any other date is non-numeric, return VALUE',
  56. 0.10,
  57. [-1000.0, 1000.1, 1000.2],
  58. ['2018-06-30', '2018-07-30', '2018-08z30'],
  59. ],
  60. [
  61. '#NUM!',
  62. 'If any date is before first date, return NUM',
  63. 0.10,
  64. [-1000.0, 1000.1, 1000.2],
  65. ['2018-06-30', '2018-07-30', '2018-05-30'],
  66. ],
  67. [
  68. 772830.734,
  69. 'XNPV calculation #1 is incorrect',
  70. 0.10,
  71. [0, 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000],
  72. ['2018-06-30', '2018-12-31', '2019-12-31', '2020-12-31', '2021-12-31', '2022-12-31', '2023-12-31', '2024-12-31', '2025-12-31', '2026-12-31', '2027-12-31'],
  73. ],
  74. [
  75. 22.257507852701,
  76. 'Gnumeric gets this right, Excel returns #NUM, Libre returns incorrect result',
  77. -0.10,
  78. [-100.0, 110.0],
  79. ['2019-12-31', '2020-12-31'],
  80. ],
  81. ];