Merge branch 'change-fees-formatting-again' into 'master'

change fees name format

See merge request saburly/psihologija!44
This commit was merged in pull request #44.
This commit is contained in:
Bilal Catic
2019-08-26 12:32:34 +00:00
2 changed files with 37 additions and 32 deletions

View File

@@ -91,8 +91,8 @@ incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_BEFORE_RESERVATION]
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_AFTER_RESERVATION] = 'Room used after reservation ended'; 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 after grace period';
incidentTypeExplanations[incidentType.BOOKING_CANCELED_LATE] = 'A reservation canceled after the grace period'; incidentTypeExplanations[incidentType.BOOKING_CANCELED_LATE] = 'Reservation cancelled after grace period';
const UI_TIMEZONE = process.env.UI_TIMEZONE || 'America/Los_Angeles'; const UI_TIMEZONE = process.env.UI_TIMEZONE || 'America/Los_Angeles';

View File

@@ -36,7 +36,7 @@ const createFeeFromIncident = (incident) => {
} = incident; } = incident;
const incidentTypeNumber = incident.incidentType; const incidentTypeNumber = incident.incidentType;
const incidentExplanation = incidentTypeExplanations[incidentTypeNumber]; let incidentExplanation = incidentTypeExplanations[incidentTypeNumber];
let date = ''; let date = '';
let price = 0; let price = 0;
@@ -65,10 +65,10 @@ const createFeeFromIncident = (incident) => {
switch (incidentTypeNumber){ switch (incidentTypeNumber){
case incidentType.UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION: case incidentType.UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION:
roomExplanation = resourceName; roomExplanation = resourceName;
dateExplanation = bookingStartMoment.clone().startOf('day').format('ddd, 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')} to ${bookingEndMoment.clone().format('HH:mm')}]`;
incidentTimeExplanation = ''; // `UNLOCK : ${unlockMoment.clone().format('HH:mm a')}`; incidentTimeExplanation = ''; // `UNLOCK : ${unlockMoment.clone().format('HH:mm a')}`;
additionalIncidentExplanation = ` ${unlockedIncidentLevelsPrices[incidentLevel].description},`; incidentExplanation += ` ${unlockedIncidentLevelsPrices[incidentLevel].description},`;
incidentTypeExplanation = ''; incidentTypeExplanation = '';
date = bookingStartMoment.clone().startOf('day').format(); date = bookingStartMoment.clone().startOf('day').format();
@@ -79,8 +79,8 @@ const createFeeFromIncident = (incident) => {
break; break;
case incidentType.UNSCHEDULED_INCIDENT_BEFORE_RESERVATION: case incidentType.UNSCHEDULED_INCIDENT_BEFORE_RESERVATION:
roomExplanation = resourceName; roomExplanation = resourceName;
dateExplanation = bookingStartMoment.clone().startOf('day').format('ddd, 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')} to ${bookingEndMoment.clone().format('HH:mm')}]`;
incidentTimeExplanation = ` Unlock : ${unlockMoment.clone().format('HH:mm a')},`; incidentTimeExplanation = ` Unlock : ${unlockMoment.clone().format('HH:mm a')},`;
incidentTypeExplanation = ''; incidentTypeExplanation = '';
@@ -92,8 +92,8 @@ const createFeeFromIncident = (incident) => {
break; break;
case incidentType.UNSCHEDULED_INCIDENT_AFTER_RESERVATION: case incidentType.UNSCHEDULED_INCIDENT_AFTER_RESERVATION:
roomExplanation = resourceName; roomExplanation = resourceName;
dateExplanation = bookingStartMoment.clone().startOf('day').format('ddd, 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')} to ${bookingEndMoment.clone().format('HH:mm')}]`;
incidentTimeExplanation = ` Lock : ${lockMoment.clone().format('HH:mm a')},`; incidentTimeExplanation = ` Lock : ${lockMoment.clone().format('HH:mm a')},`;
incidentTypeExplanation = ''; incidentTypeExplanation = '';
@@ -105,10 +105,10 @@ const createFeeFromIncident = (incident) => {
break; break;
case incidentType.UNLOCKED_INCIDENT_STANDALONE: case incidentType.UNLOCKED_INCIDENT_STANDALONE:
roomExplanation = resourceName; roomExplanation = resourceName;
dateExplanation = unlockMoment.clone().startOf('day').format('ddd, MMM DD'); dateExplanation = unlockMoment.clone().startOf('day').format('MMM DD');
bookingTimeExplanation = `No reservation`; bookingTimeExplanation = `[${unlockMoment.clone().format('HH:mm')} to ${lockMoment.clone().format('HH:mm')}]`;
incidentTimeExplanation = ''; // `UNLOCK : ${unlockMoment.clone().format('HH:mm a')}`; incidentTimeExplanation = ''; // `UNLOCK : ${unlockMoment.clone().format('HH:mm a')}`;
additionalIncidentExplanation = ` ${unlockedIncidentLevelsPrices[incidentLevel].description},`; incidentExplanation += ` ${unlockedIncidentLevelsPrices[incidentLevel].description},`;
incidentTypeExplanation = ''; incidentTypeExplanation = '';
date = unlockMoment.clone().startOf('day').format(); date = unlockMoment.clone().startOf('day').format();
@@ -119,8 +119,8 @@ const createFeeFromIncident = (incident) => {
break; break;
case incidentType.UNSCHEDULED_INCIDENT_STANDALONE: case incidentType.UNSCHEDULED_INCIDENT_STANDALONE:
roomExplanation = resourceName; roomExplanation = resourceName;
dateExplanation = unlockMoment.clone().startOf('day').format('ddd, MMM DD'); dateExplanation = unlockMoment.clone().startOf('day').format('MMM DD');
bookingTimeExplanation = `No reservation`; bookingTimeExplanation = `[${unlockMoment.clone().format('HH:mm')} to ${lockMoment.clone().format('HH:mm')}]`;
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 = ''; incidentTypeExplanation = '';
@@ -131,14 +131,16 @@ const createFeeFromIncident = (incident) => {
// priceExplanation = `$${totalChargeFee.toFixed(2)}, ${quantity} x $${price.toFixed(2)}`; // priceExplanation = `$${totalChargeFee.toFixed(2)}, ${quantity} x $${price.toFixed(2)}`;
break; break;
case incidentType.BOOKING_MOVED_TO_ANOTHER_DAY: case incidentType.BOOKING_MOVED_TO_ANOTHER_DAY:
if (oldResourceName !== newResourceName){ // if (oldResourceName !== newResourceName){
roomExplanation = `${oldResourceName} -> ${newResourceName}`; // roomExplanation = `${oldResourceName} -> ${newResourceName}`;
}else{ // }else{
roomExplanation = oldResourceName; // roomExplanation = oldResourceName;
} // }
roomExplanation = newResourceName;
dateExplanation = `${oldBookingStartMoment.clone().format('ddd, MMM DD')} -> ${newBookingStartMoment.clone().format('ddd, MMM DD')}`; // dateExplanation = `${oldBookingStartMoment.clone().format('ddd, MMM DD')} -> ${newBookingStartMoment.clone().format('ddd, MMM DD')}`;
bookingTimeExplanation = `(${oldBookingStartMoment.clone().format('HH:mm a')} - ${oldBookingEndMoment.clone().format('HH:mm a')}) -> (${newBookingStartMoment.clone().format('HH:mm a')} - ${newBookingEndMoment.clone().format('HH:mm a')})`; dateExplanation = `${incidentTimestampMoment.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 a')},`; incidentTimeExplanation = ` Moved on : ${incidentTimestampMoment.clone().format('MMM DD, HH:mm a')},`;
incidentTypeExplanation = '[Cancellation]'; incidentTypeExplanation = '[Cancellation]';
@@ -149,14 +151,16 @@ const createFeeFromIncident = (incident) => {
// priceExplanation = `$${totalChargeFee.toFixed(2)}, 1 x $${price.toFixed(2)}`; // priceExplanation = `$${totalChargeFee.toFixed(2)}, 1 x $${price.toFixed(2)}`;
break; break;
case incidentType.BOOKING_SHORTENED: case incidentType.BOOKING_SHORTENED:
if (oldResourceName !== newResourceName){ // if (oldResourceName !== newResourceName){
roomExplanation = `${oldResourceName} -> ${newResourceName}`; // roomExplanation = `${oldResourceName} -> ${newResourceName}`;
}else{ // }else{
roomExplanation = oldResourceName; // roomExplanation = oldResourceName;
} // }
roomExplanation = newResourceName;
dateExplanation = `${oldBookingStartMoment.clone().format('ddd, MMM DD')}`; // dateExplanation = `${oldBookingStartMoment.clone().format('ddd, MMM DD')}`;
bookingTimeExplanation = `(${oldBookingStartMoment.clone().format('HH:mm a')} - ${oldBookingEndMoment.clone().format('HH:mm a')}) -> (${newBookingStartMoment.clone().format('HH:mm a')} - ${newBookingEndMoment.clone().format('HH:mm a')})`; dateExplanation = `${incidentTimestampMoment.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 a')},`; incidentTimeExplanation = ` Shortened on : ${incidentTimestampMoment.clone().format('MMM DD, HH:mm a')},`;
incidentTypeExplanation = '[Cancellation]'; incidentTypeExplanation = '[Cancellation]';
@@ -168,8 +172,9 @@ const createFeeFromIncident = (incident) => {
break; break;
case incidentType.BOOKING_CANCELED_LATE: case incidentType.BOOKING_CANCELED_LATE:
roomExplanation = oldResourceName; roomExplanation = oldResourceName;
dateExplanation = `${oldBookingStartMoment.clone().format('ddd, MMM DD')}`; // dateExplanation = `${oldBookingStartMoment.clone().format('ddd, MMM DD')}`;
bookingTimeExplanation = `${oldBookingStartMoment.clone().format('HH:mm a')} - ${oldBookingEndMoment.clone().format('HH:mm a')}`; dateExplanation = `${incidentTimestampMoment.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 a')},`; incidentTimeExplanation = ` Canceled on : ${incidentTimestampMoment.clone().format('MMM DD, HH:mm a')},`;
incidentTypeExplanation = '[Cancellation]'; incidentTypeExplanation = '[Cancellation]';
@@ -181,7 +186,7 @@ const createFeeFromIncident = (incident) => {
break; break;
} }
const formattedName = `${dateExplanation}, ${bookingTimeExplanation}, ${roomExplanation}, ${incidentExplanation}, ${officeName}`; const formattedName = `${dateExplanation} ${bookingTimeExplanation} ${roomExplanation}, ${officeName}, ${incidentExplanation}`;
return { return {
name: formattedName, name: formattedName,