save funeral homes as occupants

deepsource-autofix-76c6eb20
Dan Gowans 2022-10-12 13:05:02 -04:00
parent d0daba5121
commit b811bfd157
5 changed files with 192 additions and 54 deletions

View File

@ -1,7 +1,7 @@
import type * as recordTypes from "../types/recordTypes"; import type * as recordTypes from "../types/recordTypes";
export declare function getLotOccupantTypes(): recordTypes.LotOccupantType[]; export declare function getLotOccupantTypes(): recordTypes.LotOccupantType[];
export declare function getLotOccupantTypeById(lotOccupantTypeId: number): recordTypes.LotOccupantType; export declare function getLotOccupantTypeById(lotOccupantTypeId: number): recordTypes.LotOccupantType;
export declare function getLotOccupantTypesByLotOccupantType(lotOccupantType: string): recordTypes.LotOccupantType; export declare function getLotOccupantTypeByLotOccupantType(lotOccupantType: string): recordTypes.LotOccupantType;
export declare function clearLotOccupantTypesCache(): void; export declare function clearLotOccupantTypesCache(): void;
export declare function getLotStatuses(): recordTypes.LotStatus[]; export declare function getLotStatuses(): recordTypes.LotStatus[];
export declare function getLotStatusById(lotStatusId: number): recordTypes.LotStatus; export declare function getLotStatusById(lotStatusId: number): recordTypes.LotStatus;

View File

@ -18,7 +18,7 @@ export function getLotOccupantTypeById(lotOccupantTypeId) {
return currentLotOccupantType.lotOccupantTypeId === lotOccupantTypeId; return currentLotOccupantType.lotOccupantTypeId === lotOccupantTypeId;
}); });
} }
export function getLotOccupantTypesByLotOccupantType(lotOccupantType) { export function getLotOccupantTypeByLotOccupantType(lotOccupantType) {
const cachedLotOccupantTypes = getLotOccupantTypes(); const cachedLotOccupantTypes = getLotOccupantTypes();
const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase(); const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase();
return cachedLotOccupantTypes.find((currentLotOccupantType) => { return cachedLotOccupantTypes.find((currentLotOccupantType) => {

View File

@ -35,7 +35,7 @@ export function getLotOccupantTypeById(lotOccupantTypeId: number) {
}); });
} }
export function getLotOccupantTypesByLotOccupantType(lotOccupantType: string) { export function getLotOccupantTypeByLotOccupantType(lotOccupantType: string) {
const cachedLotOccupantTypes = getLotOccupantTypes(); const cachedLotOccupantTypes = getLotOccupantTypes();
const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase(); const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase();

View File

@ -180,14 +180,64 @@ const preneedOccupancyType = cacheFunctions.getOccupancyTypeByOccupancyType("Pre
const deceasedOccupancyType = cacheFunctions.getOccupancyTypeByOccupancyType("Interment"); const deceasedOccupancyType = cacheFunctions.getOccupancyTypeByOccupancyType("Interment");
const cremationOccupancyType = cacheFunctions.getOccupancyTypeByOccupancyType("Cremation"); const cremationOccupancyType = cacheFunctions.getOccupancyTypeByOccupancyType("Cremation");
const allOccupancyTypeFields = cacheFunctions.getAllOccupancyTypeFields(); const allOccupancyTypeFields = cacheFunctions.getAllOccupancyTypeFields();
const preneedOwnerLotOccupantType = cacheFunctions.getLotOccupantTypesByLotOccupantType("Preneed Owner"); const preneedOwnerLotOccupantType = cacheFunctions.getLotOccupantTypeByLotOccupantType("Preneed Owner");
const deceasedLotOccupantType = cacheFunctions.getLotOccupantTypesByLotOccupantType("Deceased"); const funeralDirectorLotOccupantType = cacheFunctions.getLotOccupantTypeByLotOccupantType("Funeral Director");
const purchaserLotOccupantType = cacheFunctions.getLotOccupantTypesByLotOccupantType("Purchaser"); const deceasedLotOccupantType = cacheFunctions.getLotOccupantTypeByLotOccupantType("Deceased");
const purchaserLotOccupantType = cacheFunctions.getLotOccupantTypeByLotOccupantType("Purchaser");
const acknowledgedWorkOrderMilestoneType = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType("Acknowledged"); const acknowledgedWorkOrderMilestoneType = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType("Acknowledged");
const deathWorkOrderMilestoneType = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType("Death"); const deathWorkOrderMilestoneType = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType("Death");
const funeralWorkOrderMilestoneType = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType("Funeral"); const funeralWorkOrderMilestoneType = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType("Funeral");
const cremationWorkOrderMilestoneType = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType("Cremation"); const cremationWorkOrderMilestoneType = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType("Cremation");
const intermentWorkOrderMilestoneType = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType("Interment"); const intermentWorkOrderMilestoneType = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType("Interment");
function getFuneralHome(funeralHomeKey) {
switch (funeralHomeKey) {
case "AR": {
return {
lotOccupantTypeId: funeralDirectorLotOccupantType.lotOccupantTypeId,
occupantName: "Arthur Funeral Home",
occupantAddress1: "492 Wellington Street East",
occupantAddress2: "",
occupantCity: "Sault Ste. Marie",
occupantProvince: "ON",
occupantPostalCode: "P6A 2L9",
occupantPhoneNumber: "705-759-2522",
occupantEmailAddress: ""
};
}
case "NO": {
return {
lotOccupantTypeId: funeralDirectorLotOccupantType.lotOccupantTypeId,
occupantName: "Northwood Funeral Home",
occupantAddress1: "942 Great Northern Road",
occupantAddress2: "",
occupantCity: "Sault Ste. Marie",
occupantProvince: "ON",
occupantPostalCode: "P6B 0B6",
occupantPhoneNumber: "705-945-7758",
occupantEmailAddress: ""
};
}
case "OS": {
return {
lotOccupantTypeId: funeralDirectorLotOccupantType.lotOccupantTypeId,
occupantName: "O'Sullivan Funeral Home",
occupantAddress1: "215 St. James Street",
occupantAddress2: "",
occupantCity: "Sault Ste. Marie",
occupantProvince: "ON",
occupantPostalCode: "P6A 1P7",
occupantPhoneNumber: "705-759-8456",
occupantEmailAddress: ""
};
}
}
return {
lotOccupantTypeId: funeralDirectorLotOccupantType.lotOccupantTypeId,
occupantName: funeralHomeKey,
occupantCity: "Sault Ste. Marie",
occupantProvince: "ON"
};
}
function importFromMasterCSV() { function importFromMasterCSV() {
let masterRow; let masterRow;
const rawData = fs.readFileSync("./temp/CMMASTER.csv").toString(); const rawData = fs.readFileSync("./temp/CMMASTER.csv").toString();
@ -362,12 +412,18 @@ function importFromMasterCSV() {
}, user); }, user);
} }
if (masterRow.CM_FUNERAL_HOME !== "") { if (masterRow.CM_FUNERAL_HOME !== "") {
addOrUpdateLotOccupancyField({ const funeralHomeOccupant = getFuneralHome(masterRow.CM_FUNERAL_HOME);
addLotOccupancyOccupant({
lotOccupancyId: deceasedLotOccupancyId, lotOccupancyId: deceasedLotOccupancyId,
occupancyTypeFieldId: allOccupancyTypeFields.find((occupancyTypeField) => { lotOccupantTypeId: funeralHomeOccupant.lotOccupantTypeId,
return occupancyTypeField.occupancyTypeField === "Funeral Home"; occupantName: funeralHomeOccupant.occupantName,
}).occupancyTypeFieldId, occupantAddress1: funeralHomeOccupant.occupantAddress1,
lotOccupancyFieldValue: masterRow.CM_FUNERAL_HOME occupantAddress2: funeralHomeOccupant.occupantAddress2,
occupantCity: funeralHomeOccupant.occupantCity,
occupantProvince: funeralHomeOccupant.occupantProvince,
occupantPostalCode: funeralHomeOccupant.occupantPostalCode,
occupantPhoneNumber: funeralHomeOccupant.occupantPhoneNumber,
occupantEmailAddress: funeralHomeOccupant.occupantEmailAddress
}, user); }, user);
} }
if (masterRow.CM_FUNERAL_YR !== "") { if (masterRow.CM_FUNERAL_YR !== "") {
@ -790,12 +846,18 @@ function importFromWorkOrderCSV() {
}, user); }, user);
} }
if (workOrderRow.WO_FUNERAL_HOME !== "") { if (workOrderRow.WO_FUNERAL_HOME !== "") {
addOrUpdateLotOccupancyField({ const funeralHomeOccupant = getFuneralHome(workOrderRow.WO_FUNERAL_HOME);
addLotOccupancyOccupant({
lotOccupancyId: lotOccupancyId, lotOccupancyId: lotOccupancyId,
occupancyTypeFieldId: allOccupancyTypeFields.find((occupancyTypeField) => { lotOccupantTypeId: funeralHomeOccupant.lotOccupantTypeId,
return occupancyTypeField.occupancyTypeField === "Funeral Home"; occupantName: funeralHomeOccupant.occupantName,
}).occupancyTypeFieldId, occupantAddress1: funeralHomeOccupant.occupantAddress1,
lotOccupancyFieldValue: workOrderRow.WO_FUNERAL_HOME occupantAddress2: funeralHomeOccupant.occupantAddress2,
occupantCity: funeralHomeOccupant.occupantCity,
occupantProvince: funeralHomeOccupant.occupantProvince,
occupantPostalCode: funeralHomeOccupant.occupantPostalCode,
occupantPhoneNumber: funeralHomeOccupant.occupantPhoneNumber,
occupantEmailAddress: funeralHomeOccupant.occupantEmailAddress
}, user); }, user);
} }
if (workOrderRow.WO_FUNERAL_YR !== "") { if (workOrderRow.WO_FUNERAL_YR !== "") {

View File

@ -416,9 +416,11 @@ const cremationOccupancyType = cacheFunctions.getOccupancyTypeByOccupancyType("C
const allOccupancyTypeFields = cacheFunctions.getAllOccupancyTypeFields(); const allOccupancyTypeFields = cacheFunctions.getAllOccupancyTypeFields();
const preneedOwnerLotOccupantType = const preneedOwnerLotOccupantType =
cacheFunctions.getLotOccupantTypesByLotOccupantType("Preneed Owner"); cacheFunctions.getLotOccupantTypeByLotOccupantType("Preneed Owner");
const deceasedLotOccupantType = cacheFunctions.getLotOccupantTypesByLotOccupantType("Deceased"); const funeralDirectorLotOccupantType =
const purchaserLotOccupantType = cacheFunctions.getLotOccupantTypesByLotOccupantType("Purchaser"); cacheFunctions.getLotOccupantTypeByLotOccupantType("Funeral Director");
const deceasedLotOccupantType = cacheFunctions.getLotOccupantTypeByLotOccupantType("Deceased");
const purchaserLotOccupantType = cacheFunctions.getLotOccupantTypeByLotOccupantType("Purchaser");
const acknowledgedWorkOrderMilestoneType = const acknowledgedWorkOrderMilestoneType =
cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType("Acknowledged"); cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType("Acknowledged");
@ -431,6 +433,58 @@ const cremationWorkOrderMilestoneType =
const intermentWorkOrderMilestoneType = const intermentWorkOrderMilestoneType =
cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType("Interment"); cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType("Interment");
function getFuneralHome(funeralHomeKey: string): recordTypes.LotOccupancyOccupant {
switch (funeralHomeKey) {
case "AR": {
return {
lotOccupantTypeId: funeralDirectorLotOccupantType.lotOccupantTypeId,
occupantName: "Arthur Funeral Home",
occupantAddress1: "492 Wellington Street East",
occupantAddress2: "",
occupantCity: "Sault Ste. Marie",
occupantProvince: "ON",
occupantPostalCode: "P6A 2L9",
occupantPhoneNumber: "705-759-2522",
occupantEmailAddress: ""
}
}
case "NO": {
return {
lotOccupantTypeId: funeralDirectorLotOccupantType.lotOccupantTypeId,
occupantName: "Northwood Funeral Home",
occupantAddress1: "942 Great Northern Road",
occupantAddress2: "",
occupantCity: "Sault Ste. Marie",
occupantProvince: "ON",
occupantPostalCode: "P6B 0B6",
occupantPhoneNumber: "705-945-7758",
occupantEmailAddress: ""
}
}
case "OS": {
return {
lotOccupantTypeId: funeralDirectorLotOccupantType.lotOccupantTypeId,
occupantName: "O'Sullivan Funeral Home",
occupantAddress1: "215 St. James Street",
occupantAddress2: "",
occupantCity: "Sault Ste. Marie",
occupantProvince: "ON",
occupantPostalCode: "P6A 1P7",
occupantPhoneNumber: "705-759-8456",
occupantEmailAddress: ""
}
}
}
return {
lotOccupantTypeId: funeralDirectorLotOccupantType.lotOccupantTypeId,
occupantName: funeralHomeKey,
occupantCity: "Sault Ste. Marie",
occupantProvince: "ON"
}
}
function importFromMasterCSV() { function importFromMasterCSV() {
let masterRow: MasterRecord; let masterRow: MasterRecord;
@ -718,6 +772,23 @@ function importFromMasterCSV() {
} }
if (masterRow.CM_FUNERAL_HOME !== "") { if (masterRow.CM_FUNERAL_HOME !== "") {
const funeralHomeOccupant = getFuneralHome(masterRow.CM_FUNERAL_HOME);
addLotOccupancyOccupant({
lotOccupancyId: deceasedLotOccupancyId,
lotOccupantTypeId: funeralHomeOccupant.lotOccupantTypeId,
occupantName: funeralHomeOccupant.occupantName,
occupantAddress1: funeralHomeOccupant.occupantAddress1,
occupantAddress2: funeralHomeOccupant.occupantAddress2,
occupantCity: funeralHomeOccupant.occupantCity,
occupantProvince: funeralHomeOccupant.occupantProvince,
occupantPostalCode: funeralHomeOccupant.occupantPostalCode,
occupantPhoneNumber: funeralHomeOccupant.occupantPhoneNumber,
occupantEmailAddress: funeralHomeOccupant.occupantEmailAddress
}, user);
/*
addOrUpdateLotOccupancyField( addOrUpdateLotOccupancyField(
{ {
lotOccupancyId: deceasedLotOccupancyId, lotOccupancyId: deceasedLotOccupancyId,
@ -730,6 +801,7 @@ function importFromMasterCSV() {
}, },
user user
); );
*/
} }
if (masterRow.CM_FUNERAL_YR !== "") { if (masterRow.CM_FUNERAL_YR !== "") {
@ -1306,11 +1378,9 @@ function importFromWorkOrderCSV() {
addOrUpdateLotOccupancyField( addOrUpdateLotOccupancyField(
{ {
lotOccupancyId: lotOccupancyId, lotOccupancyId: lotOccupancyId,
occupancyTypeFieldId: allOccupancyTypeFields.find( occupancyTypeFieldId: allOccupancyTypeFields.find((occupancyTypeField) => {
(occupancyTypeField) => {
return occupancyTypeField.occupancyTypeField === "Death Date"; return occupancyTypeField.occupancyTypeField === "Death Date";
} }).occupancyTypeFieldId,
).occupancyTypeFieldId,
lotOccupancyFieldValue lotOccupancyFieldValue
}, },
user user
@ -1321,11 +1391,9 @@ function importFromWorkOrderCSV() {
addOrUpdateLotOccupancyField( addOrUpdateLotOccupancyField(
{ {
lotOccupancyId: lotOccupancyId, lotOccupancyId: lotOccupancyId,
occupancyTypeFieldId: allOccupancyTypeFields.find( occupancyTypeFieldId: allOccupancyTypeFields.find((occupancyTypeField) => {
(occupancyTypeField) => {
return occupancyTypeField.occupancyTypeField === "Death Age"; return occupancyTypeField.occupancyTypeField === "Death Age";
} }).occupancyTypeFieldId,
).occupancyTypeFieldId,
lotOccupancyFieldValue: workOrderRow.WO_AGE lotOccupancyFieldValue: workOrderRow.WO_AGE
}, },
user user
@ -1336,11 +1404,9 @@ function importFromWorkOrderCSV() {
addOrUpdateLotOccupancyField( addOrUpdateLotOccupancyField(
{ {
lotOccupancyId: lotOccupancyId, lotOccupancyId: lotOccupancyId,
occupancyTypeFieldId: allOccupancyTypeFields.find( occupancyTypeFieldId: allOccupancyTypeFields.find((occupancyTypeField) => {
(occupancyTypeField) => {
return occupancyTypeField.occupancyTypeField === "Death Age Period"; return occupancyTypeField.occupancyTypeField === "Death Age Period";
} }).occupancyTypeFieldId,
).occupancyTypeFieldId,
lotOccupancyFieldValue: workOrderRow.WO_PERIOD lotOccupancyFieldValue: workOrderRow.WO_PERIOD
}, },
user user
@ -1348,18 +1414,34 @@ function importFromWorkOrderCSV() {
} }
if (workOrderRow.WO_FUNERAL_HOME !== "") { if (workOrderRow.WO_FUNERAL_HOME !== "") {
const funeralHomeOccupant = getFuneralHome(workOrderRow.WO_FUNERAL_HOME);
addLotOccupancyOccupant({
lotOccupancyId: lotOccupancyId,
lotOccupantTypeId: funeralHomeOccupant.lotOccupantTypeId,
occupantName: funeralHomeOccupant.occupantName,
occupantAddress1: funeralHomeOccupant.occupantAddress1,
occupantAddress2: funeralHomeOccupant.occupantAddress2,
occupantCity: funeralHomeOccupant.occupantCity,
occupantProvince: funeralHomeOccupant.occupantProvince,
occupantPostalCode: funeralHomeOccupant.occupantPostalCode,
occupantPhoneNumber: funeralHomeOccupant.occupantPhoneNumber,
occupantEmailAddress: funeralHomeOccupant.occupantEmailAddress
}, user);
/*
addOrUpdateLotOccupancyField( addOrUpdateLotOccupancyField(
{ {
lotOccupancyId: lotOccupancyId, lotOccupancyId: lotOccupancyId,
occupancyTypeFieldId: allOccupancyTypeFields.find( occupancyTypeFieldId: allOccupancyTypeFields.find((occupancyTypeField) => {
(occupancyTypeField) => {
return occupancyTypeField.occupancyTypeField === "Funeral Home"; return occupancyTypeField.occupancyTypeField === "Funeral Home";
} }).occupancyTypeFieldId,
).occupancyTypeFieldId,
lotOccupancyFieldValue: workOrderRow.WO_FUNERAL_HOME lotOccupancyFieldValue: workOrderRow.WO_FUNERAL_HOME
}, },
user user
); );
*/
} }
if (workOrderRow.WO_FUNERAL_YR !== "") { if (workOrderRow.WO_FUNERAL_YR !== "") {
@ -1372,11 +1454,9 @@ function importFromWorkOrderCSV() {
addOrUpdateLotOccupancyField( addOrUpdateLotOccupancyField(
{ {
lotOccupancyId: lotOccupancyId, lotOccupancyId: lotOccupancyId,
occupancyTypeFieldId: allOccupancyTypeFields.find( occupancyTypeFieldId: allOccupancyTypeFields.find((occupancyTypeField) => {
(occupancyTypeField) => {
return occupancyTypeField.occupancyTypeField === "Funeral Date"; return occupancyTypeField.occupancyTypeField === "Funeral Date";
} }).occupancyTypeFieldId,
).occupancyTypeFieldId,
lotOccupancyFieldValue lotOccupancyFieldValue
}, },
user user
@ -1387,11 +1467,9 @@ function importFromWorkOrderCSV() {
addOrUpdateLotOccupancyField( addOrUpdateLotOccupancyField(
{ {
lotOccupancyId: lotOccupancyId, lotOccupancyId: lotOccupancyId,
occupancyTypeFieldId: allOccupancyTypeFields.find( occupancyTypeFieldId: allOccupancyTypeFields.find((occupancyTypeField) => {
(occupancyTypeField) => {
return occupancyTypeField.occupancyTypeField === "Container Type"; return occupancyTypeField.occupancyTypeField === "Container Type";
} }).occupancyTypeFieldId,
).occupancyTypeFieldId,
lotOccupancyFieldValue: workOrderRow.WO_CONTAINER_TYPE lotOccupancyFieldValue: workOrderRow.WO_CONTAINER_TYPE
}, },
user user
@ -1408,11 +1486,9 @@ function importFromWorkOrderCSV() {
addOrUpdateLotOccupancyField( addOrUpdateLotOccupancyField(
{ {
lotOccupancyId: lotOccupancyId, lotOccupancyId: lotOccupancyId,
occupancyTypeFieldId: allOccupancyTypeFields.find( occupancyTypeFieldId: allOccupancyTypeFields.find((occupancyTypeField) => {
(occupancyTypeField) => {
return occupancyTypeField.occupancyTypeField === "Committal Type"; return occupancyTypeField.occupancyTypeField === "Committal Type";
} }).occupancyTypeFieldId,
).occupancyTypeFieldId,
lotOccupancyFieldValue: commitalType lotOccupancyFieldValue: commitalType
}, },
user user