-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.js
More file actions
24 lines (22 loc) · 819 Bytes
/
Copy pathTransaction.js
File metadata and controls
24 lines (22 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class Transaction {
constructor(transactionType, amount, newBalance) {
const todaysDateAsString = (new Date()).toLocaleDateString('en-GB');
this.date = todaysDateAsString;
this.amount = amount.toFixed(2);
this.newBalance = newBalance.toFixed(2);
this.transactionType = transactionType;
}
format() {
let transactionData = "";
switch(this.transactionType) {
case "deposit":
transactionData = `${this.date} || ${this.amount} || || ${this.newBalance}`;
break;
case "withdrawal":
transactionData = `${this.date} || || ${this.amount} || ${this.newBalance}`;
break;
}
return transactionData;
}
}
module.exports = Transaction;