diff --git a/database/addBurialSiteTypeField.js b/database/addBurialSiteTypeField.js index 232c4df6..6c211d5e 100644 --- a/database/addBurialSiteTypeField.js +++ b/database/addBurialSiteTypeField.js @@ -14,7 +14,9 @@ export default function addBurialSiteTypeField(addForm, user) { recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`) - .run(addForm.burialSiteTypeId, addForm.burialSiteTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0, addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); + .run(addForm.burialSiteTypeId, addForm.burialSiteTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0, + // eslint-disable-next-line @typescript-eslint/no-magic-numbers + addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); database.close(); clearCacheByTableName('BurialSiteTypeFields'); return result.lastInsertRowid; diff --git a/database/addBurialSiteTypeField.ts b/database/addBurialSiteTypeField.ts index 8ba547a4..0df3d3c2 100644 --- a/database/addBurialSiteTypeField.ts +++ b/database/addBurialSiteTypeField.ts @@ -5,7 +5,7 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js' export interface AddBurialSiteTypeFieldForm { burialSiteTypeId: number | string - + burialSiteTypeField: string fieldType?: string @@ -47,6 +47,7 @@ export default function addBurialSiteTypeField( addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0, + // eslint-disable-next-line @typescript-eslint/no-magic-numbers addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, diff --git a/database/addContractTransaction.d.ts b/database/addContractTransaction.d.ts index 003d07b6..15242102 100644 --- a/database/addContractTransaction.d.ts +++ b/database/addContractTransaction.d.ts @@ -1,7 +1,8 @@ +import { type DateString, type TimeString } from '@cityssm/utils-datetime'; export interface AddTransactionForm { contractId: number | string; - transactionDateString?: string; - transactionTimeString?: string; + transactionDateString?: '' | DateString; + transactionTimeString?: '' | TimeString; externalReceiptNumber: string; transactionAmount: number | string; transactionNote: string; diff --git a/database/addContractTransaction.js b/database/addContractTransaction.js index 13fe4593..dc1b6a70 100644 --- a/database/addContractTransaction.js +++ b/database/addContractTransaction.js @@ -15,12 +15,12 @@ export default function addContractTransaction(contractTransactionForm, user) { transactionIndex = maxIndexResult.transactionIndex + 1; } const rightNow = new Date(); - const transactionDate = contractTransactionForm.transactionDateString - ? dateStringToInteger(contractTransactionForm.transactionDateString) - : dateToInteger(rightNow); - const transactionTime = contractTransactionForm.transactionTimeString - ? timeStringToInteger(contractTransactionForm.transactionTimeString) - : dateToTimeInteger(rightNow); + const transactionDate = contractTransactionForm.transactionDateString === '' + ? dateToInteger(rightNow) + : dateStringToInteger(contractTransactionForm.transactionDateString); + const transactionTime = contractTransactionForm.transactionTimeString === '' + ? dateToTimeInteger(rightNow) + : timeStringToInteger(contractTransactionForm.transactionTimeString); database .prepare(`insert into ContractTransactions ( contractId, transactionIndex, diff --git a/database/addContractTransaction.ts b/database/addContractTransaction.ts index 76f673bf..c40beada 100644 --- a/database/addContractTransaction.ts +++ b/database/addContractTransaction.ts @@ -1,4 +1,6 @@ import { + type DateString, + type TimeString, dateStringToInteger, dateToInteger, dateToTimeInteger, @@ -11,8 +13,8 @@ import { sunriseDB } from '../helpers/database.helpers.js' export interface AddTransactionForm { contractId: number | string - transactionDateString?: string - transactionTimeString?: string + transactionDateString?: '' | DateString + transactionTimeString?: '' | TimeString externalReceiptNumber: string transactionAmount: number | string @@ -45,13 +47,19 @@ export default function addContractTransaction( const rightNow = new Date() - const transactionDate = contractTransactionForm.transactionDateString - ? dateStringToInteger(contractTransactionForm.transactionDateString) - : dateToInteger(rightNow) + const transactionDate = + contractTransactionForm.transactionDateString === '' + ? dateToInteger(rightNow) + : dateStringToInteger( + contractTransactionForm.transactionDateString as DateString + ) - const transactionTime = contractTransactionForm.transactionTimeString - ? timeStringToInteger(contractTransactionForm.transactionTimeString) - : dateToTimeInteger(rightNow) + const transactionTime = + contractTransactionForm.transactionTimeString === '' + ? dateToTimeInteger(rightNow) + : timeStringToInteger( + contractTransactionForm.transactionTimeString as TimeString + ) database .prepare( diff --git a/database/addContractTypeField.d.ts b/database/addContractTypeField.d.ts index c33fa590..c922e734 100644 --- a/database/addContractTypeField.d.ts +++ b/database/addContractTypeField.d.ts @@ -1,8 +1,8 @@ export interface AddContractTypeFieldForm { contractTypeId?: number | string; contractTypeField: string; - fieldValues?: string; fieldType?: string; + fieldValues?: string; isRequired?: string; maxLength?: number | string; minLength?: number | string; diff --git a/database/addContractTypeField.js b/database/addContractTypeField.js index cd04e7f7..4c33cdc3 100644 --- a/database/addContractTypeField.js +++ b/database/addContractTypeField.js @@ -13,7 +13,9 @@ export default function addContractTypeField(addForm, user) { recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`) - .run(addForm.contractTypeId ?? undefined, addForm.contractTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0, addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); + .run(addForm.contractTypeId ?? undefined, addForm.contractTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0, + // eslint-disable-next-line @typescript-eslint/no-magic-numbers + addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); database.close(); clearCacheByTableName('ContractTypeFields'); return result.lastInsertRowid; diff --git a/database/addContractTypeField.ts b/database/addContractTypeField.ts index de86ea8a..74acfb36 100644 --- a/database/addContractTypeField.ts +++ b/database/addContractTypeField.ts @@ -5,9 +5,11 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js' export interface AddContractTypeFieldForm { contractTypeId?: number | string + contractTypeField: string - fieldValues?: string + fieldType?: string + fieldValues?: string isRequired?: string maxLength?: number | string minLength?: number | string @@ -43,6 +45,7 @@ export default function addContractTypeField( addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0, + // eslint-disable-next-line @typescript-eslint/no-magic-numbers addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, diff --git a/database/addContractTypePrint.js b/database/addContractTypePrint.js index 7f3c21c5..be47f2f2 100644 --- a/database/addContractTypePrint.js +++ b/database/addContractTypePrint.js @@ -7,11 +7,11 @@ export default function addContractTypePrint(addForm, user) { let result = database .prepare(`update ContractTypePrints set recordUpdate_userName = ?, - recordUpdate_timeMillis = ?, - recordDelete_userName = null, - recordDelete_timeMillis = null + recordUpdate_timeMillis = ?, + recordDelete_userName = null, + recordDelete_timeMillis = null where contractTypeId = ? - and printEJS = ?`) + and printEJS = ?`) .run(user.userName, rightNowMillis, addForm.contractTypeId, addForm.printEJS); if (result.changes === 0) { result = database diff --git a/database/addContractTypePrint.ts b/database/addContractTypePrint.ts index 8cddd337..ab5b4e45 100644 --- a/database/addContractTypePrint.ts +++ b/database/addContractTypePrint.ts @@ -6,6 +6,7 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js' export interface AddContractTypePrintForm { contractTypeId: number | string printEJS: string + orderNumber?: number } @@ -21,11 +22,11 @@ export default function addContractTypePrint( .prepare( `update ContractTypePrints set recordUpdate_userName = ?, - recordUpdate_timeMillis = ?, - recordDelete_userName = null, - recordDelete_timeMillis = null + recordUpdate_timeMillis = ?, + recordDelete_userName = null, + recordDelete_timeMillis = null where contractTypeId = ? - and printEJS = ?` + and printEJS = ?` ) .run( user.userName, diff --git a/database/addFuneralHome.d.ts b/database/addFuneralHome.d.ts index 7e651cee..01d163e8 100644 --- a/database/addFuneralHome.d.ts +++ b/database/addFuneralHome.d.ts @@ -1,6 +1,6 @@ export interface AddForm { - funeralHomeName: string; funeralHomeKey: string; + funeralHomeName: string; funeralHomeAddress1: string; funeralHomeAddress2: string; funeralHomeCity: string; diff --git a/database/addFuneralHome.ts b/database/addFuneralHome.ts index ddf3d74a..3937a28a 100644 --- a/database/addFuneralHome.ts +++ b/database/addFuneralHome.ts @@ -3,8 +3,8 @@ import sqlite from 'better-sqlite3' import { sunriseDB } from '../helpers/database.helpers.js' export interface AddForm { - funeralHomeName: string funeralHomeKey: string + funeralHomeName: string funeralHomeAddress1: string funeralHomeAddress2: string diff --git a/database/addOrUpdateBurialSiteField.js b/database/addOrUpdateBurialSiteField.js index b9ef32ac..be64dc25 100644 --- a/database/addOrUpdateBurialSiteField.js +++ b/database/addOrUpdateBurialSiteField.js @@ -6,12 +6,12 @@ export default function addOrUpdateBurialSiteField(fieldForm, user, connectedDat let result = database .prepare(`update BurialSiteFields set fieldValue = ?, - recordUpdate_userName = ?, - recordUpdate_timeMillis = ?, - recordDelete_userName = null, - recordDelete_timeMillis = null + recordUpdate_userName = ?, + recordUpdate_timeMillis = ?, + recordDelete_userName = null, + recordDelete_timeMillis = null where burialSiteId = ? - and burialSiteTypeFieldId = ?`) + and burialSiteTypeFieldId = ?`) .run(fieldForm.fieldValue, user.userName, rightNowMillis, fieldForm.burialSiteId, fieldForm.burialSiteTypeFieldId); if (result.changes === 0) { result = database diff --git a/database/addOrUpdateBurialSiteField.ts b/database/addOrUpdateBurialSiteField.ts index 3e5cff5b..96446abf 100644 --- a/database/addOrUpdateBurialSiteField.ts +++ b/database/addOrUpdateBurialSiteField.ts @@ -21,12 +21,12 @@ export default function addOrUpdateBurialSiteField( .prepare( `update BurialSiteFields set fieldValue = ?, - recordUpdate_userName = ?, - recordUpdate_timeMillis = ?, - recordDelete_userName = null, - recordDelete_timeMillis = null + recordUpdate_userName = ?, + recordUpdate_timeMillis = ?, + recordDelete_userName = null, + recordDelete_timeMillis = null where burialSiteId = ? - and burialSiteTypeFieldId = ?` + and burialSiteTypeFieldId = ?` ) .run( fieldForm.fieldValue, diff --git a/database/addOrUpdateContractField.js b/database/addOrUpdateContractField.js index d3d3699e..0fd09765 100644 --- a/database/addOrUpdateContractField.js +++ b/database/addOrUpdateContractField.js @@ -6,12 +6,12 @@ export default function addOrUpdateContractField(fieldForm, user, connectedDatab let result = database .prepare(`update ContractFields set fieldValue = ?, - recordUpdate_userName = ?, - recordUpdate_timeMillis = ?, - recordDelete_userName = null, - recordDelete_timeMillis = null + recordUpdate_userName = ?, + recordUpdate_timeMillis = ?, + recordDelete_userName = null, + recordDelete_timeMillis = null where contractId = ? - and contractTypeFieldId = ?`) + and contractTypeFieldId = ?`) .run(fieldForm.fieldValue, user.userName, rightNowMillis, fieldForm.contractId, fieldForm.contractTypeFieldId); if (result.changes === 0) { result = database diff --git a/database/addOrUpdateContractField.ts b/database/addOrUpdateContractField.ts index dfcfaa49..fdeaceca 100644 --- a/database/addOrUpdateContractField.ts +++ b/database/addOrUpdateContractField.ts @@ -21,12 +21,12 @@ export default function addOrUpdateContractField( .prepare( `update ContractFields set fieldValue = ?, - recordUpdate_userName = ?, - recordUpdate_timeMillis = ?, - recordDelete_userName = null, - recordDelete_timeMillis = null + recordUpdate_userName = ?, + recordUpdate_timeMillis = ?, + recordDelete_userName = null, + recordDelete_timeMillis = null where contractId = ? - and contractTypeFieldId = ?` + and contractTypeFieldId = ?` ) .run( fieldForm.fieldValue, diff --git a/database/addWorkOrder.d.ts b/database/addWorkOrder.d.ts index 192fa602..c779b240 100644 --- a/database/addWorkOrder.d.ts +++ b/database/addWorkOrder.d.ts @@ -1,9 +1,9 @@ export interface AddWorkOrderForm { - workOrderTypeId: number | string; - workOrderNumber?: string; workOrderDescription: string; - workOrderOpenDateString?: string; + workOrderNumber?: string; + workOrderTypeId: number | string; workOrderCloseDateString?: string; + workOrderOpenDateString?: string; contractId?: string; } export default function addWorkOrder(workOrderForm: AddWorkOrderForm, user: User): number; diff --git a/database/addWorkOrder.js b/database/addWorkOrder.js index b964c69f..2281d770 100644 --- a/database/addWorkOrder.js +++ b/database/addWorkOrder.js @@ -25,8 +25,8 @@ export default function addWorkOrder(workOrderForm, user) { const workOrderId = result.lastInsertRowid; if ((workOrderForm.contractId ?? '') !== '') { addWorkOrderContract({ + contractId: workOrderForm.contractId, workOrderId, - contractId: workOrderForm.contractId }, user, database); } database.close(); diff --git a/database/addWorkOrder.ts b/database/addWorkOrder.ts index a9f99854..12d7cb52 100644 --- a/database/addWorkOrder.ts +++ b/database/addWorkOrder.ts @@ -11,11 +11,14 @@ import addWorkOrderContract from './addWorkOrderContract.js' import getNextWorkOrderNumber from './getNextWorkOrderNumber.js' export interface AddWorkOrderForm { - workOrderTypeId: number | string - workOrderNumber?: string workOrderDescription: string - workOrderOpenDateString?: string + workOrderNumber?: string + + workOrderTypeId: number | string + workOrderCloseDateString?: string + workOrderOpenDateString?: string + contractId?: string } @@ -67,8 +70,8 @@ export default function addWorkOrder( if ((workOrderForm.contractId ?? '') !== '') { addWorkOrderContract( { + contractId: workOrderForm.contractId as string, workOrderId, - contractId: workOrderForm.contractId as string }, user, database diff --git a/database/addWorkOrderBurialSite.d.ts b/database/addWorkOrderBurialSite.d.ts index 057617b4..a37a4fe4 100644 --- a/database/addWorkOrderBurialSite.d.ts +++ b/database/addWorkOrderBurialSite.d.ts @@ -1,5 +1,5 @@ export interface AddForm { - workOrderId: number | string; burialSiteId: number | string; + workOrderId: number | string; } export default function addWorkOrderBurialSite(workOrderLotForm: AddForm, user: User): boolean; diff --git a/database/addWorkOrderBurialSite.ts b/database/addWorkOrderBurialSite.ts index 8a56acd5..a64f5573 100644 --- a/database/addWorkOrderBurialSite.ts +++ b/database/addWorkOrderBurialSite.ts @@ -3,8 +3,8 @@ import sqlite from 'better-sqlite3' import { sunriseDB } from '../helpers/database.helpers.js' export interface AddForm { - workOrderId: number | string burialSiteId: number | string + workOrderId: number | string } export default function addWorkOrderBurialSite( diff --git a/database/addWorkOrderComment.d.ts b/database/addWorkOrderComment.d.ts index 14527ab1..98ac9563 100644 --- a/database/addWorkOrderComment.d.ts +++ b/database/addWorkOrderComment.d.ts @@ -1,5 +1,5 @@ export interface AddWorkOrderCommentForm { - workOrderId: string; comment: string; + workOrderId: string; } export default function addWorkOrderComment(workOrderCommentForm: AddWorkOrderCommentForm, user: User): number; diff --git a/database/addWorkOrderComment.ts b/database/addWorkOrderComment.ts index 47d6734c..94c132f3 100644 --- a/database/addWorkOrderComment.ts +++ b/database/addWorkOrderComment.ts @@ -4,8 +4,8 @@ import sqlite from 'better-sqlite3' import { sunriseDB } from '../helpers/database.helpers.js' export interface AddWorkOrderCommentForm { - workOrderId: string comment: string + workOrderId: string } export default function addWorkOrderComment( diff --git a/database/cleanupDatabase.js b/database/cleanupDatabase.js index 212e9ecf..fc707dad 100644 --- a/database/cleanupDatabase.js +++ b/database/cleanupDatabase.js @@ -15,10 +15,10 @@ export default function cleanupDatabase(user) { inactivatedRecordCount += database .prepare(`update WorkOrderComments set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and workOrderId in ( - select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`) + and workOrderId in ( + select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database .prepare('delete from WorkOrderComments where recordDelete_timeMillis <= ?') @@ -29,10 +29,10 @@ export default function cleanupDatabase(user) { inactivatedRecordCount += database .prepare(`update WorkOrderContracts set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and workOrderId in ( - select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`) + and workOrderId in ( + select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database .prepare('delete from WorkOrderContracts where recordDelete_timeMillis <= ?') @@ -43,10 +43,10 @@ export default function cleanupDatabase(user) { inactivatedRecordCount += database .prepare(`update WorkOrderBurialSites set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and workOrderId in ( - select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`) + and workOrderId in ( + select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database .prepare('delete from WorkOrderBurialSites where recordDelete_timeMillis <= ?') @@ -57,10 +57,10 @@ export default function cleanupDatabase(user) { inactivatedRecordCount += database .prepare(`update WorkOrderMilestones set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and workOrderId in ( - select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`) + and workOrderId in ( + select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database .prepare('delete from WorkOrderMilestones where recordDelete_timeMillis <= ?') @@ -71,10 +71,10 @@ export default function cleanupDatabase(user) { purgedRecordCount += database .prepare(`delete from WorkOrders where recordDelete_timeMillis <= ? - and workOrderId not in (select workOrderId from WorkOrderComments) - and workOrderId not in (select workOrderId from WorkOrderContracts) - and workOrderId not in (select workOrderId from WorkOrderBurialSites) - and workOrderId not in (select workOrderId from WorkOrderMilestones)`) + and workOrderId not in (select workOrderId from WorkOrderComments) + and workOrderId not in (select workOrderId from WorkOrderContracts) + and workOrderId not in (select workOrderId from WorkOrderBurialSites) + and workOrderId not in (select workOrderId from WorkOrderMilestones)`) .run(recordDeleteTimeMillisMin).changes; /* * Work Order Milestone Types @@ -82,8 +82,8 @@ export default function cleanupDatabase(user) { purgedRecordCount += database .prepare(`delete from WorkOrderMilestoneTypes where recordDelete_timeMillis <= ? - and workOrderMilestoneTypeId not in ( - select workOrderMilestoneTypeId from WorkOrderMilestones)`) + and workOrderMilestoneTypeId not in ( + select workOrderMilestoneTypeId from WorkOrderMilestones)`) .run(recordDeleteTimeMillisMin).changes; /* * Work Order Types @@ -91,7 +91,7 @@ export default function cleanupDatabase(user) { purgedRecordCount += database .prepare(`delete from WorkOrderTypes where recordDelete_timeMillis <= ? - and workOrderTypeId not in (select workOrderTypeId from WorkOrders)`) + and workOrderTypeId not in (select workOrderTypeId from WorkOrders)`) .run(recordDeleteTimeMillisMin).changes; /* * Burial Site Contract Comments @@ -99,10 +99,10 @@ export default function cleanupDatabase(user) { inactivatedRecordCount += database .prepare(`update ContractComments set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and contractId in ( - select contractId from Contracts where recordDelete_timeMillis is not null)`) + and contractId in ( + select contractId from Contracts where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database .prepare('delete from ContractComments where recordDelete_timeMillis <= ?') @@ -113,16 +113,16 @@ export default function cleanupDatabase(user) { inactivatedRecordCount += database .prepare(`update ContractFields set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and contractId in (select contractId from Contracts where recordDelete_timeMillis is not null)`) + and contractId in (select contractId from Contracts where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database .prepare('delete from ContractFields where recordDelete_timeMillis <= ?') .run(recordDeleteTimeMillisMin).changes; /* * Burial Site Contract Fees/Transactions - * - Maintain financials, do not delete related. + * - Maintain financial data, do not delete related. */ purgedRecordCount += database .prepare('delete from ContractFees where recordDelete_timeMillis <= ?') @@ -136,12 +136,12 @@ export default function cleanupDatabase(user) { purgedRecordCount += database .prepare(`delete from Contracts where recordDelete_timeMillis <= ? - and contractId not in (select contractId from ContractComments) - and contractId not in (select contractId from ContractFees) - and contractId not in (select contractId from ContractFields) - and contractId not in (select contractId from ContractInterments) - and contractId not in (select contractId from ContractTransactions) - and contractId not in (select contractId from WorkOrderContracts)`) + and contractId not in (select contractId from ContractComments) + and contractId not in (select contractId from ContractFees) + and contractId not in (select contractId from ContractFields) + and contractId not in (select contractId from ContractInterments) + and contractId not in (select contractId from ContractTransactions) + and contractId not in (select contractId from WorkOrderContracts)`) .run(recordDeleteTimeMillisMin).changes; /* * Fees @@ -149,14 +149,14 @@ export default function cleanupDatabase(user) { inactivatedRecordCount += database .prepare(`update Fees set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and feeCategoryId in (select feeCategoryId from FeeCategories where recordDelete_timeMillis is not null)`) + and feeCategoryId in (select feeCategoryId from FeeCategories where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database .prepare(`delete from Fees where recordDelete_timeMillis <= ? - and feeId not in (select feeId from ContractFees)`) + and feeId not in (select feeId from ContractFees)`) .run(recordDeleteTimeMillisMin).changes; /* * Fee Categories @@ -164,7 +164,7 @@ export default function cleanupDatabase(user) { purgedRecordCount += database .prepare(`delete from FeeCategories where recordDelete_timeMillis <= ? - and feeCategoryId not in (select feeCategoryId from Fees)`) + and feeCategoryId not in (select feeCategoryId from Fees)`) .run(recordDeleteTimeMillisMin).changes; /* * Contract Type Fields @@ -172,14 +172,14 @@ export default function cleanupDatabase(user) { inactivatedRecordCount += database .prepare(`update ContractTypeFields set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)`) + and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database .prepare(`delete from ContractTypeFields where recordDelete_timeMillis <= ? - and contractTypeFieldId not in (select contractTypeFieldId from ContractFields)`) + and contractTypeFieldId not in (select contractTypeFieldId from ContractFields)`) .run(recordDeleteTimeMillisMin).changes; /* * Contract Type Prints @@ -187,9 +187,9 @@ export default function cleanupDatabase(user) { inactivatedRecordCount += database .prepare(`update ContractTypePrints set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)`) + and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database .prepare('delete from ContractTypePrints where recordDelete_timeMillis <= ?') @@ -200,10 +200,10 @@ export default function cleanupDatabase(user) { purgedRecordCount += database .prepare(`delete from ContractTypes where recordDelete_timeMillis <= ? - and contractTypeId not in (select contractTypeId from ContractTypeFields) - and contractTypeId not in (select contractTypeId from ContractTypePrints) - and contractTypeId not in (select contractTypeId from Contracts) - and contractTypeId not in (select contractTypeId from Fees)`) + and contractTypeId not in (select contractTypeId from ContractTypeFields) + and contractTypeId not in (select contractTypeId from ContractTypePrints) + and contractTypeId not in (select contractTypeId from Contracts) + and contractTypeId not in (select contractTypeId from Fees)`) .run(recordDeleteTimeMillisMin).changes; /* * Burial Site Comments @@ -211,9 +211,9 @@ export default function cleanupDatabase(user) { inactivatedRecordCount += database .prepare(`update BurialSiteComments set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)`) + and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database .prepare('delete from BurialSiteComments where recordDelete_timeMillis <= ?') @@ -224,9 +224,9 @@ export default function cleanupDatabase(user) { inactivatedRecordCount += database .prepare(`update BurialSiteFields set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)`) + and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database .prepare('delete from BurialSiteFields where recordDelete_timeMillis <= ?') @@ -237,17 +237,17 @@ export default function cleanupDatabase(user) { inactivatedRecordCount += database .prepare(`update BurialSites set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and cemeteryId in (select cemeteryId from Cemeteries where recordDelete_timeMillis is not null)`) + and cemeteryId in (select cemeteryId from Cemeteries where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database .prepare(`delete from BurialSites where recordDelete_timeMillis <= ? - and burialSiteId not in (select burialSiteId from BurialSiteComments) - and burialSiteId not in (select burialSiteId from BurialSiteFields) - and burialSiteId not in (select burialSiteId from Contracts) - and burialSiteId not in (select burialSiteId from WorkOrderBurialSites)`) + and burialSiteId not in (select burialSiteId from BurialSiteComments) + and burialSiteId not in (select burialSiteId from BurialSiteFields) + and burialSiteId not in (select burialSiteId from Contracts) + and burialSiteId not in (select burialSiteId from WorkOrderBurialSites)`) .run(recordDeleteTimeMillisMin).changes; /* * Burial Site Statuses @@ -255,7 +255,7 @@ export default function cleanupDatabase(user) { purgedRecordCount += database .prepare(`delete from BurialSiteStatuses where recordDelete_timeMillis <= ? - and burialSiteStatusId not in (select burialSiteStatusId from BurialSites)`) + and burialSiteStatusId not in (select burialSiteStatusId from BurialSites)`) .run(recordDeleteTimeMillisMin).changes; /* * Burial Site Type Fields @@ -263,14 +263,14 @@ export default function cleanupDatabase(user) { inactivatedRecordCount += database .prepare(`update BurialSiteTypeFields set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteTypeId in (select burialSiteTypeId from BurialSiteTypes where recordDelete_timeMillis is not null)`) + and burialSiteTypeId in (select burialSiteTypeId from BurialSiteTypes where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database .prepare(`delete from BurialSiteTypeFields where recordDelete_timeMillis <= ? - and burialSiteTypeFieldId not in (select burialSiteTypeFieldId from BurialSiteFields)`) + and burialSiteTypeFieldId not in (select burialSiteTypeFieldId from BurialSiteFields)`) .run(recordDeleteTimeMillisMin).changes; /* * Burial Site Types @@ -278,7 +278,7 @@ export default function cleanupDatabase(user) { purgedRecordCount += database .prepare(`delete from BurialSiteTypes where recordDelete_timeMillis <= ? - and burialSiteTypeId not in (select burialSiteTypeId from BurialSites)`) + and burialSiteTypeId not in (select burialSiteTypeId from BurialSites)`) .run(recordDeleteTimeMillisMin).changes; database.close(); return { diff --git a/database/cleanupDatabase.ts b/database/cleanupDatabase.ts index 851b5c1f..9f36503c 100644 --- a/database/cleanupDatabase.ts +++ b/database/cleanupDatabase.ts @@ -26,10 +26,10 @@ export default function cleanupDatabase(user: User): { .prepare( `update WorkOrderComments set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and workOrderId in ( - select workOrderId from WorkOrders where recordDelete_timeMillis is not null)` + and workOrderId in ( + select workOrderId from WorkOrders where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes @@ -45,10 +45,10 @@ export default function cleanupDatabase(user: User): { .prepare( `update WorkOrderContracts set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and workOrderId in ( - select workOrderId from WorkOrders where recordDelete_timeMillis is not null)` + and workOrderId in ( + select workOrderId from WorkOrders where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes @@ -66,10 +66,10 @@ export default function cleanupDatabase(user: User): { .prepare( `update WorkOrderBurialSites set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and workOrderId in ( - select workOrderId from WorkOrders where recordDelete_timeMillis is not null)` + and workOrderId in ( + select workOrderId from WorkOrders where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes @@ -87,10 +87,10 @@ export default function cleanupDatabase(user: User): { .prepare( `update WorkOrderMilestones set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and workOrderId in ( - select workOrderId from WorkOrders where recordDelete_timeMillis is not null)` + and workOrderId in ( + select workOrderId from WorkOrders where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes @@ -108,10 +108,10 @@ export default function cleanupDatabase(user: User): { .prepare( `delete from WorkOrders where recordDelete_timeMillis <= ? - and workOrderId not in (select workOrderId from WorkOrderComments) - and workOrderId not in (select workOrderId from WorkOrderContracts) - and workOrderId not in (select workOrderId from WorkOrderBurialSites) - and workOrderId not in (select workOrderId from WorkOrderMilestones)` + and workOrderId not in (select workOrderId from WorkOrderComments) + and workOrderId not in (select workOrderId from WorkOrderContracts) + and workOrderId not in (select workOrderId from WorkOrderBurialSites) + and workOrderId not in (select workOrderId from WorkOrderMilestones)` ) .run(recordDeleteTimeMillisMin).changes @@ -123,8 +123,8 @@ export default function cleanupDatabase(user: User): { .prepare( `delete from WorkOrderMilestoneTypes where recordDelete_timeMillis <= ? - and workOrderMilestoneTypeId not in ( - select workOrderMilestoneTypeId from WorkOrderMilestones)` + and workOrderMilestoneTypeId not in ( + select workOrderMilestoneTypeId from WorkOrderMilestones)` ) .run(recordDeleteTimeMillisMin).changes @@ -136,7 +136,7 @@ export default function cleanupDatabase(user: User): { .prepare( `delete from WorkOrderTypes where recordDelete_timeMillis <= ? - and workOrderTypeId not in (select workOrderTypeId from WorkOrders)` + and workOrderTypeId not in (select workOrderTypeId from WorkOrders)` ) .run(recordDeleteTimeMillisMin).changes @@ -148,10 +148,10 @@ export default function cleanupDatabase(user: User): { .prepare( `update ContractComments set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and contractId in ( - select contractId from Contracts where recordDelete_timeMillis is not null)` + and contractId in ( + select contractId from Contracts where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes @@ -167,9 +167,9 @@ export default function cleanupDatabase(user: User): { .prepare( `update ContractFields set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and contractId in (select contractId from Contracts where recordDelete_timeMillis is not null)` + and contractId in (select contractId from Contracts where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes @@ -179,7 +179,7 @@ export default function cleanupDatabase(user: User): { /* * Burial Site Contract Fees/Transactions - * - Maintain financials, do not delete related. + * - Maintain financial data, do not delete related. */ purgedRecordCount += database @@ -200,12 +200,12 @@ export default function cleanupDatabase(user: User): { .prepare( `delete from Contracts where recordDelete_timeMillis <= ? - and contractId not in (select contractId from ContractComments) - and contractId not in (select contractId from ContractFees) - and contractId not in (select contractId from ContractFields) - and contractId not in (select contractId from ContractInterments) - and contractId not in (select contractId from ContractTransactions) - and contractId not in (select contractId from WorkOrderContracts)` + and contractId not in (select contractId from ContractComments) + and contractId not in (select contractId from ContractFees) + and contractId not in (select contractId from ContractFields) + and contractId not in (select contractId from ContractInterments) + and contractId not in (select contractId from ContractTransactions) + and contractId not in (select contractId from WorkOrderContracts)` ) .run(recordDeleteTimeMillisMin).changes @@ -217,9 +217,9 @@ export default function cleanupDatabase(user: User): { .prepare( `update Fees set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and feeCategoryId in (select feeCategoryId from FeeCategories where recordDelete_timeMillis is not null)` + and feeCategoryId in (select feeCategoryId from FeeCategories where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes @@ -227,7 +227,7 @@ export default function cleanupDatabase(user: User): { .prepare( `delete from Fees where recordDelete_timeMillis <= ? - and feeId not in (select feeId from ContractFees)` + and feeId not in (select feeId from ContractFees)` ) .run(recordDeleteTimeMillisMin).changes @@ -239,7 +239,7 @@ export default function cleanupDatabase(user: User): { .prepare( `delete from FeeCategories where recordDelete_timeMillis <= ? - and feeCategoryId not in (select feeCategoryId from Fees)` + and feeCategoryId not in (select feeCategoryId from Fees)` ) .run(recordDeleteTimeMillisMin).changes @@ -251,9 +251,9 @@ export default function cleanupDatabase(user: User): { .prepare( `update ContractTypeFields set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)` + and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes @@ -261,7 +261,7 @@ export default function cleanupDatabase(user: User): { .prepare( `delete from ContractTypeFields where recordDelete_timeMillis <= ? - and contractTypeFieldId not in (select contractTypeFieldId from ContractFields)` + and contractTypeFieldId not in (select contractTypeFieldId from ContractFields)` ) .run(recordDeleteTimeMillisMin).changes @@ -273,9 +273,9 @@ export default function cleanupDatabase(user: User): { .prepare( `update ContractTypePrints set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)` + and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes @@ -293,10 +293,10 @@ export default function cleanupDatabase(user: User): { .prepare( `delete from ContractTypes where recordDelete_timeMillis <= ? - and contractTypeId not in (select contractTypeId from ContractTypeFields) - and contractTypeId not in (select contractTypeId from ContractTypePrints) - and contractTypeId not in (select contractTypeId from Contracts) - and contractTypeId not in (select contractTypeId from Fees)` + and contractTypeId not in (select contractTypeId from ContractTypeFields) + and contractTypeId not in (select contractTypeId from ContractTypePrints) + and contractTypeId not in (select contractTypeId from Contracts) + and contractTypeId not in (select contractTypeId from Fees)` ) .run(recordDeleteTimeMillisMin).changes @@ -308,9 +308,9 @@ export default function cleanupDatabase(user: User): { .prepare( `update BurialSiteComments set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)` + and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes @@ -328,9 +328,9 @@ export default function cleanupDatabase(user: User): { .prepare( `update BurialSiteFields set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)` + and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes @@ -346,9 +346,9 @@ export default function cleanupDatabase(user: User): { .prepare( `update BurialSites set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and cemeteryId in (select cemeteryId from Cemeteries where recordDelete_timeMillis is not null)` + and cemeteryId in (select cemeteryId from Cemeteries where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes @@ -356,10 +356,10 @@ export default function cleanupDatabase(user: User): { .prepare( `delete from BurialSites where recordDelete_timeMillis <= ? - and burialSiteId not in (select burialSiteId from BurialSiteComments) - and burialSiteId not in (select burialSiteId from BurialSiteFields) - and burialSiteId not in (select burialSiteId from Contracts) - and burialSiteId not in (select burialSiteId from WorkOrderBurialSites)` + and burialSiteId not in (select burialSiteId from BurialSiteComments) + and burialSiteId not in (select burialSiteId from BurialSiteFields) + and burialSiteId not in (select burialSiteId from Contracts) + and burialSiteId not in (select burialSiteId from WorkOrderBurialSites)` ) .run(recordDeleteTimeMillisMin).changes @@ -371,7 +371,7 @@ export default function cleanupDatabase(user: User): { .prepare( `delete from BurialSiteStatuses where recordDelete_timeMillis <= ? - and burialSiteStatusId not in (select burialSiteStatusId from BurialSites)` + and burialSiteStatusId not in (select burialSiteStatusId from BurialSites)` ) .run(recordDeleteTimeMillisMin).changes @@ -383,9 +383,9 @@ export default function cleanupDatabase(user: User): { .prepare( `update BurialSiteTypeFields set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteTypeId in (select burialSiteTypeId from BurialSiteTypes where recordDelete_timeMillis is not null)` + and burialSiteTypeId in (select burialSiteTypeId from BurialSiteTypes where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes @@ -393,7 +393,7 @@ export default function cleanupDatabase(user: User): { .prepare( `delete from BurialSiteTypeFields where recordDelete_timeMillis <= ? - and burialSiteTypeFieldId not in (select burialSiteTypeFieldId from BurialSiteFields)` + and burialSiteTypeFieldId not in (select burialSiteTypeFieldId from BurialSiteFields)` ) .run(recordDeleteTimeMillisMin).changes @@ -405,7 +405,7 @@ export default function cleanupDatabase(user: User): { .prepare( `delete from BurialSiteTypes where recordDelete_timeMillis <= ? - and burialSiteTypeId not in (select burialSiteTypeId from BurialSites)` + and burialSiteTypeId not in (select burialSiteTypeId from BurialSites)` ) .run(recordDeleteTimeMillisMin).changes diff --git a/database/closeWorkOrder.d.ts b/database/closeWorkOrder.d.ts index c24f9a65..4175e903 100644 --- a/database/closeWorkOrder.d.ts +++ b/database/closeWorkOrder.d.ts @@ -1,5 +1,6 @@ +import { type DateString } from '@cityssm/utils-datetime'; export interface CloseWorkOrderForm { workOrderId: number | string; - workOrderCloseDateString?: string; + workOrderCloseDateString?: '' | DateString; } export default function closeWorkOrder(workOrderForm: CloseWorkOrderForm, user: User): boolean; diff --git a/database/closeWorkOrder.ts b/database/closeWorkOrder.ts index e1c5ceec..9ac39a7a 100644 --- a/database/closeWorkOrder.ts +++ b/database/closeWorkOrder.ts @@ -1,4 +1,8 @@ -import { dateStringToInteger, dateToInteger } from '@cityssm/utils-datetime' +import { + type DateString, + dateStringToInteger, + dateToInteger +} from '@cityssm/utils-datetime' import sqlite from 'better-sqlite3' import { sunriseDB } from '../helpers/database.helpers.js' @@ -6,7 +10,7 @@ import { sunriseDB } from '../helpers/database.helpers.js' export interface CloseWorkOrderForm { workOrderId: number | string - workOrderCloseDateString?: string + workOrderCloseDateString?: '' | DateString } export default function closeWorkOrder( diff --git a/database/copyContract.ts b/database/copyContract.ts index 49a2599d..4f94f55d 100644 --- a/database/copyContract.ts +++ b/database/copyContract.ts @@ -29,6 +29,7 @@ export default async function copyContract( funeralDirectorName: oldContract.funeralDirectorName, funeralHomeId: oldContract.funeralHomeId ?? '', funeralTimeString: oldContract.funeralTimeString ?? '', + purchaserAddress1: oldContract.purchaserAddress1, purchaserAddress2: oldContract.purchaserAddress2, purchaserCity: oldContract.purchaserCity, diff --git a/database/deleteBurialSite.js b/database/deleteBurialSite.js index dadb1016..9410c475 100644 --- a/database/deleteBurialSite.js +++ b/database/deleteBurialSite.js @@ -11,8 +11,8 @@ export function deleteBurialSite(burialSiteId, user) { .prepare(`select contractId from Contracts where burialSiteId = ? - and recordDelete_timeMillis is null - and (contractEndDate is null or contractEndDate >= ?)`) + and recordDelete_timeMillis is null + and (contractEndDate is null or contractEndDate >= ?)`) .pluck() .get(burialSiteId, currentDateInteger); if (activeContract !== undefined) { @@ -26,9 +26,9 @@ export function deleteBurialSite(burialSiteId, user) { database .prepare(`update BurialSites set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where burialSiteId = ? - and recordDelete_timeMillis is null`) + and recordDelete_timeMillis is null`) .run(user.userName, rightNowMillis, burialSiteId); /* * Delete fields and comments @@ -36,16 +36,16 @@ export function deleteBurialSite(burialSiteId, user) { database .prepare(`update BurialSiteFields set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where burialSiteId = ? - and recordDelete_timeMillis is null`) + and recordDelete_timeMillis is null`) .run(user.userName, rightNowMillis, burialSiteId); database .prepare(`update BurialSiteComments set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where burialSiteId = ? - and recordDelete_timeMillis is null`) + and recordDelete_timeMillis is null`) .run(user.userName, rightNowMillis, burialSiteId); database.close(); return true; diff --git a/database/deleteBurialSite.ts b/database/deleteBurialSite.ts index 2db7945c..95fd442c 100644 --- a/database/deleteBurialSite.ts +++ b/database/deleteBurialSite.ts @@ -17,8 +17,8 @@ export function deleteBurialSite(burialSiteId: number, user: User): boolean { `select contractId from Contracts where burialSiteId = ? - and recordDelete_timeMillis is null - and (contractEndDate is null or contractEndDate >= ?)` + and recordDelete_timeMillis is null + and (contractEndDate is null or contractEndDate >= ?)` ) .pluck() .get(burialSiteId, currentDateInteger) as number | undefined @@ -38,9 +38,9 @@ export function deleteBurialSite(burialSiteId: number, user: User): boolean { .prepare( `update BurialSites set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where burialSiteId = ? - and recordDelete_timeMillis is null` + and recordDelete_timeMillis is null` ) .run(user.userName, rightNowMillis, burialSiteId) @@ -52,9 +52,9 @@ export function deleteBurialSite(burialSiteId: number, user: User): boolean { .prepare( `update BurialSiteFields set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where burialSiteId = ? - and recordDelete_timeMillis is null` + and recordDelete_timeMillis is null` ) .run(user.userName, rightNowMillis, burialSiteId) @@ -62,9 +62,9 @@ export function deleteBurialSite(burialSiteId: number, user: User): boolean { .prepare( `update BurialSiteComments set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where burialSiteId = ? - and recordDelete_timeMillis is null` + and recordDelete_timeMillis is null` ) .run(user.userName, rightNowMillis, burialSiteId) diff --git a/database/deleteBurialSiteField.js b/database/deleteBurialSiteField.js index 39e8bc84..9424d6c0 100644 --- a/database/deleteBurialSiteField.js +++ b/database/deleteBurialSiteField.js @@ -5,9 +5,9 @@ export default function deleteBurialSiteField(burialSiteId, burialSiteTypeFieldI const result = database .prepare(`update BurialSiteFields set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where burialSiteId = ? - and burialSiteTypeFieldId = ?`) + and burialSiteTypeFieldId = ?`) .run(user.userName, Date.now(), burialSiteId, burialSiteTypeFieldId); if (connectedDatabase === undefined) { database.close(); diff --git a/database/deleteBurialSiteField.ts b/database/deleteBurialSiteField.ts index 0f9edbb7..15fd8e14 100644 --- a/database/deleteBurialSiteField.ts +++ b/database/deleteBurialSiteField.ts @@ -14,9 +14,9 @@ export default function deleteBurialSiteField( .prepare( `update BurialSiteFields set recordDelete_userName = ?, - recordDelete_timeMillis = ? + recordDelete_timeMillis = ? where burialSiteId = ? - and burialSiteTypeFieldId = ?` + and burialSiteTypeFieldId = ?` ) .run(user.userName, Date.now(), burialSiteId, burialSiteTypeFieldId) diff --git a/database/getBurialSites.d.ts b/database/getBurialSites.d.ts index 89996879..50678a86 100644 --- a/database/getBurialSites.d.ts +++ b/database/getBurialSites.d.ts @@ -16,6 +16,6 @@ export interface GetBurialSitesOptions { includeContractCount?: boolean; } export default function getBurialSites(filters: GetBurialSitesFilters, options: GetBurialSitesOptions, connectedDatabase?: sqlite.Database): { - count: number; burialSites: BurialSite[]; + count: number; }; diff --git a/database/getBurialSites.js b/database/getBurialSites.js index 285bf673..c7d47486 100644 --- a/database/getBurialSites.js +++ b/database/getBurialSites.js @@ -4,7 +4,7 @@ import { sunriseDB } from '../helpers/database.helpers.js'; import { getBurialSiteNameWhereClause } from '../helpers/functions.sqlFilters.js'; export default function getBurialSites(filters, options, connectedDatabase) { const database = connectedDatabase ?? sqlite(sunriseDB, { readonly: true }); - const { sqlWhereClause, sqlParameters } = buildWhereClause(filters); + const { sqlParameters, sqlWhereClause } = buildWhereClause(filters); const currentDate = dateToInteger(new Date()); let count = 0; if (options.limit !== -1) { @@ -71,8 +71,8 @@ export default function getBurialSites(filters, options, connectedDatabase) { database.close(); } return { - count, - burialSites + burialSites, + count }; } function buildWhereClause(filters) { diff --git a/database/getBurialSites.ts b/database/getBurialSites.ts index d448e74a..ef64192b 100644 --- a/database/getBurialSites.ts +++ b/database/getBurialSites.ts @@ -28,10 +28,10 @@ export default function getBurialSites( filters: GetBurialSitesFilters, options: GetBurialSitesOptions, connectedDatabase?: sqlite.Database -): { count: number; burialSites: BurialSite[] } { +): { burialSites: BurialSite[]; count: number } { const database = connectedDatabase ?? sqlite(sunriseDB, { readonly: true }) - const { sqlWhereClause, sqlParameters } = buildWhereClause(filters) + const { sqlParameters, sqlWhereClause } = buildWhereClause(filters) const currentDate = dateToInteger(new Date()) @@ -120,8 +120,8 @@ export default function getBurialSites( } return { - count, - burialSites + burialSites, + count } } diff --git a/temp/legacyImportFromCsv/index.js b/temp/legacyImportFromCsv/index.js index d546caec..2189ab4c 100644 --- a/temp/legacyImportFromCsv/index.js +++ b/temp/legacyImportFromCsv/index.js @@ -603,8 +603,8 @@ async function importFromWorkOrderCSV() { const workOrderContainsBurialSite = workOrder?.workOrderBurialSites?.find((possibleLot) => possibleLot.burialSiteId === burialSite?.burialSiteId); if (!workOrderContainsBurialSite) { addWorkOrderBurialSite({ - workOrderId: workOrder?.workOrderId, - burialSiteId: burialSite?.burialSiteId + burialSiteId: burialSite?.burialSiteId, + workOrderId: workOrder?.workOrderId }, user); workOrder?.workOrderBurialSites?.push(burialSite); } @@ -633,8 +633,8 @@ async function importFromWorkOrderCSV() { const contractId = addContract({ burialSiteId: burialSite ? burialSite.burialSiteId : '', contractTypeId: contractType.contractTypeId, - contractStartDateString, contractEndDateString: '', + contractStartDateString, funeralHomeId, funeralDirectorName: workOrderRow.WO_FUNERAL_HOME, funeralDateString: workOrderRow.WO_FUNERAL_YR === '' @@ -656,8 +656,8 @@ async function importFromWorkOrderCSV() { intermentContainerTypeId }, user); addWorkOrderContract({ - workOrderId: workOrder?.workOrderId, - contractId + contractId, + workOrderId: workOrder?.workOrderId }, user); // Milestones let hasIncompleteMilestones = !workOrderRow.WO_CONFIRMATION_IN; diff --git a/temp/legacyImportFromCsv/index.ts b/temp/legacyImportFromCsv/index.ts index f76cae0c..a4ef225f 100644 --- a/temp/legacyImportFromCsv/index.ts +++ b/temp/legacyImportFromCsv/index.ts @@ -959,8 +959,8 @@ async function importFromWorkOrderCSV(): Promise { if (!workOrderContainsBurialSite) { addWorkOrderBurialSite( { - workOrderId: workOrder?.workOrderId as number, - burialSiteId: burialSite?.burialSiteId as number + burialSiteId: burialSite?.burialSiteId as number, + workOrderId: workOrder?.workOrderId as number }, user ) @@ -1011,8 +1011,9 @@ async function importFromWorkOrderCSV(): Promise { { burialSiteId: burialSite ? burialSite.burialSiteId : '', contractTypeId: contractType.contractTypeId, - contractStartDateString, + contractEndDateString: '', + contractStartDateString, funeralHomeId, funeralDirectorName: workOrderRow.WO_FUNERAL_HOME, @@ -1052,8 +1053,8 @@ async function importFromWorkOrderCSV(): Promise { addWorkOrderContract( { - workOrderId: workOrder?.workOrderId as number, - contractId + contractId, + workOrderId: workOrder?.workOrderId as number }, user )