From 3c4c85df19faaaf1a1ea124a1506fbdaba8f0575 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Mon, 28 Apr 2025 14:50:34 -0400 Subject: [PATCH] import cleanup --- .../data.burialSiteTypes.js | 1 + .../data.burialSiteTypes.ts | 1 + temp/legacyImportFromCsv/data.ids.d.ts | 7 ++- temp/legacyImportFromCsv/data.ids.js | 30 +++++---- temp/legacyImportFromCsv/data.ids.ts | 61 ++++++++----------- temp/legacyImportFromCsv/index.js | 22 +++---- temp/legacyImportFromCsv/index.ts | 28 +++++---- 7 files changed, 74 insertions(+), 76 deletions(-) diff --git a/temp/legacyImportFromCsv/data.burialSiteTypes.js b/temp/legacyImportFromCsv/data.burialSiteTypes.js index 4a5d1d15..6207a1a5 100644 --- a/temp/legacyImportFromCsv/data.burialSiteTypes.js +++ b/temp/legacyImportFromCsv/data.burialSiteTypes.js @@ -13,6 +13,7 @@ const urnGardenBurialSiteTypeId = cacheFunctions.getBurialSiteTypesByBurialSiteT ?.burialSiteTypeId; export function getBurialSiteTypeId(cemeteryKey) { switch (cemeteryKey) { + case '': case '00': { return cremationBurialSiteTypeId; } diff --git a/temp/legacyImportFromCsv/data.burialSiteTypes.ts b/temp/legacyImportFromCsv/data.burialSiteTypes.ts index 78638544..bd18e6d8 100644 --- a/temp/legacyImportFromCsv/data.burialSiteTypes.ts +++ b/temp/legacyImportFromCsv/data.burialSiteTypes.ts @@ -26,6 +26,7 @@ const urnGardenBurialSiteTypeId = export function getBurialSiteTypeId(cemeteryKey: string): number { switch (cemeteryKey) { + case '': case '00': { return cremationBurialSiteTypeId } diff --git a/temp/legacyImportFromCsv/data.ids.d.ts b/temp/legacyImportFromCsv/data.ids.d.ts index cbf75263..fc7368c2 100644 --- a/temp/legacyImportFromCsv/data.ids.d.ts +++ b/temp/legacyImportFromCsv/data.ids.d.ts @@ -1,9 +1,10 @@ +import type { ContractType } from '../../types/record.types.js'; export declare const availableBurialSiteStatusId: number; export declare const reservedBurialSiteStatusId: number; export declare const takenBurialSiteStatusId: number; -export declare const preneedContractType: import("../../types/record.types.js").ContractType; -export declare const deceasedContractType: import("../../types/record.types.js").ContractType; -export declare const cremationContractType: import("../../types/record.types.js").ContractType; +export declare const preneedContractType: ContractType; +export declare const deceasedContractType: ContractType; +export declare const cremationContractType: ContractType; export declare const acknowledgedWorkOrderMilestoneTypeId: number | undefined; export declare const deathWorkOrderMilestoneTypeId: number | undefined; export declare const funeralWorkOrderMilestoneTypeId: number | undefined; diff --git a/temp/legacyImportFromCsv/data.ids.js b/temp/legacyImportFromCsv/data.ids.js index b14ec10f..c6f29cc3 100644 --- a/temp/legacyImportFromCsv/data.ids.js +++ b/temp/legacyImportFromCsv/data.ids.js @@ -1,29 +1,27 @@ -// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair -/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/no-await-expression-member */ import * as cacheFunctions from '../../helpers/functions.cache.js'; /* * Burial Site Status IDs */ -export const availableBurialSiteStatusId = (await cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Available')) - .burialSiteStatusId; -export const reservedBurialSiteStatusId = (await cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Reserved')) - .burialSiteStatusId; -export const takenBurialSiteStatusId = (await cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Taken')) - .burialSiteStatusId; +export const availableBurialSiteStatusId = cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Available') + ?.burialSiteStatusId; +export const reservedBurialSiteStatusId = cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Reserved') + ?.burialSiteStatusId; +export const takenBurialSiteStatusId = cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Taken') + ?.burialSiteStatusId; /* * Contract Type IDs */ -export const preneedContractType = (await cacheFunctions.getContractTypeByContractType('Preneed')); -export const deceasedContractType = (await cacheFunctions.getContractTypeByContractType('Interment')); -export const cremationContractType = (await cacheFunctions.getContractTypeByContractType('Cremation')); +export const preneedContractType = cacheFunctions.getContractTypeByContractType('Preneed'); +export const deceasedContractType = cacheFunctions.getContractTypeByContractType('Interment'); +export const cremationContractType = cacheFunctions.getContractTypeByContractType('Cremation'); /* * Work Order Milestone Type IDs */ -export const acknowledgedWorkOrderMilestoneTypeId = (await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Acknowledged'))?.workOrderMilestoneTypeId; -export const deathWorkOrderMilestoneTypeId = (await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Death'))?.workOrderMilestoneTypeId; -export const funeralWorkOrderMilestoneTypeId = (await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Funeral'))?.workOrderMilestoneTypeId; -export const cremationWorkOrderMilestoneTypeId = (await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Cremation'))?.workOrderMilestoneTypeId; -export const intermentWorkOrderMilestoneTypeId = (await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Interment'))?.workOrderMilestoneTypeId; +export const acknowledgedWorkOrderMilestoneTypeId = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Acknowledged')?.workOrderMilestoneTypeId; +export const deathWorkOrderMilestoneTypeId = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Death')?.workOrderMilestoneTypeId; +export const funeralWorkOrderMilestoneTypeId = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Funeral')?.workOrderMilestoneTypeId; +export const cremationWorkOrderMilestoneTypeId = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Cremation')?.workOrderMilestoneTypeId; +export const intermentWorkOrderMilestoneTypeId = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Interment')?.workOrderMilestoneTypeId; /* * Work Order Type IDs */ diff --git a/temp/legacyImportFromCsv/data.ids.ts b/temp/legacyImportFromCsv/data.ids.ts index 62c05faf..49bb1efb 100644 --- a/temp/legacyImportFromCsv/data.ids.ts +++ b/temp/legacyImportFromCsv/data.ids.ts @@ -1,71 +1,64 @@ -// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair -/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/no-await-expression-member */ - import * as cacheFunctions from '../../helpers/functions.cache.js' +import type { ContractType } from '../../types/record.types.js' /* * Burial Site Status IDs */ export const availableBurialSiteStatusId = - (await cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Available'))! - .burialSiteStatusId + cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Available') + ?.burialSiteStatusId as number export const reservedBurialSiteStatusId = - (await cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Reserved'))! - .burialSiteStatusId + cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Reserved') + ?.burialSiteStatusId as number export const takenBurialSiteStatusId = - (await cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Taken'))! - .burialSiteStatusId - + cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Taken') + ?.burialSiteStatusId as number /* * Contract Type IDs */ -export const preneedContractType = - (await cacheFunctions.getContractTypeByContractType('Preneed'))! +export const preneedContractType = cacheFunctions.getContractTypeByContractType( + 'Preneed' +) as ContractType export const deceasedContractType = - (await cacheFunctions.getContractTypeByContractType('Interment'))! + cacheFunctions.getContractTypeByContractType('Interment') as ContractType export const cremationContractType = - (await cacheFunctions.getContractTypeByContractType('Cremation'))! + cacheFunctions.getContractTypeByContractType('Cremation') as ContractType /* * Work Order Milestone Type IDs */ -export const acknowledgedWorkOrderMilestoneTypeId = ( - await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType( +export const acknowledgedWorkOrderMilestoneTypeId = + cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType( 'Acknowledged' - ) -)?.workOrderMilestoneTypeId + )?.workOrderMilestoneTypeId -export const deathWorkOrderMilestoneTypeId = ( - await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType( +export const deathWorkOrderMilestoneTypeId = + cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType( 'Death' - ) -)?.workOrderMilestoneTypeId + )?.workOrderMilestoneTypeId -export const funeralWorkOrderMilestoneTypeId = ( - await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType( +export const funeralWorkOrderMilestoneTypeId = + cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType( 'Funeral' - ) -)?.workOrderMilestoneTypeId + )?.workOrderMilestoneTypeId -export const cremationWorkOrderMilestoneTypeId = ( - await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType( +export const cremationWorkOrderMilestoneTypeId = + cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType( 'Cremation' - ) -)?.workOrderMilestoneTypeId + )?.workOrderMilestoneTypeId -export const intermentWorkOrderMilestoneTypeId = ( - await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType( +export const intermentWorkOrderMilestoneTypeId = + cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType( 'Interment' - ) -)?.workOrderMilestoneTypeId + )?.workOrderMilestoneTypeId /* * Work Order Type IDs diff --git a/temp/legacyImportFromCsv/index.js b/temp/legacyImportFromCsv/index.js index 52ace00d..8ce80510 100644 --- a/temp/legacyImportFromCsv/index.js +++ b/temp/legacyImportFromCsv/index.js @@ -65,9 +65,9 @@ async function importFromMasterCSV() { try { for (masterRow of cmmaster.data) { const cemeteryId = getCemeteryIdByKey(masterRow.CM_CEMETERY, user); - const burialSiteTypeId = getBurialSiteTypeId(masterRow.CM_CEMETERY); let burialSiteId; - if (masterRow.CM_CEMETERY !== '00') { + if (masterRow.CM_CEMETERY !== '' && masterRow.CM_CEMETERY !== '00') { + const burialSiteTypeId = getBurialSiteTypeId(masterRow.CM_CEMETERY); const burialSiteNameSegment1 = masterRow.CM_BLOCK === '0' ? '' : masterRow.CM_BLOCK; const burialSiteNameSegment2 = (masterRow.CM_RANGE1 === '0' ? '' : masterRow.CM_RANGE1) + (masterRow.CM_RANGE2 === '0' ? '' : masterRow.CM_RANGE2); @@ -161,9 +161,9 @@ async function importFromMasterCSV() { if (masterRow.CM_REMARK1 !== '') { addContractComment({ contractId: preneedContractId, + comment: masterRow.CM_REMARK1, commentDateString: preneedContractStartDateString, - commentTimeString: '00:00', - comment: masterRow.CM_REMARK1 + commentTimeString: '00:00' }, user); } if (masterRow.CM_REMARK2 !== '') { @@ -236,10 +236,10 @@ async function importFromMasterCSV() { contractStartDateString: deceasedContractStartDateString, contractEndDateString: deceasedContractEndDateString, contractTypeFieldIds: '', + committalTypeId, funeralHomeId, funeralDirectorName: masterRow.CM_FUNERAL_HOME, funeralDateString, - committalTypeId, purchaserName: masterRow.CM_PRENEED_OWNER === '' ? masterRow.CM_DECEASED_NAME : masterRow.CM_PRENEED_OWNER, @@ -267,25 +267,25 @@ async function importFromMasterCSV() { if (masterRow.CM_REMARK1 !== '') { addContractComment({ contractId: deceasedContractId, + comment: masterRow.CM_REMARK1, commentDateString: deceasedContractStartDateString, - commentTimeString: '00:00', - comment: masterRow.CM_REMARK1 + commentTimeString: '00:00' }, user); } if (masterRow.CM_REMARK2 !== '') { addContractComment({ contractId: deceasedContractId, + comment: masterRow.CM_REMARK2, commentDateString: deceasedContractStartDateString, - commentTimeString: '00:00', - comment: masterRow.CM_REMARK2 + commentTimeString: '00:00' }, user); } if (masterRow.CM_WORK_ORDER.trim() !== '') { addContractComment({ contractId: deceasedContractId, + comment: `Imported Contract #${masterRow.CM_WORK_ORDER}`, commentDateString: deceasedContractStartDateString, - commentTimeString: '00:00', - comment: `Imported Contract #${masterRow.CM_WORK_ORDER}` + commentTimeString: '00:00' }, user); } updateBurialSiteStatus(burialSiteId ?? '', importIds.takenBurialSiteStatusId, user); diff --git a/temp/legacyImportFromCsv/index.ts b/temp/legacyImportFromCsv/index.ts index 65a03436..8451854d 100644 --- a/temp/legacyImportFromCsv/index.ts +++ b/temp/legacyImportFromCsv/index.ts @@ -104,11 +104,11 @@ async function importFromMasterCSV(): Promise { for (masterRow of cmmaster.data) { const cemeteryId = getCemeteryIdByKey(masterRow.CM_CEMETERY, user) - const burialSiteTypeId = getBurialSiteTypeId(masterRow.CM_CEMETERY) - let burialSiteId: number | undefined - if (masterRow.CM_CEMETERY !== '00') { + if (masterRow.CM_CEMETERY !== '' && masterRow.CM_CEMETERY !== '00') { + const burialSiteTypeId = getBurialSiteTypeId(masterRow.CM_CEMETERY) + const burialSiteNameSegment1 = masterRow.CM_BLOCK === '0' ? '' : masterRow.CM_BLOCK const burialSiteNameSegment2 = @@ -262,9 +262,10 @@ async function importFromMasterCSV(): Promise { addContractComment( { contractId: preneedContractId, + + comment: masterRow.CM_REMARK1, commentDateString: preneedContractStartDateString, - commentTimeString: '00:00', - comment: masterRow.CM_REMARK1 + commentTimeString: '00:00' }, user ) @@ -398,10 +399,10 @@ async function importFromMasterCSV(): Promise { contractEndDateString: deceasedContractEndDateString, contractTypeFieldIds: '', + committalTypeId, funeralHomeId, funeralDirectorName: masterRow.CM_FUNERAL_HOME, funeralDateString, - committalTypeId, purchaserName: masterRow.CM_PRENEED_OWNER === '' @@ -440,9 +441,10 @@ async function importFromMasterCSV(): Promise { addContractComment( { contractId: deceasedContractId, + + comment: masterRow.CM_REMARK1, commentDateString: deceasedContractStartDateString, - commentTimeString: '00:00', - comment: masterRow.CM_REMARK1 + commentTimeString: '00:00' }, user ) @@ -452,9 +454,10 @@ async function importFromMasterCSV(): Promise { addContractComment( { contractId: deceasedContractId, + + comment: masterRow.CM_REMARK2, commentDateString: deceasedContractStartDateString, - commentTimeString: '00:00', - comment: masterRow.CM_REMARK2 + commentTimeString: '00:00' }, user ) @@ -464,9 +467,10 @@ async function importFromMasterCSV(): Promise { addContractComment( { contractId: deceasedContractId, + + comment: `Imported Contract #${masterRow.CM_WORK_ORDER}`, commentDateString: deceasedContractStartDateString, - commentTimeString: '00:00', - comment: `Imported Contract #${masterRow.CM_WORK_ORDER}` + commentTimeString: '00:00' }, user )