Skip to content

Commit 46179f6

Browse files
committed
Split Transaction Barebones Support
[Global] - [bool splitTransac] created for split transaction accommodation [int mainMenu()] - Added entry to toggle split entry status. - Remade main menu output logic - Added splitTransac status display if splitTransac is true - Deleted input filter for month, hour, mins [void writeToFile()] - Added logic for split transaction [int main()] - Increased version number - Added splitTransac toggle
1 parent 7b3c903 commit 46179f6

File tree

2 files changed

+49
-34
lines changed

2 files changed

+49
-34
lines changed

BluecoinsImportTool.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ int main() {
1717
readFile();
1818
}
1919

20-
cout << "Bluecoins Import Tool v1.1 by KwongTN" << endl;
20+
cout << "Bluecoins Import Tool v1.3 by KwongTN" << endl;
2121

2222
cout << endl;
2323
cout << "Json file path: \"" << jsonFilename << "\"" << endl;
@@ -88,6 +88,13 @@ int main() {
8888
system("pause");
8989
break;
9090
}
91+
// To toggle split transaction mode
92+
case 6:
93+
{
94+
splitTransac = !splitTransac;
95+
break;
96+
}
97+
9198
case 9:
9299
{
93100
cout << "Thank you for using. Throughout this session, you have: " << endl;

BluecoinsImportTool.h

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ using namespace std;
1616

1717
const int menusize = 10;
1818
const string defaultJsonFileName = "D:\\WinLibrary\\Documents\\GIT-Code\\Bluecoins-ImportTool\\Tests\\ktn.json";
19+
bool splitTransac = false;
1920

2021

2122
// Used to store all properties in the json file.
@@ -120,19 +121,32 @@ int mainMenu() {
120121
menu[4].count = 4;
121122
menu[4].content = "Input New Entry";
122123

124+
menu[6].count = 6;
125+
menu[6].content = "Toggle split entry status";
126+
123127
menu[9].count = 9;
124128
menu[9].content = "Exit";
125129

126130
// Output menu.
127131
attrib();
128-
for (int j = 0; j < menusize - 2; j++) {
129-
if (menu[j].content != "") {
130-
cout << left << setw(5) << menu[j].count << menu[j].content << endl;
132+
for (int j = 0; j < menusize; j++) {
133+
if (menu[j].content != "" && menu[j].count != 0) {
134+
cout << left << setw(5) << menu[j].count << menu[j].content;
131135
}
136+
cout << endl;
132137
}
138+
133139
cout << endl;
134-
cout << left << setw(5) << menu[menusize - 1].count << menu[menusize - 1].content << endl;
135-
cout << endl;
140+
141+
// To output the status of split transaction mode if there is.
142+
if (splitTransac) {
143+
line(50, '-', true);
144+
cout << "Split transaction mode : True" << endl;
145+
cout << "Do take note that split transction mode will be switched on until you manually toggle it off. Please make sure that the date, time and title are the same." << endl;
146+
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;
147+
line(50, '-', true);
148+
}
149+
136150
cout << "Your Selection? : ";
137151
cin >> selection;
138152

@@ -621,39 +635,21 @@ bool entryInput() {
621635
cin >> entry.year;
622636

623637
// User input : Month
624-
illegal = true;
625-
while (true) {
626-
cout << "Month? ";
627-
cin >> entry.month;
628-
if ((entry.month <= 12) && (entry.month > 0)) {
629-
illegal = false;
630-
}
631-
}
638+
cout << "Month? ";
639+
cin >> entry.month;
632640

633-
// User input : Day
641+
// User input : Day
634642
cout << "Day? ";
635643
cin >> entry.day;
636644

637645
// User input : Hour
638-
illegal = true;
639-
while (true) {
640-
cout << "Hour? ";
641-
cin >> entry.hour;
642-
if ((entry.hour < 23) && (entry.hour >= 0)) {
643-
illegal = false;
644-
}
645-
}
646+
cout << "Hour? ";
647+
cin >> entry.hour;
646648

647-
// User input : Mins
648-
illegal = true;
649-
while (true) {
650-
cout << "Mins? ";
651-
cin >> entry.mins;
652-
if ((entry.mins < 60) && (entry.mins >= 0)) {
653-
illegal = false;
654-
}
655-
}
656-
// ==================================================
649+
// User input : Mins
650+
cout << "Mins? ";
651+
cin >> entry.mins;
652+
// ==================================================
657653

658654
// User input : Amount
659655
system("cls");
@@ -840,7 +836,7 @@ void readFile(bool ignore = false) {
840836
void writeToFile() {
841837
// If user selects to append or is not first entry then will not output this line.
842838
if (!append) {
843-
file << "(1)Type,(2)Date,(3)Item or Payee,(4)Amount,(5)Parent Category,(6)Category,(7)Account Type,(8)Account,(9)Notes,(10) Label,(11) Status" << endl;
839+
file << "(1)Type,(2)Date,(3)Item or Payee,(4)Amount,(5)Parent Category,(6)Category,(7)Account Type,(8)Account,(9)Notes,(10) Label,(11) Status,(12) Split" << endl;
844840
}
845841

846842
// There are different logics for transfers and normal transactions.
@@ -865,6 +861,10 @@ void writeToFile() {
865861
if(entry.status != '\0'){
866862
file << entry.status;
867863
}
864+
file << ",";
865+
if (splitTransac) {
866+
file << "split";
867+
}
868868
file << endl;
869869
// Destination Account
870870
file << "Transfer" << ",";
@@ -886,6 +886,10 @@ void writeToFile() {
886886
if(entry.status != '\0'){
887887
file << entry.status;
888888
}
889+
file << ",";
890+
if (splitTransac) {
891+
file << "split";
892+
}
889893
file << endl;
890894

891895
} else { // For normal use cases.
@@ -909,6 +913,10 @@ void writeToFile() {
909913
if(entry.status != '\0'){
910914
file << entry.status;
911915
}
916+
file << ",";
917+
if (splitTransac) {
918+
file << "split";
919+
}
912920
file << endl;
913921

914922
}

0 commit comments

Comments
 (0)