Skip to content

Commit

Permalink
added support for retrieving invoice reminder settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Walsh committed Mar 16, 2017
1 parent 1bd4eb9 commit d1868e5
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ var HELPERS = {
attachments: { file: 'attachments' },
accounts: { file: 'accounts' },
invoices: { file: 'invoices' },
trackingCategories: { file: 'trackingcategories' },
invoices: { file: 'invoices' },
invoiceReminders: { file: 'invoicereminders' },
users: { file: 'users' },
payments: { file: 'payments' },
taxRates: { file: 'taxrates' },
Expand Down
18 changes: 18 additions & 0 deletions lib/entities/accounting/invoicereminder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var _ = require('lodash'),
Entity = require('../entity'),
logger = require('../../logger');

var InvoiceReminderSchema = new Entity.SchemaObject({
Enabled: { type: Boolean }
});

var InvoiceReminder = Entity.extend(InvoiceReminderSchema, {
constructor: function(application, data, options) {
logger.debug('InvoiceReminder::constructor');
this.Entity.apply(this, arguments);
},
initialize: function(data, options) {}
});


module.exports = InvoiceReminder;
21 changes: 21 additions & 0 deletions lib/entity_helpers/accounting/invoicereminders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
var _ = require('lodash'),
logger = require('../../logger'),
EntityHelper = require('../entity_helper'),
InvoiceReminder = require('../../entities/accounting/invoicereminder'),
util = require('util')

var InvoiceReminders = EntityHelper.extend({
constructor: function(application, options) {
EntityHelper.call(this, application, Object.assign({ entityName: 'InvoiceReminder', entityPlural: 'InvoiceReminders' }, options));
},
getInvoiceReminders: function(options, callback) {
var self = this;
var clonedOptions = _.clone(options || {});
//This has been hardcoded as the URL is /InvoiceReminders/Settings
clonedOptions.id = "Settings";
clonedOptions.entityConstructor = function(data) { return new InvoiceReminder(data) };
return this.getEntities(clonedOptions)
}
})

module.exports = InvoiceReminders;
18 changes: 18 additions & 0 deletions test/accountingtests.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,24 @@ describe('regression tests', function() {
});
});

describe.only('Invoice Reminders', function() {

it('get', function(done) {
currentApp.core.invoiceReminders.getInvoiceReminders()
.then(function(invoiceReminders) {
expect(invoiceReminders).to.have.length.greaterThan(0);
invoiceReminders.forEach(function(invoiceReminder) {
expect(invoiceReminder.Enabled).to.be.oneOf([true, false]);
});
done();
})
.catch(function(err) {
console.log(err);
done(wrapError(err));
})
});
});

describe('branding themes', function() {

var brandingThemeID = "";
Expand Down

0 comments on commit d1868e5

Please sign in to comment.