Skip to content

Commit

Permalink
merged from master
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Walsh committed Mar 14, 2017
2 parents 1661b87 + 83d6150 commit ef39849
Show file tree
Hide file tree
Showing 8 changed files with 751 additions and 233 deletions.
158 changes: 139 additions & 19 deletions README.md

Large diffs are not rendered by default.

295 changes: 206 additions & 89 deletions lib/application.js

Large diffs are not rendered by default.

27 changes: 24 additions & 3 deletions lib/entities/accounting/taxrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ var TaxRateSchema = new Entity.SchemaObject({
DisplayTaxRate: { type: Number, toObject: 'always' },
EffectiveRate: { type: Number, toObject: 'always' },
Status: { type: String, toObject: 'always' },
TaxComponents: { type: Array, arrayType: TaxComponentSchema, toObject: 'always' }
TaxComponents: { type: Array, arrayType: TaxComponentSchema, toObject: 'always' },
ReportTaxType: { type: String, toObject: 'hasValue' }
});

var TaxComponentSchema = new Entity.SchemaObject({
Expand All @@ -38,8 +39,28 @@ var TaxRate = Entity.extend(TaxRateSchema, {
return this;
},
toXml: function() {
var taxrate = _.omit(this.toObject());
return this.application.js2xml(taxrate, 'TaxRate');
var taxRate = _.omit(this.toObject(), 'TaxComponents');
Object.assign(taxRate, { TaxComponents: [] });
_.forEach(this.TaxComponents, function(taxComponent) {
taxRate.TaxComponents.push({ TaxComponent: taxComponent })
})
return this.application.js2xml(taxRate, 'TaxRate');
},
save: function(options) {
var self = this;
var xml = '<TaxRates>' + this.toXml() + '</TaxRates>';
var path = 'TaxRates',
method;
if (this.Status) {
method = 'post'
} else {
method = 'put'
}
return this.application.putOrPostEntity(method, path, xml, { entityPath: 'TaxRates.TaxRate', entityConstructor: function(data) { return self.application.core.taxrates.newTaxRate(data) } });
},
delete: function(options) {
this.Status = "DELETED";
return this.save();
}
});

Expand Down
10 changes: 4 additions & 6 deletions lib/oauth/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ exports.OAuth.prototype.getOAuthAccessToken = function(oauth_token, oauth_token_
var extraParams = {};
if (typeof oauth_verifier == "function") {
callback = oauth_verifier;
} else if (typeof oauth_verifier == "object") {
extraParams.oauth_session_handle = oauth_verifier.oauth_session_handle;
} else {
extraParams.oauth_verifier = oauth_verifier;
}
Expand All @@ -469,11 +471,7 @@ exports.OAuth.prototype.getOAuthAccessToken = function(oauth_token, oauth_token_
if (error) callback(error);
else {
var results = querystring.parse(data);
var oauth_access_token = results["oauth_token"];
delete results["oauth_token"];
var oauth_access_token_secret = results["oauth_token_secret"];
delete results["oauth_token_secret"];
callback(null, oauth_access_token, oauth_access_token_secret, results);
callback(null, results);
}
})
}
Expand Down Expand Up @@ -584,4 +582,4 @@ exports.OAuth.prototype.authHeader = function(url, oauth_token, oauth_token_secr

var orderedParameters = this._prepareParameters(oauth_token, oauth_token_secret, method, url, {});
return this._buildAuthorizationHeaders(orderedParameters);
};
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"license": "MIT",
"dependencies": {
"dateformat": "~1.0.7-1.2.3",
"events": "^1.1.1",
"lodash": "~2.4.1",
"log4js": "~0.6.9",
"lru-cache": "^4.0.2",
Expand All @@ -39,6 +40,7 @@
"mustache": "^2.3.0",
"nodemailer": "",
"nyc": "^10.1.2",
"sinon": "^1.17.7",
"zombie": "^5.0.5",
"zombie-phantom": "0.0.6"
}
Expand Down
Loading

0 comments on commit ef39849

Please sign in to comment.