make booking change charge under time flexible with env variable

This commit is contained in:
Bilal Catic
2019-08-08 14:18:59 +02:00
parent 7fbb1d9dee
commit 2ff584c20b
3 changed files with 13 additions and 5 deletions

View File

@@ -4,7 +4,13 @@ const moment = require('moment-timezone');
const db = require('../../models/index');
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) => {
return new Promise((resolve, reject) => {
@@ -44,10 +50,9 @@ const chargeBookingChanges = (changes) => {
const oldReservationLength = oldEnd.diff(oldStart, '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){
// Changed reservation that was within 24hrs from now
if (differenceFromNow < CHARGE_BOOKING_CHANGE_UNDER_TIME){
const { reservationId, memberId, resourceId } = newReservation;
if (!canceled) {