diff --git a/lib/recurly/pricing/calculations.js b/lib/recurly/pricing/calculations.js index b653f17bc..0d2c59ded 100644 --- a/lib/recurly/pricing/calculations.js +++ b/lib/recurly/pricing/calculations.js @@ -94,8 +94,8 @@ Calculations.prototype.tax = function (done) { } else { each(taxes, function (tax) { if (tax.type === 'usst' && self.items.plan.tax_exempt) return; - self.price.now.tax += self.price.now.subtotal * tax.rate; - self.price.next.tax += self.price.next.subtotal * tax.rate; + 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)); }); // tax estimation prefers partial cents to always round up @@ -156,8 +156,10 @@ Calculations.prototype.discount = function () { if (coupon) { if (coupon.discount.rate) { - this.price.now.discount = Math.round(this.price.now.subtotal * coupon.discount.rate * 100) / 100; - this.price.next.discount = Math.round(this.price.next.subtotal * coupon.discount.rate * 100) / 100; + var discountNow = parseFloat((this.price.now.subtotal * coupon.discount.rate).toFixed(6)); + var discountNext = parseFloat((this.price.next.subtotal * coupon.discount.rate).toFixed(6)); + this.price.now.discount = Math.round(discountNow * 100) / 100; + this.price.next.discount = Math.round(discountNext * 100) / 100; } else { this.price.now.discount = coupon.discount.amount[this.items.currency]; this.price.next.discount = coupon.discount.amount[this.items.currency];