GnuCash
2.6.99
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
app-utils
calculation
finvar.h
1
/***************************************************************************
2
* -------------------
3
* create : Sat Jun 17 20:14:13 2000
4
* copyright: (C) 2000 by Terry D. Boldt
5
* email :
[email protected]
6
* -------------------
7
***************************************************************************/
8
/***************************************************************************
9
* *
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
14
* *
15
***************************************************************************/
16
/***************************************************************************
17
* Global Financial Variables
18
* Sat Jun 17 20:14:13 2000
19
*
20
***************************************************************************/
21
22
#ifndef FINVAR_H
23
#define FINVAR_H
24
25
#if !defined( EOS )
26
#define EOS '\x000'
27
#endif
28
29
#if !defined( TRUE )
30
#define TRUE (1)
31
#endif
32
33
#if !defined( FALSE )
34
#define FALSE (0)
35
#endif
36
37
#define INT_TYPE '\x001'
38
#define DBL_TYPE '\x002'
39
40
typedef
enum
41
{
42
PARSER_NO_ERROR = 0,
43
UNBALANCED_PARENS,
44
STACK_OVERFLOW,
45
STACK_UNDERFLOW,
46
UNDEFINED_CHARACTER,
47
NOT_A_VARIABLE,
48
NOT_A_FUNC,
49
PARSER_OUT_OF_MEMORY,
50
NUMERIC_ERROR,
51
EXPRESSION_ERROR,
52
PARSER_NUM_ERRORS
53
}
54
ParseError;
55
56
#define UNUSED_VAR '\x000'
57
#define USED_VAR '\x001'
58
#define ASSIGNED_TO '\x002'
59
60
#define ADD_OP '+'
61
#define SUB_OP '-'
62
#define DIV_OP '/'
63
#define MUL_OP '*'
64
#define ASN_OP '='
65
66
/* The following structure is used by the expression parser to store
67
* named and temporary variables. */
68
69
/* structure used for storing variables - used by expression parser/evaluator
70
*/
71
typedef
struct
var_store
*
var_store_ptr
;
72
73
/* the type of entity contained in the var_store */
74
typedef
enum
75
{
76
VST_NUMERIC = 0,
77
VST_STRING
78
} VarStoreType;
79
80
typedef
struct
var_store
81
{
82
char
*variable_name;
/* variable name if variable, NULL otherwise */
83
char
use_flag;
/* flag if variable has been assigned to */
84
char
assign_flag;
/* flag if variable is used */
85
VarStoreType type;
86
void
*value;
/* pointer to implementation defined numeric value */
87
var_store_ptr next_var;
/* pointer to next variable in linked list */
88
}
89
var_store
;
90
91
92
/* The following structure is used for the numeric operations
93
* involving double float and integer arithmetic */
94
95
/* structure used for storing numeric values - used by routines which
96
* evaluate arithmetic operators '+', '-', '/', '*' */
97
typedef
struct
numeric
*
numeric_ptr
;
98
typedef
struct
numeric
99
{
100
char
type;
/* designates type of value */
101
union
102
{
103
long
int
int_value;
/* long integer value */
104
double
dbl_value;
/* double value */
105
}
106
value;
107
}
108
numeric
;
109
110
/* The following structures are used by the amortization functions for
111
* storing amortization schedule information */
112
113
/* structure used by amortization routines for storing annual summary
114
information */
115
typedef
struct
yearly_summary
*
yearly_summary_ptr
;
116
typedef
struct
yearly_summary
117
{
118
unsigned
year;
119
double
interest;
120
double
end_balance;
121
}
122
yearly_summary
;
123
124
/* structure used by amortization routines for storing information on
125
a single payment */
126
typedef
struct
sched_pmt
*
sched_pmt_ptr
;
127
typedef
struct
sched_pmt
128
{
129
unsigned
period_num;
130
double
interest;
131
double
principal;
132
double
advanced_pmt;
133
double
total_pmt;
134
double
balance;
135
}
136
sched_pmt
;
137
138
/* structure used by amortization routines for storing information on
139
* payments for a single year */
140
typedef
struct
amort_sched_yr
*
amort_sched_yr_ptr
;
141
typedef
struct
amort_sched_yr
142
{
143
unsigned
year;
144
unsigned
num_periods;
145
sched_pmt_ptr payments;
146
double
interest_pd;
147
double
principal_pd;
148
double
yr_end_balance;
149
double
total_interest_pd;
150
double
final_pmt;
151
amort_sched_yr_ptr next_yr;
152
}
153
amort_sched_yr
;
154
155
/* structure used by amortization routines for passing and storing
156
* infomation on a particular amortization transaction */
157
typedef
struct
amort_sched
*
amort_sched_ptr
;
158
typedef
struct
amort_sched
159
{
160
/* following information set by function calling amortization
161
functions */
162
unsigned
n;
/* number of periods */
163
double
nint;
/* nominal interest rate */
164
double
pv;
/* present value */
165
double
pmt;
/* periodic payment */
166
double
fv;
/* future value */
167
unsigned
CF;
/* compounding frequency */
168
unsigned
PF;
/* payment frequency */
169
unsigned
disc;
/* discrete/continuous compounding flag */
170
unsigned
bep;
/* beginning/end of period payment flag */
171
unsigned
prec;
/* roundoff precision */
172
unsigned
year_E;
/* Effective date - year */
173
unsigned
month_E;
/* Effective date - month */
174
unsigned
day_E;
/* Effective date - day of month */
175
unsigned
year_I;
/* Initial payment date - year */
176
unsigned
month_I;
/* Initial payment date - month */
177
unsigned
day_I;
/* Initial payment date - day of month */
178
179
/* following information set by calling function to indicate which
180
* schedule to compute and which type of schedule */
181
unsigned
option;
/* option flag from 1 to 6 inclusive */
182
char
summary;
/* summary flag == 'y', 'p', 'a' or 'f' */
183
184
/* following information set by amortization functions */
185
double
eint;
/* effective interest rate */
186
double
bp;
/* float value of bep */
187
double
total_interest;
/* total interest paid */
188
unsigned
total_periods;
/* total numer of periods in schedule */
189
unsigned
long
yr_pmt;
/* number of payments in first year */
190
double
final_pmt_opt_1;
/* final payment option 1 */
191
double
final_pmt_opt_2;
/* final payment option 2 */
192
double
final_pmt_opt_3;
/* final payment option 3 */
193
double
final_pmt_opt_4;
/* final payment option 4 */
194
double
final_pmt_opt_5;
/* final payment option 5 */
195
double
final_pmt_opt_6;
/* final payment option 6 */
196
double
final_pmt;
/* final payment */
197
double
pve;
/* pv adjusted for delayed initial payment */
198
double
new_pmt;
/* pmt adjusted for delayed initial payment */
199
double
cpmt;
/* constant payment to principal */
200
double
cpmt1;
/* constant payment to principal, 1st case */
201
double
cpmt2;
/* constant payment to principal, 2cd case */
202
double
delayed_int;
/* interest due to delayed initial payment */
203
double
fixed_pmt;
/* fixed prepayment amount for amortization */
204
unsigned
new_n;
/* new number of periods to amortize due to
205
delayed intial payment */
206
unsigned
fv_case;
/* fv case flag */
207
unsigned
long
Eff_Date_jdn;
208
unsigned
yday_E;
209
unsigned
long
Init_Date_jdn;
210
unsigned
yday_I;
211
union
212
{
213
amort_sched_yr_ptr first_yr;
214
yearly_summary_ptr summary;
215
}
216
schedule;
217
}
218
amort_sched
;
219
220
/* The following structure is used to hold all of the financial
221
* variables used by the financial calculator */
222
223
/* structure used by financial computation routines to store financial
224
variables */
225
typedef
struct
financial_info
*
fi_ptr
;
226
typedef
struct
financial_info
227
{
228
double
ir;
/* interest rate */
229
double
pv;
/* present value */
230
double
pmt;
/* periodic payment */
231
double
fv;
/* future value */
232
233
unsigned
npp;
/* number of payment periods */
234
unsigned
CF;
/* Compounding frequency */
235
unsigned
PF;
/* payment frequency */
236
unsigned
bep;
/* beginning/end of period payment flag */
237
/* TRUE == beginning of period */
238
/* FALSE == end of period */
239
unsigned
disc;
/* discrete/continuous compounding flag */
240
/* TRUE == discrete compounding */
241
/* FALSE == continuous compounding */
242
243
/* precision of roundoff for pv, pmt and fv.
244
* i, Interest not rounded
245
* n, number of periods rounded to integer value, implicit value of zero, 0
246
*
247
* 2 for US Dollars
248
*/
249
unsigned
prec;
250
}
251
financial_info
;
252
253
typedef
struct
parser_env
*
parser_env_ptr
;
254
255
#endif
yearly_summary
Definition:
finvar.h:116
numeric
Definition:
finvar.h:98
parser_env
Definition:
expression_parser.c:400
var_store
Definition:
finvar.h:80
amort_sched_yr
Definition:
finvar.h:141
sched_pmt
Definition:
finvar.h:127
financial_info
Definition:
finvar.h:226
amort_sched
Definition:
finvar.h:158
Generated by
1.8.6