expand period abbreviations

deepsource-autofix-76c6eb20
Dan Gowans 2023-04-13 10:19:36 -04:00
parent 45b8af733a
commit 092decd6e1
6 changed files with 51 additions and 13 deletions

View File

@ -308,12 +308,13 @@ async function importFromMasterCSV() {
}, user); }, user);
} }
if (masterRow.CM_PERIOD !== '') { if (masterRow.CM_PERIOD !== '') {
const period = importData.getDeathAgePeriod(masterRow.CM_PERIOD);
await addOrUpdateLotOccupancyField({ await addOrUpdateLotOccupancyField({
lotOccupancyId: deceasedLotOccupancyId, lotOccupancyId: deceasedLotOccupancyId,
occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => { occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => {
return (occupancyTypeField.occupancyTypeField === 'Death Age Period'); return (occupancyTypeField.occupancyTypeField === 'Death Age Period');
}).occupancyTypeFieldId, }).occupancyTypeFieldId,
lotOccupancyFieldValue: masterRow.CM_PERIOD lotOccupancyFieldValue: period
}, user); }, user);
} }
if (masterRow.CM_FUNERAL_HOME !== '') { if (masterRow.CM_FUNERAL_HOME !== '') {
@ -791,12 +792,13 @@ async function importFromWorkOrderCSV() {
}, user); }, user);
} }
if (workOrderRow.WO_PERIOD !== '') { if (workOrderRow.WO_PERIOD !== '') {
const period = importData.getDeathAgePeriod(workOrderRow.WO_PERIOD);
await addOrUpdateLotOccupancyField({ await addOrUpdateLotOccupancyField({
lotOccupancyId, lotOccupancyId,
occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => { occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => {
return (occupancyTypeField.occupancyTypeField === 'Death Age Period'); return (occupancyTypeField.occupancyTypeField === 'Death Age Period');
}).occupancyTypeFieldId, }).occupancyTypeFieldId,
lotOccupancyFieldValue: workOrderRow.WO_PERIOD lotOccupancyFieldValue: period
}, user); }, user);
} }
if (workOrderRow.WO_FUNERAL_HOME !== '') { if (workOrderRow.WO_FUNERAL_HOME !== '') {

View File

@ -49,10 +49,7 @@ import { addWorkOrderMilestone } from '../helpers/lotOccupancyDB/addWorkOrderMil
import { closeWorkOrder } from '../helpers/lotOccupancyDB/closeWorkOrder.js' import { closeWorkOrder } from '../helpers/lotOccupancyDB/closeWorkOrder.js'
import { import { dateIntegerToString, dateToString } from '@cityssm/utils-datetime'
dateIntegerToString,
dateToString
} from '@cityssm/utils-datetime'
import type * as recordTypes from '../types/recordTypes' import type * as recordTypes from '../types/recordTypes'
@ -637,6 +634,8 @@ async function importFromMasterCSV(): Promise<void> {
} }
if (masterRow.CM_PERIOD !== '') { if (masterRow.CM_PERIOD !== '') {
const period = importData.getDeathAgePeriod(masterRow.CM_PERIOD)
await addOrUpdateLotOccupancyField( await addOrUpdateLotOccupancyField(
{ {
lotOccupancyId: deceasedLotOccupancyId, lotOccupancyId: deceasedLotOccupancyId,
@ -647,7 +646,7 @@ async function importFromMasterCSV(): Promise<void> {
) )
} }
)!.occupancyTypeFieldId!, )!.occupancyTypeFieldId!,
lotOccupancyFieldValue: masterRow.CM_PERIOD lotOccupancyFieldValue: period
}, },
user user
) )
@ -1368,6 +1367,8 @@ async function importFromWorkOrderCSV(): Promise<void> {
} }
if (workOrderRow.WO_PERIOD !== '') { if (workOrderRow.WO_PERIOD !== '') {
const period = importData.getDeathAgePeriod(workOrderRow.WO_PERIOD)
await addOrUpdateLotOccupancyField( await addOrUpdateLotOccupancyField(
{ {
lotOccupancyId, lotOccupancyId,
@ -1378,7 +1379,7 @@ async function importFromWorkOrderCSV(): Promise<void> {
) )
} }
)!.occupancyTypeFieldId!, )!.occupancyTypeFieldId!,
lotOccupancyFieldValue: workOrderRow.WO_PERIOD lotOccupancyFieldValue: period
}, },
user user
) )

View File

@ -11,3 +11,4 @@ export declare function buildLotName(lotNamePieces: {
interment: string; interment: string;
}): string; }): string;
export declare function getFuneralHomeLotOccupancyOccupantData(funeralHomeKey: string): recordTypes.LotOccupancyOccupant; export declare function getFuneralHomeLotOccupancyOccupantData(funeralHomeKey: string): recordTypes.LotOccupancyOccupant;
export declare function getDeathAgePeriod(legacyDeathAgePeriod: string): string;

View File

@ -117,3 +117,19 @@ export function getFuneralHomeLotOccupancyOccupantData(funeralHomeKey) {
occupantProvince: 'ON' occupantProvince: 'ON'
}; };
} }
export function getDeathAgePeriod(legacyDeathAgePeriod) {
switch (legacyDeathAgePeriod.toLowerCase()) {
case 'yrs': {
return 'Years';
}
case 'mts': {
return 'Months';
}
case 'dys': {
return 'Days';
}
default: {
return legacyDeathAgePeriod;
}
}
}

View File

@ -136,3 +136,21 @@ export function getFuneralHomeLotOccupancyOccupantData(
occupantProvince: 'ON' occupantProvince: 'ON'
} }
} }
export function getDeathAgePeriod(legacyDeathAgePeriod: string): string {
switch (legacyDeathAgePeriod.toLowerCase()) {
case 'yrs': {
return 'Years'
}
case 'mts': {
return 'Months'
}
case 'dys': {
return 'Days'
}
default: {
return legacyDeathAgePeriod
}
}
}

View File

@ -17,14 +17,14 @@ export function getFeeIdByFeeDescription(feeDescription: string): number {
readonly: true readonly: true
}) })
const records: Array<{ const records = database
feeId: number
feeDescription: string
}> = database
.prepare( .prepare(
"select feeId, feeDescription from Fees where feeDescription like 'CMPP_FEE_%'" "select feeId, feeDescription from Fees where feeDescription like 'CMPP_FEE_%'"
) )
.all() .all() as Array<{
feeId: number
feeDescription: string
}>
for (const record of records) { for (const record of records) {
feeCache.set(record.feeDescription, record.feeId) feeCache.set(record.feeDescription, record.feeId)