add deleteFees route and implement logic

This commit is contained in:
Bilal Catic
2019-11-21 07:12:50 +01:00
parent 3d051766b1
commit 8a3db0d481
4 changed files with 76 additions and 1 deletions

View File

@@ -274,6 +274,16 @@ const deleteBookingChangeIncidents = (incidents) => {
return Promise.all(asyncActions);
};
const deleteBookingChangeIncidentsById = (incidentIds) => {
console.log('Delete booking changes in DB :', incidentIds);
const filters = {
id: {
[Op.in]: incidentIds
}
};
return db.bookingChangeIncident.update({deleted: true},{where: filters});
};
module.exports = {
getChargedCanceledReservations,
getIncidentsFromChanges,
@@ -281,4 +291,5 @@ module.exports = {
getShorteningIncidentsForReservationId,
getReservationsIncidentsForRemoval,
deleteBookingChangeIncidents,
deleteBookingChangeIncidentsById
};

View File

@@ -2,6 +2,7 @@
const moment = require('moment-timezone');
const db = require('../../models/index');
const Op = require('sequelize').Op;
const {
doorLockEvents,
@@ -69,6 +70,16 @@ const insertUnscheduledIncidents = (incidents) => {
return Promise.all(asyncJobs);
};
const deleteUnscheduledIncidentsById = (incidentIds) => {
console.log('Delete unscheduled in DB :', incidentIds);
const filters = {
id: {
[Op.in]: incidentIds
}
};
return db.unscheduledIncident.update({deleted: true},{where: filters});
};
const insertUnlockedIncidents = (incidents) => {
const asyncJobs = [];
incidents.forEach((incident) => {
@@ -104,6 +115,16 @@ const insertUnlockedIncidents = (incidents) => {
return Promise.all(asyncJobs);
};
const deleteUnlockedIncidentsById = (incidentIds) => {
console.log('Delete unlocked in DB :', incidentIds);
const filters = {
id: {
[Op.in]: incidentIds
}
};
return db.unlockedIncident.update({deleted: true},{where: filters});
};
const setUnlockedIncidentsLevel = (incidents) => {
return new Promise ((resolve, reject) => {
const sortingFunction = (incidentA, incidentB) => {
@@ -576,5 +597,7 @@ const calculateDoorLockCharges = () => {
};
module.exports = {
calculateDoorLockCharges
calculateDoorLockCharges,
deleteUnlockedIncidentsById,
deleteUnscheduledIncidentsById
};