Skip to content

Instantly share code, notes, and snippets.

@barrydobson
Created December 1, 2015 14:26
Show Gist options
  • Save barrydobson/a59708cee2ae8442fd5c to your computer and use it in GitHub Desktop.
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
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