Make 'disable send to ord' for current month configurable
This commit is contained in:
@@ -1,10 +1,8 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { Button, Modal } from 'semantic-ui-react';
|
import { Button, Modal, Message } from 'semantic-ui-react';
|
||||||
import moment from 'moment';
|
|
||||||
|
|
||||||
import { addFeesToOrd } from '../../store/actions';
|
import { addFeesToOrd } from '../../store/actions';
|
||||||
import { defaultDateFormat } from '../../constants/constants';
|
|
||||||
|
|
||||||
class GenerateFeesInORDButton extends Component {
|
class GenerateFeesInORDButton extends Component {
|
||||||
state = { open: false };
|
state = { open: false };
|
||||||
@@ -23,25 +21,7 @@ class GenerateFeesInORDButton extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { open, size } = this.state;
|
const { open, size } = this.state;
|
||||||
const { singleMember, disabled, dateRange } = this.props;
|
const { singleMember, disabled, sendFeesError } = this.props;
|
||||||
|
|
||||||
let submitIsDisabled = disabled;
|
|
||||||
|
|
||||||
if (dateRange && dateRange.startDate) {
|
|
||||||
const startDateMoment = moment(dateRange.startDate, defaultDateFormat);
|
|
||||||
const currentMoment = moment();
|
|
||||||
|
|
||||||
const startMomentMonth = startDateMoment.month();
|
|
||||||
const startMomentYear = startDateMoment.year();
|
|
||||||
const currentMonth = currentMoment.month();
|
|
||||||
const currentYear = currentMoment.year();
|
|
||||||
|
|
||||||
const monthSelectorIsInPast = (startMomentYear < currentYear) ||
|
|
||||||
(startMomentYear === currentYear && startMomentMonth < currentMonth);
|
|
||||||
|
|
||||||
submitIsDisabled = disabled || !monthSelectorIsInPast;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const modalContent = singleMember ?
|
const modalContent = singleMember ?
|
||||||
'This will remove all existing fees in ORD for selected member in selected date range and generate new fees based on shown incident tables. Do you want to continue ?':
|
'This will remove all existing fees in ORD for selected member in selected date range and generate new fees based on shown incident tables. Do you want to continue ?':
|
||||||
@@ -49,7 +29,13 @@ class GenerateFeesInORDButton extends Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Button disabled={submitIsDisabled} onClick={this.show('tiny')}>Generate fees in ORD</Button>
|
<Button disabled={disabled} onClick={this.show('tiny')}>Generate fees in ORD</Button>
|
||||||
|
|
||||||
|
{sendFeesError &&
|
||||||
|
<Message negative>
|
||||||
|
{sendFeesError.data ? sendFeesError.data : 'Error sending fees'}
|
||||||
|
</Message>
|
||||||
|
}
|
||||||
|
|
||||||
<Modal size={size} open={open} onClose={this.close}>
|
<Modal size={size} open={open} onClose={this.close}>
|
||||||
<Modal.Header>Add fees to the ORD</Modal.Header>
|
<Modal.Header>Add fees to the ORD</Modal.Header>
|
||||||
@@ -66,8 +52,12 @@ class GenerateFeesInORDButton extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mapStateToProps = (state) => ({
|
||||||
|
sendFeesError: state.addFeesStatus.error,
|
||||||
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
addFeesToOrd: (dateRange, memberIds) => addFeesToOrd(dispatch, dateRange, memberIds),
|
addFeesToOrd: (dateRange, memberIds) => addFeesToOrd(dispatch, dateRange, memberIds),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(null, mapDispatchToProps)(GenerateFeesInORDButton);
|
export default connect(mapStateToProps, mapDispatchToProps)(GenerateFeesInORDButton);
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ const integrationServiceErrors = {
|
|||||||
FAILED_TO_GENERATE_MEMBER_PRACTICE_SUMMARY: 'Failed to generate Member Practice Summary',
|
FAILED_TO_GENERATE_MEMBER_PRACTICE_SUMMARY: 'Failed to generate Member Practice Summary',
|
||||||
ERRORS_IN_MEMBER_PRACTICE_SUMMARY_REPORT: 'Member Practice Summary Report is generated but there were some errors and report may be incomplete',
|
ERRORS_IN_MEMBER_PRACTICE_SUMMARY_REPORT: 'Member Practice Summary Report is generated but there were some errors and report may be incomplete',
|
||||||
EXPECTED_MEMBER_IDS_ARRAY: 'Expected array of member IDs',
|
EXPECTED_MEMBER_IDS_ARRAY: 'Expected array of member IDs',
|
||||||
|
SENDING_FEES_DISABLED: 'Sending fees is disabled for current and future months',
|
||||||
|
MONTH_MISSING: 'Missing month selection for sending fees to ORD',
|
||||||
};
|
};
|
||||||
|
|
||||||
const incidentType = {
|
const incidentType = {
|
||||||
@@ -129,6 +131,8 @@ const CUSTOM_FEES_PREFIXES = process.env.CUSTOM_FEES_PREFIXES.split(',')
|
|||||||
|
|
||||||
const UNPAID_FEE_STATUS = 'not_paid';
|
const UNPAID_FEE_STATUS = 'not_paid';
|
||||||
|
|
||||||
|
const ALLOW_SENDING_FEES = parseInt(process.env.ALLOW_SENDING_FEES_FOR_CURRENT_AND_FUTURE_MONTHS) ? true : false;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
VALID_CSV_HEADERS,
|
VALID_CSV_HEADERS,
|
||||||
USER_ENTRY_EVENT,
|
USER_ENTRY_EVENT,
|
||||||
@@ -153,4 +157,5 @@ module.exports = {
|
|||||||
DISCOUNT_PLANS,
|
DISCOUNT_PLANS,
|
||||||
UNPAID_FEE_STATUS,
|
UNPAID_FEE_STATUS,
|
||||||
CUSTOM_FEES_PREFIXES,
|
CUSTOM_FEES_PREFIXES,
|
||||||
|
ALLOW_SENDING_FEES,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const { reformatMembershipsName } = require('../services/officeRnD/memberships')
|
|||||||
const { checkBookingChanges } = require('../services/integration/checkBookingChange');
|
const { checkBookingChanges } = require('../services/integration/checkBookingChange');
|
||||||
const { checkIfProcessing } = require('../services/integration/processingStatus');
|
const { checkIfProcessing } = require('../services/integration/processingStatus');
|
||||||
|
|
||||||
const { UI_TIMEZONE, DEFAULT_DATE_FORMAT } = require('../constants/constants');
|
const { UI_TIMEZONE, DEFAULT_DATE_FORMAT, ALLOW_SENDING_FEES, integrationServiceErrors } = require('../constants/constants');
|
||||||
|
|
||||||
const getKnownOfficeResourceMappings = (req, res) => {
|
const getKnownOfficeResourceMappings = (req, res) => {
|
||||||
const dataToFetch = [getMappingsFromDatabase(), fetchOffices(), fetchResources()];
|
const dataToFetch = [getMappingsFromDatabase(), fetchOffices(), fetchResources()];
|
||||||
@@ -126,7 +126,10 @@ const addFees = (req, res) => {
|
|||||||
const currentMonth = currentMoment.month();
|
const currentMonth = currentMoment.month();
|
||||||
const currentYear = currentMoment.year();
|
const currentYear = currentMoment.year();
|
||||||
|
|
||||||
if ((startMomentYear < currentYear) || (startMomentYear === currentYear && startMomentMonth < currentMonth)) {
|
const allowSendingFees = ALLOW_SENDING_FEES ||
|
||||||
|
((startMomentYear < currentYear) || (startMomentYear === currentYear && startMomentMonth < currentMonth));
|
||||||
|
|
||||||
|
if (allowSendingFees) {
|
||||||
checkBookingChanges()
|
checkBookingChanges()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
deleteFeesFromORD(dateRange, memberIds)
|
deleteFeesFromORD(dateRange, memberIds)
|
||||||
@@ -169,12 +172,12 @@ const addFees = (req, res) => {
|
|||||||
res.status(500).send(error);
|
res.status(500).send(error);
|
||||||
})
|
})
|
||||||
}else{
|
}else{
|
||||||
console.log('Selected month/year pair is current month or in the future');
|
console.log(integrationServiceErrors.SENDING_FEES_DISABLED);
|
||||||
res.status(400).send('Selected month/year pair is current month or in the future');
|
res.status(400).send(integrationServiceErrors.SENDING_FEES_DISABLED);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
console.log('Date range is missing to send fees to ORD');
|
console.log(integrationServiceErrors.MONTH_MISSING);
|
||||||
res.status(400).send('Date range is missing');
|
res.status(400).send(integrationServiceErrors.MONTH_MISSING);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ ORD_OAUTH_URL=https://identity.officernd.com/oauth/token
|
|||||||
|
|
||||||
CUSTOM_FEES_PREFIXES=Array of prefixes to recognize manually added fees. Comma-separated
|
CUSTOM_FEES_PREFIXES=Array of prefixes to recognize manually added fees. Comma-separated
|
||||||
|
|
||||||
|
ALLOW_SENDING_FEES_FOR_CURRENT_AND_FUTURE_MONTHS=0 - false => Sending fees is disabled for current and future months, 1 - true => Sending fees is never disabled
|
||||||
|
|
||||||
#More about pool option : http://docs.sequelizejs.com/class/lib/sequelize.js~Sequelize.html
|
#More about pool option : http://docs.sequelizejs.com/class/lib/sequelize.js~Sequelize.html
|
||||||
DB_POOL_MAX_CONNECTIONS=Maximum number of connection in pool (ex. 18)
|
DB_POOL_MAX_CONNECTIONS=Maximum number of connection in pool (ex. 18)
|
||||||
DB_POOL_ACQUIRE=The maximum time, in milliseconds, that pool will try to get connection before throwing error (ex. 120000)
|
DB_POOL_ACQUIRE=The maximum time, in milliseconds, that pool will try to get connection before throwing error (ex. 120000)
|
||||||
|
|||||||
Reference in New Issue
Block a user