-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathentryDataStruct.h
More file actions
139 lines (112 loc) · 2.84 KB
/
entryDataStruct.h
File metadata and controls
139 lines (112 loc) · 2.84 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
#pragma once
#include "includeHeaders.h"
// Datatype for datarow
// Used to store current entry before writing into file.
struct ENTRY {
template <typename T1>
struct DATA_ROW {
T1 value;
bool isUsed = false;
bool isFixed = false;
int fixedIndex = -1;
// Resets the value to the default of that datatype
void reset() {
T1 tempValue{};
value = {};
isUsed = false;
isFixed = false;
fixedIndex = -1;
}
void set(T1 userInput) {
value = userInput;
isUsed = true;
}
void set(T1 userInput, int index) {
fixedIndex = index;
set(userInput);
}
void fix(T1 userInput) {
value = userInput;
isUsed = true;
isFixed = true;
}
void fix(T1 userInput, int index) {
fixedIndex = index;
fix(userInput);
}
// Resets value, isUsed
void reset_input() {
if (!isFixed) {
T1 tempValue{};
value = {};
isUsed = false;
fixedIndex = -1;
}
}
};
// Transaction type
DATA_ROW<string> type;
/* Transaction parent category & children type, e.g. Car -> Fuel
- If type is "Transfer", both of these are "(Transfer)"
*/
DATA_ROW<string> transCat, transChild;
// Account parent category & children type, only used for non-transfers
// E.g. Bank -> RHB Bank
DATA_ROW<string> accCat, accChild;
// Date data declarations
DATA_ROW<unsigned short int> year, month, day, hour, mins;
// Transaction amount
DATA_ROW<double> amount;
// Transaction title
DATA_ROW<string> title;
// Transaction notes
DATA_ROW<string> notes;
// Transaction label
DATA_ROW<string> label;
// Transaction status
DATA_ROW<char> status;
// Special variables for transfers
DATA_ROW<string> sourceAccCat, sourceAccChild, destAccCat, destAccChild;
// If there is even one field locked it will return true
bool is_anything_locked() {
if (type.isFixed) return true;
if (transCat.isFixed) return true;
if (transChild.isFixed) return true;
if (accCat.isFixed) return true;
if (accChild.isFixed) return true;
if (year.isFixed) return true;
if (month.isFixed) return true;
if (day.isFixed) return true;
if (hour.isFixed) return true;
if (mins.isFixed) return true;
if (amount.isFixed) return true;
if (title.isFixed) return true;
if (notes.isFixed) return true;
if (label.isFixed) return true;
if (status.isFixed) return true;
if (sourceAccCat.isFixed) return true;
if (sourceAccChild.isFixed) return true;
if (destAccCat.isFixed) return true;
if (destAccChild.isFixed) return true;
return false;
}
bool is_dateTime_locked() {
if (year.isFixed) return true;
if (month.isFixed) return true;
if (day.isFixed) return true;
if (hour.isFixed) return true;
if (mins.isFixed) return true;
return false;
}
string status_text() {
if (status.value == 'R') {
return "Reconciled";
}
else if (status.value == 'C') {
return "Cleared";
}
else {
return "<None>";
}
}
};