-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11-records.js
More file actions
194 lines (178 loc) · 7.88 KB
/
Copy path11-records.js
File metadata and controls
194 lines (178 loc) · 7.88 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
import { keyInYNStrict } from "readline-sync";
import { accountingPage } from "./01-start.js";
import readlineSync from "readline-sync";
export default function recordsPage() {
// Başlangıçta toplam gelir, gider, alışverişler ve ödemeler
let income = 0; //gelirler
let expenses = 0; //giderlerl
let purchases = []; //alışverişler
let payments = []; //ödemeler
let incomeComment = [];
let expenseComment = [];
console.clear();
console.log(
"========================================================================================"
);
console.log(`
█████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗███╗ ██╗████████╗██╗███╗ ██╗ ██████╗
██╔══██╗██╔════╝██╔════╝██╔═══██╗██║ ██║████╗ ██║╚══██╔══╝██║████╗ ██║██╔════╝
███████║██║ ██║ ██║ ██║██║ ██║██╔██╗ ██║ ██║ ██║██╔██╗ ██║██║ ███╗
██╔══██║██║ ██║ ██║ ██║██║ ██║██║╚██╗██║ ██║ ██║██║╚██╗██║██║ ██║
██║ ██║╚██████╗╚██████╗╚██████╔╝╚██████╔╝██║ ╚████║ ██║ ██║██║ ╚████║╚██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ `);
console.log(
" Income and Expense Records "
);
console.log(
"========================================================================================"
);
function mainMenu() {
let choice = [];
do {
console.log(
"========================================================================================"
);
console.log(
"|| Select an action: ||"
);
console.log(
"|| 1 - Record Income ||"
);
console.log(
"|| 2 - Record Expense ||"
);
console.log(
"|| 3 - Record Purchase ||"
);
console.log(
"|| 4 - Record Payment ||"
);
console.log(
"|| 5 - Report ||"
);
console.log(
"|| 6 - Exit ||"
);
console.log(
"========================================================================================"
);
choice = readlineSync.questionInt("Make your choice: ");
if (choice === 1) {
console.clear();
console.log("===========================================");
console.log("|| Select an action: ||");
console.log("|| 1 - Record Income ||");
console.log("===========================================");
recordIncome();
} else if (choice === 2) {
console.clear();
console.log("===========================================");
console.log("|| Select an action: ||");
console.log("|| 2 - Record Expense ||");
console.log("===========================================");
recordExpense();
} else if (choice === 3) {
console.clear();
console.log("===========================================");
console.log("|| Select an action: ||");
console.log("|| 3 - Record Purchase ||");
console.log("===========================================");
recordPurchase();
} else if (choice === 4) {
console.clear();
console.log("===========================================");
console.log("|| Select an action: ||");
console.log("|| 4 - Record Payment ||");
console.log("===========================================");
recordPayment();
} else if (choice === 5) {
console.clear();
console.log("===========================================");
console.log("|| Select an action: ||");
console.log("|| 5 - Report ||");
console.log("===========================================");
generateReport();
} else if (choice === 6) {
console.clear();
console.log("Exiting...");
} else {
console.log("Invalid option!");
}
} while (choice !== 6);
}
mainMenu();
function recordIncome() {
//gelir
let commentIncome = readlineSync.question("Enter comment: ");
let incomeAmount = readlineSync.questionFloat("Enter income amount: ");
incomeComment.push({
commentIncome: commentIncome,
incomeAmount: incomeAmount,
});
income += incomeAmount;
}
function recordExpense() {
//gider
let commentExpense = readlineSync.question("Enter comment: ");
let expenseAmount = readlineSync.questionFloat("Enter expense amount: ");
expenseComment.push({
commentExpense: commentExpense,
expenseAmount: expenseAmount,
});
expenses += expenseAmount;
}
function recordPurchase() {
//satınalma
let companyName = readlineSync.question("Enter company name: ");
let product = readlineSync.question("Enter purchased product: ");
let amount = readlineSync.questionFloat("Enter purchase amount: ");
purchases.push({ company: companyName, product: product, amount: amount });
expenses += amount;
}
function recordPayment() {
//ödemeler
let companyName = readlineSync.question("Enter payment company name: ");
let amount = readlineSync.questionFloat("Enter payment amount: ");
payments.push({ company: companyName, payment: amount });
expenses += amount;
}
//--------------------------------------------Report--------------------------------
function generateReport() {
console.log(`Total Income: ${income} €`);
incomeComment.map((item) => {
console.log(
`Comment: ${item.commentIncome}, Amount: ${item.incomeAmount} € `
);
});
//---------------------------------------
console.log(`Total Expenses: ${expenses} €`);
expenseComment.map((item) => {
console.log(
`Comment: ${item.commentExpense}, Amount: ${item.expenseAmount} € `
);
});
//----------------------------------------------
console.log("Purchases: ");
purchases.map((item) => {
console.log(
`Company: ${item.company}, Product: ${item.product}, Amount: ${item.amount} €`
);
});
//-------------------------------------------------
console.log("Payments: ");
payments.map((item) => {
console.log(
`Company: ${item.company}, Payment Amount: ${item.payment} €`
);
console.log(`Cash on hand: ${income - expenses} €`);
//--------------------------------------------------------
});
}
//-----------------------------------------
const continueApp = keyInYNStrict("Do you want to return to the main menu?");
if (continueApp) {
accountingPage();
} else {
console.log("Exiting the application...");
}
}