Files
old-crm-integration/cronServices/checkBookingChanges.js
2019-07-08 20:37:14 +02:00

34 lines
1.1 KiB
JavaScript

'use strict';
require('dotenv').config();
const { fetchAllBookings, bulkWriteReservationsWithChangesTracking } = require('../services/officeRnD/bookings');
const { chargeBookingChanges } = require('../services/integration/bookingChangeCharges');
const checkBookingChanges = () => {
fetchAllBookings()
.then((reservations) => {
bulkWriteReservationsWithChangesTracking(reservations)
.then((changes) => {
chargeBookingChanges(changes)
.then(() => {
process.exit();
})
.catch((error) => {
console.log('Error creating charges ', error);
process.exit();
});
})
.catch((error) => {
console.log('Error bulk write booking reservations :', error);
process.exit();
});
})
.catch((error) => {
console.log('Error fetching bookings from ORD ', error);
process.exit();
});
};
checkBookingChanges();