r22075 - gnucash/trunk - Remove the separate "calculation" module and swallow it in app-utils.
Christian Stimming
cstim at code.gnucash.org
Sun Mar 11 18:05:23 EDT 2012
Author: cstim
Date: 2012-03-11 18:05:22 -0400 (Sun, 11 Mar 2012)
New Revision: 22075
Trac: http://svn.gnucash.org/trac/changeset/22075
Added:
gnucash/trunk/src/app-utils/calculation/
gnucash/trunk/src/app-utils/calculation/Makefile.calc
gnucash/trunk/src/app-utils/calculation/README
gnucash/trunk/src/app-utils/calculation/amort_opt.c
gnucash/trunk/src/app-utils/calculation/amort_prt.c
gnucash/trunk/src/app-utils/calculation/expression_parser.c
gnucash/trunk/src/app-utils/calculation/fin-interactive.c
gnucash/trunk/src/app-utils/calculation/fin-main.c
gnucash/trunk/src/app-utils/calculation/fin-proto.sh
gnucash/trunk/src/app-utils/calculation/fin.c
gnucash/trunk/src/app-utils/calculation/fin_spl_protos.h
gnucash/trunk/src/app-utils/calculation/fin_static_proto.h
gnucash/trunk/src/app-utils/calculation/fini-input
gnucash/trunk/src/app-utils/calculation/fini-output
gnucash/trunk/src/app-utils/calculation/finproto.h
gnucash/trunk/src/app-utils/calculation/finvar.h
gnucash/trunk/src/app-utils/calculation/numeric_ops.c
gnucash/trunk/src/app-utils/calculation/numeric_ops.h
gnucash/trunk/src/app-utils/calculation/sample
Removed:
gnucash/trunk/src/calculation/CMakeLists.txt
gnucash/trunk/src/calculation/Makefile.am
gnucash/trunk/src/calculation/Makefile.calc
gnucash/trunk/src/calculation/README
gnucash/trunk/src/calculation/amort_opt.c
gnucash/trunk/src/calculation/amort_prt.c
gnucash/trunk/src/calculation/expression_parser.c
gnucash/trunk/src/calculation/fin-interactive.c
gnucash/trunk/src/calculation/fin-main.c
gnucash/trunk/src/calculation/fin-proto.sh
gnucash/trunk/src/calculation/fin.c
gnucash/trunk/src/calculation/fin_spl_protos.h
gnucash/trunk/src/calculation/fin_static_proto.h
gnucash/trunk/src/calculation/fini-input
gnucash/trunk/src/calculation/fini-output
gnucash/trunk/src/calculation/finproto.h
gnucash/trunk/src/calculation/finvar.h
gnucash/trunk/src/calculation/gncmod-calculation.c
gnucash/trunk/src/calculation/numeric_ops.c
gnucash/trunk/src/calculation/numeric_ops.h
gnucash/trunk/src/calculation/sample
gnucash/trunk/src/calculation/test/Makefile.am
gnucash/trunk/src/calculation/test/test-link.c
Modified:
gnucash/trunk/configure.ac
gnucash/trunk/src/Makefile.am
gnucash/trunk/src/app-utils/Makefile.am
gnucash/trunk/src/app-utils/gncmod-app-utils.c
gnucash/trunk/src/app-utils/test/Makefile.am
gnucash/trunk/src/gnome-utils/gncmod-gnome-utils.c
gnucash/trunk/src/gnome-utils/test/Makefile.am
gnucash/trunk/src/gnome/Makefile.am
gnucash/trunk/src/html/Makefile.am
gnucash/trunk/src/html/gncmod-html.c
gnucash/trunk/src/import-export/test/Makefile.am
gnucash/trunk/src/report/report-gnome/test/Makefile.am
gnucash/trunk/src/report/report-system/test/Makefile.am
gnucash/trunk/src/report/standard-reports/test/Makefile.am
gnucash/trunk/src/report/stylesheets/test/Makefile.am
gnucash/trunk/src/report/utility-reports/test/Makefile.am
Log:
Remove the separate "calculation" module and swallow it in app-utils.
Those few source files do not justify an extra loadable module. They are
just compiled-in into app-utils.
Modified: gnucash/trunk/configure.ac
===================================================================
--- gnucash/trunk/configure.ac 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/configure.ac 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1242,8 +1242,6 @@
src/bin/test/Makefile
src/core-utils/Makefile
src/core-utils/test/Makefile
- src/calculation/Makefile
- src/calculation/test/Makefile
src/debug/Makefile
src/debug/valgrind/Makefile
src/doc/Makefile
Modified: gnucash/trunk/src/Makefile.am
===================================================================
--- gnucash/trunk/src/Makefile.am 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/Makefile.am 2012-03-11 22:05:22 UTC (rev 22075)
@@ -11,7 +11,6 @@
backend \
scm \
quotes \
- calculation \
tax
# These directories should also not contain any gtk dependencies, but
Modified: gnucash/trunk/src/app-utils/Makefile.am
===================================================================
--- gnucash/trunk/src/app-utils/Makefile.am 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/app-utils/Makefile.am 2012-03-11 22:05:22 UTC (rev 22075)
@@ -24,7 +24,7 @@
-I${top_srcdir}/src \
-I${top_builddir}/src \
-I${top_srcdir}/src/gnc-module \
- -I${top_srcdir}/src/calculation \
+ -I${top_srcdir}/src/app-utils/calculation \
-I${top_srcdir}/src/core-utils \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/libqof/qof \
@@ -35,6 +35,8 @@
${GTK_CFLAGS}
libgncmod_app_utils_la_SOURCES = \
+ calculation/expression_parser.c \
+ calculation/fin.c \
swig-app-utils-guile.c \
business-options.c \
QuickFill.c \
@@ -84,7 +86,6 @@
libgncmod_app_utils_la_LIBADD = \
${top_builddir}/src/gnc-module/libgnc-module.la \
${top_builddir}/src/engine/libgncmod-engine.la \
- ${top_builddir}/src/calculation/libgncmod-calculation.la \
${top_builddir}/src/core-utils/libgnc-core-utils.la \
${top_builddir}/src/libqof/qof/libgnc-qof.la \
${GCONF_LIBS} \
@@ -133,6 +134,12 @@
noinst_DATA = .scm-links
+noinst_HEADERS = \
+ calculation/finvar.h \
+ calculation/finproto.h \
+ calculation/fin_spl_protos.h \
+ calculation/fin_static_proto.h
+
EXTRA_DIST = \
swig-app-utils-python.c \
app-utils.i \
Copied: gnucash/trunk/src/app-utils/calculation/Makefile.calc (from rev 22074, gnucash/trunk/src/calculation/Makefile.calc)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/Makefile.calc (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/Makefile.calc 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,49 @@
+# qtgrep makefile
+# created by Terry Boldt 3-16-2000
+#
+
+GLIB_CFLAGS = `glib-config --cflags`
+CFLAGS = -O3 $(GLIB_CFLAGS)
+#CFLAGS = -g
+
+CC = gcc
+
+all: financial fini
+
+HDRS = finproto.h \
+ fin_static_proto.h\
+ fin_spl_protos.h\
+ finvar.h
+
+OBJSM = fin.o\
+ amort_prt.o\
+ fin-main.o
+
+OBJSI = fin.o \
+ expression_parser.o\
+ numeric_ops.o\
+ amort_prt.o\
+ amort_opt.o\
+ fin-interactive.o
+
+financial: $(OBJSM)
+ @echo "linking"
+ $(CC) `glib-config --libs` -o $@ $(OBJSM)
+
+fini: $(OBJSI)
+ @echo "linking"
+ $(CC) `glib-config --libs` -o $@ $(OBJSI)
+
+fin.o: fin.c $(HDRS)
+
+expression_parser.o: expression_parser.c $(HDRS)
+
+fin-interactive.o: fin-interactive.c $(HDRS)
+
+fin-main.o: fin-main.c $(HDRS)
+
+numeric_ops.o: numeric_ops.c $(HDRS)
+
+amort_prt.o: amort_prt.c $(HDRS)
+
+amort_opt.o: amort_opt.c $(HDRS)
Copied: gnucash/trunk/src/app-utils/calculation/README (from rev 22074, gnucash/trunk/src/calculation/README)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/README (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/README 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,989 @@
+Dave - the attached file contains the following files:
+
+drwx------ 4096 Jul 4 16:20 ./
+drwxr-xr-x 4096 Jun 19 17:20 ../
+-rw-r--r-- 211 Jun 23 20:24 .kdbgrc.financial #kdebug file
+-rw-r--r-- 259 Jul 4 15:24 .kdbgrc.fini #kdebug file
+-rw-r--r-- 732 Jul 4 15:24 Makefile
+-rw-r--r-- 5711 Jul 3 20:02 amort_opt.c # display/set amortization options
+-rw-r--r-- 4392 Jul 4 15:25 amort_opt.o
+-rw-r--r-- 13020 Jul 4 16:16 amort_prt.c # print amortization schedule(s)
+-rw-r--r-- 7256 Jul 4 16:16 amort_prt.o
+-rw-r--r-- 14778 Jul 3 20:09 expression_parser.c # expression parser/evaluator
+-rw-r--r-- 5148 Jul 4 15:24 expression_parser.o
+-rw-r--r-- 19225 Jul 3 20:03 fin-interactive.c # demo
+-rw-r--r-- 12964 Jul 4 15:25 fin-interactive.o
+-rw-r--r-- 6102 Jul 4 16:01 fin-main.c # fixed examples
+-rw-r--r-- 5008 Jul 4 16:02 fin-main.o
+-rwxr-xr-x 1431 Jul 2 19:21 fin-proto.sh* # shell script for making 'h' files
+-rw-r--r-- 83854 Jul 4 16:34 fin.c # financial and amortization functions
+-rw-r--r-- 23880 Jul 4 16:16 fin.o
+-rw-r--r-- 1063 Jun 28 16:28 fin_spl_protos.h # function prototypes
+-rw-r--r-- 4631 Jul 3 20:07 fin_static_proto.h # function prototypes
+-rwxr-xr-x 41011 Jul 4 16:16 financial* # executable demo - from fin-main.c
+-rwxr-xr-x 54720 Jul 4 16:16 fini* # executable demo - from fin-interactive.c
+-rw-r--r-- 90 Jun 22 20:37 fini-input
+-rw-r--r-- 2624 Jun 22 20:24 fini-output
+-rw-r--r-- 7407 Jul 3 20:07 finproto.h # function prototypes
+-rw-r--r-- 8152 Jul 4 15:23 finvar.h # define global structures used
+drwx------ 4096 Jun 27 20:24 html/ # html documentation
+-rw-r--r-- 6938 Jul 3 20:04 numeric_ops.c # numeric functions - for expression parser
+-rw-r--r-- 2204 Jul 4 15:24 numeric_ops.o
+-rw-r--r-- 11814 Jun 20 19:58 readme # this file
+-rw-r--r-- 131016 Jul 4 16:20 sample # output of financial executable
+
+financial-equations/html:
+total 164
+drwx------ 4096 Jun 27 20:24 ./
+drwx------ 4096 Jul 4 16:20 ../
+-rw-r--r-- 17430 Jun 20 15:29 amorta.html # amortization schedule
+-rw-r--r-- 26222 Jun 20 15:29 amortp.html # amortization schedule
+-rw-r--r-- 2361 Jun 27 20:38 constderv.html # equations derivation
+-rw-r--r-- 11290 Jun 27 20:25 finderv.html # equations derivation
+-rw-r--r-- 82204 Jun 27 20:36 finutil.html # basic use of financial calculator
+
+This 'readme' file is probably somewhat rambling - it is coming off
+the top of my head with very little organization. Note also that much
+of the following "explanation" has been duplicated as comments at the
+top of the "fin.c" and the "expression-parser.c" files. Thus, anyone
+desiring to use the functions contained therein will have some ready
+documentation.
+
+Look into the 'sample' file. It contains sample output from the
+routines - both from the calculator and the amortization routines. The
+sample file was created with the "financial" executable. If running
+Linux, you should be able to execute this program without compiling to
+recreate 'sample' as "./financial >sample"
+
+You may want to view the file "finutil.html" in a browser - it
+explains in detail the calculator functions and variables and concepts
+and amortization schedule options.
+
+The file 'finvar.h' contains the structures needed by functions
+calling the financial functions and amortization functions and the
+expression parser/evaluator and should be included by any file calling
+any financial function and and the amortization functions. The two
+prototype files:
+
+finproto.h
+fin_spl_protos.h
+
+should be "included" by any files containing functions which call
+either the financial calculator functions (including the amortization
+functions) or the expression parser/evaluator.
+
+There are no "global variables". My first iteration on "porting"
+the calculator contained global variables for the basic financial
+variables. I decided against doing this for reasons of conflict with
+other variables used in other modules and also to insure that ANY
+module in gnucash could call the financial functions and have their
+own set of financial variables. Thus any gnucash module may use the
+financial functions without concern of interaction with any other
+module also using the functions concurrently.
+
+There are 9 "financial variables". Of the nine, four are ALWAYS set by
+the "user", i.e., calling function. Of the remaining five, four are
+set and the fifth computed by the appropriate financial calculator
+function listed below. The 9 "financial variables" are: (if more than
+one name is used for a particular financial variable, all are listed)
+
+n or npp == number of payment periods in the transaction under
+ consideration
+
+i, nint or ir == nominal interest rate for the transaction.
+ Use the interest rate as used by humans,
+ i.e., 9.5, 8.25, etc. and not 0.095, 0.0825
+
+pv == present value, i.e., the value of the transaction at the
+ present moment in time. This would be the amount of the
+ loan/mortgage/Certificate of Deposit/bank account/etc.
+
+pmt == periodic payment
+
+fv == future value, i.e., the value of the transaction at some
+ future time after n payment periods.
+
+Of the five values above, four are set by the "user" and the fifth
+computed. The remaining financial variables are:
+
+CF == Compounding Frequency, number of compounding periods in one year
+PF == Payment Frequency, number of payment periods in one year
+disc == TRUE, 1, for discrete compounding (used by most financial
+ institutions in US)
+ FALSE, 0, for continuous compounding (used by some banks
+ in my area for CDs)
+bep == TRUE for beginning of periods payments
+ FALSE for end of period payments (the norm in the US at least)
+
+The function 'set_default(fi_ptr fi)' will set the variables in the
+'fi' structure to the default values:
+
+n == 0
+i = 0.0
+pv = 0.0
+pmt = 0.0
+fv = 0.0
+CF = 12
+PF = 12
+disc = 1
+bep = 0
+
+(Maybe this could/should be made locale specific or configurable ??? )
+
+In addition, there is one other "financial variable" which is not
+really a financial variable, but which should be specific to any
+particular financial computation and under the control of the user:
+
+prec == numeric precesion used for round-off of numeric values, i.e.,
+ number of digits past the radix point.
+
+I currently have a static function defined in the "fin.c" file:
+
+static double rnd(
+ double x,
+ unsigned places)
+{
+ double r;
+ unsigned char buf[50]; /* make buffer large enough */
+
+ if ( places >= 0 ) {
+ sprintf(buf,"%.*f",places,x);
+ sscanf(buf,"%lf",&r);
+ } else r = x;
+
+ return r;
+} /* rnd */
+
+The function returns x rounded to the specified number of decimal
+digits past the radix point. I assume that gnucash currently has such
+a function. I will need the name of this function, since it is used
+extensively in the financial computation and the computation of
+amortization schedules. The function 'rnd' that I have included is
+pretty simple - it simply writes the double value to a string using
+'sprintf' to print the value and round the value. It then uses
+'sscanf' to read the value into a temporary double variable and
+returns that value. I have written many rounding functions in the past
+and could never find one that everybody agreed with. Not every one
+agrees with the rounding rules used by the C 'printf' functions, but
+at least everybody writing C and C++ uses them and is used to them.
+
+The financial functions use a structure (defined in 'finvar.h'):
+
+/* structure used by financial computation routines to store
+ * financial variables */
+typedef struct financial_info *fi_ptr;
+typedef struct financial_info {
+ double ir; /* interest rate */
+ double pv; /* present value */
+ double pmt; /* periodic payment */
+ double fv; /* future value */
+
+ unsigned npp; /* number of payment periods */
+ unsigned CF; /* Compounding frequency */
+ unsigned PF; /* payment frequency */
+ unsigned bep; /* beginning/end of period payment flag */
+ /* TRUE == beginning of period */
+ /* FALSE == end of period */
+ unsigned disc; /* discrete/continuous compounding flag */
+ /* TRUE == discrete compounding */
+ /* FALSE == continuous compounding */
+
+ /* precision of roundoff for pv, pmt and fv.
+ * i, Interest not rounded
+ * n, number of periods rounded to integer value,
+ * implicit value of zero, 0
+ *
+ * 2 for US Dollars
+ */
+ unsigned prec;
+} financial_info;
+
+to contain all information used in the financial calculations. The
+structure is created by the calling function and the variables set by
+the calling function. The appropriate financial function is called to
+compute the desired quantity with a pointer to the structure.
+
+
+The following functions are contained in the financial calculator:
+
+unsigned N(fi_ptr fi) -- solves for number of payment periods rounded to an
+ integer value. Sets the variable 'npp' in the passed
+ structure and returns the same value.
+
+double I(fi_ptr fi) -- solves for the nominal interest rate rounded to
+ the precision specified in the structure passed.
+ Sets the variable 'ir' in the passed structure
+ and returns the same value.
+
+double PV(fi_ptr fi) -- solves for the present value rounded to the precision
+ specified. Sets the variable 'pv' in the passed
+ structure and returns the same value.
+
+double PMT(fi_ptr fi) -- solves for the periodic payment rounded to the
+ precision specified. Sets the variable 'pmt' in
+ the passed structure and returns the same value.
+
+double FV(fi_ptr fi) -- solves for the future value rounded to the precision
+ specified. Sets the variable 'fv' in the passed
+ structure and returns the same value.
+
+The above functions use the following functions for the calculation
+and round the answer as indicated. The above functions are the
+"normal" functions called to calculate the corresponding values. I
+left the following functions as "global" in case there is a need for
+unrounded, full floating point accuracy answers. They could be
+converted to "static" functions if there is any conflict or the full
+accuracy is not needed elsewhere in gnucash. Also these function do
+not use the financial calculator structure, but rather the variables
+must be passed as arguments with the desired value returned.
+
+double _N(ir,pv,pmt,fv,CF,PF,disc,bep) - compute number of payment periods
+ and return value
+
+double _I(npp,pv,pmt,fv,CF,PF,disc,bep) - compute nominal interest rate and
+ return value
+
+double _PV(npp,ir,pmt,fv,CF,PF,disc,bep) - compute present value and return
+ value
+
+double _PMT(npp,ir,pv,fv,CF,PF,disc,bep) - compute periodic payment and
+ return value
+
+double _FV(npp,ir,pv,pmt,CF,PF,disc,bep) - compute future value and return
+ value
+
+Note, the return value of '_N' should always be rounded (or truncated,
+probably rounded) since a fractional payment period is a practical
+impossibility.
+
+The financial calculator functions do no "value checking". That is,
+there is no checking for erroneous values or any "reasonable value
+testing". The only values that absolutely have to be checked by the
+calling functions are:
+
+1: nominal interest rate when calculating one of the other variables.
+ If this value is zero a "divide by zero" error may occur. If the
+ divide by zero error does not occur, then the value calculated
+ will more than likely be returned as 'nan'. Always check this value
+ for non-zero if it is not the value to be computed. A non-zero value
+ is only common sense also, since a zero interest rate is probably
+ meaningless.
+
+2: number of payment periods. When calculating the nominal interest rate,
+ if the number of payment periods is zero, again a "divide by zero" error
+ may occur. Always check this value for non-zero if it is not the value to
+ be computed. Again, a zero number of payment periods is meaningless.
+ At least one payment must be made or one party to the transaction is
+ making a free gift to the other party - in which case the calculator
+ is not needed.
+
+Note: I have violated both of these rules in the two demo executables
+provided. For the 'financial' executable, such a check is not
+necessary since all of the examples are set statically and it is known
+that neither interest or number of periods is zero. For the 'fini'
+executable, they should be checked, but for demo purposes I didn't
+think it necessary.
+
+A good user interface would check that the values of CF, PF, disc and
+bep are set (at least to the default values) and that at least 4 of
+the remaining variables have been set and the user asked for the fifth
+value to be computed. Leaving the value of 'fv' to zero would be the
+normal in most cases.
+
+I decided that the financial functions should do no value checking,
+since they are far enough down the call chain that returning in the
+case of erroneous values is problamatic and adds excessive structure
+to otherwise extremely simple functions. Also since the value checking
+that does need to be accomplished is minimal and should optimally be
+done as close to the user interface as possible.
+
+
+My first take on a possible user interface would look something like
+(or as close as I can get in an ASCII text file):
+
+NOTE: ==xxxxxxxxx== means a GUI box for displaying/entering a value
+
+ ((compute)) means a GUI button with the title "compute"
+
+ <<Monthly>> means a GUI box with dropdown values that the user selects
+ there is a name for such a box in GUI nomenclature,
+ but I forget the name
+
+ || means a GUI check box button (either on or off).
+ The Title for the button would change to reflect
+ the on/off, TRUE/FALSE value
+
+ |**********| means a single line text box that the user could
+ use to enter a string. This box could be used by
+ the user to enter expressions, with named variables,
+ to be evaluated. This box is probably he same kind
+ of GUI box as I have indicated above with == xxxx==
+
+Possible Financial Calculator GUI:
+|-------------------------------------------------------------------------|
+
+ Number of
+ Payment Periods ((Compute))
+ ==xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==
+
+ Interest Rate ((Compute))
+ ==xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==
+
+ Present Value ((Compute))
+ ==xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==
+
+ Periodic Payment ((Compute))
+ ==xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==
+
+ Future Value ((Compute))
+ ==xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==
+
+
+ Compounding Payment || End of Period Payments
+ Frequency Frequency
+ <<Monthly>> <<Monthly>> || Discrete Compounding
+
+ Expression
+ |************************************************************|
+
+ User Defined Variables
+ Some kind of GUI box displaying both the names and values of
+ variables that the user has defined using the expression box
+ above or the financial variables entry boxes. The variables
+ are used to store values for future use/reference
+
+
+ Effective Date: ==mm/dd/yyyy==
+ Initial Payment date: ==mm/dd/yyyy==
+|------------------------------------------------------------------------|
+
+Note: the drop down boxes for Compounding Frequency and Payment
+Frequency should contain the following selectable values:
+
+ annual 1
+ semi-annual 2
+ tri-annual 3
+ quarterly 4
+ bi-monthly 6
+ monthly 12
+ semi-monthly 24
+ bi-weekly 26
+ weekly 52
+ daily (360) 360
+ daily (365) 365
+
+with the corresponding values used for CF and PF as indicated.
+
+Clicking on "Discrete Compounding" switches back and forth between
+"Discrete Compounding" and "Continuous Compounding". "Discrete
+Compounding" should be the default since it is by far the most common.
+
+Clicking on "End of Period Payments" switches back and forth between
+"End of Period Payments" and "Beginning of Period Payments". "End of
+Period Payments" should probably be the default since it is by far the
+most common.
+
+The user could click on the entry box under "Number of Payment
+Periods", "Interest rate", "Present Value", "Periodic Payment"
+and "Future Value" and enter a value or expression string to be
+evaluated. Clicking on the corresponding "Compute" button would
+compute that financial variable. I have made the entry boxes long so
+that a user could enter a fairly long string. The boxes could also be
+made scrollable. The entry function could be made simple and always
+regard the entry as a string and pass the string to the
+parser/evaluator to return the appropriate value.
+
+The titles for the boxes, especially "Present Value" and "Future
+Value", may need to be changed depending on the feedback from the
+gnucash community. I have always used those names since they are
+"generic" and represent all of the possible uses for the financial
+calculator. In this way a single calculator GUI could be used instead
+of inventing a GUI for mortgages, another for CDs, another for saving
+accounts, another for annuities, another for sinking funds, etc.
+
+The next question is the Amortization Schedule Interface. This
+interface should not be available until all of the financial variables
+are known. Once they are, the user should be able to click on a "tab"
+or something to get the Amortization Schedule Interface. A first stab
+at such an interface could be as shown below. Once the financial
+variables are known - either all entered by the user or one computed
+as indicated by the user, the function "Amortization_init" would be
+called to compute the quatities needed for the user to choose which
+amortization schedule is desired. The function "amort_opt" in the
+file amort_opt.c contains all of the information that the user must
+have to decide which of the six schedules is desired.
+
+Note that the function "Amortization_init" needs two dates:
+ Effective Date of Transaction -- the date the papers were signed, etc.
+ Initial Payment Date -- self explanatory
+
+Both dates could be initially filled in by the interface with default
+values. For the Effective Date, the current date would probably be the
+most likely candidate. The default Initial Payment Date would depend
+on whether the payments were being made at the beginning or end of the
+payment periods, i.e., bep in the financial information structure
+above.
+
+ bep == TRUE, use the first day of the next month for the default
+ Initial Payment Date, e.g., if current day is August 6, 2000,
+ then the default Initial Payment Date would be September 1, 2000
+ bep == FALSE, use if the first day of the month after the next month,
+ e.g., if current day is August 6, 2000, then the default Initial
+ Payment Date would be October 1, 2000
+
+The user could then change or accept the default dates as desired.
+
+The only real checking that would need to be done on either date is to
+insure that the Effective Date preceeds the Initial Payment Date.
+
+
+The following functions are used for amortization schedules. All
+functions use the amortization structure defined in "finvar.h",
+"amort_sched".
+
+Notice that some of the information is duplication of the infomation
+used by the financial calculator structure. I thought this best in
+order to "separate" these two functions so that if a new set of
+financial variables is desired by the user, the old set used by the
+amortization computation functions would still be available. The
+amount of storage is minimal.
+
+Note that the amortization schedule structure, "amort_sched" is
+divided into three parts.
+
+The first part is information set by the calling function(s) and is
+the financial information from the financial information structure
+supplemented with the Effective Date and Initial Payment Date
+information.
+
+The second part is also set by the calling function(s) and sets which
+schedule and type of schedule is computed.
+
+The third part is information set by the amortization functions. Some
+of the information is needed for the GUI below for selecting which
+amortization option to compute.
+
+
+Amortization Schedule Selection GUI:
+|----------------------------------------------------------------------------|
+ Amortization Schedule
+
+ Effective Date: mm/dd/yyyy
+ Initial Payment date: mm/dd/yyyy
+
+ The Original Present Value is: xxxxxx.xx (pv)
+ The Original Periodic Payment is: xxxx.xx (pmt)
+ The Original Future Value is: xxxx.xx (fv)
+
+ The Delayed Present Value is: xxxxxx.xx (pve)
+ The New Periodic Payment is: xxxx.xx (new_pmt)
+
+ The amortization options are:
+
+ || Amortize with Original Present Value
+ Constant Payment to Principal: xxxxx.xx (cmpt1)
+ and final payment: xxxxx.xx (final_pmt_opt_1)
+
+ || Amortize with Delayed Present Value
+ Constant Payment to Principal: xxxxx.xx (cmpt2)
+ and final payment: xxxxx.xx (final_pmt_opt_2)
+
+ || Amortize with Original Transaction Values
+ and final payment: xxxxx.xx (final_pmt_opt_3)
+
+ || Amortize with Delayed Present Value, Original Periodic Payment
+ and final payment: xxxxx.xx (final_pmt_opt_4)
+
+ || Amortize with Delayed Present Value, New Periodic Payment
+ and final payment: xxxxx.xx (final_pmt_opt_5)
+
+ || Amortize with Original Present Value, Original Periodic Payment
+ new number of total payments: xxx (new_n)
+ and final payment: xxxxx.xx (final_pmt_opt_6)
+
+|----------------------------------------------------------------------------|
+
+Note: I have included in parenthesis above the names of the variables
+in the amortization structure, amort_sched, to be used in filling in
+the appropriate values. Do not include the parenthesized infomation in
+the GUI.
+
+Note: the last option is available ONLY IF the variable "new_n" in the
+amortization schedule structure is non-zero. If "new_n" is zero, the
+last option could be "faded out" or left out completely.
+
+Note that the options are mutually exclusive, picking one turns the
+others off. Initially all should probably be off, thus forcing the
+user to pick one.
+
+Option 3 above is probably the one most likely to be selected by most
+people. The others are more likely to be choosen as comparisons to
+what is likely to be dictated by their lending institution which would
+more than likely be option 3 (at least in the US).
+
+I have laid out the above options to correspond to the values for the
+variable "option" in the "amort_sched" structure. Any other sequence
+could be used so long as the proper numbering is maintained for
+"option".
+
+Once a particular option, 1 to 6 inclusive, has been choosen above by
+the user, they have one more choice to make: namely whether they want
+an annual summary or a schedule of each payment. Also if "option" is
+3, 4, 5 or 6 they also have the additional choices of whether they
+want a fixed prepayment to principal or a variable prepayment to
+principal schedule. If they choose a fixed prepayment schedule, then
+they must enter the amount of the fixed prepayment. It's not as
+complicated as it sounds. The dialog for these choices could look
+something like:
+
+|----------------------------------------------------------------------------|
+
+ Type of Amortization Schedule
+
+ || Annual Summary
+
+ || Per Payment Schedule
+
+ || Variable Prepayment to Principal
+
+ || Fixed Prepayment to Principal Schedule
+ ==xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==
+
+|----------------------------------------------------------------------------|
+
+Note that zero for the fixed prepayment is valid. The value entered
+(or not entered as the case may be) should be set into the variable,
+"fixed_pmt" in the amortization schedule structure. If a value for the
+fixed prepayment is entered by the user, this value should probably be
+set into "fixed_pmt", irregardless of whether the user selects the
+fixed prepayment option.
+
+Note that the options are mutually exclusive, picking one turns the
+others off. Initially all should probably be off, thus forcing the
+user to pick one.
+
+The last two options would only be available if they had selected
+options 3, 4, 5 or 6 from the amortization options dialog. The
+information from this dialog would be used to set the variable
+"summary" in the "amort_sched" structure. The permissable values are:
+
+ 'y' -- indicates an annual summary schedule, first option above
+ 'p' -- indicates a per payment schedule, option 2 above
+ 'a' -- indicates a variable prepayment schedule, option 3 above
+ 'f' -- indicates a fixed prepayment schedule, option four above.
+
+I have provided a function, "amort_opt", in the file "amort_opt.c" to
+demonstrate which information is used to fill in the appropriate
+places in the above two GUIs. You can use this function as a guide.
+
+Once all of that information has been gathered from the user,
+the amortization schedule can be computed. The function
+"Amortization_Schedule" is called and does the computation, but not
+the display/output of the schedule. I orginally had the output of the
+schedule integrated in this function, but decided that was a dumb
+idea. Passing back a pointer in the "amort_sched" structure for
+all of the computed values was a better idea. This way the actual
+output/display of the schedule can be tailered as desired.
+
+I have provided the function "amort_prt" in the file "amort_prt.c" as
+a guide on how to use the structures and the information they contain
+to display/output the desired schedule. Currently, the function
+"prints" the information to a specified file. I could alter the
+function to output HTML tables if desired. The changes would not be
+very great. Also, a flag could be passed to indicate whether HTML or
+plain text was desired. Or the function could be completely rewritten
+to output some completely different format as desired.
+
+The functions used for the amortization schedule are:
+
+Amortization_init -- this functions initializes the information for
+ the schedule so that the user can decide which
+ schedule and which type is desired.
+
+Amortization_Schedule -- this function computes the desired
+ amortization schedule.
+
+Amortization_free -- this function is called to free the dynamically
+ allocated memory in the amortization schedule - it
+ does not free the amortization schedule structure passed,
+ but the schedule structures allocated by the call to
+ "Amortization_Schedule" and pointed to in the union
+ in the amortization schedule structure.
+
+amort_opt - a function to display the options to the user and input which
+ schedule and which type is desired. Uses a text display - for
+ guidance in designing the eventual GUI used.
+
+amort_prt - a function to print the desired schedule, again for guidance
+ in how to use the information computed for each type of schedule.
+
+
+A typical sequence would be:
+
+1: use the financial calculator functions to enter/calculate the
+ financial variables
+
+2: copy the financial information from the financial information
+ structure to the amortization schedule structure
+
+3: call the "Amortization_init" function to initialize the amortization
+ schedule
+
+4: obtain from the user, schedule option and type -- "amort_opt" function
+ for command line version
+
+5: call the "Amortization_Schedule" function to compute the desired
+ amortization schedule
+
+6: display/output the desired amortization schedule -- "amort_prt"
+ function for the command line version
+
+7: call the "Amortization_free" function to free memory in computed schedule
+
+8: loop back to step 4 above for another schedule using same financial
+ data and dates
+
+9: loop back to step 1 above for new financial data
+
+
+Right now the documentation is written around the use of the financial
+calculator in QTAwk, my personal implementation of a superset of awk,
+nawk and gawk. The document, especially the examples section, will
+have to be rewritten to a small extent for gnucash. I would like to
+defer this until we have settled on the GUI since that will determine
+the end document.
+
+The examples illustrate the general nature of the calculator and the
+many "seemingly" unrelated uses for it. I used CA Simply Money under
+OS/2 for many years. They had several "calculators". At first I
+thought that was great. Then I really looked at what they had - it was
+really just many different GUIs for the same calculator, The same
+calculator under different guises. I stopped using all of theirs very
+quickly and developed my own since having it all in one was much
+easier to understand. It also underscored the power of the finanacial
+functions in everyday life.
+
+<<<<<<<<<<------------------------------------------------------------>>>>>>>>
+
+The only thing left to describe is the expression parser/evaluator.
+The expression parser/evaluator is contained in the file
+"expression_parser.c".
+
+Before describing the parser per se, I want to describe the structures
+used to contain the results returned from the parser. The structure is
+defined in "finvar.h":
+
+typedef struct var_store *var_store_ptr;
+
+typedef struct var_store {
+ unsigned char *variable_name; /* variable name if variable,
+ NULL otherwise */
+ unsigned char use_flag; /* flag if variable has been assigned to */
+ unsigned char assign_flag; /* flag if variable is used */
+ void *value; /* pointer to imp[lementation defined
+ numeric value */
+ var_store_ptr next_var; /* pointer to next variable in linked
+ list */
+} var_store;
+
+The "use_flag" variable is for internal use of the parser and can be
+ignored by the user. The "variable_name" variable possibly points to
+a string containing the name of the value returned, a "variable
+name". If NULL, then this is a temporary value. The "value" variable
+points to a user defined structure containing the numeric value of the
+variable.
+
+In designing and writing the parser, I decided early on that the
+parser should be an "expression parser/evaluator" and that the actual
+arithmetic was the responsibility of the caller/user. In reading the
+debate on "gnucash-devel" and realizing that the exact numeric
+representation used in gnucash was very probably going to be changing
+in the future, I decided that the parser should be totally independent
+of the numeric representation used, and thus the exact details of how
+the arithmetic was performed. To accomplish this, four functions are
+supplied by the user/caller:
+
+1: trans_numeric - this function translates the text string into a
+ numeric in the desired representation and returns a pointer to
+ the representation as a (void *) this function has three parameters
+ passed:
+ 1: digit_str -- the actual text string of the numeric to be converted
+ to the internal representation
+ 2: radix_point -- the ASCII character used to represent the radix point
+ 3: rstr -- a pointer to a location in which to return a pointer to the
+ first character not part of the numeric string translated
+ If this pointer is NULL, do not return a value. This parameter
+ is the same as the second parameter of the standard C library
+ functions "strtod" or "strtol"
+
+2: numeric_ops - this function does the actual arithmetic on two numeric
+ quantities in internal representation. It has three
+ parameters passed:
+ 1: op_sym -- the numeric operation to be performed. The possible
+ values are defined in "finvar.h" and are:
+ ADD_OP - addition
+ SUB_OP - subtraction
+ DIV_OP - division
+ MUL_OP - multiplication
+ ASN_OP - assignment
+ 2: left_value - the left hand operand of the binary operator
+ 3: right_value - the right hand operand of the binary operator
+ Note: left_value and right_value are passed as
+ (void *). This function is responsible for casting
+ to the proper type to use.
+
+ Note: this function should make no assumptions about
+ overwriting or re-using either left_value or
+ right_value, except for ASN_OP. Both values passed
+ must be left unchanged by any operation except ASN_OP.
+ This function is also responsible for allocating/freeing
+ memory as necessary to perform the designated function
+ and returning the result.
+
+ I STRONGLY suggest that the result be returned in
+ dynamically allocated memory. If static memory is used,
+ the parser has no means of copying the returned result
+ or managing static memory to prevent overwriting
+ the result and invalidating the result.
+
+3: negate_numeric - this function negates the value passed (as a (void *))
+
+4: free_numeric - this function is responsible for freeing memory used by
+ the internal numeric representation.
+
+I have included the file "numeric_ops.c" containing the above
+functions for the usual "double" and "int" representation of
+numerics. The functions perform integer or floating point operations
+as appropriate for the string entered by the user. The division
+operation is done in "double" since I do not think that anybody really
+wants (9 / 2) to equal 4 instead of 4.5 for financial operations.
+These functions use the structure defined in finvar.h:
+
+typedef struct numeric *numeric_ptr;
+typedef struct numeric {
+ unsigned char type; /* designates type of value */
+ union {
+ long int int_value; /* long integer value */
+ double dbl_value; /* double value */
+ } value;
+} numeric;
+
+to contain all numeric values. The variable "type" in this structure
+can have the values:
+ INT_TYPE
+ DBL_TYPE
+which are defined in "finvar.h".
+
+All "named variables", variables defined by the user for storing
+intermediate results for future reference/use, and temporary variables
+used by the parser use the variable storage structure, var_store,
+defined above. The result of parsing and evaluating the string passed
+are returned in a variable storage structure specified by the caller.
+
+If the returned variable value is not named, i.e., "variable_name ==
+NULL", then the user/caller is responsible for freeing the memory used
+by the internal representation of the numeric value. If, however,
+"variable_name != NULL", freeing the memory used by the internal
+numeric representation will cause a segmentation fault later, when
+parser attempts to free the memory through a call to
+the "free_numeric". In addition, freeing the memory will probably
+invalidate the numeric value contained therein and lead to pernicuous
+results when the value is used.
+
+If "variable_name != NULL", the user/caller should never attempt to
+free this memory, that is the sole responsibility of the parser.
+
+It may be that the calling function has certain "variables" that need
+to be "pre-defined" for the user to manipulate. The demo financial
+calculator "pre-defines" the financial variables, "n, i, pv, pmt, fv,
+CF, PF, disc and bep". I would suggest that the gnucash financial
+calculator also pre-define these for direct manipulation by the user
+if they so desire. Other modules of gnucash could pre-define other
+variables with common names used in accounting if they so desire. This
+would allow knowledgable users quick access to such values and to be
+able to easly manipulate the values to obtain desired results. One
+method of "pre-defining" variables is illustrated in the
+"fin-interactive.c" file for the demo interactive financial
+calculator. In essence the function "pre-defining" variables sets up
+a linked list of variable storage structures with the proper "names"
+and numeric values. The number of "pre-defined" variables and a
+pointer to the structure array is passed to the parser in the
+initialization call. After the parser is eventually exited, the
+calling function is responsible for freeing any memory used by the
+"pre-defined" variables and their final numeric representation.
+
+I think the use of "named variables" and "pre-defined" variables could
+become very useful in gnucash eventually as people get used to the
+idea. It may be useful to allow users to define variables with values
+convienent to them and that are persistent across invocations of
+gnucash.
+
+A second design goal of the parser was that it should be callable
+concurrently by multiple modules within gnucash independently. That
+each module should be capable of using differing "pre-defined"
+variables and user defined variables and even internal numeric
+representations. To that end the calling module must first initialize
+the parser with a call to "init_parser". This call creates the parser
+internal structure for subsequent calls to the parser proper. The
+structure created and returned must then be passed to subsequent calls
+to the parser. When no further calls to the parser are to be made,
+the module then calls "exit_parser" with the pointer returned by
+"init_parser", so that the parser may release dynamically allocated
+memory.
+
+The parser recognizes the following binary operators:
+ +
+ -
+ /
+ *
+ =
+ +=
+ -=
+ /=
+ *=
+
+In addition, the unary operators
+ +
+ -
+
+are recognized. All numerics are initially recognized as positive
+numbers. If negative, the unary '-' operator is applied. This saves
+the logic of having to recogize strings as
+
+ -123
+
+The logic recognizes "-" and "123" separately. The '-' unary operator
+is then applied to negate the numeric. This also has the advanatge
+that the same logic can be used for
+
+ -123
+ +123.45
+ +uvar
+ -uvar
+
+In each case, the appropriate unary operator is applied to obtain the
+desired result with no increase in the parsing logic. Thus keeping
+things as simple as possible.
+
+The parser also follows the C practice that the assignment operators
+return a value. Thus, allowing multiple assignments and assignment
+within expressions. The following expressions are all valid:
+ nni = 123
+ hnk = nni = 23.45
+ jkl = 5 * (nj = 68.9)
+
+The first time variables are used in an expression, they are
+initialized to zero, 0. Thus, even if the following variables have not
+been assigned a value previously, the following expressions are valid:
+
+nni *= 123
+ above results in zero in nni
+jk += 45.6
+ above results in 45.6 in jk
+56.8 - tyh
+ result of above is 56.8
+tgh - 45.7
+ above the same as
+-45.7
+
+After parsing the above expressions the variables nni, jk, tyh and tgh
+would all be defined.
+
+There are six functions needed to use the parser/evaluator:
+
+Note: in the last five functions, in the function paramter (parse_env_ptr pe),
+"pe" is the pointer returned by the "init_parser" function.
+
+parser_env_ptr
+init_parser(var_store_ptr predefined_vars,
+ unsigned char radix_point,
+ void *trans_numeric(unsigned char *digit_str,
+ unsigned char radix_point,
+ unsigned char **rstr),
+ void *numeric_ops(unsigned char op_sym,
+ void *left_value,
+ void *right_value),
+ void *negate_numeric(void *value),
+ void free_numeric(void *numeric_value));
+
+This function is called by the gnucash module/function/whatever to
+initialize the parser. The parser returns a pointer to a structure
+that contains all relevant information for parsering strings. The
+pointer is returned as (void *) since all information is and should
+remain pertinent only to the parser. The calling function(s) should
+never rely on manipulating any information inside this structure
+directly, since it may and could change in the future.
+
+ -- The first parameter is a pointer to an array of "pre-defined"
+ variables the caller wishes to use with subsequent calls to
+ the parser.
+ -- The second parameter is the radix character to use in numeric
+ strings in subsequent calls to the parser. The parser needs this
+ information to recognize numeric strings of the form
+ ".123", where '.' is the radix.
+ -- The third, fourth, fifth, and sixth parameters are the functions
+ I descibed above for the internal numeric representation desired
+ by the calling function(s).
+
+void exit_parser(parser_env_ptr pe);
+
+This function is called to exit the parser and free all dynamically
+allocated memory used by the parser for an internal stack and user
+defined variables.
+
+unsigned get_parse_error(parser_env_ptr pe);
+
+Whenever the parser encounters an error in parsing/evaluating a
+string, it returns a NULL pointer instead of a valid pointer to a
+variable storage structure. This call returns an unsigned integer
+designating the error encountered. The possible values are defined in
+the "finvar.h" file. A function "parse_error" has been defined in the
+file "fin-interactive.c" illustrating how to use this function and
+pin-point for the user the exact location of the error.
+
+var_store_ptr get_vars(parser_env_ptr pe)
+
+This function returns a pointer to a linked list of variable storage
+structures containing the user defined named variables if any
+exist. NULL is returned if none exist. An illustration of using this
+function is contained in the "main" function in the
+"fin-interactive.c" file. The calling function should not alter the
+variable names. The numeric values may be altered if the calling
+function really knows what it is doing.
+
+unsigned delete_var(unsigned char *var_name,
+ parse_env_ptr pe);
+
+This function will delete the user defined named variable with a name
+identical to the name string passed in the first parameter. If no user
+defined variable exists with an identical name, zero, 0, returned. If
+the delete operation is successful, one, 1, is returned.
+
+unsigned char *parse_string(var_store_ptr value,
+ unsigned char *string,
+ parser_env_ptr pe);
+
+This function parses the string passed in the second parameter and
+returns a pointer to the last character not recognized upon a parsing
+error. If no error occurred, NULL is returned. The first parameter
+specifies a variable storage structure to contain the result of the
+parser/evaluator.
+
+Note: The parser/evaluator uses a simple recursive descent parser.
+I decided on this type for the simple reason that for a simple four
+function calculator a recursive descent parser is, in my opnion, the
+easiest to construct. I also think that recursive descent parsers are
+easier for the human to understand and thus maintain. Since gnucash is
+open source and will probably have many maintainers in its history,
+the later point is probably the more relevant.
+
+Also, the parser uses a stack which is dynamically allocated in memory
+and can grow as needed. I have not provided any mechanism for
+shrinking the stack. The initial stack size is set at 50. I really do
+not anticipate that under normal and even most extreme cases, that it
+will ever approach that size in actual use. Under "normal" operation,
+the stack will probably never exceed 3 or 4 in size and 50 is probably
+an overkill for normal use. However, since the stack is pointers and
+not entire structures, a stack size of 50 is not that much memory and
+can be tolerated by most users. Thus, a mechanism for shrinking the
+stack will probably never be needed.
Copied: gnucash/trunk/src/app-utils/calculation/amort_opt.c (from rev 22074, gnucash/trunk/src/calculation/amort_opt.c)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/amort_opt.c (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/amort_opt.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,151 @@
+/***************************************************************************
+ amort_opt.c - description
+ -------------------
+ begin : Thursday June 15 2000
+ email : tboldt at attglobal.net
+ Author : Terry D. Boldt
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+/*
+ * Functions to determine amortizations options
+ * 7-2-2000
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "finvar.h"
+#include "finproto.h"
+#include "fin_spl_protos.h"
+
+amort_sched_ptr amort_opt(
+ amort_sched_ptr amortsched,
+ void *parse_env)
+{
+ char buffer[200], *errp;
+ unsigned long ii;
+ unsigned prec = amortsched->prec;
+ var_store value;
+ numeric_ptr nval;
+ struct tm *times_E,
+ *times_I;
+
+ /* print amortization options */
+ times_E = (struct tm *)calloc(1, sizeof(struct tm));
+ ii = amortsched->Eff_Date_jdn;
+ times_E->tm_mday = amortsched->day_E;
+ times_E->tm_mon = amortsched->month_E - 1;
+ times_E->tm_year = amortsched->year_E - 1900;
+ times_E->tm_wday = (ii + 1) % 7;
+ times_E->tm_yday = amortsched->yday_E;
+
+ times_I = (struct tm *)calloc(1, sizeof(struct tm));
+ ii = amortsched->Init_Date_jdn;
+ times_I->tm_mday = amortsched->day_I;
+ times_I->tm_mon = amortsched->month_I - 1;
+ times_I->tm_year = amortsched->year_I - 1900;
+ times_I->tm_wday = (ii + 1) % 7;
+ times_I->tm_yday = amortsched->yday_I;
+
+ printf("\n******************************");
+ qof_strftime(buffer, (size_t)50, "%c", times_E);
+ printf("\nEffective Date: %s\n", buffer);
+ qof_strftime(buffer, (size_t)50, "%c", times_I);
+ printf("Initial Payment Date: %s\n", buffer);
+ free(times_E);
+ free(times_I);
+ printf("The Original Present Value (pv) is: %.*f\n", (int)prec, amortsched->pv);
+ printf("The Original Periodic Payment (pmt) is: %.*f\n", (int)prec, amortsched->pmt);
+ printf("The Original Future Value (fv) is: %.*f\n", (int)prec, amortsched->fv);
+
+ printf("The Delayed Present Value (pve) is: %.*f\n", (int)prec, amortsched->pve);
+ printf("The New Periodic Payment (pmt) for pve is: %.*f\n\n", (int)prec, amortsched->new_pmt);
+
+ printf("The amortization options are:\n");
+ printf("1 -- Amortize with Original Amount and Constant Payment to Principal: %.*f\n", (int) prec, amortsched->cpmt1);
+ printf(" and final payment: %.*f\n", (int)prec, amortsched->final_pmt_opt_1);
+ printf("2 -- Amortize with Delayed Amount and Constant Payment to Principal: %.*f\n", (int)prec, amortsched->cpmt2);
+ printf(" and final payment: %.*f\n", (int)prec, amortsched->final_pmt_opt_2);
+ printf("3 -- Amortize with Original Transaction Values\n");
+ printf(" and final payment: %.*f\n", (int)prec, amortsched->final_pmt_opt_3);
+ printf("4 -- Amortize with Delayed Amount, Original Periodic Payment\n");
+ printf(" and final payment: %.*f\n", (int)prec, amortsched->final_pmt_opt_4);
+ printf("5 -- Amortize with Delayed Amount, New Periodic Payment\n");
+ printf(" and final payment: %.*f\n", (int)prec, amortsched->final_pmt_opt_5);
+ if ( amortsched->new_n )
+{
+ printf("6 -- Amortize with Original Amount, Original Periodic Payment,\n");
+ printf(" new number of total payments (n): %u\n", amortsched->new_n);
+ printf(" and final payment: %.*f\n", (int)prec, amortsched->final_pmt_opt_6);
+ } /* endif */
+ printf("Enter choice 1, 2, 3, 4, 5 or 6: ");
+ fgets(buffer, 190, stdin);
+ amortsched->option = buffer[0] - '0';
+
+ printf("Amortization Schedule:\n");
+ printf("y -- Yearly Summary\n");
+ printf("p -- Periodic Payment\n");
+ if ( amortsched->option < 3 )
+ {
+ printf("Enter Choice y or p: ");
+ }
+ else
+ {
+ printf("f -- Fixed Advanced Payment\n");
+ printf("a -- Variable Advanced Payment\n");
+ printf("Enter Choice y, p, f or a: ");
+ } /* endif */
+ fgets(buffer, 190, stdin);
+ amortsched->summary = buffer[0];
+
+ if ( amortsched->summary == 'f' )
+ {
+ if ( amortsched->fixed_pmt != 0.0 )
+ {
+ printf("Current Fixed Prepayment: %.*f\nChange Fixed Prepayment? (y/n): ", (int)prec, amortsched->fixed_pmt);
+ fgets(buffer, 190, stdin);
+ }
+ else
+ {
+ buffer[0] = 'y';
+ } /* endif */
+
+ if ( buffer[0] == 'y' )
+ {
+ printf("Enter Fixed Prepayment Amount: ");
+ fgets(buffer, 190, stdin);
+ if ( (errp = parse_string(&value, buffer, parse_env)) == NULL )
+ {
+ nval = (numeric_ptr)(value.value);
+ switch ( nval->type )
+ {
+ case INT_TYPE:
+ amortsched->fixed_pmt = (double)(nval->value.int_value);
+ break;
+ case DBL_TYPE:
+ amortsched->fixed_pmt = nval->value.dbl_value;
+ break;
+ } /* endswitch */
+ if ( !value.variable_name ) free_numeric(value.value);
+ }
+ else
+ {
+ parse_error(get_parse_error(parse_env), buffer, errp);
+ } /* endif */
+ } /* endif */
+ } /* endif */
+
+ return amortsched;
+} /* amort_opt */
Copied: gnucash/trunk/src/app-utils/calculation/amort_prt.c (from rev 22074, gnucash/trunk/src/calculation/amort_prt.c)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/amort_prt.c (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/amort_prt.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,307 @@
+/***************************************************************************
+ amort_prt.c - description
+ -------------------
+ begin : Thursday June 15 2000
+ email : tboldt at attglobal.net
+ Author : Terry D. Boldt
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+/*
+ * Functions to print amortization schedules
+ * 6-15-2000
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <mcheck.h>
+
+#include "finvar.h"
+#include "finproto.h"
+#include "fin_spl_protos.h"
+
+
+void prt_amortization_schedule(
+ amort_sched_ptr amortsched, /* amortization schedule to print */
+ FILE *ofile) /* output file */
+{
+ unsigned j,
+ jj,
+ prec = amortsched->prec,
+ option = amortsched->option,
+ fv_case = amortsched->fv_case;
+ unsigned char datel[100],
+ summary = amortsched->summary;
+ struct tm *times_E,
+ *times_I;
+ amort_sched_yr_ptr amortyr,
+ prst_yr;
+ sched_pmt_ptr pmtsched = NULL;
+ yearly_summary_ptr annual_summary;
+
+ times_E = (struct tm *)calloc(1, sizeof(struct tm));
+ times_E->tm_mday = amortsched->day_E;
+ times_E->tm_mon = amortsched->month_E - 1;
+ times_E->tm_year = amortsched->year_E - 1900;
+ times_E->tm_wday = (amortsched->Eff_Date_jdn + 1) % 7;
+ times_E->tm_yday = amortsched->yday_E;
+
+ times_I = (struct tm *)calloc(1, sizeof(struct tm));
+ times_I->tm_mday = amortsched->day_I;
+ times_I->tm_mon = amortsched->month_I - 1;
+ times_I->tm_year = amortsched->year_I - 1900;
+ times_I->tm_wday = (amortsched->Init_Date_jdn + 1) % 7;
+ times_I->tm_yday = amortsched->yday_I;
+
+ fprintf(ofile, "Amortization Table\n");
+ qof_strftime(datel, (size_t)100, "%c", times_E);
+ fprintf(ofile, "Effective Date: %s\n", datel);
+ qof_strftime(datel, (size_t)100, "%c", times_I);
+ fprintf(ofile, "Initial Payment Date: %s\n", datel);
+ fprintf(ofile, "Compounding Frequency per year: %u\n", amortsched->CF);
+ fprintf(ofile, "Payment Frequency per year: %u\n", amortsched->PF);
+ fprintf(ofile, "Compounding: %s\n", (amortsched->disc ? "Discrete" : "Continuous"));
+ fprintf(ofile, "Payments: %s\n", (amortsched->bep ? "Beginning of Period" : "End of Period"));
+ fprintf(ofile, "Payments (%u): %.*f\n", amortsched->n - 1, (int)prec, (option < 3) ? amortsched->cpmt : (option == 5) ? amortsched->new_pmt : amortsched->pmt);
+ fprintf(ofile, "Final payment (%u): %.*f\n", amortsched->n, (int)prec, amortsched->final_pmt);
+ if ( (amortsched->CF == 1) && (amortsched->PF == 1) ) fprintf(ofile, "Nominal Interest per Payment Period: %g\t(Annualized: %g)\n", amortsched->nint, amortsched->nint * 12);
+ else fprintf(ofile, "Nominal Annual Interest Rate: %g\n", amortsched->nint);
+ fprintf(ofile, " Effective Interest Rate Per Payment Period: %g\n", amortsched->eint);
+ fprintf(ofile, "Present Value: %.*f\n", (int)prec, amortsched->pv);
+ if ( (amortsched->option == 2) || (amortsched->option > 3) )
+{
+ fprintf(ofile, "Interest due to Delayed Intial Payment: %.*f\n", (int)prec, amortsched->delayed_int);
+ } /* endif */
+
+ free(times_E);
+ free(times_I);
+
+ if ( amortsched->option < 3 )
+ {
+ summary = (summary == 'y') ? 'x' : 'o';
+ } /* endif */
+
+ switch ( summary )
+ {
+ case 'a':
+ /* variable prepayment schedule
+ */
+ fprintf(ofile, "Advanced Prepayment Amortization - Variable Prepayment\n");
+ amortyr = amortsched->schedule.first_yr;
+ for ( j = amortsched->total_periods , jj = 0 ; j && amortyr ; j-- )
+ {
+ if ( !jj )
+ {
+ fprintf(ofile, "Pmt * Interest Principal Prepay Total Pmt Balance\n");
+ pmtsched = amortyr->payments;
+ jj = amortyr->num_periods;
+ } /* endif */
+
+ fprintf(ofile, "%4u %12.*f %12.*f %12.*f %12.*f %12.*f\n",
+ pmtsched->period_num,
+ (int)prec, pmtsched->interest,
+ (int)prec, pmtsched->principal,
+ (int)prec, pmtsched->advanced_pmt,
+ (int)prec, pmtsched->total_pmt,
+ (int)prec, pmtsched->balance);
+
+ if ( !--jj )
+ {
+ fprintf(ofile, "Summary for: %u:\n", amortyr->year);
+ fprintf(ofile, " Interest Paid: %.*f\n", (int)prec, amortyr->interest_pd);
+ fprintf(ofile, " Principal Paid: %.*f\n", (int)prec, amortyr->principal_pd);
+ fprintf(ofile, " Year Ending Balance: %.*f\n", (int)prec, amortyr->yr_end_balance);
+ fprintf(ofile, " Sum of Interest Paid: %.*f\n", (int)prec, amortyr->total_interest_pd);
+ prst_yr = amortyr;
+ amortyr = amortyr->next_yr;
+ }
+ else
+ {
+ pmtsched++;
+ } /* endif */
+ } /* endfor */
+ break;
+ case 'f':
+ /* fixed prepayment schedule
+ */
+ fprintf(ofile, "Advanced Prepayment Amortization - Fixed Prepayment: %.*f\n", (int)prec, amortsched->fixed_pmt);
+ amortyr = amortsched->schedule.first_yr;
+ for ( j = amortsched->total_periods , jj = 0 ; j && amortyr ; j-- )
+ {
+ if ( !jj )
+ {
+ fprintf(ofile, "Pmt * Interest Principal Prepay Total Pmt Balance\n");
+ pmtsched = amortyr->payments;
+ jj = amortyr->num_periods;
+ } /* endif */
+
+ fprintf(ofile, "%4u %12.*f %12.*f %12.*f %12.*f %12.*f\n",
+ pmtsched->period_num,
+ (int)prec, pmtsched->interest,
+ (int)prec, pmtsched->principal,
+ (int)prec, pmtsched->advanced_pmt,
+ (int)prec, pmtsched->total_pmt,
+ (int)prec, pmtsched->balance);
+
+ if ( !--jj )
+ {
+ fprintf(ofile, "Summary for: %u:\n", amortyr->year);
+ fprintf(ofile, " Interest Paid: %.*f\n", (int)prec, amortyr->interest_pd);
+ fprintf(ofile, " Principal Paid: %.*f\n", (int)prec, amortyr->principal_pd);
+ fprintf(ofile, " Year Ending Balance: %.*f\n", (int)prec, amortyr->yr_end_balance);
+ fprintf(ofile, " Sum of Interest Paid: %.*f\n", (int)prec, amortyr->total_interest_pd);
+ prst_yr = amortyr;
+ amortyr = amortyr->next_yr;
+ }
+ else
+ {
+ pmtsched++;
+ } /* endif */
+ } /* endfor */
+ break;
+ case 'o':
+ /* constant payment to principal
+ */
+ fprintf(ofile, "Constant Payment to Principal: %.*f\n", (int)prec, amortsched->cpmt);
+ amortyr = amortsched->schedule.first_yr;
+ for ( j = amortsched->total_periods , jj = 0 ; j && amortyr ; j-- )
+ {
+ if ( !jj )
+ {
+ fprintf(ofile, "Pmt# Interest Total Payment Balance\n");
+ pmtsched = amortyr->payments;
+ jj = amortyr->num_periods;
+ } /* endif */
+
+ fprintf(ofile, "%4u %12.*f %12.*f %12.*f\n",
+ pmtsched->period_num,
+ (int)prec, pmtsched->interest,
+ (int)prec, pmtsched->total_pmt,
+ (int)prec, pmtsched->balance);
+
+ if ( !--jj )
+ {
+ fprintf(ofile, "Summary for: %u:\n", amortyr->year);
+ fprintf(ofile, " Interest Paid: %.*f\n", (int)prec, amortyr->interest_pd);
+ fprintf(ofile, " Principal Paid: %.*f\n", (int)prec, amortyr->principal_pd);
+ fprintf(ofile, " Year Ending Balance: %.*f\n", (int)prec, amortyr->yr_end_balance);
+ fprintf(ofile, " Sum of Interest Paid: %.*f\n", (int)prec, amortyr->total_interest_pd);
+ prst_yr = amortyr;
+ amortyr = amortyr->next_yr;
+ }
+ else
+ {
+ pmtsched++;
+ } /* endif */
+ } /* endfor */
+ break;
+ case 'p':
+ /* normal payment schedule
+ */
+ fprintf(ofile, "Normal Amortization Schedule\n");
+ amortyr = amortsched->schedule.first_yr;
+ for ( j = amortsched->total_periods - 1 , jj = 0 ; j && amortyr ; j-- )
+ {
+ if ( !jj )
+ {
+ fprintf(ofile, amortsched->fv_case ? "Pmt * Interest Balance\n" : "Pmt * Interest Principal Balance\n");
+ pmtsched = amortyr->payments;
+ jj = amortyr->num_periods;
+ } /* endif */
+
+ if ( fv_case )
+ {
+ fprintf(ofile, "%4u %12.*f %12.*f\n",
+ pmtsched->period_num,
+ (int)prec, pmtsched->interest,
+ (int)prec, pmtsched->balance);
+ }
+ else
+ {
+ fprintf(ofile, "%4u %12.*f %12.*f %12.*f\n",
+ pmtsched->period_num,
+ (int)prec, pmtsched->interest,
+ (int)prec, pmtsched->principal,
+ (int)prec, pmtsched->balance);
+ } /* endif */
+
+ if ( !--jj )
+ {
+ fprintf(ofile, "Summary for: %u:\n", amortyr->year);
+ fprintf(ofile, " Interest Paid: %.*f\n", (int)prec, amortyr->interest_pd);
+ if ( !fv_case ) fprintf(ofile, " Principal Paid: %.*f\n", (int)prec, amortyr->principal_pd);
+ fprintf(ofile, " Year Ending Balance: %.*f\n", (int)prec, amortyr->yr_end_balance);
+ fprintf(ofile, " Sum of Interest Paid: %.*f\n", (int)prec, amortyr->total_interest_pd);
+ prst_yr = amortyr;
+ amortyr = amortyr->next_yr;
+ }
+ else
+ {
+ pmtsched++;
+ } /* endif */
+ } /* endfor */
+
+ if ( !jj )
+ {
+ fprintf(ofile, amortsched->fv_case ? "Pmt * Interest Balance\n" : "Pmt * Interest Principal Balance\n");
+ pmtsched = amortyr->payments;
+ } /* endif */
+
+ fprintf(ofile, "Final Payment: %.*f\n", (int)prec, amortyr->final_pmt);
+
+ if ( fv_case )
+ {
+ fprintf(ofile, "%4u %12.*f %12.*f\n",
+ pmtsched->period_num,
+ (int)prec, pmtsched->interest,
+ (int)prec, pmtsched->balance);
+ }
+ else
+ {
+ fprintf(ofile, "%4u %12.*f %12.*f %12.*f\n",
+ pmtsched->period_num,
+ (int)prec, pmtsched->interest,
+ (int)prec, pmtsched->principal,
+ (int)prec, pmtsched->balance);
+ } /* endif */
+
+ fprintf(ofile, "Summary for: %u:\n", amortyr->year);
+ fprintf(ofile, " Interest Paid: %.*f\n", (int)prec, amortyr->interest_pd);
+ if ( !fv_case ) fprintf(ofile, " Principal Paid: %.*f\n", (int)prec, amortyr->principal_pd);
+ fprintf(ofile, " Year Ending Balance: %.*f\n", (int)prec, amortyr->yr_end_balance);
+ fprintf(ofile, " Sum of Interest Paid: %.*f\n", (int)prec, amortyr->total_interest_pd);
+ break;
+ case 'x':
+ /* constant payment to principal - annual summary
+ */
+ case 'y':
+ /* normal payment - annual summary
+ */
+ if ( summary == 'x' ) fprintf(ofile, "Annual Summary - Constant Payment to Principal: %.*f\n", (int)prec, amortsched->cpmt);
+ else fprintf(ofile, "Annual Summary - Normal Amortization\n");
+ fprintf(ofile, "Year Interest Ending Balance\n");
+ annual_summary = amortsched->schedule.summary;
+ for ( j = amortsched->total_periods , jj = 0 ; j ; j-- , jj++ )
+ {
+ fprintf(ofile, "%4u %12.*f %12.*f\n",
+ annual_summary[jj].year,
+ (int)prec, annual_summary[jj].interest,
+ (int)prec, annual_summary[jj].end_balance);
+ } /* endfor */
+ break;
+ } /* endswitch */
+
+ fprintf(ofile, "\nTotal Interest: %.*f\n", (int)prec, amortsched->total_interest);
+
+} /* prt_amortization_schedule */
Copied: gnucash/trunk/src/app-utils/calculation/expression_parser.c (from rev 22074, gnucash/trunk/src/calculation/expression_parser.c)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/expression_parser.c (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/expression_parser.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,1267 @@
+/***************************************************************************
+ expression-parser.c - description
+ -------------------
+ begin : Wednesday June 21 2000
+ email : tboldt at attglobal.net
+ Author : Terry D. Boldt
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+/*
+ * Functions to parse arthmetic expressions
+ * 6-21-2000
+ */
+
+/* Modified to support functions - Summer, 2002 -- jsled at asynchronous.org */
+
+/* expression parser/evaluator use:
+ *
+ * Before describing the parser per se, I want to describe the
+ * structures used to contain the results returned from the
+ * parser. The structure is defined in "finvar.h":
+ *
+ * typedef struct var_store *var_store_ptr;
+ *
+ * typedef struct var_store {
+ * char *variable_name;
+ * char use_flag;
+ * char assign_flag;
+ * void *value;
+ * var_strore_ptr next_var;
+ * } var_store;
+ *
+ * The "use_flag" variable is for internal use of the parser and can
+ * be ignored by the user. The "variable_name" variable possibly
+ * points to a string containing the name of the value returned, a
+ * "variable name". If NULL, then this is a temporary value. The
+ * "value" variable points to a user defined structure containing the
+ * numeric value of the variable.
+ *
+ * As well, variables now have a VarStoreType, to distinguish between numeric
+ * and string values, as we want string arguments to functions.
+ *
+ * In designing and writing the parser, I decided early on that the
+ * parser should be an "expression parser/evaluator" and that the
+ * actual arithmetic was the responsibility of the caller/user.
+ *
+ * I decided that the parser should be totally independent of the
+ * numeric representation used, and thus the exact details of how the
+ * arithmetic was performed. To accomplish this, four functions are
+ * supplied by the user/caller:
+ *
+ * 1: trans_numeric - this function translates the text string into a
+ * numeric in the desired representation and returns a pointer to the
+ * representation as a (void *) this function has four parameters
+ * passed:
+ *
+ * 1: digit_str -- the actual text string of the
+ * numeric to be converted to the internal
+ * representation
+ *
+ * 2: radix_point -- the ASCII character used to
+ * represent the radix point
+ *
+ * 3: group character -- the ASCII character used
+ * to separate and group digits to the left of the
+ * radix
+ *
+ * 4: rstr -- a pointer to a location in which to
+ * return a pointer to the first character not
+ * part of the numeric string translated If this
+ * pointer is NULL, do not return a value. This
+ * parameter is the same as the second parameter
+ * of the standard C library functions "strtod" or
+ * "strtol"
+ *
+ * 2: numeric_ops - this function does the actual arithmetic on two
+ * numeric quantities in internal representation. It has three
+ * parameters passed:
+ *
+ * 1: op_sym -- the numeric operation to be
+ * performed. The possible values are defined
+ * in "finvar.h" and are:
+ *
+ * ADD_OP - addition
+ * SUB_OP - subtraction
+ * DIV_OP - division
+ * MUL_OP - multiplication
+ * ASN_OP - assignment
+ *
+ * 2: left_value - the left hand operand of the
+ * binary operator
+ *
+ * 3: right_value - the right hand operand of
+ * the binary operator Note: left_value and
+ * right_value are passed as (void *). This
+ * function is responsible for casting to the
+ * proper type to use. Note: this function should
+ * make no assumptions about overwriting or
+ * re-using either left_value or right_value,
+ * except for ASN_OP. Both values passed must be
+ * left unchanged by any operation except ASN_OP.
+ * This function is also responsible for
+ * allocating/freeing memory as necessary to
+ * perform the designated function and returning
+ * the result. I STRONGLY suggest that the result
+ * be returned in dynamically allocated memory. If
+ * static memory is used, the parser has no means
+ * of copying the returned result or managing
+ * static memory to prevent overwriting the result
+ * and invalidating the result.
+ *
+ * 3: negate_numeric - this function negates the value passed (as a (void *))
+ *
+ * 4: free_numeric - this function is responsible for freeing memory
+ * used by the internal numeric representation.
+ *
+ * 5: func_op - this function is repsonsible for handling function calls.
+ *
+ * I have included the file "numeric_ops.c" containing the above
+ * functions for the usual "double" and "int" representation of
+ * numerics. The functions perform integer or floating point
+ * operations as appropriate for the string entered by the user. The
+ * division operation is done in "double" since I do not think that
+ * anybody really wants (9 / 2) to equal 4 instead of 4.5 for
+ * financial operations. These functions use the structure defined in
+ * finvar.h:
+ *
+ * typedef struct numeric *numeric_ptr;
+ * typedef struct numeric {
+ * char type;
+ * union {
+ * long int int_value;
+ * double dbl_value;
+ * } value;
+ * } numeric;
+ *
+ * to contain all numeric values. The variable "type" in this
+ * structure can have the values:
+ *
+ * INT_TYPE
+ * DBL_TYPE
+ *
+ * which are defined in "finvar.h".
+ *
+ * All "named variables", variables defined by the user for storing
+ * intermediate results for future reference/use, and temporary
+ * variables used by the parser use the variable storage structure,
+ * var_store, defined above. The result of parsing and evaluating the
+ * string passed are returned in a variable storage structure
+ * specified by the caller.
+ *
+ * If the returned variable value is not named, i.e., "variable_name
+ * == NULL", then the user/caller is responsible for freeing the
+ * memory used by the internal representation of the numeric value.
+ * If, however, "variable_name != NULL", freeing the memory used by
+ * the internal numeric representation will cause a segmentation fault
+ * later, when the parser attempts to free the memory through a call
+ * to "free_numeric". In addition, freeing the memory will probably
+ * invalidate the numeric value contained therein and lead to
+ * pernicuous results when the value is used.
+ *
+ * If "variable_name != NULL", the user/caller should never attempt to
+ * free this memory, that is the sole responsibility of the parser.
+ *
+ * It may be that the calling function has certain "variables" that
+ * need to be "pre-defined" for the user to manipulate. In essence
+ * the function "pre-defining" variables sets up a linked list of
+ * variable storage structures with the proper "names" and numeric
+ * values. The number of "pre-defined" variables and a pointer to the
+ * structure array is passed to the parser in the initialization
+ * call. After the parser is eventually exited, the calling function
+ * is responsible for freeing any memory used by the "pre-defined"
+ * variables and their final numeric representation.
+ *
+ * There may also be strings in the expression, by quoting them in '"'
+ * characters. These are intended to be passed literally into functions; the
+ * result of using a string in a numeric operation is undefined. Presently,
+ * the expression-parser code does not check the variable types during
+ * parsing or evaluation.
+ *
+ * A second design goal of the parser was that it should be callable
+ * concurrently by multiple modules independently. That each module
+ * should be capable of using differing "pre-defined" variables and
+ * user defined variables and even internal numeric representations.
+ * To that end the calling module must first initialize the parser
+ * with a call to "init_parser". This call creates the parser
+ * internal structure for subsequent calls to the parser proper. The
+ * structure created and returned must then be passed to subsequent
+ * calls to the parser. When no further calls to the parser are to be
+ * made, the module then calls "exit_parser" with the pointer returned
+ * by "init_parser", so that the parser may release dynamically
+ * allocated memory.
+ *
+ * The parser recognizes the following binary operators:
+ *
+ * +
+ * -
+ * /
+ * *
+ * =
+ * +=
+ * -=
+ * /=
+ * *=
+ *
+ * In addition, the unary operators
+ *
+ * +
+ * -
+ *
+ * are recognized. All numerics are initially recognized as positive
+ * numbers. If negative, the unary '-' operator is applied. This saves
+ * the logic of having to recogize strings as
+ *
+ * -123
+ *
+ * The logic recognizes "-" and "123" separately. The '-' unary
+ * operator is then applied to negate the numeric. This also has the
+ * advanatge that the same logic can be used for
+ *
+ * -123
+ * +123.45
+ * +uvar
+ * -uvar
+ *
+ * In each case, the appropriate unary operator is applied to obtain
+ * the desired * result with no increase in the parsing logic. Thus
+ * keeping things as simple as possible.
+ *
+ * The parser also follows the C practice that the assignment
+ * operators return a value. Thus, allowing multiple assignments and
+ * assignment within expressions. The following expressions are all
+ * valid:
+ *
+ * nni = 123
+ * hnk = nni = 23.45
+ * jkl = 5 * (nj = 68.9)
+ *
+ * The first time variables are used in an expression, they are
+ * initialized to zero, 0. Thus, even if the following variables have
+ * not been assigned a value previously, the following expressions are
+ * valid:
+ *
+ * nni *= 123
+ * above results in zero in nni
+ * jk += 45.6
+ * above results in 45.6 in jk
+ * 56.8 - tyh
+ * result of above is 56.8
+ * tgh - 45.7
+ * above the same as
+ * -45.7
+ *
+ * After parsing the above expressions the variables nni, jk, tyh and
+ * tgh would all be defined.
+ *
+ * Functions are invoked with expressions of the format
+ *
+ * [_a-zA-Z]( <argument_0> : <argument_1> : ... : <argument_n> )
+ *
+ * where each argument can itself be a sub-expression [arithmetic operation
+ * or function call].
+ *
+ *
+ * There are six parser functions needed to use the parser/evaluator:
+ *
+ * Note: in the last five functions, in the function paramter (void
+ * *vp), "vp" is the pointer returned by the "init_parser" function.
+ *
+ * void *init_parser(var_store_ptr predefined_vars,
+ * gchar *radix_point,
+ * gchar *group_char,
+ * void *trans_numeric(char *digit_str,
+ * gchar *radix_point,
+ * gchar *group_char,
+ * char **rstr),
+ * void *numeric_ops(char op_sym,
+ * void *left_value,
+ * void *right_value),
+ * void *negate_numeric(void *value),
+ * void free_numeric(void *numeric_value),
+ * void *func_op(const char *fname, int argc, void **argv));
+ *
+ * This function is called by the module/function/whatever to
+ * initialize the parser. The parser returns a pointer to a
+ * structure that contains all relevant information for
+ * parsering strings. The pointer is returned as (void *)
+ * since all information is and should remain pertinent only
+ * to the parser. The calling function(s) should never rely on
+ * manipulating any information inside this structure
+ * directly, since it may and could change in the future. --
+ * The first parameter is a pointer to a the first element in
+ * a linked list of "pre-defined" variables the caller wishes
+ * to use with subsequent calls to the parser. -- The second
+ * parameter is the radix character to use in numeric strings
+ * in subsequent calls to the parser. -- the third parameter
+ * is the optional character used for grouping digits to the
+ * left of the radix. -- The fourth, fifth, sixth and seventh
+ * parameters are the functions I descibed above for the
+ * internal numeric representation desired by the calling
+ * function(s).
+ *
+ * void exit_parser(
+ * void *vp);
+ *
+ * This function is called to exit the parser and free all
+ * dynamically allocated memory used by the parser for an
+ * internal stack and user defined variables.
+ *
+ * unsigned get_parse_error(
+ * void *vp);
+ *
+ * If the parser is successful in complete parsing and
+ * evaluating the string passed to 'parse_string' below, that
+ * functions returns a NULL pointer. If, however, an error is
+ * encountered in parsing/evaluating the string, the
+ * 'parse_string' function returns a pointer to the character
+ * which caused the error. This call returns an unsigned
+ * integer designating the error encountered. The possible
+ * values are defined in the "finvar.h" file.
+ *
+ * var_store_ptr parser_get_vars(
+ * void *vp)
+ *
+ * This function returns a pointer to the first element of a
+ * linked list of variable storage structures containing the
+ * user defined named variables if any exist. NULL is
+ * returned if none exist. The calling function should not
+ * alter the variable names. The numeric values may be
+ * altered if the calling function author really knows what
+ * they are doing.
+ *
+ * unsigned delete_var(
+ * char *var_name,
+ * void *vp);
+ *
+ * This function will delete the user defined named variable
+ * with a name identical to the name string passed in the
+ * first parameter. If no user defined variable exists with an
+ * identical name, zero, 0, is returned. If the delete
+ * operation is successful, one, 1, is returned.
+ *
+ * char *parse_string(
+ * var_store_ptr value,
+ * char *string,
+ * void *vp);
+ *
+ * This function parses the string passed in the second
+ * parameter and returns a pointer to the last character not
+ * recognized upon a parsing error. If no error occurred, NULL
+ * is returned. The first parameter is a pointer to a variable
+ * storage structure to contain the result of the
+ * parser/evaluator.
+ *
+ * Note: The parser/evaluator uses a simple recursive descent
+ * parser. I decided on this type for the simple reason that for a
+ * simple four function calculator a recursive descent parser is, in
+ * my opinion, the easiest to construct. I also think that recursive
+ * descent parsers are easier for the human to understand and thus
+ * maintain.
+ *
+ * Also, the parser uses a stack which is dynamically allocated in
+ * memory and can grow as needed. I have not provided any mechanism
+ * for shrinking the stack. The initial stack size is set at 50
+ * slots. I really do not anticipate that under normal and even most
+ * extreme cases, that it will ever approach that size in actual
+ * use. Under "normal" operation, the stack will probably never exceed
+ * 3 or 4 slots in size and 50 slots is probably an overkill for
+ * normal use. However, since the stack is pointers and not entire
+ * structures, a stack size of 50 slots is not that much memory and
+ * can be tolerated by most users. Thus, a mechanism for shrinking the
+ * stack will probably never be needed.
+ */
+
+#include "config.h"
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <glib.h>
+
+#include "qof.h"
+
+#define EXPRESSION_PARSER_STATICS
+#include "finvar.h"
+
+#define MAX_FUNC_ARG_LEN 255
+
+/* structure to hold parser environment - environment particular to
+ * each caller */
+typedef struct parser_env
+{
+ unsigned stack_cnt;
+ unsigned stack_size;
+ var_store_ptr *stack;
+ var_store_ptr predefined_vars;
+ var_store_ptr named_vars;
+ var_store_ptr unnamed_vars;
+
+ const char *parse_str;
+ gchar *radix_point;
+ gchar *group_char;
+ char name[128];
+
+ char Token;
+ char asn_op;
+
+ char *tokens;
+ char *token_tail;
+
+ ParseError error_code;
+
+ void *numeric_value;
+
+ void *(*trans_numeric) (const char *digit_str,
+ gchar *radix_point, gchar *group_char, char **rstr);
+ void *(*numeric_ops) (char op_sym, void *left_value, void *right_value);
+ void *(*negate_numeric) (void *value);
+ void (*free_numeric) (void *numeric_value);
+ void *(*func_op)( const char *fname, int argc, void **argv );
+}
+parser_env;
+
+#include "finproto.h"
+#include "fin_static_proto.h"
+#include "fin_spl_protos.h"
+
+#define FN_TOKEN 'F'
+#define ARG_TOKEN ':'
+#define VAR_TOKEN 'V'
+#define NUM_TOKEN 'I'
+#define STR_TOKEN '"'
+
+#define STACK_INIT 50
+
+#define UNNAMED_VARS 100
+
+#define NAMED_INCR 5
+
+static char allowed_operators[] = "+-*/()=:";
+
+parser_env_ptr
+init_parser (var_store_ptr predefined_vars,
+ gchar *radix_point,
+ gchar *group_char,
+ void *trans_numeric (const char *digit_str,
+ gchar *radix_point,
+ gchar *group_char,
+ char **rstr),
+ void *numeric_ops (char op_sym,
+ void *left_value,
+ void *right_value),
+ void *negate_numeric (void *value),
+ void free_numeric (void *numeric_value),
+ void *func_op( const char *fname,
+ int argc, void **argv ))
+{
+ parser_env_ptr pe = g_new0 (parser_env, 1);
+
+ pe->predefined_vars = predefined_vars;
+
+ pe->stack = g_new0 (var_store_ptr, STACK_INIT);
+ pe->stack_size = STACK_INIT;
+
+ pe->radix_point = radix_point;
+ pe->group_char = group_char;
+
+ pe->numeric_value = NULL;
+
+ pe->trans_numeric = trans_numeric;
+ pe->numeric_ops = numeric_ops;
+ pe->negate_numeric = negate_numeric;
+ pe->free_numeric = free_numeric;
+ pe->func_op = func_op;
+
+ return pe;
+} /* init_parser */
+
+void
+exit_parser (parser_env_ptr pe)
+{
+ var_store_ptr vars, bv;
+
+ if (pe == NULL)
+ return;
+
+ for (vars = pe->named_vars; vars; vars = bv)
+ {
+ g_free (vars->variable_name);
+ vars->variable_name = NULL;
+
+ if (vars->value)
+ pe->free_numeric (vars->value);
+ vars->value = NULL;
+
+ bv = vars->next_var;
+ g_free (vars);
+ } /* endfor */
+
+ pe->named_vars = NULL;
+
+ g_free (pe->stack);
+ pe->stack = NULL;
+
+ g_free (pe->tokens);
+ pe->tokens = NULL;
+ pe->token_tail = NULL;
+
+ if (pe->numeric_value)
+ pe->free_numeric (pe->numeric_value);
+ pe->numeric_value = NULL;
+
+ g_free (pe);
+} /* exit_parser */
+
+/* return parser error code */
+ParseError get_parse_error (parser_env_ptr pe)
+{
+ if (pe == NULL)
+ return PARSER_NO_ERROR;
+
+ return pe->error_code;
+} /* get_parse_error */
+
+/* return linked list of named variables which have been defined */
+var_store_ptr parser_get_vars (parser_env_ptr pe)
+{
+ if (pe == NULL)
+ return NULL;
+
+ return pe->named_vars;
+} /* get_vars */
+
+/* function to delete variable with specified name from named variables
+ * if it exists. If it exists return TRUE, 1, else return FALSE, 0 */
+unsigned
+delete_var (char *var_name, parser_env_ptr pe)
+{
+ unsigned ret = FALSE;
+ var_store_ptr nv, tv;
+
+ if (pe == NULL)
+ return FALSE;
+
+ for (nv = pe->named_vars, tv = NULL; nv; tv = nv, nv = nv->next_var)
+ {
+ if (strcmp (nv->variable_name, var_name) == 0)
+ {
+ if (tv)
+ tv->next_var = nv->next_var;
+ else
+ pe->named_vars = nv->next_var;
+
+ g_free (nv->variable_name);
+ nv->variable_name = NULL;
+
+ pe->free_numeric (nv->value);
+ nv->value = NULL;
+
+ g_free (nv);
+
+ ret = TRUE;
+ break;
+ } /* endif */
+ } /* endfor */
+
+ return ret;
+} /* delete_var */
+
+/* parse string passed using parser environment passed return
+ * evaluated value in numeric structure passed, return NULL if no
+ * parse error. If parse error, return pointer to character at which
+ * error occured. */
+char *
+parse_string (var_store_ptr value, const char *string, parser_env_ptr pe)
+{
+ var_store_ptr retv;
+ var_store unnamed_vars[UNNAMED_VARS];
+
+ if (!pe || !string)
+ return NULL;
+
+ pe->unnamed_vars = unnamed_vars;
+ memset (unnamed_vars, 0, UNNAMED_VARS * sizeof (var_store));
+
+ pe->parse_str = string;
+ pe->error_code = PARSER_NO_ERROR;
+
+ g_free (pe->tokens);
+ pe->tokens = g_new0(char, strlen (string) + 1);
+ pe->token_tail = pe->tokens;
+
+ next_token (pe);
+
+ if (!pe->error_code)
+ assignment_op (pe);
+
+ if (!pe->error_code)
+ {
+ /* interpret (num) as -num */
+ if (strcmp (pe->tokens, "(I)") == 0)
+ {
+ var_store_ptr val;
+
+ val = pop (pe);
+ pe->negate_numeric (val->value);
+ push (val, pe);
+ }
+ }
+
+ if (pe->Token == EOS)
+ {
+ if ((pe->stack_cnt) && (retv = pop (pe)))
+ {
+ if (value != NULL)
+ *value = *retv;
+ pe->parse_str = NULL;
+ }
+ else
+ pe->error_code = STACK_UNDERFLOW;
+ }
+
+ pe->stack_cnt = 0;
+ pe->unnamed_vars = NULL;
+
+ return (char *) pe->parse_str;
+} /* expression */
+
+/* pop value off value stack */
+static var_store_ptr
+pop (parser_env_ptr pe)
+{
+ var_store_ptr val;
+
+ if (pe->stack_cnt)
+ val = pe->stack[--(pe->stack_cnt)];
+ else
+ {
+ val = NULL;
+ pe->error_code = STACK_UNDERFLOW;
+ } /* endif */
+
+ return val;
+} /* pop */
+
+/* push value onto value stack */
+static var_store_ptr
+push (var_store_ptr push_value, parser_env_ptr pe)
+{
+ if (pe->stack_cnt > pe->stack_size)
+ {
+ pe->stack_size += STACK_INIT;
+ pe->stack = g_realloc (pe->stack,
+ pe->stack_size * sizeof (var_store_ptr));
+ } /* endif */
+
+ pe->stack[(pe->stack_cnt)++] = push_value;
+
+ return push_value;
+} /* push */
+
+/* get/set variable with specified name - nothing fancy just scan each
+ * variable in linked list checking for a string match return variable
+ * found if match create new variable if none found */
+static var_store_ptr
+get_named_var (parser_env_ptr pe)
+{
+ var_store_ptr retp = NULL, bv;
+
+ for (retp = pe->predefined_vars, bv = NULL; retp; retp = retp->next_var)
+ if (strcmp (retp->variable_name, pe->name) == 0)
+ break;
+
+ if (!retp && pe->named_vars)
+ for (retp = pe->named_vars; retp; bv = retp, retp = retp->next_var)
+ if (strcmp (retp->variable_name, pe->name) == 0)
+ break;
+
+ if (!retp)
+ {
+ retp = g_new0 (var_store, 1);
+ if (!pe->named_vars)
+ pe->named_vars = retp;
+ else
+ bv->next_var = retp;
+ retp->variable_name = g_strdup (pe->name);
+ retp->type = VST_NUMERIC;
+ retp->value =
+ pe->trans_numeric ("0", pe->radix_point, pe->group_char, NULL);
+ }
+
+ return retp;
+} /* get_var */
+
+/* get un-named temporary variable */
+static var_store_ptr
+get_unnamed_var (parser_env_ptr pe)
+{
+ var_store_ptr retp = NULL;
+ unsigned cntr;
+
+ for (cntr = 0; cntr < UNNAMED_VARS; cntr++)
+ if (pe->unnamed_vars[cntr].use_flag == UNUSED_VAR)
+ {
+ retp = &(pe->unnamed_vars[cntr]);
+ retp->variable_name = NULL;
+ retp->use_flag = USED_VAR;
+ retp->type = VST_NUMERIC;
+ if (retp->value)
+ {
+ pe->free_numeric (retp->value);
+ retp->value = NULL;
+ } /* endif */
+ break;
+ } /* endif */
+
+ if (retp == NULL)
+ pe->error_code = PARSER_OUT_OF_MEMORY;
+
+ return retp;
+} /* get_unnamed_var */
+
+/* mark un-named temporary variable unused */
+static void
+free_var (var_store_ptr value, parser_env_ptr pe)
+{
+ if (value == NULL)
+ return;
+
+ /* first check that not a named variable */
+ if (value->variable_name != NULL)
+ return;
+
+ value->use_flag = UNUSED_VAR;
+
+ if (value->value)
+ {
+ pe->free_numeric (value->value);
+ value->value = NULL;
+ }
+} /* free_var */
+
+static void
+add_token (parser_env_ptr pe, char token)
+{
+ pe->Token = token;
+ if ((token != EOS) || (*pe->token_tail != EOS))
+ {
+ *pe->token_tail = token;
+ pe->token_tail++;
+ }
+}
+
+/* parse next token from string */
+static void
+next_token (parser_env_ptr pe)
+{
+ char *nstr;
+ const char *str_parse = pe->parse_str;
+ void *number;
+
+ while (isspace (*str_parse))
+ str_parse++;
+
+ pe->asn_op = EOS;
+
+ /* test for end of string */
+ if (!*str_parse)
+ {
+ add_token (pe, EOS);
+ }
+ /* test for possible operator */
+ else if (strchr (allowed_operators, *str_parse))
+ {
+ add_token (pe, *str_parse++);
+ if (*str_parse == ASN_OP)
+ {
+ /* BUG/FIXME: this seems to allow '(=' and ')=' [?], neither of which
+ * make sense. */
+ if (pe->Token != ASN_OP)
+ {
+ str_parse++;
+ pe->asn_op = pe->Token;
+ add_token (pe, ASN_OP);
+ }
+ else
+ pe->error_code = UNDEFINED_CHARACTER;
+ } /* endif */
+ }
+ /* test for string */
+ else if ( *str_parse == '"' )
+ {
+ nstr = pe->name;
+ /* skip over the '"'. */
+ str_parse++;
+ do
+ {
+ *nstr++ = *str_parse++;
+ }
+ while ( *str_parse != '"' );
+ *nstr = EOS;
+ str_parse++;
+ add_token( pe, STR_TOKEN );
+ }
+ /* test for name */
+ else if (isalpha (*str_parse)
+ || (*str_parse == '_'))
+ {
+ int funcFlag = 0;
+
+ /* Check for variable or function */
+ /* If variable: add token. */
+ /* If function: parse args, build struct, add token. */
+ nstr = pe->name;
+ do
+ {
+ if ( *str_parse == '(' )
+ {
+ funcFlag = 1;
+ str_parse++;
+ break;
+ }
+ *nstr++ = *str_parse++;
+ }
+ while ((*str_parse == '_')
+ || (*str_parse == '(')
+ || isalpha (*str_parse)
+ || isdigit (*str_parse));
+
+ *nstr = EOS;
+ if ( funcFlag )
+ {
+ add_token(pe, FN_TOKEN);
+ }
+ else
+ {
+ add_token(pe, VAR_TOKEN);
+ }
+
+ }
+ /* test for numeric token */
+ else if ((number = pe->trans_numeric (str_parse, pe->radix_point,
+ pe->group_char, &nstr)))
+ {
+ add_token (pe, NUM_TOKEN);
+ pe->numeric_value = number;
+ str_parse = nstr;
+ }
+ /* unrecognized character - error */
+ else
+ {
+ add_token (pe, *str_parse);
+ pe->error_code = UNDEFINED_CHARACTER;
+ } /* endif */
+
+ pe->parse_str = str_parse;
+} /* next_token */
+
+/* evaluate assignment operators,
+ * =
+ * +=
+ * -=
+ * \=
+ * *=
+ */
+/* FIXME: add non-numeric checking. */
+static void
+assignment_op (parser_env_ptr pe)
+{
+ var_store_ptr vl; /* left value */
+ var_store_ptr vr; /* right value */
+ char ao;
+
+ add_sub_op (pe);
+ if (pe->error_code)
+ return;
+
+ while (pe->Token == ASN_OP)
+ {
+ vl = pop (pe);
+ if (pe->error_code)
+ return;
+
+ ao = pe->asn_op;
+
+ if (vl->variable_name)
+ {
+ next_token (pe);
+ if (pe->error_code)
+ {
+ free_var (vl, pe);
+ return;
+ }
+
+ assignment_op (pe);
+ if (pe->error_code)
+ {
+ free_var (vl, pe);
+ return;
+ }
+
+ vr = pop (pe);
+ if (pe->error_code)
+ {
+ free_var (vl, pe);
+ return;
+ }
+
+ vl->assign_flag = ASSIGNED_TO;
+
+ if (ao)
+ {
+ void *temp;
+
+ temp = vl->value;
+ vl->value = pe->numeric_ops (ao, vl->value, vr->value);
+ pe->free_numeric (temp);
+ }
+ else if (vl != vr)
+ {
+ if (!vr->variable_name)
+ {
+ pe->free_numeric (vl->value);
+ vl->value = vr->value;
+ vr->value = NULL;
+ }
+ else
+ {
+ pe->numeric_ops (ASN_OP, vl->value, vr->value);
+ }
+
+ free_var (vr, pe);
+ } /* endif */
+
+ push (vl, pe);
+ }
+ else
+ {
+ add_token (pe, EOS); /* error !!!!!!!!!! */
+ pe->error_code = NOT_A_VARIABLE;
+ free_var (vl, pe);
+ } /* endif */
+ } /* endwhile */
+} /* assignment_op */
+
+/* evaluate addition, subtraction operators */
+/* FIXME: add non-numeric checking. */
+static void
+add_sub_op (parser_env_ptr pe)
+{
+ var_store_ptr vl; /* left value */
+ var_store_ptr vr; /* right value */
+ var_store_ptr rslt; /* result */
+ char op;
+
+ multiply_divide_op (pe);
+ if (pe->error_code)
+ return;
+
+ while ((pe->Token == ADD_OP) || (pe->Token == SUB_OP))
+ {
+ op = pe->Token;
+
+ vl = pop (pe);
+ if (pe->error_code)
+ return;
+
+ next_token (pe);
+ if (pe->error_code)
+ {
+ free_var (vl, pe);
+ return;
+ }
+
+ multiply_divide_op (pe);
+ if (pe->error_code)
+ {
+ free_var (vl, pe);
+ return;
+ }
+
+ vr = pop (pe);
+ if (pe->error_code)
+ {
+ free_var (vl, pe);
+ return;
+ }
+
+ rslt = get_unnamed_var (pe);
+ if (pe->error_code)
+ {
+ free_var (vl, pe);
+ free_var (vr, pe);
+ return;
+ }
+
+ rslt->value = pe->numeric_ops (op, vl->value, vr->value);
+
+ free_var (vl, pe);
+ free_var (vr, pe);
+
+ push (rslt, pe);
+ } /* endwhile */
+} /* add_sub_op */
+
+/* evaluate multiplication, division operators */
+/* FIXME: add non-numeric checking. */
+static void
+multiply_divide_op (parser_env_ptr pe)
+{
+ var_store_ptr vl; /* left value */
+ var_store_ptr vr; /* right value */
+ var_store_ptr rslt; /* result */
+ char op;
+
+ primary_exp (pe);
+ if (pe->error_code)
+ return;
+
+ while ((pe->Token == MUL_OP) || (pe->Token == DIV_OP))
+ {
+ op = pe->Token;
+
+ vl = pop (pe);
+ if (pe->error_code)
+ return;
+
+ next_token (pe);
+ if (pe->error_code)
+ {
+ free_var (vl, pe);
+ return;
+ }
+
+ primary_exp (pe);
+ if (pe->error_code)
+ {
+ free_var (vl, pe);
+ return;
+ }
+
+ vr = pop (pe);
+ if (pe->error_code)
+ {
+ free_var (vl, pe);
+ return;
+ }
+
+ rslt = get_unnamed_var (pe);
+ if (pe->error_code)
+ {
+ free_var (vl, pe);
+ free_var (vr, pe);
+ return;
+ }
+
+ rslt->value = pe->numeric_ops (op, vl->value, vr->value);
+
+ free_var (vl, pe);
+ free_var (vr, pe);
+
+ push (rslt, pe);
+ } /* endwhile */
+} /* multiply_divide_op */
+
+/**
+ * Bug#334811, 308554: apply some basic grammar constraints.
+ * @return true if the expression is in error; pe->error_code will already
+ * contain the error.
+ **/
+static int
+check_expression_grammar_error(parser_env_ptr pe)
+{
+ if (pe->Token == VAR_TOKEN
+ || pe->Token == STR_TOKEN
+ || pe->Token == NUM_TOKEN
+ || pe->Token == FN_TOKEN)
+ {
+ add_token(pe, EOS);
+ pe->error_code = EXPRESSION_ERROR;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/* evaluate:
+ * unary '+' and '-'
+ * named variables
+ * numerics
+ * grouped expressions, "()"
+ * functions [ <name>( [exp : exp : ... : exp] ) ]
+ * strings
+ */
+static void
+primary_exp (parser_env_ptr pe)
+{
+ var_store_ptr rslt = NULL;
+ char *ident = NULL;
+ int funcArgCount;
+ char LToken = pe->Token;
+
+ /* If we are in a state where the non-stacked 'pe->name' is valuable, then
+ * save it before we process the next token. */
+ switch ( LToken )
+ {
+ case FN_TOKEN:
+ case STR_TOKEN:
+ ident = g_strdup( pe->name );
+ break;
+ }
+
+ next_token (pe);
+ if (pe->error_code)
+ return;
+
+ switch (LToken)
+ {
+ case '(':
+ assignment_op (pe);
+ if (pe->error_code)
+ return;
+
+ if (pe->Token == ')')
+ {
+ rslt = pop (pe);
+ if (pe->error_code)
+ return;
+
+ next_token (pe);
+ if (pe->error_code)
+ return;
+ }
+ else
+ {
+ add_token (pe, EOS); /* error here */
+ pe->error_code = UNBALANCED_PARENS;
+ } /* endif */
+
+ break;
+
+ case ADD_OP:
+ case SUB_OP:
+ primary_exp (pe);
+ if (pe->error_code)
+ return;
+
+ rslt = pop (pe);
+ if (pe->error_code)
+ return;
+
+ if (LToken == SUB_OP)
+ pe->negate_numeric (rslt->value);
+
+ break;
+
+ case NUM_TOKEN:
+ rslt = get_unnamed_var (pe);
+ if (pe->error_code)
+ return;
+
+ if (check_expression_grammar_error(pe))
+ return;
+
+ rslt->value = pe->numeric_value;
+ pe->numeric_value = NULL;
+ break;
+
+ case FN_TOKEN:
+ funcArgCount = 0;
+
+ if (pe->Token && pe->Token != ')')
+ {
+ do
+ {
+ assignment_op(pe);
+ if ( pe->error_code )
+ return;
+ funcArgCount++;
+ if (!pe->Token || pe->Token == ')')
+ {
+ break;
+ }
+ next_token(pe);
+ }
+ while (pe->Token != ARG_TOKEN);
+ }
+
+ if ( pe->Token != ')' )
+ {
+ add_token( pe, EOS );
+ pe->error_code = UNBALANCED_PARENS;
+ }
+
+ {
+ int i;
+ var_store_ptr val;
+ void **argv;
+
+ argv = g_new0( void*, funcArgCount );
+ for ( i = 0; i < funcArgCount; i++ )
+ {
+ /* fill, in back-to-front order, the funcArgCount tokens we just
+ * parsed out of the expression into a argument list to hand back
+ * to the caller's func_op callback. */
+ val = pop(pe);
+ argv[funcArgCount - i - 1] = val;
+ }
+
+ rslt = get_unnamed_var(pe);
+ rslt->value = (*pe->func_op)( ident, funcArgCount, argv );
+
+ for ( i = 0; i < funcArgCount; i++ )
+ {
+ free_var( argv[i], pe );
+ }
+ g_free( argv );
+ g_free( ident );
+
+ if ( rslt->value == NULL )
+ {
+ pe->error_code = NOT_A_FUNC;
+ add_token( pe, EOS );
+ return;
+ }
+ }
+
+ next_token(pe);
+
+ if (check_expression_grammar_error(pe))
+ return;
+
+ break;
+
+ case VAR_TOKEN:
+ if (check_expression_grammar_error(pe))
+ return;
+
+ rslt = get_named_var (pe);
+ break;
+ case STR_TOKEN:
+ if (!(pe->Token == ')'
+ || pe->Token == ARG_TOKEN))
+ {
+ add_token(pe, EOS);
+ pe->error_code = EXPRESSION_ERROR;
+ return;
+ }
+
+ rslt = get_unnamed_var( pe );
+ rslt->type = VST_STRING;
+ rslt->value = ident;
+ break;
+ } /* endswitch */
+
+ if (rslt != NULL)
+ push (rslt, pe);
+
+} /* primary_exp */
Copied: gnucash/trunk/src/app-utils/calculation/fin-interactive.c (from rev 22074, gnucash/trunk/src/calculation/fin-interactive.c)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/fin-interactive.c (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/fin-interactive.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,600 @@
+/***************************************************************************
+ fin-interactive.c - description
+ -------------------
+ begin : Thursday June 15 2000
+ email : tboldt at attglobal.net
+ Author : Terry D. Boldt
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+/*
+ * Functions to interact with user and call financial equations
+ * 6-22-2000
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <mcheck.h>
+
+#include "finvar.h"
+#include "finproto.h"
+#include "fin_spl_protos.h"
+#include "numeric_ops.h"
+
+static void prt_status(
+ fi_ptr fi,
+ FILE *ofile);
+
+static void set_fin_vars(
+ void);
+
+static void unset_fin_vars(
+ void);
+
+#define PREDEFINED_FIN_VARS 9
+
+/* define local financial variables
+ */
+static unsigned npp;
+static double ir;
+static double pv;
+static double pmt;
+static double fv;
+static unsigned CF;
+static unsigned PF;
+static unsigned disc;
+static unsigned bep;
+
+/* define local variable for roundoff precesion
+ * default here to value for US currency
+ */
+static unsigned prec = 2;
+
+/* declare array of structures for local financial variables
+ */
+static var_store predefined_fin_vars[PREDEFINED_FIN_VARS];
+
+/* declare array of finacial varibale names used by user to access financial variables
+ */
+static char *fin_var_names[] =
+{
+ "n",
+ "i",
+ "pv",
+ "pmt",
+ "fv",
+ "CF",
+ "PF",
+ "disc",
+ "bep",
+};
+
+/* declare array of financial variables
+ */
+static void *fin_vars[] =
+{
+ (void *)&npp,
+ (void *)&ir,
+ (void *)&pv,
+ (void *)&pmt,
+ (void *)&fv,
+ (void *)&CF,
+ (void *)&PF,
+ (void *)&disc,
+ (void *)&bep,
+};
+
+/* declare array of financial variable basic numeric types
+ */
+static char fin_type[] =
+{
+ INT_TYPE,
+ DBL_TYPE,
+ DBL_TYPE,
+ DBL_TYPE,
+ DBL_TYPE,
+ INT_TYPE,
+ INT_TYPE,
+ INT_TYPE,
+ INT_TYPE,
+};
+
+static char sl_commands[] = "acdqsv";
+
+/* function to set local financial variables into array for use by expression parser
+ * as pre-defined variables
+ */
+static void set_fin_vars(
+ void)
+{
+ unsigned cntr;
+ numeric_ptr value;
+
+ for ( cntr = 0 ; cntr < PREDEFINED_FIN_VARS ; cntr++ )
+ {
+ predefined_fin_vars[cntr].variable_name = fin_var_names[cntr];
+ predefined_fin_vars[cntr].assign_flag = EOS;
+ predefined_fin_vars[cntr].value = value = (numeric_ptr)calloc(1, sizeof(numeric));
+ predefined_fin_vars[cntr].next_var = &predefined_fin_vars[cntr + 1];
+ switch ( value->type = fin_type[cntr] )
+ {
+ case INT_TYPE:
+ value->value.int_value = *(unsigned *)(fin_vars[cntr]);
+ break;
+ case DBL_TYPE:
+ value->value.dbl_value = *(double *)(fin_vars[cntr]);
+ break;
+ } /* endswitch */
+ } /* endfor */
+ predefined_fin_vars[PREDEFINED_FIN_VARS - 1].next_var = NULL;
+} /* set_fin_vars */
+
+/* free storage used by local financial variables
+ */
+static void unset_fin_vars(
+ void)
+{
+ unsigned cntr;
+ numeric_ptr value;
+
+ for ( cntr = 0 ; cntr < PREDEFINED_FIN_VARS ; cntr++ )
+ {
+ free(predefined_fin_vars[cntr].value);
+ } /* endfor */
+} /* unset_fin_vars */
+
+/* check variable set by expression parser against local financial variables
+ * and update local values as necessary. Also convert variables to proper type
+ * to reflect the native type of the local variable
+ */
+void chk_vars(
+ var_store_ptr predefined_vars,
+ void **var_array,
+ char *var_type,
+ unsigned var_cnt)
+{
+ unsigned cntr;
+ numeric_ptr value;
+
+ for ( cntr = 0 ; cntr < var_cnt ; cntr++ )
+ {
+ if ( predefined_vars[cntr].assign_flag == ASSIGNED_TO )
+ {
+ predefined_vars[cntr].assign_flag = EOS;
+ value = (numeric_ptr)(predefined_vars[cntr].value);
+ switch ( var_type[cntr] )
+ {
+ case INT_TYPE:
+ switch ( value->type )
+ {
+ case INT_TYPE:
+ *(int *)(var_array[cntr]) = value->value.int_value;
+ break;
+ case DBL_TYPE:
+ value->value.int_value =
+ *(int *)(var_array[cntr]) = (unsigned)(value->value.dbl_value);
+ value->type = INT_TYPE;
+ break;
+ } /* endswitch */
+ break;
+ case DBL_TYPE:
+ switch ( value->type )
+ {
+ case INT_TYPE:
+ value->value.dbl_value =
+ *(double *)(var_array[cntr]) = (double)(value->value.int_value);
+ value->type = DBL_TYPE;
+ break;
+ case DBL_TYPE:
+ *(double *)(var_array[cntr]) = value->value.dbl_value;
+ break;
+ } /* endswitch */
+ break;
+ } /* endswitch */
+ } /* endif */
+ } /* endfor */
+} /* chk_fin_vars */
+
+/* error encountered by expression parser - output error message
+ * and offending string
+ */
+void parse_error(unsigned error_code,
+ char *buf_start,
+ char *buf_err)
+{
+ char *err_str;
+ unsigned bc = (unsigned)(buf_err - buf_start);
+
+ switch ( error_code )
+ {
+ case UNBALANCED_PARENS:
+ err_str = "Unbalanced Parenthesis\n";
+ break;
+ case STACK_OVERFLOW:
+ err_str = "Stack Overflow\n";
+ break;
+ case STACK_UNDERFLOW:
+ err_str = "Stack Underflow\n";
+ break;
+ case UNDEFINED_CHARACTER:
+ err_str = "Unrecognized Character\n";
+ break;
+ case NOT_A_VARIABLE:
+ err_str = "Need a Variable on Left side of assignment operator, '='\n";
+ break;
+ case NOT_A_FUNC:
+ err_str = "Need a valid Function name.\n";
+ break;
+
+ } /* endswitch */
+ printf(err_str);
+ printf("%s\n", buf_start);
+ if ( bc ) for ( bc - 1 ; bc ; bc-- ) printf(" ");
+ printf("^");
+ /* printf("%s\n",buf_err + 1); */
+ printf("\n");
+} /* parse_error */
+
+int main(int argc, char **argv, char **env)
+{
+ char buffer[200], *errp;
+ size_t sbuf;
+ size_t retcnt;
+ var_store value;
+ var_store_ptr value_list;
+ numeric_ptr nval;
+ unsigned compute,
+ jj,
+ yrE,
+ monthE,
+ dayE,
+ yrI,
+ monthI,
+ dayI;
+ struct tm *times_E,
+ *times_I;
+ void *parse_env;
+ amort_sched amortsched;
+ financial_info fininfo;
+
+ /* check dynamic storage allocation
+ */
+ /* mtrace(); */
+ set_default(&fininfo);
+ set_fin_vars();
+ parse_env = init_parser(predefined_fin_vars,
+ '.',
+ ',',
+ trans_numeric,
+ numeric_ops,
+ negate_numeric,
+ free_numeric);
+
+ npp = fininfo.npp;
+ ir = fininfo.ir;
+ pv = fininfo.pv;
+ pmt = fininfo.pmt;
+ fv = fininfo.fv;
+ CF = fininfo.CF;
+ PF = fininfo.PF;
+ disc = fininfo.disc;
+ bep = fininfo.bep;
+
+ fininfo.prec = prec;
+
+ printf("Single Letter Commands:\na -- amortization schedule\nc -- compute financial variable\nd -- delete variable\ns -- output financial variable status\nq -- quit\nv -- list defined variables\n");
+ for (;;)
+{
+ printf("<>");
+ retcnt = strlen(fgets(buffer, 190, stdin));
+ if ( (retcnt == 2) && (strchr(sl_commands, buffer[0]) != NULL) )
+ {
+ if ( buffer[0] == 'q' ) break;
+ amortsched.prec = fininfo.prec;
+ switch ( buffer[0] )
+ {
+ case 'a':
+ if ( amortsched.Eff_Date_jdn && amortsched.Init_Date_jdn )
+ {
+ printf("Current Effective year: %u\nCurrent Effective month: %u\nCurrent Effective day: %u\nCurrent Initial year: %u\nCurrent Initial month: %u\nCurrent Initial day %u\n",
+ amortsched.year_E,
+ amortsched.month_E,
+ amortsched.day_E,
+ amortsched.year_I,
+ amortsched.month_I,
+ amortsched.day_I);
+ printf("Change dates ? (y/n) ");
+ fgets(buffer, 190, stdin);
+ }
+ else
+ {
+ buffer[0] = 'y';
+ } /* endif */
+ if ( buffer[0] == 'y' )
+ {
+ printf("Enter Effective Date - year: ");
+ fgets(buffer, 190, stdin);
+ if ( (errp = parse_string(&value, buffer, parse_env)) == NULL )
+ {
+ nval = (numeric_ptr)(value.value);
+ switch ( nval->type )
+ {
+ case INT_TYPE:
+ amortsched.year_E = nval->value.int_value;
+ break;
+ case DBL_TYPE:
+ amortsched.year_E = (unsigned)(nval->value.dbl_value);
+ break;
+ } /* endswitch */
+ if ( !value.variable_name ) free_numeric(value.value);
+ }
+ else
+ {
+ parse_error(get_parse_error(parse_env), buffer, errp);
+ } /* endif */
+ printf("Enter Effective Date - month: ");
+ fgets(buffer, 190, stdin);
+ if ( (errp = parse_string(&value, buffer, parse_env)) == NULL )
+ {
+ nval = (numeric_ptr)(value.value);
+ switch ( nval->type )
+ {
+ case INT_TYPE:
+ amortsched.month_E = nval->value.int_value;
+ break;
+ case DBL_TYPE:
+ amortsched.month_E = (unsigned)(nval->value.dbl_value);
+ break;
+ } /* endswitch */
+ if ( !value.variable_name ) free_numeric(value.value);
+ }
+ else
+ {
+ parse_error(get_parse_error(parse_env), buffer, errp);
+ } /* endif */
+ printf("Enter Effective Date - day: ");
+ fgets(buffer, 190, stdin);
+ if ( (errp = parse_string(&value, buffer, parse_env)) == NULL )
+ {
+ nval = (numeric_ptr)(value.value);
+ switch ( nval->type )
+ {
+ case INT_TYPE:
+ amortsched.day_E = nval->value.int_value;
+ break;
+ case DBL_TYPE:
+ amortsched.day_E = (unsigned)(nval->value.dbl_value);
+ break;
+ } /* endswitch */
+ if ( !value.variable_name ) free_numeric(value.value);
+ }
+ else
+ {
+ parse_error(get_parse_error(parse_env), buffer, errp);
+ } /* endif */
+ printf("Enter Initial Payment Date - year: ");
+ fgets(buffer, 190, stdin);
+ if ( (errp = parse_string(&value, buffer, parse_env)) == NULL )
+ {
+ nval = (numeric_ptr)(value.value);
+ switch ( nval->type )
+ {
+ case INT_TYPE:
+ amortsched.year_I = nval->value.int_value;
+ break;
+ case DBL_TYPE:
+ amortsched.year_I = (unsigned)(nval->value.dbl_value);
+ break;
+ } /* endswitch */
+ if ( !value.variable_name ) free_numeric(value.value);
+ }
+ else
+ {
+ parse_error(get_parse_error(parse_env), buffer, errp);
+ } /* endif */
+ printf("Enter Initial Payment Date - month: ");
+ fgets(buffer, 190, stdin);
+ if ( (errp = parse_string(&value, buffer, parse_env)) == NULL )
+ {
+ nval = (numeric_ptr)(value.value);
+ switch ( nval->type )
+ {
+ case INT_TYPE:
+ amortsched.month_I = nval->value.int_value;
+ break;
+ case DBL_TYPE:
+ amortsched.month_I = (unsigned)(nval->value.dbl_value);
+ break;
+ } /* endswitch */
+ if ( !value.variable_name ) free_numeric(value.value);
+ }
+ else
+ {
+ parse_error(get_parse_error(parse_env), buffer, errp);
+ } /* endif */
+ printf("Enter Initial Payment Date - day: ");
+ fgets(buffer, 190, stdin);
+ if ( (errp = parse_string(&value, buffer, parse_env)) == NULL )
+ {
+ nval = (numeric_ptr)(value.value);
+ switch ( nval->type )
+ {
+ case INT_TYPE:
+ amortsched.day_I = nval->value.int_value;
+ break;
+ case DBL_TYPE:
+ amortsched.day_I = (unsigned)(nval->value.dbl_value);
+ break;
+ } /* endswitch */
+ if ( !value.variable_name ) free_numeric(value.value);
+ }
+ else
+ {
+ parse_error(get_parse_error(parse_env), buffer, errp);
+ } /* endif */
+ } /* endif */
+
+ amortsched.n = npp;
+ amortsched.nint = ir;
+ amortsched.pv = pv;
+ amortsched.pmt = pmt;
+ amortsched.fv = fv;
+ amortsched.CF = CF;
+ amortsched.PF = PF;
+ amortsched.disc = disc;
+ amortsched.bep = bep;
+
+ Amortization_init(&amortsched);
+ amort_opt(&amortsched, parse_env);
+
+ (void)Amortization_Schedule(&amortsched);
+ prt_amortization_schedule(&amortsched, stdout);
+ Amortization_free(&amortsched);
+ break;
+ case 'c':
+
+ printf("Compute:\nn - 1\ni - 2\npv - 3\npmt - 4\nfv - 5\n1, 2, 3, 4 or 5: ");
+ retcnt = strlen(fgets(buffer, 190, stdin));
+ compute = buffer[0] - '0';
+
+ switch ( compute-- )
+ {
+ case 0: /* all values specified nothing to compute */
+ break;
+ case 1: /* compute number of periods, npp */
+ printf("Computing numbor of periods\n");
+ npp = fi_calc_num_payments(&fininfo);
+ printf("Number of Periods: %u\n", npp);
+ nval = (numeric_ptr)(predefined_fin_vars[compute].value);
+ nval->value.int_value = npp;
+ break;
+ case 2: /* compute interest, ir */
+ printf("Computing interest rate\n");
+ ir = fi_calc_interest(&fininfo);
+ printf("Nominal Interest Rate: %.*f\n", prec, ir);
+ nval = (numeric_ptr)(predefined_fin_vars[compute].value);
+ nval->value.dbl_value = ir;
+ break;
+ case 3: /* compute present value, pv */
+ printf("Computing Present Value\n");
+ pv = fi_calc_present_value(&fininfo);
+ printf("Present Value: %.*f\n", prec, pv);
+ nval = (numeric_ptr)(predefined_fin_vars[compute].value);
+ nval->value.dbl_value = pv;
+ break;
+ case 4: /* compute periodic payment, pmt */
+ printf("Computing periodic payment\n");
+ pmt = fi_calc_payment(&fininfo);
+ printf("Periodic Payment: %.*f\n", prec, pmt);
+ nval = (numeric_ptr)(predefined_fin_vars[compute].value);
+ nval->value.dbl_value = pmt;
+ break;
+ case 5: /* compute future value, fv */
+ printf("Computing Future Value\n");
+ fv = fi_calc_future_value(&fininfo);
+ printf("Future Value: %.*f\n", prec, fv);
+ nval = (numeric_ptr)(predefined_fin_vars[compute].value);
+ nval->value.dbl_value = fv;
+ break;
+ default: /* whoops */
+ break;
+ } /* endswitch */
+ break;
+ case 'd':
+ printf("Enter name of variable to delete: ");
+ retcnt = strlen(fgets(buffer, 190, stdin));
+ buffer[retcnt - 1] = EOS;
+ if ( !delete_var(buffer, parse_env) )
+ {
+ printf("Unable to delete specified variable\n");
+ } /* endif */
+ break;
+ case 's':
+ prt_status(&fininfo,
+ stdout);
+ break;
+ case 'v':
+ for ( value_list = parser_get_vars(parse_env) ; value_list ; value_list = value_list->next_var )
+ {
+ printf("%s: ", value_list->variable_name);
+ nval = (numeric_ptr)(value_list->value);
+ switch ( nval->type )
+ {
+ case INT_TYPE:
+ printf("%i\n", nval->value.int_value);
+ break;
+ case DBL_TYPE:
+ printf("%.*f\n", prec, nval->value.dbl_value);
+ break;
+ } /* endswitch */
+ } /* endfor */
+ break;
+ } /* endswitch */
+ }
+ else if ( retcnt > 1 )
+ {
+ buffer[retcnt - 1] = EOS;
+
+ if ( (errp = parse_string(&value, buffer, parse_env)) == NULL )
+ {
+ if ( value.variable_name ) printf("Variable: %s\n", value.variable_name);
+ nval = (numeric_ptr)(value.value);
+ switch ( nval->type )
+ {
+ case INT_TYPE:
+ printf("Evaluated Value: %i\n", nval->value.int_value);
+ break;
+ case DBL_TYPE:
+ printf("Evaluated Value: %.*f\n", prec, nval->value.dbl_value);
+ break;
+ } /* endswitch */
+ if ( !value.variable_name ) free_numeric(value.value);
+ chk_vars(predefined_fin_vars, fin_vars, fin_type, PREDEFINED_FIN_VARS);
+ fininfo.npp = npp;
+ fininfo.ir = ir;
+ fininfo.pv = pv;
+ fininfo.pmt = pmt;
+ fininfo.fv = fv;
+ fininfo.CF = CF;
+ fininfo.PF = PF;
+ fininfo.disc = disc;
+ fininfo.bep = bep;
+ }
+ else
+ {
+ parse_error(get_parse_error(parse_env), buffer, errp);
+ } /* endif */
+ } /* endif */
+ } /* endfor */
+ exit_parser(parse_env);
+ unset_fin_vars();
+} /* main */
+
+static void prt_status(
+ fi_ptr fi,
+ FILE *ofile)
+{
+ fprintf(ofile, "<================================>\nCurrent Financial Calculator Status:\n");
+ fprintf(ofile, "Compounding Frequency: (CF) %u\n", fi->CF);
+ fprintf(ofile, "Payment Frequency: (PF) %u\n", fi->PF);
+ fprintf(ofile, "Compounding: %s\n", fi->disc ? "Discrete (disc = TRUE)" : "Continuous (disc = FALSE)");
+ fprintf(ofile, "Payments: %s\n", fi->bep ? "Beginning of Period (bep = TRUE)" : "End of Period (bep = FALSE)");
+ if ( fi->npp > 12 ) fprintf(ofile, "Number of Payment Periods (n): %u\t\t(Years: %u)\n", fi->npp, fi->npp / fi->PF);
+ else fprintf(ofile, "Number of Payment Periods (n): %u\n", fi->npp);
+ if ((fi->CF == 1) && (fi->PF == 1) ) fprintf(ofile, "Nominal Interest per Payment Period (i): %f\t(Annualized: %.*f\n", fi->ir, fi->prec, fi->ir * 12);
+ else fprintf(ofile, "Nominal Annual Interest Rate (i): %.*f\n", fi->prec, fi->ir);
+ /* fprintf(ofile, " Effective Interest Rate Per Payment Period: %f\n",eff_int(nint/100.0,CF,PF)); */
+ fprintf(ofile, "Present Value (pv): %.*f\n", fi->prec, fi->pv);
+ fprintf(ofile, "Periodic Payment (pmt): %.*f\n", fi->prec, fi->pmt);
+ fprintf(ofile, "Future Value (fv): %.*f\n<================================>\n", fi->prec, fi->fv);
+} /* prt_status */
Copied: gnucash/trunk/src/app-utils/calculation/fin-main.c (from rev 22074, gnucash/trunk/src/calculation/fin-main.c)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/fin-main.c (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/fin-main.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,160 @@
+/***************************************************************************
+ fin-main.c - description
+ -------------------
+ begin : Thursday June 15 2000
+ email : tboldt at attglobal.net
+ Author : Terry D. Boldt
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+/*
+ * Functions to call financial equations and output results
+ * 6-15-2000
+ *
+ */
+
+#include <stdio.h>
+
+#include "finvar.h"
+#include "finproto.h"
+
+static void prt_status(
+ fi_ptr fi,
+ FILE *ofile);
+
+int main(int argc, char **argv, char **env)
+{
+ financial_info fininfo;
+ amort_sched amortsched;
+
+ set_default(&fininfo);
+ fininfo.prec = 2;
+
+ fininfo.npp = 360;
+ fininfo.ir = 8.25;
+ fininfo.pv = 345725.0;
+
+ (void)fi_calc_payment(&fininfo);
+ printf("With npp == %u\n ir == %.*f\n pv == %.*f\n", fininfo.npp, fininfo.prec, fininfo.ir, fininfo.prec, fininfo.pv);
+ printf("------------>Compute pmt: -2597.32\n");
+ prt_status(&fininfo,
+ stdout);
+
+ fi_calc_interest(&fininfo);
+ printf("\n------------>Compute ir\n");
+ prt_status(&fininfo,
+ stdout);
+
+ fi_calc_num_payments(&fininfo);
+ printf("\n------------>Compute npp\n");
+ prt_status(&fininfo,
+ stdout);
+
+ fi_calc_future_value(&fininfo);
+ printf("\n------------>Compute fv\n");
+ prt_status(&fininfo,
+ stdout);
+
+ set_default(&fininfo);
+
+ fininfo.npp = 360;
+ fininfo.ir = 8.25;
+ fininfo.pv = 345725.0;
+ fi_calc_payment(&fininfo);
+
+ printf("\n\n Reset financial variables and compute amortization schedules.\n");
+ printf("First Schedule - ignore delay in first payment and\noutput annual summary\n");
+
+ amortsched.n = fininfo.npp;
+ amortsched.nint = fininfo.ir;
+ amortsched.pv = fininfo.pv;
+ amortsched.pmt = fininfo.pmt;
+ amortsched.fv = fininfo.fv;
+ amortsched.CF = fininfo.CF;
+ amortsched.PF = fininfo.PF;
+ amortsched.disc = fininfo.disc;
+ amortsched.bep = fininfo.bep;
+ amortsched.prec = fininfo.prec;
+ amortsched.year_E = 1999;
+ amortsched.month_E = 6;
+ amortsched.day_E = 15;
+ amortsched.year_I = 1999;
+ amortsched.month_I = 8;
+ amortsched.day_I = 1;
+ amortsched.fixed_pmt = -400;
+
+ (void)Amortization_init(&amortsched);
+
+ amortsched.option = 3;
+ amortsched.summary = 'y';
+ (void)Amortization_Schedule(&amortsched);
+ prt_amortization_schedule(&amortsched, stdout);
+
+ printf("\n\nSecond Schedule - ignore delay in first payment and\noutput schedule for each payment\n");
+ amortsched.summary = 'p';
+ (void)Amortization_Schedule(&amortsched);
+ prt_amortization_schedule(&amortsched, stdout);
+
+
+ printf("\n\nThird Schedule - ignore delay in first payment and\noutput variable advanced prepayment schedule\n");
+ amortsched.summary = 'a';
+ (void)Amortization_Schedule(&amortsched);
+ prt_amortization_schedule(&amortsched, stdout);
+
+ printf("\n\nFourth Schedule - ignore delay in first payment and\noutput fixed prepayment schedule\n");
+ amortsched.summary = 'f';
+ (void)Amortization_Schedule(&amortsched);
+ prt_amortization_schedule(&amortsched, stdout);
+
+ printf("\n\nFifth Schedule - use new payments due to delay and\noutput annual summary\n");
+ amortsched.option = 5;
+ amortsched.summary = 'y';
+ (void)Amortization_Schedule(&amortsched);
+ prt_amortization_schedule(&amortsched, stdout);
+
+ printf("\n\nSixth Schedule - use new payments due to delay and\noutput periodic payment schedule\n");
+ amortsched.option = 5;
+ amortsched.summary = 'p';
+ (void)Amortization_Schedule(&amortsched);
+ prt_amortization_schedule(&amortsched, stdout);
+
+ printf("\n\nSeventh Schedule - use new payments due to delay and\noutput variable prepayment schedule\n");
+ amortsched.option = 5;
+ amortsched.summary = 'a';
+ (void)Amortization_Schedule(&amortsched);
+ prt_amortization_schedule(&amortsched, stdout);
+
+ printf("\n\nEighth Schedule - use new payments due to delay and\noutput fixed prepayment schedule\n");
+ amortsched.option = 5;
+ amortsched.summary = 'f';
+ (void)Amortization_Schedule(&amortsched);
+ prt_amortization_schedule(&amortsched, stdout);
+ Amortization_free(&amortsched);
+} /* main */
+
+static void prt_status(
+ fi_ptr fi,
+ FILE *ofile)
+{
+ fprintf(ofile, "<================================>\nCurrent Financial Calculator Status:\n");
+ fprintf(ofile, "Compounding Frequency: (CF) %u\n", fi->CF);
+ fprintf(ofile, "Payment Frequency: (PF) %u\n", fi->PF);
+ fprintf(ofile, "Compounding: %s\n", fi->disc ? "Discrete (disc = TRUE)" : "Continuous (disc = FALSE)");
+ fprintf(ofile, "Payments: %s\n", fi->bep ? "Beginning of Period (bep = TRUE)" : "End of Period (bep = FALSE)");
+ if ( fi->npp > 12 ) fprintf(ofile, "Number of Payment Periods (n): %u\t\t(Years: %u)\n", fi->npp, fi->npp / fi->PF);
+ else fprintf(ofile, "Number of Payment Periods (n): %u\n", fi->npp);
+ if ((fi->CF == 1) && (fi->PF == 1) ) fprintf(ofile, "Nominal Interest per Payment Period (i): %f\t(Annualized: %.*f\n", fi->ir, fi->prec, fi->ir * 12);
+ else fprintf(ofile, "Nominal Annual Interest Rate (i): %.*f\n", fi->prec, fi->ir);
+ /* fprintf(ofile, " Effective Interest Rate Per Payment Period: %f\n",eff_int(nint/100.0,CF,PF)); */
+ fprintf(ofile, "Present Value (pv): %.*f\n", fi->prec, fi->pv);
+ fprintf(ofile, "Periodic Payment (pmt): %.*f\n", fi->prec, fi->pmt);
+ fprintf(ofile, "Future Value (fv): %.*f\n", fi->prec, fi->fv);
+} /* prt_status */
Copied: gnucash/trunk/src/app-utils/calculation/fin-proto.sh (from rev 22074, gnucash/trunk/src/calculation/fin-proto.sh)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/fin-proto.sh (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/fin-proto.sh 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,26 @@
+#! /bin/sh
+#/***************************************************************************
+# fin-proto.sh - description
+# -------------------
+# copyright : (C) 2000 by Terry D. Boldt
+# email : tboldt at attglobal.net
+# Author : Terry D. Boldt
+# ***************************************************************************/
+#
+#/***************************************************************************
+# * *
+# * This program is free software; you can redistribute it and/or modify *
+# * it under the terms of the GNU General Public License as published by *
+# * the Free Software Foundation; either version 2 of the License, or *
+# * (at your option) any later version. *
+# * *
+# ***************************************************************************/
+#
+# shell script for creating function prototype files
+#
+qtgrep -DHhf cfuncs.exp fin.c expression_parser.c numeric_ops.c amort_opt.c amort_prt.c >protos.out
+echo Creating Global Prototype File: \"finproto.h\"
+qtawk -f protos.exp protos.out >finproto.h
+echo Creating Static Prototype File: \"fin_static_proto.h\"
+qtawk -f static_protos.exp protos.out >fin_static_proto.h
+rm -fv protos.out
Copied: gnucash/trunk/src/app-utils/calculation/fin.c (from rev 22074, gnucash/trunk/src/calculation/fin.c)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/fin.c (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/fin.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,2478 @@
+/***************************************************************************
+ fin.c - description
+ -------------------
+ begin : Thursday June 15 2000
+ email : tboldt at attglobal.net
+ Author : Terry D. Boldt
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+/*
+ * Functions to compute financial equations and amortization schedules
+ * 6-15-2000
+ *
+ */
+
+/*
+ * Financial Calculator
+ *
+ * This version for use WITH ANSI.SYS display driver
+ *
+ * This is a complete financial computation utility to solve for the
+ * five * standard financial values: n, %i, PV, PMT and FV
+ *
+ * n == number of payment periods
+ * %i == nominal interest rate, NAR, charged
+ * PV == Present Value
+ * PMT == Periodic Payment
+ * FV == Future Value
+ *
+ * In addition, two additional parameters may be specified:
+ *
+ * 1) Compounding Frequency per year, CF. The compounding frequency
+ * per year may be discrete or continuous and may be different from
+ * the Payment Frequency per year
+ *
+ * 2) Payment Frequency per year, PF. Payments may be made at the
+ * beginning or the end of the payment period.
+ *
+ * When an amortization schedule is desired, the financial
+ * transaction Effective Date, ED, and Initial Payment Date, IP, must
+ * also be entered.
+ *
+ * Canadian and European style mortgages can be handled in a simple,
+ * straight-forward manner. Standard financial sign conventions are
+ * used:
+ *
+ * "Money paid out is Negative, Money received is Positive"
+ *
+ * Time value of money:
+ *
+ * If you borrow money, you can expect to pay rent or interest for its use;
+ * conversely you expect to receive rent interest on money you loan or invest.
+ * When you rent property, equipment, etc., rental payments are normal; this
+ * is also true when renting or borrowing money. Therefore, money is
+ * considered to have a "time value". Money available now, has a greater value
+ * than money available at some future date because of its rental value or the
+ * interest that it can produce during the intervening period.
+ *
+ * Simple Interest:
+ *
+ * If you loaned $800 to a friend with an agreement that at the end of one
+ * year he would would repay you $896, the "time value" you placed on your
+ * $800 (principal) was $96 (interest) for the one year period (term) of the
+ * loan. This relationship of principal, interest, and time (term) is most
+ * frequently expressed as an Annual Percentage Rate (APR). In this case the
+ * APR was 12.0% [(96/800)*100]. This example illustrates the four basic
+ * factors involved in a simple interest case. The time period (one year),
+ * rate (12.0% APR), present value of the principal ($800) and the future
+ * value of the principal including interest ($896).
+ *
+ * Compound Interest:
+ *
+ * In many cases the interest charge is computed periodically during the term
+ * of the agreement. For example, money left in a savings account earns
+ * interest that is periodically added to the principal and in turn earns
+ * additional interest during succeeding periods. The accumulation of interest
+ * during the investment period represents compound interest. If the loan
+ * agreement you made with your friend had specified a "compound interest
+ * rate" of 12% (compounded monthly) the $800 principal would have earned
+ * $101.46 interest for the one year period. The value of the original $800
+ * would be increased by 1% the first month to $808 which in turn would be
+ * increased by 1% to 816.08 the second month, reaching a future value of
+ * $901.46 after the twelfth iteration. The monthly compounding of the nominal
+ * annual rate (NAR) of 12% produces an effective Annual Percentage Rate (APR)
+ * of 12.683% [(101.46/800)*100]. Interest may be compounded at any regular
+ * interval; annually, semiannually, monthly, weekly, daily, even continuously
+ * (a specification in some financial models).
+ *
+ * Periodic Payments:
+ *
+ * When money is loaned for longer periods of time, it is customary for the
+ * agreement to require the borrower to make periodic payments to the lender
+ * during the term of the loan. The payments may be only large enough to repay
+ * the interest, with the principal due at the end of the loan period (an
+ * interest only loan), or large enough to fully repay both the interest and
+ * principal during the term of the loan (a fully amoritized loan). Many loans
+ * fall somewhere between, with payments that do not fully cover repayment of
+ * both the principal and interst. These loans require a larger final payment
+ * (balloon) to complete their amortization. Payments may occur at the
+ * beginning or end of a payment period. If you and your friend had agreed on
+ * monthly repayment of the $800 loan at 12% NAR compounded monthly, twelve
+ * payments of $71.08 for a total of $852.96 would be required to amortize the
+ * loan. The $101.46 interest from the annual plan is more than the $52.96
+ * under the monthly plan because under the monthly plan your friend would not
+ * have had the use of $800 for a full year.
+ *
+ * Financial Transactions:
+ *
+ * The above paragraphs introduce the basic factors that govern most
+ * financial transactions; the time period, interest rate, present value,
+ * payments and the future value. In addition, certain conventions must be
+ * adhered to: the interest rate must be relative to the compounding frequency
+ * and payment periods, and the term must be expressed as the total number of
+ * payments (or compounding periods if there are no payments). Loans, leases,
+ * mortgages, annuities, savings plans, appreciation, and compound growth are
+ * amoung the many financial problems that can be defined in these terms. Some
+ * transactions do not involve payments, but all of the other factors play a
+ * part in "time value of money" transactions. When any one of the five (four
+ * - if no payments are involved) factors is unknown, it can be derived from
+ * formulas using the known factors.
+ *
+ * Standard Financial Conventions Are:
+ *
+ * Money RECEIVED is a POSITIVE value and is represented by an arrow
+ * above * the line
+ *
+ * Money PAID OUT is a NEGATIVE value and is represented by an arrow
+ * below * the line.
+ *
+ * If payments are a part of the transaction, the number of payments
+ * must * equal the number of periods (n).
+ *
+ * Payments may be represented as occuring at the end or beginning of
+ * the * periods.
+ *
+ * Diagram to visualize the positive and negative cash flows (cash
+ * flow * diagrams):
+ *
+ * Amounts shown above the line are positve, received, and amounts
+ * shown below the line are negative, paid out.
+ *
+ * 1)
+ * FV*
+ * 1 2 3 4 . . . . . . . . . n ³
+ * Period ÚÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ
+ * ³
+ *
+ * PV
+ *
+ * Appreciation
+ * Depreciation
+ * Compound Growth
+ * Savings Account
+ *
+ * ****************************************************************************
+ *
+ * 2) FV
+ * PV = 0
+ * ³
+ * Period ÚÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÙ
+ * ³ 1 ³ 2 ³ 3 ³ 4 ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ n
+ *
+ * PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT
+ *
+ * Annuity (series of payments)
+ * Pension Fund
+ * Savings Plan
+ * Sinking Fund
+ *
+ * ****************************************************************************
+ *
+ * 3)
+ * PV
+ * ³ FV=0
+ * Period ÀÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿
+ * 1 ³ 2 ³ 3 ³ 4 ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ n ³
+ *
+ * PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT
+ *
+ * Amortization
+ * Direct Reduction Loan
+ * Mortgage (fully amortized)
+ *
+ * ****************************************************************************
+ *
+ * 4)
+ * FV*
+ * PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT ³ +
+ * PMT
+ * 1 ³ 2 ³ 3 ³ 4 ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ n ³
+ * Period ÚÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ
+ * ³
+ *
+ * PV
+ *
+ * Annuity
+ * Lease (with buy back or residual)*
+ * Loan or Mortgage (with balloon)*
+ *
+ * ****************************************************************************
+ *
+ * First lets discuss interest before discussing the financial
+ * equation. Most financial transactions utilize a nominal interest
+ * rate, NAR, i.e., the interest rate per year. The NAR must be
+ * converted to the interest rate per payment interval and the
+ * compounding accounted for before it can be used in computing an
+ * interest payment. After this conversion process, the interest
+ * used is the effective interest rate, EIR. In converting NAR to
+ * EIR, there are two concepts to discuss first, the Compounding
+ * Frequency and the Payment Frequency and * whether the interest is
+ * coumpounded in discrete intervals or continuously. The
+ * compounding Frequency, CF, is simply the number of times per
+ * year, the monies in the financial transaction are compounded. In
+ * the U.S., monies are usually compounded daily on bank deposits,
+ * and monthly on loans. Somtimes Long term deposits are compounded
+ * quarterly or weekly.
+ *
+ * The Payment Frequency, PF, is simply how often during a year
+ * payments are made in the transaction. Payments are usually
+ * scheduled on a regular basis and can be made at the beginning or
+ * end of the payment period. If made at the beginning of the
+ * payment period, interest must be applied to the payment as well
+ * as any previous money paid or money still owed.
+ *
+ * Normal values for CF and PF are:
+ * 1 == annual
+ * 2 == semi-annual
+ * 3 == tri-annual
+ * 4 == quaterly
+ * 6 == bi-monthly
+ * 12 == monthly
+ * 24 == semi-monthly
+ * 26 == bi-weekly
+ * 52 == weekly
+ * 360 == daily
+ * 365 == daily
+ *
+ * a) the Compounding Frequency per year, CF, need not be identical
+ * to the Payment Frequency per year, PF, and/or,
+ *
+ * b) Interest may be compounded in either discrete intervals or continuously
+ * compounded.
+ *
+ * c) Also, payments may be made at the beginning of the payment
+ * period or at the end of the payment period.
+ *
+ * CF and PF are defaulted to 1. The default is for discrete interest
+ * intervals and payments are defaulted to the end of the payment
+ * period.
+ *
+ * When a solution for n, PV, PMT or FV is required, the nominal interest
+ * rate, i, must first be converted to the effective interest rate per payment
+ * period. This rate, ieff, is then used to compute the selected variable. To
+ * convert i to ieff, the following expressions are used:
+ *
+ * Discrete interest periods:
+ *
+ * 19) ieff = (1 + i/CF)^(CF/PF) - 1
+ *
+ * Continuous Interest
+ *
+ * 20) ieff = e^(i/PF) - 1 = exp(i/PF) - 1
+ *
+ * When interest is computed, the computation produces the effective interest
+ * rate, ieff. This value must then be converted to the nominal interest rate.
+ * Function _I below returns the nominal interest rate NOT the effective
+ * interest rate. ieff is converted to i using the following expressions:
+ *
+ * Discrete Case:
+ *
+ * i = CF*[(1+ieff)^(PF/CF) - 1]
+ *
+ * Continuous Case:
+ *
+ * i = ln[(1+ieff)^PF]
+ *
+ * ****************************************************************************
+ *
+ * NOTE: in the equations below for the financial transaction, all
+ * interest rates are the effective interest rate, ieff. The symbol
+ * will be shortned to just 'i'.
+ *
+ * ****************************************************************************
+ *
+ * The basic financial equation used is:
+ *
+ * 1) PV*(1 + i)^n + PMT*(1 + iX)*[(1+i)^n - 1]/i + FV = 0
+ * Where: X = 0 for end of period payments, and
+ * X = 1 for beginning of period payments
+ *
+ * ****************************************************************************
+ *
+ * NOTE: this equation is derived in the following manner:
+ *
+ * Start with the basic equation to find the balance or Present
+ * Value, PV[1], after one payment period. Note PV[1] is the Present
+ * value after on payment and PV[0] is the initial Present
+ * Value. PV[0] will be shortened to just PV.
+ *
+ * The interest due at the end of the first payment period is:
+ *
+ * ID[1] = (PV + X * PMT) * i
+ * where: X = 0 for end of period payments, and
+ * X = 1 for beginning of period payments.
+ *
+ * Thus:
+ * PV[1] = PV + (PMT + ID[1])
+ * = PV + (PMT + (PV + X * PMT) * i)
+ * = PV * (1 + i) + PMT * (1 + Xi)
+ *
+ * This equation works for all of the money diagrams shown
+ * above. The Present Value, money received or paid, is modified by
+ * a payment made at the beginning of a payment period and
+ * multiplied by the effective interest rate to compute the interest
+ * due during the payment period. The interest due is then added to
+ * the payment to obtain the amount to be added to the Present Value
+ * to compute the new Present Value.
+ *
+ * For diagram 1): PV < 0, PMT == 0, PV[1] < 0
+ * For diagram 2): PV == 0, PMT < 0, PV[1] < 0
+ * For Diagram 3): PV > 0, PMT < 0, PV[1] >= 0 or PV[1] <= 0
+ * For Diagram 4): PV < 0, PMT > 0, PV[1] <= 0 or PV[1] >= 0
+ *
+ * X may be 0 or 1 for any diagram.
+ *
+ * For the standard loan, PV is the money borrowed, PMT is the
+ * periodic payment to repay the loan and i is the effective
+ * interest rate agreed upon.
+ *
+ * To calculate the Present Value after the second payment period,
+ * the above calculation is applied iteratively to PV_1:
+ *
+ * PV[2] = PV[1] + (PMT + (PV[1] + X * PMT) * i)
+ * = PV[1] * (1 + i) + PMT * (1 + iX)
+ * = (PV * (1 + i) + PMT * (1 + iX)) * (1 + i) + PMT * (1 + iX)
+ * = PV * (1 + i)^2 + PMT * (1 + iX) * (1 + i)
+ * + PMT * (1 + iX)
+ *
+ * Similarly:
+ *
+ * PV[3] = PV[2] + (PMT + (PV[2] + X * PMT) * i)
+ * = PV[2] * (1 + i) + PMT * (1 + iX)
+ * = PV * (1 + i)^2 + PMT * (1 + iX) * (1 + i)
+ * + PMT * (1+ iX)) * ( 1 + i)
+ * + PMT * (1+ iX)
+ * = PV * (1 + i)^3 + PMT * (1 + iX) * (1 + i)^2
+ * + PMT * (1 + iX) * (1 + i)^2
+ * + PMT * (1 + iX) * (1 + i)
+ * + PMT * (1 + iX)
+ *
+ * And for the n'th payment:
+ *
+ * PV[n] = PV[n-1] + (PMT + (PV[n-1] + X * PMT) * i)
+ * PV[n] = PV * (1 + i)^n + PMT * (1 + iX) * (1 + i)^(n-1)
+ * + PMT * (1 + iX) * (1 + i)^(n-2) +
+ * .
+ * .
+ * .
+ * + PMT * (1 + iX) * (1 + i)
+ * + PMT * (1 + iX)
+ * PV[n] = PV * (1 + i)^n + PMT * (1 + iX) * [(1 + i)^(n-1) + ...
+ * + (1 + i) + 1]
+ *
+ * ****************************************************************************
+ *
+ * The sum of the finite series:
+ *
+ * 1 + k + (k^2) + (k^3) + ... + (k^n) = (1-k^(n+1))/(1-k)
+ *
+ * as can be seen by the following. Let S(n) be the series sum. Then
+ *
+ * S(n) - k * S(n) = 1 - k^(n+1)
+ *
+ * and solving for S(n):
+ *
+ * S(n) = [1-k^(n+1)]/[1-k] = 1 + k + (k^2) + (k^3) + ... + (k^n)
+ *
+ * ****************************************************************************
+ *
+ * PV[n] = PV * (1 + i)^n + PMT * (1 + iX) * [(1 + i)^(n-1) + ...
+ * + (1 + i) + 1]
+ * = PV * (1 + i)^n + PMT * (1 + iX) * [1 - (1 + i)^n]/[1 - (1 + i)]
+ * = PV * (1 + i)^n + PMT * (1 + iX) * [1 - (1 + i)^n]/[-i]
+ * = PV * (1 + i)^n + PMT * (1 + iX) * [(1 + i)^n - 1]/i
+ *
+ * The formaula for PV[n] can be proven using mathematical induction.
+ *
+ * or:
+ *
+ * PV * (1 + i)^n + PMT * [(1 + i)^n - 1]/i - PV[n] = 0
+ *
+ * If after n payments, the remaining balance is repaid as a lump
+ * sum, the lump sum is known as the Future Value, FV[n]. Since
+ * FV[n] is negative if paid and positive if received, FV[n] is the
+ * negative of PV[n]. Since n is assumed to be the last payment,
+ * FV[n] will be shortened to simply FV.
+ *
+ * Setting: FV = -PV[N]
+ *
+ * 1) PV*(1 + i)^n + PMT*(1 + iX)*[(1 + i)^n - 1]/i + FV = 0
+ *
+ * Up to this point, we have said nothing about the value of
+ * PMT. PMT can be any value mutually agreed upon by the lender and
+ * the borrower. From the equation for PV[1]:
+ *
+ * PV[1] = PV + (PMT + (PV + X * PMT) * i),
+ *
+ * Several things can be said about PMT.
+ *
+ * 1. If PMT = PV * i, and X = 0 (end of period payments):
+ *
+ * The payment is exactly equal to the interest due and PV[1] =
+ * PV. In this case, the borrower must make larger future
+ * payments to reduce the balance due, or make a single payment,
+ * after some agreed upon number of payments, with PMT = PV to
+ * completely pay off the loan. This is an interest only payment
+ * with a balloon payment at the end.
+ *
+ * 2. If PMT < PV * i, and X = 0
+ *
+ * The payment is insufficient to cover even the interest charged
+ * and the balance due grows
+ *
+ * 3. If PMT > PV * i, and X = 0
+ *
+ * The payment is sufficient to cover the interest charged with a
+ * residual amount to be applied to reduce the balance due. The
+ * larger the residual amount, the faster the loan is repaid. For
+ * most mortgages or other loans made today, the lender and
+ * borrower agree upon a certain number of repayment periods and
+ * the interest to be charged per payment period. The interest
+ * may be multiplied by 12 and stated as an annual interest
+ * rate. Then the lender and borrower want to compute a periodic
+ * payment, PMT, which will reduce the balance due to zero after
+ * the agreed upon number of payment have been made. If N is the
+ * agreed upon number of periodic payments, then we want to use:
+ *
+ * PV * (1 + i)^N + PMT*(1 +iX)*[(1 + i)^N - 1]/i + FV = 0
+ *
+ * with FV = 0 to compute PMT:
+ *
+ * PMT = -[PV * i * (1 + i)^(N - X)]/[(1 + i)^N - 1]
+ *
+ * The value of PMT computed will reduce the balance due to zero
+ * after N periodic payments.
+ *
+ * ****************************************************************************
+ *
+ *
+ * With a simple alegebraic re-arrangement, The financial Equation becomes:
+ *
+ * 2) [PV + PMT*(1 + iX)/i][(1 + i)^n - 1] + PV + FV = 0
+ *
+ * or
+ *
+ * 3) (PV + C)*A + PV + FV = 0
+ *
+ * where:
+ * 4) A = (1 + i)^n - 1
+ *
+ * 5) B = (1 + iX)/i
+ *
+ * 6) C = PMT*B
+ *
+ * The form of equation 3) simplifies the calculation procedure for all five
+ * variables, which are readily solved as follows:
+ *
+ * 7) n = ln[(C - FV)/(C + PV)]/ln((1 + i)
+ *
+ * 8) PV = -[FV + A*C]/(A + 1)
+ *
+ * 9) PMT = -[FV + PV*(A + 1)]/[A*B]
+ *
+ * 10) FV = -[PV + A*(PV + C)]
+ *
+ * Equations 4), 5) and 6) are computed by functions:
+ *
+ * _A
+ * _B
+ * _C
+ *
+ * respectively. Equations 7), 8), 9) and 10) are computed by functions:
+ *
+ * _N
+ * _PV
+ * _PMT
+ * _FV
+ *
+ * respectively.
+ *
+ * The solution for interest is broken into two cases:
+ *
+ * PMT == 0
+ * i = [FV/PV]^(1/n) - 1
+ *
+ * PMT != 0
+ *
+ * Since equation 3) cannot be solved explicitly for i in this
+ * case, an iterative technique must be employed. Newton's
+ * method, using exact expressions for the function of i and its
+ * derivative, are employed. The expressions are:
+ *
+ * 12) i[k+1] = i[k] - f(i[k])/f'(i[k])
+ * where: i[k+1] == (k+1)st iteration of i
+ * i[k] == kth iteration of i
+ * and:
+ *
+ * 13) f(i) = A*(PV+C) + PV + FV
+ *
+ * 14) f'(i) = n*D*(PV+C) - (A*C)/i
+ *
+ * 15) D = (1 + i)^(n-1) = (A+1)/(1+i)
+ *
+ * To start the iterative solution for i, an initial guess must be made
+ * for the value of i. The closer this guess is to the actual value,
+ * the fewer iterations will have to be made, and the greater the
+ * probability that the required solution will be obtained. The initial
+ * guess for i is obtained as follows:
+ *
+ * if PMT*FV >= 0, then PV case
+ * if PMT*FV < 0, then FV case
+ *
+ * PV case:
+ * | n*PMT + PV + FV |
+ * 16) i[0] = | ----------------|
+ * | n*PV |
+ *
+ * = abs[(n*PMT + PV + FV)/(n*PV)]
+ *
+ * FV case:
+ * a) PV != 0
+ *
+ * | FV - n*PMT |
+ * 17) i[0] = |---------------------------|
+ * | 3*[PMT*(n-1)^2 + PV - FV] |
+ *
+ * = abs[(FV-n*PMT)/(3*(PMT*(n-1)^2+PV-FV))]
+ * b) PV == 0
+ *
+ * | FV + n*PMT |
+ * 18) i[0] = |---------------------------|
+ * | 3*[PMT*(n-1)^2 + PV - FV] |
+ *
+ * = abs[(FV+n*PMT)/(3*(PMT*(n-1)^2+PV-FV))]
+ *
+ * ****************************************************************************
+ * Constant payment to principal loan
+ *
+ * In this loan, each total payment is different, with each
+ * succeeding payment less than the preceeding payment. Each payment
+ * is the total of the constant ammount to the principal plus the
+ * interest for the period. The constant payment to the principal is
+ * computed as:
+ *
+ * C = -PV / N
+ *
+ * Where PV is the loan amount to be repaid in N payments
+ * (periods). Note that the constant payment to principal could be
+ * any value agreed to by the two parties involved.
+ *
+ * Thus the principal after the first payment is:
+ * PV[1] = PV[0] + C = PV + C
+ * after the second payment, the principal is:
+ * PV[2] = PV[1] + C = PV[0] + 2C
+ * In general, the remaining principal after n payments is:
+ * PV[n] = PV[0] + nC = PV + nC
+ *
+ * If the effective interest per payment period is i, then the
+ * interest for the first payment is:
+ *
+ * I[1] = -i*PV[0] = -i*PV
+ * and for the second:
+ * I[2] = -i * PV[1]
+ * and in general, for the n'th payment the interest is:
+ * I[n] = -i * PV[n-1]
+ * = -i * (PV + (n-1)C)
+ * The total payment for any period, n, is:
+ * P[n] = C + I[n]
+ * = C + i * (PV + (n-1)C)
+ * = C(1 + i) - i * (PV + nC)
+ * The total interest paid to period n is:
+ * T[n] = I[1] + I[2] + I[3] + ... + I[n]
+ * T[n] = sum(j = 1 to n: I[j])
+ * T[n] = sum(j = 1 to n: -i * (PV + (j-1)C))
+ * T[n] = sum(j=1 to n: -i*PV) + sum(j=1 to n: iC) + sum(j=1 to n: -iCj)
+ * T[n] = -i*n*PV + i*n*C - i*C*sum(j=1 to n:j)
+ * sum(j=1 to n:j) = n(n+1)/2
+ * T[n] = -i*n*(PV + C) - i*C*n(n+1)/2
+ * T[n] = -i*n*(PV + (C*(n - 1)/2))
+ *
+ * Note: substituing for C = -PV/N, in the equations for PV[n], I[n],
+ * P[n], and T[n] would give the following equations:
+ *
+ * PV[n] = PV*(1 - n/N)
+ * I[n] = -i*PV*(1 + N - n)/N
+ * P[n] = -i*PV*(2 + N - n)/N
+ * T[n] = -i*n*PV*(2*N - n + 1)/(2*N)
+ *
+ * Using these equations for the calculations would eliminate the
+ * dependence on C, but only if C is always defined as above and
+ * would eliminate the possibility of another value for C. If the
+ * value of C was less than -PV/N then a balloon payment would be
+ * due at the final payment and this is a possible alternative for
+ * some people.
+ *
+ * ****************************************************************************
+ *
+ * Amortization Schedules.
+ *
+ * Financial Transactions have an effective Date, ED, and an Initial Payment
+ * Date, IP. ED may or may not be the same as IP, but IP is always the same
+ * or later than ED. Most financial transaction calculators assume that
+ * IP is equal to ED for beginning of period payments or at the end of the
+ * first payment period for end of period payments.
+ *
+ * This is not always true. IP may be delayed for financial reasons
+ * such as cash flow or accounting calender. The subsequent payments
+ * then follow the agreed upon periodicity. Since money has a time
+ * value, the "delayed" IP must be accounted for. Computing an
+ * "Effective PV", pve, is one means of handling a delayed IP.
+ *
+ * EDj == the Julian Day Number of ED, and
+ * IPj == the Julian Day Number of IP in the following.
+ *
+ * pve is be computed as:
+ *
+ * pve = pv*(1 + i)^(s*PF/d*CF)
+ *
+ * Where: d = length of the payment period in days, and
+ * s = IPj - EDj - d*X
+ *
+ * Computing an amortization Schedule for a given financial transaction is
+ * simply applying the basic equation iteratively for each payment period:
+ *
+ * PV[n] = PV[n-1] + (PMT + (PV[n-1] + X * PMT) * i)
+ *
+ * At the end of each iteration, PV[n] is rounded to the nearest cent. For
+ * each payment period, the interest due may be computed separately as:
+ *
+ * ID[n] = (PMT + (PV[n-1] + X * PMT) * i)
+ *
+ * and rounded to the nearest cent. PV[n] then becomes:
+ *
+ * PV[n] = PV[n-1] + PMT + ID[n]
+ *
+ * For those cases where a yearly summary only is desired, it is not
+ * necessary to compute each transaction for each payment period,
+ * rather the PV may be be computed for the beginning of each year,
+ * PV[yr], and the FV computed for the end of the year, FV[yr]. The
+ * interest paid during the year is the computed as:
+ *
+ * ID[yr] = (NP * PMT) + PV[yr] + FV[yr]
+ *
+ * Since the final payment may not be equal to the periodic payment,
+ * the final payment must be computed separately as follows. Two
+ * derivations are given below for the final payment equation. Both
+ * derivations are given below since one or the other may be clearer
+ * to some readers. Both derivations are essentially the same, they
+ * just have different starting points. The first is the fastest.
+ *
+ * 1) final_pmt == final payment @ payment n == int(n)
+ * from above the basic financial equation:
+ * PV[n] = PV[n-1]*(1 + i) + final_pmt * (1 + iX),
+ * i == effective interest rate
+ *
+ * solving for final_pmt, we have:
+ *
+ * final_pmt * (1 + iX) = PV[n] - PV[n-1]*(1 + i)
+ * = FV[n-1]*(1 + i) - FV[n]
+ * final_pmt = FV[n-1]*(1+i)/(1 + iX) - FV[n]/(1 + iX)
+ *
+ * final_pmt = FV[n-1]*(1 + i) - FV[n],
+ * for X == 0, end of period payments
+ *
+ * = FV[n-1] - FV[n]/(1 + i),
+ * for X == 1, beginning of period payments
+ *
+ * 2) final_pmt == final payment @ payment n == int(n)
+ * i[n] == interest due @ payment n
+ * i[n] = (PV[n-1] + X * final_pmt) * i, i == effective interest rate
+ * = (X * final_pmt - FV[n]) * i
+ *
+ * Now the final payment is the sum of the interest due, plus
+ * the present value at the next to last payment plus any
+ * residual future value after the last payment:
+ *
+ * final_pmt = -i[n] - PV[n-1] - FV[n]
+ * = FV[n-1] - i[n] - FV[n]
+ * = FV[n-1] - (X *final_pmt - FV[n-1])*i - FV[n]
+ * = FV[n-1]*(1 + i) - X*final_pmt*i - FV[n]
+ *
+ * solving for final_pmt:
+ * final_pmt*(1 + iX) = FV[n-1]*(1 + i) - FV[n]
+ * final_pmt = FV[n-1]*(1 + i)/(1 + iX) - FV[n]/(1 + iX)
+ *
+ * final_pmt = FV[n-1]*(1 + i) - FV[n],
+ * for X == 0, end of period payments
+ *
+ * = FV[n-1] - FV[n]/(1 + i),
+ * for X == 1, beginning of period payments
+ *
+ *============================================================================
+ *
+ * The amortization schedule is computed for four different situations:
+ *
+ * 1) The original financial data is used. This ignores any possible
+ * agjustment to the Present value due to any delay in the initial
+ * payment. This is quite common in mortgages where end of period
+ * payments are used and the first payment is scheduled for the end
+ * of the first whole period, i.e., any partial payment period from
+ * ED to the beginning of the next payment period is ignored.
+ *
+ * 2) The original periodic payment is used, the Present Value is
+ * adjusted for the delayed Initial Payment. The total number of
+ * payments remains the same. The final payment is adjusted to bring
+ * the balance into agreement with the agreed upon final Future
+ * Value.
+ *
+ * 3) A new periodic payment is computed based upon the adjusted
+ * Present Value, the agreed originally upon number of total
+ * payments and the agreed upon Future Value. The new periodic
+ * payments are computed to minimize the final payment in accordance
+ * with the Future Value after the last payment.
+ *
+ * 4) The original periodic payment is retained and a new number of
+ * total payments is computed based upon the adjusted Present Value
+ * and the agreed upon Future Value.
+ *
+ * The amortization schedule may be computed and displayed in three manners:
+ *
+ * 1. The payment *, interest paid, principal paid and remaining PV
+ * for each payment period are computed and displayed. At the end of
+ * each year a summary is computed and displayed and the total
+ * interest paid is diplayed at the end.
+ *
+ * 2. A summary is computed and displayed for each year. The
+ * interest paid during the year is computed and displayed as well
+ * as the remaining balance at years end. The total interest paid
+ * is diplayed at the end.
+ *
+ * 3. An amortization schedule is computed for a common method of
+ * advanced payment of principal is computed and displayed. In this
+ * amortization, the principal for the next payment is computed and
+ * added into the current payment. This method will cut the number
+ * of total payments in half and will cut the interest paid almost
+ * in half. For mortgages, this method of prepayment has the
+ * advantage of keeping the total payments small during the initial
+ * payment periods The payments grow until the last payment period
+ * when presumably the borrower can afford larger payments.
+ *
+ * ===========================================================================
+ * NOTE: For Payment Frequencies, PF, semi-monthly or less, i.e., PF
+ * == 12 or PF == 24, a 360 day calender year and 30 day month are
+ * used. For Payment Frequencies, PF, greater than semi-monthly, PF
+ * > 24, the actual number of days per year and per payment period
+ * are used. The actual values are computed using the built-in
+ * 'julian_day_number' function
+ *
+ * ****************************************************************************
+ *
+ * Note: in the following examples, the user input is preceeded by the
+ * prompt "<>". The result of evaluating the input expression is then
+ * displayed. I have taken the liberty of including comments in the
+ * example input/output sessions by preceeding with ' *'. Thus, for
+ * the line: <>n=5 *set number of periods the comment that setting the
+ * number of periods is not really input and the true input is only:
+ * <>n=5
+ *
+ * Example 1: Simple Interest
+ * Find annual simple interest rate (%) for an $800 loan to be repayed at the
+ * end of one year with a single payment of $896.
+ * <>d
+ * <>CF=PF=1
+ * 1.00
+ * <>n=1
+ * 1.00
+ * <>pv=-800
+ * -800.00
+ * <>fv=896
+ * 896.00
+ * <>I
+ * 12.00
+ *
+ * Example 2: Compound Interest
+ * Find the future value of $800 after one year at a nominal rate of 12%
+ * compounded monthly. No payments are specified, so the payment frequency is
+ * set equal to the compounding frequency at the default values.
+ * <>d
+ * <>n=12
+ * 12.00
+ * <>i=12
+ * 12.00
+ * <>pv=-800
+ * -800.00
+ * <>FV
+ * 901.46
+ *
+ * Example 3: Periodic Payment:
+ * Find the monthly end-of-period payment required to fully amortize the loan
+ * in Example 2. A fully amortized loan has a future value of zero.
+ * <>fv=0
+ * 0.00
+ * <>PMT
+ * 71.08
+ *
+ * Example 4: Conventional Mortgage
+ *
+ * Find the number of monthly payments necessary to fully amortize a
+ * loan of $100,000 at a nominal rate of 13.25% compounded monthly, if
+ * monthly end-of-period payments of $1125.75 are made.
+ *
+ * <>d
+ * <>i=13.25
+ * 13.25
+ * <>pv=100000
+ * 100,000.00
+ * <>pmt=-1125.75
+ * -1,125.75
+ * <>_N(i,pv,pmt,fv,CF,PF,disc,bep)
+ * 360.10
+ * <>N
+ * 360
+ *
+ * Example 5: Final Payment
+ * Using the data in example 4, find the amount of the final payment if n is
+ * changed to 360. The final payment will be equal to the regular payment plus
+ * any balance, future value, remaining at the end of period number 360.
+ * <>n=360
+ * 360.00
+ * <>FV
+ * -108.87
+ * <>pmt+fv
+ * -1,234.62
+ *
+ * Using the data from this loan, compute the amortization schedule
+ * when the Effective date of the loan is June 6, 1996 and the
+ * initial payment is made on August 1, 1996. Ignore any change in
+ * the PV due to the delayed initial payment caused by the partial
+ * payment period from June 6 to July 1.
+ *
+ * <>ED = 06/06/1996
+ * Effective Date set: 06/06/1996 ( 2450241 )
+ * <>IP = 08/01/1996
+ * Initial Payment Date set: 08/01/1996 ( 2450297 )
+ * <>a
+ * Effective Date: 06/06/96
+ * Initial Payment Date: 08/01/96
+ * The amortization options are:
+ * The Old Present Value (pv) was: 100,000.00
+ * The Old Periodic Payment (pmt) was: -1,125.75
+ * The Old Future Value (fv) was: -108.87
+ * 1: Amortize with Original Transaction Values
+ * and balloon final payment: -1,125.75
+ *
+ * The New Present Value (pve) is: 100,919.30
+ * The New Periodic Payment (pmt) is: -1,136.10
+ * 2: Amortize with Original Periodic Payment
+ * and balloon final payment: -49,023.68
+ * 3: Amortize with New Periodic Payment
+ * and balloon final payment: -1,132.57
+ * 4: Amortize with Original Periodic Payment,
+ * new number of total payments (n): 417
+ * and final payment: -2,090.27
+ *
+ * Enter choice 1, 2, 3 or 4: <>
+ *
+ * Press '1'
+ * Amortization Schedule:
+ * Yearly, y, per Payment, p, or Advanced Payment, a, Amortization
+ * Enter choice y, p or a:
+ * <>
+ *
+ * Press 'y'
+ * Enter Filename for Amortization Schedule.
+ * (null string uses Standard Output):
+ * Press enter to display output on screen
+ *
+ * Amortization Table
+ * Effective Date: Thu Jun 06 00:00:00 1996
+ * Initial Payment Date: Thu Aug 01 00:00:00 1996
+ * Compounding Frequency per year: 12
+ * Payment Frequency per year: 12
+ * Compounding: Discrete
+ * Payments: End of Period
+ * Payments (359): -1,125.75
+ * Final payment: -1,125.75
+ * Nominal Annual Interest Rate: 13.25
+ * Effective Interest Rate Per Payment Period: 0.0110417
+ * Present Value: 100,000.00
+ * Year Interest Ending Balance
+ * 1996 -5,518.42 -99,889.67
+ * 1997 -13,218.14 -99,598.81
+ * 1998 -13,177.17 -99,266.98
+ * 1999 -13,130.43 -98,888.41
+ * 2000 -13,077.11 -98,456.52
+ * 2001 -13,016.28 -97,963.80
+ * 2002 -12,946.88 -97,401.68
+ * 2003 -12,867.70 -96,760.38
+ * 2004 -12,777.38 -96,028.76
+ * 2005 -12,674.33 -95,194.09
+ * 2006 -12,556.76 -94,241.85
+ * 2007 -12,422.64 -93,155.49
+ * 2008 -12,269.63 -91,916.12
+ * 2009 -12,095.06 -90,502.18
+ * 2010 -11,895.91 -88,889.09
+ * 2011 -11,668.70 -87,048.79
+ * 2012 -11,409.50 -84,949.29
+ * 2013 -11,113.78 -82,554.07
+ * 2014 -10,776.41 -79,821.48
+ * 2015 -10,391.53 -76,704.01
+ * 2016 -9,952.43 -73,147.44
+ * 2017 -9,451.49 -69,089.93
+ * 2018 -8,879.99 -64,460.92
+ * 2019 -8,227.99 -59,179.91
+ * 2020 -7,484.16 -53,155.07
+ * 2021 -6,635.56 -46,281.63
+ * 2022 -5,667.43 -38,440.06
+ * 2023 -4,562.94 -29,494.00
+ * 2024 -3,302.89 -19,287.89
+ * 2025 -1,865.36 -7,644.25
+ * 2026 -236.00 -108.87
+ *
+ * Total Interest: -305,270.00
+ *
+ * NOTE: The amortization table leaves the FV as it was when the amortization
+ * function was entered. Thus, a balance of 108.87 is due at the end of the
+ * table. To completely pay the loan, set fv to 0.0:
+ * <>fv=0
+ * 0.0
+ * <>a
+ * Effective Date: 06/06/96
+ * Initial Payment Date: 08/01/96
+ * The amortization options are:
+ * The Old Present Value (pv) was: 100,000.00
+ * The Old Periodic Payment (pmt) was: -1,125.75
+ * The Old Future Value (fv) was: 0.00
+ * 1: Amortize with Original Transaction Values
+ * and balloon final payment: -1,234.62
+ *
+ * The New Present Value (pve) is: 100,919.30
+ * The New Periodic Payment (pmt) is: -1,136.12
+ * 2: Amortize with Original Periodic Payment
+ * and balloon final payment: -49,132.55
+ * 3: Amortize with New Periodic Payment
+ * and balloon final payment: -1,148.90
+ * 4: Amortize with Original Periodic Payment,
+ * new number of total payments (n): 417
+ * and final payment: -2,199.14
+ *
+ * Enter choice 1, 2, 3 or 4: <>
+ * Press '1'
+ * Amortization Schedule:
+ * Yearly, y, per Payment, p, or Advanced Payment, a, Amortization
+ * Enter choice y, p or a:
+ * <>
+ * Press 'y'
+ * Enter Filename for Amortization Schedule.
+ * (null string uses Standard Output):
+ * Press enter to display output on screen
+ *
+ * Amortization Table
+ * Effective Date: Thu Jun 06 00:00:00 1996
+ * Initial Payment Date: Thu Aug 01 00:00:00 1996
+ * Compounding Frequency per year: 12
+ * Payment Frequency per year: 12
+ * Compounding: Discrete
+ * Payments: End of Period
+ * Payments (359): -1,125.75
+ * Final payment: -1,234.62
+ * Nominal Annual Interest Rate: 13.25
+ * Effective Interest Rate Per Payment Period: 0.0110417
+ * Present Value: 100,000.00
+ * Year Interest Ending Balance
+ * 1996 -5,518.42 -99,889.67
+ * 1997 -13,218.14 -99,598.81
+ * 1998 -13,177.17 -99,266.98
+ * 1999 -13,130.43 -98,888.41
+ * 2000 -13,077.11 -98,456.52
+ * 2001 -13,016.28 -97,963.80
+ * 2002 -12,946.88 -97,401.68
+ * 2003 -12,867.70 -96,760.38
+ * 2004 -12,777.38 -96,028.76
+ * 2005 -12,674.33 -95,194.09
+ * 2006 -12,556.76 -94,241.85
+ * 2007 -12,422.64 -93,155.49
+ * 2008 -12,269.63 -91,916.12
+ * 2009 -12,095.06 -90,502.18
+ * 2010 -11,895.91 -88,889.09
+ * 2011 -11,668.70 -87,048.79
+ * 2012 -11,409.50 -84,949.29
+ * 2013 -11,113.78 -82,554.07
+ * 2014 -10,776.41 -79,821.48
+ * 2015 -10,391.53 -76,704.01
+ * 2016 -9,952.43 -73,147.44
+ * 2017 -9,451.49 -69,089.93
+ * 2018 -8,879.99 -64,460.92
+ * 2019 -8,227.99 -59,179.91
+ * 2020 -7,484.16 -53,155.07
+ * 2021 -6,635.56 -46,281.63
+ * 2022 -5,667.43 -38,440.06
+ * 2023 -4,562.94 -29,494.00
+ * 2024 -3,302.89 -19,287.89
+ * 2025 -1,865.36 -7,644.25
+ * 2026 -344.87 0.00
+ *
+ * Total Interest: -305,378.87
+ *
+ * Example 6: Balloon Payment
+ * On long term loans, small changes in the periodic payments can generate
+ * large changes in the future value. If the monthly payment in example 5 is
+ * rounded down to $1125, how much addtional (balloon) payment will be due
+ * with the final regular payment.
+ * <>pmt=-1125
+ * -1,125
+ * <>FV
+ * -3,579.99
+ *
+ * Example 7: Canadian Mortgage
+ * Find the monthly end-of-period payment necessary to fully amortize a 25 year
+ * $85,000 loan at 11% compounded semi-annually.
+ * <>d
+ * <>CF=2
+ * 2.00
+ * <>n=300
+ * 300.00
+ * <>i=11
+ * 11.00
+ * <>pv=85000
+ * 85,000.00
+ * <>PMT
+ * -818.15
+ *
+ * Example 8: European Mortgage
+ * The "effective annual rate (EAR)" is used in some countries (especially
+ * in Europe) in lieu of the nominal rate commonly used in the United States
+ * and Canada. For a 30 year $90,000 mortgage at 14% (EAR), compute the monthly
+ * end-of-period payments. When using an EAR, the compounding frequency is
+ * set to 1.
+ * <>d
+ * <>CF=1
+ * 1.00
+ * <>n=30*12
+ * 360.00
+ * <>i=14
+ * 14.00
+ * <>pv=90000
+ * 90,000.00
+ * <>PMT
+ * -1,007.88
+ *
+ * Example 9: Bi-weekly Savings
+ * Compute the future value, fv, of bi-weekly savings of $100 for 3 years at a
+ * nominal annual rate of 5.5% compounded daily. (Set payment to
+ * beginning-of-period, bep = TRUE)
+ * <>d
+ * <>bep=TRUE
+ * 1.00
+ * <>CF=365
+ * 365.00
+ * <>PF=26
+ * 26.00
+ * <>n=3*26
+ * 78.00
+ * <>i=5.5
+ * 5.50
+ * <>pmt=-100
+ * -100.00
+ * <>FV
+ * 8,489.32
+ *
+ * Example 10: Present Value - Annuity Due
+ * What is the present value of $500 to be received at the beginning of each
+ * quarter over a 10 year period if money is being discounted at 10% nominal
+ * annual rate compounded monthly?
+ * <>d
+ * <>bep=TRUE
+ * 1.00
+ * <>PF=4
+ * 4.00
+ * <>n=4*10
+ * 40.00
+ * <>i=10
+ * 10.00
+ * <>pmt=500
+ * 500.00
+ * <>PV
+ * -12,822.64
+ *
+ * Example 11: Effective Rate - 365/360 Basis
+ * Compute the effective annual rate (%APR) for a nominal annual rate of 12%
+ * compounded on a 365/360 basis used by some Savings & Loan Associations.
+ * <>d
+ * <>n=365
+ * 365.00
+ * <>CF=365
+ * 365.00
+ * <>PF=360
+ * 360.00
+ * <>i=12
+ * 12.00
+ * <>pv=-100
+ * -100.00
+ * <>FV
+ * 112.94
+ * <>fv+pv
+ * 12.94
+ *
+ * Example 12: Mortgage with "Points"
+ *
+ * What is the true APR of a 30 year, $75,000 loan at a nominal rate
+ * of 13.25% compounded monthly, with monthly end-of-period payments,
+ * if 3 "points" are charged? The pv must be reduced by the dollar
+ * value of the points and/or any lenders fees to establish an
+ * effective pv. Because payments remain the same, the true APR will
+ * be higher than the nominal rate. Note, first compute the payments
+ * on the pv of the loan amount.
+ *
+ * <>d
+ * <>CF=PF=1
+ * 1.00
+ * <>n=30*12
+ * 360.00
+ * <>i=13.25/12
+ * 1.10
+ * <>pv=75000
+ * 75,000.00
+ * <>PMT
+ * -844.33
+ * <>pv -= pv*.03
+ * 72,750.00
+ * <>CF=PF=12
+ * 12.00
+ * <>I
+ * 13.69
+ *
+ * Example 13: Equivalent Payments
+ * Find the equivalent monthly payment required to amortize a 20 year $40,000
+ * loan at 10.5% nominal annual rate compounded monthly, with 10 annual
+ * payments of $5029.71 remaining. Compute the pv of the remaining annual
+ * payments, then change n, the number of periods, and the payment frequency,
+ * PF, to a monthly basis and compute the equivalent monthly pmt.
+ * <>d
+ * <>PF=1
+ * 1.00
+ * <>n=10
+ * 10.00
+ * <>i=10.5
+ * 10.50
+ * <>pmt=-5029.71
+ * -5,029.71
+ * <>PV
+ * 29,595.88
+ * <>PF=12
+ * 12.00
+ * <>n=120
+ * 120.00
+ * <>PMT
+ * -399.35
+ *
+ * Example 14: Perpetuity - Continuous Compounding
+ * If you can purchase a single payment annuity with an initial investment of
+ * $60,000 that will be invested at 15% nominal annual rate compounded
+ * continuously, what is the maximum monthly return you can receive without
+ * reducing the $60,000 principal? If the principal is not disturbed, the
+ * payments can go on indefinitely (a perpetuity). Note that the term,n, of
+ * a perpetuity is immaterial. It can be any non-zero value.
+ * <>d
+ * <>disc=FALSE
+ * 0.00
+ * <>n=12
+ * 12.00
+ * <>CF=1
+ * 1.00
+ * <>i=15
+ * 15.00
+ * <>fv=60000
+ * 60,000.00
+ * <>pv=-60000
+ * -60,000.00
+ * <>PMT
+ * 754.71
+ *
+ * references:
+ * 1. PPC ROM User's Manual
+ * pages 148 - 164
+ *
+ */
+
+#include <time.h>
+#include <stdio.h>
+#include <glib.h>
+#include <math.h>
+#if defined(G_OS_WIN32) && !defined(_MSC_VER)
+#include <pow.h>
+#endif
+#include <string.h>
+#include <stdlib.h>
+
+#define FIN_STATICS
+#include "finvar.h"
+#include "finproto.h"
+#include "fin_static_proto.h"
+
+/* return 'x' rounded to 'places' past decimal if 'places' < 0, return
+ * 'x' */
+static double
+rnd (double x, unsigned places)
+{
+ double r;
+ char buf[50]; /* make buffer large enough */
+
+ if (places >= 0)
+ {
+ sprintf (buf, "%.*f", (int) places, x);
+ r = strtod(buf, NULL);
+ }
+ else
+ r = x;
+
+ return r;
+} /* rnd */
+
+/* return absolute value of 'x' this function is provided by a macro
+ * in C */
+static double
+dabs (double x)
+{
+ return (x >= 0.0) ? x : -x;
+} /* dabs */
+
+/* Compute constant used in calculations */
+static double
+_A (double eint, unsigned per)
+{
+ return pow ((1.0 + eint), (double) per) - 1.0;
+} /* _A */
+
+/* Compute constant used in calculations */
+static double
+_B (double eint, unsigned beg)
+{
+ /* if eint == 0.0, all processing _must_ stop or
+ a recursive loop will start. */
+ g_return_val_if_fail(eint != 0.0, 0.0);
+ return (1.0 + eint * (double) beg) / eint;
+} /* _B */
+
+/* Compute constant used in calculations */
+static double
+_C (double eint, double pmt, unsigned beg)
+{
+ g_return_val_if_fail(eint != 0.0, 0.0);
+ return pmt * _B(eint, beg);
+} /* _C */
+
+/* compute Number of Periods from preset data */
+unsigned
+fi_calc_num_payments (fi_ptr fi)
+{
+ return fi->npp =
+ (unsigned)
+ rnd (_fi_calc_num_payments
+ (fi->ir, fi->pv, fi->pmt, fi->fv, fi->CF, fi->PF, fi->disc, fi->bep),
+ 0);
+} /* fi_calc_num_payments */
+
+/* Compute number of periods from:
+ * 1. Nominal Interest
+ * 2. Present Value
+ * 3. Periodic Payment
+ * 4. Future Value
+ */
+double
+_fi_calc_num_payments (double nint, /* nominal interest rate */
+ double pv, /* present value */
+ double pmt, /* periodic payment */
+ double fv, /* future value */
+ unsigned CF, /* compounding frequency */
+ unsigned PF, /* payment frequency */
+ unsigned disc, /* discrete/continuous compounding */
+ unsigned bep) /* beginning/end of period payment */
+{
+ double eint = eff_int (nint / 100.0, CF, PF, disc);
+ double CC = _C (eint, pmt, bep);
+ CC = (CC - fv) / (CC + pv);
+ return (CC > 0.0) ? log (CC) / log (1.0 + eint) : 0.0;
+} /* _fi_calc_num_payments */
+
+/* compute Interest from preset data */
+double
+fi_calc_interest (fi_ptr fi)
+{
+ if (fi->npp)
+ fi->ir = _fi_calc_interest (fi->npp, fi->pv, fi->pmt, fi->fv,
+ fi->CF, fi->PF, fi->disc, fi->bep);
+
+ return fi->ir;
+} /* fi_calc_interest */
+
+double ratio = 1e4; /* ratio used in iterative solution for interest */
+
+/* Compute Nominal Interest from:
+ * 1. Number of periods
+ * 2. Present Value
+ * 3. Periodic Payment
+ * 4. Future Value
+ */
+double
+_fi_calc_interest (unsigned per,/* number of periods */
+ double pv, /* present value */
+ double pmt, /* periodic payment */
+ double fv, /* future value */
+ unsigned CF, /* compounding frequency */
+ unsigned PF, /* payment frequency */
+ unsigned disc, /* discrete/continuous compounding */
+ unsigned bep) /* beginning/end of period payment */
+{
+ double eint;
+ double a, dik;
+ int ri;
+
+ if (pmt == 0.0)
+ eint = pow ((dabs (fv) / dabs (pv)), (1.0 / (double) per)) - 1.0;
+ else
+ {
+ if ((pmt * fv) < 0.0)
+ {
+ if (pv)
+ a = -1.0;
+ else
+ a = 1.0;
+ eint =
+ dabs ((fv + a * (double) per * pmt) /
+ (3.0 *
+ (((double) per - 1.0) * ((double) per - 1.0) * pmt + pv -
+ fv)));
+ }
+ else
+ {
+ if ((pv * pmt) < 0.0)
+ {
+ eint = dabs (((double) per * pmt + pv + fv) / ((double) per * pv));
+ }
+ else
+ {
+ a = dabs (pmt / (dabs (pv) + dabs (fv)));
+ eint = a + 1.0 / (a * (double) per * (double) per * (double) per);
+ }
+ }
+ do
+ {
+ dik =
+ fi (per, eint, pv, pmt, fv, bep) / fip (per, eint, pv, pmt, fv, bep);
+ eint -= dik;
+ (void) modf (ratio * (dik / eint), &a);
+ ri = (unsigned) a;
+ }
+ while (ri);
+ } /* endif */
+
+ return 100.0 * nom_int (eint, CF, PF, disc);
+} /* _fi_calc_interest */
+
+/* compute Present value from preset data */
+double
+fi_calc_present_value (fi_ptr fi)
+{
+ return fi->pv =
+ rnd (_fi_calc_present_value
+ (fi->npp, fi->ir, fi->pmt, fi->fv, fi->CF, fi->PF, fi->disc,
+ fi->bep), fi->prec);
+} /* fi_calc_present_value */
+
+/* Compute Present Value from:
+ * 1. Number of periods
+ * 2. Nominal Interest
+ * 3. Periodic Payment
+ * 4. Future Value
+ */
+double
+_fi_calc_present_value (unsigned per, /* number of periods */
+ double nint, /* nominal interest rate */
+ double pmt, /* periodic payment */
+ double fv, /* future value */
+ unsigned CF, /* compounding frequency */
+ unsigned PF, /* payment frequency */
+ unsigned disc, /* discrete/continuous compounding */
+ unsigned bep) /* beginning/end of period payment */
+{
+ double eint = eff_int (nint / 100.0, CF, PF, disc);
+ double AA = _A (eint, per);
+ double CC = _C (eint, pmt, bep);
+
+ return -(fv + (AA * CC)) / (AA + 1.0);
+} /* _fi_calc_present_value */
+
+/* compute Periodic Payment from preset data */
+double
+fi_calc_payment (fi_ptr fi)
+{
+ return fi->pmt =
+ rnd (_fi_calc_payment
+ (fi->npp, fi->ir, fi->pv, fi->fv, fi->CF, fi->PF, fi->disc, fi->bep),
+ fi->prec);
+} /* fi_calc_payment */
+
+/* Compute Periodic Payment from:
+ * 1. Number of periods
+ * 2. Nominal Interest
+ * 3. Present Value
+ * 4. Future Value
+ */
+double
+_fi_calc_payment (unsigned per, /* number of periods */
+ double nint, /* nominal interest rate */
+ double pv, /* present value */
+ double fv, /* future value */
+ unsigned CF, /* compounding frequency */
+ unsigned PF, /* payment frequency */
+ unsigned disc,/* discrete/continuous compounding */
+ unsigned bep) /* beginning/end of period payment */
+{
+ double eint = eff_int (nint / 100.0, CF, PF, disc);
+ double AA = _A (eint, per);
+ double BB = _B (eint, bep);
+ g_return_val_if_fail(BB != 0.0, 0.0);
+
+ return -(fv + pv * (AA + 1.0)) / (AA * BB);
+} /* _fi_calc_payment */
+
+/* compute Future Value from preset data */
+double
+fi_calc_future_value (fi_ptr fi)
+{
+ return fi->fv =
+ rnd (_fi_calc_future_value
+ (fi->npp, fi->ir, fi->pv, fi->pmt, fi->CF, fi->PF, fi->disc,
+ fi->bep), fi->prec);
+} /* fi_calc_future_value */
+
+/* Compute Future Value from:
+ * 1. Number of periods
+ * 2. Nominal Interest
+ * 3. Present Value
+ * 4. Periodic Payments
+ */
+double
+_fi_calc_future_value (unsigned per, /* number of periods */
+ double nint, /* nominal interest rate */
+ double pv, /* present value */
+ double pmt, /* periodic payment */
+ unsigned CF, /* compounding frequency */
+ unsigned PF, /* payment frequency */
+ unsigned disc, /* discrete/continuous compounding */
+ unsigned bep) /* beginning/end of period payment */
+{
+ double eint = eff_int (nint / 100.0, CF, PF, disc);
+ double AA = _A (eint, per);
+ double CC = _C (eint, pmt, bep);
+
+ return -(pv + AA * (pv + CC));
+} /* _fi_calc_future_value */
+
+/* compute Nominal Interest Rate from Effective Interest Rate */
+static double
+nom_int (double eint, unsigned CF, unsigned PF, unsigned disc)
+{
+ double nint;
+
+ if (disc)
+ {
+ if (CF == PF)
+ {
+ nint = CF * eint;
+ }
+ else
+ {
+ nint = CF * (pow ((1.0 + eint), ((double) PF / (double) CF)) - 1.0);
+ } /* * endif */
+ }
+ else
+ nint = log (pow (1.0 + eint, PF));
+
+ return nint;
+} /* nom_int */
+
+/* Compute Effective Interest Rate from Nominal Interest Rate */
+static double
+eff_int (double nint, unsigned CF, unsigned PF, unsigned disc)
+{
+ double eint;
+
+ if (disc)
+ {
+ if (CF == PF)
+ {
+ eint = nint / (double) CF;
+ }
+ else
+ {
+ eint =
+ pow ((1.0 + nint / (double) CF), ((double) CF / (double) PF)) - 1.0;
+ } /* endif */
+ }
+ else
+ eint = exp (nint / (double) PF) - 1.0;
+
+ return eint;
+} /* eff_int */
+
+/* calculation used in interest computation */
+static double
+fi (unsigned per, double eint, double pv, double pmt, double fv, unsigned bep)
+{
+ return _A (eint, per) * (pv + _C (eint, pmt, bep)) + pv + fv;
+} /* fi */
+
+/* calculation used in interest computation
+ */
+static double
+fip (unsigned per, double eint, double pv, double pmt, double fv, unsigned bep)
+{
+ double AA = _A (eint, per);
+ double CC = _C (eint, pmt, bep);
+ double D = (AA + 1.0) / (1.0 + eint);
+ g_return_val_if_fail(CC != 0.0, 0.0);
+ return (double) per * (pv + CC) * D - (AA * CC) / eint;
+} /* fip */
+
+void
+set_default (fi_ptr fi)
+{
+ /* flag whether accrueing interest at beginning or end of period
+ * FALSE --> end
+ * TRUE --> beginning
+ * default to end of period payment s
+ */
+ fi->bep = FALSE;
+
+ /* flag for discrete or continuous interest
+ * TRUE --> discrete
+ * FALSE --> continuous
+ * default to discrete interest
+ */
+ fi->disc = TRUE;
+
+ /* set compounding, CF, and payment, PF, frequency per year
+ * default to monthly payments and compounding
+ */
+ fi->CF = fi->PF = 12;
+
+ /* standard loan quantities:
+ * number of periods: n
+ */
+ fi->npp = 0;
+
+ /* annual interest: i
+ */
+ fi->ir = 0.0;
+
+ /* Present Value: pv
+ */
+ fi->pv = 0.0;
+
+ /* Payment: pmt
+ */
+ fi->pmt = 0.0;
+
+ /* Future Value: fv
+ */
+ fi->fv = 0.0;
+
+} /* set_default */
+
+/* compute Julian Day Number from calender date
+ */
+unsigned long
+julian_day_number (unsigned year, unsigned month, unsigned day)
+{
+ /* Gregorian/Julian Calender Flag.
+ * TRUE == Julian
+ * FALSE == Gregorian
+ */
+ unsigned gregorian = TRUE; /* assume we are dealing with current dates */
+ double yr;
+ double pfac = 0.6;
+ unsigned long ljdn;
+
+ yr = year + (month - 3.0) / 12.0;
+ ljdn = (long) (367.0 * yr + pfac) - (2 * (long) (yr)) + (long) (yr / 4.0)
+ + (long) day + 1721117L;
+ if (gregorian)
+ ljdn += -(long) (yr / 100.0) + (long) (yr / 400.0) + 2;
+
+ return ljdn;
+} /* julian_day_number */
+
+amort_sched_ptr
+Amortization_init (amort_sched_ptr amortsched)
+{
+ unsigned n = amortsched->n;
+ double nint = amortsched->nint;
+ double pv = amortsched->pv;
+ double pmt = amortsched->pmt;
+ double fv = amortsched->fv;
+ double eint;
+ double new_pmt;
+ double pve;
+ unsigned CF = amortsched->CF;
+ unsigned PF = amortsched->PF;
+ unsigned disc = amortsched->disc;
+ unsigned bep = amortsched->bep;
+ unsigned new_n;
+ unsigned prec = amortsched->prec;
+ unsigned long s,
+ d,
+ days_to_yr_end,
+ Eff_Date_jdn =
+ julian_day_number (amortsched->year_E, amortsched->month_E,
+ amortsched->day_E), Init_Date_jdn =
+ julian_day_number (amortsched->year_I, amortsched->month_I,
+ amortsched->day_I);
+
+ amortsched->Eff_Date_jdn = Eff_Date_jdn;
+ amortsched->Init_Date_jdn = Init_Date_jdn;
+ amortsched->yday_E =
+ Eff_Date_jdn - julian_day_number (amortsched->year_E, 1, 1);
+ amortsched->yday_I =
+ Init_Date_jdn - julian_day_number (amortsched->year_I, 1, 1);
+ amortsched->eint = eint = eff_int (nint / 100.0, CF, PF, disc);
+ amortsched->fv_case = dabs (fv) > dabs (pv);
+ amortsched->bp = bep ? 1.0 : 0.0;
+
+ if (PF > 24)
+ {
+ /* Payment frequency per year greater than bi-monthly
+ * use actual number of days
+ */
+ s = Init_Date_jdn - Eff_Date_jdn;
+ days_to_yr_end =
+ julian_day_number (amortsched->year_I + 1, 1, 0) - Init_Date_jdn;
+ d = 366 / PF;
+ }
+ else
+ {
+ /* Payment frequency per year bi-monthly or less
+ * use 30 days/month, 360 days/year
+ */
+ if (Eff_Date_jdn == Init_Date_jdn)
+ {
+ s = 0;
+ }
+ else
+ {
+ s =
+ ((amortsched->year_I - amortsched->year_E) * 360) +
+ ((amortsched->month_I - amortsched->month_E) * 30) +
+ amortsched->day_I - amortsched->day_E;
+ } /* endif */
+ days_to_yr_end = 390 - (amortsched->month_I * 30) - amortsched->day_I;
+ d = 360 / PF;
+ } /* endif */
+
+ if (!bep)
+ {
+ /* ordinary annuity
+ */
+ s -= d;
+ } /* endif */
+
+ amortsched->yr_pmt = (days_to_yr_end + d) / d;
+
+ if (pmt == 0.0)
+ {
+ s = 0;
+ amortsched->pve = pv;
+ }
+ else
+ {
+ amortsched->pve =
+ rnd (pv * pow ((1.0 + eint), ((double) (s * PF) / (double) (d * CF))),
+ prec);
+ } /* endif */
+
+ pve = amortsched->pve;
+
+ /* compute new data to fully amortize loan:
+ * new periodic payment, new_pmt
+ *
+ * option 1: Amortize with original transaction - ignore interest
+ * due to delayed initial payment
+ *
+ * option 2: Amortize with new pv, pve == original pv adjusted for
+ * delayed initial payment, original payment, original fv and
+ * original total number of payments, adjust final payment
+ *
+ * option 3: amortize with new pv, pve, and new payments adjusted to
+ * minimize final payment, keep original number of payments and
+ * original fv
+ *
+ * option 4: amortize with new pv, pve, original payments and new
+ * number of payments to keep original final fv */
+
+ /* option 3, compute new periodic payment */
+ amortsched->new_pmt = new_pmt =
+ rnd (_fi_calc_payment (n, nint, pve, fv, CF, PF, disc, bep), prec);
+
+ /* option 4: compute new number of total payments, new_n */
+ amortsched->new_n = new_n =
+ (unsigned)
+ rnd (_fi_calc_num_payments (nint, pve, pmt, fv, CF, PF, disc, bep), 0);
+
+ /* following used in QTAwk to insure integer value, not needed in C */
+ /* n = int(n); */
+
+ /* compute payment for constant payment to principal loan and final
+ * payment for original loan amount include interest due */
+ amortsched->cpmt1 = rnd (-pv / n, prec);
+ amortsched->final_pmt_opt_1 = -pv - amortsched->cpmt1 * (n - 1);
+ amortsched->final_pmt_opt_1 *= eint + 1;
+
+ /* compute payment for constant payment to principal loan and final
+ * payment for delayed loan amount include interest due */
+ amortsched->cpmt2 = rnd (-pve / n, prec);
+ amortsched->final_pmt_opt_2 = -pve - amortsched->cpmt2 * (n - 1);
+ amortsched->final_pmt_opt_2 *= eint + 1;
+
+ if (bep)
+ {
+ amortsched->final_pmt_opt_3 =
+ rnd (_fi_calc_future_value (n - 1, nint, pv, pmt, CF, PF, disc, bep) -
+ (fv / (1.0 + eint)), prec);
+ amortsched->final_pmt_opt_4 =
+ rnd (_fi_calc_future_value (n - 1, nint, pve, pmt, CF, PF, disc, bep) -
+ (fv / (1.0 + eint)), prec);
+ amortsched->final_pmt_opt_5 =
+ rnd (_fi_calc_future_value
+ (n - 1, nint, pve, new_pmt, CF, PF, disc,
+ bep) - (fv / (1.0 + eint)), prec);
+ if (new_n)
+ amortsched->final_pmt_opt_6 =
+ rnd (_fi_calc_future_value
+ (new_n - 1, nint, pve, pmt, CF, PF, disc,
+ bep) - (fv / (1.0 + eint)), prec);
+ else
+ amortsched->final_pmt_opt_6 = 0.0;
+ }
+ else
+ {
+ amortsched->final_pmt_opt_3 =
+ rnd (_fi_calc_future_value (n - 1, nint, pv, pmt, CF, PF, disc, bep) *
+ (1.0 + eint) - fv, prec);
+ amortsched->final_pmt_opt_4 =
+ rnd (_fi_calc_future_value (n - 1, nint, pve, pmt, CF, PF, disc, bep) *
+ (1.0 + eint) - fv, prec);
+ amortsched->final_pmt_opt_5 =
+ rnd (_fi_calc_future_value
+ (n - 1, nint, pve, new_pmt, CF, PF, disc, bep) * (1.0 + eint) - fv,
+ prec);
+ if (new_n)
+ amortsched->final_pmt_opt_6 =
+ rnd (_fi_calc_future_value
+ (new_n - 1, nint, pve, pmt, CF, PF, disc,
+ bep) * (1.0 + eint) - fv, prec);
+ else
+ amortsched->final_pmt_opt_6 = 0.0;
+ } /* endif */
+
+ /* compute delayed interest */
+ amortsched->delayed_int = pv - amortsched->pve;
+
+ return amortsched;
+} /* Amortization_init */
+
+amort_sched_ptr
+Amortization_Schedule (amort_sched_ptr amortsched)
+{
+ unsigned n = amortsched->n;
+ double nint = amortsched->nint;
+ double pv = amortsched->pv;
+ double pmt = amortsched->pmt;
+ double fv = amortsched->fv;
+ double eint = amortsched->eint;
+ unsigned CF = amortsched->CF;
+ unsigned PF = amortsched->PF;
+ unsigned disc = amortsched->disc;
+ unsigned bep = amortsched->bep;
+ double cpmt = 0;
+ double final_pmt = 0;
+ double delayed_int = amortsched->delayed_int;
+ char summary = amortsched->summary;
+ unsigned option = amortsched->option;
+ unsigned yr_pmt = amortsched->yr_pmt;
+ unsigned fv_case = amortsched->fv_case;
+ unsigned prec = amortsched->prec;
+ unsigned j, s, yr, per_cnt, pmt_cnt = 0, k = 0, sum_prt;
+
+ int jj;
+
+ unsigned long d;
+
+ double yr_fv, sum_int, yr_int, prin, adv_pmt, pmt_int, hpv = 0.0;
+ yearly_summary_ptr yrly_sum;
+ amort_sched_yr_ptr amortyr;
+ sched_pmt_ptr pmtsched = NULL;
+
+ sum_int = yr_int = 0.0;
+
+ switch (option)
+ {
+ case 1:
+ amortsched->cpmt = cpmt = amortsched->cpmt1;
+ /* re-compute final payment without interest
+ */
+ amortsched->final_pmt = final_pmt = -pv - cpmt * (n - 1);
+ summary = (summary == 'y') ? 'x' : 'o';
+ break;
+ case 2:
+ amortsched->cpmt = cpmt = amortsched->cpmt2;
+ pv = amortsched->pve;
+ /* re-compute final payment without interest
+ */
+ amortsched->final_pmt = final_pmt = -pv - cpmt * (n - 1);
+ summary = (summary == 'y') ? 'x' : 'o';
+ break;
+ case 3:
+ delayed_int = 0.0;
+ amortsched->final_pmt = final_pmt = amortsched->final_pmt_opt_3;
+ break;
+ case 4:
+ pv = amortsched->pve;
+ amortsched->final_pmt = final_pmt = amortsched->final_pmt_opt_4;
+ break;
+ case 5:
+ pv = amortsched->pve;
+ pmt = amortsched->new_pmt;
+ amortsched->final_pmt = final_pmt = amortsched->final_pmt_opt_5;
+ break;
+ case 6:
+ n = amortsched->new_n;
+ pv = amortsched->pve;
+ amortsched->final_pmt = final_pmt = amortsched->final_pmt_opt_6;
+ break;
+ } /* endswitch */
+
+ yr = amortsched->year_I;
+ sum_prt = TRUE;
+ switch (summary)
+ {
+ case 'a':
+ /* variable advanced prepayment schedule. prepayment equals next
+ * period principal. */
+ amortsched->schedule.first_yr =
+ amortyr = (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
+
+ d = pv;
+
+ for (per_cnt = 0, s = 1, j = n; pv != fv; j -= 2, per_cnt++)
+ {
+ /* basic equation to compute interest this payment period */
+ pmt_int = -rnd ((pv + (amortsched->bp * pmt)) * eint, prec);
+
+ /* sum yearly interest paid */
+ yr_int += pmt_int;
+
+ /* sum total interest paid */
+ sum_int += pmt_int;
+
+ /* compute principal paid this payment period and round to
+ nearest cent */
+ if (dabs (pmt) > dabs (pv))
+ {
+ prin = -pv;
+ pmt = prin + pmt_int;
+ adv_pmt = 0.0;
+ pv = fv;
+ }
+ else
+ {
+ prin = rnd (pmt - pmt_int, prec);
+
+ /* compute remaining pv and round to nearest cent */
+ pv = rnd (pv + prin, prec);
+
+ /* compute principal for next payment cycle and round to
+ nearest cent */
+ adv_pmt = rnd (pmt + (pv + (amortsched->bp * pmt)) * eint, prec);
+
+ if (dabs (pv) >= dabs (adv_pmt))
+ {
+ /* remaining pv greater than advanced principal payment
+ * compute remaining pv and round to nearest cent */
+ pv = rnd (pv + adv_pmt, prec);
+ }
+ else
+ {
+ /* remaining pv less than advanced principal payment reduce
+ * advanced pricipla payment to remaining pv */
+ adv_pmt = -pv;
+
+ /* and set remaining pv to fv */
+ pv = fv;
+ } /* ## endif */
+ } /* # endif */
+
+ if (sum_prt)
+ {
+ jj = (j < yr_pmt) ? j + 1 : yr_pmt;
+ amortyr->payments =
+ pmtsched = (sched_pmt_ptr) calloc (jj, sizeof (sched_pmt));
+ pmt_cnt = 0;
+
+ sum_prt = FALSE;
+ } /* endif */
+
+ pmtsched->period_num = s++;
+ pmtsched->interest = pmt_int;
+ pmtsched->principal = prin;
+ pmtsched->advanced_pmt = adv_pmt;
+ pmtsched->total_pmt = pmt + adv_pmt;
+ pmtsched->balance = pv;
+ pmtsched++;
+ pmt_cnt++;
+
+ if (!--yr_pmt)
+ {
+ yr_pmt = PF;
+
+ amortyr->year = yr++;
+ amortyr->interest_pd = yr_int;
+ amortyr->principal_pd = pv - hpv;
+ amortyr->yr_end_balance = pv;
+ amortyr->total_interest_pd = sum_int;
+ amortyr->num_periods = pmt_cnt;
+ amortyr->next_yr =
+ (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
+ amortyr = amortyr->next_yr;
+
+ hpv = pv;
+ yr_int = 0.0;
+ sum_prt = TRUE;
+ } /* endif */
+ } /* endfor */
+
+ if (dabs (pv) > 0.0)
+ {
+ /* basic equation to compute interest this payment period */
+ pmt_int = -rnd ((pv + (amortsched->bp * pmt)) * eint, prec);
+
+ /* sum yearly interest paid */
+ yr_int += pmt_int;
+
+ /* sum total interest paid */
+ sum_int += pmt_int;
+
+ /* compute principal paid this payment period and round to
+ nearest cent */
+ prin = rnd (pmt - pmt_int, prec);
+ final_pmt = pmt;
+
+ /* compute remaining pv and round to nearest cent */
+ pv = rnd (pv + prin, prec);
+
+ /* Set advanced principal payment to remaining pv */
+ adv_pmt = -pv;
+ amortyr->final_pmt = final_pmt += adv_pmt;
+
+ /* and set remaining pv to fv */
+ pv = fv;
+
+ pmtsched->period_num = s++;
+ pmtsched->interest = pmt_int;
+ pmtsched->principal = prin;
+ pmtsched->advanced_pmt = adv_pmt;
+ pmtsched->total_pmt = final_pmt;
+ pmtsched->balance = pv;
+
+ per_cnt++;
+ pmt_cnt++;
+ } /* endif */
+
+ if (dabs (yr_int) > 0.0)
+ {
+ amortyr->year = yr++;
+ amortyr->interest_pd = yr_int;
+ amortyr->principal_pd = pv - hpv;
+ amortyr->total_interest_pd = sum_int;
+ amortyr->num_periods = pmt_cnt;
+ } /* endif */
+
+ amortsched->total_periods = per_cnt;
+ break;
+ case 'f':
+ /* fixed prepaymet schedule prepayment specified by user */
+ amortsched->schedule.first_yr =
+ amortyr = (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
+
+ d = pv;
+
+ /* set advnaced payment */
+ adv_pmt = amortsched->fixed_pmt;
+
+ for (per_cnt = 0, s = 1, j = n; j && (pv != fv); j--, per_cnt++)
+ {
+ /* basic equation to compute interest this payment period */
+ pmt_int = -rnd ((pv + (amortsched->bp * pmt)) * eint, prec);
+ /* sum yearly interest paid
+ */
+ yr_int += pmt_int;
+ /* sum total interest paid */
+ sum_int += pmt_int;
+
+ /* compute principal paid this payment period and round to
+ nearest cent */
+ if (dabs (pmt) > dabs (pv))
+ {
+ prin = -pv;
+ pmt = prin + pmt_int;
+ adv_pmt = 0.0;
+ pv = 0.0;
+ }
+ else
+ {
+ prin = rnd (pmt - pmt_int, prec);
+
+ /* compute remaining pv and round to nearest cent */
+ pv = rnd (pv + prin, prec);
+
+ if (dabs (pv) >= dabs (adv_pmt))
+ {
+ /* remaining pv greater than advanced principal payment
+ * compute remaining pv and round to nearest cent */
+ pv = rnd (pv + adv_pmt, prec);
+ }
+ else
+ {
+ /* remaining pv less than advanced principal payment reduce
+ * advanced pricipal payment to remaining pv and set
+ * remaining pv to fv */
+ adv_pmt = -pv;
+ pv = fv;
+ } /*## endif */
+ } /* # endif */
+
+ if (sum_prt)
+ {
+ jj = (j < yr_pmt) ? j + 1 : yr_pmt;
+ amortyr->payments =
+ pmtsched = (sched_pmt_ptr) calloc (jj, sizeof (sched_pmt));
+ pmt_cnt = 0;
+
+ sum_prt = FALSE;
+ }
+ else
+ {
+ (amortyr->num_periods)++;
+ } /* ## endif */
+
+ pmtsched->period_num = s++;
+ pmtsched->interest = pmt_int;
+ pmtsched->principal = prin;
+ pmtsched->advanced_pmt = adv_pmt;
+ pmtsched->total_pmt = pmt + adv_pmt;
+ pmtsched->balance = pv;
+ pmt_cnt++;
+ pmtsched++;
+
+ if (!--yr_pmt)
+ {
+ yr_pmt = PF;
+
+ amortyr->year = yr++;
+ amortyr->interest_pd = yr_int;
+ amortyr->principal_pd = pv - hpv;
+ amortyr->yr_end_balance = pv;
+ amortyr->total_interest_pd = sum_int;
+ amortyr->num_periods = pmt_cnt;
+ amortyr->next_yr =
+ (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
+ amortyr = amortyr->next_yr;
+
+ hpv = pv;
+ yr_int = 0.0;
+ sum_prt = TRUE;
+ } /* ## endif */
+ } /* ## endfor */
+
+ if (pv != fv)
+ {
+ /* # basic equation to compute interest this payment period */
+ pmt_int = -rnd ((pv + (amortsched->bp * pmt)) * eint, prec);
+
+ /* # sum yearly interest paid */
+ yr_int += pmt_int;
+ /* # sum total interest paid */
+ sum_int += pmt_int;
+
+ /* # compute principal paid this payment period and round to
+ nearest cent */
+ prin = rnd (pmt - pmt_int, prec);
+ final_pmt = pmt;
+
+ /* # compute remaining pv and round to nearest cent */
+ pv = rnd (pv + prin, prec);
+
+ /* # Set advanced principal payment to remaining pv */
+ adv_pmt = -pv;
+ amortyr->final_pmt = final_pmt += adv_pmt;
+
+ /* # and set remaining pv to fv */
+ pv = fv;
+
+ pmtsched->period_num = s++;
+ pmtsched->interest = pmt_int;
+ pmtsched->principal = prin;
+ pmtsched->advanced_pmt = adv_pmt;
+ pmtsched->total_pmt = final_pmt;
+ pmtsched->balance = pv;
+
+ per_cnt++;
+ pmt_cnt++;
+ } /* # endif */
+
+ if (dabs (yr_int) > 0.0)
+ {
+ amortyr->year = yr++;
+ amortyr->interest_pd = yr_int;
+ amortyr->principal_pd = pv - hpv;
+ amortyr->total_interest_pd = sum_int;
+ amortyr->num_periods = pmt_cnt;
+ } /* endif */
+
+ amortsched->total_periods = per_cnt;
+ break;
+ case 'o':
+ /* Constant payment to principal use constant payment equal to
+ * original pv divided by number of periods. constant payment to
+ * pricipal could be amount specified by user. */
+ amortsched->schedule.first_yr =
+ amortyr = (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
+ amortsched->total_periods = n;
+
+ d = yr_pmt;
+ for (s = 1, j = n - 1; j; j--, k++)
+ {
+ pmt_int = -rnd (pv * eint, prec);
+
+ /* sum yearly interest paid */
+ yr_int += pmt_int;
+
+ /* sum total interest paid */
+ sum_int += pmt_int;
+
+ pv = rnd (pv + cpmt, prec);
+
+ if (sum_prt)
+ {
+ jj = (j < yr_pmt) ? j + 1 : yr_pmt;
+ amortyr->payments =
+ pmtsched = (sched_pmt_ptr) calloc (jj, sizeof (sched_pmt));
+ amortyr->num_periods = jj;
+ k = 0;
+
+ sum_prt = FALSE;
+ } /* endif */
+
+ pmtsched->period_num = s++;
+ pmtsched->interest = pmt_int;
+ pmtsched->total_pmt = cpmt + pmt_int;
+ pmtsched->balance = pv;
+ pmtsched++;
+
+ if (!--yr_pmt)
+ {
+ yr_pmt = PF;
+
+ amortyr->year = yr++;
+ amortyr->interest_pd = yr_int;
+ amortyr->principal_pd = d * cpmt;
+ amortyr->yr_end_balance = pv;
+ amortyr->total_interest_pd = sum_int;
+ amortyr->next_yr =
+ (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
+ amortyr = amortyr->next_yr;
+
+ d = PF;
+ yr_int = 0.0;
+ sum_prt = TRUE;
+ } /* endif */
+ } /* endfor */
+
+ if (pv)
+ {
+ pmt_int = -rnd (pv * eint, prec);
+
+ /* sum yearly interest paid */
+ yr_int += pmt_int;
+
+ /* sum total interest paid */
+ sum_int += pmt_int;
+
+ pmtsched->period_num = s++;
+ pmtsched->interest = -pmt_int;
+ pmtsched->total_pmt = -pv + pmt_int;
+ pmtsched->balance = 0.0;
+
+ amortyr->final_pmt = -pv - pmt_int;
+ } /* endif */
+
+ if (dabs (yr_int) > 0.0)
+ {
+ amortyr->year = yr++;
+ amortyr->interest_pd = yr_int;
+ amortyr->principal_pd = -pv + k * cpmt;
+ amortyr->total_interest_pd = sum_int;
+ } /* endif */
+ break;
+ case 'p':
+ /* normal amortization schedule interest, principal and balance
+ * per payment period */
+ amortsched->schedule.first_yr =
+ amortyr = (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
+ amortsched->total_periods = n;
+
+ hpv = pv;
+ for (s = 1, j = n - 1; j; j--)
+ {
+ /* basic equation for computing interest paid in payment period */
+ pmt_int = -rnd ((pv + (amortsched->bp * pmt)) * eint, prec);
+
+ /* sum yearly interest paid */
+ yr_int += pmt_int;
+
+ /* sum total interest paid */
+ sum_int += pmt_int;
+
+ /* compute principal paid this payment period */
+ prin = rnd (pmt - pmt_int, prec);
+
+ /* compute remaining pv and round to nearest cent */
+ pv = rnd (pv + prin, prec);
+
+ if (sum_prt)
+ {
+ jj = (j < yr_pmt) ? j + 1 : yr_pmt;
+ amortyr->payments =
+ pmtsched = (sched_pmt_ptr) calloc (jj, sizeof (sched_pmt));
+ amortyr->num_periods = jj;
+
+ sum_prt = FALSE;
+ } /* endif */
+
+ if (fv_case)
+ {
+ pmtsched->period_num = s++;
+ pmtsched->interest = pmt_int;
+ pmtsched->balance = pv;
+ pmtsched++;
+ }
+ else
+ {
+ pmtsched->period_num = s++;
+ pmtsched->interest = pmt_int;
+ pmtsched->principal = prin;
+ pmtsched->balance = pv;
+ pmtsched++;
+ } /* endif */
+
+ if (!--yr_pmt)
+ {
+ yr_pmt = PF;
+
+ amortyr->year = yr++;
+ amortyr->interest_pd = yr_int;
+ if (!fv_case)
+ {
+ amortyr->principal_pd = pv - hpv;
+ } /* endif */
+ amortyr->yr_end_balance = pv;
+ amortyr->total_interest_pd = sum_int;
+ amortyr->next_yr =
+ (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
+ amortyr = amortyr->next_yr;
+
+ hpv = pv;
+ yr_int = 0.0;
+ sum_prt = TRUE;
+ } /* * endif */
+ } /* * endfor */
+
+ /* determine if payment due at beginning or end of period in order
+ * to correctly compute final payment, interest and principal */
+ if (bep)
+ {
+ /* paying remainder at beginning of period compute final payment */
+ final_pmt = -pv - fv / (1 + eint);
+
+ /* then compute interest paid with final final payment */
+ pmt_int = -rnd ((pv + final_pmt) * eint, prec);
+
+ /* then compute the principal paid */
+ prin = final_pmt + pmt_int;
+ }
+ else
+ {
+ /* basic equation for computing interest paid in payment period
+ * for payment at end of period */
+ pmt_int = -rnd (pv * eint, prec);
+
+ /* compute principal paid this payment period */
+ prin = -pv;
+
+ /* compute the final payment note the final payment may be
+ * computed either of two ways both are equivalent */
+ final_pmt = prin + pmt_int;
+ } /* * endif */
+
+ pv = -fv;
+
+ /* sum yearly interest paid */
+ yr_int += pmt_int;
+
+ /* sum total interest paid */
+ sum_int += pmt_int;
+
+ if (sum_prt)
+ {
+ amortyr->payments =
+ pmtsched = (sched_pmt_ptr) calloc (1, sizeof (sched_pmt));
+ amortyr->num_periods = 1;
+ } /* endif */
+
+ amortyr->final_pmt = final_pmt;
+
+ if (fv_case)
+ {
+ pmtsched->period_num = s++;
+ pmtsched->interest = pmt_int;
+ pmtsched->balance = pv;
+ }
+ else
+ {
+ pmtsched->period_num = s++;
+ pmtsched->interest = pmt_int;
+ pmtsched->principal = prin;
+ pmtsched->balance = pv;
+ } /* endif */
+
+ if (dabs (yr_int) > 0.0)
+ {
+ amortyr->year = yr++;
+ amortyr->interest_pd = yr_int;
+ amortyr->total_interest_pd = sum_int;
+ if (!bep)
+ {
+ amortyr->principal_pd = -hpv;
+ } /* endif */
+ } /* endif */
+
+ break;
+ case 'x':
+ /* constant payment to principal - annual summary */
+ /* compute number of years to summarize */
+ j = n / PF;
+ if (yr_pmt < PF)
+ j++;
+ amortsched->total_periods = j;
+ amortsched->schedule.summary =
+ yrly_sum = (yearly_summary_ptr) calloc (j, sizeof (yearly_summary));
+
+ jj = 0;
+ for (j = n, sum_prt = 0; j > 0; j -= yr_pmt, yr_pmt = PF, sum_prt++)
+ {
+ if (j <= PF)
+ {
+ s = jj + j;
+ yr_pmt = j;
+ yr_fv = rnd (pv + cpmt * (s - 1), prec) + final_pmt;
+ }
+ else
+ {
+ s = jj + yr_pmt;
+ yr_fv = rnd (pv + cpmt * s, prec);
+ } /* endif */
+ prin = -eint * jj * (pv + (cpmt * (jj - 1) / 2.0));
+ yr_int = -eint * s * (pv + (cpmt * (s - 1) / 2.0));
+ yr_int = rnd (yr_int - prin, prec);
+ jj += yr_pmt;
+
+ sum_int += yr_int;
+
+ yrly_sum[sum_prt].year = yr++;
+ yrly_sum[sum_prt].interest = yr_int;
+ yrly_sum[sum_prt].end_balance = yr_fv;
+ } /* endfor */
+
+ break;
+ case 'y':
+ /* normal amortization - annual summary */
+ /* compute number of years to summarize */
+ j = n / PF;
+ if (yr_pmt < PF)
+ j++;
+ if (n > (j * PF))
+ j++;
+ amortsched->total_periods = j;
+ amortsched->schedule.summary =
+ yrly_sum = (yearly_summary_ptr) calloc (j, sizeof (yearly_summary));
+
+ hpv = pv;
+
+ for (jj = n, j = 0; jj > 0; jj -= yr_pmt, yr_pmt = PF, j++)
+ {
+ if (jj <= (int)PF)
+ {
+ yr_fv = fv;
+ yr_int = rnd (((jj - 1) * pmt) + hpv + final_pmt, prec);
+ }
+ else
+ {
+ yr_fv =
+ -rnd (_fi_calc_future_value
+ (yr_pmt, nint, hpv, pmt, CF, PF, disc, bep), prec);
+ yr_int = rnd ((yr_pmt * pmt) + hpv - yr_fv, prec);
+ } /* * endif */
+
+ sum_int += yr_int;
+
+ yrly_sum[j].year = yr++;
+ yrly_sum[j].interest = yr_int;
+ yrly_sum[j].end_balance = yr_fv;
+ hpv = yr_fv;
+ } /* * endfor */
+
+ break;
+ } /* * endswitch */
+
+ amortsched->total_interest = sum_int;
+
+ return amortsched;
+} /* Amortization_Schedule */
+
+/* function to free dynamically allocated memory used for amortization
+ schedule */
+void
+Amortization_free (amort_sched_ptr amortsched)
+{
+ amort_sched_yr_ptr amortyr, prst_yr;
+
+ switch (amortsched->summary)
+ {
+ case 'a':
+ case 'f':
+ case 'o':
+ case 'p':
+ for (amortyr = amortsched->schedule.first_yr; amortyr; amortyr = prst_yr)
+ {
+ if (amortyr->payments)
+ free (amortyr->payments);
+ prst_yr = amortyr->next_yr;
+ free (amortyr);
+ } /* endfor */
+ break;
+ case 'y':
+ free (amortsched->schedule.summary);
+ break;
+ } /* endswitch */
+
+ amortsched->schedule.first_yr = NULL;
+} /* amort_free */
Copied: gnucash/trunk/src/app-utils/calculation/fin_spl_protos.h (from rev 22074, gnucash/trunk/src/calculation/fin_spl_protos.h)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/fin_spl_protos.h (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/fin_spl_protos.h 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,44 @@
+/***************************************************************************
+ * -------------------
+ * create : Tue Jul 11 20:21:18 2000
+ * copyright: (C) 2000 by Terry D. Boldt
+ * email : tboldt at attglobal.net
+ * -------------------
+ ***************************************************************************/
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+/***************************************************************************
+ * Global Function Prototypes
+ * Tue Jul 11 20:21:18 2000
+ *
+ ***************************************************************************/
+
+#ifndef FIN_SPL_PROTOS_H
+#define FIN_SPL_PROTOS_H
+
+/*==================================================*/
+/* expression_parser.c */
+/* Line Number: 344 */
+parser_env_ptr init_parser(
+ var_store_ptr predefined_vars,
+ gchar *radix_point,
+ gchar *group_char,
+ void *trans_numeric(const char *digit_str,
+ gchar *radix_point,
+ gchar *group_char,
+ char **rstr),
+ void *numeric_ops(char op_sym,
+ void *left_value,
+ void *right_value),
+ void *negate_numeric(void *value),
+ void free_numeric(void *numeric_value),
+ void *func_op( const char *fname,
+ int argc, void **argv ) );
+
+#endif
Copied: gnucash/trunk/src/app-utils/calculation/fin_static_proto.h (from rev 22074, gnucash/trunk/src/calculation/fin_static_proto.h)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/fin_static_proto.h (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/fin_static_proto.h 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,126 @@
+/***************************************************************************
+ * -------------------
+ * create : Tue Jul 11 20:21:20 2000
+ * copyright: (C) 2000 by Terry D. Boldt
+ * email : tboldt at attglobal.net
+ * -------------------
+ ***************************************************************************/
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+/***************************************************************************
+ * Static Function Prototypes
+ * Tue Jul 11 20:21:20 2000
+ *
+ ***************************************************************************/
+
+#if defined( FIN_STATICS )
+/*==================================================*/
+/* fin.c
+ */
+/* Line Number: 614 */
+static double rnd(
+ double x,
+ unsigned places);
+/* Line Number: 628 */
+static double dabs(
+ double x);
+/* Line Number: 634 */
+static double _A(
+ double eint,
+ unsigned per);
+/* Line Number: 1181 */
+static double _B(
+ double eint,
+ unsigned beg);
+/* Line Number: 1394 */
+static double nom_int(
+ double eint,
+ unsigned CF,
+ unsigned PF,
+ unsigned disc);
+/* Line Number: 781 */
+static double eff_int(
+ double nint,
+ unsigned CF,
+ unsigned PF,
+ unsigned disc);
+/* Line Number: 798 */
+static double fi(
+ unsigned per,
+ double eint,
+ double pv,
+ double pmt,
+ double fv,
+ unsigned bep);
+/* Line Number: 1449 */
+static double fip(
+ unsigned per,
+ double eint,
+ double pv,
+ double pmt,
+ double fv,
+ unsigned bep);
+#endif /* FIN_STATICS */
+
+#if defined( EXPRESSION_PARSER_STATICS )
+/*==================================================*/
+/* expression_parser.c
+ */
+/* Line Number: 485 */
+static var_store_ptr pop(
+ parser_env_ptr pe);
+/* Line Number: 321 */
+static var_store_ptr push(
+ var_store_ptr push_value,
+ parser_env_ptr pe);
+/* Line Number: 519 */
+static var_store_ptr get_named_var(
+ parser_env_ptr pe);
+/* Line Number: 366 */
+static var_store_ptr get_unnamed_var(
+ parser_env_ptr pe);
+/* Line Number: 579 */
+static void free_var(
+ var_store_ptr value,
+ parser_env_ptr pe);
+/* Line Number: 596 */
+static void next_token(
+ parser_env_ptr pe);
+/* Line Number: 426 */
+static void assignment_op(
+ parser_env_ptr pe);
+/* Line Number: 695 */
+static void add_sub_op(
+ parser_env_ptr pe);
+/* Line Number: 464 */
+static void multiply_divide_op(
+ parser_env_ptr pe);
+/* Line Number: 488 */
+static void primary_exp(
+ parser_env_ptr pe);
+#endif /* EXPRESSION_PARSER_STATICS */
+
+#if defined( NUMERIC_OPS_STATICS )
+/*==================================================*/
+/* numeric_ops.c
+ */
+#endif /* NUMERIC_OPS_STATICS */
+
+#if defined( AMORT_OPT_STATICS )
+/*==================================================*/
+/* amort_opt.c
+ */
+#endif /* AMORT_OPT_STATICS */
+
+#if defined( AMORT_PRT_STATICS )
+/*==================================================*/
+/* amort_prt.c
+ */
+#endif /* AMORT_PRT_STATICS */
+
Copied: gnucash/trunk/src/app-utils/calculation/fini-input (from rev 22074, gnucash/trunk/src/calculation/fini-input)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/fini-input (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/fini-input 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,36 @@
+n
+12*30
+14.75
+100000
+
+
+
+
+4
+n
+y
+y
+opmt=pmt
+n
+12*15
+
+
+
+
+
+
+4
+n
+y
+y
+pmt-opmt
+n
+12*30
+
+
+
+
+
+
+0
+y
\ No newline at end of file
Copied: gnucash/trunk/src/app-utils/calculation/fini-output (from rev 22074, gnucash/trunk/src/calculation/fini-output)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/fini-output (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/fini-output 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,103 @@
+Evaluate expression (y/n): Current Value, n: 0
+Enter new value
+Current Value, i: 0.00
+Enter new value
+Current Value, pv: 0.00
+Enter new value
+Current Value, pmt: 0.00
+Enter new value
+Current Value, fv: 0.00
+Enter new value
+Current Value, CF: 12
+Enter new value
+Current Value, PF: 12
+Enter new value
+Compute:
+n - 1
+i - 2
+pv - 3
+pmt - 4
+fv - 5
+1,2,3,4 or 5:Computing periodic payment
+<================================>
+Current Financial Calculator Status:
+Compounding Frequency: (CF) 12
+Payment Frequency: (PF) 12
+Compounding: Discrete (disc = TRUE)
+Payments: End of Period (bep = FALSE)
+Number of Payment Periods (n): 360 (Years: 30)
+Nominal Annual Interest Rate (i): 14.75
+Present Value (pv): 100000.00
+Periodic Payment (pmt): -1244.48
+Future Value (fv): 0.00
+Compute Amortization Schedule (y/n)
+Another example (y/n): Evaluate expression (y/n): Enter Expression
+Evaluated Value: -1244.48
+Another expression (y/n): Current Value, n: 360
+Enter new value
+Current Value, i: 14.75
+Enter new value
+Current Value, pv: 100000.00
+Enter new value
+Current Value, pmt: -1244.48
+Enter new value
+Current Value, fv: 0.00
+Enter new value
+Current Value, CF: 12
+Enter new value
+Current Value, PF: 12
+Enter new value
+Compute:
+n - 1
+i - 2
+pv - 3
+pmt - 4
+fv - 5
+1,2,3,4 or 5:Computing periodic payment
+<================================>
+Current Financial Calculator Status:
+Compounding Frequency: (CF) 12
+Payment Frequency: (PF) 12
+Compounding: Discrete (disc = TRUE)
+Payments: End of Period (bep = FALSE)
+Number of Payment Periods (n): 180 (Years: 15)
+Nominal Annual Interest Rate (i): 14.75
+Present Value (pv): 100000.00
+Periodic Payment (pmt): -1382.50
+Future Value (fv): 0.00
+Compute Amortization Schedule (y/n)
+Another example (y/n): Evaluate expression (y/n): Enter Expression
+Evaluated Value: -138.02
+Another expression (y/n): Current Value, n: 180
+Enter new value
+Current Value, i: 14.75
+Enter new value
+Current Value, pv: 100000.00
+Enter new value
+Current Value, pmt: -1382.50
+Enter new value
+Current Value, fv: 0.00
+Enter new value
+Current Value, CF: 12
+Enter new value
+Current Value, PF: 12
+Enter new value
+Compute:
+n - 1
+i - 2
+pv - 3
+pmt - 4
+fv - 5
+1,2,3,4 or 5:<================================>
+Current Financial Calculator Status:
+Compounding Frequency: (CF) 12
+Payment Frequency: (PF) 12
+Compounding: Discrete (disc = TRUE)
+Payments: End of Period (bep = FALSE)
+Number of Payment Periods (n): 180 (Years: 15)
+Nominal Annual Interest Rate (i): 14.75
+Present Value (pv): 100000.00
+Periodic Payment (pmt): -1382.50
+Future Value (fv): 0.00
+Compute Amortization Schedule (y/n)
+Another example (y/n):
\ No newline at end of file
Copied: gnucash/trunk/src/app-utils/calculation/finproto.h (from rev 22074, gnucash/trunk/src/calculation/finproto.h)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/finproto.h (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/finproto.h 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,127 @@
+/***************************************************************************
+ * -------------------
+ * create : Tue Jul 11 20:21:18 2000
+ * copyright: (C) 2000 by Terry D. Boldt
+ * email : tboldt at attglobal.net
+ * -------------------
+ ***************************************************************************/
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+/***************************************************************************
+ * Global Function Prototypes
+ * Tue Jul 11 20:21:18 2000
+ *
+ ***************************************************************************/
+
+#ifndef FINPROTO_H
+#define FINPROTO_H
+
+#include <stdio.h>
+
+#include "finvar.h"
+
+/*==================================================*/
+/* fin.c */
+
+unsigned fi_calc_num_payments (fi_ptr fi);
+
+double
+_fi_calc_num_payments (double nint, /* nominal interest rate */
+ double pv, /* present value */
+ double pmt, /* periodic payment */
+ double fv, /* future value */
+ unsigned CF, /* compounding frequency */
+ unsigned PF, /* payment frequency */
+ unsigned disc, /* discrete/continuous compounding */
+ unsigned bep); /* beginning/end of period payment */
+
+double fi_calc_interest (fi_ptr fi);
+
+double
+_fi_calc_interest (unsigned per, /* number of periods */
+ double pv, /* present value */
+ double pmt, /* periodic payment */
+ double fv, /* future value */
+ unsigned CF, /* compounding frequency */
+ unsigned PF, /* payment frequency */
+ unsigned disc, /* discrete/continuous compounding */
+ unsigned bep); /* beginning/end of period payment */
+
+double fi_calc_present_value (fi_ptr fi);
+
+double
+_fi_calc_present_value (unsigned per, /* number of periods */
+ double nint, /* nominal interest rate */
+ double pmt, /* periodic payment */
+ double fv, /* future value */
+ unsigned CF, /* compounding frequency */
+ unsigned PF, /* payment frequency */
+ unsigned disc, /* discrete/continuous compounding */
+ unsigned bep); /* beginning/end of period payment */
+
+double fi_calc_payment (fi_ptr fi);
+
+double
+_fi_calc_payment (unsigned per, /* number of periods */
+ double nint, /* nominal interest rate */
+ double pv, /* present value */
+ double fv, /* future value */
+ unsigned CF, /* compounding frequency */
+ unsigned PF, /* payment frequency */
+ unsigned disc, /* discrete/continuous compounding */
+ unsigned bep); /* beginning/end of period payment */
+
+double fi_calc_future_value (fi_ptr fi);
+
+double
+_fi_calc_future_value (unsigned per, /* number of periods */
+ double nint, /* nominal interest rate */
+ double pv, /* present value */
+ double pmt, /* periodic payment */
+ unsigned CF, /* compounding frequency */
+ unsigned PF, /* payment frequency */
+ unsigned disc, /* discrete/continuous compounding */
+ unsigned bep); /* beginning/end of period payment */
+
+void set_default (fi_ptr fi);
+
+unsigned long julian_day_number (unsigned year, unsigned month, unsigned day);
+
+amort_sched_ptr Amortization_init (amort_sched_ptr amortsched);
+
+amort_sched_ptr Amortization_Schedule (amort_sched_ptr amortsched);
+
+void Amortization_free (amort_sched_ptr amortsched);
+
+
+/*==================================================*/
+/* expression_parser.c */
+
+void exit_parser (parser_env_ptr pe);
+
+ParseError get_parse_error (parser_env_ptr pe);
+
+var_store_ptr parser_get_vars (parser_env_ptr pe);
+
+unsigned delete_var (char *var_name, parser_env_ptr pe);
+
+char *parse_string (var_store_ptr value,
+ const char *string, parser_env_ptr pe);
+
+
+/*==================================================*/
+/* amort_opt.c */
+amort_sched_ptr amort_opt (amort_sched_ptr amortsched, void *parse_env);
+
+
+/*==================================================*/
+/* amort_prt.c */
+void prt_amortization_schedule (amort_sched_ptr amortsched, FILE * ofile);
+
+#endif
Copied: gnucash/trunk/src/app-utils/calculation/finvar.h (from rev 22074, gnucash/trunk/src/calculation/finvar.h)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/finvar.h (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/finvar.h 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,255 @@
+/***************************************************************************
+ * -------------------
+ * create : Sat Jun 17 20:14:13 2000
+ * copyright: (C) 2000 by Terry D. Boldt
+ * email : tboldt at attglobal.net
+ * -------------------
+ ***************************************************************************/
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+/***************************************************************************
+ * Global Financial Variables
+ * Sat Jun 17 20:14:13 2000
+ *
+ ***************************************************************************/
+
+#ifndef FINVAR_H
+#define FINVAR_H
+
+#if !defined( EOS )
+#define EOS '\x000'
+#endif
+
+#if !defined( TRUE )
+#define TRUE (1)
+#endif
+
+#if !defined( FALSE )
+#define FALSE (0)
+#endif
+
+#define INT_TYPE '\x001'
+#define DBL_TYPE '\x002'
+
+typedef enum
+{
+ PARSER_NO_ERROR = 0,
+ UNBALANCED_PARENS,
+ STACK_OVERFLOW,
+ STACK_UNDERFLOW,
+ UNDEFINED_CHARACTER,
+ NOT_A_VARIABLE,
+ NOT_A_FUNC,
+ PARSER_OUT_OF_MEMORY,
+ NUMERIC_ERROR,
+ EXPRESSION_ERROR,
+ PARSER_NUM_ERRORS
+}
+ParseError;
+
+#define UNUSED_VAR '\x000'
+#define USED_VAR '\x001'
+#define ASSIGNED_TO '\x002'
+
+#define ADD_OP '+'
+#define SUB_OP '-'
+#define DIV_OP '/'
+#define MUL_OP '*'
+#define ASN_OP '='
+
+/* The following structure is used by the expression parser to store
+ * named and temporary variables. */
+
+/* structure used for storing variables - used by expression parser/evaluator
+ */
+typedef struct var_store *var_store_ptr;
+
+/* the type of entity contained in the var_store */
+typedef enum
+{
+ VST_NUMERIC = 0,
+ VST_STRING
+} VarStoreType;
+
+typedef struct var_store
+{
+ char *variable_name; /* variable name if variable, NULL otherwise */
+ char use_flag; /* flag if variable has been assigned to */
+ char assign_flag; /* flag if variable is used */
+ VarStoreType type;
+ void *value; /* pointer to implementation defined numeric value */
+ var_store_ptr next_var; /* pointer to next variable in linked list */
+}
+var_store;
+
+
+/* The following structure is used for the numeric operations
+ * involving double float and integer arithmetic */
+
+/* structure used for storing numeric values - used by routines which
+ * evaluate arithmetic operators '+', '-', '/', '*' */
+typedef struct numeric *numeric_ptr;
+typedef struct numeric
+{
+ char type; /* designates type of value */
+ union
+ {
+ long int int_value; /* long integer value */
+ double dbl_value; /* double value */
+ }
+ value;
+}
+numeric;
+
+/* The following structures are used by the amortization functions for
+ * storing amortization schedule information */
+
+/* structure used by amortization routines for storing annual summary
+ information */
+typedef struct yearly_summary *yearly_summary_ptr;
+typedef struct yearly_summary
+{
+ unsigned year;
+ double interest;
+ double end_balance;
+}
+yearly_summary;
+
+/* structure used by amortization routines for storing information on
+ a single payment */
+typedef struct sched_pmt *sched_pmt_ptr;
+typedef struct sched_pmt
+{
+ unsigned period_num;
+ double interest;
+ double principal;
+ double advanced_pmt;
+ double total_pmt;
+ double balance;
+}
+sched_pmt;
+
+/* structure used by amortization routines for storing information on
+ * payments for a single year */
+typedef struct amort_sched_yr *amort_sched_yr_ptr;
+typedef struct amort_sched_yr
+{
+ unsigned year;
+ unsigned num_periods;
+ sched_pmt_ptr payments;
+ double interest_pd;
+ double principal_pd;
+ double yr_end_balance;
+ double total_interest_pd;
+ double final_pmt;
+ amort_sched_yr_ptr next_yr;
+}
+amort_sched_yr;
+
+/* structure used by amortization routines for passing and storing
+ * infomation on a particular amortization transaction */
+typedef struct amort_sched *amort_sched_ptr;
+typedef struct amort_sched
+{
+ /* following information set by function calling amortization
+ functions */
+ unsigned n; /* number of periods */
+ double nint; /* nominal interest rate */
+ double pv; /* present value */
+ double pmt; /* periodic payment */
+ double fv; /* future value */
+ unsigned CF; /* compounding frequency */
+ unsigned PF; /* payment frequency */
+ unsigned disc; /* discrete/continuous compounding flag */
+ unsigned bep; /* beginning/end of period payment flag */
+ unsigned prec; /* roundoff precision */
+ unsigned year_E; /* Effective date - year */
+ unsigned month_E; /* Effective date - month */
+ unsigned day_E; /* Effective date - day of month */
+ unsigned year_I; /* Initial payment date - year */
+ unsigned month_I; /* Initial payment date - month */
+ unsigned day_I; /* Initial payment date - day of month */
+
+ /* following information set by calling function to indicate which
+ * schedule to compute and which type of schedule */
+ unsigned option; /* option flag from 1 to 6 inclusive */
+ char summary; /* summary flag == 'y', 'p', 'a' or 'f' */
+
+ /* following information set by amortization functions */
+ double eint; /* effective interest rate */
+ double bp; /* float value of bep */
+ double total_interest; /* total interest paid */
+ unsigned total_periods; /* total numer of periods in schedule */
+ unsigned long yr_pmt; /* number of payments in first year */
+ double final_pmt_opt_1; /* final payment option 1 */
+ double final_pmt_opt_2; /* final payment option 2 */
+ double final_pmt_opt_3; /* final payment option 3 */
+ double final_pmt_opt_4; /* final payment option 4 */
+ double final_pmt_opt_5; /* final payment option 5 */
+ double final_pmt_opt_6; /* final payment option 6 */
+ double final_pmt; /* final payment */
+ double pve; /* pv adjusted for delayed initial payment */
+ double new_pmt; /* pmt adjusted for delayed initial payment */
+ double cpmt; /* constant payment to principal */
+ double cpmt1; /* constant payment to principal, 1st case */
+ double cpmt2; /* constant payment to principal, 2cd case */
+ double delayed_int; /* interest due to delayed initial payment */
+ double fixed_pmt; /* fixed prepayment amount for amortization */
+ unsigned new_n; /* new number of periods to amortize due to
+ delayed intial payment */
+ unsigned fv_case; /* fv case flag */
+ unsigned long Eff_Date_jdn;
+ unsigned yday_E;
+ unsigned long Init_Date_jdn;
+ unsigned yday_I;
+ union
+ {
+ amort_sched_yr_ptr first_yr;
+ yearly_summary_ptr summary;
+ }
+ schedule;
+}
+amort_sched;
+
+/* The following structure is used to hold all of the financial
+ * variables used by the financial calculator */
+
+/* structure used by financial computation routines to store financial
+ variables */
+typedef struct financial_info *fi_ptr;
+typedef struct financial_info
+{
+ double ir; /* interest rate */
+ double pv; /* present value */
+ double pmt; /* periodic payment */
+ double fv; /* future value */
+
+ unsigned npp; /* number of payment periods */
+ unsigned CF; /* Compounding frequency */
+ unsigned PF; /* payment frequency */
+ unsigned bep; /* beginning/end of period payment flag */
+ /* TRUE == beginning of period */
+ /* FALSE == end of period */
+ unsigned disc; /* discrete/continuous compounding flag */
+ /* TRUE == discrete compounding */
+ /* FALSE == continuous compounding */
+
+ /* precision of roundoff for pv, pmt and fv.
+ * i, Interest not rounded
+ * n, number of periods rounded to integer value, implicit value of zero, 0
+ *
+ * 2 for US Dollars
+ */
+ unsigned prec;
+}
+financial_info;
+
+typedef struct parser_env *parser_env_ptr;
+
+#endif
Copied: gnucash/trunk/src/app-utils/calculation/numeric_ops.c (from rev 22074, gnucash/trunk/src/calculation/numeric_ops.c)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/numeric_ops.c (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/numeric_ops.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,439 @@
+/***************************************************************************
+ numeric_ops.c - description
+ -------------------
+ begin : Wednesday June 21 2000
+ email : tboldt at attglobal.net
+ Author : Terry D. Boldt
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+/*
+ * Functions to execute arthmetic operators on integer and double operands
+ * 6-23-2000
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <float.h>
+#include <math.h>
+
+#define NUMERIC_OPS_STATICS
+#include "finvar.h"
+
+static double neg_table[] =
+{
+ 1e-256,
+ 1e-128,
+ 1e-64,
+ 1e-32,
+ 1e-16,
+ 1e-8,
+ 1e-4,
+ 1e-2,
+ 1e-1,
+ 1.0
+};
+
+static double pos_table[] =
+{
+ 1e+256,
+ 1e+128,
+ 1e+64,
+ 1e+32,
+ 1e+16,
+ 1e+8,
+ 1e+4,
+ 1e+2,
+ 1e+1
+};
+
+#define MAX_SCALE ((LONG_MAX - 10) / 10)
+
+/* function to translate ASCII string to numeric format.
+ *
+ * Recognizes either integer numerics or floating point numerics.
+ * Recognizes integers in format:
+ * (sign)digit_sequence
+ * digit_sequence may contain a grouping character, the grouping character is ignored
+ * optional sign == '+' or '-'
+ *
+ * Recognizes floating point in formats:
+ * (sign)digit_sequence.digits(exp)
+ * (sign)digit_sequence.(exp)
+ * (sign)digit_sequence(exp)
+ * (sign).digits(exp)
+ * '.' represents the radix point passed, digit_sequence may contain a grouping character
+ * the grouping character is ignored
+ * optional sign == '+' or '-'
+ * optional exp == ('e' or 'E')(sign)digits
+ *
+ * Terminates on first unrecognized character.
+ *
+ */
+void *trans_numeric(
+ const char *str, /* pointer to string to translate */
+ char radix_point, /* radix character */
+ char group_char, /* grouping character to left of radix */
+ char **endstr) /* where to return pointer to first unrecognized character */
+{
+ double dblval = 0.0;
+ int exp = 0,
+ dchr,
+ err = 0,
+ base = 10;
+ long int inum = 0;
+ unsigned long msdec = 0,
+ lsdec = 0,
+ msscale = 1;
+ unsigned radix = 0,
+ sign = 0,
+ digit_cnt = 0;
+ const char *strinit = str;
+ numeric_ptr rslt = NULL;
+
+ while ( isspace(*str) ) str++;
+
+ switch (*str)
+ {
+ case '-':
+ sign++;
+ case '+':
+ str++;
+ default:
+ break;
+ } /* endswitch */
+
+ while ( *str )
+ {
+
+ while ( (*str >= '0') && (*str <= '9') )
+ {
+ digit_cnt++;
+
+ if ( msdec < MAX_SCALE ) msdec = msdec * 10 + (*str - '0');
+ else if ( msscale < MAX_SCALE )
+ {
+ lsdec = lsdec * 10 + (*str - '0');
+ msscale *= 10;
+ }
+ else exp++;
+
+ if ( radix ) exp--;
+ else
+ {
+ dchr = *str - '0';
+ if ( ((LONG_MIN + dchr) / base) > inum ) err = 1;
+ inum = inum * base + dchr;
+ } /* endif */
+ str++;
+ } /* endwhile */
+
+ if ( !radix )
+ {
+ if ( *str == radix_point ) radix++;
+ else if ( *str != group_char ) break;
+ }
+ else
+ {
+ break;
+ } /* endif */
+
+ str++;
+ } /* endwhile */
+
+ if ( digit_cnt )
+ {
+ unsigned exp_dcnt = 0;
+
+ if ( (*str == 'e') || (*str == 'E') )
+ {
+ char exp_sign = EOS;
+ int ex_exp = 0;
+
+ switch (*++str)
+ {
+ case '-':
+ exp_sign++;
+ case '+':
+ str++;
+ default:
+ break;
+ } /* endswitch */
+
+ while ( (*str >= '0') && (*str <= '9') )
+ {
+ if (ex_exp < (DBL_MAX_EXP * 2) ) ex_exp = ex_exp * 10 + (*str - '0');
+ str++;
+ exp_dcnt++;
+ } /* endwhile */
+
+ exp += exp_sign ? -ex_exp : ex_exp;
+ } /* endif */
+
+ if ( radix || exp )
+ {
+ int pow = 256;
+
+ dblval = msdec;
+ if ( msscale != 1 ) dblval = dblval * msscale + lsdec;
+
+ if ( dblval && exp )
+ {
+ unsigned u = 0;
+
+ pow = 256;
+ while ( exp > 0 )
+ {
+ while ( exp >= pow )
+ {
+ dblval *= pos_table[u];
+ exp -= pow;
+ } /* endwhile */
+ pow >>= 1;
+ u++;
+ } /* endwhile */
+
+ while ( exp < 0 )
+ {
+ while ( exp <= -pow )
+ {
+ dblval *= neg_table[u];
+ if ( dblval == 0.0 )
+ {
+ errno = ERANGE;
+ err = 1;
+ } /* endif */
+ exp += pow;
+ } /* endwhile */
+ pow >>= 1;
+ u++;
+ } /* endwhile */
+
+ /* if overflow occurred */
+ if ( dblval == HUGE_VAL )
+ {
+ errno = ERANGE;
+ err = 1;
+ } /* endif */
+ } /* endif */
+
+ if ( !err )
+ {
+ rslt = (numeric_ptr)calloc(1, sizeof(numeric));
+ rslt->type = DBL_TYPE;
+ rslt->value.dbl_value = dblval;
+ } /* endif */
+ }
+ else
+ {
+ if ( (!sign && (inum == LONG_MIN)) || err )
+ {
+ inum = LONG_MIN + sign;
+ errno = ERANGE;
+ }
+ else
+ {
+ rslt = (numeric_ptr)calloc(1, sizeof(numeric));
+ rslt->type = INT_TYPE;
+ rslt->value.int_value = inum;
+ } /* endif */
+ } /* endif */
+ } /* endif */
+
+ if ( endstr )
+ {
+ if ( !digit_cnt ) *endstr = (char *) strinit;
+ else *endstr = (char *) str;
+ } /* endif */
+
+ return (void *)rslt;
+} /* strtod_flt */
+
+/* function to free memory used by numeric structure
+ */
+void free_numeric(
+ void *numeric_value)
+{
+ if ( numeric_value ) free(numeric_value);
+} /* free_numeric */
+
+/* function to perform unary '-' operation
+ */
+void *negate_numeric(
+ void *value)
+{
+ numeric_ptr rslt = (numeric_ptr)value;
+
+ switch ( rslt->type )
+ {
+ case INT_TYPE:
+ rslt->value.int_value = -rslt->value.int_value;
+ break;
+ case DBL_TYPE:
+ rslt->value.dbl_value = -rslt->value.dbl_value;
+ break;
+ } /* endswitch */
+
+ return (void *)rslt;
+} /* negate_numeric */
+
+/* function to perform binary operators
+ * op_symbol - operation to perform
+ * ADD_OP == perform '+'
+ * SUB_OP == perform '-'
+ * DIV_OP == perform '/'
+ * MUL_OP == perform '*'
+ * ASN_OP == perform '='
+ * l_value - pointer to left hand value
+ * r_value - pointer to right hand value
+ */
+void *numeric_ops(
+ char op_symbol,
+ void *l_value,
+ void *r_value)
+{
+ numeric_ptr lval = (numeric_ptr)l_value,
+ rval = (numeric_ptr)r_value,
+ rslt = (op_symbol == ASN_OP) ? lval : (numeric_ptr)calloc(1, sizeof(numeric));
+
+ switch ( op_symbol )
+ {
+ case ADD_OP:
+ if ( lval->type == rval->type )
+ {
+ rslt->type = lval->type;
+ switch ( lval->type )
+ {
+ case INT_TYPE:
+ rslt->value.int_value = lval->value.int_value + rval->value.int_value;
+ break;
+ case DBL_TYPE:
+ rslt->value.dbl_value = lval->value.dbl_value + rval->value.dbl_value;
+ break;
+ } /* endswitch */
+ }
+ else
+ {
+ rslt->type = DBL_TYPE;
+ switch ( lval->type )
+ {
+ case INT_TYPE:
+ rslt->value.dbl_value = (double)(lval->value.int_value) + rval->value.dbl_value;
+ break;
+ case DBL_TYPE:
+ rslt->value.dbl_value = lval->value.dbl_value + (double)(rval->value.int_value);
+ break;
+
+ } /* endswitch */
+ } /* endif */
+ break;
+ case SUB_OP:
+ if ( lval->type == rval->type )
+ {
+ rslt->type = lval->type;
+ switch ( lval->type )
+ {
+ case INT_TYPE:
+ rslt->value.int_value = lval->value.int_value - rval->value.int_value;
+ break;
+ case DBL_TYPE:
+ rslt->value.dbl_value = lval->value.dbl_value - rval->value.dbl_value;
+ break;
+ } /* endswitch */
+ }
+ else
+ {
+ rslt->type = DBL_TYPE;
+ switch ( lval->type )
+ {
+ case INT_TYPE:
+ rslt->value.dbl_value = (double)(lval->value.int_value) - rval->value.dbl_value;
+ break;
+ case DBL_TYPE:
+ rslt->value.dbl_value = lval->value.dbl_value - (double)(rval->value.int_value);
+ break;
+
+ } /* endswitch */
+ } /* endif */
+ break;
+ case DIV_OP:
+ rslt->type = DBL_TYPE;
+ if ( lval->type == rval->type )
+ {
+ switch ( lval->type )
+ {
+ case INT_TYPE:
+ rslt->value.dbl_value = (double)(lval->value.int_value) / (double)(rval->value.int_value);
+ break;
+ case DBL_TYPE:
+ rslt->value.dbl_value = lval->value.dbl_value / rval->value.dbl_value;
+ break;
+ } /* endswitch */
+ }
+ else
+ {
+ switch ( lval->type )
+ {
+ case INT_TYPE:
+ rslt->value.dbl_value = (double)(lval->value.int_value) / rval->value.dbl_value;
+ break;
+ case DBL_TYPE:
+ rslt->value.dbl_value = lval->value.dbl_value / (double)(rval->value.int_value);
+ break;
+
+ } /* endswitch */
+ } /* endif */
+ break;
+ case MUL_OP:
+ if ( lval->type == rval->type )
+ {
+ rslt->type = lval->type;
+ switch ( lval->type )
+ {
+ case INT_TYPE:
+ rslt->value.int_value = lval->value.int_value * rval->value.int_value;
+ break;
+ case DBL_TYPE:
+ rslt->value.dbl_value = lval->value.dbl_value * rval->value.dbl_value;
+ break;
+ } /* endswitch */
+ }
+ else
+ {
+ rslt->type = DBL_TYPE;
+ switch ( lval->type )
+ {
+ case INT_TYPE:
+ rslt->value.dbl_value = (double)(lval->value.int_value) * rval->value.dbl_value;
+ break;
+ case DBL_TYPE:
+ rslt->value.dbl_value = lval->value.dbl_value * (double)(rval->value.int_value);
+ break;
+
+ } /* endswitch */
+ } /* endif */
+ break;
+ case ASN_OP:
+ if ( !lval ) lval = (numeric_ptr)calloc(1, sizeof(numeric));
+ lval->type = rval->type;
+ lval->value = rval->value;
+ rslt = lval;
+ break;
+ } /* endswitch */
+
+
+ return (void *)rslt;
+} /* numeric_ops */
Copied: gnucash/trunk/src/app-utils/calculation/numeric_ops.h (from rev 22074, gnucash/trunk/src/calculation/numeric_ops.h)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/numeric_ops.h (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/numeric_ops.h 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,39 @@
+/***************************************************************************
+ * -------------------
+ * create : Tue Jul 11 20:21:18 2000
+ * copyright: (C) 2000 by Terry D. Boldt
+ * email : tboldt at attglobal.net
+ * -------------------
+ ***************************************************************************/
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+/***************************************************************************
+ * Global Function Prototypes
+ * Tue Jul 11 20:21:18 2000
+ *
+ ***************************************************************************/
+
+#ifndef NUMERIC_OPS_H
+#define NUMERIC_OPS_H
+
+void *trans_numeric(const char *str, /* pointer to string to translate */
+ char radix_point, /* radix character */
+ char group_char, /* grouping character to left of radix */
+ char **endstr); /* where to return pointer to first
+ * unrecognized character */
+
+void free_numeric(void *numeric_value);
+
+void *negate_numeric(void *value);
+
+void *numeric_ops(char op_symbol,
+ void *l_value,
+ void *r_value);
+
+#endif
Copied: gnucash/trunk/src/app-utils/calculation/sample (from rev 22074, gnucash/trunk/src/calculation/sample)
===================================================================
--- gnucash/trunk/src/app-utils/calculation/sample (rev 0)
+++ gnucash/trunk/src/app-utils/calculation/sample 2012-03-11 22:05:22 UTC (rev 22075)
@@ -0,0 +1,2623 @@
+With npp == 360
+ ir == 8.25
+ pv == 345725.00
+------------>Compute pmt: -2597.32
+<================================>
+Current Financial Calculator Status:
+Compounding Frequency: (CF) 12
+Payment Frequency: (PF) 12
+Compounding: Discrete (disc = TRUE)
+Payments: End of Period (bep = FALSE)
+Number of Payment Periods (n): 360 (Years: 30)
+Nominal Annual Interest Rate (i): 8.25
+Present Value (pv): 345725.00
+Periodic Payment (pmt): -2597.32
+Future Value (fv): 0.00
+
+------------>Compute ir
+<================================>
+Current Financial Calculator Status:
+Compounding Frequency: (CF) 12
+Payment Frequency: (PF) 12
+Compounding: Discrete (disc = TRUE)
+Payments: End of Period (bep = FALSE)
+Number of Payment Periods (n): 360 (Years: 30)
+Nominal Annual Interest Rate (i): 8.25
+Present Value (pv): 345725.00
+Periodic Payment (pmt): -2597.32
+Future Value (fv): 0.00
+
+------------>Compute npp
+<================================>
+Current Financial Calculator Status:
+Compounding Frequency: (CF) 12
+Payment Frequency: (PF) 12
+Compounding: Discrete (disc = TRUE)
+Payments: End of Period (bep = FALSE)
+Number of Payment Periods (n): 360 (Years: 30)
+Nominal Annual Interest Rate (i): 8.25
+Present Value (pv): 345725.00
+Periodic Payment (pmt): -2597.32
+Future Value (fv): 0.00
+
+------------>Compute fv
+<================================>
+Current Financial Calculator Status:
+Compounding Frequency: (CF) 12
+Payment Frequency: (PF) 12
+Compounding: Discrete (disc = TRUE)
+Payments: End of Period (bep = FALSE)
+Number of Payment Periods (n): 360 (Years: 30)
+Nominal Annual Interest Rate (i): 8.25
+Present Value (pv): 345725.00
+Periodic Payment (pmt): -2597.32
+Future Value (fv): -0.00
+
+
+ Reset financial variables and compute amortization schedules.
+First Schedule - ignore delay in first payment and
+output annual summary
+Amortization Table
+Effective Date: Tue Jun 15 00:00:00 1999
+Initial Payment Date: Sun Aug 1 00:00:00 1999
+Compounding Frequency per year: 12
+Payment Frequency per year: 12
+Compounding: Discrete
+Payments: End of Period
+Payments (359): -2597.32
+Final payment (360): -2591.78
+Nominal Annual Interest Rate: 8.25
+ Effective Interest Rate Per Payment Period: 0.006875
+Present Value: 345725.00
+Annual Summary - Normal Amortization
+Year Interest Ending Balance
+1999 -11869.04 344607.44
+2000 -28324.18 341763.78
+2001 -28080.50 338676.44
+2002 -27815.94 335324.54
+2003 -27528.71 331685.41
+2004 -27216.87 327734.44
+2005 -26878.30 323444.90
+2006 -26510.72 318787.78
+2007 -26111.64 313731.58
+2008 -25678.37 308242.11
+2009 -25207.96 302282.23
+2010 -24697.25 295811.64
+2011 -24142.77 288786.57
+2012 -23540.77 281159.50
+2013 -22887.19 272878.85
+2014 -22177.61 263888.62
+2015 -21407.22 254128.00
+2016 -20570.81 243530.97
+2017 -19662.73 232025.86
+2018 -18676.83 219534.85
+2019 -17606.45 205973.46
+2020 -16444.34 191249.96
+2021 -15182.65 175264.77
+2022 -13812.85 157909.78
+2023 -12325.66 139067.60
+2024 -10711.04 118610.80
+2025 -8958.05 96401.01
+2026 -7054.84 72288.01
+2027 -4988.55 46108.72
+2028 -2745.19 17686.07
+2029 -489.63 0.00
+
+Total Interest: -589304.66
+
+
+Second Schedule - ignore delay in first payment and
+output schedule for each payment
+Amortization Table
+Effective Date: Tue Jun 15 00:00:00 1999
+Initial Payment Date: Sun Aug 1 00:00:00 1999
+Compounding Frequency per year: 12
+Payment Frequency per year: 12
+Compounding: Discrete
+Payments: End of Period
+Payments (359): -2597.32
+Final payment (360): -2591.78
+Nominal Annual Interest Rate: 8.25
+ Effective Interest Rate Per Payment Period: 0.006875
+Present Value: 345725.00
+Normal Amortization Schedule
+Pmt * Interest Principal Balance
+ 1 -2376.86 -220.46 345504.54
+ 2 -2375.34 -221.98 345282.56
+ 3 -2373.82 -223.50 345059.06
+ 4 -2372.28 -225.04 344834.02
+ 5 -2370.73 -226.59 344607.43
+Summary for: 1999:
+ Interest Paid: -11869.03
+ Principal Paid: -1117.57
+ Year Ending Balance: 344607.43
+ Sum of Interest Paid: -11869.03
+Pmt * Interest Principal Balance
+ 6 -2369.18 -228.14 344379.29
+ 7 -2367.61 -229.71 344149.58
+ 8 -2366.03 -231.29 343918.29
+ 9 -2364.44 -232.88 343685.41
+ 10 -2362.84 -234.48 343450.93
+ 11 -2361.23 -236.09 343214.84
+ 12 -2359.60 -237.72 342977.12
+ 13 -2357.97 -239.35 342737.77
+ 14 -2356.32 -241.00 342496.77
+ 15 -2354.67 -242.65 342254.12
+ 16 -2353.00 -244.32 342009.80
+ 17 -2351.32 -246.00 341763.80
+Summary for: 2000:
+ Interest Paid: -28324.21
+ Principal Paid: -2843.63
+ Year Ending Balance: 341763.80
+ Sum of Interest Paid: -40193.24
+Pmt * Interest Principal Balance
+ 18 -2349.63 -247.69 341516.11
+ 19 -2347.92 -249.40 341266.71
+ 20 -2346.21 -251.11 341015.60
+ 21 -2344.48 -252.84 340762.76
+ 22 -2342.74 -254.58 340508.18
+ 23 -2340.99 -256.33 340251.85
+ 24 -2339.23 -258.09 339993.76
+ 25 -2337.46 -259.86 339733.90
+ 26 -2335.67 -261.65 339472.25
+ 27 -2333.87 -263.45 339208.80
+ 28 -2332.06 -265.26 338943.54
+ 29 -2330.24 -267.08 338676.46
+Summary for: 2001:
+ Interest Paid: -28080.50
+ Principal Paid: -3087.34
+ Year Ending Balance: 338676.46
+ Sum of Interest Paid: -68273.74
+Pmt * Interest Principal Balance
+ 30 -2328.40 -268.92 338407.54
+ 31 -2326.55 -270.77 338136.77
+ 32 -2324.69 -272.63 337864.14
+ 33 -2322.82 -274.50 337589.64
+ 34 -2320.93 -276.39 337313.25
+ 35 -2319.03 -278.29 337034.96
+ 36 -2317.12 -280.20 336754.76
+ 37 -2315.19 -282.13 336472.63
+ 38 -2313.25 -284.07 336188.56
+ 39 -2311.30 -286.02 335902.54
+ 40 -2309.33 -287.99 335614.55
+ 41 -2307.35 -289.97 335324.58
+Summary for: 2002:
+ Interest Paid: -27815.96
+ Principal Paid: -3351.88
+ Year Ending Balance: 335324.58
+ Sum of Interest Paid: -96089.70
+Pmt * Interest Principal Balance
+ 42 -2305.36 -291.96 335032.62
+ 43 -2303.35 -293.97 334738.65
+ 44 -2301.33 -295.99 334442.66
+ 45 -2299.29 -298.03 334144.63
+ 46 -2297.24 -300.08 333844.55
+ 47 -2295.18 -302.14 333542.41
+ 48 -2293.10 -304.22 333238.19
+ 49 -2291.01 -306.31 332931.88
+ 50 -2288.91 -308.41 332623.47
+ 51 -2286.79 -310.53 332312.94
+ 52 -2284.65 -312.67 332000.27
+ 53 -2282.50 -314.82 331685.45
+Summary for: 2003:
+ Interest Paid: -27528.71
+ Principal Paid: -3639.13
+ Year Ending Balance: 331685.45
+ Sum of Interest Paid: -123618.41
+Pmt * Interest Principal Balance
+ 54 -2280.34 -316.98 331368.47
+ 55 -2278.16 -319.16 331049.31
+ 56 -2275.96 -321.36 330727.95
+ 57 -2273.75 -323.57 330404.38
+ 58 -2271.53 -325.79 330078.59
+ 59 -2269.29 -328.03 329750.56
+ 60 -2267.04 -330.28 329420.28
+ 61 -2264.76 -332.56 329087.72
+ 62 -2262.48 -334.84 328752.88
+ 63 -2260.18 -337.14 328415.74
+ 64 -2257.86 -339.46 328076.28
+ 65 -2255.52 -341.80 327734.48
+Summary for: 2004:
+ Interest Paid: -27216.87
+ Principal Paid: -3950.97
+ Year Ending Balance: 327734.48
+ Sum of Interest Paid: -150835.28
+Pmt * Interest Principal Balance
+ 66 -2253.17 -344.15 327390.33
+ 67 -2250.81 -346.51 327043.82
+ 68 -2248.43 -348.89 326694.93
+ 69 -2246.03 -351.29 326343.64
+ 70 -2243.61 -353.71 325989.93
+ 71 -2241.18 -356.14 325633.79
+ 72 -2238.73 -358.59 325275.20
+ 73 -2236.27 -361.05 324914.15
+ 74 -2233.78 -363.54 324550.61
+ 75 -2231.29 -366.03 324184.58
+ 76 -2228.77 -368.55 323816.03
+ 77 -2226.24 -371.08 323444.95
+Summary for: 2005:
+ Interest Paid: -26878.31
+ Principal Paid: -4289.53
+ Year Ending Balance: 323444.95
+ Sum of Interest Paid: -177713.59
+Pmt * Interest Principal Balance
+ 78 -2223.68 -373.64 323071.31
+ 79 -2221.12 -376.20 322695.11
+ 80 -2218.53 -378.79 322316.32
+ 81 -2215.92 -381.40 321934.92
+ 82 -2213.30 -384.02 321550.90
+ 83 -2210.66 -386.66 321164.24
+ 84 -2208.00 -389.32 320774.92
+ 85 -2205.33 -391.99 320382.93
+ 86 -2202.63 -394.69 319988.24
+ 87 -2199.92 -397.40 319590.84
+ 88 -2197.19 -400.13 319190.71
+ 89 -2194.44 -402.88 318787.83
+Summary for: 2006:
+ Interest Paid: -26510.72
+ Principal Paid: -4657.12
+ Year Ending Balance: 318787.83
+ Sum of Interest Paid: -204224.31
+Pmt * Interest Principal Balance
+ 90 -2191.67 -405.65 318382.18
+ 91 -2188.88 -408.44 317973.74
+ 92 -2186.07 -411.25 317562.49
+ 93 -2183.24 -414.08 317148.41
+ 94 -2180.40 -416.92 316731.49
+ 95 -2177.53 -419.79 316311.70
+ 96 -2174.64 -422.68 315889.02
+ 97 -2171.74 -425.58 315463.44
+ 98 -2168.81 -428.51 315034.93
+ 99 -2165.87 -431.45 314603.48
+ 100 -2162.90 -434.42 314169.06
+ 101 -2159.91 -437.41 313731.65
+Summary for: 2007:
+ Interest Paid: -26111.66
+ Principal Paid: -5056.18
+ Year Ending Balance: 313731.65
+ Sum of Interest Paid: -230335.97
+Pmt * Interest Principal Balance
+ 102 -2156.91 -440.41 313291.24
+ 103 -2153.88 -443.44 312847.80
+ 104 -2150.83 -446.49 312401.31
+ 105 -2147.76 -449.56 311951.75
+ 106 -2144.67 -452.65 311499.10
+ 107 -2141.56 -455.76 311043.34
+ 108 -2138.42 -458.90 310584.44
+ 109 -2135.27 -462.05 310122.39
+ 110 -2132.09 -465.23 309657.16
+ 111 -2128.89 -468.43 309188.73
+ 112 -2125.67 -471.65 308717.08
+ 113 -2122.43 -474.89 308242.19
+Summary for: 2008:
+ Interest Paid: -25678.38
+ Principal Paid: -5489.46
+ Year Ending Balance: 308242.19
+ Sum of Interest Paid: -256014.35
+Pmt * Interest Principal Balance
+ 114 -2119.17 -478.15 307764.04
+ 115 -2115.88 -481.44 307282.60
+ 116 -2112.57 -484.75 306797.85
+ 117 -2109.24 -488.08 306309.77
+ 118 -2105.88 -491.44 305818.33
+ 119 -2102.50 -494.82 305323.51
+ 120 -2099.10 -498.22 304825.29
+ 121 -2095.67 -501.65 304323.64
+ 122 -2092.23 -505.09 303818.55
+ 123 -2088.75 -508.57 303309.98
+ 124 -2085.26 -512.06 302797.92
+ 125 -2081.74 -515.58 302282.34
+Summary for: 2009:
+ Interest Paid: -25207.99
+ Principal Paid: -5959.85
+ Year Ending Balance: 302282.34
+ Sum of Interest Paid: -281222.34
+Pmt * Interest Principal Balance
+ 126 -2078.19 -519.13 301763.21
+ 127 -2074.62 -522.70 301240.51
+ 128 -2071.03 -526.29 300714.22
+ 129 -2067.41 -529.91 300184.31
+ 130 -2063.77 -533.55 299650.76
+ 131 -2060.10 -537.22 299113.54
+ 132 -2056.41 -540.91 298572.63
+ 133 -2052.69 -544.63 298028.00
+ 134 -2048.94 -548.38 297479.62
+ 135 -2045.17 -552.15 296927.47
+ 136 -2041.38 -555.94 296371.53
+ 137 -2037.55 -559.77 295811.76
+Summary for: 2010:
+ Interest Paid: -24697.26
+ Principal Paid: -6470.58
+ Year Ending Balance: 295811.76
+ Sum of Interest Paid: -305919.60
+Pmt * Interest Principal Balance
+ 138 -2033.71 -563.61 295248.15
+ 139 -2029.83 -567.49 294680.66
+ 140 -2025.93 -571.39 294109.27
+ 141 -2022.00 -575.32 293533.95
+ 142 -2018.05 -579.27 292954.68
+ 143 -2014.06 -583.26 292371.42
+ 144 -2010.05 -587.27 291784.15
+ 145 -2006.02 -591.30 291192.85
+ 146 -2001.95 -595.37 290597.48
+ 147 -1997.86 -599.46 289998.02
+ 148 -1993.74 -603.58 289394.44
+ 149 -1989.59 -607.73 288786.71
+Summary for: 2011:
+ Interest Paid: -24142.79
+ Principal Paid: -7025.05
+ Year Ending Balance: 288786.71
+ Sum of Interest Paid: -330062.39
+Pmt * Interest Principal Balance
+ 150 -1985.41 -611.91 288174.80
+ 151 -1981.20 -616.12 287558.68
+ 152 -1976.97 -620.35 286938.33
+ 153 -1972.70 -624.62 286313.71
+ 154 -1968.41 -628.91 285684.80
+ 155 -1964.08 -633.24 285051.56
+ 156 -1959.73 -637.59 284413.97
+ 157 -1955.35 -641.97 283772.00
+ 158 -1950.93 -646.39 283125.61
+ 159 -1946.49 -650.83 282474.78
+ 160 -1942.01 -655.31 281819.47
+ 161 -1937.51 -659.81 281159.66
+Summary for: 2012:
+ Interest Paid: -23540.79
+ Principal Paid: -7627.05
+ Year Ending Balance: 281159.66
+ Sum of Interest Paid: -353603.18
+Pmt * Interest Principal Balance
+ 162 -1932.97 -664.35 280495.31
+ 163 -1928.41 -668.91 279826.40
+ 164 -1923.81 -673.51 279152.89
+ 165 -1919.18 -678.14 278474.75
+ 166 -1914.51 -682.81 277791.94
+ 167 -1909.82 -687.50 277104.44
+ 168 -1905.09 -692.23 276412.21
+ 169 -1900.33 -696.99 275715.22
+ 170 -1895.54 -701.78 275013.44
+ 171 -1890.72 -706.60 274306.84
+ 172 -1885.86 -711.46 273595.38
+ 173 -1880.97 -716.35 272879.03
+Summary for: 2013:
+ Interest Paid: -22887.21
+ Principal Paid: -8280.63
+ Year Ending Balance: 272879.03
+ Sum of Interest Paid: -376490.39
+Pmt * Interest Principal Balance
+ 174 -1876.04 -721.28 272157.75
+ 175 -1871.08 -726.24 271431.51
+ 176 -1866.09 -731.23 270700.28
+ 177 -1861.06 -736.26 269964.02
+ 178 -1856.00 -741.32 269222.70
+ 179 -1850.91 -746.41 268476.29
+ 180 -1845.77 -751.55 267724.74
+ 181 -1840.61 -756.71 266968.03
+ 182 -1835.41 -761.91 266206.12
+ 183 -1830.17 -767.15 265438.97
+ 184 -1824.89 -772.43 264666.54
+ 185 -1819.58 -777.74 263888.80
+Summary for: 2014:
+ Interest Paid: -22177.61
+ Principal Paid: -8990.23
+ Year Ending Balance: 263888.80
+ Sum of Interest Paid: -398668.00
+Pmt * Interest Principal Balance
+ 186 -1814.24 -783.08 263105.72
+ 187 -1808.85 -788.47 262317.25
+ 188 -1803.43 -793.89 261523.36
+ 189 -1797.97 -799.35 260724.01
+ 190 -1792.48 -804.84 259919.17
+ 191 -1786.94 -810.38 259108.79
+ 192 -1781.37 -815.95 258292.84
+ 193 -1775.76 -821.56 257471.28
+ 194 -1770.12 -827.20 256644.08
+ 195 -1764.43 -832.89 255811.19
+ 196 -1758.70 -838.62 254972.57
+ 197 -1752.94 -844.38 254128.19
+Summary for: 2015:
+ Interest Paid: -21407.23
+ Principal Paid: -9760.61
+ Year Ending Balance: 254128.19
+ Sum of Interest Paid: -420075.23
+Pmt * Interest Principal Balance
+ 198 -1747.13 -850.19 253278.00
+ 199 -1741.29 -856.03 252421.97
+ 200 -1735.40 -861.92 251560.05
+ 201 -1729.48 -867.84 250692.21
+ 202 -1723.51 -873.81 249818.40
+ 203 -1717.50 -879.82 248938.58
+ 204 -1711.45 -885.87 248052.71
+ 205 -1705.36 -891.96 247160.75
+ 206 -1699.23 -898.09 246262.66
+ 207 -1693.06 -904.26 245358.40
+ 208 -1686.84 -910.48 244447.92
+ 209 -1680.58 -916.74 243531.18
+Summary for: 2016:
+ Interest Paid: -20570.83
+ Principal Paid: -10597.01
+ Year Ending Balance: 243531.18
+ Sum of Interest Paid: -440646.06
+Pmt * Interest Principal Balance
+ 210 -1674.28 -923.04 242608.14
+ 211 -1667.93 -929.39 241678.75
+ 212 -1661.54 -935.78 240742.97
+ 213 -1655.11 -942.21 239800.76
+ 214 -1648.63 -948.69 238852.07
+ 215 -1642.11 -955.21 237896.86
+ 216 -1635.54 -961.78 236935.08
+ 217 -1628.93 -968.39 235966.69
+ 218 -1622.27 -975.05 234991.64
+ 219 -1615.57 -981.75 234009.89
+ 220 -1608.82 -988.50 233021.39
+ 221 -1602.02 -995.30 232026.09
+Summary for: 2017:
+ Interest Paid: -19662.75
+ Principal Paid: -11505.09
+ Year Ending Balance: 232026.09
+ Sum of Interest Paid: -460308.81
+Pmt * Interest Principal Balance
+ 222 -1595.18 -1002.14 231023.95
+ 223 -1588.29 -1009.03 230014.92
+ 224 -1581.35 -1015.97 228998.95
+ 225 -1574.37 -1022.95 227976.00
+ 226 -1567.34 -1029.98 226946.02
+ 227 -1560.25 -1037.07 225908.95
+ 228 -1553.12 -1044.20 224864.75
+ 229 -1545.95 -1051.37 223813.38
+ 230 -1538.72 -1058.60 222754.78
+ 231 -1531.44 -1065.88 221688.90
+ 232 -1524.11 -1073.21 220615.69
+ 233 -1516.73 -1080.59 219535.10
+Summary for: 2018:
+ Interest Paid: -18676.85
+ Principal Paid: -12490.99
+ Year Ending Balance: 219535.10
+ Sum of Interest Paid: -478985.66
+Pmt * Interest Principal Balance
+ 234 -1509.30 -1088.02 218447.08
+ 235 -1501.82 -1095.50 217351.58
+ 236 -1494.29 -1103.03 216248.55
+ 237 -1486.71 -1110.61 215137.94
+ 238 -1479.07 -1118.25 214019.69
+ 239 -1471.39 -1125.93 212893.76
+ 240 -1463.64 -1133.68 211760.08
+ 241 -1455.85 -1141.47 210618.61
+ 242 -1448.00 -1149.32 209469.29
+ 243 -1440.10 -1157.22 208312.07
+ 244 -1432.15 -1165.17 207146.90
+ 245 -1424.13 -1173.19 205973.71
+Summary for: 2019:
+ Interest Paid: -17606.45
+ Principal Paid: -13561.39
+ Year Ending Balance: 205973.71
+ Sum of Interest Paid: -496592.11
+Pmt * Interest Principal Balance
+ 246 -1416.07 -1181.25 204792.46
+ 247 -1407.95 -1189.37 203603.09
+ 248 -1399.77 -1197.55 202405.54
+ 249 -1391.54 -1205.78 201199.76
+ 250 -1383.25 -1214.07 199985.69
+ 251 -1374.90 -1222.42 198763.27
+ 252 -1366.50 -1230.82 197532.45
+ 253 -1358.04 -1239.28 196293.17
+ 254 -1349.52 -1247.80 195045.37
+ 255 -1340.94 -1256.38 193788.99
+ 256 -1332.30 -1265.02 192523.97
+ 257 -1323.60 -1273.72 191250.25
+Summary for: 2020:
+ Interest Paid: -16444.38
+ Principal Paid: -14723.46
+ Year Ending Balance: 191250.25
+ Sum of Interest Paid: -513036.49
+Pmt * Interest Principal Balance
+ 258 -1314.85 -1282.47 189967.78
+ 259 -1306.03 -1291.29 188676.49
+ 260 -1297.15 -1300.17 187376.32
+ 261 -1288.21 -1309.11 186067.21
+ 262 -1279.21 -1318.11 184749.10
+ 263 -1270.15 -1327.17 183421.93
+ 264 -1261.03 -1336.29 182085.64
+ 265 -1251.84 -1345.48 180740.16
+ 266 -1242.59 -1354.73 179385.43
+ 267 -1233.27 -1364.05 178021.38
+ 268 -1223.90 -1373.42 176647.96
+ 269 -1214.45 -1382.87 175265.09
+Summary for: 2021:
+ Interest Paid: -15182.68
+ Principal Paid: -15985.16
+ Year Ending Balance: 175265.09
+ Sum of Interest Paid: -528219.17
+Pmt * Interest Principal Balance
+ 270 -1204.95 -1392.37 173872.72
+ 271 -1195.37 -1401.95 172470.77
+ 272 -1185.74 -1411.58 171059.19
+ 273 -1176.03 -1421.29 169637.90
+ 274 -1166.26 -1431.06 168206.84
+ 275 -1156.42 -1440.90 166765.94
+ 276 -1146.52 -1450.80 165315.14
+ 277 -1136.54 -1460.78 163854.36
+ 278 -1126.50 -1470.82 162383.54
+ 279 -1116.39 -1480.93 160902.61
+ 280 -1106.21 -1491.11 159411.50
+ 281 -1095.95 -1501.37 157910.13
+Summary for: 2022:
+ Interest Paid: -13812.88
+ Principal Paid: -17354.96
+ Year Ending Balance: 157910.13
+ Sum of Interest Paid: -542032.05
+Pmt * Interest Principal Balance
+ 282 -1085.63 -1511.69 156398.44
+ 283 -1075.24 -1522.08 154876.36
+ 284 -1064.77 -1532.55 153343.81
+ 285 -1054.24 -1543.08 151800.73
+ 286 -1043.63 -1553.69 150247.04
+ 287 -1032.95 -1564.37 148682.67
+ 288 -1022.19 -1575.13 147107.54
+ 289 -1011.36 -1585.96 145521.58
+ 290 -1000.46 -1596.86 143924.72
+ 291 -989.48 -1607.84 142316.88
+ 292 -978.43 -1618.89 140697.99
+ 293 -967.30 -1630.02 139067.97
+Summary for: 2023:
+ Interest Paid: -12325.68
+ Principal Paid: -18842.16
+ Year Ending Balance: 139067.97
+ Sum of Interest Paid: -554357.73
+Pmt * Interest Principal Balance
+ 294 -956.09 -1641.23 137426.74
+ 295 -944.81 -1652.51 135774.23
+ 296 -933.45 -1663.87 134110.36
+ 297 -922.01 -1675.31 132435.05
+ 298 -910.49 -1686.83 130748.22
+ 299 -898.89 -1698.43 129049.79
+ 300 -887.22 -1710.10 127339.69
+ 301 -875.46 -1721.86 125617.83
+ 302 -863.62 -1733.70 123884.13
+ 303 -851.70 -1745.62 122138.51
+ 304 -839.70 -1757.62 120380.89
+ 305 -827.62 -1769.70 118611.19
+Summary for: 2024:
+ Interest Paid: -10711.06
+ Principal Paid: -20456.78
+ Year Ending Balance: 118611.19
+ Sum of Interest Paid: -565068.79
+Pmt * Interest Principal Balance
+ 306 -815.45 -1781.87 116829.32
+ 307 -803.20 -1794.12 115035.20
+ 308 -790.87 -1806.45 113228.75
+ 309 -778.45 -1818.87 111409.88
+ 310 -765.94 -1831.38 109578.50
+ 311 -753.35 -1843.97 107734.53
+ 312 -740.67 -1856.65 105877.88
+ 313 -727.91 -1869.41 104008.47
+ 314 -715.06 -1882.26 102126.21
+ 315 -702.12 -1895.20 100231.01
+ 316 -689.09 -1908.23 98322.78
+ 317 -675.97 -1921.35 96401.43
+Summary for: 2025:
+ Interest Paid: -8958.08
+ Principal Paid: -22209.76
+ Year Ending Balance: 96401.43
+ Sum of Interest Paid: -574026.87
+Pmt * Interest Principal Balance
+ 318 -662.76 -1934.56 94466.87
+ 319 -649.46 -1947.86 92519.01
+ 320 -636.07 -1961.25 90557.76
+ 321 -622.58 -1974.74 88583.02
+ 322 -609.01 -1988.31 86594.71
+ 323 -595.34 -2001.98 84592.73
+ 324 -581.58 -2015.74 82576.99
+ 325 -567.72 -2029.60 80547.39
+ 326 -553.76 -2043.56 78503.83
+ 327 -539.71 -2057.61 76446.22
+ 328 -525.57 -2071.75 74374.47
+ 329 -511.32 -2086.00 72288.47
+Summary for: 2026:
+ Interest Paid: -7054.88
+ Principal Paid: -24112.96
+ Year Ending Balance: 72288.47
+ Sum of Interest Paid: -581081.75
+Pmt * Interest Principal Balance
+ 330 -496.98 -2100.34 70188.13
+ 331 -482.54 -2114.78 68073.35
+ 332 -468.00 -2129.32 65944.03
+ 333 -453.37 -2143.95 63800.08
+ 334 -438.63 -2158.69 61641.39
+ 335 -423.78 -2173.54 59467.85
+ 336 -408.84 -2188.48 57279.37
+ 337 -393.80 -2203.52 55075.85
+ 338 -378.65 -2218.67 52857.18
+ 339 -363.39 -2233.93 50623.25
+ 340 -348.03 -2249.29 48373.96
+ 341 -332.57 -2264.75 46109.21
+Summary for: 2027:
+ Interest Paid: -4988.58
+ Principal Paid: -26179.26
+ Year Ending Balance: 46109.21
+ Sum of Interest Paid: -586070.33
+Pmt * Interest Principal Balance
+ 342 -317.00 -2280.32 43828.89
+ 343 -301.32 -2296.00 41532.89
+ 344 -285.54 -2311.78 39221.11
+ 345 -269.65 -2327.67 36893.44
+ 346 -253.64 -2343.68 34549.76
+ 347 -237.53 -2359.79 32189.97
+ 348 -221.31 -2376.01 29813.96
+ 349 -204.97 -2392.35 27421.61
+ 350 -188.52 -2408.80 25012.81
+ 351 -171.96 -2425.36 22587.45
+ 352 -155.29 -2442.03 20145.42
+ 353 -138.50 -2458.82 17686.60
+Summary for: 2028:
+ Interest Paid: -2745.23
+ Principal Paid: -28422.61
+ Year Ending Balance: 17686.60
+ Sum of Interest Paid: -588815.56
+Pmt * Interest Principal Balance
+ 354 -121.60 -2475.72 15210.88
+ 355 -104.57 -2492.75 12718.13
+ 356 -87.44 -2509.88 10208.25
+ 357 -70.18 -2527.14 7681.11
+ 358 -52.81 -2544.51 5136.60
+ 359 -35.31 -2562.01 2574.59
+Final Payment: -2592.29
+ 360 -17.70 -2574.59 -0.00
+Summary for: 2029:
+ Interest Paid: -489.61
+ Principal Paid: -17686.60
+ Year Ending Balance: 0.00
+ Sum of Interest Paid: -589305.17
+
+Total Interest: -589305.17
+
+
+Third Schedule - ignore delay in first payment and
+output variable advanced prepayment schedule
+Amortization Table
+Effective Date: Tue Jun 15 00:00:00 1999
+Initial Payment Date: Sun Aug 1 00:00:00 1999
+Compounding Frequency per year: 12
+Payment Frequency per year: 12
+Compounding: Discrete
+Payments: End of Period
+Payments (359): -2597.32
+Final payment (360): -2591.78
+Nominal Annual Interest Rate: 8.25
+ Effective Interest Rate Per Payment Period: 0.006875
+Present Value: 345725.00
+Advanced Prepayment Amortization - Variable Prepayment
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 1 -2376.86 -220.46 -221.98 -2819.30 345282.56
+ 2 -2373.82 -223.50 -225.04 -2822.36 344834.02
+ 3 -2370.73 -226.59 -228.14 -2825.46 344379.29
+ 4 -2367.61 -229.71 -231.29 -2828.61 343918.29
+ 5 -2364.44 -232.88 -234.48 -2831.80 343450.93
+Summary for: 1999:
+ Interest Paid: -11853.46
+ Principal Paid: 343447.80
+ Year Ending Balance: 343450.93
+ Sum of Interest Paid: -11853.46
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 6 -2361.23 -236.09 -237.72 -2835.04 342977.12
+ 7 -2357.97 -239.35 -241.00 -2838.32 342496.77
+ 8 -2354.67 -242.65 -244.32 -2841.64 342009.80
+ 9 -2351.32 -246.00 -247.69 -2845.01 341516.11
+ 10 -2347.92 -249.40 -251.11 -2848.43 341015.60
+ 11 -2344.48 -252.84 -254.58 -2851.90 340508.18
+ 12 -2340.99 -256.33 -258.09 -2855.41 339993.76
+ 13 -2337.46 -259.86 -261.65 -2858.97 339472.25
+ 14 -2333.87 -263.45 -265.26 -2862.58 338943.54
+ 15 -2330.24 -267.08 -268.92 -2866.24 338407.54
+ 16 -2326.55 -270.77 -272.63 -2869.95 337864.14
+ 17 -2322.82 -274.50 -276.39 -2873.71 337313.25
+Summary for: 2000:
+ Interest Paid: -28109.52
+ Principal Paid: -6137.68
+ Year Ending Balance: 337313.25
+ Sum of Interest Paid: -39962.98
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 18 -2319.03 -278.29 -280.20 -2877.52 336754.76
+ 19 -2315.19 -282.13 -284.07 -2881.39 336188.56
+ 20 -2311.30 -286.02 -287.99 -2885.31 335614.55
+ 21 -2307.35 -289.97 -291.96 -2889.28 335032.62
+ 22 -2303.35 -293.97 -295.99 -2893.31 334442.66
+ 23 -2299.29 -298.03 -300.08 -2897.40 333844.55
+ 24 -2295.18 -302.14 -304.22 -2901.54 333238.19
+ 25 -2291.01 -306.31 -308.41 -2905.73 332623.47
+ 26 -2286.79 -310.53 -312.67 -2909.99 332000.27
+ 27 -2282.50 -314.82 -316.98 -2914.30 331368.47
+ 28 -2278.16 -319.16 -321.36 -2918.68 330727.95
+ 29 -2273.75 -323.57 -325.79 -2923.11 330078.59
+Summary for: 2001:
+ Interest Paid: -27562.90
+ Principal Paid: -7234.66
+ Year Ending Balance: 330078.59
+ Sum of Interest Paid: -67525.88
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 30 -2269.29 -328.03 -330.28 -2927.60 329420.28
+ 31 -2264.76 -332.56 -334.84 -2932.16 328752.88
+ 32 -2260.18 -337.14 -339.46 -2936.78 328076.28
+ 33 -2255.52 -341.80 -344.15 -2941.47 327390.33
+ 34 -2250.81 -346.51 -348.89 -2946.21 326694.93
+ 35 -2246.03 -351.29 -353.71 -2951.03 325989.93
+ 36 -2241.18 -356.14 -358.59 -2955.91 325275.20
+ 37 -2236.27 -361.05 -363.54 -2960.86 324550.61
+ 38 -2231.29 -366.03 -368.55 -2965.87 323816.03
+ 39 -2226.24 -371.08 -373.64 -2970.96 323071.31
+ 40 -2221.12 -376.20 -378.79 -2976.11 322316.32
+ 41 -2215.92 -381.40 -384.02 -2981.34 321550.90
+Summary for: 2002:
+ Interest Paid: -26918.61
+ Principal Paid: -8527.69
+ Year Ending Balance: 321550.90
+ Sum of Interest Paid: -94444.49
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 42 -2210.66 -386.66 -389.32 -2986.64 320774.92
+ 43 -2205.33 -391.99 -394.69 -2992.01 319988.24
+ 44 -2199.92 -397.40 -400.13 -2997.45 319190.71
+ 45 -2194.44 -402.88 -405.65 -3002.97 318382.18
+ 46 -2188.88 -408.44 -411.25 -3008.57 317562.49
+ 47 -2183.24 -414.08 -416.92 -3014.24 316731.49
+ 48 -2177.53 -419.79 -422.68 -3020.00 315889.02
+ 49 -2171.74 -425.58 -428.51 -3025.83 315034.93
+ 50 -2165.87 -431.45 -434.42 -3031.74 314169.06
+ 51 -2159.91 -437.41 -440.41 -3037.73 313291.24
+ 52 -2153.88 -443.44 -446.49 -3043.81 312401.31
+ 53 -2147.76 -449.56 -452.65 -3049.97 311499.10
+Summary for: 2003:
+ Interest Paid: -26159.16
+ Principal Paid: -10051.80
+ Year Ending Balance: 311499.10
+ Sum of Interest Paid: -120603.65
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 54 -2141.56 -455.76 -458.90 -3056.22 310584.44
+ 55 -2135.27 -462.05 -465.23 -3062.55 309657.16
+ 56 -2128.89 -468.43 -471.65 -3068.97 308717.08
+ 57 -2122.43 -474.89 -478.15 -3075.47 307764.04
+ 58 -2115.88 -481.44 -484.75 -3082.07 306797.85
+ 59 -2109.24 -488.08 -491.44 -3088.76 305818.33
+ 60 -2102.50 -494.82 -498.22 -3095.54 304825.29
+ 61 -2095.67 -501.65 -505.09 -3102.41 303818.55
+ 62 -2088.75 -508.57 -512.06 -3109.38 302797.92
+ 63 -2081.74 -515.58 -519.13 -3116.45 301763.21
+ 64 -2074.62 -522.70 -526.29 -3123.61 300714.22
+ 65 -2067.41 -529.91 -533.55 -3130.87 299650.76
+Summary for: 2004:
+ Interest Paid: -25263.96
+ Principal Paid: -11848.34
+ Year Ending Balance: 299650.76
+ Sum of Interest Paid: -145867.61
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 66 -2060.10 -537.22 -540.91 -3138.23 298572.63
+ 67 -2052.69 -544.63 -548.38 -3145.70 297479.62
+ 68 -2045.17 -552.15 -555.94 -3153.26 296371.53
+ 69 -2037.55 -559.77 -563.61 -3160.93 295248.15
+ 70 -2029.83 -567.49 -571.39 -3168.71 294109.27
+ 71 -2022.00 -575.32 -579.27 -3176.59 292954.68
+ 72 -2014.06 -583.26 -587.27 -3184.59 291784.15
+ 73 -2006.02 -591.30 -595.37 -3192.69 290597.48
+ 74 -1997.86 -599.46 -603.58 -3200.90 289394.44
+ 75 -1989.59 -607.73 -611.91 -3209.23 288174.80
+ 76 -1981.20 -616.12 -620.35 -3217.67 286938.33
+ 77 -1972.70 -624.62 -628.91 -3226.23 285684.80
+Summary for: 2005:
+ Interest Paid: -24208.77
+ Principal Paid: -13965.96
+ Year Ending Balance: 285684.80
+ Sum of Interest Paid: -170076.38
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 78 -1964.08 -633.24 -637.59 -3234.91 284413.97
+ 79 -1955.35 -641.97 -646.39 -3243.71 283125.61
+ 80 -1946.49 -650.83 -655.31 -3252.63 281819.47
+ 81 -1937.51 -659.81 -664.35 -3261.67 280495.31
+ 82 -1928.41 -668.91 -673.51 -3270.83 279152.89
+ 83 -1919.18 -678.14 -682.81 -3280.13 277791.94
+ 84 -1909.82 -687.50 -692.23 -3289.55 276412.21
+ 85 -1900.33 -696.99 -701.78 -3299.10 275013.44
+ 86 -1890.72 -706.60 -711.46 -3308.78 273595.38
+ 87 -1880.97 -716.35 -721.28 -3318.60 272157.75
+ 88 -1871.08 -726.24 -731.23 -3328.55 270700.28
+ 89 -1861.06 -736.26 -741.32 -3338.64 269222.70
+Summary for: 2006:
+ Interest Paid: -22965.00
+ Principal Paid: -16462.10
+ Year Ending Balance: 269222.70
+ Sum of Interest Paid: -193041.38
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 90 -1850.91 -746.41 -751.55 -3348.87 267724.74
+ 91 -1840.61 -756.71 -761.91 -3359.23 266206.12
+ 92 -1830.17 -767.15 -772.43 -3369.75 264666.54
+ 93 -1819.58 -777.74 -783.08 -3380.40 263105.72
+ 94 -1808.85 -788.47 -793.89 -3391.21 261523.36
+ 95 -1797.97 -799.35 -804.84 -3402.16 259919.17
+ 96 -1786.94 -810.38 -815.95 -3413.27 258292.84
+ 97 -1775.76 -821.56 -827.20 -3424.52 256644.08
+ 98 -1764.43 -832.89 -838.62 -3435.94 254972.57
+ 99 -1752.94 -844.38 -850.19 -3447.51 253278.00
+ 100 -1741.29 -856.03 -861.92 -3459.24 251560.05
+ 101 -1729.48 -867.84 -873.81 -3471.13 249818.40
+Summary for: 2007:
+ Interest Paid: -21498.93
+ Principal Paid: -19404.30
+ Year Ending Balance: 249818.40
+ Sum of Interest Paid: -214540.31
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 102 -1717.50 -879.82 -885.87 -3483.19 248052.71
+ 103 -1705.36 -891.96 -898.09 -3495.41 246262.66
+ 104 -1693.06 -904.26 -910.48 -3507.80 244447.92
+ 105 -1680.58 -916.74 -923.04 -3520.36 242608.14
+ 106 -1667.93 -929.39 -935.78 -3533.10 240742.97
+ 107 -1655.11 -942.21 -948.69 -3546.01 238852.07
+ 108 -1642.11 -955.21 -961.78 -3559.10 236935.08
+ 109 -1628.93 -968.39 -975.05 -3572.37 234991.64
+ 110 -1615.57 -981.75 -988.50 -3585.82 233021.39
+ 111 -1602.02 -995.30 -1002.14 -3599.46 231023.95
+ 112 -1588.29 -1009.03 -1015.97 -3613.29 228998.95
+ 113 -1574.37 -1022.95 -1029.99 -3627.31 226946.01
+Summary for: 2008:
+ Interest Paid: -19770.83
+ Principal Paid: -22872.39
+ Year Ending Balance: 226946.01
+ Sum of Interest Paid: -234311.14
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 114 -1560.25 -1037.07 -1044.20 -3641.52 224864.74
+ 115 -1545.95 -1051.37 -1058.60 -3655.92 222754.77
+ 116 -1531.44 -1065.88 -1073.21 -3670.53 220615.68
+ 117 -1516.73 -1080.59 -1088.02 -3685.34 218447.07
+ 118 -1501.82 -1095.50 -1103.03 -3700.35 216248.54
+ 119 -1486.71 -1110.61 -1118.25 -3715.57 214019.68
+ 120 -1471.39 -1125.93 -1133.68 -3731.00 211760.07
+ 121 -1455.85 -1141.47 -1149.32 -3746.64 209469.28
+ 122 -1440.10 -1157.22 -1165.17 -3762.49 207146.89
+ 123 -1424.13 -1173.19 -1181.25 -3778.57 204792.45
+ 124 -1407.95 -1189.37 -1197.55 -3794.87 202405.53
+ 125 -1391.54 -1205.78 -1214.07 -3811.39 199985.68
+Summary for: 2009:
+ Interest Paid: -17733.86
+ Principal Paid: -26960.33
+ Year Ending Balance: 199985.68
+ Sum of Interest Paid: -252045.00
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 126 -1374.90 -1222.42 -1230.82 -3828.14 197532.44
+ 127 -1358.04 -1239.28 -1247.80 -3845.12 195045.36
+ 128 -1340.94 -1256.38 -1265.02 -3862.34 192523.96
+ 129 -1323.60 -1273.72 -1282.47 -3879.79 189967.77
+ 130 -1306.03 -1291.29 -1300.17 -3897.49 187376.31
+ 131 -1288.21 -1309.11 -1318.11 -3915.43 184749.09
+ 132 -1270.15 -1327.17 -1336.29 -3933.61 182085.63
+ 133 -1251.84 -1345.48 -1354.73 -3952.05 179385.42
+ 134 -1233.27 -1364.05 -1373.42 -3970.74 176647.95
+ 135 -1214.45 -1382.87 -1392.37 -3989.69 173872.71
+ 136 -1195.37 -1401.95 -1411.58 -4008.90 171059.18
+ 137 -1176.03 -1421.29 -1431.06 -4028.38 168206.83
+Summary for: 2010:
+ Interest Paid: -15332.83
+ Principal Paid: -31778.85
+ Year Ending Balance: 168206.83
+ Sum of Interest Paid: -267377.83
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 138 -1156.42 -1440.90 -1450.80 -4048.12 165315.13
+ 139 -1136.54 -1460.78 -1470.82 -4068.14 162383.53
+ 140 -1116.39 -1480.93 -1491.11 -4088.43 159411.49
+ 141 -1095.95 -1501.37 -1511.69 -4109.01 156398.43
+ 142 -1075.24 -1522.08 -1532.55 -4129.87 153343.80
+ 143 -1054.24 -1543.08 -1553.69 -4151.01 150247.03
+ 144 -1032.95 -1564.37 -1575.13 -4172.45 147107.53
+ 145 -1011.36 -1585.96 -1596.86 -4194.18 143924.71
+ 146 -989.48 -1607.84 -1618.89 -4216.21 140697.98
+ 147 -967.30 -1630.02 -1641.23 -4238.55 137426.73
+ 148 -944.81 -1652.51 -1663.87 -4261.19 134110.35
+ 149 -922.01 -1675.31 -1686.83 -4284.15 130748.21
+Summary for: 2011:
+ Interest Paid: -12502.69
+ Principal Paid: -37458.62
+ Year Ending Balance: 130748.21
+ Sum of Interest Paid: -279880.52
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 150 -898.89 -1698.43 -1710.10 -4307.42 127339.68
+ 151 -875.46 -1721.86 -1733.70 -4331.02 123884.12
+ 152 -851.70 -1745.62 -1757.62 -4354.94 120380.88
+ 153 -827.62 -1769.70 -1781.87 -4379.19 116829.31
+ 154 -803.20 -1794.12 -1806.45 -4403.77 113228.74
+ 155 -778.45 -1818.87 -1831.38 -4428.70 109578.49
+ 156 -753.35 -1843.97 -1856.65 -4453.97 105877.87
+ 157 -727.91 -1869.41 -1882.26 -4479.58 102126.20
+ 158 -702.12 -1895.20 -1908.23 -4505.55 98322.77
+ 159 -675.97 -1921.35 -1934.56 -4531.88 94466.86
+ 160 -649.46 -1947.86 -1961.25 -4558.57 90557.75
+ 161 -622.58 -1974.74 -1988.31 -4585.63 86594.70
+Summary for: 2012:
+ Interest Paid: -9166.71
+ Principal Paid: -44153.51
+ Year Ending Balance: 86594.70
+ Sum of Interest Paid: -289047.23
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 162 -595.34 -2001.98 -2015.75 -4613.07 82576.97
+ 163 -567.72 -2029.60 -2043.56 -4640.88 78503.81
+ 164 -539.71 -2057.61 -2071.75 -4669.07 74374.45
+ 165 -511.32 -2086.00 -2100.34 -4697.66 70188.11
+ 166 -482.54 -2114.78 -2129.32 -4726.64 65944.01
+ 167 -453.37 -2143.95 -2158.69 -4756.01 61641.37
+ 168 -423.78 -2173.54 -2188.48 -4785.80 57279.35
+ 169 -393.80 -2203.52 -2218.67 -4815.99 52857.16
+ 170 -363.39 -2233.93 -2249.29 -4846.61 48373.94
+ 171 -332.57 -2264.75 -2280.32 -4877.64 43828.87
+ 172 -301.32 -2296.00 -2311.78 -4909.10 39221.09
+ 173 -269.64 -2327.68 -2343.68 -4941.00 34549.73
+Summary for: 2013:
+ Interest Paid: -5234.50
+ Principal Paid: -52044.97
+ Year Ending Balance: 34549.73
+ Sum of Interest Paid: -294281.73
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 174 -237.53 -2359.79 -2376.01 -4973.33 29813.93
+ 175 -204.97 -2392.35 -2408.80 -5006.12 25012.78
+ 176 -171.96 -2425.36 -2442.03 -5039.35 20145.39
+ 177 -138.50 -2458.82 -2475.72 -5073.04 15210.85
+ 178 -104.57 -2492.75 -2509.88 -5107.20 10208.22
+ 179 -70.18 -2527.14 -2544.51 -5141.83 5136.57
+ 180 -35.31 -2562.01 -2574.56 -5171.88 0.00
+Summary for: 2014:
+ Interest Paid: -963.02
+ Principal Paid: -34549.73
+ Year Ending Balance: 0.00
+ Sum of Interest Paid: -295244.75
+
+Total Interest: -295244.75
+
+
+Fourth Schedule - ignore delay in first payment and
+output fixed prepayment schedule
+Amortization Table
+Effective Date: Tue Jun 15 00:00:00 1999
+Initial Payment Date: Sun Aug 1 00:00:00 1999
+Compounding Frequency per year: 12
+Payment Frequency per year: 12
+Compounding: Discrete
+Payments: End of Period
+Payments (359): -2597.32
+Final payment (360): -2591.78
+Nominal Annual Interest Rate: 8.25
+ Effective Interest Rate Per Payment Period: 0.006875
+Present Value: 345725.00
+Advanced Prepayment Amortization - Fixed Prepayment: -400.00
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 1 -2376.86 -220.46 -400.00 -2997.32 345104.54
+ 2 -2372.59 -224.73 -400.00 -2997.32 344479.81
+ 3 -2368.30 -229.02 -400.00 -2997.32 343850.79
+ 4 -2363.97 -233.35 -400.00 -2997.32 343217.44
+ 5 -2359.62 -237.70 -400.00 -2997.32 342579.74
+Summary for: 1999:
+ Interest Paid: -11841.34
+ Principal Paid: 342576.61
+ Year Ending Balance: 342579.74
+ Sum of Interest Paid: -11841.34
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 6 -2355.24 -242.08 -400.00 -2997.32 341937.66
+ 7 -2350.82 -246.50 -400.00 -2997.32 341291.16
+ 8 -2346.38 -250.94 -400.00 -2997.32 340640.22
+ 9 -2341.90 -255.42 -400.00 -2997.32 339984.80
+ 10 -2337.40 -259.92 -400.00 -2997.32 339324.88
+ 11 -2332.86 -264.46 -400.00 -2997.32 338660.42
+ 12 -2328.29 -269.03 -400.00 -2997.32 337991.39
+ 13 -2323.69 -273.63 -400.00 -2997.32 337317.76
+ 14 -2319.06 -278.26 -400.00 -2997.32 336639.50
+ 15 -2314.40 -282.92 -400.00 -2997.32 335956.58
+ 16 -2309.70 -287.62 -400.00 -2997.32 335268.96
+ 17 -2304.97 -292.35 -400.00 -2997.32 334576.61
+Summary for: 2000:
+ Interest Paid: -27964.71
+ Principal Paid: -8003.13
+ Year Ending Balance: 334576.61
+ Sum of Interest Paid: -39806.05
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 18 -2300.21 -297.11 -400.00 -2997.32 333879.50
+ 19 -2295.42 -301.90 -400.00 -2997.32 333177.60
+ 20 -2290.60 -306.72 -400.00 -2997.32 332470.88
+ 21 -2285.74 -311.58 -400.00 -2997.32 331759.30
+ 22 -2280.85 -316.47 -400.00 -2997.32 331042.83
+ 23 -2275.92 -321.40 -400.00 -2997.32 330321.43
+ 24 -2270.96 -326.36 -400.00 -2997.32 329595.07
+ 25 -2265.97 -331.35 -400.00 -2997.32 328863.72
+ 26 -2260.94 -336.38 -400.00 -2997.32 328127.34
+ 27 -2255.88 -341.44 -400.00 -2997.32 327385.90
+ 28 -2250.78 -346.54 -400.00 -2997.32 326639.36
+ 29 -2245.65 -351.67 -400.00 -2997.32 325887.69
+Summary for: 2001:
+ Interest Paid: -27278.92
+ Principal Paid: -8688.92
+ Year Ending Balance: 325887.69
+ Sum of Interest Paid: -67084.97
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 30 -2240.48 -356.84 -400.00 -2997.32 325130.85
+ 31 -2235.27 -362.05 -400.00 -2997.32 324368.80
+ 32 -2230.04 -367.28 -400.00 -2997.32 323601.52
+ 33 -2224.76 -372.56 -400.00 -2997.32 322828.96
+ 34 -2219.45 -377.87 -400.00 -2997.32 322051.09
+ 35 -2214.10 -383.22 -400.00 -2997.32 321267.87
+ 36 -2208.72 -388.60 -400.00 -2997.32 320479.27
+ 37 -2203.29 -394.03 -400.00 -2997.32 319685.24
+ 38 -2197.84 -399.48 -400.00 -2997.32 318885.76
+ 39 -2192.34 -404.98 -400.00 -2997.32 318080.78
+ 40 -2186.81 -410.51 -400.00 -2997.32 317270.27
+ 41 -2181.23 -416.09 -400.00 -2997.32 316454.18
+Summary for: 2002:
+ Interest Paid: -26534.33
+ Principal Paid: -9433.51
+ Year Ending Balance: 316454.18
+ Sum of Interest Paid: -93619.30
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 42 -2175.62 -421.70 -400.00 -2997.32 315632.48
+ 43 -2169.97 -427.35 -400.00 -2997.32 314805.13
+ 44 -2164.29 -433.03 -400.00 -2997.32 313972.10
+ 45 -2158.56 -438.76 -400.00 -2997.32 313133.34
+ 46 -2152.79 -444.53 -400.00 -2997.32 312288.81
+ 47 -2146.99 -450.33 -400.00 -2997.32 311438.48
+ 48 -2141.14 -456.18 -400.00 -2997.32 310582.30
+ 49 -2135.25 -462.07 -400.00 -2997.32 309720.23
+ 50 -2129.33 -467.99 -400.00 -2997.32 308852.24
+ 51 -2123.36 -473.96 -400.00 -2997.32 307978.28
+ 52 -2117.35 -479.97 -400.00 -2997.32 307098.31
+ 53 -2111.30 -486.02 -400.00 -2997.32 306212.29
+Summary for: 2003:
+ Interest Paid: -25725.95
+ Principal Paid: -10241.89
+ Year Ending Balance: 306212.29
+ Sum of Interest Paid: -119345.25
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 54 -2105.21 -492.11 -400.00 -2997.32 305320.18
+ 55 -2099.08 -498.24 -400.00 -2997.32 304421.94
+ 56 -2092.90 -504.42 -400.00 -2997.32 303517.52
+ 57 -2086.68 -510.64 -400.00 -2997.32 302606.88
+ 58 -2080.42 -516.90 -400.00 -2997.32 301689.98
+ 59 -2074.12 -523.20 -400.00 -2997.32 300766.78
+ 60 -2067.77 -529.55 -400.00 -2997.32 299837.23
+ 61 -2061.38 -535.94 -400.00 -2997.32 298901.29
+ 62 -2054.95 -542.37 -400.00 -2997.32 297958.92
+ 63 -2048.47 -548.85 -400.00 -2997.32 297010.07
+ 64 -2041.94 -555.38 -400.00 -2997.32 296054.69
+ 65 -2035.38 -561.94 -400.00 -2997.32 295092.75
+Summary for: 2004:
+ Interest Paid: -24848.30
+ Principal Paid: -11119.54
+ Year Ending Balance: 295092.75
+ Sum of Interest Paid: -144193.55
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 66 -2028.76 -568.56 -400.00 -2997.32 294124.19
+ 67 -2022.10 -575.22 -400.00 -2997.32 293148.97
+ 68 -2015.40 -581.92 -400.00 -2997.32 292167.05
+ 69 -2008.65 -588.67 -400.00 -2997.32 291178.38
+ 70 -2001.85 -595.47 -400.00 -2997.32 290182.91
+ 71 -1995.01 -602.31 -400.00 -2997.32 289180.60
+ 72 -1988.12 -609.20 -400.00 -2997.32 288171.40
+ 73 -1981.18 -616.14 -400.00 -2997.32 287155.26
+ 74 -1974.19 -623.13 -400.00 -2997.32 286132.13
+ 75 -1967.16 -630.16 -400.00 -2997.32 285101.97
+ 76 -1960.08 -637.24 -400.00 -2997.32 284064.73
+ 77 -1952.95 -644.37 -400.00 -2997.32 283020.36
+Summary for: 2005:
+ Interest Paid: -23895.45
+ Principal Paid: -12072.39
+ Year Ending Balance: 283020.36
+ Sum of Interest Paid: -168089.00
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 78 -1945.76 -651.56 -400.00 -2997.32 281968.80
+ 79 -1938.54 -658.78 -400.00 -2997.32 280910.02
+ 80 -1931.26 -666.06 -400.00 -2997.32 279843.96
+ 81 -1923.93 -673.39 -400.00 -2997.32 278770.57
+ 82 -1916.55 -680.77 -400.00 -2997.32 277689.80
+ 83 -1909.12 -688.20 -400.00 -2997.32 276601.60
+ 84 -1901.64 -695.68 -400.00 -2997.32 275505.92
+ 85 -1894.10 -703.22 -400.00 -2997.32 274402.70
+ 86 -1886.52 -710.80 -400.00 -2997.32 273291.90
+ 87 -1878.88 -718.44 -400.00 -2997.32 272173.46
+ 88 -1871.19 -726.13 -400.00 -2997.32 271047.33
+ 89 -1863.45 -733.87 -400.00 -2997.32 269913.46
+Summary for: 2006:
+ Interest Paid: -22860.94
+ Principal Paid: -13106.90
+ Year Ending Balance: 269913.46
+ Sum of Interest Paid: -190949.94
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 90 -1855.66 -741.66 -400.00 -2997.32 268771.80
+ 91 -1847.81 -749.51 -400.00 -2997.32 267622.29
+ 92 -1839.90 -757.42 -400.00 -2997.32 266464.87
+ 93 -1831.95 -765.37 -400.00 -2997.32 265299.50
+ 94 -1823.93 -773.39 -400.00 -2997.32 264126.11
+ 95 -1815.87 -781.45 -400.00 -2997.32 262944.66
+ 96 -1807.74 -789.58 -400.00 -2997.32 261755.08
+ 97 -1799.57 -797.75 -400.00 -2997.32 260557.33
+ 98 -1791.33 -805.99 -400.00 -2997.32 259351.34
+ 99 -1783.04 -814.28 -400.00 -2997.32 258137.06
+ 100 -1774.69 -822.63 -400.00 -2997.32 256914.43
+ 101 -1766.29 -831.03 -400.00 -2997.32 255683.40
+Summary for: 2007:
+ Interest Paid: -21737.78
+ Principal Paid: -14230.06
+ Year Ending Balance: 255683.40
+ Sum of Interest Paid: -212687.72
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 102 -1757.82 -839.50 -400.00 -2997.32 254443.90
+ 103 -1749.30 -848.02 -400.00 -2997.32 253195.88
+ 104 -1740.72 -856.60 -400.00 -2997.32 251939.28
+ 105 -1732.08 -865.24 -400.00 -2997.32 250674.04
+ 106 -1723.38 -873.94 -400.00 -2997.32 249400.10
+ 107 -1714.63 -882.69 -400.00 -2997.32 248117.41
+ 108 -1705.81 -891.51 -400.00 -2997.32 246825.90
+ 109 -1696.93 -900.39 -400.00 -2997.32 245525.51
+ 110 -1687.99 -909.33 -400.00 -2997.32 244216.18
+ 111 -1678.99 -918.33 -400.00 -2997.32 242897.85
+ 112 -1669.92 -927.40 -400.00 -2997.32 241570.45
+ 113 -1660.80 -936.52 -400.00 -2997.32 240233.93
+Summary for: 2008:
+ Interest Paid: -20518.37
+ Principal Paid: -15449.47
+ Year Ending Balance: 240233.93
+ Sum of Interest Paid: -233206.09
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 114 -1651.61 -945.71 -400.00 -2997.32 238888.22
+ 115 -1642.36 -954.96 -400.00 -2997.32 237533.26
+ 116 -1633.04 -964.28 -400.00 -2997.32 236168.98
+ 117 -1623.66 -973.66 -400.00 -2997.32 234795.32
+ 118 -1614.22 -983.10 -400.00 -2997.32 233412.22
+ 119 -1604.71 -992.61 -400.00 -2997.32 232019.61
+ 120 -1595.13 -1002.19 -400.00 -2997.32 230617.42
+ 121 -1585.49 -1011.83 -400.00 -2997.32 229205.59
+ 122 -1575.79 -1021.53 -400.00 -2997.32 227784.06
+ 123 -1566.02 -1031.30 -400.00 -2997.32 226352.76
+ 124 -1556.18 -1041.14 -400.00 -2997.32 224911.62
+ 125 -1546.27 -1051.05 -400.00 -2997.32 223460.57
+Summary for: 2009:
+ Interest Paid: -19194.48
+ Principal Paid: -16773.36
+ Year Ending Balance: 223460.57
+ Sum of Interest Paid: -252400.57
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 126 -1536.29 -1061.03 -400.00 -2997.32 221999.54
+ 127 -1526.25 -1071.07 -400.00 -2997.32 220528.47
+ 128 -1516.13 -1081.19 -400.00 -2997.32 219047.28
+ 129 -1505.95 -1091.37 -400.00 -2997.32 217555.91
+ 130 -1495.70 -1101.62 -400.00 -2997.32 216054.29
+ 131 -1485.37 -1111.95 -400.00 -2997.32 214542.34
+ 132 -1474.98 -1122.34 -400.00 -2997.32 213020.00
+ 133 -1464.51 -1132.81 -400.00 -2997.32 211487.19
+ 134 -1453.97 -1143.35 -400.00 -2997.32 209943.84
+ 135 -1443.36 -1153.96 -400.00 -2997.32 208389.88
+ 136 -1432.68 -1164.64 -400.00 -2997.32 206825.24
+ 137 -1421.92 -1175.40 -400.00 -2997.32 205249.84
+Summary for: 2010:
+ Interest Paid: -17757.11
+ Principal Paid: -18210.73
+ Year Ending Balance: 205249.84
+ Sum of Interest Paid: -270157.68
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 138 -1411.09 -1186.23 -400.00 -2997.32 203663.61
+ 139 -1400.19 -1197.13 -400.00 -2997.32 202066.48
+ 140 -1389.21 -1208.11 -400.00 -2997.32 200458.37
+ 141 -1378.15 -1219.17 -400.00 -2997.32 198839.20
+ 142 -1367.02 -1230.30 -400.00 -2997.32 197208.90
+ 143 -1355.81 -1241.51 -400.00 -2997.32 195567.39
+ 144 -1344.53 -1252.79 -400.00 -2997.32 193914.60
+ 145 -1333.16 -1264.16 -400.00 -2997.32 192250.44
+ 146 -1321.72 -1275.60 -400.00 -2997.32 190574.84
+ 147 -1310.20 -1287.12 -400.00 -2997.32 188887.72
+ 148 -1298.60 -1298.72 -400.00 -2997.32 187189.00
+ 149 -1286.92 -1310.40 -400.00 -2997.32 185478.60
+Summary for: 2011:
+ Interest Paid: -16196.60
+ Principal Paid: -19771.24
+ Year Ending Balance: 185478.60
+ Sum of Interest Paid: -286354.28
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 150 -1275.17 -1322.15 -400.00 -2997.32 183756.45
+ 151 -1263.33 -1333.99 -400.00 -2997.32 182022.46
+ 152 -1251.40 -1345.92 -400.00 -2997.32 180276.54
+ 153 -1239.40 -1357.92 -400.00 -2997.32 178518.62
+ 154 -1227.32 -1370.00 -400.00 -2997.32 176748.62
+ 155 -1215.15 -1382.17 -400.00 -2997.32 174966.45
+ 156 -1202.89 -1394.43 -400.00 -2997.32 173172.02
+ 157 -1190.56 -1406.76 -400.00 -2997.32 171365.26
+ 158 -1178.14 -1419.18 -400.00 -2997.32 169546.08
+ 159 -1165.63 -1431.69 -400.00 -2997.32 167714.39
+ 160 -1153.04 -1444.28 -400.00 -2997.32 165870.11
+ 161 -1140.36 -1456.96 -400.00 -2997.32 164013.15
+Summary for: 2012:
+ Interest Paid: -14502.39
+ Principal Paid: -21465.45
+ Year Ending Balance: 164013.15
+ Sum of Interest Paid: -300856.67
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 162 -1127.59 -1469.73 -400.00 -2997.32 162143.42
+ 163 -1114.74 -1482.58 -400.00 -2997.32 160260.84
+ 164 -1101.79 -1495.53 -400.00 -2997.32 158365.31
+ 165 -1088.76 -1508.56 -400.00 -2997.32 156456.75
+ 166 -1075.64 -1521.68 -400.00 -2997.32 154535.07
+ 167 -1062.43 -1534.89 -400.00 -2997.32 152600.18
+ 168 -1049.13 -1548.19 -400.00 -2997.32 150651.99
+ 169 -1035.73 -1561.59 -400.00 -2997.32 148690.40
+ 170 -1022.25 -1575.07 -400.00 -2997.32 146715.33
+ 171 -1008.67 -1588.65 -400.00 -2997.32 144726.68
+ 172 -995.00 -1602.32 -400.00 -2997.32 142724.36
+ 173 -981.23 -1616.09 -400.00 -2997.32 140708.27
+Summary for: 2013:
+ Interest Paid: -12662.96
+ Principal Paid: -23304.88
+ Year Ending Balance: 140708.27
+ Sum of Interest Paid: -313519.63
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 174 -967.37 -1629.95 -400.00 -2997.32 138678.32
+ 175 -953.41 -1643.91 -400.00 -2997.32 136634.41
+ 176 -939.36 -1657.96 -400.00 -2997.32 134576.45
+ 177 -925.21 -1672.11 -400.00 -2997.32 132504.34
+ 178 -910.97 -1686.35 -400.00 -2997.32 130417.99
+ 179 -896.62 -1700.70 -400.00 -2997.32 128317.29
+ 180 -882.18 -1715.14 -400.00 -2997.32 126202.15
+ 181 -867.64 -1729.68 -400.00 -2997.32 124072.47
+ 182 -853.00 -1744.32 -400.00 -2997.32 121928.15
+ 183 -838.26 -1759.06 -400.00 -2997.32 119769.09
+ 184 -823.41 -1773.91 -400.00 -2997.32 117595.18
+ 185 -808.47 -1788.85 -400.00 -2997.32 115406.33
+Summary for: 2014:
+ Interest Paid: -10665.90
+ Principal Paid: -25301.94
+ Year Ending Balance: 115406.33
+ Sum of Interest Paid: -324185.53
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 186 -793.42 -1803.90 -400.00 -2997.32 113202.43
+ 187 -778.27 -1819.05 -400.00 -2997.32 110983.38
+ 188 -763.01 -1834.31 -400.00 -2997.32 108749.07
+ 189 -747.65 -1849.67 -400.00 -2997.32 106499.40
+ 190 -732.18 -1865.14 -400.00 -2997.32 104234.26
+ 191 -716.61 -1880.71 -400.00 -2997.32 101953.55
+ 192 -700.93 -1896.39 -400.00 -2997.32 99657.16
+ 193 -685.14 -1912.18 -400.00 -2997.32 97344.98
+ 194 -669.25 -1928.07 -400.00 -2997.32 95016.91
+ 195 -653.24 -1944.08 -400.00 -2997.32 92672.83
+ 196 -637.13 -1960.19 -400.00 -2997.32 90312.64
+ 197 -620.90 -1976.42 -400.00 -2997.32 87936.22
+Summary for: 2015:
+ Interest Paid: -8497.73
+ Principal Paid: -27470.11
+ Year Ending Balance: 87936.22
+ Sum of Interest Paid: -332683.26
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 198 -604.56 -1992.76 -400.00 -2997.32 85543.46
+ 199 -588.11 -2009.21 -400.00 -2997.32 83134.25
+ 200 -571.55 -2025.77 -400.00 -2997.32 80708.48
+ 201 -554.87 -2042.45 -400.00 -2997.32 78266.03
+ 202 -538.08 -2059.24 -400.00 -2997.32 75806.79
+ 203 -521.17 -2076.15 -400.00 -2997.32 73330.64
+ 204 -504.15 -2093.17 -400.00 -2997.32 70837.47
+ 205 -487.01 -2110.31 -400.00 -2997.32 68327.16
+ 206 -469.75 -2127.57 -400.00 -2997.32 65799.59
+ 207 -452.37 -2144.95 -400.00 -2997.32 63254.64
+ 208 -434.88 -2162.44 -400.00 -2997.32 60692.20
+ 209 -417.26 -2180.06 -400.00 -2997.32 58112.14
+Summary for: 2016:
+ Interest Paid: -6143.76
+ Principal Paid: -29824.08
+ Year Ending Balance: 58112.14
+ Sum of Interest Paid: -338827.02
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 210 -399.52 -2197.80 -400.00 -2997.32 55514.34
+ 211 -381.66 -2215.66 -400.00 -2997.32 52898.68
+ 212 -363.68 -2233.64 -400.00 -2997.32 50265.04
+ 213 -345.57 -2251.75 -400.00 -2997.32 47613.29
+ 214 -327.34 -2269.98 -400.00 -2997.32 44943.31
+ 215 -308.99 -2288.33 -400.00 -2997.32 42254.98
+ 216 -290.50 -2306.82 -400.00 -2997.32 39548.16
+ 217 -271.89 -2325.43 -400.00 -2997.32 36822.73
+ 218 -253.16 -2344.16 -400.00 -2997.32 34078.57
+ 219 -234.29 -2363.03 -400.00 -2997.32 31315.54
+ 220 -215.29 -2382.03 -400.00 -2997.32 28533.51
+ 221 -196.17 -2401.15 -400.00 -2997.32 25732.36
+Summary for: 2017:
+ Interest Paid: -3588.06
+ Principal Paid: -32379.78
+ Year Ending Balance: 25732.36
+ Sum of Interest Paid: -342415.08
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 222 -176.91 -2420.41 -400.00 -2997.32 22911.95
+ 223 -157.52 -2439.80 -400.00 -2997.32 20072.15
+ 224 -138.00 -2459.32 -400.00 -2997.32 17212.83
+ 225 -118.34 -2478.98 -400.00 -2997.32 14333.85
+ 226 -98.55 -2498.77 -400.00 -2997.32 11435.08
+ 227 -78.62 -2518.70 -400.00 -2997.32 8516.38
+ 228 -58.55 -2538.77 -400.00 -2997.32 5577.61
+ 229 -38.35 -2558.97 -400.00 -2997.32 2618.64
+ 230 -18.00 -2579.32 -39.32 -2636.64 0.00
+Summary for: 2018:
+ Interest Paid: -882.84
+ Principal Paid: -25732.36
+ Year Ending Balance: 0.00
+ Sum of Interest Paid: -343297.92
+
+Total Interest: -343297.92
+
+
+Fifth Schedule - use new payments due to delay and
+output annual summary
+Amortization Table
+Effective Date: Tue Jun 15 00:00:00 1999
+Initial Payment Date: Sun Aug 1 00:00:00 1999
+Compounding Frequency per year: 12
+Payment Frequency per year: 12
+Compounding: Discrete
+Payments: End of Period
+Payments (359): -2606.82
+Final payment (360): -2614.23
+Nominal Annual Interest Rate: 8.25
+ Effective Interest Rate Per Payment Period: 0.006875
+Present Value: 345725.00
+Interest due to Delayed Intial Payment: -1265.63
+Annual Summary - Normal Amortization
+Year Interest Ending Balance
+1999 -11912.49 345869.02
+2000 -28427.88 343015.06
+2001 -28183.32 339916.54
+2002 -27917.80 336552.50
+2003 -27629.53 332900.19
+2004 -27316.55 328934.90
+2005 -26976.76 324629.82
+2006 -26607.85 319955.83
+2007 -26207.32 314881.31
+2008 -25772.48 309371.95
+2009 -25300.37 303390.48
+2010 -24787.80 296896.44
+2011 -24231.32 289845.92
+2012 -23627.14 282191.22
+2013 -22971.19 273880.57
+2014 -22259.04 264857.77
+2015 -21485.85 255061.78
+2016 -20646.41 244426.35
+2017 -19735.04 232879.55
+2018 -18745.57 220343.28
+2019 -17671.31 206732.75
+2020 -16505.00 191955.91
+2021 -15238.74 175912.81
+2022 -13863.97 158494.94
+2023 -12371.39 139584.49
+2024 -10750.92 119053.57
+2025 -8991.58 96763.31
+2026 -7081.48 72562.95
+2027 -5007.70 46288.81
+2028 -2756.21 17763.18
+2029 -491.97 0.00
+
+Total Interest: -591471.98
+
+
+Sixth Schedule - use new payments due to delay and
+output periodic payment schedule
+Amortization Table
+Effective Date: Tue Jun 15 00:00:00 1999
+Initial Payment Date: Sun Aug 1 00:00:00 1999
+Compounding Frequency per year: 12
+Payment Frequency per year: 12
+Compounding: Discrete
+Payments: End of Period
+Payments (359): -2606.82
+Final payment (360): -2614.23
+Nominal Annual Interest Rate: 8.25
+ Effective Interest Rate Per Payment Period: 0.006875
+Present Value: 345725.00
+Interest due to Delayed Intial Payment: -1265.63
+Normal Amortization Schedule
+Pmt * Interest Principal Balance
+ 1 -2385.56 -221.26 346769.37
+ 2 -2384.04 -222.78 346546.59
+ 3 -2382.51 -224.31 346322.28
+ 4 -2380.97 -225.85 346096.43
+ 5 -2379.41 -227.41 345869.02
+Summary for: 1999:
+ Interest Paid: -11912.49
+ Principal Paid: -1121.61
+ Year Ending Balance: 345869.02
+ Sum of Interest Paid: -11912.49
+Pmt * Interest Principal Balance
+ 6 -2377.85 -228.97 345640.05
+ 7 -2376.28 -230.54 345409.51
+ 8 -2374.69 -232.13 345177.38
+ 9 -2373.09 -233.73 344943.65
+ 10 -2371.49 -235.33 344708.32
+ 11 -2369.87 -236.95 344471.37
+ 12 -2368.24 -238.58 344232.79
+ 13 -2366.60 -240.22 343992.57
+ 14 -2364.95 -241.87 343750.70
+ 15 -2363.29 -243.53 343507.17
+ 16 -2361.61 -245.21 343261.96
+ 17 -2359.93 -246.89 343015.07
+Summary for: 2000:
+ Interest Paid: -28427.89
+ Principal Paid: -2853.95
+ Year Ending Balance: 343015.07
+ Sum of Interest Paid: -40340.38
+Pmt * Interest Principal Balance
+ 18 -2358.23 -248.59 342766.48
+ 19 -2356.52 -250.30 342516.18
+ 20 -2354.80 -252.02 342264.16
+ 21 -2353.07 -253.75 342010.41
+ 22 -2351.32 -255.50 341754.91
+ 23 -2349.57 -257.25 341497.66
+ 24 -2347.80 -259.02 341238.64
+ 25 -2346.02 -260.80 340977.84
+ 26 -2344.22 -262.60 340715.24
+ 27 -2342.42 -264.40 340450.84
+ 28 -2340.60 -266.22 340184.62
+ 29 -2338.77 -268.05 339916.57
+Summary for: 2001:
+ Interest Paid: -28183.34
+ Principal Paid: -3098.50
+ Year Ending Balance: 339916.57
+ Sum of Interest Paid: -68523.72
+Pmt * Interest Principal Balance
+ 30 -2336.93 -269.89 339646.68
+ 31 -2335.07 -271.75 339374.93
+ 32 -2333.20 -273.62 339101.31
+ 33 -2331.32 -275.50 338825.81
+ 34 -2329.43 -277.39 338548.42
+ 35 -2327.52 -279.30 338269.12
+ 36 -2325.60 -281.22 337987.90
+ 37 -2323.67 -283.15 337704.75
+ 38 -2321.72 -285.10 337419.65
+ 39 -2319.76 -287.06 337132.59
+ 40 -2317.79 -289.03 336843.56
+ 41 -2315.80 -291.02 336552.54
+Summary for: 2002:
+ Interest Paid: -27917.81
+ Principal Paid: -3364.03
+ Year Ending Balance: 336552.54
+ Sum of Interest Paid: -96441.53
+Pmt * Interest Principal Balance
+ 42 -2313.80 -293.02 336259.52
+ 43 -2311.78 -295.04 335964.48
+ 44 -2309.76 -297.06 335667.42
+ 45 -2307.71 -299.11 335368.31
+ 46 -2305.66 -301.16 335067.15
+ 47 -2303.59 -303.23 334763.92
+ 48 -2301.50 -305.32 334458.60
+ 49 -2299.40 -307.42 334151.18
+ 50 -2297.29 -309.53 333841.65
+ 51 -2295.16 -311.66 333529.99
+ 52 -2293.02 -313.80 333216.19
+ 53 -2290.86 -315.96 332900.23
+Summary for: 2003:
+ Interest Paid: -27629.53
+ Principal Paid: -3652.31
+ Year Ending Balance: 332900.23
+ Sum of Interest Paid: -124071.06
+Pmt * Interest Principal Balance
+ 54 -2288.69 -318.13 332582.10
+ 55 -2286.50 -320.32 332261.78
+ 56 -2284.30 -322.52 331939.26
+ 57 -2282.08 -324.74 331614.52
+ 58 -2279.85 -326.97 331287.55
+ 59 -2277.60 -329.22 330958.33
+ 60 -2275.34 -331.48 330626.85
+ 61 -2273.06 -333.76 330293.09
+ 62 -2270.76 -336.06 329957.03
+ 63 -2268.45 -338.37 329618.66
+ 64 -2266.13 -340.69 329277.97
+ 65 -2263.79 -343.03 328934.94
+Summary for: 2004:
+ Interest Paid: -27316.55
+ Principal Paid: -3965.29
+ Year Ending Balance: 328934.94
+ Sum of Interest Paid: -151387.61
+Pmt * Interest Principal Balance
+ 66 -2261.43 -345.39 328589.55
+ 67 -2259.05 -347.77 328241.78
+ 68 -2256.66 -350.16 327891.62
+ 69 -2254.25 -352.57 327539.05
+ 70 -2251.83 -354.99 327184.06
+ 71 -2249.39 -357.43 326826.63
+ 72 -2246.93 -359.89 326466.74
+ 73 -2244.46 -362.36 326104.38
+ 74 -2241.97 -364.85 325739.53
+ 75 -2239.46 -367.36 325372.17
+ 76 -2236.93 -369.89 325002.28
+ 77 -2234.39 -372.43 324629.85
+Summary for: 2005:
+ Interest Paid: -26976.75
+ Principal Paid: -4305.09
+ Year Ending Balance: 324629.85
+ Sum of Interest Paid: -178364.36
+Pmt * Interest Principal Balance
+ 78 -2231.83 -374.99 324254.86
+ 79 -2229.25 -377.57 323877.29
+ 80 -2226.66 -380.16 323497.13
+ 81 -2224.04 -382.78 323114.35
+ 82 -2221.41 -385.41 322728.94
+ 83 -2218.76 -388.06 322340.88
+ 84 -2216.09 -390.73 321950.15
+ 85 -2213.41 -393.41 321556.74
+ 86 -2210.70 -396.12 321160.62
+ 87 -2207.98 -398.84 320761.78
+ 88 -2205.24 -401.58 320360.20
+ 89 -2202.48 -404.34 319955.86
+Summary for: 2006:
+ Interest Paid: -26607.85
+ Principal Paid: -4673.99
+ Year Ending Balance: 319955.86
+ Sum of Interest Paid: -204972.21
+Pmt * Interest Principal Balance
+ 90 -2199.70 -407.12 319548.74
+ 91 -2196.90 -409.92 319138.82
+ 92 -2194.08 -412.74 318726.08
+ 93 -2191.24 -415.58 318310.50
+ 94 -2188.38 -418.44 317892.06
+ 95 -2185.51 -421.31 317470.75
+ 96 -2182.61 -424.21 317046.54
+ 97 -2179.69 -427.13 316619.41
+ 98 -2176.76 -430.06 316189.35
+ 99 -2173.80 -433.02 315756.33
+ 100 -2170.82 -436.00 315320.33
+ 101 -2167.83 -438.99 314881.34
+Summary for: 2007:
+ Interest Paid: -26207.32
+ Principal Paid: -5074.52
+ Year Ending Balance: 314881.34
+ Sum of Interest Paid: -231179.53
+Pmt * Interest Principal Balance
+ 102 -2164.81 -442.01 314439.33
+ 103 -2161.77 -445.05 313994.28
+ 104 -2158.71 -448.11 313546.17
+ 105 -2155.63 -451.19 313094.98
+ 106 -2152.53 -454.29 312640.69
+ 107 -2149.40 -457.42 312183.27
+ 108 -2146.26 -460.56 311722.71
+ 109 -2143.09 -463.73 311258.98
+ 110 -2139.91 -466.91 310792.07
+ 111 -2136.70 -470.12 310321.95
+ 112 -2133.46 -473.36 309848.59
+ 113 -2130.21 -476.61 309371.98
+Summary for: 2008:
+ Interest Paid: -25772.48
+ Principal Paid: -5509.36
+ Year Ending Balance: 309371.98
+ Sum of Interest Paid: -256952.01
+Pmt * Interest Principal Balance
+ 114 -2126.93 -479.89 308892.09
+ 115 -2123.63 -483.19 308408.90
+ 116 -2120.31 -486.51 307922.39
+ 117 -2116.97 -489.85 307432.54
+ 118 -2113.60 -493.22 306939.32
+ 119 -2110.21 -496.61 306442.71
+ 120 -2106.79 -500.03 305942.68
+ 121 -2103.36 -503.46 305439.22
+ 122 -2099.89 -506.93 304932.29
+ 123 -2096.41 -510.41 304421.88
+ 124 -2092.90 -513.92 303907.96
+ 125 -2089.37 -517.45 303390.51
+Summary for: 2009:
+ Interest Paid: -25300.37
+ Principal Paid: -5981.47
+ Year Ending Balance: 303390.51
+ Sum of Interest Paid: -282252.38
+Pmt * Interest Principal Balance
+ 126 -2085.81 -521.01 302869.50
+ 127 -2082.23 -524.59 302344.91
+ 128 -2078.62 -528.20 301816.71
+ 129 -2074.99 -531.83 301284.88
+ 130 -2071.33 -535.49 300749.39
+ 131 -2067.65 -539.17 300210.22
+ 132 -2063.95 -542.87 299667.35
+ 133 -2060.21 -546.61 299120.74
+ 134 -2056.46 -550.36 298570.38
+ 135 -2052.67 -554.15 298016.23
+ 136 -2048.86 -557.96 297458.27
+ 137 -2045.03 -561.79 296896.48
+Summary for: 2010:
+ Interest Paid: -24787.81
+ Principal Paid: -6494.03
+ Year Ending Balance: 296896.48
+ Sum of Interest Paid: -307040.19
+Pmt * Interest Principal Balance
+ 138 -2041.16 -565.66 296330.82
+ 139 -2037.27 -569.55 295761.27
+ 140 -2033.36 -573.46 295187.81
+ 141 -2029.42 -577.40 294610.41
+ 142 -2025.45 -581.37 294029.04
+ 143 -2021.45 -585.37 293443.67
+ 144 -2017.43 -589.39 292854.28
+ 145 -2013.37 -593.45 292260.83
+ 146 -2009.29 -597.53 291663.30
+ 147 -2005.19 -601.63 291061.67
+ 148 -2001.05 -605.77 290455.90
+ 149 -1996.88 -609.94 289845.96
+Summary for: 2011:
+ Interest Paid: -24231.32
+ Principal Paid: -7050.52
+ Year Ending Balance: 289845.96
+ Sum of Interest Paid: -331271.51
+Pmt * Interest Principal Balance
+ 150 -1992.69 -614.13 289231.83
+ 151 -1988.47 -618.35 288613.48
+ 152 -1984.22 -622.60 287990.88
+ 153 -1979.94 -626.88 287364.00
+ 154 -1975.63 -631.19 286732.81
+ 155 -1971.29 -635.53 286097.28
+ 156 -1966.92 -639.90 285457.38
+ 157 -1962.52 -644.30 284813.08
+ 158 -1958.09 -648.73 284164.35
+ 159 -1953.63 -653.19 283511.16
+ 160 -1949.14 -657.68 282853.48
+ 161 -1944.62 -662.20 282191.28
+Summary for: 2012:
+ Interest Paid: -23627.16
+ Principal Paid: -7654.68
+ Year Ending Balance: 282191.28
+ Sum of Interest Paid: -354898.67
+Pmt * Interest Principal Balance
+ 162 -1940.07 -666.75 281524.53
+ 163 -1935.48 -671.34 280853.19
+ 164 -1930.87 -675.95 280177.24
+ 165 -1926.22 -680.60 279496.64
+ 166 -1921.54 -685.28 278811.36
+ 167 -1916.83 -689.99 278121.37
+ 168 -1912.08 -694.74 277426.63
+ 169 -1907.31 -699.51 276727.12
+ 170 -1902.50 -704.32 276022.80
+ 171 -1897.66 -709.16 275313.64
+ 172 -1892.78 -714.04 274599.60
+ 173 -1887.87 -718.95 273880.65
+Summary for: 2013:
+ Interest Paid: -22971.21
+ Principal Paid: -8310.63
+ Year Ending Balance: 273880.65
+ Sum of Interest Paid: -377869.88
+Pmt * Interest Principal Balance
+ 174 -1882.93 -723.89 273156.76
+ 175 -1877.95 -728.87 272427.89
+ 176 -1872.94 -733.88 271694.01
+ 177 -1867.90 -738.92 270955.09
+ 178 -1862.82 -744.00 270211.09
+ 179 -1857.70 -749.12 269461.97
+ 180 -1852.55 -754.27 268707.70
+ 181 -1847.37 -759.45 267948.25
+ 182 -1842.14 -764.68 267183.57
+ 183 -1836.89 -769.93 266413.64
+ 184 -1831.59 -775.23 265638.41
+ 185 -1826.26 -780.56 264857.85
+Summary for: 2014:
+ Interest Paid: -22259.04
+ Principal Paid: -9022.80
+ Year Ending Balance: 264857.85
+ Sum of Interest Paid: -400128.92
+Pmt * Interest Principal Balance
+ 186 -1820.90 -785.92 264071.93
+ 187 -1815.49 -791.33 263280.60
+ 188 -1810.05 -796.77 262483.83
+ 189 -1804.58 -802.24 261681.59
+ 190 -1799.06 -807.76 260873.83
+ 191 -1793.51 -813.31 260060.52
+ 192 -1787.92 -818.90 259241.62
+ 193 -1782.29 -824.53 258417.09
+ 194 -1776.62 -830.20 257586.89
+ 195 -1770.91 -835.91 256750.98
+ 196 -1765.16 -841.66 255909.32
+ 197 -1759.38 -847.44 255061.88
+Summary for: 2015:
+ Interest Paid: -21485.87
+ Principal Paid: -9795.97
+ Year Ending Balance: 255061.88
+ Sum of Interest Paid: -421614.79
+Pmt * Interest Principal Balance
+ 198 -1753.55 -853.27 254208.61
+ 199 -1747.68 -859.14 253349.47
+ 200 -1741.78 -865.04 252484.43
+ 201 -1735.83 -870.99 251613.44
+ 202 -1729.84 -876.98 250736.46
+ 203 -1723.81 -883.01 249853.45
+ 204 -1717.74 -889.08 248964.37
+ 205 -1711.63 -895.19 248069.18
+ 206 -1705.48 -901.34 247167.84
+ 207 -1699.28 -907.54 246260.30
+ 208 -1693.04 -913.78 245346.52
+ 209 -1686.76 -920.06 244426.46
+Summary for: 2016:
+ Interest Paid: -20646.42
+ Principal Paid: -10635.42
+ Year Ending Balance: 244426.46
+ Sum of Interest Paid: -442261.21
+Pmt * Interest Principal Balance
+ 210 -1680.43 -926.39 243500.07
+ 211 -1674.06 -932.76 242567.31
+ 212 -1667.65 -939.17 241628.14
+ 213 -1661.19 -945.63 240682.51
+ 214 -1654.69 -952.13 239730.38
+ 215 -1648.15 -958.67 238771.71
+ 216 -1641.56 -965.26 237806.45
+ 217 -1634.92 -971.90 236834.55
+ 218 -1628.24 -978.58 235855.97
+ 219 -1621.51 -985.31 234870.66
+ 220 -1614.74 -992.08 233878.58
+ 221 -1607.92 -998.90 232879.68
+Summary for: 2017:
+ Interest Paid: -19735.06
+ Principal Paid: -11546.78
+ Year Ending Balance: 232879.68
+ Sum of Interest Paid: -461996.27
+Pmt * Interest Principal Balance
+ 222 -1601.05 -1005.77 231873.91
+ 223 -1594.13 -1012.69 230861.22
+ 224 -1587.17 -1019.65 229841.57
+ 225 -1580.16 -1026.66 228814.91
+ 226 -1573.10 -1033.72 227781.19
+ 227 -1566.00 -1040.82 226740.37
+ 228 -1558.84 -1047.98 225692.39
+ 229 -1551.64 -1055.18 224637.21
+ 230 -1544.38 -1062.44 223574.77
+ 231 -1537.08 -1069.74 222505.03
+ 232 -1529.72 -1077.10 221427.93
+ 233 -1522.32 -1084.50 220343.43
+Summary for: 2018:
+ Interest Paid: -18745.59
+ Principal Paid: -12536.25
+ Year Ending Balance: 220343.43
+ Sum of Interest Paid: -480741.86
+Pmt * Interest Principal Balance
+ 234 -1514.86 -1091.96 219251.47
+ 235 -1507.35 -1099.47 218152.00
+ 236 -1499.80 -1107.02 217044.98
+ 237 -1492.18 -1114.64 215930.34
+ 238 -1484.52 -1122.30 214808.04
+ 239 -1476.81 -1130.01 213678.03
+ 240 -1469.04 -1137.78 212540.25
+ 241 -1461.21 -1145.61 211394.64
+ 242 -1453.34 -1153.48 210241.16
+ 243 -1445.41 -1161.41 209079.75
+ 244 -1437.42 -1169.40 207910.35
+ 245 -1429.38 -1177.44 206732.91
+Summary for: 2019:
+ Interest Paid: -17671.32
+ Principal Paid: -13610.52
+ Year Ending Balance: 206732.91
+ Sum of Interest Paid: -498413.18
+Pmt * Interest Principal Balance
+ 246 -1421.29 -1185.53 205547.38
+ 247 -1413.14 -1193.68 204353.70
+ 248 -1404.93 -1201.89 203151.81
+ 249 -1396.67 -1210.15 201941.66
+ 250 -1388.35 -1218.47 200723.19
+ 251 -1379.97 -1226.85 199496.34
+ 252 -1371.54 -1235.28 198261.06
+ 253 -1363.04 -1243.78 197017.28
+ 254 -1354.49 -1252.33 195764.95
+ 255 -1345.88 -1260.94 194504.01
+ 256 -1337.22 -1269.60 193234.41
+ 257 -1328.49 -1278.33 191956.08
+Summary for: 2020:
+ Interest Paid: -16505.01
+ Principal Paid: -14776.83
+ Year Ending Balance: 191956.08
+ Sum of Interest Paid: -514918.19
+Pmt * Interest Principal Balance
+ 258 -1319.70 -1287.12 190668.96
+ 259 -1310.85 -1295.97 189372.99
+ 260 -1301.94 -1304.88 188068.11
+ 261 -1292.97 -1313.85 186754.26
+ 262 -1283.94 -1322.88 185431.38
+ 263 -1274.84 -1331.98 184099.40
+ 264 -1265.68 -1341.14 182758.26
+ 265 -1256.46 -1350.36 181407.90
+ 266 -1247.18 -1359.64 180048.26
+ 267 -1237.83 -1368.99 178679.27
+ 268 -1228.42 -1378.40 177300.87
+ 269 -1218.94 -1387.88 175912.99
+Summary for: 2021:
+ Interest Paid: -15238.75
+ Principal Paid: -16043.09
+ Year Ending Balance: 175912.99
+ Sum of Interest Paid: -530156.94
+Pmt * Interest Principal Balance
+ 270 -1209.40 -1397.42 174515.57
+ 271 -1199.79 -1407.03 173108.54
+ 272 -1190.12 -1416.70 171691.84
+ 273 -1180.38 -1426.44 170265.40
+ 274 -1170.57 -1436.25 168829.15
+ 275 -1160.70 -1446.12 167383.03
+ 276 -1150.76 -1456.06 165926.97
+ 277 -1140.75 -1466.07 164460.90
+ 278 -1130.67 -1476.15 162984.75
+ 279 -1120.52 -1486.30 161498.45
+ 280 -1110.30 -1496.52 160001.93
+ 281 -1100.01 -1506.81 158495.12
+Summary for: 2022:
+ Interest Paid: -13863.97
+ Principal Paid: -17417.87
+ Year Ending Balance: 158495.12
+ Sum of Interest Paid: -544020.91
+Pmt * Interest Principal Balance
+ 282 -1089.65 -1517.17 156977.95
+ 283 -1079.22 -1527.60 155450.35
+ 284 -1068.72 -1538.10 153912.25
+ 285 -1058.15 -1548.67 152363.58
+ 286 -1047.50 -1559.32 150804.26
+ 287 -1036.78 -1570.04 149234.22
+ 288 -1025.99 -1580.83 147653.39
+ 289 -1015.12 -1591.70 146061.69
+ 290 -1004.17 -1602.65 144459.04
+ 291 -993.16 -1613.66 142845.38
+ 292 -982.06 -1624.76 141220.62
+ 293 -970.89 -1635.93 139584.69
+Summary for: 2023:
+ Interest Paid: -12371.41
+ Principal Paid: -18910.43
+ Year Ending Balance: 139584.69
+ Sum of Interest Paid: -556392.32
+Pmt * Interest Principal Balance
+ 294 -959.64 -1647.18 137937.51
+ 295 -948.32 -1658.50 136279.01
+ 296 -936.92 -1669.90 134609.11
+ 297 -925.44 -1681.38 132927.73
+ 298 -913.88 -1692.94 131234.79
+ 299 -902.24 -1704.58 129530.21
+ 300 -890.52 -1716.30 127813.91
+ 301 -878.72 -1728.10 126085.81
+ 302 -866.84 -1739.98 124345.83
+ 303 -854.88 -1751.94 122593.89
+ 304 -842.83 -1763.99 120829.90
+ 305 -830.71 -1776.11 119053.79
+Summary for: 2024:
+ Interest Paid: -10750.94
+ Principal Paid: -20530.90
+ Year Ending Balance: 119053.79
+ Sum of Interest Paid: -567143.26
+Pmt * Interest Principal Balance
+ 306 -818.49 -1788.33 117265.46
+ 307 -806.20 -1800.62 115464.84
+ 308 -793.82 -1813.00 113651.84
+ 309 -781.36 -1825.46 111826.38
+ 310 -768.81 -1838.01 109988.37
+ 311 -756.17 -1850.65 108137.72
+ 312 -743.45 -1863.37 106274.35
+ 313 -730.64 -1876.18 104398.17
+ 314 -717.74 -1889.08 102509.09
+ 315 -704.75 -1902.07 100607.02
+ 316 -691.67 -1915.15 98691.87
+ 317 -678.51 -1928.31 96763.56
+Summary for: 2025:
+ Interest Paid: -8991.61
+ Principal Paid: -22290.23
+ Year Ending Balance: 96763.56
+ Sum of Interest Paid: -576134.87
+Pmt * Interest Principal Balance
+ 318 -665.25 -1941.57 94821.99
+ 319 -651.90 -1954.92 92867.07
+ 320 -638.46 -1968.36 90898.71
+ 321 -624.93 -1981.89 88916.82
+ 322 -611.30 -1995.52 86921.30
+ 323 -597.58 -2009.24 84912.06
+ 324 -583.77 -2023.05 82889.01
+ 325 -569.86 -2036.96 80852.05
+ 326 -555.86 -2050.96 78801.09
+ 327 -541.76 -2065.06 76736.03
+ 328 -527.56 -2079.26 74656.77
+ 329 -513.27 -2093.55 72563.22
+Summary for: 2026:
+ Interest Paid: -7081.50
+ Principal Paid: -24200.34
+ Year Ending Balance: 72563.22
+ Sum of Interest Paid: -583216.37
+Pmt * Interest Principal Balance
+ 330 -498.87 -2107.95 70455.27
+ 331 -484.38 -2122.44 68332.83
+ 332 -469.79 -2137.03 66195.80
+ 333 -455.10 -2151.72 64044.08
+ 334 -440.30 -2166.52 61877.56
+ 335 -425.41 -2181.41 59696.15
+ 336 -410.41 -2196.41 57499.74
+ 337 -395.31 -2211.51 55288.23
+ 338 -380.11 -2226.71 53061.52
+ 339 -364.80 -2242.02 50819.50
+ 340 -349.38 -2257.44 48562.06
+ 341 -333.86 -2272.96 46289.10
+Summary for: 2027:
+ Interest Paid: -5007.72
+ Principal Paid: -26274.12
+ Year Ending Balance: 46289.10
+ Sum of Interest Paid: -588224.09
+Pmt * Interest Principal Balance
+ 342 -318.24 -2288.58 44000.52
+ 343 -302.50 -2304.32 41696.20
+ 344 -286.66 -2320.16 39376.04
+ 345 -270.71 -2336.11 37039.93
+ 346 -254.65 -2352.17 34687.76
+ 347 -238.48 -2368.34 32319.42
+ 348 -222.20 -2384.62 29934.80
+ 349 -205.80 -2401.02 27533.78
+ 350 -189.29 -2417.53 25116.25
+ 351 -172.67 -2434.15 22682.10
+ 352 -155.94 -2450.88 20231.22
+ 353 -139.09 -2467.73 17763.49
+Summary for: 2028:
+ Interest Paid: -2756.23
+ Principal Paid: -28525.61
+ Year Ending Balance: 17763.49
+ Sum of Interest Paid: -590980.32
+Pmt * Interest Principal Balance
+ 354 -122.12 -2484.70 15278.79
+ 355 -105.04 -2501.78 12777.01
+ 356 -87.84 -2518.98 10258.03
+ 357 -70.52 -2536.30 7721.73
+ 358 -53.09 -2553.73 5168.00
+ 359 -35.53 -2571.29 2596.71
+Final Payment: -2614.56
+ 360 -17.85 -2596.71 -0.00
+Summary for: 2029:
+ Interest Paid: -491.99
+ Principal Paid: -17763.49
+ Year Ending Balance: 0.00
+ Sum of Interest Paid: -591472.31
+
+Total Interest: -591472.31
+
+
+Seventh Schedule - use new payments due to delay and
+output variable prepayment schedule
+Amortization Table
+Effective Date: Tue Jun 15 00:00:00 1999
+Initial Payment Date: Sun Aug 1 00:00:00 1999
+Compounding Frequency per year: 12
+Payment Frequency per year: 12
+Compounding: Discrete
+Payments: End of Period
+Payments (359): -2606.82
+Final payment (360): -2614.23
+Nominal Annual Interest Rate: 8.25
+ Effective Interest Rate Per Payment Period: 0.006875
+Present Value: 345725.00
+Interest due to Delayed Intial Payment: -1265.63
+Advanced Prepayment Amortization - Variable Prepayment
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 1 -2385.56 -221.26 -222.78 -2829.60 346546.59
+ 2 -2382.51 -224.31 -225.85 -2832.67 346096.43
+ 3 -2379.41 -227.41 -228.97 -2835.79 345640.05
+ 4 -2376.28 -230.54 -232.13 -2838.95 345177.38
+ 5 -2373.09 -233.73 -235.33 -2842.15 344708.32
+Summary for: 1999:
+ Interest Paid: -11896.85
+ Principal Paid: 344705.19
+ Year Ending Balance: 344708.32
+ Sum of Interest Paid: -11896.85
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 6 -2369.87 -236.95 -238.58 -2845.40 344232.79
+ 7 -2366.60 -240.22 -241.87 -2848.69 343750.70
+ 8 -2363.29 -243.53 -245.21 -2852.03 343261.96
+ 9 -2359.93 -246.89 -248.59 -2855.41 342766.48
+ 10 -2356.52 -250.30 -252.02 -2858.84 342264.16
+ 11 -2353.07 -253.75 -255.50 -2862.32 341754.91
+ 12 -2349.57 -257.25 -259.02 -2865.84 341238.64
+ 13 -2346.02 -260.80 -262.60 -2869.42 340715.24
+ 14 -2342.42 -264.40 -266.22 -2873.04 340184.62
+ 15 -2338.77 -268.05 -269.89 -2876.71 339646.68
+ 16 -2335.07 -271.75 -273.62 -2880.44 339101.31
+ 17 -2331.32 -275.50 -277.39 -2884.21 338548.42
+Summary for: 2000:
+ Interest Paid: -28212.45
+ Principal Paid: -6159.90
+ Year Ending Balance: 338548.42
+ Sum of Interest Paid: -40109.30
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 18 -2327.52 -279.30 -281.22 -2888.04 337987.90
+ 19 -2323.67 -283.15 -285.10 -2891.92 337419.65
+ 20 -2319.76 -287.06 -289.03 -2895.85 336843.56
+ 21 -2315.80 -291.02 -293.02 -2899.84 336259.52
+ 22 -2311.78 -295.04 -297.06 -2903.88 335667.42
+ 23 -2307.71 -299.11 -301.16 -2907.98 335067.15
+ 24 -2303.59 -303.23 -305.32 -2912.14 334458.60
+ 25 -2299.40 -307.42 -309.53 -2916.35 333841.65
+ 26 -2295.16 -311.66 -313.80 -2920.62 333216.19
+ 27 -2290.86 -315.96 -318.13 -2924.95 332582.10
+ 28 -2286.50 -320.32 -322.52 -2929.34 331939.26
+ 29 -2282.08 -324.74 -326.97 -2933.79 331287.55
+Summary for: 2001:
+ Interest Paid: -27663.83
+ Principal Paid: -7260.87
+ Year Ending Balance: 331287.55
+ Sum of Interest Paid: -67773.13
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 30 -2277.60 -329.22 -331.48 -2938.30 330626.85
+ 31 -2273.06 -333.76 -336.06 -2942.88 329957.03
+ 32 -2268.45 -338.37 -340.69 -2947.51 329277.97
+ 33 -2263.79 -343.03 -345.39 -2952.21 328589.55
+ 34 -2259.05 -347.77 -350.16 -2956.98 327891.62
+ 35 -2254.25 -352.57 -354.99 -2961.81 327184.06
+ 36 -2249.39 -357.43 -359.89 -2966.71 326466.74
+ 37 -2244.46 -362.36 -364.85 -2971.67 325739.53
+ 38 -2239.46 -367.36 -369.89 -2976.71 325002.28
+ 39 -2234.39 -372.43 -374.99 -2981.81 324254.86
+ 40 -2229.25 -377.57 -380.16 -2986.98 323497.13
+ 41 -2224.04 -382.78 -385.41 -2992.23 322728.94
+Summary for: 2002:
+ Interest Paid: -27017.19
+ Principal Paid: -8558.61
+ Year Ending Balance: 322728.94
+ Sum of Interest Paid: -94790.32
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 42 -2218.76 -388.06 -390.73 -2997.55 321950.15
+ 43 -2213.41 -393.41 -396.12 -3002.94 321160.62
+ 44 -2207.98 -398.84 -401.58 -3008.40 320360.20
+ 45 -2202.48 -404.34 -407.12 -3013.94 319548.74
+ 46 -2196.90 -409.92 -412.74 -3019.56 318726.08
+ 47 -2191.24 -415.58 -418.44 -3025.26 317892.06
+ 48 -2185.51 -421.31 -424.21 -3031.03 317046.54
+ 49 -2179.69 -427.13 -430.06 -3036.88 316189.35
+ 50 -2173.80 -433.02 -436.00 -3042.82 315320.33
+ 51 -2167.83 -438.99 -442.01 -3048.83 314439.33
+ 52 -2161.77 -445.05 -448.11 -3054.93 313546.17
+ 53 -2155.63 -451.19 -454.29 -3061.11 312640.69
+Summary for: 2003:
+ Interest Paid: -26255.00
+ Principal Paid: -10088.25
+ Year Ending Balance: 312640.69
+ Sum of Interest Paid: -121045.32
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 54 -2149.40 -457.42 -460.56 -3067.38 311722.71
+ 55 -2143.09 -463.73 -466.91 -3073.73 310792.07
+ 56 -2136.70 -470.12 -473.36 -3080.18 309848.59
+ 57 -2130.21 -476.61 -479.89 -3086.71 308892.09
+ 58 -2123.63 -483.19 -486.51 -3093.33 307922.39
+ 59 -2116.97 -489.85 -493.22 -3100.04 306939.32
+ 60 -2110.21 -496.61 -500.03 -3106.85 305942.68
+ 61 -2103.36 -503.46 -506.93 -3113.75 304932.29
+ 62 -2096.41 -510.41 -513.92 -3120.74 303907.96
+ 63 -2089.37 -517.45 -521.01 -3127.83 302869.50
+ 64 -2082.23 -524.59 -528.20 -3135.02 301816.71
+ 65 -2074.99 -531.83 -535.49 -3142.31 300749.39
+Summary for: 2004:
+ Interest Paid: -25356.57
+ Principal Paid: -11891.30
+ Year Ending Balance: 300749.39
+ Sum of Interest Paid: -146401.89
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 66 -2067.65 -539.17 -542.87 -3149.69 299667.35
+ 67 -2060.21 -546.61 -550.36 -3157.18 298570.38
+ 68 -2052.67 -554.15 -557.96 -3164.78 297458.27
+ 69 -2045.03 -561.79 -565.66 -3172.48 296330.82
+ 70 -2037.27 -569.55 -573.46 -3180.28 295187.81
+ 71 -2029.42 -577.40 -581.37 -3188.19 294029.04
+ 72 -2021.45 -585.37 -589.39 -3196.21 292854.28
+ 73 -2013.37 -593.45 -597.53 -3204.35 291663.30
+ 74 -2005.19 -601.63 -605.77 -3212.59 290455.90
+ 75 -1996.88 -609.94 -614.13 -3220.95 289231.83
+ 76 -1988.47 -618.35 -622.60 -3229.42 287990.88
+ 77 -1979.94 -626.88 -631.19 -3238.01 286732.81
+Summary for: 2005:
+ Interest Paid: -24297.55
+ Principal Paid: -14016.58
+ Year Ending Balance: 286732.81
+ Sum of Interest Paid: -170699.44
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 78 -1971.29 -635.53 -639.90 -3246.72 285457.38
+ 79 -1962.52 -644.30 -648.73 -3255.55 284164.35
+ 80 -1953.63 -653.19 -657.68 -3264.50 282853.48
+ 81 -1944.62 -662.20 -666.75 -3273.57 281524.53
+ 82 -1935.48 -671.34 -675.95 -3282.77 280177.24
+ 83 -1926.22 -680.60 -685.28 -3292.10 278811.36
+ 84 -1916.83 -689.99 -694.74 -3301.56 277426.63
+ 85 -1907.31 -699.51 -704.32 -3311.14 276022.80
+ 86 -1897.66 -709.16 -714.04 -3320.86 274599.60
+ 87 -1887.87 -718.95 -723.89 -3330.71 273156.76
+ 88 -1877.95 -728.87 -733.88 -3340.70 271694.01
+ 89 -1867.90 -738.92 -744.00 -3350.82 270211.09
+Summary for: 2006:
+ Interest Paid: -23049.28
+ Principal Paid: -16521.72
+ Year Ending Balance: 270211.09
+ Sum of Interest Paid: -193748.72
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 90 -1857.70 -749.12 -754.27 -3361.09 268707.70
+ 91 -1847.37 -759.45 -764.68 -3371.50 267183.57
+ 92 -1836.89 -769.93 -775.23 -3382.05 265638.41
+ 93 -1826.26 -780.56 -785.92 -3392.74 264071.93
+ 94 -1815.49 -791.33 -796.77 -3403.59 262483.83
+ 95 -1804.58 -802.24 -807.76 -3414.58 260873.83
+ 96 -1793.51 -813.31 -818.90 -3425.72 259241.62
+ 97 -1782.29 -824.53 -830.20 -3437.02 257586.89
+ 98 -1770.91 -835.91 -841.66 -3448.48 255909.32
+ 99 -1759.38 -847.44 -853.27 -3460.09 254208.61
+ 100 -1747.68 -859.14 -865.04 -3471.86 252484.43
+ 101 -1735.83 -870.99 -876.98 -3483.80 250736.46
+Summary for: 2007:
+ Interest Paid: -21577.89
+ Principal Paid: -19474.63
+ Year Ending Balance: 250736.46
+ Sum of Interest Paid: -215326.61
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 102 -1723.81 -883.01 -889.08 -3495.90 248964.37
+ 103 -1711.63 -895.19 -901.34 -3508.16 247167.84
+ 104 -1699.28 -907.54 -913.78 -3520.60 245346.52
+ 105 -1686.76 -920.06 -926.39 -3533.21 243500.07
+ 106 -1674.06 -932.76 -939.17 -3545.99 241628.14
+ 107 -1661.19 -945.63 -952.13 -3558.95 239730.38
+ 108 -1648.15 -958.67 -965.26 -3572.08 237806.45
+ 109 -1634.92 -971.90 -978.58 -3585.40 235855.97
+ 110 -1621.51 -985.31 -992.08 -3598.90 233878.58
+ 111 -1607.92 -998.90 -1005.77 -3612.59 231873.91
+ 112 -1594.13 -1012.69 -1019.65 -3626.47 229841.57
+ 113 -1580.16 -1026.66 -1033.72 -3640.54 227781.19
+Summary for: 2008:
+ Interest Paid: -19843.52
+ Principal Paid: -22955.27
+ Year Ending Balance: 227781.19
+ Sum of Interest Paid: -235170.13
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 114 -1566.00 -1040.82 -1047.98 -3654.80 225692.39
+ 115 -1551.64 -1055.18 -1062.44 -3669.26 223574.77
+ 116 -1537.08 -1069.74 -1077.10 -3683.92 221427.93
+ 117 -1522.32 -1084.50 -1091.96 -3698.78 219251.47
+ 118 -1507.35 -1099.47 -1107.03 -3713.85 217044.97
+ 119 -1492.18 -1114.64 -1122.30 -3729.12 214808.03
+ 120 -1476.81 -1130.01 -1137.78 -3744.60 212540.24
+ 121 -1461.21 -1145.61 -1153.48 -3760.30 210241.15
+ 122 -1445.41 -1161.41 -1169.40 -3776.22 207910.34
+ 123 -1429.38 -1177.44 -1185.53 -3792.35 205547.37
+ 124 -1413.14 -1193.68 -1201.89 -3808.71 203151.80
+ 125 -1396.67 -1210.15 -1218.47 -3825.29 200723.18
+Summary for: 2009:
+ Interest Paid: -17799.19
+ Principal Paid: -27058.01
+ Year Ending Balance: 200723.18
+ Sum of Interest Paid: -252969.32
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 126 -1379.97 -1226.85 -1235.28 -3842.10 198261.05
+ 127 -1363.04 -1243.78 -1252.33 -3859.15 195764.94
+ 128 -1345.88 -1260.94 -1269.61 -3876.43 193234.39
+ 129 -1328.49 -1278.33 -1287.12 -3893.94 190668.94
+ 130 -1310.85 -1295.97 -1304.88 -3911.70 188068.09
+ 131 -1292.97 -1313.85 -1322.88 -3929.70 185431.36
+ 132 -1274.84 -1331.98 -1341.14 -3947.96 182758.24
+ 133 -1256.46 -1350.36 -1359.64 -3966.46 180048.24
+ 134 -1237.83 -1368.99 -1378.40 -3985.22 177300.85
+ 135 -1218.94 -1387.88 -1397.42 -4004.24 174515.55
+ 136 -1199.79 -1407.03 -1416.70 -4023.52 171691.82
+ 137 -1180.38 -1426.44 -1436.25 -4043.07 168829.13
+Summary for: 2010:
+ Interest Paid: -15389.44
+ Principal Paid: -31894.05
+ Year Ending Balance: 168829.13
+ Sum of Interest Paid: -268358.76
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 138 -1160.70 -1446.12 -1456.06 -4062.88 165926.95
+ 139 -1140.75 -1466.07 -1476.15 -4082.97 162984.73
+ 140 -1120.52 -1486.30 -1496.52 -4103.34 160001.91
+ 141 -1100.01 -1506.81 -1517.17 -4123.99 156977.93
+ 142 -1079.22 -1527.60 -1538.10 -4144.92 153912.23
+ 143 -1058.15 -1548.67 -1559.32 -4166.14 150804.24
+ 144 -1036.78 -1570.04 -1580.83 -4187.65 147653.37
+ 145 -1015.12 -1591.70 -1602.65 -4209.47 144459.02
+ 146 -993.16 -1613.66 -1624.76 -4231.58 141220.60
+ 147 -970.89 -1635.93 -1647.18 -4254.00 137937.49
+ 148 -948.32 -1658.50 -1669.90 -4276.72 134609.09
+ 149 -925.44 -1681.38 -1692.94 -4299.76 131234.77
+Summary for: 2011:
+ Interest Paid: -12549.06
+ Principal Paid: -37594.36
+ Year Ending Balance: 131234.77
+ Sum of Interest Paid: -280907.82
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 150 -902.24 -1704.58 -1716.30 -4323.12 127813.89
+ 151 -878.72 -1728.10 -1739.98 -4346.80 124345.81
+ 152 -854.88 -1751.94 -1763.99 -4370.81 120829.88
+ 153 -830.71 -1776.11 -1788.33 -4395.15 117265.44
+ 154 -806.20 -1800.62 -1813.00 -4419.82 113651.82
+ 155 -781.36 -1825.46 -1838.01 -4444.83 109988.35
+ 156 -756.17 -1850.65 -1863.37 -4470.19 106274.33
+ 157 -730.64 -1876.18 -1889.08 -4495.90 102509.07
+ 158 -704.75 -1902.07 -1915.15 -4521.97 98691.85
+ 159 -678.51 -1928.31 -1941.57 -4548.39 94821.97
+ 160 -651.90 -1954.92 -1968.36 -4575.18 90898.69
+ 161 -624.93 -1981.89 -1995.52 -4602.34 86921.28
+Summary for: 2012:
+ Interest Paid: -9201.01
+ Principal Paid: -44313.49
+ Year Ending Balance: 86921.28
+ Sum of Interest Paid: -290108.83
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 162 -597.58 -2009.24 -2023.05 -4629.87 82888.99
+ 163 -569.86 -2036.96 -2050.96 -4657.78 78801.07
+ 164 -541.76 -2065.06 -2079.26 -4686.08 74656.75
+ 165 -513.27 -2093.55 -2107.95 -4714.77 70455.25
+ 166 -484.38 -2122.44 -2137.03 -4743.85 66195.78
+ 167 -455.10 -2151.72 -2166.52 -4773.34 61877.54
+ 168 -425.41 -2181.41 -2196.41 -4803.23 57499.72
+ 169 -395.31 -2211.51 -2226.71 -4833.53 53061.50
+ 170 -364.80 -2242.02 -2257.44 -4864.26 48562.04
+ 171 -333.86 -2272.96 -2288.58 -4895.40 44000.50
+ 172 -302.50 -2304.32 -2320.16 -4926.98 39376.02
+ 173 -270.71 -2336.11 -2352.17 -4958.99 34687.74
+Summary for: 2013:
+ Interest Paid: -5254.54
+ Principal Paid: -52233.54
+ Year Ending Balance: 34687.74
+ Sum of Interest Paid: -295363.37
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 174 -238.48 -2368.34 -2384.62 -4991.44 29934.78
+ 175 -205.80 -2401.02 -2417.53 -5024.35 25116.23
+ 176 -172.67 -2434.15 -2450.88 -5057.70 20231.20
+ 177 -139.09 -2467.73 -2484.70 -5091.52 15278.77
+ 178 -105.04 -2501.78 -2518.98 -5125.80 10258.01
+ 179 -70.52 -2536.30 -2553.73 -5160.55 5167.98
+ 180 -35.53 -2571.29 -2588.97 -5195.79 7.72
+ 181 -0.05 -7.72 0.00 -7.77 0.00
+Summary for: 2014:
+ Interest Paid: -967.18
+ Principal Paid: -34687.74
+ Year Ending Balance: 0.00
+ Sum of Interest Paid: -296330.55
+
+Total Interest: -296330.55
+
+
+Eighth Schedule - use new payments due to delay and
+output fixed prepayment schedule
+Amortization Table
+Effective Date: Tue Jun 15 00:00:00 1999
+Initial Payment Date: Sun Aug 1 00:00:00 1999
+Compounding Frequency per year: 12
+Payment Frequency per year: 12
+Compounding: Discrete
+Payments: End of Period
+Payments (359): -2606.82
+Final payment (360): -2614.23
+Nominal Annual Interest Rate: 8.25
+ Effective Interest Rate Per Payment Period: 0.006875
+Present Value: 345725.00
+Interest due to Delayed Intial Payment: -1265.63
+Advanced Prepayment Amortization - Fixed Prepayment: -400.00
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 1 -2385.56 -221.26 -400.00 -3006.82 346369.37
+ 2 -2381.29 -225.53 -400.00 -3006.82 345743.84
+ 3 -2376.99 -229.83 -400.00 -3006.82 345114.01
+ 4 -2372.66 -234.16 -400.00 -3006.82 344479.85
+ 5 -2368.30 -238.52 -400.00 -3006.82 343841.33
+Summary for: 1999:
+ Interest Paid: -11884.80
+ Principal Paid: 343838.20
+ Year Ending Balance: 343841.33
+ Sum of Interest Paid: -11884.80
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 6 -2363.91 -242.91 -400.00 -3006.82 343198.42
+ 7 -2359.49 -247.33 -400.00 -3006.82 342551.09
+ 8 -2355.04 -251.78 -400.00 -3006.82 341899.31
+ 9 -2350.56 -256.26 -400.00 -3006.82 341243.05
+ 10 -2346.05 -260.77 -400.00 -3006.82 340582.28
+ 11 -2341.50 -265.32 -400.00 -3006.82 339916.96
+ 12 -2336.93 -269.89 -400.00 -3006.82 339247.07
+ 13 -2332.32 -274.50 -400.00 -3006.82 338572.57
+ 14 -2327.69 -279.13 -400.00 -3006.82 337893.44
+ 15 -2323.02 -283.80 -400.00 -3006.82 337209.64
+ 16 -2318.32 -288.50 -400.00 -3006.82 336521.14
+ 17 -2313.58 -293.24 -400.00 -3006.82 335827.90
+Summary for: 2000:
+ Interest Paid: -28068.41
+ Principal Paid: -8013.43
+ Year Ending Balance: 335827.90
+ Sum of Interest Paid: -39953.21
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 18 -2308.82 -298.00 -400.00 -3006.82 335129.90
+ 19 -2304.02 -302.80 -400.00 -3006.82 334427.10
+ 20 -2299.19 -307.63 -400.00 -3006.82 333719.47
+ 21 -2294.32 -312.50 -400.00 -3006.82 333006.97
+ 22 -2289.42 -317.40 -400.00 -3006.82 332289.57
+ 23 -2284.49 -322.33 -400.00 -3006.82 331567.24
+ 24 -2279.52 -327.30 -400.00 -3006.82 330839.94
+ 25 -2274.52 -332.30 -400.00 -3006.82 330107.64
+ 26 -2269.49 -337.33 -400.00 -3006.82 329370.31
+ 27 -2264.42 -342.40 -400.00 -3006.82 328627.91
+ 28 -2259.32 -347.50 -400.00 -3006.82 327880.41
+ 29 -2254.18 -352.64 -400.00 -3006.82 327127.77
+Summary for: 2001:
+ Interest Paid: -27381.71
+ Principal Paid: -8700.13
+ Year Ending Balance: 327127.77
+ Sum of Interest Paid: -67334.92
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 30 -2249.00 -357.82 -400.00 -3006.82 326369.95
+ 31 -2243.79 -363.03 -400.00 -3006.82 325606.92
+ 32 -2238.55 -368.27 -400.00 -3006.82 324838.65
+ 33 -2233.27 -373.55 -400.00 -3006.82 324065.10
+ 34 -2227.95 -378.87 -400.00 -3006.82 323286.23
+ 35 -2222.59 -384.23 -400.00 -3006.82 322502.00
+ 36 -2217.20 -389.62 -400.00 -3006.82 321712.38
+ 37 -2211.77 -395.05 -400.00 -3006.82 320917.33
+ 38 -2206.31 -400.51 -400.00 -3006.82 320116.82
+ 39 -2200.80 -406.02 -400.00 -3006.82 319310.80
+ 40 -2195.26 -411.56 -400.00 -3006.82 318499.24
+ 41 -2189.68 -417.14 -400.00 -3006.82 317682.10
+Summary for: 2002:
+ Interest Paid: -26636.17
+ Principal Paid: -9445.67
+ Year Ending Balance: 317682.10
+ Sum of Interest Paid: -93971.09
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 42 -2184.06 -422.76 -400.00 -3006.82 316859.34
+ 43 -2178.41 -428.41 -400.00 -3006.82 316030.93
+ 44 -2172.71 -434.11 -400.00 -3006.82 315196.82
+ 45 -2166.98 -439.84 -400.00 -3006.82 314356.98
+ 46 -2161.20 -445.62 -400.00 -3006.82 313511.36
+ 47 -2155.39 -451.43 -400.00 -3006.82 312659.93
+ 48 -2149.54 -457.28 -400.00 -3006.82 311802.65
+ 49 -2143.64 -463.18 -400.00 -3006.82 310939.47
+ 50 -2137.71 -469.11 -400.00 -3006.82 310070.36
+ 51 -2131.73 -475.09 -400.00 -3006.82 309195.27
+ 52 -2125.72 -481.10 -400.00 -3006.82 308314.17
+ 53 -2119.66 -487.16 -400.00 -3006.82 307427.01
+Summary for: 2003:
+ Interest Paid: -25826.75
+ Principal Paid: -10255.09
+ Year Ending Balance: 307427.01
+ Sum of Interest Paid: -119797.84
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 54 -2113.56 -493.26 -400.00 -3006.82 306533.75
+ 55 -2107.42 -499.40 -400.00 -3006.82 305634.35
+ 56 -2101.24 -505.58 -400.00 -3006.82 304728.77
+ 57 -2095.01 -511.81 -400.00 -3006.82 303816.96
+ 58 -2088.74 -518.08 -400.00 -3006.82 302898.88
+ 59 -2082.43 -524.39 -400.00 -3006.82 301974.49
+ 60 -2076.07 -530.75 -400.00 -3006.82 301043.74
+ 61 -2069.68 -537.14 -400.00 -3006.82 300106.60
+ 62 -2063.23 -543.59 -400.00 -3006.82 299163.01
+ 63 -2056.75 -550.07 -400.00 -3006.82 298212.94
+ 64 -2050.21 -556.61 -400.00 -3006.82 297256.33
+ 65 -2043.64 -563.18 -400.00 -3006.82 296293.15
+Summary for: 2004:
+ Interest Paid: -24947.98
+ Principal Paid: -11133.86
+ Year Ending Balance: 296293.15
+ Sum of Interest Paid: -144745.82
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 66 -2037.02 -569.80 -400.00 -3006.82 295323.35
+ 67 -2030.35 -576.47 -400.00 -3006.82 294346.88
+ 68 -2023.63 -583.19 -400.00 -3006.82 293363.69
+ 69 -2016.88 -589.94 -400.00 -3006.82 292373.75
+ 70 -2010.07 -596.75 -400.00 -3006.82 291377.00
+ 71 -2003.22 -603.60 -400.00 -3006.82 290373.40
+ 72 -1996.32 -610.50 -400.00 -3006.82 289362.90
+ 73 -1989.37 -617.45 -400.00 -3006.82 288345.45
+ 74 -1982.37 -624.45 -400.00 -3006.82 287321.00
+ 75 -1975.33 -631.49 -400.00 -3006.82 286289.51
+ 76 -1968.24 -638.58 -400.00 -3006.82 285250.93
+ 77 -1961.10 -645.72 -400.00 -3006.82 284205.21
+Summary for: 2005:
+ Interest Paid: -23993.90
+ Principal Paid: -12087.94
+ Year Ending Balance: 284205.21
+ Sum of Interest Paid: -168739.72
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 78 -1953.91 -652.91 -400.00 -3006.82 283152.30
+ 79 -1946.67 -660.15 -400.00 -3006.82 282092.15
+ 80 -1939.38 -667.44 -400.00 -3006.82 281024.71
+ 81 -1932.04 -674.78 -400.00 -3006.82 279949.93
+ 82 -1924.66 -682.16 -400.00 -3006.82 278867.77
+ 83 -1917.22 -689.60 -400.00 -3006.82 277778.17
+ 84 -1909.72 -697.10 -400.00 -3006.82 276681.07
+ 85 -1902.18 -704.64 -400.00 -3006.82 275576.43
+ 86 -1894.59 -712.23 -400.00 -3006.82 274464.20
+ 87 -1886.94 -719.88 -400.00 -3006.82 273344.32
+ 88 -1879.24 -727.58 -400.00 -3006.82 272216.74
+ 89 -1871.49 -735.33 -400.00 -3006.82 271081.41
+Summary for: 2006:
+ Interest Paid: -22958.04
+ Principal Paid: -13123.80
+ Year Ending Balance: 271081.41
+ Sum of Interest Paid: -191697.76
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 90 -1863.68 -743.14 -400.00 -3006.82 269938.27
+ 91 -1855.83 -750.99 -400.00 -3006.82 268787.28
+ 92 -1847.91 -758.91 -400.00 -3006.82 267628.37
+ 93 -1839.95 -766.87 -400.00 -3006.82 266461.50
+ 94 -1831.92 -774.90 -400.00 -3006.82 265286.60
+ 95 -1823.85 -782.97 -400.00 -3006.82 264103.63
+ 96 -1815.71 -791.11 -400.00 -3006.82 262912.52
+ 97 -1807.52 -799.30 -400.00 -3006.82 261713.22
+ 98 -1799.28 -807.54 -400.00 -3006.82 260505.68
+ 99 -1790.98 -815.84 -400.00 -3006.82 259289.84
+ 100 -1782.62 -824.20 -400.00 -3006.82 258065.64
+ 101 -1774.20 -832.62 -400.00 -3006.82 256833.02
+Summary for: 2007:
+ Interest Paid: -21833.45
+ Principal Paid: -14248.39
+ Year Ending Balance: 256833.02
+ Sum of Interest Paid: -213531.21
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 102 -1765.73 -841.09 -400.00 -3006.82 255591.93
+ 103 -1757.19 -849.63 -400.00 -3006.82 254342.30
+ 104 -1748.60 -858.22 -400.00 -3006.82 253084.08
+ 105 -1739.95 -866.87 -400.00 -3006.82 251817.21
+ 106 -1731.24 -875.58 -400.00 -3006.82 250541.63
+ 107 -1722.47 -884.35 -400.00 -3006.82 249257.28
+ 108 -1713.64 -893.18 -400.00 -3006.82 247964.10
+ 109 -1704.75 -902.07 -400.00 -3006.82 246662.03
+ 110 -1695.80 -911.02 -400.00 -3006.82 245351.01
+ 111 -1686.79 -920.03 -400.00 -3006.82 244030.98
+ 112 -1677.71 -929.11 -400.00 -3006.82 242701.87
+ 113 -1668.58 -938.24 -400.00 -3006.82 241363.63
+Summary for: 2008:
+ Interest Paid: -20612.45
+ Principal Paid: -15469.39
+ Year Ending Balance: 241363.63
+ Sum of Interest Paid: -234143.66
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 114 -1659.37 -947.45 -400.00 -3006.82 240016.18
+ 115 -1650.11 -956.71 -400.00 -3006.82 238659.47
+ 116 -1640.78 -966.04 -400.00 -3006.82 237293.43
+ 117 -1631.39 -975.43 -400.00 -3006.82 235918.00
+ 118 -1621.94 -984.88 -400.00 -3006.82 234533.12
+ 119 -1612.42 -994.40 -400.00 -3006.82 233138.72
+ 120 -1602.83 -1003.99 -400.00 -3006.82 231734.73
+ 121 -1593.18 -1013.64 -400.00 -3006.82 230321.09
+ 122 -1583.46 -1023.36 -400.00 -3006.82 228897.73
+ 123 -1573.67 -1033.15 -400.00 -3006.82 227464.58
+ 124 -1563.82 -1043.00 -400.00 -3006.82 226021.58
+ 125 -1553.90 -1052.92 -400.00 -3006.82 224568.66
+Summary for: 2009:
+ Interest Paid: -19286.87
+ Principal Paid: -16794.97
+ Year Ending Balance: 224568.66
+ Sum of Interest Paid: -253430.53
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 126 -1543.91 -1062.91 -400.00 -3006.82 223105.75
+ 127 -1533.85 -1072.97 -400.00 -3006.82 221632.78
+ 128 -1523.73 -1083.09 -400.00 -3006.82 220149.69
+ 129 -1513.53 -1093.29 -400.00 -3006.82 218656.40
+ 130 -1503.26 -1103.56 -400.00 -3006.82 217152.84
+ 131 -1492.93 -1113.89 -400.00 -3006.82 215638.95
+ 132 -1482.52 -1124.30 -400.00 -3006.82 214114.65
+ 133 -1472.04 -1134.78 -400.00 -3006.82 212579.87
+ 134 -1461.49 -1145.33 -400.00 -3006.82 211034.54
+ 135 -1450.86 -1155.96 -400.00 -3006.82 209478.58
+ 136 -1440.17 -1166.65 -400.00 -3006.82 207911.93
+ 137 -1429.39 -1177.43 -400.00 -3006.82 206334.50
+Summary for: 2010:
+ Interest Paid: -17847.68
+ Principal Paid: -18234.16
+ Year Ending Balance: 206334.50
+ Sum of Interest Paid: -271278.21
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 138 -1418.55 -1188.27 -400.00 -3006.82 204746.23
+ 139 -1407.63 -1199.19 -400.00 -3006.82 203147.04
+ 140 -1396.64 -1210.18 -400.00 -3006.82 201536.86
+ 141 -1385.57 -1221.25 -400.00 -3006.82 199915.61
+ 142 -1374.42 -1232.40 -400.00 -3006.82 198283.21
+ 143 -1363.20 -1243.62 -400.00 -3006.82 196639.59
+ 144 -1351.90 -1254.92 -400.00 -3006.82 194984.67
+ 145 -1340.52 -1266.30 -400.00 -3006.82 193318.37
+ 146 -1329.06 -1277.76 -400.00 -3006.82 191640.61
+ 147 -1317.53 -1289.29 -400.00 -3006.82 189951.32
+ 148 -1305.92 -1300.90 -400.00 -3006.82 188250.42
+ 149 -1294.22 -1312.60 -400.00 -3006.82 186537.82
+Summary for: 2011:
+ Interest Paid: -16285.16
+ Principal Paid: -19796.68
+ Year Ending Balance: 186537.82
+ Sum of Interest Paid: -287563.37
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 150 -1282.45 -1324.37 -400.00 -3006.82 184813.45
+ 151 -1270.59 -1336.23 -400.00 -3006.82 183077.22
+ 152 -1258.66 -1348.16 -400.00 -3006.82 181329.06
+ 153 -1246.64 -1360.18 -400.00 -3006.82 179568.88
+ 154 -1234.54 -1372.28 -400.00 -3006.82 177796.60
+ 155 -1222.35 -1384.47 -400.00 -3006.82 176012.13
+ 156 -1210.08 -1396.74 -400.00 -3006.82 174215.39
+ 157 -1197.73 -1409.09 -400.00 -3006.82 172406.30
+ 158 -1185.29 -1421.53 -400.00 -3006.82 170584.77
+ 159 -1172.77 -1434.05 -400.00 -3006.82 168750.72
+ 160 -1160.16 -1446.66 -400.00 -3006.82 166904.06
+ 161 -1147.47 -1459.35 -400.00 -3006.82 165044.71
+Summary for: 2012:
+ Interest Paid: -14588.73
+ Principal Paid: -21493.11
+ Year Ending Balance: 165044.71
+ Sum of Interest Paid: -302152.10
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 162 -1134.68 -1472.14 -400.00 -3006.82 163172.57
+ 163 -1121.81 -1485.01 -400.00 -3006.82 161287.56
+ 164 -1108.85 -1497.97 -400.00 -3006.82 159389.59
+ 165 -1095.80 -1511.02 -400.00 -3006.82 157478.57
+ 166 -1082.67 -1524.15 -400.00 -3006.82 155554.42
+ 167 -1069.44 -1537.38 -400.00 -3006.82 153617.04
+ 168 -1056.12 -1550.70 -400.00 -3006.82 151666.34
+ 169 -1042.71 -1564.11 -400.00 -3006.82 149702.23
+ 170 -1029.20 -1577.62 -400.00 -3006.82 147724.61
+ 171 -1015.61 -1591.21 -400.00 -3006.82 145733.40
+ 172 -1001.92 -1604.90 -400.00 -3006.82 143728.50
+ 173 -988.13 -1618.69 -400.00 -3006.82 141709.81
+Summary for: 2013:
+ Interest Paid: -12746.94
+ Principal Paid: -23334.90
+ Year Ending Balance: 141709.81
+ Sum of Interest Paid: -314899.04
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 174 -974.25 -1632.57 -400.00 -3006.82 139677.24
+ 175 -960.28 -1646.54 -400.00 -3006.82 137630.70
+ 176 -946.21 -1660.61 -400.00 -3006.82 135570.09
+ 177 -932.04 -1674.78 -400.00 -3006.82 133495.31
+ 178 -917.78 -1689.04 -400.00 -3006.82 131406.27
+ 179 -903.42 -1703.40 -400.00 -3006.82 129302.87
+ 180 -888.96 -1717.86 -400.00 -3006.82 127185.01
+ 181 -874.40 -1732.42 -400.00 -3006.82 125052.59
+ 182 -859.74 -1747.08 -400.00 -3006.82 122905.51
+ 183 -844.98 -1761.84 -400.00 -3006.82 120743.67
+ 184 -830.11 -1776.71 -400.00 -3006.82 118566.96
+ 185 -815.15 -1791.67 -400.00 -3006.82 116375.29
+Summary for: 2014:
+ Interest Paid: -10747.32
+ Principal Paid: -25334.52
+ Year Ending Balance: 116375.29
+ Sum of Interest Paid: -325646.36
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 186 -800.08 -1806.74 -400.00 -3006.82 114168.55
+ 187 -784.91 -1821.91 -400.00 -3006.82 111946.64
+ 188 -769.63 -1837.19 -400.00 -3006.82 109709.45
+ 189 -754.25 -1852.57 -400.00 -3006.82 107456.88
+ 190 -738.77 -1868.05 -400.00 -3006.82 105188.83
+ 191 -723.17 -1883.65 -400.00 -3006.82 102905.18
+ 192 -707.47 -1899.35 -400.00 -3006.82 100605.83
+ 193 -691.67 -1915.15 -400.00 -3006.82 98290.68
+ 194 -675.75 -1931.07 -400.00 -3006.82 95959.61
+ 195 -659.72 -1947.10 -400.00 -3006.82 93612.51
+ 196 -643.59 -1963.23 -400.00 -3006.82 91249.28
+ 197 -627.34 -1979.48 -400.00 -3006.82 88869.80
+Summary for: 2015:
+ Interest Paid: -8576.35
+ Principal Paid: -27505.49
+ Year Ending Balance: 88869.80
+ Sum of Interest Paid: -334222.71
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 198 -610.98 -1995.84 -400.00 -3006.82 86473.96
+ 199 -594.51 -2012.31 -400.00 -3006.82 84061.65
+ 200 -577.92 -2028.90 -400.00 -3006.82 81632.75
+ 201 -561.23 -2045.59 -400.00 -3006.82 79187.16
+ 202 -544.41 -2062.41 -400.00 -3006.82 76724.75
+ 203 -527.48 -2079.34 -400.00 -3006.82 74245.41
+ 204 -510.44 -2096.38 -400.00 -3006.82 71749.03
+ 205 -493.27 -2113.55 -400.00 -3006.82 69235.48
+ 206 -475.99 -2130.83 -400.00 -3006.82 66704.65
+ 207 -458.59 -2148.23 -400.00 -3006.82 64156.42
+ 208 -441.08 -2165.74 -400.00 -3006.82 61590.68
+ 209 -423.44 -2183.38 -400.00 -3006.82 59007.30
+Summary for: 2016:
+ Interest Paid: -6219.34
+ Principal Paid: -29862.50
+ Year Ending Balance: 59007.30
+ Sum of Interest Paid: -340442.05
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 210 -405.68 -2201.14 -400.00 -3006.82 56406.16
+ 211 -387.79 -2219.03 -400.00 -3006.82 53787.13
+ 212 -369.79 -2237.03 -400.00 -3006.82 51150.10
+ 213 -351.66 -2255.16 -400.00 -3006.82 48494.94
+ 214 -333.40 -2273.42 -400.00 -3006.82 45821.52
+ 215 -315.02 -2291.80 -400.00 -3006.82 43129.72
+ 216 -296.52 -2310.30 -400.00 -3006.82 40419.42
+ 217 -277.88 -2328.94 -400.00 -3006.82 37690.48
+ 218 -259.12 -2347.70 -400.00 -3006.82 34942.78
+ 219 -240.23 -2366.59 -400.00 -3006.82 32176.19
+ 220 -221.21 -2385.61 -400.00 -3006.82 29390.58
+ 221 -202.06 -2404.76 -400.00 -3006.82 26585.82
+Summary for: 2017:
+ Interest Paid: -3660.36
+ Principal Paid: -32421.48
+ Year Ending Balance: 26585.82
+ Sum of Interest Paid: -344102.41
+Pmt * Interest Principal Prepay Total Pmt Balance
+ 222 -182.78 -2424.04 -400.00 -3006.82 23761.78
+ 223 -163.36 -2443.46 -400.00 -3006.82 20918.32
+ 224 -143.81 -2463.01 -400.00 -3006.82 18055.31
+ 225 -124.13 -2482.69 -400.00 -3006.82 15172.62
+ 226 -104.31 -2502.51 -400.00 -3006.82 12270.11
+ 227 -84.36 -2522.46 -400.00 -3006.82 9347.65
+ 228 -64.27 -2542.55 -400.00 -3006.82 6405.10
+ 229 -44.04 -2562.78 -400.00 -3006.82 3442.32
+ 230 -23.67 -2583.15 -400.00 -3006.82 459.17
+ 231 -3.16 -459.17 0.00 -462.33 0.00
+Summary for: 2018:
+ Interest Paid: -937.89
+ Principal Paid: -26585.82
+ Year Ending Balance: 0.00
+ Sum of Interest Paid: -345040.30
+
+Total Interest: -345040.30
Modified: gnucash/trunk/src/app-utils/gncmod-app-utils.c
===================================================================
--- gnucash/trunk/src/app-utils/gncmod-app-utils.c 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/app-utils/gncmod-app-utils.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -66,12 +66,6 @@
return FALSE;
}
- /* load the calculation module (we depend on it) */
- if (!gnc_module_load("gnucash/calculation", 0))
- {
- return FALSE;
- }
-
scm_init_sw_app_utils_module();
/* publish swig bindings */
/* load the scheme code */
Modified: gnucash/trunk/src/app-utils/test/Makefile.am
===================================================================
--- gnucash/trunk/src/app-utils/test/Makefile.am 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/app-utils/test/Makefile.am 2012-03-11 22:05:22 UTC (rev 22075)
@@ -13,7 +13,6 @@
test-print-parse-amount.c
GNC_TEST_DEPS = --gnc-module-dir ${top_builddir}/src/engine \
- --gnc-module-dir ${top_builddir}/src/calculation \
--gnc-module-dir ${top_builddir}/src/app-utils \
--guile-load-dir ${top_builddir}/src/core-utils \
--guile-load-dir ${top_builddir}/src/gnc-module \
@@ -26,7 +25,6 @@
--library-dir ${top_builddir}/src/engine \
--library-dir ${top_builddir}/src/backend/xml \
--library-dir ${top_builddir}/src/backend/sql \
- --library-dir ${top_builddir}/src/calculation \
--library-dir ${top_builddir}/src/app-utils
TESTS_ENVIRONMENT = \
Deleted: gnucash/trunk/src/calculation/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/calculation/CMakeLists.txt 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/CMakeLists.txt 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,32 +0,0 @@
-# CMakeLists.txt for src/calculation
-
-INCLUDE_DIRECTORIES (${GLIB2_INCLUDE_DIRS})
-INCLUDE_DIRECTORIES (${LIBINTL_INCLUDE_PATH})
-INCLUDE_DIRECTORIES (${REGEX_INCLUDE_PATH})
-INCLUDE_DIRECTORIES (${GUILE_INCLUDE_DIRS})
-INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src ) # for config.h
-INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src ) # for gnc-ui.h
-INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/libqof/qof) # for qof.h
-INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/lib/libc) # for pow.h
-INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/gnc-module) # for gnc-module.h
-
-SET (calculation_SOURCES
- expression_parser.c
- fin.c
- gncmod-calculation.c
-)
-
-# Add dependency on config.h
-SET_SOURCE_FILES_PROPERTIES (${calculation_SOURCES} PROPERTIES OBJECT_DEPENDS ${CONFIG_H})
-
-SET (calculation_HEADERS
- finvar.h
- finproto.h
- fin_spl_protos.h
- fin_static_proto.h
-)
-
-ADD_LIBRARY (calculation
- ${calculation_SOURCES}
- ${calculation_HEADERS}
- )
Deleted: gnucash/trunk/src/calculation/Makefile.am
===================================================================
--- gnucash/trunk/src/calculation/Makefile.am 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/Makefile.am 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,38 +0,0 @@
-SUBDIRS = . test
-
-pkglib_LTLIBRARIES = libgncmod-calculation.la
-
-libgncmod_calculation_la_LDFLAGS = -avoid-version
-
-libgncmod_calculation_la_LIBADD = \
- ${top_builddir}/src/libqof/qof/libgnc-qof.la \
- ${GLIB_LIBS} \
- ${GUILE_LIBS}
-
-libgncmod_calculation_la_SOURCES = \
- expression_parser.c \
- fin.c \
- gncmod-calculation.c
-
-noinst_HEADERS = \
- finvar.h \
- finproto.h \
- fin_spl_protos.h \
- fin_static_proto.h
-
-EXTRA_DIST = \
- README \
- amort_opt.c \
- amort_prt.c \
- fin-interactive.c \
- fin-main.c \
- numeric_ops.c \
- numeric_ops.h
-
-AM_CPPFLAGS = \
- -I${top_srcdir}/lib/libc \
- -I${top_srcdir}/src \
- -I${top_srcdir}/src/gnc-module \
- -I${top_srcdir}/src/libqof/qof \
- ${GUILE_INCS} \
- ${GLIB_CFLAGS}
Deleted: gnucash/trunk/src/calculation/Makefile.calc
===================================================================
--- gnucash/trunk/src/calculation/Makefile.calc 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/Makefile.calc 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,49 +0,0 @@
-# qtgrep makefile
-# created by Terry Boldt 3-16-2000
-#
-
-GLIB_CFLAGS = `glib-config --cflags`
-CFLAGS = -O3 $(GLIB_CFLAGS)
-#CFLAGS = -g
-
-CC = gcc
-
-all: financial fini
-
-HDRS = finproto.h \
- fin_static_proto.h\
- fin_spl_protos.h\
- finvar.h
-
-OBJSM = fin.o\
- amort_prt.o\
- fin-main.o
-
-OBJSI = fin.o \
- expression_parser.o\
- numeric_ops.o\
- amort_prt.o\
- amort_opt.o\
- fin-interactive.o
-
-financial: $(OBJSM)
- @echo "linking"
- $(CC) `glib-config --libs` -o $@ $(OBJSM)
-
-fini: $(OBJSI)
- @echo "linking"
- $(CC) `glib-config --libs` -o $@ $(OBJSI)
-
-fin.o: fin.c $(HDRS)
-
-expression_parser.o: expression_parser.c $(HDRS)
-
-fin-interactive.o: fin-interactive.c $(HDRS)
-
-fin-main.o: fin-main.c $(HDRS)
-
-numeric_ops.o: numeric_ops.c $(HDRS)
-
-amort_prt.o: amort_prt.c $(HDRS)
-
-amort_opt.o: amort_opt.c $(HDRS)
Deleted: gnucash/trunk/src/calculation/README
===================================================================
--- gnucash/trunk/src/calculation/README 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/README 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,989 +0,0 @@
-Dave - the attached file contains the following files:
-
-drwx------ 4096 Jul 4 16:20 ./
-drwxr-xr-x 4096 Jun 19 17:20 ../
--rw-r--r-- 211 Jun 23 20:24 .kdbgrc.financial #kdebug file
--rw-r--r-- 259 Jul 4 15:24 .kdbgrc.fini #kdebug file
--rw-r--r-- 732 Jul 4 15:24 Makefile
--rw-r--r-- 5711 Jul 3 20:02 amort_opt.c # display/set amortization options
--rw-r--r-- 4392 Jul 4 15:25 amort_opt.o
--rw-r--r-- 13020 Jul 4 16:16 amort_prt.c # print amortization schedule(s)
--rw-r--r-- 7256 Jul 4 16:16 amort_prt.o
--rw-r--r-- 14778 Jul 3 20:09 expression_parser.c # expression parser/evaluator
--rw-r--r-- 5148 Jul 4 15:24 expression_parser.o
--rw-r--r-- 19225 Jul 3 20:03 fin-interactive.c # demo
--rw-r--r-- 12964 Jul 4 15:25 fin-interactive.o
--rw-r--r-- 6102 Jul 4 16:01 fin-main.c # fixed examples
--rw-r--r-- 5008 Jul 4 16:02 fin-main.o
--rwxr-xr-x 1431 Jul 2 19:21 fin-proto.sh* # shell script for making 'h' files
--rw-r--r-- 83854 Jul 4 16:34 fin.c # financial and amortization functions
--rw-r--r-- 23880 Jul 4 16:16 fin.o
--rw-r--r-- 1063 Jun 28 16:28 fin_spl_protos.h # function prototypes
--rw-r--r-- 4631 Jul 3 20:07 fin_static_proto.h # function prototypes
--rwxr-xr-x 41011 Jul 4 16:16 financial* # executable demo - from fin-main.c
--rwxr-xr-x 54720 Jul 4 16:16 fini* # executable demo - from fin-interactive.c
--rw-r--r-- 90 Jun 22 20:37 fini-input
--rw-r--r-- 2624 Jun 22 20:24 fini-output
--rw-r--r-- 7407 Jul 3 20:07 finproto.h # function prototypes
--rw-r--r-- 8152 Jul 4 15:23 finvar.h # define global structures used
-drwx------ 4096 Jun 27 20:24 html/ # html documentation
--rw-r--r-- 6938 Jul 3 20:04 numeric_ops.c # numeric functions - for expression parser
--rw-r--r-- 2204 Jul 4 15:24 numeric_ops.o
--rw-r--r-- 11814 Jun 20 19:58 readme # this file
--rw-r--r-- 131016 Jul 4 16:20 sample # output of financial executable
-
-financial-equations/html:
-total 164
-drwx------ 4096 Jun 27 20:24 ./
-drwx------ 4096 Jul 4 16:20 ../
--rw-r--r-- 17430 Jun 20 15:29 amorta.html # amortization schedule
--rw-r--r-- 26222 Jun 20 15:29 amortp.html # amortization schedule
--rw-r--r-- 2361 Jun 27 20:38 constderv.html # equations derivation
--rw-r--r-- 11290 Jun 27 20:25 finderv.html # equations derivation
--rw-r--r-- 82204 Jun 27 20:36 finutil.html # basic use of financial calculator
-
-This 'readme' file is probably somewhat rambling - it is coming off
-the top of my head with very little organization. Note also that much
-of the following "explanation" has been duplicated as comments at the
-top of the "fin.c" and the "expression-parser.c" files. Thus, anyone
-desiring to use the functions contained therein will have some ready
-documentation.
-
-Look into the 'sample' file. It contains sample output from the
-routines - both from the calculator and the amortization routines. The
-sample file was created with the "financial" executable. If running
-Linux, you should be able to execute this program without compiling to
-recreate 'sample' as "./financial >sample"
-
-You may want to view the file "finutil.html" in a browser - it
-explains in detail the calculator functions and variables and concepts
-and amortization schedule options.
-
-The file 'finvar.h' contains the structures needed by functions
-calling the financial functions and amortization functions and the
-expression parser/evaluator and should be included by any file calling
-any financial function and and the amortization functions. The two
-prototype files:
-
-finproto.h
-fin_spl_protos.h
-
-should be "included" by any files containing functions which call
-either the financial calculator functions (including the amortization
-functions) or the expression parser/evaluator.
-
-There are no "global variables". My first iteration on "porting"
-the calculator contained global variables for the basic financial
-variables. I decided against doing this for reasons of conflict with
-other variables used in other modules and also to insure that ANY
-module in gnucash could call the financial functions and have their
-own set of financial variables. Thus any gnucash module may use the
-financial functions without concern of interaction with any other
-module also using the functions concurrently.
-
-There are 9 "financial variables". Of the nine, four are ALWAYS set by
-the "user", i.e., calling function. Of the remaining five, four are
-set and the fifth computed by the appropriate financial calculator
-function listed below. The 9 "financial variables" are: (if more than
-one name is used for a particular financial variable, all are listed)
-
-n or npp == number of payment periods in the transaction under
- consideration
-
-i, nint or ir == nominal interest rate for the transaction.
- Use the interest rate as used by humans,
- i.e., 9.5, 8.25, etc. and not 0.095, 0.0825
-
-pv == present value, i.e., the value of the transaction at the
- present moment in time. This would be the amount of the
- loan/mortgage/Certificate of Deposit/bank account/etc.
-
-pmt == periodic payment
-
-fv == future value, i.e., the value of the transaction at some
- future time after n payment periods.
-
-Of the five values above, four are set by the "user" and the fifth
-computed. The remaining financial variables are:
-
-CF == Compounding Frequency, number of compounding periods in one year
-PF == Payment Frequency, number of payment periods in one year
-disc == TRUE, 1, for discrete compounding (used by most financial
- institutions in US)
- FALSE, 0, for continuous compounding (used by some banks
- in my area for CDs)
-bep == TRUE for beginning of periods payments
- FALSE for end of period payments (the norm in the US at least)
-
-The function 'set_default(fi_ptr fi)' will set the variables in the
-'fi' structure to the default values:
-
-n == 0
-i = 0.0
-pv = 0.0
-pmt = 0.0
-fv = 0.0
-CF = 12
-PF = 12
-disc = 1
-bep = 0
-
-(Maybe this could/should be made locale specific or configurable ??? )
-
-In addition, there is one other "financial variable" which is not
-really a financial variable, but which should be specific to any
-particular financial computation and under the control of the user:
-
-prec == numeric precesion used for round-off of numeric values, i.e.,
- number of digits past the radix point.
-
-I currently have a static function defined in the "fin.c" file:
-
-static double rnd(
- double x,
- unsigned places)
-{
- double r;
- unsigned char buf[50]; /* make buffer large enough */
-
- if ( places >= 0 ) {
- sprintf(buf,"%.*f",places,x);
- sscanf(buf,"%lf",&r);
- } else r = x;
-
- return r;
-} /* rnd */
-
-The function returns x rounded to the specified number of decimal
-digits past the radix point. I assume that gnucash currently has such
-a function. I will need the name of this function, since it is used
-extensively in the financial computation and the computation of
-amortization schedules. The function 'rnd' that I have included is
-pretty simple - it simply writes the double value to a string using
-'sprintf' to print the value and round the value. It then uses
-'sscanf' to read the value into a temporary double variable and
-returns that value. I have written many rounding functions in the past
-and could never find one that everybody agreed with. Not every one
-agrees with the rounding rules used by the C 'printf' functions, but
-at least everybody writing C and C++ uses them and is used to them.
-
-The financial functions use a structure (defined in 'finvar.h'):
-
-/* structure used by financial computation routines to store
- * financial variables */
-typedef struct financial_info *fi_ptr;
-typedef struct financial_info {
- double ir; /* interest rate */
- double pv; /* present value */
- double pmt; /* periodic payment */
- double fv; /* future value */
-
- unsigned npp; /* number of payment periods */
- unsigned CF; /* Compounding frequency */
- unsigned PF; /* payment frequency */
- unsigned bep; /* beginning/end of period payment flag */
- /* TRUE == beginning of period */
- /* FALSE == end of period */
- unsigned disc; /* discrete/continuous compounding flag */
- /* TRUE == discrete compounding */
- /* FALSE == continuous compounding */
-
- /* precision of roundoff for pv, pmt and fv.
- * i, Interest not rounded
- * n, number of periods rounded to integer value,
- * implicit value of zero, 0
- *
- * 2 for US Dollars
- */
- unsigned prec;
-} financial_info;
-
-to contain all information used in the financial calculations. The
-structure is created by the calling function and the variables set by
-the calling function. The appropriate financial function is called to
-compute the desired quantity with a pointer to the structure.
-
-
-The following functions are contained in the financial calculator:
-
-unsigned N(fi_ptr fi) -- solves for number of payment periods rounded to an
- integer value. Sets the variable 'npp' in the passed
- structure and returns the same value.
-
-double I(fi_ptr fi) -- solves for the nominal interest rate rounded to
- the precision specified in the structure passed.
- Sets the variable 'ir' in the passed structure
- and returns the same value.
-
-double PV(fi_ptr fi) -- solves for the present value rounded to the precision
- specified. Sets the variable 'pv' in the passed
- structure and returns the same value.
-
-double PMT(fi_ptr fi) -- solves for the periodic payment rounded to the
- precision specified. Sets the variable 'pmt' in
- the passed structure and returns the same value.
-
-double FV(fi_ptr fi) -- solves for the future value rounded to the precision
- specified. Sets the variable 'fv' in the passed
- structure and returns the same value.
-
-The above functions use the following functions for the calculation
-and round the answer as indicated. The above functions are the
-"normal" functions called to calculate the corresponding values. I
-left the following functions as "global" in case there is a need for
-unrounded, full floating point accuracy answers. They could be
-converted to "static" functions if there is any conflict or the full
-accuracy is not needed elsewhere in gnucash. Also these function do
-not use the financial calculator structure, but rather the variables
-must be passed as arguments with the desired value returned.
-
-double _N(ir,pv,pmt,fv,CF,PF,disc,bep) - compute number of payment periods
- and return value
-
-double _I(npp,pv,pmt,fv,CF,PF,disc,bep) - compute nominal interest rate and
- return value
-
-double _PV(npp,ir,pmt,fv,CF,PF,disc,bep) - compute present value and return
- value
-
-double _PMT(npp,ir,pv,fv,CF,PF,disc,bep) - compute periodic payment and
- return value
-
-double _FV(npp,ir,pv,pmt,CF,PF,disc,bep) - compute future value and return
- value
-
-Note, the return value of '_N' should always be rounded (or truncated,
-probably rounded) since a fractional payment period is a practical
-impossibility.
-
-The financial calculator functions do no "value checking". That is,
-there is no checking for erroneous values or any "reasonable value
-testing". The only values that absolutely have to be checked by the
-calling functions are:
-
-1: nominal interest rate when calculating one of the other variables.
- If this value is zero a "divide by zero" error may occur. If the
- divide by zero error does not occur, then the value calculated
- will more than likely be returned as 'nan'. Always check this value
- for non-zero if it is not the value to be computed. A non-zero value
- is only common sense also, since a zero interest rate is probably
- meaningless.
-
-2: number of payment periods. When calculating the nominal interest rate,
- if the number of payment periods is zero, again a "divide by zero" error
- may occur. Always check this value for non-zero if it is not the value to
- be computed. Again, a zero number of payment periods is meaningless.
- At least one payment must be made or one party to the transaction is
- making a free gift to the other party - in which case the calculator
- is not needed.
-
-Note: I have violated both of these rules in the two demo executables
-provided. For the 'financial' executable, such a check is not
-necessary since all of the examples are set statically and it is known
-that neither interest or number of periods is zero. For the 'fini'
-executable, they should be checked, but for demo purposes I didn't
-think it necessary.
-
-A good user interface would check that the values of CF, PF, disc and
-bep are set (at least to the default values) and that at least 4 of
-the remaining variables have been set and the user asked for the fifth
-value to be computed. Leaving the value of 'fv' to zero would be the
-normal in most cases.
-
-I decided that the financial functions should do no value checking,
-since they are far enough down the call chain that returning in the
-case of erroneous values is problamatic and adds excessive structure
-to otherwise extremely simple functions. Also since the value checking
-that does need to be accomplished is minimal and should optimally be
-done as close to the user interface as possible.
-
-
-My first take on a possible user interface would look something like
-(or as close as I can get in an ASCII text file):
-
-NOTE: ==xxxxxxxxx== means a GUI box for displaying/entering a value
-
- ((compute)) means a GUI button with the title "compute"
-
- <<Monthly>> means a GUI box with dropdown values that the user selects
- there is a name for such a box in GUI nomenclature,
- but I forget the name
-
- || means a GUI check box button (either on or off).
- The Title for the button would change to reflect
- the on/off, TRUE/FALSE value
-
- |**********| means a single line text box that the user could
- use to enter a string. This box could be used by
- the user to enter expressions, with named variables,
- to be evaluated. This box is probably he same kind
- of GUI box as I have indicated above with == xxxx==
-
-Possible Financial Calculator GUI:
-|-------------------------------------------------------------------------|
-
- Number of
- Payment Periods ((Compute))
- ==xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==
-
- Interest Rate ((Compute))
- ==xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==
-
- Present Value ((Compute))
- ==xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==
-
- Periodic Payment ((Compute))
- ==xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==
-
- Future Value ((Compute))
- ==xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==
-
-
- Compounding Payment || End of Period Payments
- Frequency Frequency
- <<Monthly>> <<Monthly>> || Discrete Compounding
-
- Expression
- |************************************************************|
-
- User Defined Variables
- Some kind of GUI box displaying both the names and values of
- variables that the user has defined using the expression box
- above or the financial variables entry boxes. The variables
- are used to store values for future use/reference
-
-
- Effective Date: ==mm/dd/yyyy==
- Initial Payment date: ==mm/dd/yyyy==
-|------------------------------------------------------------------------|
-
-Note: the drop down boxes for Compounding Frequency and Payment
-Frequency should contain the following selectable values:
-
- annual 1
- semi-annual 2
- tri-annual 3
- quarterly 4
- bi-monthly 6
- monthly 12
- semi-monthly 24
- bi-weekly 26
- weekly 52
- daily (360) 360
- daily (365) 365
-
-with the corresponding values used for CF and PF as indicated.
-
-Clicking on "Discrete Compounding" switches back and forth between
-"Discrete Compounding" and "Continuous Compounding". "Discrete
-Compounding" should be the default since it is by far the most common.
-
-Clicking on "End of Period Payments" switches back and forth between
-"End of Period Payments" and "Beginning of Period Payments". "End of
-Period Payments" should probably be the default since it is by far the
-most common.
-
-The user could click on the entry box under "Number of Payment
-Periods", "Interest rate", "Present Value", "Periodic Payment"
-and "Future Value" and enter a value or expression string to be
-evaluated. Clicking on the corresponding "Compute" button would
-compute that financial variable. I have made the entry boxes long so
-that a user could enter a fairly long string. The boxes could also be
-made scrollable. The entry function could be made simple and always
-regard the entry as a string and pass the string to the
-parser/evaluator to return the appropriate value.
-
-The titles for the boxes, especially "Present Value" and "Future
-Value", may need to be changed depending on the feedback from the
-gnucash community. I have always used those names since they are
-"generic" and represent all of the possible uses for the financial
-calculator. In this way a single calculator GUI could be used instead
-of inventing a GUI for mortgages, another for CDs, another for saving
-accounts, another for annuities, another for sinking funds, etc.
-
-The next question is the Amortization Schedule Interface. This
-interface should not be available until all of the financial variables
-are known. Once they are, the user should be able to click on a "tab"
-or something to get the Amortization Schedule Interface. A first stab
-at such an interface could be as shown below. Once the financial
-variables are known - either all entered by the user or one computed
-as indicated by the user, the function "Amortization_init" would be
-called to compute the quatities needed for the user to choose which
-amortization schedule is desired. The function "amort_opt" in the
-file amort_opt.c contains all of the information that the user must
-have to decide which of the six schedules is desired.
-
-Note that the function "Amortization_init" needs two dates:
- Effective Date of Transaction -- the date the papers were signed, etc.
- Initial Payment Date -- self explanatory
-
-Both dates could be initially filled in by the interface with default
-values. For the Effective Date, the current date would probably be the
-most likely candidate. The default Initial Payment Date would depend
-on whether the payments were being made at the beginning or end of the
-payment periods, i.e., bep in the financial information structure
-above.
-
- bep == TRUE, use the first day of the next month for the default
- Initial Payment Date, e.g., if current day is August 6, 2000,
- then the default Initial Payment Date would be September 1, 2000
- bep == FALSE, use if the first day of the month after the next month,
- e.g., if current day is August 6, 2000, then the default Initial
- Payment Date would be October 1, 2000
-
-The user could then change or accept the default dates as desired.
-
-The only real checking that would need to be done on either date is to
-insure that the Effective Date preceeds the Initial Payment Date.
-
-
-The following functions are used for amortization schedules. All
-functions use the amortization structure defined in "finvar.h",
-"amort_sched".
-
-Notice that some of the information is duplication of the infomation
-used by the financial calculator structure. I thought this best in
-order to "separate" these two functions so that if a new set of
-financial variables is desired by the user, the old set used by the
-amortization computation functions would still be available. The
-amount of storage is minimal.
-
-Note that the amortization schedule structure, "amort_sched" is
-divided into three parts.
-
-The first part is information set by the calling function(s) and is
-the financial information from the financial information structure
-supplemented with the Effective Date and Initial Payment Date
-information.
-
-The second part is also set by the calling function(s) and sets which
-schedule and type of schedule is computed.
-
-The third part is information set by the amortization functions. Some
-of the information is needed for the GUI below for selecting which
-amortization option to compute.
-
-
-Amortization Schedule Selection GUI:
-|----------------------------------------------------------------------------|
- Amortization Schedule
-
- Effective Date: mm/dd/yyyy
- Initial Payment date: mm/dd/yyyy
-
- The Original Present Value is: xxxxxx.xx (pv)
- The Original Periodic Payment is: xxxx.xx (pmt)
- The Original Future Value is: xxxx.xx (fv)
-
- The Delayed Present Value is: xxxxxx.xx (pve)
- The New Periodic Payment is: xxxx.xx (new_pmt)
-
- The amortization options are:
-
- || Amortize with Original Present Value
- Constant Payment to Principal: xxxxx.xx (cmpt1)
- and final payment: xxxxx.xx (final_pmt_opt_1)
-
- || Amortize with Delayed Present Value
- Constant Payment to Principal: xxxxx.xx (cmpt2)
- and final payment: xxxxx.xx (final_pmt_opt_2)
-
- || Amortize with Original Transaction Values
- and final payment: xxxxx.xx (final_pmt_opt_3)
-
- || Amortize with Delayed Present Value, Original Periodic Payment
- and final payment: xxxxx.xx (final_pmt_opt_4)
-
- || Amortize with Delayed Present Value, New Periodic Payment
- and final payment: xxxxx.xx (final_pmt_opt_5)
-
- || Amortize with Original Present Value, Original Periodic Payment
- new number of total payments: xxx (new_n)
- and final payment: xxxxx.xx (final_pmt_opt_6)
-
-|----------------------------------------------------------------------------|
-
-Note: I have included in parenthesis above the names of the variables
-in the amortization structure, amort_sched, to be used in filling in
-the appropriate values. Do not include the parenthesized infomation in
-the GUI.
-
-Note: the last option is available ONLY IF the variable "new_n" in the
-amortization schedule structure is non-zero. If "new_n" is zero, the
-last option could be "faded out" or left out completely.
-
-Note that the options are mutually exclusive, picking one turns the
-others off. Initially all should probably be off, thus forcing the
-user to pick one.
-
-Option 3 above is probably the one most likely to be selected by most
-people. The others are more likely to be choosen as comparisons to
-what is likely to be dictated by their lending institution which would
-more than likely be option 3 (at least in the US).
-
-I have laid out the above options to correspond to the values for the
-variable "option" in the "amort_sched" structure. Any other sequence
-could be used so long as the proper numbering is maintained for
-"option".
-
-Once a particular option, 1 to 6 inclusive, has been choosen above by
-the user, they have one more choice to make: namely whether they want
-an annual summary or a schedule of each payment. Also if "option" is
-3, 4, 5 or 6 they also have the additional choices of whether they
-want a fixed prepayment to principal or a variable prepayment to
-principal schedule. If they choose a fixed prepayment schedule, then
-they must enter the amount of the fixed prepayment. It's not as
-complicated as it sounds. The dialog for these choices could look
-something like:
-
-|----------------------------------------------------------------------------|
-
- Type of Amortization Schedule
-
- || Annual Summary
-
- || Per Payment Schedule
-
- || Variable Prepayment to Principal
-
- || Fixed Prepayment to Principal Schedule
- ==xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==
-
-|----------------------------------------------------------------------------|
-
-Note that zero for the fixed prepayment is valid. The value entered
-(or not entered as the case may be) should be set into the variable,
-"fixed_pmt" in the amortization schedule structure. If a value for the
-fixed prepayment is entered by the user, this value should probably be
-set into "fixed_pmt", irregardless of whether the user selects the
-fixed prepayment option.
-
-Note that the options are mutually exclusive, picking one turns the
-others off. Initially all should probably be off, thus forcing the
-user to pick one.
-
-The last two options would only be available if they had selected
-options 3, 4, 5 or 6 from the amortization options dialog. The
-information from this dialog would be used to set the variable
-"summary" in the "amort_sched" structure. The permissable values are:
-
- 'y' -- indicates an annual summary schedule, first option above
- 'p' -- indicates a per payment schedule, option 2 above
- 'a' -- indicates a variable prepayment schedule, option 3 above
- 'f' -- indicates a fixed prepayment schedule, option four above.
-
-I have provided a function, "amort_opt", in the file "amort_opt.c" to
-demonstrate which information is used to fill in the appropriate
-places in the above two GUIs. You can use this function as a guide.
-
-Once all of that information has been gathered from the user,
-the amortization schedule can be computed. The function
-"Amortization_Schedule" is called and does the computation, but not
-the display/output of the schedule. I orginally had the output of the
-schedule integrated in this function, but decided that was a dumb
-idea. Passing back a pointer in the "amort_sched" structure for
-all of the computed values was a better idea. This way the actual
-output/display of the schedule can be tailered as desired.
-
-I have provided the function "amort_prt" in the file "amort_prt.c" as
-a guide on how to use the structures and the information they contain
-to display/output the desired schedule. Currently, the function
-"prints" the information to a specified file. I could alter the
-function to output HTML tables if desired. The changes would not be
-very great. Also, a flag could be passed to indicate whether HTML or
-plain text was desired. Or the function could be completely rewritten
-to output some completely different format as desired.
-
-The functions used for the amortization schedule are:
-
-Amortization_init -- this functions initializes the information for
- the schedule so that the user can decide which
- schedule and which type is desired.
-
-Amortization_Schedule -- this function computes the desired
- amortization schedule.
-
-Amortization_free -- this function is called to free the dynamically
- allocated memory in the amortization schedule - it
- does not free the amortization schedule structure passed,
- but the schedule structures allocated by the call to
- "Amortization_Schedule" and pointed to in the union
- in the amortization schedule structure.
-
-amort_opt - a function to display the options to the user and input which
- schedule and which type is desired. Uses a text display - for
- guidance in designing the eventual GUI used.
-
-amort_prt - a function to print the desired schedule, again for guidance
- in how to use the information computed for each type of schedule.
-
-
-A typical sequence would be:
-
-1: use the financial calculator functions to enter/calculate the
- financial variables
-
-2: copy the financial information from the financial information
- structure to the amortization schedule structure
-
-3: call the "Amortization_init" function to initialize the amortization
- schedule
-
-4: obtain from the user, schedule option and type -- "amort_opt" function
- for command line version
-
-5: call the "Amortization_Schedule" function to compute the desired
- amortization schedule
-
-6: display/output the desired amortization schedule -- "amort_prt"
- function for the command line version
-
-7: call the "Amortization_free" function to free memory in computed schedule
-
-8: loop back to step 4 above for another schedule using same financial
- data and dates
-
-9: loop back to step 1 above for new financial data
-
-
-Right now the documentation is written around the use of the financial
-calculator in QTAwk, my personal implementation of a superset of awk,
-nawk and gawk. The document, especially the examples section, will
-have to be rewritten to a small extent for gnucash. I would like to
-defer this until we have settled on the GUI since that will determine
-the end document.
-
-The examples illustrate the general nature of the calculator and the
-many "seemingly" unrelated uses for it. I used CA Simply Money under
-OS/2 for many years. They had several "calculators". At first I
-thought that was great. Then I really looked at what they had - it was
-really just many different GUIs for the same calculator, The same
-calculator under different guises. I stopped using all of theirs very
-quickly and developed my own since having it all in one was much
-easier to understand. It also underscored the power of the finanacial
-functions in everyday life.
-
-<<<<<<<<<<------------------------------------------------------------>>>>>>>>
-
-The only thing left to describe is the expression parser/evaluator.
-The expression parser/evaluator is contained in the file
-"expression_parser.c".
-
-Before describing the parser per se, I want to describe the structures
-used to contain the results returned from the parser. The structure is
-defined in "finvar.h":
-
-typedef struct var_store *var_store_ptr;
-
-typedef struct var_store {
- unsigned char *variable_name; /* variable name if variable,
- NULL otherwise */
- unsigned char use_flag; /* flag if variable has been assigned to */
- unsigned char assign_flag; /* flag if variable is used */
- void *value; /* pointer to imp[lementation defined
- numeric value */
- var_store_ptr next_var; /* pointer to next variable in linked
- list */
-} var_store;
-
-The "use_flag" variable is for internal use of the parser and can be
-ignored by the user. The "variable_name" variable possibly points to
-a string containing the name of the value returned, a "variable
-name". If NULL, then this is a temporary value. The "value" variable
-points to a user defined structure containing the numeric value of the
-variable.
-
-In designing and writing the parser, I decided early on that the
-parser should be an "expression parser/evaluator" and that the actual
-arithmetic was the responsibility of the caller/user. In reading the
-debate on "gnucash-devel" and realizing that the exact numeric
-representation used in gnucash was very probably going to be changing
-in the future, I decided that the parser should be totally independent
-of the numeric representation used, and thus the exact details of how
-the arithmetic was performed. To accomplish this, four functions are
-supplied by the user/caller:
-
-1: trans_numeric - this function translates the text string into a
- numeric in the desired representation and returns a pointer to
- the representation as a (void *) this function has three parameters
- passed:
- 1: digit_str -- the actual text string of the numeric to be converted
- to the internal representation
- 2: radix_point -- the ASCII character used to represent the radix point
- 3: rstr -- a pointer to a location in which to return a pointer to the
- first character not part of the numeric string translated
- If this pointer is NULL, do not return a value. This parameter
- is the same as the second parameter of the standard C library
- functions "strtod" or "strtol"
-
-2: numeric_ops - this function does the actual arithmetic on two numeric
- quantities in internal representation. It has three
- parameters passed:
- 1: op_sym -- the numeric operation to be performed. The possible
- values are defined in "finvar.h" and are:
- ADD_OP - addition
- SUB_OP - subtraction
- DIV_OP - division
- MUL_OP - multiplication
- ASN_OP - assignment
- 2: left_value - the left hand operand of the binary operator
- 3: right_value - the right hand operand of the binary operator
- Note: left_value and right_value are passed as
- (void *). This function is responsible for casting
- to the proper type to use.
-
- Note: this function should make no assumptions about
- overwriting or re-using either left_value or
- right_value, except for ASN_OP. Both values passed
- must be left unchanged by any operation except ASN_OP.
- This function is also responsible for allocating/freeing
- memory as necessary to perform the designated function
- and returning the result.
-
- I STRONGLY suggest that the result be returned in
- dynamically allocated memory. If static memory is used,
- the parser has no means of copying the returned result
- or managing static memory to prevent overwriting
- the result and invalidating the result.
-
-3: negate_numeric - this function negates the value passed (as a (void *))
-
-4: free_numeric - this function is responsible for freeing memory used by
- the internal numeric representation.
-
-I have included the file "numeric_ops.c" containing the above
-functions for the usual "double" and "int" representation of
-numerics. The functions perform integer or floating point operations
-as appropriate for the string entered by the user. The division
-operation is done in "double" since I do not think that anybody really
-wants (9 / 2) to equal 4 instead of 4.5 for financial operations.
-These functions use the structure defined in finvar.h:
-
-typedef struct numeric *numeric_ptr;
-typedef struct numeric {
- unsigned char type; /* designates type of value */
- union {
- long int int_value; /* long integer value */
- double dbl_value; /* double value */
- } value;
-} numeric;
-
-to contain all numeric values. The variable "type" in this structure
-can have the values:
- INT_TYPE
- DBL_TYPE
-which are defined in "finvar.h".
-
-All "named variables", variables defined by the user for storing
-intermediate results for future reference/use, and temporary variables
-used by the parser use the variable storage structure, var_store,
-defined above. The result of parsing and evaluating the string passed
-are returned in a variable storage structure specified by the caller.
-
-If the returned variable value is not named, i.e., "variable_name ==
-NULL", then the user/caller is responsible for freeing the memory used
-by the internal representation of the numeric value. If, however,
-"variable_name != NULL", freeing the memory used by the internal
-numeric representation will cause a segmentation fault later, when
-parser attempts to free the memory through a call to
-the "free_numeric". In addition, freeing the memory will probably
-invalidate the numeric value contained therein and lead to pernicuous
-results when the value is used.
-
-If "variable_name != NULL", the user/caller should never attempt to
-free this memory, that is the sole responsibility of the parser.
-
-It may be that the calling function has certain "variables" that need
-to be "pre-defined" for the user to manipulate. The demo financial
-calculator "pre-defines" the financial variables, "n, i, pv, pmt, fv,
-CF, PF, disc and bep". I would suggest that the gnucash financial
-calculator also pre-define these for direct manipulation by the user
-if they so desire. Other modules of gnucash could pre-define other
-variables with common names used in accounting if they so desire. This
-would allow knowledgable users quick access to such values and to be
-able to easly manipulate the values to obtain desired results. One
-method of "pre-defining" variables is illustrated in the
-"fin-interactive.c" file for the demo interactive financial
-calculator. In essence the function "pre-defining" variables sets up
-a linked list of variable storage structures with the proper "names"
-and numeric values. The number of "pre-defined" variables and a
-pointer to the structure array is passed to the parser in the
-initialization call. After the parser is eventually exited, the
-calling function is responsible for freeing any memory used by the
-"pre-defined" variables and their final numeric representation.
-
-I think the use of "named variables" and "pre-defined" variables could
-become very useful in gnucash eventually as people get used to the
-idea. It may be useful to allow users to define variables with values
-convienent to them and that are persistent across invocations of
-gnucash.
-
-A second design goal of the parser was that it should be callable
-concurrently by multiple modules within gnucash independently. That
-each module should be capable of using differing "pre-defined"
-variables and user defined variables and even internal numeric
-representations. To that end the calling module must first initialize
-the parser with a call to "init_parser". This call creates the parser
-internal structure for subsequent calls to the parser proper. The
-structure created and returned must then be passed to subsequent calls
-to the parser. When no further calls to the parser are to be made,
-the module then calls "exit_parser" with the pointer returned by
-"init_parser", so that the parser may release dynamically allocated
-memory.
-
-The parser recognizes the following binary operators:
- +
- -
- /
- *
- =
- +=
- -=
- /=
- *=
-
-In addition, the unary operators
- +
- -
-
-are recognized. All numerics are initially recognized as positive
-numbers. If negative, the unary '-' operator is applied. This saves
-the logic of having to recogize strings as
-
- -123
-
-The logic recognizes "-" and "123" separately. The '-' unary operator
-is then applied to negate the numeric. This also has the advanatge
-that the same logic can be used for
-
- -123
- +123.45
- +uvar
- -uvar
-
-In each case, the appropriate unary operator is applied to obtain the
-desired result with no increase in the parsing logic. Thus keeping
-things as simple as possible.
-
-The parser also follows the C practice that the assignment operators
-return a value. Thus, allowing multiple assignments and assignment
-within expressions. The following expressions are all valid:
- nni = 123
- hnk = nni = 23.45
- jkl = 5 * (nj = 68.9)
-
-The first time variables are used in an expression, they are
-initialized to zero, 0. Thus, even if the following variables have not
-been assigned a value previously, the following expressions are valid:
-
-nni *= 123
- above results in zero in nni
-jk += 45.6
- above results in 45.6 in jk
-56.8 - tyh
- result of above is 56.8
-tgh - 45.7
- above the same as
--45.7
-
-After parsing the above expressions the variables nni, jk, tyh and tgh
-would all be defined.
-
-There are six functions needed to use the parser/evaluator:
-
-Note: in the last five functions, in the function paramter (parse_env_ptr pe),
-"pe" is the pointer returned by the "init_parser" function.
-
-parser_env_ptr
-init_parser(var_store_ptr predefined_vars,
- unsigned char radix_point,
- void *trans_numeric(unsigned char *digit_str,
- unsigned char radix_point,
- unsigned char **rstr),
- void *numeric_ops(unsigned char op_sym,
- void *left_value,
- void *right_value),
- void *negate_numeric(void *value),
- void free_numeric(void *numeric_value));
-
-This function is called by the gnucash module/function/whatever to
-initialize the parser. The parser returns a pointer to a structure
-that contains all relevant information for parsering strings. The
-pointer is returned as (void *) since all information is and should
-remain pertinent only to the parser. The calling function(s) should
-never rely on manipulating any information inside this structure
-directly, since it may and could change in the future.
-
- -- The first parameter is a pointer to an array of "pre-defined"
- variables the caller wishes to use with subsequent calls to
- the parser.
- -- The second parameter is the radix character to use in numeric
- strings in subsequent calls to the parser. The parser needs this
- information to recognize numeric strings of the form
- ".123", where '.' is the radix.
- -- The third, fourth, fifth, and sixth parameters are the functions
- I descibed above for the internal numeric representation desired
- by the calling function(s).
-
-void exit_parser(parser_env_ptr pe);
-
-This function is called to exit the parser and free all dynamically
-allocated memory used by the parser for an internal stack and user
-defined variables.
-
-unsigned get_parse_error(parser_env_ptr pe);
-
-Whenever the parser encounters an error in parsing/evaluating a
-string, it returns a NULL pointer instead of a valid pointer to a
-variable storage structure. This call returns an unsigned integer
-designating the error encountered. The possible values are defined in
-the "finvar.h" file. A function "parse_error" has been defined in the
-file "fin-interactive.c" illustrating how to use this function and
-pin-point for the user the exact location of the error.
-
-var_store_ptr get_vars(parser_env_ptr pe)
-
-This function returns a pointer to a linked list of variable storage
-structures containing the user defined named variables if any
-exist. NULL is returned if none exist. An illustration of using this
-function is contained in the "main" function in the
-"fin-interactive.c" file. The calling function should not alter the
-variable names. The numeric values may be altered if the calling
-function really knows what it is doing.
-
-unsigned delete_var(unsigned char *var_name,
- parse_env_ptr pe);
-
-This function will delete the user defined named variable with a name
-identical to the name string passed in the first parameter. If no user
-defined variable exists with an identical name, zero, 0, returned. If
-the delete operation is successful, one, 1, is returned.
-
-unsigned char *parse_string(var_store_ptr value,
- unsigned char *string,
- parser_env_ptr pe);
-
-This function parses the string passed in the second parameter and
-returns a pointer to the last character not recognized upon a parsing
-error. If no error occurred, NULL is returned. The first parameter
-specifies a variable storage structure to contain the result of the
-parser/evaluator.
-
-Note: The parser/evaluator uses a simple recursive descent parser.
-I decided on this type for the simple reason that for a simple four
-function calculator a recursive descent parser is, in my opnion, the
-easiest to construct. I also think that recursive descent parsers are
-easier for the human to understand and thus maintain. Since gnucash is
-open source and will probably have many maintainers in its history,
-the later point is probably the more relevant.
-
-Also, the parser uses a stack which is dynamically allocated in memory
-and can grow as needed. I have not provided any mechanism for
-shrinking the stack. The initial stack size is set at 50. I really do
-not anticipate that under normal and even most extreme cases, that it
-will ever approach that size in actual use. Under "normal" operation,
-the stack will probably never exceed 3 or 4 in size and 50 is probably
-an overkill for normal use. However, since the stack is pointers and
-not entire structures, a stack size of 50 is not that much memory and
-can be tolerated by most users. Thus, a mechanism for shrinking the
-stack will probably never be needed.
Deleted: gnucash/trunk/src/calculation/amort_opt.c
===================================================================
--- gnucash/trunk/src/calculation/amort_opt.c 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/amort_opt.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,151 +0,0 @@
-/***************************************************************************
- amort_opt.c - description
- -------------------
- begin : Thursday June 15 2000
- email : tboldt at attglobal.net
- Author : Terry D. Boldt
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-/*
- * Functions to determine amortizations options
- * 7-2-2000
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-#include "finvar.h"
-#include "finproto.h"
-#include "fin_spl_protos.h"
-
-amort_sched_ptr amort_opt(
- amort_sched_ptr amortsched,
- void *parse_env)
-{
- char buffer[200], *errp;
- unsigned long ii;
- unsigned prec = amortsched->prec;
- var_store value;
- numeric_ptr nval;
- struct tm *times_E,
- *times_I;
-
- /* print amortization options */
- times_E = (struct tm *)calloc(1, sizeof(struct tm));
- ii = amortsched->Eff_Date_jdn;
- times_E->tm_mday = amortsched->day_E;
- times_E->tm_mon = amortsched->month_E - 1;
- times_E->tm_year = amortsched->year_E - 1900;
- times_E->tm_wday = (ii + 1) % 7;
- times_E->tm_yday = amortsched->yday_E;
-
- times_I = (struct tm *)calloc(1, sizeof(struct tm));
- ii = amortsched->Init_Date_jdn;
- times_I->tm_mday = amortsched->day_I;
- times_I->tm_mon = amortsched->month_I - 1;
- times_I->tm_year = amortsched->year_I - 1900;
- times_I->tm_wday = (ii + 1) % 7;
- times_I->tm_yday = amortsched->yday_I;
-
- printf("\n******************************");
- qof_strftime(buffer, (size_t)50, "%c", times_E);
- printf("\nEffective Date: %s\n", buffer);
- qof_strftime(buffer, (size_t)50, "%c", times_I);
- printf("Initial Payment Date: %s\n", buffer);
- free(times_E);
- free(times_I);
- printf("The Original Present Value (pv) is: %.*f\n", (int)prec, amortsched->pv);
- printf("The Original Periodic Payment (pmt) is: %.*f\n", (int)prec, amortsched->pmt);
- printf("The Original Future Value (fv) is: %.*f\n", (int)prec, amortsched->fv);
-
- printf("The Delayed Present Value (pve) is: %.*f\n", (int)prec, amortsched->pve);
- printf("The New Periodic Payment (pmt) for pve is: %.*f\n\n", (int)prec, amortsched->new_pmt);
-
- printf("The amortization options are:\n");
- printf("1 -- Amortize with Original Amount and Constant Payment to Principal: %.*f\n", (int) prec, amortsched->cpmt1);
- printf(" and final payment: %.*f\n", (int)prec, amortsched->final_pmt_opt_1);
- printf("2 -- Amortize with Delayed Amount and Constant Payment to Principal: %.*f\n", (int)prec, amortsched->cpmt2);
- printf(" and final payment: %.*f\n", (int)prec, amortsched->final_pmt_opt_2);
- printf("3 -- Amortize with Original Transaction Values\n");
- printf(" and final payment: %.*f\n", (int)prec, amortsched->final_pmt_opt_3);
- printf("4 -- Amortize with Delayed Amount, Original Periodic Payment\n");
- printf(" and final payment: %.*f\n", (int)prec, amortsched->final_pmt_opt_4);
- printf("5 -- Amortize with Delayed Amount, New Periodic Payment\n");
- printf(" and final payment: %.*f\n", (int)prec, amortsched->final_pmt_opt_5);
- if ( amortsched->new_n )
-{
- printf("6 -- Amortize with Original Amount, Original Periodic Payment,\n");
- printf(" new number of total payments (n): %u\n", amortsched->new_n);
- printf(" and final payment: %.*f\n", (int)prec, amortsched->final_pmt_opt_6);
- } /* endif */
- printf("Enter choice 1, 2, 3, 4, 5 or 6: ");
- fgets(buffer, 190, stdin);
- amortsched->option = buffer[0] - '0';
-
- printf("Amortization Schedule:\n");
- printf("y -- Yearly Summary\n");
- printf("p -- Periodic Payment\n");
- if ( amortsched->option < 3 )
- {
- printf("Enter Choice y or p: ");
- }
- else
- {
- printf("f -- Fixed Advanced Payment\n");
- printf("a -- Variable Advanced Payment\n");
- printf("Enter Choice y, p, f or a: ");
- } /* endif */
- fgets(buffer, 190, stdin);
- amortsched->summary = buffer[0];
-
- if ( amortsched->summary == 'f' )
- {
- if ( amortsched->fixed_pmt != 0.0 )
- {
- printf("Current Fixed Prepayment: %.*f\nChange Fixed Prepayment? (y/n): ", (int)prec, amortsched->fixed_pmt);
- fgets(buffer, 190, stdin);
- }
- else
- {
- buffer[0] = 'y';
- } /* endif */
-
- if ( buffer[0] == 'y' )
- {
- printf("Enter Fixed Prepayment Amount: ");
- fgets(buffer, 190, stdin);
- if ( (errp = parse_string(&value, buffer, parse_env)) == NULL )
- {
- nval = (numeric_ptr)(value.value);
- switch ( nval->type )
- {
- case INT_TYPE:
- amortsched->fixed_pmt = (double)(nval->value.int_value);
- break;
- case DBL_TYPE:
- amortsched->fixed_pmt = nval->value.dbl_value;
- break;
- } /* endswitch */
- if ( !value.variable_name ) free_numeric(value.value);
- }
- else
- {
- parse_error(get_parse_error(parse_env), buffer, errp);
- } /* endif */
- } /* endif */
- } /* endif */
-
- return amortsched;
-} /* amort_opt */
Deleted: gnucash/trunk/src/calculation/amort_prt.c
===================================================================
--- gnucash/trunk/src/calculation/amort_prt.c 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/amort_prt.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,307 +0,0 @@
-/***************************************************************************
- amort_prt.c - description
- -------------------
- begin : Thursday June 15 2000
- email : tboldt at attglobal.net
- Author : Terry D. Boldt
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-/*
- * Functions to print amortization schedules
- * 6-15-2000
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <mcheck.h>
-
-#include "finvar.h"
-#include "finproto.h"
-#include "fin_spl_protos.h"
-
-
-void prt_amortization_schedule(
- amort_sched_ptr amortsched, /* amortization schedule to print */
- FILE *ofile) /* output file */
-{
- unsigned j,
- jj,
- prec = amortsched->prec,
- option = amortsched->option,
- fv_case = amortsched->fv_case;
- unsigned char datel[100],
- summary = amortsched->summary;
- struct tm *times_E,
- *times_I;
- amort_sched_yr_ptr amortyr,
- prst_yr;
- sched_pmt_ptr pmtsched = NULL;
- yearly_summary_ptr annual_summary;
-
- times_E = (struct tm *)calloc(1, sizeof(struct tm));
- times_E->tm_mday = amortsched->day_E;
- times_E->tm_mon = amortsched->month_E - 1;
- times_E->tm_year = amortsched->year_E - 1900;
- times_E->tm_wday = (amortsched->Eff_Date_jdn + 1) % 7;
- times_E->tm_yday = amortsched->yday_E;
-
- times_I = (struct tm *)calloc(1, sizeof(struct tm));
- times_I->tm_mday = amortsched->day_I;
- times_I->tm_mon = amortsched->month_I - 1;
- times_I->tm_year = amortsched->year_I - 1900;
- times_I->tm_wday = (amortsched->Init_Date_jdn + 1) % 7;
- times_I->tm_yday = amortsched->yday_I;
-
- fprintf(ofile, "Amortization Table\n");
- qof_strftime(datel, (size_t)100, "%c", times_E);
- fprintf(ofile, "Effective Date: %s\n", datel);
- qof_strftime(datel, (size_t)100, "%c", times_I);
- fprintf(ofile, "Initial Payment Date: %s\n", datel);
- fprintf(ofile, "Compounding Frequency per year: %u\n", amortsched->CF);
- fprintf(ofile, "Payment Frequency per year: %u\n", amortsched->PF);
- fprintf(ofile, "Compounding: %s\n", (amortsched->disc ? "Discrete" : "Continuous"));
- fprintf(ofile, "Payments: %s\n", (amortsched->bep ? "Beginning of Period" : "End of Period"));
- fprintf(ofile, "Payments (%u): %.*f\n", amortsched->n - 1, (int)prec, (option < 3) ? amortsched->cpmt : (option == 5) ? amortsched->new_pmt : amortsched->pmt);
- fprintf(ofile, "Final payment (%u): %.*f\n", amortsched->n, (int)prec, amortsched->final_pmt);
- if ( (amortsched->CF == 1) && (amortsched->PF == 1) ) fprintf(ofile, "Nominal Interest per Payment Period: %g\t(Annualized: %g)\n", amortsched->nint, amortsched->nint * 12);
- else fprintf(ofile, "Nominal Annual Interest Rate: %g\n", amortsched->nint);
- fprintf(ofile, " Effective Interest Rate Per Payment Period: %g\n", amortsched->eint);
- fprintf(ofile, "Present Value: %.*f\n", (int)prec, amortsched->pv);
- if ( (amortsched->option == 2) || (amortsched->option > 3) )
-{
- fprintf(ofile, "Interest due to Delayed Intial Payment: %.*f\n", (int)prec, amortsched->delayed_int);
- } /* endif */
-
- free(times_E);
- free(times_I);
-
- if ( amortsched->option < 3 )
- {
- summary = (summary == 'y') ? 'x' : 'o';
- } /* endif */
-
- switch ( summary )
- {
- case 'a':
- /* variable prepayment schedule
- */
- fprintf(ofile, "Advanced Prepayment Amortization - Variable Prepayment\n");
- amortyr = amortsched->schedule.first_yr;
- for ( j = amortsched->total_periods , jj = 0 ; j && amortyr ; j-- )
- {
- if ( !jj )
- {
- fprintf(ofile, "Pmt * Interest Principal Prepay Total Pmt Balance\n");
- pmtsched = amortyr->payments;
- jj = amortyr->num_periods;
- } /* endif */
-
- fprintf(ofile, "%4u %12.*f %12.*f %12.*f %12.*f %12.*f\n",
- pmtsched->period_num,
- (int)prec, pmtsched->interest,
- (int)prec, pmtsched->principal,
- (int)prec, pmtsched->advanced_pmt,
- (int)prec, pmtsched->total_pmt,
- (int)prec, pmtsched->balance);
-
- if ( !--jj )
- {
- fprintf(ofile, "Summary for: %u:\n", amortyr->year);
- fprintf(ofile, " Interest Paid: %.*f\n", (int)prec, amortyr->interest_pd);
- fprintf(ofile, " Principal Paid: %.*f\n", (int)prec, amortyr->principal_pd);
- fprintf(ofile, " Year Ending Balance: %.*f\n", (int)prec, amortyr->yr_end_balance);
- fprintf(ofile, " Sum of Interest Paid: %.*f\n", (int)prec, amortyr->total_interest_pd);
- prst_yr = amortyr;
- amortyr = amortyr->next_yr;
- }
- else
- {
- pmtsched++;
- } /* endif */
- } /* endfor */
- break;
- case 'f':
- /* fixed prepayment schedule
- */
- fprintf(ofile, "Advanced Prepayment Amortization - Fixed Prepayment: %.*f\n", (int)prec, amortsched->fixed_pmt);
- amortyr = amortsched->schedule.first_yr;
- for ( j = amortsched->total_periods , jj = 0 ; j && amortyr ; j-- )
- {
- if ( !jj )
- {
- fprintf(ofile, "Pmt * Interest Principal Prepay Total Pmt Balance\n");
- pmtsched = amortyr->payments;
- jj = amortyr->num_periods;
- } /* endif */
-
- fprintf(ofile, "%4u %12.*f %12.*f %12.*f %12.*f %12.*f\n",
- pmtsched->period_num,
- (int)prec, pmtsched->interest,
- (int)prec, pmtsched->principal,
- (int)prec, pmtsched->advanced_pmt,
- (int)prec, pmtsched->total_pmt,
- (int)prec, pmtsched->balance);
-
- if ( !--jj )
- {
- fprintf(ofile, "Summary for: %u:\n", amortyr->year);
- fprintf(ofile, " Interest Paid: %.*f\n", (int)prec, amortyr->interest_pd);
- fprintf(ofile, " Principal Paid: %.*f\n", (int)prec, amortyr->principal_pd);
- fprintf(ofile, " Year Ending Balance: %.*f\n", (int)prec, amortyr->yr_end_balance);
- fprintf(ofile, " Sum of Interest Paid: %.*f\n", (int)prec, amortyr->total_interest_pd);
- prst_yr = amortyr;
- amortyr = amortyr->next_yr;
- }
- else
- {
- pmtsched++;
- } /* endif */
- } /* endfor */
- break;
- case 'o':
- /* constant payment to principal
- */
- fprintf(ofile, "Constant Payment to Principal: %.*f\n", (int)prec, amortsched->cpmt);
- amortyr = amortsched->schedule.first_yr;
- for ( j = amortsched->total_periods , jj = 0 ; j && amortyr ; j-- )
- {
- if ( !jj )
- {
- fprintf(ofile, "Pmt# Interest Total Payment Balance\n");
- pmtsched = amortyr->payments;
- jj = amortyr->num_periods;
- } /* endif */
-
- fprintf(ofile, "%4u %12.*f %12.*f %12.*f\n",
- pmtsched->period_num,
- (int)prec, pmtsched->interest,
- (int)prec, pmtsched->total_pmt,
- (int)prec, pmtsched->balance);
-
- if ( !--jj )
- {
- fprintf(ofile, "Summary for: %u:\n", amortyr->year);
- fprintf(ofile, " Interest Paid: %.*f\n", (int)prec, amortyr->interest_pd);
- fprintf(ofile, " Principal Paid: %.*f\n", (int)prec, amortyr->principal_pd);
- fprintf(ofile, " Year Ending Balance: %.*f\n", (int)prec, amortyr->yr_end_balance);
- fprintf(ofile, " Sum of Interest Paid: %.*f\n", (int)prec, amortyr->total_interest_pd);
- prst_yr = amortyr;
- amortyr = amortyr->next_yr;
- }
- else
- {
- pmtsched++;
- } /* endif */
- } /* endfor */
- break;
- case 'p':
- /* normal payment schedule
- */
- fprintf(ofile, "Normal Amortization Schedule\n");
- amortyr = amortsched->schedule.first_yr;
- for ( j = amortsched->total_periods - 1 , jj = 0 ; j && amortyr ; j-- )
- {
- if ( !jj )
- {
- fprintf(ofile, amortsched->fv_case ? "Pmt * Interest Balance\n" : "Pmt * Interest Principal Balance\n");
- pmtsched = amortyr->payments;
- jj = amortyr->num_periods;
- } /* endif */
-
- if ( fv_case )
- {
- fprintf(ofile, "%4u %12.*f %12.*f\n",
- pmtsched->period_num,
- (int)prec, pmtsched->interest,
- (int)prec, pmtsched->balance);
- }
- else
- {
- fprintf(ofile, "%4u %12.*f %12.*f %12.*f\n",
- pmtsched->period_num,
- (int)prec, pmtsched->interest,
- (int)prec, pmtsched->principal,
- (int)prec, pmtsched->balance);
- } /* endif */
-
- if ( !--jj )
- {
- fprintf(ofile, "Summary for: %u:\n", amortyr->year);
- fprintf(ofile, " Interest Paid: %.*f\n", (int)prec, amortyr->interest_pd);
- if ( !fv_case ) fprintf(ofile, " Principal Paid: %.*f\n", (int)prec, amortyr->principal_pd);
- fprintf(ofile, " Year Ending Balance: %.*f\n", (int)prec, amortyr->yr_end_balance);
- fprintf(ofile, " Sum of Interest Paid: %.*f\n", (int)prec, amortyr->total_interest_pd);
- prst_yr = amortyr;
- amortyr = amortyr->next_yr;
- }
- else
- {
- pmtsched++;
- } /* endif */
- } /* endfor */
-
- if ( !jj )
- {
- fprintf(ofile, amortsched->fv_case ? "Pmt * Interest Balance\n" : "Pmt * Interest Principal Balance\n");
- pmtsched = amortyr->payments;
- } /* endif */
-
- fprintf(ofile, "Final Payment: %.*f\n", (int)prec, amortyr->final_pmt);
-
- if ( fv_case )
- {
- fprintf(ofile, "%4u %12.*f %12.*f\n",
- pmtsched->period_num,
- (int)prec, pmtsched->interest,
- (int)prec, pmtsched->balance);
- }
- else
- {
- fprintf(ofile, "%4u %12.*f %12.*f %12.*f\n",
- pmtsched->period_num,
- (int)prec, pmtsched->interest,
- (int)prec, pmtsched->principal,
- (int)prec, pmtsched->balance);
- } /* endif */
-
- fprintf(ofile, "Summary for: %u:\n", amortyr->year);
- fprintf(ofile, " Interest Paid: %.*f\n", (int)prec, amortyr->interest_pd);
- if ( !fv_case ) fprintf(ofile, " Principal Paid: %.*f\n", (int)prec, amortyr->principal_pd);
- fprintf(ofile, " Year Ending Balance: %.*f\n", (int)prec, amortyr->yr_end_balance);
- fprintf(ofile, " Sum of Interest Paid: %.*f\n", (int)prec, amortyr->total_interest_pd);
- break;
- case 'x':
- /* constant payment to principal - annual summary
- */
- case 'y':
- /* normal payment - annual summary
- */
- if ( summary == 'x' ) fprintf(ofile, "Annual Summary - Constant Payment to Principal: %.*f\n", (int)prec, amortsched->cpmt);
- else fprintf(ofile, "Annual Summary - Normal Amortization\n");
- fprintf(ofile, "Year Interest Ending Balance\n");
- annual_summary = amortsched->schedule.summary;
- for ( j = amortsched->total_periods , jj = 0 ; j ; j-- , jj++ )
- {
- fprintf(ofile, "%4u %12.*f %12.*f\n",
- annual_summary[jj].year,
- (int)prec, annual_summary[jj].interest,
- (int)prec, annual_summary[jj].end_balance);
- } /* endfor */
- break;
- } /* endswitch */
-
- fprintf(ofile, "\nTotal Interest: %.*f\n", (int)prec, amortsched->total_interest);
-
-} /* prt_amortization_schedule */
Deleted: gnucash/trunk/src/calculation/expression_parser.c
===================================================================
--- gnucash/trunk/src/calculation/expression_parser.c 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/expression_parser.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,1267 +0,0 @@
-/***************************************************************************
- expression-parser.c - description
- -------------------
- begin : Wednesday June 21 2000
- email : tboldt at attglobal.net
- Author : Terry D. Boldt
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-/*
- * Functions to parse arthmetic expressions
- * 6-21-2000
- */
-
-/* Modified to support functions - Summer, 2002 -- jsled at asynchronous.org */
-
-/* expression parser/evaluator use:
- *
- * Before describing the parser per se, I want to describe the
- * structures used to contain the results returned from the
- * parser. The structure is defined in "finvar.h":
- *
- * typedef struct var_store *var_store_ptr;
- *
- * typedef struct var_store {
- * char *variable_name;
- * char use_flag;
- * char assign_flag;
- * void *value;
- * var_strore_ptr next_var;
- * } var_store;
- *
- * The "use_flag" variable is for internal use of the parser and can
- * be ignored by the user. The "variable_name" variable possibly
- * points to a string containing the name of the value returned, a
- * "variable name". If NULL, then this is a temporary value. The
- * "value" variable points to a user defined structure containing the
- * numeric value of the variable.
- *
- * As well, variables now have a VarStoreType, to distinguish between numeric
- * and string values, as we want string arguments to functions.
- *
- * In designing and writing the parser, I decided early on that the
- * parser should be an "expression parser/evaluator" and that the
- * actual arithmetic was the responsibility of the caller/user.
- *
- * I decided that the parser should be totally independent of the
- * numeric representation used, and thus the exact details of how the
- * arithmetic was performed. To accomplish this, four functions are
- * supplied by the user/caller:
- *
- * 1: trans_numeric - this function translates the text string into a
- * numeric in the desired representation and returns a pointer to the
- * representation as a (void *) this function has four parameters
- * passed:
- *
- * 1: digit_str -- the actual text string of the
- * numeric to be converted to the internal
- * representation
- *
- * 2: radix_point -- the ASCII character used to
- * represent the radix point
- *
- * 3: group character -- the ASCII character used
- * to separate and group digits to the left of the
- * radix
- *
- * 4: rstr -- a pointer to a location in which to
- * return a pointer to the first character not
- * part of the numeric string translated If this
- * pointer is NULL, do not return a value. This
- * parameter is the same as the second parameter
- * of the standard C library functions "strtod" or
- * "strtol"
- *
- * 2: numeric_ops - this function does the actual arithmetic on two
- * numeric quantities in internal representation. It has three
- * parameters passed:
- *
- * 1: op_sym -- the numeric operation to be
- * performed. The possible values are defined
- * in "finvar.h" and are:
- *
- * ADD_OP - addition
- * SUB_OP - subtraction
- * DIV_OP - division
- * MUL_OP - multiplication
- * ASN_OP - assignment
- *
- * 2: left_value - the left hand operand of the
- * binary operator
- *
- * 3: right_value - the right hand operand of
- * the binary operator Note: left_value and
- * right_value are passed as (void *). This
- * function is responsible for casting to the
- * proper type to use. Note: this function should
- * make no assumptions about overwriting or
- * re-using either left_value or right_value,
- * except for ASN_OP. Both values passed must be
- * left unchanged by any operation except ASN_OP.
- * This function is also responsible for
- * allocating/freeing memory as necessary to
- * perform the designated function and returning
- * the result. I STRONGLY suggest that the result
- * be returned in dynamically allocated memory. If
- * static memory is used, the parser has no means
- * of copying the returned result or managing
- * static memory to prevent overwriting the result
- * and invalidating the result.
- *
- * 3: negate_numeric - this function negates the value passed (as a (void *))
- *
- * 4: free_numeric - this function is responsible for freeing memory
- * used by the internal numeric representation.
- *
- * 5: func_op - this function is repsonsible for handling function calls.
- *
- * I have included the file "numeric_ops.c" containing the above
- * functions for the usual "double" and "int" representation of
- * numerics. The functions perform integer or floating point
- * operations as appropriate for the string entered by the user. The
- * division operation is done in "double" since I do not think that
- * anybody really wants (9 / 2) to equal 4 instead of 4.5 for
- * financial operations. These functions use the structure defined in
- * finvar.h:
- *
- * typedef struct numeric *numeric_ptr;
- * typedef struct numeric {
- * char type;
- * union {
- * long int int_value;
- * double dbl_value;
- * } value;
- * } numeric;
- *
- * to contain all numeric values. The variable "type" in this
- * structure can have the values:
- *
- * INT_TYPE
- * DBL_TYPE
- *
- * which are defined in "finvar.h".
- *
- * All "named variables", variables defined by the user for storing
- * intermediate results for future reference/use, and temporary
- * variables used by the parser use the variable storage structure,
- * var_store, defined above. The result of parsing and evaluating the
- * string passed are returned in a variable storage structure
- * specified by the caller.
- *
- * If the returned variable value is not named, i.e., "variable_name
- * == NULL", then the user/caller is responsible for freeing the
- * memory used by the internal representation of the numeric value.
- * If, however, "variable_name != NULL", freeing the memory used by
- * the internal numeric representation will cause a segmentation fault
- * later, when the parser attempts to free the memory through a call
- * to "free_numeric". In addition, freeing the memory will probably
- * invalidate the numeric value contained therein and lead to
- * pernicuous results when the value is used.
- *
- * If "variable_name != NULL", the user/caller should never attempt to
- * free this memory, that is the sole responsibility of the parser.
- *
- * It may be that the calling function has certain "variables" that
- * need to be "pre-defined" for the user to manipulate. In essence
- * the function "pre-defining" variables sets up a linked list of
- * variable storage structures with the proper "names" and numeric
- * values. The number of "pre-defined" variables and a pointer to the
- * structure array is passed to the parser in the initialization
- * call. After the parser is eventually exited, the calling function
- * is responsible for freeing any memory used by the "pre-defined"
- * variables and their final numeric representation.
- *
- * There may also be strings in the expression, by quoting them in '"'
- * characters. These are intended to be passed literally into functions; the
- * result of using a string in a numeric operation is undefined. Presently,
- * the expression-parser code does not check the variable types during
- * parsing or evaluation.
- *
- * A second design goal of the parser was that it should be callable
- * concurrently by multiple modules independently. That each module
- * should be capable of using differing "pre-defined" variables and
- * user defined variables and even internal numeric representations.
- * To that end the calling module must first initialize the parser
- * with a call to "init_parser". This call creates the parser
- * internal structure for subsequent calls to the parser proper. The
- * structure created and returned must then be passed to subsequent
- * calls to the parser. When no further calls to the parser are to be
- * made, the module then calls "exit_parser" with the pointer returned
- * by "init_parser", so that the parser may release dynamically
- * allocated memory.
- *
- * The parser recognizes the following binary operators:
- *
- * +
- * -
- * /
- * *
- * =
- * +=
- * -=
- * /=
- * *=
- *
- * In addition, the unary operators
- *
- * +
- * -
- *
- * are recognized. All numerics are initially recognized as positive
- * numbers. If negative, the unary '-' operator is applied. This saves
- * the logic of having to recogize strings as
- *
- * -123
- *
- * The logic recognizes "-" and "123" separately. The '-' unary
- * operator is then applied to negate the numeric. This also has the
- * advanatge that the same logic can be used for
- *
- * -123
- * +123.45
- * +uvar
- * -uvar
- *
- * In each case, the appropriate unary operator is applied to obtain
- * the desired * result with no increase in the parsing logic. Thus
- * keeping things as simple as possible.
- *
- * The parser also follows the C practice that the assignment
- * operators return a value. Thus, allowing multiple assignments and
- * assignment within expressions. The following expressions are all
- * valid:
- *
- * nni = 123
- * hnk = nni = 23.45
- * jkl = 5 * (nj = 68.9)
- *
- * The first time variables are used in an expression, they are
- * initialized to zero, 0. Thus, even if the following variables have
- * not been assigned a value previously, the following expressions are
- * valid:
- *
- * nni *= 123
- * above results in zero in nni
- * jk += 45.6
- * above results in 45.6 in jk
- * 56.8 - tyh
- * result of above is 56.8
- * tgh - 45.7
- * above the same as
- * -45.7
- *
- * After parsing the above expressions the variables nni, jk, tyh and
- * tgh would all be defined.
- *
- * Functions are invoked with expressions of the format
- *
- * [_a-zA-Z]( <argument_0> : <argument_1> : ... : <argument_n> )
- *
- * where each argument can itself be a sub-expression [arithmetic operation
- * or function call].
- *
- *
- * There are six parser functions needed to use the parser/evaluator:
- *
- * Note: in the last five functions, in the function paramter (void
- * *vp), "vp" is the pointer returned by the "init_parser" function.
- *
- * void *init_parser(var_store_ptr predefined_vars,
- * gchar *radix_point,
- * gchar *group_char,
- * void *trans_numeric(char *digit_str,
- * gchar *radix_point,
- * gchar *group_char,
- * char **rstr),
- * void *numeric_ops(char op_sym,
- * void *left_value,
- * void *right_value),
- * void *negate_numeric(void *value),
- * void free_numeric(void *numeric_value),
- * void *func_op(const char *fname, int argc, void **argv));
- *
- * This function is called by the module/function/whatever to
- * initialize the parser. The parser returns a pointer to a
- * structure that contains all relevant information for
- * parsering strings. The pointer is returned as (void *)
- * since all information is and should remain pertinent only
- * to the parser. The calling function(s) should never rely on
- * manipulating any information inside this structure
- * directly, since it may and could change in the future. --
- * The first parameter is a pointer to a the first element in
- * a linked list of "pre-defined" variables the caller wishes
- * to use with subsequent calls to the parser. -- The second
- * parameter is the radix character to use in numeric strings
- * in subsequent calls to the parser. -- the third parameter
- * is the optional character used for grouping digits to the
- * left of the radix. -- The fourth, fifth, sixth and seventh
- * parameters are the functions I descibed above for the
- * internal numeric representation desired by the calling
- * function(s).
- *
- * void exit_parser(
- * void *vp);
- *
- * This function is called to exit the parser and free all
- * dynamically allocated memory used by the parser for an
- * internal stack and user defined variables.
- *
- * unsigned get_parse_error(
- * void *vp);
- *
- * If the parser is successful in complete parsing and
- * evaluating the string passed to 'parse_string' below, that
- * functions returns a NULL pointer. If, however, an error is
- * encountered in parsing/evaluating the string, the
- * 'parse_string' function returns a pointer to the character
- * which caused the error. This call returns an unsigned
- * integer designating the error encountered. The possible
- * values are defined in the "finvar.h" file.
- *
- * var_store_ptr parser_get_vars(
- * void *vp)
- *
- * This function returns a pointer to the first element of a
- * linked list of variable storage structures containing the
- * user defined named variables if any exist. NULL is
- * returned if none exist. The calling function should not
- * alter the variable names. The numeric values may be
- * altered if the calling function author really knows what
- * they are doing.
- *
- * unsigned delete_var(
- * char *var_name,
- * void *vp);
- *
- * This function will delete the user defined named variable
- * with a name identical to the name string passed in the
- * first parameter. If no user defined variable exists with an
- * identical name, zero, 0, is returned. If the delete
- * operation is successful, one, 1, is returned.
- *
- * char *parse_string(
- * var_store_ptr value,
- * char *string,
- * void *vp);
- *
- * This function parses the string passed in the second
- * parameter and returns a pointer to the last character not
- * recognized upon a parsing error. If no error occurred, NULL
- * is returned. The first parameter is a pointer to a variable
- * storage structure to contain the result of the
- * parser/evaluator.
- *
- * Note: The parser/evaluator uses a simple recursive descent
- * parser. I decided on this type for the simple reason that for a
- * simple four function calculator a recursive descent parser is, in
- * my opinion, the easiest to construct. I also think that recursive
- * descent parsers are easier for the human to understand and thus
- * maintain.
- *
- * Also, the parser uses a stack which is dynamically allocated in
- * memory and can grow as needed. I have not provided any mechanism
- * for shrinking the stack. The initial stack size is set at 50
- * slots. I really do not anticipate that under normal and even most
- * extreme cases, that it will ever approach that size in actual
- * use. Under "normal" operation, the stack will probably never exceed
- * 3 or 4 slots in size and 50 slots is probably an overkill for
- * normal use. However, since the stack is pointers and not entire
- * structures, a stack size of 50 slots is not that much memory and
- * can be tolerated by most users. Thus, a mechanism for shrinking the
- * stack will probably never be needed.
- */
-
-#include "config.h"
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <glib.h>
-
-#include "qof.h"
-
-#define EXPRESSION_PARSER_STATICS
-#include "finvar.h"
-
-#define MAX_FUNC_ARG_LEN 255
-
-/* structure to hold parser environment - environment particular to
- * each caller */
-typedef struct parser_env
-{
- unsigned stack_cnt;
- unsigned stack_size;
- var_store_ptr *stack;
- var_store_ptr predefined_vars;
- var_store_ptr named_vars;
- var_store_ptr unnamed_vars;
-
- const char *parse_str;
- gchar *radix_point;
- gchar *group_char;
- char name[128];
-
- char Token;
- char asn_op;
-
- char *tokens;
- char *token_tail;
-
- ParseError error_code;
-
- void *numeric_value;
-
- void *(*trans_numeric) (const char *digit_str,
- gchar *radix_point, gchar *group_char, char **rstr);
- void *(*numeric_ops) (char op_sym, void *left_value, void *right_value);
- void *(*negate_numeric) (void *value);
- void (*free_numeric) (void *numeric_value);
- void *(*func_op)( const char *fname, int argc, void **argv );
-}
-parser_env;
-
-#include "finproto.h"
-#include "fin_static_proto.h"
-#include "fin_spl_protos.h"
-
-#define FN_TOKEN 'F'
-#define ARG_TOKEN ':'
-#define VAR_TOKEN 'V'
-#define NUM_TOKEN 'I'
-#define STR_TOKEN '"'
-
-#define STACK_INIT 50
-
-#define UNNAMED_VARS 100
-
-#define NAMED_INCR 5
-
-static char allowed_operators[] = "+-*/()=:";
-
-parser_env_ptr
-init_parser (var_store_ptr predefined_vars,
- gchar *radix_point,
- gchar *group_char,
- void *trans_numeric (const char *digit_str,
- gchar *radix_point,
- gchar *group_char,
- char **rstr),
- void *numeric_ops (char op_sym,
- void *left_value,
- void *right_value),
- void *negate_numeric (void *value),
- void free_numeric (void *numeric_value),
- void *func_op( const char *fname,
- int argc, void **argv ))
-{
- parser_env_ptr pe = g_new0 (parser_env, 1);
-
- pe->predefined_vars = predefined_vars;
-
- pe->stack = g_new0 (var_store_ptr, STACK_INIT);
- pe->stack_size = STACK_INIT;
-
- pe->radix_point = radix_point;
- pe->group_char = group_char;
-
- pe->numeric_value = NULL;
-
- pe->trans_numeric = trans_numeric;
- pe->numeric_ops = numeric_ops;
- pe->negate_numeric = negate_numeric;
- pe->free_numeric = free_numeric;
- pe->func_op = func_op;
-
- return pe;
-} /* init_parser */
-
-void
-exit_parser (parser_env_ptr pe)
-{
- var_store_ptr vars, bv;
-
- if (pe == NULL)
- return;
-
- for (vars = pe->named_vars; vars; vars = bv)
- {
- g_free (vars->variable_name);
- vars->variable_name = NULL;
-
- if (vars->value)
- pe->free_numeric (vars->value);
- vars->value = NULL;
-
- bv = vars->next_var;
- g_free (vars);
- } /* endfor */
-
- pe->named_vars = NULL;
-
- g_free (pe->stack);
- pe->stack = NULL;
-
- g_free (pe->tokens);
- pe->tokens = NULL;
- pe->token_tail = NULL;
-
- if (pe->numeric_value)
- pe->free_numeric (pe->numeric_value);
- pe->numeric_value = NULL;
-
- g_free (pe);
-} /* exit_parser */
-
-/* return parser error code */
-ParseError get_parse_error (parser_env_ptr pe)
-{
- if (pe == NULL)
- return PARSER_NO_ERROR;
-
- return pe->error_code;
-} /* get_parse_error */
-
-/* return linked list of named variables which have been defined */
-var_store_ptr parser_get_vars (parser_env_ptr pe)
-{
- if (pe == NULL)
- return NULL;
-
- return pe->named_vars;
-} /* get_vars */
-
-/* function to delete variable with specified name from named variables
- * if it exists. If it exists return TRUE, 1, else return FALSE, 0 */
-unsigned
-delete_var (char *var_name, parser_env_ptr pe)
-{
- unsigned ret = FALSE;
- var_store_ptr nv, tv;
-
- if (pe == NULL)
- return FALSE;
-
- for (nv = pe->named_vars, tv = NULL; nv; tv = nv, nv = nv->next_var)
- {
- if (strcmp (nv->variable_name, var_name) == 0)
- {
- if (tv)
- tv->next_var = nv->next_var;
- else
- pe->named_vars = nv->next_var;
-
- g_free (nv->variable_name);
- nv->variable_name = NULL;
-
- pe->free_numeric (nv->value);
- nv->value = NULL;
-
- g_free (nv);
-
- ret = TRUE;
- break;
- } /* endif */
- } /* endfor */
-
- return ret;
-} /* delete_var */
-
-/* parse string passed using parser environment passed return
- * evaluated value in numeric structure passed, return NULL if no
- * parse error. If parse error, return pointer to character at which
- * error occured. */
-char *
-parse_string (var_store_ptr value, const char *string, parser_env_ptr pe)
-{
- var_store_ptr retv;
- var_store unnamed_vars[UNNAMED_VARS];
-
- if (!pe || !string)
- return NULL;
-
- pe->unnamed_vars = unnamed_vars;
- memset (unnamed_vars, 0, UNNAMED_VARS * sizeof (var_store));
-
- pe->parse_str = string;
- pe->error_code = PARSER_NO_ERROR;
-
- g_free (pe->tokens);
- pe->tokens = g_new0(char, strlen (string) + 1);
- pe->token_tail = pe->tokens;
-
- next_token (pe);
-
- if (!pe->error_code)
- assignment_op (pe);
-
- if (!pe->error_code)
- {
- /* interpret (num) as -num */
- if (strcmp (pe->tokens, "(I)") == 0)
- {
- var_store_ptr val;
-
- val = pop (pe);
- pe->negate_numeric (val->value);
- push (val, pe);
- }
- }
-
- if (pe->Token == EOS)
- {
- if ((pe->stack_cnt) && (retv = pop (pe)))
- {
- if (value != NULL)
- *value = *retv;
- pe->parse_str = NULL;
- }
- else
- pe->error_code = STACK_UNDERFLOW;
- }
-
- pe->stack_cnt = 0;
- pe->unnamed_vars = NULL;
-
- return (char *) pe->parse_str;
-} /* expression */
-
-/* pop value off value stack */
-static var_store_ptr
-pop (parser_env_ptr pe)
-{
- var_store_ptr val;
-
- if (pe->stack_cnt)
- val = pe->stack[--(pe->stack_cnt)];
- else
- {
- val = NULL;
- pe->error_code = STACK_UNDERFLOW;
- } /* endif */
-
- return val;
-} /* pop */
-
-/* push value onto value stack */
-static var_store_ptr
-push (var_store_ptr push_value, parser_env_ptr pe)
-{
- if (pe->stack_cnt > pe->stack_size)
- {
- pe->stack_size += STACK_INIT;
- pe->stack = g_realloc (pe->stack,
- pe->stack_size * sizeof (var_store_ptr));
- } /* endif */
-
- pe->stack[(pe->stack_cnt)++] = push_value;
-
- return push_value;
-} /* push */
-
-/* get/set variable with specified name - nothing fancy just scan each
- * variable in linked list checking for a string match return variable
- * found if match create new variable if none found */
-static var_store_ptr
-get_named_var (parser_env_ptr pe)
-{
- var_store_ptr retp = NULL, bv;
-
- for (retp = pe->predefined_vars, bv = NULL; retp; retp = retp->next_var)
- if (strcmp (retp->variable_name, pe->name) == 0)
- break;
-
- if (!retp && pe->named_vars)
- for (retp = pe->named_vars; retp; bv = retp, retp = retp->next_var)
- if (strcmp (retp->variable_name, pe->name) == 0)
- break;
-
- if (!retp)
- {
- retp = g_new0 (var_store, 1);
- if (!pe->named_vars)
- pe->named_vars = retp;
- else
- bv->next_var = retp;
- retp->variable_name = g_strdup (pe->name);
- retp->type = VST_NUMERIC;
- retp->value =
- pe->trans_numeric ("0", pe->radix_point, pe->group_char, NULL);
- }
-
- return retp;
-} /* get_var */
-
-/* get un-named temporary variable */
-static var_store_ptr
-get_unnamed_var (parser_env_ptr pe)
-{
- var_store_ptr retp = NULL;
- unsigned cntr;
-
- for (cntr = 0; cntr < UNNAMED_VARS; cntr++)
- if (pe->unnamed_vars[cntr].use_flag == UNUSED_VAR)
- {
- retp = &(pe->unnamed_vars[cntr]);
- retp->variable_name = NULL;
- retp->use_flag = USED_VAR;
- retp->type = VST_NUMERIC;
- if (retp->value)
- {
- pe->free_numeric (retp->value);
- retp->value = NULL;
- } /* endif */
- break;
- } /* endif */
-
- if (retp == NULL)
- pe->error_code = PARSER_OUT_OF_MEMORY;
-
- return retp;
-} /* get_unnamed_var */
-
-/* mark un-named temporary variable unused */
-static void
-free_var (var_store_ptr value, parser_env_ptr pe)
-{
- if (value == NULL)
- return;
-
- /* first check that not a named variable */
- if (value->variable_name != NULL)
- return;
-
- value->use_flag = UNUSED_VAR;
-
- if (value->value)
- {
- pe->free_numeric (value->value);
- value->value = NULL;
- }
-} /* free_var */
-
-static void
-add_token (parser_env_ptr pe, char token)
-{
- pe->Token = token;
- if ((token != EOS) || (*pe->token_tail != EOS))
- {
- *pe->token_tail = token;
- pe->token_tail++;
- }
-}
-
-/* parse next token from string */
-static void
-next_token (parser_env_ptr pe)
-{
- char *nstr;
- const char *str_parse = pe->parse_str;
- void *number;
-
- while (isspace (*str_parse))
- str_parse++;
-
- pe->asn_op = EOS;
-
- /* test for end of string */
- if (!*str_parse)
- {
- add_token (pe, EOS);
- }
- /* test for possible operator */
- else if (strchr (allowed_operators, *str_parse))
- {
- add_token (pe, *str_parse++);
- if (*str_parse == ASN_OP)
- {
- /* BUG/FIXME: this seems to allow '(=' and ')=' [?], neither of which
- * make sense. */
- if (pe->Token != ASN_OP)
- {
- str_parse++;
- pe->asn_op = pe->Token;
- add_token (pe, ASN_OP);
- }
- else
- pe->error_code = UNDEFINED_CHARACTER;
- } /* endif */
- }
- /* test for string */
- else if ( *str_parse == '"' )
- {
- nstr = pe->name;
- /* skip over the '"'. */
- str_parse++;
- do
- {
- *nstr++ = *str_parse++;
- }
- while ( *str_parse != '"' );
- *nstr = EOS;
- str_parse++;
- add_token( pe, STR_TOKEN );
- }
- /* test for name */
- else if (isalpha (*str_parse)
- || (*str_parse == '_'))
- {
- int funcFlag = 0;
-
- /* Check for variable or function */
- /* If variable: add token. */
- /* If function: parse args, build struct, add token. */
- nstr = pe->name;
- do
- {
- if ( *str_parse == '(' )
- {
- funcFlag = 1;
- str_parse++;
- break;
- }
- *nstr++ = *str_parse++;
- }
- while ((*str_parse == '_')
- || (*str_parse == '(')
- || isalpha (*str_parse)
- || isdigit (*str_parse));
-
- *nstr = EOS;
- if ( funcFlag )
- {
- add_token(pe, FN_TOKEN);
- }
- else
- {
- add_token(pe, VAR_TOKEN);
- }
-
- }
- /* test for numeric token */
- else if ((number = pe->trans_numeric (str_parse, pe->radix_point,
- pe->group_char, &nstr)))
- {
- add_token (pe, NUM_TOKEN);
- pe->numeric_value = number;
- str_parse = nstr;
- }
- /* unrecognized character - error */
- else
- {
- add_token (pe, *str_parse);
- pe->error_code = UNDEFINED_CHARACTER;
- } /* endif */
-
- pe->parse_str = str_parse;
-} /* next_token */
-
-/* evaluate assignment operators,
- * =
- * +=
- * -=
- * \=
- * *=
- */
-/* FIXME: add non-numeric checking. */
-static void
-assignment_op (parser_env_ptr pe)
-{
- var_store_ptr vl; /* left value */
- var_store_ptr vr; /* right value */
- char ao;
-
- add_sub_op (pe);
- if (pe->error_code)
- return;
-
- while (pe->Token == ASN_OP)
- {
- vl = pop (pe);
- if (pe->error_code)
- return;
-
- ao = pe->asn_op;
-
- if (vl->variable_name)
- {
- next_token (pe);
- if (pe->error_code)
- {
- free_var (vl, pe);
- return;
- }
-
- assignment_op (pe);
- if (pe->error_code)
- {
- free_var (vl, pe);
- return;
- }
-
- vr = pop (pe);
- if (pe->error_code)
- {
- free_var (vl, pe);
- return;
- }
-
- vl->assign_flag = ASSIGNED_TO;
-
- if (ao)
- {
- void *temp;
-
- temp = vl->value;
- vl->value = pe->numeric_ops (ao, vl->value, vr->value);
- pe->free_numeric (temp);
- }
- else if (vl != vr)
- {
- if (!vr->variable_name)
- {
- pe->free_numeric (vl->value);
- vl->value = vr->value;
- vr->value = NULL;
- }
- else
- {
- pe->numeric_ops (ASN_OP, vl->value, vr->value);
- }
-
- free_var (vr, pe);
- } /* endif */
-
- push (vl, pe);
- }
- else
- {
- add_token (pe, EOS); /* error !!!!!!!!!! */
- pe->error_code = NOT_A_VARIABLE;
- free_var (vl, pe);
- } /* endif */
- } /* endwhile */
-} /* assignment_op */
-
-/* evaluate addition, subtraction operators */
-/* FIXME: add non-numeric checking. */
-static void
-add_sub_op (parser_env_ptr pe)
-{
- var_store_ptr vl; /* left value */
- var_store_ptr vr; /* right value */
- var_store_ptr rslt; /* result */
- char op;
-
- multiply_divide_op (pe);
- if (pe->error_code)
- return;
-
- while ((pe->Token == ADD_OP) || (pe->Token == SUB_OP))
- {
- op = pe->Token;
-
- vl = pop (pe);
- if (pe->error_code)
- return;
-
- next_token (pe);
- if (pe->error_code)
- {
- free_var (vl, pe);
- return;
- }
-
- multiply_divide_op (pe);
- if (pe->error_code)
- {
- free_var (vl, pe);
- return;
- }
-
- vr = pop (pe);
- if (pe->error_code)
- {
- free_var (vl, pe);
- return;
- }
-
- rslt = get_unnamed_var (pe);
- if (pe->error_code)
- {
- free_var (vl, pe);
- free_var (vr, pe);
- return;
- }
-
- rslt->value = pe->numeric_ops (op, vl->value, vr->value);
-
- free_var (vl, pe);
- free_var (vr, pe);
-
- push (rslt, pe);
- } /* endwhile */
-} /* add_sub_op */
-
-/* evaluate multiplication, division operators */
-/* FIXME: add non-numeric checking. */
-static void
-multiply_divide_op (parser_env_ptr pe)
-{
- var_store_ptr vl; /* left value */
- var_store_ptr vr; /* right value */
- var_store_ptr rslt; /* result */
- char op;
-
- primary_exp (pe);
- if (pe->error_code)
- return;
-
- while ((pe->Token == MUL_OP) || (pe->Token == DIV_OP))
- {
- op = pe->Token;
-
- vl = pop (pe);
- if (pe->error_code)
- return;
-
- next_token (pe);
- if (pe->error_code)
- {
- free_var (vl, pe);
- return;
- }
-
- primary_exp (pe);
- if (pe->error_code)
- {
- free_var (vl, pe);
- return;
- }
-
- vr = pop (pe);
- if (pe->error_code)
- {
- free_var (vl, pe);
- return;
- }
-
- rslt = get_unnamed_var (pe);
- if (pe->error_code)
- {
- free_var (vl, pe);
- free_var (vr, pe);
- return;
- }
-
- rslt->value = pe->numeric_ops (op, vl->value, vr->value);
-
- free_var (vl, pe);
- free_var (vr, pe);
-
- push (rslt, pe);
- } /* endwhile */
-} /* multiply_divide_op */
-
-/**
- * Bug#334811, 308554: apply some basic grammar constraints.
- * @return true if the expression is in error; pe->error_code will already
- * contain the error.
- **/
-static int
-check_expression_grammar_error(parser_env_ptr pe)
-{
- if (pe->Token == VAR_TOKEN
- || pe->Token == STR_TOKEN
- || pe->Token == NUM_TOKEN
- || pe->Token == FN_TOKEN)
- {
- add_token(pe, EOS);
- pe->error_code = EXPRESSION_ERROR;
- return TRUE;
- }
- return FALSE;
-}
-
-/* evaluate:
- * unary '+' and '-'
- * named variables
- * numerics
- * grouped expressions, "()"
- * functions [ <name>( [exp : exp : ... : exp] ) ]
- * strings
- */
-static void
-primary_exp (parser_env_ptr pe)
-{
- var_store_ptr rslt = NULL;
- char *ident = NULL;
- int funcArgCount;
- char LToken = pe->Token;
-
- /* If we are in a state where the non-stacked 'pe->name' is valuable, then
- * save it before we process the next token. */
- switch ( LToken )
- {
- case FN_TOKEN:
- case STR_TOKEN:
- ident = g_strdup( pe->name );
- break;
- }
-
- next_token (pe);
- if (pe->error_code)
- return;
-
- switch (LToken)
- {
- case '(':
- assignment_op (pe);
- if (pe->error_code)
- return;
-
- if (pe->Token == ')')
- {
- rslt = pop (pe);
- if (pe->error_code)
- return;
-
- next_token (pe);
- if (pe->error_code)
- return;
- }
- else
- {
- add_token (pe, EOS); /* error here */
- pe->error_code = UNBALANCED_PARENS;
- } /* endif */
-
- break;
-
- case ADD_OP:
- case SUB_OP:
- primary_exp (pe);
- if (pe->error_code)
- return;
-
- rslt = pop (pe);
- if (pe->error_code)
- return;
-
- if (LToken == SUB_OP)
- pe->negate_numeric (rslt->value);
-
- break;
-
- case NUM_TOKEN:
- rslt = get_unnamed_var (pe);
- if (pe->error_code)
- return;
-
- if (check_expression_grammar_error(pe))
- return;
-
- rslt->value = pe->numeric_value;
- pe->numeric_value = NULL;
- break;
-
- case FN_TOKEN:
- funcArgCount = 0;
-
- if (pe->Token && pe->Token != ')')
- {
- do
- {
- assignment_op(pe);
- if ( pe->error_code )
- return;
- funcArgCount++;
- if (!pe->Token || pe->Token == ')')
- {
- break;
- }
- next_token(pe);
- }
- while (pe->Token != ARG_TOKEN);
- }
-
- if ( pe->Token != ')' )
- {
- add_token( pe, EOS );
- pe->error_code = UNBALANCED_PARENS;
- }
-
- {
- int i;
- var_store_ptr val;
- void **argv;
-
- argv = g_new0( void*, funcArgCount );
- for ( i = 0; i < funcArgCount; i++ )
- {
- /* fill, in back-to-front order, the funcArgCount tokens we just
- * parsed out of the expression into a argument list to hand back
- * to the caller's func_op callback. */
- val = pop(pe);
- argv[funcArgCount - i - 1] = val;
- }
-
- rslt = get_unnamed_var(pe);
- rslt->value = (*pe->func_op)( ident, funcArgCount, argv );
-
- for ( i = 0; i < funcArgCount; i++ )
- {
- free_var( argv[i], pe );
- }
- g_free( argv );
- g_free( ident );
-
- if ( rslt->value == NULL )
- {
- pe->error_code = NOT_A_FUNC;
- add_token( pe, EOS );
- return;
- }
- }
-
- next_token(pe);
-
- if (check_expression_grammar_error(pe))
- return;
-
- break;
-
- case VAR_TOKEN:
- if (check_expression_grammar_error(pe))
- return;
-
- rslt = get_named_var (pe);
- break;
- case STR_TOKEN:
- if (!(pe->Token == ')'
- || pe->Token == ARG_TOKEN))
- {
- add_token(pe, EOS);
- pe->error_code = EXPRESSION_ERROR;
- return;
- }
-
- rslt = get_unnamed_var( pe );
- rslt->type = VST_STRING;
- rslt->value = ident;
- break;
- } /* endswitch */
-
- if (rslt != NULL)
- push (rslt, pe);
-
-} /* primary_exp */
Deleted: gnucash/trunk/src/calculation/fin-interactive.c
===================================================================
--- gnucash/trunk/src/calculation/fin-interactive.c 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/fin-interactive.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,600 +0,0 @@
-/***************************************************************************
- fin-interactive.c - description
- -------------------
- begin : Thursday June 15 2000
- email : tboldt at attglobal.net
- Author : Terry D. Boldt
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-/*
- * Functions to interact with user and call financial equations
- * 6-22-2000
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <mcheck.h>
-
-#include "finvar.h"
-#include "finproto.h"
-#include "fin_spl_protos.h"
-#include "numeric_ops.h"
-
-static void prt_status(
- fi_ptr fi,
- FILE *ofile);
-
-static void set_fin_vars(
- void);
-
-static void unset_fin_vars(
- void);
-
-#define PREDEFINED_FIN_VARS 9
-
-/* define local financial variables
- */
-static unsigned npp;
-static double ir;
-static double pv;
-static double pmt;
-static double fv;
-static unsigned CF;
-static unsigned PF;
-static unsigned disc;
-static unsigned bep;
-
-/* define local variable for roundoff precesion
- * default here to value for US currency
- */
-static unsigned prec = 2;
-
-/* declare array of structures for local financial variables
- */
-static var_store predefined_fin_vars[PREDEFINED_FIN_VARS];
-
-/* declare array of finacial varibale names used by user to access financial variables
- */
-static char *fin_var_names[] =
-{
- "n",
- "i",
- "pv",
- "pmt",
- "fv",
- "CF",
- "PF",
- "disc",
- "bep",
-};
-
-/* declare array of financial variables
- */
-static void *fin_vars[] =
-{
- (void *)&npp,
- (void *)&ir,
- (void *)&pv,
- (void *)&pmt,
- (void *)&fv,
- (void *)&CF,
- (void *)&PF,
- (void *)&disc,
- (void *)&bep,
-};
-
-/* declare array of financial variable basic numeric types
- */
-static char fin_type[] =
-{
- INT_TYPE,
- DBL_TYPE,
- DBL_TYPE,
- DBL_TYPE,
- DBL_TYPE,
- INT_TYPE,
- INT_TYPE,
- INT_TYPE,
- INT_TYPE,
-};
-
-static char sl_commands[] = "acdqsv";
-
-/* function to set local financial variables into array for use by expression parser
- * as pre-defined variables
- */
-static void set_fin_vars(
- void)
-{
- unsigned cntr;
- numeric_ptr value;
-
- for ( cntr = 0 ; cntr < PREDEFINED_FIN_VARS ; cntr++ )
- {
- predefined_fin_vars[cntr].variable_name = fin_var_names[cntr];
- predefined_fin_vars[cntr].assign_flag = EOS;
- predefined_fin_vars[cntr].value = value = (numeric_ptr)calloc(1, sizeof(numeric));
- predefined_fin_vars[cntr].next_var = &predefined_fin_vars[cntr + 1];
- switch ( value->type = fin_type[cntr] )
- {
- case INT_TYPE:
- value->value.int_value = *(unsigned *)(fin_vars[cntr]);
- break;
- case DBL_TYPE:
- value->value.dbl_value = *(double *)(fin_vars[cntr]);
- break;
- } /* endswitch */
- } /* endfor */
- predefined_fin_vars[PREDEFINED_FIN_VARS - 1].next_var = NULL;
-} /* set_fin_vars */
-
-/* free storage used by local financial variables
- */
-static void unset_fin_vars(
- void)
-{
- unsigned cntr;
- numeric_ptr value;
-
- for ( cntr = 0 ; cntr < PREDEFINED_FIN_VARS ; cntr++ )
- {
- free(predefined_fin_vars[cntr].value);
- } /* endfor */
-} /* unset_fin_vars */
-
-/* check variable set by expression parser against local financial variables
- * and update local values as necessary. Also convert variables to proper type
- * to reflect the native type of the local variable
- */
-void chk_vars(
- var_store_ptr predefined_vars,
- void **var_array,
- char *var_type,
- unsigned var_cnt)
-{
- unsigned cntr;
- numeric_ptr value;
-
- for ( cntr = 0 ; cntr < var_cnt ; cntr++ )
- {
- if ( predefined_vars[cntr].assign_flag == ASSIGNED_TO )
- {
- predefined_vars[cntr].assign_flag = EOS;
- value = (numeric_ptr)(predefined_vars[cntr].value);
- switch ( var_type[cntr] )
- {
- case INT_TYPE:
- switch ( value->type )
- {
- case INT_TYPE:
- *(int *)(var_array[cntr]) = value->value.int_value;
- break;
- case DBL_TYPE:
- value->value.int_value =
- *(int *)(var_array[cntr]) = (unsigned)(value->value.dbl_value);
- value->type = INT_TYPE;
- break;
- } /* endswitch */
- break;
- case DBL_TYPE:
- switch ( value->type )
- {
- case INT_TYPE:
- value->value.dbl_value =
- *(double *)(var_array[cntr]) = (double)(value->value.int_value);
- value->type = DBL_TYPE;
- break;
- case DBL_TYPE:
- *(double *)(var_array[cntr]) = value->value.dbl_value;
- break;
- } /* endswitch */
- break;
- } /* endswitch */
- } /* endif */
- } /* endfor */
-} /* chk_fin_vars */
-
-/* error encountered by expression parser - output error message
- * and offending string
- */
-void parse_error(unsigned error_code,
- char *buf_start,
- char *buf_err)
-{
- char *err_str;
- unsigned bc = (unsigned)(buf_err - buf_start);
-
- switch ( error_code )
- {
- case UNBALANCED_PARENS:
- err_str = "Unbalanced Parenthesis\n";
- break;
- case STACK_OVERFLOW:
- err_str = "Stack Overflow\n";
- break;
- case STACK_UNDERFLOW:
- err_str = "Stack Underflow\n";
- break;
- case UNDEFINED_CHARACTER:
- err_str = "Unrecognized Character\n";
- break;
- case NOT_A_VARIABLE:
- err_str = "Need a Variable on Left side of assignment operator, '='\n";
- break;
- case NOT_A_FUNC:
- err_str = "Need a valid Function name.\n";
- break;
-
- } /* endswitch */
- printf(err_str);
- printf("%s\n", buf_start);
- if ( bc ) for ( bc - 1 ; bc ; bc-- ) printf(" ");
- printf("^");
- /* printf("%s\n",buf_err + 1); */
- printf("\n");
-} /* parse_error */
-
-int main(int argc, char **argv, char **env)
-{
- char buffer[200], *errp;
- size_t sbuf;
- size_t retcnt;
- var_store value;
- var_store_ptr value_list;
- numeric_ptr nval;
- unsigned compute,
- jj,
- yrE,
- monthE,
- dayE,
- yrI,
- monthI,
- dayI;
- struct tm *times_E,
- *times_I;
- void *parse_env;
- amort_sched amortsched;
- financial_info fininfo;
-
- /* check dynamic storage allocation
- */
- /* mtrace(); */
- set_default(&fininfo);
- set_fin_vars();
- parse_env = init_parser(predefined_fin_vars,
- '.',
- ',',
- trans_numeric,
- numeric_ops,
- negate_numeric,
- free_numeric);
-
- npp = fininfo.npp;
- ir = fininfo.ir;
- pv = fininfo.pv;
- pmt = fininfo.pmt;
- fv = fininfo.fv;
- CF = fininfo.CF;
- PF = fininfo.PF;
- disc = fininfo.disc;
- bep = fininfo.bep;
-
- fininfo.prec = prec;
-
- printf("Single Letter Commands:\na -- amortization schedule\nc -- compute financial variable\nd -- delete variable\ns -- output financial variable status\nq -- quit\nv -- list defined variables\n");
- for (;;)
-{
- printf("<>");
- retcnt = strlen(fgets(buffer, 190, stdin));
- if ( (retcnt == 2) && (strchr(sl_commands, buffer[0]) != NULL) )
- {
- if ( buffer[0] == 'q' ) break;
- amortsched.prec = fininfo.prec;
- switch ( buffer[0] )
- {
- case 'a':
- if ( amortsched.Eff_Date_jdn && amortsched.Init_Date_jdn )
- {
- printf("Current Effective year: %u\nCurrent Effective month: %u\nCurrent Effective day: %u\nCurrent Initial year: %u\nCurrent Initial month: %u\nCurrent Initial day %u\n",
- amortsched.year_E,
- amortsched.month_E,
- amortsched.day_E,
- amortsched.year_I,
- amortsched.month_I,
- amortsched.day_I);
- printf("Change dates ? (y/n) ");
- fgets(buffer, 190, stdin);
- }
- else
- {
- buffer[0] = 'y';
- } /* endif */
- if ( buffer[0] == 'y' )
- {
- printf("Enter Effective Date - year: ");
- fgets(buffer, 190, stdin);
- if ( (errp = parse_string(&value, buffer, parse_env)) == NULL )
- {
- nval = (numeric_ptr)(value.value);
- switch ( nval->type )
- {
- case INT_TYPE:
- amortsched.year_E = nval->value.int_value;
- break;
- case DBL_TYPE:
- amortsched.year_E = (unsigned)(nval->value.dbl_value);
- break;
- } /* endswitch */
- if ( !value.variable_name ) free_numeric(value.value);
- }
- else
- {
- parse_error(get_parse_error(parse_env), buffer, errp);
- } /* endif */
- printf("Enter Effective Date - month: ");
- fgets(buffer, 190, stdin);
- if ( (errp = parse_string(&value, buffer, parse_env)) == NULL )
- {
- nval = (numeric_ptr)(value.value);
- switch ( nval->type )
- {
- case INT_TYPE:
- amortsched.month_E = nval->value.int_value;
- break;
- case DBL_TYPE:
- amortsched.month_E = (unsigned)(nval->value.dbl_value);
- break;
- } /* endswitch */
- if ( !value.variable_name ) free_numeric(value.value);
- }
- else
- {
- parse_error(get_parse_error(parse_env), buffer, errp);
- } /* endif */
- printf("Enter Effective Date - day: ");
- fgets(buffer, 190, stdin);
- if ( (errp = parse_string(&value, buffer, parse_env)) == NULL )
- {
- nval = (numeric_ptr)(value.value);
- switch ( nval->type )
- {
- case INT_TYPE:
- amortsched.day_E = nval->value.int_value;
- break;
- case DBL_TYPE:
- amortsched.day_E = (unsigned)(nval->value.dbl_value);
- break;
- } /* endswitch */
- if ( !value.variable_name ) free_numeric(value.value);
- }
- else
- {
- parse_error(get_parse_error(parse_env), buffer, errp);
- } /* endif */
- printf("Enter Initial Payment Date - year: ");
- fgets(buffer, 190, stdin);
- if ( (errp = parse_string(&value, buffer, parse_env)) == NULL )
- {
- nval = (numeric_ptr)(value.value);
- switch ( nval->type )
- {
- case INT_TYPE:
- amortsched.year_I = nval->value.int_value;
- break;
- case DBL_TYPE:
- amortsched.year_I = (unsigned)(nval->value.dbl_value);
- break;
- } /* endswitch */
- if ( !value.variable_name ) free_numeric(value.value);
- }
- else
- {
- parse_error(get_parse_error(parse_env), buffer, errp);
- } /* endif */
- printf("Enter Initial Payment Date - month: ");
- fgets(buffer, 190, stdin);
- if ( (errp = parse_string(&value, buffer, parse_env)) == NULL )
- {
- nval = (numeric_ptr)(value.value);
- switch ( nval->type )
- {
- case INT_TYPE:
- amortsched.month_I = nval->value.int_value;
- break;
- case DBL_TYPE:
- amortsched.month_I = (unsigned)(nval->value.dbl_value);
- break;
- } /* endswitch */
- if ( !value.variable_name ) free_numeric(value.value);
- }
- else
- {
- parse_error(get_parse_error(parse_env), buffer, errp);
- } /* endif */
- printf("Enter Initial Payment Date - day: ");
- fgets(buffer, 190, stdin);
- if ( (errp = parse_string(&value, buffer, parse_env)) == NULL )
- {
- nval = (numeric_ptr)(value.value);
- switch ( nval->type )
- {
- case INT_TYPE:
- amortsched.day_I = nval->value.int_value;
- break;
- case DBL_TYPE:
- amortsched.day_I = (unsigned)(nval->value.dbl_value);
- break;
- } /* endswitch */
- if ( !value.variable_name ) free_numeric(value.value);
- }
- else
- {
- parse_error(get_parse_error(parse_env), buffer, errp);
- } /* endif */
- } /* endif */
-
- amortsched.n = npp;
- amortsched.nint = ir;
- amortsched.pv = pv;
- amortsched.pmt = pmt;
- amortsched.fv = fv;
- amortsched.CF = CF;
- amortsched.PF = PF;
- amortsched.disc = disc;
- amortsched.bep = bep;
-
- Amortization_init(&amortsched);
- amort_opt(&amortsched, parse_env);
-
- (void)Amortization_Schedule(&amortsched);
- prt_amortization_schedule(&amortsched, stdout);
- Amortization_free(&amortsched);
- break;
- case 'c':
-
- printf("Compute:\nn - 1\ni - 2\npv - 3\npmt - 4\nfv - 5\n1, 2, 3, 4 or 5: ");
- retcnt = strlen(fgets(buffer, 190, stdin));
- compute = buffer[0] - '0';
-
- switch ( compute-- )
- {
- case 0: /* all values specified nothing to compute */
- break;
- case 1: /* compute number of periods, npp */
- printf("Computing numbor of periods\n");
- npp = fi_calc_num_payments(&fininfo);
- printf("Number of Periods: %u\n", npp);
- nval = (numeric_ptr)(predefined_fin_vars[compute].value);
- nval->value.int_value = npp;
- break;
- case 2: /* compute interest, ir */
- printf("Computing interest rate\n");
- ir = fi_calc_interest(&fininfo);
- printf("Nominal Interest Rate: %.*f\n", prec, ir);
- nval = (numeric_ptr)(predefined_fin_vars[compute].value);
- nval->value.dbl_value = ir;
- break;
- case 3: /* compute present value, pv */
- printf("Computing Present Value\n");
- pv = fi_calc_present_value(&fininfo);
- printf("Present Value: %.*f\n", prec, pv);
- nval = (numeric_ptr)(predefined_fin_vars[compute].value);
- nval->value.dbl_value = pv;
- break;
- case 4: /* compute periodic payment, pmt */
- printf("Computing periodic payment\n");
- pmt = fi_calc_payment(&fininfo);
- printf("Periodic Payment: %.*f\n", prec, pmt);
- nval = (numeric_ptr)(predefined_fin_vars[compute].value);
- nval->value.dbl_value = pmt;
- break;
- case 5: /* compute future value, fv */
- printf("Computing Future Value\n");
- fv = fi_calc_future_value(&fininfo);
- printf("Future Value: %.*f\n", prec, fv);
- nval = (numeric_ptr)(predefined_fin_vars[compute].value);
- nval->value.dbl_value = fv;
- break;
- default: /* whoops */
- break;
- } /* endswitch */
- break;
- case 'd':
- printf("Enter name of variable to delete: ");
- retcnt = strlen(fgets(buffer, 190, stdin));
- buffer[retcnt - 1] = EOS;
- if ( !delete_var(buffer, parse_env) )
- {
- printf("Unable to delete specified variable\n");
- } /* endif */
- break;
- case 's':
- prt_status(&fininfo,
- stdout);
- break;
- case 'v':
- for ( value_list = parser_get_vars(parse_env) ; value_list ; value_list = value_list->next_var )
- {
- printf("%s: ", value_list->variable_name);
- nval = (numeric_ptr)(value_list->value);
- switch ( nval->type )
- {
- case INT_TYPE:
- printf("%i\n", nval->value.int_value);
- break;
- case DBL_TYPE:
- printf("%.*f\n", prec, nval->value.dbl_value);
- break;
- } /* endswitch */
- } /* endfor */
- break;
- } /* endswitch */
- }
- else if ( retcnt > 1 )
- {
- buffer[retcnt - 1] = EOS;
-
- if ( (errp = parse_string(&value, buffer, parse_env)) == NULL )
- {
- if ( value.variable_name ) printf("Variable: %s\n", value.variable_name);
- nval = (numeric_ptr)(value.value);
- switch ( nval->type )
- {
- case INT_TYPE:
- printf("Evaluated Value: %i\n", nval->value.int_value);
- break;
- case DBL_TYPE:
- printf("Evaluated Value: %.*f\n", prec, nval->value.dbl_value);
- break;
- } /* endswitch */
- if ( !value.variable_name ) free_numeric(value.value);
- chk_vars(predefined_fin_vars, fin_vars, fin_type, PREDEFINED_FIN_VARS);
- fininfo.npp = npp;
- fininfo.ir = ir;
- fininfo.pv = pv;
- fininfo.pmt = pmt;
- fininfo.fv = fv;
- fininfo.CF = CF;
- fininfo.PF = PF;
- fininfo.disc = disc;
- fininfo.bep = bep;
- }
- else
- {
- parse_error(get_parse_error(parse_env), buffer, errp);
- } /* endif */
- } /* endif */
- } /* endfor */
- exit_parser(parse_env);
- unset_fin_vars();
-} /* main */
-
-static void prt_status(
- fi_ptr fi,
- FILE *ofile)
-{
- fprintf(ofile, "<================================>\nCurrent Financial Calculator Status:\n");
- fprintf(ofile, "Compounding Frequency: (CF) %u\n", fi->CF);
- fprintf(ofile, "Payment Frequency: (PF) %u\n", fi->PF);
- fprintf(ofile, "Compounding: %s\n", fi->disc ? "Discrete (disc = TRUE)" : "Continuous (disc = FALSE)");
- fprintf(ofile, "Payments: %s\n", fi->bep ? "Beginning of Period (bep = TRUE)" : "End of Period (bep = FALSE)");
- if ( fi->npp > 12 ) fprintf(ofile, "Number of Payment Periods (n): %u\t\t(Years: %u)\n", fi->npp, fi->npp / fi->PF);
- else fprintf(ofile, "Number of Payment Periods (n): %u\n", fi->npp);
- if ((fi->CF == 1) && (fi->PF == 1) ) fprintf(ofile, "Nominal Interest per Payment Period (i): %f\t(Annualized: %.*f\n", fi->ir, fi->prec, fi->ir * 12);
- else fprintf(ofile, "Nominal Annual Interest Rate (i): %.*f\n", fi->prec, fi->ir);
- /* fprintf(ofile, " Effective Interest Rate Per Payment Period: %f\n",eff_int(nint/100.0,CF,PF)); */
- fprintf(ofile, "Present Value (pv): %.*f\n", fi->prec, fi->pv);
- fprintf(ofile, "Periodic Payment (pmt): %.*f\n", fi->prec, fi->pmt);
- fprintf(ofile, "Future Value (fv): %.*f\n<================================>\n", fi->prec, fi->fv);
-} /* prt_status */
Deleted: gnucash/trunk/src/calculation/fin-main.c
===================================================================
--- gnucash/trunk/src/calculation/fin-main.c 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/fin-main.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,160 +0,0 @@
-/***************************************************************************
- fin-main.c - description
- -------------------
- begin : Thursday June 15 2000
- email : tboldt at attglobal.net
- Author : Terry D. Boldt
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-/*
- * Functions to call financial equations and output results
- * 6-15-2000
- *
- */
-
-#include <stdio.h>
-
-#include "finvar.h"
-#include "finproto.h"
-
-static void prt_status(
- fi_ptr fi,
- FILE *ofile);
-
-int main(int argc, char **argv, char **env)
-{
- financial_info fininfo;
- amort_sched amortsched;
-
- set_default(&fininfo);
- fininfo.prec = 2;
-
- fininfo.npp = 360;
- fininfo.ir = 8.25;
- fininfo.pv = 345725.0;
-
- (void)fi_calc_payment(&fininfo);
- printf("With npp == %u\n ir == %.*f\n pv == %.*f\n", fininfo.npp, fininfo.prec, fininfo.ir, fininfo.prec, fininfo.pv);
- printf("------------>Compute pmt: -2597.32\n");
- prt_status(&fininfo,
- stdout);
-
- fi_calc_interest(&fininfo);
- printf("\n------------>Compute ir\n");
- prt_status(&fininfo,
- stdout);
-
- fi_calc_num_payments(&fininfo);
- printf("\n------------>Compute npp\n");
- prt_status(&fininfo,
- stdout);
-
- fi_calc_future_value(&fininfo);
- printf("\n------------>Compute fv\n");
- prt_status(&fininfo,
- stdout);
-
- set_default(&fininfo);
-
- fininfo.npp = 360;
- fininfo.ir = 8.25;
- fininfo.pv = 345725.0;
- fi_calc_payment(&fininfo);
-
- printf("\n\n Reset financial variables and compute amortization schedules.\n");
- printf("First Schedule - ignore delay in first payment and\noutput annual summary\n");
-
- amortsched.n = fininfo.npp;
- amortsched.nint = fininfo.ir;
- amortsched.pv = fininfo.pv;
- amortsched.pmt = fininfo.pmt;
- amortsched.fv = fininfo.fv;
- amortsched.CF = fininfo.CF;
- amortsched.PF = fininfo.PF;
- amortsched.disc = fininfo.disc;
- amortsched.bep = fininfo.bep;
- amortsched.prec = fininfo.prec;
- amortsched.year_E = 1999;
- amortsched.month_E = 6;
- amortsched.day_E = 15;
- amortsched.year_I = 1999;
- amortsched.month_I = 8;
- amortsched.day_I = 1;
- amortsched.fixed_pmt = -400;
-
- (void)Amortization_init(&amortsched);
-
- amortsched.option = 3;
- amortsched.summary = 'y';
- (void)Amortization_Schedule(&amortsched);
- prt_amortization_schedule(&amortsched, stdout);
-
- printf("\n\nSecond Schedule - ignore delay in first payment and\noutput schedule for each payment\n");
- amortsched.summary = 'p';
- (void)Amortization_Schedule(&amortsched);
- prt_amortization_schedule(&amortsched, stdout);
-
-
- printf("\n\nThird Schedule - ignore delay in first payment and\noutput variable advanced prepayment schedule\n");
- amortsched.summary = 'a';
- (void)Amortization_Schedule(&amortsched);
- prt_amortization_schedule(&amortsched, stdout);
-
- printf("\n\nFourth Schedule - ignore delay in first payment and\noutput fixed prepayment schedule\n");
- amortsched.summary = 'f';
- (void)Amortization_Schedule(&amortsched);
- prt_amortization_schedule(&amortsched, stdout);
-
- printf("\n\nFifth Schedule - use new payments due to delay and\noutput annual summary\n");
- amortsched.option = 5;
- amortsched.summary = 'y';
- (void)Amortization_Schedule(&amortsched);
- prt_amortization_schedule(&amortsched, stdout);
-
- printf("\n\nSixth Schedule - use new payments due to delay and\noutput periodic payment schedule\n");
- amortsched.option = 5;
- amortsched.summary = 'p';
- (void)Amortization_Schedule(&amortsched);
- prt_amortization_schedule(&amortsched, stdout);
-
- printf("\n\nSeventh Schedule - use new payments due to delay and\noutput variable prepayment schedule\n");
- amortsched.option = 5;
- amortsched.summary = 'a';
- (void)Amortization_Schedule(&amortsched);
- prt_amortization_schedule(&amortsched, stdout);
-
- printf("\n\nEighth Schedule - use new payments due to delay and\noutput fixed prepayment schedule\n");
- amortsched.option = 5;
- amortsched.summary = 'f';
- (void)Amortization_Schedule(&amortsched);
- prt_amortization_schedule(&amortsched, stdout);
- Amortization_free(&amortsched);
-} /* main */
-
-static void prt_status(
- fi_ptr fi,
- FILE *ofile)
-{
- fprintf(ofile, "<================================>\nCurrent Financial Calculator Status:\n");
- fprintf(ofile, "Compounding Frequency: (CF) %u\n", fi->CF);
- fprintf(ofile, "Payment Frequency: (PF) %u\n", fi->PF);
- fprintf(ofile, "Compounding: %s\n", fi->disc ? "Discrete (disc = TRUE)" : "Continuous (disc = FALSE)");
- fprintf(ofile, "Payments: %s\n", fi->bep ? "Beginning of Period (bep = TRUE)" : "End of Period (bep = FALSE)");
- if ( fi->npp > 12 ) fprintf(ofile, "Number of Payment Periods (n): %u\t\t(Years: %u)\n", fi->npp, fi->npp / fi->PF);
- else fprintf(ofile, "Number of Payment Periods (n): %u\n", fi->npp);
- if ((fi->CF == 1) && (fi->PF == 1) ) fprintf(ofile, "Nominal Interest per Payment Period (i): %f\t(Annualized: %.*f\n", fi->ir, fi->prec, fi->ir * 12);
- else fprintf(ofile, "Nominal Annual Interest Rate (i): %.*f\n", fi->prec, fi->ir);
- /* fprintf(ofile, " Effective Interest Rate Per Payment Period: %f\n",eff_int(nint/100.0,CF,PF)); */
- fprintf(ofile, "Present Value (pv): %.*f\n", fi->prec, fi->pv);
- fprintf(ofile, "Periodic Payment (pmt): %.*f\n", fi->prec, fi->pmt);
- fprintf(ofile, "Future Value (fv): %.*f\n", fi->prec, fi->fv);
-} /* prt_status */
Deleted: gnucash/trunk/src/calculation/fin-proto.sh
===================================================================
--- gnucash/trunk/src/calculation/fin-proto.sh 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/fin-proto.sh 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,26 +0,0 @@
-#! /bin/sh
-#/***************************************************************************
-# fin-proto.sh - description
-# -------------------
-# copyright : (C) 2000 by Terry D. Boldt
-# email : tboldt at attglobal.net
-# Author : Terry D. Boldt
-# ***************************************************************************/
-#
-#/***************************************************************************
-# * *
-# * This program is free software; you can redistribute it and/or modify *
-# * it under the terms of the GNU General Public License as published by *
-# * the Free Software Foundation; either version 2 of the License, or *
-# * (at your option) any later version. *
-# * *
-# ***************************************************************************/
-#
-# shell script for creating function prototype files
-#
-qtgrep -DHhf cfuncs.exp fin.c expression_parser.c numeric_ops.c amort_opt.c amort_prt.c >protos.out
-echo Creating Global Prototype File: \"finproto.h\"
-qtawk -f protos.exp protos.out >finproto.h
-echo Creating Static Prototype File: \"fin_static_proto.h\"
-qtawk -f static_protos.exp protos.out >fin_static_proto.h
-rm -fv protos.out
Deleted: gnucash/trunk/src/calculation/fin.c
===================================================================
--- gnucash/trunk/src/calculation/fin.c 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/fin.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,2478 +0,0 @@
-/***************************************************************************
- fin.c - description
- -------------------
- begin : Thursday June 15 2000
- email : tboldt at attglobal.net
- Author : Terry D. Boldt
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-/*
- * Functions to compute financial equations and amortization schedules
- * 6-15-2000
- *
- */
-
-/*
- * Financial Calculator
- *
- * This version for use WITH ANSI.SYS display driver
- *
- * This is a complete financial computation utility to solve for the
- * five * standard financial values: n, %i, PV, PMT and FV
- *
- * n == number of payment periods
- * %i == nominal interest rate, NAR, charged
- * PV == Present Value
- * PMT == Periodic Payment
- * FV == Future Value
- *
- * In addition, two additional parameters may be specified:
- *
- * 1) Compounding Frequency per year, CF. The compounding frequency
- * per year may be discrete or continuous and may be different from
- * the Payment Frequency per year
- *
- * 2) Payment Frequency per year, PF. Payments may be made at the
- * beginning or the end of the payment period.
- *
- * When an amortization schedule is desired, the financial
- * transaction Effective Date, ED, and Initial Payment Date, IP, must
- * also be entered.
- *
- * Canadian and European style mortgages can be handled in a simple,
- * straight-forward manner. Standard financial sign conventions are
- * used:
- *
- * "Money paid out is Negative, Money received is Positive"
- *
- * Time value of money:
- *
- * If you borrow money, you can expect to pay rent or interest for its use;
- * conversely you expect to receive rent interest on money you loan or invest.
- * When you rent property, equipment, etc., rental payments are normal; this
- * is also true when renting or borrowing money. Therefore, money is
- * considered to have a "time value". Money available now, has a greater value
- * than money available at some future date because of its rental value or the
- * interest that it can produce during the intervening period.
- *
- * Simple Interest:
- *
- * If you loaned $800 to a friend with an agreement that at the end of one
- * year he would would repay you $896, the "time value" you placed on your
- * $800 (principal) was $96 (interest) for the one year period (term) of the
- * loan. This relationship of principal, interest, and time (term) is most
- * frequently expressed as an Annual Percentage Rate (APR). In this case the
- * APR was 12.0% [(96/800)*100]. This example illustrates the four basic
- * factors involved in a simple interest case. The time period (one year),
- * rate (12.0% APR), present value of the principal ($800) and the future
- * value of the principal including interest ($896).
- *
- * Compound Interest:
- *
- * In many cases the interest charge is computed periodically during the term
- * of the agreement. For example, money left in a savings account earns
- * interest that is periodically added to the principal and in turn earns
- * additional interest during succeeding periods. The accumulation of interest
- * during the investment period represents compound interest. If the loan
- * agreement you made with your friend had specified a "compound interest
- * rate" of 12% (compounded monthly) the $800 principal would have earned
- * $101.46 interest for the one year period. The value of the original $800
- * would be increased by 1% the first month to $808 which in turn would be
- * increased by 1% to 816.08 the second month, reaching a future value of
- * $901.46 after the twelfth iteration. The monthly compounding of the nominal
- * annual rate (NAR) of 12% produces an effective Annual Percentage Rate (APR)
- * of 12.683% [(101.46/800)*100]. Interest may be compounded at any regular
- * interval; annually, semiannually, monthly, weekly, daily, even continuously
- * (a specification in some financial models).
- *
- * Periodic Payments:
- *
- * When money is loaned for longer periods of time, it is customary for the
- * agreement to require the borrower to make periodic payments to the lender
- * during the term of the loan. The payments may be only large enough to repay
- * the interest, with the principal due at the end of the loan period (an
- * interest only loan), or large enough to fully repay both the interest and
- * principal during the term of the loan (a fully amoritized loan). Many loans
- * fall somewhere between, with payments that do not fully cover repayment of
- * both the principal and interst. These loans require a larger final payment
- * (balloon) to complete their amortization. Payments may occur at the
- * beginning or end of a payment period. If you and your friend had agreed on
- * monthly repayment of the $800 loan at 12% NAR compounded monthly, twelve
- * payments of $71.08 for a total of $852.96 would be required to amortize the
- * loan. The $101.46 interest from the annual plan is more than the $52.96
- * under the monthly plan because under the monthly plan your friend would not
- * have had the use of $800 for a full year.
- *
- * Financial Transactions:
- *
- * The above paragraphs introduce the basic factors that govern most
- * financial transactions; the time period, interest rate, present value,
- * payments and the future value. In addition, certain conventions must be
- * adhered to: the interest rate must be relative to the compounding frequency
- * and payment periods, and the term must be expressed as the total number of
- * payments (or compounding periods if there are no payments). Loans, leases,
- * mortgages, annuities, savings plans, appreciation, and compound growth are
- * amoung the many financial problems that can be defined in these terms. Some
- * transactions do not involve payments, but all of the other factors play a
- * part in "time value of money" transactions. When any one of the five (four
- * - if no payments are involved) factors is unknown, it can be derived from
- * formulas using the known factors.
- *
- * Standard Financial Conventions Are:
- *
- * Money RECEIVED is a POSITIVE value and is represented by an arrow
- * above * the line
- *
- * Money PAID OUT is a NEGATIVE value and is represented by an arrow
- * below * the line.
- *
- * If payments are a part of the transaction, the number of payments
- * must * equal the number of periods (n).
- *
- * Payments may be represented as occuring at the end or beginning of
- * the * periods.
- *
- * Diagram to visualize the positive and negative cash flows (cash
- * flow * diagrams):
- *
- * Amounts shown above the line are positve, received, and amounts
- * shown below the line are negative, paid out.
- *
- * 1)
- * FV*
- * 1 2 3 4 . . . . . . . . . n ³
- * Period ÚÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ
- * ³
- *
- * PV
- *
- * Appreciation
- * Depreciation
- * Compound Growth
- * Savings Account
- *
- * ****************************************************************************
- *
- * 2) FV
- * PV = 0
- * ³
- * Period ÚÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÙ
- * ³ 1 ³ 2 ³ 3 ³ 4 ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ n
- *
- * PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT
- *
- * Annuity (series of payments)
- * Pension Fund
- * Savings Plan
- * Sinking Fund
- *
- * ****************************************************************************
- *
- * 3)
- * PV
- * ³ FV=0
- * Period ÀÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿
- * 1 ³ 2 ³ 3 ³ 4 ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ n ³
- *
- * PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT
- *
- * Amortization
- * Direct Reduction Loan
- * Mortgage (fully amortized)
- *
- * ****************************************************************************
- *
- * 4)
- * FV*
- * PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT PMT ³ +
- * PMT
- * 1 ³ 2 ³ 3 ³ 4 ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ . ³ n ³
- * Period ÚÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ
- * ³
- *
- * PV
- *
- * Annuity
- * Lease (with buy back or residual)*
- * Loan or Mortgage (with balloon)*
- *
- * ****************************************************************************
- *
- * First lets discuss interest before discussing the financial
- * equation. Most financial transactions utilize a nominal interest
- * rate, NAR, i.e., the interest rate per year. The NAR must be
- * converted to the interest rate per payment interval and the
- * compounding accounted for before it can be used in computing an
- * interest payment. After this conversion process, the interest
- * used is the effective interest rate, EIR. In converting NAR to
- * EIR, there are two concepts to discuss first, the Compounding
- * Frequency and the Payment Frequency and * whether the interest is
- * coumpounded in discrete intervals or continuously. The
- * compounding Frequency, CF, is simply the number of times per
- * year, the monies in the financial transaction are compounded. In
- * the U.S., monies are usually compounded daily on bank deposits,
- * and monthly on loans. Somtimes Long term deposits are compounded
- * quarterly or weekly.
- *
- * The Payment Frequency, PF, is simply how often during a year
- * payments are made in the transaction. Payments are usually
- * scheduled on a regular basis and can be made at the beginning or
- * end of the payment period. If made at the beginning of the
- * payment period, interest must be applied to the payment as well
- * as any previous money paid or money still owed.
- *
- * Normal values for CF and PF are:
- * 1 == annual
- * 2 == semi-annual
- * 3 == tri-annual
- * 4 == quaterly
- * 6 == bi-monthly
- * 12 == monthly
- * 24 == semi-monthly
- * 26 == bi-weekly
- * 52 == weekly
- * 360 == daily
- * 365 == daily
- *
- * a) the Compounding Frequency per year, CF, need not be identical
- * to the Payment Frequency per year, PF, and/or,
- *
- * b) Interest may be compounded in either discrete intervals or continuously
- * compounded.
- *
- * c) Also, payments may be made at the beginning of the payment
- * period or at the end of the payment period.
- *
- * CF and PF are defaulted to 1. The default is for discrete interest
- * intervals and payments are defaulted to the end of the payment
- * period.
- *
- * When a solution for n, PV, PMT or FV is required, the nominal interest
- * rate, i, must first be converted to the effective interest rate per payment
- * period. This rate, ieff, is then used to compute the selected variable. To
- * convert i to ieff, the following expressions are used:
- *
- * Discrete interest periods:
- *
- * 19) ieff = (1 + i/CF)^(CF/PF) - 1
- *
- * Continuous Interest
- *
- * 20) ieff = e^(i/PF) - 1 = exp(i/PF) - 1
- *
- * When interest is computed, the computation produces the effective interest
- * rate, ieff. This value must then be converted to the nominal interest rate.
- * Function _I below returns the nominal interest rate NOT the effective
- * interest rate. ieff is converted to i using the following expressions:
- *
- * Discrete Case:
- *
- * i = CF*[(1+ieff)^(PF/CF) - 1]
- *
- * Continuous Case:
- *
- * i = ln[(1+ieff)^PF]
- *
- * ****************************************************************************
- *
- * NOTE: in the equations below for the financial transaction, all
- * interest rates are the effective interest rate, ieff. The symbol
- * will be shortned to just 'i'.
- *
- * ****************************************************************************
- *
- * The basic financial equation used is:
- *
- * 1) PV*(1 + i)^n + PMT*(1 + iX)*[(1+i)^n - 1]/i + FV = 0
- * Where: X = 0 for end of period payments, and
- * X = 1 for beginning of period payments
- *
- * ****************************************************************************
- *
- * NOTE: this equation is derived in the following manner:
- *
- * Start with the basic equation to find the balance or Present
- * Value, PV[1], after one payment period. Note PV[1] is the Present
- * value after on payment and PV[0] is the initial Present
- * Value. PV[0] will be shortened to just PV.
- *
- * The interest due at the end of the first payment period is:
- *
- * ID[1] = (PV + X * PMT) * i
- * where: X = 0 for end of period payments, and
- * X = 1 for beginning of period payments.
- *
- * Thus:
- * PV[1] = PV + (PMT + ID[1])
- * = PV + (PMT + (PV + X * PMT) * i)
- * = PV * (1 + i) + PMT * (1 + Xi)
- *
- * This equation works for all of the money diagrams shown
- * above. The Present Value, money received or paid, is modified by
- * a payment made at the beginning of a payment period and
- * multiplied by the effective interest rate to compute the interest
- * due during the payment period. The interest due is then added to
- * the payment to obtain the amount to be added to the Present Value
- * to compute the new Present Value.
- *
- * For diagram 1): PV < 0, PMT == 0, PV[1] < 0
- * For diagram 2): PV == 0, PMT < 0, PV[1] < 0
- * For Diagram 3): PV > 0, PMT < 0, PV[1] >= 0 or PV[1] <= 0
- * For Diagram 4): PV < 0, PMT > 0, PV[1] <= 0 or PV[1] >= 0
- *
- * X may be 0 or 1 for any diagram.
- *
- * For the standard loan, PV is the money borrowed, PMT is the
- * periodic payment to repay the loan and i is the effective
- * interest rate agreed upon.
- *
- * To calculate the Present Value after the second payment period,
- * the above calculation is applied iteratively to PV_1:
- *
- * PV[2] = PV[1] + (PMT + (PV[1] + X * PMT) * i)
- * = PV[1] * (1 + i) + PMT * (1 + iX)
- * = (PV * (1 + i) + PMT * (1 + iX)) * (1 + i) + PMT * (1 + iX)
- * = PV * (1 + i)^2 + PMT * (1 + iX) * (1 + i)
- * + PMT * (1 + iX)
- *
- * Similarly:
- *
- * PV[3] = PV[2] + (PMT + (PV[2] + X * PMT) * i)
- * = PV[2] * (1 + i) + PMT * (1 + iX)
- * = PV * (1 + i)^2 + PMT * (1 + iX) * (1 + i)
- * + PMT * (1+ iX)) * ( 1 + i)
- * + PMT * (1+ iX)
- * = PV * (1 + i)^3 + PMT * (1 + iX) * (1 + i)^2
- * + PMT * (1 + iX) * (1 + i)^2
- * + PMT * (1 + iX) * (1 + i)
- * + PMT * (1 + iX)
- *
- * And for the n'th payment:
- *
- * PV[n] = PV[n-1] + (PMT + (PV[n-1] + X * PMT) * i)
- * PV[n] = PV * (1 + i)^n + PMT * (1 + iX) * (1 + i)^(n-1)
- * + PMT * (1 + iX) * (1 + i)^(n-2) +
- * .
- * .
- * .
- * + PMT * (1 + iX) * (1 + i)
- * + PMT * (1 + iX)
- * PV[n] = PV * (1 + i)^n + PMT * (1 + iX) * [(1 + i)^(n-1) + ...
- * + (1 + i) + 1]
- *
- * ****************************************************************************
- *
- * The sum of the finite series:
- *
- * 1 + k + (k^2) + (k^3) + ... + (k^n) = (1-k^(n+1))/(1-k)
- *
- * as can be seen by the following. Let S(n) be the series sum. Then
- *
- * S(n) - k * S(n) = 1 - k^(n+1)
- *
- * and solving for S(n):
- *
- * S(n) = [1-k^(n+1)]/[1-k] = 1 + k + (k^2) + (k^3) + ... + (k^n)
- *
- * ****************************************************************************
- *
- * PV[n] = PV * (1 + i)^n + PMT * (1 + iX) * [(1 + i)^(n-1) + ...
- * + (1 + i) + 1]
- * = PV * (1 + i)^n + PMT * (1 + iX) * [1 - (1 + i)^n]/[1 - (1 + i)]
- * = PV * (1 + i)^n + PMT * (1 + iX) * [1 - (1 + i)^n]/[-i]
- * = PV * (1 + i)^n + PMT * (1 + iX) * [(1 + i)^n - 1]/i
- *
- * The formaula for PV[n] can be proven using mathematical induction.
- *
- * or:
- *
- * PV * (1 + i)^n + PMT * [(1 + i)^n - 1]/i - PV[n] = 0
- *
- * If after n payments, the remaining balance is repaid as a lump
- * sum, the lump sum is known as the Future Value, FV[n]. Since
- * FV[n] is negative if paid and positive if received, FV[n] is the
- * negative of PV[n]. Since n is assumed to be the last payment,
- * FV[n] will be shortened to simply FV.
- *
- * Setting: FV = -PV[N]
- *
- * 1) PV*(1 + i)^n + PMT*(1 + iX)*[(1 + i)^n - 1]/i + FV = 0
- *
- * Up to this point, we have said nothing about the value of
- * PMT. PMT can be any value mutually agreed upon by the lender and
- * the borrower. From the equation for PV[1]:
- *
- * PV[1] = PV + (PMT + (PV + X * PMT) * i),
- *
- * Several things can be said about PMT.
- *
- * 1. If PMT = PV * i, and X = 0 (end of period payments):
- *
- * The payment is exactly equal to the interest due and PV[1] =
- * PV. In this case, the borrower must make larger future
- * payments to reduce the balance due, or make a single payment,
- * after some agreed upon number of payments, with PMT = PV to
- * completely pay off the loan. This is an interest only payment
- * with a balloon payment at the end.
- *
- * 2. If PMT < PV * i, and X = 0
- *
- * The payment is insufficient to cover even the interest charged
- * and the balance due grows
- *
- * 3. If PMT > PV * i, and X = 0
- *
- * The payment is sufficient to cover the interest charged with a
- * residual amount to be applied to reduce the balance due. The
- * larger the residual amount, the faster the loan is repaid. For
- * most mortgages or other loans made today, the lender and
- * borrower agree upon a certain number of repayment periods and
- * the interest to be charged per payment period. The interest
- * may be multiplied by 12 and stated as an annual interest
- * rate. Then the lender and borrower want to compute a periodic
- * payment, PMT, which will reduce the balance due to zero after
- * the agreed upon number of payment have been made. If N is the
- * agreed upon number of periodic payments, then we want to use:
- *
- * PV * (1 + i)^N + PMT*(1 +iX)*[(1 + i)^N - 1]/i + FV = 0
- *
- * with FV = 0 to compute PMT:
- *
- * PMT = -[PV * i * (1 + i)^(N - X)]/[(1 + i)^N - 1]
- *
- * The value of PMT computed will reduce the balance due to zero
- * after N periodic payments.
- *
- * ****************************************************************************
- *
- *
- * With a simple alegebraic re-arrangement, The financial Equation becomes:
- *
- * 2) [PV + PMT*(1 + iX)/i][(1 + i)^n - 1] + PV + FV = 0
- *
- * or
- *
- * 3) (PV + C)*A + PV + FV = 0
- *
- * where:
- * 4) A = (1 + i)^n - 1
- *
- * 5) B = (1 + iX)/i
- *
- * 6) C = PMT*B
- *
- * The form of equation 3) simplifies the calculation procedure for all five
- * variables, which are readily solved as follows:
- *
- * 7) n = ln[(C - FV)/(C + PV)]/ln((1 + i)
- *
- * 8) PV = -[FV + A*C]/(A + 1)
- *
- * 9) PMT = -[FV + PV*(A + 1)]/[A*B]
- *
- * 10) FV = -[PV + A*(PV + C)]
- *
- * Equations 4), 5) and 6) are computed by functions:
- *
- * _A
- * _B
- * _C
- *
- * respectively. Equations 7), 8), 9) and 10) are computed by functions:
- *
- * _N
- * _PV
- * _PMT
- * _FV
- *
- * respectively.
- *
- * The solution for interest is broken into two cases:
- *
- * PMT == 0
- * i = [FV/PV]^(1/n) - 1
- *
- * PMT != 0
- *
- * Since equation 3) cannot be solved explicitly for i in this
- * case, an iterative technique must be employed. Newton's
- * method, using exact expressions for the function of i and its
- * derivative, are employed. The expressions are:
- *
- * 12) i[k+1] = i[k] - f(i[k])/f'(i[k])
- * where: i[k+1] == (k+1)st iteration of i
- * i[k] == kth iteration of i
- * and:
- *
- * 13) f(i) = A*(PV+C) + PV + FV
- *
- * 14) f'(i) = n*D*(PV+C) - (A*C)/i
- *
- * 15) D = (1 + i)^(n-1) = (A+1)/(1+i)
- *
- * To start the iterative solution for i, an initial guess must be made
- * for the value of i. The closer this guess is to the actual value,
- * the fewer iterations will have to be made, and the greater the
- * probability that the required solution will be obtained. The initial
- * guess for i is obtained as follows:
- *
- * if PMT*FV >= 0, then PV case
- * if PMT*FV < 0, then FV case
- *
- * PV case:
- * | n*PMT + PV + FV |
- * 16) i[0] = | ----------------|
- * | n*PV |
- *
- * = abs[(n*PMT + PV + FV)/(n*PV)]
- *
- * FV case:
- * a) PV != 0
- *
- * | FV - n*PMT |
- * 17) i[0] = |---------------------------|
- * | 3*[PMT*(n-1)^2 + PV - FV] |
- *
- * = abs[(FV-n*PMT)/(3*(PMT*(n-1)^2+PV-FV))]
- * b) PV == 0
- *
- * | FV + n*PMT |
- * 18) i[0] = |---------------------------|
- * | 3*[PMT*(n-1)^2 + PV - FV] |
- *
- * = abs[(FV+n*PMT)/(3*(PMT*(n-1)^2+PV-FV))]
- *
- * ****************************************************************************
- * Constant payment to principal loan
- *
- * In this loan, each total payment is different, with each
- * succeeding payment less than the preceeding payment. Each payment
- * is the total of the constant ammount to the principal plus the
- * interest for the period. The constant payment to the principal is
- * computed as:
- *
- * C = -PV / N
- *
- * Where PV is the loan amount to be repaid in N payments
- * (periods). Note that the constant payment to principal could be
- * any value agreed to by the two parties involved.
- *
- * Thus the principal after the first payment is:
- * PV[1] = PV[0] + C = PV + C
- * after the second payment, the principal is:
- * PV[2] = PV[1] + C = PV[0] + 2C
- * In general, the remaining principal after n payments is:
- * PV[n] = PV[0] + nC = PV + nC
- *
- * If the effective interest per payment period is i, then the
- * interest for the first payment is:
- *
- * I[1] = -i*PV[0] = -i*PV
- * and for the second:
- * I[2] = -i * PV[1]
- * and in general, for the n'th payment the interest is:
- * I[n] = -i * PV[n-1]
- * = -i * (PV + (n-1)C)
- * The total payment for any period, n, is:
- * P[n] = C + I[n]
- * = C + i * (PV + (n-1)C)
- * = C(1 + i) - i * (PV + nC)
- * The total interest paid to period n is:
- * T[n] = I[1] + I[2] + I[3] + ... + I[n]
- * T[n] = sum(j = 1 to n: I[j])
- * T[n] = sum(j = 1 to n: -i * (PV + (j-1)C))
- * T[n] = sum(j=1 to n: -i*PV) + sum(j=1 to n: iC) + sum(j=1 to n: -iCj)
- * T[n] = -i*n*PV + i*n*C - i*C*sum(j=1 to n:j)
- * sum(j=1 to n:j) = n(n+1)/2
- * T[n] = -i*n*(PV + C) - i*C*n(n+1)/2
- * T[n] = -i*n*(PV + (C*(n - 1)/2))
- *
- * Note: substituing for C = -PV/N, in the equations for PV[n], I[n],
- * P[n], and T[n] would give the following equations:
- *
- * PV[n] = PV*(1 - n/N)
- * I[n] = -i*PV*(1 + N - n)/N
- * P[n] = -i*PV*(2 + N - n)/N
- * T[n] = -i*n*PV*(2*N - n + 1)/(2*N)
- *
- * Using these equations for the calculations would eliminate the
- * dependence on C, but only if C is always defined as above and
- * would eliminate the possibility of another value for C. If the
- * value of C was less than -PV/N then a balloon payment would be
- * due at the final payment and this is a possible alternative for
- * some people.
- *
- * ****************************************************************************
- *
- * Amortization Schedules.
- *
- * Financial Transactions have an effective Date, ED, and an Initial Payment
- * Date, IP. ED may or may not be the same as IP, but IP is always the same
- * or later than ED. Most financial transaction calculators assume that
- * IP is equal to ED for beginning of period payments or at the end of the
- * first payment period for end of period payments.
- *
- * This is not always true. IP may be delayed for financial reasons
- * such as cash flow or accounting calender. The subsequent payments
- * then follow the agreed upon periodicity. Since money has a time
- * value, the "delayed" IP must be accounted for. Computing an
- * "Effective PV", pve, is one means of handling a delayed IP.
- *
- * EDj == the Julian Day Number of ED, and
- * IPj == the Julian Day Number of IP in the following.
- *
- * pve is be computed as:
- *
- * pve = pv*(1 + i)^(s*PF/d*CF)
- *
- * Where: d = length of the payment period in days, and
- * s = IPj - EDj - d*X
- *
- * Computing an amortization Schedule for a given financial transaction is
- * simply applying the basic equation iteratively for each payment period:
- *
- * PV[n] = PV[n-1] + (PMT + (PV[n-1] + X * PMT) * i)
- *
- * At the end of each iteration, PV[n] is rounded to the nearest cent. For
- * each payment period, the interest due may be computed separately as:
- *
- * ID[n] = (PMT + (PV[n-1] + X * PMT) * i)
- *
- * and rounded to the nearest cent. PV[n] then becomes:
- *
- * PV[n] = PV[n-1] + PMT + ID[n]
- *
- * For those cases where a yearly summary only is desired, it is not
- * necessary to compute each transaction for each payment period,
- * rather the PV may be be computed for the beginning of each year,
- * PV[yr], and the FV computed for the end of the year, FV[yr]. The
- * interest paid during the year is the computed as:
- *
- * ID[yr] = (NP * PMT) + PV[yr] + FV[yr]
- *
- * Since the final payment may not be equal to the periodic payment,
- * the final payment must be computed separately as follows. Two
- * derivations are given below for the final payment equation. Both
- * derivations are given below since one or the other may be clearer
- * to some readers. Both derivations are essentially the same, they
- * just have different starting points. The first is the fastest.
- *
- * 1) final_pmt == final payment @ payment n == int(n)
- * from above the basic financial equation:
- * PV[n] = PV[n-1]*(1 + i) + final_pmt * (1 + iX),
- * i == effective interest rate
- *
- * solving for final_pmt, we have:
- *
- * final_pmt * (1 + iX) = PV[n] - PV[n-1]*(1 + i)
- * = FV[n-1]*(1 + i) - FV[n]
- * final_pmt = FV[n-1]*(1+i)/(1 + iX) - FV[n]/(1 + iX)
- *
- * final_pmt = FV[n-1]*(1 + i) - FV[n],
- * for X == 0, end of period payments
- *
- * = FV[n-1] - FV[n]/(1 + i),
- * for X == 1, beginning of period payments
- *
- * 2) final_pmt == final payment @ payment n == int(n)
- * i[n] == interest due @ payment n
- * i[n] = (PV[n-1] + X * final_pmt) * i, i == effective interest rate
- * = (X * final_pmt - FV[n]) * i
- *
- * Now the final payment is the sum of the interest due, plus
- * the present value at the next to last payment plus any
- * residual future value after the last payment:
- *
- * final_pmt = -i[n] - PV[n-1] - FV[n]
- * = FV[n-1] - i[n] - FV[n]
- * = FV[n-1] - (X *final_pmt - FV[n-1])*i - FV[n]
- * = FV[n-1]*(1 + i) - X*final_pmt*i - FV[n]
- *
- * solving for final_pmt:
- * final_pmt*(1 + iX) = FV[n-1]*(1 + i) - FV[n]
- * final_pmt = FV[n-1]*(1 + i)/(1 + iX) - FV[n]/(1 + iX)
- *
- * final_pmt = FV[n-1]*(1 + i) - FV[n],
- * for X == 0, end of period payments
- *
- * = FV[n-1] - FV[n]/(1 + i),
- * for X == 1, beginning of period payments
- *
- *============================================================================
- *
- * The amortization schedule is computed for four different situations:
- *
- * 1) The original financial data is used. This ignores any possible
- * agjustment to the Present value due to any delay in the initial
- * payment. This is quite common in mortgages where end of period
- * payments are used and the first payment is scheduled for the end
- * of the first whole period, i.e., any partial payment period from
- * ED to the beginning of the next payment period is ignored.
- *
- * 2) The original periodic payment is used, the Present Value is
- * adjusted for the delayed Initial Payment. The total number of
- * payments remains the same. The final payment is adjusted to bring
- * the balance into agreement with the agreed upon final Future
- * Value.
- *
- * 3) A new periodic payment is computed based upon the adjusted
- * Present Value, the agreed originally upon number of total
- * payments and the agreed upon Future Value. The new periodic
- * payments are computed to minimize the final payment in accordance
- * with the Future Value after the last payment.
- *
- * 4) The original periodic payment is retained and a new number of
- * total payments is computed based upon the adjusted Present Value
- * and the agreed upon Future Value.
- *
- * The amortization schedule may be computed and displayed in three manners:
- *
- * 1. The payment *, interest paid, principal paid and remaining PV
- * for each payment period are computed and displayed. At the end of
- * each year a summary is computed and displayed and the total
- * interest paid is diplayed at the end.
- *
- * 2. A summary is computed and displayed for each year. The
- * interest paid during the year is computed and displayed as well
- * as the remaining balance at years end. The total interest paid
- * is diplayed at the end.
- *
- * 3. An amortization schedule is computed for a common method of
- * advanced payment of principal is computed and displayed. In this
- * amortization, the principal for the next payment is computed and
- * added into the current payment. This method will cut the number
- * of total payments in half and will cut the interest paid almost
- * in half. For mortgages, this method of prepayment has the
- * advantage of keeping the total payments small during the initial
- * payment periods The payments grow until the last payment period
- * when presumably the borrower can afford larger payments.
- *
- * ===========================================================================
- * NOTE: For Payment Frequencies, PF, semi-monthly or less, i.e., PF
- * == 12 or PF == 24, a 360 day calender year and 30 day month are
- * used. For Payment Frequencies, PF, greater than semi-monthly, PF
- * > 24, the actual number of days per year and per payment period
- * are used. The actual values are computed using the built-in
- * 'julian_day_number' function
- *
- * ****************************************************************************
- *
- * Note: in the following examples, the user input is preceeded by the
- * prompt "<>". The result of evaluating the input expression is then
- * displayed. I have taken the liberty of including comments in the
- * example input/output sessions by preceeding with ' *'. Thus, for
- * the line: <>n=5 *set number of periods the comment that setting the
- * number of periods is not really input and the true input is only:
- * <>n=5
- *
- * Example 1: Simple Interest
- * Find annual simple interest rate (%) for an $800 loan to be repayed at the
- * end of one year with a single payment of $896.
- * <>d
- * <>CF=PF=1
- * 1.00
- * <>n=1
- * 1.00
- * <>pv=-800
- * -800.00
- * <>fv=896
- * 896.00
- * <>I
- * 12.00
- *
- * Example 2: Compound Interest
- * Find the future value of $800 after one year at a nominal rate of 12%
- * compounded monthly. No payments are specified, so the payment frequency is
- * set equal to the compounding frequency at the default values.
- * <>d
- * <>n=12
- * 12.00
- * <>i=12
- * 12.00
- * <>pv=-800
- * -800.00
- * <>FV
- * 901.46
- *
- * Example 3: Periodic Payment:
- * Find the monthly end-of-period payment required to fully amortize the loan
- * in Example 2. A fully amortized loan has a future value of zero.
- * <>fv=0
- * 0.00
- * <>PMT
- * 71.08
- *
- * Example 4: Conventional Mortgage
- *
- * Find the number of monthly payments necessary to fully amortize a
- * loan of $100,000 at a nominal rate of 13.25% compounded monthly, if
- * monthly end-of-period payments of $1125.75 are made.
- *
- * <>d
- * <>i=13.25
- * 13.25
- * <>pv=100000
- * 100,000.00
- * <>pmt=-1125.75
- * -1,125.75
- * <>_N(i,pv,pmt,fv,CF,PF,disc,bep)
- * 360.10
- * <>N
- * 360
- *
- * Example 5: Final Payment
- * Using the data in example 4, find the amount of the final payment if n is
- * changed to 360. The final payment will be equal to the regular payment plus
- * any balance, future value, remaining at the end of period number 360.
- * <>n=360
- * 360.00
- * <>FV
- * -108.87
- * <>pmt+fv
- * -1,234.62
- *
- * Using the data from this loan, compute the amortization schedule
- * when the Effective date of the loan is June 6, 1996 and the
- * initial payment is made on August 1, 1996. Ignore any change in
- * the PV due to the delayed initial payment caused by the partial
- * payment period from June 6 to July 1.
- *
- * <>ED = 06/06/1996
- * Effective Date set: 06/06/1996 ( 2450241 )
- * <>IP = 08/01/1996
- * Initial Payment Date set: 08/01/1996 ( 2450297 )
- * <>a
- * Effective Date: 06/06/96
- * Initial Payment Date: 08/01/96
- * The amortization options are:
- * The Old Present Value (pv) was: 100,000.00
- * The Old Periodic Payment (pmt) was: -1,125.75
- * The Old Future Value (fv) was: -108.87
- * 1: Amortize with Original Transaction Values
- * and balloon final payment: -1,125.75
- *
- * The New Present Value (pve) is: 100,919.30
- * The New Periodic Payment (pmt) is: -1,136.10
- * 2: Amortize with Original Periodic Payment
- * and balloon final payment: -49,023.68
- * 3: Amortize with New Periodic Payment
- * and balloon final payment: -1,132.57
- * 4: Amortize with Original Periodic Payment,
- * new number of total payments (n): 417
- * and final payment: -2,090.27
- *
- * Enter choice 1, 2, 3 or 4: <>
- *
- * Press '1'
- * Amortization Schedule:
- * Yearly, y, per Payment, p, or Advanced Payment, a, Amortization
- * Enter choice y, p or a:
- * <>
- *
- * Press 'y'
- * Enter Filename for Amortization Schedule.
- * (null string uses Standard Output):
- * Press enter to display output on screen
- *
- * Amortization Table
- * Effective Date: Thu Jun 06 00:00:00 1996
- * Initial Payment Date: Thu Aug 01 00:00:00 1996
- * Compounding Frequency per year: 12
- * Payment Frequency per year: 12
- * Compounding: Discrete
- * Payments: End of Period
- * Payments (359): -1,125.75
- * Final payment: -1,125.75
- * Nominal Annual Interest Rate: 13.25
- * Effective Interest Rate Per Payment Period: 0.0110417
- * Present Value: 100,000.00
- * Year Interest Ending Balance
- * 1996 -5,518.42 -99,889.67
- * 1997 -13,218.14 -99,598.81
- * 1998 -13,177.17 -99,266.98
- * 1999 -13,130.43 -98,888.41
- * 2000 -13,077.11 -98,456.52
- * 2001 -13,016.28 -97,963.80
- * 2002 -12,946.88 -97,401.68
- * 2003 -12,867.70 -96,760.38
- * 2004 -12,777.38 -96,028.76
- * 2005 -12,674.33 -95,194.09
- * 2006 -12,556.76 -94,241.85
- * 2007 -12,422.64 -93,155.49
- * 2008 -12,269.63 -91,916.12
- * 2009 -12,095.06 -90,502.18
- * 2010 -11,895.91 -88,889.09
- * 2011 -11,668.70 -87,048.79
- * 2012 -11,409.50 -84,949.29
- * 2013 -11,113.78 -82,554.07
- * 2014 -10,776.41 -79,821.48
- * 2015 -10,391.53 -76,704.01
- * 2016 -9,952.43 -73,147.44
- * 2017 -9,451.49 -69,089.93
- * 2018 -8,879.99 -64,460.92
- * 2019 -8,227.99 -59,179.91
- * 2020 -7,484.16 -53,155.07
- * 2021 -6,635.56 -46,281.63
- * 2022 -5,667.43 -38,440.06
- * 2023 -4,562.94 -29,494.00
- * 2024 -3,302.89 -19,287.89
- * 2025 -1,865.36 -7,644.25
- * 2026 -236.00 -108.87
- *
- * Total Interest: -305,270.00
- *
- * NOTE: The amortization table leaves the FV as it was when the amortization
- * function was entered. Thus, a balance of 108.87 is due at the end of the
- * table. To completely pay the loan, set fv to 0.0:
- * <>fv=0
- * 0.0
- * <>a
- * Effective Date: 06/06/96
- * Initial Payment Date: 08/01/96
- * The amortization options are:
- * The Old Present Value (pv) was: 100,000.00
- * The Old Periodic Payment (pmt) was: -1,125.75
- * The Old Future Value (fv) was: 0.00
- * 1: Amortize with Original Transaction Values
- * and balloon final payment: -1,234.62
- *
- * The New Present Value (pve) is: 100,919.30
- * The New Periodic Payment (pmt) is: -1,136.12
- * 2: Amortize with Original Periodic Payment
- * and balloon final payment: -49,132.55
- * 3: Amortize with New Periodic Payment
- * and balloon final payment: -1,148.90
- * 4: Amortize with Original Periodic Payment,
- * new number of total payments (n): 417
- * and final payment: -2,199.14
- *
- * Enter choice 1, 2, 3 or 4: <>
- * Press '1'
- * Amortization Schedule:
- * Yearly, y, per Payment, p, or Advanced Payment, a, Amortization
- * Enter choice y, p or a:
- * <>
- * Press 'y'
- * Enter Filename for Amortization Schedule.
- * (null string uses Standard Output):
- * Press enter to display output on screen
- *
- * Amortization Table
- * Effective Date: Thu Jun 06 00:00:00 1996
- * Initial Payment Date: Thu Aug 01 00:00:00 1996
- * Compounding Frequency per year: 12
- * Payment Frequency per year: 12
- * Compounding: Discrete
- * Payments: End of Period
- * Payments (359): -1,125.75
- * Final payment: -1,234.62
- * Nominal Annual Interest Rate: 13.25
- * Effective Interest Rate Per Payment Period: 0.0110417
- * Present Value: 100,000.00
- * Year Interest Ending Balance
- * 1996 -5,518.42 -99,889.67
- * 1997 -13,218.14 -99,598.81
- * 1998 -13,177.17 -99,266.98
- * 1999 -13,130.43 -98,888.41
- * 2000 -13,077.11 -98,456.52
- * 2001 -13,016.28 -97,963.80
- * 2002 -12,946.88 -97,401.68
- * 2003 -12,867.70 -96,760.38
- * 2004 -12,777.38 -96,028.76
- * 2005 -12,674.33 -95,194.09
- * 2006 -12,556.76 -94,241.85
- * 2007 -12,422.64 -93,155.49
- * 2008 -12,269.63 -91,916.12
- * 2009 -12,095.06 -90,502.18
- * 2010 -11,895.91 -88,889.09
- * 2011 -11,668.70 -87,048.79
- * 2012 -11,409.50 -84,949.29
- * 2013 -11,113.78 -82,554.07
- * 2014 -10,776.41 -79,821.48
- * 2015 -10,391.53 -76,704.01
- * 2016 -9,952.43 -73,147.44
- * 2017 -9,451.49 -69,089.93
- * 2018 -8,879.99 -64,460.92
- * 2019 -8,227.99 -59,179.91
- * 2020 -7,484.16 -53,155.07
- * 2021 -6,635.56 -46,281.63
- * 2022 -5,667.43 -38,440.06
- * 2023 -4,562.94 -29,494.00
- * 2024 -3,302.89 -19,287.89
- * 2025 -1,865.36 -7,644.25
- * 2026 -344.87 0.00
- *
- * Total Interest: -305,378.87
- *
- * Example 6: Balloon Payment
- * On long term loans, small changes in the periodic payments can generate
- * large changes in the future value. If the monthly payment in example 5 is
- * rounded down to $1125, how much addtional (balloon) payment will be due
- * with the final regular payment.
- * <>pmt=-1125
- * -1,125
- * <>FV
- * -3,579.99
- *
- * Example 7: Canadian Mortgage
- * Find the monthly end-of-period payment necessary to fully amortize a 25 year
- * $85,000 loan at 11% compounded semi-annually.
- * <>d
- * <>CF=2
- * 2.00
- * <>n=300
- * 300.00
- * <>i=11
- * 11.00
- * <>pv=85000
- * 85,000.00
- * <>PMT
- * -818.15
- *
- * Example 8: European Mortgage
- * The "effective annual rate (EAR)" is used in some countries (especially
- * in Europe) in lieu of the nominal rate commonly used in the United States
- * and Canada. For a 30 year $90,000 mortgage at 14% (EAR), compute the monthly
- * end-of-period payments. When using an EAR, the compounding frequency is
- * set to 1.
- * <>d
- * <>CF=1
- * 1.00
- * <>n=30*12
- * 360.00
- * <>i=14
- * 14.00
- * <>pv=90000
- * 90,000.00
- * <>PMT
- * -1,007.88
- *
- * Example 9: Bi-weekly Savings
- * Compute the future value, fv, of bi-weekly savings of $100 for 3 years at a
- * nominal annual rate of 5.5% compounded daily. (Set payment to
- * beginning-of-period, bep = TRUE)
- * <>d
- * <>bep=TRUE
- * 1.00
- * <>CF=365
- * 365.00
- * <>PF=26
- * 26.00
- * <>n=3*26
- * 78.00
- * <>i=5.5
- * 5.50
- * <>pmt=-100
- * -100.00
- * <>FV
- * 8,489.32
- *
- * Example 10: Present Value - Annuity Due
- * What is the present value of $500 to be received at the beginning of each
- * quarter over a 10 year period if money is being discounted at 10% nominal
- * annual rate compounded monthly?
- * <>d
- * <>bep=TRUE
- * 1.00
- * <>PF=4
- * 4.00
- * <>n=4*10
- * 40.00
- * <>i=10
- * 10.00
- * <>pmt=500
- * 500.00
- * <>PV
- * -12,822.64
- *
- * Example 11: Effective Rate - 365/360 Basis
- * Compute the effective annual rate (%APR) for a nominal annual rate of 12%
- * compounded on a 365/360 basis used by some Savings & Loan Associations.
- * <>d
- * <>n=365
- * 365.00
- * <>CF=365
- * 365.00
- * <>PF=360
- * 360.00
- * <>i=12
- * 12.00
- * <>pv=-100
- * -100.00
- * <>FV
- * 112.94
- * <>fv+pv
- * 12.94
- *
- * Example 12: Mortgage with "Points"
- *
- * What is the true APR of a 30 year, $75,000 loan at a nominal rate
- * of 13.25% compounded monthly, with monthly end-of-period payments,
- * if 3 "points" are charged? The pv must be reduced by the dollar
- * value of the points and/or any lenders fees to establish an
- * effective pv. Because payments remain the same, the true APR will
- * be higher than the nominal rate. Note, first compute the payments
- * on the pv of the loan amount.
- *
- * <>d
- * <>CF=PF=1
- * 1.00
- * <>n=30*12
- * 360.00
- * <>i=13.25/12
- * 1.10
- * <>pv=75000
- * 75,000.00
- * <>PMT
- * -844.33
- * <>pv -= pv*.03
- * 72,750.00
- * <>CF=PF=12
- * 12.00
- * <>I
- * 13.69
- *
- * Example 13: Equivalent Payments
- * Find the equivalent monthly payment required to amortize a 20 year $40,000
- * loan at 10.5% nominal annual rate compounded monthly, with 10 annual
- * payments of $5029.71 remaining. Compute the pv of the remaining annual
- * payments, then change n, the number of periods, and the payment frequency,
- * PF, to a monthly basis and compute the equivalent monthly pmt.
- * <>d
- * <>PF=1
- * 1.00
- * <>n=10
- * 10.00
- * <>i=10.5
- * 10.50
- * <>pmt=-5029.71
- * -5,029.71
- * <>PV
- * 29,595.88
- * <>PF=12
- * 12.00
- * <>n=120
- * 120.00
- * <>PMT
- * -399.35
- *
- * Example 14: Perpetuity - Continuous Compounding
- * If you can purchase a single payment annuity with an initial investment of
- * $60,000 that will be invested at 15% nominal annual rate compounded
- * continuously, what is the maximum monthly return you can receive without
- * reducing the $60,000 principal? If the principal is not disturbed, the
- * payments can go on indefinitely (a perpetuity). Note that the term,n, of
- * a perpetuity is immaterial. It can be any non-zero value.
- * <>d
- * <>disc=FALSE
- * 0.00
- * <>n=12
- * 12.00
- * <>CF=1
- * 1.00
- * <>i=15
- * 15.00
- * <>fv=60000
- * 60,000.00
- * <>pv=-60000
- * -60,000.00
- * <>PMT
- * 754.71
- *
- * references:
- * 1. PPC ROM User's Manual
- * pages 148 - 164
- *
- */
-
-#include <time.h>
-#include <stdio.h>
-#include <glib.h>
-#include <math.h>
-#if defined(G_OS_WIN32) && !defined(_MSC_VER)
-#include <pow.h>
-#endif
-#include <string.h>
-#include <stdlib.h>
-
-#define FIN_STATICS
-#include "finvar.h"
-#include "finproto.h"
-#include "fin_static_proto.h"
-
-/* return 'x' rounded to 'places' past decimal if 'places' < 0, return
- * 'x' */
-static double
-rnd (double x, unsigned places)
-{
- double r;
- char buf[50]; /* make buffer large enough */
-
- if (places >= 0)
- {
- sprintf (buf, "%.*f", (int) places, x);
- r = strtod(buf, NULL);
- }
- else
- r = x;
-
- return r;
-} /* rnd */
-
-/* return absolute value of 'x' this function is provided by a macro
- * in C */
-static double
-dabs (double x)
-{
- return (x >= 0.0) ? x : -x;
-} /* dabs */
-
-/* Compute constant used in calculations */
-static double
-_A (double eint, unsigned per)
-{
- return pow ((1.0 + eint), (double) per) - 1.0;
-} /* _A */
-
-/* Compute constant used in calculations */
-static double
-_B (double eint, unsigned beg)
-{
- /* if eint == 0.0, all processing _must_ stop or
- a recursive loop will start. */
- g_return_val_if_fail(eint != 0.0, 0.0);
- return (1.0 + eint * (double) beg) / eint;
-} /* _B */
-
-/* Compute constant used in calculations */
-static double
-_C (double eint, double pmt, unsigned beg)
-{
- g_return_val_if_fail(eint != 0.0, 0.0);
- return pmt * _B(eint, beg);
-} /* _C */
-
-/* compute Number of Periods from preset data */
-unsigned
-fi_calc_num_payments (fi_ptr fi)
-{
- return fi->npp =
- (unsigned)
- rnd (_fi_calc_num_payments
- (fi->ir, fi->pv, fi->pmt, fi->fv, fi->CF, fi->PF, fi->disc, fi->bep),
- 0);
-} /* fi_calc_num_payments */
-
-/* Compute number of periods from:
- * 1. Nominal Interest
- * 2. Present Value
- * 3. Periodic Payment
- * 4. Future Value
- */
-double
-_fi_calc_num_payments (double nint, /* nominal interest rate */
- double pv, /* present value */
- double pmt, /* periodic payment */
- double fv, /* future value */
- unsigned CF, /* compounding frequency */
- unsigned PF, /* payment frequency */
- unsigned disc, /* discrete/continuous compounding */
- unsigned bep) /* beginning/end of period payment */
-{
- double eint = eff_int (nint / 100.0, CF, PF, disc);
- double CC = _C (eint, pmt, bep);
- CC = (CC - fv) / (CC + pv);
- return (CC > 0.0) ? log (CC) / log (1.0 + eint) : 0.0;
-} /* _fi_calc_num_payments */
-
-/* compute Interest from preset data */
-double
-fi_calc_interest (fi_ptr fi)
-{
- if (fi->npp)
- fi->ir = _fi_calc_interest (fi->npp, fi->pv, fi->pmt, fi->fv,
- fi->CF, fi->PF, fi->disc, fi->bep);
-
- return fi->ir;
-} /* fi_calc_interest */
-
-double ratio = 1e4; /* ratio used in iterative solution for interest */
-
-/* Compute Nominal Interest from:
- * 1. Number of periods
- * 2. Present Value
- * 3. Periodic Payment
- * 4. Future Value
- */
-double
-_fi_calc_interest (unsigned per,/* number of periods */
- double pv, /* present value */
- double pmt, /* periodic payment */
- double fv, /* future value */
- unsigned CF, /* compounding frequency */
- unsigned PF, /* payment frequency */
- unsigned disc, /* discrete/continuous compounding */
- unsigned bep) /* beginning/end of period payment */
-{
- double eint;
- double a, dik;
- int ri;
-
- if (pmt == 0.0)
- eint = pow ((dabs (fv) / dabs (pv)), (1.0 / (double) per)) - 1.0;
- else
- {
- if ((pmt * fv) < 0.0)
- {
- if (pv)
- a = -1.0;
- else
- a = 1.0;
- eint =
- dabs ((fv + a * (double) per * pmt) /
- (3.0 *
- (((double) per - 1.0) * ((double) per - 1.0) * pmt + pv -
- fv)));
- }
- else
- {
- if ((pv * pmt) < 0.0)
- {
- eint = dabs (((double) per * pmt + pv + fv) / ((double) per * pv));
- }
- else
- {
- a = dabs (pmt / (dabs (pv) + dabs (fv)));
- eint = a + 1.0 / (a * (double) per * (double) per * (double) per);
- }
- }
- do
- {
- dik =
- fi (per, eint, pv, pmt, fv, bep) / fip (per, eint, pv, pmt, fv, bep);
- eint -= dik;
- (void) modf (ratio * (dik / eint), &a);
- ri = (unsigned) a;
- }
- while (ri);
- } /* endif */
-
- return 100.0 * nom_int (eint, CF, PF, disc);
-} /* _fi_calc_interest */
-
-/* compute Present value from preset data */
-double
-fi_calc_present_value (fi_ptr fi)
-{
- return fi->pv =
- rnd (_fi_calc_present_value
- (fi->npp, fi->ir, fi->pmt, fi->fv, fi->CF, fi->PF, fi->disc,
- fi->bep), fi->prec);
-} /* fi_calc_present_value */
-
-/* Compute Present Value from:
- * 1. Number of periods
- * 2. Nominal Interest
- * 3. Periodic Payment
- * 4. Future Value
- */
-double
-_fi_calc_present_value (unsigned per, /* number of periods */
- double nint, /* nominal interest rate */
- double pmt, /* periodic payment */
- double fv, /* future value */
- unsigned CF, /* compounding frequency */
- unsigned PF, /* payment frequency */
- unsigned disc, /* discrete/continuous compounding */
- unsigned bep) /* beginning/end of period payment */
-{
- double eint = eff_int (nint / 100.0, CF, PF, disc);
- double AA = _A (eint, per);
- double CC = _C (eint, pmt, bep);
-
- return -(fv + (AA * CC)) / (AA + 1.0);
-} /* _fi_calc_present_value */
-
-/* compute Periodic Payment from preset data */
-double
-fi_calc_payment (fi_ptr fi)
-{
- return fi->pmt =
- rnd (_fi_calc_payment
- (fi->npp, fi->ir, fi->pv, fi->fv, fi->CF, fi->PF, fi->disc, fi->bep),
- fi->prec);
-} /* fi_calc_payment */
-
-/* Compute Periodic Payment from:
- * 1. Number of periods
- * 2. Nominal Interest
- * 3. Present Value
- * 4. Future Value
- */
-double
-_fi_calc_payment (unsigned per, /* number of periods */
- double nint, /* nominal interest rate */
- double pv, /* present value */
- double fv, /* future value */
- unsigned CF, /* compounding frequency */
- unsigned PF, /* payment frequency */
- unsigned disc,/* discrete/continuous compounding */
- unsigned bep) /* beginning/end of period payment */
-{
- double eint = eff_int (nint / 100.0, CF, PF, disc);
- double AA = _A (eint, per);
- double BB = _B (eint, bep);
- g_return_val_if_fail(BB != 0.0, 0.0);
-
- return -(fv + pv * (AA + 1.0)) / (AA * BB);
-} /* _fi_calc_payment */
-
-/* compute Future Value from preset data */
-double
-fi_calc_future_value (fi_ptr fi)
-{
- return fi->fv =
- rnd (_fi_calc_future_value
- (fi->npp, fi->ir, fi->pv, fi->pmt, fi->CF, fi->PF, fi->disc,
- fi->bep), fi->prec);
-} /* fi_calc_future_value */
-
-/* Compute Future Value from:
- * 1. Number of periods
- * 2. Nominal Interest
- * 3. Present Value
- * 4. Periodic Payments
- */
-double
-_fi_calc_future_value (unsigned per, /* number of periods */
- double nint, /* nominal interest rate */
- double pv, /* present value */
- double pmt, /* periodic payment */
- unsigned CF, /* compounding frequency */
- unsigned PF, /* payment frequency */
- unsigned disc, /* discrete/continuous compounding */
- unsigned bep) /* beginning/end of period payment */
-{
- double eint = eff_int (nint / 100.0, CF, PF, disc);
- double AA = _A (eint, per);
- double CC = _C (eint, pmt, bep);
-
- return -(pv + AA * (pv + CC));
-} /* _fi_calc_future_value */
-
-/* compute Nominal Interest Rate from Effective Interest Rate */
-static double
-nom_int (double eint, unsigned CF, unsigned PF, unsigned disc)
-{
- double nint;
-
- if (disc)
- {
- if (CF == PF)
- {
- nint = CF * eint;
- }
- else
- {
- nint = CF * (pow ((1.0 + eint), ((double) PF / (double) CF)) - 1.0);
- } /* * endif */
- }
- else
- nint = log (pow (1.0 + eint, PF));
-
- return nint;
-} /* nom_int */
-
-/* Compute Effective Interest Rate from Nominal Interest Rate */
-static double
-eff_int (double nint, unsigned CF, unsigned PF, unsigned disc)
-{
- double eint;
-
- if (disc)
- {
- if (CF == PF)
- {
- eint = nint / (double) CF;
- }
- else
- {
- eint =
- pow ((1.0 + nint / (double) CF), ((double) CF / (double) PF)) - 1.0;
- } /* endif */
- }
- else
- eint = exp (nint / (double) PF) - 1.0;
-
- return eint;
-} /* eff_int */
-
-/* calculation used in interest computation */
-static double
-fi (unsigned per, double eint, double pv, double pmt, double fv, unsigned bep)
-{
- return _A (eint, per) * (pv + _C (eint, pmt, bep)) + pv + fv;
-} /* fi */
-
-/* calculation used in interest computation
- */
-static double
-fip (unsigned per, double eint, double pv, double pmt, double fv, unsigned bep)
-{
- double AA = _A (eint, per);
- double CC = _C (eint, pmt, bep);
- double D = (AA + 1.0) / (1.0 + eint);
- g_return_val_if_fail(CC != 0.0, 0.0);
- return (double) per * (pv + CC) * D - (AA * CC) / eint;
-} /* fip */
-
-void
-set_default (fi_ptr fi)
-{
- /* flag whether accrueing interest at beginning or end of period
- * FALSE --> end
- * TRUE --> beginning
- * default to end of period payment s
- */
- fi->bep = FALSE;
-
- /* flag for discrete or continuous interest
- * TRUE --> discrete
- * FALSE --> continuous
- * default to discrete interest
- */
- fi->disc = TRUE;
-
- /* set compounding, CF, and payment, PF, frequency per year
- * default to monthly payments and compounding
- */
- fi->CF = fi->PF = 12;
-
- /* standard loan quantities:
- * number of periods: n
- */
- fi->npp = 0;
-
- /* annual interest: i
- */
- fi->ir = 0.0;
-
- /* Present Value: pv
- */
- fi->pv = 0.0;
-
- /* Payment: pmt
- */
- fi->pmt = 0.0;
-
- /* Future Value: fv
- */
- fi->fv = 0.0;
-
-} /* set_default */
-
-/* compute Julian Day Number from calender date
- */
-unsigned long
-julian_day_number (unsigned year, unsigned month, unsigned day)
-{
- /* Gregorian/Julian Calender Flag.
- * TRUE == Julian
- * FALSE == Gregorian
- */
- unsigned gregorian = TRUE; /* assume we are dealing with current dates */
- double yr;
- double pfac = 0.6;
- unsigned long ljdn;
-
- yr = year + (month - 3.0) / 12.0;
- ljdn = (long) (367.0 * yr + pfac) - (2 * (long) (yr)) + (long) (yr / 4.0)
- + (long) day + 1721117L;
- if (gregorian)
- ljdn += -(long) (yr / 100.0) + (long) (yr / 400.0) + 2;
-
- return ljdn;
-} /* julian_day_number */
-
-amort_sched_ptr
-Amortization_init (amort_sched_ptr amortsched)
-{
- unsigned n = amortsched->n;
- double nint = amortsched->nint;
- double pv = amortsched->pv;
- double pmt = amortsched->pmt;
- double fv = amortsched->fv;
- double eint;
- double new_pmt;
- double pve;
- unsigned CF = amortsched->CF;
- unsigned PF = amortsched->PF;
- unsigned disc = amortsched->disc;
- unsigned bep = amortsched->bep;
- unsigned new_n;
- unsigned prec = amortsched->prec;
- unsigned long s,
- d,
- days_to_yr_end,
- Eff_Date_jdn =
- julian_day_number (amortsched->year_E, amortsched->month_E,
- amortsched->day_E), Init_Date_jdn =
- julian_day_number (amortsched->year_I, amortsched->month_I,
- amortsched->day_I);
-
- amortsched->Eff_Date_jdn = Eff_Date_jdn;
- amortsched->Init_Date_jdn = Init_Date_jdn;
- amortsched->yday_E =
- Eff_Date_jdn - julian_day_number (amortsched->year_E, 1, 1);
- amortsched->yday_I =
- Init_Date_jdn - julian_day_number (amortsched->year_I, 1, 1);
- amortsched->eint = eint = eff_int (nint / 100.0, CF, PF, disc);
- amortsched->fv_case = dabs (fv) > dabs (pv);
- amortsched->bp = bep ? 1.0 : 0.0;
-
- if (PF > 24)
- {
- /* Payment frequency per year greater than bi-monthly
- * use actual number of days
- */
- s = Init_Date_jdn - Eff_Date_jdn;
- days_to_yr_end =
- julian_day_number (amortsched->year_I + 1, 1, 0) - Init_Date_jdn;
- d = 366 / PF;
- }
- else
- {
- /* Payment frequency per year bi-monthly or less
- * use 30 days/month, 360 days/year
- */
- if (Eff_Date_jdn == Init_Date_jdn)
- {
- s = 0;
- }
- else
- {
- s =
- ((amortsched->year_I - amortsched->year_E) * 360) +
- ((amortsched->month_I - amortsched->month_E) * 30) +
- amortsched->day_I - amortsched->day_E;
- } /* endif */
- days_to_yr_end = 390 - (amortsched->month_I * 30) - amortsched->day_I;
- d = 360 / PF;
- } /* endif */
-
- if (!bep)
- {
- /* ordinary annuity
- */
- s -= d;
- } /* endif */
-
- amortsched->yr_pmt = (days_to_yr_end + d) / d;
-
- if (pmt == 0.0)
- {
- s = 0;
- amortsched->pve = pv;
- }
- else
- {
- amortsched->pve =
- rnd (pv * pow ((1.0 + eint), ((double) (s * PF) / (double) (d * CF))),
- prec);
- } /* endif */
-
- pve = amortsched->pve;
-
- /* compute new data to fully amortize loan:
- * new periodic payment, new_pmt
- *
- * option 1: Amortize with original transaction - ignore interest
- * due to delayed initial payment
- *
- * option 2: Amortize with new pv, pve == original pv adjusted for
- * delayed initial payment, original payment, original fv and
- * original total number of payments, adjust final payment
- *
- * option 3: amortize with new pv, pve, and new payments adjusted to
- * minimize final payment, keep original number of payments and
- * original fv
- *
- * option 4: amortize with new pv, pve, original payments and new
- * number of payments to keep original final fv */
-
- /* option 3, compute new periodic payment */
- amortsched->new_pmt = new_pmt =
- rnd (_fi_calc_payment (n, nint, pve, fv, CF, PF, disc, bep), prec);
-
- /* option 4: compute new number of total payments, new_n */
- amortsched->new_n = new_n =
- (unsigned)
- rnd (_fi_calc_num_payments (nint, pve, pmt, fv, CF, PF, disc, bep), 0);
-
- /* following used in QTAwk to insure integer value, not needed in C */
- /* n = int(n); */
-
- /* compute payment for constant payment to principal loan and final
- * payment for original loan amount include interest due */
- amortsched->cpmt1 = rnd (-pv / n, prec);
- amortsched->final_pmt_opt_1 = -pv - amortsched->cpmt1 * (n - 1);
- amortsched->final_pmt_opt_1 *= eint + 1;
-
- /* compute payment for constant payment to principal loan and final
- * payment for delayed loan amount include interest due */
- amortsched->cpmt2 = rnd (-pve / n, prec);
- amortsched->final_pmt_opt_2 = -pve - amortsched->cpmt2 * (n - 1);
- amortsched->final_pmt_opt_2 *= eint + 1;
-
- if (bep)
- {
- amortsched->final_pmt_opt_3 =
- rnd (_fi_calc_future_value (n - 1, nint, pv, pmt, CF, PF, disc, bep) -
- (fv / (1.0 + eint)), prec);
- amortsched->final_pmt_opt_4 =
- rnd (_fi_calc_future_value (n - 1, nint, pve, pmt, CF, PF, disc, bep) -
- (fv / (1.0 + eint)), prec);
- amortsched->final_pmt_opt_5 =
- rnd (_fi_calc_future_value
- (n - 1, nint, pve, new_pmt, CF, PF, disc,
- bep) - (fv / (1.0 + eint)), prec);
- if (new_n)
- amortsched->final_pmt_opt_6 =
- rnd (_fi_calc_future_value
- (new_n - 1, nint, pve, pmt, CF, PF, disc,
- bep) - (fv / (1.0 + eint)), prec);
- else
- amortsched->final_pmt_opt_6 = 0.0;
- }
- else
- {
- amortsched->final_pmt_opt_3 =
- rnd (_fi_calc_future_value (n - 1, nint, pv, pmt, CF, PF, disc, bep) *
- (1.0 + eint) - fv, prec);
- amortsched->final_pmt_opt_4 =
- rnd (_fi_calc_future_value (n - 1, nint, pve, pmt, CF, PF, disc, bep) *
- (1.0 + eint) - fv, prec);
- amortsched->final_pmt_opt_5 =
- rnd (_fi_calc_future_value
- (n - 1, nint, pve, new_pmt, CF, PF, disc, bep) * (1.0 + eint) - fv,
- prec);
- if (new_n)
- amortsched->final_pmt_opt_6 =
- rnd (_fi_calc_future_value
- (new_n - 1, nint, pve, pmt, CF, PF, disc,
- bep) * (1.0 + eint) - fv, prec);
- else
- amortsched->final_pmt_opt_6 = 0.0;
- } /* endif */
-
- /* compute delayed interest */
- amortsched->delayed_int = pv - amortsched->pve;
-
- return amortsched;
-} /* Amortization_init */
-
-amort_sched_ptr
-Amortization_Schedule (amort_sched_ptr amortsched)
-{
- unsigned n = amortsched->n;
- double nint = amortsched->nint;
- double pv = amortsched->pv;
- double pmt = amortsched->pmt;
- double fv = amortsched->fv;
- double eint = amortsched->eint;
- unsigned CF = amortsched->CF;
- unsigned PF = amortsched->PF;
- unsigned disc = amortsched->disc;
- unsigned bep = amortsched->bep;
- double cpmt = 0;
- double final_pmt = 0;
- double delayed_int = amortsched->delayed_int;
- char summary = amortsched->summary;
- unsigned option = amortsched->option;
- unsigned yr_pmt = amortsched->yr_pmt;
- unsigned fv_case = amortsched->fv_case;
- unsigned prec = amortsched->prec;
- unsigned j, s, yr, per_cnt, pmt_cnt = 0, k = 0, sum_prt;
-
- int jj;
-
- unsigned long d;
-
- double yr_fv, sum_int, yr_int, prin, adv_pmt, pmt_int, hpv = 0.0;
- yearly_summary_ptr yrly_sum;
- amort_sched_yr_ptr amortyr;
- sched_pmt_ptr pmtsched = NULL;
-
- sum_int = yr_int = 0.0;
-
- switch (option)
- {
- case 1:
- amortsched->cpmt = cpmt = amortsched->cpmt1;
- /* re-compute final payment without interest
- */
- amortsched->final_pmt = final_pmt = -pv - cpmt * (n - 1);
- summary = (summary == 'y') ? 'x' : 'o';
- break;
- case 2:
- amortsched->cpmt = cpmt = amortsched->cpmt2;
- pv = amortsched->pve;
- /* re-compute final payment without interest
- */
- amortsched->final_pmt = final_pmt = -pv - cpmt * (n - 1);
- summary = (summary == 'y') ? 'x' : 'o';
- break;
- case 3:
- delayed_int = 0.0;
- amortsched->final_pmt = final_pmt = amortsched->final_pmt_opt_3;
- break;
- case 4:
- pv = amortsched->pve;
- amortsched->final_pmt = final_pmt = amortsched->final_pmt_opt_4;
- break;
- case 5:
- pv = amortsched->pve;
- pmt = amortsched->new_pmt;
- amortsched->final_pmt = final_pmt = amortsched->final_pmt_opt_5;
- break;
- case 6:
- n = amortsched->new_n;
- pv = amortsched->pve;
- amortsched->final_pmt = final_pmt = amortsched->final_pmt_opt_6;
- break;
- } /* endswitch */
-
- yr = amortsched->year_I;
- sum_prt = TRUE;
- switch (summary)
- {
- case 'a':
- /* variable advanced prepayment schedule. prepayment equals next
- * period principal. */
- amortsched->schedule.first_yr =
- amortyr = (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
-
- d = pv;
-
- for (per_cnt = 0, s = 1, j = n; pv != fv; j -= 2, per_cnt++)
- {
- /* basic equation to compute interest this payment period */
- pmt_int = -rnd ((pv + (amortsched->bp * pmt)) * eint, prec);
-
- /* sum yearly interest paid */
- yr_int += pmt_int;
-
- /* sum total interest paid */
- sum_int += pmt_int;
-
- /* compute principal paid this payment period and round to
- nearest cent */
- if (dabs (pmt) > dabs (pv))
- {
- prin = -pv;
- pmt = prin + pmt_int;
- adv_pmt = 0.0;
- pv = fv;
- }
- else
- {
- prin = rnd (pmt - pmt_int, prec);
-
- /* compute remaining pv and round to nearest cent */
- pv = rnd (pv + prin, prec);
-
- /* compute principal for next payment cycle and round to
- nearest cent */
- adv_pmt = rnd (pmt + (pv + (amortsched->bp * pmt)) * eint, prec);
-
- if (dabs (pv) >= dabs (adv_pmt))
- {
- /* remaining pv greater than advanced principal payment
- * compute remaining pv and round to nearest cent */
- pv = rnd (pv + adv_pmt, prec);
- }
- else
- {
- /* remaining pv less than advanced principal payment reduce
- * advanced pricipla payment to remaining pv */
- adv_pmt = -pv;
-
- /* and set remaining pv to fv */
- pv = fv;
- } /* ## endif */
- } /* # endif */
-
- if (sum_prt)
- {
- jj = (j < yr_pmt) ? j + 1 : yr_pmt;
- amortyr->payments =
- pmtsched = (sched_pmt_ptr) calloc (jj, sizeof (sched_pmt));
- pmt_cnt = 0;
-
- sum_prt = FALSE;
- } /* endif */
-
- pmtsched->period_num = s++;
- pmtsched->interest = pmt_int;
- pmtsched->principal = prin;
- pmtsched->advanced_pmt = adv_pmt;
- pmtsched->total_pmt = pmt + adv_pmt;
- pmtsched->balance = pv;
- pmtsched++;
- pmt_cnt++;
-
- if (!--yr_pmt)
- {
- yr_pmt = PF;
-
- amortyr->year = yr++;
- amortyr->interest_pd = yr_int;
- amortyr->principal_pd = pv - hpv;
- amortyr->yr_end_balance = pv;
- amortyr->total_interest_pd = sum_int;
- amortyr->num_periods = pmt_cnt;
- amortyr->next_yr =
- (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
- amortyr = amortyr->next_yr;
-
- hpv = pv;
- yr_int = 0.0;
- sum_prt = TRUE;
- } /* endif */
- } /* endfor */
-
- if (dabs (pv) > 0.0)
- {
- /* basic equation to compute interest this payment period */
- pmt_int = -rnd ((pv + (amortsched->bp * pmt)) * eint, prec);
-
- /* sum yearly interest paid */
- yr_int += pmt_int;
-
- /* sum total interest paid */
- sum_int += pmt_int;
-
- /* compute principal paid this payment period and round to
- nearest cent */
- prin = rnd (pmt - pmt_int, prec);
- final_pmt = pmt;
-
- /* compute remaining pv and round to nearest cent */
- pv = rnd (pv + prin, prec);
-
- /* Set advanced principal payment to remaining pv */
- adv_pmt = -pv;
- amortyr->final_pmt = final_pmt += adv_pmt;
-
- /* and set remaining pv to fv */
- pv = fv;
-
- pmtsched->period_num = s++;
- pmtsched->interest = pmt_int;
- pmtsched->principal = prin;
- pmtsched->advanced_pmt = adv_pmt;
- pmtsched->total_pmt = final_pmt;
- pmtsched->balance = pv;
-
- per_cnt++;
- pmt_cnt++;
- } /* endif */
-
- if (dabs (yr_int) > 0.0)
- {
- amortyr->year = yr++;
- amortyr->interest_pd = yr_int;
- amortyr->principal_pd = pv - hpv;
- amortyr->total_interest_pd = sum_int;
- amortyr->num_periods = pmt_cnt;
- } /* endif */
-
- amortsched->total_periods = per_cnt;
- break;
- case 'f':
- /* fixed prepaymet schedule prepayment specified by user */
- amortsched->schedule.first_yr =
- amortyr = (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
-
- d = pv;
-
- /* set advnaced payment */
- adv_pmt = amortsched->fixed_pmt;
-
- for (per_cnt = 0, s = 1, j = n; j && (pv != fv); j--, per_cnt++)
- {
- /* basic equation to compute interest this payment period */
- pmt_int = -rnd ((pv + (amortsched->bp * pmt)) * eint, prec);
- /* sum yearly interest paid
- */
- yr_int += pmt_int;
- /* sum total interest paid */
- sum_int += pmt_int;
-
- /* compute principal paid this payment period and round to
- nearest cent */
- if (dabs (pmt) > dabs (pv))
- {
- prin = -pv;
- pmt = prin + pmt_int;
- adv_pmt = 0.0;
- pv = 0.0;
- }
- else
- {
- prin = rnd (pmt - pmt_int, prec);
-
- /* compute remaining pv and round to nearest cent */
- pv = rnd (pv + prin, prec);
-
- if (dabs (pv) >= dabs (adv_pmt))
- {
- /* remaining pv greater than advanced principal payment
- * compute remaining pv and round to nearest cent */
- pv = rnd (pv + adv_pmt, prec);
- }
- else
- {
- /* remaining pv less than advanced principal payment reduce
- * advanced pricipal payment to remaining pv and set
- * remaining pv to fv */
- adv_pmt = -pv;
- pv = fv;
- } /*## endif */
- } /* # endif */
-
- if (sum_prt)
- {
- jj = (j < yr_pmt) ? j + 1 : yr_pmt;
- amortyr->payments =
- pmtsched = (sched_pmt_ptr) calloc (jj, sizeof (sched_pmt));
- pmt_cnt = 0;
-
- sum_prt = FALSE;
- }
- else
- {
- (amortyr->num_periods)++;
- } /* ## endif */
-
- pmtsched->period_num = s++;
- pmtsched->interest = pmt_int;
- pmtsched->principal = prin;
- pmtsched->advanced_pmt = adv_pmt;
- pmtsched->total_pmt = pmt + adv_pmt;
- pmtsched->balance = pv;
- pmt_cnt++;
- pmtsched++;
-
- if (!--yr_pmt)
- {
- yr_pmt = PF;
-
- amortyr->year = yr++;
- amortyr->interest_pd = yr_int;
- amortyr->principal_pd = pv - hpv;
- amortyr->yr_end_balance = pv;
- amortyr->total_interest_pd = sum_int;
- amortyr->num_periods = pmt_cnt;
- amortyr->next_yr =
- (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
- amortyr = amortyr->next_yr;
-
- hpv = pv;
- yr_int = 0.0;
- sum_prt = TRUE;
- } /* ## endif */
- } /* ## endfor */
-
- if (pv != fv)
- {
- /* # basic equation to compute interest this payment period */
- pmt_int = -rnd ((pv + (amortsched->bp * pmt)) * eint, prec);
-
- /* # sum yearly interest paid */
- yr_int += pmt_int;
- /* # sum total interest paid */
- sum_int += pmt_int;
-
- /* # compute principal paid this payment period and round to
- nearest cent */
- prin = rnd (pmt - pmt_int, prec);
- final_pmt = pmt;
-
- /* # compute remaining pv and round to nearest cent */
- pv = rnd (pv + prin, prec);
-
- /* # Set advanced principal payment to remaining pv */
- adv_pmt = -pv;
- amortyr->final_pmt = final_pmt += adv_pmt;
-
- /* # and set remaining pv to fv */
- pv = fv;
-
- pmtsched->period_num = s++;
- pmtsched->interest = pmt_int;
- pmtsched->principal = prin;
- pmtsched->advanced_pmt = adv_pmt;
- pmtsched->total_pmt = final_pmt;
- pmtsched->balance = pv;
-
- per_cnt++;
- pmt_cnt++;
- } /* # endif */
-
- if (dabs (yr_int) > 0.0)
- {
- amortyr->year = yr++;
- amortyr->interest_pd = yr_int;
- amortyr->principal_pd = pv - hpv;
- amortyr->total_interest_pd = sum_int;
- amortyr->num_periods = pmt_cnt;
- } /* endif */
-
- amortsched->total_periods = per_cnt;
- break;
- case 'o':
- /* Constant payment to principal use constant payment equal to
- * original pv divided by number of periods. constant payment to
- * pricipal could be amount specified by user. */
- amortsched->schedule.first_yr =
- amortyr = (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
- amortsched->total_periods = n;
-
- d = yr_pmt;
- for (s = 1, j = n - 1; j; j--, k++)
- {
- pmt_int = -rnd (pv * eint, prec);
-
- /* sum yearly interest paid */
- yr_int += pmt_int;
-
- /* sum total interest paid */
- sum_int += pmt_int;
-
- pv = rnd (pv + cpmt, prec);
-
- if (sum_prt)
- {
- jj = (j < yr_pmt) ? j + 1 : yr_pmt;
- amortyr->payments =
- pmtsched = (sched_pmt_ptr) calloc (jj, sizeof (sched_pmt));
- amortyr->num_periods = jj;
- k = 0;
-
- sum_prt = FALSE;
- } /* endif */
-
- pmtsched->period_num = s++;
- pmtsched->interest = pmt_int;
- pmtsched->total_pmt = cpmt + pmt_int;
- pmtsched->balance = pv;
- pmtsched++;
-
- if (!--yr_pmt)
- {
- yr_pmt = PF;
-
- amortyr->year = yr++;
- amortyr->interest_pd = yr_int;
- amortyr->principal_pd = d * cpmt;
- amortyr->yr_end_balance = pv;
- amortyr->total_interest_pd = sum_int;
- amortyr->next_yr =
- (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
- amortyr = amortyr->next_yr;
-
- d = PF;
- yr_int = 0.0;
- sum_prt = TRUE;
- } /* endif */
- } /* endfor */
-
- if (pv)
- {
- pmt_int = -rnd (pv * eint, prec);
-
- /* sum yearly interest paid */
- yr_int += pmt_int;
-
- /* sum total interest paid */
- sum_int += pmt_int;
-
- pmtsched->period_num = s++;
- pmtsched->interest = -pmt_int;
- pmtsched->total_pmt = -pv + pmt_int;
- pmtsched->balance = 0.0;
-
- amortyr->final_pmt = -pv - pmt_int;
- } /* endif */
-
- if (dabs (yr_int) > 0.0)
- {
- amortyr->year = yr++;
- amortyr->interest_pd = yr_int;
- amortyr->principal_pd = -pv + k * cpmt;
- amortyr->total_interest_pd = sum_int;
- } /* endif */
- break;
- case 'p':
- /* normal amortization schedule interest, principal and balance
- * per payment period */
- amortsched->schedule.first_yr =
- amortyr = (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
- amortsched->total_periods = n;
-
- hpv = pv;
- for (s = 1, j = n - 1; j; j--)
- {
- /* basic equation for computing interest paid in payment period */
- pmt_int = -rnd ((pv + (amortsched->bp * pmt)) * eint, prec);
-
- /* sum yearly interest paid */
- yr_int += pmt_int;
-
- /* sum total interest paid */
- sum_int += pmt_int;
-
- /* compute principal paid this payment period */
- prin = rnd (pmt - pmt_int, prec);
-
- /* compute remaining pv and round to nearest cent */
- pv = rnd (pv + prin, prec);
-
- if (sum_prt)
- {
- jj = (j < yr_pmt) ? j + 1 : yr_pmt;
- amortyr->payments =
- pmtsched = (sched_pmt_ptr) calloc (jj, sizeof (sched_pmt));
- amortyr->num_periods = jj;
-
- sum_prt = FALSE;
- } /* endif */
-
- if (fv_case)
- {
- pmtsched->period_num = s++;
- pmtsched->interest = pmt_int;
- pmtsched->balance = pv;
- pmtsched++;
- }
- else
- {
- pmtsched->period_num = s++;
- pmtsched->interest = pmt_int;
- pmtsched->principal = prin;
- pmtsched->balance = pv;
- pmtsched++;
- } /* endif */
-
- if (!--yr_pmt)
- {
- yr_pmt = PF;
-
- amortyr->year = yr++;
- amortyr->interest_pd = yr_int;
- if (!fv_case)
- {
- amortyr->principal_pd = pv - hpv;
- } /* endif */
- amortyr->yr_end_balance = pv;
- amortyr->total_interest_pd = sum_int;
- amortyr->next_yr =
- (amort_sched_yr_ptr) calloc (1, sizeof (amort_sched_yr));
- amortyr = amortyr->next_yr;
-
- hpv = pv;
- yr_int = 0.0;
- sum_prt = TRUE;
- } /* * endif */
- } /* * endfor */
-
- /* determine if payment due at beginning or end of period in order
- * to correctly compute final payment, interest and principal */
- if (bep)
- {
- /* paying remainder at beginning of period compute final payment */
- final_pmt = -pv - fv / (1 + eint);
-
- /* then compute interest paid with final final payment */
- pmt_int = -rnd ((pv + final_pmt) * eint, prec);
-
- /* then compute the principal paid */
- prin = final_pmt + pmt_int;
- }
- else
- {
- /* basic equation for computing interest paid in payment period
- * for payment at end of period */
- pmt_int = -rnd (pv * eint, prec);
-
- /* compute principal paid this payment period */
- prin = -pv;
-
- /* compute the final payment note the final payment may be
- * computed either of two ways both are equivalent */
- final_pmt = prin + pmt_int;
- } /* * endif */
-
- pv = -fv;
-
- /* sum yearly interest paid */
- yr_int += pmt_int;
-
- /* sum total interest paid */
- sum_int += pmt_int;
-
- if (sum_prt)
- {
- amortyr->payments =
- pmtsched = (sched_pmt_ptr) calloc (1, sizeof (sched_pmt));
- amortyr->num_periods = 1;
- } /* endif */
-
- amortyr->final_pmt = final_pmt;
-
- if (fv_case)
- {
- pmtsched->period_num = s++;
- pmtsched->interest = pmt_int;
- pmtsched->balance = pv;
- }
- else
- {
- pmtsched->period_num = s++;
- pmtsched->interest = pmt_int;
- pmtsched->principal = prin;
- pmtsched->balance = pv;
- } /* endif */
-
- if (dabs (yr_int) > 0.0)
- {
- amortyr->year = yr++;
- amortyr->interest_pd = yr_int;
- amortyr->total_interest_pd = sum_int;
- if (!bep)
- {
- amortyr->principal_pd = -hpv;
- } /* endif */
- } /* endif */
-
- break;
- case 'x':
- /* constant payment to principal - annual summary */
- /* compute number of years to summarize */
- j = n / PF;
- if (yr_pmt < PF)
- j++;
- amortsched->total_periods = j;
- amortsched->schedule.summary =
- yrly_sum = (yearly_summary_ptr) calloc (j, sizeof (yearly_summary));
-
- jj = 0;
- for (j = n, sum_prt = 0; j > 0; j -= yr_pmt, yr_pmt = PF, sum_prt++)
- {
- if (j <= PF)
- {
- s = jj + j;
- yr_pmt = j;
- yr_fv = rnd (pv + cpmt * (s - 1), prec) + final_pmt;
- }
- else
- {
- s = jj + yr_pmt;
- yr_fv = rnd (pv + cpmt * s, prec);
- } /* endif */
- prin = -eint * jj * (pv + (cpmt * (jj - 1) / 2.0));
- yr_int = -eint * s * (pv + (cpmt * (s - 1) / 2.0));
- yr_int = rnd (yr_int - prin, prec);
- jj += yr_pmt;
-
- sum_int += yr_int;
-
- yrly_sum[sum_prt].year = yr++;
- yrly_sum[sum_prt].interest = yr_int;
- yrly_sum[sum_prt].end_balance = yr_fv;
- } /* endfor */
-
- break;
- case 'y':
- /* normal amortization - annual summary */
- /* compute number of years to summarize */
- j = n / PF;
- if (yr_pmt < PF)
- j++;
- if (n > (j * PF))
- j++;
- amortsched->total_periods = j;
- amortsched->schedule.summary =
- yrly_sum = (yearly_summary_ptr) calloc (j, sizeof (yearly_summary));
-
- hpv = pv;
-
- for (jj = n, j = 0; jj > 0; jj -= yr_pmt, yr_pmt = PF, j++)
- {
- if (jj <= (int)PF)
- {
- yr_fv = fv;
- yr_int = rnd (((jj - 1) * pmt) + hpv + final_pmt, prec);
- }
- else
- {
- yr_fv =
- -rnd (_fi_calc_future_value
- (yr_pmt, nint, hpv, pmt, CF, PF, disc, bep), prec);
- yr_int = rnd ((yr_pmt * pmt) + hpv - yr_fv, prec);
- } /* * endif */
-
- sum_int += yr_int;
-
- yrly_sum[j].year = yr++;
- yrly_sum[j].interest = yr_int;
- yrly_sum[j].end_balance = yr_fv;
- hpv = yr_fv;
- } /* * endfor */
-
- break;
- } /* * endswitch */
-
- amortsched->total_interest = sum_int;
-
- return amortsched;
-} /* Amortization_Schedule */
-
-/* function to free dynamically allocated memory used for amortization
- schedule */
-void
-Amortization_free (amort_sched_ptr amortsched)
-{
- amort_sched_yr_ptr amortyr, prst_yr;
-
- switch (amortsched->summary)
- {
- case 'a':
- case 'f':
- case 'o':
- case 'p':
- for (amortyr = amortsched->schedule.first_yr; amortyr; amortyr = prst_yr)
- {
- if (amortyr->payments)
- free (amortyr->payments);
- prst_yr = amortyr->next_yr;
- free (amortyr);
- } /* endfor */
- break;
- case 'y':
- free (amortsched->schedule.summary);
- break;
- } /* endswitch */
-
- amortsched->schedule.first_yr = NULL;
-} /* amort_free */
Deleted: gnucash/trunk/src/calculation/fin_spl_protos.h
===================================================================
--- gnucash/trunk/src/calculation/fin_spl_protos.h 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/fin_spl_protos.h 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,44 +0,0 @@
-/***************************************************************************
- * -------------------
- * create : Tue Jul 11 20:21:18 2000
- * copyright: (C) 2000 by Terry D. Boldt
- * email : tboldt at attglobal.net
- * -------------------
- ***************************************************************************/
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-/***************************************************************************
- * Global Function Prototypes
- * Tue Jul 11 20:21:18 2000
- *
- ***************************************************************************/
-
-#ifndef FIN_SPL_PROTOS_H
-#define FIN_SPL_PROTOS_H
-
-/*==================================================*/
-/* expression_parser.c */
-/* Line Number: 344 */
-parser_env_ptr init_parser(
- var_store_ptr predefined_vars,
- gchar *radix_point,
- gchar *group_char,
- void *trans_numeric(const char *digit_str,
- gchar *radix_point,
- gchar *group_char,
- char **rstr),
- void *numeric_ops(char op_sym,
- void *left_value,
- void *right_value),
- void *negate_numeric(void *value),
- void free_numeric(void *numeric_value),
- void *func_op( const char *fname,
- int argc, void **argv ) );
-
-#endif
Deleted: gnucash/trunk/src/calculation/fin_static_proto.h
===================================================================
--- gnucash/trunk/src/calculation/fin_static_proto.h 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/fin_static_proto.h 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,126 +0,0 @@
-/***************************************************************************
- * -------------------
- * create : Tue Jul 11 20:21:20 2000
- * copyright: (C) 2000 by Terry D. Boldt
- * email : tboldt at attglobal.net
- * -------------------
- ***************************************************************************/
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-/***************************************************************************
- * Static Function Prototypes
- * Tue Jul 11 20:21:20 2000
- *
- ***************************************************************************/
-
-#if defined( FIN_STATICS )
-/*==================================================*/
-/* fin.c
- */
-/* Line Number: 614 */
-static double rnd(
- double x,
- unsigned places);
-/* Line Number: 628 */
-static double dabs(
- double x);
-/* Line Number: 634 */
-static double _A(
- double eint,
- unsigned per);
-/* Line Number: 1181 */
-static double _B(
- double eint,
- unsigned beg);
-/* Line Number: 1394 */
-static double nom_int(
- double eint,
- unsigned CF,
- unsigned PF,
- unsigned disc);
-/* Line Number: 781 */
-static double eff_int(
- double nint,
- unsigned CF,
- unsigned PF,
- unsigned disc);
-/* Line Number: 798 */
-static double fi(
- unsigned per,
- double eint,
- double pv,
- double pmt,
- double fv,
- unsigned bep);
-/* Line Number: 1449 */
-static double fip(
- unsigned per,
- double eint,
- double pv,
- double pmt,
- double fv,
- unsigned bep);
-#endif /* FIN_STATICS */
-
-#if defined( EXPRESSION_PARSER_STATICS )
-/*==================================================*/
-/* expression_parser.c
- */
-/* Line Number: 485 */
-static var_store_ptr pop(
- parser_env_ptr pe);
-/* Line Number: 321 */
-static var_store_ptr push(
- var_store_ptr push_value,
- parser_env_ptr pe);
-/* Line Number: 519 */
-static var_store_ptr get_named_var(
- parser_env_ptr pe);
-/* Line Number: 366 */
-static var_store_ptr get_unnamed_var(
- parser_env_ptr pe);
-/* Line Number: 579 */
-static void free_var(
- var_store_ptr value,
- parser_env_ptr pe);
-/* Line Number: 596 */
-static void next_token(
- parser_env_ptr pe);
-/* Line Number: 426 */
-static void assignment_op(
- parser_env_ptr pe);
-/* Line Number: 695 */
-static void add_sub_op(
- parser_env_ptr pe);
-/* Line Number: 464 */
-static void multiply_divide_op(
- parser_env_ptr pe);
-/* Line Number: 488 */
-static void primary_exp(
- parser_env_ptr pe);
-#endif /* EXPRESSION_PARSER_STATICS */
-
-#if defined( NUMERIC_OPS_STATICS )
-/*==================================================*/
-/* numeric_ops.c
- */
-#endif /* NUMERIC_OPS_STATICS */
-
-#if defined( AMORT_OPT_STATICS )
-/*==================================================*/
-/* amort_opt.c
- */
-#endif /* AMORT_OPT_STATICS */
-
-#if defined( AMORT_PRT_STATICS )
-/*==================================================*/
-/* amort_prt.c
- */
-#endif /* AMORT_PRT_STATICS */
-
Deleted: gnucash/trunk/src/calculation/fini-input
===================================================================
--- gnucash/trunk/src/calculation/fini-input 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/fini-input 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,36 +0,0 @@
-n
-12*30
-14.75
-100000
-
-
-
-
-4
-n
-y
-y
-opmt=pmt
-n
-12*15
-
-
-
-
-
-
-4
-n
-y
-y
-pmt-opmt
-n
-12*30
-
-
-
-
-
-
-0
-y
\ No newline at end of file
Deleted: gnucash/trunk/src/calculation/fini-output
===================================================================
--- gnucash/trunk/src/calculation/fini-output 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/fini-output 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,103 +0,0 @@
-Evaluate expression (y/n): Current Value, n: 0
-Enter new value
-Current Value, i: 0.00
-Enter new value
-Current Value, pv: 0.00
-Enter new value
-Current Value, pmt: 0.00
-Enter new value
-Current Value, fv: 0.00
-Enter new value
-Current Value, CF: 12
-Enter new value
-Current Value, PF: 12
-Enter new value
-Compute:
-n - 1
-i - 2
-pv - 3
-pmt - 4
-fv - 5
-1,2,3,4 or 5:Computing periodic payment
-<================================>
-Current Financial Calculator Status:
-Compounding Frequency: (CF) 12
-Payment Frequency: (PF) 12
-Compounding: Discrete (disc = TRUE)
-Payments: End of Period (bep = FALSE)
-Number of Payment Periods (n): 360 (Years: 30)
-Nominal Annual Interest Rate (i): 14.75
-Present Value (pv): 100000.00
-Periodic Payment (pmt): -1244.48
-Future Value (fv): 0.00
-Compute Amortization Schedule (y/n)
-Another example (y/n): Evaluate expression (y/n): Enter Expression
-Evaluated Value: -1244.48
-Another expression (y/n): Current Value, n: 360
-Enter new value
-Current Value, i: 14.75
-Enter new value
-Current Value, pv: 100000.00
-Enter new value
-Current Value, pmt: -1244.48
-Enter new value
-Current Value, fv: 0.00
-Enter new value
-Current Value, CF: 12
-Enter new value
-Current Value, PF: 12
-Enter new value
-Compute:
-n - 1
-i - 2
-pv - 3
-pmt - 4
-fv - 5
-1,2,3,4 or 5:Computing periodic payment
-<================================>
-Current Financial Calculator Status:
-Compounding Frequency: (CF) 12
-Payment Frequency: (PF) 12
-Compounding: Discrete (disc = TRUE)
-Payments: End of Period (bep = FALSE)
-Number of Payment Periods (n): 180 (Years: 15)
-Nominal Annual Interest Rate (i): 14.75
-Present Value (pv): 100000.00
-Periodic Payment (pmt): -1382.50
-Future Value (fv): 0.00
-Compute Amortization Schedule (y/n)
-Another example (y/n): Evaluate expression (y/n): Enter Expression
-Evaluated Value: -138.02
-Another expression (y/n): Current Value, n: 180
-Enter new value
-Current Value, i: 14.75
-Enter new value
-Current Value, pv: 100000.00
-Enter new value
-Current Value, pmt: -1382.50
-Enter new value
-Current Value, fv: 0.00
-Enter new value
-Current Value, CF: 12
-Enter new value
-Current Value, PF: 12
-Enter new value
-Compute:
-n - 1
-i - 2
-pv - 3
-pmt - 4
-fv - 5
-1,2,3,4 or 5:<================================>
-Current Financial Calculator Status:
-Compounding Frequency: (CF) 12
-Payment Frequency: (PF) 12
-Compounding: Discrete (disc = TRUE)
-Payments: End of Period (bep = FALSE)
-Number of Payment Periods (n): 180 (Years: 15)
-Nominal Annual Interest Rate (i): 14.75
-Present Value (pv): 100000.00
-Periodic Payment (pmt): -1382.50
-Future Value (fv): 0.00
-Compute Amortization Schedule (y/n)
-Another example (y/n):
\ No newline at end of file
Deleted: gnucash/trunk/src/calculation/finproto.h
===================================================================
--- gnucash/trunk/src/calculation/finproto.h 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/finproto.h 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,127 +0,0 @@
-/***************************************************************************
- * -------------------
- * create : Tue Jul 11 20:21:18 2000
- * copyright: (C) 2000 by Terry D. Boldt
- * email : tboldt at attglobal.net
- * -------------------
- ***************************************************************************/
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-/***************************************************************************
- * Global Function Prototypes
- * Tue Jul 11 20:21:18 2000
- *
- ***************************************************************************/
-
-#ifndef FINPROTO_H
-#define FINPROTO_H
-
-#include <stdio.h>
-
-#include "finvar.h"
-
-/*==================================================*/
-/* fin.c */
-
-unsigned fi_calc_num_payments (fi_ptr fi);
-
-double
-_fi_calc_num_payments (double nint, /* nominal interest rate */
- double pv, /* present value */
- double pmt, /* periodic payment */
- double fv, /* future value */
- unsigned CF, /* compounding frequency */
- unsigned PF, /* payment frequency */
- unsigned disc, /* discrete/continuous compounding */
- unsigned bep); /* beginning/end of period payment */
-
-double fi_calc_interest (fi_ptr fi);
-
-double
-_fi_calc_interest (unsigned per, /* number of periods */
- double pv, /* present value */
- double pmt, /* periodic payment */
- double fv, /* future value */
- unsigned CF, /* compounding frequency */
- unsigned PF, /* payment frequency */
- unsigned disc, /* discrete/continuous compounding */
- unsigned bep); /* beginning/end of period payment */
-
-double fi_calc_present_value (fi_ptr fi);
-
-double
-_fi_calc_present_value (unsigned per, /* number of periods */
- double nint, /* nominal interest rate */
- double pmt, /* periodic payment */
- double fv, /* future value */
- unsigned CF, /* compounding frequency */
- unsigned PF, /* payment frequency */
- unsigned disc, /* discrete/continuous compounding */
- unsigned bep); /* beginning/end of period payment */
-
-double fi_calc_payment (fi_ptr fi);
-
-double
-_fi_calc_payment (unsigned per, /* number of periods */
- double nint, /* nominal interest rate */
- double pv, /* present value */
- double fv, /* future value */
- unsigned CF, /* compounding frequency */
- unsigned PF, /* payment frequency */
- unsigned disc, /* discrete/continuous compounding */
- unsigned bep); /* beginning/end of period payment */
-
-double fi_calc_future_value (fi_ptr fi);
-
-double
-_fi_calc_future_value (unsigned per, /* number of periods */
- double nint, /* nominal interest rate */
- double pv, /* present value */
- double pmt, /* periodic payment */
- unsigned CF, /* compounding frequency */
- unsigned PF, /* payment frequency */
- unsigned disc, /* discrete/continuous compounding */
- unsigned bep); /* beginning/end of period payment */
-
-void set_default (fi_ptr fi);
-
-unsigned long julian_day_number (unsigned year, unsigned month, unsigned day);
-
-amort_sched_ptr Amortization_init (amort_sched_ptr amortsched);
-
-amort_sched_ptr Amortization_Schedule (amort_sched_ptr amortsched);
-
-void Amortization_free (amort_sched_ptr amortsched);
-
-
-/*==================================================*/
-/* expression_parser.c */
-
-void exit_parser (parser_env_ptr pe);
-
-ParseError get_parse_error (parser_env_ptr pe);
-
-var_store_ptr parser_get_vars (parser_env_ptr pe);
-
-unsigned delete_var (char *var_name, parser_env_ptr pe);
-
-char *parse_string (var_store_ptr value,
- const char *string, parser_env_ptr pe);
-
-
-/*==================================================*/
-/* amort_opt.c */
-amort_sched_ptr amort_opt (amort_sched_ptr amortsched, void *parse_env);
-
-
-/*==================================================*/
-/* amort_prt.c */
-void prt_amortization_schedule (amort_sched_ptr amortsched, FILE * ofile);
-
-#endif
Deleted: gnucash/trunk/src/calculation/finvar.h
===================================================================
--- gnucash/trunk/src/calculation/finvar.h 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/finvar.h 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,255 +0,0 @@
-/***************************************************************************
- * -------------------
- * create : Sat Jun 17 20:14:13 2000
- * copyright: (C) 2000 by Terry D. Boldt
- * email : tboldt at attglobal.net
- * -------------------
- ***************************************************************************/
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-/***************************************************************************
- * Global Financial Variables
- * Sat Jun 17 20:14:13 2000
- *
- ***************************************************************************/
-
-#ifndef FINVAR_H
-#define FINVAR_H
-
-#if !defined( EOS )
-#define EOS '\x000'
-#endif
-
-#if !defined( TRUE )
-#define TRUE (1)
-#endif
-
-#if !defined( FALSE )
-#define FALSE (0)
-#endif
-
-#define INT_TYPE '\x001'
-#define DBL_TYPE '\x002'
-
-typedef enum
-{
- PARSER_NO_ERROR = 0,
- UNBALANCED_PARENS,
- STACK_OVERFLOW,
- STACK_UNDERFLOW,
- UNDEFINED_CHARACTER,
- NOT_A_VARIABLE,
- NOT_A_FUNC,
- PARSER_OUT_OF_MEMORY,
- NUMERIC_ERROR,
- EXPRESSION_ERROR,
- PARSER_NUM_ERRORS
-}
-ParseError;
-
-#define UNUSED_VAR '\x000'
-#define USED_VAR '\x001'
-#define ASSIGNED_TO '\x002'
-
-#define ADD_OP '+'
-#define SUB_OP '-'
-#define DIV_OP '/'
-#define MUL_OP '*'
-#define ASN_OP '='
-
-/* The following structure is used by the expression parser to store
- * named and temporary variables. */
-
-/* structure used for storing variables - used by expression parser/evaluator
- */
-typedef struct var_store *var_store_ptr;
-
-/* the type of entity contained in the var_store */
-typedef enum
-{
- VST_NUMERIC = 0,
- VST_STRING
-} VarStoreType;
-
-typedef struct var_store
-{
- char *variable_name; /* variable name if variable, NULL otherwise */
- char use_flag; /* flag if variable has been assigned to */
- char assign_flag; /* flag if variable is used */
- VarStoreType type;
- void *value; /* pointer to implementation defined numeric value */
- var_store_ptr next_var; /* pointer to next variable in linked list */
-}
-var_store;
-
-
-/* The following structure is used for the numeric operations
- * involving double float and integer arithmetic */
-
-/* structure used for storing numeric values - used by routines which
- * evaluate arithmetic operators '+', '-', '/', '*' */
-typedef struct numeric *numeric_ptr;
-typedef struct numeric
-{
- char type; /* designates type of value */
- union
- {
- long int int_value; /* long integer value */
- double dbl_value; /* double value */
- }
- value;
-}
-numeric;
-
-/* The following structures are used by the amortization functions for
- * storing amortization schedule information */
-
-/* structure used by amortization routines for storing annual summary
- information */
-typedef struct yearly_summary *yearly_summary_ptr;
-typedef struct yearly_summary
-{
- unsigned year;
- double interest;
- double end_balance;
-}
-yearly_summary;
-
-/* structure used by amortization routines for storing information on
- a single payment */
-typedef struct sched_pmt *sched_pmt_ptr;
-typedef struct sched_pmt
-{
- unsigned period_num;
- double interest;
- double principal;
- double advanced_pmt;
- double total_pmt;
- double balance;
-}
-sched_pmt;
-
-/* structure used by amortization routines for storing information on
- * payments for a single year */
-typedef struct amort_sched_yr *amort_sched_yr_ptr;
-typedef struct amort_sched_yr
-{
- unsigned year;
- unsigned num_periods;
- sched_pmt_ptr payments;
- double interest_pd;
- double principal_pd;
- double yr_end_balance;
- double total_interest_pd;
- double final_pmt;
- amort_sched_yr_ptr next_yr;
-}
-amort_sched_yr;
-
-/* structure used by amortization routines for passing and storing
- * infomation on a particular amortization transaction */
-typedef struct amort_sched *amort_sched_ptr;
-typedef struct amort_sched
-{
- /* following information set by function calling amortization
- functions */
- unsigned n; /* number of periods */
- double nint; /* nominal interest rate */
- double pv; /* present value */
- double pmt; /* periodic payment */
- double fv; /* future value */
- unsigned CF; /* compounding frequency */
- unsigned PF; /* payment frequency */
- unsigned disc; /* discrete/continuous compounding flag */
- unsigned bep; /* beginning/end of period payment flag */
- unsigned prec; /* roundoff precision */
- unsigned year_E; /* Effective date - year */
- unsigned month_E; /* Effective date - month */
- unsigned day_E; /* Effective date - day of month */
- unsigned year_I; /* Initial payment date - year */
- unsigned month_I; /* Initial payment date - month */
- unsigned day_I; /* Initial payment date - day of month */
-
- /* following information set by calling function to indicate which
- * schedule to compute and which type of schedule */
- unsigned option; /* option flag from 1 to 6 inclusive */
- char summary; /* summary flag == 'y', 'p', 'a' or 'f' */
-
- /* following information set by amortization functions */
- double eint; /* effective interest rate */
- double bp; /* float value of bep */
- double total_interest; /* total interest paid */
- unsigned total_periods; /* total numer of periods in schedule */
- unsigned long yr_pmt; /* number of payments in first year */
- double final_pmt_opt_1; /* final payment option 1 */
- double final_pmt_opt_2; /* final payment option 2 */
- double final_pmt_opt_3; /* final payment option 3 */
- double final_pmt_opt_4; /* final payment option 4 */
- double final_pmt_opt_5; /* final payment option 5 */
- double final_pmt_opt_6; /* final payment option 6 */
- double final_pmt; /* final payment */
- double pve; /* pv adjusted for delayed initial payment */
- double new_pmt; /* pmt adjusted for delayed initial payment */
- double cpmt; /* constant payment to principal */
- double cpmt1; /* constant payment to principal, 1st case */
- double cpmt2; /* constant payment to principal, 2cd case */
- double delayed_int; /* interest due to delayed initial payment */
- double fixed_pmt; /* fixed prepayment amount for amortization */
- unsigned new_n; /* new number of periods to amortize due to
- delayed intial payment */
- unsigned fv_case; /* fv case flag */
- unsigned long Eff_Date_jdn;
- unsigned yday_E;
- unsigned long Init_Date_jdn;
- unsigned yday_I;
- union
- {
- amort_sched_yr_ptr first_yr;
- yearly_summary_ptr summary;
- }
- schedule;
-}
-amort_sched;
-
-/* The following structure is used to hold all of the financial
- * variables used by the financial calculator */
-
-/* structure used by financial computation routines to store financial
- variables */
-typedef struct financial_info *fi_ptr;
-typedef struct financial_info
-{
- double ir; /* interest rate */
- double pv; /* present value */
- double pmt; /* periodic payment */
- double fv; /* future value */
-
- unsigned npp; /* number of payment periods */
- unsigned CF; /* Compounding frequency */
- unsigned PF; /* payment frequency */
- unsigned bep; /* beginning/end of period payment flag */
- /* TRUE == beginning of period */
- /* FALSE == end of period */
- unsigned disc; /* discrete/continuous compounding flag */
- /* TRUE == discrete compounding */
- /* FALSE == continuous compounding */
-
- /* precision of roundoff for pv, pmt and fv.
- * i, Interest not rounded
- * n, number of periods rounded to integer value, implicit value of zero, 0
- *
- * 2 for US Dollars
- */
- unsigned prec;
-}
-financial_info;
-
-typedef struct parser_env *parser_env_ptr;
-
-#endif
Deleted: gnucash/trunk/src/calculation/gncmod-calculation.c
===================================================================
--- gnucash/trunk/src/calculation/gncmod-calculation.c 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/gncmod-calculation.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,47 +0,0 @@
-/*********************************************************************
- * gncmod-calculation.c
- * module definition/initialization for the calculation module
- *
- * Copyright (c) 2001 Linux Developers Group, Inc.
- *********************************************************************/
-
-#include <stdio.h>
-#include <gmodule.h>
-
-#include "gnc-module.h"
-#include "gnc-module-api.h"
-
-GNC_MODULE_API_DECL(libgncmod_calculation)
-
-/* version of the gnc module system interface we require */
-int libgncmod_calculation_gnc_module_system_interface = 0;
-
-/* module versioning uses libtool semantics. */
-int libgncmod_calculation_gnc_module_current = 0;
-int libgncmod_calculation_gnc_module_revision = 0;
-int libgncmod_calculation_gnc_module_age = 0;
-
-
-char *
-libgncmod_calculation_gnc_module_path(void)
-{
- return g_strdup("gnucash/calculation");
-}
-
-char *
-libgncmod_calculation_gnc_module_description(void)
-{
- return g_strdup("GnuCash calculation module");
-}
-
-int
-libgncmod_calculation_gnc_module_init(int refcount)
-{
- return TRUE;
-}
-
-int
-libgncmod_calculation_gnc_module_end(int refcount)
-{
- return TRUE;
-}
Deleted: gnucash/trunk/src/calculation/numeric_ops.c
===================================================================
--- gnucash/trunk/src/calculation/numeric_ops.c 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/numeric_ops.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,439 +0,0 @@
-/***************************************************************************
- numeric_ops.c - description
- -------------------
- begin : Wednesday June 21 2000
- email : tboldt at attglobal.net
- Author : Terry D. Boldt
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-/*
- * Functions to execute arthmetic operators on integer and double operands
- * 6-23-2000
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <errno.h>
-#include <limits.h>
-#include <float.h>
-#include <math.h>
-
-#define NUMERIC_OPS_STATICS
-#include "finvar.h"
-
-static double neg_table[] =
-{
- 1e-256,
- 1e-128,
- 1e-64,
- 1e-32,
- 1e-16,
- 1e-8,
- 1e-4,
- 1e-2,
- 1e-1,
- 1.0
-};
-
-static double pos_table[] =
-{
- 1e+256,
- 1e+128,
- 1e+64,
- 1e+32,
- 1e+16,
- 1e+8,
- 1e+4,
- 1e+2,
- 1e+1
-};
-
-#define MAX_SCALE ((LONG_MAX - 10) / 10)
-
-/* function to translate ASCII string to numeric format.
- *
- * Recognizes either integer numerics or floating point numerics.
- * Recognizes integers in format:
- * (sign)digit_sequence
- * digit_sequence may contain a grouping character, the grouping character is ignored
- * optional sign == '+' or '-'
- *
- * Recognizes floating point in formats:
- * (sign)digit_sequence.digits(exp)
- * (sign)digit_sequence.(exp)
- * (sign)digit_sequence(exp)
- * (sign).digits(exp)
- * '.' represents the radix point passed, digit_sequence may contain a grouping character
- * the grouping character is ignored
- * optional sign == '+' or '-'
- * optional exp == ('e' or 'E')(sign)digits
- *
- * Terminates on first unrecognized character.
- *
- */
-void *trans_numeric(
- const char *str, /* pointer to string to translate */
- char radix_point, /* radix character */
- char group_char, /* grouping character to left of radix */
- char **endstr) /* where to return pointer to first unrecognized character */
-{
- double dblval = 0.0;
- int exp = 0,
- dchr,
- err = 0,
- base = 10;
- long int inum = 0;
- unsigned long msdec = 0,
- lsdec = 0,
- msscale = 1;
- unsigned radix = 0,
- sign = 0,
- digit_cnt = 0;
- const char *strinit = str;
- numeric_ptr rslt = NULL;
-
- while ( isspace(*str) ) str++;
-
- switch (*str)
- {
- case '-':
- sign++;
- case '+':
- str++;
- default:
- break;
- } /* endswitch */
-
- while ( *str )
- {
-
- while ( (*str >= '0') && (*str <= '9') )
- {
- digit_cnt++;
-
- if ( msdec < MAX_SCALE ) msdec = msdec * 10 + (*str - '0');
- else if ( msscale < MAX_SCALE )
- {
- lsdec = lsdec * 10 + (*str - '0');
- msscale *= 10;
- }
- else exp++;
-
- if ( radix ) exp--;
- else
- {
- dchr = *str - '0';
- if ( ((LONG_MIN + dchr) / base) > inum ) err = 1;
- inum = inum * base + dchr;
- } /* endif */
- str++;
- } /* endwhile */
-
- if ( !radix )
- {
- if ( *str == radix_point ) radix++;
- else if ( *str != group_char ) break;
- }
- else
- {
- break;
- } /* endif */
-
- str++;
- } /* endwhile */
-
- if ( digit_cnt )
- {
- unsigned exp_dcnt = 0;
-
- if ( (*str == 'e') || (*str == 'E') )
- {
- char exp_sign = EOS;
- int ex_exp = 0;
-
- switch (*++str)
- {
- case '-':
- exp_sign++;
- case '+':
- str++;
- default:
- break;
- } /* endswitch */
-
- while ( (*str >= '0') && (*str <= '9') )
- {
- if (ex_exp < (DBL_MAX_EXP * 2) ) ex_exp = ex_exp * 10 + (*str - '0');
- str++;
- exp_dcnt++;
- } /* endwhile */
-
- exp += exp_sign ? -ex_exp : ex_exp;
- } /* endif */
-
- if ( radix || exp )
- {
- int pow = 256;
-
- dblval = msdec;
- if ( msscale != 1 ) dblval = dblval * msscale + lsdec;
-
- if ( dblval && exp )
- {
- unsigned u = 0;
-
- pow = 256;
- while ( exp > 0 )
- {
- while ( exp >= pow )
- {
- dblval *= pos_table[u];
- exp -= pow;
- } /* endwhile */
- pow >>= 1;
- u++;
- } /* endwhile */
-
- while ( exp < 0 )
- {
- while ( exp <= -pow )
- {
- dblval *= neg_table[u];
- if ( dblval == 0.0 )
- {
- errno = ERANGE;
- err = 1;
- } /* endif */
- exp += pow;
- } /* endwhile */
- pow >>= 1;
- u++;
- } /* endwhile */
-
- /* if overflow occurred */
- if ( dblval == HUGE_VAL )
- {
- errno = ERANGE;
- err = 1;
- } /* endif */
- } /* endif */
-
- if ( !err )
- {
- rslt = (numeric_ptr)calloc(1, sizeof(numeric));
- rslt->type = DBL_TYPE;
- rslt->value.dbl_value = dblval;
- } /* endif */
- }
- else
- {
- if ( (!sign && (inum == LONG_MIN)) || err )
- {
- inum = LONG_MIN + sign;
- errno = ERANGE;
- }
- else
- {
- rslt = (numeric_ptr)calloc(1, sizeof(numeric));
- rslt->type = INT_TYPE;
- rslt->value.int_value = inum;
- } /* endif */
- } /* endif */
- } /* endif */
-
- if ( endstr )
- {
- if ( !digit_cnt ) *endstr = (char *) strinit;
- else *endstr = (char *) str;
- } /* endif */
-
- return (void *)rslt;
-} /* strtod_flt */
-
-/* function to free memory used by numeric structure
- */
-void free_numeric(
- void *numeric_value)
-{
- if ( numeric_value ) free(numeric_value);
-} /* free_numeric */
-
-/* function to perform unary '-' operation
- */
-void *negate_numeric(
- void *value)
-{
- numeric_ptr rslt = (numeric_ptr)value;
-
- switch ( rslt->type )
- {
- case INT_TYPE:
- rslt->value.int_value = -rslt->value.int_value;
- break;
- case DBL_TYPE:
- rslt->value.dbl_value = -rslt->value.dbl_value;
- break;
- } /* endswitch */
-
- return (void *)rslt;
-} /* negate_numeric */
-
-/* function to perform binary operators
- * op_symbol - operation to perform
- * ADD_OP == perform '+'
- * SUB_OP == perform '-'
- * DIV_OP == perform '/'
- * MUL_OP == perform '*'
- * ASN_OP == perform '='
- * l_value - pointer to left hand value
- * r_value - pointer to right hand value
- */
-void *numeric_ops(
- char op_symbol,
- void *l_value,
- void *r_value)
-{
- numeric_ptr lval = (numeric_ptr)l_value,
- rval = (numeric_ptr)r_value,
- rslt = (op_symbol == ASN_OP) ? lval : (numeric_ptr)calloc(1, sizeof(numeric));
-
- switch ( op_symbol )
- {
- case ADD_OP:
- if ( lval->type == rval->type )
- {
- rslt->type = lval->type;
- switch ( lval->type )
- {
- case INT_TYPE:
- rslt->value.int_value = lval->value.int_value + rval->value.int_value;
- break;
- case DBL_TYPE:
- rslt->value.dbl_value = lval->value.dbl_value + rval->value.dbl_value;
- break;
- } /* endswitch */
- }
- else
- {
- rslt->type = DBL_TYPE;
- switch ( lval->type )
- {
- case INT_TYPE:
- rslt->value.dbl_value = (double)(lval->value.int_value) + rval->value.dbl_value;
- break;
- case DBL_TYPE:
- rslt->value.dbl_value = lval->value.dbl_value + (double)(rval->value.int_value);
- break;
-
- } /* endswitch */
- } /* endif */
- break;
- case SUB_OP:
- if ( lval->type == rval->type )
- {
- rslt->type = lval->type;
- switch ( lval->type )
- {
- case INT_TYPE:
- rslt->value.int_value = lval->value.int_value - rval->value.int_value;
- break;
- case DBL_TYPE:
- rslt->value.dbl_value = lval->value.dbl_value - rval->value.dbl_value;
- break;
- } /* endswitch */
- }
- else
- {
- rslt->type = DBL_TYPE;
- switch ( lval->type )
- {
- case INT_TYPE:
- rslt->value.dbl_value = (double)(lval->value.int_value) - rval->value.dbl_value;
- break;
- case DBL_TYPE:
- rslt->value.dbl_value = lval->value.dbl_value - (double)(rval->value.int_value);
- break;
-
- } /* endswitch */
- } /* endif */
- break;
- case DIV_OP:
- rslt->type = DBL_TYPE;
- if ( lval->type == rval->type )
- {
- switch ( lval->type )
- {
- case INT_TYPE:
- rslt->value.dbl_value = (double)(lval->value.int_value) / (double)(rval->value.int_value);
- break;
- case DBL_TYPE:
- rslt->value.dbl_value = lval->value.dbl_value / rval->value.dbl_value;
- break;
- } /* endswitch */
- }
- else
- {
- switch ( lval->type )
- {
- case INT_TYPE:
- rslt->value.dbl_value = (double)(lval->value.int_value) / rval->value.dbl_value;
- break;
- case DBL_TYPE:
- rslt->value.dbl_value = lval->value.dbl_value / (double)(rval->value.int_value);
- break;
-
- } /* endswitch */
- } /* endif */
- break;
- case MUL_OP:
- if ( lval->type == rval->type )
- {
- rslt->type = lval->type;
- switch ( lval->type )
- {
- case INT_TYPE:
- rslt->value.int_value = lval->value.int_value * rval->value.int_value;
- break;
- case DBL_TYPE:
- rslt->value.dbl_value = lval->value.dbl_value * rval->value.dbl_value;
- break;
- } /* endswitch */
- }
- else
- {
- rslt->type = DBL_TYPE;
- switch ( lval->type )
- {
- case INT_TYPE:
- rslt->value.dbl_value = (double)(lval->value.int_value) * rval->value.dbl_value;
- break;
- case DBL_TYPE:
- rslt->value.dbl_value = lval->value.dbl_value * (double)(rval->value.int_value);
- break;
-
- } /* endswitch */
- } /* endif */
- break;
- case ASN_OP:
- if ( !lval ) lval = (numeric_ptr)calloc(1, sizeof(numeric));
- lval->type = rval->type;
- lval->value = rval->value;
- rslt = lval;
- break;
- } /* endswitch */
-
-
- return (void *)rslt;
-} /* numeric_ops */
Deleted: gnucash/trunk/src/calculation/numeric_ops.h
===================================================================
--- gnucash/trunk/src/calculation/numeric_ops.h 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/numeric_ops.h 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,39 +0,0 @@
-/***************************************************************************
- * -------------------
- * create : Tue Jul 11 20:21:18 2000
- * copyright: (C) 2000 by Terry D. Boldt
- * email : tboldt at attglobal.net
- * -------------------
- ***************************************************************************/
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-/***************************************************************************
- * Global Function Prototypes
- * Tue Jul 11 20:21:18 2000
- *
- ***************************************************************************/
-
-#ifndef NUMERIC_OPS_H
-#define NUMERIC_OPS_H
-
-void *trans_numeric(const char *str, /* pointer to string to translate */
- char radix_point, /* radix character */
- char group_char, /* grouping character to left of radix */
- char **endstr); /* where to return pointer to first
- * unrecognized character */
-
-void free_numeric(void *numeric_value);
-
-void *negate_numeric(void *value);
-
-void *numeric_ops(char op_symbol,
- void *l_value,
- void *r_value);
-
-#endif
Deleted: gnucash/trunk/src/calculation/sample
===================================================================
--- gnucash/trunk/src/calculation/sample 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/sample 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,2623 +0,0 @@
-With npp == 360
- ir == 8.25
- pv == 345725.00
------------->Compute pmt: -2597.32
-<================================>
-Current Financial Calculator Status:
-Compounding Frequency: (CF) 12
-Payment Frequency: (PF) 12
-Compounding: Discrete (disc = TRUE)
-Payments: End of Period (bep = FALSE)
-Number of Payment Periods (n): 360 (Years: 30)
-Nominal Annual Interest Rate (i): 8.25
-Present Value (pv): 345725.00
-Periodic Payment (pmt): -2597.32
-Future Value (fv): 0.00
-
------------->Compute ir
-<================================>
-Current Financial Calculator Status:
-Compounding Frequency: (CF) 12
-Payment Frequency: (PF) 12
-Compounding: Discrete (disc = TRUE)
-Payments: End of Period (bep = FALSE)
-Number of Payment Periods (n): 360 (Years: 30)
-Nominal Annual Interest Rate (i): 8.25
-Present Value (pv): 345725.00
-Periodic Payment (pmt): -2597.32
-Future Value (fv): 0.00
-
------------->Compute npp
-<================================>
-Current Financial Calculator Status:
-Compounding Frequency: (CF) 12
-Payment Frequency: (PF) 12
-Compounding: Discrete (disc = TRUE)
-Payments: End of Period (bep = FALSE)
-Number of Payment Periods (n): 360 (Years: 30)
-Nominal Annual Interest Rate (i): 8.25
-Present Value (pv): 345725.00
-Periodic Payment (pmt): -2597.32
-Future Value (fv): 0.00
-
------------->Compute fv
-<================================>
-Current Financial Calculator Status:
-Compounding Frequency: (CF) 12
-Payment Frequency: (PF) 12
-Compounding: Discrete (disc = TRUE)
-Payments: End of Period (bep = FALSE)
-Number of Payment Periods (n): 360 (Years: 30)
-Nominal Annual Interest Rate (i): 8.25
-Present Value (pv): 345725.00
-Periodic Payment (pmt): -2597.32
-Future Value (fv): -0.00
-
-
- Reset financial variables and compute amortization schedules.
-First Schedule - ignore delay in first payment and
-output annual summary
-Amortization Table
-Effective Date: Tue Jun 15 00:00:00 1999
-Initial Payment Date: Sun Aug 1 00:00:00 1999
-Compounding Frequency per year: 12
-Payment Frequency per year: 12
-Compounding: Discrete
-Payments: End of Period
-Payments (359): -2597.32
-Final payment (360): -2591.78
-Nominal Annual Interest Rate: 8.25
- Effective Interest Rate Per Payment Period: 0.006875
-Present Value: 345725.00
-Annual Summary - Normal Amortization
-Year Interest Ending Balance
-1999 -11869.04 344607.44
-2000 -28324.18 341763.78
-2001 -28080.50 338676.44
-2002 -27815.94 335324.54
-2003 -27528.71 331685.41
-2004 -27216.87 327734.44
-2005 -26878.30 323444.90
-2006 -26510.72 318787.78
-2007 -26111.64 313731.58
-2008 -25678.37 308242.11
-2009 -25207.96 302282.23
-2010 -24697.25 295811.64
-2011 -24142.77 288786.57
-2012 -23540.77 281159.50
-2013 -22887.19 272878.85
-2014 -22177.61 263888.62
-2015 -21407.22 254128.00
-2016 -20570.81 243530.97
-2017 -19662.73 232025.86
-2018 -18676.83 219534.85
-2019 -17606.45 205973.46
-2020 -16444.34 191249.96
-2021 -15182.65 175264.77
-2022 -13812.85 157909.78
-2023 -12325.66 139067.60
-2024 -10711.04 118610.80
-2025 -8958.05 96401.01
-2026 -7054.84 72288.01
-2027 -4988.55 46108.72
-2028 -2745.19 17686.07
-2029 -489.63 0.00
-
-Total Interest: -589304.66
-
-
-Second Schedule - ignore delay in first payment and
-output schedule for each payment
-Amortization Table
-Effective Date: Tue Jun 15 00:00:00 1999
-Initial Payment Date: Sun Aug 1 00:00:00 1999
-Compounding Frequency per year: 12
-Payment Frequency per year: 12
-Compounding: Discrete
-Payments: End of Period
-Payments (359): -2597.32
-Final payment (360): -2591.78
-Nominal Annual Interest Rate: 8.25
- Effective Interest Rate Per Payment Period: 0.006875
-Present Value: 345725.00
-Normal Amortization Schedule
-Pmt * Interest Principal Balance
- 1 -2376.86 -220.46 345504.54
- 2 -2375.34 -221.98 345282.56
- 3 -2373.82 -223.50 345059.06
- 4 -2372.28 -225.04 344834.02
- 5 -2370.73 -226.59 344607.43
-Summary for: 1999:
- Interest Paid: -11869.03
- Principal Paid: -1117.57
- Year Ending Balance: 344607.43
- Sum of Interest Paid: -11869.03
-Pmt * Interest Principal Balance
- 6 -2369.18 -228.14 344379.29
- 7 -2367.61 -229.71 344149.58
- 8 -2366.03 -231.29 343918.29
- 9 -2364.44 -232.88 343685.41
- 10 -2362.84 -234.48 343450.93
- 11 -2361.23 -236.09 343214.84
- 12 -2359.60 -237.72 342977.12
- 13 -2357.97 -239.35 342737.77
- 14 -2356.32 -241.00 342496.77
- 15 -2354.67 -242.65 342254.12
- 16 -2353.00 -244.32 342009.80
- 17 -2351.32 -246.00 341763.80
-Summary for: 2000:
- Interest Paid: -28324.21
- Principal Paid: -2843.63
- Year Ending Balance: 341763.80
- Sum of Interest Paid: -40193.24
-Pmt * Interest Principal Balance
- 18 -2349.63 -247.69 341516.11
- 19 -2347.92 -249.40 341266.71
- 20 -2346.21 -251.11 341015.60
- 21 -2344.48 -252.84 340762.76
- 22 -2342.74 -254.58 340508.18
- 23 -2340.99 -256.33 340251.85
- 24 -2339.23 -258.09 339993.76
- 25 -2337.46 -259.86 339733.90
- 26 -2335.67 -261.65 339472.25
- 27 -2333.87 -263.45 339208.80
- 28 -2332.06 -265.26 338943.54
- 29 -2330.24 -267.08 338676.46
-Summary for: 2001:
- Interest Paid: -28080.50
- Principal Paid: -3087.34
- Year Ending Balance: 338676.46
- Sum of Interest Paid: -68273.74
-Pmt * Interest Principal Balance
- 30 -2328.40 -268.92 338407.54
- 31 -2326.55 -270.77 338136.77
- 32 -2324.69 -272.63 337864.14
- 33 -2322.82 -274.50 337589.64
- 34 -2320.93 -276.39 337313.25
- 35 -2319.03 -278.29 337034.96
- 36 -2317.12 -280.20 336754.76
- 37 -2315.19 -282.13 336472.63
- 38 -2313.25 -284.07 336188.56
- 39 -2311.30 -286.02 335902.54
- 40 -2309.33 -287.99 335614.55
- 41 -2307.35 -289.97 335324.58
-Summary for: 2002:
- Interest Paid: -27815.96
- Principal Paid: -3351.88
- Year Ending Balance: 335324.58
- Sum of Interest Paid: -96089.70
-Pmt * Interest Principal Balance
- 42 -2305.36 -291.96 335032.62
- 43 -2303.35 -293.97 334738.65
- 44 -2301.33 -295.99 334442.66
- 45 -2299.29 -298.03 334144.63
- 46 -2297.24 -300.08 333844.55
- 47 -2295.18 -302.14 333542.41
- 48 -2293.10 -304.22 333238.19
- 49 -2291.01 -306.31 332931.88
- 50 -2288.91 -308.41 332623.47
- 51 -2286.79 -310.53 332312.94
- 52 -2284.65 -312.67 332000.27
- 53 -2282.50 -314.82 331685.45
-Summary for: 2003:
- Interest Paid: -27528.71
- Principal Paid: -3639.13
- Year Ending Balance: 331685.45
- Sum of Interest Paid: -123618.41
-Pmt * Interest Principal Balance
- 54 -2280.34 -316.98 331368.47
- 55 -2278.16 -319.16 331049.31
- 56 -2275.96 -321.36 330727.95
- 57 -2273.75 -323.57 330404.38
- 58 -2271.53 -325.79 330078.59
- 59 -2269.29 -328.03 329750.56
- 60 -2267.04 -330.28 329420.28
- 61 -2264.76 -332.56 329087.72
- 62 -2262.48 -334.84 328752.88
- 63 -2260.18 -337.14 328415.74
- 64 -2257.86 -339.46 328076.28
- 65 -2255.52 -341.80 327734.48
-Summary for: 2004:
- Interest Paid: -27216.87
- Principal Paid: -3950.97
- Year Ending Balance: 327734.48
- Sum of Interest Paid: -150835.28
-Pmt * Interest Principal Balance
- 66 -2253.17 -344.15 327390.33
- 67 -2250.81 -346.51 327043.82
- 68 -2248.43 -348.89 326694.93
- 69 -2246.03 -351.29 326343.64
- 70 -2243.61 -353.71 325989.93
- 71 -2241.18 -356.14 325633.79
- 72 -2238.73 -358.59 325275.20
- 73 -2236.27 -361.05 324914.15
- 74 -2233.78 -363.54 324550.61
- 75 -2231.29 -366.03 324184.58
- 76 -2228.77 -368.55 323816.03
- 77 -2226.24 -371.08 323444.95
-Summary for: 2005:
- Interest Paid: -26878.31
- Principal Paid: -4289.53
- Year Ending Balance: 323444.95
- Sum of Interest Paid: -177713.59
-Pmt * Interest Principal Balance
- 78 -2223.68 -373.64 323071.31
- 79 -2221.12 -376.20 322695.11
- 80 -2218.53 -378.79 322316.32
- 81 -2215.92 -381.40 321934.92
- 82 -2213.30 -384.02 321550.90
- 83 -2210.66 -386.66 321164.24
- 84 -2208.00 -389.32 320774.92
- 85 -2205.33 -391.99 320382.93
- 86 -2202.63 -394.69 319988.24
- 87 -2199.92 -397.40 319590.84
- 88 -2197.19 -400.13 319190.71
- 89 -2194.44 -402.88 318787.83
-Summary for: 2006:
- Interest Paid: -26510.72
- Principal Paid: -4657.12
- Year Ending Balance: 318787.83
- Sum of Interest Paid: -204224.31
-Pmt * Interest Principal Balance
- 90 -2191.67 -405.65 318382.18
- 91 -2188.88 -408.44 317973.74
- 92 -2186.07 -411.25 317562.49
- 93 -2183.24 -414.08 317148.41
- 94 -2180.40 -416.92 316731.49
- 95 -2177.53 -419.79 316311.70
- 96 -2174.64 -422.68 315889.02
- 97 -2171.74 -425.58 315463.44
- 98 -2168.81 -428.51 315034.93
- 99 -2165.87 -431.45 314603.48
- 100 -2162.90 -434.42 314169.06
- 101 -2159.91 -437.41 313731.65
-Summary for: 2007:
- Interest Paid: -26111.66
- Principal Paid: -5056.18
- Year Ending Balance: 313731.65
- Sum of Interest Paid: -230335.97
-Pmt * Interest Principal Balance
- 102 -2156.91 -440.41 313291.24
- 103 -2153.88 -443.44 312847.80
- 104 -2150.83 -446.49 312401.31
- 105 -2147.76 -449.56 311951.75
- 106 -2144.67 -452.65 311499.10
- 107 -2141.56 -455.76 311043.34
- 108 -2138.42 -458.90 310584.44
- 109 -2135.27 -462.05 310122.39
- 110 -2132.09 -465.23 309657.16
- 111 -2128.89 -468.43 309188.73
- 112 -2125.67 -471.65 308717.08
- 113 -2122.43 -474.89 308242.19
-Summary for: 2008:
- Interest Paid: -25678.38
- Principal Paid: -5489.46
- Year Ending Balance: 308242.19
- Sum of Interest Paid: -256014.35
-Pmt * Interest Principal Balance
- 114 -2119.17 -478.15 307764.04
- 115 -2115.88 -481.44 307282.60
- 116 -2112.57 -484.75 306797.85
- 117 -2109.24 -488.08 306309.77
- 118 -2105.88 -491.44 305818.33
- 119 -2102.50 -494.82 305323.51
- 120 -2099.10 -498.22 304825.29
- 121 -2095.67 -501.65 304323.64
- 122 -2092.23 -505.09 303818.55
- 123 -2088.75 -508.57 303309.98
- 124 -2085.26 -512.06 302797.92
- 125 -2081.74 -515.58 302282.34
-Summary for: 2009:
- Interest Paid: -25207.99
- Principal Paid: -5959.85
- Year Ending Balance: 302282.34
- Sum of Interest Paid: -281222.34
-Pmt * Interest Principal Balance
- 126 -2078.19 -519.13 301763.21
- 127 -2074.62 -522.70 301240.51
- 128 -2071.03 -526.29 300714.22
- 129 -2067.41 -529.91 300184.31
- 130 -2063.77 -533.55 299650.76
- 131 -2060.10 -537.22 299113.54
- 132 -2056.41 -540.91 298572.63
- 133 -2052.69 -544.63 298028.00
- 134 -2048.94 -548.38 297479.62
- 135 -2045.17 -552.15 296927.47
- 136 -2041.38 -555.94 296371.53
- 137 -2037.55 -559.77 295811.76
-Summary for: 2010:
- Interest Paid: -24697.26
- Principal Paid: -6470.58
- Year Ending Balance: 295811.76
- Sum of Interest Paid: -305919.60
-Pmt * Interest Principal Balance
- 138 -2033.71 -563.61 295248.15
- 139 -2029.83 -567.49 294680.66
- 140 -2025.93 -571.39 294109.27
- 141 -2022.00 -575.32 293533.95
- 142 -2018.05 -579.27 292954.68
- 143 -2014.06 -583.26 292371.42
- 144 -2010.05 -587.27 291784.15
- 145 -2006.02 -591.30 291192.85
- 146 -2001.95 -595.37 290597.48
- 147 -1997.86 -599.46 289998.02
- 148 -1993.74 -603.58 289394.44
- 149 -1989.59 -607.73 288786.71
-Summary for: 2011:
- Interest Paid: -24142.79
- Principal Paid: -7025.05
- Year Ending Balance: 288786.71
- Sum of Interest Paid: -330062.39
-Pmt * Interest Principal Balance
- 150 -1985.41 -611.91 288174.80
- 151 -1981.20 -616.12 287558.68
- 152 -1976.97 -620.35 286938.33
- 153 -1972.70 -624.62 286313.71
- 154 -1968.41 -628.91 285684.80
- 155 -1964.08 -633.24 285051.56
- 156 -1959.73 -637.59 284413.97
- 157 -1955.35 -641.97 283772.00
- 158 -1950.93 -646.39 283125.61
- 159 -1946.49 -650.83 282474.78
- 160 -1942.01 -655.31 281819.47
- 161 -1937.51 -659.81 281159.66
-Summary for: 2012:
- Interest Paid: -23540.79
- Principal Paid: -7627.05
- Year Ending Balance: 281159.66
- Sum of Interest Paid: -353603.18
-Pmt * Interest Principal Balance
- 162 -1932.97 -664.35 280495.31
- 163 -1928.41 -668.91 279826.40
- 164 -1923.81 -673.51 279152.89
- 165 -1919.18 -678.14 278474.75
- 166 -1914.51 -682.81 277791.94
- 167 -1909.82 -687.50 277104.44
- 168 -1905.09 -692.23 276412.21
- 169 -1900.33 -696.99 275715.22
- 170 -1895.54 -701.78 275013.44
- 171 -1890.72 -706.60 274306.84
- 172 -1885.86 -711.46 273595.38
- 173 -1880.97 -716.35 272879.03
-Summary for: 2013:
- Interest Paid: -22887.21
- Principal Paid: -8280.63
- Year Ending Balance: 272879.03
- Sum of Interest Paid: -376490.39
-Pmt * Interest Principal Balance
- 174 -1876.04 -721.28 272157.75
- 175 -1871.08 -726.24 271431.51
- 176 -1866.09 -731.23 270700.28
- 177 -1861.06 -736.26 269964.02
- 178 -1856.00 -741.32 269222.70
- 179 -1850.91 -746.41 268476.29
- 180 -1845.77 -751.55 267724.74
- 181 -1840.61 -756.71 266968.03
- 182 -1835.41 -761.91 266206.12
- 183 -1830.17 -767.15 265438.97
- 184 -1824.89 -772.43 264666.54
- 185 -1819.58 -777.74 263888.80
-Summary for: 2014:
- Interest Paid: -22177.61
- Principal Paid: -8990.23
- Year Ending Balance: 263888.80
- Sum of Interest Paid: -398668.00
-Pmt * Interest Principal Balance
- 186 -1814.24 -783.08 263105.72
- 187 -1808.85 -788.47 262317.25
- 188 -1803.43 -793.89 261523.36
- 189 -1797.97 -799.35 260724.01
- 190 -1792.48 -804.84 259919.17
- 191 -1786.94 -810.38 259108.79
- 192 -1781.37 -815.95 258292.84
- 193 -1775.76 -821.56 257471.28
- 194 -1770.12 -827.20 256644.08
- 195 -1764.43 -832.89 255811.19
- 196 -1758.70 -838.62 254972.57
- 197 -1752.94 -844.38 254128.19
-Summary for: 2015:
- Interest Paid: -21407.23
- Principal Paid: -9760.61
- Year Ending Balance: 254128.19
- Sum of Interest Paid: -420075.23
-Pmt * Interest Principal Balance
- 198 -1747.13 -850.19 253278.00
- 199 -1741.29 -856.03 252421.97
- 200 -1735.40 -861.92 251560.05
- 201 -1729.48 -867.84 250692.21
- 202 -1723.51 -873.81 249818.40
- 203 -1717.50 -879.82 248938.58
- 204 -1711.45 -885.87 248052.71
- 205 -1705.36 -891.96 247160.75
- 206 -1699.23 -898.09 246262.66
- 207 -1693.06 -904.26 245358.40
- 208 -1686.84 -910.48 244447.92
- 209 -1680.58 -916.74 243531.18
-Summary for: 2016:
- Interest Paid: -20570.83
- Principal Paid: -10597.01
- Year Ending Balance: 243531.18
- Sum of Interest Paid: -440646.06
-Pmt * Interest Principal Balance
- 210 -1674.28 -923.04 242608.14
- 211 -1667.93 -929.39 241678.75
- 212 -1661.54 -935.78 240742.97
- 213 -1655.11 -942.21 239800.76
- 214 -1648.63 -948.69 238852.07
- 215 -1642.11 -955.21 237896.86
- 216 -1635.54 -961.78 236935.08
- 217 -1628.93 -968.39 235966.69
- 218 -1622.27 -975.05 234991.64
- 219 -1615.57 -981.75 234009.89
- 220 -1608.82 -988.50 233021.39
- 221 -1602.02 -995.30 232026.09
-Summary for: 2017:
- Interest Paid: -19662.75
- Principal Paid: -11505.09
- Year Ending Balance: 232026.09
- Sum of Interest Paid: -460308.81
-Pmt * Interest Principal Balance
- 222 -1595.18 -1002.14 231023.95
- 223 -1588.29 -1009.03 230014.92
- 224 -1581.35 -1015.97 228998.95
- 225 -1574.37 -1022.95 227976.00
- 226 -1567.34 -1029.98 226946.02
- 227 -1560.25 -1037.07 225908.95
- 228 -1553.12 -1044.20 224864.75
- 229 -1545.95 -1051.37 223813.38
- 230 -1538.72 -1058.60 222754.78
- 231 -1531.44 -1065.88 221688.90
- 232 -1524.11 -1073.21 220615.69
- 233 -1516.73 -1080.59 219535.10
-Summary for: 2018:
- Interest Paid: -18676.85
- Principal Paid: -12490.99
- Year Ending Balance: 219535.10
- Sum of Interest Paid: -478985.66
-Pmt * Interest Principal Balance
- 234 -1509.30 -1088.02 218447.08
- 235 -1501.82 -1095.50 217351.58
- 236 -1494.29 -1103.03 216248.55
- 237 -1486.71 -1110.61 215137.94
- 238 -1479.07 -1118.25 214019.69
- 239 -1471.39 -1125.93 212893.76
- 240 -1463.64 -1133.68 211760.08
- 241 -1455.85 -1141.47 210618.61
- 242 -1448.00 -1149.32 209469.29
- 243 -1440.10 -1157.22 208312.07
- 244 -1432.15 -1165.17 207146.90
- 245 -1424.13 -1173.19 205973.71
-Summary for: 2019:
- Interest Paid: -17606.45
- Principal Paid: -13561.39
- Year Ending Balance: 205973.71
- Sum of Interest Paid: -496592.11
-Pmt * Interest Principal Balance
- 246 -1416.07 -1181.25 204792.46
- 247 -1407.95 -1189.37 203603.09
- 248 -1399.77 -1197.55 202405.54
- 249 -1391.54 -1205.78 201199.76
- 250 -1383.25 -1214.07 199985.69
- 251 -1374.90 -1222.42 198763.27
- 252 -1366.50 -1230.82 197532.45
- 253 -1358.04 -1239.28 196293.17
- 254 -1349.52 -1247.80 195045.37
- 255 -1340.94 -1256.38 193788.99
- 256 -1332.30 -1265.02 192523.97
- 257 -1323.60 -1273.72 191250.25
-Summary for: 2020:
- Interest Paid: -16444.38
- Principal Paid: -14723.46
- Year Ending Balance: 191250.25
- Sum of Interest Paid: -513036.49
-Pmt * Interest Principal Balance
- 258 -1314.85 -1282.47 189967.78
- 259 -1306.03 -1291.29 188676.49
- 260 -1297.15 -1300.17 187376.32
- 261 -1288.21 -1309.11 186067.21
- 262 -1279.21 -1318.11 184749.10
- 263 -1270.15 -1327.17 183421.93
- 264 -1261.03 -1336.29 182085.64
- 265 -1251.84 -1345.48 180740.16
- 266 -1242.59 -1354.73 179385.43
- 267 -1233.27 -1364.05 178021.38
- 268 -1223.90 -1373.42 176647.96
- 269 -1214.45 -1382.87 175265.09
-Summary for: 2021:
- Interest Paid: -15182.68
- Principal Paid: -15985.16
- Year Ending Balance: 175265.09
- Sum of Interest Paid: -528219.17
-Pmt * Interest Principal Balance
- 270 -1204.95 -1392.37 173872.72
- 271 -1195.37 -1401.95 172470.77
- 272 -1185.74 -1411.58 171059.19
- 273 -1176.03 -1421.29 169637.90
- 274 -1166.26 -1431.06 168206.84
- 275 -1156.42 -1440.90 166765.94
- 276 -1146.52 -1450.80 165315.14
- 277 -1136.54 -1460.78 163854.36
- 278 -1126.50 -1470.82 162383.54
- 279 -1116.39 -1480.93 160902.61
- 280 -1106.21 -1491.11 159411.50
- 281 -1095.95 -1501.37 157910.13
-Summary for: 2022:
- Interest Paid: -13812.88
- Principal Paid: -17354.96
- Year Ending Balance: 157910.13
- Sum of Interest Paid: -542032.05
-Pmt * Interest Principal Balance
- 282 -1085.63 -1511.69 156398.44
- 283 -1075.24 -1522.08 154876.36
- 284 -1064.77 -1532.55 153343.81
- 285 -1054.24 -1543.08 151800.73
- 286 -1043.63 -1553.69 150247.04
- 287 -1032.95 -1564.37 148682.67
- 288 -1022.19 -1575.13 147107.54
- 289 -1011.36 -1585.96 145521.58
- 290 -1000.46 -1596.86 143924.72
- 291 -989.48 -1607.84 142316.88
- 292 -978.43 -1618.89 140697.99
- 293 -967.30 -1630.02 139067.97
-Summary for: 2023:
- Interest Paid: -12325.68
- Principal Paid: -18842.16
- Year Ending Balance: 139067.97
- Sum of Interest Paid: -554357.73
-Pmt * Interest Principal Balance
- 294 -956.09 -1641.23 137426.74
- 295 -944.81 -1652.51 135774.23
- 296 -933.45 -1663.87 134110.36
- 297 -922.01 -1675.31 132435.05
- 298 -910.49 -1686.83 130748.22
- 299 -898.89 -1698.43 129049.79
- 300 -887.22 -1710.10 127339.69
- 301 -875.46 -1721.86 125617.83
- 302 -863.62 -1733.70 123884.13
- 303 -851.70 -1745.62 122138.51
- 304 -839.70 -1757.62 120380.89
- 305 -827.62 -1769.70 118611.19
-Summary for: 2024:
- Interest Paid: -10711.06
- Principal Paid: -20456.78
- Year Ending Balance: 118611.19
- Sum of Interest Paid: -565068.79
-Pmt * Interest Principal Balance
- 306 -815.45 -1781.87 116829.32
- 307 -803.20 -1794.12 115035.20
- 308 -790.87 -1806.45 113228.75
- 309 -778.45 -1818.87 111409.88
- 310 -765.94 -1831.38 109578.50
- 311 -753.35 -1843.97 107734.53
- 312 -740.67 -1856.65 105877.88
- 313 -727.91 -1869.41 104008.47
- 314 -715.06 -1882.26 102126.21
- 315 -702.12 -1895.20 100231.01
- 316 -689.09 -1908.23 98322.78
- 317 -675.97 -1921.35 96401.43
-Summary for: 2025:
- Interest Paid: -8958.08
- Principal Paid: -22209.76
- Year Ending Balance: 96401.43
- Sum of Interest Paid: -574026.87
-Pmt * Interest Principal Balance
- 318 -662.76 -1934.56 94466.87
- 319 -649.46 -1947.86 92519.01
- 320 -636.07 -1961.25 90557.76
- 321 -622.58 -1974.74 88583.02
- 322 -609.01 -1988.31 86594.71
- 323 -595.34 -2001.98 84592.73
- 324 -581.58 -2015.74 82576.99
- 325 -567.72 -2029.60 80547.39
- 326 -553.76 -2043.56 78503.83
- 327 -539.71 -2057.61 76446.22
- 328 -525.57 -2071.75 74374.47
- 329 -511.32 -2086.00 72288.47
-Summary for: 2026:
- Interest Paid: -7054.88
- Principal Paid: -24112.96
- Year Ending Balance: 72288.47
- Sum of Interest Paid: -581081.75
-Pmt * Interest Principal Balance
- 330 -496.98 -2100.34 70188.13
- 331 -482.54 -2114.78 68073.35
- 332 -468.00 -2129.32 65944.03
- 333 -453.37 -2143.95 63800.08
- 334 -438.63 -2158.69 61641.39
- 335 -423.78 -2173.54 59467.85
- 336 -408.84 -2188.48 57279.37
- 337 -393.80 -2203.52 55075.85
- 338 -378.65 -2218.67 52857.18
- 339 -363.39 -2233.93 50623.25
- 340 -348.03 -2249.29 48373.96
- 341 -332.57 -2264.75 46109.21
-Summary for: 2027:
- Interest Paid: -4988.58
- Principal Paid: -26179.26
- Year Ending Balance: 46109.21
- Sum of Interest Paid: -586070.33
-Pmt * Interest Principal Balance
- 342 -317.00 -2280.32 43828.89
- 343 -301.32 -2296.00 41532.89
- 344 -285.54 -2311.78 39221.11
- 345 -269.65 -2327.67 36893.44
- 346 -253.64 -2343.68 34549.76
- 347 -237.53 -2359.79 32189.97
- 348 -221.31 -2376.01 29813.96
- 349 -204.97 -2392.35 27421.61
- 350 -188.52 -2408.80 25012.81
- 351 -171.96 -2425.36 22587.45
- 352 -155.29 -2442.03 20145.42
- 353 -138.50 -2458.82 17686.60
-Summary for: 2028:
- Interest Paid: -2745.23
- Principal Paid: -28422.61
- Year Ending Balance: 17686.60
- Sum of Interest Paid: -588815.56
-Pmt * Interest Principal Balance
- 354 -121.60 -2475.72 15210.88
- 355 -104.57 -2492.75 12718.13
- 356 -87.44 -2509.88 10208.25
- 357 -70.18 -2527.14 7681.11
- 358 -52.81 -2544.51 5136.60
- 359 -35.31 -2562.01 2574.59
-Final Payment: -2592.29
- 360 -17.70 -2574.59 -0.00
-Summary for: 2029:
- Interest Paid: -489.61
- Principal Paid: -17686.60
- Year Ending Balance: 0.00
- Sum of Interest Paid: -589305.17
-
-Total Interest: -589305.17
-
-
-Third Schedule - ignore delay in first payment and
-output variable advanced prepayment schedule
-Amortization Table
-Effective Date: Tue Jun 15 00:00:00 1999
-Initial Payment Date: Sun Aug 1 00:00:00 1999
-Compounding Frequency per year: 12
-Payment Frequency per year: 12
-Compounding: Discrete
-Payments: End of Period
-Payments (359): -2597.32
-Final payment (360): -2591.78
-Nominal Annual Interest Rate: 8.25
- Effective Interest Rate Per Payment Period: 0.006875
-Present Value: 345725.00
-Advanced Prepayment Amortization - Variable Prepayment
-Pmt * Interest Principal Prepay Total Pmt Balance
- 1 -2376.86 -220.46 -221.98 -2819.30 345282.56
- 2 -2373.82 -223.50 -225.04 -2822.36 344834.02
- 3 -2370.73 -226.59 -228.14 -2825.46 344379.29
- 4 -2367.61 -229.71 -231.29 -2828.61 343918.29
- 5 -2364.44 -232.88 -234.48 -2831.80 343450.93
-Summary for: 1999:
- Interest Paid: -11853.46
- Principal Paid: 343447.80
- Year Ending Balance: 343450.93
- Sum of Interest Paid: -11853.46
-Pmt * Interest Principal Prepay Total Pmt Balance
- 6 -2361.23 -236.09 -237.72 -2835.04 342977.12
- 7 -2357.97 -239.35 -241.00 -2838.32 342496.77
- 8 -2354.67 -242.65 -244.32 -2841.64 342009.80
- 9 -2351.32 -246.00 -247.69 -2845.01 341516.11
- 10 -2347.92 -249.40 -251.11 -2848.43 341015.60
- 11 -2344.48 -252.84 -254.58 -2851.90 340508.18
- 12 -2340.99 -256.33 -258.09 -2855.41 339993.76
- 13 -2337.46 -259.86 -261.65 -2858.97 339472.25
- 14 -2333.87 -263.45 -265.26 -2862.58 338943.54
- 15 -2330.24 -267.08 -268.92 -2866.24 338407.54
- 16 -2326.55 -270.77 -272.63 -2869.95 337864.14
- 17 -2322.82 -274.50 -276.39 -2873.71 337313.25
-Summary for: 2000:
- Interest Paid: -28109.52
- Principal Paid: -6137.68
- Year Ending Balance: 337313.25
- Sum of Interest Paid: -39962.98
-Pmt * Interest Principal Prepay Total Pmt Balance
- 18 -2319.03 -278.29 -280.20 -2877.52 336754.76
- 19 -2315.19 -282.13 -284.07 -2881.39 336188.56
- 20 -2311.30 -286.02 -287.99 -2885.31 335614.55
- 21 -2307.35 -289.97 -291.96 -2889.28 335032.62
- 22 -2303.35 -293.97 -295.99 -2893.31 334442.66
- 23 -2299.29 -298.03 -300.08 -2897.40 333844.55
- 24 -2295.18 -302.14 -304.22 -2901.54 333238.19
- 25 -2291.01 -306.31 -308.41 -2905.73 332623.47
- 26 -2286.79 -310.53 -312.67 -2909.99 332000.27
- 27 -2282.50 -314.82 -316.98 -2914.30 331368.47
- 28 -2278.16 -319.16 -321.36 -2918.68 330727.95
- 29 -2273.75 -323.57 -325.79 -2923.11 330078.59
-Summary for: 2001:
- Interest Paid: -27562.90
- Principal Paid: -7234.66
- Year Ending Balance: 330078.59
- Sum of Interest Paid: -67525.88
-Pmt * Interest Principal Prepay Total Pmt Balance
- 30 -2269.29 -328.03 -330.28 -2927.60 329420.28
- 31 -2264.76 -332.56 -334.84 -2932.16 328752.88
- 32 -2260.18 -337.14 -339.46 -2936.78 328076.28
- 33 -2255.52 -341.80 -344.15 -2941.47 327390.33
- 34 -2250.81 -346.51 -348.89 -2946.21 326694.93
- 35 -2246.03 -351.29 -353.71 -2951.03 325989.93
- 36 -2241.18 -356.14 -358.59 -2955.91 325275.20
- 37 -2236.27 -361.05 -363.54 -2960.86 324550.61
- 38 -2231.29 -366.03 -368.55 -2965.87 323816.03
- 39 -2226.24 -371.08 -373.64 -2970.96 323071.31
- 40 -2221.12 -376.20 -378.79 -2976.11 322316.32
- 41 -2215.92 -381.40 -384.02 -2981.34 321550.90
-Summary for: 2002:
- Interest Paid: -26918.61
- Principal Paid: -8527.69
- Year Ending Balance: 321550.90
- Sum of Interest Paid: -94444.49
-Pmt * Interest Principal Prepay Total Pmt Balance
- 42 -2210.66 -386.66 -389.32 -2986.64 320774.92
- 43 -2205.33 -391.99 -394.69 -2992.01 319988.24
- 44 -2199.92 -397.40 -400.13 -2997.45 319190.71
- 45 -2194.44 -402.88 -405.65 -3002.97 318382.18
- 46 -2188.88 -408.44 -411.25 -3008.57 317562.49
- 47 -2183.24 -414.08 -416.92 -3014.24 316731.49
- 48 -2177.53 -419.79 -422.68 -3020.00 315889.02
- 49 -2171.74 -425.58 -428.51 -3025.83 315034.93
- 50 -2165.87 -431.45 -434.42 -3031.74 314169.06
- 51 -2159.91 -437.41 -440.41 -3037.73 313291.24
- 52 -2153.88 -443.44 -446.49 -3043.81 312401.31
- 53 -2147.76 -449.56 -452.65 -3049.97 311499.10
-Summary for: 2003:
- Interest Paid: -26159.16
- Principal Paid: -10051.80
- Year Ending Balance: 311499.10
- Sum of Interest Paid: -120603.65
-Pmt * Interest Principal Prepay Total Pmt Balance
- 54 -2141.56 -455.76 -458.90 -3056.22 310584.44
- 55 -2135.27 -462.05 -465.23 -3062.55 309657.16
- 56 -2128.89 -468.43 -471.65 -3068.97 308717.08
- 57 -2122.43 -474.89 -478.15 -3075.47 307764.04
- 58 -2115.88 -481.44 -484.75 -3082.07 306797.85
- 59 -2109.24 -488.08 -491.44 -3088.76 305818.33
- 60 -2102.50 -494.82 -498.22 -3095.54 304825.29
- 61 -2095.67 -501.65 -505.09 -3102.41 303818.55
- 62 -2088.75 -508.57 -512.06 -3109.38 302797.92
- 63 -2081.74 -515.58 -519.13 -3116.45 301763.21
- 64 -2074.62 -522.70 -526.29 -3123.61 300714.22
- 65 -2067.41 -529.91 -533.55 -3130.87 299650.76
-Summary for: 2004:
- Interest Paid: -25263.96
- Principal Paid: -11848.34
- Year Ending Balance: 299650.76
- Sum of Interest Paid: -145867.61
-Pmt * Interest Principal Prepay Total Pmt Balance
- 66 -2060.10 -537.22 -540.91 -3138.23 298572.63
- 67 -2052.69 -544.63 -548.38 -3145.70 297479.62
- 68 -2045.17 -552.15 -555.94 -3153.26 296371.53
- 69 -2037.55 -559.77 -563.61 -3160.93 295248.15
- 70 -2029.83 -567.49 -571.39 -3168.71 294109.27
- 71 -2022.00 -575.32 -579.27 -3176.59 292954.68
- 72 -2014.06 -583.26 -587.27 -3184.59 291784.15
- 73 -2006.02 -591.30 -595.37 -3192.69 290597.48
- 74 -1997.86 -599.46 -603.58 -3200.90 289394.44
- 75 -1989.59 -607.73 -611.91 -3209.23 288174.80
- 76 -1981.20 -616.12 -620.35 -3217.67 286938.33
- 77 -1972.70 -624.62 -628.91 -3226.23 285684.80
-Summary for: 2005:
- Interest Paid: -24208.77
- Principal Paid: -13965.96
- Year Ending Balance: 285684.80
- Sum of Interest Paid: -170076.38
-Pmt * Interest Principal Prepay Total Pmt Balance
- 78 -1964.08 -633.24 -637.59 -3234.91 284413.97
- 79 -1955.35 -641.97 -646.39 -3243.71 283125.61
- 80 -1946.49 -650.83 -655.31 -3252.63 281819.47
- 81 -1937.51 -659.81 -664.35 -3261.67 280495.31
- 82 -1928.41 -668.91 -673.51 -3270.83 279152.89
- 83 -1919.18 -678.14 -682.81 -3280.13 277791.94
- 84 -1909.82 -687.50 -692.23 -3289.55 276412.21
- 85 -1900.33 -696.99 -701.78 -3299.10 275013.44
- 86 -1890.72 -706.60 -711.46 -3308.78 273595.38
- 87 -1880.97 -716.35 -721.28 -3318.60 272157.75
- 88 -1871.08 -726.24 -731.23 -3328.55 270700.28
- 89 -1861.06 -736.26 -741.32 -3338.64 269222.70
-Summary for: 2006:
- Interest Paid: -22965.00
- Principal Paid: -16462.10
- Year Ending Balance: 269222.70
- Sum of Interest Paid: -193041.38
-Pmt * Interest Principal Prepay Total Pmt Balance
- 90 -1850.91 -746.41 -751.55 -3348.87 267724.74
- 91 -1840.61 -756.71 -761.91 -3359.23 266206.12
- 92 -1830.17 -767.15 -772.43 -3369.75 264666.54
- 93 -1819.58 -777.74 -783.08 -3380.40 263105.72
- 94 -1808.85 -788.47 -793.89 -3391.21 261523.36
- 95 -1797.97 -799.35 -804.84 -3402.16 259919.17
- 96 -1786.94 -810.38 -815.95 -3413.27 258292.84
- 97 -1775.76 -821.56 -827.20 -3424.52 256644.08
- 98 -1764.43 -832.89 -838.62 -3435.94 254972.57
- 99 -1752.94 -844.38 -850.19 -3447.51 253278.00
- 100 -1741.29 -856.03 -861.92 -3459.24 251560.05
- 101 -1729.48 -867.84 -873.81 -3471.13 249818.40
-Summary for: 2007:
- Interest Paid: -21498.93
- Principal Paid: -19404.30
- Year Ending Balance: 249818.40
- Sum of Interest Paid: -214540.31
-Pmt * Interest Principal Prepay Total Pmt Balance
- 102 -1717.50 -879.82 -885.87 -3483.19 248052.71
- 103 -1705.36 -891.96 -898.09 -3495.41 246262.66
- 104 -1693.06 -904.26 -910.48 -3507.80 244447.92
- 105 -1680.58 -916.74 -923.04 -3520.36 242608.14
- 106 -1667.93 -929.39 -935.78 -3533.10 240742.97
- 107 -1655.11 -942.21 -948.69 -3546.01 238852.07
- 108 -1642.11 -955.21 -961.78 -3559.10 236935.08
- 109 -1628.93 -968.39 -975.05 -3572.37 234991.64
- 110 -1615.57 -981.75 -988.50 -3585.82 233021.39
- 111 -1602.02 -995.30 -1002.14 -3599.46 231023.95
- 112 -1588.29 -1009.03 -1015.97 -3613.29 228998.95
- 113 -1574.37 -1022.95 -1029.99 -3627.31 226946.01
-Summary for: 2008:
- Interest Paid: -19770.83
- Principal Paid: -22872.39
- Year Ending Balance: 226946.01
- Sum of Interest Paid: -234311.14
-Pmt * Interest Principal Prepay Total Pmt Balance
- 114 -1560.25 -1037.07 -1044.20 -3641.52 224864.74
- 115 -1545.95 -1051.37 -1058.60 -3655.92 222754.77
- 116 -1531.44 -1065.88 -1073.21 -3670.53 220615.68
- 117 -1516.73 -1080.59 -1088.02 -3685.34 218447.07
- 118 -1501.82 -1095.50 -1103.03 -3700.35 216248.54
- 119 -1486.71 -1110.61 -1118.25 -3715.57 214019.68
- 120 -1471.39 -1125.93 -1133.68 -3731.00 211760.07
- 121 -1455.85 -1141.47 -1149.32 -3746.64 209469.28
- 122 -1440.10 -1157.22 -1165.17 -3762.49 207146.89
- 123 -1424.13 -1173.19 -1181.25 -3778.57 204792.45
- 124 -1407.95 -1189.37 -1197.55 -3794.87 202405.53
- 125 -1391.54 -1205.78 -1214.07 -3811.39 199985.68
-Summary for: 2009:
- Interest Paid: -17733.86
- Principal Paid: -26960.33
- Year Ending Balance: 199985.68
- Sum of Interest Paid: -252045.00
-Pmt * Interest Principal Prepay Total Pmt Balance
- 126 -1374.90 -1222.42 -1230.82 -3828.14 197532.44
- 127 -1358.04 -1239.28 -1247.80 -3845.12 195045.36
- 128 -1340.94 -1256.38 -1265.02 -3862.34 192523.96
- 129 -1323.60 -1273.72 -1282.47 -3879.79 189967.77
- 130 -1306.03 -1291.29 -1300.17 -3897.49 187376.31
- 131 -1288.21 -1309.11 -1318.11 -3915.43 184749.09
- 132 -1270.15 -1327.17 -1336.29 -3933.61 182085.63
- 133 -1251.84 -1345.48 -1354.73 -3952.05 179385.42
- 134 -1233.27 -1364.05 -1373.42 -3970.74 176647.95
- 135 -1214.45 -1382.87 -1392.37 -3989.69 173872.71
- 136 -1195.37 -1401.95 -1411.58 -4008.90 171059.18
- 137 -1176.03 -1421.29 -1431.06 -4028.38 168206.83
-Summary for: 2010:
- Interest Paid: -15332.83
- Principal Paid: -31778.85
- Year Ending Balance: 168206.83
- Sum of Interest Paid: -267377.83
-Pmt * Interest Principal Prepay Total Pmt Balance
- 138 -1156.42 -1440.90 -1450.80 -4048.12 165315.13
- 139 -1136.54 -1460.78 -1470.82 -4068.14 162383.53
- 140 -1116.39 -1480.93 -1491.11 -4088.43 159411.49
- 141 -1095.95 -1501.37 -1511.69 -4109.01 156398.43
- 142 -1075.24 -1522.08 -1532.55 -4129.87 153343.80
- 143 -1054.24 -1543.08 -1553.69 -4151.01 150247.03
- 144 -1032.95 -1564.37 -1575.13 -4172.45 147107.53
- 145 -1011.36 -1585.96 -1596.86 -4194.18 143924.71
- 146 -989.48 -1607.84 -1618.89 -4216.21 140697.98
- 147 -967.30 -1630.02 -1641.23 -4238.55 137426.73
- 148 -944.81 -1652.51 -1663.87 -4261.19 134110.35
- 149 -922.01 -1675.31 -1686.83 -4284.15 130748.21
-Summary for: 2011:
- Interest Paid: -12502.69
- Principal Paid: -37458.62
- Year Ending Balance: 130748.21
- Sum of Interest Paid: -279880.52
-Pmt * Interest Principal Prepay Total Pmt Balance
- 150 -898.89 -1698.43 -1710.10 -4307.42 127339.68
- 151 -875.46 -1721.86 -1733.70 -4331.02 123884.12
- 152 -851.70 -1745.62 -1757.62 -4354.94 120380.88
- 153 -827.62 -1769.70 -1781.87 -4379.19 116829.31
- 154 -803.20 -1794.12 -1806.45 -4403.77 113228.74
- 155 -778.45 -1818.87 -1831.38 -4428.70 109578.49
- 156 -753.35 -1843.97 -1856.65 -4453.97 105877.87
- 157 -727.91 -1869.41 -1882.26 -4479.58 102126.20
- 158 -702.12 -1895.20 -1908.23 -4505.55 98322.77
- 159 -675.97 -1921.35 -1934.56 -4531.88 94466.86
- 160 -649.46 -1947.86 -1961.25 -4558.57 90557.75
- 161 -622.58 -1974.74 -1988.31 -4585.63 86594.70
-Summary for: 2012:
- Interest Paid: -9166.71
- Principal Paid: -44153.51
- Year Ending Balance: 86594.70
- Sum of Interest Paid: -289047.23
-Pmt * Interest Principal Prepay Total Pmt Balance
- 162 -595.34 -2001.98 -2015.75 -4613.07 82576.97
- 163 -567.72 -2029.60 -2043.56 -4640.88 78503.81
- 164 -539.71 -2057.61 -2071.75 -4669.07 74374.45
- 165 -511.32 -2086.00 -2100.34 -4697.66 70188.11
- 166 -482.54 -2114.78 -2129.32 -4726.64 65944.01
- 167 -453.37 -2143.95 -2158.69 -4756.01 61641.37
- 168 -423.78 -2173.54 -2188.48 -4785.80 57279.35
- 169 -393.80 -2203.52 -2218.67 -4815.99 52857.16
- 170 -363.39 -2233.93 -2249.29 -4846.61 48373.94
- 171 -332.57 -2264.75 -2280.32 -4877.64 43828.87
- 172 -301.32 -2296.00 -2311.78 -4909.10 39221.09
- 173 -269.64 -2327.68 -2343.68 -4941.00 34549.73
-Summary for: 2013:
- Interest Paid: -5234.50
- Principal Paid: -52044.97
- Year Ending Balance: 34549.73
- Sum of Interest Paid: -294281.73
-Pmt * Interest Principal Prepay Total Pmt Balance
- 174 -237.53 -2359.79 -2376.01 -4973.33 29813.93
- 175 -204.97 -2392.35 -2408.80 -5006.12 25012.78
- 176 -171.96 -2425.36 -2442.03 -5039.35 20145.39
- 177 -138.50 -2458.82 -2475.72 -5073.04 15210.85
- 178 -104.57 -2492.75 -2509.88 -5107.20 10208.22
- 179 -70.18 -2527.14 -2544.51 -5141.83 5136.57
- 180 -35.31 -2562.01 -2574.56 -5171.88 0.00
-Summary for: 2014:
- Interest Paid: -963.02
- Principal Paid: -34549.73
- Year Ending Balance: 0.00
- Sum of Interest Paid: -295244.75
-
-Total Interest: -295244.75
-
-
-Fourth Schedule - ignore delay in first payment and
-output fixed prepayment schedule
-Amortization Table
-Effective Date: Tue Jun 15 00:00:00 1999
-Initial Payment Date: Sun Aug 1 00:00:00 1999
-Compounding Frequency per year: 12
-Payment Frequency per year: 12
-Compounding: Discrete
-Payments: End of Period
-Payments (359): -2597.32
-Final payment (360): -2591.78
-Nominal Annual Interest Rate: 8.25
- Effective Interest Rate Per Payment Period: 0.006875
-Present Value: 345725.00
-Advanced Prepayment Amortization - Fixed Prepayment: -400.00
-Pmt * Interest Principal Prepay Total Pmt Balance
- 1 -2376.86 -220.46 -400.00 -2997.32 345104.54
- 2 -2372.59 -224.73 -400.00 -2997.32 344479.81
- 3 -2368.30 -229.02 -400.00 -2997.32 343850.79
- 4 -2363.97 -233.35 -400.00 -2997.32 343217.44
- 5 -2359.62 -237.70 -400.00 -2997.32 342579.74
-Summary for: 1999:
- Interest Paid: -11841.34
- Principal Paid: 342576.61
- Year Ending Balance: 342579.74
- Sum of Interest Paid: -11841.34
-Pmt * Interest Principal Prepay Total Pmt Balance
- 6 -2355.24 -242.08 -400.00 -2997.32 341937.66
- 7 -2350.82 -246.50 -400.00 -2997.32 341291.16
- 8 -2346.38 -250.94 -400.00 -2997.32 340640.22
- 9 -2341.90 -255.42 -400.00 -2997.32 339984.80
- 10 -2337.40 -259.92 -400.00 -2997.32 339324.88
- 11 -2332.86 -264.46 -400.00 -2997.32 338660.42
- 12 -2328.29 -269.03 -400.00 -2997.32 337991.39
- 13 -2323.69 -273.63 -400.00 -2997.32 337317.76
- 14 -2319.06 -278.26 -400.00 -2997.32 336639.50
- 15 -2314.40 -282.92 -400.00 -2997.32 335956.58
- 16 -2309.70 -287.62 -400.00 -2997.32 335268.96
- 17 -2304.97 -292.35 -400.00 -2997.32 334576.61
-Summary for: 2000:
- Interest Paid: -27964.71
- Principal Paid: -8003.13
- Year Ending Balance: 334576.61
- Sum of Interest Paid: -39806.05
-Pmt * Interest Principal Prepay Total Pmt Balance
- 18 -2300.21 -297.11 -400.00 -2997.32 333879.50
- 19 -2295.42 -301.90 -400.00 -2997.32 333177.60
- 20 -2290.60 -306.72 -400.00 -2997.32 332470.88
- 21 -2285.74 -311.58 -400.00 -2997.32 331759.30
- 22 -2280.85 -316.47 -400.00 -2997.32 331042.83
- 23 -2275.92 -321.40 -400.00 -2997.32 330321.43
- 24 -2270.96 -326.36 -400.00 -2997.32 329595.07
- 25 -2265.97 -331.35 -400.00 -2997.32 328863.72
- 26 -2260.94 -336.38 -400.00 -2997.32 328127.34
- 27 -2255.88 -341.44 -400.00 -2997.32 327385.90
- 28 -2250.78 -346.54 -400.00 -2997.32 326639.36
- 29 -2245.65 -351.67 -400.00 -2997.32 325887.69
-Summary for: 2001:
- Interest Paid: -27278.92
- Principal Paid: -8688.92
- Year Ending Balance: 325887.69
- Sum of Interest Paid: -67084.97
-Pmt * Interest Principal Prepay Total Pmt Balance
- 30 -2240.48 -356.84 -400.00 -2997.32 325130.85
- 31 -2235.27 -362.05 -400.00 -2997.32 324368.80
- 32 -2230.04 -367.28 -400.00 -2997.32 323601.52
- 33 -2224.76 -372.56 -400.00 -2997.32 322828.96
- 34 -2219.45 -377.87 -400.00 -2997.32 322051.09
- 35 -2214.10 -383.22 -400.00 -2997.32 321267.87
- 36 -2208.72 -388.60 -400.00 -2997.32 320479.27
- 37 -2203.29 -394.03 -400.00 -2997.32 319685.24
- 38 -2197.84 -399.48 -400.00 -2997.32 318885.76
- 39 -2192.34 -404.98 -400.00 -2997.32 318080.78
- 40 -2186.81 -410.51 -400.00 -2997.32 317270.27
- 41 -2181.23 -416.09 -400.00 -2997.32 316454.18
-Summary for: 2002:
- Interest Paid: -26534.33
- Principal Paid: -9433.51
- Year Ending Balance: 316454.18
- Sum of Interest Paid: -93619.30
-Pmt * Interest Principal Prepay Total Pmt Balance
- 42 -2175.62 -421.70 -400.00 -2997.32 315632.48
- 43 -2169.97 -427.35 -400.00 -2997.32 314805.13
- 44 -2164.29 -433.03 -400.00 -2997.32 313972.10
- 45 -2158.56 -438.76 -400.00 -2997.32 313133.34
- 46 -2152.79 -444.53 -400.00 -2997.32 312288.81
- 47 -2146.99 -450.33 -400.00 -2997.32 311438.48
- 48 -2141.14 -456.18 -400.00 -2997.32 310582.30
- 49 -2135.25 -462.07 -400.00 -2997.32 309720.23
- 50 -2129.33 -467.99 -400.00 -2997.32 308852.24
- 51 -2123.36 -473.96 -400.00 -2997.32 307978.28
- 52 -2117.35 -479.97 -400.00 -2997.32 307098.31
- 53 -2111.30 -486.02 -400.00 -2997.32 306212.29
-Summary for: 2003:
- Interest Paid: -25725.95
- Principal Paid: -10241.89
- Year Ending Balance: 306212.29
- Sum of Interest Paid: -119345.25
-Pmt * Interest Principal Prepay Total Pmt Balance
- 54 -2105.21 -492.11 -400.00 -2997.32 305320.18
- 55 -2099.08 -498.24 -400.00 -2997.32 304421.94
- 56 -2092.90 -504.42 -400.00 -2997.32 303517.52
- 57 -2086.68 -510.64 -400.00 -2997.32 302606.88
- 58 -2080.42 -516.90 -400.00 -2997.32 301689.98
- 59 -2074.12 -523.20 -400.00 -2997.32 300766.78
- 60 -2067.77 -529.55 -400.00 -2997.32 299837.23
- 61 -2061.38 -535.94 -400.00 -2997.32 298901.29
- 62 -2054.95 -542.37 -400.00 -2997.32 297958.92
- 63 -2048.47 -548.85 -400.00 -2997.32 297010.07
- 64 -2041.94 -555.38 -400.00 -2997.32 296054.69
- 65 -2035.38 -561.94 -400.00 -2997.32 295092.75
-Summary for: 2004:
- Interest Paid: -24848.30
- Principal Paid: -11119.54
- Year Ending Balance: 295092.75
- Sum of Interest Paid: -144193.55
-Pmt * Interest Principal Prepay Total Pmt Balance
- 66 -2028.76 -568.56 -400.00 -2997.32 294124.19
- 67 -2022.10 -575.22 -400.00 -2997.32 293148.97
- 68 -2015.40 -581.92 -400.00 -2997.32 292167.05
- 69 -2008.65 -588.67 -400.00 -2997.32 291178.38
- 70 -2001.85 -595.47 -400.00 -2997.32 290182.91
- 71 -1995.01 -602.31 -400.00 -2997.32 289180.60
- 72 -1988.12 -609.20 -400.00 -2997.32 288171.40
- 73 -1981.18 -616.14 -400.00 -2997.32 287155.26
- 74 -1974.19 -623.13 -400.00 -2997.32 286132.13
- 75 -1967.16 -630.16 -400.00 -2997.32 285101.97
- 76 -1960.08 -637.24 -400.00 -2997.32 284064.73
- 77 -1952.95 -644.37 -400.00 -2997.32 283020.36
-Summary for: 2005:
- Interest Paid: -23895.45
- Principal Paid: -12072.39
- Year Ending Balance: 283020.36
- Sum of Interest Paid: -168089.00
-Pmt * Interest Principal Prepay Total Pmt Balance
- 78 -1945.76 -651.56 -400.00 -2997.32 281968.80
- 79 -1938.54 -658.78 -400.00 -2997.32 280910.02
- 80 -1931.26 -666.06 -400.00 -2997.32 279843.96
- 81 -1923.93 -673.39 -400.00 -2997.32 278770.57
- 82 -1916.55 -680.77 -400.00 -2997.32 277689.80
- 83 -1909.12 -688.20 -400.00 -2997.32 276601.60
- 84 -1901.64 -695.68 -400.00 -2997.32 275505.92
- 85 -1894.10 -703.22 -400.00 -2997.32 274402.70
- 86 -1886.52 -710.80 -400.00 -2997.32 273291.90
- 87 -1878.88 -718.44 -400.00 -2997.32 272173.46
- 88 -1871.19 -726.13 -400.00 -2997.32 271047.33
- 89 -1863.45 -733.87 -400.00 -2997.32 269913.46
-Summary for: 2006:
- Interest Paid: -22860.94
- Principal Paid: -13106.90
- Year Ending Balance: 269913.46
- Sum of Interest Paid: -190949.94
-Pmt * Interest Principal Prepay Total Pmt Balance
- 90 -1855.66 -741.66 -400.00 -2997.32 268771.80
- 91 -1847.81 -749.51 -400.00 -2997.32 267622.29
- 92 -1839.90 -757.42 -400.00 -2997.32 266464.87
- 93 -1831.95 -765.37 -400.00 -2997.32 265299.50
- 94 -1823.93 -773.39 -400.00 -2997.32 264126.11
- 95 -1815.87 -781.45 -400.00 -2997.32 262944.66
- 96 -1807.74 -789.58 -400.00 -2997.32 261755.08
- 97 -1799.57 -797.75 -400.00 -2997.32 260557.33
- 98 -1791.33 -805.99 -400.00 -2997.32 259351.34
- 99 -1783.04 -814.28 -400.00 -2997.32 258137.06
- 100 -1774.69 -822.63 -400.00 -2997.32 256914.43
- 101 -1766.29 -831.03 -400.00 -2997.32 255683.40
-Summary for: 2007:
- Interest Paid: -21737.78
- Principal Paid: -14230.06
- Year Ending Balance: 255683.40
- Sum of Interest Paid: -212687.72
-Pmt * Interest Principal Prepay Total Pmt Balance
- 102 -1757.82 -839.50 -400.00 -2997.32 254443.90
- 103 -1749.30 -848.02 -400.00 -2997.32 253195.88
- 104 -1740.72 -856.60 -400.00 -2997.32 251939.28
- 105 -1732.08 -865.24 -400.00 -2997.32 250674.04
- 106 -1723.38 -873.94 -400.00 -2997.32 249400.10
- 107 -1714.63 -882.69 -400.00 -2997.32 248117.41
- 108 -1705.81 -891.51 -400.00 -2997.32 246825.90
- 109 -1696.93 -900.39 -400.00 -2997.32 245525.51
- 110 -1687.99 -909.33 -400.00 -2997.32 244216.18
- 111 -1678.99 -918.33 -400.00 -2997.32 242897.85
- 112 -1669.92 -927.40 -400.00 -2997.32 241570.45
- 113 -1660.80 -936.52 -400.00 -2997.32 240233.93
-Summary for: 2008:
- Interest Paid: -20518.37
- Principal Paid: -15449.47
- Year Ending Balance: 240233.93
- Sum of Interest Paid: -233206.09
-Pmt * Interest Principal Prepay Total Pmt Balance
- 114 -1651.61 -945.71 -400.00 -2997.32 238888.22
- 115 -1642.36 -954.96 -400.00 -2997.32 237533.26
- 116 -1633.04 -964.28 -400.00 -2997.32 236168.98
- 117 -1623.66 -973.66 -400.00 -2997.32 234795.32
- 118 -1614.22 -983.10 -400.00 -2997.32 233412.22
- 119 -1604.71 -992.61 -400.00 -2997.32 232019.61
- 120 -1595.13 -1002.19 -400.00 -2997.32 230617.42
- 121 -1585.49 -1011.83 -400.00 -2997.32 229205.59
- 122 -1575.79 -1021.53 -400.00 -2997.32 227784.06
- 123 -1566.02 -1031.30 -400.00 -2997.32 226352.76
- 124 -1556.18 -1041.14 -400.00 -2997.32 224911.62
- 125 -1546.27 -1051.05 -400.00 -2997.32 223460.57
-Summary for: 2009:
- Interest Paid: -19194.48
- Principal Paid: -16773.36
- Year Ending Balance: 223460.57
- Sum of Interest Paid: -252400.57
-Pmt * Interest Principal Prepay Total Pmt Balance
- 126 -1536.29 -1061.03 -400.00 -2997.32 221999.54
- 127 -1526.25 -1071.07 -400.00 -2997.32 220528.47
- 128 -1516.13 -1081.19 -400.00 -2997.32 219047.28
- 129 -1505.95 -1091.37 -400.00 -2997.32 217555.91
- 130 -1495.70 -1101.62 -400.00 -2997.32 216054.29
- 131 -1485.37 -1111.95 -400.00 -2997.32 214542.34
- 132 -1474.98 -1122.34 -400.00 -2997.32 213020.00
- 133 -1464.51 -1132.81 -400.00 -2997.32 211487.19
- 134 -1453.97 -1143.35 -400.00 -2997.32 209943.84
- 135 -1443.36 -1153.96 -400.00 -2997.32 208389.88
- 136 -1432.68 -1164.64 -400.00 -2997.32 206825.24
- 137 -1421.92 -1175.40 -400.00 -2997.32 205249.84
-Summary for: 2010:
- Interest Paid: -17757.11
- Principal Paid: -18210.73
- Year Ending Balance: 205249.84
- Sum of Interest Paid: -270157.68
-Pmt * Interest Principal Prepay Total Pmt Balance
- 138 -1411.09 -1186.23 -400.00 -2997.32 203663.61
- 139 -1400.19 -1197.13 -400.00 -2997.32 202066.48
- 140 -1389.21 -1208.11 -400.00 -2997.32 200458.37
- 141 -1378.15 -1219.17 -400.00 -2997.32 198839.20
- 142 -1367.02 -1230.30 -400.00 -2997.32 197208.90
- 143 -1355.81 -1241.51 -400.00 -2997.32 195567.39
- 144 -1344.53 -1252.79 -400.00 -2997.32 193914.60
- 145 -1333.16 -1264.16 -400.00 -2997.32 192250.44
- 146 -1321.72 -1275.60 -400.00 -2997.32 190574.84
- 147 -1310.20 -1287.12 -400.00 -2997.32 188887.72
- 148 -1298.60 -1298.72 -400.00 -2997.32 187189.00
- 149 -1286.92 -1310.40 -400.00 -2997.32 185478.60
-Summary for: 2011:
- Interest Paid: -16196.60
- Principal Paid: -19771.24
- Year Ending Balance: 185478.60
- Sum of Interest Paid: -286354.28
-Pmt * Interest Principal Prepay Total Pmt Balance
- 150 -1275.17 -1322.15 -400.00 -2997.32 183756.45
- 151 -1263.33 -1333.99 -400.00 -2997.32 182022.46
- 152 -1251.40 -1345.92 -400.00 -2997.32 180276.54
- 153 -1239.40 -1357.92 -400.00 -2997.32 178518.62
- 154 -1227.32 -1370.00 -400.00 -2997.32 176748.62
- 155 -1215.15 -1382.17 -400.00 -2997.32 174966.45
- 156 -1202.89 -1394.43 -400.00 -2997.32 173172.02
- 157 -1190.56 -1406.76 -400.00 -2997.32 171365.26
- 158 -1178.14 -1419.18 -400.00 -2997.32 169546.08
- 159 -1165.63 -1431.69 -400.00 -2997.32 167714.39
- 160 -1153.04 -1444.28 -400.00 -2997.32 165870.11
- 161 -1140.36 -1456.96 -400.00 -2997.32 164013.15
-Summary for: 2012:
- Interest Paid: -14502.39
- Principal Paid: -21465.45
- Year Ending Balance: 164013.15
- Sum of Interest Paid: -300856.67
-Pmt * Interest Principal Prepay Total Pmt Balance
- 162 -1127.59 -1469.73 -400.00 -2997.32 162143.42
- 163 -1114.74 -1482.58 -400.00 -2997.32 160260.84
- 164 -1101.79 -1495.53 -400.00 -2997.32 158365.31
- 165 -1088.76 -1508.56 -400.00 -2997.32 156456.75
- 166 -1075.64 -1521.68 -400.00 -2997.32 154535.07
- 167 -1062.43 -1534.89 -400.00 -2997.32 152600.18
- 168 -1049.13 -1548.19 -400.00 -2997.32 150651.99
- 169 -1035.73 -1561.59 -400.00 -2997.32 148690.40
- 170 -1022.25 -1575.07 -400.00 -2997.32 146715.33
- 171 -1008.67 -1588.65 -400.00 -2997.32 144726.68
- 172 -995.00 -1602.32 -400.00 -2997.32 142724.36
- 173 -981.23 -1616.09 -400.00 -2997.32 140708.27
-Summary for: 2013:
- Interest Paid: -12662.96
- Principal Paid: -23304.88
- Year Ending Balance: 140708.27
- Sum of Interest Paid: -313519.63
-Pmt * Interest Principal Prepay Total Pmt Balance
- 174 -967.37 -1629.95 -400.00 -2997.32 138678.32
- 175 -953.41 -1643.91 -400.00 -2997.32 136634.41
- 176 -939.36 -1657.96 -400.00 -2997.32 134576.45
- 177 -925.21 -1672.11 -400.00 -2997.32 132504.34
- 178 -910.97 -1686.35 -400.00 -2997.32 130417.99
- 179 -896.62 -1700.70 -400.00 -2997.32 128317.29
- 180 -882.18 -1715.14 -400.00 -2997.32 126202.15
- 181 -867.64 -1729.68 -400.00 -2997.32 124072.47
- 182 -853.00 -1744.32 -400.00 -2997.32 121928.15
- 183 -838.26 -1759.06 -400.00 -2997.32 119769.09
- 184 -823.41 -1773.91 -400.00 -2997.32 117595.18
- 185 -808.47 -1788.85 -400.00 -2997.32 115406.33
-Summary for: 2014:
- Interest Paid: -10665.90
- Principal Paid: -25301.94
- Year Ending Balance: 115406.33
- Sum of Interest Paid: -324185.53
-Pmt * Interest Principal Prepay Total Pmt Balance
- 186 -793.42 -1803.90 -400.00 -2997.32 113202.43
- 187 -778.27 -1819.05 -400.00 -2997.32 110983.38
- 188 -763.01 -1834.31 -400.00 -2997.32 108749.07
- 189 -747.65 -1849.67 -400.00 -2997.32 106499.40
- 190 -732.18 -1865.14 -400.00 -2997.32 104234.26
- 191 -716.61 -1880.71 -400.00 -2997.32 101953.55
- 192 -700.93 -1896.39 -400.00 -2997.32 99657.16
- 193 -685.14 -1912.18 -400.00 -2997.32 97344.98
- 194 -669.25 -1928.07 -400.00 -2997.32 95016.91
- 195 -653.24 -1944.08 -400.00 -2997.32 92672.83
- 196 -637.13 -1960.19 -400.00 -2997.32 90312.64
- 197 -620.90 -1976.42 -400.00 -2997.32 87936.22
-Summary for: 2015:
- Interest Paid: -8497.73
- Principal Paid: -27470.11
- Year Ending Balance: 87936.22
- Sum of Interest Paid: -332683.26
-Pmt * Interest Principal Prepay Total Pmt Balance
- 198 -604.56 -1992.76 -400.00 -2997.32 85543.46
- 199 -588.11 -2009.21 -400.00 -2997.32 83134.25
- 200 -571.55 -2025.77 -400.00 -2997.32 80708.48
- 201 -554.87 -2042.45 -400.00 -2997.32 78266.03
- 202 -538.08 -2059.24 -400.00 -2997.32 75806.79
- 203 -521.17 -2076.15 -400.00 -2997.32 73330.64
- 204 -504.15 -2093.17 -400.00 -2997.32 70837.47
- 205 -487.01 -2110.31 -400.00 -2997.32 68327.16
- 206 -469.75 -2127.57 -400.00 -2997.32 65799.59
- 207 -452.37 -2144.95 -400.00 -2997.32 63254.64
- 208 -434.88 -2162.44 -400.00 -2997.32 60692.20
- 209 -417.26 -2180.06 -400.00 -2997.32 58112.14
-Summary for: 2016:
- Interest Paid: -6143.76
- Principal Paid: -29824.08
- Year Ending Balance: 58112.14
- Sum of Interest Paid: -338827.02
-Pmt * Interest Principal Prepay Total Pmt Balance
- 210 -399.52 -2197.80 -400.00 -2997.32 55514.34
- 211 -381.66 -2215.66 -400.00 -2997.32 52898.68
- 212 -363.68 -2233.64 -400.00 -2997.32 50265.04
- 213 -345.57 -2251.75 -400.00 -2997.32 47613.29
- 214 -327.34 -2269.98 -400.00 -2997.32 44943.31
- 215 -308.99 -2288.33 -400.00 -2997.32 42254.98
- 216 -290.50 -2306.82 -400.00 -2997.32 39548.16
- 217 -271.89 -2325.43 -400.00 -2997.32 36822.73
- 218 -253.16 -2344.16 -400.00 -2997.32 34078.57
- 219 -234.29 -2363.03 -400.00 -2997.32 31315.54
- 220 -215.29 -2382.03 -400.00 -2997.32 28533.51
- 221 -196.17 -2401.15 -400.00 -2997.32 25732.36
-Summary for: 2017:
- Interest Paid: -3588.06
- Principal Paid: -32379.78
- Year Ending Balance: 25732.36
- Sum of Interest Paid: -342415.08
-Pmt * Interest Principal Prepay Total Pmt Balance
- 222 -176.91 -2420.41 -400.00 -2997.32 22911.95
- 223 -157.52 -2439.80 -400.00 -2997.32 20072.15
- 224 -138.00 -2459.32 -400.00 -2997.32 17212.83
- 225 -118.34 -2478.98 -400.00 -2997.32 14333.85
- 226 -98.55 -2498.77 -400.00 -2997.32 11435.08
- 227 -78.62 -2518.70 -400.00 -2997.32 8516.38
- 228 -58.55 -2538.77 -400.00 -2997.32 5577.61
- 229 -38.35 -2558.97 -400.00 -2997.32 2618.64
- 230 -18.00 -2579.32 -39.32 -2636.64 0.00
-Summary for: 2018:
- Interest Paid: -882.84
- Principal Paid: -25732.36
- Year Ending Balance: 0.00
- Sum of Interest Paid: -343297.92
-
-Total Interest: -343297.92
-
-
-Fifth Schedule - use new payments due to delay and
-output annual summary
-Amortization Table
-Effective Date: Tue Jun 15 00:00:00 1999
-Initial Payment Date: Sun Aug 1 00:00:00 1999
-Compounding Frequency per year: 12
-Payment Frequency per year: 12
-Compounding: Discrete
-Payments: End of Period
-Payments (359): -2606.82
-Final payment (360): -2614.23
-Nominal Annual Interest Rate: 8.25
- Effective Interest Rate Per Payment Period: 0.006875
-Present Value: 345725.00
-Interest due to Delayed Intial Payment: -1265.63
-Annual Summary - Normal Amortization
-Year Interest Ending Balance
-1999 -11912.49 345869.02
-2000 -28427.88 343015.06
-2001 -28183.32 339916.54
-2002 -27917.80 336552.50
-2003 -27629.53 332900.19
-2004 -27316.55 328934.90
-2005 -26976.76 324629.82
-2006 -26607.85 319955.83
-2007 -26207.32 314881.31
-2008 -25772.48 309371.95
-2009 -25300.37 303390.48
-2010 -24787.80 296896.44
-2011 -24231.32 289845.92
-2012 -23627.14 282191.22
-2013 -22971.19 273880.57
-2014 -22259.04 264857.77
-2015 -21485.85 255061.78
-2016 -20646.41 244426.35
-2017 -19735.04 232879.55
-2018 -18745.57 220343.28
-2019 -17671.31 206732.75
-2020 -16505.00 191955.91
-2021 -15238.74 175912.81
-2022 -13863.97 158494.94
-2023 -12371.39 139584.49
-2024 -10750.92 119053.57
-2025 -8991.58 96763.31
-2026 -7081.48 72562.95
-2027 -5007.70 46288.81
-2028 -2756.21 17763.18
-2029 -491.97 0.00
-
-Total Interest: -591471.98
-
-
-Sixth Schedule - use new payments due to delay and
-output periodic payment schedule
-Amortization Table
-Effective Date: Tue Jun 15 00:00:00 1999
-Initial Payment Date: Sun Aug 1 00:00:00 1999
-Compounding Frequency per year: 12
-Payment Frequency per year: 12
-Compounding: Discrete
-Payments: End of Period
-Payments (359): -2606.82
-Final payment (360): -2614.23
-Nominal Annual Interest Rate: 8.25
- Effective Interest Rate Per Payment Period: 0.006875
-Present Value: 345725.00
-Interest due to Delayed Intial Payment: -1265.63
-Normal Amortization Schedule
-Pmt * Interest Principal Balance
- 1 -2385.56 -221.26 346769.37
- 2 -2384.04 -222.78 346546.59
- 3 -2382.51 -224.31 346322.28
- 4 -2380.97 -225.85 346096.43
- 5 -2379.41 -227.41 345869.02
-Summary for: 1999:
- Interest Paid: -11912.49
- Principal Paid: -1121.61
- Year Ending Balance: 345869.02
- Sum of Interest Paid: -11912.49
-Pmt * Interest Principal Balance
- 6 -2377.85 -228.97 345640.05
- 7 -2376.28 -230.54 345409.51
- 8 -2374.69 -232.13 345177.38
- 9 -2373.09 -233.73 344943.65
- 10 -2371.49 -235.33 344708.32
- 11 -2369.87 -236.95 344471.37
- 12 -2368.24 -238.58 344232.79
- 13 -2366.60 -240.22 343992.57
- 14 -2364.95 -241.87 343750.70
- 15 -2363.29 -243.53 343507.17
- 16 -2361.61 -245.21 343261.96
- 17 -2359.93 -246.89 343015.07
-Summary for: 2000:
- Interest Paid: -28427.89
- Principal Paid: -2853.95
- Year Ending Balance: 343015.07
- Sum of Interest Paid: -40340.38
-Pmt * Interest Principal Balance
- 18 -2358.23 -248.59 342766.48
- 19 -2356.52 -250.30 342516.18
- 20 -2354.80 -252.02 342264.16
- 21 -2353.07 -253.75 342010.41
- 22 -2351.32 -255.50 341754.91
- 23 -2349.57 -257.25 341497.66
- 24 -2347.80 -259.02 341238.64
- 25 -2346.02 -260.80 340977.84
- 26 -2344.22 -262.60 340715.24
- 27 -2342.42 -264.40 340450.84
- 28 -2340.60 -266.22 340184.62
- 29 -2338.77 -268.05 339916.57
-Summary for: 2001:
- Interest Paid: -28183.34
- Principal Paid: -3098.50
- Year Ending Balance: 339916.57
- Sum of Interest Paid: -68523.72
-Pmt * Interest Principal Balance
- 30 -2336.93 -269.89 339646.68
- 31 -2335.07 -271.75 339374.93
- 32 -2333.20 -273.62 339101.31
- 33 -2331.32 -275.50 338825.81
- 34 -2329.43 -277.39 338548.42
- 35 -2327.52 -279.30 338269.12
- 36 -2325.60 -281.22 337987.90
- 37 -2323.67 -283.15 337704.75
- 38 -2321.72 -285.10 337419.65
- 39 -2319.76 -287.06 337132.59
- 40 -2317.79 -289.03 336843.56
- 41 -2315.80 -291.02 336552.54
-Summary for: 2002:
- Interest Paid: -27917.81
- Principal Paid: -3364.03
- Year Ending Balance: 336552.54
- Sum of Interest Paid: -96441.53
-Pmt * Interest Principal Balance
- 42 -2313.80 -293.02 336259.52
- 43 -2311.78 -295.04 335964.48
- 44 -2309.76 -297.06 335667.42
- 45 -2307.71 -299.11 335368.31
- 46 -2305.66 -301.16 335067.15
- 47 -2303.59 -303.23 334763.92
- 48 -2301.50 -305.32 334458.60
- 49 -2299.40 -307.42 334151.18
- 50 -2297.29 -309.53 333841.65
- 51 -2295.16 -311.66 333529.99
- 52 -2293.02 -313.80 333216.19
- 53 -2290.86 -315.96 332900.23
-Summary for: 2003:
- Interest Paid: -27629.53
- Principal Paid: -3652.31
- Year Ending Balance: 332900.23
- Sum of Interest Paid: -124071.06
-Pmt * Interest Principal Balance
- 54 -2288.69 -318.13 332582.10
- 55 -2286.50 -320.32 332261.78
- 56 -2284.30 -322.52 331939.26
- 57 -2282.08 -324.74 331614.52
- 58 -2279.85 -326.97 331287.55
- 59 -2277.60 -329.22 330958.33
- 60 -2275.34 -331.48 330626.85
- 61 -2273.06 -333.76 330293.09
- 62 -2270.76 -336.06 329957.03
- 63 -2268.45 -338.37 329618.66
- 64 -2266.13 -340.69 329277.97
- 65 -2263.79 -343.03 328934.94
-Summary for: 2004:
- Interest Paid: -27316.55
- Principal Paid: -3965.29
- Year Ending Balance: 328934.94
- Sum of Interest Paid: -151387.61
-Pmt * Interest Principal Balance
- 66 -2261.43 -345.39 328589.55
- 67 -2259.05 -347.77 328241.78
- 68 -2256.66 -350.16 327891.62
- 69 -2254.25 -352.57 327539.05
- 70 -2251.83 -354.99 327184.06
- 71 -2249.39 -357.43 326826.63
- 72 -2246.93 -359.89 326466.74
- 73 -2244.46 -362.36 326104.38
- 74 -2241.97 -364.85 325739.53
- 75 -2239.46 -367.36 325372.17
- 76 -2236.93 -369.89 325002.28
- 77 -2234.39 -372.43 324629.85
-Summary for: 2005:
- Interest Paid: -26976.75
- Principal Paid: -4305.09
- Year Ending Balance: 324629.85
- Sum of Interest Paid: -178364.36
-Pmt * Interest Principal Balance
- 78 -2231.83 -374.99 324254.86
- 79 -2229.25 -377.57 323877.29
- 80 -2226.66 -380.16 323497.13
- 81 -2224.04 -382.78 323114.35
- 82 -2221.41 -385.41 322728.94
- 83 -2218.76 -388.06 322340.88
- 84 -2216.09 -390.73 321950.15
- 85 -2213.41 -393.41 321556.74
- 86 -2210.70 -396.12 321160.62
- 87 -2207.98 -398.84 320761.78
- 88 -2205.24 -401.58 320360.20
- 89 -2202.48 -404.34 319955.86
-Summary for: 2006:
- Interest Paid: -26607.85
- Principal Paid: -4673.99
- Year Ending Balance: 319955.86
- Sum of Interest Paid: -204972.21
-Pmt * Interest Principal Balance
- 90 -2199.70 -407.12 319548.74
- 91 -2196.90 -409.92 319138.82
- 92 -2194.08 -412.74 318726.08
- 93 -2191.24 -415.58 318310.50
- 94 -2188.38 -418.44 317892.06
- 95 -2185.51 -421.31 317470.75
- 96 -2182.61 -424.21 317046.54
- 97 -2179.69 -427.13 316619.41
- 98 -2176.76 -430.06 316189.35
- 99 -2173.80 -433.02 315756.33
- 100 -2170.82 -436.00 315320.33
- 101 -2167.83 -438.99 314881.34
-Summary for: 2007:
- Interest Paid: -26207.32
- Principal Paid: -5074.52
- Year Ending Balance: 314881.34
- Sum of Interest Paid: -231179.53
-Pmt * Interest Principal Balance
- 102 -2164.81 -442.01 314439.33
- 103 -2161.77 -445.05 313994.28
- 104 -2158.71 -448.11 313546.17
- 105 -2155.63 -451.19 313094.98
- 106 -2152.53 -454.29 312640.69
- 107 -2149.40 -457.42 312183.27
- 108 -2146.26 -460.56 311722.71
- 109 -2143.09 -463.73 311258.98
- 110 -2139.91 -466.91 310792.07
- 111 -2136.70 -470.12 310321.95
- 112 -2133.46 -473.36 309848.59
- 113 -2130.21 -476.61 309371.98
-Summary for: 2008:
- Interest Paid: -25772.48
- Principal Paid: -5509.36
- Year Ending Balance: 309371.98
- Sum of Interest Paid: -256952.01
-Pmt * Interest Principal Balance
- 114 -2126.93 -479.89 308892.09
- 115 -2123.63 -483.19 308408.90
- 116 -2120.31 -486.51 307922.39
- 117 -2116.97 -489.85 307432.54
- 118 -2113.60 -493.22 306939.32
- 119 -2110.21 -496.61 306442.71
- 120 -2106.79 -500.03 305942.68
- 121 -2103.36 -503.46 305439.22
- 122 -2099.89 -506.93 304932.29
- 123 -2096.41 -510.41 304421.88
- 124 -2092.90 -513.92 303907.96
- 125 -2089.37 -517.45 303390.51
-Summary for: 2009:
- Interest Paid: -25300.37
- Principal Paid: -5981.47
- Year Ending Balance: 303390.51
- Sum of Interest Paid: -282252.38
-Pmt * Interest Principal Balance
- 126 -2085.81 -521.01 302869.50
- 127 -2082.23 -524.59 302344.91
- 128 -2078.62 -528.20 301816.71
- 129 -2074.99 -531.83 301284.88
- 130 -2071.33 -535.49 300749.39
- 131 -2067.65 -539.17 300210.22
- 132 -2063.95 -542.87 299667.35
- 133 -2060.21 -546.61 299120.74
- 134 -2056.46 -550.36 298570.38
- 135 -2052.67 -554.15 298016.23
- 136 -2048.86 -557.96 297458.27
- 137 -2045.03 -561.79 296896.48
-Summary for: 2010:
- Interest Paid: -24787.81
- Principal Paid: -6494.03
- Year Ending Balance: 296896.48
- Sum of Interest Paid: -307040.19
-Pmt * Interest Principal Balance
- 138 -2041.16 -565.66 296330.82
- 139 -2037.27 -569.55 295761.27
- 140 -2033.36 -573.46 295187.81
- 141 -2029.42 -577.40 294610.41
- 142 -2025.45 -581.37 294029.04
- 143 -2021.45 -585.37 293443.67
- 144 -2017.43 -589.39 292854.28
- 145 -2013.37 -593.45 292260.83
- 146 -2009.29 -597.53 291663.30
- 147 -2005.19 -601.63 291061.67
- 148 -2001.05 -605.77 290455.90
- 149 -1996.88 -609.94 289845.96
-Summary for: 2011:
- Interest Paid: -24231.32
- Principal Paid: -7050.52
- Year Ending Balance: 289845.96
- Sum of Interest Paid: -331271.51
-Pmt * Interest Principal Balance
- 150 -1992.69 -614.13 289231.83
- 151 -1988.47 -618.35 288613.48
- 152 -1984.22 -622.60 287990.88
- 153 -1979.94 -626.88 287364.00
- 154 -1975.63 -631.19 286732.81
- 155 -1971.29 -635.53 286097.28
- 156 -1966.92 -639.90 285457.38
- 157 -1962.52 -644.30 284813.08
- 158 -1958.09 -648.73 284164.35
- 159 -1953.63 -653.19 283511.16
- 160 -1949.14 -657.68 282853.48
- 161 -1944.62 -662.20 282191.28
-Summary for: 2012:
- Interest Paid: -23627.16
- Principal Paid: -7654.68
- Year Ending Balance: 282191.28
- Sum of Interest Paid: -354898.67
-Pmt * Interest Principal Balance
- 162 -1940.07 -666.75 281524.53
- 163 -1935.48 -671.34 280853.19
- 164 -1930.87 -675.95 280177.24
- 165 -1926.22 -680.60 279496.64
- 166 -1921.54 -685.28 278811.36
- 167 -1916.83 -689.99 278121.37
- 168 -1912.08 -694.74 277426.63
- 169 -1907.31 -699.51 276727.12
- 170 -1902.50 -704.32 276022.80
- 171 -1897.66 -709.16 275313.64
- 172 -1892.78 -714.04 274599.60
- 173 -1887.87 -718.95 273880.65
-Summary for: 2013:
- Interest Paid: -22971.21
- Principal Paid: -8310.63
- Year Ending Balance: 273880.65
- Sum of Interest Paid: -377869.88
-Pmt * Interest Principal Balance
- 174 -1882.93 -723.89 273156.76
- 175 -1877.95 -728.87 272427.89
- 176 -1872.94 -733.88 271694.01
- 177 -1867.90 -738.92 270955.09
- 178 -1862.82 -744.00 270211.09
- 179 -1857.70 -749.12 269461.97
- 180 -1852.55 -754.27 268707.70
- 181 -1847.37 -759.45 267948.25
- 182 -1842.14 -764.68 267183.57
- 183 -1836.89 -769.93 266413.64
- 184 -1831.59 -775.23 265638.41
- 185 -1826.26 -780.56 264857.85
-Summary for: 2014:
- Interest Paid: -22259.04
- Principal Paid: -9022.80
- Year Ending Balance: 264857.85
- Sum of Interest Paid: -400128.92
-Pmt * Interest Principal Balance
- 186 -1820.90 -785.92 264071.93
- 187 -1815.49 -791.33 263280.60
- 188 -1810.05 -796.77 262483.83
- 189 -1804.58 -802.24 261681.59
- 190 -1799.06 -807.76 260873.83
- 191 -1793.51 -813.31 260060.52
- 192 -1787.92 -818.90 259241.62
- 193 -1782.29 -824.53 258417.09
- 194 -1776.62 -830.20 257586.89
- 195 -1770.91 -835.91 256750.98
- 196 -1765.16 -841.66 255909.32
- 197 -1759.38 -847.44 255061.88
-Summary for: 2015:
- Interest Paid: -21485.87
- Principal Paid: -9795.97
- Year Ending Balance: 255061.88
- Sum of Interest Paid: -421614.79
-Pmt * Interest Principal Balance
- 198 -1753.55 -853.27 254208.61
- 199 -1747.68 -859.14 253349.47
- 200 -1741.78 -865.04 252484.43
- 201 -1735.83 -870.99 251613.44
- 202 -1729.84 -876.98 250736.46
- 203 -1723.81 -883.01 249853.45
- 204 -1717.74 -889.08 248964.37
- 205 -1711.63 -895.19 248069.18
- 206 -1705.48 -901.34 247167.84
- 207 -1699.28 -907.54 246260.30
- 208 -1693.04 -913.78 245346.52
- 209 -1686.76 -920.06 244426.46
-Summary for: 2016:
- Interest Paid: -20646.42
- Principal Paid: -10635.42
- Year Ending Balance: 244426.46
- Sum of Interest Paid: -442261.21
-Pmt * Interest Principal Balance
- 210 -1680.43 -926.39 243500.07
- 211 -1674.06 -932.76 242567.31
- 212 -1667.65 -939.17 241628.14
- 213 -1661.19 -945.63 240682.51
- 214 -1654.69 -952.13 239730.38
- 215 -1648.15 -958.67 238771.71
- 216 -1641.56 -965.26 237806.45
- 217 -1634.92 -971.90 236834.55
- 218 -1628.24 -978.58 235855.97
- 219 -1621.51 -985.31 234870.66
- 220 -1614.74 -992.08 233878.58
- 221 -1607.92 -998.90 232879.68
-Summary for: 2017:
- Interest Paid: -19735.06
- Principal Paid: -11546.78
- Year Ending Balance: 232879.68
- Sum of Interest Paid: -461996.27
-Pmt * Interest Principal Balance
- 222 -1601.05 -1005.77 231873.91
- 223 -1594.13 -1012.69 230861.22
- 224 -1587.17 -1019.65 229841.57
- 225 -1580.16 -1026.66 228814.91
- 226 -1573.10 -1033.72 227781.19
- 227 -1566.00 -1040.82 226740.37
- 228 -1558.84 -1047.98 225692.39
- 229 -1551.64 -1055.18 224637.21
- 230 -1544.38 -1062.44 223574.77
- 231 -1537.08 -1069.74 222505.03
- 232 -1529.72 -1077.10 221427.93
- 233 -1522.32 -1084.50 220343.43
-Summary for: 2018:
- Interest Paid: -18745.59
- Principal Paid: -12536.25
- Year Ending Balance: 220343.43
- Sum of Interest Paid: -480741.86
-Pmt * Interest Principal Balance
- 234 -1514.86 -1091.96 219251.47
- 235 -1507.35 -1099.47 218152.00
- 236 -1499.80 -1107.02 217044.98
- 237 -1492.18 -1114.64 215930.34
- 238 -1484.52 -1122.30 214808.04
- 239 -1476.81 -1130.01 213678.03
- 240 -1469.04 -1137.78 212540.25
- 241 -1461.21 -1145.61 211394.64
- 242 -1453.34 -1153.48 210241.16
- 243 -1445.41 -1161.41 209079.75
- 244 -1437.42 -1169.40 207910.35
- 245 -1429.38 -1177.44 206732.91
-Summary for: 2019:
- Interest Paid: -17671.32
- Principal Paid: -13610.52
- Year Ending Balance: 206732.91
- Sum of Interest Paid: -498413.18
-Pmt * Interest Principal Balance
- 246 -1421.29 -1185.53 205547.38
- 247 -1413.14 -1193.68 204353.70
- 248 -1404.93 -1201.89 203151.81
- 249 -1396.67 -1210.15 201941.66
- 250 -1388.35 -1218.47 200723.19
- 251 -1379.97 -1226.85 199496.34
- 252 -1371.54 -1235.28 198261.06
- 253 -1363.04 -1243.78 197017.28
- 254 -1354.49 -1252.33 195764.95
- 255 -1345.88 -1260.94 194504.01
- 256 -1337.22 -1269.60 193234.41
- 257 -1328.49 -1278.33 191956.08
-Summary for: 2020:
- Interest Paid: -16505.01
- Principal Paid: -14776.83
- Year Ending Balance: 191956.08
- Sum of Interest Paid: -514918.19
-Pmt * Interest Principal Balance
- 258 -1319.70 -1287.12 190668.96
- 259 -1310.85 -1295.97 189372.99
- 260 -1301.94 -1304.88 188068.11
- 261 -1292.97 -1313.85 186754.26
- 262 -1283.94 -1322.88 185431.38
- 263 -1274.84 -1331.98 184099.40
- 264 -1265.68 -1341.14 182758.26
- 265 -1256.46 -1350.36 181407.90
- 266 -1247.18 -1359.64 180048.26
- 267 -1237.83 -1368.99 178679.27
- 268 -1228.42 -1378.40 177300.87
- 269 -1218.94 -1387.88 175912.99
-Summary for: 2021:
- Interest Paid: -15238.75
- Principal Paid: -16043.09
- Year Ending Balance: 175912.99
- Sum of Interest Paid: -530156.94
-Pmt * Interest Principal Balance
- 270 -1209.40 -1397.42 174515.57
- 271 -1199.79 -1407.03 173108.54
- 272 -1190.12 -1416.70 171691.84
- 273 -1180.38 -1426.44 170265.40
- 274 -1170.57 -1436.25 168829.15
- 275 -1160.70 -1446.12 167383.03
- 276 -1150.76 -1456.06 165926.97
- 277 -1140.75 -1466.07 164460.90
- 278 -1130.67 -1476.15 162984.75
- 279 -1120.52 -1486.30 161498.45
- 280 -1110.30 -1496.52 160001.93
- 281 -1100.01 -1506.81 158495.12
-Summary for: 2022:
- Interest Paid: -13863.97
- Principal Paid: -17417.87
- Year Ending Balance: 158495.12
- Sum of Interest Paid: -544020.91
-Pmt * Interest Principal Balance
- 282 -1089.65 -1517.17 156977.95
- 283 -1079.22 -1527.60 155450.35
- 284 -1068.72 -1538.10 153912.25
- 285 -1058.15 -1548.67 152363.58
- 286 -1047.50 -1559.32 150804.26
- 287 -1036.78 -1570.04 149234.22
- 288 -1025.99 -1580.83 147653.39
- 289 -1015.12 -1591.70 146061.69
- 290 -1004.17 -1602.65 144459.04
- 291 -993.16 -1613.66 142845.38
- 292 -982.06 -1624.76 141220.62
- 293 -970.89 -1635.93 139584.69
-Summary for: 2023:
- Interest Paid: -12371.41
- Principal Paid: -18910.43
- Year Ending Balance: 139584.69
- Sum of Interest Paid: -556392.32
-Pmt * Interest Principal Balance
- 294 -959.64 -1647.18 137937.51
- 295 -948.32 -1658.50 136279.01
- 296 -936.92 -1669.90 134609.11
- 297 -925.44 -1681.38 132927.73
- 298 -913.88 -1692.94 131234.79
- 299 -902.24 -1704.58 129530.21
- 300 -890.52 -1716.30 127813.91
- 301 -878.72 -1728.10 126085.81
- 302 -866.84 -1739.98 124345.83
- 303 -854.88 -1751.94 122593.89
- 304 -842.83 -1763.99 120829.90
- 305 -830.71 -1776.11 119053.79
-Summary for: 2024:
- Interest Paid: -10750.94
- Principal Paid: -20530.90
- Year Ending Balance: 119053.79
- Sum of Interest Paid: -567143.26
-Pmt * Interest Principal Balance
- 306 -818.49 -1788.33 117265.46
- 307 -806.20 -1800.62 115464.84
- 308 -793.82 -1813.00 113651.84
- 309 -781.36 -1825.46 111826.38
- 310 -768.81 -1838.01 109988.37
- 311 -756.17 -1850.65 108137.72
- 312 -743.45 -1863.37 106274.35
- 313 -730.64 -1876.18 104398.17
- 314 -717.74 -1889.08 102509.09
- 315 -704.75 -1902.07 100607.02
- 316 -691.67 -1915.15 98691.87
- 317 -678.51 -1928.31 96763.56
-Summary for: 2025:
- Interest Paid: -8991.61
- Principal Paid: -22290.23
- Year Ending Balance: 96763.56
- Sum of Interest Paid: -576134.87
-Pmt * Interest Principal Balance
- 318 -665.25 -1941.57 94821.99
- 319 -651.90 -1954.92 92867.07
- 320 -638.46 -1968.36 90898.71
- 321 -624.93 -1981.89 88916.82
- 322 -611.30 -1995.52 86921.30
- 323 -597.58 -2009.24 84912.06
- 324 -583.77 -2023.05 82889.01
- 325 -569.86 -2036.96 80852.05
- 326 -555.86 -2050.96 78801.09
- 327 -541.76 -2065.06 76736.03
- 328 -527.56 -2079.26 74656.77
- 329 -513.27 -2093.55 72563.22
-Summary for: 2026:
- Interest Paid: -7081.50
- Principal Paid: -24200.34
- Year Ending Balance: 72563.22
- Sum of Interest Paid: -583216.37
-Pmt * Interest Principal Balance
- 330 -498.87 -2107.95 70455.27
- 331 -484.38 -2122.44 68332.83
- 332 -469.79 -2137.03 66195.80
- 333 -455.10 -2151.72 64044.08
- 334 -440.30 -2166.52 61877.56
- 335 -425.41 -2181.41 59696.15
- 336 -410.41 -2196.41 57499.74
- 337 -395.31 -2211.51 55288.23
- 338 -380.11 -2226.71 53061.52
- 339 -364.80 -2242.02 50819.50
- 340 -349.38 -2257.44 48562.06
- 341 -333.86 -2272.96 46289.10
-Summary for: 2027:
- Interest Paid: -5007.72
- Principal Paid: -26274.12
- Year Ending Balance: 46289.10
- Sum of Interest Paid: -588224.09
-Pmt * Interest Principal Balance
- 342 -318.24 -2288.58 44000.52
- 343 -302.50 -2304.32 41696.20
- 344 -286.66 -2320.16 39376.04
- 345 -270.71 -2336.11 37039.93
- 346 -254.65 -2352.17 34687.76
- 347 -238.48 -2368.34 32319.42
- 348 -222.20 -2384.62 29934.80
- 349 -205.80 -2401.02 27533.78
- 350 -189.29 -2417.53 25116.25
- 351 -172.67 -2434.15 22682.10
- 352 -155.94 -2450.88 20231.22
- 353 -139.09 -2467.73 17763.49
-Summary for: 2028:
- Interest Paid: -2756.23
- Principal Paid: -28525.61
- Year Ending Balance: 17763.49
- Sum of Interest Paid: -590980.32
-Pmt * Interest Principal Balance
- 354 -122.12 -2484.70 15278.79
- 355 -105.04 -2501.78 12777.01
- 356 -87.84 -2518.98 10258.03
- 357 -70.52 -2536.30 7721.73
- 358 -53.09 -2553.73 5168.00
- 359 -35.53 -2571.29 2596.71
-Final Payment: -2614.56
- 360 -17.85 -2596.71 -0.00
-Summary for: 2029:
- Interest Paid: -491.99
- Principal Paid: -17763.49
- Year Ending Balance: 0.00
- Sum of Interest Paid: -591472.31
-
-Total Interest: -591472.31
-
-
-Seventh Schedule - use new payments due to delay and
-output variable prepayment schedule
-Amortization Table
-Effective Date: Tue Jun 15 00:00:00 1999
-Initial Payment Date: Sun Aug 1 00:00:00 1999
-Compounding Frequency per year: 12
-Payment Frequency per year: 12
-Compounding: Discrete
-Payments: End of Period
-Payments (359): -2606.82
-Final payment (360): -2614.23
-Nominal Annual Interest Rate: 8.25
- Effective Interest Rate Per Payment Period: 0.006875
-Present Value: 345725.00
-Interest due to Delayed Intial Payment: -1265.63
-Advanced Prepayment Amortization - Variable Prepayment
-Pmt * Interest Principal Prepay Total Pmt Balance
- 1 -2385.56 -221.26 -222.78 -2829.60 346546.59
- 2 -2382.51 -224.31 -225.85 -2832.67 346096.43
- 3 -2379.41 -227.41 -228.97 -2835.79 345640.05
- 4 -2376.28 -230.54 -232.13 -2838.95 345177.38
- 5 -2373.09 -233.73 -235.33 -2842.15 344708.32
-Summary for: 1999:
- Interest Paid: -11896.85
- Principal Paid: 344705.19
- Year Ending Balance: 344708.32
- Sum of Interest Paid: -11896.85
-Pmt * Interest Principal Prepay Total Pmt Balance
- 6 -2369.87 -236.95 -238.58 -2845.40 344232.79
- 7 -2366.60 -240.22 -241.87 -2848.69 343750.70
- 8 -2363.29 -243.53 -245.21 -2852.03 343261.96
- 9 -2359.93 -246.89 -248.59 -2855.41 342766.48
- 10 -2356.52 -250.30 -252.02 -2858.84 342264.16
- 11 -2353.07 -253.75 -255.50 -2862.32 341754.91
- 12 -2349.57 -257.25 -259.02 -2865.84 341238.64
- 13 -2346.02 -260.80 -262.60 -2869.42 340715.24
- 14 -2342.42 -264.40 -266.22 -2873.04 340184.62
- 15 -2338.77 -268.05 -269.89 -2876.71 339646.68
- 16 -2335.07 -271.75 -273.62 -2880.44 339101.31
- 17 -2331.32 -275.50 -277.39 -2884.21 338548.42
-Summary for: 2000:
- Interest Paid: -28212.45
- Principal Paid: -6159.90
- Year Ending Balance: 338548.42
- Sum of Interest Paid: -40109.30
-Pmt * Interest Principal Prepay Total Pmt Balance
- 18 -2327.52 -279.30 -281.22 -2888.04 337987.90
- 19 -2323.67 -283.15 -285.10 -2891.92 337419.65
- 20 -2319.76 -287.06 -289.03 -2895.85 336843.56
- 21 -2315.80 -291.02 -293.02 -2899.84 336259.52
- 22 -2311.78 -295.04 -297.06 -2903.88 335667.42
- 23 -2307.71 -299.11 -301.16 -2907.98 335067.15
- 24 -2303.59 -303.23 -305.32 -2912.14 334458.60
- 25 -2299.40 -307.42 -309.53 -2916.35 333841.65
- 26 -2295.16 -311.66 -313.80 -2920.62 333216.19
- 27 -2290.86 -315.96 -318.13 -2924.95 332582.10
- 28 -2286.50 -320.32 -322.52 -2929.34 331939.26
- 29 -2282.08 -324.74 -326.97 -2933.79 331287.55
-Summary for: 2001:
- Interest Paid: -27663.83
- Principal Paid: -7260.87
- Year Ending Balance: 331287.55
- Sum of Interest Paid: -67773.13
-Pmt * Interest Principal Prepay Total Pmt Balance
- 30 -2277.60 -329.22 -331.48 -2938.30 330626.85
- 31 -2273.06 -333.76 -336.06 -2942.88 329957.03
- 32 -2268.45 -338.37 -340.69 -2947.51 329277.97
- 33 -2263.79 -343.03 -345.39 -2952.21 328589.55
- 34 -2259.05 -347.77 -350.16 -2956.98 327891.62
- 35 -2254.25 -352.57 -354.99 -2961.81 327184.06
- 36 -2249.39 -357.43 -359.89 -2966.71 326466.74
- 37 -2244.46 -362.36 -364.85 -2971.67 325739.53
- 38 -2239.46 -367.36 -369.89 -2976.71 325002.28
- 39 -2234.39 -372.43 -374.99 -2981.81 324254.86
- 40 -2229.25 -377.57 -380.16 -2986.98 323497.13
- 41 -2224.04 -382.78 -385.41 -2992.23 322728.94
-Summary for: 2002:
- Interest Paid: -27017.19
- Principal Paid: -8558.61
- Year Ending Balance: 322728.94
- Sum of Interest Paid: -94790.32
-Pmt * Interest Principal Prepay Total Pmt Balance
- 42 -2218.76 -388.06 -390.73 -2997.55 321950.15
- 43 -2213.41 -393.41 -396.12 -3002.94 321160.62
- 44 -2207.98 -398.84 -401.58 -3008.40 320360.20
- 45 -2202.48 -404.34 -407.12 -3013.94 319548.74
- 46 -2196.90 -409.92 -412.74 -3019.56 318726.08
- 47 -2191.24 -415.58 -418.44 -3025.26 317892.06
- 48 -2185.51 -421.31 -424.21 -3031.03 317046.54
- 49 -2179.69 -427.13 -430.06 -3036.88 316189.35
- 50 -2173.80 -433.02 -436.00 -3042.82 315320.33
- 51 -2167.83 -438.99 -442.01 -3048.83 314439.33
- 52 -2161.77 -445.05 -448.11 -3054.93 313546.17
- 53 -2155.63 -451.19 -454.29 -3061.11 312640.69
-Summary for: 2003:
- Interest Paid: -26255.00
- Principal Paid: -10088.25
- Year Ending Balance: 312640.69
- Sum of Interest Paid: -121045.32
-Pmt * Interest Principal Prepay Total Pmt Balance
- 54 -2149.40 -457.42 -460.56 -3067.38 311722.71
- 55 -2143.09 -463.73 -466.91 -3073.73 310792.07
- 56 -2136.70 -470.12 -473.36 -3080.18 309848.59
- 57 -2130.21 -476.61 -479.89 -3086.71 308892.09
- 58 -2123.63 -483.19 -486.51 -3093.33 307922.39
- 59 -2116.97 -489.85 -493.22 -3100.04 306939.32
- 60 -2110.21 -496.61 -500.03 -3106.85 305942.68
- 61 -2103.36 -503.46 -506.93 -3113.75 304932.29
- 62 -2096.41 -510.41 -513.92 -3120.74 303907.96
- 63 -2089.37 -517.45 -521.01 -3127.83 302869.50
- 64 -2082.23 -524.59 -528.20 -3135.02 301816.71
- 65 -2074.99 -531.83 -535.49 -3142.31 300749.39
-Summary for: 2004:
- Interest Paid: -25356.57
- Principal Paid: -11891.30
- Year Ending Balance: 300749.39
- Sum of Interest Paid: -146401.89
-Pmt * Interest Principal Prepay Total Pmt Balance
- 66 -2067.65 -539.17 -542.87 -3149.69 299667.35
- 67 -2060.21 -546.61 -550.36 -3157.18 298570.38
- 68 -2052.67 -554.15 -557.96 -3164.78 297458.27
- 69 -2045.03 -561.79 -565.66 -3172.48 296330.82
- 70 -2037.27 -569.55 -573.46 -3180.28 295187.81
- 71 -2029.42 -577.40 -581.37 -3188.19 294029.04
- 72 -2021.45 -585.37 -589.39 -3196.21 292854.28
- 73 -2013.37 -593.45 -597.53 -3204.35 291663.30
- 74 -2005.19 -601.63 -605.77 -3212.59 290455.90
- 75 -1996.88 -609.94 -614.13 -3220.95 289231.83
- 76 -1988.47 -618.35 -622.60 -3229.42 287990.88
- 77 -1979.94 -626.88 -631.19 -3238.01 286732.81
-Summary for: 2005:
- Interest Paid: -24297.55
- Principal Paid: -14016.58
- Year Ending Balance: 286732.81
- Sum of Interest Paid: -170699.44
-Pmt * Interest Principal Prepay Total Pmt Balance
- 78 -1971.29 -635.53 -639.90 -3246.72 285457.38
- 79 -1962.52 -644.30 -648.73 -3255.55 284164.35
- 80 -1953.63 -653.19 -657.68 -3264.50 282853.48
- 81 -1944.62 -662.20 -666.75 -3273.57 281524.53
- 82 -1935.48 -671.34 -675.95 -3282.77 280177.24
- 83 -1926.22 -680.60 -685.28 -3292.10 278811.36
- 84 -1916.83 -689.99 -694.74 -3301.56 277426.63
- 85 -1907.31 -699.51 -704.32 -3311.14 276022.80
- 86 -1897.66 -709.16 -714.04 -3320.86 274599.60
- 87 -1887.87 -718.95 -723.89 -3330.71 273156.76
- 88 -1877.95 -728.87 -733.88 -3340.70 271694.01
- 89 -1867.90 -738.92 -744.00 -3350.82 270211.09
-Summary for: 2006:
- Interest Paid: -23049.28
- Principal Paid: -16521.72
- Year Ending Balance: 270211.09
- Sum of Interest Paid: -193748.72
-Pmt * Interest Principal Prepay Total Pmt Balance
- 90 -1857.70 -749.12 -754.27 -3361.09 268707.70
- 91 -1847.37 -759.45 -764.68 -3371.50 267183.57
- 92 -1836.89 -769.93 -775.23 -3382.05 265638.41
- 93 -1826.26 -780.56 -785.92 -3392.74 264071.93
- 94 -1815.49 -791.33 -796.77 -3403.59 262483.83
- 95 -1804.58 -802.24 -807.76 -3414.58 260873.83
- 96 -1793.51 -813.31 -818.90 -3425.72 259241.62
- 97 -1782.29 -824.53 -830.20 -3437.02 257586.89
- 98 -1770.91 -835.91 -841.66 -3448.48 255909.32
- 99 -1759.38 -847.44 -853.27 -3460.09 254208.61
- 100 -1747.68 -859.14 -865.04 -3471.86 252484.43
- 101 -1735.83 -870.99 -876.98 -3483.80 250736.46
-Summary for: 2007:
- Interest Paid: -21577.89
- Principal Paid: -19474.63
- Year Ending Balance: 250736.46
- Sum of Interest Paid: -215326.61
-Pmt * Interest Principal Prepay Total Pmt Balance
- 102 -1723.81 -883.01 -889.08 -3495.90 248964.37
- 103 -1711.63 -895.19 -901.34 -3508.16 247167.84
- 104 -1699.28 -907.54 -913.78 -3520.60 245346.52
- 105 -1686.76 -920.06 -926.39 -3533.21 243500.07
- 106 -1674.06 -932.76 -939.17 -3545.99 241628.14
- 107 -1661.19 -945.63 -952.13 -3558.95 239730.38
- 108 -1648.15 -958.67 -965.26 -3572.08 237806.45
- 109 -1634.92 -971.90 -978.58 -3585.40 235855.97
- 110 -1621.51 -985.31 -992.08 -3598.90 233878.58
- 111 -1607.92 -998.90 -1005.77 -3612.59 231873.91
- 112 -1594.13 -1012.69 -1019.65 -3626.47 229841.57
- 113 -1580.16 -1026.66 -1033.72 -3640.54 227781.19
-Summary for: 2008:
- Interest Paid: -19843.52
- Principal Paid: -22955.27
- Year Ending Balance: 227781.19
- Sum of Interest Paid: -235170.13
-Pmt * Interest Principal Prepay Total Pmt Balance
- 114 -1566.00 -1040.82 -1047.98 -3654.80 225692.39
- 115 -1551.64 -1055.18 -1062.44 -3669.26 223574.77
- 116 -1537.08 -1069.74 -1077.10 -3683.92 221427.93
- 117 -1522.32 -1084.50 -1091.96 -3698.78 219251.47
- 118 -1507.35 -1099.47 -1107.03 -3713.85 217044.97
- 119 -1492.18 -1114.64 -1122.30 -3729.12 214808.03
- 120 -1476.81 -1130.01 -1137.78 -3744.60 212540.24
- 121 -1461.21 -1145.61 -1153.48 -3760.30 210241.15
- 122 -1445.41 -1161.41 -1169.40 -3776.22 207910.34
- 123 -1429.38 -1177.44 -1185.53 -3792.35 205547.37
- 124 -1413.14 -1193.68 -1201.89 -3808.71 203151.80
- 125 -1396.67 -1210.15 -1218.47 -3825.29 200723.18
-Summary for: 2009:
- Interest Paid: -17799.19
- Principal Paid: -27058.01
- Year Ending Balance: 200723.18
- Sum of Interest Paid: -252969.32
-Pmt * Interest Principal Prepay Total Pmt Balance
- 126 -1379.97 -1226.85 -1235.28 -3842.10 198261.05
- 127 -1363.04 -1243.78 -1252.33 -3859.15 195764.94
- 128 -1345.88 -1260.94 -1269.61 -3876.43 193234.39
- 129 -1328.49 -1278.33 -1287.12 -3893.94 190668.94
- 130 -1310.85 -1295.97 -1304.88 -3911.70 188068.09
- 131 -1292.97 -1313.85 -1322.88 -3929.70 185431.36
- 132 -1274.84 -1331.98 -1341.14 -3947.96 182758.24
- 133 -1256.46 -1350.36 -1359.64 -3966.46 180048.24
- 134 -1237.83 -1368.99 -1378.40 -3985.22 177300.85
- 135 -1218.94 -1387.88 -1397.42 -4004.24 174515.55
- 136 -1199.79 -1407.03 -1416.70 -4023.52 171691.82
- 137 -1180.38 -1426.44 -1436.25 -4043.07 168829.13
-Summary for: 2010:
- Interest Paid: -15389.44
- Principal Paid: -31894.05
- Year Ending Balance: 168829.13
- Sum of Interest Paid: -268358.76
-Pmt * Interest Principal Prepay Total Pmt Balance
- 138 -1160.70 -1446.12 -1456.06 -4062.88 165926.95
- 139 -1140.75 -1466.07 -1476.15 -4082.97 162984.73
- 140 -1120.52 -1486.30 -1496.52 -4103.34 160001.91
- 141 -1100.01 -1506.81 -1517.17 -4123.99 156977.93
- 142 -1079.22 -1527.60 -1538.10 -4144.92 153912.23
- 143 -1058.15 -1548.67 -1559.32 -4166.14 150804.24
- 144 -1036.78 -1570.04 -1580.83 -4187.65 147653.37
- 145 -1015.12 -1591.70 -1602.65 -4209.47 144459.02
- 146 -993.16 -1613.66 -1624.76 -4231.58 141220.60
- 147 -970.89 -1635.93 -1647.18 -4254.00 137937.49
- 148 -948.32 -1658.50 -1669.90 -4276.72 134609.09
- 149 -925.44 -1681.38 -1692.94 -4299.76 131234.77
-Summary for: 2011:
- Interest Paid: -12549.06
- Principal Paid: -37594.36
- Year Ending Balance: 131234.77
- Sum of Interest Paid: -280907.82
-Pmt * Interest Principal Prepay Total Pmt Balance
- 150 -902.24 -1704.58 -1716.30 -4323.12 127813.89
- 151 -878.72 -1728.10 -1739.98 -4346.80 124345.81
- 152 -854.88 -1751.94 -1763.99 -4370.81 120829.88
- 153 -830.71 -1776.11 -1788.33 -4395.15 117265.44
- 154 -806.20 -1800.62 -1813.00 -4419.82 113651.82
- 155 -781.36 -1825.46 -1838.01 -4444.83 109988.35
- 156 -756.17 -1850.65 -1863.37 -4470.19 106274.33
- 157 -730.64 -1876.18 -1889.08 -4495.90 102509.07
- 158 -704.75 -1902.07 -1915.15 -4521.97 98691.85
- 159 -678.51 -1928.31 -1941.57 -4548.39 94821.97
- 160 -651.90 -1954.92 -1968.36 -4575.18 90898.69
- 161 -624.93 -1981.89 -1995.52 -4602.34 86921.28
-Summary for: 2012:
- Interest Paid: -9201.01
- Principal Paid: -44313.49
- Year Ending Balance: 86921.28
- Sum of Interest Paid: -290108.83
-Pmt * Interest Principal Prepay Total Pmt Balance
- 162 -597.58 -2009.24 -2023.05 -4629.87 82888.99
- 163 -569.86 -2036.96 -2050.96 -4657.78 78801.07
- 164 -541.76 -2065.06 -2079.26 -4686.08 74656.75
- 165 -513.27 -2093.55 -2107.95 -4714.77 70455.25
- 166 -484.38 -2122.44 -2137.03 -4743.85 66195.78
- 167 -455.10 -2151.72 -2166.52 -4773.34 61877.54
- 168 -425.41 -2181.41 -2196.41 -4803.23 57499.72
- 169 -395.31 -2211.51 -2226.71 -4833.53 53061.50
- 170 -364.80 -2242.02 -2257.44 -4864.26 48562.04
- 171 -333.86 -2272.96 -2288.58 -4895.40 44000.50
- 172 -302.50 -2304.32 -2320.16 -4926.98 39376.02
- 173 -270.71 -2336.11 -2352.17 -4958.99 34687.74
-Summary for: 2013:
- Interest Paid: -5254.54
- Principal Paid: -52233.54
- Year Ending Balance: 34687.74
- Sum of Interest Paid: -295363.37
-Pmt * Interest Principal Prepay Total Pmt Balance
- 174 -238.48 -2368.34 -2384.62 -4991.44 29934.78
- 175 -205.80 -2401.02 -2417.53 -5024.35 25116.23
- 176 -172.67 -2434.15 -2450.88 -5057.70 20231.20
- 177 -139.09 -2467.73 -2484.70 -5091.52 15278.77
- 178 -105.04 -2501.78 -2518.98 -5125.80 10258.01
- 179 -70.52 -2536.30 -2553.73 -5160.55 5167.98
- 180 -35.53 -2571.29 -2588.97 -5195.79 7.72
- 181 -0.05 -7.72 0.00 -7.77 0.00
-Summary for: 2014:
- Interest Paid: -967.18
- Principal Paid: -34687.74
- Year Ending Balance: 0.00
- Sum of Interest Paid: -296330.55
-
-Total Interest: -296330.55
-
-
-Eighth Schedule - use new payments due to delay and
-output fixed prepayment schedule
-Amortization Table
-Effective Date: Tue Jun 15 00:00:00 1999
-Initial Payment Date: Sun Aug 1 00:00:00 1999
-Compounding Frequency per year: 12
-Payment Frequency per year: 12
-Compounding: Discrete
-Payments: End of Period
-Payments (359): -2606.82
-Final payment (360): -2614.23
-Nominal Annual Interest Rate: 8.25
- Effective Interest Rate Per Payment Period: 0.006875
-Present Value: 345725.00
-Interest due to Delayed Intial Payment: -1265.63
-Advanced Prepayment Amortization - Fixed Prepayment: -400.00
-Pmt * Interest Principal Prepay Total Pmt Balance
- 1 -2385.56 -221.26 -400.00 -3006.82 346369.37
- 2 -2381.29 -225.53 -400.00 -3006.82 345743.84
- 3 -2376.99 -229.83 -400.00 -3006.82 345114.01
- 4 -2372.66 -234.16 -400.00 -3006.82 344479.85
- 5 -2368.30 -238.52 -400.00 -3006.82 343841.33
-Summary for: 1999:
- Interest Paid: -11884.80
- Principal Paid: 343838.20
- Year Ending Balance: 343841.33
- Sum of Interest Paid: -11884.80
-Pmt * Interest Principal Prepay Total Pmt Balance
- 6 -2363.91 -242.91 -400.00 -3006.82 343198.42
- 7 -2359.49 -247.33 -400.00 -3006.82 342551.09
- 8 -2355.04 -251.78 -400.00 -3006.82 341899.31
- 9 -2350.56 -256.26 -400.00 -3006.82 341243.05
- 10 -2346.05 -260.77 -400.00 -3006.82 340582.28
- 11 -2341.50 -265.32 -400.00 -3006.82 339916.96
- 12 -2336.93 -269.89 -400.00 -3006.82 339247.07
- 13 -2332.32 -274.50 -400.00 -3006.82 338572.57
- 14 -2327.69 -279.13 -400.00 -3006.82 337893.44
- 15 -2323.02 -283.80 -400.00 -3006.82 337209.64
- 16 -2318.32 -288.50 -400.00 -3006.82 336521.14
- 17 -2313.58 -293.24 -400.00 -3006.82 335827.90
-Summary for: 2000:
- Interest Paid: -28068.41
- Principal Paid: -8013.43
- Year Ending Balance: 335827.90
- Sum of Interest Paid: -39953.21
-Pmt * Interest Principal Prepay Total Pmt Balance
- 18 -2308.82 -298.00 -400.00 -3006.82 335129.90
- 19 -2304.02 -302.80 -400.00 -3006.82 334427.10
- 20 -2299.19 -307.63 -400.00 -3006.82 333719.47
- 21 -2294.32 -312.50 -400.00 -3006.82 333006.97
- 22 -2289.42 -317.40 -400.00 -3006.82 332289.57
- 23 -2284.49 -322.33 -400.00 -3006.82 331567.24
- 24 -2279.52 -327.30 -400.00 -3006.82 330839.94
- 25 -2274.52 -332.30 -400.00 -3006.82 330107.64
- 26 -2269.49 -337.33 -400.00 -3006.82 329370.31
- 27 -2264.42 -342.40 -400.00 -3006.82 328627.91
- 28 -2259.32 -347.50 -400.00 -3006.82 327880.41
- 29 -2254.18 -352.64 -400.00 -3006.82 327127.77
-Summary for: 2001:
- Interest Paid: -27381.71
- Principal Paid: -8700.13
- Year Ending Balance: 327127.77
- Sum of Interest Paid: -67334.92
-Pmt * Interest Principal Prepay Total Pmt Balance
- 30 -2249.00 -357.82 -400.00 -3006.82 326369.95
- 31 -2243.79 -363.03 -400.00 -3006.82 325606.92
- 32 -2238.55 -368.27 -400.00 -3006.82 324838.65
- 33 -2233.27 -373.55 -400.00 -3006.82 324065.10
- 34 -2227.95 -378.87 -400.00 -3006.82 323286.23
- 35 -2222.59 -384.23 -400.00 -3006.82 322502.00
- 36 -2217.20 -389.62 -400.00 -3006.82 321712.38
- 37 -2211.77 -395.05 -400.00 -3006.82 320917.33
- 38 -2206.31 -400.51 -400.00 -3006.82 320116.82
- 39 -2200.80 -406.02 -400.00 -3006.82 319310.80
- 40 -2195.26 -411.56 -400.00 -3006.82 318499.24
- 41 -2189.68 -417.14 -400.00 -3006.82 317682.10
-Summary for: 2002:
- Interest Paid: -26636.17
- Principal Paid: -9445.67
- Year Ending Balance: 317682.10
- Sum of Interest Paid: -93971.09
-Pmt * Interest Principal Prepay Total Pmt Balance
- 42 -2184.06 -422.76 -400.00 -3006.82 316859.34
- 43 -2178.41 -428.41 -400.00 -3006.82 316030.93
- 44 -2172.71 -434.11 -400.00 -3006.82 315196.82
- 45 -2166.98 -439.84 -400.00 -3006.82 314356.98
- 46 -2161.20 -445.62 -400.00 -3006.82 313511.36
- 47 -2155.39 -451.43 -400.00 -3006.82 312659.93
- 48 -2149.54 -457.28 -400.00 -3006.82 311802.65
- 49 -2143.64 -463.18 -400.00 -3006.82 310939.47
- 50 -2137.71 -469.11 -400.00 -3006.82 310070.36
- 51 -2131.73 -475.09 -400.00 -3006.82 309195.27
- 52 -2125.72 -481.10 -400.00 -3006.82 308314.17
- 53 -2119.66 -487.16 -400.00 -3006.82 307427.01
-Summary for: 2003:
- Interest Paid: -25826.75
- Principal Paid: -10255.09
- Year Ending Balance: 307427.01
- Sum of Interest Paid: -119797.84
-Pmt * Interest Principal Prepay Total Pmt Balance
- 54 -2113.56 -493.26 -400.00 -3006.82 306533.75
- 55 -2107.42 -499.40 -400.00 -3006.82 305634.35
- 56 -2101.24 -505.58 -400.00 -3006.82 304728.77
- 57 -2095.01 -511.81 -400.00 -3006.82 303816.96
- 58 -2088.74 -518.08 -400.00 -3006.82 302898.88
- 59 -2082.43 -524.39 -400.00 -3006.82 301974.49
- 60 -2076.07 -530.75 -400.00 -3006.82 301043.74
- 61 -2069.68 -537.14 -400.00 -3006.82 300106.60
- 62 -2063.23 -543.59 -400.00 -3006.82 299163.01
- 63 -2056.75 -550.07 -400.00 -3006.82 298212.94
- 64 -2050.21 -556.61 -400.00 -3006.82 297256.33
- 65 -2043.64 -563.18 -400.00 -3006.82 296293.15
-Summary for: 2004:
- Interest Paid: -24947.98
- Principal Paid: -11133.86
- Year Ending Balance: 296293.15
- Sum of Interest Paid: -144745.82
-Pmt * Interest Principal Prepay Total Pmt Balance
- 66 -2037.02 -569.80 -400.00 -3006.82 295323.35
- 67 -2030.35 -576.47 -400.00 -3006.82 294346.88
- 68 -2023.63 -583.19 -400.00 -3006.82 293363.69
- 69 -2016.88 -589.94 -400.00 -3006.82 292373.75
- 70 -2010.07 -596.75 -400.00 -3006.82 291377.00
- 71 -2003.22 -603.60 -400.00 -3006.82 290373.40
- 72 -1996.32 -610.50 -400.00 -3006.82 289362.90
- 73 -1989.37 -617.45 -400.00 -3006.82 288345.45
- 74 -1982.37 -624.45 -400.00 -3006.82 287321.00
- 75 -1975.33 -631.49 -400.00 -3006.82 286289.51
- 76 -1968.24 -638.58 -400.00 -3006.82 285250.93
- 77 -1961.10 -645.72 -400.00 -3006.82 284205.21
-Summary for: 2005:
- Interest Paid: -23993.90
- Principal Paid: -12087.94
- Year Ending Balance: 284205.21
- Sum of Interest Paid: -168739.72
-Pmt * Interest Principal Prepay Total Pmt Balance
- 78 -1953.91 -652.91 -400.00 -3006.82 283152.30
- 79 -1946.67 -660.15 -400.00 -3006.82 282092.15
- 80 -1939.38 -667.44 -400.00 -3006.82 281024.71
- 81 -1932.04 -674.78 -400.00 -3006.82 279949.93
- 82 -1924.66 -682.16 -400.00 -3006.82 278867.77
- 83 -1917.22 -689.60 -400.00 -3006.82 277778.17
- 84 -1909.72 -697.10 -400.00 -3006.82 276681.07
- 85 -1902.18 -704.64 -400.00 -3006.82 275576.43
- 86 -1894.59 -712.23 -400.00 -3006.82 274464.20
- 87 -1886.94 -719.88 -400.00 -3006.82 273344.32
- 88 -1879.24 -727.58 -400.00 -3006.82 272216.74
- 89 -1871.49 -735.33 -400.00 -3006.82 271081.41
-Summary for: 2006:
- Interest Paid: -22958.04
- Principal Paid: -13123.80
- Year Ending Balance: 271081.41
- Sum of Interest Paid: -191697.76
-Pmt * Interest Principal Prepay Total Pmt Balance
- 90 -1863.68 -743.14 -400.00 -3006.82 269938.27
- 91 -1855.83 -750.99 -400.00 -3006.82 268787.28
- 92 -1847.91 -758.91 -400.00 -3006.82 267628.37
- 93 -1839.95 -766.87 -400.00 -3006.82 266461.50
- 94 -1831.92 -774.90 -400.00 -3006.82 265286.60
- 95 -1823.85 -782.97 -400.00 -3006.82 264103.63
- 96 -1815.71 -791.11 -400.00 -3006.82 262912.52
- 97 -1807.52 -799.30 -400.00 -3006.82 261713.22
- 98 -1799.28 -807.54 -400.00 -3006.82 260505.68
- 99 -1790.98 -815.84 -400.00 -3006.82 259289.84
- 100 -1782.62 -824.20 -400.00 -3006.82 258065.64
- 101 -1774.20 -832.62 -400.00 -3006.82 256833.02
-Summary for: 2007:
- Interest Paid: -21833.45
- Principal Paid: -14248.39
- Year Ending Balance: 256833.02
- Sum of Interest Paid: -213531.21
-Pmt * Interest Principal Prepay Total Pmt Balance
- 102 -1765.73 -841.09 -400.00 -3006.82 255591.93
- 103 -1757.19 -849.63 -400.00 -3006.82 254342.30
- 104 -1748.60 -858.22 -400.00 -3006.82 253084.08
- 105 -1739.95 -866.87 -400.00 -3006.82 251817.21
- 106 -1731.24 -875.58 -400.00 -3006.82 250541.63
- 107 -1722.47 -884.35 -400.00 -3006.82 249257.28
- 108 -1713.64 -893.18 -400.00 -3006.82 247964.10
- 109 -1704.75 -902.07 -400.00 -3006.82 246662.03
- 110 -1695.80 -911.02 -400.00 -3006.82 245351.01
- 111 -1686.79 -920.03 -400.00 -3006.82 244030.98
- 112 -1677.71 -929.11 -400.00 -3006.82 242701.87
- 113 -1668.58 -938.24 -400.00 -3006.82 241363.63
-Summary for: 2008:
- Interest Paid: -20612.45
- Principal Paid: -15469.39
- Year Ending Balance: 241363.63
- Sum of Interest Paid: -234143.66
-Pmt * Interest Principal Prepay Total Pmt Balance
- 114 -1659.37 -947.45 -400.00 -3006.82 240016.18
- 115 -1650.11 -956.71 -400.00 -3006.82 238659.47
- 116 -1640.78 -966.04 -400.00 -3006.82 237293.43
- 117 -1631.39 -975.43 -400.00 -3006.82 235918.00
- 118 -1621.94 -984.88 -400.00 -3006.82 234533.12
- 119 -1612.42 -994.40 -400.00 -3006.82 233138.72
- 120 -1602.83 -1003.99 -400.00 -3006.82 231734.73
- 121 -1593.18 -1013.64 -400.00 -3006.82 230321.09
- 122 -1583.46 -1023.36 -400.00 -3006.82 228897.73
- 123 -1573.67 -1033.15 -400.00 -3006.82 227464.58
- 124 -1563.82 -1043.00 -400.00 -3006.82 226021.58
- 125 -1553.90 -1052.92 -400.00 -3006.82 224568.66
-Summary for: 2009:
- Interest Paid: -19286.87
- Principal Paid: -16794.97
- Year Ending Balance: 224568.66
- Sum of Interest Paid: -253430.53
-Pmt * Interest Principal Prepay Total Pmt Balance
- 126 -1543.91 -1062.91 -400.00 -3006.82 223105.75
- 127 -1533.85 -1072.97 -400.00 -3006.82 221632.78
- 128 -1523.73 -1083.09 -400.00 -3006.82 220149.69
- 129 -1513.53 -1093.29 -400.00 -3006.82 218656.40
- 130 -1503.26 -1103.56 -400.00 -3006.82 217152.84
- 131 -1492.93 -1113.89 -400.00 -3006.82 215638.95
- 132 -1482.52 -1124.30 -400.00 -3006.82 214114.65
- 133 -1472.04 -1134.78 -400.00 -3006.82 212579.87
- 134 -1461.49 -1145.33 -400.00 -3006.82 211034.54
- 135 -1450.86 -1155.96 -400.00 -3006.82 209478.58
- 136 -1440.17 -1166.65 -400.00 -3006.82 207911.93
- 137 -1429.39 -1177.43 -400.00 -3006.82 206334.50
-Summary for: 2010:
- Interest Paid: -17847.68
- Principal Paid: -18234.16
- Year Ending Balance: 206334.50
- Sum of Interest Paid: -271278.21
-Pmt * Interest Principal Prepay Total Pmt Balance
- 138 -1418.55 -1188.27 -400.00 -3006.82 204746.23
- 139 -1407.63 -1199.19 -400.00 -3006.82 203147.04
- 140 -1396.64 -1210.18 -400.00 -3006.82 201536.86
- 141 -1385.57 -1221.25 -400.00 -3006.82 199915.61
- 142 -1374.42 -1232.40 -400.00 -3006.82 198283.21
- 143 -1363.20 -1243.62 -400.00 -3006.82 196639.59
- 144 -1351.90 -1254.92 -400.00 -3006.82 194984.67
- 145 -1340.52 -1266.30 -400.00 -3006.82 193318.37
- 146 -1329.06 -1277.76 -400.00 -3006.82 191640.61
- 147 -1317.53 -1289.29 -400.00 -3006.82 189951.32
- 148 -1305.92 -1300.90 -400.00 -3006.82 188250.42
- 149 -1294.22 -1312.60 -400.00 -3006.82 186537.82
-Summary for: 2011:
- Interest Paid: -16285.16
- Principal Paid: -19796.68
- Year Ending Balance: 186537.82
- Sum of Interest Paid: -287563.37
-Pmt * Interest Principal Prepay Total Pmt Balance
- 150 -1282.45 -1324.37 -400.00 -3006.82 184813.45
- 151 -1270.59 -1336.23 -400.00 -3006.82 183077.22
- 152 -1258.66 -1348.16 -400.00 -3006.82 181329.06
- 153 -1246.64 -1360.18 -400.00 -3006.82 179568.88
- 154 -1234.54 -1372.28 -400.00 -3006.82 177796.60
- 155 -1222.35 -1384.47 -400.00 -3006.82 176012.13
- 156 -1210.08 -1396.74 -400.00 -3006.82 174215.39
- 157 -1197.73 -1409.09 -400.00 -3006.82 172406.30
- 158 -1185.29 -1421.53 -400.00 -3006.82 170584.77
- 159 -1172.77 -1434.05 -400.00 -3006.82 168750.72
- 160 -1160.16 -1446.66 -400.00 -3006.82 166904.06
- 161 -1147.47 -1459.35 -400.00 -3006.82 165044.71
-Summary for: 2012:
- Interest Paid: -14588.73
- Principal Paid: -21493.11
- Year Ending Balance: 165044.71
- Sum of Interest Paid: -302152.10
-Pmt * Interest Principal Prepay Total Pmt Balance
- 162 -1134.68 -1472.14 -400.00 -3006.82 163172.57
- 163 -1121.81 -1485.01 -400.00 -3006.82 161287.56
- 164 -1108.85 -1497.97 -400.00 -3006.82 159389.59
- 165 -1095.80 -1511.02 -400.00 -3006.82 157478.57
- 166 -1082.67 -1524.15 -400.00 -3006.82 155554.42
- 167 -1069.44 -1537.38 -400.00 -3006.82 153617.04
- 168 -1056.12 -1550.70 -400.00 -3006.82 151666.34
- 169 -1042.71 -1564.11 -400.00 -3006.82 149702.23
- 170 -1029.20 -1577.62 -400.00 -3006.82 147724.61
- 171 -1015.61 -1591.21 -400.00 -3006.82 145733.40
- 172 -1001.92 -1604.90 -400.00 -3006.82 143728.50
- 173 -988.13 -1618.69 -400.00 -3006.82 141709.81
-Summary for: 2013:
- Interest Paid: -12746.94
- Principal Paid: -23334.90
- Year Ending Balance: 141709.81
- Sum of Interest Paid: -314899.04
-Pmt * Interest Principal Prepay Total Pmt Balance
- 174 -974.25 -1632.57 -400.00 -3006.82 139677.24
- 175 -960.28 -1646.54 -400.00 -3006.82 137630.70
- 176 -946.21 -1660.61 -400.00 -3006.82 135570.09
- 177 -932.04 -1674.78 -400.00 -3006.82 133495.31
- 178 -917.78 -1689.04 -400.00 -3006.82 131406.27
- 179 -903.42 -1703.40 -400.00 -3006.82 129302.87
- 180 -888.96 -1717.86 -400.00 -3006.82 127185.01
- 181 -874.40 -1732.42 -400.00 -3006.82 125052.59
- 182 -859.74 -1747.08 -400.00 -3006.82 122905.51
- 183 -844.98 -1761.84 -400.00 -3006.82 120743.67
- 184 -830.11 -1776.71 -400.00 -3006.82 118566.96
- 185 -815.15 -1791.67 -400.00 -3006.82 116375.29
-Summary for: 2014:
- Interest Paid: -10747.32
- Principal Paid: -25334.52
- Year Ending Balance: 116375.29
- Sum of Interest Paid: -325646.36
-Pmt * Interest Principal Prepay Total Pmt Balance
- 186 -800.08 -1806.74 -400.00 -3006.82 114168.55
- 187 -784.91 -1821.91 -400.00 -3006.82 111946.64
- 188 -769.63 -1837.19 -400.00 -3006.82 109709.45
- 189 -754.25 -1852.57 -400.00 -3006.82 107456.88
- 190 -738.77 -1868.05 -400.00 -3006.82 105188.83
- 191 -723.17 -1883.65 -400.00 -3006.82 102905.18
- 192 -707.47 -1899.35 -400.00 -3006.82 100605.83
- 193 -691.67 -1915.15 -400.00 -3006.82 98290.68
- 194 -675.75 -1931.07 -400.00 -3006.82 95959.61
- 195 -659.72 -1947.10 -400.00 -3006.82 93612.51
- 196 -643.59 -1963.23 -400.00 -3006.82 91249.28
- 197 -627.34 -1979.48 -400.00 -3006.82 88869.80
-Summary for: 2015:
- Interest Paid: -8576.35
- Principal Paid: -27505.49
- Year Ending Balance: 88869.80
- Sum of Interest Paid: -334222.71
-Pmt * Interest Principal Prepay Total Pmt Balance
- 198 -610.98 -1995.84 -400.00 -3006.82 86473.96
- 199 -594.51 -2012.31 -400.00 -3006.82 84061.65
- 200 -577.92 -2028.90 -400.00 -3006.82 81632.75
- 201 -561.23 -2045.59 -400.00 -3006.82 79187.16
- 202 -544.41 -2062.41 -400.00 -3006.82 76724.75
- 203 -527.48 -2079.34 -400.00 -3006.82 74245.41
- 204 -510.44 -2096.38 -400.00 -3006.82 71749.03
- 205 -493.27 -2113.55 -400.00 -3006.82 69235.48
- 206 -475.99 -2130.83 -400.00 -3006.82 66704.65
- 207 -458.59 -2148.23 -400.00 -3006.82 64156.42
- 208 -441.08 -2165.74 -400.00 -3006.82 61590.68
- 209 -423.44 -2183.38 -400.00 -3006.82 59007.30
-Summary for: 2016:
- Interest Paid: -6219.34
- Principal Paid: -29862.50
- Year Ending Balance: 59007.30
- Sum of Interest Paid: -340442.05
-Pmt * Interest Principal Prepay Total Pmt Balance
- 210 -405.68 -2201.14 -400.00 -3006.82 56406.16
- 211 -387.79 -2219.03 -400.00 -3006.82 53787.13
- 212 -369.79 -2237.03 -400.00 -3006.82 51150.10
- 213 -351.66 -2255.16 -400.00 -3006.82 48494.94
- 214 -333.40 -2273.42 -400.00 -3006.82 45821.52
- 215 -315.02 -2291.80 -400.00 -3006.82 43129.72
- 216 -296.52 -2310.30 -400.00 -3006.82 40419.42
- 217 -277.88 -2328.94 -400.00 -3006.82 37690.48
- 218 -259.12 -2347.70 -400.00 -3006.82 34942.78
- 219 -240.23 -2366.59 -400.00 -3006.82 32176.19
- 220 -221.21 -2385.61 -400.00 -3006.82 29390.58
- 221 -202.06 -2404.76 -400.00 -3006.82 26585.82
-Summary for: 2017:
- Interest Paid: -3660.36
- Principal Paid: -32421.48
- Year Ending Balance: 26585.82
- Sum of Interest Paid: -344102.41
-Pmt * Interest Principal Prepay Total Pmt Balance
- 222 -182.78 -2424.04 -400.00 -3006.82 23761.78
- 223 -163.36 -2443.46 -400.00 -3006.82 20918.32
- 224 -143.81 -2463.01 -400.00 -3006.82 18055.31
- 225 -124.13 -2482.69 -400.00 -3006.82 15172.62
- 226 -104.31 -2502.51 -400.00 -3006.82 12270.11
- 227 -84.36 -2522.46 -400.00 -3006.82 9347.65
- 228 -64.27 -2542.55 -400.00 -3006.82 6405.10
- 229 -44.04 -2562.78 -400.00 -3006.82 3442.32
- 230 -23.67 -2583.15 -400.00 -3006.82 459.17
- 231 -3.16 -459.17 0.00 -462.33 0.00
-Summary for: 2018:
- Interest Paid: -937.89
- Principal Paid: -26585.82
- Year Ending Balance: 0.00
- Sum of Interest Paid: -345040.30
-
-Total Interest: -345040.30
Deleted: gnucash/trunk/src/calculation/test/Makefile.am
===================================================================
--- gnucash/trunk/src/calculation/test/Makefile.am 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/test/Makefile.am 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,9 +0,0 @@
-TESTS=test-link
-
-check_PROGRAMS=test-link
-
-test_link_SOURCES=test-link.c
-test_link_LDADD= \
- ../libgncmod-calculation.la \
- ${GLIB_LIBS} \
- -lgmodule-2.0
Deleted: gnucash/trunk/src/calculation/test/test-link.c
===================================================================
--- gnucash/trunk/src/calculation/test/test-link.c 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/calculation/test/test-link.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,6 +0,0 @@
-int
-main(int argc, char ** argv)
-{
- return 0;
-}
-
Modified: gnucash/trunk/src/gnome/Makefile.am
===================================================================
--- gnucash/trunk/src/gnome/Makefile.am 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/gnome/Makefile.am 2012-03-11 22:05:22 UTC (rev 22075)
@@ -105,9 +105,9 @@
-I${top_srcdir}/src \
-I${top_builddir}/src \
-I${top_srcdir}/src/core-utils \
- -I${top_srcdir}/src/calculation \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/app-utils \
+ -I${top_srcdir}/src/app-utils/calculation \
-I${top_srcdir}/src/backend/xml \
-I${top_srcdir}/src/gnome-utils \
-I${top_srcdir}/src/gnome-search \
Modified: gnucash/trunk/src/gnome-utils/gncmod-gnome-utils.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gncmod-gnome-utils.c 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/gnome-utils/gncmod-gnome-utils.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -59,12 +59,6 @@
return FALSE;
}
- /* load the calculation module (we depend on it) */
- if (!gnc_module_load("gnucash/calculation", 0))
- {
- return FALSE;
- }
-
if (!gnc_module_load("gnucash/app-utils", 0))
{
return FALSE;
Modified: gnucash/trunk/src/gnome-utils/test/Makefile.am
===================================================================
--- gnucash/trunk/src/gnome-utils/test/Makefile.am 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/gnome-utils/test/Makefile.am 2012-03-11 22:05:22 UTC (rev 22075)
@@ -9,7 +9,6 @@
##lib_LTLIBRARIES = libgncgnome.la
GNC_TEST_DEPS = --gnc-module-dir ${top_builddir}/src/engine \
- --gnc-module-dir ${top_builddir}/src/calculation \
--gnc-module-dir ${top_builddir}/src/app-utils \
--gnc-module-dir ${top_builddir}/src/gnome-utils \
--guile-load-dir ${top_builddir}/src/gnc-module \
@@ -24,7 +23,6 @@
--library-dir ${top_builddir}/src/engine \
--library-dir ${top_builddir}/src/backend/xml \
--library-dir ${top_builddir}/src/backend/sql \
- --library-dir ${top_builddir}/src/calculation \
--library-dir ${top_builddir}/src/app-utils
Modified: gnucash/trunk/src/html/Makefile.am
===================================================================
--- gnucash/trunk/src/html/Makefile.am 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/html/Makefile.am 2012-03-11 22:05:22 UTC (rev 22075)
@@ -49,7 +49,6 @@
${top_builddir}/src/core-utils/libgnc-core-utils.la \
${top_builddir}/src/gnc-module/libgnc-module.la \
${top_builddir}/src/engine/libgncmod-engine.la \
- ${top_builddir}/src/calculation/libgncmod-calculation.la \
${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
${top_builddir}/src/app-utils/libgncmod-app-utils.la \
$(top_builddir)/lib/libc/libc-missing.la \
Modified: gnucash/trunk/src/html/gncmod-html.c
===================================================================
--- gnucash/trunk/src/html/gncmod-html.c 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/html/gncmod-html.c 2012-03-11 22:05:22 UTC (rev 22075)
@@ -59,12 +59,6 @@
return FALSE;
}
- /* load the calculation module (we depend on it) */
- if ( !gnc_module_load( "gnucash/calculation", 0 ) )
- {
- return FALSE;
- }
-
if ( !gnc_module_load( "gnucash/app-utils", 0 ) )
{
return FALSE;
Modified: gnucash/trunk/src/import-export/test/Makefile.am
===================================================================
--- gnucash/trunk/src/import-export/test/Makefile.am 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/import-export/test/Makefile.am 2012-03-11 22:05:22 UTC (rev 22075)
@@ -25,7 +25,6 @@
test-import-parse
GNC_TEST_DEPS = --gnc-module-dir ${top_builddir}/src/engine \
- --gnc-module-dir ${top_builddir}/src/calculation \
--gnc-module-dir ${top_builddir}/src/app-utils \
--gnc-module-dir ${top_builddir}/src/gnome-utils \
--gnc-module-dir ${top_builddir}/src/import-export \
@@ -38,7 +37,6 @@
\
--library-dir ${top_builddir}/src/libqof/qof \
--library-dir ${top_builddir}/src/core-utils \
- --library-dir ${top_builddir}/src/calculation \
--library-dir ${top_builddir}/src/app-utils \
--library-dir ${top_builddir}/src/gnome-utils \
--library-dir ${top_builddir}/src/engine \
Modified: gnucash/trunk/src/report/report-gnome/test/Makefile.am
===================================================================
--- gnucash/trunk/src/report/report-gnome/test/Makefile.am 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/report/report-gnome/test/Makefile.am 2012-03-11 22:05:22 UTC (rev 22075)
@@ -20,7 +20,6 @@
test-load-module
GNC_TEST_DEPS = --gnc-module-dir ${top_builddir}/src/engine \
- --gnc-module-dir ${top_builddir}/src/calculation \
--gnc-module-dir ${top_builddir}/src/app-utils \
--gnc-module-dir ${top_builddir}/src/gnome-utils \
--gnc-module-dir ${top_builddir}/src/html \
@@ -40,7 +39,6 @@
\
--library-dir ${top_builddir}/src/libqof/qof \
--library-dir ${top_builddir}/src/core-utils \
- --library-dir ${top_builddir}/src/calculation \
--library-dir ${top_builddir}/src/app-utils \
--library-dir ${top_builddir}/src/gnc-module \
--library-dir ${top_builddir}/src/engine \
Modified: gnucash/trunk/src/report/report-system/test/Makefile.am
===================================================================
--- gnucash/trunk/src/report/report-system/test/Makefile.am 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/report/report-system/test/Makefile.am 2012-03-11 22:05:22 UTC (rev 22075)
@@ -17,7 +17,6 @@
test-load-module
GNC_TEST_DEPS = --gnc-module-dir ${top_builddir}/src/engine \
- --gnc-module-dir ${top_builddir}/src/calculation \
--gnc-module-dir ${top_builddir}/src/app-utils \
--gnc-module-dir ${top_builddir}/src/gnome-utils \
--gnc-module-dir ${top_builddir}/src/html \
@@ -33,7 +32,6 @@
\
--library-dir ${top_builddir}/src/libqof/qof \
--library-dir ${top_builddir}/src/core-utils \
- --library-dir ${top_builddir}/src/calculation \
--library-dir ${top_builddir}/src/app-utils \
--library-dir ${top_builddir}/src/gnome-utils \
--library-dir ${top_builddir}/src/engine \
@@ -52,4 +50,4 @@
EXTRA_DIST = test-load-module
testit:
- $(TESTS_ENVIRONMENT) libtool --mode execute gdb test-link-module
\ No newline at end of file
+ $(TESTS_ENVIRONMENT) libtool --mode execute gdb test-link-module
Modified: gnucash/trunk/src/report/standard-reports/test/Makefile.am
===================================================================
--- gnucash/trunk/src/report/standard-reports/test/Makefile.am 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/report/standard-reports/test/Makefile.am 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,7 +1,6 @@
TESTS=test-load-module
GNC_TEST_DEPS = --gnc-module-dir ${top_builddir}/src/engine \
- --gnc-module-dir ${top_builddir}/src/calculation \
--gnc-module-dir ${top_builddir}/src/app-utils \
--gnc-module-dir ${top_builddir}/src/gnome-utils \
--gnc-module-dir ${top_builddir}/src/html \
@@ -21,7 +20,6 @@
--library-dir ${top_builddir}/src/core-utils \
--library-dir ${top_builddir}/src/app-utils \
--library-dir ${top_builddir}/src/gnome-utils \
- --library-dir ${top_builddir}/src/calculation \
--library-dir ${top_builddir}/src/engine \
--library-dir ${top_builddir}/src/backend/xml \
--library-dir ${top_builddir}/src/backend/sql \
Modified: gnucash/trunk/src/report/stylesheets/test/Makefile.am
===================================================================
--- gnucash/trunk/src/report/stylesheets/test/Makefile.am 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/report/stylesheets/test/Makefile.am 2012-03-11 22:05:22 UTC (rev 22075)
@@ -6,7 +6,6 @@
--gnc-module-dir ${top_builddir}/src/html \
--gnc-module-dir ${top_builddir}/src/report/report-system \
--gnc-module-dir ${top_builddir}/src/report/stylesheets \
- --gnc-module-dir ${top_builddir}/src/calculation \
\
--guile-load-dir ${top_builddir}/src/test-core \
--guile-load-dir ${top_builddir}/src/gnc-module \
@@ -27,7 +26,6 @@
--library-dir ${top_builddir}/src/backend/sql \
--library-dir ${top_builddir}/src/app-utils \
--library-dir ${top_builddir}/src/gnome-utils \
- --library-dir ${top_builddir}/src/calculation \
--library-dir ${top_builddir}/src/html \
--library-dir ${top_builddir}/src/report/report-system \
--library-dir ${top_builddir}/src/report/report-gnome
Modified: gnucash/trunk/src/report/utility-reports/test/Makefile.am
===================================================================
--- gnucash/trunk/src/report/utility-reports/test/Makefile.am 2012-03-11 21:55:53 UTC (rev 22074)
+++ gnucash/trunk/src/report/utility-reports/test/Makefile.am 2012-03-11 22:05:22 UTC (rev 22075)
@@ -1,7 +1,6 @@
TESTS = test-load-module
GNC_TEST_DEPS = --gnc-module-dir ${top_builddir}/src/engine \
- --gnc-module-dir ${top_builddir}/src/calculation \
--gnc-module-dir ${top_builddir}/src/app-utils \
--gnc-module-dir ${top_builddir}/src/gnome-utils \
--gnc-module-dir ${top_builddir}/src/html \
@@ -19,7 +18,6 @@
\
--library-dir ${top_builddir}/src/libqof/qof \
--library-dir ${top_builddir}/src/core-utils \
- --library-dir ${top_builddir}/src/calculation \
--library-dir ${top_builddir}/src/app-utils \
--library-dir ${top_builddir}/src/gnome-utils \
--library-dir ${top_builddir}/src/engine \
More information about the gnucash-changes
mailing list