Created
December 1, 2015 14:26
-
-
Save barrydobson/a59708cee2ae8442fd5c to your computer and use it in GitHub Desktop.
A sample modifier to apply tax information to a set of room rates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = require('bluebird'); | |
module.exports = function create(taxService) { | |
function addTaxInformation(id, roomRates) { | |
return Promise.each(roomRates, function (roomRate) { | |
return taxService.getTaxInformation(id, roomRate.total.price) | |
.then(function (taxInformation) { | |
if (taxInformation) { | |
roomRate.total.priceBeforeTax = taxInformation.priceBeforeTax; | |
roomRate.taxes = taxInformation.taxBreakdown; | |
} | |
}); | |
}).then(function () { | |
return roomRates; | |
}); | |
} | |
return function modifyRoomRates(originalRoomRates, id) { | |
return addTaxInformation(id, originalRoomRates); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment