diff --git a/src/NetPresentValue.hs b/src/NetPresentValue.hs index 5e8b32b4dd231f42d26b3329418c5171fe241318..c8469dad958a002cb9110aa64ef6918a40212627 100644 --- a/src/NetPresentValue.hs +++ b/src/NetPresentValue.hs @@ -32,9 +32,16 @@ netPresentValue inputNetPresentValue = foldl (+) 0 pv where pv = presentValue inputNetPresentValue -presentValue inputNetPresentValue = zipWith (*) (netcashflow income outcome) [0.833, 0.694, 0.579, 0.482, 0.402] +presentValue inputNetPresentValue = zipWith (*) (netcashflow income outcome) (factorpresentvalue (project_interest inputNetPresentValue)) where income = [income_1 inputNetPresentValue, income_2 inputNetPresentValue, income_3 inputNetPresentValue, income_4 inputNetPresentValue, income_5 inputNetPresentValue] outcome = [outcome_1 inputNetPresentValue, outcome_2 inputNetPresentValue, outcome_3 inputNetPresentValue, outcome_4 inputNetPresentValue, outcome_5 inputNetPresentValue] netcashflow a b = zipWith (-) a b + +power n 1 = n +power n m = n * (power n (m-1)) + +powervalue interest n = 1 / (power (1 + interest) n) + +factorpresentvalue interest = map (\x -> powervalue interest x) [1..5]