-
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.
refactored directories to clean up the structure
- Loading branch information
Jordan Walsh
committed
Mar 14, 2017
1 parent
71c2f6e
commit 3edb1d0
Showing
40 changed files
with
325 additions
and
525 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
4 changes: 2 additions & 2 deletions
4
lib/entities/attachment.js → lib/entities/accounting/attachment.js
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
6 changes: 3 additions & 3 deletions
6
lib/entities/banktransaction.js → lib/entities/accounting/banktransaction.js
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
6 changes: 3 additions & 3 deletions
6
lib/entities/banktransfer.js → lib/entities/accounting/banktransfer.js
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
12 changes: 6 additions & 6 deletions
12
lib/entities/contact.js → lib/entities/accounting/contact.js
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
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
12 changes: 6 additions & 6 deletions
12
lib/entities/organisation.js → lib/entities/accounting/organisation.js
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
6 changes: 3 additions & 3 deletions
6
lib/entities/trackingcategory.js → lib/entities/accounting/trackingcategory.js
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,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; |
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
6 changes: 3 additions & 3 deletions
6
lib/entities/payroll_employee.js → lib/entities/payroll/payroll_employee.js
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,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 = '<Timesheets>' + this.toXml() + '</Timesheets>'; | ||
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; |
Oops, something went wrong.