Files
old-crm-integration/constants/constants.js

173 lines
7.4 KiB
JavaScript
Raw Normal View History

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'];
2019-06-14 17:41:09 +02:00
const doorLockEvents = {
USER_LOCKED: 'locked',
USER_UNLOCKED: 'unlocked',
};
const unlockedIncidentLevelsPrices = {
UNLOCKED_0: {
id: 0,
title: 'UNLOCKED_0',
2019-07-25 06:53:32 +02:00
price: parseInt(process.env.UNLOCK_0) || 0,
description: 'first month - warning',
2019-06-14 17:41:09 +02:00
},
UNLOCKED_1: {
id: 1,
title: 'UNLOCKED_1',
2019-07-25 06:53:32 +02:00
price: parseInt(process.env.UNLOCK_1) || 10,
description: 'second month',
2019-06-14 17:41:09 +02:00
},
UNLOCKED_2: {
id: 2,
title: 'UNLOCKED_2',
2019-07-25 06:53:32 +02:00
price: parseInt(process.env.UNLOCK_2) || 20,
description: 'third month',
2019-06-14 17:41:09 +02:00
},
UNLOCKED_3: {
id: 3,
title: 'UNLOCKED_3',
2019-07-25 06:53:32 +02:00
price: parseInt(process.env.UNLOCK_3) || 30,
description: 'fourth month',
2019-06-14 17:41:09 +02:00
},
UNLOCKED_4: {
id: 4,
title: 'UNLOCKED_4',
2019-07-25 06:53:32 +02:00
price: parseInt(process.env.UNLOCK_4) || 40,
description: 'fifth month',
2019-06-14 17:41:09 +02:00
},
UNLOCKED_5: {
id: 5,
title: 'UNLOCKED_5',
2019-07-25 06:53:32 +02:00
price: parseInt(process.env.UNLOCK_5) || 50,
description: 'sixth month and onward',
2019-06-14 17:41:09 +02:00
}
};
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',
2019-06-14 17:41:09 +02:00
GENERIC_ERROR: 'There was error while parsing uploaded file(s)',
};
const officeRnDAPIErrors = {
FAILED_TO_FETCH_MEMBERS: 'Failed to fetch members',
2019-07-25 06:53:32 +02:00
FAILED_TO_FETCH_BOOKINGS: 'Failed to fetch booking reservations',
FAILED_TO_CREATE_BOOKINGS: 'Failed to create booking reservations',
FAILED_TO_DELETE_BOOKINGS: 'Failed to delete booking reservations',
FAILED_TO_FETCH_FEES: 'Failed to fetch existing fees from ORD',
FAILED_TO_FETCH_PLANS: 'Failed to fetch plans from ORD',
2019-07-25 06:53:32 +02:00
FAILED_TO_DELETE_FEES: 'Failed to delete fees in ORD',
FAILED_TO_ADD_FEES: 'Failed to add fees in ORD',
2019-08-27 09:43:37 +02:00
MEMBERSHIPS_ARE_NOT_LOADED_CORRECTLY: 'Memberships are not loaded correctly',
OAUTH_FAILED: 'Failed to fetch new OAUTH token',
FAILED_TO_FETCH_DATA: 'Failed to fetch data from ORD. Please try again in a few minutes',
FAILED_TO_FETCH_RESOURCES: 'Failed to fetch resources data from ORD',
FAILED_TO_FETCH_RATES: 'Failed to fetch rates data from ORD',
FAILED_TO_UPDATE_MEMBERSHIP: 'Failed to update membership in ORD'
2019-06-14 17:41:09 +02:00
};
const integrationServiceErrors = {
2019-07-25 15:36:49 +02:00
PROCESSING_TRY_AGAIN: 'Incident calculations are in progress. Please try again in a few minutes',
2019-07-25 06:53:32 +02:00
IMPORT_SUCCESSFUL_CALCULATION_FAILED: 'Import succeeded but fetching reservations and calculating charges failed',
2019-06-14 17:41:09 +02:00
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',
2019-06-19 11:23:58 +02:00
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',
2019-08-27 09:43:37 +02:00
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',
2019-06-14 17:41:09 +02:00
};
const incidentType = {
NOT_AN_INCIDENT: 1,
2019-07-07 07:02:42 +02:00
UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION: 2,
UNSCHEDULED_INCIDENT_BEFORE_RESERVATION: 3,
UNSCHEDULED_INCIDENT_AFTER_RESERVATION: 4,
UNLOCKED_INCIDENT_STANDALONE: 5,
UNSCHEDULED_INCIDENT_STANDALONE: 6,
2019-07-08 20:37:14 +02:00
BOOKING_MOVED_TO_ANOTHER_DAY: 7,
BOOKING_SHORTENED: 8,
2019-07-19 09:46:15 +02:00
BOOKING_CANCELED_LATE: 9,
};
2019-07-25 06:53:32 +02:00
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';
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_AFTER_RESERVATION] = 'room used after reservation';
incidentTypeExplanations[incidentType.UNSCHEDULED_INCIDENT_STANDALONE] = 'room used without reservation';
incidentTypeExplanations[incidentType.BOOKING_MOVED_TO_ANOTHER_DAY] = 'reservation moved to another day in less than 24 hrs';
incidentTypeExplanations[incidentType.BOOKING_SHORTENED] = 'reservation shortened after grace period';
incidentTypeExplanations[incidentType.BOOKING_CANCELED_LATE] = 'reservation cancelled after grace period';
2019-07-25 06:53:32 +02:00
2019-06-19 11:23:58 +02:00
const UI_TIMEZONE = process.env.UI_TIMEZONE || 'America/Los_Angeles';
const DEFAULT_DATE_FORMAT = 'YYYY-MM-DD';
2019-07-01 09:31:13 +02:00
const MAX_BACK_TO_BACK_DIFFERENCE = parseInt(process.env.MAX_BACK_TO_BACK_DIFFERENCE) || 0;
const UNSCHEDULED_USE_INITIAL_TIME_SEGMENT_LENGTH = parseInt(process.env.UNSCHEDULED_USE_INITIAL_TIME_SEGMENT_LENGTH) || 7;
2019-07-01 09:31:13 +02:00
const UNSCHEDULED_TIME_RESOLUTION = parseInt(process.env.UNSCHEDULED_USE_TIME_RESOLUTION) || 5;
const UNSCHEDULED_CHARGE_PRICE = parseFloat(process.env.UNSCHEDULED_USE_CHARGE_PRICE) || 5;
2019-07-08 20:37:14 +02:00
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;
2019-07-19 22:25:22 +02:00
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()) || [];
2019-09-05 14:52:10 +02:00
const CUSTOM_FEES_PREFIXES = process.env.CUSTOM_FEES_PREFIXES.split(',')
.map(prefix => prefix.trim())
.filter(prefix => prefix && prefix.length ? prefix.length > 0 : false) || [];
2019-08-22 06:02:29 +02:00
const UNPAID_FEE_STATUS = 'not_paid';
const ALLOW_SENDING_FEES = parseInt(process.env.ALLOW_SENDING_FEES_FOR_CURRENT_AND_FUTURE_MONTHS) ? true : false;
const TRIM_DLOCK_NAMES_LENGTH = parseInt(process.env.TRIM_DLOCK_NAMES_LENGTH) || 22;
module.exports = {
VALID_CSV_HEADERS,
USER_ENTRY_EVENT,
ENABLE_PASSAGE_MODE,
DISABLE_PASSAGE_MODE,
csvParserErrors,
officeRnDAPIErrors,
2019-06-14 17:41:09 +02:00
doorLockEvents,
unlockedIncidentLevelsPrices,
integrationServiceErrors,
incidentType,
2019-07-25 06:53:32 +02:00
incidentTypeExplanations,
2019-06-19 11:23:58 +02:00
UI_TIMEZONE,
DEFAULT_DATE_FORMAT,
2019-07-01 09:31:13 +02:00
MAX_BACK_TO_BACK_DIFFERENCE,
UNSCHEDULED_USE_INITIAL_TIME_SEGMENT_LENGTH,
2019-07-01 09:31:13 +02:00
UNSCHEDULED_TIME_RESOLUTION,
UNSCHEDULED_CHARGE_PRICE,
2019-07-08 20:37:14 +02:00
BOOKING_CHANGE_PERCENTAGE_CHARGE,
CHARGE_BOOKING_CHANGE_UNDER_TIME,
2019-07-19 22:25:22 +02:00
ALLOWED_BOOKING_CANCELLATION_TIME,
discounts,
DISCOUNT_PLANS,
2019-08-22 06:02:29 +02:00
UNPAID_FEE_STATUS,
2019-09-05 14:52:10 +02:00
CUSTOM_FEES_PREFIXES,
ALLOW_SENDING_FEES,
TRIM_DLOCK_NAMES_LENGTH
};