refactor function for getting all bookings to allow more filters

This commit is contained in:
Bilal Catic
2019-08-09 16:31:59 +02:00
parent 44a2303877
commit 832c0f8eeb
2 changed files with 20 additions and 6 deletions

View File

@@ -10,7 +10,7 @@ const workbookCreator = require('excel4node');
const { checkBookingChanges } = require('./checkBookingChange');
const { incidentType, UI_TIMEZONE, DEFAULT_DATE_FORMAT, integrationServiceErrors } = require('../../constants/constants');
const { getAllBookingsForYear } = require('./bookings');
const { getAllBookingsForMembersInDateRange } = require('./bookings');
const { fetchAllMembers } = require('../officeRnD/members');
const { fetchOffices, fetchResources } = require('../officeRnD/resources');
const { getChargedCanceledReservations } = require('../integration/bookingChangeCharges');
@@ -320,7 +320,15 @@ const getAllIncidents = (dateRange, memberIds) => {
const getMemberPracticeSummaryReport = (year) => {
return new Promise((resolve, reject) => {
const asyncJobs = [checkBookingChanges(), getAllBookingsForYear(year), fetchAllMembers()];
const startDate = moment.tz(year, 'YYYY', UI_TIMEZONE).startOf('year').format(DEFAULT_DATE_FORMAT);
const endDate = moment.tz(year, 'YYYY', UI_TIMEZONE).endOf('year').format(DEFAULT_DATE_FORMAT);
const dateRange = {
startDate,
endDate,
};
const asyncJobs = [checkBookingChanges(), getAllBookingsForMembersInDateRange(dateRange), fetchAllMembers()];
Promise.all(asyncJobs)
.then((results) => {