From e18f6c476fddfad3ac7ae7836aae9103927bf823 Mon Sep 17 00:00:00 2001 From: Evan Knapke Date: Tue, 10 May 2022 13:35:20 -0400 Subject: [PATCH] Remove incorrect checks for PMT and FV calculations --- src/ExcelFinancialFunctions/testpreconditions.fs | 4 +--- src/ExcelFinancialFunctions/tvm.fs | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/ExcelFinancialFunctions/testpreconditions.fs b/src/ExcelFinancialFunctions/testpreconditions.fs index 2ede03b..5004aa4 100644 --- a/src/ExcelFinancialFunctions/testpreconditions.fs +++ b/src/ExcelFinancialFunctions/testpreconditions.fs @@ -18,12 +18,10 @@ module internal TestPreconditions = ( pmt <> 0. || fv <> 0. ) let tryFv r nper pmt pv pd = ( raisable r nper) && - ( r <> -1. || (r = -1. && nper > 0.) ) && - ( pmt <> 0. || pv <> 0. ) + ( r <> -1. || (r = -1. && nper > 0.) ) let tryPmt r nper pv fv pd = ( raisable r nper) && ( r > -1. ) && - ( fv <> 0. || pv <> 0. ) && ( annuityCertainPvFactor r nper pd <> 0. ) let tryNper r pmt pv fv pd = ( r > -1.) && diff --git a/src/ExcelFinancialFunctions/tvm.fs b/src/ExcelFinancialFunctions/tvm.fs index 60275d8..39c1f98 100644 --- a/src/ExcelFinancialFunctions/tvm.fs +++ b/src/ExcelFinancialFunctions/tvm.fs @@ -28,13 +28,11 @@ module internal Tvm = let calcFv r nper pmt pv pd = ( raisable r nper) |> elseThrow "r is not raisable to nper (r is negative and nper not an integer" ( r <> -1. || (r = -1. && nper > 0.) ) |> elseThrow "r cannot be -100% when nper is <= 0" - ( pmt <> 0. || pv <> 0. ) |> elseThrow "pmt or pv need to be different from 0" if r = -1. && pd = PaymentDue.BeginningOfPeriod then - (pv * fvFactor r nper) elif r = -1. && pd = PaymentDue.EndOfPeriod then - (pv * fvFactor r nper + pmt) else fv r nper pmt pv pd let calcPmt r nper pv fv pd = ( raisable r nper) |> elseThrow "r is not raisable to nper (r is negative and nper not an integer" - ( fv <> 0. || pv <> 0. ) |> elseThrow "fv or pv need to be different from 0" ( r <> -1. || (r = -1. && nper > 0. && pd = PaymentDue.EndOfPeriod) ) |> elseThrow "r cannot be -100% when nper is <= 0" ( annuityCertainPvFactor r nper pd <> 0. ) |> elseThrow "1 * pd + 1 - (1 / (1 + r)^nper) / nper has to be <> 0" if r = -1. then -fv