make difference between door lock charges related to reservations and standalone incidents
This commit is contained in:
@@ -11,7 +11,7 @@ const { fetchAllMembers } = require('../officeRnD/members');
|
||||
const { fetchOffices, fetchResources } = require('../officeRnD/resources');
|
||||
|
||||
const getUnlockedIncidents = (startDate, endDate, memberId) => {
|
||||
const attributes = ['id', 'memberId', 'resourceId', 'bookingStart', 'bookingEnd', 'incidentLevel', 'incidentLevelPrice'];
|
||||
const attributes = ['id', 'reservationId', 'memberId', 'resourceId', 'bookingStart', 'bookingEnd', 'incidentLevel', 'incidentLevelPrice'];
|
||||
|
||||
const filters = {};
|
||||
|
||||
@@ -40,6 +40,7 @@ const getUnlockedIncidents = (startDate, endDate, memberId) => {
|
||||
const getUnscheduledIncidents = (startDate, endDate, memberId) => {
|
||||
const attributes = [
|
||||
'id',
|
||||
'reservationId',
|
||||
'memberId',
|
||||
'resourceId',
|
||||
'bookingStart',
|
||||
@@ -114,6 +115,8 @@ const getAllDoorLockIncidents = (dateRange, memberId) => {
|
||||
const allIncidents = [];
|
||||
|
||||
unlockedIncidents.forEach((unlockedIncident) => {
|
||||
const incidentTypeNumber = unlockedIncident.reservationId.length > 0 ?
|
||||
incidentType.UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION : incidentType.UNLOCKED_INCIDENT_STANDALONE;
|
||||
allIncidents.push({
|
||||
incidentId: unlockedIncident.id,
|
||||
memberId: unlockedIncident.memberId,
|
||||
@@ -122,13 +125,15 @@ const getAllDoorLockIncidents = (dateRange, memberId) => {
|
||||
officeName: officesMap[resourcesMap[unlockedIncident.resourceId].officeId].officeName,
|
||||
bookingStart: formatTime(unlockedIncident.bookingStart),
|
||||
bookingEnd: formatTime(unlockedIncident.bookingEnd),
|
||||
incidentType: incidentType.UNLOCKED_INCIDENT,
|
||||
incidentType: incidentTypeNumber,
|
||||
incidentLevel: unlockedIncident.incidentLevel,
|
||||
incidentPrice: unlockedIncident.incidentLevelPrice,
|
||||
});
|
||||
});
|
||||
|
||||
unscheduledIncidents.forEach((unscheduledIncident) => {
|
||||
const incidentTypeNumber = unscheduledIncident.reservationId.length > 0 ?
|
||||
incidentType.UNSCHEDULED_INCIDENT_RELATED_WITH_RESERVATION : incidentType.UNSCHEDULED_INCIDENT_STANDALONE;
|
||||
allIncidents.push({
|
||||
incidentId: unscheduledIncident.id,
|
||||
memberId: unscheduledIncident.memberId,
|
||||
@@ -137,7 +142,7 @@ const getAllDoorLockIncidents = (dateRange, memberId) => {
|
||||
officeName: officesMap[resourcesMap[unscheduledIncident.resourceId].officeId].officeName,
|
||||
bookingStart: formatTime(unscheduledIncident.bookingStart),
|
||||
bookingEnd: formatTime(unscheduledIncident.bookingEnd),
|
||||
incidentType: incidentType.UNSCHEDULED_INCIDENT,
|
||||
incidentType: incidentTypeNumber,
|
||||
timeIntervalsToCharge: unscheduledIncident.timeIntervalsToCharge,
|
||||
chargePrice: unscheduledIncident.chargePrice,
|
||||
totalChargeFee: unscheduledIncident.totalChargeFee,
|
||||
|
||||
Reference in New Issue
Block a user