Fix wrong date in the charge
This commit is contained in:
@@ -76,7 +76,14 @@ const getIncidentsFromChanges = (changes) => {
|
||||
const reservationHourlyRate = oldReservation.hourlyRate ? oldReservation.hourlyRate : newReservation.hourlyRate;
|
||||
const canceled = newReservation.canceled;
|
||||
|
||||
if (oldStart && oldEnd && newStart && newEnd && reservationHourlyRate){
|
||||
// console.log('oldStart : ', oldStart ? oldStart.format() : 'null');
|
||||
// console.log('oldEnd : ', oldEnd ? oldEnd.format() : 'null ');
|
||||
// console.log('newStart : ', newStart ? newStart.format() : 'null');
|
||||
// console.log('newEnd : ', newEnd ? newEnd.format() : 'null');
|
||||
// console.log('hourly Rate : old : ', oldReservation ? oldReservation.hourlyRate : ' - ', newReservation ? newReservation.hourlyRate : ' - ');
|
||||
// console.log('Canceled : ', newReservation.canceled);
|
||||
|
||||
if (oldStart && oldEnd && newStart && newEnd){
|
||||
const oldReservationLength = oldEnd.diff(oldStart, 'hours', true);
|
||||
const newReservationLength = newEnd.diff(newStart, 'hours', true);
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ const createFeeFromIncident = (incident) => {
|
||||
roomExplanation = newResourceName;
|
||||
|
||||
// dateExplanation = `${oldBookingStartMoment.clone().format('ddd, MMM DD')} -> ${newBookingStartMoment.clone().format('ddd, MMM DD')}`;
|
||||
dateExplanation = `${incidentTimestampMoment.clone().format('MMM DD')}`;
|
||||
dateExplanation = `${newBookingStartMoment.clone().format('MMM DD')}`;
|
||||
bookingTimeExplanation = `[${newBookingStartMoment.clone().format('HH:mm')} to ${newBookingEndMoment.clone().format('HH:mm')}]`;
|
||||
incidentTimeExplanation = `moved on : ${incidentTimestampMoment.clone().format('MMM DD, HH:mm')}`;
|
||||
incidentExplanation += `, ${incidentTimeExplanation}`;
|
||||
@@ -147,7 +147,7 @@ const createFeeFromIncident = (incident) => {
|
||||
roomExplanation = newResourceName;
|
||||
|
||||
// dateExplanation = `${oldBookingStartMoment.clone().format('ddd, MMM DD')}`;
|
||||
dateExplanation = `${incidentTimestampMoment.clone().format('MMM DD')}`;
|
||||
dateExplanation = `${newBookingStartMoment.clone().format('MMM DD')}`;
|
||||
bookingTimeExplanation = `[${newBookingStartMoment.clone().format('HH:mm')} to ${newBookingEndMoment.clone().format('HH:mm')}]`;
|
||||
incidentTimeExplanation = `shortened on : ${incidentTimestampMoment.clone().format('MMM DD, HH:mm')}`;
|
||||
incidentExplanation += `, ${incidentTimeExplanation}`;
|
||||
@@ -160,7 +160,7 @@ const createFeeFromIncident = (incident) => {
|
||||
case incidentType.BOOKING_CANCELED_LATE:
|
||||
roomExplanation = oldResourceName;
|
||||
// dateExplanation = `${oldBookingStartMoment.clone().format('ddd, MMM DD')}`;
|
||||
dateExplanation = `${incidentTimestampMoment.clone().format('MMM DD')}`;
|
||||
dateExplanation = `${oldBookingStartMoment.clone().format('MMM DD')}`;
|
||||
bookingTimeExplanation = `[${oldBookingStartMoment.clone().format('HH:mm')} to ${oldBookingEndMoment.clone().format('HH:mm')}]`;
|
||||
incidentTimeExplanation = `canceled on : ${incidentTimestampMoment.clone().format('MMM DD, HH:mm')}`;
|
||||
incidentExplanation += `, ${incidentTimeExplanation}`;
|
||||
|
||||
@@ -184,7 +184,9 @@ const bulkWriteReservationsWithChangesTracking = (reservations) => {
|
||||
}
|
||||
});
|
||||
|
||||
instance.setDataValue('hourlyRate', instance.previous('hourlyRate'));
|
||||
if (instance.hourlyRate === 0 && parseFloat(instance.previous('hourlyRate')) > 0){
|
||||
instance.setDataValue('hourlyRate', instance.previous('hourlyRate'));
|
||||
}
|
||||
|
||||
if (realChange){
|
||||
changes.push({
|
||||
|
||||
Reference in New Issue
Block a user