1
/***************************************************************************
2
amort_prt.c - description
4
begin : Thursday June 15 2000
5
email : tboldt@attglobal.net
6
Author : Terry D. Boldt
7
***************************************************************************/
9
/***************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
16
***************************************************************************/
19
* Functions to print amortization schedules
32
#include "fin_spl_protos.h"
35
void prt_amortization_schedule(
36
amort_sched_ptr amortsched, /* amortization schedule to print */
37
FILE *ofile) /* output file */
41
prec = amortsched->prec,
42
option = amortsched->option,
43
fv_case = amortsched->fv_case;
44
unsigned char datel[100],
45
summary = amortsched->summary;
48
amort_sched_yr_ptr amortyr,
50
sched_pmt_ptr pmtsched = NULL;
51
yearly_summary_ptr annual_summary;
53
times_E = (struct tm *)calloc(1,sizeof(struct tm));
54
times_E->tm_mday = amortsched->day_E;
55
times_E->tm_mon = amortsched->month_E - 1;
56
times_E->tm_year = amortsched->year_E - 1900;
57
times_E->tm_wday = (amortsched->Eff_Date_jdn + 1) % 7;
58
times_E->tm_yday = amortsched->yday_E;
60
times_I = (struct tm *)calloc(1,sizeof(struct tm));
61
times_I->tm_mday = amortsched->day_I;
62
times_I->tm_mon = amortsched->month_I - 1;
63
times_I->tm_year = amortsched->year_I - 1900;
64
times_I->tm_wday = (amortsched->Init_Date_jdn + 1) % 7;
65
times_I->tm_yday = amortsched->yday_I;
67
fprintf(ofile,"Amortization Table\n");
68
strftime(datel,(size_t)100,"%c",times_E);
69
fprintf(ofile,"Effective Date: %s\n",datel);
70
strftime(datel,(size_t)100,"%c",times_I);
71
fprintf(ofile,"Initial Payment Date: %s\n",datel);
72
fprintf(ofile,"Compounding Frequency per year: %u\n",amortsched->CF);
73
fprintf(ofile,"Payment Frequency per year: %u\n",amortsched->PF);
74
fprintf(ofile,"Compounding: %s\n",(amortsched->disc ? "Discrete" : "Continuous"));
75
fprintf(ofile,"Payments: %s\n",(amortsched->bep ? "Beginning of Period" : "End of Period"));
76
fprintf(ofile,"Payments (%u): %.*f\n",amortsched->n - 1,(int)prec,(option < 3) ? amortsched->cpmt : (option == 5) ? amortsched->new_pmt : amortsched->pmt);
77
fprintf(ofile,"Final payment (%u): %.*f\n",amortsched->n,(int)prec,amortsched->final_pmt);
78
if ( (amortsched->CF == 1) && (amortsched->PF == 1) ) fprintf(ofile,"Nominal Interest per Payment Period: %g\t(Annualized: %g)\n",amortsched->nint,amortsched->nint * 12);
79
else fprintf(ofile,"Nominal Annual Interest Rate: %g\n",amortsched->nint);
80
fprintf(ofile," Effective Interest Rate Per Payment Period: %g\n",amortsched->eint);
81
fprintf(ofile,"Present Value: %.*f\n",(int)prec,amortsched->pv);
82
if ( (amortsched->option == 2) || (amortsched->option > 3) ) {
83
fprintf(ofile,"Interest due to Delayed Intial Payment: %.*f\n",(int)prec,amortsched->delayed_int);
89
if ( amortsched->option < 3 ) {
90
summary = (summary == 'y') ? 'x' : 'o';
95
/* variable prepayment schedule
97
fprintf(ofile,"Advanced Prepayment Amortization - Variable Prepayment\n");
98
amortyr = amortsched->schedule.first_yr;
99
for ( j = amortsched->total_periods , jj = 0 ; j && amortyr ; j-- ) {
101
fprintf(ofile,"Pmt * Interest Principal Prepay Total Pmt Balance\n");
102
pmtsched = amortyr->payments;
103
jj = amortyr->num_periods;
106
fprintf(ofile,"%4u %12.*f %12.*f %12.*f %12.*f %12.*f\n",
107
pmtsched->period_num,
108
(int)prec,pmtsched->interest,
109
(int)prec,pmtsched->principal,
110
(int)prec,pmtsched->advanced_pmt,
111
(int)prec,pmtsched->total_pmt,
112
(int)prec,pmtsched->balance);
115
fprintf(ofile,"Summary for: %u:\n",amortyr->year);
116
fprintf(ofile," Interest Paid: %.*f\n",(int)prec,amortyr->interest_pd);
117
fprintf(ofile," Principal Paid: %.*f\n",(int)prec,amortyr->principal_pd);
118
fprintf(ofile," Year Ending Balance: %.*f\n",(int)prec,amortyr->yr_end_balance);
119
fprintf(ofile," Sum of Interest Paid: %.*f\n",(int)prec,amortyr->total_interest_pd);
121
amortyr = amortyr->next_yr;
128
/* fixed prepayment schedule
130
fprintf(ofile,"Advanced Prepayment Amortization - Fixed Prepayment: %.*f\n",(int)prec,amortsched->fixed_pmt);
131
amortyr = amortsched->schedule.first_yr;
132
for ( j = amortsched->total_periods , jj = 0 ; j && amortyr ; j-- ) {
134
fprintf(ofile,"Pmt * Interest Principal Prepay Total Pmt Balance\n");
135
pmtsched = amortyr->payments;
136
jj = amortyr->num_periods;
139
fprintf(ofile,"%4u %12.*f %12.*f %12.*f %12.*f %12.*f\n",
140
pmtsched->period_num,
141
(int)prec,pmtsched->interest,
142
(int)prec,pmtsched->principal,
143
(int)prec,pmtsched->advanced_pmt,
144
(int)prec,pmtsched->total_pmt,
145
(int)prec,pmtsched->balance);
148
fprintf(ofile,"Summary for: %u:\n",amortyr->year);
149
fprintf(ofile," Interest Paid: %.*f\n",(int)prec,amortyr->interest_pd);
150
fprintf(ofile," Principal Paid: %.*f\n",(int)prec,amortyr->principal_pd);
151
fprintf(ofile," Year Ending Balance: %.*f\n",(int)prec,amortyr->yr_end_balance);
152
fprintf(ofile," Sum of Interest Paid: %.*f\n",(int)prec,amortyr->total_interest_pd);
154
amortyr = amortyr->next_yr;
161
/* constant payment to principal
163
fprintf(ofile,"Constant Payment to Principal: %.*f\n",(int)prec,amortsched->cpmt);
164
amortyr = amortsched->schedule.first_yr;
165
for ( j = amortsched->total_periods , jj = 0 ; j && amortyr ; j-- ) {
167
fprintf(ofile,"Pmt# Interest Total Payment Balance\n");
168
pmtsched = amortyr->payments;
169
jj = amortyr->num_periods;
172
fprintf(ofile,"%4u %12.*f %12.*f %12.*f\n",
173
pmtsched->period_num,
174
(int)prec,pmtsched->interest,
175
(int)prec,pmtsched->total_pmt,
176
(int)prec,pmtsched->balance);
179
fprintf(ofile,"Summary for: %u:\n",amortyr->year);
180
fprintf(ofile," Interest Paid: %.*f\n",(int)prec,amortyr->interest_pd);
181
fprintf(ofile," Principal Paid: %.*f\n",(int)prec,amortyr->principal_pd);
182
fprintf(ofile," Year Ending Balance: %.*f\n",(int)prec,amortyr->yr_end_balance);
183
fprintf(ofile," Sum of Interest Paid: %.*f\n",(int)prec,amortyr->total_interest_pd);
185
amortyr = amortyr->next_yr;
192
/* normal payment schedule
194
fprintf(ofile,"Normal Amortization Schedule\n");
195
amortyr = amortsched->schedule.first_yr;
196
for ( j = amortsched->total_periods - 1 , jj = 0 ; j && amortyr ; j-- ) {
198
fprintf(ofile,amortsched->fv_case ? "Pmt * Interest Balance\n" : "Pmt * Interest Principal Balance\n");
199
pmtsched = amortyr->payments;
200
jj = amortyr->num_periods;
204
fprintf(ofile,"%4u %12.*f %12.*f\n",
205
pmtsched->period_num,
206
(int)prec,pmtsched->interest,
207
(int)prec,pmtsched->balance);
209
fprintf(ofile,"%4u %12.*f %12.*f %12.*f\n",
210
pmtsched->period_num,
211
(int)prec,pmtsched->interest,
212
(int)prec,pmtsched->principal,
213
(int)prec,pmtsched->balance);
217
fprintf(ofile,"Summary for: %u:\n",amortyr->year);
218
fprintf(ofile," Interest Paid: %.*f\n",(int)prec,amortyr->interest_pd);
219
if ( !fv_case ) fprintf(ofile," Principal Paid: %.*f\n",(int)prec,amortyr->principal_pd);
220
fprintf(ofile," Year Ending Balance: %.*f\n",(int)prec,amortyr->yr_end_balance);
221
fprintf(ofile," Sum of Interest Paid: %.*f\n",(int)prec,amortyr->total_interest_pd);
223
amortyr = amortyr->next_yr;
230
fprintf(ofile,amortsched->fv_case ? "Pmt * Interest Balance\n" : "Pmt * Interest Principal Balance\n");
231
pmtsched = amortyr->payments;
234
fprintf(ofile,"Final Payment: %.*f\n",(int)prec,amortyr->final_pmt);
237
fprintf(ofile,"%4u %12.*f %12.*f\n",
238
pmtsched->period_num,
239
(int)prec,pmtsched->interest,
240
(int)prec,pmtsched->balance);
242
fprintf(ofile,"%4u %12.*f %12.*f %12.*f\n",
243
pmtsched->period_num,
244
(int)prec,pmtsched->interest,
245
(int)prec,pmtsched->principal,
246
(int)prec,pmtsched->balance);
249
fprintf(ofile,"Summary for: %u:\n",amortyr->year);
250
fprintf(ofile," Interest Paid: %.*f\n",(int)prec,amortyr->interest_pd);
251
if ( !fv_case ) fprintf(ofile," Principal Paid: %.*f\n",(int)prec,amortyr->principal_pd);
252
fprintf(ofile," Year Ending Balance: %.*f\n",(int)prec,amortyr->yr_end_balance);
253
fprintf(ofile," Sum of Interest Paid: %.*f\n",(int)prec,amortyr->total_interest_pd);
256
/* constant payment to principal - annual summary
259
/* normal payment - annual summary
261
if ( summary == 'x' ) fprintf(ofile,"Annual Summary - Constant Payment to Principal: %.*f\n",(int)prec,amortsched->cpmt);
262
else fprintf(ofile,"Annual Summary - Normal Amortization\n");
263
fprintf(ofile,"Year Interest Ending Balance\n");
264
annual_summary = amortsched->schedule.summary;
265
for ( j = amortsched->total_periods , jj = 0 ; j ; j-- , jj++ ) {
266
fprintf(ofile,"%4u %12.*f %12.*f\n",
267
annual_summary[jj].year,
268
(int)prec,annual_summary[jj].interest,
269
(int)prec,annual_summary[jj].end_balance);
274
fprintf(ofile,"\nTotal Interest: %.*f\n",(int)prec,amortsched->total_interest);
276
} /* prt_amortization_schedule */