Fix bug with calendar
This commit is contained in:
@@ -2,7 +2,12 @@
|
||||
|
||||
const { fetchAllBookings, bulkWriteReservationsWithChangesTracking } = require('../officeRnD/bookings');
|
||||
|
||||
const { chargeBookingChanges } = require('./bookingChangeCharges');
|
||||
const {
|
||||
getIncidentsFromChanges,
|
||||
bulkWriteBookingChangeIncidents,
|
||||
getReservationsIncidentsForRemoval,
|
||||
deleteBookingChangeIncidents,
|
||||
} = require('./bookingChangeCharges');
|
||||
const { bulkWriteChanges } = require('./bookingChangeLog');
|
||||
|
||||
const checkBookingChanges = () => {
|
||||
@@ -13,9 +18,28 @@ const checkBookingChanges = () => {
|
||||
.then((changes) => {
|
||||
bulkWriteChanges(changes)
|
||||
.then(() => {
|
||||
chargeBookingChanges(changes)
|
||||
.then(() => {
|
||||
resolve(true);
|
||||
getIncidentsFromChanges(changes)
|
||||
.then(({incidents, reservationsForAdditionalCheck}) => {
|
||||
bulkWriteBookingChangeIncidents(incidents)
|
||||
.then(() => {
|
||||
getReservationsIncidentsForRemoval(reservationsForAdditionalCheck)
|
||||
.then((incidentsToRemove) => {
|
||||
deleteBookingChangeIncidents(incidentsToRemove)
|
||||
.then(() => resolve(true))
|
||||
.catch((error) => {
|
||||
console.log('Error deleting incidents : ', error);
|
||||
reject(error);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('Failed to fetch reservations possible incidents for removal', error);
|
||||
reject(error);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error', error);
|
||||
reject(error);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('Error creating charges ', error);
|
||||
|
||||
Reference in New Issue
Block a user