-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added initial reports functionality... tests currently broken
- Loading branch information
Jordan Walsh
committed
Mar 14, 2017
1 parent
3edb1d0
commit 1661b87
Showing
5 changed files
with
113 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
var _ = require('lodash'), | ||
Entity = require('../entity'), | ||
logger = require('../../logger'); | ||
|
||
var ReportSchema = new Entity.SchemaObject({ | ||
ReportID: { type: String, toObject: 'always' }, | ||
ReportName: { type: String, toObject: 'always' }, | ||
ReportType: { type: String, toObject: 'always' }, | ||
ReportTitles: [ReportTitleSchema], | ||
ReportDate: { type: String, toObject: 'always' }, | ||
UpdatedDateUTC: { type: String, toObject: 'always' }, | ||
Rows: [ReportRowSchema] | ||
}); | ||
|
||
var ReportTitleSchema = new Entity.SchemaObject({ | ||
ReportTitle: { type: String, toObject: 'always' } | ||
}); | ||
|
||
var ReportRowSchema = new Entity.SchemaObject({ | ||
RowType: { type: String, toObject: 'always' }, | ||
Title: { type: String, toObject: 'always' }, | ||
Cells: [ReportCellSchema] | ||
}); | ||
|
||
var ReportCellSchema = new Entity.SchemaObject({ | ||
Value: { type: String, toObject: 'always' }, | ||
Attributes: [ReportAttributeSchema] | ||
}); | ||
|
||
var ReportAttributeSchema = new Entity.SchemaObject({ | ||
Value: { type: String, toObject: 'always' }, | ||
Id: { type: String, toObject: 'always' } | ||
}); | ||
|
||
var Report = Entity.extend(ReportSchema, { | ||
constructor: function(application, data, options) { | ||
logger.debug('Report::constructor'); | ||
this.Entity.apply(this, arguments); | ||
}, | ||
initialize: function(data, options) {}, | ||
fromXmlObj: function(obj) { | ||
var self = this; | ||
Object.assign(self, _.omit(obj, 'Rows', 'Cells')); | ||
if (obj.Rows) { | ||
_.each(obj.Rows.Row, function(row) { | ||
_.each(row.Cells.Cell, function(cell) { | ||
console.log(cell); | ||
}); | ||
self.Rows.push(row); | ||
}); | ||
} | ||
|
||
return this; | ||
} | ||
}); | ||
|
||
module.exports = Report; | ||
module.exports.ItemSchema = ReportSchema; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var _ = require('lodash'), | ||
logger = require('../../logger'), | ||
EntityHelper = require('../entity_helper'), | ||
Report = require('../../entities/accounting/report'), | ||
util = require('util') | ||
|
||
var Reports = EntityHelper.extend({ | ||
constructor: function(application, options) { | ||
EntityHelper.call(this, application, Object.assign({ entityName: 'Report', entityPlural: 'Reports' }, options)); | ||
}, | ||
create: function(data, options) { | ||
return new Report(this.application, data, options) | ||
}, | ||
generateReport: function(options) { | ||
var self = this; | ||
var clonedOptions = _.clone(options || {}); | ||
clonedOptions.entityConstructor = function(data) { return self.create(data) }; | ||
return this.getEntities(clonedOptions) | ||
.then(function(reports) { | ||
return _.first(reports); | ||
}); | ||
} | ||
}) | ||
|
||
module.exports = Reports; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters