couponable
Advanced tools
Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "couponable", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Helper functions for dealing with coupons.", | ||
@@ -5,0 +5,0 @@ "main": [ "index.js" ], |
@@ -28,7 +28,10 @@ function priceFormat(amountInCents) { | ||
function totalDueNow(orderItem) { | ||
function totalDueNow(orderItem, includeShipping) { | ||
var quantity = orderItem.quantity || 0, | ||
total = orderItem.priceInCents; | ||
if (orderItem.shippingOption) { | ||
// default to true | ||
includeShipping = includeShipping === false ? false : true; | ||
if (includeShipping && orderItem.shippingOption) { | ||
total += orderItem.shippingOption.priceInCents || 0; | ||
@@ -35,0 +38,0 @@ } |
{ | ||
"name": "couponable", | ||
"description": "Helper functions for dealing with coupons.", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"author": "Chris McC", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -21,2 +21,11 @@ var couponable = require('.'); | ||
it('calculates correctly without shipping', function() { | ||
assert.equal(totalDueNow({ | ||
quantity: 2, | ||
shippingOption: {priceInCents: 2}, | ||
variation: {priceInCents: 2}, | ||
priceInCents: 2 | ||
}, false), 8); | ||
}); | ||
it('handles coupons correctly', function() { | ||
@@ -23,0 +32,0 @@ assert.equal(totalDueNow({ |
11718
343