Index: openacs-4/packages/accounts-finance/tcl/finance-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/accounts-finance/tcl/finance-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/accounts-finance/tcl/finance-procs.tcl 21 May 2010 23:36:33 -0000 1.3 +++ openacs-4/packages/accounts-finance/tcl/finance-procs.tcl 22 May 2010 00:17:17 -0000 1.4 @@ -233,15 +233,17 @@ } ad_proc -private acc_fin::qaf_mirr { - net_period_list + period_cf_list finance_rate re_invest_rate {intervals_per_year 1} } { Returns a Modified Internal Rate of Return } { + # see http://en.wikipedia.org/wiki/Modified_internal_rate_of_return # create separate positive and negative cashflows from list - set period_count [llength $net_period_list] + + set period_count [llength $period_cf_list] foreach period_cf $period_cf_list { if { $period_cf > 0 } { lappend positive_cf_list $period_cf @@ -253,6 +255,6 @@ } set pv [acc_fin::qaf_npv $negative_cf_list [list $finance_rate] $intervals_per_year] set fv [acc_fin::qaf_fvsimple $positive_cf_list $re_invest_rate $intervals_per_year] - set mirr [expr { pow( -1. * $fv / double( $pv ), 1. / double( $period_count ) ) - 1. } ] + set mirr [expr { pow( ( -1. * $fv ) / double( $pv ), 1. / ( double( $period_count ) -1. ) ) - 1. } ] return $mirr } Index: openacs-4/packages/accounts-finance/tcl/test/finance-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/accounts-finance/tcl/test/finance-test-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/accounts-finance/tcl/test/finance-test-procs.tcl 21 May 2010 23:36:33 -0000 1.3 +++ openacs-4/packages/accounts-finance/tcl/test/finance-test-procs.tcl 22 May 2010 00:17:17 -0000 1.4 @@ -21,6 +21,6 @@ aa_equals "Check FV simple interest" [acc_fin::fvsimple $cashflow3 $reinvest_rate] "7600.0" aa_equals "Check NPV" [acc_fin::npv $cashflow1 $discount_rate] "0.000550114657813" aa_equals "Check IRR" [acc_fin::irr $cashflow1] $discount_rate - aa_equals "Check MIRR" [acc_fin::mirr $cashflow1 $finance_rate $reinvest_rate] "0.1791" + aa_equals "Check MIRR" [acc_fin::mirr $cashflow1 $finance_rate $reinvest_rate] "0.179085686035" } }