Compare commits
No commits in common. "main" and "v1.0.0-alpha.9" have entirely different histories.
main
...
v1.0.0-alp
|
|
@ -1,2 +1,2 @@
|
|||
theme: jekyll-theme-cayman
|
||||
title: Sunrise Cemetery Management System (CMS)
|
||||
title: Sunrise Cemetery Management System
|
||||
|
|
@ -12,7 +12,7 @@ import { getConfigProperty } from '../helpers/config.helpers.js';
|
|||
import version from '../version.js';
|
||||
const debug = Debug(`${DEBUG_NAMESPACE}:www:${process.pid}`);
|
||||
// INITIALIZE THE DATABASE
|
||||
initializeDatabase();
|
||||
await initializeDatabase();
|
||||
const directoryName = path.dirname(fileURLToPath(import.meta.url));
|
||||
const processCount = Math.min(getConfigProperty('application.maximumProcesses'), os.cpus().length * 2);
|
||||
const applicationName = getConfigProperty('application.applicationName');
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import version from '../version.js'
|
|||
const debug = Debug(`${DEBUG_NAMESPACE}:www:${process.pid}`)
|
||||
|
||||
// INITIALIZE THE DATABASE
|
||||
initializeDatabase()
|
||||
await initializeDatabase()
|
||||
|
||||
const directoryName = path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { getConfigProperty } from '../helpers/config.helpers.js';
|
|||
const debug = Debug(`${DEBUG_NAMESPACE}:wwwProcess:${process.pid.toString().padEnd(5)}`);
|
||||
if (process.send === undefined) {
|
||||
// INITIALIZE THE DATABASE
|
||||
initializeDatabase();
|
||||
await initializeDatabase();
|
||||
}
|
||||
function onError(error) {
|
||||
if (error.syscall !== 'listen') {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ const debug = Debug(`${DEBUG_NAMESPACE}:wwwProcess:${process.pid.toString().padE
|
|||
|
||||
if (process.send === undefined) {
|
||||
// INITIALIZE THE DATABASE
|
||||
initializeDatabase()
|
||||
await initializeDatabase()
|
||||
}
|
||||
|
||||
interface ServerError extends Error {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ export const config = {
|
|||
settings: {
|
||||
adminCleanup: {},
|
||||
burialSites: {},
|
||||
burialSiteTypes: {},
|
||||
cemeteries: {},
|
||||
contracts: {},
|
||||
dynamicsGP: {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ export const config: Config = {
|
|||
settings: {
|
||||
adminCleanup: {},
|
||||
burialSites: {},
|
||||
burialSiteTypes: {},
|
||||
cemeteries: {},
|
||||
contracts: {},
|
||||
dynamicsGP: {
|
||||
|
|
|
|||
|
|
@ -33,8 +33,6 @@ export declare const configDefaultValues: {
|
|||
'settings.longitudeMax': number;
|
||||
'settings.longitudeMin': number;
|
||||
'settings.cemeteries.refreshImageChanges': boolean;
|
||||
'settings.burialSiteTypes.bodyCapacityMaxDefault': number;
|
||||
'settings.burialSiteTypes.crematedCapacityMaxDefault': number;
|
||||
'settings.burialSites.burialSiteNameSegments': ConfigBurialSiteNameSegments;
|
||||
'settings.burialSites.burialSiteNameSegments.includeCemeteryKey': boolean;
|
||||
'settings.burialSites.refreshImageChanges': boolean;
|
||||
|
|
|
|||
|
|
@ -32,10 +32,6 @@ export const configDefaultValues = {
|
|||
'settings.longitudeMax': 180,
|
||||
'settings.longitudeMin': -180,
|
||||
'settings.cemeteries.refreshImageChanges': false,
|
||||
// eslint-disable-next-line no-secrets/no-secrets
|
||||
'settings.burialSiteTypes.bodyCapacityMaxDefault': 2,
|
||||
// eslint-disable-next-line no-secrets/no-secrets
|
||||
'settings.burialSiteTypes.crematedCapacityMaxDefault': 6,
|
||||
'settings.burialSites.burialSiteNameSegments': {
|
||||
includeCemeteryKey: false,
|
||||
separator: '-',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { hoursToMillis } from '@cityssm/to-millis'
|
||||
import type { config as MSSQLConfig } from 'mssql'
|
||||
|
||||
import { hoursToMillis } from '@cityssm/to-millis'
|
||||
|
||||
import type {
|
||||
ConfigActiveDirectory,
|
||||
ConfigBurialSiteNameSegments,
|
||||
|
|
@ -51,12 +52,6 @@ export const configDefaultValues = {
|
|||
|
||||
'settings.cemeteries.refreshImageChanges': false,
|
||||
|
||||
// eslint-disable-next-line no-secrets/no-secrets
|
||||
'settings.burialSiteTypes.bodyCapacityMaxDefault': 2,
|
||||
|
||||
// eslint-disable-next-line no-secrets/no-secrets
|
||||
'settings.burialSiteTypes.crematedCapacityMaxDefault': 6,
|
||||
|
||||
'settings.burialSites.burialSiteNameSegments': {
|
||||
includeCemeteryKey: false,
|
||||
separator: '-',
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ export interface AddBurialSiteForm {
|
|||
burialSiteNameSegment5?: string;
|
||||
burialSiteStatusId: number | string;
|
||||
burialSiteTypeId: number | string;
|
||||
bodyCapacity?: number | string;
|
||||
crematedCapacity?: number | string;
|
||||
burialSiteImage?: string;
|
||||
cemeteryId: number | string;
|
||||
cemeterySvgId?: string;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import getCemetery from './getCemetery.js';
|
|||
* @returns The new burial site's id.
|
||||
* @throws If an active burial site with the same name already exists.
|
||||
*/
|
||||
// eslint-disable-next-line complexity
|
||||
export default function addBurialSite(burialSiteForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
|
|
@ -39,22 +38,17 @@ export default function addBurialSite(burialSiteForm, user) {
|
|||
burialSiteNameSegment5,
|
||||
burialSiteName,
|
||||
burialSiteTypeId, burialSiteStatusId,
|
||||
bodyCapacity, crematedCapacity,
|
||||
cemeteryId, cemeterySvgId, burialSiteImage,
|
||||
burialSiteLatitude, burialSiteLongitude,
|
||||
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?,
|
||||
values (?, ?, ?,
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?)`)
|
||||
.run(burialSiteForm.burialSiteNameSegment1 ?? '', burialSiteForm.burialSiteNameSegment2 ?? '', burialSiteForm.burialSiteNameSegment3 ?? '', burialSiteForm.burialSiteNameSegment4 ?? '', burialSiteForm.burialSiteNameSegment5 ?? '', burialSiteName, burialSiteForm.burialSiteTypeId, burialSiteForm.burialSiteStatusId === ''
|
||||
? undefined
|
||||
: burialSiteForm.burialSiteStatusId, burialSiteForm.bodyCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.bodyCapacity, burialSiteForm.crematedCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.crematedCapacity, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteImage ?? '', burialSiteForm.burialSiteLatitude === ''
|
||||
: burialSiteForm.burialSiteStatusId, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteImage ?? '', burialSiteForm.burialSiteLatitude === ''
|
||||
? undefined
|
||||
: burialSiteForm.burialSiteLatitude, burialSiteForm.burialSiteLongitude === ''
|
||||
? undefined
|
||||
|
|
|
|||
|
|
@ -16,9 +16,6 @@ export interface AddBurialSiteForm {
|
|||
burialSiteStatusId: number | string
|
||||
burialSiteTypeId: number | string
|
||||
|
||||
bodyCapacity?: number | string
|
||||
crematedCapacity?: number | string
|
||||
|
||||
burialSiteImage?: string
|
||||
cemeteryId: number | string
|
||||
cemeterySvgId?: string
|
||||
|
|
@ -38,7 +35,6 @@ export interface AddBurialSiteForm {
|
|||
* @returns The new burial site's id.
|
||||
* @throws If an active burial site with the same name already exists.
|
||||
*/
|
||||
// eslint-disable-next-line complexity
|
||||
export default function addBurialSite(
|
||||
burialSiteForm: AddBurialSiteForm,
|
||||
user: User
|
||||
|
|
@ -84,13 +80,12 @@ export default function addBurialSite(
|
|||
burialSiteNameSegment5,
|
||||
burialSiteName,
|
||||
burialSiteTypeId, burialSiteStatusId,
|
||||
bodyCapacity, crematedCapacity,
|
||||
cemeteryId, cemeterySvgId, burialSiteImage,
|
||||
burialSiteLatitude, burialSiteLongitude,
|
||||
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?,
|
||||
values (?, ?, ?,
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?)`
|
||||
)
|
||||
|
|
@ -105,15 +100,6 @@ export default function addBurialSite(
|
|||
burialSiteForm.burialSiteStatusId === ''
|
||||
? undefined
|
||||
: burialSiteForm.burialSiteStatusId,
|
||||
|
||||
burialSiteForm.bodyCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.bodyCapacity,
|
||||
|
||||
burialSiteForm.crematedCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.crematedCapacity,
|
||||
|
||||
burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId,
|
||||
burialSiteForm.cemeterySvgId,
|
||||
burialSiteForm.burialSiteImage ?? '',
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
export interface AddBurialSiteTypeForm {
|
||||
burialSiteType: string;
|
||||
bodyCapacityMax: number | string;
|
||||
crematedCapacityMax: number | string;
|
||||
orderNumber?: number | string;
|
||||
}
|
||||
export default function addBurialSiteType(addForm: AddBurialSiteTypeForm, user: User): number;
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
export default function addBurialSiteType(addForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare(`insert into BurialSiteTypes (
|
||||
burialSiteType, bodyCapacityMax, crematedCapacityMax,
|
||||
orderNumber,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.burialSiteType, addForm.bodyCapacityMax === '' ? undefined : addForm.bodyCapacityMax, addForm.crematedCapacityMax === ''
|
||||
? undefined
|
||||
: addForm.crematedCapacityMax, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.close();
|
||||
clearCacheByTableName('BurialSiteTypes');
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
|
||||
export interface AddBurialSiteTypeForm {
|
||||
burialSiteType: string
|
||||
|
||||
bodyCapacityMax: number | string
|
||||
crematedCapacityMax: number | string
|
||||
|
||||
orderNumber?: number | string
|
||||
}
|
||||
|
||||
export default function addBurialSiteType(
|
||||
addForm: AddBurialSiteTypeForm,
|
||||
user: User
|
||||
): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
const result = database
|
||||
.prepare(
|
||||
`insert into BurialSiteTypes (
|
||||
burialSiteType, bodyCapacityMax, crematedCapacityMax,
|
||||
orderNumber,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
)
|
||||
.run(
|
||||
addForm.burialSiteType,
|
||||
addForm.bodyCapacityMax === '' ? undefined : addForm.bodyCapacityMax,
|
||||
addForm.crematedCapacityMax === ''
|
||||
? undefined
|
||||
: addForm.crematedCapacityMax,
|
||||
addForm.orderNumber ?? -1,
|
||||
user.userName,
|
||||
rightNowMillis,
|
||||
user.userName,
|
||||
rightNowMillis
|
||||
)
|
||||
|
||||
database.close()
|
||||
|
||||
clearCacheByTableName('BurialSiteTypes')
|
||||
|
||||
return result.lastInsertRowid as number
|
||||
}
|
||||
|
|
@ -14,9 +14,7 @@ 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,
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
||||
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, 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,7 +47,6 @@ 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,8 +1,7 @@
|
|||
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
||||
export interface AddTransactionForm {
|
||||
contractId: number | string;
|
||||
transactionDateString?: '' | DateString;
|
||||
transactionTimeString?: '' | TimeString;
|
||||
transactionDateString?: string;
|
||||
transactionTimeString?: string;
|
||||
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 ?? '') === ''
|
||||
? dateToInteger(rightNow)
|
||||
: dateStringToInteger(contractTransactionForm.transactionDateString);
|
||||
const transactionTime = (contractTransactionForm.transactionTimeString ?? '') === ''
|
||||
? dateToTimeInteger(rightNow)
|
||||
: timeStringToInteger(contractTransactionForm.transactionTimeString);
|
||||
const transactionDate = contractTransactionForm.transactionDateString
|
||||
? dateStringToInteger(contractTransactionForm.transactionDateString)
|
||||
: dateToInteger(rightNow);
|
||||
const transactionTime = contractTransactionForm.transactionTimeString
|
||||
? timeStringToInteger(contractTransactionForm.transactionTimeString)
|
||||
: dateToTimeInteger(rightNow);
|
||||
database
|
||||
.prepare(`insert into ContractTransactions (
|
||||
contractId, transactionIndex,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import {
|
||||
type DateString,
|
||||
type TimeString,
|
||||
dateStringToInteger,
|
||||
dateToInteger,
|
||||
dateToTimeInteger,
|
||||
|
|
@ -13,8 +11,8 @@ import { sunriseDB } from '../helpers/database.helpers.js'
|
|||
export interface AddTransactionForm {
|
||||
contractId: number | string
|
||||
|
||||
transactionDateString?: '' | DateString
|
||||
transactionTimeString?: '' | TimeString
|
||||
transactionDateString?: string
|
||||
transactionTimeString?: string
|
||||
|
||||
externalReceiptNumber: string
|
||||
transactionAmount: number | string
|
||||
|
|
@ -47,19 +45,13 @@ export default function addContractTransaction(
|
|||
|
||||
const rightNow = new Date()
|
||||
|
||||
const transactionDate =
|
||||
(contractTransactionForm.transactionDateString ?? '') === ''
|
||||
? dateToInteger(rightNow)
|
||||
: dateStringToInteger(
|
||||
contractTransactionForm.transactionDateString as DateString
|
||||
)
|
||||
const transactionDate = contractTransactionForm.transactionDateString
|
||||
? dateStringToInteger(contractTransactionForm.transactionDateString)
|
||||
: dateToInteger(rightNow)
|
||||
|
||||
const transactionTime =
|
||||
(contractTransactionForm.transactionTimeString ?? '') === ''
|
||||
? dateToTimeInteger(rightNow)
|
||||
: timeStringToInteger(
|
||||
contractTransactionForm.transactionTimeString as TimeString
|
||||
)
|
||||
const transactionTime = contractTransactionForm.transactionTimeString
|
||||
? timeStringToInteger(contractTransactionForm.transactionTimeString)
|
||||
: dateToTimeInteger(rightNow)
|
||||
|
||||
database
|
||||
.prepare(
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
export interface AddContractTypeFieldForm {
|
||||
contractTypeId?: number | string;
|
||||
contractTypeField: string;
|
||||
fieldType?: string;
|
||||
fieldValues?: string;
|
||||
fieldType?: string;
|
||||
isRequired?: string;
|
||||
maxLength?: number | string;
|
||||
minLength?: number | string;
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@ 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,
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
||||
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, addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.close();
|
||||
clearCacheByTableName('ContractTypeFields');
|
||||
return result.lastInsertRowid;
|
||||
|
|
|
|||
|
|
@ -5,11 +5,9 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
|||
|
||||
export interface AddContractTypeFieldForm {
|
||||
contractTypeId?: number | string
|
||||
|
||||
contractTypeField: string
|
||||
|
||||
fieldType?: string
|
||||
fieldValues?: string
|
||||
fieldType?: string
|
||||
isRequired?: string
|
||||
maxLength?: number | string
|
||||
minLength?: number | string
|
||||
|
|
@ -45,7 +43,6 @@ 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,7 +6,6 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
|||
export interface AddContractTypePrintForm {
|
||||
contractTypeId: number | string
|
||||
printEJS: string
|
||||
|
||||
orderNumber?: number
|
||||
}
|
||||
|
||||
|
|
@ -22,11 +21,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 {
|
||||
funeralHomeKey: string;
|
||||
funeralHomeName: string;
|
||||
funeralHomeKey: 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 {
|
||||
funeralHomeKey: string
|
||||
funeralHomeName: string
|
||||
funeralHomeKey: 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,3 +1,3 @@
|
|||
type RecordTable = 'BurialSiteStatuses' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes';
|
||||
type RecordTable = 'BurialSiteStatuses' | 'BurialSiteTypes' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes';
|
||||
export default function addRecord(recordTable: RecordTable, recordName: string, orderNumber: number | string, user: User): number;
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { sunriseDB } from '../helpers/database.helpers.js';
|
|||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
const recordNameColumns = new Map([
|
||||
['BurialSiteStatuses', 'burialSiteStatus'],
|
||||
['BurialSiteTypes', 'burialSiteType'],
|
||||
['WorkOrderMilestoneTypes', 'workOrderMilestoneType'],
|
||||
['WorkOrderTypes', 'workOrderType']
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -5,11 +5,13 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
|||
|
||||
type RecordTable =
|
||||
| 'BurialSiteStatuses'
|
||||
| 'BurialSiteTypes'
|
||||
| 'WorkOrderMilestoneTypes'
|
||||
| 'WorkOrderTypes'
|
||||
|
||||
const recordNameColumns = new Map<RecordTable, string>([
|
||||
['BurialSiteStatuses', 'burialSiteStatus'],
|
||||
['BurialSiteTypes', 'burialSiteType'],
|
||||
['WorkOrderMilestoneTypes', 'workOrderMilestoneType'],
|
||||
['WorkOrderTypes', 'workOrderType']
|
||||
])
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
export interface AddWorkOrderForm {
|
||||
workOrderDescription: string;
|
||||
workOrderNumber?: string;
|
||||
workOrderTypeId: number | string;
|
||||
workOrderCloseDateString?: string;
|
||||
workOrderNumber?: string;
|
||||
workOrderDescription: string;
|
||||
workOrderOpenDateString?: string;
|
||||
workOrderCloseDateString?: 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,14 +11,11 @@ import addWorkOrderContract from './addWorkOrderContract.js'
|
|||
import getNextWorkOrderNumber from './getNextWorkOrderNumber.js'
|
||||
|
||||
export interface AddWorkOrderForm {
|
||||
workOrderDescription: string
|
||||
workOrderNumber?: string
|
||||
|
||||
workOrderTypeId: number | string
|
||||
|
||||
workOrderCloseDateString?: string
|
||||
workOrderNumber?: string
|
||||
workOrderDescription: string
|
||||
workOrderOpenDateString?: string
|
||||
|
||||
workOrderCloseDateString?: string
|
||||
contractId?: string
|
||||
}
|
||||
|
||||
|
|
@ -70,8 +67,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 {
|
||||
burialSiteId: number | string;
|
||||
workOrderId: number | string;
|
||||
burialSiteId: 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 {
|
||||
burialSiteId: number | string
|
||||
workOrderId: number | string
|
||||
burialSiteId: number | string
|
||||
}
|
||||
|
||||
export default function addWorkOrderBurialSite(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export interface AddWorkOrderCommentForm {
|
||||
comment: string;
|
||||
workOrderId: string;
|
||||
comment: 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 {
|
||||
comment: string
|
||||
workOrderId: string
|
||||
comment: string
|
||||
}
|
||||
|
||||
export default function addWorkOrderComment(
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
||||
export interface AddWorkOrderMilestoneForm {
|
||||
workOrderId: number | string;
|
||||
workOrderMilestoneTypeId: number | string;
|
||||
workOrderMilestoneDateString: '' | DateString;
|
||||
workOrderMilestoneTimeString?: '' | TimeString;
|
||||
workOrderMilestoneDateString: string;
|
||||
workOrderMilestoneTimeString?: string;
|
||||
workOrderMilestoneDescription: string;
|
||||
workOrderMilestoneCompletionDateString?: '' | DateString;
|
||||
workOrderMilestoneCompletionTimeString?: '' | TimeString;
|
||||
workOrderMilestoneCompletionDateString?: string;
|
||||
workOrderMilestoneCompletionTimeString?: string;
|
||||
}
|
||||
export default function addWorkOrderMilestone(milestoneForm: AddWorkOrderMilestoneForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import {
|
||||
type DateString,
|
||||
type TimeString,
|
||||
dateStringToInteger,
|
||||
timeStringToInteger
|
||||
} from '@cityssm/utils-datetime'
|
||||
|
|
@ -12,13 +10,13 @@ export interface AddWorkOrderMilestoneForm {
|
|||
workOrderId: number | string
|
||||
workOrderMilestoneTypeId: number | string
|
||||
|
||||
workOrderMilestoneDateString: '' | DateString
|
||||
workOrderMilestoneTimeString?: '' | TimeString
|
||||
workOrderMilestoneDateString: string
|
||||
workOrderMilestoneTimeString?: string
|
||||
|
||||
workOrderMilestoneDescription: string
|
||||
|
||||
workOrderMilestoneCompletionDateString?: '' | DateString
|
||||
workOrderMilestoneCompletionTimeString?: '' | TimeString
|
||||
workOrderMilestoneCompletionDateString?: string
|
||||
workOrderMilestoneCompletionTimeString?: string
|
||||
}
|
||||
|
||||
export default function addWorkOrderMilestone(
|
||||
|
|
@ -50,19 +48,17 @@ export default function addWorkOrderMilestone(
|
|||
: dateStringToInteger(milestoneForm.workOrderMilestoneDateString),
|
||||
(milestoneForm.workOrderMilestoneTimeString ?? '') === ''
|
||||
? 0
|
||||
: timeStringToInteger(
|
||||
milestoneForm.workOrderMilestoneTimeString as TimeString
|
||||
),
|
||||
: timeStringToInteger(milestoneForm.workOrderMilestoneTimeString!),
|
||||
milestoneForm.workOrderMilestoneDescription,
|
||||
(milestoneForm.workOrderMilestoneCompletionDateString ?? '') === ''
|
||||
? undefined
|
||||
: dateStringToInteger(
|
||||
milestoneForm.workOrderMilestoneCompletionDateString as DateString
|
||||
milestoneForm.workOrderMilestoneCompletionDateString!
|
||||
),
|
||||
(milestoneForm.workOrderMilestoneCompletionTimeString ?? '') === ''
|
||||
? undefined
|
||||
: timeStringToInteger(
|
||||
milestoneForm.workOrderMilestoneCompletionTimeString as TimeString
|
||||
milestoneForm.workOrderMilestoneCompletionTimeString!
|
||||
),
|
||||
user.userName,
|
||||
rightNowMillis,
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
export declare function backupDatabase(): Promise<false | string>;
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import Debug from 'debug';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
const debug = Debug('sunrise:database:backupDatabase');
|
||||
const backupFolder = 'data/backups';
|
||||
export async function backupDatabase() {
|
||||
const databasePathSplit = sunriseDB.split(/[/\\]/);
|
||||
const backupDatabasePath = `${backupFolder}/${databasePathSplit.at(-1)}.${Date.now().toString()}`;
|
||||
const database = sqlite(sunriseDB);
|
||||
try {
|
||||
const result = await database.backup(backupDatabasePath);
|
||||
if (result.remainingPages === 0) {
|
||||
debug('Database backup completed successfully:', backupDatabasePath);
|
||||
return backupDatabasePath;
|
||||
}
|
||||
else {
|
||||
debug('Database backup incomplete:', result.remainingPages, 'pages remaining');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
debug('Error backing up database:', error);
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
database.close();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
import Debug from 'debug'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
const debug = Debug('sunrise:database:backupDatabase')
|
||||
|
||||
const backupFolder = 'data/backups'
|
||||
|
||||
export async function backupDatabase(): Promise<false | string> {
|
||||
const databasePathSplit = sunriseDB.split(/[/\\]/)
|
||||
|
||||
const backupDatabasePath = `${backupFolder}/${databasePathSplit.at(-1)}.${Date.now().toString()}`
|
||||
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
try {
|
||||
const result = await database.backup(backupDatabasePath)
|
||||
|
||||
if (result.remainingPages === 0) {
|
||||
debug('Database backup completed successfully:', backupDatabasePath)
|
||||
return backupDatabasePath
|
||||
} else {
|
||||
debug(
|
||||
'Database backup incomplete:',
|
||||
result.remainingPages,
|
||||
'pages remaining'
|
||||
)
|
||||
return false
|
||||
}
|
||||
} catch (error) {
|
||||
debug('Error backing up database:', error)
|
||||
return false
|
||||
} finally {
|
||||
database.close()
|
||||
}
|
||||
}
|
||||
|
|
@ -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 financial data, do not delete related.
|
||||
* - Maintain financials, 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 financial data, do not delete related.
|
||||
* - Maintain financials, 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,6 +1,5 @@
|
|||
import { type DateString } from '@cityssm/utils-datetime';
|
||||
export interface CloseWorkOrderForm {
|
||||
workOrderId: number | string;
|
||||
workOrderCloseDateString?: '' | DateString;
|
||||
workOrderCloseDateString?: string;
|
||||
}
|
||||
export default function closeWorkOrder(workOrderForm: CloseWorkOrderForm, user: User): boolean;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
import {
|
||||
type DateString,
|
||||
dateStringToInteger,
|
||||
dateToInteger
|
||||
} from '@cityssm/utils-datetime'
|
||||
import { dateStringToInteger, dateToInteger } from '@cityssm/utils-datetime'
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
|
@ -10,7 +6,7 @@ import { sunriseDB } from '../helpers/database.helpers.js'
|
|||
export interface CloseWorkOrderForm {
|
||||
workOrderId: number | string
|
||||
|
||||
workOrderCloseDateString?: '' | DateString
|
||||
workOrderCloseDateString?: string
|
||||
}
|
||||
|
||||
export default function closeWorkOrder(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
||||
export interface CompleteWorkOrderMilestoneForm {
|
||||
workOrderMilestoneId: number | string;
|
||||
workOrderMilestoneCompletionDateString?: '' | DateString;
|
||||
workOrderMilestoneCompletionTimeString?: '' | TimeString;
|
||||
workOrderMilestoneCompletionDateString?: string;
|
||||
workOrderMilestoneCompletionTimeString?: string;
|
||||
}
|
||||
export default function completeWorkOrderMilestone(milestoneForm: CompleteWorkOrderMilestoneForm, user: User): boolean;
|
||||
|
|
|
|||
|
|
@ -4,12 +4,6 @@ import { sunriseDB } from '../helpers/database.helpers.js';
|
|||
export default function completeWorkOrderMilestone(milestoneForm, user) {
|
||||
const rightNow = new Date();
|
||||
const database = sqlite(sunriseDB);
|
||||
const completionDate = (milestoneForm.workOrderMilestoneCompletionDateString ?? '') === ''
|
||||
? dateToInteger(rightNow)
|
||||
: dateStringToInteger(milestoneForm.workOrderMilestoneCompletionDateString);
|
||||
const completionTime = (milestoneForm.workOrderMilestoneCompletionTimeString ?? '') === ''
|
||||
? dateToTimeInteger(rightNow)
|
||||
: timeStringToInteger(milestoneForm.workOrderMilestoneCompletionTimeString);
|
||||
const result = database
|
||||
.prepare(`update WorkOrderMilestones
|
||||
set workOrderMilestoneCompletionDate = ?,
|
||||
|
|
@ -17,7 +11,11 @@ export default function completeWorkOrderMilestone(milestoneForm, user) {
|
|||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where workOrderMilestoneId = ?`)
|
||||
.run(completionDate, completionTime, user.userName, rightNow.getTime(), milestoneForm.workOrderMilestoneId);
|
||||
.run((milestoneForm.workOrderMilestoneCompletionDateString ?? '') === ''
|
||||
? dateToInteger(rightNow)
|
||||
: dateStringToInteger(milestoneForm.workOrderMilestoneCompletionDateString), (milestoneForm.workOrderMilestoneCompletionTimeString ?? '') === ''
|
||||
? dateToTimeInteger(rightNow)
|
||||
: timeStringToInteger(milestoneForm.workOrderMilestoneCompletionTimeString), user.userName, rightNow.getTime(), milestoneForm.workOrderMilestoneId);
|
||||
database.close();
|
||||
return result.changes > 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import {
|
||||
type DateString,
|
||||
type TimeString,
|
||||
dateStringToInteger,
|
||||
dateToInteger,
|
||||
dateToTimeInteger,
|
||||
|
|
@ -12,9 +10,9 @@ import { sunriseDB } from '../helpers/database.helpers.js'
|
|||
|
||||
export interface CompleteWorkOrderMilestoneForm {
|
||||
workOrderMilestoneId: number | string
|
||||
|
||||
workOrderMilestoneCompletionDateString?: '' | DateString
|
||||
workOrderMilestoneCompletionTimeString?: '' | TimeString
|
||||
|
||||
workOrderMilestoneCompletionDateString?: string
|
||||
workOrderMilestoneCompletionTimeString?: string
|
||||
}
|
||||
|
||||
export default function completeWorkOrderMilestone(
|
||||
|
|
@ -25,20 +23,6 @@ export default function completeWorkOrderMilestone(
|
|||
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const completionDate =
|
||||
(milestoneForm.workOrderMilestoneCompletionDateString ?? '') === ''
|
||||
? dateToInteger(rightNow)
|
||||
: dateStringToInteger(
|
||||
milestoneForm.workOrderMilestoneCompletionDateString as DateString
|
||||
)
|
||||
|
||||
const completionTime =
|
||||
(milestoneForm.workOrderMilestoneCompletionTimeString ?? '') === ''
|
||||
? dateToTimeInteger(rightNow)
|
||||
: timeStringToInteger(
|
||||
milestoneForm.workOrderMilestoneCompletionTimeString as TimeString
|
||||
)
|
||||
|
||||
const result = database
|
||||
.prepare(
|
||||
`update WorkOrderMilestones
|
||||
|
|
@ -49,8 +33,16 @@ export default function completeWorkOrderMilestone(
|
|||
where workOrderMilestoneId = ?`
|
||||
)
|
||||
.run(
|
||||
completionDate,
|
||||
completionTime,
|
||||
(milestoneForm.workOrderMilestoneCompletionDateString ?? '') === ''
|
||||
? dateToInteger(rightNow)
|
||||
: dateStringToInteger(
|
||||
milestoneForm.workOrderMilestoneCompletionDateString!
|
||||
),
|
||||
(milestoneForm.workOrderMilestoneCompletionTimeString ?? '') === ''
|
||||
? dateToTimeInteger(rightNow)
|
||||
: timeStringToInteger(
|
||||
milestoneForm.workOrderMilestoneCompletionTimeString!
|
||||
),
|
||||
user.userName,
|
||||
rightNow.getTime(),
|
||||
milestoneForm.workOrderMilestoneId
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ 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,26 @@ 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
|
||||
*/
|
||||
database
|
||||
.prepare(`update BurialSiteFields
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
where burialSiteId = ?
|
||||
and recordDelete_timeMillis is null`)
|
||||
.run(user.userName, rightNowMillis, burialSiteId);
|
||||
database
|
||||
.prepare(`update BurialSiteComments
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
where burialSiteId = ?
|
||||
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,33 @@ 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)
|
||||
|
||||
/*
|
||||
* Delete fields and comments
|
||||
*/
|
||||
|
||||
database
|
||||
.prepare(
|
||||
`update BurialSiteFields
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
where burialSiteId = ?
|
||||
and recordDelete_timeMillis is null`
|
||||
)
|
||||
.run(user.userName, rightNowMillis, burialSiteId)
|
||||
|
||||
database
|
||||
.prepare(
|
||||
`update BurialSiteComments
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
where burialSiteId = ?
|
||||
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)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import { cacheTableNames, clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
const recordIdColumns = new Map([
|
||||
['BurialSiteComments', 'burialSiteCommentId'],
|
||||
['BurialSiteStatuses', 'burialSiteStatusId'],
|
||||
|
|
@ -55,9 +55,6 @@ export function deleteRecord(recordTable, recordId, user) {
|
|||
.run(user.userName, rightNowMillis, recordId);
|
||||
}
|
||||
database.close();
|
||||
// Clear cache for tables that are cached
|
||||
if (cacheTableNames.includes(recordTable)) {
|
||||
clearCacheByTableName(recordTable);
|
||||
}
|
||||
clearCacheByTableName(recordTable);
|
||||
return result.changes > 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
import {
|
||||
CacheTableNames,
|
||||
cacheTableNames,
|
||||
clearCacheByTableName
|
||||
} from '../helpers/functions.cache.js'
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
|
||||
type RecordTable =
|
||||
| 'BurialSiteComments'
|
||||
|
|
@ -77,7 +73,7 @@ export function deleteRecord(
|
|||
`update ${recordTable}
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
where ${recordIdColumns.get(recordTable)} = ?
|
||||
where ${recordIdColumns.get(recordTable)!} = ?
|
||||
and recordDelete_timeMillis is null`
|
||||
)
|
||||
.run(user.userName, rightNowMillis, recordId)
|
||||
|
|
@ -88,7 +84,7 @@ export function deleteRecord(
|
|||
`update ${relatedTable}
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
where ${recordIdColumns.get(recordTable)} = ?
|
||||
where ${recordIdColumns.get(recordTable)!} = ?
|
||||
and recordDelete_timeMillis is null`
|
||||
)
|
||||
.run(user.userName, rightNowMillis, recordId)
|
||||
|
|
@ -96,10 +92,7 @@ export function deleteRecord(
|
|||
|
||||
database.close()
|
||||
|
||||
// Clear cache for tables that are cached
|
||||
if (cacheTableNames.includes(recordTable as CacheTableNames)) {
|
||||
clearCacheByTableName(recordTable as CacheTableNames)
|
||||
}
|
||||
clearCacheByTableName(recordTable)
|
||||
|
||||
return result.changes > 0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import type { BurialSite } from '../types/record.types.js';
|
||||
export default function getBurialSite(burialSiteId: number | string, includeDeleted?: boolean): Promise<BurialSite | undefined>;
|
||||
export declare function getBurialSiteByBurialSiteName(burialSiteName: string, includeDeleted?: boolean): Promise<BurialSite | undefined>;
|
||||
export default function getBurialSite(burialSiteId: number | string): Promise<BurialSite | undefined>;
|
||||
export declare function getBurialSiteByBurialSiteName(burialSiteName: string): Promise<BurialSite | undefined>;
|
||||
|
|
|
|||
|
|
@ -13,31 +13,25 @@ const baseSQL = `select l.burialSiteId,
|
|||
l.burialSiteName,
|
||||
l.burialSiteStatusId, s.burialSiteStatus,
|
||||
|
||||
l.bodyCapacity, l.crematedCapacity,
|
||||
t.bodyCapacityMax, t.crematedCapacityMax,
|
||||
|
||||
l.cemeteryId, m.cemeteryName,
|
||||
m.cemeteryLatitude, m.cemeteryLongitude,
|
||||
m.cemeterySvg, l.cemeterySvgId, l.burialSiteImage,
|
||||
l.burialSiteLatitude, l.burialSiteLongitude,
|
||||
|
||||
l.recordDelete_userName, l.recordDelete_timeMillis
|
||||
l.burialSiteLatitude, l.burialSiteLongitude
|
||||
|
||||
from BurialSites l
|
||||
left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId
|
||||
left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId`;
|
||||
export default async function getBurialSite(burialSiteId, includeDeleted = false) {
|
||||
return await _getBurialSite(`l.burialSiteId = ?`, burialSiteId, includeDeleted);
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||
where l.recordDelete_timeMillis is null`;
|
||||
export default async function getBurialSite(burialSiteId) {
|
||||
return await _getBurialSite(`${baseSQL} and l.burialSiteId = ?`, burialSiteId);
|
||||
}
|
||||
export async function getBurialSiteByBurialSiteName(burialSiteName, includeDeleted = false) {
|
||||
return await _getBurialSite(`l.burialSiteName = ?`, burialSiteName, includeDeleted);
|
||||
export async function getBurialSiteByBurialSiteName(burialSiteName) {
|
||||
return await _getBurialSite(`${baseSQL} and l.burialSiteName = ?`, burialSiteName);
|
||||
}
|
||||
async function _getBurialSite(whereClausePiece, burialSiteIdOrLotName, includeDeleted = false) {
|
||||
async function _getBurialSite(sql, burialSiteIdOrLotName) {
|
||||
const database = sqlite(sunriseDB, { readonly: true });
|
||||
const burialSite = database
|
||||
.prepare(`${baseSQL} ${includeDeleted ? 'where' : 'where l.recordDelete_timeMillis is null and'} ${whereClausePiece}`)
|
||||
.get(burialSiteIdOrLotName);
|
||||
const burialSite = database.prepare(sql).get(burialSiteIdOrLotName);
|
||||
if (burialSite !== undefined) {
|
||||
const contracts = await getContracts({
|
||||
burialSiteId: burialSite.burialSiteId
|
||||
|
|
|
|||
|
|
@ -17,55 +17,41 @@ const baseSQL = `select l.burialSiteId,
|
|||
l.burialSiteName,
|
||||
l.burialSiteStatusId, s.burialSiteStatus,
|
||||
|
||||
l.bodyCapacity, l.crematedCapacity,
|
||||
t.bodyCapacityMax, t.crematedCapacityMax,
|
||||
|
||||
l.cemeteryId, m.cemeteryName,
|
||||
m.cemeteryLatitude, m.cemeteryLongitude,
|
||||
m.cemeterySvg, l.cemeterySvgId, l.burialSiteImage,
|
||||
l.burialSiteLatitude, l.burialSiteLongitude,
|
||||
|
||||
l.recordDelete_userName, l.recordDelete_timeMillis
|
||||
l.burialSiteLatitude, l.burialSiteLongitude
|
||||
|
||||
from BurialSites l
|
||||
left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId
|
||||
left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId`
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||
where l.recordDelete_timeMillis is null`
|
||||
|
||||
export default async function getBurialSite(
|
||||
burialSiteId: number | string,
|
||||
includeDeleted = false
|
||||
burialSiteId: number | string
|
||||
): Promise<BurialSite | undefined> {
|
||||
return await _getBurialSite(
|
||||
`l.burialSiteId = ?`,
|
||||
burialSiteId,
|
||||
includeDeleted
|
||||
)
|
||||
return await _getBurialSite(`${baseSQL} and l.burialSiteId = ?`, burialSiteId)
|
||||
}
|
||||
|
||||
export async function getBurialSiteByBurialSiteName(
|
||||
burialSiteName: string,
|
||||
includeDeleted = false
|
||||
burialSiteName: string
|
||||
): Promise<BurialSite | undefined> {
|
||||
return await _getBurialSite(
|
||||
`l.burialSiteName = ?`,
|
||||
burialSiteName,
|
||||
includeDeleted
|
||||
`${baseSQL} and l.burialSiteName = ?`,
|
||||
burialSiteName
|
||||
)
|
||||
}
|
||||
|
||||
async function _getBurialSite(
|
||||
whereClausePiece: string,
|
||||
burialSiteIdOrLotName: number | string,
|
||||
includeDeleted = false
|
||||
sql: string,
|
||||
burialSiteIdOrLotName: number | string
|
||||
): Promise<BurialSite | undefined> {
|
||||
const database = sqlite(sunriseDB, { readonly: true })
|
||||
|
||||
const burialSite = database
|
||||
.prepare(
|
||||
`${baseSQL} ${includeDeleted ? 'where' : 'where l.recordDelete_timeMillis is null and'} ${whereClausePiece}`
|
||||
)
|
||||
.get(burialSiteIdOrLotName) as BurialSite | undefined
|
||||
const burialSite = database.prepare(sql).get(burialSiteIdOrLotName) as
|
||||
| BurialSite
|
||||
| undefined
|
||||
|
||||
if (burialSite !== undefined) {
|
||||
const contracts = await getContracts(
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
import type { BurialSiteStatus } from '../types/record.types.js';
|
||||
export default function getBurialSiteStatuses(includeDeleted?: boolean): BurialSiteStatus[];
|
||||
export default function getBurialSiteStatuses(): BurialSiteStatus[];
|
||||
|
|
|
|||
|
|
@ -1,24 +1,21 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
export default function getBurialSiteStatuses(includeDeleted = false) {
|
||||
export default function getBurialSiteStatuses() {
|
||||
const database = sqlite(sunriseDB);
|
||||
const updateOrderNumbers = !includeDeleted;
|
||||
const statuses = database
|
||||
.prepare(`select burialSiteStatusId, burialSiteStatus, orderNumber
|
||||
from BurialSiteStatuses
|
||||
${includeDeleted ? '' : ' where recordDelete_timeMillis is null '}
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, burialSiteStatus`)
|
||||
.all();
|
||||
if (updateOrderNumbers) {
|
||||
let expectedOrderNumber = 0;
|
||||
for (const status of statuses) {
|
||||
if (status.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber('BurialSiteStatuses', status.burialSiteStatusId, expectedOrderNumber, database);
|
||||
status.orderNumber = expectedOrderNumber;
|
||||
}
|
||||
expectedOrderNumber += 1;
|
||||
let expectedOrderNumber = 0;
|
||||
for (const status of statuses) {
|
||||
if (status.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber('BurialSiteStatuses', status.burialSiteStatusId, expectedOrderNumber, database);
|
||||
status.orderNumber = expectedOrderNumber;
|
||||
}
|
||||
expectedOrderNumber += 1;
|
||||
}
|
||||
database.close();
|
||||
return statuses;
|
||||
|
|
|
|||
|
|
@ -5,39 +5,32 @@ import type { BurialSiteStatus } from '../types/record.types.js'
|
|||
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
export default function getBurialSiteStatuses(
|
||||
includeDeleted = false
|
||||
): BurialSiteStatus[] {
|
||||
export default function getBurialSiteStatuses(): BurialSiteStatus[] {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const updateOrderNumbers = !includeDeleted
|
||||
|
||||
const statuses = database
|
||||
.prepare(
|
||||
`select burialSiteStatusId, burialSiteStatus, orderNumber
|
||||
from BurialSiteStatuses
|
||||
${includeDeleted ? '' : ' where recordDelete_timeMillis is null '}
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, burialSiteStatus`
|
||||
)
|
||||
.all() as BurialSiteStatus[]
|
||||
|
||||
if (updateOrderNumbers) {
|
||||
let expectedOrderNumber = 0
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
for (const status of statuses) {
|
||||
if (status.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber(
|
||||
'BurialSiteStatuses',
|
||||
status.burialSiteStatusId,
|
||||
expectedOrderNumber,
|
||||
database
|
||||
)
|
||||
|
||||
status.orderNumber = expectedOrderNumber
|
||||
}
|
||||
|
||||
expectedOrderNumber += 1
|
||||
for (const status of statuses) {
|
||||
if (status.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber(
|
||||
'BurialSiteStatuses',
|
||||
status.burialSiteStatusId,
|
||||
expectedOrderNumber,
|
||||
database
|
||||
)
|
||||
status.orderNumber = expectedOrderNumber
|
||||
}
|
||||
|
||||
expectedOrderNumber += 1
|
||||
}
|
||||
|
||||
database.close()
|
||||
|
|
|
|||
|
|
@ -4,11 +4,9 @@ import getBurialSiteTypeFields from './getBurialSiteTypeFields.js';
|
|||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
export default function getBurialSiteTypes(includeDeleted = false) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const updateOrderNumbers = !includeDeleted;
|
||||
const updateOrderNumbers = !database.readonly && !includeDeleted;
|
||||
const burialSiteTypes = database
|
||||
.prepare(`select burialSiteTypeId, burialSiteType,
|
||||
bodyCapacityMax, crematedCapacityMax,
|
||||
orderNumber
|
||||
.prepare(`select burialSiteTypeId, burialSiteType, orderNumber
|
||||
from BurialSiteTypes
|
||||
${includeDeleted ? '' : ' where recordDelete_timeMillis is null '}
|
||||
order by orderNumber, burialSiteType`)
|
||||
|
|
|
|||
|
|
@ -11,13 +11,11 @@ export default function getBurialSiteTypes(
|
|||
): BurialSiteType[] {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const updateOrderNumbers = !includeDeleted
|
||||
const updateOrderNumbers = !database.readonly && !includeDeleted
|
||||
|
||||
const burialSiteTypes = database
|
||||
.prepare(
|
||||
`select burialSiteTypeId, burialSiteType,
|
||||
bodyCapacityMax, crematedCapacityMax,
|
||||
orderNumber
|
||||
`select burialSiteTypeId, burialSiteType, orderNumber
|
||||
from BurialSiteTypes
|
||||
${includeDeleted ? '' : ' where recordDelete_timeMillis is null '}
|
||||
order by orderNumber, burialSiteType`
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ export interface GetBurialSitesFilters {
|
|||
burialSiteNameSearchType?: '' | 'endsWith' | 'startsWith';
|
||||
burialSiteName?: string;
|
||||
cemeteryId?: number | string;
|
||||
burialSiteStatusId?: number | string;
|
||||
burialSiteTypeId?: number | string;
|
||||
burialSiteStatusId?: number | string;
|
||||
contractStatus?: '' | 'occupied' | 'unoccupied';
|
||||
workOrderId?: number | string;
|
||||
}
|
||||
|
|
@ -16,6 +16,6 @@ export interface GetBurialSitesOptions {
|
|||
includeContractCount?: boolean;
|
||||
}
|
||||
export default function getBurialSites(filters: GetBurialSitesFilters, options: GetBurialSitesOptions, connectedDatabase?: sqlite.Database): {
|
||||
burialSites: BurialSite[];
|
||||
count: number;
|
||||
burialSites: BurialSite[];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,24 +4,23 @@ 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 { sqlParameters, sqlWhereClause } = buildWhereClause(filters);
|
||||
const { sqlWhereClause, sqlParameters } = buildWhereClause(filters);
|
||||
const currentDate = dateToInteger(new Date());
|
||||
let count = 0;
|
||||
if (options.limit !== -1) {
|
||||
count = database
|
||||
.prepare(`select count(*) as recordCount
|
||||
from BurialSites l
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||
left join (
|
||||
select burialSiteId, count(contractId) as contractCount from Contracts
|
||||
where recordDelete_timeMillis is null
|
||||
and contractStartDate <= ${currentDate.toString()}
|
||||
and (contractEndDate is null or contractEndDate >= ${currentDate.toString()})
|
||||
group by burialSiteId
|
||||
) o on l.burialSiteId = o.burialSiteId
|
||||
${sqlWhereClause}`)
|
||||
.pluck()
|
||||
.get(sqlParameters);
|
||||
from BurialSites l
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||
left join (
|
||||
select burialSiteId, count(contractId) as contractCount from Contracts
|
||||
where recordDelete_timeMillis is null
|
||||
and contractStartDate <= ${currentDate.toString()}
|
||||
and (contractEndDate is null or contractEndDate >= ${currentDate.toString()})
|
||||
group by burialSiteId
|
||||
) o on l.burialSiteId = o.burialSiteId
|
||||
${sqlWhereClause}`)
|
||||
.get(sqlParameters).recordCount;
|
||||
}
|
||||
let burialSites = [];
|
||||
if (options.limit === -1 || count > 0) {
|
||||
|
|
@ -38,7 +37,6 @@ export default function getBurialSites(filters, options, connectedDatabase) {
|
|||
l.burialSiteNameSegment5,
|
||||
l.burialSiteName,
|
||||
t.burialSiteType,
|
||||
l.bodyCapacity, l.crematedCapacity,
|
||||
l.cemeteryId, m.cemeteryName, l.cemeterySvgId,
|
||||
l.burialSiteStatusId, s.burialSiteStatus
|
||||
${includeContractCount
|
||||
|
|
@ -72,8 +70,8 @@ export default function getBurialSites(filters, options, connectedDatabase) {
|
|||
database.close();
|
||||
}
|
||||
return {
|
||||
burialSites,
|
||||
count
|
||||
count,
|
||||
burialSites
|
||||
};
|
||||
}
|
||||
function buildWhereClause(filters) {
|
||||
|
|
|
|||
|
|
@ -9,9 +9,8 @@ export interface GetBurialSitesFilters {
|
|||
burialSiteNameSearchType?: '' | 'endsWith' | 'startsWith'
|
||||
burialSiteName?: string
|
||||
cemeteryId?: number | string
|
||||
|
||||
burialSiteStatusId?: number | string
|
||||
burialSiteTypeId?: number | string
|
||||
burialSiteStatusId?: number | string
|
||||
contractStatus?: '' | 'occupied' | 'unoccupied'
|
||||
workOrderId?: number | string
|
||||
}
|
||||
|
|
@ -28,32 +27,33 @@ export default function getBurialSites(
|
|||
filters: GetBurialSitesFilters,
|
||||
options: GetBurialSitesOptions,
|
||||
connectedDatabase?: sqlite.Database
|
||||
): { burialSites: BurialSite[]; count: number } {
|
||||
): { count: number; burialSites: BurialSite[] } {
|
||||
const database = connectedDatabase ?? sqlite(sunriseDB, { readonly: true })
|
||||
|
||||
const { sqlParameters, sqlWhereClause } = buildWhereClause(filters)
|
||||
const { sqlWhereClause, sqlParameters } = buildWhereClause(filters)
|
||||
|
||||
const currentDate = dateToInteger(new Date())
|
||||
|
||||
let count = 0
|
||||
|
||||
if (options.limit !== -1) {
|
||||
count = database
|
||||
.prepare(
|
||||
`select count(*) as recordCount
|
||||
from BurialSites l
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||
left join (
|
||||
select burialSiteId, count(contractId) as contractCount from Contracts
|
||||
where recordDelete_timeMillis is null
|
||||
and contractStartDate <= ${currentDate.toString()}
|
||||
and (contractEndDate is null or contractEndDate >= ${currentDate.toString()})
|
||||
group by burialSiteId
|
||||
) o on l.burialSiteId = o.burialSiteId
|
||||
${sqlWhereClause}`
|
||||
)
|
||||
.pluck()
|
||||
.get(sqlParameters) as number
|
||||
count = (
|
||||
database
|
||||
.prepare(
|
||||
`select count(*) as recordCount
|
||||
from BurialSites l
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||
left join (
|
||||
select burialSiteId, count(contractId) as contractCount from Contracts
|
||||
where recordDelete_timeMillis is null
|
||||
and contractStartDate <= ${currentDate.toString()}
|
||||
and (contractEndDate is null or contractEndDate >= ${currentDate.toString()})
|
||||
group by burialSiteId
|
||||
) o on l.burialSiteId = o.burialSiteId
|
||||
${sqlWhereClause}`
|
||||
)
|
||||
.get(sqlParameters) as { recordCount: number }
|
||||
).recordCount
|
||||
}
|
||||
|
||||
let burialSites: BurialSite[] = []
|
||||
|
|
@ -75,7 +75,6 @@ export default function getBurialSites(
|
|||
l.burialSiteNameSegment5,
|
||||
l.burialSiteName,
|
||||
t.burialSiteType,
|
||||
l.bodyCapacity, l.crematedCapacity,
|
||||
l.cemeteryId, m.cemeteryName, l.cemeterySvgId,
|
||||
l.burialSiteStatusId, s.burialSiteStatus
|
||||
${
|
||||
|
|
@ -119,8 +118,8 @@ export default function getBurialSites(
|
|||
}
|
||||
|
||||
return {
|
||||
burialSites,
|
||||
count
|
||||
count,
|
||||
burialSites
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ export default async function getContract(contractId, connectedDatabase) {
|
|||
.prepare(`select o.contractId,
|
||||
o.contractTypeId, t.contractType, t.isPreneed,
|
||||
o.burialSiteId, l.burialSiteName, l.burialSiteTypeId,
|
||||
case when l.recordDelete_timeMillis is null then 1 else 0 end as burialSiteIsActive,
|
||||
l.cemeteryId, m.cemeteryName,
|
||||
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
||||
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ export default async function getContract(
|
|||
`select o.contractId,
|
||||
o.contractTypeId, t.contractType, t.isPreneed,
|
||||
o.burialSiteId, l.burialSiteName, l.burialSiteTypeId,
|
||||
case when l.recordDelete_timeMillis is null then 1 else 0 end as burialSiteIsActive,
|
||||
l.cemeteryId, m.cemeteryName,
|
||||
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
||||
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ export default async function GetContractTransactions(contractId, options, conne
|
|||
database.function('userFn_timeIntegerToString', timeIntegerToString);
|
||||
const contractTransactions = database
|
||||
.prepare(`select contractId, transactionIndex,
|
||||
transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString,
|
||||
transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString,
|
||||
transactionAmount, externalReceiptNumber, transactionNote
|
||||
transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString,
|
||||
transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString,
|
||||
transactionAmount, externalReceiptNumber, transactionNote
|
||||
from ContractTransactions
|
||||
where recordDelete_timeMillis is null
|
||||
and contractId = ?
|
||||
and contractId = ?
|
||||
order by transactionDate, transactionTime, transactionIndex`)
|
||||
.all(contractId);
|
||||
if (connectedDatabase === undefined) {
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@ export default async function GetContractTransactions(
|
|||
const contractTransactions = database
|
||||
.prepare(
|
||||
`select contractId, transactionIndex,
|
||||
transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString,
|
||||
transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString,
|
||||
transactionAmount, externalReceiptNumber, transactionNote
|
||||
transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString,
|
||||
transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString,
|
||||
transactionAmount, externalReceiptNumber, transactionNote
|
||||
from ContractTransactions
|
||||
where recordDelete_timeMillis is null
|
||||
and contractId = ?
|
||||
and contractId = ?
|
||||
order by transactionDate, transactionTime, transactionIndex`
|
||||
)
|
||||
.all(contractId) as ContractTransaction[]
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
import type { ContractType } from '../types/record.types.js';
|
||||
export default function getContractTypes(includeDeleted?: boolean): ContractType[];
|
||||
export default function getContractTypes(): ContractType[];
|
||||
|
|
|
|||
|
|
@ -3,20 +3,18 @@ import { sunriseDB } from '../helpers/database.helpers.js';
|
|||
import getContractTypeFields from './getContractTypeFields.js';
|
||||
import getContractTypePrints from './getContractTypePrints.js';
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
export default function getContractTypes(includeDeleted = false) {
|
||||
export default function getContractTypes() {
|
||||
const database = sqlite(sunriseDB);
|
||||
const updateOrderNumbers = !includeDeleted;
|
||||
const contractTypes = database
|
||||
.prepare(`select contractTypeId, contractType, isPreneed, orderNumber
|
||||
from ContractTypes
|
||||
${includeDeleted ? '' : ' where recordDelete_timeMillis is null '}
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, contractType, contractTypeId`)
|
||||
.all();
|
||||
let expectedOrderNumber = -1;
|
||||
for (const contractType of contractTypes) {
|
||||
expectedOrderNumber += 1;
|
||||
if (updateOrderNumbers &&
|
||||
contractType.orderNumber !== expectedOrderNumber) {
|
||||
if (contractType.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber('ContractTypes', contractType.contractTypeId, expectedOrderNumber, database);
|
||||
contractType.orderNumber = expectedOrderNumber;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,18 +7,14 @@ import getContractTypeFields from './getContractTypeFields.js'
|
|||
import getContractTypePrints from './getContractTypePrints.js'
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
export default function getContractTypes(
|
||||
includeDeleted = false
|
||||
): ContractType[] {
|
||||
export default function getContractTypes(): ContractType[] {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const updateOrderNumbers = !includeDeleted
|
||||
|
||||
const contractTypes = database
|
||||
.prepare(
|
||||
`select contractTypeId, contractType, isPreneed, orderNumber
|
||||
from ContractTypes
|
||||
${includeDeleted ? '' : ' where recordDelete_timeMillis is null '}
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, contractType, contractTypeId`
|
||||
)
|
||||
.all() as ContractType[]
|
||||
|
|
@ -28,10 +24,7 @@ export default function getContractTypes(
|
|||
for (const contractType of contractTypes) {
|
||||
expectedOrderNumber += 1
|
||||
|
||||
if (
|
||||
updateOrderNumbers &&
|
||||
contractType.orderNumber !== expectedOrderNumber
|
||||
) {
|
||||
if (contractType.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber(
|
||||
'ContractTypes',
|
||||
contractType.contractTypeId,
|
||||
|
|
|
|||
|
|
@ -6,14 +6,13 @@ export interface GetContractsFilters {
|
|||
contractEffectiveDateString?: string;
|
||||
contractStartDateString?: DateString;
|
||||
contractTime?: '' | 'current' | 'future' | 'past';
|
||||
cemeteryId?: number | string;
|
||||
contractTypeId?: number | string;
|
||||
deceasedName?: string;
|
||||
contractTypeId?: number | string;
|
||||
cemeteryId?: number | string;
|
||||
burialSiteName?: string;
|
||||
burialSiteNameSearchType?: '' | 'endsWith' | 'startsWith';
|
||||
burialSiteTypeId?: number | string;
|
||||
funeralHomeId?: number | string;
|
||||
funeralTime?: '' | 'upcoming';
|
||||
notWorkOrderId?: number | string;
|
||||
workOrderId?: number | string;
|
||||
}
|
||||
|
|
@ -21,7 +20,6 @@ export interface GetContractsOptions {
|
|||
/** -1 for no limit */
|
||||
limit: number | string;
|
||||
offset: number | string;
|
||||
orderBy?: string;
|
||||
includeFees: boolean;
|
||||
includeInterments: boolean;
|
||||
includeTransactions: boolean;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { dateIntegerToString, dateStringToInteger, dateToInteger, timeIntegerToPeriodString, timeIntegerToString } from '@cityssm/utils-datetime';
|
||||
import { dateIntegerToString, dateStringToInteger, timeIntegerToPeriodString, timeIntegerToString } from '@cityssm/utils-datetime';
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { getConfigProperty } from '../helpers/config.helpers.js';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
|
|
@ -20,55 +20,48 @@ export default async function getContracts(filters, options, connectedDatabase)
|
|||
if (isLimited) {
|
||||
count = database
|
||||
.prepare(`select count(*) as recordCount
|
||||
from Contracts c
|
||||
left join BurialSites l on c.burialSiteId = l.burialSiteId
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||
${sqlWhereClause}`)
|
||||
.pluck()
|
||||
.get(sqlParameters);
|
||||
from Contracts o
|
||||
left join BurialSites l on o.burialSiteId = l.burialSiteId
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||
${sqlWhereClause}`)
|
||||
.get(sqlParameters).recordCount;
|
||||
}
|
||||
let contracts = [];
|
||||
if (count !== 0) {
|
||||
const sqlLimitClause = isLimited
|
||||
? ` limit ${options.limit} offset ${options.offset}`
|
||||
: '';
|
||||
contracts = database
|
||||
.prepare(`select c.contractId,
|
||||
c.contractTypeId, t.contractType, t.isPreneed,
|
||||
c.burialSiteId, lt.burialSiteType, l.burialSiteName,
|
||||
case when l.recordDelete_timeMillis is null then 1 else 0 end as burialSiteIsActive,
|
||||
l.cemeteryId, m.cemeteryName,
|
||||
c.contractStartDate, userFn_dateIntegerToString(c.contractStartDate) as contractStartDateString,
|
||||
c.contractEndDate, userFn_dateIntegerToString(c.contractEndDate) as contractEndDateString,
|
||||
c.purchaserName, c.purchaserAddress1, c.purchaserAddress2,
|
||||
c.purchaserCity, c.purchaserProvince, c.purchaserPostalCode,
|
||||
c.purchaserPhoneNumber, c.purchaserEmail, c.purchaserRelationship,
|
||||
c.funeralHomeId, c.funeralDirectorName, f.funeralHomeName,
|
||||
.prepare(`select o.contractId,
|
||||
o.contractTypeId, t.contractType, t.isPreneed,
|
||||
o.burialSiteId, lt.burialSiteType, l.burialSiteName,
|
||||
l.cemeteryId, m.cemeteryName,
|
||||
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
||||
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,
|
||||
o.purchaserName, o.purchaserAddress1, o.purchaserAddress2,
|
||||
o.purchaserCity, o.purchaserProvince, o.purchaserPostalCode,
|
||||
o.purchaserPhoneNumber, o.purchaserEmail, o.purchaserRelationship,
|
||||
o.funeralHomeId, o.funeralDirectorName, f.funeralHomeName,
|
||||
|
||||
c.funeralDate, userFn_dateIntegerToString(c.funeralDate) as funeralDateString,
|
||||
c.funeralTime,
|
||||
userFn_timeIntegerToString(c.funeralTime) as funeralTimeString,
|
||||
userFn_timeIntegerToPeriodString(c.funeralTime) as funeralTimePeriodString,
|
||||
c.directionOfArrival,
|
||||
c.committalTypeId, cm.committalType
|
||||
from Contracts c
|
||||
left join ContractTypes t on c.contractTypeId = t.contractTypeId
|
||||
left join CommittalTypes cm on c.committalTypeId = cm.committalTypeId
|
||||
left join BurialSites l on c.burialSiteId = l.burialSiteId
|
||||
o.funeralDate, userFn_dateIntegerToString(o.funeralDate) as funeralDateString,
|
||||
o.funeralTime,
|
||||
userFn_timeIntegerToString(o.funeralTime) as funeralTimeString,
|
||||
userFn_timeIntegerToPeriodString(o.funeralTime) as funeralTimePeriodString,
|
||||
o.directionOfArrival,
|
||||
o.committalTypeId, c.committalType
|
||||
from Contracts o
|
||||
left join ContractTypes t on o.contractTypeId = t.contractTypeId
|
||||
left join CommittalTypes c on o.committalTypeId = c.committalTypeId
|
||||
left join BurialSites l on o.burialSiteId = l.burialSiteId
|
||||
left join BurialSiteTypes lt on l.burialSiteTypeId = lt.burialSiteTypeId
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||
left join FuneralHomes f on c.funeralHomeId = f.funeralHomeId
|
||||
left join FuneralHomes f on o.funeralHomeId = f.funeralHomeId
|
||||
${sqlWhereClause}
|
||||
${options.orderBy !== undefined && options.orderBy !== ''
|
||||
? ` order by ${options.orderBy}`
|
||||
: ` order by c.contractStartDate desc, ifnull(c.contractEndDate, 99999999) desc,
|
||||
l.burialSiteNameSegment1,
|
||||
l.burialSiteNameSegment2,
|
||||
l.burialSiteNameSegment3,
|
||||
l.burialSiteNameSegment4,
|
||||
l.burialSiteNameSegment5,
|
||||
c.burialSiteId, c.contractId desc`}
|
||||
${sqlLimitClause}`)
|
||||
order by o.contractStartDate desc, ifnull(o.contractEndDate, 99999999) desc,
|
||||
l.burialSiteNameSegment1,
|
||||
l.burialSiteNameSegment2,
|
||||
l.burialSiteNameSegment3,
|
||||
l.burialSiteNameSegment4,
|
||||
l.burialSiteNameSegment5,
|
||||
o.burialSiteId, o.contractId desc
|
||||
${isLimited ? ` limit ${options.limit} offset ${options.offset}` : ''}`)
|
||||
.all(sqlParameters);
|
||||
if (!isLimited) {
|
||||
count = contracts.length;
|
||||
|
|
@ -105,38 +98,38 @@ async function addInclusions(contract, options, database) {
|
|||
}
|
||||
// eslint-disable-next-line complexity
|
||||
function buildWhereClause(filters) {
|
||||
let sqlWhereClause = ' where c.recordDelete_timeMillis is null';
|
||||
let sqlWhereClause = ' where o.recordDelete_timeMillis is null';
|
||||
const sqlParameters = [];
|
||||
if ((filters.burialSiteId ?? '') !== '') {
|
||||
sqlWhereClause += ' and c.burialSiteId = ?';
|
||||
sqlWhereClause += ' and o.burialSiteId = ?';
|
||||
sqlParameters.push(filters.burialSiteId);
|
||||
}
|
||||
const burialSiteNameFilters = getBurialSiteNameWhereClause(filters.burialSiteName, filters.burialSiteNameSearchType ?? '', 'l');
|
||||
sqlWhereClause += burialSiteNameFilters.sqlWhereClause;
|
||||
sqlParameters.push(...burialSiteNameFilters.sqlParameters);
|
||||
const deceasedNameFilters = getDeceasedNameWhereClause(filters.deceasedName, 'c');
|
||||
const deceasedNameFilters = getDeceasedNameWhereClause(filters.deceasedName, 'o');
|
||||
if (deceasedNameFilters.sqlParameters.length > 0) {
|
||||
sqlWhereClause += ` and c.contractId in (
|
||||
select contractId from ContractInterments c
|
||||
sqlWhereClause += ` and o.contractId in (
|
||||
select contractId from ContractInterments o
|
||||
where recordDelete_timeMillis is null
|
||||
${deceasedNameFilters.sqlWhereClause})`;
|
||||
sqlParameters.push(...deceasedNameFilters.sqlParameters);
|
||||
}
|
||||
if ((filters.contractTypeId ?? '') !== '') {
|
||||
sqlWhereClause += ' and c.contractTypeId = ?';
|
||||
sqlWhereClause += ' and o.contractTypeId = ?';
|
||||
sqlParameters.push(filters.contractTypeId);
|
||||
}
|
||||
const contractTimeFilters = getContractTimeWhereClause(filters.contractTime ?? '', 'c');
|
||||
const contractTimeFilters = getContractTimeWhereClause(filters.contractTime ?? '', 'o');
|
||||
sqlWhereClause += contractTimeFilters.sqlWhereClause;
|
||||
sqlParameters.push(...contractTimeFilters.sqlParameters);
|
||||
if ((filters.contractStartDateString ?? '') !== '') {
|
||||
sqlWhereClause += ' and c.contractStartDate = ?';
|
||||
sqlWhereClause += ' and o.contractStartDate = ?';
|
||||
sqlParameters.push(dateStringToInteger(filters.contractStartDateString));
|
||||
}
|
||||
if ((filters.contractEffectiveDateString ?? '') !== '') {
|
||||
sqlWhereClause += ` and (
|
||||
c.contractEndDate is null
|
||||
or (c.contractStartDate <= ? and c.contractEndDate >= ?)
|
||||
o.contractEndDate is null
|
||||
or (o.contractStartDate <= ? and o.contractEndDate >= ?)
|
||||
)`;
|
||||
sqlParameters.push(dateStringToInteger(filters.contractEffectiveDateString), dateStringToInteger(filters.contractEffectiveDateString));
|
||||
}
|
||||
|
|
@ -149,21 +142,17 @@ function buildWhereClause(filters) {
|
|||
sqlParameters.push(filters.burialSiteTypeId);
|
||||
}
|
||||
if ((filters.funeralHomeId ?? '') !== '') {
|
||||
sqlWhereClause += ' and c.funeralHomeId = ?';
|
||||
sqlWhereClause += ' and o.funeralHomeId = ?';
|
||||
sqlParameters.push(filters.funeralHomeId);
|
||||
}
|
||||
if ((filters.funeralTime ?? '') === 'upcoming') {
|
||||
sqlWhereClause += ' and c.funeralDate >= ?';
|
||||
sqlParameters.push(dateToInteger(new Date()));
|
||||
}
|
||||
if ((filters.workOrderId ?? '') !== '') {
|
||||
sqlWhereClause +=
|
||||
' and c.contractId in (select contractId from WorkOrderContracts where recordDelete_timeMillis is null and workOrderId = ?)';
|
||||
' and o.contractId in (select contractId from WorkOrderContracts where recordDelete_timeMillis is null and workOrderId = ?)';
|
||||
sqlParameters.push(filters.workOrderId);
|
||||
}
|
||||
if ((filters.notWorkOrderId ?? '') !== '') {
|
||||
sqlWhereClause +=
|
||||
' and c.contractId not in (select contractId from WorkOrderContracts where recordDelete_timeMillis is null and workOrderId = ?)';
|
||||
' and o.contractId not in (select contractId from WorkOrderContracts where recordDelete_timeMillis is null and workOrderId = ?)';
|
||||
sqlParameters.push(filters.notWorkOrderId);
|
||||
}
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
type DateString,
|
||||
dateIntegerToString,
|
||||
dateStringToInteger,
|
||||
dateToInteger,
|
||||
timeIntegerToPeriodString,
|
||||
timeIntegerToString
|
||||
} from '@cityssm/utils-datetime'
|
||||
|
|
@ -29,17 +28,15 @@ export interface GetContractsFilters {
|
|||
contractStartDateString?: DateString
|
||||
contractTime?: '' | 'current' | 'future' | 'past'
|
||||
|
||||
cemeteryId?: number | string
|
||||
contractTypeId?: number | string
|
||||
deceasedName?: string
|
||||
contractTypeId?: number | string
|
||||
cemeteryId?: number | string
|
||||
|
||||
burialSiteName?: string
|
||||
burialSiteNameSearchType?: '' | 'endsWith' | 'startsWith'
|
||||
|
||||
burialSiteTypeId?: number | string
|
||||
|
||||
funeralHomeId?: number | string
|
||||
funeralTime?: '' | 'upcoming'
|
||||
|
||||
notWorkOrderId?: number | string
|
||||
workOrderId?: number | string
|
||||
|
|
@ -50,8 +47,6 @@ export interface GetContractsOptions {
|
|||
limit: number | string
|
||||
offset: number | string
|
||||
|
||||
orderBy?: string
|
||||
|
||||
includeFees: boolean
|
||||
includeInterments: boolean
|
||||
includeTransactions: boolean
|
||||
|
|
@ -67,9 +62,7 @@ export default async function getContracts(
|
|||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
database.function('userFn_timeIntegerToString', timeIntegerToString)
|
||||
database.function(
|
||||
'userFn_timeIntegerToPeriodString',
|
||||
timeIntegerToPeriodString
|
||||
)
|
||||
'userFn_timeIntegerToPeriodString', timeIntegerToPeriodString)
|
||||
|
||||
const { sqlParameters, sqlWhereClause } = buildWhereClause(filters)
|
||||
|
||||
|
|
@ -81,65 +74,59 @@ export default async function getContracts(
|
|||
const isLimited = options.limit !== -1
|
||||
|
||||
if (isLimited) {
|
||||
count = database
|
||||
.prepare(
|
||||
`select count(*) as recordCount
|
||||
from Contracts c
|
||||
left join BurialSites l on c.burialSiteId = l.burialSiteId
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||
${sqlWhereClause}`
|
||||
)
|
||||
.pluck()
|
||||
.get(sqlParameters) as number
|
||||
count = (
|
||||
database
|
||||
.prepare(
|
||||
`select count(*) as recordCount
|
||||
from Contracts o
|
||||
left join BurialSites l on o.burialSiteId = l.burialSiteId
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||
${sqlWhereClause}`
|
||||
)
|
||||
.get(sqlParameters) as { recordCount: number }
|
||||
).recordCount
|
||||
}
|
||||
|
||||
let contracts: Contract[] = []
|
||||
|
||||
if (count !== 0) {
|
||||
const sqlLimitClause = isLimited
|
||||
? ` limit ${options.limit} offset ${options.offset}`
|
||||
: ''
|
||||
|
||||
contracts = database
|
||||
.prepare(
|
||||
`select c.contractId,
|
||||
c.contractTypeId, t.contractType, t.isPreneed,
|
||||
c.burialSiteId, lt.burialSiteType, l.burialSiteName,
|
||||
case when l.recordDelete_timeMillis is null then 1 else 0 end as burialSiteIsActive,
|
||||
l.cemeteryId, m.cemeteryName,
|
||||
c.contractStartDate, userFn_dateIntegerToString(c.contractStartDate) as contractStartDateString,
|
||||
c.contractEndDate, userFn_dateIntegerToString(c.contractEndDate) as contractEndDateString,
|
||||
c.purchaserName, c.purchaserAddress1, c.purchaserAddress2,
|
||||
c.purchaserCity, c.purchaserProvince, c.purchaserPostalCode,
|
||||
c.purchaserPhoneNumber, c.purchaserEmail, c.purchaserRelationship,
|
||||
c.funeralHomeId, c.funeralDirectorName, f.funeralHomeName,
|
||||
`select o.contractId,
|
||||
o.contractTypeId, t.contractType, t.isPreneed,
|
||||
o.burialSiteId, lt.burialSiteType, l.burialSiteName,
|
||||
l.cemeteryId, m.cemeteryName,
|
||||
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
||||
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,
|
||||
o.purchaserName, o.purchaserAddress1, o.purchaserAddress2,
|
||||
o.purchaserCity, o.purchaserProvince, o.purchaserPostalCode,
|
||||
o.purchaserPhoneNumber, o.purchaserEmail, o.purchaserRelationship,
|
||||
o.funeralHomeId, o.funeralDirectorName, f.funeralHomeName,
|
||||
|
||||
c.funeralDate, userFn_dateIntegerToString(c.funeralDate) as funeralDateString,
|
||||
c.funeralTime,
|
||||
userFn_timeIntegerToString(c.funeralTime) as funeralTimeString,
|
||||
userFn_timeIntegerToPeriodString(c.funeralTime) as funeralTimePeriodString,
|
||||
c.directionOfArrival,
|
||||
c.committalTypeId, cm.committalType
|
||||
from Contracts c
|
||||
left join ContractTypes t on c.contractTypeId = t.contractTypeId
|
||||
left join CommittalTypes cm on c.committalTypeId = cm.committalTypeId
|
||||
left join BurialSites l on c.burialSiteId = l.burialSiteId
|
||||
o.funeralDate, userFn_dateIntegerToString(o.funeralDate) as funeralDateString,
|
||||
o.funeralTime,
|
||||
userFn_timeIntegerToString(o.funeralTime) as funeralTimeString,
|
||||
userFn_timeIntegerToPeriodString(o.funeralTime) as funeralTimePeriodString,
|
||||
o.directionOfArrival,
|
||||
o.committalTypeId, c.committalType
|
||||
from Contracts o
|
||||
left join ContractTypes t on o.contractTypeId = t.contractTypeId
|
||||
left join CommittalTypes c on o.committalTypeId = c.committalTypeId
|
||||
left join BurialSites l on o.burialSiteId = l.burialSiteId
|
||||
left join BurialSiteTypes lt on l.burialSiteTypeId = lt.burialSiteTypeId
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||
left join FuneralHomes f on c.funeralHomeId = f.funeralHomeId
|
||||
left join FuneralHomes f on o.funeralHomeId = f.funeralHomeId
|
||||
${sqlWhereClause}
|
||||
order by o.contractStartDate desc, ifnull(o.contractEndDate, 99999999) desc,
|
||||
l.burialSiteNameSegment1,
|
||||
l.burialSiteNameSegment2,
|
||||
l.burialSiteNameSegment3,
|
||||
l.burialSiteNameSegment4,
|
||||
l.burialSiteNameSegment5,
|
||||
o.burialSiteId, o.contractId desc
|
||||
${
|
||||
options.orderBy !== undefined && options.orderBy !== ''
|
||||
? ` order by ${options.orderBy}`
|
||||
: ` order by c.contractStartDate desc, ifnull(c.contractEndDate, 99999999) desc,
|
||||
l.burialSiteNameSegment1,
|
||||
l.burialSiteNameSegment2,
|
||||
l.burialSiteNameSegment3,
|
||||
l.burialSiteNameSegment4,
|
||||
l.burialSiteNameSegment5,
|
||||
c.burialSiteId, c.contractId desc`
|
||||
}
|
||||
${sqlLimitClause}`
|
||||
isLimited ? ` limit ${options.limit} offset ${options.offset}` : ''
|
||||
}`
|
||||
)
|
||||
.all(sqlParameters) as Contract[]
|
||||
|
||||
|
|
@ -204,11 +191,11 @@ function buildWhereClause(filters: GetContractsFilters): {
|
|||
sqlParameters: unknown[]
|
||||
sqlWhereClause: string
|
||||
} {
|
||||
let sqlWhereClause = ' where c.recordDelete_timeMillis is null'
|
||||
let sqlWhereClause = ' where o.recordDelete_timeMillis is null'
|
||||
const sqlParameters: unknown[] = []
|
||||
|
||||
if ((filters.burialSiteId ?? '') !== '') {
|
||||
sqlWhereClause += ' and c.burialSiteId = ?'
|
||||
sqlWhereClause += ' and o.burialSiteId = ?'
|
||||
sqlParameters.push(filters.burialSiteId)
|
||||
}
|
||||
|
||||
|
|
@ -222,30 +209,30 @@ function buildWhereClause(filters: GetContractsFilters): {
|
|||
|
||||
const deceasedNameFilters = getDeceasedNameWhereClause(
|
||||
filters.deceasedName,
|
||||
'c'
|
||||
'o'
|
||||
)
|
||||
if (deceasedNameFilters.sqlParameters.length > 0) {
|
||||
sqlWhereClause += ` and c.contractId in (
|
||||
select contractId from ContractInterments c
|
||||
sqlWhereClause += ` and o.contractId in (
|
||||
select contractId from ContractInterments o
|
||||
where recordDelete_timeMillis is null
|
||||
${deceasedNameFilters.sqlWhereClause})`
|
||||
sqlParameters.push(...deceasedNameFilters.sqlParameters)
|
||||
}
|
||||
|
||||
if ((filters.contractTypeId ?? '') !== '') {
|
||||
sqlWhereClause += ' and c.contractTypeId = ?'
|
||||
sqlWhereClause += ' and o.contractTypeId = ?'
|
||||
sqlParameters.push(filters.contractTypeId)
|
||||
}
|
||||
|
||||
const contractTimeFilters = getContractTimeWhereClause(
|
||||
filters.contractTime ?? '',
|
||||
'c'
|
||||
'o'
|
||||
)
|
||||
sqlWhereClause += contractTimeFilters.sqlWhereClause
|
||||
sqlParameters.push(...contractTimeFilters.sqlParameters)
|
||||
|
||||
if ((filters.contractStartDateString ?? '') !== '') {
|
||||
sqlWhereClause += ' and c.contractStartDate = ?'
|
||||
sqlWhereClause += ' and o.contractStartDate = ?'
|
||||
sqlParameters.push(
|
||||
dateStringToInteger(filters.contractStartDateString as DateString)
|
||||
)
|
||||
|
|
@ -253,8 +240,8 @@ function buildWhereClause(filters: GetContractsFilters): {
|
|||
|
||||
if ((filters.contractEffectiveDateString ?? '') !== '') {
|
||||
sqlWhereClause += ` and (
|
||||
c.contractEndDate is null
|
||||
or (c.contractStartDate <= ? and c.contractEndDate >= ?)
|
||||
o.contractEndDate is null
|
||||
or (o.contractStartDate <= ? and o.contractEndDate >= ?)
|
||||
)`
|
||||
sqlParameters.push(
|
||||
dateStringToInteger(filters.contractEffectiveDateString as DateString),
|
||||
|
|
@ -273,24 +260,19 @@ function buildWhereClause(filters: GetContractsFilters): {
|
|||
}
|
||||
|
||||
if ((filters.funeralHomeId ?? '') !== '') {
|
||||
sqlWhereClause += ' and c.funeralHomeId = ?'
|
||||
sqlWhereClause += ' and o.funeralHomeId = ?'
|
||||
sqlParameters.push(filters.funeralHomeId)
|
||||
}
|
||||
|
||||
if ((filters.funeralTime ?? '') === 'upcoming') {
|
||||
sqlWhereClause += ' and c.funeralDate >= ?'
|
||||
sqlParameters.push(dateToInteger(new Date()))
|
||||
}
|
||||
|
||||
if ((filters.workOrderId ?? '') !== '') {
|
||||
sqlWhereClause +=
|
||||
' and c.contractId in (select contractId from WorkOrderContracts where recordDelete_timeMillis is null and workOrderId = ?)'
|
||||
' and o.contractId in (select contractId from WorkOrderContracts where recordDelete_timeMillis is null and workOrderId = ?)'
|
||||
sqlParameters.push(filters.workOrderId)
|
||||
}
|
||||
|
||||
if ((filters.notWorkOrderId ?? '') !== '') {
|
||||
sqlWhereClause +=
|
||||
' and c.contractId not in (select contractId from WorkOrderContracts where recordDelete_timeMillis is null and workOrderId = ?)'
|
||||
' and o.contractId not in (select contractId from WorkOrderContracts where recordDelete_timeMillis is null and workOrderId = ?)'
|
||||
sqlParameters.push(filters.notWorkOrderId)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ export default function getNextWorkOrderNumber(connectedDatabase) {
|
|||
const database = connectedDatabase ?? sqlite(sunriseDB, { readonly: true });
|
||||
const paddingLength = getConfigProperty('settings.workOrders.workOrderNumberLength');
|
||||
const currentYearString = new Date().getFullYear().toString();
|
||||
// eslint-disable-next-line security/detect-non-literal-regexp
|
||||
const regex = new RegExp(`^${currentYearString}-\\d+$`);
|
||||
database.function(
|
||||
// eslint-disable-next-line no-secrets/no-secrets
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ export default function getNextWorkOrderNumber(
|
|||
)
|
||||
const currentYearString = new Date().getFullYear().toString()
|
||||
|
||||
// eslint-disable-next-line security/detect-non-literal-regexp
|
||||
const regex = new RegExp(`^${currentYearString}-\\d+$`)
|
||||
|
||||
database.function(
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
import type { WorkOrderMilestoneType } from '../types/record.types.js';
|
||||
export default function getWorkOrderMilestoneTypes(includeDeleted?: boolean): WorkOrderMilestoneType[];
|
||||
export default function getWorkOrderMilestoneTypes(): WorkOrderMilestoneType[];
|
||||
|
|
|
|||
|
|
@ -1,24 +1,21 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
export default function getWorkOrderMilestoneTypes(includeDeleted = false) {
|
||||
export default function getWorkOrderMilestoneTypes() {
|
||||
const database = sqlite(sunriseDB);
|
||||
const updateOrderNumbers = !includeDeleted;
|
||||
const workOrderMilestoneTypes = database
|
||||
.prepare(`select workOrderMilestoneTypeId, workOrderMilestoneType, orderNumber
|
||||
from WorkOrderMilestoneTypes
|
||||
${includeDeleted ? '' : ' where recordDelete_timeMillis is null '}
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, workOrderMilestoneType`)
|
||||
.all();
|
||||
if (updateOrderNumbers) {
|
||||
let expectedOrderNumber = 0;
|
||||
for (const workOrderMilestoneType of workOrderMilestoneTypes) {
|
||||
if (workOrderMilestoneType.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber('WorkOrderMilestoneTypes', workOrderMilestoneType.workOrderMilestoneTypeId, expectedOrderNumber, database);
|
||||
workOrderMilestoneType.orderNumber = expectedOrderNumber;
|
||||
}
|
||||
expectedOrderNumber += 1;
|
||||
let expectedOrderNumber = 0;
|
||||
for (const workOrderMilestoneType of workOrderMilestoneTypes) {
|
||||
if (workOrderMilestoneType.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber('WorkOrderMilestoneTypes', workOrderMilestoneType.workOrderMilestoneTypeId, expectedOrderNumber, database);
|
||||
workOrderMilestoneType.orderNumber = expectedOrderNumber;
|
||||
}
|
||||
expectedOrderNumber += 1;
|
||||
}
|
||||
database.close();
|
||||
return workOrderMilestoneTypes;
|
||||
|
|
|
|||
|
|
@ -5,39 +5,33 @@ import type { WorkOrderMilestoneType } from '../types/record.types.js'
|
|||
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
export default function getWorkOrderMilestoneTypes(
|
||||
includeDeleted = false
|
||||
): WorkOrderMilestoneType[] {
|
||||
export default function getWorkOrderMilestoneTypes(): WorkOrderMilestoneType[] {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const updateOrderNumbers = !includeDeleted
|
||||
|
||||
const workOrderMilestoneTypes = database
|
||||
.prepare(
|
||||
`select workOrderMilestoneTypeId, workOrderMilestoneType, orderNumber
|
||||
from WorkOrderMilestoneTypes
|
||||
${includeDeleted ? '' : ' where recordDelete_timeMillis is null '}
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, workOrderMilestoneType`
|
||||
)
|
||||
.all() as WorkOrderMilestoneType[]
|
||||
|
||||
if (updateOrderNumbers) {
|
||||
let expectedOrderNumber = 0
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
for (const workOrderMilestoneType of workOrderMilestoneTypes) {
|
||||
if (workOrderMilestoneType.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber(
|
||||
'WorkOrderMilestoneTypes',
|
||||
workOrderMilestoneType.workOrderMilestoneTypeId,
|
||||
expectedOrderNumber,
|
||||
database
|
||||
)
|
||||
for (const workOrderMilestoneType of workOrderMilestoneTypes) {
|
||||
if (workOrderMilestoneType.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber(
|
||||
'WorkOrderMilestoneTypes',
|
||||
workOrderMilestoneType.workOrderMilestoneTypeId,
|
||||
expectedOrderNumber,
|
||||
database
|
||||
)
|
||||
|
||||
workOrderMilestoneType.orderNumber = expectedOrderNumber
|
||||
}
|
||||
|
||||
expectedOrderNumber += 1
|
||||
workOrderMilestoneType.orderNumber = expectedOrderNumber
|
||||
}
|
||||
|
||||
expectedOrderNumber += 1
|
||||
}
|
||||
|
||||
database.close()
|
||||
|
|
|
|||
|
|
@ -12,10 +12,9 @@ export async function getWorkOrders(filters, options, connectedDatabase) {
|
|||
const { sqlParameters, sqlWhereClause } = buildWhereClause(filters);
|
||||
const count = database
|
||||
.prepare(`select count(*) as recordCount
|
||||
from WorkOrders w
|
||||
${sqlWhereClause}`)
|
||||
.pluck()
|
||||
.get(sqlParameters);
|
||||
from WorkOrders w
|
||||
${sqlWhereClause}`)
|
||||
.get(sqlParameters).recordCount;
|
||||
let workOrders = [];
|
||||
if (count > 0) {
|
||||
workOrders = database
|
||||
|
|
|
|||
|
|
@ -48,14 +48,15 @@ export async function getWorkOrders(
|
|||
|
||||
const { sqlParameters, sqlWhereClause } = buildWhereClause(filters)
|
||||
|
||||
const count: number = database
|
||||
.prepare(
|
||||
`select count(*) as recordCount
|
||||
from WorkOrders w
|
||||
${sqlWhereClause}`
|
||||
)
|
||||
.pluck()
|
||||
.get(sqlParameters) as number
|
||||
const count: number = (
|
||||
database
|
||||
.prepare(
|
||||
`select count(*) as recordCount
|
||||
from WorkOrders w
|
||||
${sqlWhereClause}`
|
||||
)
|
||||
.get(sqlParameters) as { recordCount: number }
|
||||
).recordCount
|
||||
|
||||
let workOrders: WorkOrder[] = []
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
|
||||
/* eslint-disable @typescript-eslint/no-magic-numbers, max-lines, no-secrets/no-secrets */
|
||||
/* eslint-disable max-lines, no-secrets/no-secrets */
|
||||
import sqlite from 'better-sqlite3';
|
||||
import Debug from 'debug';
|
||||
import { DEBUG_NAMESPACE } from '../debug.config.js';
|
||||
import { sunriseDB as databasePath } from '../helpers/database.helpers.js';
|
||||
import addBurialSiteType from './addBurialSiteType.js';
|
||||
import addCommittalType from './addCommittalType.js';
|
||||
import addContractType from './addContractType.js';
|
||||
import addFeeCategory from './addFeeCategory.js';
|
||||
|
|
@ -24,8 +23,6 @@ const createStatements = [
|
|||
`create table if not exists BurialSiteTypes (
|
||||
burialSiteTypeId integer not null primary key autoincrement,
|
||||
burialSiteType varchar(100) not null,
|
||||
bodyCapacityMax smallint,
|
||||
crematedCapacityMax smallint,
|
||||
orderNumber smallint not null default 0,
|
||||
${recordColumns})`,
|
||||
`create index if not exists idx_BurialSiteTypes_orderNumber
|
||||
|
|
@ -97,9 +94,6 @@ const createStatements = [
|
|||
burialSiteNameSegment5 varchar(20) not null,
|
||||
burialSiteName varchar(200) not null,
|
||||
|
||||
bodyCapacity smallint,
|
||||
crematedCapacity smallint,
|
||||
|
||||
cemeteryId integer,
|
||||
cemeterySvgId varchar(100),
|
||||
burialSiteImage varchar(100) not null default '',
|
||||
|
|
@ -418,42 +412,12 @@ export function initializeDatabase() {
|
|||
}
|
||||
function initializeData() {
|
||||
debug('Initializing data...');
|
||||
addBurialSiteType({
|
||||
burialSiteType: 'In-Ground Grave',
|
||||
bodyCapacityMax: 2,
|
||||
crematedCapacityMax: 6,
|
||||
orderNumber: 1
|
||||
}, initializingUser);
|
||||
addBurialSiteType({
|
||||
burialSiteType: 'Columbarium',
|
||||
bodyCapacityMax: 0,
|
||||
crematedCapacityMax: '',
|
||||
orderNumber: 2
|
||||
}, initializingUser);
|
||||
addBurialSiteType({
|
||||
burialSiteType: 'Mausoleum',
|
||||
bodyCapacityMax: 2,
|
||||
crematedCapacityMax: 0,
|
||||
orderNumber: 2
|
||||
}, initializingUser);
|
||||
addBurialSiteType({
|
||||
burialSiteType: 'Niche Wall',
|
||||
bodyCapacityMax: 0,
|
||||
crematedCapacityMax: 1,
|
||||
orderNumber: 2
|
||||
}, initializingUser);
|
||||
addBurialSiteType({
|
||||
burialSiteType: 'Urn Garden',
|
||||
bodyCapacityMax: 0,
|
||||
crematedCapacityMax: 1,
|
||||
orderNumber: 2
|
||||
}, initializingUser);
|
||||
addBurialSiteType({
|
||||
burialSiteType: 'Crematorium',
|
||||
bodyCapacityMax: 0,
|
||||
crematedCapacityMax: 1,
|
||||
orderNumber: 2
|
||||
}, initializingUser);
|
||||
addRecord('BurialSiteTypes', 'Casket Grave', 1, initializingUser);
|
||||
addRecord('BurialSiteTypes', 'Columbarium', 2, initializingUser);
|
||||
addRecord('BurialSiteTypes', 'Mausoleum', 2, initializingUser);
|
||||
addRecord('BurialSiteTypes', 'Niche Wall', 2, initializingUser);
|
||||
addRecord('BurialSiteTypes', 'Urn Garden', 2, initializingUser);
|
||||
addRecord('BurialSiteTypes', 'Crematorium', 2, initializingUser);
|
||||
addRecord('BurialSiteStatuses', 'Available', 1, initializingUser);
|
||||
addRecord('BurialSiteStatuses', 'Reserved', 2, initializingUser);
|
||||
addRecord('BurialSiteStatuses', 'Taken', 3, initializingUser);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
|
||||
/* eslint-disable @typescript-eslint/no-magic-numbers, max-lines, no-secrets/no-secrets */
|
||||
/* eslint-disable max-lines, no-secrets/no-secrets */
|
||||
|
||||
import sqlite from 'better-sqlite3'
|
||||
import Debug from 'debug'
|
||||
|
|
@ -7,7 +7,6 @@ import Debug from 'debug'
|
|||
import { DEBUG_NAMESPACE } from '../debug.config.js'
|
||||
import { sunriseDB as databasePath } from '../helpers/database.helpers.js'
|
||||
|
||||
import addBurialSiteType from './addBurialSiteType.js'
|
||||
import addCommittalType from './addCommittalType.js'
|
||||
import addContractType from './addContractType.js'
|
||||
import addFeeCategory from './addFeeCategory.js'
|
||||
|
|
@ -31,8 +30,6 @@ const createStatements = [
|
|||
`create table if not exists BurialSiteTypes (
|
||||
burialSiteTypeId integer not null primary key autoincrement,
|
||||
burialSiteType varchar(100) not null,
|
||||
bodyCapacityMax smallint,
|
||||
crematedCapacityMax smallint,
|
||||
orderNumber smallint not null default 0,
|
||||
${recordColumns})`,
|
||||
|
||||
|
|
@ -115,9 +112,6 @@ const createStatements = [
|
|||
burialSiteNameSegment5 varchar(20) not null,
|
||||
burialSiteName varchar(200) not null,
|
||||
|
||||
bodyCapacity smallint,
|
||||
crematedCapacity smallint,
|
||||
|
||||
cemeteryId integer,
|
||||
cemeterySvgId varchar(100),
|
||||
burialSiteImage varchar(100) not null default '',
|
||||
|
|
@ -488,71 +482,12 @@ export function initializeDatabase(): boolean {
|
|||
function initializeData(): void {
|
||||
debug('Initializing data...')
|
||||
|
||||
addBurialSiteType(
|
||||
{
|
||||
burialSiteType: 'In-Ground Grave',
|
||||
|
||||
bodyCapacityMax: 2,
|
||||
crematedCapacityMax: 6,
|
||||
orderNumber: 1
|
||||
},
|
||||
initializingUser
|
||||
)
|
||||
|
||||
addBurialSiteType(
|
||||
{
|
||||
burialSiteType: 'Columbarium',
|
||||
|
||||
bodyCapacityMax: 0,
|
||||
crematedCapacityMax: '',
|
||||
orderNumber: 2
|
||||
},
|
||||
initializingUser
|
||||
)
|
||||
|
||||
addBurialSiteType(
|
||||
{
|
||||
burialSiteType: 'Mausoleum',
|
||||
|
||||
bodyCapacityMax: 2,
|
||||
crematedCapacityMax: 0,
|
||||
orderNumber: 2
|
||||
},
|
||||
initializingUser
|
||||
)
|
||||
|
||||
addBurialSiteType(
|
||||
{
|
||||
burialSiteType: 'Niche Wall',
|
||||
|
||||
bodyCapacityMax: 0,
|
||||
crematedCapacityMax: 1,
|
||||
orderNumber: 2
|
||||
},
|
||||
initializingUser
|
||||
)
|
||||
|
||||
addBurialSiteType(
|
||||
{
|
||||
burialSiteType: 'Urn Garden',
|
||||
|
||||
bodyCapacityMax: 0,
|
||||
crematedCapacityMax: 1,
|
||||
orderNumber: 2
|
||||
},
|
||||
initializingUser
|
||||
)
|
||||
|
||||
addBurialSiteType(
|
||||
{
|
||||
burialSiteType: 'Crematorium',
|
||||
|
||||
bodyCapacityMax: 0,
|
||||
crematedCapacityMax: 1,
|
||||
orderNumber: 2
|
||||
},
|
||||
initializingUser
|
||||
)
|
||||
addRecord('BurialSiteTypes', 'Casket Grave', 1, initializingUser)
|
||||
addRecord('BurialSiteTypes', 'Columbarium', 2, initializingUser)
|
||||
addRecord('BurialSiteTypes', 'Mausoleum', 2, initializingUser)
|
||||
addRecord('BurialSiteTypes', 'Niche Wall', 2, initializingUser)
|
||||
addRecord('BurialSiteTypes', 'Urn Garden', 2, initializingUser)
|
||||
addRecord('BurialSiteTypes', 'Crematorium', 2, initializingUser)
|
||||
|
||||
addRecord('BurialSiteStatuses', 'Available', 1, initializingUser)
|
||||
addRecord('BurialSiteStatuses', 'Reserved', 2, initializingUser)
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ export default function reopenWorkOrder(workOrderId, user) {
|
|||
const result = database
|
||||
.prepare(`update WorkOrders
|
||||
set workOrderCloseDate = null,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where workOrderId = ?
|
||||
and workOrderCloseDate is not null`)
|
||||
and workOrderCloseDate is not null`)
|
||||
.run(user.userName, Date.now(), workOrderId);
|
||||
database.close();
|
||||
return result.changes > 0;
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ export default function reopenWorkOrder(
|
|||
.prepare(
|
||||
`update WorkOrders
|
||||
set workOrderCloseDate = null,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where workOrderId = ?
|
||||
and workOrderCloseDate is not null`
|
||||
and workOrderCloseDate is not null`
|
||||
)
|
||||
.run(user.userName, Date.now(), workOrderId)
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
export declare function restoreBurialSite(burialSiteId: number, user: User): boolean;
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
export function restoreBurialSite(burialSiteId, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare(`update BurialSites
|
||||
set recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where burialSiteId = ?
|
||||
and recordDelete_timeMillis is not null`)
|
||||
.run(user.userName, rightNowMillis, burialSiteId);
|
||||
database.close();
|
||||
return result.changes > 0;
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
export function restoreBurialSite(burialSiteId: number, user: User): boolean {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
const result = database
|
||||
.prepare(
|
||||
`update BurialSites
|
||||
set recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where burialSiteId = ?
|
||||
and recordDelete_timeMillis is not null`
|
||||
)
|
||||
.run(user.userName, rightNowMillis, burialSiteId)
|
||||
|
||||
database.close()
|
||||
|
||||
return result.changes > 0
|
||||
}
|
||||
|
|
@ -7,8 +7,6 @@ export interface UpdateBurialSiteForm {
|
|||
burialSiteNameSegment5?: string;
|
||||
burialSiteStatusId: number | string;
|
||||
burialSiteTypeId: number | string;
|
||||
bodyCapacity?: number | string;
|
||||
crematedCapacity?: number | string;
|
||||
burialSiteImage: string;
|
||||
cemeteryId: number | string;
|
||||
cemeterySvgId: string;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import getCemetery from './getCemetery.js';
|
|||
* @returns True if the burial site was updated.
|
||||
* @throws If an active burial site with the same name already exists.
|
||||
*/
|
||||
// eslint-disable-next-line complexity
|
||||
export default function updateBurialSite(updateForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const cemetery = updateForm.cemeteryId === ''
|
||||
|
|
@ -34,29 +33,25 @@ export default function updateBurialSite(updateForm, user) {
|
|||
const result = database
|
||||
.prepare(`update BurialSites
|
||||
set burialSiteNameSegment1 = ?,
|
||||
burialSiteNameSegment2 = ?,
|
||||
burialSiteNameSegment3 = ?,
|
||||
burialSiteNameSegment4 = ?,
|
||||
burialSiteNameSegment5 = ?,
|
||||
burialSiteName = ?,
|
||||
burialSiteTypeId = ?,
|
||||
burialSiteStatusId = ?,
|
||||
bodyCapacity = ?,
|
||||
crematedCapacity = ?,
|
||||
cemeteryId = ?,
|
||||
cemeterySvgId = ?,
|
||||
burialSiteImage = ?,
|
||||
burialSiteLatitude = ?,
|
||||
burialSiteLongitude = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
burialSiteNameSegment2 = ?,
|
||||
burialSiteNameSegment3 = ?,
|
||||
burialSiteNameSegment4 = ?,
|
||||
burialSiteNameSegment5 = ?,
|
||||
burialSiteName = ?,
|
||||
burialSiteTypeId = ?,
|
||||
burialSiteStatusId = ?,
|
||||
cemeteryId = ?,
|
||||
cemeterySvgId = ?,
|
||||
burialSiteImage = ?,
|
||||
burialSiteLatitude = ?,
|
||||
burialSiteLongitude = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where burialSiteId = ?
|
||||
and recordDelete_timeMillis is null`)
|
||||
and recordDelete_timeMillis is null`)
|
||||
.run(updateForm.burialSiteNameSegment1 ?? '', updateForm.burialSiteNameSegment2 ?? '', updateForm.burialSiteNameSegment3 ?? '', updateForm.burialSiteNameSegment4 ?? '', updateForm.burialSiteNameSegment5 ?? '', burialSiteName, updateForm.burialSiteTypeId, updateForm.burialSiteStatusId === ''
|
||||
? undefined
|
||||
: updateForm.burialSiteStatusId, updateForm.bodyCapacity === '' ? undefined : updateForm.bodyCapacity, updateForm.crematedCapacity === ''
|
||||
? undefined
|
||||
: updateForm.crematedCapacity, updateForm.cemeteryId === '' ? undefined : updateForm.cemeteryId, updateForm.cemeterySvgId, updateForm.burialSiteImage, updateForm.burialSiteLatitude === ''
|
||||
: updateForm.burialSiteStatusId, updateForm.cemeteryId === '' ? undefined : updateForm.cemeteryId, updateForm.cemeterySvgId, updateForm.burialSiteImage, updateForm.burialSiteLatitude === ''
|
||||
? undefined
|
||||
: updateForm.burialSiteLatitude, updateForm.burialSiteLongitude === ''
|
||||
? undefined
|
||||
|
|
@ -83,10 +78,10 @@ export function updateBurialSiteStatus(burialSiteId, burialSiteStatusId, user) {
|
|||
const result = database
|
||||
.prepare(`update BurialSites
|
||||
set burialSiteStatusId = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where burialSiteId = ?
|
||||
and recordDelete_timeMillis is null`)
|
||||
and recordDelete_timeMillis is null`)
|
||||
.run(burialSiteStatusId === '' ? undefined : burialSiteStatusId, user.userName, rightNowMillis, burialSiteId);
|
||||
database.close();
|
||||
return result.changes > 0;
|
||||
|
|
|
|||
|
|
@ -19,9 +19,6 @@ export interface UpdateBurialSiteForm {
|
|||
burialSiteStatusId: number | string
|
||||
burialSiteTypeId: number | string
|
||||
|
||||
bodyCapacity?: number | string
|
||||
crematedCapacity?: number | string
|
||||
|
||||
burialSiteImage: string
|
||||
cemeteryId: number | string
|
||||
cemeterySvgId: string
|
||||
|
|
@ -40,7 +37,6 @@ export interface UpdateBurialSiteForm {
|
|||
* @returns True if the burial site was updated.
|
||||
* @throws If an active burial site with the same name already exists.
|
||||
*/
|
||||
// eslint-disable-next-line complexity
|
||||
export default function updateBurialSite(
|
||||
updateForm: UpdateBurialSiteForm,
|
||||
user: User
|
||||
|
|
@ -76,24 +72,22 @@ export default function updateBurialSite(
|
|||
.prepare(
|
||||
`update BurialSites
|
||||
set burialSiteNameSegment1 = ?,
|
||||
burialSiteNameSegment2 = ?,
|
||||
burialSiteNameSegment3 = ?,
|
||||
burialSiteNameSegment4 = ?,
|
||||
burialSiteNameSegment5 = ?,
|
||||
burialSiteName = ?,
|
||||
burialSiteTypeId = ?,
|
||||
burialSiteStatusId = ?,
|
||||
bodyCapacity = ?,
|
||||
crematedCapacity = ?,
|
||||
cemeteryId = ?,
|
||||
cemeterySvgId = ?,
|
||||
burialSiteImage = ?,
|
||||
burialSiteLatitude = ?,
|
||||
burialSiteLongitude = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
burialSiteNameSegment2 = ?,
|
||||
burialSiteNameSegment3 = ?,
|
||||
burialSiteNameSegment4 = ?,
|
||||
burialSiteNameSegment5 = ?,
|
||||
burialSiteName = ?,
|
||||
burialSiteTypeId = ?,
|
||||
burialSiteStatusId = ?,
|
||||
cemeteryId = ?,
|
||||
cemeterySvgId = ?,
|
||||
burialSiteImage = ?,
|
||||
burialSiteLatitude = ?,
|
||||
burialSiteLongitude = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where burialSiteId = ?
|
||||
and recordDelete_timeMillis is null`
|
||||
and recordDelete_timeMillis is null`
|
||||
)
|
||||
.run(
|
||||
updateForm.burialSiteNameSegment1 ?? '',
|
||||
|
|
@ -106,13 +100,6 @@ export default function updateBurialSite(
|
|||
updateForm.burialSiteStatusId === ''
|
||||
? undefined
|
||||
: updateForm.burialSiteStatusId,
|
||||
|
||||
updateForm.bodyCapacity === '' ? undefined : updateForm.bodyCapacity,
|
||||
|
||||
updateForm.crematedCapacity === ''
|
||||
? undefined
|
||||
: updateForm.crematedCapacity,
|
||||
|
||||
updateForm.cemeteryId === '' ? undefined : updateForm.cemeteryId,
|
||||
updateForm.cemeterySvgId,
|
||||
updateForm.burialSiteImage,
|
||||
|
|
@ -174,10 +161,10 @@ export function updateBurialSiteStatus(
|
|||
.prepare(
|
||||
`update BurialSites
|
||||
set burialSiteStatusId = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where burialSiteId = ?
|
||||
and recordDelete_timeMillis is null`
|
||||
and recordDelete_timeMillis is null`
|
||||
)
|
||||
.run(
|
||||
burialSiteStatusId === '' ? undefined : burialSiteStatusId,
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
export interface UpdateBurialSiteTypeForm {
|
||||
burialSiteTypeId: number | string;
|
||||
burialSiteType: string;
|
||||
bodyCapacityMax: number | string;
|
||||
crematedCapacityMax: number | string;
|
||||
}
|
||||
export default function updateBurialSiteType(updateForm: UpdateBurialSiteTypeForm, user: User): boolean;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue