fix how unlock and lock entries are matched to the reservation

This commit is contained in:
Bilal Catic
2019-12-23 09:08:36 +01:00
parent a4573a9a13
commit 57cb6e8eaf
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,