Compare commits
53 Commits
v1.0.0-alp
...
main
| Author | SHA1 | Date |
|---|---|---|
|
|
118fc1959b | |
|
|
9830bede34 | |
|
|
302a9a4c48 | |
|
|
fe9188d1fb | |
|
|
4664366e12 | |
|
|
afcdca959b | |
|
|
434e15ba1d | |
|
|
39dc10369f | |
|
|
7371be711a | |
|
|
9048235ef2 | |
|
|
59b0fb7e5f | |
|
|
57b6dbf35e | |
|
|
c460d073e7 | |
|
|
a7ce5a99cb | |
|
|
db05999c72 | |
|
|
9c47b48abc | |
|
|
2ed7902320 | |
|
|
7887230c86 | |
|
|
18edc57f70 | |
|
|
656f1b052e | |
|
|
3c1d023ccd | |
|
|
2c506711fb | |
|
|
0dcdfaaa8a | |
|
|
ba0c9f3287 | |
|
|
ab61a3e340 | |
|
|
111663a274 | |
|
|
1c7bc96392 | |
|
|
b26e8b17b2 | |
|
|
c9b10f3696 | |
|
|
34c00b856b | |
|
|
0474631bf5 | |
|
|
927334d954 | |
|
|
50551582c1 | |
|
|
19a7c81766 | |
|
|
f96d975aa0 | |
|
|
3c4c85df19 | |
|
|
0d2f6f78ce | |
|
|
007b47a1f0 | |
|
|
62efb70542 | |
|
|
f440a35df7 | |
|
|
78cae2f964 | |
|
|
afa0286a2a | |
|
|
556a6a71b6 | |
|
|
96a41862bf | |
|
|
f35946d0a5 | |
|
|
d4670603b7 | |
|
|
09b3de1086 | |
|
|
c7640f6dfd | |
|
|
14bd8e0ea4 | |
|
|
b356d771ab | |
|
|
b359aaf564 | |
|
|
c330dff849 | |
|
|
a4522ec4d0 |
|
|
@ -30,7 +30,7 @@ jobs:
|
|||
npm install -g mocha c8 cypress@14
|
||||
|
||||
- name: Copy Test Config
|
||||
run: cp ./data/config.testing.js ./data/config.js
|
||||
run: cp ./data/testing.config.js ./data/config.js
|
||||
|
||||
- name: Test Application Startup
|
||||
run: npm run test:startup
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ to focus exculsively on cemetery management.
|
|||
### ✔️ Cemetery Maps are NOT Required
|
||||
|
||||
Many cemetery applications rely on maps to drill down into burial sites.
|
||||
In Sunrise CMS, maps are completely optional, greatly reducing the effort needed to get started.
|
||||
In Sunrise CMS, maps are completely optional, greatly reducing the effort needed to get started,
|
||||
and reducing the maintenance work when new blocks of burial sites are introduced.
|
||||
|
||||
### ✔️ The System Requirements are Very Low
|
||||
|
||||
|
|
@ -33,14 +34,14 @@ Sunrise CMS does not need an expensive server to run.
|
|||
No separate database server is required either.
|
||||
The whole application could run on a current, modest workstation.
|
||||
|
||||
### ✔️ Track Unlimited Cemeteries and Burial Sites
|
||||
### ✔️ Track Unlimited Cemeteries, Unlimited Burial Sites, Unlimited Contracts...
|
||||
|
||||
There are no limits to the number of records that can be tracked in Sunrise CMS.
|
||||
|
||||
### ✔️ Includes a Built-In Work Order System
|
||||
### ✔️ Includes a Simple Built-In Work Order System
|
||||
|
||||
In addition to tracking data related to cemetery plots,
|
||||
Sunrise CMS can also track work order activities, like grave maintenance.
|
||||
Sunrise CMS can also track work order activities, like interments and grave maintenance.
|
||||
|
||||
### ✔️ Sunrise CMS is Free and Open Source
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
theme: jekyll-theme-cayman
|
||||
title: Sunrise Cemetery Management System
|
||||
title: Sunrise Cemetery Management System (CMS)
|
||||
2
app.js
2
app.js
|
|
@ -10,6 +10,7 @@ import rateLimit from 'express-rate-limit';
|
|||
import session from 'express-session';
|
||||
import createError from 'http-errors';
|
||||
import FileStore from 'session-file-store';
|
||||
import dataLists from './data/dataLists.js';
|
||||
import { DEBUG_NAMESPACE } from './debug.config.js';
|
||||
import * as permissionHandlers from './handlers/permissions.js';
|
||||
import { getSafeRedirectURL } from './helpers/authentication.helpers.js';
|
||||
|
|
@ -141,6 +142,7 @@ app.use((request, response, next) => {
|
|||
response.locals.configFunctions = configFunctions;
|
||||
response.locals.printFunctions = printFunctions;
|
||||
response.locals.dateTimeFunctions = dateTimeFunctions;
|
||||
response.locals.dataLists = dataLists;
|
||||
response.locals.urlPrefix = configFunctions.getConfigProperty('reverseProxy.urlPrefix');
|
||||
next();
|
||||
});
|
||||
|
|
|
|||
3
app.ts
3
app.ts
|
|
@ -12,6 +12,7 @@ import session from 'express-session'
|
|||
import createError from 'http-errors'
|
||||
import FileStore from 'session-file-store'
|
||||
|
||||
import dataLists from './data/dataLists.js'
|
||||
import { DEBUG_NAMESPACE } from './debug.config.js'
|
||||
import * as permissionHandlers from './handlers/permissions.js'
|
||||
import { getSafeRedirectURL } from './helpers/authentication.helpers.js'
|
||||
|
|
@ -244,6 +245,8 @@ app.use((request, response, next) => {
|
|||
response.locals.printFunctions = printFunctions
|
||||
response.locals.dateTimeFunctions = dateTimeFunctions
|
||||
|
||||
response.locals.dataLists = dataLists
|
||||
|
||||
response.locals.urlPrefix = configFunctions.getConfigProperty(
|
||||
'reverseProxy.urlPrefix'
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
await initializeDatabase();
|
||||
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
|
||||
await initializeDatabase()
|
||||
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
|
||||
await initializeDatabase();
|
||||
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
|
||||
await initializeDatabase()
|
||||
initializeDatabase()
|
||||
}
|
||||
|
||||
interface ServerError extends Error {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ export const config = {
|
|||
settings: {
|
||||
adminCleanup: {},
|
||||
burialSites: {},
|
||||
burialSiteTypes: {},
|
||||
cemeteries: {},
|
||||
contracts: {},
|
||||
dynamicsGP: {
|
||||
|
|
@ -8,6 +8,7 @@ export const config: Config = {
|
|||
settings: {
|
||||
adminCleanup: {},
|
||||
burialSites: {},
|
||||
burialSiteTypes: {},
|
||||
cemeteries: {},
|
||||
contracts: {},
|
||||
dynamicsGP: {
|
||||
|
|
@ -33,14 +33,14 @@ 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;
|
||||
'settings.contracts.burialSiteIdIsRequired': boolean;
|
||||
'settings.contracts.contractEndDateIsRequired': boolean;
|
||||
'settings.contracts.deathAgePeriods': string[];
|
||||
'settings.contracts.prints': string[];
|
||||
'settings.contracts.purchaserRelationships': string[];
|
||||
'settings.fees.taxPercentageDefault': number;
|
||||
'settings.workOrders.workOrderNumberLength': number;
|
||||
'settings.workOrders.calendarEmailAddress': string;
|
||||
|
|
@ -57,3 +57,4 @@ export declare const configDefaultValues: {
|
|||
'settings.dynamicsGP.itemNumbers': string[];
|
||||
'settings.dynamicsGP.trialBalanceCodes': string[];
|
||||
};
|
||||
export default configDefaultValues;
|
||||
|
|
@ -32,6 +32,10 @@ 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: '-',
|
||||
|
|
@ -49,21 +53,7 @@ export const configDefaultValues = {
|
|||
'settings.burialSites.refreshImageChanges': false,
|
||||
'settings.contracts.burialSiteIdIsRequired': true,
|
||||
'settings.contracts.contractEndDateIsRequired': false,
|
||||
'settings.contracts.deathAgePeriods': [
|
||||
'Years',
|
||||
'Months',
|
||||
'Days',
|
||||
'Stillborn'
|
||||
],
|
||||
'settings.contracts.prints': ['screen/contract'],
|
||||
'settings.contracts.purchaserRelationships': [
|
||||
'Spouse',
|
||||
'Child',
|
||||
'Parent',
|
||||
'Sibling',
|
||||
'Friend',
|
||||
'Self'
|
||||
],
|
||||
'settings.fees.taxPercentageDefault': 0,
|
||||
'settings.workOrders.workOrderNumberLength': 6,
|
||||
'settings.workOrders.calendarEmailAddress': 'no-reply@127.0.0.1',
|
||||
|
|
@ -81,3 +71,4 @@ export const configDefaultValues = {
|
|||
'settings.dynamicsGP.itemNumbers': [],
|
||||
'settings.dynamicsGP.trialBalanceCodes': []
|
||||
};
|
||||
export default configDefaultValues;
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
import type { config as MSSQLConfig } from 'mssql'
|
||||
|
||||
import { hoursToMillis } from '@cityssm/to-millis'
|
||||
import type { config as MSSQLConfig } from 'mssql'
|
||||
|
||||
import type {
|
||||
ConfigActiveDirectory,
|
||||
|
|
@ -52,6 +51,12 @@ 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: '-',
|
||||
|
|
@ -73,21 +78,8 @@ export const configDefaultValues = {
|
|||
|
||||
'settings.contracts.burialSiteIdIsRequired': true,
|
||||
'settings.contracts.contractEndDateIsRequired': false,
|
||||
'settings.contracts.deathAgePeriods': [
|
||||
'Years',
|
||||
'Months',
|
||||
'Days',
|
||||
'Stillborn'
|
||||
],
|
||||
|
||||
'settings.contracts.prints': ['screen/contract'],
|
||||
'settings.contracts.purchaserRelationships': [
|
||||
'Spouse',
|
||||
'Child',
|
||||
'Parent',
|
||||
'Sibling',
|
||||
'Friend',
|
||||
'Self'
|
||||
],
|
||||
|
||||
'settings.fees.taxPercentageDefault': 0,
|
||||
|
||||
|
|
@ -115,3 +107,5 @@ export const configDefaultValues = {
|
|||
'settings.dynamicsGP.itemNumbers': [] as string[],
|
||||
'settings.dynamicsGP.trialBalanceCodes': [] as string[]
|
||||
}
|
||||
|
||||
export default configDefaultValues
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
export declare const deathAgePeriods: readonly ["Years", "Months", "Days", "Stillborn"];
|
||||
export declare const purchaserRelationships: readonly ["Spouse", "Husband", "Wife", "Child", "Parent", "Sibling", "Friend", "Self"];
|
||||
export declare const directionsOfArrival: readonly ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
|
||||
declare const _default: {
|
||||
deathAgePeriods: readonly ["Years", "Months", "Days", "Stillborn"];
|
||||
directionsOfArrival: readonly ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
|
||||
purchaserRelationships: readonly ["Spouse", "Husband", "Wife", "Child", "Parent", "Sibling", "Friend", "Self"];
|
||||
};
|
||||
export default _default;
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
export const deathAgePeriods = ['Years', 'Months', 'Days', 'Stillborn'];
|
||||
export const purchaserRelationships = [
|
||||
'Spouse',
|
||||
'Husband',
|
||||
'Wife',
|
||||
'Child',
|
||||
'Parent',
|
||||
'Sibling',
|
||||
'Friend',
|
||||
'Self'
|
||||
];
|
||||
export const directionsOfArrival = [
|
||||
'N',
|
||||
'NE',
|
||||
'E',
|
||||
'SE',
|
||||
'S',
|
||||
'SW',
|
||||
'W',
|
||||
'NW'
|
||||
];
|
||||
export default {
|
||||
deathAgePeriods,
|
||||
directionsOfArrival,
|
||||
purchaserRelationships
|
||||
};
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
export const deathAgePeriods = ['Years', 'Months', 'Days', 'Stillborn'] as const
|
||||
|
||||
export const purchaserRelationships = [
|
||||
'Spouse',
|
||||
'Husband',
|
||||
'Wife',
|
||||
'Child',
|
||||
'Parent',
|
||||
'Sibling',
|
||||
'Friend',
|
||||
'Self'
|
||||
] as const
|
||||
|
||||
export const directionsOfArrival = [
|
||||
'N',
|
||||
'NE',
|
||||
'E',
|
||||
'SE',
|
||||
'S',
|
||||
'SW',
|
||||
'W',
|
||||
'NW'
|
||||
] as const
|
||||
|
||||
export default {
|
||||
deathAgePeriods,
|
||||
directionsOfArrival,
|
||||
purchaserRelationships
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { config as baseConfig } from './config.base.js';
|
||||
import { config as baseConfig } from './base.config.js';
|
||||
export const config = Object.assign({}, baseConfig);
|
||||
config.settings.provinceDefault = 'ON';
|
||||
config.settings.latitudeMax = 56.85;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { config as baseConfig } from './config.base.js'
|
||||
import { config as baseConfig } from './base.config.js'
|
||||
|
||||
export const config = Object.assign({}, baseConfig)
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { config as cemeteryConfig } from './config.baseOntario.js';
|
||||
import { config as cemeteryConfig } from './ontario.config.js';
|
||||
export const config = { ...cemeteryConfig };
|
||||
config.aliases.externalReceiptNumber = 'GP Receipt Number';
|
||||
config.settings.publicInternalPath =
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import type { Config } from '../types/config.types.js'
|
||||
|
||||
import { config as cemeteryConfig } from './config.baseOntario.js'
|
||||
import { config as cemeteryConfig } from './ontario.config.js'
|
||||
|
||||
export const config: Config = { ...cemeteryConfig }
|
||||
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
import { config as cemeteryConfig } from './config.baseSsm.js';
|
||||
import { config as cemeteryConfig } from './ssm.ontario.config.js';
|
||||
export const config = { ...cemeteryConfig };
|
||||
config.application.useTestDatabases = true;
|
||||
config.session.doKeepAlive = true;
|
||||
config.users = {
|
||||
canLogin: ['*testView', '*testUpdate', '*testAdmin'],
|
||||
canUpdate: ['*testUpdate'],
|
||||
canUpdateWorkOrders: ['*testUpdate'],
|
||||
isAdmin: ['*testAdmin'],
|
||||
testing: ['*testView', '*testUpdate', '*testAdmin']
|
||||
};
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import type { Config } from '../types/config.types.js'
|
||||
|
||||
import { config as cemeteryConfig } from './config.baseSsm.js'
|
||||
import { config as cemeteryConfig } from './ssm.ontario.config.js'
|
||||
|
||||
export const config: Config = { ...cemeteryConfig }
|
||||
|
||||
|
|
@ -11,6 +11,7 @@ config.session.doKeepAlive = true
|
|||
config.users = {
|
||||
canLogin: ['*testView', '*testUpdate', '*testAdmin'],
|
||||
canUpdate: ['*testUpdate'],
|
||||
canUpdateWorkOrders: ['*testUpdate'],
|
||||
isAdmin: ['*testAdmin'],
|
||||
testing: ['*testView', '*testUpdate', '*testAdmin']
|
||||
}
|
||||
|
|
@ -6,6 +6,8 @@ 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,6 +10,7 @@ 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();
|
||||
|
|
@ -38,17 +39,22 @@ 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.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteImage ?? '', burialSiteForm.burialSiteLatitude === ''
|
||||
: burialSiteForm.burialSiteStatusId, burialSiteForm.bodyCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.bodyCapacity, burialSiteForm.crematedCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.crematedCapacity, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteImage ?? '', burialSiteForm.burialSiteLatitude === ''
|
||||
? undefined
|
||||
: burialSiteForm.burialSiteLatitude, burialSiteForm.burialSiteLongitude === ''
|
||||
? undefined
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ export interface AddBurialSiteForm {
|
|||
burialSiteStatusId: number | string
|
||||
burialSiteTypeId: number | string
|
||||
|
||||
bodyCapacity?: number | string
|
||||
crematedCapacity?: number | string
|
||||
|
||||
burialSiteImage?: string
|
||||
cemeteryId: number | string
|
||||
cemeterySvgId?: string
|
||||
|
|
@ -35,6 +38,7 @@ 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
|
||||
|
|
@ -80,12 +84,13 @@ 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 (?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?)`
|
||||
)
|
||||
|
|
@ -100,6 +105,15 @@ 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 ?? '',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
export interface AddBurialSiteTypeForm {
|
||||
burialSiteType: string;
|
||||
bodyCapacityMax: number | string;
|
||||
crematedCapacityMax: number | string;
|
||||
orderNumber?: number | string;
|
||||
}
|
||||
export default function addBurialSiteType(addForm: AddBurialSiteTypeForm, user: User): number;
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
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,7 +14,9 @@ export default function addBurialSiteTypeField(addForm, user) {
|
|||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.burialSiteTypeId, addForm.burialSiteTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0, addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
.run(addForm.burialSiteTypeId, addForm.burialSiteTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0,
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
||||
addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.close();
|
||||
clearCacheByTableName('BurialSiteTypeFields');
|
||||
return result.lastInsertRowid;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
|||
|
||||
export interface AddBurialSiteTypeFieldForm {
|
||||
burialSiteTypeId: number | string
|
||||
|
||||
|
||||
burialSiteTypeField: string
|
||||
|
||||
fieldType?: string
|
||||
|
|
@ -47,6 +47,7 @@ export default function addBurialSiteTypeField(
|
|||
addForm.isRequired === '' ? 0 : 1,
|
||||
addForm.pattern ?? '',
|
||||
addForm.minLength ?? 0,
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
||||
addForm.maxLength ?? 100,
|
||||
addForm.orderNumber ?? -1,
|
||||
user.userName,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
export interface AddCemeteryForm {
|
||||
import { type UpdateCemeteryDirectionsOfArrivalForm } from './updateCemeteryDirectionsOfArrival.js';
|
||||
export type AddCemeteryForm = UpdateCemeteryDirectionsOfArrivalForm & {
|
||||
cemeteryDescription: string;
|
||||
cemeteryKey: string;
|
||||
cemeteryName: string;
|
||||
|
|
@ -12,5 +13,5 @@ export interface AddCemeteryForm {
|
|||
cemeteryPostalCode: string;
|
||||
cemeteryProvince: string;
|
||||
cemeteryPhoneNumber: string;
|
||||
}
|
||||
};
|
||||
export default function addCemetery(addForm: AddCemeteryForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import updateCemeteryDirectionsOfArrival from './updateCemeteryDirectionsOfArrival.js';
|
||||
export default function addCemetery(addForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
|
|
@ -15,6 +16,8 @@ export default function addCemetery(addForm, user) {
|
|||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.cemeteryName, addForm.cemeteryKey, addForm.cemeteryDescription, addForm.cemeterySvg, addForm.cemeteryLatitude === '' ? undefined : addForm.cemeteryLatitude, addForm.cemeteryLongitude === '' ? undefined : addForm.cemeteryLongitude, addForm.cemeteryAddress1, addForm.cemeteryAddress2, addForm.cemeteryCity, addForm.cemeteryProvince, addForm.cemeteryPostalCode, addForm.cemeteryPhoneNumber, addForm.parentCemeteryId === '' ? undefined : addForm.parentCemeteryId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
const cemeteryId = result.lastInsertRowid;
|
||||
updateCemeteryDirectionsOfArrival(cemeteryId, addForm, database);
|
||||
database.close();
|
||||
return result.lastInsertRowid;
|
||||
return cemeteryId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@ import sqlite from 'better-sqlite3'
|
|||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
export interface AddCemeteryForm {
|
||||
import updateCemeteryDirectionsOfArrival, {
|
||||
type UpdateCemeteryDirectionsOfArrivalForm
|
||||
} from './updateCemeteryDirectionsOfArrival.js'
|
||||
|
||||
export type AddCemeteryForm = UpdateCemeteryDirectionsOfArrivalForm & {
|
||||
cemeteryDescription: string
|
||||
cemeteryKey: string
|
||||
cemeteryName: string
|
||||
|
|
@ -62,7 +66,11 @@ export default function addCemetery(
|
|||
rightNowMillis
|
||||
)
|
||||
|
||||
const cemeteryId = result.lastInsertRowid as number
|
||||
|
||||
updateCemeteryDirectionsOfArrival(cemeteryId, addForm, database)
|
||||
|
||||
database.close()
|
||||
|
||||
return result.lastInsertRowid as number
|
||||
return cemeteryId
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
export interface AddForm {
|
||||
committalType: string;
|
||||
committalTypeKey?: string;
|
||||
orderNumber?: number;
|
||||
orderNumber?: number | string;
|
||||
}
|
||||
export default function addCommittalType(addForm: AddForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
|||
export interface AddForm {
|
||||
committalType: string
|
||||
committalTypeKey?: string
|
||||
orderNumber?: number
|
||||
orderNumber?: number | string
|
||||
}
|
||||
|
||||
export default function addCommittalType(addForm: AddForm, user: User): number {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ export interface AddContractForm {
|
|||
[fieldValue_contractTypeFieldId: `fieldValue_${string}`]: unknown;
|
||||
contractTypeFieldIds?: string;
|
||||
committalTypeId?: number | string;
|
||||
directionOfArrival?: string;
|
||||
funeralDateString?: '' | DateString;
|
||||
funeralDirectorName?: string;
|
||||
funeralHomeId?: number | string;
|
||||
|
|
|
|||
|
|
@ -16,17 +16,17 @@ export default function addContract(addForm, user, connectedDatabase) {
|
|||
purchaserPhoneNumber, purchaserEmail, purchaserRelationship,
|
||||
funeralHomeId, funeralDirectorName,
|
||||
funeralDate, funeralTime,
|
||||
committalTypeId,
|
||||
directionOfArrival, committalTypeId,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.contractTypeId, addForm.burialSiteId === '' ? undefined : addForm.burialSiteId, contractStartDate, addForm.contractEndDateString === ''
|
||||
? undefined
|
||||
: dateStringToInteger(addForm.contractEndDateString), addForm.purchaserName ?? '', addForm.purchaserAddress1 ?? '', addForm.purchaserAddress2 ?? '', addForm.purchaserCity ?? '', addForm.purchaserProvince ?? '', addForm.purchaserPostalCode ?? '', addForm.purchaserPhoneNumber ?? '', addForm.purchaserEmail ?? '', addForm.purchaserRelationship ?? '', addForm.funeralHomeId === '' ? undefined : addForm.funeralHomeId, addForm.funeralDirectorName ?? '', addForm.funeralDateString === ''
|
||||
? undefined
|
||||
: dateStringToInteger(addForm.funeralDateString), addForm.funeralTimeString === ''
|
||||
? undefined
|
||||
: timeStringToInteger(addForm.funeralTimeString), addForm.committalTypeId === '' ? undefined : addForm.committalTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
: timeStringToInteger(addForm.funeralTimeString), addForm.directionOfArrival ?? '', addForm.committalTypeId === '' ? undefined : addForm.committalTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
const contractId = result.lastInsertRowid;
|
||||
/*
|
||||
* Add contract fields
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ export interface AddContractForm {
|
|||
contractTypeFieldIds?: string
|
||||
|
||||
committalTypeId?: number | string
|
||||
directionOfArrival?: string
|
||||
funeralDateString?: '' | DateString
|
||||
funeralDirectorName?: string
|
||||
funeralHomeId?: number | string
|
||||
|
|
@ -74,10 +75,10 @@ export default function addContract(
|
|||
purchaserPhoneNumber, purchaserEmail, purchaserRelationship,
|
||||
funeralHomeId, funeralDirectorName,
|
||||
funeralDate, funeralTime,
|
||||
committalTypeId,
|
||||
directionOfArrival, committalTypeId,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
)
|
||||
.run(
|
||||
addForm.contractTypeId,
|
||||
|
|
@ -103,6 +104,7 @@ export default function addContract(
|
|||
addForm.funeralTimeString === ''
|
||||
? undefined
|
||||
: timeStringToInteger(addForm.funeralTimeString as TimeString),
|
||||
addForm.directionOfArrival ?? '',
|
||||
addForm.committalTypeId === '' ? undefined : addForm.committalTypeId,
|
||||
user.userName,
|
||||
rightNowMillis,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
||||
export interface AddTransactionForm {
|
||||
contractId: number | string;
|
||||
transactionDateString?: string;
|
||||
transactionTimeString?: string;
|
||||
transactionDateString?: '' | DateString;
|
||||
transactionTimeString?: '' | TimeString;
|
||||
externalReceiptNumber: string;
|
||||
transactionAmount: number | string;
|
||||
transactionNote: string;
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ export default function addContractTransaction(contractTransactionForm, user) {
|
|||
transactionIndex = maxIndexResult.transactionIndex + 1;
|
||||
}
|
||||
const rightNow = new Date();
|
||||
const transactionDate = contractTransactionForm.transactionDateString
|
||||
? dateStringToInteger(contractTransactionForm.transactionDateString)
|
||||
: dateToInteger(rightNow);
|
||||
const transactionTime = contractTransactionForm.transactionTimeString
|
||||
? timeStringToInteger(contractTransactionForm.transactionTimeString)
|
||||
: dateToTimeInteger(rightNow);
|
||||
const transactionDate = (contractTransactionForm.transactionDateString ?? '') === ''
|
||||
? dateToInteger(rightNow)
|
||||
: dateStringToInteger(contractTransactionForm.transactionDateString);
|
||||
const transactionTime = (contractTransactionForm.transactionTimeString ?? '') === ''
|
||||
? dateToTimeInteger(rightNow)
|
||||
: timeStringToInteger(contractTransactionForm.transactionTimeString);
|
||||
database
|
||||
.prepare(`insert into ContractTransactions (
|
||||
contractId, transactionIndex,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import {
|
||||
type DateString,
|
||||
type TimeString,
|
||||
dateStringToInteger,
|
||||
dateToInteger,
|
||||
dateToTimeInteger,
|
||||
|
|
@ -11,8 +13,8 @@ import { sunriseDB } from '../helpers/database.helpers.js'
|
|||
export interface AddTransactionForm {
|
||||
contractId: number | string
|
||||
|
||||
transactionDateString?: string
|
||||
transactionTimeString?: string
|
||||
transactionDateString?: '' | DateString
|
||||
transactionTimeString?: '' | TimeString
|
||||
|
||||
externalReceiptNumber: string
|
||||
transactionAmount: number | string
|
||||
|
|
@ -45,13 +47,19 @@ export default function addContractTransaction(
|
|||
|
||||
const rightNow = new Date()
|
||||
|
||||
const transactionDate = contractTransactionForm.transactionDateString
|
||||
? dateStringToInteger(contractTransactionForm.transactionDateString)
|
||||
: dateToInteger(rightNow)
|
||||
const transactionDate =
|
||||
(contractTransactionForm.transactionDateString ?? '') === ''
|
||||
? dateToInteger(rightNow)
|
||||
: dateStringToInteger(
|
||||
contractTransactionForm.transactionDateString as DateString
|
||||
)
|
||||
|
||||
const transactionTime = contractTransactionForm.transactionTimeString
|
||||
? timeStringToInteger(contractTransactionForm.transactionTimeString)
|
||||
: dateToTimeInteger(rightNow)
|
||||
const transactionTime =
|
||||
(contractTransactionForm.transactionTimeString ?? '') === ''
|
||||
? dateToTimeInteger(rightNow)
|
||||
: timeStringToInteger(
|
||||
contractTransactionForm.transactionTimeString as TimeString
|
||||
)
|
||||
|
||||
database
|
||||
.prepare(
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
export interface AddContractTypeFieldForm {
|
||||
contractTypeId?: number | string;
|
||||
contractTypeField: string;
|
||||
fieldValues?: string;
|
||||
fieldType?: string;
|
||||
fieldValues?: string;
|
||||
isRequired?: string;
|
||||
maxLength?: number | string;
|
||||
minLength?: number | string;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ export default function addContractTypeField(addForm, user) {
|
|||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.contractTypeId ?? undefined, addForm.contractTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0, addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
.run(addForm.contractTypeId ?? undefined, addForm.contractTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0,
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
||||
addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.close();
|
||||
clearCacheByTableName('ContractTypeFields');
|
||||
return result.lastInsertRowid;
|
||||
|
|
|
|||
|
|
@ -5,9 +5,11 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
|||
|
||||
export interface AddContractTypeFieldForm {
|
||||
contractTypeId?: number | string
|
||||
|
||||
contractTypeField: string
|
||||
fieldValues?: string
|
||||
|
||||
fieldType?: string
|
||||
fieldValues?: string
|
||||
isRequired?: string
|
||||
maxLength?: number | string
|
||||
minLength?: number | string
|
||||
|
|
@ -43,6 +45,7 @@ export default function addContractTypeField(
|
|||
addForm.isRequired === '' ? 0 : 1,
|
||||
addForm.pattern ?? '',
|
||||
addForm.minLength ?? 0,
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
||||
addForm.maxLength ?? 100,
|
||||
addForm.orderNumber ?? -1,
|
||||
user.userName,
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ export default function addContractTypePrint(addForm, user) {
|
|||
let result = database
|
||||
.prepare(`update ContractTypePrints
|
||||
set recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
where contractTypeId = ?
|
||||
and printEJS = ?`)
|
||||
and printEJS = ?`)
|
||||
.run(user.userName, rightNowMillis, addForm.contractTypeId, addForm.printEJS);
|
||||
if (result.changes === 0) {
|
||||
result = database
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
|||
export interface AddContractTypePrintForm {
|
||||
contractTypeId: number | string
|
||||
printEJS: string
|
||||
|
||||
orderNumber?: number
|
||||
}
|
||||
|
||||
|
|
@ -21,11 +22,11 @@ export default function addContractTypePrint(
|
|||
.prepare(
|
||||
`update ContractTypePrints
|
||||
set recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
where contractTypeId = ?
|
||||
and printEJS = ?`
|
||||
and printEJS = ?`
|
||||
)
|
||||
.run(
|
||||
user.userName,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
export interface AddForm {
|
||||
funeralHomeName: string;
|
||||
funeralHomeKey: string;
|
||||
funeralHomeName: string;
|
||||
funeralHomeAddress1: string;
|
||||
funeralHomeAddress2: string;
|
||||
funeralHomeCity: string;
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import sqlite from 'better-sqlite3'
|
|||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
export interface AddForm {
|
||||
funeralHomeName: string
|
||||
funeralHomeKey: string
|
||||
funeralHomeName: string
|
||||
|
||||
funeralHomeAddress1: string
|
||||
funeralHomeAddress2: string
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
export interface AddForm {
|
||||
export interface AddIntermentContainerTypeForm {
|
||||
intermentContainerType: string;
|
||||
intermentContainerTypeKey?: string;
|
||||
isCremationType?: string;
|
||||
orderNumber?: number;
|
||||
isCremationType?: '0' | '1';
|
||||
orderNumber?: number | string;
|
||||
}
|
||||
export default function addIntermentContainerType(addForm: AddForm, user: User): number;
|
||||
export default function addIntermentContainerType(addForm: AddIntermentContainerTypeForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export default function addIntermentContainerType(addForm, user) {
|
|||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.intermentContainerType, addForm.intermentContainerTypeKey ?? '', addForm.isCremationType === undefined ? 0 : 1, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
.run(addForm.intermentContainerType, addForm.intermentContainerTypeKey ?? '', addForm.isCremationType ?? '0', addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.close();
|
||||
clearCacheByTableName('IntermentContainerTypes');
|
||||
return result.lastInsertRowid;
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@ import sqlite from 'better-sqlite3'
|
|||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
|
||||
export interface AddForm {
|
||||
export interface AddIntermentContainerTypeForm {
|
||||
intermentContainerType: string
|
||||
intermentContainerTypeKey?: string
|
||||
isCremationType?: string
|
||||
orderNumber?: number
|
||||
isCremationType?: '0' | '1'
|
||||
orderNumber?: number | string
|
||||
}
|
||||
|
||||
export default function addIntermentContainerType(
|
||||
addForm: AddForm,
|
||||
addForm: AddIntermentContainerTypeForm,
|
||||
user: User
|
||||
): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
|
@ -29,7 +29,7 @@ export default function addIntermentContainerType(
|
|||
.run(
|
||||
addForm.intermentContainerType,
|
||||
addForm.intermentContainerTypeKey ?? '',
|
||||
addForm.isCremationType === undefined ? 0 : 1,
|
||||
addForm.isCremationType ?? '0',
|
||||
addForm.orderNumber ?? -1,
|
||||
user.userName,
|
||||
rightNowMillis,
|
||||
|
|
|
|||
|
|
@ -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' | 'BurialSiteTypes' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes';
|
||||
type RecordTable = 'BurialSiteStatuses' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes';
|
||||
export default function addRecord(recordTable: RecordTable, recordName: string, orderNumber: number | string, user: User): number;
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ 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,13 +5,11 @@ 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 {
|
||||
workOrderTypeId: number | string;
|
||||
workOrderNumber?: string;
|
||||
workOrderDescription: string;
|
||||
workOrderOpenDateString?: string;
|
||||
workOrderNumber?: string;
|
||||
workOrderTypeId: number | string;
|
||||
workOrderCloseDateString?: string;
|
||||
workOrderOpenDateString?: string;
|
||||
contractId?: string;
|
||||
}
|
||||
export default function addWorkOrder(workOrderForm: AddWorkOrderForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ export default function addWorkOrder(workOrderForm, user) {
|
|||
const workOrderId = result.lastInsertRowid;
|
||||
if ((workOrderForm.contractId ?? '') !== '') {
|
||||
addWorkOrderContract({
|
||||
contractId: workOrderForm.contractId,
|
||||
workOrderId,
|
||||
contractId: workOrderForm.contractId
|
||||
}, user, database);
|
||||
}
|
||||
database.close();
|
||||
|
|
|
|||
|
|
@ -11,11 +11,14 @@ import addWorkOrderContract from './addWorkOrderContract.js'
|
|||
import getNextWorkOrderNumber from './getNextWorkOrderNumber.js'
|
||||
|
||||
export interface AddWorkOrderForm {
|
||||
workOrderTypeId: number | string
|
||||
workOrderNumber?: string
|
||||
workOrderDescription: string
|
||||
workOrderOpenDateString?: string
|
||||
workOrderNumber?: string
|
||||
|
||||
workOrderTypeId: number | string
|
||||
|
||||
workOrderCloseDateString?: string
|
||||
workOrderOpenDateString?: string
|
||||
|
||||
contractId?: string
|
||||
}
|
||||
|
||||
|
|
@ -67,8 +70,8 @@ export default function addWorkOrder(
|
|||
if ((workOrderForm.contractId ?? '') !== '') {
|
||||
addWorkOrderContract(
|
||||
{
|
||||
contractId: workOrderForm.contractId as string,
|
||||
workOrderId,
|
||||
contractId: workOrderForm.contractId as string
|
||||
},
|
||||
user,
|
||||
database
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export interface AddForm {
|
||||
workOrderId: number | string;
|
||||
burialSiteId: number | string;
|
||||
workOrderId: number | string;
|
||||
}
|
||||
export default function addWorkOrderBurialSite(workOrderLotForm: AddForm, user: User): boolean;
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import sqlite from 'better-sqlite3'
|
|||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
export interface AddForm {
|
||||
workOrderId: number | string
|
||||
burialSiteId: number | string
|
||||
workOrderId: number | string
|
||||
}
|
||||
|
||||
export default function addWorkOrderBurialSite(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export interface AddWorkOrderCommentForm {
|
||||
workOrderId: string;
|
||||
comment: string;
|
||||
workOrderId: string;
|
||||
}
|
||||
export default function addWorkOrderComment(workOrderCommentForm: AddWorkOrderCommentForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import sqlite from 'better-sqlite3'
|
|||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
export interface AddWorkOrderCommentForm {
|
||||
workOrderId: string
|
||||
comment: string
|
||||
workOrderId: string
|
||||
}
|
||||
|
||||
export default function addWorkOrderComment(
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
||||
export interface AddWorkOrderMilestoneForm {
|
||||
workOrderId: number | string;
|
||||
workOrderMilestoneTypeId: number | string;
|
||||
workOrderMilestoneDateString: string;
|
||||
workOrderMilestoneTimeString?: string;
|
||||
workOrderMilestoneDateString: '' | DateString;
|
||||
workOrderMilestoneTimeString?: '' | TimeString;
|
||||
workOrderMilestoneDescription: string;
|
||||
workOrderMilestoneCompletionDateString?: string;
|
||||
workOrderMilestoneCompletionTimeString?: string;
|
||||
workOrderMilestoneCompletionDateString?: '' | DateString;
|
||||
workOrderMilestoneCompletionTimeString?: '' | TimeString;
|
||||
}
|
||||
export default function addWorkOrderMilestone(milestoneForm: AddWorkOrderMilestoneForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import {
|
||||
type DateString,
|
||||
type TimeString,
|
||||
dateStringToInteger,
|
||||
timeStringToInteger
|
||||
} from '@cityssm/utils-datetime'
|
||||
|
|
@ -10,13 +12,13 @@ export interface AddWorkOrderMilestoneForm {
|
|||
workOrderId: number | string
|
||||
workOrderMilestoneTypeId: number | string
|
||||
|
||||
workOrderMilestoneDateString: string
|
||||
workOrderMilestoneTimeString?: string
|
||||
workOrderMilestoneDateString: '' | DateString
|
||||
workOrderMilestoneTimeString?: '' | TimeString
|
||||
|
||||
workOrderMilestoneDescription: string
|
||||
|
||||
workOrderMilestoneCompletionDateString?: string
|
||||
workOrderMilestoneCompletionTimeString?: string
|
||||
workOrderMilestoneCompletionDateString?: '' | DateString
|
||||
workOrderMilestoneCompletionTimeString?: '' | TimeString
|
||||
}
|
||||
|
||||
export default function addWorkOrderMilestone(
|
||||
|
|
@ -48,17 +50,19 @@ export default function addWorkOrderMilestone(
|
|||
: dateStringToInteger(milestoneForm.workOrderMilestoneDateString),
|
||||
(milestoneForm.workOrderMilestoneTimeString ?? '') === ''
|
||||
? 0
|
||||
: timeStringToInteger(milestoneForm.workOrderMilestoneTimeString!),
|
||||
: timeStringToInteger(
|
||||
milestoneForm.workOrderMilestoneTimeString as TimeString
|
||||
),
|
||||
milestoneForm.workOrderMilestoneDescription,
|
||||
(milestoneForm.workOrderMilestoneCompletionDateString ?? '') === ''
|
||||
? undefined
|
||||
: dateStringToInteger(
|
||||
milestoneForm.workOrderMilestoneCompletionDateString!
|
||||
milestoneForm.workOrderMilestoneCompletionDateString as DateString
|
||||
),
|
||||
(milestoneForm.workOrderMilestoneCompletionTimeString ?? '') === ''
|
||||
? undefined
|
||||
: timeStringToInteger(
|
||||
milestoneForm.workOrderMilestoneCompletionTimeString!
|
||||
milestoneForm.workOrderMilestoneCompletionTimeString as TimeString
|
||||
),
|
||||
user.userName,
|
||||
rightNowMillis,
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
export declare function backupDatabase(): Promise<false | string>;
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
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 financials, do not delete related.
|
||||
* - Maintain financial data, do not delete related.
|
||||
*/
|
||||
purgedRecordCount += database
|
||||
.prepare('delete from ContractFees where recordDelete_timeMillis <= ?')
|
||||
|
|
@ -136,12 +136,12 @@ export default function cleanupDatabase(user) {
|
|||
purgedRecordCount += database
|
||||
.prepare(`delete from Contracts
|
||||
where recordDelete_timeMillis <= ?
|
||||
and contractId not in (select contractId from ContractComments)
|
||||
and contractId not in (select contractId from ContractFees)
|
||||
and contractId not in (select contractId from ContractFields)
|
||||
and contractId not in (select contractId from ContractInterments)
|
||||
and contractId not in (select contractId from ContractTransactions)
|
||||
and contractId not in (select contractId from WorkOrderContracts)`)
|
||||
and contractId not in (select contractId from ContractComments)
|
||||
and contractId not in (select contractId from ContractFees)
|
||||
and contractId not in (select contractId from ContractFields)
|
||||
and contractId not in (select contractId from ContractInterments)
|
||||
and contractId not in (select contractId from ContractTransactions)
|
||||
and contractId not in (select contractId from WorkOrderContracts)`)
|
||||
.run(recordDeleteTimeMillisMin).changes;
|
||||
/*
|
||||
* Fees
|
||||
|
|
@ -149,14 +149,14 @@ export default function cleanupDatabase(user) {
|
|||
inactivatedRecordCount += database
|
||||
.prepare(`update Fees
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and feeCategoryId in (select feeCategoryId from FeeCategories where recordDelete_timeMillis is not null)`)
|
||||
and feeCategoryId in (select feeCategoryId from FeeCategories where recordDelete_timeMillis is not null)`)
|
||||
.run(user.userName, rightNowMillis).changes;
|
||||
purgedRecordCount += database
|
||||
.prepare(`delete from Fees
|
||||
where recordDelete_timeMillis <= ?
|
||||
and feeId not in (select feeId from ContractFees)`)
|
||||
and feeId not in (select feeId from ContractFees)`)
|
||||
.run(recordDeleteTimeMillisMin).changes;
|
||||
/*
|
||||
* Fee Categories
|
||||
|
|
@ -164,7 +164,7 @@ export default function cleanupDatabase(user) {
|
|||
purgedRecordCount += database
|
||||
.prepare(`delete from FeeCategories
|
||||
where recordDelete_timeMillis <= ?
|
||||
and feeCategoryId not in (select feeCategoryId from Fees)`)
|
||||
and feeCategoryId not in (select feeCategoryId from Fees)`)
|
||||
.run(recordDeleteTimeMillisMin).changes;
|
||||
/*
|
||||
* Contract Type Fields
|
||||
|
|
@ -172,14 +172,14 @@ export default function cleanupDatabase(user) {
|
|||
inactivatedRecordCount += database
|
||||
.prepare(`update ContractTypeFields
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)`)
|
||||
and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)`)
|
||||
.run(user.userName, rightNowMillis).changes;
|
||||
purgedRecordCount += database
|
||||
.prepare(`delete from ContractTypeFields
|
||||
where recordDelete_timeMillis <= ?
|
||||
and contractTypeFieldId not in (select contractTypeFieldId from ContractFields)`)
|
||||
and contractTypeFieldId not in (select contractTypeFieldId from ContractFields)`)
|
||||
.run(recordDeleteTimeMillisMin).changes;
|
||||
/*
|
||||
* Contract Type Prints
|
||||
|
|
@ -187,9 +187,9 @@ export default function cleanupDatabase(user) {
|
|||
inactivatedRecordCount += database
|
||||
.prepare(`update ContractTypePrints
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)`)
|
||||
and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)`)
|
||||
.run(user.userName, rightNowMillis).changes;
|
||||
purgedRecordCount += database
|
||||
.prepare('delete from ContractTypePrints where recordDelete_timeMillis <= ?')
|
||||
|
|
@ -200,10 +200,10 @@ export default function cleanupDatabase(user) {
|
|||
purgedRecordCount += database
|
||||
.prepare(`delete from ContractTypes
|
||||
where recordDelete_timeMillis <= ?
|
||||
and contractTypeId not in (select contractTypeId from ContractTypeFields)
|
||||
and contractTypeId not in (select contractTypeId from ContractTypePrints)
|
||||
and contractTypeId not in (select contractTypeId from Contracts)
|
||||
and contractTypeId not in (select contractTypeId from Fees)`)
|
||||
and contractTypeId not in (select contractTypeId from ContractTypeFields)
|
||||
and contractTypeId not in (select contractTypeId from ContractTypePrints)
|
||||
and contractTypeId not in (select contractTypeId from Contracts)
|
||||
and contractTypeId not in (select contractTypeId from Fees)`)
|
||||
.run(recordDeleteTimeMillisMin).changes;
|
||||
/*
|
||||
* Burial Site Comments
|
||||
|
|
@ -211,9 +211,9 @@ export default function cleanupDatabase(user) {
|
|||
inactivatedRecordCount += database
|
||||
.prepare(`update BurialSiteComments
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)`)
|
||||
and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)`)
|
||||
.run(user.userName, rightNowMillis).changes;
|
||||
purgedRecordCount += database
|
||||
.prepare('delete from BurialSiteComments where recordDelete_timeMillis <= ?')
|
||||
|
|
@ -224,9 +224,9 @@ export default function cleanupDatabase(user) {
|
|||
inactivatedRecordCount += database
|
||||
.prepare(`update BurialSiteFields
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)`)
|
||||
and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)`)
|
||||
.run(user.userName, rightNowMillis).changes;
|
||||
purgedRecordCount += database
|
||||
.prepare('delete from BurialSiteFields where recordDelete_timeMillis <= ?')
|
||||
|
|
@ -237,17 +237,17 @@ export default function cleanupDatabase(user) {
|
|||
inactivatedRecordCount += database
|
||||
.prepare(`update BurialSites
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and cemeteryId in (select cemeteryId from Cemeteries where recordDelete_timeMillis is not null)`)
|
||||
and cemeteryId in (select cemeteryId from Cemeteries where recordDelete_timeMillis is not null)`)
|
||||
.run(user.userName, rightNowMillis).changes;
|
||||
purgedRecordCount += database
|
||||
.prepare(`delete from BurialSites
|
||||
where recordDelete_timeMillis <= ?
|
||||
and burialSiteId not in (select burialSiteId from BurialSiteComments)
|
||||
and burialSiteId not in (select burialSiteId from BurialSiteFields)
|
||||
and burialSiteId not in (select burialSiteId from Contracts)
|
||||
and burialSiteId not in (select burialSiteId from WorkOrderBurialSites)`)
|
||||
and burialSiteId not in (select burialSiteId from BurialSiteComments)
|
||||
and burialSiteId not in (select burialSiteId from BurialSiteFields)
|
||||
and burialSiteId not in (select burialSiteId from Contracts)
|
||||
and burialSiteId not in (select burialSiteId from WorkOrderBurialSites)`)
|
||||
.run(recordDeleteTimeMillisMin).changes;
|
||||
/*
|
||||
* Burial Site Statuses
|
||||
|
|
@ -255,7 +255,7 @@ export default function cleanupDatabase(user) {
|
|||
purgedRecordCount += database
|
||||
.prepare(`delete from BurialSiteStatuses
|
||||
where recordDelete_timeMillis <= ?
|
||||
and burialSiteStatusId not in (select burialSiteStatusId from BurialSites)`)
|
||||
and burialSiteStatusId not in (select burialSiteStatusId from BurialSites)`)
|
||||
.run(recordDeleteTimeMillisMin).changes;
|
||||
/*
|
||||
* Burial Site Type Fields
|
||||
|
|
@ -263,14 +263,14 @@ export default function cleanupDatabase(user) {
|
|||
inactivatedRecordCount += database
|
||||
.prepare(`update BurialSiteTypeFields
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and burialSiteTypeId in (select burialSiteTypeId from BurialSiteTypes where recordDelete_timeMillis is not null)`)
|
||||
and burialSiteTypeId in (select burialSiteTypeId from BurialSiteTypes where recordDelete_timeMillis is not null)`)
|
||||
.run(user.userName, rightNowMillis).changes;
|
||||
purgedRecordCount += database
|
||||
.prepare(`delete from BurialSiteTypeFields
|
||||
where recordDelete_timeMillis <= ?
|
||||
and burialSiteTypeFieldId not in (select burialSiteTypeFieldId from BurialSiteFields)`)
|
||||
and burialSiteTypeFieldId not in (select burialSiteTypeFieldId from BurialSiteFields)`)
|
||||
.run(recordDeleteTimeMillisMin).changes;
|
||||
/*
|
||||
* Burial Site Types
|
||||
|
|
@ -278,7 +278,7 @@ export default function cleanupDatabase(user) {
|
|||
purgedRecordCount += database
|
||||
.prepare(`delete from BurialSiteTypes
|
||||
where recordDelete_timeMillis <= ?
|
||||
and burialSiteTypeId not in (select burialSiteTypeId from BurialSites)`)
|
||||
and burialSiteTypeId not in (select burialSiteTypeId from BurialSites)`)
|
||||
.run(recordDeleteTimeMillisMin).changes;
|
||||
database.close();
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`update WorkOrderComments
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and workOrderId in (
|
||||
select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`
|
||||
and workOrderId in (
|
||||
select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`
|
||||
)
|
||||
.run(user.userName, rightNowMillis).changes
|
||||
|
||||
|
|
@ -45,10 +45,10 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`update WorkOrderContracts
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and workOrderId in (
|
||||
select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`
|
||||
and workOrderId in (
|
||||
select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`
|
||||
)
|
||||
.run(user.userName, rightNowMillis).changes
|
||||
|
||||
|
|
@ -66,10 +66,10 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`update WorkOrderBurialSites
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and workOrderId in (
|
||||
select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`
|
||||
and workOrderId in (
|
||||
select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`
|
||||
)
|
||||
.run(user.userName, rightNowMillis).changes
|
||||
|
||||
|
|
@ -87,10 +87,10 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`update WorkOrderMilestones
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and workOrderId in (
|
||||
select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`
|
||||
and workOrderId in (
|
||||
select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`
|
||||
)
|
||||
.run(user.userName, rightNowMillis).changes
|
||||
|
||||
|
|
@ -108,10 +108,10 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`delete from WorkOrders
|
||||
where recordDelete_timeMillis <= ?
|
||||
and workOrderId not in (select workOrderId from WorkOrderComments)
|
||||
and workOrderId not in (select workOrderId from WorkOrderContracts)
|
||||
and workOrderId not in (select workOrderId from WorkOrderBurialSites)
|
||||
and workOrderId not in (select workOrderId from WorkOrderMilestones)`
|
||||
and workOrderId not in (select workOrderId from WorkOrderComments)
|
||||
and workOrderId not in (select workOrderId from WorkOrderContracts)
|
||||
and workOrderId not in (select workOrderId from WorkOrderBurialSites)
|
||||
and workOrderId not in (select workOrderId from WorkOrderMilestones)`
|
||||
)
|
||||
.run(recordDeleteTimeMillisMin).changes
|
||||
|
||||
|
|
@ -123,8 +123,8 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`delete from WorkOrderMilestoneTypes
|
||||
where recordDelete_timeMillis <= ?
|
||||
and workOrderMilestoneTypeId not in (
|
||||
select workOrderMilestoneTypeId from WorkOrderMilestones)`
|
||||
and workOrderMilestoneTypeId not in (
|
||||
select workOrderMilestoneTypeId from WorkOrderMilestones)`
|
||||
)
|
||||
.run(recordDeleteTimeMillisMin).changes
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`delete from WorkOrderTypes
|
||||
where recordDelete_timeMillis <= ?
|
||||
and workOrderTypeId not in (select workOrderTypeId from WorkOrders)`
|
||||
and workOrderTypeId not in (select workOrderTypeId from WorkOrders)`
|
||||
)
|
||||
.run(recordDeleteTimeMillisMin).changes
|
||||
|
||||
|
|
@ -148,10 +148,10 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`update ContractComments
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and contractId in (
|
||||
select contractId from Contracts where recordDelete_timeMillis is not null)`
|
||||
and contractId in (
|
||||
select contractId from Contracts where recordDelete_timeMillis is not null)`
|
||||
)
|
||||
.run(user.userName, rightNowMillis).changes
|
||||
|
||||
|
|
@ -167,9 +167,9 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`update ContractFields
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and contractId in (select contractId from Contracts where recordDelete_timeMillis is not null)`
|
||||
and contractId in (select contractId from Contracts where recordDelete_timeMillis is not null)`
|
||||
)
|
||||
.run(user.userName, rightNowMillis).changes
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ export default function cleanupDatabase(user: User): {
|
|||
|
||||
/*
|
||||
* Burial Site Contract Fees/Transactions
|
||||
* - Maintain financials, do not delete related.
|
||||
* - Maintain financial data, do not delete related.
|
||||
*/
|
||||
|
||||
purgedRecordCount += database
|
||||
|
|
@ -200,12 +200,12 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`delete from Contracts
|
||||
where recordDelete_timeMillis <= ?
|
||||
and contractId not in (select contractId from ContractComments)
|
||||
and contractId not in (select contractId from ContractFees)
|
||||
and contractId not in (select contractId from ContractFields)
|
||||
and contractId not in (select contractId from ContractInterments)
|
||||
and contractId not in (select contractId from ContractTransactions)
|
||||
and contractId not in (select contractId from WorkOrderContracts)`
|
||||
and contractId not in (select contractId from ContractComments)
|
||||
and contractId not in (select contractId from ContractFees)
|
||||
and contractId not in (select contractId from ContractFields)
|
||||
and contractId not in (select contractId from ContractInterments)
|
||||
and contractId not in (select contractId from ContractTransactions)
|
||||
and contractId not in (select contractId from WorkOrderContracts)`
|
||||
)
|
||||
.run(recordDeleteTimeMillisMin).changes
|
||||
|
||||
|
|
@ -217,9 +217,9 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`update Fees
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and feeCategoryId in (select feeCategoryId from FeeCategories where recordDelete_timeMillis is not null)`
|
||||
and feeCategoryId in (select feeCategoryId from FeeCategories where recordDelete_timeMillis is not null)`
|
||||
)
|
||||
.run(user.userName, rightNowMillis).changes
|
||||
|
||||
|
|
@ -227,7 +227,7 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`delete from Fees
|
||||
where recordDelete_timeMillis <= ?
|
||||
and feeId not in (select feeId from ContractFees)`
|
||||
and feeId not in (select feeId from ContractFees)`
|
||||
)
|
||||
.run(recordDeleteTimeMillisMin).changes
|
||||
|
||||
|
|
@ -239,7 +239,7 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`delete from FeeCategories
|
||||
where recordDelete_timeMillis <= ?
|
||||
and feeCategoryId not in (select feeCategoryId from Fees)`
|
||||
and feeCategoryId not in (select feeCategoryId from Fees)`
|
||||
)
|
||||
.run(recordDeleteTimeMillisMin).changes
|
||||
|
||||
|
|
@ -251,9 +251,9 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`update ContractTypeFields
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)`
|
||||
and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)`
|
||||
)
|
||||
.run(user.userName, rightNowMillis).changes
|
||||
|
||||
|
|
@ -261,7 +261,7 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`delete from ContractTypeFields
|
||||
where recordDelete_timeMillis <= ?
|
||||
and contractTypeFieldId not in (select contractTypeFieldId from ContractFields)`
|
||||
and contractTypeFieldId not in (select contractTypeFieldId from ContractFields)`
|
||||
)
|
||||
.run(recordDeleteTimeMillisMin).changes
|
||||
|
||||
|
|
@ -273,9 +273,9 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`update ContractTypePrints
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)`
|
||||
and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)`
|
||||
)
|
||||
.run(user.userName, rightNowMillis).changes
|
||||
|
||||
|
|
@ -293,10 +293,10 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`delete from ContractTypes
|
||||
where recordDelete_timeMillis <= ?
|
||||
and contractTypeId not in (select contractTypeId from ContractTypeFields)
|
||||
and contractTypeId not in (select contractTypeId from ContractTypePrints)
|
||||
and contractTypeId not in (select contractTypeId from Contracts)
|
||||
and contractTypeId not in (select contractTypeId from Fees)`
|
||||
and contractTypeId not in (select contractTypeId from ContractTypeFields)
|
||||
and contractTypeId not in (select contractTypeId from ContractTypePrints)
|
||||
and contractTypeId not in (select contractTypeId from Contracts)
|
||||
and contractTypeId not in (select contractTypeId from Fees)`
|
||||
)
|
||||
.run(recordDeleteTimeMillisMin).changes
|
||||
|
||||
|
|
@ -308,9 +308,9 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`update BurialSiteComments
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)`
|
||||
and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)`
|
||||
)
|
||||
.run(user.userName, rightNowMillis).changes
|
||||
|
||||
|
|
@ -328,9 +328,9 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`update BurialSiteFields
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)`
|
||||
and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)`
|
||||
)
|
||||
.run(user.userName, rightNowMillis).changes
|
||||
|
||||
|
|
@ -346,9 +346,9 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`update BurialSites
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and cemeteryId in (select cemeteryId from Cemeteries where recordDelete_timeMillis is not null)`
|
||||
and cemeteryId in (select cemeteryId from Cemeteries where recordDelete_timeMillis is not null)`
|
||||
)
|
||||
.run(user.userName, rightNowMillis).changes
|
||||
|
||||
|
|
@ -356,10 +356,10 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`delete from BurialSites
|
||||
where recordDelete_timeMillis <= ?
|
||||
and burialSiteId not in (select burialSiteId from BurialSiteComments)
|
||||
and burialSiteId not in (select burialSiteId from BurialSiteFields)
|
||||
and burialSiteId not in (select burialSiteId from Contracts)
|
||||
and burialSiteId not in (select burialSiteId from WorkOrderBurialSites)`
|
||||
and burialSiteId not in (select burialSiteId from BurialSiteComments)
|
||||
and burialSiteId not in (select burialSiteId from BurialSiteFields)
|
||||
and burialSiteId not in (select burialSiteId from Contracts)
|
||||
and burialSiteId not in (select burialSiteId from WorkOrderBurialSites)`
|
||||
)
|
||||
.run(recordDeleteTimeMillisMin).changes
|
||||
|
||||
|
|
@ -371,7 +371,7 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`delete from BurialSiteStatuses
|
||||
where recordDelete_timeMillis <= ?
|
||||
and burialSiteStatusId not in (select burialSiteStatusId from BurialSites)`
|
||||
and burialSiteStatusId not in (select burialSiteStatusId from BurialSites)`
|
||||
)
|
||||
.run(recordDeleteTimeMillisMin).changes
|
||||
|
||||
|
|
@ -383,9 +383,9 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`update BurialSiteTypeFields
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and burialSiteTypeId in (select burialSiteTypeId from BurialSiteTypes where recordDelete_timeMillis is not null)`
|
||||
and burialSiteTypeId in (select burialSiteTypeId from BurialSiteTypes where recordDelete_timeMillis is not null)`
|
||||
)
|
||||
.run(user.userName, rightNowMillis).changes
|
||||
|
||||
|
|
@ -393,7 +393,7 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`delete from BurialSiteTypeFields
|
||||
where recordDelete_timeMillis <= ?
|
||||
and burialSiteTypeFieldId not in (select burialSiteTypeFieldId from BurialSiteFields)`
|
||||
and burialSiteTypeFieldId not in (select burialSiteTypeFieldId from BurialSiteFields)`
|
||||
)
|
||||
.run(recordDeleteTimeMillisMin).changes
|
||||
|
||||
|
|
@ -405,7 +405,7 @@ export default function cleanupDatabase(user: User): {
|
|||
.prepare(
|
||||
`delete from BurialSiteTypes
|
||||
where recordDelete_timeMillis <= ?
|
||||
and burialSiteTypeId not in (select burialSiteTypeId from BurialSites)`
|
||||
and burialSiteTypeId not in (select burialSiteTypeId from BurialSites)`
|
||||
)
|
||||
.run(recordDeleteTimeMillisMin).changes
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { type DateString } from '@cityssm/utils-datetime';
|
||||
export interface CloseWorkOrderForm {
|
||||
workOrderId: number | string;
|
||||
workOrderCloseDateString?: string;
|
||||
workOrderCloseDateString?: '' | DateString;
|
||||
}
|
||||
export default function closeWorkOrder(workOrderForm: CloseWorkOrderForm, user: User): boolean;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
import { dateStringToInteger, dateToInteger } from '@cityssm/utils-datetime'
|
||||
import {
|
||||
type DateString,
|
||||
dateStringToInteger,
|
||||
dateToInteger
|
||||
} from '@cityssm/utils-datetime'
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
|
@ -6,7 +10,7 @@ import { sunriseDB } from '../helpers/database.helpers.js'
|
|||
export interface CloseWorkOrderForm {
|
||||
workOrderId: number | string
|
||||
|
||||
workOrderCloseDateString?: string
|
||||
workOrderCloseDateString?: '' | DateString
|
||||
}
|
||||
|
||||
export default function closeWorkOrder(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
||||
export interface CompleteWorkOrderMilestoneForm {
|
||||
workOrderMilestoneId: number | string;
|
||||
workOrderMilestoneCompletionDateString?: string;
|
||||
workOrderMilestoneCompletionTimeString?: string;
|
||||
workOrderMilestoneCompletionDateString?: '' | DateString;
|
||||
workOrderMilestoneCompletionTimeString?: '' | TimeString;
|
||||
}
|
||||
export default function completeWorkOrderMilestone(milestoneForm: CompleteWorkOrderMilestoneForm, user: User): boolean;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@ 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 = ?,
|
||||
|
|
@ -11,11 +17,7 @@ export default function completeWorkOrderMilestone(milestoneForm, user) {
|
|||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where workOrderMilestoneId = ?`)
|
||||
.run((milestoneForm.workOrderMilestoneCompletionDateString ?? '') === ''
|
||||
? dateToInteger(rightNow)
|
||||
: dateStringToInteger(milestoneForm.workOrderMilestoneCompletionDateString), (milestoneForm.workOrderMilestoneCompletionTimeString ?? '') === ''
|
||||
? dateToTimeInteger(rightNow)
|
||||
: timeStringToInteger(milestoneForm.workOrderMilestoneCompletionTimeString), user.userName, rightNow.getTime(), milestoneForm.workOrderMilestoneId);
|
||||
.run(completionDate, completionTime, user.userName, rightNow.getTime(), milestoneForm.workOrderMilestoneId);
|
||||
database.close();
|
||||
return result.changes > 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import {
|
||||
type DateString,
|
||||
type TimeString,
|
||||
dateStringToInteger,
|
||||
dateToInteger,
|
||||
dateToTimeInteger,
|
||||
|
|
@ -10,9 +12,9 @@ import { sunriseDB } from '../helpers/database.helpers.js'
|
|||
|
||||
export interface CompleteWorkOrderMilestoneForm {
|
||||
workOrderMilestoneId: number | string
|
||||
|
||||
workOrderMilestoneCompletionDateString?: string
|
||||
workOrderMilestoneCompletionTimeString?: string
|
||||
|
||||
workOrderMilestoneCompletionDateString?: '' | DateString
|
||||
workOrderMilestoneCompletionTimeString?: '' | TimeString
|
||||
}
|
||||
|
||||
export default function completeWorkOrderMilestone(
|
||||
|
|
@ -23,6 +25,20 @@ 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
|
||||
|
|
@ -33,16 +49,8 @@ export default function completeWorkOrderMilestone(
|
|||
where workOrderMilestoneId = ?`
|
||||
)
|
||||
.run(
|
||||
(milestoneForm.workOrderMilestoneCompletionDateString ?? '') === ''
|
||||
? dateToInteger(rightNow)
|
||||
: dateStringToInteger(
|
||||
milestoneForm.workOrderMilestoneCompletionDateString!
|
||||
),
|
||||
(milestoneForm.workOrderMilestoneCompletionTimeString ?? '') === ''
|
||||
? dateToTimeInteger(rightNow)
|
||||
: timeStringToInteger(
|
||||
milestoneForm.workOrderMilestoneCompletionTimeString!
|
||||
),
|
||||
completionDate,
|
||||
completionTime,
|
||||
user.userName,
|
||||
rightNow.getTime(),
|
||||
milestoneForm.workOrderMilestoneId
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ export default async function copyContract(
|
|||
funeralDirectorName: oldContract.funeralDirectorName,
|
||||
funeralHomeId: oldContract.funeralHomeId ?? '',
|
||||
funeralTimeString: oldContract.funeralTimeString ?? '',
|
||||
|
||||
purchaserAddress1: oldContract.purchaserAddress1,
|
||||
purchaserAddress2: oldContract.purchaserAddress2,
|
||||
purchaserCity: oldContract.purchaserCity,
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ export function deleteBurialSite(burialSiteId, user) {
|
|||
.prepare(`select contractId
|
||||
from Contracts
|
||||
where burialSiteId = ?
|
||||
and recordDelete_timeMillis is null
|
||||
and (contractEndDate is null or contractEndDate >= ?)`)
|
||||
and recordDelete_timeMillis is null
|
||||
and (contractEndDate is null or contractEndDate >= ?)`)
|
||||
.pluck()
|
||||
.get(burialSiteId, currentDateInteger);
|
||||
if (activeContract !== undefined) {
|
||||
|
|
@ -26,26 +26,9 @@ export function deleteBurialSite(burialSiteId, user) {
|
|||
database
|
||||
.prepare(`update BurialSites
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where burialSiteId = ?
|
||||
and recordDelete_timeMillis is null`)
|
||||
.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`)
|
||||
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,33 +38,9 @@ export function deleteBurialSite(burialSiteId: number, user: User): boolean {
|
|||
.prepare(
|
||||
`update BurialSites
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
recordDelete_timeMillis = ?
|
||||
where burialSiteId = ?
|
||||
and recordDelete_timeMillis is null`
|
||||
)
|
||||
.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`
|
||||
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,3 +1,3 @@
|
|||
type RecordTable = 'BurialSiteComments' | 'BurialSiteStatuses' | 'BurialSiteTypeFields' | 'BurialSiteTypes' | 'ContractComments' | 'Contracts' | 'ContractTypeFields' | 'ContractTypes' | 'FeeCategories' | 'Fees' | 'FuneralHomes' | 'WorkOrderComments' | 'WorkOrderMilestones' | 'WorkOrderMilestoneTypes' | 'WorkOrders' | 'WorkOrderTypes';
|
||||
type RecordTable = 'BurialSiteComments' | 'BurialSiteStatuses' | 'BurialSiteTypeFields' | 'BurialSiteTypes' | 'CommittalTypes' | 'ContractComments' | 'Contracts' | 'ContractTypeFields' | 'ContractTypes' | 'FeeCategories' | 'Fees' | 'FuneralHomes' | 'IntermentContainerTypes' | 'WorkOrderComments' | 'WorkOrderMilestones' | 'WorkOrderMilestoneTypes' | 'WorkOrders' | 'WorkOrderTypes';
|
||||
export declare function deleteRecord(recordTable: RecordTable, recordId: number | string, user: User): boolean;
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
import { cacheTableNames, clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
const recordIdColumns = new Map([
|
||||
['BurialSiteComments', 'burialSiteCommentId'],
|
||||
['BurialSiteStatuses', 'burialSiteStatusId'],
|
||||
['BurialSiteTypeFields', 'burialSiteTypeFieldId'],
|
||||
['BurialSiteTypes', 'burialSiteTypeId'],
|
||||
['CommittalTypes', 'committalTypeId'],
|
||||
['ContractComments', 'contractCommentId'],
|
||||
['Contracts', 'contractId'],
|
||||
['ContractTypeFields', 'contractTypeFieldId'],
|
||||
|
|
@ -13,6 +14,7 @@ const recordIdColumns = new Map([
|
|||
['FeeCategories', 'feeCategoryId'],
|
||||
['Fees', 'feeId'],
|
||||
['FuneralHomes', 'funeralHomeId'],
|
||||
['IntermentContainerTypes', 'intermentContainerTypeId'],
|
||||
['WorkOrderComments', 'workOrderCommentId'],
|
||||
['WorkOrderMilestones', 'workOrderMilestoneId'],
|
||||
['WorkOrderMilestoneTypes', 'workOrderMilestoneTypeId'],
|
||||
|
|
@ -53,6 +55,9 @@ export function deleteRecord(recordTable, recordId, user) {
|
|||
.run(user.userName, rightNowMillis, recordId);
|
||||
}
|
||||
database.close();
|
||||
clearCacheByTableName(recordTable);
|
||||
// Clear cache for tables that are cached
|
||||
if (cacheTableNames.includes(recordTable)) {
|
||||
clearCacheByTableName(recordTable);
|
||||
}
|
||||
return result.changes > 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
import {
|
||||
CacheTableNames,
|
||||
cacheTableNames,
|
||||
clearCacheByTableName
|
||||
} from '../helpers/functions.cache.js'
|
||||
|
||||
type RecordTable =
|
||||
| 'BurialSiteComments'
|
||||
| 'BurialSiteStatuses'
|
||||
| 'BurialSiteTypeFields'
|
||||
| 'BurialSiteTypes'
|
||||
| 'CommittalTypes'
|
||||
| 'ContractComments'
|
||||
| 'Contracts'
|
||||
| 'ContractTypeFields'
|
||||
|
|
@ -15,6 +20,7 @@ type RecordTable =
|
|||
| 'FeeCategories'
|
||||
| 'Fees'
|
||||
| 'FuneralHomes'
|
||||
| 'IntermentContainerTypes'
|
||||
| 'WorkOrderComments'
|
||||
| 'WorkOrderMilestones'
|
||||
| 'WorkOrderMilestoneTypes'
|
||||
|
|
@ -26,6 +32,7 @@ const recordIdColumns = new Map<RecordTable, string>([
|
|||
['BurialSiteStatuses', 'burialSiteStatusId'],
|
||||
['BurialSiteTypeFields', 'burialSiteTypeFieldId'],
|
||||
['BurialSiteTypes', 'burialSiteTypeId'],
|
||||
['CommittalTypes', 'committalTypeId'],
|
||||
['ContractComments', 'contractCommentId'],
|
||||
['Contracts', 'contractId'],
|
||||
['ContractTypeFields', 'contractTypeFieldId'],
|
||||
|
|
@ -33,6 +40,7 @@ const recordIdColumns = new Map<RecordTable, string>([
|
|||
['FeeCategories', 'feeCategoryId'],
|
||||
['Fees', 'feeId'],
|
||||
['FuneralHomes', 'funeralHomeId'],
|
||||
['IntermentContainerTypes', 'intermentContainerTypeId'],
|
||||
['WorkOrderComments', 'workOrderCommentId'],
|
||||
['WorkOrderMilestones', 'workOrderMilestoneId'],
|
||||
['WorkOrderMilestoneTypes', 'workOrderMilestoneTypeId'],
|
||||
|
|
@ -69,7 +77,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)
|
||||
|
|
@ -80,7 +88,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)
|
||||
|
|
@ -88,7 +96,10 @@ export function deleteRecord(
|
|||
|
||||
database.close()
|
||||
|
||||
clearCacheByTableName(recordTable)
|
||||
// Clear cache for tables that are cached
|
||||
if (cacheTableNames.includes(recordTable as CacheTableNames)) {
|
||||
clearCacheByTableName(recordTable as CacheTableNames)
|
||||
}
|
||||
|
||||
return result.changes > 0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import type { BurialSite } from '../types/record.types.js';
|
||||
export default function getBurialSite(burialSiteId: number | string): Promise<BurialSite | undefined>;
|
||||
export declare function getBurialSiteByBurialSiteName(burialSiteName: string): Promise<BurialSite | undefined>;
|
||||
export default function getBurialSite(burialSiteId: number | string, includeDeleted?: boolean): Promise<BurialSite | undefined>;
|
||||
export declare function getBurialSiteByBurialSiteName(burialSiteName: string, includeDeleted?: boolean): Promise<BurialSite | undefined>;
|
||||
|
|
|
|||
|
|
@ -13,25 +13,31 @@ 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.burialSiteLatitude, l.burialSiteLongitude,
|
||||
|
||||
l.recordDelete_userName, l.recordDelete_timeMillis
|
||||
|
||||
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
|
||||
where l.recordDelete_timeMillis is null`;
|
||||
export default async function getBurialSite(burialSiteId) {
|
||||
return await _getBurialSite(`${baseSQL} and l.burialSiteId = ?`, burialSiteId);
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId`;
|
||||
export default async function getBurialSite(burialSiteId, includeDeleted = false) {
|
||||
return await _getBurialSite(`l.burialSiteId = ?`, burialSiteId, includeDeleted);
|
||||
}
|
||||
export async function getBurialSiteByBurialSiteName(burialSiteName) {
|
||||
return await _getBurialSite(`${baseSQL} and l.burialSiteName = ?`, burialSiteName);
|
||||
export async function getBurialSiteByBurialSiteName(burialSiteName, includeDeleted = false) {
|
||||
return await _getBurialSite(`l.burialSiteName = ?`, burialSiteName, includeDeleted);
|
||||
}
|
||||
async function _getBurialSite(sql, burialSiteIdOrLotName) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const burialSite = database.prepare(sql).get(burialSiteIdOrLotName);
|
||||
async function _getBurialSite(whereClausePiece, burialSiteIdOrLotName, includeDeleted = false) {
|
||||
const database = sqlite(sunriseDB, { readonly: true });
|
||||
const burialSite = database
|
||||
.prepare(`${baseSQL} ${includeDeleted ? 'where' : 'where l.recordDelete_timeMillis is null and'} ${whereClausePiece}`)
|
||||
.get(burialSiteIdOrLotName);
|
||||
if (burialSite !== undefined) {
|
||||
const contracts = await getContracts({
|
||||
burialSiteId: burialSite.burialSiteId
|
||||
|
|
|
|||
|
|
@ -17,41 +17,55 @@ 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.burialSiteLatitude, l.burialSiteLongitude,
|
||||
|
||||
l.recordDelete_userName, l.recordDelete_timeMillis
|
||||
|
||||
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
|
||||
where l.recordDelete_timeMillis is null`
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId`
|
||||
|
||||
export default async function getBurialSite(
|
||||
burialSiteId: number | string
|
||||
burialSiteId: number | string,
|
||||
includeDeleted = false
|
||||
): Promise<BurialSite | undefined> {
|
||||
return await _getBurialSite(`${baseSQL} and l.burialSiteId = ?`, burialSiteId)
|
||||
return await _getBurialSite(
|
||||
`l.burialSiteId = ?`,
|
||||
burialSiteId,
|
||||
includeDeleted
|
||||
)
|
||||
}
|
||||
|
||||
export async function getBurialSiteByBurialSiteName(
|
||||
burialSiteName: string
|
||||
burialSiteName: string,
|
||||
includeDeleted = false
|
||||
): Promise<BurialSite | undefined> {
|
||||
return await _getBurialSite(
|
||||
`${baseSQL} and l.burialSiteName = ?`,
|
||||
burialSiteName
|
||||
`l.burialSiteName = ?`,
|
||||
burialSiteName,
|
||||
includeDeleted
|
||||
)
|
||||
}
|
||||
|
||||
async function _getBurialSite(
|
||||
sql: string,
|
||||
burialSiteIdOrLotName: number | string
|
||||
whereClausePiece: string,
|
||||
burialSiteIdOrLotName: number | string,
|
||||
includeDeleted = false
|
||||
): Promise<BurialSite | undefined> {
|
||||
const database = sqlite(sunriseDB)
|
||||
const database = sqlite(sunriseDB, { readonly: true })
|
||||
|
||||
const burialSite = database.prepare(sql).get(burialSiteIdOrLotName) as
|
||||
| BurialSite
|
||||
| undefined
|
||||
const burialSite = database
|
||||
.prepare(
|
||||
`${baseSQL} ${includeDeleted ? 'where' : 'where l.recordDelete_timeMillis is null and'} ${whereClausePiece}`
|
||||
)
|
||||
.get(burialSiteIdOrLotName) as BurialSite | undefined
|
||||
|
||||
if (burialSite !== undefined) {
|
||||
const contracts = await getContracts(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import type { directionsOfArrival } from '../data/dataLists.js';
|
||||
export declare const defaultDirectionsOfArrival: {
|
||||
E: string;
|
||||
N: string;
|
||||
S: string;
|
||||
W: string;
|
||||
};
|
||||
export default function getBurialSiteDirectionsOfArrival(burialSiteId: number | string, connectedDatabase?: sqlite.Database): Partial<Record<(typeof directionsOfArrival)[number], string>>;
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import getCemeteryDirectionsOfArrival from './getCemeteryDirectionsOfArrival.js';
|
||||
export const defaultDirectionsOfArrival = {
|
||||
E: 'East',
|
||||
N: 'North',
|
||||
S: 'South',
|
||||
W: 'West'
|
||||
};
|
||||
export default function getBurialSiteDirectionsOfArrival(burialSiteId, connectedDatabase) {
|
||||
const database = connectedDatabase ?? sqlite(sunriseDB, { readonly: true });
|
||||
const directionsList = database
|
||||
.prepare(`select c.parentCemeteryId,
|
||||
d.directionOfArrival, d.directionOfArrivalDescription
|
||||
from BurialSites b
|
||||
left join Cemeteries c on b.cemeteryId = c.cemeteryId
|
||||
left join CemeteryDirectionsOfArrival d on c.cemeteryId = d.cemeteryId
|
||||
where b.burialSiteId = ?`)
|
||||
.all(burialSiteId);
|
||||
let directions = {};
|
||||
if (directionsList.length === 1 &&
|
||||
directionsList[0].directionOfArrival === null &&
|
||||
directionsList[0].parentCemeteryId !== null) {
|
||||
directions = getCemeteryDirectionsOfArrival(directionsList[0].parentCemeteryId, connectedDatabase);
|
||||
}
|
||||
else if (directionsList.length > 0 && directionsList[0].directionOfArrival !== null) {
|
||||
for (const direction of directionsList) {
|
||||
directions[direction.directionOfArrival] =
|
||||
direction.directionOfArrivalDescription ?? '';
|
||||
}
|
||||
}
|
||||
if (Object.keys(directions).length === 0) {
|
||||
directions = defaultDirectionsOfArrival;
|
||||
}
|
||||
if (connectedDatabase === undefined) {
|
||||
database.close();
|
||||
}
|
||||
return directions;
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import type { directionsOfArrival } from '../data/dataLists.js'
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
import getCemeteryDirectionsOfArrival from './getCemeteryDirectionsOfArrival.js'
|
||||
|
||||
export const defaultDirectionsOfArrival = {
|
||||
E: 'East',
|
||||
N: 'North',
|
||||
S: 'South',
|
||||
W: 'West'
|
||||
}
|
||||
|
||||
export default function getBurialSiteDirectionsOfArrival(
|
||||
burialSiteId: number | string,
|
||||
connectedDatabase?: sqlite.Database
|
||||
): Partial<Record<(typeof directionsOfArrival)[number], string>> {
|
||||
const database = connectedDatabase ?? sqlite(sunriseDB, { readonly: true })
|
||||
|
||||
const directionsList = database
|
||||
.prepare(
|
||||
`select c.parentCemeteryId,
|
||||
d.directionOfArrival, d.directionOfArrivalDescription
|
||||
from BurialSites b
|
||||
left join Cemeteries c on b.cemeteryId = c.cemeteryId
|
||||
left join CemeteryDirectionsOfArrival d on c.cemeteryId = d.cemeteryId
|
||||
where b.burialSiteId = ?`
|
||||
)
|
||||
.all(burialSiteId) as Array<{
|
||||
directionOfArrival: (typeof directionsOfArrival)[number] | null
|
||||
directionOfArrivalDescription: string | null
|
||||
parentCemeteryId: number | null
|
||||
}>
|
||||
|
||||
let directions: Partial<
|
||||
Record<(typeof directionsOfArrival)[number], string>
|
||||
> = {}
|
||||
|
||||
if (
|
||||
directionsList.length === 1 &&
|
||||
directionsList[0].directionOfArrival === null &&
|
||||
directionsList[0].parentCemeteryId !== null
|
||||
) {
|
||||
directions = getCemeteryDirectionsOfArrival(
|
||||
directionsList[0].parentCemeteryId,
|
||||
connectedDatabase
|
||||
)
|
||||
} else if (directionsList.length > 0 && directionsList[0].directionOfArrival !== null) {
|
||||
for (const direction of directionsList) {
|
||||
directions[direction.directionOfArrival as string] =
|
||||
direction.directionOfArrivalDescription ?? ''
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(directions).length === 0) {
|
||||
directions = defaultDirectionsOfArrival
|
||||
}
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.close()
|
||||
}
|
||||
|
||||
return directions
|
||||
}
|
||||
|
|
@ -4,30 +4,30 @@ export default function getBurialSiteFields(burialSiteId, connectedDatabase) {
|
|||
const database = connectedDatabase ?? sqlite(sunriseDB, { readonly: true });
|
||||
const burialSiteFields = database
|
||||
.prepare(`select l.burialSiteId, l.burialSiteTypeFieldId,
|
||||
l.fieldValue,
|
||||
f.burialSiteTypeField, f.fieldType, f.fieldValues,
|
||||
f.isRequired, f.pattern, f.minLength, f.maxLength,
|
||||
f.orderNumber, t.orderNumber as burialSiteTypeOrderNumber
|
||||
l.fieldValue,
|
||||
f.burialSiteTypeField, f.fieldType, f.fieldValues,
|
||||
f.isRequired, f.pattern, f.minLength, f.maxLength,
|
||||
f.orderNumber, t.orderNumber as burialSiteTypeOrderNumber
|
||||
from BurialSiteFields l
|
||||
left join BurialSiteTypeFields f on l.burialSiteTypeFieldId = f.burialSiteTypeFieldId
|
||||
left join BurialSiteTypes t on f.burialSiteTypeId = t.burialSiteTypeId
|
||||
where l.recordDelete_timeMillis is null
|
||||
and l.burialSiteId = ?
|
||||
and l.burialSiteId = ?
|
||||
|
||||
union
|
||||
|
||||
select ? as burialSiteId, f.burialSiteTypeFieldId,
|
||||
'' as fieldValue,
|
||||
f.burialSiteTypeField, f.fieldType, f.fieldValues,
|
||||
f.isRequired, f.pattern, f.minLength, f.maxLength,
|
||||
f.orderNumber, t.orderNumber as burialSiteTypeOrderNumber
|
||||
'' as fieldValue,
|
||||
f.burialSiteTypeField, f.fieldType, f.fieldValues,
|
||||
f.isRequired, f.pattern, f.minLength, f.maxLength,
|
||||
f.orderNumber, t.orderNumber as burialSiteTypeOrderNumber
|
||||
from BurialSiteTypeFields f
|
||||
left join BurialSiteTypes t on f.burialSiteTypeId = t.burialSiteTypeId
|
||||
where f.recordDelete_timeMillis is null
|
||||
and (
|
||||
and (
|
||||
f.burialSiteTypeId is null
|
||||
or f.burialSiteTypeId in (select burialSiteTypeId from BurialSites where burialSiteId = ?))
|
||||
and f.burialSiteTypeFieldId not in (select burialSiteTypeFieldId from BurialSiteFields where burialSiteId = ? and recordDelete_timeMillis is null)
|
||||
and f.burialSiteTypeFieldId not in (select burialSiteTypeFieldId from BurialSiteFields where burialSiteId = ? and recordDelete_timeMillis is null)
|
||||
order by burialSiteTypeOrderNumber, f.orderNumber, f.burialSiteTypeField`)
|
||||
.all(burialSiteId, burialSiteId, burialSiteId, burialSiteId);
|
||||
if (connectedDatabase === undefined) {
|
||||
|
|
|
|||
|
|
@ -12,30 +12,30 @@ export default function getBurialSiteFields(
|
|||
const burialSiteFields = database
|
||||
.prepare(
|
||||
`select l.burialSiteId, l.burialSiteTypeFieldId,
|
||||
l.fieldValue,
|
||||
f.burialSiteTypeField, f.fieldType, f.fieldValues,
|
||||
f.isRequired, f.pattern, f.minLength, f.maxLength,
|
||||
f.orderNumber, t.orderNumber as burialSiteTypeOrderNumber
|
||||
l.fieldValue,
|
||||
f.burialSiteTypeField, f.fieldType, f.fieldValues,
|
||||
f.isRequired, f.pattern, f.minLength, f.maxLength,
|
||||
f.orderNumber, t.orderNumber as burialSiteTypeOrderNumber
|
||||
from BurialSiteFields l
|
||||
left join BurialSiteTypeFields f on l.burialSiteTypeFieldId = f.burialSiteTypeFieldId
|
||||
left join BurialSiteTypes t on f.burialSiteTypeId = t.burialSiteTypeId
|
||||
where l.recordDelete_timeMillis is null
|
||||
and l.burialSiteId = ?
|
||||
and l.burialSiteId = ?
|
||||
|
||||
union
|
||||
|
||||
select ? as burialSiteId, f.burialSiteTypeFieldId,
|
||||
'' as fieldValue,
|
||||
f.burialSiteTypeField, f.fieldType, f.fieldValues,
|
||||
f.isRequired, f.pattern, f.minLength, f.maxLength,
|
||||
f.orderNumber, t.orderNumber as burialSiteTypeOrderNumber
|
||||
'' as fieldValue,
|
||||
f.burialSiteTypeField, f.fieldType, f.fieldValues,
|
||||
f.isRequired, f.pattern, f.minLength, f.maxLength,
|
||||
f.orderNumber, t.orderNumber as burialSiteTypeOrderNumber
|
||||
from BurialSiteTypeFields f
|
||||
left join BurialSiteTypes t on f.burialSiteTypeId = t.burialSiteTypeId
|
||||
where f.recordDelete_timeMillis is null
|
||||
and (
|
||||
and (
|
||||
f.burialSiteTypeId is null
|
||||
or f.burialSiteTypeId in (select burialSiteTypeId from BurialSites where burialSiteId = ?))
|
||||
and f.burialSiteTypeFieldId not in (select burialSiteTypeFieldId from BurialSiteFields where burialSiteId = ? and recordDelete_timeMillis is null)
|
||||
and f.burialSiteTypeFieldId not in (select burialSiteTypeFieldId from BurialSiteFields where burialSiteId = ? and recordDelete_timeMillis is null)
|
||||
order by burialSiteTypeOrderNumber, f.orderNumber, f.burialSiteTypeField`
|
||||
)
|
||||
.all(
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
import type { BurialSiteStatus } from '../types/record.types.js';
|
||||
export default function getBurialSiteStatuses(): BurialSiteStatus[];
|
||||
export default function getBurialSiteStatuses(includeDeleted?: boolean): BurialSiteStatus[];
|
||||
|
|
|
|||
|
|
@ -1,21 +1,24 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
export default function getBurialSiteStatuses() {
|
||||
export default function getBurialSiteStatuses(includeDeleted = false) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const updateOrderNumbers = !includeDeleted;
|
||||
const statuses = database
|
||||
.prepare(`select burialSiteStatusId, burialSiteStatus, orderNumber
|
||||
from BurialSiteStatuses
|
||||
where recordDelete_timeMillis is null
|
||||
${includeDeleted ? '' : ' where recordDelete_timeMillis is null '}
|
||||
order by orderNumber, burialSiteStatus`)
|
||||
.all();
|
||||
let expectedOrderNumber = 0;
|
||||
for (const status of statuses) {
|
||||
if (status.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber('BurialSiteStatuses', status.burialSiteStatusId, expectedOrderNumber, database);
|
||||
status.orderNumber = expectedOrderNumber;
|
||||
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;
|
||||
}
|
||||
expectedOrderNumber += 1;
|
||||
}
|
||||
database.close();
|
||||
return statuses;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue