1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2025-07-01 12:08:37 -04:00

reports: Allow drilling down

This commit is contained in:
2017-02-17 10:01:31 -05:00
parent 4d642d1772
commit b443963375
16 changed files with 250 additions and 82 deletions

View File

@ -399,16 +399,16 @@ Error.prototype.isError = function() {
function Series() {
this.Values = [];
this.Children = {};
this.Series = {};
}
Series.prototype.toJSONobj = function() {
var json_obj = {};
json_obj.Values = this.Values;
json_obj.Children = {};
for (var child in this.Children) {
if (this.Children.hasOwnProperty(child))
json_obj.Children[child] = this.Children[child].toJSONobj();
json_obj.Series = {};
for (var child in this.Series) {
if (this.Series.hasOwnProperty(child))
json_obj.Series[child] = this.Series[child].toJSONobj();
}
return json_obj;
}
@ -416,20 +416,20 @@ Series.prototype.toJSONobj = function() {
Series.prototype.fromJSONobj = function(json_obj) {
if (json_obj.hasOwnProperty("Values"))
this.Values = json_obj.Values;
if (json_obj.hasOwnProperty("Children")) {
for (var child in json_obj.Children) {
if (json_obj.Children.hasOwnProperty(child))
this.Children[child] = new Series();
this.Children[child].fromJSONobj(json_obj.Children[child]);
if (json_obj.hasOwnProperty("Series")) {
for (var child in json_obj.Series) {
if (json_obj.Series.hasOwnProperty(child))
this.Series[child] = new Series();
this.Series[child].fromJSONobj(json_obj.Series[child]);
}
}
}
Series.prototype.mapReduceChildren = function(mapFn, reduceFn) {
var children = {}
for (var child in this.Children) {
if (this.Children.hasOwnProperty(child))
children[child] = this.Children[child].mapReduce(mapFn, reduceFn);
for (var child in this.Series) {
if (this.Series.hasOwnProperty(child))
children[child] = this.Series[child].mapReduce(mapFn, reduceFn);
}
return children;
}
@ -441,9 +441,9 @@ Series.prototype.mapReduce = function(mapFn, reduceFn) {
else
childValues.push(this.Values.slice());
for (var child in this.Children) {
if (this.Children.hasOwnProperty(child))
childValues.push(this.Children[child].mapReduce(mapFn, reduceFn));
for (var child in this.Series) {
if (this.Series.hasOwnProperty(child))
childValues.push(this.Series[child].mapReduce(mapFn, reduceFn));
}
var reducedValues = [];
@ -466,8 +466,11 @@ function Report() {
this.YAxisLabel = "";
this.Labels = [];
this.Series = {};
this.FlattenedSeries = {};
}
Report.prototype.topLevelAccountName = "(top level)";
Report.prototype.toJSON = function() {
var json_obj = {};
json_obj.ReportId = this.ReportId;