Formatting of invoices / Door lock time to incident reports

This commit is contained in:
Senad Uka
2019-11-20 13:56:02 +01:00
parent 81538600a6
commit fe1f691b2f
13 changed files with 136 additions and 92 deletions

View File

@@ -1,3 +1,5 @@
export const CONTAINER_WIDTH_PERCENTAGE = 90;
export const defaultDateFormat = 'YYYY-MM-DD'; export const defaultDateFormat = 'YYYY-MM-DD';
export const doorLockRelatedWithReservationIncidentHeaders = [ export const doorLockRelatedWithReservationIncidentHeaders = [
@@ -5,6 +7,7 @@ export const doorLockRelatedWithReservationIncidentHeaders = [
'resourceName', 'resourceName',
'memberName', 'memberName',
'reservation', 'reservation',
'doorLockTimestamps',
'incidentType', 'incidentType',
'feeDescription', 'feeDescription',
'totalChargeFee' 'totalChargeFee'

View File

@@ -4,12 +4,13 @@ import { Container, Message } from 'semantic-ui-react';
import MainMenu from '../../components/MainMenu'; import MainMenu from '../../components/MainMenu';
import { mainMenuItems } from '../../constants/menuItems'; import { mainMenuItems } from '../../constants/menuItems';
import {CONTAINER_WIDTH_PERCENTAGE} from "../../constants/constants";
class Home extends Component { class Home extends Component {
render () { render () {
return ( return (
<Container> <Container style={ {width: `${CONTAINER_WIDTH_PERCENTAGE}%`} }>
<MainMenu/> <MainMenu/>
<h3>SIMA SPACE </h3> <h3>SIMA SPACE </h3>
<hr/> <hr/>

View File

@@ -8,6 +8,7 @@ import MemberIncidentsTables from '../../components/MemberIncidentsTables';
import GenerateFeesInORDButton from '../../components/GenerateFeesInORDButton'; import GenerateFeesInORDButton from '../../components/GenerateFeesInORDButton';
import { fetchIncidents } from '../../store/actions'; import { fetchIncidents } from '../../store/actions';
import { CONTAINER_WIDTH_PERCENTAGE } from '../../constants/constants';
class IncidentsReport extends Component { class IncidentsReport extends Component {
state = {dateRange: null}; state = {dateRange: null};
@@ -33,7 +34,7 @@ class IncidentsReport extends Component {
} }
return ( return (
<Container> <Container style={ {width: `${CONTAINER_WIDTH_PERCENTAGE}%`} }>
<MainMenu/> <MainMenu/>
<h3>Incidents Report</h3> <h3>Incidents Report</h3>
<hr/> <hr/>

View File

@@ -5,6 +5,7 @@ import { Container, Button, Loader, Input, Message, Grid } from 'semantic-ui-rea
import MainMenu from '../../components/MainMenu'; import MainMenu from '../../components/MainMenu';
import { fetchMemberPracticeSummaryReport } from '../../store/actions'; import { fetchMemberPracticeSummaryReport } from '../../store/actions';
import {CONTAINER_WIDTH_PERCENTAGE} from "../../constants/constants";
class MemberPracticeSummaryReport extends Component { class MemberPracticeSummaryReport extends Component {
@@ -54,7 +55,7 @@ class MemberPracticeSummaryReport extends Component {
error = fetchReportError ? fetchReportError : error; error = fetchReportError ? fetchReportError : error;
return ( return (
<Container> <Container style={ {width: `${CONTAINER_WIDTH_PERCENTAGE}%`} }>
<MainMenu/> <MainMenu/>
<h3>Member Practice Summary Report</h3> <h3>Member Practice Summary Report</h3>
<hr/> <hr/>

View File

@@ -76,67 +76,71 @@ class SingleMapping extends Component {
}; };
render() { render() {
const { singleMapping: { officeSlug, resourceSlug } } = this.props; try {
const { officeId, resourceId, officeOptions, allResourceOptions, pendingMappings } = this.props; const {singleMapping: {officeSlug, resourceSlug}} = this.props;
const { showDeletePrompt, newOfficeId, newResourceId } = this.state; const {officeId, resourceId, officeOptions, allResourceOptions, pendingMappings} = this.props;
const {showDeletePrompt, newOfficeId, newResourceId} = this.state;
const selectedOfficeId = newOfficeId ? newOfficeId : officeId; const selectedOfficeId = newOfficeId ? newOfficeId : officeId;
const selectedResourceId = newResourceId ? newResourceId : resourceId; const selectedResourceId = newResourceId ? newResourceId : resourceId;
const resourceOptions = allResourceOptions && officeId ? allResourceOptions[selectedOfficeId].roomOptions : []; const resourceOptions = allResourceOptions && officeId ? allResourceOptions[selectedOfficeId].roomOptions : [];
const enableActions = !pendingMappings; const enableActions = !pendingMappings;
const enableSave = enableActions && ((newOfficeId !== null) || (newResourceId !== null)); const enableSave = enableActions && ((newOfficeId !== null) || (newResourceId !== null));
const saveIconColor = enableSave ? 'green' : null; const saveIconColor = enableSave ? 'green' : null;
return ( return (
<Table.Row> <Table.Row>
<PromptMessage <PromptMessage
onClose={this.onPromptClose} onClose={this.onPromptClose}
onActionNo={this.onPromptClose} onActionNo={this.onPromptClose}
onActionYes={this.onPromptYes} onActionYes={this.onPromptYes}
title={'Delete mapping'} title={'Delete mapping'}
message={'Do you want to delete this mapping ?'} message={'Do you want to delete this mapping ?'}
show={showDeletePrompt} show={showDeletePrompt}
/>
<Table.Cell>
<Label size={'big'}>{`[${officeSlug}-${resourceSlug}]`}</Label>
</Table.Cell>
<Table.Cell>
<Dropdown
options={officeOptions}
defaultValue={officeId}
onChange={this.onOfficeChange}
/> />
</Table.Cell> <Table.Cell>
<Table.Cell> <Label size={'big'}>{`[${officeSlug}-${resourceSlug}]`}</Label>
<Dropdown </Table.Cell>
options={resourceOptions} <Table.Cell>
value={selectedResourceId} <Dropdown
onChange={this.onResourceChange} options={officeOptions}
/> defaultValue={officeId}
</Table.Cell> onChange={this.onOfficeChange}
<Table.Cell> />
<Icon </Table.Cell>
circular <Table.Cell>
name={'check'} <Dropdown
size={'large'} options={resourceOptions}
disabled={!enableSave} value={selectedResourceId}
link={enableSave || null} onChange={this.onResourceChange}
color={saveIconColor} />
onClick={this.onMappingUpdate} </Table.Cell>
/> <Table.Cell>
<Icon <Icon
circular circular
name={'trash'} name={'check'}
size={'large'} size={'large'}
disabled={!enableActions} disabled={!enableSave}
link={enableActions || null} link={enableSave || null}
onClick={this.deleteMapping} color={saveIconColor}
/> onClick={this.onMappingUpdate}
</Table.Cell> />
</Table.Row> <Icon
); circular
name={'trash'}
size={'large'}
disabled={!enableActions}
link={enableActions || null}
onClick={this.deleteMapping}
/>
</Table.Cell>
</Table.Row>
);
}catch (e) {
return null;
}
} }
} }

View File

@@ -5,6 +5,7 @@ import { Container, Message, Loader, Table } from 'semantic-ui-react';
import MainMenu from '../../components/MainMenu'; import MainMenu from '../../components/MainMenu';
import { fetchMappings } from '../../store/actions'; import { fetchMappings } from '../../store/actions';
import SingleMapping from './components/SingleMapping'; import SingleMapping from './components/SingleMapping';
import {CONTAINER_WIDTH_PERCENTAGE} from "../../constants/constants";
class RoomOfficeNameMapping extends Component { class RoomOfficeNameMapping extends Component {
@@ -47,7 +48,7 @@ class RoomOfficeNameMapping extends Component {
}); });
return ( return (
<Container> <Container style={ {width: `${CONTAINER_WIDTH_PERCENTAGE}%`} }>
<Loader active={pendingMappings} /> <Loader active={pendingMappings} />
<MainMenu/> <MainMenu/>
<h3>Room Office Mapping</h3> <h3>Room Office Mapping</h3>

View File

@@ -10,6 +10,7 @@ import MemberIncidentsTables from '../../components/MemberIncidentsTables';
import GenerateFeesInORDButton from '../../components/GenerateFeesInORDButton'; import GenerateFeesInORDButton from '../../components/GenerateFeesInORDButton';
import { fetchMemberIncidents } from '../../store/actions'; import { fetchMemberIncidents } from '../../store/actions';
import {CONTAINER_WIDTH_PERCENTAGE} from "../../constants/constants";
class SpecificMemberIncidentsReport extends Component { class SpecificMemberIncidentsReport extends Component {
constructor(props){ constructor(props){
@@ -48,7 +49,7 @@ class SpecificMemberIncidentsReport extends Component {
const addFeesButtonDisabled = !memberId || !dateRange || loading; const addFeesButtonDisabled = !memberId || !dateRange || loading;
return ( return (
<Container> <Container style={ {width: `${CONTAINER_WIDTH_PERCENTAGE}%`} }>
<MainMenu/> <MainMenu/>
<h3>Member Incidents Report</h3> <h3>Member Incidents Report</h3>
<hr/> <hr/>

View File

@@ -4,10 +4,11 @@ import { Container, Form } from 'semantic-ui-react';
import MainMenu from '../../components/MainMenu'; import MainMenu from '../../components/MainMenu';
import FileUpload from './components/FileUpload'; import FileUpload from './components/FileUpload';
import UploadResults from './components/UploadResults'; import UploadResults from './components/UploadResults';
import {CONTAINER_WIDTH_PERCENTAGE} from "../../constants/constants";
function UploadDLockData() { function UploadDLockData() {
return ( return (
<Container> <Container style={ {width: `${CONTAINER_WIDTH_PERCENTAGE}%`} }>
<MainMenu/> <MainMenu/>
<h3>DLock Data</h3> <h3>DLock Data</h3>
<hr/> <hr/>

View File

@@ -14,37 +14,37 @@ const unlockedIncidentLevelsPrices = {
id: 0, id: 0,
title: 'UNLOCKED_0', title: 'UNLOCKED_0',
price: parseInt(process.env.UNLOCK_0) || 0, price: parseInt(process.env.UNLOCK_0) || 0,
description: 'First month - warning', description: 'first month - warning',
}, },
UNLOCKED_1: { UNLOCKED_1: {
id: 1, id: 1,
title: 'UNLOCKED_1', title: 'UNLOCKED_1',
price: parseInt(process.env.UNLOCK_1) || 10, price: parseInt(process.env.UNLOCK_1) || 10,
description: 'Second month', description: 'second month',
}, },
UNLOCKED_2: { UNLOCKED_2: {
id: 2, id: 2,
title: 'UNLOCKED_2', title: 'UNLOCKED_2',
price: parseInt(process.env.UNLOCK_2) || 20, price: parseInt(process.env.UNLOCK_2) || 20,
description: 'Third month', description: 'third month',
}, },
UNLOCKED_3: { UNLOCKED_3: {
id: 3, id: 3,
title: 'UNLOCKED_3', title: 'UNLOCKED_3',
price: parseInt(process.env.UNLOCK_3) || 30, price: parseInt(process.env.UNLOCK_3) || 30,
description: 'Fourth month', description: 'fourth month',
}, },
UNLOCKED_4: { UNLOCKED_4: {
id: 4, id: 4,
title: 'UNLOCKED_4', title: 'UNLOCKED_4',
price: parseInt(process.env.UNLOCK_4) || 40, price: parseInt(process.env.UNLOCK_4) || 40,
description: 'Fifth month', description: 'fifth month',
}, },
UNLOCKED_5: { UNLOCKED_5: {
id: 5, id: 5,
title: 'UNLOCKED_5', title: 'UNLOCKED_5',
price: parseInt(process.env.UNLOCK_5) || 50, price: parseInt(process.env.UNLOCK_5) || 50,
description: 'Sixth month and onward', description: 'sixth month and onward',
} }
}; };
const csvParserErrors = { const csvParserErrors = {
@@ -95,14 +95,14 @@ const incidentType = {
}; };
const incidentTypeExplanations = {}; const incidentTypeExplanations = {};
incidentTypeExplanations[incidentType.UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION] = 'Door left unlocked'; incidentTypeExplanations[incidentType.UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION] = 'door left unlocked';
incidentTypeExplanations[incidentType.UNLOCKED_INCIDENT_STANDALONE] = 'Door left unlocked'; incidentTypeExplanations[incidentType.UNLOCKED_INCIDENT_STANDALONE] = 'door left unlocked';
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_BEFORE_RESERVATION] = 'Room used before reservation'; incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_BEFORE_RESERVATION] = 'room used before reservation';
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_AFTER_RESERVATION] = 'Room used after reservation'; incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_AFTER_RESERVATION] = 'room used after reservation';
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 after grace period'; incidentTypeExplanations[incidentType.BOOKING_SHORTENED] = 'reservation shortened after grace period';
incidentTypeExplanations[incidentType.BOOKING_CANCELED_LATE] = 'Reservation cancelled after 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

@@ -17,6 +17,7 @@ const createFeeFromIncident = (incident) => {
memberId, memberId,
officeId, officeId,
officeName, officeName,
officeSlug,
resourceName, resourceName,
oldResourceName, oldResourceName,
newResourceName, newResourceName,
@@ -45,6 +46,8 @@ const createFeeFromIncident = (incident) => {
let bookingTimeExplanation = ''; let bookingTimeExplanation = '';
let incidentTimeExplanation = ''; let incidentTimeExplanation = '';
let spacing = '';
let roomExplanation = ''; let roomExplanation = '';
let dateExplanation = ''; let dateExplanation = '';
@@ -62,7 +65,8 @@ const createFeeFromIncident = (incident) => {
switch (incidentTypeNumber) { switch (incidentTypeNumber) {
case incidentType.UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION: case incidentType.UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION:
roomExplanation = resourceName; spacing = ' ';
roomExplanation = resourceName || 'Unknown';
dateExplanation = bookingStartMoment.clone().startOf('day').format('MMM DD'); dateExplanation = bookingStartMoment.clone().startOf('day').format('MMM DD');
bookingTimeExplanation = `[${bookingStartMoment.clone().format('HH:mm')} to ${bookingEndMoment.clone().format('HH:mm')}]`; bookingTimeExplanation = `[${bookingStartMoment.clone().format('HH:mm')} to ${bookingEndMoment.clone().format('HH:mm')}]`;
incidentTimeExplanation = `unlock : ${unlockMoment.clone().format('HH:mm')}`; incidentTimeExplanation = `unlock : ${unlockMoment.clone().format('HH:mm')}`;
@@ -74,7 +78,8 @@ const createFeeFromIncident = (incident) => {
quantity = 1.00; quantity = 1.00;
break; break;
case incidentType.UNSCHEDULED_INCIDENT_BEFORE_RESERVATION: case incidentType.UNSCHEDULED_INCIDENT_BEFORE_RESERVATION:
roomExplanation = resourceName; spacing = ' ';
roomExplanation = resourceName || 'Unknown';
dateExplanation = bookingStartMoment.clone().startOf('day').format('MMM DD'); dateExplanation = bookingStartMoment.clone().startOf('day').format('MMM DD');
bookingTimeExplanation = `[${bookingStartMoment.clone().format('HH:mm')} to ${bookingEndMoment.clone().format('HH:mm')}]`; bookingTimeExplanation = `[${bookingStartMoment.clone().format('HH:mm')} to ${bookingEndMoment.clone().format('HH:mm')}]`;
incidentTimeExplanation = `unlock : ${unlockMoment.clone().format('HH:mm')}`; incidentTimeExplanation = `unlock : ${unlockMoment.clone().format('HH:mm')}`;
@@ -86,7 +91,8 @@ const createFeeFromIncident = (incident) => {
quantity = +timeIntervalsToCharge.toFixed(2); quantity = +timeIntervalsToCharge.toFixed(2);
break; break;
case incidentType.UNSCHEDULED_INCIDENT_AFTER_RESERVATION: case incidentType.UNSCHEDULED_INCIDENT_AFTER_RESERVATION:
roomExplanation = resourceName; spacing = ' ';
roomExplanation = resourceName || 'Unknown';
dateExplanation = bookingStartMoment.clone().startOf('day').format('MMM DD'); dateExplanation = bookingStartMoment.clone().startOf('day').format('MMM DD');
bookingTimeExplanation = `[${bookingStartMoment.clone().format('HH:mm')} to ${bookingEndMoment.clone().format('HH:mm')}]`; bookingTimeExplanation = `[${bookingStartMoment.clone().format('HH:mm')} to ${bookingEndMoment.clone().format('HH:mm')}]`;
incidentTimeExplanation = `lock : ${lockMoment.clone().format('HH:mm')}`; incidentTimeExplanation = `lock : ${lockMoment.clone().format('HH:mm')}`;
@@ -98,7 +104,8 @@ const createFeeFromIncident = (incident) => {
quantity = +timeIntervalsToCharge.toFixed(2); quantity = +timeIntervalsToCharge.toFixed(2);
break; break;
case incidentType.UNLOCKED_INCIDENT_STANDALONE: case incidentType.UNLOCKED_INCIDENT_STANDALONE:
roomExplanation = resourceName; spacing = ' ';
roomExplanation = resourceName || 'Unknown';
dateExplanation = unlockMoment.clone().startOf('day').format('MMM DD'); dateExplanation = unlockMoment.clone().startOf('day').format('MMM DD');
bookingTimeExplanation = `[${unlockMoment.clone().format('HH:mm')} to ${lockMoment.clone().format('HH:mm')}]`; bookingTimeExplanation = `[${unlockMoment.clone().format('HH:mm')} to ${lockMoment.clone().format('HH:mm')}]`;
incidentTimeExplanation = `unlock : ${unlockMoment.clone().format('HH:mm')}`; incidentTimeExplanation = `unlock : ${unlockMoment.clone().format('HH:mm')}`;
@@ -110,7 +117,8 @@ const createFeeFromIncident = (incident) => {
quantity = 1.00; quantity = 1.00;
break; break;
case incidentType.UNSCHEDULED_INCIDENT_STANDALONE: case incidentType.UNSCHEDULED_INCIDENT_STANDALONE:
roomExplanation = resourceName; spacing = ' ';
roomExplanation = resourceName || 'Unknown';
dateExplanation = unlockMoment.clone().startOf('day').format('MMM DD'); dateExplanation = unlockMoment.clone().startOf('day').format('MMM DD');
bookingTimeExplanation = `[${unlockMoment.clone().format('HH:mm')} to ${lockMoment.clone().format('HH:mm')}]`; bookingTimeExplanation = `[${unlockMoment.clone().format('HH:mm')} to ${lockMoment.clone().format('HH:mm')}]`;
//incidentTimeExplanation = `unlock : ${unlockMoment.clone().format('HH:mm')}, lock : ${lockMoment.clone().format('HH:mm')}`; //incidentTimeExplanation = `unlock : ${unlockMoment.clone().format('HH:mm')}, lock : ${lockMoment.clone().format('HH:mm')}`;
@@ -121,12 +129,13 @@ const createFeeFromIncident = (incident) => {
quantity = +timeIntervalsToCharge.toFixed(2); quantity = +timeIntervalsToCharge.toFixed(2);
break; break;
case incidentType.BOOKING_MOVED_TO_ANOTHER_DAY: case incidentType.BOOKING_MOVED_TO_ANOTHER_DAY:
spacing = ' ';
// if (oldResourceName !== newResourceName){ // if (oldResourceName !== newResourceName){
// roomExplanation = `${oldResourceName} -> ${newResourceName}`; // roomExplanation = `${oldResourceName} -> ${newResourceName}`;
// }else{ // }else{
// roomExplanation = oldResourceName; // roomExplanation = oldResourceName;
// } // }
roomExplanation = newResourceName; roomExplanation = newResourceName || 'Unknown';
// 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')}`;
dateExplanation = `${newBookingStartMoment.clone().format('MMM DD')}`; dateExplanation = `${newBookingStartMoment.clone().format('MMM DD')}`;
@@ -140,18 +149,35 @@ const createFeeFromIncident = (incident) => {
quantity = 1.00; quantity = 1.00;
break; break;
case incidentType.BOOKING_SHORTENED: case incidentType.BOOKING_SHORTENED:
spacing = ' ';
// if (oldResourceName !== newResourceName){ // if (oldResourceName !== newResourceName){
// roomExplanation = `${oldResourceName} -> ${newResourceName}`; // roomExplanation = `${oldResourceName} -> ${newResourceName}`;
// }else{ // }else{
// roomExplanation = oldResourceName; // roomExplanation = oldResourceName;
// } // }
roomExplanation = newResourceName; roomExplanation = newResourceName || 'Unknown';
// dateExplanation = `${oldBookingStartMoment.clone().format('ddd, MMM DD')}`; // dateExplanation = `${oldBookingStartMoment.clone().format('ddd, MMM DD')}`;
const oldBookingDuration = oldBookingEndMoment.diff(oldBookingStartMoment, "minutes", false);
const durationInHours = Math.floor(oldBookingDuration / 60);
const durationInMinutes = Math.floor(oldBookingDuration % 60);
let durationAsText = '';
if (durationInHours !== 0){
durationAsText += durationInHours + ' hour';
if (durationInHours === 1){
durationAsText += ' ';
}else{
durationAsText += 's ';
}
}
durationAsText += durationInMinutes + ' minute';
if (durationInMinutes > 1){
durationAsText += 's';
}
dateExplanation = `${newBookingStartMoment.clone().format('MMM DD')}`; dateExplanation = `${newBookingStartMoment.clone().format('MMM DD')}`;
bookingTimeExplanation = `[${newBookingStartMoment.clone().format('HH:mm')} to ${newBookingEndMoment.clone().format('HH:mm')}]`; bookingTimeExplanation = `[${newBookingStartMoment.clone().format('HH:mm')} to ${newBookingEndMoment.clone().format('HH:mm')}]`;
incidentTimeExplanation = `shortened on : ${incidentTimestampMoment.clone().format('MMM DD, HH:mm')}`; incidentTimeExplanation = `reservation shortened from ${durationAsText} on : ${incidentTimestampMoment.clone().format('MMM DD, HH:mm')}`;
incidentExplanation += `, ${incidentTimeExplanation}`; incidentExplanation = `${incidentTimeExplanation}`;
date = incidentTimestampMoment.clone().startOf('day').format(); date = incidentTimestampMoment.clone().startOf('day').format();
@@ -159,7 +185,8 @@ const createFeeFromIncident = (incident) => {
quantity = 1.00; quantity = 1.00;
break; break;
case incidentType.BOOKING_CANCELED_LATE: case incidentType.BOOKING_CANCELED_LATE:
roomExplanation = oldResourceName; spacing = ' ';
roomExplanation = oldResourceName || 'Unknown';
// dateExplanation = `${oldBookingStartMoment.clone().format('ddd, MMM DD')}`; // dateExplanation = `${oldBookingStartMoment.clone().format('ddd, MMM DD')}`;
dateExplanation = `${oldBookingStartMoment.clone().format('MMM DD')}`; dateExplanation = `${oldBookingStartMoment.clone().format('MMM DD')}`;
bookingTimeExplanation = `[${oldBookingStartMoment.clone().format('HH:mm')} to ${oldBookingEndMoment.clone().format('HH:mm')}]`; bookingTimeExplanation = `[${oldBookingStartMoment.clone().format('HH:mm')} to ${oldBookingEndMoment.clone().format('HH:mm')}]`;
@@ -173,7 +200,7 @@ const createFeeFromIncident = (incident) => {
break; break;
} }
const formattedName = `${dateExplanation} ${bookingTimeExplanation} ${roomExplanation}, ${officeName}, ${incidentExplanation}`; const formattedName = `${officeSlug}, ${dateExplanation} ${bookingTimeExplanation}${spacing}${roomExplanation}, ${incidentExplanation}`;
return { return {
name: formattedName, name: formattedName,
@@ -202,14 +229,14 @@ const createFeeFromBooking = (booking, resourceMappings) => {
const endMoment = moment.tz(end, DEFAULT_DATE_FORMAT, timezone); const endMoment = moment.tz(end, DEFAULT_DATE_FORMAT, timezone);
const reservationLength = endMoment.diff(startMoment, 'hours', true); const reservationLength = endMoment.diff(startMoment, 'hours', true);
const officeName = officesMap[officeId].officeName || 'Unknown'; const officeSlug = officesMap[officeId].officeSlug || 'Unknown';
const resourceName = resourcesMap[resourceId].resourceName || 'Unknown'; const resourceName = resourcesMap[resourceId].resourceName || 'Unknown';
const formattedDate = startMoment.clone().startOf('day').format('MMM DD'); const formattedDate = startMoment.clone().startOf('day').format('MMM DD');
const formattedStartTime = startMoment.format('HH:mm'); const formattedStartTime = startMoment.format('HH:mm');
const formattedEndTime = endMoment.format('HH:mm'); const formattedEndTime = endMoment.format('HH:mm');
const formattedName = `${formattedDate} [${formattedStartTime} to ${formattedEndTime}] ${resourceName}, ${officeName}`; const formattedName = `${officeSlug}, ${formattedDate} [${formattedStartTime} to ${formattedEndTime}] ${resourceName}`;
return { return {
name: formattedName, name: formattedName,
@@ -330,7 +357,7 @@ const getMembersFeesForDateRange = (dateRange, memberIds) => {
allIncidents.forEach((incident) => { allIncidents.forEach((incident) => {
const feeFromIncident = createFeeFromIncident(incident); const feeFromIncident = createFeeFromIncident(incident);
if (feeFromIncident){ if (feeFromIncident){
allFees.push(createFeeFromIncident(incident)); allFees.push(feeFromIncident);
} }
const incidentsValuableForDiscountCalculation = [ const incidentsValuableForDiscountCalculation = [
@@ -464,7 +491,7 @@ const getMembersFeesForDateRange = (dateRange, memberIds) => {
fee.team = memberIdTeamMappings[member] || null; fee.team = memberIdTeamMappings[member] || null;
if (teamId){ if (teamId){
//if member is part of the company, add name to the fee description/name //if member is part of the company, add name to the fee description/name
fee.name += `, ${memberName}`; fee.name = `${memberName}, ${fee.name}`;
} }
} }
}); });

View File

@@ -225,6 +225,7 @@ const getAllIncidents = (dateRange, memberIds) => {
resourceName: resourcesMap[unlockedIncident.resourceId].resourceName, resourceName: resourcesMap[unlockedIncident.resourceId].resourceName,
officeId: resourcesMap[unlockedIncident.resourceId].officeId, officeId: resourcesMap[unlockedIncident.resourceId].officeId,
officeName: officesMap[resourcesMap[unlockedIncident.resourceId].officeId].officeName, officeName: officesMap[resourcesMap[unlockedIncident.resourceId].officeId].officeName,
officeSlug: officesMap[resourcesMap[unlockedIncident.resourceId].officeId].officeSlug,
bookingStart: formatTime(unlockedIncident.bookingStart), bookingStart: formatTime(unlockedIncident.bookingStart),
bookingEnd: formatTime(unlockedIncident.bookingEnd), bookingEnd: formatTime(unlockedIncident.bookingEnd),
bookingStartRaw: unlockedIncident.bookingStart, bookingStartRaw: unlockedIncident.bookingStart,
@@ -255,6 +256,7 @@ const getAllIncidents = (dateRange, memberIds) => {
resourceName: resourcesMap[unscheduledIncident.resourceId].resourceName, resourceName: resourcesMap[unscheduledIncident.resourceId].resourceName,
officeId: resourcesMap[unscheduledIncident.resourceId].officeId, officeId: resourcesMap[unscheduledIncident.resourceId].officeId,
officeName: officesMap[resourcesMap[unscheduledIncident.resourceId].officeId].officeName, officeName: officesMap[resourcesMap[unscheduledIncident.resourceId].officeId].officeName,
officeSlug: officesMap[resourcesMap[unscheduledIncident.resourceId].officeId].officeSlug,
bookingStart: formatTime(unscheduledIncident.bookingStart), bookingStart: formatTime(unscheduledIncident.bookingStart),
bookingEnd: formatTime(unscheduledIncident.bookingEnd), bookingEnd: formatTime(unscheduledIncident.bookingEnd),
bookingStartRaw: unscheduledIncident.bookingStart, bookingStartRaw: unscheduledIncident.bookingStart,
@@ -292,6 +294,7 @@ const getAllIncidents = (dateRange, memberIds) => {
const newResourceName = newResource ? newResource.resourceName : null; const newResourceName = newResource ? newResource.resourceName : null;
const officeId = oldResource.officeId; const officeId = oldResource.officeId;
const officeName = officesMap[officeId].officeName; const officeName = officesMap[officeId].officeName;
const officeSlug = officesMap[officeId].officeSlug;
allIncidents.push({ allIncidents.push({
incidentId: id, incidentId: id,
memberId, memberId,
@@ -300,6 +303,7 @@ const getAllIncidents = (dateRange, memberIds) => {
newResourceName, newResourceName,
officeId, officeId,
officeName, officeName,
officeSlug,
oldBookingStart: formatTime(oldBookingStart), oldBookingStart: formatTime(oldBookingStart),
oldBookingEnd: formatTime(oldBookingEnd), oldBookingEnd: formatTime(oldBookingEnd),
newBookingStart: formatTime(newBookingStart), newBookingStart: formatTime(newBookingStart),

View File

@@ -202,7 +202,6 @@ const bulkWriteReservationsWithChangesTracking = (reservations, resourcesMap) =>
}else{ }else{
hourlyRate = resourceId ? resourcesMap[resourceId].price.price : 0; hourlyRate = resourceId ? resourcesMap[resourceId].price.price : 0;
} }
console.log(hourlyRate);
instance.setDataValue('hourlyRate', hourlyRate); instance.setDataValue('hourlyRate', hourlyRate);
} }
} }

View File

@@ -15,6 +15,7 @@ const fetchOffices = () => {
cleanedOffices.push({ cleanedOffices.push({
officeId: office['_id'], officeId: office['_id'],
officeName: office.name, officeName: office.name,
officeSlug: office.description,
}); });
}); });
resolve(cleanedOffices); resolve(cleanedOffices);