-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnote.cpp
More file actions
273 lines (224 loc) · 5.64 KB
/
note.cpp
File metadata and controls
273 lines (224 loc) · 5.64 KB
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
// note.cpp
#include "eWallet.h"
#include "note.h"
#include <ctime>
wlt::Note::Note(Operation OperationType, Category CategoryType, std::string Acc_1, double Value, unsigned long id, std::string details, unsigned long long seconds )
{
this->OperationType = OperationType;
this->CategoryType = CategoryType;
this->AccountName = Acc_1;
this->Value = Value;
this->Details = details;
this->ID = id;
this->fillTimeData(seconds);
}
wlt::Note::Note(Operation OperationType, std::string Acc1, std::string Acc2, double val, unsigned long id, std::string details, unsigned long long seconds )
{
if (OperationType != wlt::Operation::TRANSFER)
throw std::error_condition();
this->OperationType = OperationType;
this->CategoryType = wlt::Category::TRANSFER_OPERATION;
this->AccountName = Acc1;
this->AccountNameAddit = Acc2;
this->Value = val;
this->Details = details;
this->ID = id;
this->fillTimeData(seconds);
}
wlt::Note::Note(Operation OperationType, Category CategoryType, const char* str1, double Value, unsigned long id, std::string details, unsigned long long seconds )
{
std::string Acc1(str1);
this->OperationType = OperationType;
this->CategoryType = CategoryType;
this->AccountName = Acc1;
this->Value = Value;
this->Details = details;
this->ID = id;
this->fillTimeData(seconds);
}
wlt::Note::Note(Operation, const char* str1, const char* str2, double val, unsigned long id, std::string details, unsigned long long seconds )
{
if (OperationType != wlt::Operation::TRANSFER)
throw std::error_condition();
std::string Acc1(str1);
std::string Acc2(str2);
this->OperationType = OperationType;
//this->CategoryType = CategoryType;
this->AccountName = Acc1;
this->AccountNameAddit = Acc2;
this->Value = Value;
this->Details = details;
this->ID = id;
this->fillTimeData(seconds);
}
wlt::Note::~Note()
{
}
wlt::Operation wlt::Note::getOperation()
{
return this->OperationType;
}
void wlt::Note::setOperation(wlt::Operation OperationType)
{
this->OperationType = OperationType;
}
wlt::Category wlt::Note::getCategory()
{
return this->CategoryType;
}
void wlt::Note::setCategory(wlt::Category CatType)
{
this->CategoryType = CatType;
}
std::string wlt::Note::getAccountName()
{
return this->AccountName;
}
void wlt::Note::setAccountName(std::string& NewName)
{
this->AccountName = NewName;
}
double wlt::Note::getValue()
{
return this->Value;
}
void wlt::Note::setValue(double NewValue)
{
this->Value = NewValue;
}
unsigned long wlt::Note::getId()
{
return this->ID;
}
std::string wlt::Note::debugInfo()
{
std::string Oper;
std::string Categ;
switch(this->OperationType)
{
case 0: Oper = "Income";
break;
case 1: Oper = "Expense";
break;
case 2: Oper = "Transfer";
break;
default:
Oper = "";
break;
}
switch (this->CategoryType)
{
case 0: Categ = "Food";
break;
case 1:Categ = "Products";
break;
case 2: Categ = "Healthcare";
break;
case 3: Categ = "Public Transport";
break;
case 4: Categ = "Vehicle";
break;
case 5: Categ = "Entertainment";
break;
case 6: Categ = "Network";
break;
case 7: Categ = "Finance Expensies";
break;
case 8: Categ = "Transfer operation";
break;
case 9: Categ = "Earnings";
break;
default:
Categ = "";
break;
}
std::string str;
if (AccountNameAddit.empty())
str = "Operation: \'" + Oper + "\'\tCategory: \'" + Categ + "\'\tAccount Name: \'" + this->AccountName + "\' Value: " + std::to_string(this->Value);
else
str = "Operation: \'" + Oper + "\'" + "\tFrom Account: \'" + this->AccountName + "\' To Account: \'" + this->AccountNameAddit + "\' Value: " + std::to_string(this->getValue());
return str;
}
void wlt::Note::fillTimeData(unsigned long long seconds)
{
time_t t;
if (seconds == 0)
t = time(NULL);
else
t = seconds;
this->EpochTime = t;
struct tm buf;
_localtime64_s(&buf, &t);
this->minutes = buf.tm_min;
this->hours = buf.tm_hour;
this->day = buf.tm_mday;
this->month = buf.tm_mon + 1;
this->year = buf.tm_year + 1900;
}
std::string wlt::Note::getTimeInfo()
{
char buffer[25];
sprintf_s(buffer,"%02d:%02d %02d.%02d.%d",this->hours, this->minutes, this->day, this->month, this->year);
return std::string(buffer);
}
time_t wlt::Note::getEpochTime()
{
return this->EpochTime;
}
std::string wlt::Note::getAccountNameAddit()
{
return this->AccountNameAddit;
}
void wlt::Note::setAccountNameAddit(std::string& newName)
{
this->AccountNameAddit = newName;
}
std::string wlt::Note::getDetails()
{
return this->Details;
}
void wlt::Note::setDetails(std::string new_detail)
{
this->Details = new_detail;
}
unsigned int wlt::Note::getDay()
{
return this->day;
}
unsigned int wlt::Note::getMonth()
{
return this->month;
}
unsigned int wlt::Note::getYear()
{
return this->year;
}
std::string wlt::Note::getCategoryString()
{
switch (this->CategoryType)
{
case 0: return "Food";
break;
case 1:return "Products";
break;
case 2: return "Healthcare";
break;
case 3: return "Public Transport";
break;
case 4: return "Vehicle";
break;
case 5: return "Entertainment";
break;
case 6: return "Network";
break;
case 7: return "Finance Expensies";
break;
case 8: return "Transfer operation";
break;
case 9: return "Earnings";
break;
default:
return "";
break;
}
}