linting
parent
a7ce5a99cb
commit
c460d073e7
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
export interface AddForm {
|
||||
funeralHomeName: string;
|
||||
funeralHomeKey: string;
|
||||
funeralHomeName: string;
|
||||
funeralHomeAddress1: string;
|
||||
funeralHomeAddress2: string;
|
||||
funeralHomeCity: string;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export interface AddWorkOrderCommentForm {
|
||||
workOrderId: string;
|
||||
comment: string;
|
||||
workOrderId: string;
|
||||
}
|
||||
export default function addWorkOrderComment(workOrderCommentForm: AddWorkOrderCommentForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -959,8 +959,8 @@ async function importFromWorkOrderCSV(): Promise<void> {
|
|||
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<void> {
|
|||
{
|
||||
burialSiteId: burialSite ? burialSite.burialSiteId : '',
|
||||
contractTypeId: contractType.contractTypeId,
|
||||
contractStartDateString,
|
||||
|
||||
contractEndDateString: '',
|
||||
contractStartDateString,
|
||||
|
||||
funeralHomeId,
|
||||
funeralDirectorName: workOrderRow.WO_FUNERAL_HOME,
|
||||
|
|
@ -1052,8 +1053,8 @@ async function importFromWorkOrderCSV(): Promise<void> {
|
|||
|
||||
addWorkOrderContract(
|
||||
{
|
||||
workOrderId: workOrder?.workOrderId as number,
|
||||
contractId
|
||||
contractId,
|
||||
workOrderId: workOrder?.workOrderId as number
|
||||
},
|
||||
user
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue