Fix for loading
This commit is contained in:
44
services/integration/checkBookingChange.js
Normal file
44
services/integration/checkBookingChange.js
Normal file
@@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
const { fetchAllBookings, bulkWriteReservationsWithChangesTracking } = require('../officeRnD/bookings');
|
||||
|
||||
const { chargeBookingChanges } = require('./bookingChangeCharges');
|
||||
const { bulkWriteChanges } = require('./bookingChangeLog');
|
||||
|
||||
const checkBookingChanges = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fetchAllBookings()
|
||||
.then((reservations) => {
|
||||
bulkWriteReservationsWithChangesTracking(reservations)
|
||||
.then((changes) => {
|
||||
bulkWriteChanges(changes)
|
||||
.then(() => {
|
||||
chargeBookingChanges(changes)
|
||||
.then(() => {
|
||||
resolve(true);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('Error creating charges ', error);
|
||||
reject(error);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('Error bulk write booking reservation change log :', error);
|
||||
reject(error);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('Error bulk write booking reservations :', error);
|
||||
reject(error);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('Error fetching bookings from ORD ', error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
checkBookingChanges
|
||||
};
|
||||
Reference in New Issue
Block a user