diff --git a/database/getBurialSiteTypes.d.ts b/database/getBurialSiteTypes.d.ts index c5dd3dce..99fc9610 100644 --- a/database/getBurialSiteTypes.d.ts +++ b/database/getBurialSiteTypes.d.ts @@ -1,2 +1,2 @@ import type { BurialSiteType } from '../types/record.types.js'; -export default function getBurialSiteTypes(): BurialSiteType[]; +export default function getBurialSiteTypes(includeDeleted?: boolean): BurialSiteType[]; diff --git a/database/getBurialSiteTypes.js b/database/getBurialSiteTypes.js index 4b1424dd..26cae497 100644 --- a/database/getBurialSiteTypes.js +++ b/database/getBurialSiteTypes.js @@ -2,12 +2,12 @@ import sqlite from 'better-sqlite3'; import { sunriseDB } from '../helpers/database.helpers.js'; import getBurialSiteTypeFields from './getBurialSiteTypeFields.js'; import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'; -export default function getBurialSiteTypes() { +export default function getBurialSiteTypes(includeDeleted = false) { const database = sqlite(sunriseDB); const burialSiteTypes = database .prepare(`select burialSiteTypeId, burialSiteType, orderNumber from BurialSiteTypes - where recordDelete_timeMillis is null + ${includeDeleted ? '' : ' where recordDelete_timeMillis is null '} order by orderNumber, burialSiteType`) .all(); let expectedOrderNumber = -1; diff --git a/database/getBurialSiteTypes.ts b/database/getBurialSiteTypes.ts index d776150d..7db0f3a4 100644 --- a/database/getBurialSiteTypes.ts +++ b/database/getBurialSiteTypes.ts @@ -6,14 +6,16 @@ import type { BurialSiteType } from '../types/record.types.js' import getBurialSiteTypeFields from './getBurialSiteTypeFields.js' import { updateRecordOrderNumber } from './updateRecordOrderNumber.js' -export default function getBurialSiteTypes(): BurialSiteType[] { +export default function getBurialSiteTypes( + includeDeleted = false +): BurialSiteType[] { const database = sqlite(sunriseDB) const burialSiteTypes = database .prepare( `select burialSiteTypeId, burialSiteType, orderNumber from BurialSiteTypes - where recordDelete_timeMillis is null + ${includeDeleted ? '' : ' where recordDelete_timeMillis is null '} order by orderNumber, burialSiteType` ) .all() as BurialSiteType[] diff --git a/database/getCommittalTypes.d.ts b/database/getCommittalTypes.d.ts index 5d83bfef..765c18c7 100644 --- a/database/getCommittalTypes.d.ts +++ b/database/getCommittalTypes.d.ts @@ -1,2 +1,2 @@ import type { CommittalType } from '../types/record.types.js'; -export default function getCommittalTypes(): CommittalType[]; +export default function getCommittalTypes(includeDeleted?: boolean): CommittalType[]; diff --git a/database/getCommittalTypes.js b/database/getCommittalTypes.js index 125efeaa..ff7226ac 100644 --- a/database/getCommittalTypes.js +++ b/database/getCommittalTypes.js @@ -1,12 +1,12 @@ import sqlite from 'better-sqlite3'; import { sunriseDB } from '../helpers/database.helpers.js'; import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'; -export default function getCommittalTypes() { +export default function getCommittalTypes(includeDeleted = false) { const database = sqlite(sunriseDB); const committalTypes = database .prepare(`select committalTypeId, committalTypeKey, committalType, orderNumber from CommittalTypes - where recordDelete_timeMillis is null + ${includeDeleted ? '' : ' where recordDelete_timeMillis is null '} order by orderNumber, committalType, committalTypeId`) .all(); let expectedOrderNumber = -1; diff --git a/database/getCommittalTypes.ts b/database/getCommittalTypes.ts index 08f787dd..43e71aa2 100644 --- a/database/getCommittalTypes.ts +++ b/database/getCommittalTypes.ts @@ -5,14 +5,16 @@ import type { CommittalType } from '../types/record.types.js' import { updateRecordOrderNumber } from './updateRecordOrderNumber.js' -export default function getCommittalTypes(): CommittalType[] { +export default function getCommittalTypes( + includeDeleted = false +): CommittalType[] { const database = sqlite(sunriseDB) const committalTypes = database .prepare( `select committalTypeId, committalTypeKey, committalType, orderNumber from CommittalTypes - where recordDelete_timeMillis is null + ${includeDeleted ? '' : ' where recordDelete_timeMillis is null '} order by orderNumber, committalType, committalTypeId` ) .all() as CommittalType[] diff --git a/database/getIntermentContainerTypes.d.ts b/database/getIntermentContainerTypes.d.ts index 7ff64a46..1bee7ceb 100644 --- a/database/getIntermentContainerTypes.d.ts +++ b/database/getIntermentContainerTypes.d.ts @@ -1,2 +1,2 @@ import type { IntermentContainerType } from '../types/record.types.js'; -export default function getIntermentContainerTypes(): IntermentContainerType[]; +export default function getIntermentContainerTypes(includeDeleted?: boolean): IntermentContainerType[]; diff --git a/database/getIntermentContainerTypes.js b/database/getIntermentContainerTypes.js index bba16ea2..23013f98 100644 --- a/database/getIntermentContainerTypes.js +++ b/database/getIntermentContainerTypes.js @@ -1,13 +1,13 @@ import sqlite from 'better-sqlite3'; import { sunriseDB } from '../helpers/database.helpers.js'; import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'; -export default function getIntermentContainerTypes() { +export default function getIntermentContainerTypes(includeDeleted = false) { const database = sqlite(sunriseDB); const containerTypes = database .prepare(`select intermentContainerTypeId, intermentContainerType, intermentContainerTypeKey, isCremationType, orderNumber from IntermentContainerTypes - where recordDelete_timeMillis is null + ${includeDeleted ? '' : ' where recordDelete_timeMillis is null '} order by isCremationType, orderNumber, intermentContainerType, intermentContainerTypeId`) .all(); let expectedOrderNumber = -1; diff --git a/database/getIntermentContainerTypes.ts b/database/getIntermentContainerTypes.ts index 3c7d85b4..2f63f96d 100644 --- a/database/getIntermentContainerTypes.ts +++ b/database/getIntermentContainerTypes.ts @@ -5,7 +5,9 @@ import type { IntermentContainerType } from '../types/record.types.js' import { updateRecordOrderNumber } from './updateRecordOrderNumber.js' -export default function getIntermentContainerTypes(): IntermentContainerType[] { +export default function getIntermentContainerTypes( + includeDeleted = false +): IntermentContainerType[] { const database = sqlite(sunriseDB) const containerTypes = database @@ -13,7 +15,7 @@ export default function getIntermentContainerTypes(): IntermentContainerType[] { `select intermentContainerTypeId, intermentContainerType, intermentContainerTypeKey, isCremationType, orderNumber from IntermentContainerTypes - where recordDelete_timeMillis is null + ${includeDeleted ? '' : ' where recordDelete_timeMillis is null '} order by isCremationType, orderNumber, intermentContainerType, intermentContainerTypeId` ) .all() as IntermentContainerType[] diff --git a/temp/legacyImportFromCsv/data.burialSiteTypes.js b/temp/legacyImportFromCsv/data.burialSiteTypes.js index 0e33c0f3..d5d05edb 100644 --- a/temp/legacyImportFromCsv/data.burialSiteTypes.js +++ b/temp/legacyImportFromCsv/data.burialSiteTypes.js @@ -1,16 +1,10 @@ import * as cacheFunctions from '../../helpers/functions.cache.js'; -const inGroundBurialSiteTypeId = (await cacheFunctions.getBurialSiteTypesByBurialSiteType('In-Ground Grave')) - .burialSiteTypeId; -const columbariumBurialSiteTypeId = (await cacheFunctions.getBurialSiteTypesByBurialSiteType('Columbarium')) - .burialSiteTypeId; -const cremationBurialSiteTypeId = (await cacheFunctions.getBurialSiteTypesByBurialSiteType('Crematorium')) - .burialSiteTypeId; -const mausoleumBurialSiteTypeId = (await cacheFunctions.getBurialSiteTypesByBurialSiteType('Mausoleum')) - .burialSiteTypeId; -const nicheWallBurialSiteTypeId = (await cacheFunctions.getBurialSiteTypesByBurialSiteType('Niche Wall')) - .burialSiteTypeId; -const urnGardenBurialSiteTypeId = (await cacheFunctions.getBurialSiteTypesByBurialSiteType('Urn Garden')) - .burialSiteTypeId; +const inGroundBurialSiteTypeId = cacheFunctions.getBurialSiteTypesByBurialSiteType('In-Ground Grave').burialSiteTypeId; +const columbariumBurialSiteTypeId = cacheFunctions.getBurialSiteTypesByBurialSiteType('Columbarium').burialSiteTypeId; +const cremationBurialSiteTypeId = cacheFunctions.getBurialSiteTypesByBurialSiteType('Crematorium').burialSiteTypeId; +const mausoleumBurialSiteTypeId = cacheFunctions.getBurialSiteTypesByBurialSiteType('Mausoleum').burialSiteTypeId; +const nicheWallBurialSiteTypeId = cacheFunctions.getBurialSiteTypesByBurialSiteType('Niche Wall').burialSiteTypeId; +const urnGardenBurialSiteTypeId = cacheFunctions.getBurialSiteTypesByBurialSiteType('Urn Garden').burialSiteTypeId; export function getBurialSiteTypeId(cemeteryKey) { switch (cemeteryKey) { case '00': { diff --git a/temp/legacyImportFromCsv/data.burialSiteTypes.ts b/temp/legacyImportFromCsv/data.burialSiteTypes.ts index b78abf8e..02fcce49 100644 --- a/temp/legacyImportFromCsv/data.burialSiteTypes.ts +++ b/temp/legacyImportFromCsv/data.burialSiteTypes.ts @@ -1,24 +1,30 @@ import * as cacheFunctions from '../../helpers/functions.cache.js' const inGroundBurialSiteTypeId = - (await cacheFunctions.getBurialSiteTypesByBurialSiteType('In-Ground Grave'))! - .burialSiteTypeId + cacheFunctions.getBurialSiteTypesByBurialSiteType( + 'In-Ground Grave' + )!.burialSiteTypeId const columbariumBurialSiteTypeId = - (await cacheFunctions.getBurialSiteTypesByBurialSiteType('Columbarium'))! - .burialSiteTypeId + cacheFunctions.getBurialSiteTypesByBurialSiteType( + 'Columbarium' + )!.burialSiteTypeId const cremationBurialSiteTypeId = - (await cacheFunctions.getBurialSiteTypesByBurialSiteType('Crematorium'))! - .burialSiteTypeId + cacheFunctions.getBurialSiteTypesByBurialSiteType( + 'Crematorium' + )!.burialSiteTypeId const mausoleumBurialSiteTypeId = - (await cacheFunctions.getBurialSiteTypesByBurialSiteType('Mausoleum'))! - .burialSiteTypeId + cacheFunctions.getBurialSiteTypesByBurialSiteType( + 'Mausoleum' + )!.burialSiteTypeId const nicheWallBurialSiteTypeId = - (await cacheFunctions.getBurialSiteTypesByBurialSiteType('Niche Wall'))! - .burialSiteTypeId + cacheFunctions.getBurialSiteTypesByBurialSiteType( + 'Niche Wall' + )!.burialSiteTypeId const urnGardenBurialSiteTypeId = - (await cacheFunctions.getBurialSiteTypesByBurialSiteType('Urn Garden'))! - .burialSiteTypeId + cacheFunctions.getBurialSiteTypesByBurialSiteType( + 'Urn Garden' + )!.burialSiteTypeId export function getBurialSiteTypeId(cemeteryKey: string): number { switch (cemeteryKey) { @@ -42,4 +48,4 @@ export function getBurialSiteTypeId(cemeteryKey: string): number { } return inGroundBurialSiteTypeId -} \ No newline at end of file +} diff --git a/temp/legacyImportFromCsv/data.committalTypes.js b/temp/legacyImportFromCsv/data.committalTypes.js index 8c54a778..562622c0 100644 --- a/temp/legacyImportFromCsv/data.committalTypes.js +++ b/temp/legacyImportFromCsv/data.committalTypes.js @@ -1,6 +1,6 @@ import addCommittalType from '../../database/addCommittalType.js'; import getCommittalTypes from '../../database/getCommittalTypes.js'; -let committalTypes = getCommittalTypes(); +let committalTypes = getCommittalTypes(true); export function getCommittalTypeIdByKey(committalTypeKey, user) { const committalType = committalTypes.find((committalType) => committalType.committalTypeKey === committalTypeKey); if (committalType === undefined) { diff --git a/temp/legacyImportFromCsv/data.committalTypes.ts b/temp/legacyImportFromCsv/data.committalTypes.ts index 5d1b3cf2..6fc1a52d 100644 --- a/temp/legacyImportFromCsv/data.committalTypes.ts +++ b/temp/legacyImportFromCsv/data.committalTypes.ts @@ -1,7 +1,7 @@ import addCommittalType from '../../database/addCommittalType.js' import getCommittalTypes from '../../database/getCommittalTypes.js' -let committalTypes = getCommittalTypes() +let committalTypes = getCommittalTypes(true) export function getCommittalTypeIdByKey( committalTypeKey: string, diff --git a/temp/legacyImportFromCsv/data.intermentContainerTypes.js b/temp/legacyImportFromCsv/data.intermentContainerTypes.js index ccb70669..065a40eb 100644 --- a/temp/legacyImportFromCsv/data.intermentContainerTypes.js +++ b/temp/legacyImportFromCsv/data.intermentContainerTypes.js @@ -9,7 +9,7 @@ export function getIntermentContainerTypeIdByKey(intermentContainerTypeKey, user intermentContainerTypeKey, intermentContainerType: intermentContainerTypeKey }, user); - intermentContainerTypes = getIntermentContainerTypes(); + intermentContainerTypes = getIntermentContainerTypes(true); return intermentContainerTypeId; } return intermentContainerType.intermentContainerTypeId; diff --git a/temp/legacyImportFromCsv/data.intermentContainerTypes.ts b/temp/legacyImportFromCsv/data.intermentContainerTypes.ts index 13881761..14890153 100644 --- a/temp/legacyImportFromCsv/data.intermentContainerTypes.ts +++ b/temp/legacyImportFromCsv/data.intermentContainerTypes.ts @@ -22,7 +22,7 @@ export function getIntermentContainerTypeIdByKey( user ) - intermentContainerTypes = getIntermentContainerTypes() + intermentContainerTypes = getIntermentContainerTypes(true) return intermentContainerTypeId } diff --git a/temp/legacyImportFromCsv/index.ts b/temp/legacyImportFromCsv/index.ts index 50bbbb62..65a03436 100644 --- a/temp/legacyImportFromCsv/index.ts +++ b/temp/legacyImportFromCsv/index.ts @@ -388,10 +388,7 @@ async function importFromMasterCSV(): Promise { const intermentContainerTypeId = intermentContainerTypeKey === '' ? '' - : getIntermentContainerTypeIdByKey( - intermentContainerTypeKey, - user - ) + : getIntermentContainerTypeIdByKey(intermentContainerTypeKey, user) deceasedContractId = addContract( { @@ -649,6 +646,7 @@ async function importFromPrepaidCSV(): Promise { contractId, feeId: getFeeIdByFeeDescription('CMPP_FEE_GRAV_SD', user), quantity: 1, + feeAmount: prepaidRow.CMPP_FEE_GRAV_SD, taxAmount: prepaidRow.CMPP_GST_GRAV_SD }, @@ -662,6 +660,7 @@ async function importFromPrepaidCSV(): Promise { contractId, feeId: getFeeIdByFeeDescription('CMPP_FEE_GRAV_DD', user), quantity: 1, + feeAmount: prepaidRow.CMPP_FEE_GRAV_DD, taxAmount: prepaidRow.CMPP_GST_GRAV_DD }, @@ -675,6 +674,7 @@ async function importFromPrepaidCSV(): Promise { contractId, feeId: getFeeIdByFeeDescription('CMPP_FEE_CHAP_SD', user), quantity: 1, + feeAmount: prepaidRow.CMPP_FEE_CHAP_SD, taxAmount: prepaidRow.CMPP_GST_CHAP_SD }, @@ -688,6 +688,7 @@ async function importFromPrepaidCSV(): Promise { contractId, feeId: getFeeIdByFeeDescription('CMPP_FEE_CHAP_DD', user), quantity: 1, + feeAmount: prepaidRow.CMPP_FEE_CHAP_DD, taxAmount: prepaidRow.CMPP_GST_CHAP_DD }, @@ -701,6 +702,7 @@ async function importFromPrepaidCSV(): Promise { contractId, feeId: getFeeIdByFeeDescription('CMPP_FEE_ENTOMBMENT', user), quantity: 1, + feeAmount: prepaidRow.CMPP_FEE_ENTOMBMENT, taxAmount: prepaidRow.CMPP_GST_ENTOMBMENT }, @@ -714,6 +716,7 @@ async function importFromPrepaidCSV(): Promise { contractId, feeId: getFeeIdByFeeDescription('CMPP_FEE_CREM', user), quantity: 1, + feeAmount: prepaidRow.CMPP_FEE_CREM, taxAmount: prepaidRow.CMPP_GST_CREM }, @@ -727,6 +730,7 @@ async function importFromPrepaidCSV(): Promise { contractId, feeId: getFeeIdByFeeDescription('CMPP_FEE_NICHE', user), quantity: 1, + feeAmount: prepaidRow.CMPP_FEE_NICHE, taxAmount: prepaidRow.CMPP_GST_NICHE }, @@ -741,11 +745,9 @@ async function importFromPrepaidCSV(): Promise { await addContractFee( { contractId, - feeId: getFeeIdByFeeDescription( - 'CMPP_FEE_DISINTERMENT', - user - ), + feeId: getFeeIdByFeeDescription('CMPP_FEE_DISINTERMENT', user), quantity: 1, + feeAmount: prepaidRow.CMPP_FEE_DISINTERMENT, taxAmount: prepaidRow.CMPP_GST_DISINTERMENT }, @@ -794,6 +796,7 @@ async function importFromPrepaidCSV(): Promise { addContractComment( { contractId, + commentDateString: contractStartDateString, comment: prepaidRow.CMPP_REMARK1 }, @@ -805,6 +808,7 @@ async function importFromPrepaidCSV(): Promise { addContractComment( { contractId, + commentDateString: contractStartDateString, comment: prepaidRow.CMPP_REMARK2 }, @@ -992,10 +996,7 @@ async function importFromWorkOrderCSV(): Promise { const intermentContainerTypeId = intermentContainerTypeKey === '' ? '' - : getIntermentContainerTypeIdByKey( - intermentContainerTypeKey, - user - ) + : getIntermentContainerTypeIdByKey(intermentContainerTypeKey, user) const contractId = addContract( {