Control sending fees via ENV variable

This commit is contained in:
Bilal Catic
2019-09-10 06:56:02 +02:00
parent 1e2eadba6c
commit 75201dea6d
3 changed files with 16 additions and 6 deletions

View File

@@ -10,7 +10,7 @@ const { reformatMembershipsName } = require('../services/officeRnD/memberships')
const { checkBookingChanges } = require('../services/integration/checkBookingChange');
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 dataToFetch = [getMappingsFromDatabase(), fetchOffices(), fetchResources()];
@@ -126,7 +126,10 @@ const addFees = (req, res) => {
const currentMonth = currentMoment.month();
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()
.then(() => {
deleteFeesFromORD(dateRange, memberIds)
@@ -169,12 +172,12 @@ const addFees = (req, res) => {
res.status(500).send(error);
})
}else{
console.log('Selected month/year pair is current month or in the future');
res.status(400).send('Selected month/year pair is current month or in the future');
console.log(integrationServiceErrors.SENDING_FEES_DISABLED);
res.status(400).send(integrationServiceErrors.SENDING_FEES_DISABLED);
}
}else{
console.log('Date range is missing to send fees to ORD');
res.status(400).send('Date range is missing');
console.log(integrationServiceErrors.MONTH_MISSING);
res.status(400).send(integrationServiceErrors.MONTH_MISSING);
}
};