do not create booking reservation for non existing reservation in ORD with exceptions

This commit is contained in:
Bilal Catic
2020-01-15 18:48:55 +01:00
parent 45258334c1
commit aa771bc7bd

View File

@@ -22,6 +22,21 @@ const fetchAllBookings = () => {
return;
}
const fees = fullBookingEntry.fees ? fullBookingEntry.fees : [];
const canceled = fullBookingEntry.canceled ? fullBookingEntry.canceled : false;
const recurringReservation = fullBookingEntry.recurrence && fullBookingEntry.recurrence.rrule ?
fullBookingEntry.recurrence.rrule : null;
const tentative = fullBookingEntry.tentative ? fullBookingEntry.tentative : false;
const free = fullBookingEntry.free ? fullBookingEntry.free : false;
//Special case, canceled recurring reservation
//It has empty fees array (fees.length = 0) and no "canceled" field
//Normally, canceled reservation has canceled field
//Also, it has rrule !== null
//If it is tentative, it will have tentative = true, skip those (do not delete)
//If it is free, it will have free = true, skip those (do not delete)
if (fees.length === 0 && !canceled && recurringReservation && !tentative && !free){
bookingIdsToRemove.push(fullBookingEntry['_id']);
}
if (fees.length > 1){
// Recurring booking, let's create new booking
@@ -111,7 +126,7 @@ const fetchAllBookings = () => {
// console.log('End : ', endMoment.clone().tz(fullBookingEntry.timezone).format('DD.MM. HH:mm'), '[', endMoment.toISOString(), ']');
// console.log('Fees : ');
if (firstFee && startMoment && endMoment){
if (startMoment && endMoment){
cleanedBookingReservations.push({
reservationId: fullBookingEntry['_id'],
memberId: fullBookingEntry.member,