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 }