track room change for booking change incidents
This commit is contained in:
@@ -22,12 +22,14 @@ const bulkWriteBookingChangeIncidents = (incidents) => {
|
||||
|
||||
const chargeBookingChanges = (changes) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log(changes);
|
||||
if (Array.isArray(changes)){
|
||||
const incidents = [];
|
||||
const errors = [];
|
||||
changes.forEach((change) => {
|
||||
const { oldReservation, newReservation } = change;
|
||||
if (oldReservation && newReservation){
|
||||
const oldResourceId = oldReservation.resourceId;
|
||||
const oldStart = oldReservation.start ? moment.utc(oldReservation.start) : null;
|
||||
const oldEnd = oldReservation.end ? moment.utc(oldReservation.end) : null;
|
||||
|
||||
@@ -56,14 +58,14 @@ const chargeBookingChanges = (changes) => {
|
||||
// Check if member shortened the reservation
|
||||
|
||||
if (newReservationLength < oldReservationLength){
|
||||
|
||||
const differenceInLength = oldReservationLength - newReservationLength;
|
||||
const chargeFee = differenceInLength*hourlyRate*BOOKING_CHANGE_PERCENTAGE_CHARGE/100;
|
||||
|
||||
const incident = {
|
||||
reservationId,
|
||||
memberId,
|
||||
resourceId,
|
||||
oldResourceId: oldResourceId || newReservation.resourceId,
|
||||
newResourceId: newReservation.resourceId,
|
||||
oldBookingStart: oldReservation.start,
|
||||
oldBookingEnd: oldReservation.end,
|
||||
newBookingStart: newReservation.start,
|
||||
@@ -82,7 +84,8 @@ const chargeBookingChanges = (changes) => {
|
||||
const incident = {
|
||||
reservationId,
|
||||
memberId,
|
||||
resourceId,
|
||||
oldResourceId: oldResourceId || newReservation.resourceId,
|
||||
newResourceId: newReservation.resourceId,
|
||||
oldBookingStart: oldReservation.start,
|
||||
oldBookingEnd: oldReservation.end,
|
||||
newBookingStart: newReservation.start,
|
||||
|
||||
Reference in New Issue
Block a user