Editing of the fees before sending / bugfixes

This commit is contained in:
Senad Uka
2020-01-13 07:56:00 +01:00
parent 404f27e208
commit 3d8e9c987f
6 changed files with 281 additions and 22 deletions

View File

@@ -283,6 +283,22 @@ const deleteBookingChangeIncidentsById = (incidentIds) => {
return db.bookingChangeIncident.update({deleted: true},{where: filters});
};
const updateBookingChangeIncidentsById = (incidentFees) => {
const incidentIds = Object.keys(incidentFees);
const asyncUpdateActions = [];
incidentIds.forEach((incidentId) => {
const newFeeCharge = parseFloat(incidentFees[incidentId]);
if (newFeeCharge || (newFeeCharge === 0)){
asyncUpdateActions.push(db.bookingChangeIncident.update({chargeFee: newFeeCharge}, {where: {id: incidentId}}));
}
});
return Promise.all(asyncUpdateActions);
};
module.exports = {
getChargedCanceledReservations,
getIncidentsFromChanges,
@@ -290,5 +306,6 @@ module.exports = {
getShorteningIncidentsForReservationId,
getReservationsIncidentsForRemoval,
deleteBookingChangeIncidents,
deleteBookingChangeIncidentsById
deleteBookingChangeIncidentsById,
updateBookingChangeIncidentsById
};