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);
}
if (masterRow.CM_PERIOD !== '') {
const period = importData.getDeathAgePeriod(masterRow.CM_PERIOD);
await addOrUpdateLotOccupancyField({
lotOccupancyId: deceasedLotOccupancyId,
occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => {
return (occupancyTypeField.occupancyTypeField === 'Death Age Period');
}).occupancyTypeFieldId,
lotOccupancyFieldValue: masterRow.CM_PERIOD
lotOccupancyFieldValue: period
}, user);
}
if (masterRow.CM_FUNERAL_HOME !== '') {
@ -791,12 +792,13 @@ async function importFromWorkOrderCSV() {
}, user);
}
if (workOrderRow.WO_PERIOD !== '') {
const period = importData.getDeathAgePeriod(workOrderRow.WO_PERIOD);
await addOrUpdateLotOccupancyField({
lotOccupancyId,
occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => {
return (occupancyTypeField.occupancyTypeField === 'Death Age Period');
}).occupancyTypeFieldId,
lotOccupancyFieldValue: workOrderRow.WO_PERIOD
lotOccupancyFieldValue: period
}, user);
}
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 {
dateIntegerToString,
dateToString
} from '@cityssm/utils-datetime'
import { dateIntegerToString, dateToString } from '@cityssm/utils-datetime'
import type * as recordTypes from '../types/recordTypes'
@ -637,6 +634,8 @@ async function importFromMasterCSV(): Promise<void> {
}
if (masterRow.CM_PERIOD !== '') {
const period = importData.getDeathAgePeriod(masterRow.CM_PERIOD)
await addOrUpdateLotOccupancyField(
{
lotOccupancyId: deceasedLotOccupancyId,
@ -647,7 +646,7 @@ async function importFromMasterCSV(): Promise<void> {
)
}
)!.occupancyTypeFieldId!,
lotOccupancyFieldValue: masterRow.CM_PERIOD
lotOccupancyFieldValue: period
},
user
)
@ -1368,6 +1367,8 @@ async function importFromWorkOrderCSV(): Promise<void> {
}
if (workOrderRow.WO_PERIOD !== '') {
const period = importData.getDeathAgePeriod(workOrderRow.WO_PERIOD)
await addOrUpdateLotOccupancyField(
{
lotOccupancyId,
@ -1378,7 +1379,7 @@ async function importFromWorkOrderCSV(): Promise<void> {
)
}
)!.occupancyTypeFieldId!,
lotOccupancyFieldValue: workOrderRow.WO_PERIOD
lotOccupancyFieldValue: period
},
user
)

View File

@ -11,3 +11,4 @@ export declare function buildLotName(lotNamePieces: {
interment: string;
}): string;
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'
};
}
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'
}
}
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
})
const records: Array<{
feeId: number
feeDescription: string
}> = database
const records = database
.prepare(
"select feeId, feeDescription from Fees where feeDescription like 'CMPP_FEE_%'"
)
.all()
.all() as Array<{
feeId: number
feeDescription: string
}>
for (const record of records) {
feeCache.set(record.feeDescription, record.feeId)