Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added various tests and updated sample app
- Loading branch information
Jordan Walsh
committed
Mar 6, 2017
1 parent
7e8a62d
commit 5f719b1
Showing
11 changed files
with
167 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
/coverage | ||
.nyc_output/ | ||
.DS_Store | ||
.vscode |
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,36 @@ | ||
var _ = require('lodash'), | ||
Entity = require('./entity'), | ||
logger = require('../logger'); | ||
|
||
var TaxRateSchema = new Entity.SchemaObject({ | ||
|
||
}); | ||
|
||
var TaxRate = Entity.extend(TaxRateSchema, { | ||
constructor: function(application, data, options) { | ||
logger.debug('TaxRate::constructor'); | ||
this.Entity.apply(this, arguments); | ||
}, | ||
initialize: function(data, options) {}, | ||
toXml: function() { | ||
var taxRate = _.omit(this.toObject()); | ||
return this.application.js2xml(taxRate, 'TaxRate'); | ||
}, | ||
save: function(options) { | ||
var self = this; | ||
var xml = '<TaxRates>' + this.toXml() + '</TaxRates>'; | ||
var path, method; | ||
if (this.TaxRateID) { | ||
path = 'Items/' + this.ItemID; | ||
method = 'post' | ||
} else { | ||
path = 'Items'; | ||
method = 'put' | ||
} | ||
return this.application.putOrPostEntity(method, path, xml, { entityPath: 'Items.Item', entityConstructor: function(data) { return self.application.core.items.newItem(data) } }); | ||
} | ||
}); | ||
|
||
|
||
module.exports = TaxRate; | ||
module.exports.TaxRateSchema = TaxRateSchema; |
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 |
---|---|---|
@@ -1,40 +1,33 @@ | ||
var _ = require('lodash') | ||
, logger = require('../logger') | ||
, EntityHelper = require('./entity_helper') | ||
, Employee = require('../entities/payroll_employee') | ||
, p = require('../misc/promise') | ||
, util = require('util') | ||
var _ = require('lodash'), | ||
logger = require('../logger'), | ||
EntityHelper = require('./entity_helper'), | ||
Employee = require('../entities/payroll_employee'), | ||
p = require('../misc/promise'), | ||
util = require('util') | ||
|
||
var Employees = EntityHelper.extend({ | ||
constructor: function (application, options) | ||
{ | ||
EntityHelper.call(this, application, _.extend({ entityName:'Employee', entityPlural:'Employees'}, options)); | ||
constructor: function(application, options) { | ||
EntityHelper.call(this, application, _.extend({ entityName: 'Employee', entityPlural: 'Employees' }, options)); | ||
}, | ||
newEmployee: function (data, options) | ||
{ | ||
newEmployee: function(data, options) { | ||
return new Employee(this.application, data, options) | ||
}, | ||
getEmployee: function (id, modifiedAfter,where, order) | ||
{ | ||
return this.getEmployees({ id: id, modifiedAfter: modifiedAfter, where: where, order: order}) | ||
.then(function (employees) | ||
{ | ||
getEmployee: function(id, modifiedAfter, where, order) { | ||
return this.getEmployees({ id: id, modifiedAfter: modifiedAfter, where: where, order: order }) | ||
.then(function(employees) { | ||
return _.first(employees); | ||
}) | ||
}, | ||
saveEmployees: function (employees, options) | ||
{ | ||
saveEmployees: function(employees, options) { | ||
// TO-DO | ||
// return this.saveEntities(employees, options) | ||
}, | ||
getEmployees: function (options) | ||
{ | ||
getEmployees: function(options) { | ||
var self = this; | ||
var clonedOptions = _.extend({},options, { api: 'payroll'}); | ||
clonedOptions.entityConstructor = function(data) { return self.newEmployee(data)}; | ||
var clonedOptions = _.extend({}, options, { api: 'payroll' }); | ||
clonedOptions.entityConstructor = function(data) { return self.newEmployee(data) }; | ||
return this.getEntities(clonedOptions) | ||
} | ||
}) | ||
|
||
module.exports = Employees; | ||
|
||
module.exports = Employees; |
Oops, something went wrong.