1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
//! The statistic helper definition.
// Copyright (c) 2021 ShiftLeft Software
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use rust_decimal::prelude::*;
pub struct ElemStatisticHelper {
/// Name of the statistic event.
name: String,
/// Accumulated principal decrease for statistics period.
principal_decrease: Decimal,
/// Accumulated principal increase for statistics period.
principal_increase: Decimal,
/// Accumulated compounded interest for period.
interest: Decimal,
/// Accumulated straight-line interest for period.
sl_interest: Decimal,
/// Accumulated value to interest for period.
value_to_interest: Decimal,
/// Accumulated value to principal for period.
value_to_principal: Decimal,
/// The last statistic event date.
last_date: usize,
/// Index of the ElemAmortization object.
elem_am_index: usize,
}
/// The statistic helper implementation.
impl ElemStatisticHelper {
/// Create a new statistic helper.
///
/// # Arguments
///
/// * `name_param` - Statistic helper name.
/// * `principal_decrease_param` - Principal decrease.
/// * `principal_increase_param` - Principal increase.
/// * `interest_param` - Interest parameter.
/// * `sl_interest_param` - Straight line interest.
/// * `value_to_interest_param` - Value to interest.
/// * `value_to_principal_param` - Value to principal.
/// * `last_date_param` - Last date.
/// * `elem_am_index_param` - Amortization element index.
///
/// # Return
///
/// * See description.
#[allow(clippy::too_many_arguments)]
pub fn new(
name_param: &str,
principal_decrease_param: Decimal,
principal_increase_param: Decimal,
interest_param: Decimal,
sl_interest_param: Decimal,
value_to_interest_param: Decimal,
value_to_principal_param: Decimal,
last_date_param: usize,
elem_am_index_param: usize,
) -> ElemStatisticHelper {
ElemStatisticHelper {
name: String::from(name_param),
principal_decrease: principal_decrease_param,
principal_increase: principal_increase_param,
interest: interest_param,
sl_interest: sl_interest_param,
value_to_interest: value_to_interest_param,
value_to_principal: value_to_principal_param,
last_date: last_date_param,
elem_am_index: elem_am_index_param,
}
}
/// Get the name of the statistic helper.
///
/// # Return
///
/// * See description.
pub fn name(&self) -> &str {
self.name.as_str()
}
/// Get the principal decrease of the statistic helper.
///
/// # Return
///
/// * See description.
pub fn principal_decrease(&self) -> Decimal {
self.principal_decrease
}
/// Get the principal increase of the statistic helper.
///
/// # Return
///
/// * See description.
pub fn principal_increase(&self) -> Decimal {
self.principal_increase
}
/// Get the interest of the statistic helper.
///
/// # Return
///
/// * See description.
pub fn interest(&self) -> Decimal {
self.interest
}
/// Get the straight line interest of the statistic helper.
///
/// # Return
///
/// * See description.
pub fn sl_interest(&self) -> Decimal {
self.sl_interest
}
/// Get the value to interest of the statistic helper.
///
/// # Return
///
/// * See description.
pub fn value_to_interest(&self) -> Decimal {
self.value_to_interest
}
/// Get the value to principal of the statistic helper.
///
/// # Return
///
/// * See description.
pub fn value_to_principal(&self) -> Decimal {
self.value_to_principal
}
/// Get the last date of the statistic helper.
///
/// # Return
///
/// * See description.
pub fn last_date(&self) -> usize {
self.last_date
}
/// Get the element amortization index of the statistic helper.
///
/// # Return
///
/// * See description.
pub fn elem_am_index(&self) -> usize {
self.elem_am_index
}
/// Set the name of the statistic helper.
///
/// # Arguments
///
/// * `name_param` - See description.
pub fn set_name(&mut self, name_param: &str) {
self.name = String::from(name_param);
}
/// Set the principal decrease of the statistic helper.
///
/// # Arguments
///
/// * `principal_decrease_param` - See description.
pub fn set_principal_decrease(&mut self, principal_decrease_param: Decimal) {
self.principal_decrease = principal_decrease_param;
}
/// Set the principal increase of the statistic helper.
///
/// # Arguments
///
/// * `principal_increase_param` - See description.
pub fn set_principal_increase(&mut self, principal_increase_param: Decimal) {
self.principal_increase = principal_increase_param;
}
/// Set the interest of the statistic helper.
///
/// # Arguments
///
/// * `interest_param` - See description.
pub fn set_interest(&mut self, interest_param: Decimal) {
self.interest = interest_param;
}
/// Set the straight line interest of the statistic helper.
///
/// # Arguments
///
/// * `sl_interest_param` - See description.
pub fn set_sl_interest(&mut self, sl_interest_param: Decimal) {
self.sl_interest = sl_interest_param;
}
/// Set the value to interest of the statistic helper.
///
/// # Arguments
///
/// * `value_to_interest_param` - See description.
pub fn set_value_to_interest(&mut self, value_to_interest_param: Decimal) {
self.value_to_interest = value_to_interest_param;
}
/// Set the value to principal of the statistic helper.
///
/// # Arguments
///
/// * `value_to_principal_param` - See description.
pub fn set_value_to_principal(&mut self, value_to_principal_param: Decimal) {
self.value_to_principal = value_to_principal_param;
}
/// Set the last date of the statistic helper.
///
/// # Arguments
///
/// * `last_date_param` - See description.
pub fn set_last_date(&mut self, last_date_param: usize) {
self.last_date = last_date_param;
}
/// Set the element amortization index of the statistic helper.
///
/// # Arguments
///
/// * `elem_am_index_param` - See description.
pub fn set_elem_am_index(&mut self, elem_am_index_param: usize) {
self.elem_am_index = elem_am_index_param;
}
}