import cleanup

pull/11/head
Dan Gowans 2025-04-28 14:50:34 -04:00
parent 0d2f6f78ce
commit 3c4c85df19
7 changed files with 74 additions and 76 deletions

View File

@ -13,6 +13,7 @@ const urnGardenBurialSiteTypeId = cacheFunctions.getBurialSiteTypesByBurialSiteT
?.burialSiteTypeId; ?.burialSiteTypeId;
export function getBurialSiteTypeId(cemeteryKey) { export function getBurialSiteTypeId(cemeteryKey) {
switch (cemeteryKey) { switch (cemeteryKey) {
case '':
case '00': { case '00': {
return cremationBurialSiteTypeId; return cremationBurialSiteTypeId;
} }

View File

@ -26,6 +26,7 @@ const urnGardenBurialSiteTypeId =
export function getBurialSiteTypeId(cemeteryKey: string): number { export function getBurialSiteTypeId(cemeteryKey: string): number {
switch (cemeteryKey) { switch (cemeteryKey) {
case '':
case '00': { case '00': {
return cremationBurialSiteTypeId return cremationBurialSiteTypeId
} }

View File

@ -1,9 +1,10 @@
import type { ContractType } from '../../types/record.types.js';
export declare const availableBurialSiteStatusId: number; export declare const availableBurialSiteStatusId: number;
export declare const reservedBurialSiteStatusId: number; export declare const reservedBurialSiteStatusId: number;
export declare const takenBurialSiteStatusId: number; export declare const takenBurialSiteStatusId: number;
export declare const preneedContractType: import("../../types/record.types.js").ContractType; export declare const preneedContractType: ContractType;
export declare const deceasedContractType: import("../../types/record.types.js").ContractType; export declare const deceasedContractType: ContractType;
export declare const cremationContractType: import("../../types/record.types.js").ContractType; export declare const cremationContractType: ContractType;
export declare const acknowledgedWorkOrderMilestoneTypeId: number | undefined; export declare const acknowledgedWorkOrderMilestoneTypeId: number | undefined;
export declare const deathWorkOrderMilestoneTypeId: number | undefined; export declare const deathWorkOrderMilestoneTypeId: number | undefined;
export declare const funeralWorkOrderMilestoneTypeId: number | undefined; export declare const funeralWorkOrderMilestoneTypeId: number | undefined;

View File

@ -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'; import * as cacheFunctions from '../../helpers/functions.cache.js';
/* /*
* Burial Site Status IDs * Burial Site Status IDs
*/ */
export const availableBurialSiteStatusId = (await cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Available')) export const availableBurialSiteStatusId = cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Available')
.burialSiteStatusId; ?.burialSiteStatusId;
export const reservedBurialSiteStatusId = (await cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Reserved')) export const reservedBurialSiteStatusId = cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Reserved')
.burialSiteStatusId; ?.burialSiteStatusId;
export const takenBurialSiteStatusId = (await cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Taken')) export const takenBurialSiteStatusId = cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Taken')
.burialSiteStatusId; ?.burialSiteStatusId;
/* /*
* Contract Type IDs * Contract Type IDs
*/ */
export const preneedContractType = (await cacheFunctions.getContractTypeByContractType('Preneed')); export const preneedContractType = cacheFunctions.getContractTypeByContractType('Preneed');
export const deceasedContractType = (await cacheFunctions.getContractTypeByContractType('Interment')); export const deceasedContractType = cacheFunctions.getContractTypeByContractType('Interment');
export const cremationContractType = (await cacheFunctions.getContractTypeByContractType('Cremation')); export const cremationContractType = cacheFunctions.getContractTypeByContractType('Cremation');
/* /*
* Work Order Milestone Type IDs * Work Order Milestone Type IDs
*/ */
export const acknowledgedWorkOrderMilestoneTypeId = (await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Acknowledged'))?.workOrderMilestoneTypeId; export const acknowledgedWorkOrderMilestoneTypeId = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Acknowledged')?.workOrderMilestoneTypeId;
export const deathWorkOrderMilestoneTypeId = (await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Death'))?.workOrderMilestoneTypeId; export const deathWorkOrderMilestoneTypeId = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Death')?.workOrderMilestoneTypeId;
export const funeralWorkOrderMilestoneTypeId = (await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Funeral'))?.workOrderMilestoneTypeId; export const funeralWorkOrderMilestoneTypeId = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Funeral')?.workOrderMilestoneTypeId;
export const cremationWorkOrderMilestoneTypeId = (await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Cremation'))?.workOrderMilestoneTypeId; export const cremationWorkOrderMilestoneTypeId = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Cremation')?.workOrderMilestoneTypeId;
export const intermentWorkOrderMilestoneTypeId = (await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Interment'))?.workOrderMilestoneTypeId; export const intermentWorkOrderMilestoneTypeId = cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType('Interment')?.workOrderMilestoneTypeId;
/* /*
* Work Order Type IDs * Work Order Type IDs
*/ */

View File

@ -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 * as cacheFunctions from '../../helpers/functions.cache.js'
import type { ContractType } from '../../types/record.types.js'
/* /*
* Burial Site Status IDs * Burial Site Status IDs
*/ */
export const availableBurialSiteStatusId = export const availableBurialSiteStatusId =
(await cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Available'))! cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Available')
.burialSiteStatusId ?.burialSiteStatusId as number
export const reservedBurialSiteStatusId = export const reservedBurialSiteStatusId =
(await cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Reserved'))! cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Reserved')
.burialSiteStatusId ?.burialSiteStatusId as number
export const takenBurialSiteStatusId = export const takenBurialSiteStatusId =
(await cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Taken'))! cacheFunctions.getBurialSiteStatusByBurialSiteStatus('Taken')
.burialSiteStatusId ?.burialSiteStatusId as number
/* /*
* Contract Type IDs * Contract Type IDs
*/ */
export const preneedContractType = export const preneedContractType = cacheFunctions.getContractTypeByContractType(
(await cacheFunctions.getContractTypeByContractType('Preneed'))! 'Preneed'
) as ContractType
export const deceasedContractType = export const deceasedContractType =
(await cacheFunctions.getContractTypeByContractType('Interment'))! cacheFunctions.getContractTypeByContractType('Interment') as ContractType
export const cremationContractType = export const cremationContractType =
(await cacheFunctions.getContractTypeByContractType('Cremation'))! cacheFunctions.getContractTypeByContractType('Cremation') as ContractType
/* /*
* Work Order Milestone Type IDs * Work Order Milestone Type IDs
*/ */
export const acknowledgedWorkOrderMilestoneTypeId = ( export const acknowledgedWorkOrderMilestoneTypeId =
await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType( cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType(
'Acknowledged' 'Acknowledged'
) )?.workOrderMilestoneTypeId
)?.workOrderMilestoneTypeId
export const deathWorkOrderMilestoneTypeId = ( export const deathWorkOrderMilestoneTypeId =
await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType( cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType(
'Death' 'Death'
) )?.workOrderMilestoneTypeId
)?.workOrderMilestoneTypeId
export const funeralWorkOrderMilestoneTypeId = ( export const funeralWorkOrderMilestoneTypeId =
await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType( cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType(
'Funeral' 'Funeral'
) )?.workOrderMilestoneTypeId
)?.workOrderMilestoneTypeId
export const cremationWorkOrderMilestoneTypeId = ( export const cremationWorkOrderMilestoneTypeId =
await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType( cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType(
'Cremation' 'Cremation'
) )?.workOrderMilestoneTypeId
)?.workOrderMilestoneTypeId
export const intermentWorkOrderMilestoneTypeId = ( export const intermentWorkOrderMilestoneTypeId =
await cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType( cacheFunctions.getWorkOrderMilestoneTypeByWorkOrderMilestoneType(
'Interment' 'Interment'
) )?.workOrderMilestoneTypeId
)?.workOrderMilestoneTypeId
/* /*
* Work Order Type IDs * Work Order Type IDs

View File

@ -65,9 +65,9 @@ async function importFromMasterCSV() {
try { try {
for (masterRow of cmmaster.data) { for (masterRow of cmmaster.data) {
const cemeteryId = getCemeteryIdByKey(masterRow.CM_CEMETERY, user); const cemeteryId = getCemeteryIdByKey(masterRow.CM_CEMETERY, user);
const burialSiteTypeId = getBurialSiteTypeId(masterRow.CM_CEMETERY);
let burialSiteId; 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 burialSiteNameSegment1 = masterRow.CM_BLOCK === '0' ? '' : masterRow.CM_BLOCK;
const burialSiteNameSegment2 = (masterRow.CM_RANGE1 === '0' ? '' : masterRow.CM_RANGE1) + const burialSiteNameSegment2 = (masterRow.CM_RANGE1 === '0' ? '' : masterRow.CM_RANGE1) +
(masterRow.CM_RANGE2 === '0' ? '' : masterRow.CM_RANGE2); (masterRow.CM_RANGE2 === '0' ? '' : masterRow.CM_RANGE2);
@ -161,9 +161,9 @@ async function importFromMasterCSV() {
if (masterRow.CM_REMARK1 !== '') { if (masterRow.CM_REMARK1 !== '') {
addContractComment({ addContractComment({
contractId: preneedContractId, contractId: preneedContractId,
comment: masterRow.CM_REMARK1,
commentDateString: preneedContractStartDateString, commentDateString: preneedContractStartDateString,
commentTimeString: '00:00', commentTimeString: '00:00'
comment: masterRow.CM_REMARK1
}, user); }, user);
} }
if (masterRow.CM_REMARK2 !== '') { if (masterRow.CM_REMARK2 !== '') {
@ -236,10 +236,10 @@ async function importFromMasterCSV() {
contractStartDateString: deceasedContractStartDateString, contractStartDateString: deceasedContractStartDateString,
contractEndDateString: deceasedContractEndDateString, contractEndDateString: deceasedContractEndDateString,
contractTypeFieldIds: '', contractTypeFieldIds: '',
committalTypeId,
funeralHomeId, funeralHomeId,
funeralDirectorName: masterRow.CM_FUNERAL_HOME, funeralDirectorName: masterRow.CM_FUNERAL_HOME,
funeralDateString, funeralDateString,
committalTypeId,
purchaserName: masterRow.CM_PRENEED_OWNER === '' purchaserName: masterRow.CM_PRENEED_OWNER === ''
? masterRow.CM_DECEASED_NAME ? masterRow.CM_DECEASED_NAME
: masterRow.CM_PRENEED_OWNER, : masterRow.CM_PRENEED_OWNER,
@ -267,25 +267,25 @@ async function importFromMasterCSV() {
if (masterRow.CM_REMARK1 !== '') { if (masterRow.CM_REMARK1 !== '') {
addContractComment({ addContractComment({
contractId: deceasedContractId, contractId: deceasedContractId,
comment: masterRow.CM_REMARK1,
commentDateString: deceasedContractStartDateString, commentDateString: deceasedContractStartDateString,
commentTimeString: '00:00', commentTimeString: '00:00'
comment: masterRow.CM_REMARK1
}, user); }, user);
} }
if (masterRow.CM_REMARK2 !== '') { if (masterRow.CM_REMARK2 !== '') {
addContractComment({ addContractComment({
contractId: deceasedContractId, contractId: deceasedContractId,
comment: masterRow.CM_REMARK2,
commentDateString: deceasedContractStartDateString, commentDateString: deceasedContractStartDateString,
commentTimeString: '00:00', commentTimeString: '00:00'
comment: masterRow.CM_REMARK2
}, user); }, user);
} }
if (masterRow.CM_WORK_ORDER.trim() !== '') { if (masterRow.CM_WORK_ORDER.trim() !== '') {
addContractComment({ addContractComment({
contractId: deceasedContractId, contractId: deceasedContractId,
comment: `Imported Contract #${masterRow.CM_WORK_ORDER}`,
commentDateString: deceasedContractStartDateString, commentDateString: deceasedContractStartDateString,
commentTimeString: '00:00', commentTimeString: '00:00'
comment: `Imported Contract #${masterRow.CM_WORK_ORDER}`
}, user); }, user);
} }
updateBurialSiteStatus(burialSiteId ?? '', importIds.takenBurialSiteStatusId, user); updateBurialSiteStatus(burialSiteId ?? '', importIds.takenBurialSiteStatusId, user);

View File

@ -104,11 +104,11 @@ async function importFromMasterCSV(): Promise<void> {
for (masterRow of cmmaster.data) { for (masterRow of cmmaster.data) {
const cemeteryId = getCemeteryIdByKey(masterRow.CM_CEMETERY, user) const cemeteryId = getCemeteryIdByKey(masterRow.CM_CEMETERY, user)
const burialSiteTypeId = getBurialSiteTypeId(masterRow.CM_CEMETERY)
let burialSiteId: number | undefined 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 = const burialSiteNameSegment1 =
masterRow.CM_BLOCK === '0' ? '' : masterRow.CM_BLOCK masterRow.CM_BLOCK === '0' ? '' : masterRow.CM_BLOCK
const burialSiteNameSegment2 = const burialSiteNameSegment2 =
@ -262,9 +262,10 @@ async function importFromMasterCSV(): Promise<void> {
addContractComment( addContractComment(
{ {
contractId: preneedContractId, contractId: preneedContractId,
comment: masterRow.CM_REMARK1,
commentDateString: preneedContractStartDateString, commentDateString: preneedContractStartDateString,
commentTimeString: '00:00', commentTimeString: '00:00'
comment: masterRow.CM_REMARK1
}, },
user user
) )
@ -398,10 +399,10 @@ async function importFromMasterCSV(): Promise<void> {
contractEndDateString: deceasedContractEndDateString, contractEndDateString: deceasedContractEndDateString,
contractTypeFieldIds: '', contractTypeFieldIds: '',
committalTypeId,
funeralHomeId, funeralHomeId,
funeralDirectorName: masterRow.CM_FUNERAL_HOME, funeralDirectorName: masterRow.CM_FUNERAL_HOME,
funeralDateString, funeralDateString,
committalTypeId,
purchaserName: purchaserName:
masterRow.CM_PRENEED_OWNER === '' masterRow.CM_PRENEED_OWNER === ''
@ -440,9 +441,10 @@ async function importFromMasterCSV(): Promise<void> {
addContractComment( addContractComment(
{ {
contractId: deceasedContractId, contractId: deceasedContractId,
comment: masterRow.CM_REMARK1,
commentDateString: deceasedContractStartDateString, commentDateString: deceasedContractStartDateString,
commentTimeString: '00:00', commentTimeString: '00:00'
comment: masterRow.CM_REMARK1
}, },
user user
) )
@ -452,9 +454,10 @@ async function importFromMasterCSV(): Promise<void> {
addContractComment( addContractComment(
{ {
contractId: deceasedContractId, contractId: deceasedContractId,
comment: masterRow.CM_REMARK2,
commentDateString: deceasedContractStartDateString, commentDateString: deceasedContractStartDateString,
commentTimeString: '00:00', commentTimeString: '00:00'
comment: masterRow.CM_REMARK2
}, },
user user
) )
@ -464,9 +467,10 @@ async function importFromMasterCSV(): Promise<void> {
addContractComment( addContractComment(
{ {
contractId: deceasedContractId, contractId: deceasedContractId,
comment: `Imported Contract #${masterRow.CM_WORK_ORDER}`,
commentDateString: deceasedContractStartDateString, commentDateString: deceasedContractStartDateString,
commentTimeString: '00:00', commentTimeString: '00:00'
comment: `Imported Contract #${masterRow.CM_WORK_ORDER}`
}, },
user user
) )