1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2025-07-03 04:38:38 -04:00

Add basic transaction register support

This commit is contained in:
2015-08-05 21:25:25 -04:00
parent b1e5e26338
commit 4f61f9e74d
8 changed files with 577 additions and 37 deletions

View File

@ -212,8 +212,6 @@ Split.prototype.toJSONobj = function() {
}
Split.prototype.fromJSONobj = function(json_obj) {
var json_obj = getJSONObj(json_input);
if (json_obj.hasOwnProperty("SplitId"))
this.SplitId = json_obj.SplitId;
if (json_obj.hasOwnProperty("TransactionId"))
@ -243,6 +241,18 @@ const TransactionStatus = {
Reconciled: 3,
Voided: 4
}
var TransactionStatusList = [];
for (var type in TransactionStatus) {
if (TransactionStatus.hasOwnProperty(type)) {
TransactionStatusList.push({'StatusId': TransactionStatus[type], 'Name': type});
}
}
var TransactionStatusMap = {};
for (var status in TransactionStatus) {
if (TransactionStatus.hasOwnProperty(status)) {
TransactionStatusMap[TransactionStatus[status]] = status;
}
}
function Transaction() {
this.TransactionId = -1;
@ -262,8 +272,8 @@ Transaction.prototype.toJSON = function() {
json_obj.Date = this.Date.toJSON();
json_obj.Splits = [];
for (var i = 0; i < this.Splits.length; i++)
json_obj.push(this.Splits[i].toJSONobj());
return json_obj;
json_obj.Splits.push(this.Splits[i].toJSONobj());
return JSON.stringify(json_obj);
}
Transaction.prototype.fromJSON = function(json_input) {
@ -289,8 +299,11 @@ Transaction.prototype.fromJSON = function(json_input) {
this.Date = new Date(0);
}
if (json_obj.hasOwnProperty("Splits")) {
for (var i = 0; i < json_obj.Splits.length; i++)
this.Splits.push(this.Splits[i].fromJSON());
for (var i = 0; i < json_obj.Splits.length; i++) {
var s = new Split();
s.fromJSONobj(json_obj.Splits[i]);
this.Splits.push(s);
}
}
}
@ -300,6 +313,12 @@ Transaction.prototype.isTransaction = function() {
this.UserId != empty_transaction.UserId;
}
Transaction.prototype.deepCopy = function() {
var t = new Transaction();
t.fromJSON(this.toJSON());
return t;
}
function Error() {
this.ErrorId = -1;
this.ErrorString = "";