Bugfixes / Format change
This commit is contained in:
@@ -91,8 +91,8 @@ const incidentType = {
|
||||
const incidentTypeExplanations = {};
|
||||
incidentTypeExplanations[incidentType.UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION] = 'Door left unlocked';
|
||||
incidentTypeExplanations[incidentType.UNLOCKED_INCIDENT_STANDALONE] = 'Door left unlocked';
|
||||
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_BEFORE_RESERVATION] = 'Room used before reservation started';
|
||||
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_AFTER_RESERVATION] = 'Room used after reservation ended';
|
||||
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_BEFORE_RESERVATION] = 'Room used before reservation';
|
||||
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_AFTER_RESERVATION] = 'Room used after 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_SHORTENED] = 'Reservation shortened after grace period';
|
||||
|
||||
@@ -41,11 +41,8 @@ const createFeeFromIncident = (incident) => {
|
||||
let date = '';
|
||||
let price = 0;
|
||||
let quantity = 0;
|
||||
// let priceExplanation = '';
|
||||
let bookingTimeExplanation = '';
|
||||
let incidentTimeExplanation = '';
|
||||
let incidentTypeExplanation = '';
|
||||
let additionalIncidentExplanation = '';
|
||||
|
||||
let roomExplanation = '';
|
||||
let dateExplanation = '';
|
||||
@@ -67,68 +64,60 @@ const createFeeFromIncident = (incident) => {
|
||||
roomExplanation = resourceName;
|
||||
dateExplanation = bookingStartMoment.clone().startOf('day').format('MMM DD');
|
||||
bookingTimeExplanation = `[${bookingStartMoment.clone().format('HH:mm')} to ${bookingEndMoment.clone().format('HH:mm')}]`;
|
||||
incidentTimeExplanation = ''; // `UNLOCK : ${unlockMoment.clone().format('HH:mm a')}`;
|
||||
incidentExplanation += ` ${unlockedIncidentLevelsPrices[incidentLevel].description},`;
|
||||
incidentTypeExplanation = '';
|
||||
incidentTimeExplanation = `unlock : ${unlockMoment.clone().format('HH:mm')}`;
|
||||
incidentExplanation += `, ${unlockedIncidentLevelsPrices[incidentLevel].description}, ${incidentTimeExplanation}`;
|
||||
|
||||
date = bookingStartMoment.clone().startOf('day').format();
|
||||
|
||||
price = +incidentPrice.toFixed(2);
|
||||
quantity = 1.00;
|
||||
// priceExplanation = `$${price}, 1 x $${price.toFixed(2)}`;
|
||||
break;
|
||||
case incidentType.UNSCHEDULED_INCIDENT_BEFORE_RESERVATION:
|
||||
roomExplanation = resourceName;
|
||||
dateExplanation = bookingStartMoment.clone().startOf('day').format('MMM DD');
|
||||
bookingTimeExplanation = `[${bookingStartMoment.clone().format('HH:mm')} to ${bookingEndMoment.clone().format('HH:mm')}]`;
|
||||
incidentTimeExplanation = ` Unlock : ${unlockMoment.clone().format('HH:mm a')},`;
|
||||
incidentTypeExplanation = '';
|
||||
incidentTimeExplanation = `unlock : ${unlockMoment.clone().format('HH:mm')}`;
|
||||
incidentExplanation += `, ${incidentTimeExplanation}`;
|
||||
|
||||
date = bookingStartMoment.clone().startOf('day').format();
|
||||
|
||||
price = +chargePrice.toFixed(2);
|
||||
quantity = +timeIntervalsToCharge.toFixed(2);
|
||||
// priceExplanation = `$${totalChargeFee.toFixed(2)}, ${quantity} x $${price.toFixed(2)}`;
|
||||
break;
|
||||
case incidentType.UNSCHEDULED_INCIDENT_AFTER_RESERVATION:
|
||||
roomExplanation = resourceName;
|
||||
dateExplanation = bookingStartMoment.clone().startOf('day').format('MMM DD');
|
||||
bookingTimeExplanation = `[${bookingStartMoment.clone().format('HH:mm')} to ${bookingEndMoment.clone().format('HH:mm')}]`;
|
||||
incidentTimeExplanation = ` Lock : ${lockMoment.clone().format('HH:mm a')},`;
|
||||
incidentTypeExplanation = '';
|
||||
incidentTimeExplanation = `lock : ${lockMoment.clone().format('HH:mm')}`;
|
||||
incidentExplanation += `, ${incidentTimeExplanation}`;
|
||||
|
||||
date = bookingStartMoment.clone().startOf('day').format();
|
||||
|
||||
price = +chargePrice.toFixed(2);
|
||||
quantity = +timeIntervalsToCharge.toFixed(2);
|
||||
// priceExplanation = `$${totalChargeFee.toFixed(2)}, ${quantity} x $${price.toFixed(2)}`;
|
||||
break;
|
||||
case incidentType.UNLOCKED_INCIDENT_STANDALONE:
|
||||
roomExplanation = resourceName;
|
||||
dateExplanation = unlockMoment.clone().startOf('day').format('MMM DD');
|
||||
bookingTimeExplanation = `[${unlockMoment.clone().format('HH:mm')} to ${lockMoment.clone().format('HH:mm')}]`;
|
||||
incidentTimeExplanation = ''; // `UNLOCK : ${unlockMoment.clone().format('HH:mm a')}`;
|
||||
incidentExplanation += ` ${unlockedIncidentLevelsPrices[incidentLevel].description},`;
|
||||
incidentTypeExplanation = '';
|
||||
incidentTimeExplanation = `unlock : ${unlockMoment.clone().format('HH:mm')}`;
|
||||
incidentExplanation += `, ${unlockedIncidentLevelsPrices[incidentLevel].description}, ${incidentTimeExplanation}`;
|
||||
|
||||
date = unlockMoment.clone().startOf('day').format();
|
||||
|
||||
price = +incidentPrice.toFixed(2);
|
||||
quantity = 1.00;
|
||||
// priceExplanation = `$${price.toFixed(2)}, 1 x $${price.toFixed(2)}`;
|
||||
break;
|
||||
case incidentType.UNSCHEDULED_INCIDENT_STANDALONE:
|
||||
roomExplanation = resourceName;
|
||||
dateExplanation = unlockMoment.clone().startOf('day').format('MMM DD');
|
||||
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')},`;
|
||||
incidentTypeExplanation = '';
|
||||
//incidentTimeExplanation = `unlock : ${unlockMoment.clone().format('HH:mm')}, lock : ${lockMoment.clone().format('HH:mm')}`;
|
||||
|
||||
date = unlockMoment.clone().startOf('day').format();
|
||||
|
||||
price = +chargePrice.toFixed(2);
|
||||
quantity = +timeIntervalsToCharge.toFixed(2);
|
||||
// priceExplanation = `$${totalChargeFee.toFixed(2)}, ${quantity} x $${price.toFixed(2)}`;
|
||||
break;
|
||||
case incidentType.BOOKING_MOVED_TO_ANOTHER_DAY:
|
||||
// if (oldResourceName !== newResourceName){
|
||||
@@ -141,14 +130,13 @@ const createFeeFromIncident = (incident) => {
|
||||
// dateExplanation = `${oldBookingStartMoment.clone().format('ddd, MMM DD')} -> ${newBookingStartMoment.clone().format('ddd, MMM DD')}`;
|
||||
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')},`;
|
||||
incidentTypeExplanation = '[Cancellation]';
|
||||
incidentTimeExplanation = `moved on : ${incidentTimestampMoment.clone().format('MMM DD, HH:mm')}`;
|
||||
incidentExplanation += `, ${incidentTimeExplanation}`;
|
||||
|
||||
date = incidentTimestampMoment.clone().startOf('day').format();
|
||||
|
||||
price = +totalChargeFee.toFixed(2);
|
||||
quantity = 1.00;
|
||||
// priceExplanation = `$${totalChargeFee.toFixed(2)}, 1 x $${price.toFixed(2)}`;
|
||||
break;
|
||||
case incidentType.BOOKING_SHORTENED:
|
||||
// if (oldResourceName !== newResourceName){
|
||||
@@ -161,28 +149,26 @@ const createFeeFromIncident = (incident) => {
|
||||
// dateExplanation = `${oldBookingStartMoment.clone().format('ddd, MMM DD')}`;
|
||||
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')},`;
|
||||
incidentTypeExplanation = '[Cancellation]';
|
||||
incidentTimeExplanation = `shortened on : ${incidentTimestampMoment.clone().format('MMM DD, HH:mm')}`;
|
||||
incidentExplanation += `, ${incidentTimeExplanation}`;
|
||||
|
||||
date = incidentTimestampMoment.clone().startOf('day').format();
|
||||
|
||||
price = +totalChargeFee.toFixed(2);
|
||||
quantity = 1.00;
|
||||
// priceExplanation = `$${totalChargeFee.toFixed(2)}, 1 x $${price.toFixed(2)}`;
|
||||
break;
|
||||
case incidentType.BOOKING_CANCELED_LATE:
|
||||
roomExplanation = oldResourceName;
|
||||
// dateExplanation = `${oldBookingStartMoment.clone().format('ddd, MMM DD')}`;
|
||||
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')},`;
|
||||
incidentTypeExplanation = '[Cancellation]';
|
||||
incidentTimeExplanation = `canceled on : ${incidentTimestampMoment.clone().format('MMM DD, HH:mm')}`;
|
||||
incidentExplanation += `, ${incidentTimeExplanation}`;
|
||||
|
||||
date = incidentTimestampMoment.clone().startOf('day').format();
|
||||
|
||||
price = +totalChargeFee.toFixed(2);
|
||||
quantity = 1.00;
|
||||
// priceExplanation = `$${totalChargeFee.toFixed(2)}, 1 x $${price.toFixed(2)}`;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -242,7 +228,8 @@ const createNegativeFeeForDiscount = (memberData, dateRange) => {
|
||||
let membershipFeeForDiscount = 0;
|
||||
membershipFees.forEach((membershipFee) => {
|
||||
const {name, price} = membershipFee;
|
||||
if (DISCOUNT_PLANS.indexOf(name) !== -1){
|
||||
const cleanName = name.replace('[', '').replace(']', '').trim();
|
||||
if (DISCOUNT_PLANS.indexOf(cleanName) !== -1){
|
||||
membershipFeeForDiscount = price;
|
||||
}
|
||||
});
|
||||
@@ -310,6 +297,7 @@ const getMembersFeesForDateRange = (dateRange, memberIds) => {
|
||||
}
|
||||
});
|
||||
|
||||
const memberIdTeamMappings = {};
|
||||
const membersMap = {};
|
||||
const oneMemberObject = {
|
||||
totalBookedHours: 0,
|
||||
@@ -323,13 +311,12 @@ const getMembersFeesForDateRange = (dateRange, memberIds) => {
|
||||
bookingData: Object.assign({}, oneMemberObject),
|
||||
membershipFees: membershipsMap[member.memberId] || [],
|
||||
};
|
||||
});
|
||||
|
||||
const memberIdTeamMappings = {};
|
||||
membersList.forEach((member) => {
|
||||
memberIdTeamMappings[member.memberId] = member.teamId;
|
||||
});
|
||||
|
||||
const memberIdsToUse = memberIds.length > 0 ? memberIds : Object.keys(membersMap);
|
||||
|
||||
const allFees = [];
|
||||
|
||||
allIncidents.forEach((incident) => {
|
||||
@@ -440,7 +427,7 @@ const getMembersFeesForDateRange = (dateRange, memberIds) => {
|
||||
});
|
||||
|
||||
//add discount
|
||||
memberIds.forEach((memberId) => {
|
||||
memberIdsToUse.forEach((memberId) => {
|
||||
const discountFee = createNegativeFeeForDiscount(membersMap[memberId], dateRange);
|
||||
if (discountFee){
|
||||
allFees.push(discountFee);
|
||||
|
||||
@@ -39,12 +39,8 @@ const reformatMembershipsName = (memberships) => {
|
||||
memberships.forEach((membership) => {
|
||||
const { name, _id } = membership;
|
||||
|
||||
if (name && name.length > 0 && name[0] !== '['){
|
||||
DISCOUNT_PLANS.forEach((discountPlan) => {
|
||||
if (name === discountPlan){
|
||||
asyncMembershipUpdates.push(API.put(`memberships/${_id}`, {name: `[${name}]`}));
|
||||
}
|
||||
});
|
||||
if (name && name.length > 0 && name[0] !== '[' && DISCOUNT_PLANS.indexOf(name) !== -1){
|
||||
asyncMembershipUpdates.push(API.put(`memberships/${_id}`, {name: `[${name}]`}));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user