fix incidents date

This commit is contained in:
Bilal Catic
2019-07-25 02:36:38 +02:00
parent 71e034b6c2
commit a5221da2f1
2 changed files with 24 additions and 9 deletions

View File

@@ -36,6 +36,7 @@ const createFeeFromIncident = (incident) => {
const incidentExplanation = incidentTypeExplanations[incidentTypeNumber];
let date = '';
let price = 0;
let quantity = 0;
let priceExplanation = '';
@@ -67,6 +68,8 @@ const createFeeFromIncident = (incident) => {
unlockedIncidentLevelsPrices[incidentLevel].description
additionalIncidentExplanation = unlockedIncidentLevelsPrices[incidentLevel].description;
date = bookingStartMoment.clone().startOf('day').format();
price = incidentPrice;
quantity = 1;
priceExplanation = `$${price.toFixed(2)}, 1 x $${price.toFixed(2)}`;
@@ -77,6 +80,8 @@ const createFeeFromIncident = (incident) => {
bookingTimeExplanation = `${bookingStartMoment.clone().format('HH:mm a')} - ${bookingEndMoment.clone().format('HH:mm a')}`;
incidentTimeExplanation = `UNLOCK : ${unlockMoment.clone().format('HH:mm a')}`;
date = bookingStartMoment.clone().startOf('day').format();
price = chargePrice;
quantity = timeIntervalsToCharge;
priceExplanation = `$${totalChargeFee.toFixed(2)}, ${quantity} x $${price.toFixed(2)}`;
@@ -87,6 +92,8 @@ const createFeeFromIncident = (incident) => {
bookingTimeExplanation = `${bookingStartMoment.clone().format('HH:mm a')} - ${bookingEndMoment.clone().format('HH:mm a')}`;
incidentTimeExplanation = `LOCK : ${lockMoment.clone().format('HH:mm a')}`;
date = bookingStartMoment.clone().startOf('day').format();
price = chargePrice;
quantity = timeIntervalsToCharge;
priceExplanation = `$${totalChargeFee.toFixed(2)}, ${quantity} x $${price.toFixed(2)}`;
@@ -98,6 +105,8 @@ const createFeeFromIncident = (incident) => {
incidentTimeExplanation = `UNLOCK : ${unlockMoment.clone().format('HH:mm a')}`;
additionalIncidentExplanation = unlockedIncidentLevelsPrices[incidentLevel].description;
date = unlockMoment.clone().startOf('day').format();
price = incidentPrice;
quantity = 1;
priceExplanation = `$${price.toFixed(2)}, 1 x $${price.toFixed(2)}`;
@@ -109,6 +118,8 @@ const createFeeFromIncident = (incident) => {
incidentTimeExplanation = `UNLOCK : ${unlockMoment.clone().format('HH:mm a')} LOCK : ${lockMoment.clone().format('HH:mm a')}`;
additionalIncidentExplanation = '';
date = unlockMoment.clone().startOf('day').format();
price = chargePrice;
quantity = timeIntervalsToCharge;
priceExplanation = `$${totalChargeFee.toFixed(2)}, ${quantity} x $${price.toFixed(2)}`;
@@ -122,7 +133,9 @@ const createFeeFromIncident = (incident) => {
dateExplanation = `${oldBookingStartMoment.clone().format('MMM DD, YYYY')} -> ${newBookingStartMoment.clone().format('MMM DD, YYYY')}`;
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(DEFAULT_DATE_FORMAT)}`;
incidentTimeExplanation = `MOVED ON : ${incidentTimestampMoment.clone().format('MMM DD, YYYY')}`;
date = incidentTimestampMoment.clone().startOf('day').format();
price = totalChargeFee;
quantity = 1;
@@ -137,7 +150,9 @@ const createFeeFromIncident = (incident) => {
dateExplanation = `${oldBookingStartMoment.clone().format('MMM DD, YYYY')}`;
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(DEFAULT_DATE_FORMAT)}`;
incidentTimeExplanation = `SHORTENED ON : ${incidentTimestampMoment.clone().format('MMM DD, YYYY')}`;
date = incidentTimestampMoment.clone().startOf('day').format();
price = totalChargeFee;
quantity = 1;
@@ -147,7 +162,9 @@ const createFeeFromIncident = (incident) => {
roomExplanation = oldResourceName;
dateExplanation = `${oldBookingStartMoment.clone().format('MMM DD, YYYY')}`;
bookingTimeExplanation = `${oldBookingStartMoment.clone().format('HH:mm a')} - ${oldBookingEndMoment.clone().format('HH:mm a')}`;
incidentTimeExplanation = `CANCELED ON : ${incidentTimestampMoment.clone().format(DEFAULT_DATE_FORMAT)}`;
incidentTimeExplanation = `CANCELED ON : ${incidentTimestampMoment.clone().format('MMM DD, YYYY')}`;
date = incidentTimestampMoment.clone().startOf('day').format();
price = totalChargeFee;
quantity = 1;
@@ -161,7 +178,7 @@ const createFeeFromIncident = (incident) => {
name: formattedName,
price,
quantity,
date: moment.tz(incidentTimestampRaw, UI_TIMEZONE).startOf('day').toISOString(),
date,
member: memberId,
team: null,
office: officeId,

View File

@@ -32,11 +32,9 @@ const deleteFeesFromORD = (dateRange, memberIds) => {
const { member, date } = fee;
const feeId = fee['_id'];
if (memberIdsMap[member]) {
const isDateInDateRange = startDate.isSameOrBefore(date) && endDate.isSameOrAfter(date);
if (memberIdsMap[member] && isDateInDateRange) {
deleteRequests.push(sendDeleteRequestPromise(feeId));
}
const isDateInDateRange = startDate.isSameOrBefore(date) && endDate.isSameOrAfter(date);
if (memberIdsMap[member] && isDateInDateRange) {
deleteRequests.push(sendDeleteRequestPromise(feeId));
}
});