Files
old-crm-integration/constants/constants.js
2019-08-27 09:43:37 +02:00

150 lines
6.0 KiB
JavaScript

const USER_ENTRY_EVENT = 'User Entry';
const ENABLE_PASSAGE_MODE = 'Enable Passage Mode by Group 2';
const DISABLE_PASSAGE_MODE = 'Disable Passage Mode by Group 2';
const VALID_CSV_HEADERS = ['Date', 'Time', 'User No', 'Name', 'Event'];
const doorLockEvents = {
USER_LOCKED: 'locked',
USER_UNLOCKED: 'unlocked',
};
const unlockedIncidentLevelsPrices = {
UNLOCKED_0: {
id: 0,
title: 'UNLOCKED_0',
price: parseInt(process.env.UNLOCK_0) || 0,
description: 'First month - warning',
},
UNLOCKED_1: {
id: 1,
title: 'UNLOCKED_1',
price: parseInt(process.env.UNLOCK_1) || 10,
description: 'Second month',
},
UNLOCKED_2: {
id: 2,
title: 'UNLOCKED_2',
price: parseInt(process.env.UNLOCK_2) || 20,
description: 'Third month',
},
UNLOCKED_3: {
id: 3,
title: 'UNLOCKED_3',
price: parseInt(process.env.UNLOCK_3) || 30,
description: 'Fourth month',
},
UNLOCKED_4: {
id: 4,
title: 'UNLOCKED_4',
price: parseInt(process.env.UNLOCK_4) || 40,
description: 'Fifth month',
},
UNLOCKED_5: {
id: 5,
title: 'UNLOCKED_5',
price: parseInt(process.env.UNLOCK_5) || 50,
description: 'Sixth month and onward',
}
};
const csvParserErrors = {
INVALID_HEADERS: 'Invalid headers',
INVALID_ENTRY_EXPECTED_USER: 'Invalid entry type. Expected user entry type',
INVALID_ENTRY_EXPECTED_PASSAGE_MODE: 'Invalid entry type. Expected enable/disable passage mode following user entry',
UNKNOWN_MEMBER: 'Member is not registered in OfficeRnD system',
GENERIC_ERROR: 'There was error while parsing uploaded file(s)',
};
const officeRnDAPIErrors = {
FAILED_TO_FETCH_MEMBERS: 'Failed to fetch members',
FAILED_TO_FETCH_BOOKINGS: 'Failed to fetch booking reservations',
FAILED_TO_FETCH_FEES: 'Failed to fetch existing fees',
FAILED_TO_DELETE_FEES: 'Failed to delete fees in ORD',
FAILED_TO_ADD_FEES: 'Failed to add fees in ORD',
MEMBERSHIPS_ARE_NOT_LOADED_CORRECTLY: 'Memberships are not loaded correctly',
};
const integrationServiceErrors = {
PROCESSING_TRY_AGAIN: 'Incident calculations are in progress. Please try again in a few minutes',
IMPORT_SUCCESSFUL_CALCULATION_FAILED: 'Import succeeded but fetching reservations and calculating charges failed',
FAILED_TO_SAVE_BOOKINGS: 'Failed to save booking reservations',
FAILED_TO_SAVE_DOOR_LOCK_ENTRIES: 'Failed to save door lock entries',
FAILED_TO_SAVE_DATA_GENERIC: 'Failed to save data',
INVALID_DATE_RANGE: 'Dates in date range are invalid',
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',
EXPECTED_MEMBER_IDS_ARRAY: 'Expected array of member IDs',
};
const incidentType = {
NOT_AN_INCIDENT: 1,
UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION: 2,
UNSCHEDULED_INCIDENT_BEFORE_RESERVATION: 3,
UNSCHEDULED_INCIDENT_AFTER_RESERVATION: 4,
UNLOCKED_INCIDENT_STANDALONE: 5,
UNSCHEDULED_INCIDENT_STANDALONE: 6,
BOOKING_MOVED_TO_ANOTHER_DAY: 7,
BOOKING_SHORTENED: 8,
BOOKING_CANCELED_LATE: 9,
};
const incidentTypeExplanations = {};
incidentTypeExplanations[incidentType.UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION] = 'Door left unlocked';
incidentTypeExplanations[incidentType.UNLOCKED_INCIDENT_STANDALONE] = 'Door left unlocked';
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_BEFORE_RESERVATION] = 'Room used before reservation started';
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_AFTER_RESERVATION] = 'Room used after reservation ended';
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_STANDALONE] = 'Room used without reservation';
incidentTypeExplanations[incidentType.BOOKING_MOVED_TO_ANOTHER_DAY] = 'Reservation moved to another day';
incidentTypeExplanations[incidentType.BOOKING_SHORTENED] = 'Reservation shortened after grace period';
incidentTypeExplanations[incidentType.BOOKING_CANCELED_LATE] = 'Reservation cancelled after grace period';
const UI_TIMEZONE = process.env.UI_TIMEZONE || 'America/Los_Angeles';
const DEFAULT_DATE_FORMAT = 'YYYY-MM-DD';
const MAX_BACK_TO_BACK_DIFFERENCE = parseInt(process.env.MAX_BACK_TO_BACK_DIFFERENCE) || 0;
const UNSCHEDULED_TIME_RESOLUTION = parseInt(process.env.UNSCHEDULED_USE_TIME_RESOLUTION) || 5;
const UNSCHEDULED_CHARGE_PRICE = parseFloat(process.env.UNSCHEDULED_USE_CHARGE_PRICE) || 5;
const BOOKING_CHANGE_PERCENTAGE_CHARGE = parseInt(process.env.BOOKING_CHANGE_PERCENTAGE_CHARGE) || 100;
const CHARGE_BOOKING_CHANGE_UNDER_TIME = parseInt(process.env.CHARGE_BOOKING_CHANGE_UNDER_TIME) || 1430;
const ALLOWED_BOOKING_CANCELLATION_TIME = parseInt(process.env.ALLOWED_BOOKING_CANCELLATION_TIME) || 30;
const discounts = {
LEVEL_1:{
hoursRequired: parseInt(process.env.DISCOUNT_LEVEL_1_HOURS) || 10,
percentage: parseInt(process.env.DISCOUNT_LEVEL_1_PERCENTAGE) || 5,
},
LEVEL_2:{
hoursRequired: parseInt(process.env.DISCOUNT_LEVEL_2_HOURS) || 40,
percentage: parseInt(process.env.DISCOUNT_LEVEL_2_PERCENTAGE) || 10,
}
};
const DISCOUNT_PLANS = process.env.DISCOUNT_PLANS.split(',').map(planName => planName.trim()) || [];
const UNPAID_FEE_STATUS = 'not_paid';
module.exports = {
VALID_CSV_HEADERS,
USER_ENTRY_EVENT,
ENABLE_PASSAGE_MODE,
DISABLE_PASSAGE_MODE,
csvParserErrors,
officeRnDAPIErrors,
doorLockEvents,
unlockedIncidentLevelsPrices,
integrationServiceErrors,
incidentType,
incidentTypeExplanations,
UI_TIMEZONE,
DEFAULT_DATE_FORMAT,
MAX_BACK_TO_BACK_DIFFERENCE,
UNSCHEDULED_TIME_RESOLUTION,
UNSCHEDULED_CHARGE_PRICE,
BOOKING_CHANGE_PERCENTAGE_CHARGE,
CHARGE_BOOKING_CHANGE_UNDER_TIME,
ALLOWED_BOOKING_CANCELLATION_TIME,
discounts,
DISCOUNT_PLANS,
UNPAID_FEE_STATUS,
};