Merge branch 'fix-fees-formatting' into 'master'
Fix fees formatting See merge request saburly/psihologija!31
This commit was merged in pull request #31.
This commit is contained in:
@@ -39,9 +39,10 @@ const createFeeFromIncident = (incident) => {
|
|||||||
let date = '';
|
let date = '';
|
||||||
let price = 0;
|
let price = 0;
|
||||||
let quantity = 0;
|
let quantity = 0;
|
||||||
let priceExplanation = '';
|
// let priceExplanation = '';
|
||||||
let bookingTimeExplanation = '';
|
let bookingTimeExplanation = '';
|
||||||
let incidentTimeExplanation = '';
|
let incidentTimeExplanation = '';
|
||||||
|
let incidentTypeExplanation = '';
|
||||||
let additionalIncidentExplanation = '';
|
let additionalIncidentExplanation = '';
|
||||||
|
|
||||||
let roomExplanation = '';
|
let roomExplanation = '';
|
||||||
@@ -62,67 +63,70 @@ 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('MMM DD, YYYY');
|
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')}`;
|
||||||
unlockedIncidentLevelsPrices[incidentLevel].description
|
additionalIncidentExplanation = ` ${unlockedIncidentLevelsPrices[incidentLevel].description},`;
|
||||||
additionalIncidentExplanation = unlockedIncidentLevelsPrices[incidentLevel].description;
|
incidentTypeExplanation = '[Additional charge]';
|
||||||
|
|
||||||
date = bookingStartMoment.clone().startOf('day').format();
|
date = bookingStartMoment.clone().startOf('day').format();
|
||||||
|
|
||||||
price = incidentPrice;
|
price = +incidentPrice.toFixed(2);
|
||||||
quantity = 1;
|
quantity = 1.00;
|
||||||
priceExplanation = `$${price.toFixed(2)}, 1 x $${price.toFixed(2)}`;
|
// priceExplanation = `$${price}, 1 x $${price.toFixed(2)}`;
|
||||||
break;
|
break;
|
||||||
case incidentType.UNSCHEDULED_INCIDENT_BEFORE_RESERVATION:
|
case incidentType.UNSCHEDULED_INCIDENT_BEFORE_RESERVATION:
|
||||||
roomExplanation = resourceName;
|
roomExplanation = resourceName;
|
||||||
dateExplanation = bookingStartMoment.clone().startOf('day').format('MMM DD, YYYY');
|
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]';
|
||||||
|
|
||||||
date = bookingStartMoment.clone().startOf('day').format();
|
date = bookingStartMoment.clone().startOf('day').format();
|
||||||
|
|
||||||
price = chargePrice;
|
price = +chargePrice.toFixed(2);
|
||||||
quantity = timeIntervalsToCharge;
|
quantity = +timeIntervalsToCharge.toFixed(2);
|
||||||
priceExplanation = `$${totalChargeFee.toFixed(2)}, ${quantity} x $${price.toFixed(2)}`;
|
// priceExplanation = `$${totalChargeFee.toFixed(2)}, ${quantity} x $${price.toFixed(2)}`;
|
||||||
break;
|
break;
|
||||||
case incidentType.UNSCHEDULED_INCIDENT_AFTER_RESERVATION:
|
case incidentType.UNSCHEDULED_INCIDENT_AFTER_RESERVATION:
|
||||||
roomExplanation = resourceName;
|
roomExplanation = resourceName;
|
||||||
dateExplanation = bookingStartMoment.clone().startOf('day').format('MMM DD, YYYY');
|
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]';
|
||||||
|
|
||||||
date = bookingStartMoment.clone().startOf('day').format();
|
date = bookingStartMoment.clone().startOf('day').format();
|
||||||
|
|
||||||
price = chargePrice;
|
price = +chargePrice.toFixed(2);
|
||||||
quantity = timeIntervalsToCharge;
|
quantity = +timeIntervalsToCharge.toFixed(2);
|
||||||
priceExplanation = `$${totalChargeFee.toFixed(2)}, ${quantity} x $${price.toFixed(2)}`;
|
// priceExplanation = `$${totalChargeFee.toFixed(2)}, ${quantity} x $${price.toFixed(2)}`;
|
||||||
break;
|
break;
|
||||||
case incidentType.UNLOCKED_INCIDENT_STANDALONE:
|
case incidentType.UNLOCKED_INCIDENT_STANDALONE:
|
||||||
roomExplanation = resourceName;
|
roomExplanation = resourceName;
|
||||||
dateExplanation = unlockMoment.clone().startOf('day').format('MMM DD, YYYY');
|
dateExplanation = unlockMoment.clone().startOf('day').format('MMM DD');
|
||||||
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]';
|
||||||
|
|
||||||
date = unlockMoment.clone().startOf('day').format();
|
date = unlockMoment.clone().startOf('day').format();
|
||||||
|
|
||||||
price = incidentPrice;
|
price = +incidentPrice.toFixed(2);
|
||||||
quantity = 1;
|
quantity = 1.00;
|
||||||
priceExplanation = `$${price.toFixed(2)}, 1 x $${price.toFixed(2)}`;
|
// priceExplanation = `$${price.toFixed(2)}, 1 x $${price.toFixed(2)}`;
|
||||||
break;
|
break;
|
||||||
case incidentType.UNSCHEDULED_INCIDENT_STANDALONE:
|
case incidentType.UNSCHEDULED_INCIDENT_STANDALONE:
|
||||||
roomExplanation = resourceName;
|
roomExplanation = resourceName;
|
||||||
dateExplanation = unlockMoment.clone().startOf('day').format('MMM DD, YYYY');
|
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')},`;
|
||||||
additionalIncidentExplanation = '';
|
incidentTypeExplanation = '[Additional charge]';
|
||||||
|
|
||||||
date = unlockMoment.clone().startOf('day').format();
|
date = unlockMoment.clone().startOf('day').format();
|
||||||
|
|
||||||
price = chargePrice;
|
price = +chargePrice.toFixed(2);
|
||||||
quantity = timeIntervalsToCharge;
|
quantity = +timeIntervalsToCharge.toFixed(2);
|
||||||
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){
|
||||||
@@ -131,15 +135,16 @@ const createFeeFromIncident = (incident) => {
|
|||||||
roomExplanation = oldResourceName;
|
roomExplanation = oldResourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
dateExplanation = `${oldBookingStartMoment.clone().format('MMM DD, YYYY')} -> ${newBookingStartMoment.clone().format('MMM DD, YYYY')}`;
|
dateExplanation = `${oldBookingStartMoment.clone().format('MMM DD')} -> ${newBookingStartMoment.clone().format('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')})`;
|
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')})`;
|
||||||
incidentTimeExplanation = `MOVED ON : ${incidentTimestampMoment.clone().format('MMM DD, YYYY')}`;
|
incidentTimeExplanation = ` Moved on : ${incidentTimestampMoment.clone().format('MMM DD, HH:mm a')},`;
|
||||||
|
incidentTypeExplanation = '[Cancellation]';
|
||||||
|
|
||||||
date = incidentTimestampMoment.clone().startOf('day').format();
|
date = incidentTimestampMoment.clone().startOf('day').format();
|
||||||
|
|
||||||
price = totalChargeFee;
|
price = +totalChargeFee.toFixed(2);
|
||||||
quantity = 1;
|
quantity = 1.00;
|
||||||
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){
|
||||||
@@ -148,31 +153,33 @@ const createFeeFromIncident = (incident) => {
|
|||||||
roomExplanation = oldResourceName;
|
roomExplanation = oldResourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
dateExplanation = `${oldBookingStartMoment.clone().format('MMM DD, YYYY')}`;
|
dateExplanation = `${oldBookingStartMoment.clone().format('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')})`;
|
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')})`;
|
||||||
incidentTimeExplanation = `SHORTENED ON : ${incidentTimestampMoment.clone().format('MMM DD, YYYY')}`;
|
incidentTimeExplanation = ` Shortened on : ${incidentTimestampMoment.clone().format('MMM DD, HH:mm a')},`;
|
||||||
|
incidentTypeExplanation = '[Cancellation]';
|
||||||
|
|
||||||
date = incidentTimestampMoment.clone().startOf('day').format();
|
date = incidentTimestampMoment.clone().startOf('day').format();
|
||||||
|
|
||||||
price = totalChargeFee;
|
price = +totalChargeFee.toFixed(2);
|
||||||
quantity = 1;
|
quantity = 1.00;
|
||||||
priceExplanation = `$${totalChargeFee.toFixed(2)}, 1 x $${price.toFixed(2)}`;
|
// priceExplanation = `$${totalChargeFee.toFixed(2)}, 1 x $${price.toFixed(2)}`;
|
||||||
break;
|
break;
|
||||||
case incidentType.BOOKING_CANCELED_LATE:
|
case incidentType.BOOKING_CANCELED_LATE:
|
||||||
roomExplanation = oldResourceName;
|
roomExplanation = oldResourceName;
|
||||||
dateExplanation = `${oldBookingStartMoment.clone().format('MMM DD, YYYY')}`;
|
dateExplanation = `${oldBookingStartMoment.clone().format('MMM DD')}`;
|
||||||
bookingTimeExplanation = `${oldBookingStartMoment.clone().format('HH:mm a')} - ${oldBookingEndMoment.clone().format('HH:mm a')}`;
|
bookingTimeExplanation = `${oldBookingStartMoment.clone().format('HH:mm a')} - ${oldBookingEndMoment.clone().format('HH:mm a')}`;
|
||||||
incidentTimeExplanation = `CANCELED ON : ${incidentTimestampMoment.clone().format('MMM DD, YYYY')}`;
|
incidentTimeExplanation = ` Canceled on : ${incidentTimestampMoment.clone().format('MMM DD, HH:mm a')},`;
|
||||||
|
incidentTypeExplanation = '[Cancellation]';
|
||||||
|
|
||||||
date = incidentTimestampMoment.clone().startOf('day').format();
|
date = incidentTimestampMoment.clone().startOf('day').format();
|
||||||
|
|
||||||
price = totalChargeFee;
|
price = +totalChargeFee.toFixed(2);
|
||||||
quantity = 1;
|
quantity = 1.00;
|
||||||
priceExplanation = `$${totalChargeFee.toFixed(2)}, 1 x $${price.toFixed(2)}`;
|
// priceExplanation = `$${totalChargeFee.toFixed(2)}, 1 x $${price.toFixed(2)}`;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const formattedName = `[INCIDENT FEES] ${officeName}, ${roomExplanation}, ${dateExplanation}, ${bookingTimeExplanation}, ${incidentTimeExplanation}, ${incidentExplanation}, ${additionalIncidentExplanation} ${additionalIncidentExplanation !== '' ? ',' : ''} ${priceExplanation}`;
|
const formattedName = `${incidentTypeExplanation} ${incidentExplanation},${additionalIncidentExplanation}${incidentTimeExplanation} ${officeName}, ${roomExplanation}, ${dateExplanation}, ${bookingTimeExplanation}`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: formattedName,
|
name: formattedName,
|
||||||
@@ -197,18 +204,16 @@ const createFeeFromBooking = (booking, resourceMappings) => {
|
|||||||
const officeName = officesMap[officeId].officeName || 'Unknown';
|
const officeName = officesMap[officeId].officeName || 'Unknown';
|
||||||
const resourceName = resourcesMap[resourceId].resourceName || 'Unknown';
|
const resourceName = resourcesMap[resourceId].resourceName || 'Unknown';
|
||||||
|
|
||||||
const totalCost = (hourlyRate*reservationLength).toFixed(2);
|
const formattedDate = startMoment.clone().startOf('day').format('MMM DD');
|
||||||
|
|
||||||
const formattedDate = startMoment.clone().startOf('day').format('MMM DD, YYYY');
|
|
||||||
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 = `${officeName}, ${resourceName}, $${totalCost}, ${formattedDate} [${formattedStartTime} - ${formattedEndTime}]`;
|
const formattedName = `[Reservation] ${officeName}, ${resourceName}, ${formattedDate} [${formattedStartTime} - ${formattedEndTime}]`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: formattedName,
|
name: formattedName,
|
||||||
price: hourlyRate,
|
price: +hourlyRate.toFixed(2),
|
||||||
quantity: reservationLength,
|
quantity: +reservationLength.toFixed(2),
|
||||||
date: startMoment.startOf('day').toISOString(),
|
date: startMoment.startOf('day').toISOString(),
|
||||||
member: memberId,
|
member: memberId,
|
||||||
team: null,
|
team: null,
|
||||||
|
|||||||
Reference in New Issue
Block a user