/
timesheets.js
38 lines (35 loc) · 1.28 KB
/
timesheets.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;