Changed formating for Reservation and additional charge / fixed bugs
This commit is contained in:
@@ -88,7 +88,7 @@ const incidentTypeExplanations = {};
|
|||||||
incidentTypeExplanations[incidentType.UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION] = 'Door left unlocked';
|
incidentTypeExplanations[incidentType.UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION] = 'Door left unlocked';
|
||||||
incidentTypeExplanations[incidentType.UNLOCKED_INCIDENT_STANDALONE] = 'Door left unlocked';
|
incidentTypeExplanations[incidentType.UNLOCKED_INCIDENT_STANDALONE] = 'Door left unlocked';
|
||||||
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_BEFORE_RESERVATION] = 'Room used before reservation started';
|
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_BEFORE_RESERVATION] = 'Room used before reservation started';
|
||||||
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_AFTER_RESERVATION] = 'Room used after reservation started';
|
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_AFTER_RESERVATION] = 'Room used after reservation ended';
|
||||||
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_STANDALONE] = 'Room used without reservation';
|
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_STANDALONE] = 'Room used without reservation';
|
||||||
incidentTypeExplanations[incidentType.BOOKING_MOVED_TO_ANOTHER_DAY] = 'Reservation moved to another day';
|
incidentTypeExplanations[incidentType.BOOKING_MOVED_TO_ANOTHER_DAY] = 'Reservation moved to another day';
|
||||||
incidentTypeExplanations[incidentType.BOOKING_SHORTENED] = 'Reservation shortened';
|
incidentTypeExplanations[incidentType.BOOKING_SHORTENED] = 'Reservation shortened';
|
||||||
@@ -104,7 +104,8 @@ const UNSCHEDULED_CHARGE_PRICE = parseFloat(process.env.UNSCHEDULED_USE_CHARGE_P
|
|||||||
|
|
||||||
const BOOKING_CHANGE_PERCENTAGE_CHARGE = parseInt(process.env.BOOKING_CHANGE_PERCENTAGE_CHARGE) || 100;
|
const BOOKING_CHANGE_PERCENTAGE_CHARGE = parseInt(process.env.BOOKING_CHANGE_PERCENTAGE_CHARGE) || 100;
|
||||||
|
|
||||||
const ALLOWED_BOOKING_CANCELLATION_TIME= parseInt(process.env.ALLOWED_BOOKING_CANCELLATION_TIME) || 30;
|
const CHARGE_BOOKING_CHANGE_UNDER_TIME = parseInt(process.env.CHARGE_BOOKING_CHANGE_UNDER_TIME) || 1430;
|
||||||
|
const ALLOWED_BOOKING_CANCELLATION_TIME = parseInt(process.env.ALLOWED_BOOKING_CANCELLATION_TIME) || 30;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
VALID_CSV_HEADERS,
|
VALID_CSV_HEADERS,
|
||||||
@@ -124,5 +125,6 @@ module.exports = {
|
|||||||
UNSCHEDULED_TIME_RESOLUTION,
|
UNSCHEDULED_TIME_RESOLUTION,
|
||||||
UNSCHEDULED_CHARGE_PRICE,
|
UNSCHEDULED_CHARGE_PRICE,
|
||||||
BOOKING_CHANGE_PERCENTAGE_CHARGE,
|
BOOKING_CHANGE_PERCENTAGE_CHARGE,
|
||||||
|
CHARGE_BOOKING_CHANGE_UNDER_TIME,
|
||||||
ALLOWED_BOOKING_CANCELLATION_TIME,
|
ALLOWED_BOOKING_CANCELLATION_TIME,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ UNLOCK_STREAK_REPAIR_AFTER=Number of months without incidents to reset user inci
|
|||||||
|
|
||||||
BOOKING_CHANGE_PERCENTAGE_CHARGE=Percentage of hourly reate to apply for cancellation-like charges
|
BOOKING_CHANGE_PERCENTAGE_CHARGE=Percentage of hourly reate to apply for cancellation-like charges
|
||||||
|
|
||||||
|
CHARGE_BOOKING_CHANGE_UNDER_TIME=Time to booking start when booking change will be charged (in minutes) [Default is 1430 = 24*60 - 10; that is 24hrs - 10 minutes for booking change tracking cycle]
|
||||||
ALLOWED_BOOKING_CANCELLATION_TIME=Time from creation (in minutes) in which cancellation is not charged
|
ALLOWED_BOOKING_CANCELLATION_TIME=Time from creation (in minutes) in which cancellation is not charged
|
||||||
|
|
||||||
SEQUELIZE_LOGGING=0 - false, 1 - true (console logging)
|
SEQUELIZE_LOGGING=0 - false, 1 - true (console logging)
|
||||||
|
|||||||
@@ -4,7 +4,13 @@ const moment = require('moment-timezone');
|
|||||||
const db = require('../../models/index');
|
const db = require('../../models/index');
|
||||||
const Op = require('sequelize').Op;
|
const Op = require('sequelize').Op;
|
||||||
|
|
||||||
const { UI_TIMEZONE, BOOKING_CHANGE_PERCENTAGE_CHARGE, ALLOWED_BOOKING_CANCELLATION_TIME, incidentType } = require('../../constants/constants');
|
const {
|
||||||
|
UI_TIMEZONE,
|
||||||
|
BOOKING_CHANGE_PERCENTAGE_CHARGE,
|
||||||
|
CHARGE_BOOKING_CHANGE_UNDER_TIME,
|
||||||
|
ALLOWED_BOOKING_CANCELLATION_TIME,
|
||||||
|
incidentType
|
||||||
|
} = require('../../constants/constants');
|
||||||
|
|
||||||
const bulkWriteBookingChangeIncidents = (incidents) => {
|
const bulkWriteBookingChangeIncidents = (incidents) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@@ -44,10 +50,9 @@ const chargeBookingChanges = (changes) => {
|
|||||||
const oldReservationLength = oldEnd.diff(oldStart, 'hours', true);
|
const oldReservationLength = oldEnd.diff(oldStart, 'hours', true);
|
||||||
const newReservationLength = newEnd.diff(newStart, 'hours', true);
|
const newReservationLength = newEnd.diff(newStart, 'hours', true);
|
||||||
|
|
||||||
const differenceFromNow = oldStart.diff(moment.utc(), 'hours');
|
const differenceFromNow = oldStart.diff(moment.utc(), 'minutes');
|
||||||
|
|
||||||
if (differenceFromNow < 24){
|
if (differenceFromNow < CHARGE_BOOKING_CHANGE_UNDER_TIME){
|
||||||
// Changed reservation that was within 24hrs from now
|
|
||||||
const { reservationId, memberId, resourceId } = newReservation;
|
const { reservationId, memberId, resourceId } = newReservation;
|
||||||
|
|
||||||
if (!canceled) {
|
if (!canceled) {
|
||||||
@@ -101,7 +106,7 @@ const chargeBookingChanges = (changes) => {
|
|||||||
const differenceFromCreation = moment.utc().diff(reservationCreationTimestamp, 'minutes');
|
const differenceFromCreation = moment.utc().diff(reservationCreationTimestamp, 'minutes');
|
||||||
|
|
||||||
if (differenceFromCreation > ALLOWED_BOOKING_CANCELLATION_TIME){
|
if (differenceFromCreation > ALLOWED_BOOKING_CANCELLATION_TIME){
|
||||||
const chargeFee = 2 * reservationHourlyRate * oldReservationLength * BOOKING_CHANGE_PERCENTAGE_CHARGE / 100;
|
const chargeFee = reservationHourlyRate * oldReservationLength * BOOKING_CHANGE_PERCENTAGE_CHARGE / 100;
|
||||||
const incident = {
|
const incident = {
|
||||||
reservationId,
|
reservationId,
|
||||||
memberId,
|
memberId,
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ const createFeeFromIncident = (incident) => {
|
|||||||
bookingTimeExplanation = `${bookingStartMoment.clone().format('HH:mm a')} - ${bookingEndMoment.clone().format('HH:mm a')}`;
|
bookingTimeExplanation = `${bookingStartMoment.clone().format('HH:mm a')} - ${bookingEndMoment.clone().format('HH:mm a')}`;
|
||||||
incidentTimeExplanation = ''; // `UNLOCK : ${unlockMoment.clone().format('HH:mm a')}`;
|
incidentTimeExplanation = ''; // `UNLOCK : ${unlockMoment.clone().format('HH:mm a')}`;
|
||||||
additionalIncidentExplanation = ` ${unlockedIncidentLevelsPrices[incidentLevel].description},`;
|
additionalIncidentExplanation = ` ${unlockedIncidentLevelsPrices[incidentLevel].description},`;
|
||||||
incidentTypeExplanation = '[Additional charge]';
|
incidentTypeExplanation = '';
|
||||||
|
|
||||||
date = bookingStartMoment.clone().startOf('day').format();
|
date = bookingStartMoment.clone().startOf('day').format();
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ const createFeeFromIncident = (incident) => {
|
|||||||
dateExplanation = bookingStartMoment.clone().startOf('day').format('MMM DD');
|
dateExplanation = bookingStartMoment.clone().startOf('day').format('MMM DD');
|
||||||
bookingTimeExplanation = `${bookingStartMoment.clone().format('HH:mm a')} - ${bookingEndMoment.clone().format('HH:mm a')}`;
|
bookingTimeExplanation = `${bookingStartMoment.clone().format('HH:mm a')} - ${bookingEndMoment.clone().format('HH:mm a')}`;
|
||||||
incidentTimeExplanation = ` Unlock : ${unlockMoment.clone().format('HH:mm a')},`;
|
incidentTimeExplanation = ` Unlock : ${unlockMoment.clone().format('HH:mm a')},`;
|
||||||
incidentTypeExplanation = '[Additional charge]';
|
incidentTypeExplanation = '';
|
||||||
|
|
||||||
date = bookingStartMoment.clone().startOf('day').format();
|
date = bookingStartMoment.clone().startOf('day').format();
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ const createFeeFromIncident = (incident) => {
|
|||||||
dateExplanation = bookingStartMoment.clone().startOf('day').format('MMM DD');
|
dateExplanation = bookingStartMoment.clone().startOf('day').format('MMM DD');
|
||||||
bookingTimeExplanation = `${bookingStartMoment.clone().format('HH:mm a')} - ${bookingEndMoment.clone().format('HH:mm a')}`;
|
bookingTimeExplanation = `${bookingStartMoment.clone().format('HH:mm a')} - ${bookingEndMoment.clone().format('HH:mm a')}`;
|
||||||
incidentTimeExplanation = ` Lock : ${lockMoment.clone().format('HH:mm a')},`;
|
incidentTimeExplanation = ` Lock : ${lockMoment.clone().format('HH:mm a')},`;
|
||||||
incidentTypeExplanation = '[Additional charge]';
|
incidentTypeExplanation = '';
|
||||||
|
|
||||||
date = bookingStartMoment.clone().startOf('day').format();
|
date = bookingStartMoment.clone().startOf('day').format();
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ const createFeeFromIncident = (incident) => {
|
|||||||
bookingTimeExplanation = `No reservation`;
|
bookingTimeExplanation = `No reservation`;
|
||||||
incidentTimeExplanation = ''; // `UNLOCK : ${unlockMoment.clone().format('HH:mm a')}`;
|
incidentTimeExplanation = ''; // `UNLOCK : ${unlockMoment.clone().format('HH:mm a')}`;
|
||||||
additionalIncidentExplanation = ` ${unlockedIncidentLevelsPrices[incidentLevel].description},`;
|
additionalIncidentExplanation = ` ${unlockedIncidentLevelsPrices[incidentLevel].description},`;
|
||||||
incidentTypeExplanation = '[Additional charge]';
|
incidentTypeExplanation = '';
|
||||||
|
|
||||||
date = unlockMoment.clone().startOf('day').format();
|
date = unlockMoment.clone().startOf('day').format();
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ const createFeeFromIncident = (incident) => {
|
|||||||
dateExplanation = unlockMoment.clone().startOf('day').format('MMM DD');
|
dateExplanation = unlockMoment.clone().startOf('day').format('MMM DD');
|
||||||
bookingTimeExplanation = `No reservation`;
|
bookingTimeExplanation = `No reservation`;
|
||||||
incidentTimeExplanation = ` Unlock : ${unlockMoment.clone().format('HH:mm a')} Lock : ${lockMoment.clone().format('HH:mm a')},`;
|
incidentTimeExplanation = ` Unlock : ${unlockMoment.clone().format('HH:mm a')} Lock : ${lockMoment.clone().format('HH:mm a')},`;
|
||||||
incidentTypeExplanation = '[Additional charge]';
|
incidentTypeExplanation = '';
|
||||||
|
|
||||||
date = unlockMoment.clone().startOf('day').format();
|
date = unlockMoment.clone().startOf('day').format();
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ const createFeeFromBooking = (booking, resourceMappings) => {
|
|||||||
const formattedStartTime = startMoment.format('HH:mm a');
|
const formattedStartTime = startMoment.format('HH:mm a');
|
||||||
const formattedEndTime = endMoment.format('HH:mm a');
|
const formattedEndTime = endMoment.format('HH:mm a');
|
||||||
|
|
||||||
const formattedName = `[Reservation] ${officeName}, ${resourceName}, ${formattedDate} [${formattedStartTime} - ${formattedEndTime}]`;
|
const formattedName = `${officeName}, ${resourceName}, ${formattedDate} [${formattedStartTime} - ${formattedEndTime}]`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: formattedName,
|
name: formattedName,
|
||||||
|
|||||||
Reference in New Issue
Block a user