1 Commits

Author SHA1 Message Date
Bilal Catic
57cb6e8eaf fix how unlock and lock entries are matched to the reservation 2019-12-23 09:08:36 +01:00
2 changed files with 12 additions and 9 deletions

View File

@@ -196,12 +196,12 @@ const getUnlockEntryForReservation = (reservation, previousReservation) => {
return new Promise((resolve, reject) => {
const { memberId, resourceId } = reservation;
const previousReservationEndMoment = previousReservation && previousReservation.end ?
moment.utc(previousReservation.end) : null;
const previousReservationStartMoment = previousReservation && previousReservation.start ?
moment.utc(previousReservation.start) : null;
const reservationStartMoment = moment.utc(reservation.start);
const fromTimestamp = previousReservationEndMoment && previousReservationEndMoment.tz(UI_TIMEZONE).isSame(reservationStartMoment.tz(UI_TIMEZONE), 'day') ?
previousReservation.end : reservationStartMoment.tz(UI_TIMEZONE).startOf('day').toISOString();
const fromTimestamp = previousReservationStartMoment && previousReservationStartMoment.tz(UI_TIMEZONE).isSame(reservationStartMoment.tz(UI_TIMEZONE), 'day') ?
previousReservation.start : reservationStartMoment.tz(UI_TIMEZONE).startOf('day').toISOString();
const toTimestamp = reservation.end;
@@ -314,13 +314,13 @@ const getLockEntryForReservation = (reservation, nextReservation) => {
const attributes = ['memberName', 'event', 'timestamp'];
const nextReservationStartMoment = nextReservation && nextReservation.start ?
moment.utc(nextReservation.start) : null;
const nextReservationEndMoment = nextReservation && nextReservation.end ?
moment.utc(nextReservation.end) : null;
const reservationStartMoment = moment.utc(reservation.start);
const fromTimestamp = reservation.start;
const toTimestamp = nextReservationStartMoment && nextReservationStartMoment.tz(UI_TIMEZONE).isSame(reservationStartMoment.tz(UI_TIMEZONE), 'day') ?
nextReservation.start : reservationStartMoment.tz(UI_TIMEZONE).endOf('day').toISOString();
const toTimestamp = nextReservationEndMoment && nextReservationEndMoment.tz(UI_TIMEZONE).isSame(reservationStartMoment.tz(UI_TIMEZONE), 'day') ?
nextReservation.end : reservationStartMoment.tz(UI_TIMEZONE).endOf('day').toISOString();
const filters = {
memberId,

View File

@@ -368,7 +368,10 @@ const getIncidentData = (reservation) => {
const { resourceId } = currentReservation;
// const reservationMoment = moment.tz(currentReservation.start, currentReservation.timezone);
// if (currentReservation.memberId === '5ce785af422bdd00967fb781' && reservationMoment.isAfter('2019-11-23 00:00:16+00')) {
// if (currentReservation.memberId === '5ce785af422bdd00967fb781' &&
// reservationMoment.isAfter('2019-12-11 00:00:16+00') &&
// reservationMoment.isBefore('2019-12-12 23:59:59')
// ) {
// console.log('\r\n\r\n==== ANALYSE RESERVATION [GET INCIDENT DATA] ==== ');
// console.log('\tStart : ', reservationMoment.format('DD.MM, HH:mm'));
// console.log('\tEnd : ', moment.tz(currentReservation.end, currentReservation.timezone).format('DD.MM, HH:mm'));