Fix for loading

This commit is contained in:
Senad Uka
2019-07-25 06:53:32 +02:00
parent a691ab94c7
commit 2db47e95e1
26 changed files with 838 additions and 400 deletions

View 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
};