Merge branch 'fix-cancellation-charges-display' into 'master'

display cancellation charges correctly

See merge request saburly/psihologija!26
This commit was merged in pull request #26.
This commit is contained in:
Bilal Catic
2019-07-16 08:18:03 +00:00
6 changed files with 33 additions and 11 deletions

View File

@@ -81,7 +81,7 @@ class DateRangePicker extends Component {
const endDateValue = endDate.format(defaultDateFormat); const endDateValue = endDate.format(defaultDateFormat);
const buttonRender = ( const buttonRender = (
<Grid.Column width={inlineButton ? 1 : null}> <Grid.Column width={inlineButton ? 3 : null}>
{ inlineButton && <label>{'\u00A0'}</label> } { inlineButton && <label>{'\u00A0'}</label> }
<Form.Button onClick={this.onButtonClick.bind(this)}>{buttonLabel}</Form.Button> <Form.Button onClick={this.onButtonClick.bind(this)}>{buttonLabel}</Form.Button>
</Grid.Column> </Grid.Column>

View File

@@ -70,6 +70,19 @@ const SingleIncidentsTable = props => {
urlValue = `/practice-summary-report/${memberId}`; urlValue = `/practice-summary-report/${memberId}`;
cellValue = props.value; cellValue = props.value;
break; break;
case 'resourceName':
if (props.row['_original'].resourceName){
cellValue = props.row['_original'].resourceName || '---';
}else{
const oldResourceName = props.row['_original'].oldResourceName || '---';
const newResourceName = props.row['_original'].newResourceName || '---';
if (oldResourceName !== newResourceName){
cellValue = `${oldResourceName}\n${newResourceName}`;
}else{
cellValue = oldResourceName;
}
}
break;
case 'reservation': case 'reservation':
const bookingStart = props.row['_original'].bookingStart; const bookingStart = props.row['_original'].bookingStart;
const bookingEnd = props.row['_original'].bookingEnd; const bookingEnd = props.row['_original'].bookingEnd;
@@ -116,8 +129,8 @@ const SingleIncidentsTable = props => {
cellValue = `${oldBookingStart}\n${oldBookingEnd}`; cellValue = `${oldBookingStart}\n${oldBookingEnd}`;
break; break;
case 'newReservation': case 'newReservation':
const newBookingStart = props.row['_original'].newBookingStart; const newBookingStart = props.row['_original'].newBookingStart || '---';
const newBookingEnd = props.row['_original'].newBookingEnd; const newBookingEnd = props.row['_original'].newBookingEnd || '---';
cellValue = `${newBookingStart}\n${newBookingEnd}`; cellValue = `${newBookingStart}\n${newBookingEnd}`;
break; break;
default: default:

View File

@@ -3,7 +3,7 @@ import {Accordion, Label} from 'semantic-ui-react';
import SingleIncidentsTable from './components/SingleIncidentsTable'; import SingleIncidentsTable from './components/SingleIncidentsTable';
import { import {
UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION, UNLOCKED_INCIDENT_STANDALONE, UNSCHEDULED_INCIDENT_AFTER_RESERVATION, UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION, UNLOCKED_INCIDENT_STANDALONE, UNSCHEDULED_INCIDENT_AFTER_RESERVATION,
UNSCHEDULED_INCIDENT_BEFORE_RESERVATION, UNSCHEDULED_INCIDENT_STANDALONE, BOOKING_MOVED_TO_ANOTHER_DAY, BOOKING_SHORTENED, UNSCHEDULED_INCIDENT_BEFORE_RESERVATION, UNSCHEDULED_INCIDENT_STANDALONE, BOOKING_MOVED_TO_ANOTHER_DAY, BOOKING_SHORTENED, BOOKING_CANCELED_LATE,
incidentTableTypes incidentTableTypes
} from '../../constants/enums'; } from '../../constants/enums';
@@ -29,6 +29,7 @@ export default function MemberIncidentsTables (props) {
break; break;
case BOOKING_MOVED_TO_ANOTHER_DAY: case BOOKING_MOVED_TO_ANOTHER_DAY:
case BOOKING_SHORTENED: case BOOKING_SHORTENED:
case BOOKING_CANCELED_LATE:
bookingChangeIncidents.push(incident); bookingChangeIncidents.push(incident);
break; break;
default: default:

View File

@@ -6,6 +6,7 @@ export const UNLOCKED_INCIDENT_STANDALONE = 5;
export const UNSCHEDULED_INCIDENT_STANDALONE = 6; export const UNSCHEDULED_INCIDENT_STANDALONE = 6;
export const BOOKING_MOVED_TO_ANOTHER_DAY = 7; export const BOOKING_MOVED_TO_ANOTHER_DAY = 7;
export const BOOKING_SHORTENED = 8; export const BOOKING_SHORTENED = 8;
export const BOOKING_CANCELED_LATE = 9;
export const incidentDescriptions = {}; export const incidentDescriptions = {};
incidentDescriptions[UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION] = 'User left door unlocked'; incidentDescriptions[UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION] = 'User left door unlocked';
@@ -15,6 +16,7 @@ incidentDescriptions[UNLOCKED_INCIDENT_STANDALONE] = 'User left door unlocked';
incidentDescriptions[UNSCHEDULED_INCIDENT_STANDALONE] = 'Unscheduled use'; incidentDescriptions[UNSCHEDULED_INCIDENT_STANDALONE] = 'Unscheduled use';
incidentDescriptions[BOOKING_MOVED_TO_ANOTHER_DAY] = 'Reservation moved to another day'; incidentDescriptions[BOOKING_MOVED_TO_ANOTHER_DAY] = 'Reservation moved to another day';
incidentDescriptions[BOOKING_SHORTENED] = 'Reservation shortened'; incidentDescriptions[BOOKING_SHORTENED] = 'Reservation shortened';
incidentDescriptions[BOOKING_CANCELED_LATE] = 'Reservation canceled late';
export const incidentLevelDescriptions = { export const incidentLevelDescriptions = {
UNLOCKED_0: 'First month', UNLOCKED_0: 'First month',

View File

@@ -5,7 +5,7 @@ import {
UNSCHEDULED_INCIDENT_BEFORE_RESERVATION, UNSCHEDULED_INCIDENT_BEFORE_RESERVATION,
UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION, UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION,
UNSCHEDULED_INCIDENT_AFTER_RESERVATION, UNSCHEDULED_INCIDENT_STANDALONE, UNLOCKED_INCIDENT_STANDALONE, UNSCHEDULED_INCIDENT_AFTER_RESERVATION, UNSCHEDULED_INCIDENT_STANDALONE, UNLOCKED_INCIDENT_STANDALONE,
BOOKING_MOVED_TO_ANOTHER_DAY, BOOKING_SHORTENED, BOOKING_MOVED_TO_ANOTHER_DAY, BOOKING_SHORTENED, BOOKING_CANCELED_LATE,
} from '../../../constants/enums'; } from '../../../constants/enums';
const MemberSummary = props => { const MemberSummary = props => {
@@ -29,6 +29,7 @@ const MemberSummary = props => {
break; break;
case BOOKING_MOVED_TO_ANOTHER_DAY: case BOOKING_MOVED_TO_ANOTHER_DAY:
case BOOKING_SHORTENED: case BOOKING_SHORTENED:
case BOOKING_CANCELED_LATE:
totalBookingChangeFees += parseFloat(incident.totalChargeFee); totalBookingChangeFees += parseFloat(incident.totalChargeFee);
break; break;
default: default:

View File

@@ -116,7 +116,8 @@ const getBookingChangeIncidents = (startDate, endDate, memberId) => {
'id', 'id',
'reservationId', 'reservationId',
'memberId', 'memberId',
'resourceId', 'oldResourceId',
'newResourceId',
'oldBookingStart', 'oldBookingStart',
'oldBookingEnd', 'oldBookingEnd',
'newBookingStart', 'newBookingStart',
@@ -251,7 +252,8 @@ const getAllIncidents = (dateRange, memberId) => {
const { const {
id, id,
memberId, memberId,
resourceId, oldResourceId,
newResourceId,
oldBookingStart, oldBookingStart,
oldBookingEnd, oldBookingEnd,
newBookingStart, newBookingStart,
@@ -261,14 +263,17 @@ const getAllIncidents = (dateRange, memberId) => {
createdAt, createdAt,
} = bookingChangeIncident; } = bookingChangeIncident;
const memberName = membersMap[memberId].name; const memberName = membersMap[memberId].name;
const resource = resourcesMap[resourceId]; const oldResource = resourcesMap[oldResourceId];
const resourceName = resource.resourceName; const newResource = newResourceId ? resourcesMap[newResourceId] : null;
const officeName = officesMap[resource.officeId].officeName; const oldResourceName = oldResource.resourceName;
const newResourceName = newResource ? newResource.resourceName : null;
const officeName = officesMap[oldResource.officeId].officeName;
allIncidents.push({ allIncidents.push({
incidentId: id, incidentId: id,
memberId, memberId,
memberName, memberName,
resourceName, oldResourceName,
newResourceName,
officeName, officeName,
oldBookingStart: formatTime(oldBookingStart), oldBookingStart: formatTime(oldBookingStart),
oldBookingEnd: formatTime(oldBookingEnd), oldBookingEnd: formatTime(oldBookingEnd),