fix door lock charges

This commit is contained in:
Bilal Catic
2019-07-03 11:50:23 +02:00
parent fc4d374e23
commit 2b492025fb
2 changed files with 23 additions and 34 deletions

View File

@@ -4,7 +4,7 @@ const moment = require('moment-timezone');
const db = require('../../models/index');
const { doorLockEvents, incidentType, unlockedIncidentLevelsPrices, UNSCHEDULED_CHARGE_PRICE, MAX_BACK_TO_BACK_DIFFERENCE, UNSCHEDULED_TIME_RESOLUTION } = require('../../constants/constants');
const { getUnlockEntryForReservation, getLockEntryForReservation, getLastEntryForReservation } = require('../doorLock/doorLock');
const { getUnlockEntryForReservation, getLockEntryForReservation, getEntriesBetween, getLastEntryForReservation } = require('../doorLock/doorLock');
const { getAllFinishedBookings, getFirstPreviousBooking, getFirstNextBooking } = require('../officeRnD/bookings');
const getSortedIncidentsForMember = (memberId) => {
@@ -180,11 +180,12 @@ const analyseReservation = (reservation) => {
.then(([previousReservation, nextReservation]) => {
const getRelatedDoorLockEntriesAsync = [
getUnlockEntryForReservation(reservation, previousReservation),
getLockEntryForReservation(reservation, nextReservation)
getLockEntryForReservation(reservation, nextReservation),
getEntriesBetween(reservation, previousReservation)
];
Promise.all(getRelatedDoorLockEntriesAsync)
.then(([unlockEntry, lockEntry]) => {
.then(([unlockEntry, lockEntry, entriesBetween]) => {
const currentReservationStart = moment.utc(reservation.start);
const currentReservationEnd = moment.utc(reservation.end);