include deleted list items

for import purposes
pull/11/head
Dan Gowans 2025-04-28 14:05:45 -04:00
parent f440a35df7
commit 62efb70542
16 changed files with 63 additions and 56 deletions

View File

@ -1,2 +1,2 @@
import type { BurialSiteType } from '../types/record.types.js'; import type { BurialSiteType } from '../types/record.types.js';
export default function getBurialSiteTypes(): BurialSiteType[]; export default function getBurialSiteTypes(includeDeleted?: boolean): BurialSiteType[];

View File

@ -2,12 +2,12 @@ import sqlite from 'better-sqlite3';
import { sunriseDB } from '../helpers/database.helpers.js'; import { sunriseDB } from '../helpers/database.helpers.js';
import getBurialSiteTypeFields from './getBurialSiteTypeFields.js'; import getBurialSiteTypeFields from './getBurialSiteTypeFields.js';
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'; import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
export default function getBurialSiteTypes() { export default function getBurialSiteTypes(includeDeleted = false) {
const database = sqlite(sunriseDB); const database = sqlite(sunriseDB);
const burialSiteTypes = database const burialSiteTypes = database
.prepare(`select burialSiteTypeId, burialSiteType, orderNumber .prepare(`select burialSiteTypeId, burialSiteType, orderNumber
from BurialSiteTypes from BurialSiteTypes
where recordDelete_timeMillis is null ${includeDeleted ? '' : ' where recordDelete_timeMillis is null '}
order by orderNumber, burialSiteType`) order by orderNumber, burialSiteType`)
.all(); .all();
let expectedOrderNumber = -1; let expectedOrderNumber = -1;

View File

@ -6,14 +6,16 @@ import type { BurialSiteType } from '../types/record.types.js'
import getBurialSiteTypeFields from './getBurialSiteTypeFields.js' import getBurialSiteTypeFields from './getBurialSiteTypeFields.js'
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js' import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
export default function getBurialSiteTypes(): BurialSiteType[] { export default function getBurialSiteTypes(
includeDeleted = false
): BurialSiteType[] {
const database = sqlite(sunriseDB) const database = sqlite(sunriseDB)
const burialSiteTypes = database const burialSiteTypes = database
.prepare( .prepare(
`select burialSiteTypeId, burialSiteType, orderNumber `select burialSiteTypeId, burialSiteType, orderNumber
from BurialSiteTypes from BurialSiteTypes
where recordDelete_timeMillis is null ${includeDeleted ? '' : ' where recordDelete_timeMillis is null '}
order by orderNumber, burialSiteType` order by orderNumber, burialSiteType`
) )
.all() as BurialSiteType[] .all() as BurialSiteType[]

View File

@ -1,2 +1,2 @@
import type { CommittalType } from '../types/record.types.js'; import type { CommittalType } from '../types/record.types.js';
export default function getCommittalTypes(): CommittalType[]; export default function getCommittalTypes(includeDeleted?: boolean): CommittalType[];

View File

@ -1,12 +1,12 @@
import sqlite from 'better-sqlite3'; import sqlite from 'better-sqlite3';
import { sunriseDB } from '../helpers/database.helpers.js'; import { sunriseDB } from '../helpers/database.helpers.js';
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'; import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
export default function getCommittalTypes() { export default function getCommittalTypes(includeDeleted = false) {
const database = sqlite(sunriseDB); const database = sqlite(sunriseDB);
const committalTypes = database const committalTypes = database
.prepare(`select committalTypeId, committalTypeKey, committalType, orderNumber .prepare(`select committalTypeId, committalTypeKey, committalType, orderNumber
from CommittalTypes from CommittalTypes
where recordDelete_timeMillis is null ${includeDeleted ? '' : ' where recordDelete_timeMillis is null '}
order by orderNumber, committalType, committalTypeId`) order by orderNumber, committalType, committalTypeId`)
.all(); .all();
let expectedOrderNumber = -1; let expectedOrderNumber = -1;

View File

@ -5,14 +5,16 @@ import type { CommittalType } from '../types/record.types.js'
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js' import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
export default function getCommittalTypes(): CommittalType[] { export default function getCommittalTypes(
includeDeleted = false
): CommittalType[] {
const database = sqlite(sunriseDB) const database = sqlite(sunriseDB)
const committalTypes = database const committalTypes = database
.prepare( .prepare(
`select committalTypeId, committalTypeKey, committalType, orderNumber `select committalTypeId, committalTypeKey, committalType, orderNumber
from CommittalTypes from CommittalTypes
where recordDelete_timeMillis is null ${includeDeleted ? '' : ' where recordDelete_timeMillis is null '}
order by orderNumber, committalType, committalTypeId` order by orderNumber, committalType, committalTypeId`
) )
.all() as CommittalType[] .all() as CommittalType[]

View File

@ -1,2 +1,2 @@
import type { IntermentContainerType } from '../types/record.types.js'; import type { IntermentContainerType } from '../types/record.types.js';
export default function getIntermentContainerTypes(): IntermentContainerType[]; export default function getIntermentContainerTypes(includeDeleted?: boolean): IntermentContainerType[];

View File

@ -1,13 +1,13 @@
import sqlite from 'better-sqlite3'; import sqlite from 'better-sqlite3';
import { sunriseDB } from '../helpers/database.helpers.js'; import { sunriseDB } from '../helpers/database.helpers.js';
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'; import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
export default function getIntermentContainerTypes() { export default function getIntermentContainerTypes(includeDeleted = false) {
const database = sqlite(sunriseDB); const database = sqlite(sunriseDB);
const containerTypes = database const containerTypes = database
.prepare(`select intermentContainerTypeId, intermentContainerType, intermentContainerTypeKey, .prepare(`select intermentContainerTypeId, intermentContainerType, intermentContainerTypeKey,
isCremationType, orderNumber isCremationType, orderNumber
from IntermentContainerTypes from IntermentContainerTypes
where recordDelete_timeMillis is null ${includeDeleted ? '' : ' where recordDelete_timeMillis is null '}
order by isCremationType, orderNumber, intermentContainerType, intermentContainerTypeId`) order by isCremationType, orderNumber, intermentContainerType, intermentContainerTypeId`)
.all(); .all();
let expectedOrderNumber = -1; let expectedOrderNumber = -1;

View File

@ -5,7 +5,9 @@ import type { IntermentContainerType } from '../types/record.types.js'
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js' import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
export default function getIntermentContainerTypes(): IntermentContainerType[] { export default function getIntermentContainerTypes(
includeDeleted = false
): IntermentContainerType[] {
const database = sqlite(sunriseDB) const database = sqlite(sunriseDB)
const containerTypes = database const containerTypes = database
@ -13,7 +15,7 @@ export default function getIntermentContainerTypes(): IntermentContainerType[] {
`select intermentContainerTypeId, intermentContainerType, intermentContainerTypeKey, `select intermentContainerTypeId, intermentContainerType, intermentContainerTypeKey,
isCremationType, orderNumber isCremationType, orderNumber
from IntermentContainerTypes from IntermentContainerTypes
where recordDelete_timeMillis is null ${includeDeleted ? '' : ' where recordDelete_timeMillis is null '}
order by isCremationType, orderNumber, intermentContainerType, intermentContainerTypeId` order by isCremationType, orderNumber, intermentContainerType, intermentContainerTypeId`
) )
.all() as IntermentContainerType[] .all() as IntermentContainerType[]

View File

@ -1,16 +1,10 @@
import * as cacheFunctions from '../../helpers/functions.cache.js'; import * as cacheFunctions from '../../helpers/functions.cache.js';
const inGroundBurialSiteTypeId = (await cacheFunctions.getBurialSiteTypesByBurialSiteType('In-Ground Grave')) const inGroundBurialSiteTypeId = cacheFunctions.getBurialSiteTypesByBurialSiteType('In-Ground Grave').burialSiteTypeId;
.burialSiteTypeId; const columbariumBurialSiteTypeId = cacheFunctions.getBurialSiteTypesByBurialSiteType('Columbarium').burialSiteTypeId;
const columbariumBurialSiteTypeId = (await cacheFunctions.getBurialSiteTypesByBurialSiteType('Columbarium')) const cremationBurialSiteTypeId = cacheFunctions.getBurialSiteTypesByBurialSiteType('Crematorium').burialSiteTypeId;
.burialSiteTypeId; const mausoleumBurialSiteTypeId = cacheFunctions.getBurialSiteTypesByBurialSiteType('Mausoleum').burialSiteTypeId;
const cremationBurialSiteTypeId = (await cacheFunctions.getBurialSiteTypesByBurialSiteType('Crematorium')) const nicheWallBurialSiteTypeId = cacheFunctions.getBurialSiteTypesByBurialSiteType('Niche Wall').burialSiteTypeId;
.burialSiteTypeId; const urnGardenBurialSiteTypeId = cacheFunctions.getBurialSiteTypesByBurialSiteType('Urn Garden').burialSiteTypeId;
const mausoleumBurialSiteTypeId = (await cacheFunctions.getBurialSiteTypesByBurialSiteType('Mausoleum'))
.burialSiteTypeId;
const nicheWallBurialSiteTypeId = (await cacheFunctions.getBurialSiteTypesByBurialSiteType('Niche Wall'))
.burialSiteTypeId;
const urnGardenBurialSiteTypeId = (await cacheFunctions.getBurialSiteTypesByBurialSiteType('Urn Garden'))
.burialSiteTypeId;
export function getBurialSiteTypeId(cemeteryKey) { export function getBurialSiteTypeId(cemeteryKey) {
switch (cemeteryKey) { switch (cemeteryKey) {
case '00': { case '00': {

View File

@ -1,24 +1,30 @@
import * as cacheFunctions from '../../helpers/functions.cache.js' import * as cacheFunctions from '../../helpers/functions.cache.js'
const inGroundBurialSiteTypeId = const inGroundBurialSiteTypeId =
(await cacheFunctions.getBurialSiteTypesByBurialSiteType('In-Ground Grave'))! cacheFunctions.getBurialSiteTypesByBurialSiteType(
.burialSiteTypeId 'In-Ground Grave'
)!.burialSiteTypeId
const columbariumBurialSiteTypeId = const columbariumBurialSiteTypeId =
(await cacheFunctions.getBurialSiteTypesByBurialSiteType('Columbarium'))! cacheFunctions.getBurialSiteTypesByBurialSiteType(
.burialSiteTypeId 'Columbarium'
)!.burialSiteTypeId
const cremationBurialSiteTypeId = const cremationBurialSiteTypeId =
(await cacheFunctions.getBurialSiteTypesByBurialSiteType('Crematorium'))! cacheFunctions.getBurialSiteTypesByBurialSiteType(
.burialSiteTypeId 'Crematorium'
)!.burialSiteTypeId
const mausoleumBurialSiteTypeId = const mausoleumBurialSiteTypeId =
(await cacheFunctions.getBurialSiteTypesByBurialSiteType('Mausoleum'))! cacheFunctions.getBurialSiteTypesByBurialSiteType(
.burialSiteTypeId 'Mausoleum'
)!.burialSiteTypeId
const nicheWallBurialSiteTypeId = const nicheWallBurialSiteTypeId =
(await cacheFunctions.getBurialSiteTypesByBurialSiteType('Niche Wall'))! cacheFunctions.getBurialSiteTypesByBurialSiteType(
.burialSiteTypeId 'Niche Wall'
)!.burialSiteTypeId
const urnGardenBurialSiteTypeId = const urnGardenBurialSiteTypeId =
(await cacheFunctions.getBurialSiteTypesByBurialSiteType('Urn Garden'))! cacheFunctions.getBurialSiteTypesByBurialSiteType(
.burialSiteTypeId 'Urn Garden'
)!.burialSiteTypeId
export function getBurialSiteTypeId(cemeteryKey: string): number { export function getBurialSiteTypeId(cemeteryKey: string): number {
switch (cemeteryKey) { switch (cemeteryKey) {

View File

@ -1,6 +1,6 @@
import addCommittalType from '../../database/addCommittalType.js'; import addCommittalType from '../../database/addCommittalType.js';
import getCommittalTypes from '../../database/getCommittalTypes.js'; import getCommittalTypes from '../../database/getCommittalTypes.js';
let committalTypes = getCommittalTypes(); let committalTypes = getCommittalTypes(true);
export function getCommittalTypeIdByKey(committalTypeKey, user) { export function getCommittalTypeIdByKey(committalTypeKey, user) {
const committalType = committalTypes.find((committalType) => committalType.committalTypeKey === committalTypeKey); const committalType = committalTypes.find((committalType) => committalType.committalTypeKey === committalTypeKey);
if (committalType === undefined) { if (committalType === undefined) {

View File

@ -1,7 +1,7 @@
import addCommittalType from '../../database/addCommittalType.js' import addCommittalType from '../../database/addCommittalType.js'
import getCommittalTypes from '../../database/getCommittalTypes.js' import getCommittalTypes from '../../database/getCommittalTypes.js'
let committalTypes = getCommittalTypes() let committalTypes = getCommittalTypes(true)
export function getCommittalTypeIdByKey( export function getCommittalTypeIdByKey(
committalTypeKey: string, committalTypeKey: string,

View File

@ -9,7 +9,7 @@ export function getIntermentContainerTypeIdByKey(intermentContainerTypeKey, user
intermentContainerTypeKey, intermentContainerTypeKey,
intermentContainerType: intermentContainerTypeKey intermentContainerType: intermentContainerTypeKey
}, user); }, user);
intermentContainerTypes = getIntermentContainerTypes(); intermentContainerTypes = getIntermentContainerTypes(true);
return intermentContainerTypeId; return intermentContainerTypeId;
} }
return intermentContainerType.intermentContainerTypeId; return intermentContainerType.intermentContainerTypeId;

View File

@ -22,7 +22,7 @@ export function getIntermentContainerTypeIdByKey(
user user
) )
intermentContainerTypes = getIntermentContainerTypes() intermentContainerTypes = getIntermentContainerTypes(true)
return intermentContainerTypeId return intermentContainerTypeId
} }

View File

@ -388,10 +388,7 @@ async function importFromMasterCSV(): Promise<void> {
const intermentContainerTypeId = const intermentContainerTypeId =
intermentContainerTypeKey === '' intermentContainerTypeKey === ''
? '' ? ''
: getIntermentContainerTypeIdByKey( : getIntermentContainerTypeIdByKey(intermentContainerTypeKey, user)
intermentContainerTypeKey,
user
)
deceasedContractId = addContract( deceasedContractId = addContract(
{ {
@ -649,6 +646,7 @@ async function importFromPrepaidCSV(): Promise<void> {
contractId, contractId,
feeId: getFeeIdByFeeDescription('CMPP_FEE_GRAV_SD', user), feeId: getFeeIdByFeeDescription('CMPP_FEE_GRAV_SD', user),
quantity: 1, quantity: 1,
feeAmount: prepaidRow.CMPP_FEE_GRAV_SD, feeAmount: prepaidRow.CMPP_FEE_GRAV_SD,
taxAmount: prepaidRow.CMPP_GST_GRAV_SD taxAmount: prepaidRow.CMPP_GST_GRAV_SD
}, },
@ -662,6 +660,7 @@ async function importFromPrepaidCSV(): Promise<void> {
contractId, contractId,
feeId: getFeeIdByFeeDescription('CMPP_FEE_GRAV_DD', user), feeId: getFeeIdByFeeDescription('CMPP_FEE_GRAV_DD', user),
quantity: 1, quantity: 1,
feeAmount: prepaidRow.CMPP_FEE_GRAV_DD, feeAmount: prepaidRow.CMPP_FEE_GRAV_DD,
taxAmount: prepaidRow.CMPP_GST_GRAV_DD taxAmount: prepaidRow.CMPP_GST_GRAV_DD
}, },
@ -675,6 +674,7 @@ async function importFromPrepaidCSV(): Promise<void> {
contractId, contractId,
feeId: getFeeIdByFeeDescription('CMPP_FEE_CHAP_SD', user), feeId: getFeeIdByFeeDescription('CMPP_FEE_CHAP_SD', user),
quantity: 1, quantity: 1,
feeAmount: prepaidRow.CMPP_FEE_CHAP_SD, feeAmount: prepaidRow.CMPP_FEE_CHAP_SD,
taxAmount: prepaidRow.CMPP_GST_CHAP_SD taxAmount: prepaidRow.CMPP_GST_CHAP_SD
}, },
@ -688,6 +688,7 @@ async function importFromPrepaidCSV(): Promise<void> {
contractId, contractId,
feeId: getFeeIdByFeeDescription('CMPP_FEE_CHAP_DD', user), feeId: getFeeIdByFeeDescription('CMPP_FEE_CHAP_DD', user),
quantity: 1, quantity: 1,
feeAmount: prepaidRow.CMPP_FEE_CHAP_DD, feeAmount: prepaidRow.CMPP_FEE_CHAP_DD,
taxAmount: prepaidRow.CMPP_GST_CHAP_DD taxAmount: prepaidRow.CMPP_GST_CHAP_DD
}, },
@ -701,6 +702,7 @@ async function importFromPrepaidCSV(): Promise<void> {
contractId, contractId,
feeId: getFeeIdByFeeDescription('CMPP_FEE_ENTOMBMENT', user), feeId: getFeeIdByFeeDescription('CMPP_FEE_ENTOMBMENT', user),
quantity: 1, quantity: 1,
feeAmount: prepaidRow.CMPP_FEE_ENTOMBMENT, feeAmount: prepaidRow.CMPP_FEE_ENTOMBMENT,
taxAmount: prepaidRow.CMPP_GST_ENTOMBMENT taxAmount: prepaidRow.CMPP_GST_ENTOMBMENT
}, },
@ -714,6 +716,7 @@ async function importFromPrepaidCSV(): Promise<void> {
contractId, contractId,
feeId: getFeeIdByFeeDescription('CMPP_FEE_CREM', user), feeId: getFeeIdByFeeDescription('CMPP_FEE_CREM', user),
quantity: 1, quantity: 1,
feeAmount: prepaidRow.CMPP_FEE_CREM, feeAmount: prepaidRow.CMPP_FEE_CREM,
taxAmount: prepaidRow.CMPP_GST_CREM taxAmount: prepaidRow.CMPP_GST_CREM
}, },
@ -727,6 +730,7 @@ async function importFromPrepaidCSV(): Promise<void> {
contractId, contractId,
feeId: getFeeIdByFeeDescription('CMPP_FEE_NICHE', user), feeId: getFeeIdByFeeDescription('CMPP_FEE_NICHE', user),
quantity: 1, quantity: 1,
feeAmount: prepaidRow.CMPP_FEE_NICHE, feeAmount: prepaidRow.CMPP_FEE_NICHE,
taxAmount: prepaidRow.CMPP_GST_NICHE taxAmount: prepaidRow.CMPP_GST_NICHE
}, },
@ -741,11 +745,9 @@ async function importFromPrepaidCSV(): Promise<void> {
await addContractFee( await addContractFee(
{ {
contractId, contractId,
feeId: getFeeIdByFeeDescription( feeId: getFeeIdByFeeDescription('CMPP_FEE_DISINTERMENT', user),
'CMPP_FEE_DISINTERMENT',
user
),
quantity: 1, quantity: 1,
feeAmount: prepaidRow.CMPP_FEE_DISINTERMENT, feeAmount: prepaidRow.CMPP_FEE_DISINTERMENT,
taxAmount: prepaidRow.CMPP_GST_DISINTERMENT taxAmount: prepaidRow.CMPP_GST_DISINTERMENT
}, },
@ -794,6 +796,7 @@ async function importFromPrepaidCSV(): Promise<void> {
addContractComment( addContractComment(
{ {
contractId, contractId,
commentDateString: contractStartDateString, commentDateString: contractStartDateString,
comment: prepaidRow.CMPP_REMARK1 comment: prepaidRow.CMPP_REMARK1
}, },
@ -805,6 +808,7 @@ async function importFromPrepaidCSV(): Promise<void> {
addContractComment( addContractComment(
{ {
contractId, contractId,
commentDateString: contractStartDateString, commentDateString: contractStartDateString,
comment: prepaidRow.CMPP_REMARK2 comment: prepaidRow.CMPP_REMARK2
}, },
@ -992,10 +996,7 @@ async function importFromWorkOrderCSV(): Promise<void> {
const intermentContainerTypeId = const intermentContainerTypeId =
intermentContainerTypeKey === '' intermentContainerTypeKey === ''
? '' ? ''
: getIntermentContainerTypeIdByKey( : getIntermentContainerTypeIdByKey(intermentContainerTypeKey, user)
intermentContainerTypeKey,
user
)
const contractId = addContract( const contractId = addContract(
{ {