-
Notifications
You must be signed in to change notification settings - Fork 1
/
transaction.js
35 lines (31 loc) · 1.03 KB
/
transaction.js
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
function Transaction(transactionArray) {
if (transactionArray) {
console.log("transaction constructor 1 " + transactionArray);
this.transactionArray = JSON.parse(transactionArray);
} else {
console.log("transaction constructor 2 " + transactionArray);
this.transactionArray = [];
}
console.log("transaction constructor 3 " + this.transactionArray);
}
Transaction.prototype.getDateForIndex = function(index) {
return this.transactionArray[index].date;
}
Transaction.prototype.getNameForIndex = function(index) {
return this.transactionArray[index].name;
}
Transaction.prototype.getValueForIndex = function(index) {
return this.transactionArray[index].value;
}
Transaction.prototype.putNewTransaction = function(name, value) {
this.transactionArray.push({name:name, value:value, date:new Date()});
}
Transaction.prototype.getTransactionsLength = function()
{
return this.transactionArray.length;
}
Transaction.prototype.getTransactionArray = function()
{
return this.transactionArray;
}
module.exports = Transaction;