diff --git a/lib/core.js b/lib/core.js
index 400d66fd..9942184e 100644
--- a/lib/core.js
+++ b/lib/core.js
@@ -23,7 +23,7 @@ function Core(application, options) {
this._application = application;
_.each(HELPERS, function(entityHelper, id) {
- var instance = new(require('./entity_helpers/' + entityHelper.file))(application);
+ var instance = new(require('./entity_helpers/accounting/' + entityHelper.file))(application);
Object.defineProperty(self, id, {
get: function() { return instance }
})
diff --git a/lib/entities/account.js b/lib/entities/accounting/account.js
similarity index 97%
rename from lib/entities/account.js
rename to lib/entities/accounting/account.js
index 2d002266..76ae6583 100644
--- a/lib/entities/account.js
+++ b/lib/entities/accounting/account.js
@@ -1,6 +1,6 @@
var _ = require('lodash'),
- Entity = require('./entity'),
- logger = require('../logger')
+ Entity = require('../entity'),
+ logger = require('../../logger')
var AccountSchema = new Entity.SchemaObject({
Code: { type: String, toObject: 'always' },
diff --git a/lib/entities/attachment.js b/lib/entities/accounting/attachment.js
similarity index 95%
rename from lib/entities/attachment.js
rename to lib/entities/accounting/attachment.js
index e2300b5f..493faaa6 100644
--- a/lib/entities/attachment.js
+++ b/lib/entities/accounting/attachment.js
@@ -1,6 +1,6 @@
var _ = require('lodash'),
- Entity = require('./entity'),
- logger = require('../logger'),
+ Entity = require('../entity'),
+ logger = require('../../logger'),
dateformat = require('dateformat'),
fs = require('fs')
diff --git a/lib/entities/banktransaction.js b/lib/entities/accounting/banktransaction.js
similarity index 96%
rename from lib/entities/banktransaction.js
rename to lib/entities/accounting/banktransaction.js
index c0677458..19908d4b 100644
--- a/lib/entities/banktransaction.js
+++ b/lib/entities/accounting/banktransaction.js
@@ -1,9 +1,9 @@
var _ = require('lodash'),
- Entity = require('./entity'),
- logger = require('../logger'),
+ Entity = require('../entity'),
+ logger = require('../../logger'),
ContactSchema = require('./contact').ContactSchema,
Contact = require('./contact'),
- LineItemSchema = require('./shared').LineItemSchema
+ LineItemSchema = require('../shared').LineItemSchema
var BankTransactionSchema = new Entity.SchemaObject({
Type: { type: String, toObject: 'always' },
diff --git a/lib/entities/banktransfer.js b/lib/entities/accounting/banktransfer.js
similarity index 94%
rename from lib/entities/banktransfer.js
rename to lib/entities/accounting/banktransfer.js
index ceb175b1..ac6ab147 100644
--- a/lib/entities/banktransfer.js
+++ b/lib/entities/accounting/banktransfer.js
@@ -1,9 +1,9 @@
var _ = require('lodash'),
- Entity = require('./entity'),
- logger = require('../logger'),
+ Entity = require('../entity'),
+ logger = require('../../logger'),
ContactSchema = require('./contact').ContactSchema,
Contact = require('./contact'),
- LineItemSchema = require('./shared').LineItemSchema
+ LineItemSchema = require('../shared').LineItemSchema
var BankTransferSchema = new Entity.SchemaObject({
FromBankAccount: {
diff --git a/lib/entities/contact.js b/lib/entities/accounting/contact.js
similarity index 95%
rename from lib/entities/contact.js
rename to lib/entities/accounting/contact.js
index 8e740224..f2968121 100644
--- a/lib/entities/contact.js
+++ b/lib/entities/accounting/contact.js
@@ -1,10 +1,10 @@
var _ = require('lodash'),
- Entity = require('./entity'),
- logger = require('../logger'),
- AddressSchema = require('./shared').AddressSchema,
- PhoneSchema = require('./shared').PhoneSchema,
- ContactPersonSchema = require('./shared').ContactPerson,
- PaymentTermSchema = require('./shared').PaymentTermSchema,
+ Entity = require('../entity'),
+ logger = require('../../logger'),
+ AddressSchema = require('../shared').AddressSchema,
+ PhoneSchema = require('../shared').PhoneSchema,
+ ContactPersonSchema = require('../shared').ContactPerson,
+ PaymentTermSchema = require('../shared').PaymentTermSchema,
dateformat = require('dateformat')
var BatchPaymentSchema = new Entity.SchemaObject({
diff --git a/lib/entities/invoice.js b/lib/entities/accounting/invoice.js
similarity index 97%
rename from lib/entities/invoice.js
rename to lib/entities/accounting/invoice.js
index fd8900ab..44c62c21 100644
--- a/lib/entities/invoice.js
+++ b/lib/entities/accounting/invoice.js
@@ -1,9 +1,9 @@
var _ = require('lodash'),
- Entity = require('./entity'),
- logger = require('../logger'),
+ Entity = require('../entity'),
+ logger = require('../../logger'),
ContactSchema = require('./contact').ContactSchema,
Contact = require('./contact'),
- PaymentSchema = require('./shared').PaymentSchema
+ PaymentSchema = require('../shared').PaymentSchema
var TrackingCategoryOptionsSchema = new Entity.SchemaObject({
TrackingCategoryID: { type: String, toObject: 'hasValue' },
diff --git a/lib/entities/item.js b/lib/entities/accounting/item.js
similarity index 96%
rename from lib/entities/item.js
rename to lib/entities/accounting/item.js
index 85b32190..129d6441 100644
--- a/lib/entities/item.js
+++ b/lib/entities/accounting/item.js
@@ -1,6 +1,6 @@
var _ = require('lodash'),
- Entity = require('./entity'),
- logger = require('../logger')
+ Entity = require('../entity'),
+ logger = require('../../logger');
var ItemDetailSchema = new Entity.SchemaObject({
UnitPrice: { type: Number, toObject: 'hasValue' },
diff --git a/lib/entities/journal.js b/lib/entities/accounting/journal.js
similarity index 96%
rename from lib/entities/journal.js
rename to lib/entities/accounting/journal.js
index 19ff7b6d..48defe6d 100644
--- a/lib/entities/journal.js
+++ b/lib/entities/accounting/journal.js
@@ -1,6 +1,6 @@
var _ = require('lodash'),
- Entity = require('./entity'),
- logger = require('../logger')
+ Entity = require('../entity'),
+ logger = require('../../logger');
var TrackingCategorySchema = new Entity.SchemaObject({
TrackingCategoryID: { type: String },
diff --git a/lib/entities/organisation.js b/lib/entities/accounting/organisation.js
similarity index 88%
rename from lib/entities/organisation.js
rename to lib/entities/accounting/organisation.js
index 7261be4e..121e47d2 100644
--- a/lib/entities/organisation.js
+++ b/lib/entities/accounting/organisation.js
@@ -1,10 +1,10 @@
var _ = require('lodash'),
- Entity = require('./entity'),
- logger = require('../logger'),
- AddressSchema = require('./shared').AddressSchema,
- PhoneSchema = require('./shared').PhoneSchema,
- ExternalLinkSchema = require('./shared').ExternalLinkSchema,
- PaymentTermSchema = require('./shared').PaymentTermSchema
+ Entity = require('../entity'),
+ logger = require('../../logger'),
+ AddressSchema = require('../shared').AddressSchema,
+ PhoneSchema = require('../shared').PhoneSchema,
+ ExternalLinkSchema = require('../shared').ExternalLinkSchema,
+ PaymentTermSchema = require('../shared').PaymentTermSchema
var OrganisationSchema = new Entity.SchemaObject({
APIKey: { type: String },
diff --git a/lib/entities/payment.js b/lib/entities/accounting/payment.js
similarity index 89%
rename from lib/entities/payment.js
rename to lib/entities/accounting/payment.js
index 6dda0164..650ca429 100644
--- a/lib/entities/payment.js
+++ b/lib/entities/accounting/payment.js
@@ -1,7 +1,7 @@
var _ = require('lodash'),
- Entity = require('./entity'),
- logger = require('../logger'),
- PaymentSchema = require('./shared').PaymentSchema
+ Entity = require('../entity'),
+ logger = require('../../logger'),
+ PaymentSchema = require('../shared').PaymentSchema
var Payment = Entity.extend(PaymentSchema, {
constructor: function(application, data, options) {
diff --git a/lib/entities/taxrate.js b/lib/entities/accounting/taxrate.js
similarity index 96%
rename from lib/entities/taxrate.js
rename to lib/entities/accounting/taxrate.js
index 84b5f7e9..7cab9dfb 100644
--- a/lib/entities/taxrate.js
+++ b/lib/entities/accounting/taxrate.js
@@ -1,6 +1,6 @@
var _ = require('lodash'),
- Entity = require('./entity'),
- logger = require('../logger');
+ Entity = require('../entity'),
+ logger = require('../../logger');
var TaxRateSchema = new Entity.SchemaObject({
Name: { type: String, toObject: 'always' },
diff --git a/lib/entities/trackingcategory.js b/lib/entities/accounting/trackingcategory.js
similarity index 96%
rename from lib/entities/trackingcategory.js
rename to lib/entities/accounting/trackingcategory.js
index 06996135..c12bbd77 100644
--- a/lib/entities/trackingcategory.js
+++ b/lib/entities/accounting/trackingcategory.js
@@ -1,7 +1,7 @@
var _ = require('lodash'),
- Entity = require('./entity'),
- logger = require('../logger'),
- TrackingOptionSchema = require('./shared').TrackingOptionSchema;
+ Entity = require('../entity'),
+ logger = require('../../logger'),
+ TrackingOptionSchema = require('../shared').TrackingOptionSchema;
var TrackingCategorySchema = new Entity.SchemaObject({
TrackingCategoryID: { type: String, toObject: 'always' },
diff --git a/lib/entities/accounting/trackingoption.js b/lib/entities/accounting/trackingoption.js
new file mode 100644
index 00000000..493faaa6
--- /dev/null
+++ b/lib/entities/accounting/trackingoption.js
@@ -0,0 +1,53 @@
+var _ = require('lodash'),
+ Entity = require('../entity'),
+ logger = require('../../logger'),
+ dateformat = require('dateformat'),
+ fs = require('fs')
+
+var AttachmentSchema = new Entity.SchemaObject({
+ AttachmentID: { type: String, toObject: 'never' },
+ FileName: { type: String, toObject: 'always' },
+ Url: { type: String, toObject: 'always' },
+ MimeType: { type: String, toObject: 'always' },
+ ContentLength: { type: Number, toObject: 'always' }
+});
+
+
+var Attachment = Entity.extend(AttachmentSchema, {
+ constructor: function(application, data, options) {
+ logger.debug('Attachment::constructor');
+ this.Entity.apply(this, arguments);
+ },
+ initialize: function(data, options) {},
+ getContent: function(ownerPath) {
+ return this.application.core.attachments.getContent(ownerPath, this.FileName);
+ },
+ save: function(ownerPath, streamOrFilePath) {
+ var self = this;
+ var path = ownerPath + '/Attachments/' + this.FileName;
+
+ var base64string = base64_encode(streamOrFilePath);
+ console.log(base64string);
+ console.log(path);
+
+ return this.application.postEntity(path, base64string, { type: this.MimeType })
+ .then(function(ret) {
+ console.log(ret);
+ return ret.response.Attachments.Attachment;
+ })
+ .catch(function(err) {
+ console.log(err);
+ })
+
+ function base64_encode(file) {
+ // read binary data
+ var bitmap = fs.readFileSync(file);
+ // convert binary data to base64 encoded string
+ return new Buffer(bitmap).toString('base64');
+ }
+ }
+});
+
+
+module.exports = Attachment;
+module.exports.AttachmentSchema = AttachmentSchema;
\ No newline at end of file
diff --git a/lib/entities/user.js b/lib/entities/accounting/user.js
similarity index 93%
rename from lib/entities/user.js
rename to lib/entities/accounting/user.js
index cc5e1ec5..2defb590 100644
--- a/lib/entities/user.js
+++ b/lib/entities/accounting/user.js
@@ -1,6 +1,6 @@
var _ = require('lodash'),
- Entity = require('./entity'),
- logger = require('../logger')
+ Entity = require('../entity'),
+ logger = require('../../logger');
var UserSchema = new Entity.SchemaObject({
UserID: {
diff --git a/lib/entities/payitems.js b/lib/entities/payroll/payitems.js
similarity index 97%
rename from lib/entities/payitems.js
rename to lib/entities/payroll/payitems.js
index efef58e6..da00c1ed 100644
--- a/lib/entities/payitems.js
+++ b/lib/entities/payroll/payitems.js
@@ -1,6 +1,6 @@
var _ = require('lodash'),
- Entity = require('./entity'),
- logger = require('../logger')
+ Entity = require('../entity'),
+ logger = require('../../logger')
var EarningTypeSchema = new Entity.SchemaObject({
EarningsType: { type: String },
diff --git a/lib/entities/payroll_employee.js b/lib/entities/payroll/payroll_employee.js
similarity index 98%
rename from lib/entities/payroll_employee.js
rename to lib/entities/payroll/payroll_employee.js
index 1a54f333..21f29e59 100644
--- a/lib/entities/payroll_employee.js
+++ b/lib/entities/payroll/payroll_employee.js
@@ -1,7 +1,7 @@
var _ = require('lodash'),
- Entity = require('./entity'),
- logger = require('../logger'),
- ExternalLinkSchema = require('./shared').ExternalLinkSchema
+ Entity = require('../entity'),
+ logger = require('../../logger'),
+ ExternalLinkSchema = require('../shared').ExternalLinkSchema
var AddressSchema = new Entity.SchemaObject({
StreetAddress: { type: String },
diff --git a/lib/entities/payroll/timesheet.js b/lib/entities/payroll/timesheet.js
new file mode 100644
index 00000000..7fae2135
--- /dev/null
+++ b/lib/entities/payroll/timesheet.js
@@ -0,0 +1,85 @@
+var _ = require('lodash'),
+ Entity = require('../entity'),
+ logger = require('../../logger')
+
+
+var TimesheetLineSchema = new Entity.SchemaObject({
+ EarningsTypeID: { type: String },
+ TrackingItemID: { type: String },
+ NumberOfUnits: { type: Array, arrayType: Number, toObject: 'always' }
+});
+
+var TimesheetSchema = new Entity.SchemaObject({
+ EmployeeID: { type: String, toObject: 'hasValue' },
+ StartDate: { type: Date, toObjectTransform: Entity.dateToString, toObject: 'hasValue' },
+ EndDate: { type: Date, toObjectTransform: Entity.dateToString, toObject: 'hasValue' },
+ TimesheetLines: { type: Array, arrayType: TimesheetLineSchema, toObject: 'always' },
+ Status: { type: String, toObject: 'hasValue' },
+ TimesheetID: { type: String, toObject: 'hasValue' },
+ Hours: { type: Number, toObject: 'hasValue' }
+});
+
+var Timesheet = Entity.extend(TimesheetSchema, {
+ constructor: function(application, data, options) {
+ logger.debug('Timesheet::constructor');
+ this.Entity.apply(this, arguments);
+ },
+ initialize: function(data, options) {},
+ changes: function(options) {
+ return this._super(options);
+ },
+ _toObject: function(options) {
+ return this._super(options);
+ },
+ fromXmlObj: function(obj) {
+ var self = this;
+ Object.assign(self, _.omit(obj, 'TimesheetLines'));
+ if (obj.TimesheetLines) {
+ var items = this.application.asArray(obj.TimesheetLines.TimesheetLine);
+ _.each(items, function(item) {
+
+ var index = self.TimesheetLines.push({ EarningsTypeID: item.EarningsTypeID }) - 1;
+ var addedNumberOfUnit = self.TimesheetLines[index];
+ _.each(item.NumberOfUnits.NumberOfUnit, function(unit) {
+ addedNumberOfUnit.NumberOfUnits.push(unit);
+ })
+
+ })
+ }
+
+ return this;
+ },
+ toXml: function() {
+ var timesheet = _.omit(this.toObject(), 'TimesheetLines');
+ Object.assign(timesheet, { TimesheetLines: [] });
+ _.forEach(this.TimesheetLines, function(timesheetline) {
+ timesheet.TimesheetLines.push({ TimesheetLine: _.pick(timesheetline.toObject(), 'EarningsTypeID', 'TrackingItemID') });
+ var addedTimesheetLine = _.last(timesheet.TimesheetLines).TimesheetLine;
+ addedTimesheetLine.NumberOfUnits = { NumberOfUnit: [] };
+ _.each(timesheetline.NumberOfUnits, function(num) {
+ addedTimesheetLine.NumberOfUnits.NumberOfUnit.push(num);
+ })
+
+ })
+
+ return this.application.js2xml(timesheet, 'Timesheet');
+ },
+ save: function(options) {
+ var self = this
+ var xml = '' + this.toXml() + '';
+ var path, method;
+ if (this.TimesheetID) {
+ path = 'Timesheets/' + this.TimesheetID;
+ method = 'post'
+ } else {
+ path = 'Timesheets';
+ method = 'post'
+ }
+ return this.application.putOrPostEntity(method, path, xml, { entityPath: 'Timesheets.Timesheet', entityConstructor: function(data) { return self.application.payroll.timesheets.newTimesheet(data) }, api: 'payroll' });
+ }
+
+});
+
+
+module.exports = Timesheet;
+module.exports.TimesheetSchema = TimesheetSchema;
\ No newline at end of file
diff --git a/lib/entities/timesheet.js b/lib/entities/timesheet.js
deleted file mode 100644
index 37f32430..00000000
--- a/lib/entities/timesheet.js
+++ /dev/null
@@ -1,100 +0,0 @@
-var _ = require('lodash')
- , Entity = require('./entity')
- , logger = require('../logger')
-
-
-var TimesheetLineSchema = new Entity.SchemaObject({
- EarningsTypeID: {type: String},
- TrackingItemID: {type: String},
- NumberOfUnits: {type: Array, arrayType: Number, toObject: 'always'}
-});
-
-var TimesheetSchema = new Entity.SchemaObject({
- EmployeeID: {type: String, toObject: 'hasValue'},
- StartDate: {type: Date, toObjectTransform: Entity.dateToString,toObject: 'hasValue'},
- EndDate: {type: Date, toObjectTransform: Entity.dateToString,toObject: 'hasValue'},
- TimesheetLines: {type: Array, arrayType: TimesheetLineSchema, toObject: 'always'},
- Status: {type: String, toObject: 'hasValue'},
- TimesheetID: {type: String, toObject: 'hasValue'},
- Hours: {type: Number, toObject: 'hasValue'}
-});
-
-var Timesheet = Entity.extend(TimesheetSchema, {
- constructor: function (application, data, options)
- {
- logger.debug('Timesheet::constructor');
- this.Entity.apply(this, arguments);
- },
- initialize: function (data, options)
- {
- },
- changes: function (options)
- {
- return this._super(options);
- },
- _toObject: function (options)
- {
- return this._super(options);
- },
- fromXmlObj: function (obj)
- {
- var self = this;
- Object.assign(self, _.omit(obj, 'TimesheetLines'));
- if (obj.TimesheetLines) {
- var items = this.application.asArray(obj.TimesheetLines.TimesheetLine);
- _.each(items,function(item)
- {
-
- var index = self.TimesheetLines.push({ EarningsTypeID: item.EarningsTypeID}) - 1;
- var addedNumberOfUnit = self.TimesheetLines[index];
- _.each(item.NumberOfUnits.NumberOfUnit, function(unit)
- {
- addedNumberOfUnit.NumberOfUnits.push(unit);
- })
-
- })
- }
-
- return this;
- },
- toXml: function ()
- {
- var timesheet = _.omit(this.toObject(), 'TimesheetLines');
- Object.assign(timesheet, { TimesheetLines: []});
- _.forEach(this.TimesheetLines, function(timesheetline)
- {
- timesheet.TimesheetLines.push({ TimesheetLine: _.pick(timesheetline.toObject(),'EarningsTypeID','TrackingItemID')});
- var addedTimesheetLine = _.last(timesheet.TimesheetLines).TimesheetLine;
- addedTimesheetLine.NumberOfUnits = { NumberOfUnit: []};
- _.each(timesheetline.NumberOfUnits, function(num)
- {
- addedTimesheetLine.NumberOfUnits.NumberOfUnit.push(num);
- })
-
- })
-
- return this.application.js2xml(timesheet, 'Timesheet');
- },
- save:function(options)
- {
- var self = this
- var xml = '' + this.toXml() + '';
- var path, method;
- if (this.TimesheetID)
- {
- path = 'Timesheets/' + this.TimesheetID;
- method = 'post'
- }
- else
- {
- path = 'Timesheets';
- method = 'post'
- }
- return this.application.putOrPostEntity(method, path, xml, { entityPath: 'Timesheets.Timesheet',entityConstructor: function(data) { return self.application.payroll.timesheets.newTimesheet(data)}, api: 'payroll'});
- }
-
-});
-
-
-module.exports = Timesheet;
-module.exports.TimesheetSchema = TimesheetSchema;
diff --git a/lib/entities/trackingoption.js b/lib/entities/trackingoption.js
deleted file mode 100644
index 01bb9fe2..00000000
--- a/lib/entities/trackingoption.js
+++ /dev/null
@@ -1,23 +0,0 @@
-var _ = require('lodash'),
- Entity = require('./entity'),
- logger = require('../logger'),
- TrackingOptionSchema = require('./shared').TrackingOptionSchema;
-
-var TrackingOption = Entity.extend(TrackingOptionSchema, {
- constructor: function(application, data, options) {
- logger.debug('TrackingOption::constructor');
- this.Entity.apply(this, arguments);
- },
- initialize: function(data, options) {},
- changes: function(options) {
- return this._super(options);
- },
- _toObject: function(options) {
- return this._super(options);
- },
- delete: function() {
- return this.deleteEntities({ id: this.TrackingOptionID });
- }
-});
-
-module.exports = TrackingOption;
\ No newline at end of file
diff --git a/lib/entity_helpers/accounts.js b/lib/entity_helpers/accounting/accounts.js
similarity index 86%
rename from lib/entity_helpers/accounts.js
rename to lib/entity_helpers/accounting/accounts.js
index 7389ff7d..e50950b8 100644
--- a/lib/entity_helpers/accounts.js
+++ b/lib/entity_helpers/accounting/accounts.js
@@ -1,7 +1,7 @@
var _ = require('lodash'),
- logger = require('../logger'),
- EntityHelper = require('./entity_helper'),
- Account = require('../entities/account'),
+ logger = require('../../logger'),
+ EntityHelper = require('../entity_helper'),
+ Account = require('../../entities/accounting/account'),
util = require('util')
var Accounts = EntityHelper.extend({
@@ -34,4 +34,4 @@ var Accounts = EntityHelper.extend({
}
})
-module.exports = Accounts;
+module.exports = Accounts;
\ No newline at end of file
diff --git a/lib/entity_helpers/attachments.js b/lib/entity_helpers/accounting/attachments.js
similarity index 84%
rename from lib/entity_helpers/attachments.js
rename to lib/entity_helpers/accounting/attachments.js
index f6e8d9f8..9ef5edc1 100644
--- a/lib/entity_helpers/attachments.js
+++ b/lib/entity_helpers/accounting/attachments.js
@@ -1,7 +1,7 @@
var _ = require('lodash'),
- logger = require('../logger'),
- EntityHelper = require('./entity_helper'),
- Attachment = require('../entities/attachment'),
+ logger = require('../../logger'),
+ EntityHelper = require('../entity_helper'),
+ Attachment = require('../../entities/accounting/attachment'),
util = require('util')
var Attachments = EntityHelper.extend({
@@ -25,4 +25,4 @@ var Attachments = EntityHelper.extend({
}
})
-module.exports = Attachments;
+module.exports = Attachments;
\ No newline at end of file
diff --git a/lib/entity_helpers/banktransactions.js b/lib/entity_helpers/accounting/banktransactions.js
similarity index 85%
rename from lib/entity_helpers/banktransactions.js
rename to lib/entity_helpers/accounting/banktransactions.js
index e8d046eb..5983b912 100644
--- a/lib/entity_helpers/banktransactions.js
+++ b/lib/entity_helpers/accounting/banktransactions.js
@@ -1,7 +1,7 @@
var _ = require('lodash'),
- logger = require('../logger'),
- EntityHelper = require('./entity_helper'),
- BankTransaction = require('../entities/banktransaction'),
+ logger = require('../../logger'),
+ EntityHelper = require('../entity_helper'),
+ BankTransaction = require('../../entities/accounting/banktransaction'),
util = require('util')
var BankTransactions = EntityHelper.extend({
@@ -31,4 +31,4 @@ var BankTransactions = EntityHelper.extend({
}
})
-module.exports = BankTransactions;
+module.exports = BankTransactions;
\ No newline at end of file
diff --git a/lib/entity_helpers/banktransfers.js b/lib/entity_helpers/accounting/banktransfers.js
similarity index 85%
rename from lib/entity_helpers/banktransfers.js
rename to lib/entity_helpers/accounting/banktransfers.js
index 9f8da4ab..dd0fd1cf 100644
--- a/lib/entity_helpers/banktransfers.js
+++ b/lib/entity_helpers/accounting/banktransfers.js
@@ -1,7 +1,7 @@
var _ = require('lodash'),
- logger = require('../logger'),
- EntityHelper = require('./entity_helper'),
- BankTransfer = require('../entities/banktransfer'),
+ logger = require('../../logger'),
+ EntityHelper = require('../entity_helper'),
+ BankTransfer = require('../../entities/accounting/banktransfer'),
util = require('util')
var BankTransfers = EntityHelper.extend({
@@ -31,4 +31,4 @@ var BankTransfers = EntityHelper.extend({
}
})
-module.exports = BankTransfers;
+module.exports = BankTransfers;
\ No newline at end of file
diff --git a/lib/entity_helpers/contacts.js b/lib/entity_helpers/accounting/contacts.js
similarity index 86%
rename from lib/entity_helpers/contacts.js
rename to lib/entity_helpers/accounting/contacts.js
index d12b677a..65fcf0a5 100644
--- a/lib/entity_helpers/contacts.js
+++ b/lib/entity_helpers/accounting/contacts.js
@@ -1,7 +1,7 @@
var _ = require('lodash'),
- logger = require('../logger'),
- EntityHelper = require('./entity_helper'),
- Contact = require('../entities/contact'),
+ logger = require('../../logger'),
+ EntityHelper = require('../entity_helper'),
+ Contact = require('../../entities/accounting/contact'),
util = require('util')
var Contacts = EntityHelper.extend({
@@ -32,4 +32,4 @@ var Contacts = EntityHelper.extend({
}
})
-module.exports = Contacts;
+module.exports = Contacts;
\ No newline at end of file
diff --git a/lib/entity_helpers/invoices.js b/lib/entity_helpers/accounting/invoices.js
similarity index 89%
rename from lib/entity_helpers/invoices.js
rename to lib/entity_helpers/accounting/invoices.js
index ddf82c24..f41ef55c 100644
--- a/lib/entity_helpers/invoices.js
+++ b/lib/entity_helpers/accounting/invoices.js
@@ -1,7 +1,7 @@
var _ = require('lodash'),
- logger = require('../logger'),
- EntityHelper = require('./entity_helper'),
- Invoice = require('../entities/invoice'),
+ logger = require('../../logger'),
+ EntityHelper = require('../entity_helper'),
+ Invoice = require('../../entities/accounting/invoice'),
util = require('util')
var Invoices = EntityHelper.extend({
@@ -38,4 +38,4 @@ var Invoices = EntityHelper.extend({
}
})
-module.exports = Invoices;
+module.exports = Invoices;
\ No newline at end of file
diff --git a/lib/entity_helpers/items.js b/lib/entity_helpers/accounting/items.js
similarity index 85%
rename from lib/entity_helpers/items.js
rename to lib/entity_helpers/accounting/items.js
index 3f1f3b5d..9492c651 100644
--- a/lib/entity_helpers/items.js
+++ b/lib/entity_helpers/accounting/items.js
@@ -1,7 +1,7 @@
var _ = require('lodash'),
- logger = require('../logger'),
- EntityHelper = require('./entity_helper'),
- Item = require('../entities/item'),
+ logger = require('../../logger'),
+ EntityHelper = require('../entity_helper'),
+ Item = require('../../entities/accounting/item'),
util = require('util')
var Items = EntityHelper.extend({
@@ -31,4 +31,4 @@ var Items = EntityHelper.extend({
}
})
-module.exports = Items;
+module.exports = Items;
\ No newline at end of file
diff --git a/lib/entity_helpers/journals.js b/lib/entity_helpers/accounting/journals.js
similarity index 92%
rename from lib/entity_helpers/journals.js
rename to lib/entity_helpers/accounting/journals.js
index 0ba7c671..1b8b5219 100644
--- a/lib/entity_helpers/journals.js
+++ b/lib/entity_helpers/accounting/journals.js
@@ -1,7 +1,7 @@
var _ = require('lodash'),
- logger = require('../logger'),
- EntityHelper = require('./entity_helper'),
- Journal = require('../entities/journal'),
+ logger = require('../../logger'),
+ EntityHelper = require('../entity_helper'),
+ Journal = require('../../entities/accounting/journal'),
util = require('util')
var Journals = EntityHelper.extend({
@@ -59,4 +59,4 @@ var Journals = EntityHelper.extend({
}
})
-module.exports = Journals;
+module.exports = Journals;
\ No newline at end of file
diff --git a/lib/entity_helpers/organisations.js b/lib/entity_helpers/accounting/organisations.js
similarity index 83%
rename from lib/entity_helpers/organisations.js
rename to lib/entity_helpers/accounting/organisations.js
index c643114b..f66ba677 100644
--- a/lib/entity_helpers/organisations.js
+++ b/lib/entity_helpers/accounting/organisations.js
@@ -1,7 +1,7 @@
var _ = require('lodash'),
- logger = require('../logger'),
- EntityHelper = require('./entity_helper'),
- Organisation = require('../entities/organisation'),
+ logger = require('../../logger'),
+ EntityHelper = require('../entity_helper'),
+ Organisation = require('../../entities/accounting/organisation'),
util = require('util')
var Organisations = EntityHelper.extend({
@@ -27,4 +27,4 @@ var Organisations = EntityHelper.extend({
}
})
-module.exports = Organisations;
+module.exports = Organisations;
\ No newline at end of file
diff --git a/lib/entity_helpers/payments.js b/lib/entity_helpers/accounting/payments.js
similarity index 83%
rename from lib/entity_helpers/payments.js
rename to lib/entity_helpers/accounting/payments.js
index 10f93256..e59e246a 100644
--- a/lib/entity_helpers/payments.js
+++ b/lib/entity_helpers/accounting/payments.js
@@ -1,7 +1,7 @@
var _ = require('lodash'),
- logger = require('../logger'),
- EntityHelper = require('./entity_helper'),
- Payment = require('../entities/payment'),
+ logger = require('../../logger'),
+ EntityHelper = require('../entity_helper'),
+ Payment = require('../../entities/accounting/payment'),
util = require('util')
var Payments = EntityHelper.extend({
@@ -25,4 +25,4 @@ var Payments = EntityHelper.extend({
}
})
-module.exports = Payments;
+module.exports = Payments;
\ No newline at end of file
diff --git a/lib/entity_helpers/taxrates.js b/lib/entity_helpers/accounting/taxrates.js
similarity index 82%
rename from lib/entity_helpers/taxrates.js
rename to lib/entity_helpers/accounting/taxrates.js
index 41a727ef..809800a8 100644
--- a/lib/entity_helpers/taxrates.js
+++ b/lib/entity_helpers/accounting/taxrates.js
@@ -1,7 +1,7 @@
var _ = require('lodash'),
- logger = require('../logger'),
- EntityHelper = require('./entity_helper'),
- TaxRate = require('../entities/taxrate'),
+ logger = require('../../logger'),
+ EntityHelper = require('../entity_helper'),
+ TaxRate = require('../../entities/accounting/taxrate'),
util = require('util')
var TaxRates = EntityHelper.extend({
@@ -23,4 +23,4 @@ var TaxRates = EntityHelper.extend({
}
})
-module.exports = TaxRates;
+module.exports = TaxRates;
\ No newline at end of file
diff --git a/lib/entity_helpers/trackingcategories.js b/lib/entity_helpers/accounting/trackingcategories.js
similarity index 83%
rename from lib/entity_helpers/trackingcategories.js
rename to lib/entity_helpers/accounting/trackingcategories.js
index 412d0930..f9ed5e56 100644
--- a/lib/entity_helpers/trackingcategories.js
+++ b/lib/entity_helpers/accounting/trackingcategories.js
@@ -1,8 +1,8 @@
var _ = require('lodash'),
- logger = require('../logger'),
- EntityHelper = require('./entity_helper'),
- TrackingCategory = require('../entities/trackingcategory'),
- TrackingOption = require('../entities/trackingoption.js'),
+ logger = require('../../logger'),
+ EntityHelper = require('../entity_helper'),
+ TrackingCategory = require('../../entities/accounting/trackingcategory'),
+ TrackingOption = require('../../entities/accounting/trackingoption'),
util = require('util')
var TrackingCategories = EntityHelper.extend({
@@ -36,4 +36,4 @@ var TrackingCategories = EntityHelper.extend({
}
})
-module.exports = TrackingCategories;
+module.exports = TrackingCategories;
\ No newline at end of file
diff --git a/lib/entity_helpers/users.js b/lib/entity_helpers/accounting/users.js
similarity index 86%
rename from lib/entity_helpers/users.js
rename to lib/entity_helpers/accounting/users.js
index 414f59ff..c4cf3c6c 100644
--- a/lib/entity_helpers/users.js
+++ b/lib/entity_helpers/accounting/users.js
@@ -1,7 +1,7 @@
var _ = require('lodash'),
- logger = require('../logger'),
- EntityHelper = require('./entity_helper'),
- User = require('../entities/user'),
+ logger = require('../../logger'),
+ EntityHelper = require('../entity_helper'),
+ User = require('../../entities/accounting/user'),
util = require('util')
var Users = EntityHelper.extend({
@@ -30,4 +30,4 @@ var Users = EntityHelper.extend({
}
})
-module.exports = Users;
+module.exports = Users;
\ No newline at end of file
diff --git a/lib/entity_helpers/payitems.js b/lib/entity_helpers/payitems.js
deleted file mode 100644
index e88ac005..00000000
--- a/lib/entity_helpers/payitems.js
+++ /dev/null
@@ -1,52 +0,0 @@
-var _ = require('lodash')
- , logger = require('../logger')
- , EntityHelper = require('./entity_helper')
- , PayItemsObject = require('../entities/payitems')
- , EarningsType = require('../entities/payitems').EarningsType
- , BenefitType = require('../entities/payitems').BenefitType
- , DeductionType = require('../entities/payitems').DeductionType
- , ReimbursementType = require('../entities/payitems').ReimbursementType
- , TimeOffType = require('../entities/payitems').TimeOffType
- , util = require('util')
-
-var PayItems = EntityHelper.extend({
- constructor: function (application, options)
- {
- EntityHelper.call(this, application, Object.assign({
- entityPlural: 'PayItems', path: 'Payitems'}, options));
- },
- newPayItems: function(data, options)
- {
- return new PayItemsObject(this.application, data, options)
- },
- newEarningType: function (data, options)
- {
- return new EarningsType(this.application, data, options)
- },
- newDeductionType: function (data, options)
- {
- return new DeductionType(this.application, data, options)
- },
- newBenefitType: function (data, options)
- {
- return new BenefitType(this.application, data, options)
- },
- newReimbursementType: function (data, options)
- {
- return new ReimbursementType(this.application, data, options)
- },
- newTimeOffType: function (data, options)
- {
- return new TimeOffType(this.application, data, options)
- },
- getPayItems: function (options)
- {
- var self = this;
- var clonedOptions = Object.assign({},options, { api: 'payroll'});
- clonedOptions.entityConstructor = function(data) { return self.newPayItems(data)};
- return this.getEntities(clonedOptions)
- }
-})
-
-module.exports = PayItems;
-
diff --git a/lib/entity_helpers/payroll/payitems.js b/lib/entity_helpers/payroll/payitems.js
new file mode 100644
index 00000000..7d374869
--- /dev/null
+++ b/lib/entity_helpers/payroll/payitems.js
@@ -0,0 +1,45 @@
+var _ = require('lodash'),
+ logger = require('../../logger'),
+ EntityHelper = require('../entity_helper'),
+ PayItemsObject = require('../../entities/payroll/payitems'),
+ EarningsType = require('../../entities/payroll/payitems').EarningsType,
+ BenefitType = require('../../entities/payroll/payitems').BenefitType,
+ DeductionType = require('../../entities/payroll/payitems').DeductionType,
+ ReimbursementType = require('../../entities/payroll/payitems').ReimbursementType,
+ TimeOffType = require('../../entities/payroll/payitems').TimeOffType,
+ util = require('util')
+
+var PayItems = EntityHelper.extend({
+ constructor: function(application, options) {
+ EntityHelper.call(this, application, Object.assign({
+ entityPlural: 'PayItems',
+ path: 'Payitems'
+ }, options));
+ },
+ newPayItems: function(data, options) {
+ return new PayItemsObject(this.application, data, options)
+ },
+ newEarningType: function(data, options) {
+ return new EarningsType(this.application, data, options)
+ },
+ newDeductionType: function(data, options) {
+ return new DeductionType(this.application, data, options)
+ },
+ newBenefitType: function(data, options) {
+ return new BenefitType(this.application, data, options)
+ },
+ newReimbursementType: function(data, options) {
+ return new ReimbursementType(this.application, data, options)
+ },
+ newTimeOffType: function(data, options) {
+ return new TimeOffType(this.application, data, options)
+ },
+ getPayItems: function(options) {
+ var self = this;
+ var clonedOptions = Object.assign({}, options, { api: 'payroll' });
+ clonedOptions.entityConstructor = function(data) { return self.newPayItems(data) };
+ return this.getEntities(clonedOptions)
+ }
+})
+
+module.exports = PayItems;
\ No newline at end of file
diff --git a/lib/entity_helpers/payroll_employees.js b/lib/entity_helpers/payroll/payroll_employees.js
similarity index 85%
rename from lib/entity_helpers/payroll_employees.js
rename to lib/entity_helpers/payroll/payroll_employees.js
index 648a3471..b3d559c8 100644
--- a/lib/entity_helpers/payroll_employees.js
+++ b/lib/entity_helpers/payroll/payroll_employees.js
@@ -1,7 +1,7 @@
var _ = require('lodash'),
- logger = require('../logger'),
- EntityHelper = require('./entity_helper'),
- Employee = require('../entities/payroll_employee'),
+ logger = require('../../logger'),
+ EntityHelper = require('../entity_helper'),
+ Employee = require('../../entities/payroll/payroll_employee'),
util = require('util')
var Employees = EntityHelper.extend({
@@ -29,4 +29,4 @@ var Employees = EntityHelper.extend({
}
})
-module.exports = Employees;
+module.exports = Employees;
\ No newline at end of file
diff --git a/lib/entity_helpers/payroll/timesheets.js b/lib/entity_helpers/payroll/timesheets.js
new file mode 100644
index 00000000..79e5159a
--- /dev/null
+++ b/lib/entity_helpers/payroll/timesheets.js
@@ -0,0 +1,31 @@
+var _ = require('lodash'),
+ logger = require('../../logger'),
+ EntityHelper = require('../entity_helper'),
+ Timesheet = require('../../entities/payroll/timesheet'),
+ util = require('util')
+
+var Timesheets = EntityHelper.extend({
+ constructor: function(application, options) {
+ EntityHelper.call(this, application, Object.assign({ entityName: 'Timesheet', entityPlural: 'Timesheets' }, options));
+ },
+ newTimesheet: function(data, options) {
+ return new Timesheet(this.application, data, options)
+ },
+ getTimesheet: function(id, modifiedAfter, where, order) {
+ return this.getTimesheets({ id: id, modifiedAfter: modifiedAfter, where: where, order: order })
+ .then(function(timesheets) {
+ return _.first(timesheets);
+ })
+ },
+ saveTimesheets: function(timesheets, options) {
+ return this.saveEntities(timesheets, Object.assign({}, options, { method: 'post', api: 'payroll' }));
+ },
+ getTimesheets: function(options) {
+ var self = this;
+ var clonedOptions = Object.assign({}, options, { api: 'payroll' });
+ clonedOptions.entityConstructor = function(data) { return self.newTimesheet(data) };
+ return this.getEntities(clonedOptions)
+ }
+})
+
+module.exports = Timesheets;
\ No newline at end of file
diff --git a/lib/entity_helpers/timesheets.js b/lib/entity_helpers/timesheets.js
deleted file mode 100644
index 9aa4dec6..00000000
--- a/lib/entity_helpers/timesheets.js
+++ /dev/null
@@ -1,38 +0,0 @@
-var _ = require('lodash')
- , logger = require('../logger')
- , EntityHelper = require('./entity_helper')
- , Timesheet = require('../entities/timesheet')
- , util = require('util')
-
-var Timesheets = EntityHelper.extend({
- constructor: function (application, options)
- {
- EntityHelper.call(this, application, Object.assign({ entityName:'Timesheet', entityPlural:'Timesheets'}, options));
- },
- newTimesheet: function (data, options)
- {
- return new Timesheet(this.application, data, options)
- },
- getTimesheet: function (id, modifiedAfter,where, order)
- {
- return this.getTimesheets({ id: id, modifiedAfter: modifiedAfter, where: where, order: order})
- .then(function (timesheets)
- {
- return _.first(timesheets);
- })
- },
- saveTimesheets: function (timesheets, options)
- {
- return this.saveEntities(timesheets, Object.assign({},options,{ method: 'post',api: 'payroll'}));
- },
- getTimesheets: function (options)
- {
- var self = this;
- var clonedOptions = Object.assign({},options, { api: 'payroll'});
- clonedOptions.entityConstructor = function(data) { return self.newTimesheet(data)};
- return this.getEntities(clonedOptions)
- }
-})
-
-module.exports = Timesheets;
-
diff --git a/lib/oauth/oauth2.js b/lib/oauth/oauth2.js
deleted file mode 100644
index 3210171f..00000000
--- a/lib/oauth/oauth2.js
+++ /dev/null
@@ -1,199 +0,0 @@
-var querystring= require('querystring'),
- crypto= require('crypto'),
- https= require('https'),
- http= require('http'),
- URL= require('url'),
- OAuthUtils= require('./_utils');
-
-exports.OAuth2= function(clientId, clientSecret, baseSite, authorizePath, accessTokenPath, customHeaders) {
- this._clientId= clientId;
- this._clientSecret= clientSecret;
- this._baseSite= baseSite;
- this._authorizeUrl= authorizePath || "/oauth/authorize";
- this._accessTokenUrl= accessTokenPath || "/oauth/access_token";
- this._accessTokenName= "access_token";
- this._authMethod= "Bearer";
- this._customHeaders = customHeaders || {};
- this._useAuthorizationHeaderForGET= false;
-}
-
-// This 'hack' method is required for sites that don't use
-// 'access_token' as the name of the access token (for requests).
-// ( http://tools.ietf.org/html/draft-ietf-oauth-v2-16#section-7 )
-// it isn't clear what the correct value should be atm, so allowing
-// for specific (temporary?) override for now.
-exports.OAuth2.prototype.setAccessTokenName= function ( name ) {
- this._accessTokenName= name;
-}
-
-// Sets the authorization method for Authorization header.
-// e.g. Authorization: Bearer # "Bearer" is the authorization method.
-exports.OAuth2.prototype.setAuthMethod = function ( authMethod ) {
- this._authMethod = authMethod;
-};
-
-
-// If you use the OAuth2 exposed 'get' method (and don't construct your own _request call )
-// this will specify whether to use an 'Authorize' header instead of passing the access_token as a query parameter
-exports.OAuth2.prototype.useAuthorizationHeaderforGET = function(useIt) {
- this._useAuthorizationHeaderForGET= useIt;
-}
-
-exports.OAuth2.prototype._getAccessTokenUrl= function() {
- return this._baseSite + this._accessTokenUrl; /* + "?" + querystring.stringify(params); */
-}
-
-// Build the authorization header. In particular, build the part after the colon.
-// e.g. Authorization: Bearer # Build "Bearer "
-exports.OAuth2.prototype.buildAuthHeader= function(token) {
- return this._authMethod + ' ' + token;
-};
-
-exports.OAuth2.prototype._request= function(method, url, headers, post_body, access_token, callback) {
-
- var http_library= https;
- var creds = crypto.createCredentials({ });
- var parsedUrl= URL.parse( url, true );
- if( parsedUrl.protocol == "https:" && !parsedUrl.port ) {
- parsedUrl.port= 443;
- }
-
- // As this is OAUth2, we *assume* https unless told explicitly otherwise.
- if( parsedUrl.protocol != "https:" ) {
- http_library= http;
- }
-
- var realHeaders= {};
- for( var key in this._customHeaders ) {
- realHeaders[key]= this._customHeaders[key];
- }
- if( headers ) {
- for(var key in headers) {
- realHeaders[key] = headers[key];
- }
- }
- realHeaders['Host']= parsedUrl.host;
-
- if (!realHeaders['User-Agent']) {
- realHeaders['User-Agent'] = 'Node-oauth';
- }
-
- realHeaders['Content-Length']= post_body ? Buffer.byteLength(post_body) : 0;
- if( access_token && !('Authorization' in realHeaders)) {
- if( ! parsedUrl.query ) parsedUrl.query= {};
- parsedUrl.query[this._accessTokenName]= access_token;
- }
-
- var queryStr= querystring.stringify(parsedUrl.query);
- if( queryStr ) queryStr= "?" + queryStr;
- var options = {
- host:parsedUrl.hostname,
- port: parsedUrl.port,
- path: parsedUrl.pathname + queryStr,
- method: method,
- headers: realHeaders
- };
-
- this._executeRequest( http_library, options, post_body, callback );
-}
-
-exports.OAuth2.prototype._executeRequest= function( http_library, options, post_body, callback ) {
- // Some hosts *cough* google appear to close the connection early / send no content-length header
- // allow this behaviour.
- var allowEarlyClose= OAuthUtils.isAnEarlyCloseHost(options.host);
- var callbackCalled= false;
- function passBackControl( response, result ) {
- if(!callbackCalled) {
- callbackCalled=true;
- if( response.statusCode != 200 && (response.statusCode != 301) && (response.statusCode != 302) ) {
- callback({ statusCode: response.statusCode, data: result });
- } else {
- callback(null, result, response);
- }
- }
- }
-
- var result= "";
-
- var request = http_library.request(options, function (response) {
- response.on("data", function (chunk) {
- result+= chunk
- });
- response.on("close", function (err) {
- if( allowEarlyClose ) {
- passBackControl( response, result );
- }
- });
- response.addListener("end", function () {
- passBackControl( response, result );
- });
- });
- request.on('error', function(e) {
- callbackCalled= true;
- callback(e);
- });
-
- if( options.method == 'POST' && post_body ) {
- request.write(post_body);
- }
- request.end();
-}
-
-exports.OAuth2.prototype.getAuthorizeUrl= function( params ) {
- var params= params || {};
- params['client_id'] = this._clientId;
- return this._baseSite + this._authorizeUrl + "?" + querystring.stringify(params);
-}
-
-exports.OAuth2.prototype.getOAuthAccessToken= function(code, params, callback) {
- var params= params || {};
- params['client_id'] = this._clientId;
- params['client_secret'] = this._clientSecret;
- var codeParam = (params.grant_type === 'refresh_token') ? 'refresh_token' : 'code';
- params[codeParam]= code;
-
- var post_data= querystring.stringify( params );
- var post_headers= {
- 'Content-Type': 'application/x-www-form-urlencoded'
- };
-
-
- this._request("POST", this._getAccessTokenUrl(), post_headers, post_data, null, function(error, data, response) {
- if( error ) callback(error);
- else {
- var results;
- try {
- // As of http://tools.ietf.org/html/draft-ietf-oauth-v2-07
- // responses should be in JSON
- results= JSON.parse( data );
- }
- catch(e) {
- // .... However both Facebook + Github currently use rev05 of the spec
- // and neither seem to specify a content-type correctly in their response headers :(
- // clients of these services will suffer a *minor* performance cost of the exception
- // being thrown
- results= querystring.parse( data );
- }
- var access_token= results["access_token"];
- var refresh_token= results["refresh_token"];
- delete results["refresh_token"];
- callback(null, access_token, refresh_token, results); // callback results =-=
- }
- });
-}
-
-// Deprecated
-exports.OAuth2.prototype.getProtectedResource= function(url, access_token, callback) {
- this._request("GET", url, {}, "", access_token, callback );
-}
-
-exports.OAuth2.prototype.get= function(url, access_token, callback) {
- if( this._useAuthorizationHeaderForGET ) {
- var headers= {'Authorization': this.buildAuthHeader(access_token) }
- access_token= null;
- }
- else {
- headers= {};
- }
- this._request("GET", url, headers, "", access_token, callback );
-}
diff --git a/lib/payroll.js b/lib/payroll.js
index 4f930f04..2f0f43e8 100644
--- a/lib/payroll.js
+++ b/lib/payroll.js
@@ -1,22 +1,20 @@
-var _ = require('lodash')
- , logger = require('./logger')
+var _ = require('lodash'),
+ logger = require('./logger')
var HELPERS = {
- timesheets: { file: 'timesheets'},
- payitems: { file: 'payitems'},
- employees: { file: 'payroll_employees'}
+ timesheets: { file: 'timesheets' },
+ payitems: { file: 'payitems' },
+ employees: { file: 'payroll_employees' }
};
-function Payroll(application, options)
-{
+function Payroll(application, options) {
var self = this;
logger.debug('Payroll::constructor');
this._application = application;
- _.each(HELPERS, function(entityHelper, id)
- {
- var instance = new (require('./entity_helpers/' + entityHelper.file))(application);
- Object.defineProperty(self, id, {
+ _.each(HELPERS, function(entityHelper, id) {
+ var instance = new(require('./entity_helpers/payroll/' + entityHelper.file))(application);
+ Object.defineProperty(self, id, {
get: function() { return instance }
})
})