### Description

The NPV/IRR calculations in demands are not working properly.

Steps to reproduce:

Create new demand

create demand budget

create cost and benefit plans

set the discount % value

no calculations are done

NPV and IRR fields are not populated

### Cause

Conditions for populating NPV and IRR need to be met..

A cost plan for a fiscal year must exist to calculate NPV.

IRR is the discount rate that would cause the net present value (NPV) of a project to be 0.

So, in order to calculate IRR we need to have Cash flow values with at least one positive value and one negative value.

Cash flow from a cost plan is considered a negative value and cash flow from a benefit plan is considered as a positive value.

If, at least, one positive and one negative value exists, then calculate IRR

### Resolution

For NPV to be populated, the following condition must be met:

A cost plan must be created that spans a fiscal year.

For IRR to be populated, the following conditions must be met:

1. Cost plan and/or benefit plan records should be present for at least two Fiscal years

2. There should be at least one fiscal year with positive value(Sum of benefit plan breakdown values for the fiscal period is greater than sum of cost plan breakdown values)

3. There should be at least one fiscal year with negative value (Sum of cost plan breakdown values for the fiscal period is greater than sum of benefit plan breakdown values)

The logic for the above is implemented in the Script Include - IRRAndNPVAPI:

https://coviacorpdev.service-now.com/nav_to.do?uri=sys_script_include.do?sys_id=c8fa147f0b372200a6acc93563673a40

For example:

Create a Demand

Navigate to Related List : Benefit Plans

Create one Benefit Plan

- Create a new Benefit Plan ( Fiscal Year FY20: M01-Jan to FY20: M01-Dec, set 'entered benefit' to 2000)

Navigate to Related List : Cost Plans

Create two Cost Plans:

- Fiscal Year FY20: M01-Jan to FY20: M01-Dec (ensure Total Planned Cost is 0 by setting unit cost to 0 on the cost plan)
- Fiscal Year FY21: M01-Jan to FY21: M01-Dec (ensure Total Planned Cost 1000 e.g set unit cost to 100 and quantity to 10 on the cost plan)

NPV and IRR will be populated.

Please note for better user experience, if the IRR calculation could not be done, a message is displayed:

-------------

Unable to calculate IRR

----------------

Also, please note that Internal Rate of Return does not calculate if financial return value greater than 100,000

PRB1322063 exists for this and has been closed as 'Working as expected' with the following reason:

----------------------------

The current support maximum IRR percentage is 1000. There are performance reasons not to support IRR more than 1000% , as response time of the form on change of planned_cost, planned_benefit or discount rates will increase exponentially. It will also effect all cost rollup scenario.

....

------------------------