Bug fixes

This commit is contained in:
Senad Uka
2020-01-19 11:39:09 +01:00
parent 3792fcf0d1
commit ed6cc5a1bc

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
@@ -101,6 +116,8 @@ const fetchAllBookings = () => {
const fees = fullBookingEntry && fullBookingEntry.fees ? fullBookingEntry.fees : [];
const firstFee = fees.length > 0 && fees[0].fee ? fees[0].fee : undefined;
const hourlyRate = firstFee && firstFee.price ? firstFee.price : 0;
const free = fullBookingEntry.free ? fullBookingEntry.free : false;
const tentative = fullBookingEntry.tentative ? fullBookingEntry.tentative : false;
const startMoment = fullBookingEntry && fullBookingEntry.start && fullBookingEntry.start.dateTime ?
moment.utc(fullBookingEntry.start.dateTime) : null;
@@ -111,7 +128,7 @@ const fetchAllBookings = () => {
// console.log('End : ', endMoment.clone().tz(fullBookingEntry.timezone).format('DD.MM. HH:mm'), '[', endMoment.toISOString(), ']');
// console.log('Fees : ');
if (startMoment && endMoment){
if (startMoment && endMoment && !free && !tentative){
cleanedBookingReservations.push({
reservationId: fullBookingEntry['_id'],
memberId: fullBookingEntry.member,