-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfixedEntry.cpp
More file actions
1062 lines (834 loc) · 23.7 KB
/
fixedEntry.cpp
File metadata and controls
1062 lines (834 loc) · 23.7 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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "utils.h"
#include "displayUtils.h"
const int FIXED_MENU_SIZE = 10;
#define BYPASS_COMPULSORY_INPUT_NUMBER \
if(bypass && (userInput == NO_INPUT_NUM)){ \
break; \
}
#define BYPASS_COMPULSORY_INPUT_STRING \
if(bypass && (userInput == to_string(NO_INPUT_NUM))){ \
return; \
}
#include "entryDataStruct.h"
ENTRY templateEntry;
json props;
int type_index = -1;
void outArray(bool, int type = -1, int cat = -1);
void lockTransactionType(bool bypass = false) {
type_index = -1;
while (true) {
heading("Lock Field -> Transaction Type");
int userInput = 0;
outArray(false);
cout << endl << left << setw(5) << "5" << "Transfer" << endl;
cout << endl << "Type? ";
userInput = inputNumber<int>(false, !bypass);
BYPASS_COMPULSORY_INPUT_NUMBER;
switch (userInput) {
case 1:
case 2:
type_index = userInput;
templateEntry.type.fix(returnString(props["presetLists"][userInput]["type"]), userInput);
break;
case 5:
type_index = userInput;
templateEntry.type.fix("Transfer", 5);
templateEntry.transCat.fix("(Transfer)");
templateEntry.transChild.fix("(Transfer)");
break;
default:
cout << "Illegal action!" << endl;
system("pause");
continue;
}
break;
}
}
// Expenses & Income
void lockTransCat(bool bypass = false) {
templateEntry.transCat.reset();
templateEntry.transChild.reset();
while (true) {
int userInput = 0;
heading("Lock Field -> Transaction Category");
show_fixed(templateEntry);
outArray(false, type_index);
cout << "Category? ";
userInput = inputNumber<int>(false, !bypass);
BYPASS_COMPULSORY_INPUT_NUMBER;
if ((userInput < props["presetLists"][type_index]["catList"].size()) && (userInput >= 0)) {
templateEntry.transCat.fix(
returnString(props["presetLists"][type_index]["catList"][userInput]["cat"]),
userInput);
break;
}
else {
cout << "Illegal action!" << endl;
system("pause");
continue;
}
}
}
void lockTransChild(bool bypass = false) {
templateEntry.transChild.reset();
int parentIndex = templateEntry.transCat.fixedIndex;
while (true) {
int userInput = -1;
heading("Lock Field -> Transaction Category -> Transaction");
show_fixed(templateEntry);
outArray(false, type_index, parentIndex);
cout << "Category Child? ";
userInput = inputNumber<int>(false, !bypass);
BYPASS_COMPULSORY_INPUT_NUMBER;
if ((userInput < props["presetLists"][type_index]["catList"][parentIndex]["child"].size()) && (userInput >= 0)) {
templateEntry.transChild.fix(
returnString(props["presetLists"][type_index]["catList"][parentIndex]["child"][userInput]["childName"]),
userInput);
break;
}
else {
cout << "Illegal action!" << endl;
system("pause");
continue;
}
}
}
void lockAccCat(bool bypass = false) {
templateEntry.accCat.reset();
templateEntry.accChild.reset();
while (true) {
int userInput = -1;
heading("Lock Field -> Transaction Account Category");
show_fixed(templateEntry);
outArray(true, 0);
cout << "Account Type? ";
userInput = inputNumber<int>(false, !bypass);
BYPASS_COMPULSORY_INPUT_NUMBER;
if ((userInput < props["presetLists"][0]["catList"].size()) && (userInput >= 0)) {
templateEntry.accCat.fix(
returnString(props["presetLists"][0]["catList"][userInput]["cat"]),
userInput);
break;
}
else {
cout << "Illegal action!" << endl;
system("pause");
continue;
}
}
}
void lockAccChild(bool bypass = false) {
templateEntry.accChild.reset();
int parentIndex = templateEntry.accCat.fixedIndex;
while (true) {
int userInput = -1;
heading("Lock Field -> Transaction Account Category -> Transaction Account");
show_fixed(templateEntry);
outArray(true, 0, parentIndex);
cout << "Account Child? ";
userInput = inputNumber<int>(false, !bypass);
BYPASS_COMPULSORY_INPUT_NUMBER;
if ((userInput < props["presetLists"][0]["catList"][parentIndex]["child"].size()) && (userInput >= 0)) {
templateEntry.accChild.fix(
returnString(props["presetLists"][0]["catList"][parentIndex]["child"][userInput]["childName"]),
userInput);
break;
}
else {
cout << "Illegal action!" << endl;
system("pause");
continue;
}
}
}
// Transfers
void lockTransferSourceCategory(bool bypass = false) {
templateEntry.sourceAccCat.reset();
templateEntry.sourceAccChild.reset();
while (true) {
int userInput = 0;
heading("Lock Field -> \"Transfer\" -> Source Account Category");
show_fixed(templateEntry);
outArray(true, 0);
cout << "Source Account Type? ";
userInput = inputNumber<int>(false, !bypass);
BYPASS_COMPULSORY_INPUT_NUMBER;
if ((userInput < props["presetLists"][0]["catList"].size()) && (userInput >= 0)) {
templateEntry.sourceAccCat.fix(
returnString(props["presetLists"][0]["catList"][userInput]["cat"]),
userInput);
break;
}
else {
cout << "Illegal action!" << endl;
system("pause");
continue;
}
}
}
void lockTransferSourceChild(bool bypass = false) {
templateEntry.sourceAccChild.reset();
int parentIndex = templateEntry.sourceAccCat.fixedIndex;
while (true) {
int userInput = 0;
heading("Lock Field -> \"Transfer\" -> Source Account Category -> Source Account");
show_fixed(templateEntry);
outArray(true, 0, parentIndex);
cout << "Source Account Child? ";
userInput = inputNumber<int>(false, !bypass);
BYPASS_COMPULSORY_INPUT_NUMBER;
if ((userInput < props["presetLists"][0]["catList"][parentIndex]["child"].size()) && (userInput >= 0)) {
templateEntry.sourceAccChild.fix(returnString(props["presetLists"][0]["catList"][parentIndex]["child"][userInput]["childName"]),
userInput);
break;
}
else {
cout << "Illegal action!" << endl;
system("pause");
continue;
}
}
}
void lockTransferDestinationCategory(bool bypass = false) {
templateEntry.destAccCat.reset();
templateEntry.destAccChild.reset();
while (true) {
int userInput = 0;
heading("Lock Field -> \"Transfer\" -> Destination Account Category");
show_fixed(templateEntry);
outArray(true, 0);
cout << "Destination Account Type? ";
userInput = inputNumber<int>(false, !bypass);
BYPASS_COMPULSORY_INPUT_NUMBER;
if ((userInput < props["presetLists"][0]["catList"].size()) && (userInput >= 0)) {
templateEntry.destAccCat.fix(
returnString(props["presetLists"][0]["catList"][userInput]["cat"]),
userInput);
break;
}
else {
cout << "Illegal action!" << endl;
system("pause");
continue;
}
}
}
void lockTransferDestinationChild(bool bypass = false) {
templateEntry.destAccChild.reset();
int parentIndex = templateEntry.destAccCat.fixedIndex;
while (true) {
int userInput = 0;
heading("Lock Field -> \"Transfer\" -> Destination Account Category -> Destination Account");
show_fixed(templateEntry);
outArray(true, 0, parentIndex);
cout << "Destination Account Child? ";
userInput = inputNumber<int>(false, !bypass);
BYPASS_COMPULSORY_INPUT_NUMBER;
if ((userInput < props["presetLists"][0]["catList"][userInput]["child"].size()) && (userInput >= 0)) {
templateEntry.destAccChild.fix(
returnString(props["presetLists"][0]["catList"][parentIndex]["child"][userInput]["childName"]),
userInput);
break;
}
else {
cout << "Illegal action!" << endl;
system("pause");
continue;
}
}
}
// Common
void lockYear(bool bypass = true) {
while (true) {
templateEntry.year.reset();
int userInput = 0;
heading("Lock Field -> Date-time -> Year");
show_fixed(templateEntry);
line(50, '-');
cout << "Year? ";
userInput = inputNumber<int>(false, !bypass);
BYPASS_COMPULSORY_INPUT_NUMBER;
if (userInput >= 1) {
templateEntry.year.fix(userInput);
break;
}
else {
cout << "Illegal action!" << endl;
system("pause");
continue;
}
}
}
void lockMonth(bool bypass = true) {
while (true) {
templateEntry.month.reset();
int userInput = 0;
heading("Lock Field -> Date-time -> Month");
show_fixed(templateEntry);
line(50, '-');
cout << "Month? ";
userInput = inputNumber<int>(false, false);
BYPASS_COMPULSORY_INPUT_NUMBER;
if (userInput >= 1 && userInput <= 12) {
templateEntry.month.fix(userInput);
break;
}
else {
cout << "Illegal action!" << endl;
system("pause");
continue;
}
}
}
void lockDay(bool bypass = true) {
while (true) {
templateEntry.day.reset();
int userInput = 0;
heading("Lock Field -> Date-time -> Day");
show_fixed(templateEntry);
line(50, '-');
cout << "Day? ";
userInput = inputNumber<int>(false, false);
BYPASS_COMPULSORY_INPUT_NUMBER;
if (userInput > 0 && userInput <= 31) {
templateEntry.day.fix(userInput);
break;
}
else {
cout << "Illegal action!" << endl;
system("pause");
continue;
}
}
}
void lockHour(bool bypass = true) {
while (true) {
templateEntry.hour.reset();
int userInput = 0;
heading("Lock Field -> Date-time -> Hour");
show_fixed(templateEntry);
line(50, '-');
cout << "Hour? ";
userInput = inputNumber<int>(false, false);
BYPASS_COMPULSORY_INPUT_NUMBER;
if (userInput >= 0 && userInput <= 23) {
templateEntry.hour.fix(userInput);
break;
}
else {
cout << "Illegal action!" << endl;
system("pause");
continue;
}
}
}
void lockMins(bool bypass = true) {
while (true) {
templateEntry.mins.reset();
int userInput = 0;
heading("Lock Field -> Date-time -> Minutes");
show_fixed(templateEntry);
line(50, '-');
cout << "Mins? ";
userInput = inputNumber<int>(false, false);
BYPASS_COMPULSORY_INPUT_NUMBER;
if (userInput >= 0 && userInput <= 59) {
templateEntry.mins.fix(userInput);
break;
}
else {
cout << "Illegal action!" << endl;
system("pause");
continue;
}
}
}
void dtInteractive() {
templateEntry.year.reset();
templateEntry.month.reset();
templateEntry.day.reset();
templateEntry.hour.reset();
templateEntry.mins.reset();
lockYear();
lockMonth();
lockDay();
lockHour();
lockMins();
}
void lockTitle(bool bypass = false) {
while (true) {
templateEntry.title.reset();
string userInput = "";
heading("Lock Field -> Title");
show_fixed(templateEntry);
line(50, '-');
cout << "Transaction title? " << endl << "> ";
getline(cin, userInput);
BYPASS_COMPULSORY_INPUT_STRING;
if ((userInput == "") && !bypass) {
cout << "Please insert a title." << endl;
pause();
continue;
}
else {
templateEntry.title.fix(userInput);
break;
}
}
}
void lockNotes(bool bypass = false) {
templateEntry.notes.reset();
heading("Lock Field -> Notes");
show_fixed(templateEntry);
line(50, '-');
cout << "Notes? (Multi-line available. Input \" to save and exit note-ing mode.)" << endl;
line(50, '-');
string userInput;
getline(cin, userInput, '\"');
BYPASS_COMPULSORY_INPUT_STRING;
templateEntry.notes.fix(userInput);
}
void lockStatus(bool bypass = false) {
while (true) {
templateEntry.status.reset();
string userInput = "";
heading("Lock Field -> Status");
show_fixed(templateEntry);
menuHeading();
cout << left << setw(5) << "R" << "Reconciled" << endl;
cout << left << setw(5) << "C" << "Cleared" << endl;
cout << left << setw(5) << "0" << "<None>" << endl;
cout << "Status? ";
getline(cin, userInput);
BYPASS_COMPULSORY_INPUT_STRING;
if (userInput == "R" || userInput == "r") {
templateEntry.status.fix('R');
break;
}
else if (userInput == "C" || userInput == "c") {
templateEntry.status.fix('C');
break;
}
else if (userInput == "0") {
templateEntry.status.fix('\0');
break;
}
else {
cout << "Illegal action!" << endl;
system("pause");
continue;
}
}
}
void lockAmount(bool bypass = false) {
while (true) {
templateEntry.amount.reset();
double userInput = 0;
heading("Lock Field -> Status");
show_fixed(templateEntry);
line(50, '-');
cout << "Amount? ";
userInput = inputNumber<double>(false);
BYPASS_COMPULSORY_INPUT_NUMBER;
templateEntry.amount.fix(userInput);
break;
}
}
// Option 0
void resetAll() {
ENTRY newEntry;
templateEntry = newEntry;
}
void interactiveMode() {
lockTransactionType(true);
if (type_index == 5) {
// Do transfer stuff
lockTransferSourceCategory();
if (templateEntry.sourceAccCat.isFixed) lockTransferSourceChild();
lockTransferDestinationCategory();
if (templateEntry.destAccCat.isFixed) lockTransferDestinationChild();
}
else if ((type_index == 1) || type_index == 2) {
// Do expenses or income stuff
lockTransCat();
if (templateEntry.transCat.isFixed) lockTransChild();
lockAccCat();
if (templateEntry.accCat.isFixed) lockAccChild();
}
dtInteractive();
lockTitle(true);
lockNotes(true);
lockAmount(true);
lockStatus(true);
}
ENTRY fixedEntryMenu(json myProperties, ENTRY entryTemplate) {
templateEntry = entryTemplate;
props = myProperties;
while (true) {
heading("Lock Field Menu");
show_fixed(templateEntry);
int selection = 0;
struct MENU {
int count = 0;
string content = "";
};
/*
0. Prompted, if "enter" without selecting anything means ignore / don't lock
1. type
-> If changed between expenses&income with transfers, transCat, transChild, accCat, accChild, sourceAccCat, sourceAccChild, destAccCat, destAccChild resets
-- Only show for non-transfers --
2. transCat
-> If transCat resets transChild resets too
21. transChild
-> Will show only after selecting transCat
3. accCat
->
31. accChild
-> Will only show after selecting accCat
----
-- Only show for transfers --
4. sourceAccCat
->
41. sourceAccChild
-> Will only show after selecting sourceAccCat
5. destAccCat
->
51. destAccChild
-> Will only show after selecting destAccCat
----
6. Input
-> Function to input datetime one by one, subfunction of "0"
61. year
62. month
63. day
64. hour
65. mins
7. title
71. notes
72. amount
8. status
*/
// Define menus
vector<MENU> menu;
templateEntry.is_anything_locked() ?
menu.push_back({ 0, "[!!!] Unlock everything" }) :
menu.push_back({ 0, "Interactive Lock, if \"enter\" without selecting anything means ignore / don't lock." });
// Menu entry for transaction type
templateEntry.type.isFixed ?
menu.push_back({ 1, "[!] Reset Transaction Type, Current: " + templateEntry.type.value }) :
menu.push_back({ 1, "Lock Transaction Type" });
// Show this section for expenses and income
if ((templateEntry.type.value == "Expense" && templateEntry.type.isFixed) ||
(templateEntry.type.value == "Income" && templateEntry.type.isFixed)) {
menu.push_back({ 0, "" });
// Option to lock transaction category & child if entry type is expense & income
if (templateEntry.transCat.isFixed) {
menu.push_back({ 2, "[!] Reset " + templateEntry.type.value + " Category, Current: " + templateEntry.transCat.value });
templateEntry.transChild.isFixed ?
menu.push_back({ 21, "[!] Reset " + templateEntry.type.value + " Category Child, Current: " + templateEntry.transChild.value }) :
menu.push_back({ 21, "Lock " + templateEntry.type.value + " Category Child" });
}
else {
menu.push_back({ 2, "Lock " + templateEntry.type.value + " Category" });
}
// Option to lock target account category & children type
if (templateEntry.accCat.isFixed) {
menu.push_back({ 3, "[!] Reset " + templateEntry.type.value + " Account Category, Current: " + templateEntry.accCat.value });
templateEntry.accChild.isFixed ?
menu.push_back({ 31, "[!] Reset " + templateEntry.type.value + " Account Category Child, Current: " + templateEntry.accChild.value }) :
menu.push_back({ 31, "Lock " + templateEntry.type.value + " Account Category Child" });
}
else {
menu.push_back({ 3, "Lock " + templateEntry.type.value + " Account Category" });
}
}
// Else show this for transfers
else if (templateEntry.type.value == "Transfer" && templateEntry.type.isFixed) {
menu.push_back({ 0, "" });
// Option to lock source account category & children type
if (templateEntry.sourceAccCat.isFixed) {
menu.push_back({ 4, "[!] Reset " + templateEntry.type.value + " Source Account Category, Current: " + templateEntry.sourceAccCat.value });
templateEntry.sourceAccChild.isFixed ?
menu.push_back({ 41, "[!] Reset " + templateEntry.type.value + " Source Account Category Child, Current: " + templateEntry.sourceAccChild.value }) :
menu.push_back({ 41, "Lock " + templateEntry.type.value + " Source Account Category Child" });
}
else {
menu.push_back({ 4, "Lock " + templateEntry.type.value + " Source Account Category" });
}
// Option to lock destination account category & children type
if (templateEntry.destAccCat.isFixed) {
menu.push_back({ 5, "[!] Reset " + templateEntry.type.value + " Destination Account Category, Current: " + templateEntry.destAccCat.value });
templateEntry.destAccChild.isFixed ?
menu.push_back({ 51, "[!] Reset " + templateEntry.type.value + " Destination Account Category Child, Current: " + templateEntry.destAccChild.value }) :
menu.push_back({ 51, "Lock " + templateEntry.type.value + " Destination Account Category Child" });
}
else {
menu.push_back({ 5, "Lock " + templateEntry.type.value + " Destination Account Category" });
}
}
menu.push_back({ 0, "" });
// Date time (Interactive)
templateEntry.is_dateTime_locked() ?
menu.push_back({ 6, "[!] Reset Datetime, Current: " + return_dt_string(templateEntry) }) :
menu.push_back({ 6, "Lock Datetime (Interactive)" });
templateEntry.year.isFixed ?
menu.push_back({ 61,
"[!] Reset Year, Current: " + return_fixed_digits(templateEntry.year.value, 4) }) :
menu.push_back({ 61, "Lock Year" });
templateEntry.month.isFixed ?
menu.push_back({ 62,
"[!] Reset Month, Current: " + return_fixed_digits(templateEntry.month.value, 2) }) :
menu.push_back({ 62, "Lock Month" });
templateEntry.day.isFixed ?
menu.push_back({ 63,
"[!] Reset Day, Current: " + return_fixed_digits(templateEntry.day.value) }) :
menu.push_back({ 63, "Lock Day" });
templateEntry.hour.isFixed ?
menu.push_back({ 64,
"[!] Reset Hour, Current: " + return_fixed_digits(templateEntry.hour.value) }) :
menu.push_back({ 64, "Lock Hour" });
templateEntry.mins.isFixed ?
menu.push_back({ 65,
"[!] Reset Minutes, Current: " + return_fixed_digits(templateEntry.mins.value) }) :
menu.push_back({ 65, "Lock Minutes" });
templateEntry.title.isFixed ?
menu.push_back({ 7, "[!] Reset Title, Current: " + templateEntry.title.value }) :
menu.push_back({ 7, "Lock Title" });
menu.push_back({ 0, "" });
templateEntry.notes.isFixed ?
menu.push_back({ 71, "[!] Reset Notes, Current: " + templateEntry.notes.value }) :
menu.push_back({ 71, "Lock Notes" });
templateEntry.amount.isFixed ?
menu.push_back({ 72, "[!] Reset Amount, Current: " + to_string(templateEntry.amount.value) }) :
menu.push_back({ 72, "Lock Amount" });
templateEntry.status.isFixed ?
menu.push_back({ 8, "[!] Reset Status, Current: " + templateEntry.status_text() }) :
menu.push_back({ 8, "Lock Status" });
menu.push_back({ 0, "" });
menu.push_back({ 9, "Exit to Main Menu" });
// Output menu.
menuHeading();
for (int j = 0; j < menu.size(); j++) {
if (menu[j].content != "") {
cout << left << setw(5) << menu[j].count << menu[j].content;
}
cout << endl;
}
selection = inputNumber<int>();
switch (selection)
{
case 0: { // Interactive Mode
templateEntry.is_anything_locked() ?
resetAll() : // Reset everything
interactiveMode(); // TODO: Enter interactive mode
break;
}
case 1: { // Transaction Type
if (templateEntry.type.isFixed) {
templateEntry.type.reset();
templateEntry.transCat.reset();
templateEntry.transChild.reset();
templateEntry.accCat.reset();
templateEntry.accChild.reset();
}
else {
lockTransactionType();
}
break;
}
case 2: { // Transaction Category ("Car")
// Reset if transCat is fixed
if (templateEntry.transCat.isFixed) {
templateEntry.transCat.reset();
templateEntry.transChild.reset();
break;
}
if (templateEntry.type.value == "Transfer") {
goto InvalidSelection;
}
else {
lockTransCat();
}
break;
}
case 21: { // Transaction Child ("Fuel")
// Reset if transChild is fixed
if (templateEntry.transChild.isFixed) {
templateEntry.transChild.reset();
break;
}
if ((templateEntry.type.value == "Transfer") || !templateEntry.transCat.isFixed) {
goto InvalidSelection;
}
else {
lockTransChild();
}
break;
}
case 3: {
// Reset if accCat is fixed
if (templateEntry.accCat.isFixed) {
templateEntry.accCat.reset();
templateEntry.accChild.reset();
break;
}
if (templateEntry.type.value == "Transfer") {
goto InvalidSelection;
}
else {
lockAccCat();
}
break;
}
case 31: {
// Reset if accCat is fixed
if (templateEntry.accChild.isFixed) {
templateEntry.accChild.reset();
break;
}
if ((templateEntry.type.value == "Transfer") || !templateEntry.accCat.isFixed) {
goto InvalidSelection;
}
else {
lockAccChild();
}
break;
}
case 4: {
// Reset if sourceAccCat is fixed
if (templateEntry.sourceAccCat.isFixed) {
templateEntry.sourceAccCat.reset();
templateEntry.sourceAccChild.reset();
break;
}
if (templateEntry.type.value != "Transfer") {
goto InvalidSelection;
}
else {
lockTransferSourceCategory();
}
break;
}
case 41: {
// Reset if sourceAccChild is fixed
if (templateEntry.sourceAccChild.isFixed) {
templateEntry.sourceAccChild.reset();
break;
}
if (templateEntry.type.value != "Transfer" || !templateEntry.sourceAccCat.isFixed) {
goto InvalidSelection;
}
else {
lockTransferSourceChild();
}
break;
}
case 5: {
// Reset if destAccCat is fixed
if (templateEntry.destAccCat.isFixed) {
templateEntry.destAccCat.reset();
templateEntry.destAccChild.reset();
break;
}
if (templateEntry.type.value != "Transfer") {
goto InvalidSelection;
}
else {
lockTransferDestinationCategory();
}
break;
}
case 51: {
// Reset if destAccChild is fixed
if (templateEntry.destAccChild.isFixed) {
templateEntry.destAccChild.reset();
break;
}
if (templateEntry.type.value != "Transfer" || !templateEntry.destAccChild.isFixed) {
goto InvalidSelection;
}
else {
lockTransferDestinationChild();
}
break;
}
case 6: { // Date-time interactive mode
// Reset if any datetime is fixed
if (templateEntry.is_dateTime_locked()) {
templateEntry.year.reset();
templateEntry.month.reset();
templateEntry.day.reset();
templateEntry.hour.reset();
templateEntry.mins.reset();
}
else {
dtInteractive();
}
break;
}
case 61: { // Lock year
templateEntry.year.isFixed ?
templateEntry.year.reset() :
lockYear();
break;
}
case 62: { // Lock month
templateEntry.month.isFixed ?
templateEntry.month.reset() :
lockMonth();
break;