apply weekend rate to the reservation if applicable

This commit is contained in:
Bilal Catic
2019-10-28 20:02:57 +01:00
parent 4946b051c5
commit 9ac1f57396
3 changed files with 24 additions and 4 deletions

View File

@@ -24,14 +24,17 @@ const checkBookingChanges = () => {
const ratesMap = {};
rates.forEach(rate => {
const { rateId, price } = rate;
ratesMap[rateId] = price;
const { rateId, price, weekendPrice } = rate;
ratesMap[rateId] = {
price,
weekendPrice
};
});
const resourcesMap = {};
resources.forEach(resource => {
const { resourceId, rate } = resource;
resource.price = ratesMap[rate] || 0;
resource.price = ratesMap[rate] || {price: 0, weekendPrice: 0};
resourcesMap[resourceId] = resource;
});