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

View File

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