Skip to content

Commit

Permalink
Merge pull request #186 from recurly/fix_tax_exempt_for_non_usst
Browse files Browse the repository at this point in the history
Fix tax exempt for non usst
  • Loading branch information
chrissrogers committed Mar 13, 2015
2 parents 5e771ea + 3f8f989 commit b5ab08d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/recurly/pricing/calculations.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Calculations.prototype.tax = function (done) {
} else {
self.price.taxes = [];
each(taxes, function (tax) {
if (tax.type === 'usst' && self.items.plan.tax_exempt) return;
if (self.items.plan.tax_exempt) return;
self.price.now.tax += parseFloat((self.price.now.subtotal * tax.rate).toFixed(6));
self.price.next.tax += parseFloat((self.price.next.subtotal * tax.rate).toFixed(6));
// If we have taxes, we may want to display the rate...
Expand Down
34 changes: 34 additions & 0 deletions test/server/fixtures/plans/tax_exempt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"code": "basic",
"name": "Basic",
"period": {
"interval": "months",
"length": 1
},
"trial": {
"interval": "days",
"length": 7
},
"price": {
"USD": {
"setup_fee": 2.0,
"unit_amount": 19.99
}
},
"addons": [{
"name": "Snarf",
"code": "snarf",
"quantity": 1,
"price": {
"USD": {
"unit_amount": 1.0
}
}
}],
"accepted_card_types": [{
"USD": {
"card_types": ["visa", "master", "american_express", "discover", "diners_club", "jcb"]
}
}],
"tax_exempt": true
}
14 changes: 14 additions & 0 deletions test/unit/pricing.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ describe('Recurly.Pricing', function () {
});
});

it('should not apply tax if plan is tax exempt and not usst', function (done) {
pricing
.plan('tax_exempt', { quantity: 1 })
.address({
country: 'GB'
})
.done(function (price) {
assert.equal(price.taxes.length, 0);
assert.equal(price.now.tax, '0.00');
assert.equal(price.next.tax, '0.00');
done();
});
});

it('should append US tax elements in the US', function (done) {
pricing
.plan('basic', { quantity: 1 })
Expand Down

0 comments on commit b5ab08d

Please sign in to comment.