From 57b6dbf35eb8da3076aecf44cab9a2fe6b062ee2 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Thu, 1 May 2025 08:55:34 -0400 Subject: [PATCH] use common "cremation" cemetery list --- temp/legacyImportFromCsv/data.cemeteries.d.ts | 1 + temp/legacyImportFromCsv/data.cemeteries.js | 1 + temp/legacyImportFromCsv/data.cemeteries.ts | 4 +++- temp/legacyImportFromCsv/index.js | 6 +++--- temp/legacyImportFromCsv/index.ts | 8 ++++---- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/temp/legacyImportFromCsv/data.cemeteries.d.ts b/temp/legacyImportFromCsv/data.cemeteries.d.ts index c0639126..04a44e2c 100644 --- a/temp/legacyImportFromCsv/data.cemeteries.d.ts +++ b/temp/legacyImportFromCsv/data.cemeteries.d.ts @@ -1 +1,2 @@ +export declare const cremationCemeteryKeys: Set; export declare function getCemeteryIdByKey(cemeteryKeyToSearch: string | undefined, user: User): number; diff --git a/temp/legacyImportFromCsv/data.cemeteries.js b/temp/legacyImportFromCsv/data.cemeteries.js index 82c72d9f..1926e147 100644 --- a/temp/legacyImportFromCsv/data.cemeteries.js +++ b/temp/legacyImportFromCsv/data.cemeteries.js @@ -2,6 +2,7 @@ /* eslint-disable no-console */ import addCemetery from '../../database/addCemetery.js'; import { getCemeteryByKey } from '../../database/getCemetery.js'; +export const cremationCemeteryKeys = new Set(['', '00', '`', 'N', 'R']); const cemeteryKeyToCemetery = { '00': { cemeteryName: 'Crematorium', diff --git a/temp/legacyImportFromCsv/data.cemeteries.ts b/temp/legacyImportFromCsv/data.cemeteries.ts index 2120edb6..bf73beac 100644 --- a/temp/legacyImportFromCsv/data.cemeteries.ts +++ b/temp/legacyImportFromCsv/data.cemeteries.ts @@ -6,6 +6,8 @@ import addCemetery, { } from '../../database/addCemetery.js' import { getCemeteryByKey } from '../../database/getCemetery.js' +export const cremationCemeteryKeys = new Set(['', '00', '`', 'N', 'R']) + const cemeteryKeyToCemetery: Record = { '00': { cemeteryName: 'Crematorium', @@ -295,7 +297,7 @@ export function getCemeteryIdByKey( // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition addForm ??= { cemeteryName: cemeteryKey, - + cemeteryDescription: '', cemeteryKey, diff --git a/temp/legacyImportFromCsv/index.js b/temp/legacyImportFromCsv/index.js index 2189ab4c..4522ce77 100644 --- a/temp/legacyImportFromCsv/index.js +++ b/temp/legacyImportFromCsv/index.js @@ -22,7 +22,7 @@ import { updateBurialSiteStatus } from '../../database/updateBurialSite.js'; import { buildBurialSiteName } from '../../helpers/burialSites.helpers.js'; import { sunriseDB as databasePath } from '../../helpers/database.helpers.js'; import { getBurialSiteTypeId } from './data.burialSiteTypes.js'; -import { getCemeteryIdByKey } from './data.cemeteries.js'; +import { cremationCemeteryKeys, getCemeteryIdByKey } from './data.cemeteries.js'; import { getCommittalTypeIdByKey } from './data.committalTypes.js'; import { getDeathAgePeriod } from './data.deathAgePeriods.js'; import { getFeeIdByFeeDescription } from './data.fees.js'; @@ -66,7 +66,7 @@ async function importFromMasterCSV() { for (masterRow of cmmaster.data) { const cemeteryId = getCemeteryIdByKey(masterRow.CM_CEMETERY, user); let burialSiteId; - if (masterRow.CM_CEMETERY !== '' && masterRow.CM_CEMETERY !== '00') { + if (!cremationCemeteryKeys.has(masterRow.CM_CEMETERY)) { const burialSiteTypeId = getBurialSiteTypeId(masterRow.CM_CEMETERY); const burialSiteNameSegment1 = masterRow.CM_BLOCK === '0' ? '' : masterRow.CM_BLOCK; const burialSiteNameSegment2 = (masterRow.CM_RANGE1 === '0' ? '' : masterRow.CM_RANGE1) + @@ -322,7 +322,7 @@ async function importFromPrepaidCSV() { cemeteryKey = 'HC'; } let burialSite; - if (cemeteryKey !== '') { + if (!cremationCemeteryKeys.has(cemeteryKey)) { const cemeteryId = getCemeteryIdByKey(cemeteryKey, user); const burialSiteNameSegment1 = prepaidRow.CMPP_BLOCK === '0' ? '' : prepaidRow.CMPP_BLOCK; const burialSiteNameSegment2 = (prepaidRow.CMPP_RANGE1 === '0' ? '' : prepaidRow.CMPP_RANGE1) + diff --git a/temp/legacyImportFromCsv/index.ts b/temp/legacyImportFromCsv/index.ts index a4ef225f..e804d52c 100644 --- a/temp/legacyImportFromCsv/index.ts +++ b/temp/legacyImportFromCsv/index.ts @@ -36,7 +36,7 @@ import { sunriseDB as databasePath } from '../../helpers/database.helpers.js' import type * as recordTypes from '../../types/record.types.js' import { getBurialSiteTypeId } from './data.burialSiteTypes.js' -import { getCemeteryIdByKey } from './data.cemeteries.js' +import { cremationCemeteryKeys, getCemeteryIdByKey } from './data.cemeteries.js' import { getCommittalTypeIdByKey } from './data.committalTypes.js' import { getDeathAgePeriod } from './data.deathAgePeriods.js' import { getFeeIdByFeeDescription } from './data.fees.js' @@ -106,7 +106,7 @@ async function importFromMasterCSV(): Promise { let burialSiteId: number | undefined - if (masterRow.CM_CEMETERY !== '' && masterRow.CM_CEMETERY !== '00') { + if (!cremationCemeteryKeys.has(masterRow.CM_CEMETERY)) { const burialSiteTypeId = getBurialSiteTypeId(masterRow.CM_CEMETERY) const burialSiteNameSegment1 = @@ -524,7 +524,7 @@ async function importFromPrepaidCSV(): Promise { let burialSite: recordTypes.BurialSite | undefined - if (cemeteryKey !== '') { + if (!cremationCemeteryKeys.has(cemeteryKey)) { const cemeteryId = getCemeteryIdByKey(cemeteryKey, user) const burialSiteNameSegment1 = @@ -1011,7 +1011,7 @@ async function importFromWorkOrderCSV(): Promise { { burialSiteId: burialSite ? burialSite.burialSiteId : '', contractTypeId: contractType.contractTypeId, - + contractEndDateString: '', contractStartDateString,