-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBluecoinsImportTool.cpp
More file actions
252 lines (216 loc) · 5.79 KB
/
BluecoinsImportTool.cpp
File metadata and controls
252 lines (216 loc) · 5.79 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
// BluecoinsImportTool.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include "BluecoinsImportTool.h"
ENTRY fixedEntryMenu(json, ENTRY);
ENTRY entryTemplate;
int countEntry = 0,
countDiscard = 0;
const int menusize = 11;
// Main menu for program.
int mainMenu() {
int selection;
struct MENU {
int count = 0;
string content = "";
};
MENU menu[menusize];
// Define menus
menu[0].count = 0;
menu[0].content = "Load New Json File";
menu[1].count = 1;
menu[1].content = "Set New Output File";
menu[2].count = 2;
menu[2].content = "View All Current Categories";
menu[3].count = 3;
menu[3].content = "View Last Entry";
menu[4].count = 4;
menu[4].content = "Input New Entry";
menu[6].count = 6;
menu[6].content = "Toggle split entry status";
if (splitTransac) {
menu[6].content += " [!! Enabled !!]";
}
else if (usedSplit) {
menu[6].content += " [Disabled]. You may want to go to option 7 to clear fields if you haven't.";
}
else {
menu[6].content += " [Disabled]";
}
menu[7].count = 7;
menu[7].content = "Toggle fixed entries status";
menu[8].count = 8;
menu[8].content = "Toggle multi-line notes";
if (multiLine) {
menu[8].content += " [Enabled]";
}
else {
menu[8].content += " [Disabled]";
}
menu[10].count = 10;
menu[10].content = "Exit";
// Output menu.
menuHeading();
for (int j = 0; j < menusize; j++) {
if (menu[j].content != "") {
cout << left << setw(5) << menu[j].count << menu[j].content;
}
cout << endl;
}
cout << endl;
// To output the status of split transaction mode if there is.
if (splitTransac) {
line(50, '-', true);
cout << "- Please make sure that the date, time and title are the same. We recommend you to use the \'lock\' function in option 7 to do so." << endl;
cout << "- Using different label sets and status for each split is not currently supported. Only the first row of those will be used for each split transaction." << endl;
cout << "- You can only import one split transaction per csv file." << endl;
line(50, '-', true);
}
cout << "Your Selection";
selection = inputNumber<int>();
return selection;
}
int main() {
// Future feature: json file creator.
introduction();
while (true) {
try {
// If json file is empty then load.
if (properties.empty()) {
readFile();
}
heading("Main Menu");
cout << "Json file path : \"" << jsonFilename << "\"" << endl;
cout << "Output file path : \"" << outFilename << "\"" << endl;
int selection = mainMenu();
switch (selection) {
// Load a new json file.
case 0:
{
heading("Reload JSON File");
cout << "Are you sure you want to clear the current json configuration and load a new one? " << endl;
if (decider()) {
properties.clear();
continue;
}
else {
cout << "No actions taken. ";
system("pause");
}
break;
}
// Set a new output file.
case 1:
{
fileFunc();
break;
}
// Outputs all properties.
case 2:
{
outAllProperties();
break;
}
// View last inputted entry.
case 3:
{
heading("View Last Entry");
if (countEntry == 0 && countDiscard == 0) {
cout << "There are no entries inputted before this." << endl;
}
else {
show_inputted(entry);
}
system("pause");
break;
}
// Creates a new entry.
case 4:
{
reset();
int decision = entryInput(entryTemplate);
if (decision == 0) {
if (!file.is_open()) {
fileFunc();
}
writeToFile();
append = true;
cout << "\nWritten to file. ";
countEntry++;
if (splitTransac) {
usedSplit = true;
entryTemplate = syncFixed(entry, entryTemplate);
}
system("pause");
}
else if (decision == 1) {
cout << "\nEntry discarded. ";
countDiscard++;
system("pause");
}
break;
}
// To toggle split transaction mode
case 6:
{
if (!splitTransac && usedSplit) {
cout << "Only one split transaction can be used per CSV file. Are you sure you want to continue?" << endl;
if (decider()) {
splitTransac = true;
}
else {
break;
}
}
else if (!splitTransac) {
splitTransac = true;
}
else {
splitTransac = false;
}
break;
}
case 7:
{
entryTemplate = fixedEntryMenu(properties, entryTemplate);
break;
}
case 8: {
multiLine = !multiLine;
break;
}
case 10:
{
heading("Exit");
cout << "Thank you for using the bluecoins import tool. Throughout this session, you have: " << endl;
cout << endl;
cout << "Inserted " << countEntry << " entries." << endl;
cout << "Discarded " << countDiscard << " entries." << endl;
cout << endl;
system("pause");
exit(0);
}
default:
break;
}
}
catch (...) {
cout << "Oops! You found a bug!" << endl
<< "Please file a bug report (issue) at the following page:" << endl
<< "https://github.com/kwongtn/Bluecoins-ImportTool/issues" << endl << endl
<< "Within the issue, please detail the things you were doing (steps, etc) when you encountered this bug." << endl << endl
<< "Thank you! :D";
}
// system("pause");
}
//outAllProperties();
return 0;
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file