Compare commits
No commits in common. "main" and "v1.0.0-alpha.1" have entirely different histories.
main
...
v1.0.0-alp
|
|
@ -10,7 +10,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
node: [ 20, 22, 23 ]
|
node: [ 18, 20, 22, 23 ]
|
||||||
env:
|
env:
|
||||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
||||||
|
|
@ -25,12 +25,11 @@ jobs:
|
||||||
|
|
||||||
- name: Install Application
|
- name: Install Application
|
||||||
run: |
|
run: |
|
||||||
npm uninstall puppeteer
|
|
||||||
npm ci
|
npm ci
|
||||||
npm install -g mocha c8 cypress@14
|
npm install -g mocha c8 cypress@14
|
||||||
|
|
||||||
- name: Copy Test Config
|
- name: Copy Test Config
|
||||||
run: cp ./data/testing.config.js ./data/config.js
|
run: cp ./data/config.testing.js ./data/config.js
|
||||||
|
|
||||||
- name: Test Application Startup
|
- name: Test Application Startup
|
||||||
run: npm run test:startup
|
run: npm run test:startup
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"reject": ["puppeteer"]
|
|
||||||
}
|
|
||||||
29
README.md
29
README.md
|
|
@ -5,28 +5,25 @@
|
||||||
[](https://cloud.cypress.io/projects/26a4bi/runs)
|
[](https://cloud.cypress.io/projects/26a4bi/runs)
|
||||||
[](https://github.com/cityssm/sunrise-cms/actions/workflows/coverage.yml)
|
[](https://github.com/cityssm/sunrise-cms/actions/workflows/coverage.yml)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
🚧 **In development** 🚧
|
🚧 **In development** 🚧
|
||||||
|
|
||||||
**A web-based application to assist cemetery managers with managing their cemetery records.**
|
**A web-based application to assist cemetery managers with managing their cemetery records.**
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
This is a major refactoring of the now archived
|
This is a major refactoring of the now archived
|
||||||
[Lot Occupancy System](https://github.com/cityssm/lot-occupancy-system),
|
[Lot Occupancy System](https://github.com/cityssm/lot-occupancy-system),
|
||||||
originally built with multiple focuses in mind. This fork completely reworks the project
|
originally built with multiple focuses in mind. This fork completely reworks the project
|
||||||
to focus exculsively on cemetery management.
|
to focus exculsively on cemetery management.
|
||||||
|
|
||||||
[**User Documentation (In the Works)**](./docs/README.md)
|
|
||||||
|
|
||||||
## Why Sunrise CMS?
|
## Why Sunrise CMS?
|
||||||
|
|
||||||
### ✔️ Cemetery Maps are NOT Required
|
### ✔️ Cemetery Maps are NOT Required
|
||||||
|
|
||||||
Many cemetery applications rely on maps to drill down into burial sites.
|
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
|
### ✔️ The System Requirements are Very Low
|
||||||
|
|
||||||
|
|
@ -34,22 +31,12 @@ Sunrise CMS does not need an expensive server to run.
|
||||||
No separate database server is required either.
|
No separate database server is required either.
|
||||||
The whole application could run on a current, modest workstation.
|
The whole application could run on a current, modest workstation.
|
||||||
|
|
||||||
### ✔️ 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 Simple Built-In Work Order System
|
|
||||||
|
|
||||||
In addition to tracking data related to cemetery plots,
|
|
||||||
Sunrise CMS can also track work order activities, like interments and grave maintenance.
|
|
||||||
|
|
||||||
### ✔️ Sunrise CMS is Free and Open Source
|
### ✔️ Sunrise CMS is Free and Open Source
|
||||||
|
|
||||||
There's no cost to use it.
|
There's no cost to use it.
|
||||||
|
|
||||||
## About this Project
|
## About this Project
|
||||||
|
|
||||||
- 📘 [Documentation](./docs/README.md)
|
|
||||||
- 🤗 [Code of Conduct](CODE_OF_CONDUCT.md)
|
- 🤗 [Code of Conduct](CODE_OF_CONDUCT.md)
|
||||||
- 🥰 [Contributing Guidelines](CONTRIBUTING.md)
|
- 🥰 [Contributing Guidelines](CONTRIBUTING.md)
|
||||||
- 🛡️ [Security Policy](SECURITY.md)
|
- 🛡️ [Security Policy](SECURITY.md)
|
||||||
|
|
@ -58,13 +45,3 @@ There's no cost to use it.
|
||||||
Although the system is quite niche, it's being released in an open source environment in hopes to pool developer resources from other municipalities looking to move away from older, legacy systems.
|
Although the system is quite niche, it's being released in an open source environment in hopes to pool developer resources from other municipalities looking to move away from older, legacy systems.
|
||||||
|
|
||||||
It is being shared to start the dialog among other municipalities and present an option to those who may be looking to refresh their own cemetery systems.
|
It is being shared to start the dialog among other municipalities and present an option to those who may be looking to refresh their own cemetery systems.
|
||||||
|
|
||||||
## More City Management Applications from the City of Sault Ste. Marie
|
|
||||||
|
|
||||||
[**General Licence Manager**](https://cityssm.github.io/general-licence-manager/)<br />
|
|
||||||
An application built to manage the general licences issued by municipalities.
|
|
||||||
|
|
||||||
[**Attendance Tracking**](https://cityssm.github.io/attendance-tracking/)<br />
|
|
||||||
Track employee absences, call outs, and more.
|
|
||||||
|
|
||||||
💡 Discover even more on [the City of Sault Ste. Marie's GitHub page](https://cityssm.github.io/).
|
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
theme: jekyll-theme-cayman
|
theme: jekyll-theme-cayman
|
||||||
title: Sunrise Cemetery Management System (CMS)
|
title: Sunrise Cemetery Management System
|
||||||
10
app.js
10
app.js
|
|
@ -10,12 +10,11 @@ import rateLimit from 'express-rate-limit';
|
||||||
import session from 'express-session';
|
import session from 'express-session';
|
||||||
import createError from 'http-errors';
|
import createError from 'http-errors';
|
||||||
import FileStore from 'session-file-store';
|
import FileStore from 'session-file-store';
|
||||||
import dataLists from './data/dataLists.js';
|
|
||||||
import { DEBUG_NAMESPACE } from './debug.config.js';
|
import { DEBUG_NAMESPACE } from './debug.config.js';
|
||||||
import * as permissionHandlers from './handlers/permissions.js';
|
import * as permissionHandlers from './handlers/permissions.js';
|
||||||
import { getSafeRedirectURL } from './helpers/authentication.helpers.js';
|
|
||||||
import * as configFunctions from './helpers/config.helpers.js';
|
import * as configFunctions from './helpers/config.helpers.js';
|
||||||
import { useTestDatabases } from './helpers/database.helpers.js';
|
import { useTestDatabases } from './helpers/database.helpers.js';
|
||||||
|
import { getSafeRedirectURL } from './helpers/functions.authentication.js';
|
||||||
import * as printFunctions from './helpers/functions.print.js';
|
import * as printFunctions from './helpers/functions.print.js';
|
||||||
import routerAdmin from './routes/admin.js';
|
import routerAdmin from './routes/admin.js';
|
||||||
import routerApi from './routes/api.js';
|
import routerApi from './routes/api.js';
|
||||||
|
|
@ -29,7 +28,7 @@ import routerPrint from './routes/print.js';
|
||||||
import routerReports from './routes/reports.js';
|
import routerReports from './routes/reports.js';
|
||||||
import routerWorkOrders from './routes/workOrders.js';
|
import routerWorkOrders from './routes/workOrders.js';
|
||||||
import { version } from './version.js';
|
import { version } from './version.js';
|
||||||
const debug = Debug(`${DEBUG_NAMESPACE}:app:${process.pid.toString().padEnd(5)}`);
|
const debug = Debug(`${DEBUG_NAMESPACE}:app:${process.pid}`);
|
||||||
/*
|
/*
|
||||||
* INITIALIZE APP
|
* INITIALIZE APP
|
||||||
*/
|
*/
|
||||||
|
|
@ -80,7 +79,7 @@ app.use(session({
|
||||||
},
|
},
|
||||||
secret: configFunctions.getConfigProperty('session.secret'),
|
secret: configFunctions.getConfigProperty('session.secret'),
|
||||||
store: new FileStoreSession({
|
store: new FileStoreSession({
|
||||||
logFn: Debug(`${DEBUG_NAMESPACE}:session:${process.pid.toString().padEnd(5)}`),
|
logFn: Debug(`${DEBUG_NAMESPACE}:session:${process.pid}`),
|
||||||
path: './data/sessions',
|
path: './data/sessions',
|
||||||
retries: 20
|
retries: 20
|
||||||
}),
|
}),
|
||||||
|
|
@ -110,7 +109,7 @@ app.use(`${urlPrefix}/internal`, (request, response, next) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
response.sendStatus(403);
|
response.sendStatus(403);
|
||||||
}, express.static(configFunctions.getConfigProperty('settings.publicInternalPath')));
|
}, express.static(path.join('public-internal')));
|
||||||
app.use(urlPrefix, express.static(path.join('public')));
|
app.use(urlPrefix, express.static(path.join('public')));
|
||||||
app.use(`${urlPrefix}/lib/bulma`, express.static(path.join('node_modules', 'bulma', 'css')));
|
app.use(`${urlPrefix}/lib/bulma`, express.static(path.join('node_modules', 'bulma', 'css')));
|
||||||
app.use(`${urlPrefix}/lib/bulma-tooltip`, express.static(path.join('node_modules', 'bulma-tooltip', 'dist', 'css')));
|
app.use(`${urlPrefix}/lib/bulma-tooltip`, express.static(path.join('node_modules', 'bulma-tooltip', 'dist', 'css')));
|
||||||
|
|
@ -142,7 +141,6 @@ app.use((request, response, next) => {
|
||||||
response.locals.configFunctions = configFunctions;
|
response.locals.configFunctions = configFunctions;
|
||||||
response.locals.printFunctions = printFunctions;
|
response.locals.printFunctions = printFunctions;
|
||||||
response.locals.dateTimeFunctions = dateTimeFunctions;
|
response.locals.dateTimeFunctions = dateTimeFunctions;
|
||||||
response.locals.dataLists = dataLists;
|
|
||||||
response.locals.urlPrefix = configFunctions.getConfigProperty('reverseProxy.urlPrefix');
|
response.locals.urlPrefix = configFunctions.getConfigProperty('reverseProxy.urlPrefix');
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
11
app.ts
11
app.ts
|
|
@ -12,12 +12,11 @@ import session from 'express-session'
|
||||||
import createError from 'http-errors'
|
import createError from 'http-errors'
|
||||||
import FileStore from 'session-file-store'
|
import FileStore from 'session-file-store'
|
||||||
|
|
||||||
import dataLists from './data/dataLists.js'
|
|
||||||
import { DEBUG_NAMESPACE } from './debug.config.js'
|
import { DEBUG_NAMESPACE } from './debug.config.js'
|
||||||
import * as permissionHandlers from './handlers/permissions.js'
|
import * as permissionHandlers from './handlers/permissions.js'
|
||||||
import { getSafeRedirectURL } from './helpers/authentication.helpers.js'
|
|
||||||
import * as configFunctions from './helpers/config.helpers.js'
|
import * as configFunctions from './helpers/config.helpers.js'
|
||||||
import { useTestDatabases } from './helpers/database.helpers.js'
|
import { useTestDatabases } from './helpers/database.helpers.js'
|
||||||
|
import { getSafeRedirectURL } from './helpers/functions.authentication.js'
|
||||||
import * as printFunctions from './helpers/functions.print.js'
|
import * as printFunctions from './helpers/functions.print.js'
|
||||||
import routerAdmin from './routes/admin.js'
|
import routerAdmin from './routes/admin.js'
|
||||||
import routerApi from './routes/api.js'
|
import routerApi from './routes/api.js'
|
||||||
|
|
@ -32,7 +31,7 @@ import routerReports from './routes/reports.js'
|
||||||
import routerWorkOrders from './routes/workOrders.js'
|
import routerWorkOrders from './routes/workOrders.js'
|
||||||
import { version } from './version.js'
|
import { version } from './version.js'
|
||||||
|
|
||||||
const debug = Debug(`${DEBUG_NAMESPACE}:app:${process.pid.toString().padEnd(5)}`)
|
const debug = Debug(`${DEBUG_NAMESPACE}:app:${process.pid}`)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* INITIALIZE APP
|
* INITIALIZE APP
|
||||||
|
|
@ -108,7 +107,7 @@ app.use(
|
||||||
},
|
},
|
||||||
secret: configFunctions.getConfigProperty('session.secret'),
|
secret: configFunctions.getConfigProperty('session.secret'),
|
||||||
store: new FileStoreSession({
|
store: new FileStoreSession({
|
||||||
logFn: Debug(`${DEBUG_NAMESPACE}:session:${process.pid.toString().padEnd(5)}`),
|
logFn: Debug(`${DEBUG_NAMESPACE}:session:${process.pid}`),
|
||||||
path: './data/sessions',
|
path: './data/sessions',
|
||||||
retries: 20
|
retries: 20
|
||||||
}),
|
}),
|
||||||
|
|
@ -154,7 +153,7 @@ app.use(
|
||||||
|
|
||||||
response.sendStatus(403)
|
response.sendStatus(403)
|
||||||
},
|
},
|
||||||
express.static(configFunctions.getConfigProperty('settings.publicInternalPath'))
|
express.static(path.join('public-internal'))
|
||||||
)
|
)
|
||||||
|
|
||||||
app.use(urlPrefix, express.static(path.join('public')))
|
app.use(urlPrefix, express.static(path.join('public')))
|
||||||
|
|
@ -245,8 +244,6 @@ app.use((request, response, next) => {
|
||||||
response.locals.printFunctions = printFunctions
|
response.locals.printFunctions = printFunctions
|
||||||
response.locals.dateTimeFunctions = dateTimeFunctions
|
response.locals.dateTimeFunctions = dateTimeFunctions
|
||||||
|
|
||||||
response.locals.dataLists = dataLists
|
|
||||||
|
|
||||||
response.locals.urlPrefix = configFunctions.getConfigProperty(
|
response.locals.urlPrefix = configFunctions.getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)
|
)
|
||||||
|
|
|
||||||
38
bin/www.js
38
bin/www.js
|
|
@ -9,23 +9,19 @@ import exitHook from 'exit-hook';
|
||||||
import { initializeDatabase } from '../database/initializeDatabase.js';
|
import { initializeDatabase } from '../database/initializeDatabase.js';
|
||||||
import { DEBUG_NAMESPACE } from '../debug.config.js';
|
import { DEBUG_NAMESPACE } from '../debug.config.js';
|
||||||
import { getConfigProperty } from '../helpers/config.helpers.js';
|
import { getConfigProperty } from '../helpers/config.helpers.js';
|
||||||
import version from '../version.js';
|
|
||||||
const debug = Debug(`${DEBUG_NAMESPACE}:www:${process.pid}`);
|
const debug = Debug(`${DEBUG_NAMESPACE}:www:${process.pid}`);
|
||||||
// INITIALIZE THE DATABASE
|
// INITIALIZE THE DATABASE
|
||||||
initializeDatabase();
|
await initializeDatabase();
|
||||||
const directoryName = path.dirname(fileURLToPath(import.meta.url));
|
const directoryName = path.dirname(fileURLToPath(import.meta.url));
|
||||||
const processCount = Math.min(getConfigProperty('application.maximumProcesses'), os.cpus().length * 2);
|
const processCount = Math.min(getConfigProperty('application.maximumProcesses'), os.cpus().length);
|
||||||
const applicationName = getConfigProperty('application.applicationName');
|
process.title = `${getConfigProperty('application.applicationName')} (Primary)`;
|
||||||
process.title = `${applicationName} (Primary)`;
|
|
||||||
debug(`Primary pid: ${process.pid}`);
|
debug(`Primary pid: ${process.pid}`);
|
||||||
debug(`Primary title: ${process.title}`);
|
debug(`Primary title: ${process.title}`);
|
||||||
debug(`Version: ${version}`);
|
|
||||||
debug(`Launching ${processCount} processes`);
|
debug(`Launching ${processCount} processes`);
|
||||||
const clusterSettings = {
|
const clusterSettings = {
|
||||||
exec: `${directoryName}/wwwProcess.js`
|
exec: `${directoryName}/wwwProcess.js`
|
||||||
};
|
};
|
||||||
cluster.setupPrimary(clusterSettings);
|
cluster.setupPrimary(clusterSettings);
|
||||||
let doShutdown = false;
|
|
||||||
const activeWorkers = new Map();
|
const activeWorkers = new Map();
|
||||||
for (let index = 0; index < processCount; index += 1) {
|
for (let index = 0; index < processCount; index += 1) {
|
||||||
const worker = cluster.fork();
|
const worker = cluster.fork();
|
||||||
|
|
@ -44,27 +40,24 @@ cluster.on('message', (worker, message) => {
|
||||||
cluster.on('exit', (worker) => {
|
cluster.on('exit', (worker) => {
|
||||||
debug(`Worker ${(worker.process.pid ?? 0).toString()} has been killed`);
|
debug(`Worker ${(worker.process.pid ?? 0).toString()} has been killed`);
|
||||||
activeWorkers.delete(worker.process.pid ?? 0);
|
activeWorkers.delete(worker.process.pid ?? 0);
|
||||||
if (!doShutdown) {
|
debug('Starting another worker');
|
||||||
debug('Starting another worker');
|
cluster.fork();
|
||||||
const newWorker = cluster.fork();
|
|
||||||
activeWorkers.set(newWorker.process.pid ?? 0, newWorker);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
const ntfyStartupConfig = getConfigProperty('application.ntfyStartup');
|
const ntfyStartupConfig = getConfigProperty('application.ntfyStartup');
|
||||||
if (ntfyStartupConfig !== undefined) {
|
if (ntfyStartupConfig !== undefined) {
|
||||||
const topic = ntfyStartupConfig.topic;
|
const topic = ntfyStartupConfig.topic;
|
||||||
const server = ntfyStartupConfig.server;
|
const server = ntfyStartupConfig.server;
|
||||||
const ntfyStartupMessage = {
|
const ntfyStartupMessage = {
|
||||||
|
topic,
|
||||||
|
title: getConfigProperty('application.applicationName'),
|
||||||
message: 'Application Started',
|
message: 'Application Started',
|
||||||
tags: ['arrow_up'],
|
tags: ['arrow_up']
|
||||||
title: applicationName,
|
|
||||||
topic
|
|
||||||
};
|
};
|
||||||
const ntfyShutdownMessage = {
|
const ntfyShutdownMessage = {
|
||||||
|
topic,
|
||||||
|
title: getConfigProperty('application.applicationName'),
|
||||||
message: 'Application Shut Down',
|
message: 'Application Shut Down',
|
||||||
tags: ['arrow_down'],
|
tags: ['arrow_down']
|
||||||
title: applicationName,
|
|
||||||
topic
|
|
||||||
};
|
};
|
||||||
if (server !== undefined) {
|
if (server !== undefined) {
|
||||||
ntfyStartupMessage.server = server;
|
ntfyStartupMessage.server = server;
|
||||||
|
|
@ -81,16 +74,7 @@ if (process.env.STARTUP_TEST === 'true') {
|
||||||
debug(`Killing processes in ${killSeconds} seconds...`);
|
debug(`Killing processes in ${killSeconds} seconds...`);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
debug('Killing processes');
|
debug('Killing processes');
|
||||||
doShutdown = true;
|
|
||||||
// eslint-disable-next-line unicorn/no-process-exit
|
// eslint-disable-next-line unicorn/no-process-exit
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}, secondsToMillis(killSeconds));
|
}, secondsToMillis(killSeconds));
|
||||||
}
|
}
|
||||||
exitHook(() => {
|
|
||||||
doShutdown = true;
|
|
||||||
debug('Shutting down...');
|
|
||||||
for (const worker of activeWorkers.values()) {
|
|
||||||
debug(`Killing worker ${worker.process.pid}`);
|
|
||||||
worker.kill();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
|
||||||
45
bin/www.ts
45
bin/www.ts
|
|
@ -11,28 +11,24 @@ import exitHook from 'exit-hook'
|
||||||
import { initializeDatabase } from '../database/initializeDatabase.js'
|
import { initializeDatabase } from '../database/initializeDatabase.js'
|
||||||
import { DEBUG_NAMESPACE } from '../debug.config.js'
|
import { DEBUG_NAMESPACE } from '../debug.config.js'
|
||||||
import { getConfigProperty } from '../helpers/config.helpers.js'
|
import { getConfigProperty } from '../helpers/config.helpers.js'
|
||||||
import type { WorkerMessage } from '../types/application.types.js'
|
import type { WorkerMessage } from '../types/applicationTypes.js'
|
||||||
import version from '../version.js'
|
|
||||||
|
|
||||||
const debug = Debug(`${DEBUG_NAMESPACE}:www:${process.pid}`)
|
const debug = Debug(`${DEBUG_NAMESPACE}:www:${process.pid}`)
|
||||||
|
|
||||||
// INITIALIZE THE DATABASE
|
// INITIALIZE THE DATABASE
|
||||||
initializeDatabase()
|
await initializeDatabase()
|
||||||
|
|
||||||
const directoryName = path.dirname(fileURLToPath(import.meta.url))
|
const directoryName = path.dirname(fileURLToPath(import.meta.url))
|
||||||
|
|
||||||
const processCount = Math.min(
|
const processCount = Math.min(
|
||||||
getConfigProperty('application.maximumProcesses'),
|
getConfigProperty('application.maximumProcesses'),
|
||||||
os.cpus().length * 2
|
os.cpus().length
|
||||||
)
|
)
|
||||||
|
|
||||||
const applicationName = getConfigProperty('application.applicationName')
|
process.title = `${getConfigProperty('application.applicationName')} (Primary)`
|
||||||
|
|
||||||
process.title = `${applicationName} (Primary)`
|
|
||||||
|
|
||||||
debug(`Primary pid: ${process.pid}`)
|
debug(`Primary pid: ${process.pid}`)
|
||||||
debug(`Primary title: ${process.title}`)
|
debug(`Primary title: ${process.title}`)
|
||||||
debug(`Version: ${version}`)
|
|
||||||
debug(`Launching ${processCount} processes`)
|
debug(`Launching ${processCount} processes`)
|
||||||
|
|
||||||
const clusterSettings = {
|
const clusterSettings = {
|
||||||
|
|
@ -41,7 +37,6 @@ const clusterSettings = {
|
||||||
|
|
||||||
cluster.setupPrimary(clusterSettings)
|
cluster.setupPrimary(clusterSettings)
|
||||||
|
|
||||||
let doShutdown = false
|
|
||||||
const activeWorkers = new Map<number, Worker>()
|
const activeWorkers = new Map<number, Worker>()
|
||||||
|
|
||||||
for (let index = 0; index < processCount; index += 1) {
|
for (let index = 0; index < processCount; index += 1) {
|
||||||
|
|
@ -65,12 +60,8 @@ cluster.on('exit', (worker) => {
|
||||||
debug(`Worker ${(worker.process.pid ?? 0).toString()} has been killed`)
|
debug(`Worker ${(worker.process.pid ?? 0).toString()} has been killed`)
|
||||||
activeWorkers.delete(worker.process.pid ?? 0)
|
activeWorkers.delete(worker.process.pid ?? 0)
|
||||||
|
|
||||||
if (!doShutdown) {
|
debug('Starting another worker')
|
||||||
debug('Starting another worker')
|
cluster.fork()
|
||||||
const newWorker = cluster.fork()
|
|
||||||
|
|
||||||
activeWorkers.set(newWorker.process.pid ?? 0, newWorker)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const ntfyStartupConfig = getConfigProperty('application.ntfyStartup')
|
const ntfyStartupConfig = getConfigProperty('application.ntfyStartup')
|
||||||
|
|
@ -80,17 +71,17 @@ if (ntfyStartupConfig !== undefined) {
|
||||||
const server = ntfyStartupConfig.server
|
const server = ntfyStartupConfig.server
|
||||||
|
|
||||||
const ntfyStartupMessage: NtfyMessageOptions = {
|
const ntfyStartupMessage: NtfyMessageOptions = {
|
||||||
|
topic,
|
||||||
|
title: getConfigProperty('application.applicationName'),
|
||||||
message: 'Application Started',
|
message: 'Application Started',
|
||||||
tags: ['arrow_up'],
|
tags: ['arrow_up']
|
||||||
title: applicationName,
|
|
||||||
topic
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ntfyShutdownMessage: NtfyMessageOptions = {
|
const ntfyShutdownMessage: NtfyMessageOptions = {
|
||||||
|
topic,
|
||||||
|
title: getConfigProperty('application.applicationName'),
|
||||||
message: 'Application Shut Down',
|
message: 'Application Shut Down',
|
||||||
tags: ['arrow_down'],
|
tags: ['arrow_down']
|
||||||
title: applicationName,
|
|
||||||
topic
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server !== undefined) {
|
if (server !== undefined) {
|
||||||
|
|
@ -114,19 +105,7 @@ if (process.env.STARTUP_TEST === 'true') {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
debug('Killing processes')
|
debug('Killing processes')
|
||||||
|
|
||||||
doShutdown = true
|
|
||||||
|
|
||||||
// eslint-disable-next-line unicorn/no-process-exit
|
// eslint-disable-next-line unicorn/no-process-exit
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
}, secondsToMillis(killSeconds))
|
}, secondsToMillis(killSeconds))
|
||||||
}
|
}
|
||||||
|
|
||||||
exitHook(() => {
|
|
||||||
doShutdown = true
|
|
||||||
debug('Shutting down...')
|
|
||||||
|
|
||||||
for (const worker of activeWorkers.values()) {
|
|
||||||
debug(`Killing worker ${worker.process.pid}`)
|
|
||||||
worker.kill()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,10 @@ import { app } from '../app.js';
|
||||||
import { initializeDatabase } from '../database/initializeDatabase.js';
|
import { initializeDatabase } from '../database/initializeDatabase.js';
|
||||||
import { DEBUG_NAMESPACE } from '../debug.config.js';
|
import { DEBUG_NAMESPACE } from '../debug.config.js';
|
||||||
import { getConfigProperty } from '../helpers/config.helpers.js';
|
import { getConfigProperty } from '../helpers/config.helpers.js';
|
||||||
const debug = Debug(`${DEBUG_NAMESPACE}:wwwProcess:${process.pid.toString().padEnd(5)}`);
|
const debug = Debug(`${DEBUG_NAMESPACE}:wwwProcess:${process.pid}`);
|
||||||
if (process.send === undefined) {
|
if (process.send === undefined) {
|
||||||
// INITIALIZE THE DATABASE
|
// INITIALIZE THE DATABASE
|
||||||
initializeDatabase();
|
await initializeDatabase();
|
||||||
}
|
}
|
||||||
function onError(error) {
|
function onError(error) {
|
||||||
if (error.syscall !== 'listen') {
|
if (error.syscall !== 'listen') {
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,11 @@ import { initializeDatabase } from '../database/initializeDatabase.js'
|
||||||
import { DEBUG_NAMESPACE } from '../debug.config.js'
|
import { DEBUG_NAMESPACE } from '../debug.config.js'
|
||||||
import { getConfigProperty } from '../helpers/config.helpers.js'
|
import { getConfigProperty } from '../helpers/config.helpers.js'
|
||||||
|
|
||||||
const debug = Debug(`${DEBUG_NAMESPACE}:wwwProcess:${process.pid.toString().padEnd(5)}`)
|
const debug = Debug(`${DEBUG_NAMESPACE}:wwwProcess:${process.pid}`)
|
||||||
|
|
||||||
if (process.send === undefined) {
|
if (process.send === undefined) {
|
||||||
// INITIALIZE THE DATABASE
|
// INITIALIZE THE DATABASE
|
||||||
initializeDatabase()
|
await initializeDatabase()
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ServerError extends Error {
|
interface ServerError extends Error {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { getConfigProperty } from '../../../helpers/config.helpers.js'
|
import { getConfigProperty } from '../../../helpers/config.helpers.js'
|
||||||
import { testAdmin } from '../../../test/_globals.js'
|
import { testAdmin } from '../../../test/_globals.js'
|
||||||
import type { Fee } from '../../../types/record.types.js'
|
import type { Fee } from '../../../types/recordTypes.js'
|
||||||
import { ajaxDelayMillis, login, logout } from '../../support/index.js'
|
import { ajaxDelayMillis, login, logout } from '../../support/index.js'
|
||||||
|
|
||||||
describe('Admin - Fee Management', () => {
|
describe('Admin - Fee Management', () => {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { getConfigProperty } from '../../../helpers/config.helpers.js'
|
import { getConfigProperty } from '../../../helpers/config.helpers.js'
|
||||||
import { testUpdate } from '../../../test/_globals.js'
|
import { testUpdate } from '../../../test/_globals.js'
|
||||||
import type { Cemetery } from '../../../types/record.types.js'
|
import type { Cemetery } from '../../../types/recordTypes.js'
|
||||||
import { login, logout } from '../../support/index.js'
|
import { login, logout } from '../../support/index.js'
|
||||||
|
|
||||||
describe('Update - Cemeteries', () => {
|
describe('Update - Cemeteries', () => {
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export {};
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
import { testUpdate } from '../../../test/_globals.js';
|
|
||||||
import { login, logout } from '../../support/index.js';
|
|
||||||
describe('Update - Funeral Homes', () => {
|
|
||||||
beforeEach('Loads page', () => {
|
|
||||||
logout();
|
|
||||||
login(testUpdate);
|
|
||||||
});
|
|
||||||
afterEach(logout);
|
|
||||||
it('Has a "Create" link on the Funeral Home Search', () => {
|
|
||||||
cy.visit('/funeralHomes');
|
|
||||||
cy.location('pathname').should('equal', '/funeralHomes');
|
|
||||||
cy.get("a[href$='/funeralHomes/new']").should('exist');
|
|
||||||
});
|
|
||||||
describe('Creates a New Funeral Home', () => {
|
|
||||||
it('Has no detectable accessibility issues', () => {
|
|
||||||
cy.visit('/funeralHomes/new');
|
|
||||||
cy.injectAxe();
|
|
||||||
cy.checkA11y();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
import { testUpdate } from '../../../test/_globals.js'
|
|
||||||
import { login, logout } from '../../support/index.js'
|
|
||||||
|
|
||||||
describe('Update - Funeral Homes', () => {
|
|
||||||
beforeEach('Loads page', () => {
|
|
||||||
logout()
|
|
||||||
login(testUpdate)
|
|
||||||
})
|
|
||||||
|
|
||||||
afterEach(logout)
|
|
||||||
|
|
||||||
it('Has a "Create" link on the Funeral Home Search', () => {
|
|
||||||
cy.visit('/funeralHomes')
|
|
||||||
cy.location('pathname').should('equal', '/funeralHomes')
|
|
||||||
cy.get("a[href$='/funeralHomes/new']").should('exist')
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('Creates a New Funeral Home', () => {
|
|
||||||
it('Has no detectable accessibility issues', () => {
|
|
||||||
cy.visit('/funeralHomes/new')
|
|
||||||
cy.injectAxe()
|
|
||||||
cy.checkA11y()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
import type { Config } from '../types/config.types.js';
|
import type { Config } from '../types/configTypes.js';
|
||||||
export declare const config: Config;
|
export declare const config: Config;
|
||||||
export default config;
|
export default config;
|
||||||
|
|
@ -6,8 +6,6 @@ export const config = {
|
||||||
settings: {
|
settings: {
|
||||||
adminCleanup: {},
|
adminCleanup: {},
|
||||||
burialSites: {},
|
burialSites: {},
|
||||||
burialSiteTypes: {},
|
|
||||||
cemeteries: {},
|
|
||||||
contracts: {},
|
contracts: {},
|
||||||
dynamicsGP: {
|
dynamicsGP: {
|
||||||
integrationIsEnabled: false
|
integrationIsEnabled: false
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type { Config } from '../types/config.types.js'
|
import type { Config } from '../types/configTypes.js'
|
||||||
|
|
||||||
export const config: Config = {
|
export const config: Config = {
|
||||||
aliases: {},
|
aliases: {},
|
||||||
|
|
@ -8,8 +8,6 @@ export const config: Config = {
|
||||||
settings: {
|
settings: {
|
||||||
adminCleanup: {},
|
adminCleanup: {},
|
||||||
burialSites: {},
|
burialSites: {},
|
||||||
burialSiteTypes: {},
|
|
||||||
cemeteries: {},
|
|
||||||
contracts: {},
|
contracts: {},
|
||||||
dynamicsGP: {
|
dynamicsGP: {
|
||||||
integrationIsEnabled: false
|
integrationIsEnabled: false
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
export declare const config: import("../types/configTypes.js").Config;
|
||||||
|
export default config;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { config as baseConfig } from './base.config.js';
|
import { config as baseConfig } from './config.base.js';
|
||||||
export const config = Object.assign({}, baseConfig);
|
export const config = Object.assign({}, baseConfig);
|
||||||
config.settings.provinceDefault = 'ON';
|
config.settings.provinceDefault = 'ON';
|
||||||
config.settings.latitudeMax = 56.85;
|
config.settings.latitudeMax = 56.85;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { config as baseConfig } from './base.config.js'
|
import { config as baseConfig } from './config.base.js'
|
||||||
|
|
||||||
export const config = Object.assign({}, baseConfig)
|
export const config = Object.assign({}, baseConfig)
|
||||||
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
import type { Config } from '../types/config.types.js';
|
import type { Config } from '../types/configTypes.js';
|
||||||
export declare const config: Config;
|
export declare const config: Config;
|
||||||
export default config;
|
export default config;
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
import { config as cemeteryConfig } from './ontario.config.js';
|
import { config as cemeteryConfig } from './config.baseOntario.js';
|
||||||
export const config = { ...cemeteryConfig };
|
export const config = { ...cemeteryConfig };
|
||||||
config.aliases.externalReceiptNumber = 'GP Receipt Number';
|
config.aliases.externalReceiptNumber = 'GP Receipt Number';
|
||||||
config.settings.publicInternalPath =
|
|
||||||
'../sunrise-cms-saultstemarie/public-internal';
|
|
||||||
config.settings.burialSites.burialSiteNameSegments = {
|
config.settings.burialSites.burialSiteNameSegments = {
|
||||||
includeCemeteryKey: true,
|
includeCemeteryKey: true,
|
||||||
separator: '-',
|
separator: '-',
|
||||||
|
|
@ -1,18 +1,15 @@
|
||||||
import type { Config } from '../types/config.types.js'
|
import type { Config } from '../types/configTypes.js'
|
||||||
|
|
||||||
import { config as cemeteryConfig } from './ontario.config.js'
|
import { config as cemeteryConfig } from './config.baseOntario.js'
|
||||||
|
|
||||||
export const config: Config = { ...cemeteryConfig }
|
export const config: Config = { ...cemeteryConfig }
|
||||||
|
|
||||||
config.aliases.externalReceiptNumber = 'GP Receipt Number'
|
config.aliases.externalReceiptNumber = 'GP Receipt Number'
|
||||||
|
|
||||||
config.settings.publicInternalPath =
|
|
||||||
'../sunrise-cms-saultstemarie/public-internal'
|
|
||||||
|
|
||||||
config.settings.burialSites.burialSiteNameSegments = {
|
config.settings.burialSites.burialSiteNameSegments = {
|
||||||
includeCemeteryKey: true,
|
includeCemeteryKey: true,
|
||||||
separator: '-',
|
separator: '-',
|
||||||
|
|
||||||
segments: {
|
segments: {
|
||||||
1: {
|
1: {
|
||||||
isAvailable: true,
|
isAvailable: true,
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import type { config as MSSQLConfig } from 'mssql';
|
import type { config as MSSQLConfig } from 'mssql';
|
||||||
import type { ConfigActiveDirectory, ConfigBurialSiteNameSegments, ConfigNtfyStartup, DynamicsGPLookup } from '../types/config.types.js';
|
import type { ConfigActiveDirectory, ConfigBurialSiteNameSegments, ConfigNtfyStartup, DynamicsGPLookup } from '../types/configTypes.js';
|
||||||
export declare const configDefaultValues: {
|
export declare const configDefaultValues: {
|
||||||
activeDirectory: ConfigActiveDirectory;
|
activeDirectory: ConfigActiveDirectory;
|
||||||
'application.applicationName': string;
|
'application.applicationName': string;
|
||||||
|
|
@ -19,7 +19,6 @@ export declare const configDefaultValues: {
|
||||||
'session.secret': string;
|
'session.secret': string;
|
||||||
'users.canLogin': string[];
|
'users.canLogin': string[];
|
||||||
'users.canUpdate': string[];
|
'users.canUpdate': string[];
|
||||||
'users.canUpdateWorkOrders': string[];
|
|
||||||
'users.isAdmin': string[];
|
'users.isAdmin': string[];
|
||||||
'users.testing': string[];
|
'users.testing': string[];
|
||||||
'aliases.externalReceiptNumber': string;
|
'aliases.externalReceiptNumber': string;
|
||||||
|
|
@ -27,20 +26,17 @@ export declare const configDefaultValues: {
|
||||||
'aliases.workOrderOpenDate': string;
|
'aliases.workOrderOpenDate': string;
|
||||||
'settings.cityDefault': string;
|
'settings.cityDefault': string;
|
||||||
'settings.provinceDefault': string;
|
'settings.provinceDefault': string;
|
||||||
'settings.publicInternalPath': string;
|
|
||||||
'settings.latitudeMax': number;
|
'settings.latitudeMax': number;
|
||||||
'settings.latitudeMin': number;
|
'settings.latitudeMin': number;
|
||||||
'settings.longitudeMax': number;
|
'settings.longitudeMax': number;
|
||||||
'settings.longitudeMin': number;
|
'settings.longitudeMin': number;
|
||||||
'settings.cemeteries.refreshImageChanges': boolean;
|
|
||||||
'settings.burialSiteTypes.bodyCapacityMaxDefault': number;
|
|
||||||
'settings.burialSiteTypes.crematedCapacityMaxDefault': number;
|
|
||||||
'settings.burialSites.burialSiteNameSegments': ConfigBurialSiteNameSegments;
|
'settings.burialSites.burialSiteNameSegments': ConfigBurialSiteNameSegments;
|
||||||
'settings.burialSites.burialSiteNameSegments.includeCemeteryKey': boolean;
|
'settings.burialSites.burialSiteNameSegments.includeCemeteryKey': boolean;
|
||||||
'settings.burialSites.refreshImageChanges': boolean;
|
|
||||||
'settings.contracts.burialSiteIdIsRequired': boolean;
|
'settings.contracts.burialSiteIdIsRequired': boolean;
|
||||||
'settings.contracts.contractEndDateIsRequired': boolean;
|
'settings.contracts.contractEndDateIsRequired': boolean;
|
||||||
|
'settings.contracts.deathAgePeriods': string[];
|
||||||
'settings.contracts.prints': string[];
|
'settings.contracts.prints': string[];
|
||||||
|
'settings.contracts.purchaserRelationships': string[];
|
||||||
'settings.fees.taxPercentageDefault': number;
|
'settings.fees.taxPercentageDefault': number;
|
||||||
'settings.workOrders.workOrderNumberLength': number;
|
'settings.workOrders.workOrderNumberLength': number;
|
||||||
'settings.workOrders.calendarEmailAddress': string;
|
'settings.workOrders.calendarEmailAddress': string;
|
||||||
|
|
@ -57,4 +53,3 @@ export declare const configDefaultValues: {
|
||||||
'settings.dynamicsGP.itemNumbers': string[];
|
'settings.dynamicsGP.itemNumbers': string[];
|
||||||
'settings.dynamicsGP.trialBalanceCodes': string[];
|
'settings.dynamicsGP.trialBalanceCodes': string[];
|
||||||
};
|
};
|
||||||
export default configDefaultValues;
|
|
||||||
|
|
@ -18,7 +18,6 @@ export const configDefaultValues = {
|
||||||
'session.secret': 'cityssm/sunrise',
|
'session.secret': 'cityssm/sunrise',
|
||||||
'users.canLogin': ['administrator'],
|
'users.canLogin': ['administrator'],
|
||||||
'users.canUpdate': [],
|
'users.canUpdate': [],
|
||||||
'users.canUpdateWorkOrders': [],
|
|
||||||
'users.isAdmin': ['administrator'],
|
'users.isAdmin': ['administrator'],
|
||||||
'users.testing': [],
|
'users.testing': [],
|
||||||
'aliases.externalReceiptNumber': 'External Receipt Number',
|
'aliases.externalReceiptNumber': 'External Receipt Number',
|
||||||
|
|
@ -26,16 +25,10 @@ export const configDefaultValues = {
|
||||||
'aliases.workOrderOpenDate': 'Order Date',
|
'aliases.workOrderOpenDate': 'Order Date',
|
||||||
'settings.cityDefault': '',
|
'settings.cityDefault': '',
|
||||||
'settings.provinceDefault': '',
|
'settings.provinceDefault': '',
|
||||||
'settings.publicInternalPath': 'public-internal',
|
|
||||||
'settings.latitudeMax': 90,
|
'settings.latitudeMax': 90,
|
||||||
'settings.latitudeMin': -90,
|
'settings.latitudeMin': -90,
|
||||||
'settings.longitudeMax': 180,
|
'settings.longitudeMax': 180,
|
||||||
'settings.longitudeMin': -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': {
|
'settings.burialSites.burialSiteNameSegments': {
|
||||||
includeCemeteryKey: false,
|
includeCemeteryKey: false,
|
||||||
separator: '-',
|
separator: '-',
|
||||||
|
|
@ -50,10 +43,23 @@ export const configDefaultValues = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'settings.burialSites.burialSiteNameSegments.includeCemeteryKey': false,
|
'settings.burialSites.burialSiteNameSegments.includeCemeteryKey': false,
|
||||||
'settings.burialSites.refreshImageChanges': false,
|
|
||||||
'settings.contracts.burialSiteIdIsRequired': true,
|
'settings.contracts.burialSiteIdIsRequired': true,
|
||||||
'settings.contracts.contractEndDateIsRequired': false,
|
'settings.contracts.contractEndDateIsRequired': false,
|
||||||
|
'settings.contracts.deathAgePeriods': [
|
||||||
|
'Years',
|
||||||
|
'Months',
|
||||||
|
'Days',
|
||||||
|
'Stillborn'
|
||||||
|
],
|
||||||
'settings.contracts.prints': ['screen/contract'],
|
'settings.contracts.prints': ['screen/contract'],
|
||||||
|
'settings.contracts.purchaserRelationships': [
|
||||||
|
'Spouse',
|
||||||
|
'Child',
|
||||||
|
'Parent',
|
||||||
|
'Sibling',
|
||||||
|
'Friend',
|
||||||
|
'Self'
|
||||||
|
],
|
||||||
'settings.fees.taxPercentageDefault': 0,
|
'settings.fees.taxPercentageDefault': 0,
|
||||||
'settings.workOrders.workOrderNumberLength': 6,
|
'settings.workOrders.workOrderNumberLength': 6,
|
||||||
'settings.workOrders.calendarEmailAddress': 'no-reply@127.0.0.1',
|
'settings.workOrders.calendarEmailAddress': 'no-reply@127.0.0.1',
|
||||||
|
|
@ -71,4 +77,3 @@ export const configDefaultValues = {
|
||||||
'settings.dynamicsGP.itemNumbers': [],
|
'settings.dynamicsGP.itemNumbers': [],
|
||||||
'settings.dynamicsGP.trialBalanceCodes': []
|
'settings.dynamicsGP.trialBalanceCodes': []
|
||||||
};
|
};
|
||||||
export default configDefaultValues;
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
import { hoursToMillis } from '@cityssm/to-millis'
|
|
||||||
import type { config as MSSQLConfig } from 'mssql'
|
import type { config as MSSQLConfig } from 'mssql'
|
||||||
|
|
||||||
|
import { hoursToMillis } from '@cityssm/to-millis'
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
ConfigActiveDirectory,
|
ConfigActiveDirectory,
|
||||||
ConfigBurialSiteNameSegments,
|
ConfigBurialSiteNameSegments,
|
||||||
ConfigNtfyStartup,
|
ConfigNtfyStartup,
|
||||||
DynamicsGPLookup
|
DynamicsGPLookup
|
||||||
} from '../types/config.types.js'
|
} from '../types/configTypes.js'
|
||||||
|
|
||||||
export const configDefaultValues = {
|
export const configDefaultValues = {
|
||||||
activeDirectory: undefined as unknown as ConfigActiveDirectory,
|
activeDirectory: undefined as unknown as ConfigActiveDirectory,
|
||||||
|
|
@ -31,7 +32,6 @@ export const configDefaultValues = {
|
||||||
|
|
||||||
'users.canLogin': ['administrator'],
|
'users.canLogin': ['administrator'],
|
||||||
'users.canUpdate': [] as string[],
|
'users.canUpdate': [] as string[],
|
||||||
'users.canUpdateWorkOrders': [] as string[],
|
|
||||||
'users.isAdmin': ['administrator'],
|
'users.isAdmin': ['administrator'],
|
||||||
'users.testing': [] as string[],
|
'users.testing': [] as string[],
|
||||||
|
|
||||||
|
|
@ -42,21 +42,11 @@ export const configDefaultValues = {
|
||||||
'settings.cityDefault': '',
|
'settings.cityDefault': '',
|
||||||
'settings.provinceDefault': '',
|
'settings.provinceDefault': '',
|
||||||
|
|
||||||
'settings.publicInternalPath': 'public-internal',
|
|
||||||
|
|
||||||
'settings.latitudeMax': 90,
|
'settings.latitudeMax': 90,
|
||||||
'settings.latitudeMin': -90,
|
'settings.latitudeMin': -90,
|
||||||
'settings.longitudeMax': 180,
|
'settings.longitudeMax': 180,
|
||||||
'settings.longitudeMin': -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': {
|
'settings.burialSites.burialSiteNameSegments': {
|
||||||
includeCemeteryKey: false,
|
includeCemeteryKey: false,
|
||||||
separator: '-',
|
separator: '-',
|
||||||
|
|
@ -74,12 +64,23 @@ export const configDefaultValues = {
|
||||||
|
|
||||||
'settings.burialSites.burialSiteNameSegments.includeCemeteryKey': false,
|
'settings.burialSites.burialSiteNameSegments.includeCemeteryKey': false,
|
||||||
|
|
||||||
'settings.burialSites.refreshImageChanges': false,
|
|
||||||
|
|
||||||
'settings.contracts.burialSiteIdIsRequired': true,
|
'settings.contracts.burialSiteIdIsRequired': true,
|
||||||
'settings.contracts.contractEndDateIsRequired': false,
|
'settings.contracts.contractEndDateIsRequired': false,
|
||||||
|
'settings.contracts.deathAgePeriods': [
|
||||||
|
'Years',
|
||||||
|
'Months',
|
||||||
|
'Days',
|
||||||
|
'Stillborn'
|
||||||
|
],
|
||||||
'settings.contracts.prints': ['screen/contract'],
|
'settings.contracts.prints': ['screen/contract'],
|
||||||
|
'settings.contracts.purchaserRelationships': [
|
||||||
|
'Spouse',
|
||||||
|
'Child',
|
||||||
|
'Parent',
|
||||||
|
'Sibling',
|
||||||
|
'Friend',
|
||||||
|
'Self'
|
||||||
|
],
|
||||||
|
|
||||||
'settings.fees.taxPercentageDefault': 0,
|
'settings.fees.taxPercentageDefault': 0,
|
||||||
|
|
||||||
|
|
@ -107,5 +108,3 @@ export const configDefaultValues = {
|
||||||
'settings.dynamicsGP.itemNumbers': [] as string[],
|
'settings.dynamicsGP.itemNumbers': [] as string[],
|
||||||
'settings.dynamicsGP.trialBalanceCodes': [] as string[]
|
'settings.dynamicsGP.trialBalanceCodes': [] as string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export default configDefaultValues
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
import type { Config } from '../types/config.types.js';
|
import type { Config } from '../types/configTypes.js';
|
||||||
export declare const config: Config;
|
export declare const config: Config;
|
||||||
export default config;
|
export default config;
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
import { config as cemeteryConfig } from './ssm.ontario.config.js';
|
import { config as cemeteryConfig } from './config.baseSsm.js';
|
||||||
export const config = { ...cemeteryConfig };
|
export const config = { ...cemeteryConfig };
|
||||||
config.application.useTestDatabases = true;
|
config.application.useTestDatabases = true;
|
||||||
config.session.doKeepAlive = true;
|
config.session.doKeepAlive = true;
|
||||||
config.users = {
|
config.users = {
|
||||||
|
testing: ['*testView', '*testUpdate', '*testAdmin'],
|
||||||
canLogin: ['*testView', '*testUpdate', '*testAdmin'],
|
canLogin: ['*testView', '*testUpdate', '*testAdmin'],
|
||||||
canUpdate: ['*testUpdate'],
|
canUpdate: ['*testUpdate'],
|
||||||
canUpdateWorkOrders: ['*testUpdate'],
|
isAdmin: ['*testAdmin']
|
||||||
isAdmin: ['*testAdmin'],
|
|
||||||
testing: ['*testView', '*testUpdate', '*testAdmin']
|
|
||||||
};
|
};
|
||||||
config.settings.publicInternalPath = 'public-internal';
|
|
||||||
config.settings.dynamicsGP.integrationIsEnabled = false;
|
config.settings.dynamicsGP.integrationIsEnabled = false;
|
||||||
export default config;
|
export default config;
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import type { Config } from '../types/config.types.js'
|
import type { Config } from '../types/configTypes.js'
|
||||||
|
|
||||||
import { config as cemeteryConfig } from './ssm.ontario.config.js'
|
import { config as cemeteryConfig } from './config.baseSsm.js'
|
||||||
|
|
||||||
export const config: Config = { ...cemeteryConfig }
|
export const config: Config = { ...cemeteryConfig }
|
||||||
|
|
||||||
|
|
@ -9,15 +9,12 @@ config.application.useTestDatabases = true
|
||||||
config.session.doKeepAlive = true
|
config.session.doKeepAlive = true
|
||||||
|
|
||||||
config.users = {
|
config.users = {
|
||||||
|
testing: ['*testView', '*testUpdate', '*testAdmin'],
|
||||||
canLogin: ['*testView', '*testUpdate', '*testAdmin'],
|
canLogin: ['*testView', '*testUpdate', '*testAdmin'],
|
||||||
canUpdate: ['*testUpdate'],
|
canUpdate: ['*testUpdate'],
|
||||||
canUpdateWorkOrders: ['*testUpdate'],
|
isAdmin: ['*testAdmin']
|
||||||
isAdmin: ['*testAdmin'],
|
|
||||||
testing: ['*testView', '*testUpdate', '*testAdmin']
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config.settings.publicInternalPath = 'public-internal'
|
|
||||||
|
|
||||||
config.settings.dynamicsGP!.integrationIsEnabled = false
|
config.settings.dynamicsGP!.integrationIsEnabled = false
|
||||||
|
|
||||||
export default config
|
export default config
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
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;
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
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
|
|
||||||
};
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
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,2 +0,0 @@
|
||||||
export declare const config: import("../types/config.types.js").Config;
|
|
||||||
export default config;
|
|
||||||
|
|
@ -1,18 +1,16 @@
|
||||||
export interface AddBurialSiteForm {
|
export interface AddBurialSiteForm {
|
||||||
burialSiteNameSegment1?: string;
|
burialSiteNameSegment1: string;
|
||||||
burialSiteNameSegment2?: string;
|
burialSiteNameSegment2?: string;
|
||||||
burialSiteNameSegment3?: string;
|
burialSiteNameSegment3?: string;
|
||||||
burialSiteNameSegment4?: string;
|
burialSiteNameSegment4?: string;
|
||||||
burialSiteNameSegment5?: string;
|
burialSiteNameSegment5?: string;
|
||||||
burialSiteStatusId: number | string;
|
burialSiteStatusId: number | string;
|
||||||
burialSiteTypeId: number | string;
|
burialSiteTypeId: number | string;
|
||||||
bodyCapacity?: number | string;
|
burialSiteImage: string;
|
||||||
crematedCapacity?: number | string;
|
|
||||||
burialSiteImage?: string;
|
|
||||||
cemeteryId: number | string;
|
cemeteryId: number | string;
|
||||||
cemeterySvgId?: string;
|
cemeterySvgId: string;
|
||||||
burialSiteLatitude?: string;
|
burialSiteLatitude: string;
|
||||||
burialSiteLongitude?: string;
|
burialSiteLongitude: string;
|
||||||
burialSiteTypeFieldIds?: string;
|
burialSiteTypeFieldIds?: string;
|
||||||
[fieldValue_burialSiteTypeFieldId: string]: unknown;
|
[fieldValue_burialSiteTypeFieldId: string]: unknown;
|
||||||
}
|
}
|
||||||
|
|
@ -23,7 +21,4 @@ export interface AddBurialSiteForm {
|
||||||
* @returns The new burial site's id.
|
* @returns The new burial site's id.
|
||||||
* @throws If an active burial site with the same name already exists.
|
* @throws If an active burial site with the same name already exists.
|
||||||
*/
|
*/
|
||||||
export default function addBurialSite(burialSiteForm: AddBurialSiteForm, user: User): {
|
export default function addBurialSite(burialSiteForm: AddBurialSiteForm, user: User): Promise<number>;
|
||||||
burialSiteId: number;
|
|
||||||
burialSiteName: string;
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import sqlite from 'better-sqlite3';
|
|
||||||
import { buildBurialSiteName } from '../helpers/burialSites.helpers.js';
|
import { buildBurialSiteName } from '../helpers/burialSites.helpers.js';
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
|
||||||
import addOrUpdateBurialSiteField from './addOrUpdateBurialSiteField.js';
|
import addOrUpdateBurialSiteField from './addOrUpdateBurialSiteField.js';
|
||||||
import getCemetery from './getCemetery.js';
|
import getCemetery from './getCemetery.js';
|
||||||
|
import { acquireConnection } from './pool.js';
|
||||||
/**
|
/**
|
||||||
* Creates a new burial site.
|
* Creates a new burial site.
|
||||||
* @param burialSiteForm - The new burial site's information
|
* @param burialSiteForm - The new burial site's information
|
||||||
|
|
@ -10,13 +9,12 @@ import getCemetery from './getCemetery.js';
|
||||||
* @returns The new burial site's id.
|
* @returns The new burial site's id.
|
||||||
* @throws If an active burial site with the same name already exists.
|
* @throws If an active burial site with the same name already exists.
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line complexity
|
export default async function addBurialSite(burialSiteForm, user) {
|
||||||
export default function addBurialSite(burialSiteForm, user) {
|
const database = await acquireConnection();
|
||||||
const database = sqlite(sunriseDB);
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const cemetery = burialSiteForm.cemeteryId === ''
|
const cemetery = burialSiteForm.cemeteryId === ''
|
||||||
? undefined
|
? undefined
|
||||||
: getCemetery(burialSiteForm.cemeteryId, database);
|
: await getCemetery(burialSiteForm.cemeteryId, database);
|
||||||
const burialSiteName = buildBurialSiteName(cemetery?.cemeteryKey, burialSiteForm);
|
const burialSiteName = buildBurialSiteName(cemetery?.cemeteryKey, burialSiteForm);
|
||||||
// Ensure no active burial sites share the same name
|
// Ensure no active burial sites share the same name
|
||||||
const existingBurialSite = database
|
const existingBurialSite = database
|
||||||
|
|
@ -27,7 +25,7 @@ export default function addBurialSite(burialSiteForm, user) {
|
||||||
.pluck()
|
.pluck()
|
||||||
.get(burialSiteName);
|
.get(burialSiteName);
|
||||||
if (existingBurialSite !== undefined) {
|
if (existingBurialSite !== undefined) {
|
||||||
database.close();
|
database.release();
|
||||||
throw new Error('An active burial site with that name already exists.');
|
throw new Error('An active burial site with that name already exists.');
|
||||||
}
|
}
|
||||||
const result = database
|
const result = database
|
||||||
|
|
@ -39,22 +37,17 @@ export default function addBurialSite(burialSiteForm, user) {
|
||||||
burialSiteNameSegment5,
|
burialSiteNameSegment5,
|
||||||
burialSiteName,
|
burialSiteName,
|
||||||
burialSiteTypeId, burialSiteStatusId,
|
burialSiteTypeId, burialSiteStatusId,
|
||||||
bodyCapacity, crematedCapacity,
|
|
||||||
cemeteryId, cemeterySvgId, burialSiteImage,
|
cemeteryId, cemeterySvgId, burialSiteImage,
|
||||||
burialSiteLatitude, burialSiteLongitude,
|
burialSiteLatitude, burialSiteLongitude,
|
||||||
|
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?,
|
values (?, ?,
|
||||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||||
?, ?, ?, ?)`)
|
?, ?, ?, ?)`)
|
||||||
.run(burialSiteForm.burialSiteNameSegment1 ?? '', burialSiteForm.burialSiteNameSegment2 ?? '', burialSiteForm.burialSiteNameSegment3 ?? '', burialSiteForm.burialSiteNameSegment4 ?? '', burialSiteForm.burialSiteNameSegment5 ?? '', burialSiteName, burialSiteForm.burialSiteTypeId, burialSiteForm.burialSiteStatusId === ''
|
.run(burialSiteForm.burialSiteNameSegment1, burialSiteForm.burialSiteNameSegment2 ?? '', burialSiteForm.burialSiteNameSegment3 ?? '', burialSiteForm.burialSiteNameSegment4 ?? '', burialSiteForm.burialSiteNameSegment5 ?? '', burialSiteName, burialSiteForm.burialSiteTypeId, burialSiteForm.burialSiteStatusId === ''
|
||||||
? undefined
|
? undefined
|
||||||
: burialSiteForm.burialSiteStatusId, burialSiteForm.bodyCapacity === ''
|
: burialSiteForm.burialSiteStatusId, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteImage, burialSiteForm.burialSiteLatitude === ''
|
||||||
? undefined
|
|
||||||
: burialSiteForm.bodyCapacity, burialSiteForm.crematedCapacity === ''
|
|
||||||
? undefined
|
|
||||||
: burialSiteForm.crematedCapacity, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteImage ?? '', burialSiteForm.burialSiteLatitude === ''
|
|
||||||
? undefined
|
? undefined
|
||||||
: burialSiteForm.burialSiteLatitude, burialSiteForm.burialSiteLongitude === ''
|
: burialSiteForm.burialSiteLatitude, burialSiteForm.burialSiteLongitude === ''
|
||||||
? undefined
|
? undefined
|
||||||
|
|
@ -64,16 +57,13 @@ export default function addBurialSite(burialSiteForm, user) {
|
||||||
for (const burialSiteTypeFieldId of burialSiteTypeFieldIds) {
|
for (const burialSiteTypeFieldId of burialSiteTypeFieldIds) {
|
||||||
const fieldValue = burialSiteForm[`burialSiteFieldValue_${burialSiteTypeFieldId}`];
|
const fieldValue = burialSiteForm[`burialSiteFieldValue_${burialSiteTypeFieldId}`];
|
||||||
if ((fieldValue ?? '') !== '') {
|
if ((fieldValue ?? '') !== '') {
|
||||||
addOrUpdateBurialSiteField({
|
await addOrUpdateBurialSiteField({
|
||||||
burialSiteId,
|
burialSiteId,
|
||||||
burialSiteTypeFieldId,
|
burialSiteTypeFieldId,
|
||||||
fieldValue: fieldValue ?? ''
|
fieldValue: fieldValue ?? ''
|
||||||
}, user, database);
|
}, user, database);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
database.close();
|
database.release();
|
||||||
return {
|
return burialSiteId;
|
||||||
burialSiteId,
|
|
||||||
burialSiteName
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,11 @@
|
||||||
import sqlite from 'better-sqlite3'
|
|
||||||
|
|
||||||
import { buildBurialSiteName } from '../helpers/burialSites.helpers.js'
|
import { buildBurialSiteName } from '../helpers/burialSites.helpers.js'
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
|
||||||
|
|
||||||
import addOrUpdateBurialSiteField from './addOrUpdateBurialSiteField.js'
|
import addOrUpdateBurialSiteField from './addOrUpdateBurialSiteField.js'
|
||||||
import getCemetery from './getCemetery.js'
|
import getCemetery from './getCemetery.js'
|
||||||
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface AddBurialSiteForm {
|
export interface AddBurialSiteForm {
|
||||||
burialSiteNameSegment1?: string
|
burialSiteNameSegment1: string
|
||||||
burialSiteNameSegment2?: string
|
burialSiteNameSegment2?: string
|
||||||
burialSiteNameSegment3?: string
|
burialSiteNameSegment3?: string
|
||||||
burialSiteNameSegment4?: string
|
burialSiteNameSegment4?: string
|
||||||
|
|
@ -16,18 +14,15 @@ export interface AddBurialSiteForm {
|
||||||
burialSiteStatusId: number | string
|
burialSiteStatusId: number | string
|
||||||
burialSiteTypeId: number | string
|
burialSiteTypeId: number | string
|
||||||
|
|
||||||
bodyCapacity?: number | string
|
burialSiteImage: string
|
||||||
crematedCapacity?: number | string
|
|
||||||
|
|
||||||
burialSiteImage?: string
|
|
||||||
cemeteryId: number | string
|
cemeteryId: number | string
|
||||||
cemeterySvgId?: string
|
cemeterySvgId: string
|
||||||
|
|
||||||
burialSiteLatitude?: string
|
burialSiteLatitude: string
|
||||||
burialSiteLongitude?: string
|
burialSiteLongitude: string
|
||||||
|
|
||||||
burialSiteTypeFieldIds?: string
|
burialSiteTypeFieldIds?: string
|
||||||
|
|
||||||
[fieldValue_burialSiteTypeFieldId: string]: unknown
|
[fieldValue_burialSiteTypeFieldId: string]: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -38,19 +33,18 @@ export interface AddBurialSiteForm {
|
||||||
* @returns The new burial site's id.
|
* @returns The new burial site's id.
|
||||||
* @throws If an active burial site with the same name already exists.
|
* @throws If an active burial site with the same name already exists.
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line complexity
|
export default async function addBurialSite(
|
||||||
export default function addBurialSite(
|
|
||||||
burialSiteForm: AddBurialSiteForm,
|
burialSiteForm: AddBurialSiteForm,
|
||||||
user: User
|
user: User
|
||||||
): { burialSiteId: number; burialSiteName: string } {
|
): Promise<number> {
|
||||||
const database = sqlite(sunriseDB)
|
const database = await acquireConnection()
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
const cemetery =
|
const cemetery =
|
||||||
burialSiteForm.cemeteryId === ''
|
burialSiteForm.cemeteryId === ''
|
||||||
? undefined
|
? undefined
|
||||||
: getCemetery(burialSiteForm.cemeteryId, database)
|
: await getCemetery(burialSiteForm.cemeteryId, database)
|
||||||
|
|
||||||
const burialSiteName = buildBurialSiteName(
|
const burialSiteName = buildBurialSiteName(
|
||||||
cemetery?.cemeteryKey,
|
cemetery?.cemeteryKey,
|
||||||
|
|
@ -70,7 +64,7 @@ export default function addBurialSite(
|
||||||
.get(burialSiteName) as number | undefined
|
.get(burialSiteName) as number | undefined
|
||||||
|
|
||||||
if (existingBurialSite !== undefined) {
|
if (existingBurialSite !== undefined) {
|
||||||
database.close()
|
database.release()
|
||||||
throw new Error('An active burial site with that name already exists.')
|
throw new Error('An active burial site with that name already exists.')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,18 +78,17 @@ export default function addBurialSite(
|
||||||
burialSiteNameSegment5,
|
burialSiteNameSegment5,
|
||||||
burialSiteName,
|
burialSiteName,
|
||||||
burialSiteTypeId, burialSiteStatusId,
|
burialSiteTypeId, burialSiteStatusId,
|
||||||
bodyCapacity, crematedCapacity,
|
|
||||||
cemeteryId, cemeterySvgId, burialSiteImage,
|
cemeteryId, cemeterySvgId, burialSiteImage,
|
||||||
burialSiteLatitude, burialSiteLongitude,
|
burialSiteLatitude, burialSiteLongitude,
|
||||||
|
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?,
|
values (?, ?,
|
||||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||||
?, ?, ?, ?)`
|
?, ?, ?, ?)`
|
||||||
)
|
)
|
||||||
.run(
|
.run(
|
||||||
burialSiteForm.burialSiteNameSegment1 ?? '',
|
burialSiteForm.burialSiteNameSegment1,
|
||||||
burialSiteForm.burialSiteNameSegment2 ?? '',
|
burialSiteForm.burialSiteNameSegment2 ?? '',
|
||||||
burialSiteForm.burialSiteNameSegment3 ?? '',
|
burialSiteForm.burialSiteNameSegment3 ?? '',
|
||||||
burialSiteForm.burialSiteNameSegment4 ?? '',
|
burialSiteForm.burialSiteNameSegment4 ?? '',
|
||||||
|
|
@ -105,18 +98,9 @@ export default function addBurialSite(
|
||||||
burialSiteForm.burialSiteStatusId === ''
|
burialSiteForm.burialSiteStatusId === ''
|
||||||
? undefined
|
? undefined
|
||||||
: burialSiteForm.burialSiteStatusId,
|
: burialSiteForm.burialSiteStatusId,
|
||||||
|
|
||||||
burialSiteForm.bodyCapacity === ''
|
|
||||||
? undefined
|
|
||||||
: burialSiteForm.bodyCapacity,
|
|
||||||
|
|
||||||
burialSiteForm.crematedCapacity === ''
|
|
||||||
? undefined
|
|
||||||
: burialSiteForm.crematedCapacity,
|
|
||||||
|
|
||||||
burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId,
|
burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId,
|
||||||
burialSiteForm.cemeterySvgId,
|
burialSiteForm.cemeterySvgId,
|
||||||
burialSiteForm.burialSiteImage ?? '',
|
burialSiteForm.burialSiteImage,
|
||||||
burialSiteForm.burialSiteLatitude === ''
|
burialSiteForm.burialSiteLatitude === ''
|
||||||
? undefined
|
? undefined
|
||||||
: burialSiteForm.burialSiteLatitude,
|
: burialSiteForm.burialSiteLatitude,
|
||||||
|
|
@ -141,7 +125,7 @@ export default function addBurialSite(
|
||||||
] as string | undefined
|
] as string | undefined
|
||||||
|
|
||||||
if ((fieldValue ?? '') !== '') {
|
if ((fieldValue ?? '') !== '') {
|
||||||
addOrUpdateBurialSiteField(
|
await addOrUpdateBurialSiteField(
|
||||||
{
|
{
|
||||||
burialSiteId,
|
burialSiteId,
|
||||||
burialSiteTypeFieldId,
|
burialSiteTypeFieldId,
|
||||||
|
|
@ -153,10 +137,7 @@ export default function addBurialSite(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
database.close()
|
database.release()
|
||||||
|
|
||||||
return {
|
return burialSiteId
|
||||||
burialSiteId,
|
|
||||||
burialSiteName
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,4 @@ export interface AddBurialSiteCommentForm {
|
||||||
burialSiteId: string;
|
burialSiteId: string;
|
||||||
comment: string;
|
comment: string;
|
||||||
}
|
}
|
||||||
export default function addBurialSiteComment(commentForm: AddBurialSiteCommentForm, user: User): number;
|
export default function addBurialSiteComment(commentForm: AddBurialSiteCommentForm, user: User): Promise<number>;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import { dateToInteger, dateToTimeInteger } from '@cityssm/utils-datetime';
|
import { dateToInteger, dateToTimeInteger } from '@cityssm/utils-datetime';
|
||||||
import sqlite from 'better-sqlite3';
|
import { acquireConnection } from './pool.js';
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
export default async function addBurialSiteComment(commentForm, user) {
|
||||||
export default function addBurialSiteComment(commentForm, user) {
|
const database = await acquireConnection();
|
||||||
const database = sqlite(sunriseDB);
|
|
||||||
const rightNow = new Date();
|
const rightNow = new Date();
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(`insert into BurialSiteComments (
|
.prepare(`insert into BurialSiteComments (
|
||||||
|
|
@ -12,6 +11,6 @@ export default function addBurialSiteComment(commentForm, user) {
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(commentForm.burialSiteId, dateToInteger(rightNow), dateToTimeInteger(rightNow), commentForm.comment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime());
|
.run(commentForm.burialSiteId, dateToInteger(rightNow), dateToTimeInteger(rightNow), commentForm.comment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime());
|
||||||
database.close();
|
database.release();
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,17 @@
|
||||||
import { dateToInteger, dateToTimeInteger } from '@cityssm/utils-datetime'
|
import { dateToInteger, dateToTimeInteger } from '@cityssm/utils-datetime'
|
||||||
import sqlite from 'better-sqlite3'
|
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface AddBurialSiteCommentForm {
|
export interface AddBurialSiteCommentForm {
|
||||||
burialSiteId: string
|
burialSiteId: string
|
||||||
comment: string
|
comment: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function addBurialSiteComment(
|
export default async function addBurialSiteComment(
|
||||||
commentForm: AddBurialSiteCommentForm,
|
commentForm: AddBurialSiteCommentForm,
|
||||||
user: User
|
user: User
|
||||||
): number {
|
): Promise<number> {
|
||||||
const database = sqlite(sunriseDB)
|
const database = await acquireConnection()
|
||||||
|
|
||||||
const rightNow = new Date()
|
const rightNow = new Date()
|
||||||
|
|
||||||
|
|
@ -36,7 +35,7 @@ export default function addBurialSiteComment(
|
||||||
rightNow.getTime()
|
rightNow.getTime()
|
||||||
)
|
)
|
||||||
|
|
||||||
database.close()
|
database.release()
|
||||||
|
|
||||||
return result.lastInsertRowid as number
|
return result.lastInsertRowid as number
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
export interface AddBurialSiteTypeForm {
|
|
||||||
burialSiteType: string;
|
|
||||||
bodyCapacityMax: number | string;
|
|
||||||
crematedCapacityMax: number | string;
|
|
||||||
orderNumber?: number | string;
|
|
||||||
}
|
|
||||||
export default function addBurialSiteType(addForm: AddBurialSiteTypeForm, user: User): number;
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
import sqlite from 'better-sqlite3';
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
|
||||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
|
||||||
export default function addBurialSiteType(addForm, user) {
|
|
||||||
const database = sqlite(sunriseDB);
|
|
||||||
const rightNowMillis = Date.now();
|
|
||||||
const result = database
|
|
||||||
.prepare(`insert into BurialSiteTypes (
|
|
||||||
burialSiteType, bodyCapacityMax, crematedCapacityMax,
|
|
||||||
orderNumber,
|
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
||||||
.run(addForm.burialSiteType, addForm.bodyCapacityMax === '' ? undefined : addForm.bodyCapacityMax, addForm.crematedCapacityMax === ''
|
|
||||||
? undefined
|
|
||||||
: addForm.crematedCapacityMax, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
|
||||||
database.close();
|
|
||||||
clearCacheByTableName('BurialSiteTypes');
|
|
||||||
return result.lastInsertRowid;
|
|
||||||
}
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
import sqlite from 'better-sqlite3'
|
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
|
||||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
|
||||||
|
|
||||||
export interface AddBurialSiteTypeForm {
|
|
||||||
burialSiteType: string
|
|
||||||
|
|
||||||
bodyCapacityMax: number | string
|
|
||||||
crematedCapacityMax: number | string
|
|
||||||
|
|
||||||
orderNumber?: number | string
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function addBurialSiteType(
|
|
||||||
addForm: AddBurialSiteTypeForm,
|
|
||||||
user: User
|
|
||||||
): number {
|
|
||||||
const database = sqlite(sunriseDB)
|
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
|
||||||
|
|
||||||
const result = database
|
|
||||||
.prepare(
|
|
||||||
`insert into BurialSiteTypes (
|
|
||||||
burialSiteType, bodyCapacityMax, crematedCapacityMax,
|
|
||||||
orderNumber,
|
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?)`
|
|
||||||
)
|
|
||||||
.run(
|
|
||||||
addForm.burialSiteType,
|
|
||||||
addForm.bodyCapacityMax === '' ? undefined : addForm.bodyCapacityMax,
|
|
||||||
addForm.crematedCapacityMax === ''
|
|
||||||
? undefined
|
|
||||||
: addForm.crematedCapacityMax,
|
|
||||||
addForm.orderNumber ?? -1,
|
|
||||||
user.userName,
|
|
||||||
rightNowMillis,
|
|
||||||
user.userName,
|
|
||||||
rightNowMillis
|
|
||||||
)
|
|
||||||
|
|
||||||
database.close()
|
|
||||||
|
|
||||||
clearCacheByTableName('BurialSiteTypes')
|
|
||||||
|
|
||||||
return result.lastInsertRowid as number
|
|
||||||
}
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
export interface AddBurialSiteTypeFieldForm {
|
export interface AddBurialSiteTypeFieldForm {
|
||||||
burialSiteTypeId: number | string;
|
burialSiteTypeId: string | number;
|
||||||
burialSiteTypeField: string;
|
burialSiteTypeField: string;
|
||||||
fieldType?: string;
|
fieldType?: string;
|
||||||
fieldValues?: string;
|
fieldValues?: string;
|
||||||
isRequired?: string;
|
isRequired?: string;
|
||||||
maxLength?: number | string;
|
|
||||||
minLength?: number | string;
|
|
||||||
pattern?: string;
|
pattern?: string;
|
||||||
|
minLength?: string | number;
|
||||||
|
maxLength?: string | number;
|
||||||
orderNumber?: number;
|
orderNumber?: number;
|
||||||
}
|
}
|
||||||
export default function addBurialSiteTypeField(addForm: AddBurialSiteTypeFieldForm, user: User): number;
|
export default function addBurialSiteTypeField(addForm: AddBurialSiteTypeFieldForm, user: User): Promise<number>;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import sqlite from 'better-sqlite3';
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
|
||||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||||
export default function addBurialSiteTypeField(addForm, user) {
|
import { acquireConnection } from './pool.js';
|
||||||
const database = sqlite(sunriseDB);
|
export default async function addBurialSiteTypeField(addForm, user) {
|
||||||
|
const database = await acquireConnection();
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(`insert into BurialSiteTypeFields (
|
.prepare(`insert into BurialSiteTypeFields (
|
||||||
|
|
@ -14,10 +13,8 @@ export default function addBurialSiteTypeField(addForm, user) {
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(addForm.burialSiteTypeId, addForm.burialSiteTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0,
|
.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);
|
||||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
database.release();
|
||||||
addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
|
||||||
database.close();
|
|
||||||
clearCacheByTableName('BurialSiteTypeFields');
|
clearCacheByTableName('BurialSiteTypeFields');
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,24 @@
|
||||||
import sqlite from 'better-sqlite3'
|
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
|
||||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||||
|
|
||||||
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface AddBurialSiteTypeFieldForm {
|
export interface AddBurialSiteTypeFieldForm {
|
||||||
burialSiteTypeId: number | string
|
burialSiteTypeId: string | number
|
||||||
|
|
||||||
burialSiteTypeField: string
|
burialSiteTypeField: string
|
||||||
|
|
||||||
fieldType?: string
|
fieldType?: string
|
||||||
fieldValues?: string
|
fieldValues?: string
|
||||||
|
|
||||||
isRequired?: string
|
isRequired?: string
|
||||||
maxLength?: number | string
|
|
||||||
minLength?: number | string
|
|
||||||
pattern?: string
|
pattern?: string
|
||||||
|
minLength?: string | number
|
||||||
|
maxLength?: string | number
|
||||||
orderNumber?: number
|
orderNumber?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function addBurialSiteTypeField(
|
export default async function addBurialSiteTypeField(
|
||||||
addForm: AddBurialSiteTypeFieldForm,
|
addForm: AddBurialSiteTypeFieldForm,
|
||||||
user: User
|
user: User
|
||||||
): number {
|
): Promise<number> {
|
||||||
const database = sqlite(sunriseDB)
|
const database = await acquireConnection()
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
|
|
@ -47,7 +42,6 @@ export default function addBurialSiteTypeField(
|
||||||
addForm.isRequired === '' ? 0 : 1,
|
addForm.isRequired === '' ? 0 : 1,
|
||||||
addForm.pattern ?? '',
|
addForm.pattern ?? '',
|
||||||
addForm.minLength ?? 0,
|
addForm.minLength ?? 0,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
||||||
addForm.maxLength ?? 100,
|
addForm.maxLength ?? 100,
|
||||||
addForm.orderNumber ?? -1,
|
addForm.orderNumber ?? -1,
|
||||||
user.userName,
|
user.userName,
|
||||||
|
|
@ -56,7 +50,7 @@ export default function addBurialSiteTypeField(
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
)
|
)
|
||||||
|
|
||||||
database.close()
|
database.release()
|
||||||
|
|
||||||
clearCacheByTableName('BurialSiteTypeFields')
|
clearCacheByTableName('BurialSiteTypeFields')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
import { type UpdateCemeteryDirectionsOfArrivalForm } from './updateCemeteryDirectionsOfArrival.js';
|
export interface AddCemeteryForm {
|
||||||
export type AddCemeteryForm = UpdateCemeteryDirectionsOfArrivalForm & {
|
|
||||||
cemeteryDescription: string;
|
cemeteryDescription: string;
|
||||||
cemeteryKey: string;
|
cemeteryKey: string;
|
||||||
cemeteryName: string;
|
cemeteryName: string;
|
||||||
parentCemeteryId: string;
|
|
||||||
cemeteryLatitude: string;
|
cemeteryLatitude: string;
|
||||||
cemeteryLongitude: string;
|
cemeteryLongitude: string;
|
||||||
cemeterySvg: string;
|
cemeterySvg: string;
|
||||||
|
|
@ -13,5 +11,5 @@ export type AddCemeteryForm = UpdateCemeteryDirectionsOfArrivalForm & {
|
||||||
cemeteryPostalCode: string;
|
cemeteryPostalCode: string;
|
||||||
cemeteryProvince: string;
|
cemeteryProvince: string;
|
||||||
cemeteryPhoneNumber: string;
|
cemeteryPhoneNumber: string;
|
||||||
};
|
}
|
||||||
export default function addCemetery(addForm: AddCemeteryForm, user: User): number;
|
export default function addCemetery(addForm: AddCemeteryForm, user: User): Promise<number>;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
import sqlite from 'better-sqlite3';
|
import { acquireConnection } from './pool.js';
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
export default async function addCemetery(addForm, user) {
|
||||||
import updateCemeteryDirectionsOfArrival from './updateCemeteryDirectionsOfArrival.js';
|
const database = await acquireConnection();
|
||||||
export default function addCemetery(addForm, user) {
|
|
||||||
const database = sqlite(sunriseDB);
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(`insert into Cemeteries (
|
.prepare(`insert into Cemeteries (
|
||||||
|
|
@ -11,13 +9,10 @@ export default function addCemetery(addForm, user) {
|
||||||
cemeteryAddress1, cemeteryAddress2,
|
cemeteryAddress1, cemeteryAddress2,
|
||||||
cemeteryCity, cemeteryProvince, cemeteryPostalCode,
|
cemeteryCity, cemeteryProvince, cemeteryPostalCode,
|
||||||
cemeteryPhoneNumber,
|
cemeteryPhoneNumber,
|
||||||
parentCemeteryId,
|
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
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);
|
.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, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||||
const cemeteryId = result.lastInsertRowid;
|
database.release();
|
||||||
updateCemeteryDirectionsOfArrival(cemeteryId, addForm, database);
|
return result.lastInsertRowid;
|
||||||
database.close();
|
|
||||||
return cemeteryId;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,9 @@
|
||||||
import sqlite from 'better-sqlite3'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
export interface AddCemeteryForm {
|
||||||
|
|
||||||
import updateCemeteryDirectionsOfArrival, {
|
|
||||||
type UpdateCemeteryDirectionsOfArrivalForm
|
|
||||||
} from './updateCemeteryDirectionsOfArrival.js'
|
|
||||||
|
|
||||||
export type AddCemeteryForm = UpdateCemeteryDirectionsOfArrivalForm & {
|
|
||||||
cemeteryDescription: string
|
cemeteryDescription: string
|
||||||
cemeteryKey: string
|
cemeteryKey: string
|
||||||
cemeteryName: string
|
cemeteryName: string
|
||||||
parentCemeteryId: string
|
|
||||||
|
|
||||||
cemeteryLatitude: string
|
cemeteryLatitude: string
|
||||||
cemeteryLongitude: string
|
cemeteryLongitude: string
|
||||||
|
|
@ -21,15 +14,15 @@ export type AddCemeteryForm = UpdateCemeteryDirectionsOfArrivalForm & {
|
||||||
cemeteryCity: string
|
cemeteryCity: string
|
||||||
cemeteryPostalCode: string
|
cemeteryPostalCode: string
|
||||||
cemeteryProvince: string
|
cemeteryProvince: string
|
||||||
|
|
||||||
cemeteryPhoneNumber: string
|
cemeteryPhoneNumber: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function addCemetery(
|
export default async function addCemetery(
|
||||||
addForm: AddCemeteryForm,
|
addForm: AddCemeteryForm,
|
||||||
user: User
|
user: User
|
||||||
): number {
|
): Promise<number> {
|
||||||
const database = sqlite(sunriseDB)
|
const database = await acquireConnection()
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
|
|
@ -41,10 +34,9 @@ export default function addCemetery(
|
||||||
cemeteryAddress1, cemeteryAddress2,
|
cemeteryAddress1, cemeteryAddress2,
|
||||||
cemeteryCity, cemeteryProvince, cemeteryPostalCode,
|
cemeteryCity, cemeteryProvince, cemeteryPostalCode,
|
||||||
cemeteryPhoneNumber,
|
cemeteryPhoneNumber,
|
||||||
parentCemeteryId,
|
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||||
)
|
)
|
||||||
.run(
|
.run(
|
||||||
addForm.cemeteryName,
|
addForm.cemeteryName,
|
||||||
|
|
@ -59,18 +51,13 @@ export default function addCemetery(
|
||||||
addForm.cemeteryProvince,
|
addForm.cemeteryProvince,
|
||||||
addForm.cemeteryPostalCode,
|
addForm.cemeteryPostalCode,
|
||||||
addForm.cemeteryPhoneNumber,
|
addForm.cemeteryPhoneNumber,
|
||||||
addForm.parentCemeteryId === '' ? undefined : addForm.parentCemeteryId,
|
|
||||||
user.userName,
|
user.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
user.userName,
|
user.userName,
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
)
|
)
|
||||||
|
|
||||||
const cemeteryId = result.lastInsertRowid as number
|
database.release()
|
||||||
|
|
||||||
updateCemeteryDirectionsOfArrival(cemeteryId, addForm, database)
|
return result.lastInsertRowid as number
|
||||||
|
|
||||||
database.close()
|
|
||||||
|
|
||||||
return cemeteryId
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
export interface AddForm {
|
export interface AddForm {
|
||||||
committalType: string;
|
committalType: string;
|
||||||
committalTypeKey?: string;
|
committalTypeKey?: string;
|
||||||
orderNumber?: number | string;
|
orderNumber?: number;
|
||||||
}
|
}
|
||||||
export default function addCommittalType(addForm: AddForm, user: User): number;
|
export default function addCommittalType(addForm: AddForm, user: User): Promise<number>;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import sqlite from 'better-sqlite3';
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
|
||||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||||
export default function addCommittalType(addForm, user) {
|
import { acquireConnection } from './pool.js';
|
||||||
const database = sqlite(sunriseDB);
|
export default async function addCommittalType(addForm, user) {
|
||||||
|
const database = await acquireConnection();
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(`insert into CommittalTypes (
|
.prepare(`insert into CommittalTypes (
|
||||||
|
|
@ -11,7 +10,7 @@ export default function addCommittalType(addForm, user) {
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(addForm.committalType, addForm.committalTypeKey ?? '', addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
.run(addForm.committalType, addForm.committalTypeKey ?? '', addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||||
database.close();
|
database.release();
|
||||||
clearCacheByTableName('CommittalTypes');
|
clearCacheByTableName('CommittalTypes');
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,18 @@
|
||||||
import sqlite from 'better-sqlite3'
|
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
|
||||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||||
|
|
||||||
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface AddForm {
|
export interface AddForm {
|
||||||
committalType: string
|
committalType: string
|
||||||
committalTypeKey?: string
|
committalTypeKey?: string
|
||||||
orderNumber?: number | string
|
orderNumber?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function addCommittalType(addForm: AddForm, user: User): number {
|
export default async function addCommittalType(
|
||||||
const database = sqlite(sunriseDB)
|
addForm: AddForm,
|
||||||
|
user: User
|
||||||
|
): Promise<number> {
|
||||||
|
const database = await acquireConnection()
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
|
|
@ -32,7 +34,7 @@ export default function addCommittalType(addForm: AddForm, user: User): number {
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
)
|
)
|
||||||
|
|
||||||
database.close()
|
database.release()
|
||||||
|
|
||||||
clearCacheByTableName('CommittalTypes')
|
clearCacheByTableName('CommittalTypes')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
import type { PoolConnection } from 'better-sqlite-pool';
|
||||||
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
||||||
import sqlite from 'better-sqlite3';
|
|
||||||
export interface AddContractForm {
|
export interface AddContractForm {
|
||||||
burialSiteId: number | string;
|
burialSiteId: number | string;
|
||||||
contractEndDateString: '' | DateString;
|
contractEndDateString: '' | DateString;
|
||||||
|
|
@ -8,7 +8,6 @@ export interface AddContractForm {
|
||||||
[fieldValue_contractTypeFieldId: `fieldValue_${string}`]: unknown;
|
[fieldValue_contractTypeFieldId: `fieldValue_${string}`]: unknown;
|
||||||
contractTypeFieldIds?: string;
|
contractTypeFieldIds?: string;
|
||||||
committalTypeId?: number | string;
|
committalTypeId?: number | string;
|
||||||
directionOfArrival?: string;
|
|
||||||
funeralDateString?: '' | DateString;
|
funeralDateString?: '' | DateString;
|
||||||
funeralDirectorName?: string;
|
funeralDirectorName?: string;
|
||||||
funeralHomeId?: number | string;
|
funeralHomeId?: number | string;
|
||||||
|
|
@ -36,4 +35,4 @@ export interface AddContractForm {
|
||||||
deceasedProvince?: string;
|
deceasedProvince?: string;
|
||||||
intermentContainerTypeId?: number | string;
|
intermentContainerTypeId?: number | string;
|
||||||
}
|
}
|
||||||
export default function addContract(addForm: AddContractForm, user: User, connectedDatabase?: sqlite.Database): number;
|
export default function addContract(addForm: AddContractForm, user: User, connectedDatabase?: PoolConnection): Promise<number>;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
import { dateStringToInteger, timeStringToInteger } from '@cityssm/utils-datetime';
|
import { dateStringToInteger, timeStringToInteger } from '@cityssm/utils-datetime';
|
||||||
import sqlite from 'better-sqlite3';
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
|
||||||
import addOrUpdateContractField from './addOrUpdateContractField.js';
|
import addOrUpdateContractField from './addOrUpdateContractField.js';
|
||||||
|
import { acquireConnection } from './pool.js';
|
||||||
// eslint-disable-next-line complexity
|
// eslint-disable-next-line complexity
|
||||||
export default function addContract(addForm, user, connectedDatabase) {
|
export default async function addContract(addForm, user, connectedDatabase) {
|
||||||
const database = connectedDatabase ?? sqlite(sunriseDB);
|
const database = connectedDatabase ?? (await acquireConnection());
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const contractStartDate = dateStringToInteger(addForm.contractStartDateString);
|
const contractStartDate = dateStringToInteger(addForm.contractStartDateString);
|
||||||
const result = database
|
const result = database
|
||||||
|
|
@ -16,17 +15,17 @@ export default function addContract(addForm, user, connectedDatabase) {
|
||||||
purchaserPhoneNumber, purchaserEmail, purchaserRelationship,
|
purchaserPhoneNumber, purchaserEmail, purchaserRelationship,
|
||||||
funeralHomeId, funeralDirectorName,
|
funeralHomeId, funeralDirectorName,
|
||||||
funeralDate, funeralTime,
|
funeralDate, funeralTime,
|
||||||
directionOfArrival, committalTypeId,
|
committalTypeId,
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(addForm.contractTypeId, addForm.burialSiteId === '' ? undefined : addForm.burialSiteId, contractStartDate, addForm.contractEndDateString === ''
|
.run(addForm.contractTypeId, addForm.burialSiteId === '' ? undefined : addForm.burialSiteId, contractStartDate, addForm.contractEndDateString === ''
|
||||||
? undefined
|
? 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 === ''
|
: 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
|
? undefined
|
||||||
: dateStringToInteger(addForm.funeralDateString), addForm.funeralTimeString === ''
|
: dateStringToInteger(addForm.funeralDateString), addForm.funeralTimeString === ''
|
||||||
? undefined
|
? undefined
|
||||||
: timeStringToInteger(addForm.funeralTimeString), addForm.directionOfArrival ?? '', addForm.committalTypeId === '' ? undefined : addForm.committalTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
: timeStringToInteger(addForm.funeralTimeString), addForm.committalTypeId === '' ? undefined : addForm.committalTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||||
const contractId = result.lastInsertRowid;
|
const contractId = result.lastInsertRowid;
|
||||||
/*
|
/*
|
||||||
* Add contract fields
|
* Add contract fields
|
||||||
|
|
@ -35,7 +34,7 @@ export default function addContract(addForm, user, connectedDatabase) {
|
||||||
for (const contractTypeFieldId of contractTypeFieldIds) {
|
for (const contractTypeFieldId of contractTypeFieldIds) {
|
||||||
const fieldValue = addForm[`fieldValue_${contractTypeFieldId}`];
|
const fieldValue = addForm[`fieldValue_${contractTypeFieldId}`];
|
||||||
if ((fieldValue ?? '') !== '') {
|
if ((fieldValue ?? '') !== '') {
|
||||||
addOrUpdateContractField({
|
await addOrUpdateContractField({
|
||||||
contractId,
|
contractId,
|
||||||
contractTypeFieldId,
|
contractTypeFieldId,
|
||||||
fieldValue: fieldValue ?? ''
|
fieldValue: fieldValue ?? ''
|
||||||
|
|
@ -67,7 +66,7 @@ export default function addContract(addForm, user, connectedDatabase) {
|
||||||
: addForm.intermentContainerTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
: addForm.intermentContainerTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||||
}
|
}
|
||||||
if (connectedDatabase === undefined) {
|
if (connectedDatabase === undefined) {
|
||||||
database.close();
|
database.release();
|
||||||
}
|
}
|
||||||
return contractId;
|
return contractId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
|
import type { PoolConnection } from 'better-sqlite-pool'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type DateString,
|
type DateString,
|
||||||
type TimeString,
|
type TimeString,
|
||||||
dateStringToInteger,
|
dateStringToInteger,
|
||||||
timeStringToInteger
|
timeStringToInteger
|
||||||
} from '@cityssm/utils-datetime'
|
} from '@cityssm/utils-datetime'
|
||||||
import sqlite from 'better-sqlite3'
|
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
|
||||||
|
|
||||||
import addOrUpdateContractField from './addOrUpdateContractField.js'
|
import addOrUpdateContractField from './addOrUpdateContractField.js'
|
||||||
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface AddContractForm {
|
export interface AddContractForm {
|
||||||
burialSiteId: number | string
|
burialSiteId: number | string
|
||||||
|
|
@ -20,7 +20,6 @@ export interface AddContractForm {
|
||||||
contractTypeFieldIds?: string
|
contractTypeFieldIds?: string
|
||||||
|
|
||||||
committalTypeId?: number | string
|
committalTypeId?: number | string
|
||||||
directionOfArrival?: string
|
|
||||||
funeralDateString?: '' | DateString
|
funeralDateString?: '' | DateString
|
||||||
funeralDirectorName?: string
|
funeralDirectorName?: string
|
||||||
funeralHomeId?: number | string
|
funeralHomeId?: number | string
|
||||||
|
|
@ -52,12 +51,12 @@ export interface AddContractForm {
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line complexity
|
// eslint-disable-next-line complexity
|
||||||
export default function addContract(
|
export default async function addContract(
|
||||||
addForm: AddContractForm,
|
addForm: AddContractForm,
|
||||||
user: User,
|
user: User,
|
||||||
connectedDatabase?: sqlite.Database
|
connectedDatabase?: PoolConnection
|
||||||
): number {
|
): Promise<number> {
|
||||||
const database = connectedDatabase ?? sqlite(sunriseDB)
|
const database = connectedDatabase ?? (await acquireConnection())
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
|
|
@ -75,10 +74,10 @@ export default function addContract(
|
||||||
purchaserPhoneNumber, purchaserEmail, purchaserRelationship,
|
purchaserPhoneNumber, purchaserEmail, purchaserRelationship,
|
||||||
funeralHomeId, funeralDirectorName,
|
funeralHomeId, funeralDirectorName,
|
||||||
funeralDate, funeralTime,
|
funeralDate, funeralTime,
|
||||||
directionOfArrival, committalTypeId,
|
committalTypeId,
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||||
)
|
)
|
||||||
.run(
|
.run(
|
||||||
addForm.contractTypeId,
|
addForm.contractTypeId,
|
||||||
|
|
@ -104,7 +103,6 @@ export default function addContract(
|
||||||
addForm.funeralTimeString === ''
|
addForm.funeralTimeString === ''
|
||||||
? undefined
|
? undefined
|
||||||
: timeStringToInteger(addForm.funeralTimeString as TimeString),
|
: timeStringToInteger(addForm.funeralTimeString as TimeString),
|
||||||
addForm.directionOfArrival ?? '',
|
|
||||||
addForm.committalTypeId === '' ? undefined : addForm.committalTypeId,
|
addForm.committalTypeId === '' ? undefined : addForm.committalTypeId,
|
||||||
user.userName,
|
user.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
|
|
@ -126,7 +124,7 @@ export default function addContract(
|
||||||
| undefined
|
| undefined
|
||||||
|
|
||||||
if ((fieldValue ?? '') !== '') {
|
if ((fieldValue ?? '') !== '') {
|
||||||
addOrUpdateContractField(
|
await addOrUpdateContractField(
|
||||||
{
|
{
|
||||||
contractId,
|
contractId,
|
||||||
contractTypeFieldId,
|
contractTypeFieldId,
|
||||||
|
|
@ -188,7 +186,7 @@ export default function addContract(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connectedDatabase === undefined) {
|
if (connectedDatabase === undefined) {
|
||||||
database.close()
|
database.release()
|
||||||
}
|
}
|
||||||
|
|
||||||
return contractId
|
return contractId
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
||||||
export interface AddContractCommentForm {
|
export interface AddContractCommentForm {
|
||||||
contractId: number | string;
|
|
||||||
comment: string;
|
comment: string;
|
||||||
commentDateString?: DateString;
|
commentDateString?: DateString;
|
||||||
commentTimeString?: TimeString;
|
commentTimeString?: TimeString;
|
||||||
|
contractId: number | string;
|
||||||
}
|
}
|
||||||
export default function addContractComment(commentForm: AddContractCommentForm, user: User): number;
|
export default function addContractComment(commentForm: AddContractCommentForm, user: User): Promise<number>;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/utils-datetime';
|
import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/utils-datetime';
|
||||||
import sqlite from 'better-sqlite3';
|
import { acquireConnection } from './pool.js';
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
export default async function addContractComment(commentForm, user) {
|
||||||
export default function addContractComment(commentForm, user) {
|
|
||||||
const rightNow = new Date();
|
const rightNow = new Date();
|
||||||
let commentDate = 0;
|
let commentDate = 0;
|
||||||
let commentTime = 0;
|
let commentTime = 0;
|
||||||
|
|
@ -13,7 +12,7 @@ export default function addContractComment(commentForm, user) {
|
||||||
commentDate = dateStringToInteger(commentForm.commentDateString);
|
commentDate = dateStringToInteger(commentForm.commentDateString);
|
||||||
commentTime = timeStringToInteger(commentForm.commentTimeString);
|
commentTime = timeStringToInteger(commentForm.commentTimeString);
|
||||||
}
|
}
|
||||||
const database = sqlite(sunriseDB);
|
const database = await acquireConnection();
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(`insert into ContractComments (
|
.prepare(`insert into ContractComments (
|
||||||
contractId,
|
contractId,
|
||||||
|
|
@ -23,6 +22,6 @@ export default function addContractComment(commentForm, user) {
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(commentForm.contractId, commentDate, commentTime ?? 0, commentForm.comment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime());
|
.run(commentForm.contractId, commentDate, commentTime ?? 0, commentForm.comment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime());
|
||||||
database.close();
|
database.release();
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,22 +6,20 @@ import {
|
||||||
dateToTimeInteger,
|
dateToTimeInteger,
|
||||||
timeStringToInteger
|
timeStringToInteger
|
||||||
} from '@cityssm/utils-datetime'
|
} from '@cityssm/utils-datetime'
|
||||||
import sqlite from 'better-sqlite3'
|
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface AddContractCommentForm {
|
export interface AddContractCommentForm {
|
||||||
contractId: number | string
|
|
||||||
|
|
||||||
comment: string
|
comment: string
|
||||||
commentDateString?: DateString
|
commentDateString?: DateString
|
||||||
commentTimeString?: TimeString
|
commentTimeString?: TimeString
|
||||||
|
contractId: number | string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function addContractComment(
|
export default async function addContractComment(
|
||||||
commentForm: AddContractCommentForm,
|
commentForm: AddContractCommentForm,
|
||||||
user: User
|
user: User
|
||||||
): number {
|
): Promise<number> {
|
||||||
const rightNow = new Date()
|
const rightNow = new Date()
|
||||||
|
|
||||||
let commentDate = 0
|
let commentDate = 0
|
||||||
|
|
@ -39,7 +37,7 @@ export default function addContractComment(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const database = sqlite(sunriseDB)
|
const database = await acquireConnection()
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(
|
.prepare(
|
||||||
|
|
@ -62,7 +60,7 @@ export default function addContractComment(
|
||||||
rightNow.getTime()
|
rightNow.getTime()
|
||||||
)
|
)
|
||||||
|
|
||||||
database.close()
|
database.release()
|
||||||
|
|
||||||
return result.lastInsertRowid as number
|
return result.lastInsertRowid as number
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import sqlite from 'better-sqlite3';
|
import type { PoolConnection } from 'better-sqlite-pool';
|
||||||
export interface AddContractFeeForm {
|
export interface AddContractFeeForm {
|
||||||
contractId: number | string;
|
contractId: number | string;
|
||||||
feeId: number | string;
|
feeId: number | string;
|
||||||
|
|
@ -6,4 +6,4 @@ export interface AddContractFeeForm {
|
||||||
quantity: number | string;
|
quantity: number | string;
|
||||||
taxAmount?: number | string;
|
taxAmount?: number | string;
|
||||||
}
|
}
|
||||||
export default function addContractFee(addFeeForm: AddContractFeeForm, user: User, connectedDatabase?: sqlite.Database): Promise<boolean>;
|
export default function addContractFee(addFeeForm: AddContractFeeForm, user: User, connectedDatabase?: PoolConnection): Promise<boolean>;
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,16 @@
|
||||||
import sqlite from 'better-sqlite3';
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
|
||||||
import { calculateFeeAmount, calculateTaxAmount } from '../helpers/functions.fee.js';
|
import { calculateFeeAmount, calculateTaxAmount } from '../helpers/functions.fee.js';
|
||||||
import getContract from './getContract.js';
|
import getContract from './getContract.js';
|
||||||
import getFee from './getFee.js';
|
import getFee from './getFee.js';
|
||||||
|
import { acquireConnection } from './pool.js';
|
||||||
export default async function addContractFee(addFeeForm, user, connectedDatabase) {
|
export default async function addContractFee(addFeeForm, user, connectedDatabase) {
|
||||||
const database = connectedDatabase ?? sqlite(sunriseDB);
|
const database = connectedDatabase ?? (await acquireConnection());
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
// Calculate fee and tax (if not set)
|
// Calculate fee and tax (if not set)
|
||||||
let feeAmount;
|
let feeAmount;
|
||||||
let taxAmount;
|
let taxAmount;
|
||||||
if ((addFeeForm.feeAmount ?? '') === '') {
|
if ((addFeeForm.feeAmount ?? '') === '') {
|
||||||
const contract = (await getContract(addFeeForm.contractId));
|
const contract = (await getContract(addFeeForm.contractId));
|
||||||
const fee = getFee(addFeeForm.feeId);
|
const fee = (await getFee(addFeeForm.feeId));
|
||||||
feeAmount = calculateFeeAmount(fee, contract);
|
feeAmount = calculateFeeAmount(fee, contract);
|
||||||
taxAmount = calculateTaxAmount(fee, feeAmount);
|
taxAmount = calculateTaxAmount(fee, feeAmount);
|
||||||
}
|
}
|
||||||
|
|
@ -84,7 +83,7 @@ export default async function addContractFee(addFeeForm, user, connectedDatabase
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (connectedDatabase === undefined) {
|
if (connectedDatabase === undefined) {
|
||||||
database.close();
|
database.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
import sqlite from 'better-sqlite3'
|
import type { PoolConnection } from 'better-sqlite-pool'
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
|
||||||
import {
|
import {
|
||||||
calculateFeeAmount,
|
calculateFeeAmount,
|
||||||
calculateTaxAmount
|
calculateTaxAmount
|
||||||
} from '../helpers/functions.fee.js'
|
} from '../helpers/functions.fee.js'
|
||||||
import type { Contract, Fee } from '../types/record.types.js'
|
import type { Contract, Fee } from '../types/recordTypes.js'
|
||||||
|
|
||||||
import getContract from './getContract.js'
|
import getContract from './getContract.js'
|
||||||
import getFee from './getFee.js'
|
import getFee from './getFee.js'
|
||||||
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface AddContractFeeForm {
|
export interface AddContractFeeForm {
|
||||||
contractId: number | string
|
contractId: number | string
|
||||||
|
|
@ -22,9 +22,9 @@ export interface AddContractFeeForm {
|
||||||
export default async function addContractFee(
|
export default async function addContractFee(
|
||||||
addFeeForm: AddContractFeeForm,
|
addFeeForm: AddContractFeeForm,
|
||||||
user: User,
|
user: User,
|
||||||
connectedDatabase?: sqlite.Database
|
connectedDatabase?: PoolConnection
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const database = connectedDatabase ?? sqlite(sunriseDB)
|
const database = connectedDatabase ?? (await acquireConnection())
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
|
|
@ -33,9 +33,11 @@ export default async function addContractFee(
|
||||||
let taxAmount: number
|
let taxAmount: number
|
||||||
|
|
||||||
if ((addFeeForm.feeAmount ?? '') === '') {
|
if ((addFeeForm.feeAmount ?? '') === '') {
|
||||||
const contract = (await getContract(addFeeForm.contractId)) as Contract
|
const contract = (await getContract(
|
||||||
|
addFeeForm.contractId
|
||||||
|
)) as Contract
|
||||||
|
|
||||||
const fee = getFee(addFeeForm.feeId) as Fee
|
const fee = (await getFee(addFeeForm.feeId)) as Fee
|
||||||
|
|
||||||
feeAmount = calculateFeeAmount(fee, contract)
|
feeAmount = calculateFeeAmount(fee, contract)
|
||||||
taxAmount = calculateTaxAmount(fee, feeAmount)
|
taxAmount = calculateTaxAmount(fee, feeAmount)
|
||||||
|
|
@ -63,7 +65,6 @@ export default async function addContractFee(
|
||||||
| {
|
| {
|
||||||
feeAmount: number | null
|
feeAmount: number | null
|
||||||
taxAmount: number | null
|
taxAmount: number | null
|
||||||
|
|
||||||
recordDelete_timeMillis: number | null
|
recordDelete_timeMillis: number | null
|
||||||
}
|
}
|
||||||
| undefined
|
| undefined
|
||||||
|
|
@ -155,7 +156,7 @@ export default async function addContractFee(
|
||||||
return result.changes > 0
|
return result.changes > 0
|
||||||
} finally {
|
} finally {
|
||||||
if (connectedDatabase === undefined) {
|
if (connectedDatabase === undefined) {
|
||||||
database.close()
|
database.release()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
import sqlite from 'better-sqlite3';
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
|
||||||
import addContractFee from './addContractFee.js';
|
import addContractFee from './addContractFee.js';
|
||||||
import { getFeeCategory } from './getFeeCategories.js';
|
import { getFeeCategory } from './getFeeCategories.js';
|
||||||
|
import { acquireConnection } from './pool.js';
|
||||||
export default async function addContractFeeCategory(addFeeCategoryForm, user) {
|
export default async function addContractFeeCategory(addFeeCategoryForm, user) {
|
||||||
const database = sqlite(sunriseDB);
|
const database = await acquireConnection();
|
||||||
const feeCategory = getFeeCategory(addFeeCategoryForm.feeCategoryId, database);
|
const feeCategory = await getFeeCategory(addFeeCategoryForm.feeCategoryId, database);
|
||||||
let addedFeeCount = 0;
|
let addedFeeCount = 0;
|
||||||
for (const fee of feeCategory?.fees ?? []) {
|
for (const fee of feeCategory?.fees ?? []) {
|
||||||
const success = await addContractFee({
|
const success = await addContractFee({
|
||||||
|
|
@ -16,6 +15,6 @@ export default async function addContractFeeCategory(addFeeCategoryForm, user) {
|
||||||
addedFeeCount += 1;
|
addedFeeCount += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
database.close();
|
database.release();
|
||||||
return addedFeeCount;
|
return addedFeeCount;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
import sqlite from 'better-sqlite3'
|
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
|
||||||
|
|
||||||
import addContractFee from './addContractFee.js'
|
import addContractFee from './addContractFee.js'
|
||||||
import { getFeeCategory } from './getFeeCategories.js'
|
import { getFeeCategory } from './getFeeCategories.js'
|
||||||
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface AddContractCategoryForm {
|
export interface AddContractCategoryForm {
|
||||||
contractId: number | string
|
contractId: number | string
|
||||||
|
|
@ -14,9 +11,12 @@ export default async function addContractFeeCategory(
|
||||||
addFeeCategoryForm: AddContractCategoryForm,
|
addFeeCategoryForm: AddContractCategoryForm,
|
||||||
user: User
|
user: User
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
const database = sqlite(sunriseDB)
|
const database = await acquireConnection()
|
||||||
|
|
||||||
const feeCategory = getFeeCategory(addFeeCategoryForm.feeCategoryId, database)
|
const feeCategory = await getFeeCategory(
|
||||||
|
addFeeCategoryForm.feeCategoryId,
|
||||||
|
database
|
||||||
|
)
|
||||||
|
|
||||||
let addedFeeCount = 0
|
let addedFeeCount = 0
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ export default async function addContractFeeCategory(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
database.close()
|
database.release()
|
||||||
|
|
||||||
return addedFeeCount
|
return addedFeeCount
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
import { type DateString } from '@cityssm/utils-datetime';
|
import { type DateString } from '@cityssm/utils-datetime';
|
||||||
import sqlite from 'better-sqlite3';
|
import type { PoolConnection } from 'better-sqlite-pool';
|
||||||
export interface AddForm {
|
export interface AddForm {
|
||||||
contractId: number | string;
|
contractId: string | number;
|
||||||
deceasedName: string;
|
deceasedName: string;
|
||||||
deceasedAddress1: string;
|
deceasedAddress1: string;
|
||||||
deceasedAddress2: string;
|
deceasedAddress2: string;
|
||||||
deceasedCity: string;
|
deceasedCity: string;
|
||||||
deceasedPostalCode: string;
|
|
||||||
deceasedProvince: string;
|
deceasedProvince: string;
|
||||||
birthDateString: '' | DateString;
|
deceasedPostalCode: string;
|
||||||
|
birthDateString: DateString | '';
|
||||||
birthPlace: string;
|
birthPlace: string;
|
||||||
deathDateString: '' | DateString;
|
deathDateString: DateString | '';
|
||||||
deathPlace: string;
|
deathPlace: string;
|
||||||
deathAge: number | string;
|
deathAge: string | number;
|
||||||
deathAgePeriod: string;
|
deathAgePeriod: string;
|
||||||
intermentContainerTypeId: number | string;
|
intermentContainerTypeId: string | number;
|
||||||
}
|
}
|
||||||
export default function addContractInterment(contractForm: AddForm, user: User, connectedDatabase?: sqlite.Database): number;
|
export default function addContractInterment(contractForm: AddForm, user: User, connectedDatabase?: PoolConnection): Promise<number>;
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
import { dateStringToInteger } from '@cityssm/utils-datetime';
|
import { dateStringToInteger } from '@cityssm/utils-datetime';
|
||||||
import sqlite from 'better-sqlite3';
|
import { acquireConnection } from './pool.js';
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
export default async function addContractInterment(contractForm, user, connectedDatabase) {
|
||||||
export default function addContractInterment(contractForm, user, connectedDatabase) {
|
const database = connectedDatabase ?? (await acquireConnection());
|
||||||
const database = connectedDatabase ?? sqlite(sunriseDB);
|
|
||||||
const maxIntermentNumber = (database
|
const maxIntermentNumber = (database
|
||||||
.prepare(`select max(intermentNumber) as maxIntermentNumber
|
.prepare(`select max(intermentNumber) as maxIntermentNumber
|
||||||
from ContractInterments
|
from ContractInterments
|
||||||
where contractId = ?`)
|
where contractId = ?`)
|
||||||
.pluck()
|
.pluck()
|
||||||
.get(contractForm.contractId) ?? 0);
|
.get(contractForm.contractId) ?? 0);
|
||||||
const newIntermentNumber = maxIntermentNumber + 1;
|
const newIntermentNumber = maxIntermentNumber + 1;
|
||||||
|
|
@ -27,7 +26,7 @@ export default function addContractInterment(contractForm, user, connectedDataba
|
||||||
? undefined
|
? undefined
|
||||||
: contractForm.intermentContainerTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
: contractForm.intermentContainerTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||||
if (connectedDatabase === undefined) {
|
if (connectedDatabase === undefined) {
|
||||||
database.close();
|
database.release();
|
||||||
}
|
}
|
||||||
return newIntermentNumber;
|
return newIntermentNumber;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,37 @@
|
||||||
import { type DateString, dateStringToInteger } from '@cityssm/utils-datetime'
|
import { type DateString, dateStringToInteger } from '@cityssm/utils-datetime'
|
||||||
import sqlite from 'better-sqlite3'
|
import type { PoolConnection } from 'better-sqlite-pool'
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface AddForm {
|
export interface AddForm {
|
||||||
contractId: number | string
|
contractId: string | number
|
||||||
|
|
||||||
deceasedName: string
|
deceasedName: string
|
||||||
|
|
||||||
deceasedAddress1: string
|
deceasedAddress1: string
|
||||||
deceasedAddress2: string
|
deceasedAddress2: string
|
||||||
deceasedCity: string
|
deceasedCity: string
|
||||||
deceasedPostalCode: string
|
|
||||||
deceasedProvince: string
|
deceasedProvince: string
|
||||||
|
deceasedPostalCode: string
|
||||||
birthDateString: '' | DateString
|
birthDateString: DateString | ''
|
||||||
birthPlace: string
|
birthPlace: string
|
||||||
deathDateString: '' | DateString
|
deathDateString: DateString | ''
|
||||||
deathPlace: string
|
deathPlace: string
|
||||||
|
deathAge: string | number
|
||||||
deathAge: number | string
|
|
||||||
deathAgePeriod: string
|
deathAgePeriod: string
|
||||||
|
intermentContainerTypeId: string | number
|
||||||
intermentContainerTypeId: number | string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function addContractInterment(
|
export default async function addContractInterment(
|
||||||
contractForm: AddForm,
|
contractForm: AddForm,
|
||||||
user: User,
|
user: User,
|
||||||
connectedDatabase?: sqlite.Database
|
connectedDatabase?: PoolConnection
|
||||||
): number {
|
): Promise<number> {
|
||||||
const database = connectedDatabase ?? sqlite(sunriseDB)
|
const database = connectedDatabase ?? (await acquireConnection())
|
||||||
|
|
||||||
const maxIntermentNumber = (database
|
const maxIntermentNumber = (database
|
||||||
.prepare(
|
.prepare(
|
||||||
`select max(intermentNumber) as maxIntermentNumber
|
`select max(intermentNumber) as maxIntermentNumber
|
||||||
from ContractInterments
|
from ContractInterments
|
||||||
where contractId = ?`
|
where contractId = ?`
|
||||||
)
|
)
|
||||||
.pluck()
|
.pluck()
|
||||||
.get(contractForm.contractId) ?? 0) as number
|
.get(contractForm.contractId) ?? 0) as number
|
||||||
|
|
@ -81,7 +76,7 @@ export default function addContractInterment(
|
||||||
)
|
)
|
||||||
|
|
||||||
if (connectedDatabase === undefined) {
|
if (connectedDatabase === undefined) {
|
||||||
database.close()
|
database.release()
|
||||||
}
|
}
|
||||||
|
|
||||||
return newIntermentNumber
|
return newIntermentNumber
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
|
||||||
export interface AddTransactionForm {
|
export interface AddTransactionForm {
|
||||||
contractId: number | string;
|
contractId: string | number;
|
||||||
transactionDateString?: '' | DateString;
|
transactionDateString?: string;
|
||||||
transactionTimeString?: '' | TimeString;
|
transactionTimeString?: string;
|
||||||
|
transactionAmount: string | number;
|
||||||
externalReceiptNumber: string;
|
externalReceiptNumber: string;
|
||||||
transactionAmount: number | string;
|
|
||||||
transactionNote: string;
|
transactionNote: string;
|
||||||
}
|
}
|
||||||
export default function addContractTransaction(contractTransactionForm: AddTransactionForm, user: User): number;
|
export default function addContractTransaction(contractTransactionForm: AddTransactionForm, user: User): Promise<number>;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/utils-datetime';
|
import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/utils-datetime';
|
||||||
import sqlite from 'better-sqlite3';
|
import { acquireConnection } from './pool.js';
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
export default async function addContractTransaction(contractTransactionForm, user) {
|
||||||
export default function addContractTransaction(contractTransactionForm, user) {
|
const database = await acquireConnection();
|
||||||
const database = sqlite(sunriseDB);
|
|
||||||
let transactionIndex = 0;
|
let transactionIndex = 0;
|
||||||
const maxIndexResult = database
|
const maxIndexResult = database
|
||||||
.prepare(`select transactionIndex
|
.prepare(`select transactionIndex
|
||||||
|
|
@ -15,12 +14,12 @@ export default function addContractTransaction(contractTransactionForm, user) {
|
||||||
transactionIndex = maxIndexResult.transactionIndex + 1;
|
transactionIndex = maxIndexResult.transactionIndex + 1;
|
||||||
}
|
}
|
||||||
const rightNow = new Date();
|
const rightNow = new Date();
|
||||||
const transactionDate = (contractTransactionForm.transactionDateString ?? '') === ''
|
const transactionDate = contractTransactionForm.transactionDateString
|
||||||
? dateToInteger(rightNow)
|
? dateStringToInteger(contractTransactionForm.transactionDateString)
|
||||||
: dateStringToInteger(contractTransactionForm.transactionDateString);
|
: dateToInteger(rightNow);
|
||||||
const transactionTime = (contractTransactionForm.transactionTimeString ?? '') === ''
|
const transactionTime = contractTransactionForm.transactionTimeString
|
||||||
? dateToTimeInteger(rightNow)
|
? timeStringToInteger(contractTransactionForm.transactionTimeString)
|
||||||
: timeStringToInteger(contractTransactionForm.transactionTimeString);
|
: dateToTimeInteger(rightNow);
|
||||||
database
|
database
|
||||||
.prepare(`insert into ContractTransactions (
|
.prepare(`insert into ContractTransactions (
|
||||||
contractId, transactionIndex,
|
contractId, transactionIndex,
|
||||||
|
|
@ -30,6 +29,6 @@ export default function addContractTransaction(contractTransactionForm, user) {
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(contractTransactionForm.contractId, transactionIndex, transactionDate, transactionTime, contractTransactionForm.transactionAmount, contractTransactionForm.externalReceiptNumber, contractTransactionForm.transactionNote, user.userName, rightNow.getTime(), user.userName, rightNow.getTime());
|
.run(contractTransactionForm.contractId, transactionIndex, transactionDate, transactionTime, contractTransactionForm.transactionAmount, contractTransactionForm.externalReceiptNumber, contractTransactionForm.transactionNote, user.userName, rightNow.getTime(), user.userName, rightNow.getTime());
|
||||||
database.close();
|
database.release();
|
||||||
return transactionIndex;
|
return transactionIndex;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,26 @@
|
||||||
import {
|
import {
|
||||||
type DateString,
|
|
||||||
type TimeString,
|
|
||||||
dateStringToInteger,
|
dateStringToInteger,
|
||||||
dateToInteger,
|
dateToInteger,
|
||||||
dateToTimeInteger,
|
dateToTimeInteger,
|
||||||
timeStringToInteger
|
timeStringToInteger
|
||||||
} from '@cityssm/utils-datetime'
|
} from '@cityssm/utils-datetime'
|
||||||
import sqlite from 'better-sqlite3'
|
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface AddTransactionForm {
|
export interface AddTransactionForm {
|
||||||
contractId: number | string
|
contractId: string | number
|
||||||
|
transactionDateString?: string
|
||||||
transactionDateString?: '' | DateString
|
transactionTimeString?: string
|
||||||
transactionTimeString?: '' | TimeString
|
transactionAmount: string | number
|
||||||
|
|
||||||
externalReceiptNumber: string
|
externalReceiptNumber: string
|
||||||
transactionAmount: number | string
|
|
||||||
transactionNote: string
|
transactionNote: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function addContractTransaction(
|
export default async function addContractTransaction(
|
||||||
contractTransactionForm: AddTransactionForm,
|
contractTransactionForm: AddTransactionForm,
|
||||||
user: User
|
user: User
|
||||||
): number {
|
): Promise<number> {
|
||||||
const database = sqlite(sunriseDB)
|
const database = await acquireConnection()
|
||||||
|
|
||||||
let transactionIndex = 0
|
let transactionIndex = 0
|
||||||
|
|
||||||
|
|
@ -47,19 +42,13 @@ export default function addContractTransaction(
|
||||||
|
|
||||||
const rightNow = new Date()
|
const rightNow = new Date()
|
||||||
|
|
||||||
const transactionDate =
|
const transactionDate = contractTransactionForm.transactionDateString
|
||||||
(contractTransactionForm.transactionDateString ?? '') === ''
|
? dateStringToInteger(contractTransactionForm.transactionDateString)
|
||||||
? dateToInteger(rightNow)
|
: dateToInteger(rightNow)
|
||||||
: dateStringToInteger(
|
|
||||||
contractTransactionForm.transactionDateString as DateString
|
|
||||||
)
|
|
||||||
|
|
||||||
const transactionTime =
|
const transactionTime = contractTransactionForm.transactionTimeString
|
||||||
(contractTransactionForm.transactionTimeString ?? '') === ''
|
? timeStringToInteger(contractTransactionForm.transactionTimeString)
|
||||||
? dateToTimeInteger(rightNow)
|
: dateToTimeInteger(rightNow)
|
||||||
: timeStringToInteger(
|
|
||||||
contractTransactionForm.transactionTimeString as TimeString
|
|
||||||
)
|
|
||||||
|
|
||||||
database
|
database
|
||||||
.prepare(
|
.prepare(
|
||||||
|
|
@ -85,7 +74,7 @@ export default function addContractTransaction(
|
||||||
rightNow.getTime()
|
rightNow.getTime()
|
||||||
)
|
)
|
||||||
|
|
||||||
database.close()
|
database.release()
|
||||||
|
|
||||||
return transactionIndex
|
return transactionIndex
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,4 @@ export interface AddForm {
|
||||||
isPreneed?: string;
|
isPreneed?: string;
|
||||||
orderNumber?: number;
|
orderNumber?: number;
|
||||||
}
|
}
|
||||||
export default function addContractType(addForm: AddForm, user: User): number;
|
export default function addContractType(addForm: AddForm, user: User): Promise<number>;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import sqlite from 'better-sqlite3';
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
|
||||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||||
export default function addContractType(addForm, user) {
|
import { acquireConnection } from './pool.js';
|
||||||
const database = sqlite(sunriseDB);
|
export default async function addContractType(addForm, user) {
|
||||||
|
const database = await acquireConnection();
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(`insert into ContractTypes (
|
.prepare(`insert into ContractTypes (
|
||||||
|
|
@ -11,7 +10,7 @@ export default function addContractType(addForm, user) {
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(addForm.contractType, addForm.isPreneed === undefined ? 0 : 1, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
.run(addForm.contractType, addForm.isPreneed === undefined ? 0 : 1, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||||
database.close();
|
database.release();
|
||||||
clearCacheByTableName('ContractTypes');
|
clearCacheByTableName('ContractTypes');
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,18 @@
|
||||||
import sqlite from 'better-sqlite3'
|
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
|
||||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||||
|
|
||||||
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface AddForm {
|
export interface AddForm {
|
||||||
contractType: string
|
contractType: string
|
||||||
isPreneed?: string
|
isPreneed?: string
|
||||||
orderNumber?: number
|
orderNumber?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function addContractType(addForm: AddForm, user: User): number {
|
export default async function addContractType(
|
||||||
const database = sqlite(sunriseDB)
|
addForm: AddForm,
|
||||||
|
user: User
|
||||||
|
): Promise<number> {
|
||||||
|
const database = await acquireConnection()
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
|
|
@ -32,7 +34,7 @@ export default function addContractType(addForm: AddForm, user: User): number {
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
)
|
)
|
||||||
|
|
||||||
database.close()
|
database.release()
|
||||||
|
|
||||||
clearCacheByTableName('ContractTypes')
|
clearCacheByTableName('ContractTypes')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
export interface AddContractTypeFieldForm {
|
export interface AddContractTypeFieldForm {
|
||||||
contractTypeId?: number | string;
|
contractTypeId?: string | number;
|
||||||
contractTypeField: string;
|
contractTypeField: string;
|
||||||
fieldType?: string;
|
|
||||||
fieldValues?: string;
|
fieldValues?: string;
|
||||||
|
fieldType?: string;
|
||||||
isRequired?: string;
|
isRequired?: string;
|
||||||
maxLength?: number | string;
|
|
||||||
minLength?: number | string;
|
|
||||||
pattern?: string;
|
pattern?: string;
|
||||||
|
minLength?: string | number;
|
||||||
|
maxLength?: string | number;
|
||||||
orderNumber?: number;
|
orderNumber?: number;
|
||||||
}
|
}
|
||||||
export default function addContractTypeField(addForm: AddContractTypeFieldForm, user: User): number;
|
export default function addContractTypeField(addForm: AddContractTypeFieldForm, user: User): Promise<number>;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import sqlite from 'better-sqlite3';
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
|
||||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||||
export default function addContractTypeField(addForm, user) {
|
import { acquireConnection } from './pool.js';
|
||||||
const database = sqlite(sunriseDB);
|
export default async function addContractTypeField(addForm, user) {
|
||||||
|
const database = await acquireConnection();
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(`insert into ContractTypeFields (
|
.prepare(`insert into ContractTypeFields (
|
||||||
|
|
@ -13,10 +12,8 @@ export default function addContractTypeField(addForm, user) {
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(addForm.contractTypeId ?? undefined, addForm.contractTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0,
|
.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);
|
||||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
database.release();
|
||||||
addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
|
||||||
database.close();
|
|
||||||
clearCacheByTableName('ContractTypeFields');
|
clearCacheByTableName('ContractTypeFields');
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,24 @@
|
||||||
import sqlite from 'better-sqlite3'
|
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
|
||||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||||
|
|
||||||
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface AddContractTypeFieldForm {
|
export interface AddContractTypeFieldForm {
|
||||||
contractTypeId?: number | string
|
contractTypeId?: string | number
|
||||||
|
|
||||||
contractTypeField: string
|
contractTypeField: string
|
||||||
|
|
||||||
fieldType?: string
|
|
||||||
fieldValues?: string
|
fieldValues?: string
|
||||||
|
fieldType?: string
|
||||||
isRequired?: string
|
isRequired?: string
|
||||||
maxLength?: number | string
|
|
||||||
minLength?: number | string
|
|
||||||
pattern?: string
|
pattern?: string
|
||||||
|
minLength?: string | number
|
||||||
|
maxLength?: string | number
|
||||||
orderNumber?: number
|
orderNumber?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function addContractTypeField(
|
export default async function addContractTypeField(
|
||||||
addForm: AddContractTypeFieldForm,
|
addForm: AddContractTypeFieldForm,
|
||||||
user: User
|
user: User
|
||||||
): number {
|
): Promise<number> {
|
||||||
const database = sqlite(sunriseDB)
|
const database = await acquireConnection()
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
|
|
@ -45,7 +41,6 @@ export default function addContractTypeField(
|
||||||
addForm.isRequired === '' ? 0 : 1,
|
addForm.isRequired === '' ? 0 : 1,
|
||||||
addForm.pattern ?? '',
|
addForm.pattern ?? '',
|
||||||
addForm.minLength ?? 0,
|
addForm.minLength ?? 0,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
||||||
addForm.maxLength ?? 100,
|
addForm.maxLength ?? 100,
|
||||||
addForm.orderNumber ?? -1,
|
addForm.orderNumber ?? -1,
|
||||||
user.userName,
|
user.userName,
|
||||||
|
|
@ -54,7 +49,7 @@ export default function addContractTypeField(
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
)
|
)
|
||||||
|
|
||||||
database.close()
|
database.release()
|
||||||
|
|
||||||
clearCacheByTableName('ContractTypeFields')
|
clearCacheByTableName('ContractTypeFields')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
export interface AddContractTypePrintForm {
|
export interface AddContractTypePrintForm {
|
||||||
contractTypeId: number | string;
|
contractTypeId: string | number;
|
||||||
printEJS: string;
|
printEJS: string;
|
||||||
orderNumber?: number;
|
orderNumber?: number;
|
||||||
}
|
}
|
||||||
export default function addContractTypePrint(addForm: AddContractTypePrintForm, user: User): boolean;
|
export default function addContractTypePrint(addForm: AddContractTypePrintForm, user: User): Promise<boolean>;
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,16 @@
|
||||||
import sqlite from 'better-sqlite3';
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
|
||||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||||
export default function addContractTypePrint(addForm, user) {
|
import { acquireConnection } from './pool.js';
|
||||||
const database = sqlite(sunriseDB);
|
export default async function addContractTypePrint(addForm, user) {
|
||||||
|
const database = await acquireConnection();
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
let result = database
|
let result = database
|
||||||
.prepare(`update ContractTypePrints
|
.prepare(`update ContractTypePrints
|
||||||
set recordUpdate_userName = ?,
|
set recordUpdate_userName = ?,
|
||||||
recordUpdate_timeMillis = ?,
|
recordUpdate_timeMillis = ?,
|
||||||
recordDelete_userName = null,
|
recordDelete_userName = null,
|
||||||
recordDelete_timeMillis = null
|
recordDelete_timeMillis = null
|
||||||
where contractTypeId = ?
|
where contractTypeId = ?
|
||||||
and printEJS = ?`)
|
and printEJS = ?`)
|
||||||
.run(user.userName, rightNowMillis, addForm.contractTypeId, addForm.printEJS);
|
.run(user.userName, rightNowMillis, addForm.contractTypeId, addForm.printEJS);
|
||||||
if (result.changes === 0) {
|
if (result.changes === 0) {
|
||||||
result = database
|
result = database
|
||||||
|
|
@ -22,7 +21,7 @@ export default function addContractTypePrint(addForm, user) {
|
||||||
values (?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(addForm.contractTypeId, addForm.printEJS, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
.run(addForm.contractTypeId, addForm.printEJS, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||||
}
|
}
|
||||||
database.close();
|
database.release();
|
||||||
clearCacheByTableName('ContractTypePrints');
|
clearCacheByTableName('ContractTypePrints');
|
||||||
return result.changes > 0;
|
return result.changes > 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,18 @@
|
||||||
import sqlite from 'better-sqlite3'
|
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
|
||||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||||
|
|
||||||
export interface AddContractTypePrintForm {
|
import { acquireConnection } from './pool.js'
|
||||||
contractTypeId: number | string
|
|
||||||
printEJS: string
|
|
||||||
|
|
||||||
|
export interface AddContractTypePrintForm {
|
||||||
|
contractTypeId: string | number
|
||||||
|
printEJS: string
|
||||||
orderNumber?: number
|
orderNumber?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function addContractTypePrint(
|
export default async function addContractTypePrint(
|
||||||
addForm: AddContractTypePrintForm,
|
addForm: AddContractTypePrintForm,
|
||||||
user: User
|
user: User
|
||||||
): boolean {
|
): Promise<boolean> {
|
||||||
const database = sqlite(sunriseDB)
|
const database = await acquireConnection()
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
|
|
@ -22,11 +20,11 @@ export default function addContractTypePrint(
|
||||||
.prepare(
|
.prepare(
|
||||||
`update ContractTypePrints
|
`update ContractTypePrints
|
||||||
set recordUpdate_userName = ?,
|
set recordUpdate_userName = ?,
|
||||||
recordUpdate_timeMillis = ?,
|
recordUpdate_timeMillis = ?,
|
||||||
recordDelete_userName = null,
|
recordDelete_userName = null,
|
||||||
recordDelete_timeMillis = null
|
recordDelete_timeMillis = null
|
||||||
where contractTypeId = ?
|
where contractTypeId = ?
|
||||||
and printEJS = ?`
|
and printEJS = ?`
|
||||||
)
|
)
|
||||||
.run(
|
.run(
|
||||||
user.userName,
|
user.userName,
|
||||||
|
|
@ -55,7 +53,7 @@ export default function addContractTypePrint(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
database.close()
|
database.release()
|
||||||
|
|
||||||
clearCacheByTableName('ContractTypePrints')
|
clearCacheByTableName('ContractTypePrints')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
export interface AddFeeForm {
|
export interface AddFeeForm {
|
||||||
feeCategoryId: number | string;
|
feeCategoryId: string | number;
|
||||||
feeName: string;
|
feeName: string;
|
||||||
feeDescription: string;
|
feeDescription: string;
|
||||||
feeAccount: string;
|
feeAccount: string;
|
||||||
contractTypeId: number | string;
|
contractTypeId: string | number;
|
||||||
burialSiteTypeId: number | string;
|
burialSiteTypeId: string | number;
|
||||||
feeAmount?: string;
|
feeAmount?: string;
|
||||||
feeFunction?: string;
|
feeFunction?: string;
|
||||||
taxAmount?: string;
|
taxAmount?: string;
|
||||||
|
|
@ -14,4 +14,4 @@ export interface AddFeeForm {
|
||||||
isRequired?: '' | '1';
|
isRequired?: '' | '1';
|
||||||
orderNumber?: number;
|
orderNumber?: number;
|
||||||
}
|
}
|
||||||
export default function addFee(feeForm: AddFeeForm, user: User): number;
|
export default function addFee(feeForm: AddFeeForm, user: User): Promise<number>;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import sqlite from 'better-sqlite3';
|
import { acquireConnection } from './pool.js';
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
export default async function addFee(feeForm, user) {
|
||||||
export default function addFee(feeForm, user) {
|
const database = await acquireConnection();
|
||||||
const database = sqlite(sunriseDB);
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(`insert into Fees (
|
.prepare(`insert into Fees (
|
||||||
|
|
@ -16,6 +15,6 @@ export default function addFee(feeForm, user) {
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(feeForm.feeCategoryId, feeForm.feeName, feeForm.feeDescription, feeForm.feeAccount, feeForm.contractTypeId === '' ? undefined : feeForm.contractTypeId, feeForm.burialSiteTypeId === '' ? undefined : feeForm.burialSiteTypeId, feeForm.feeAmount === '' ? undefined : feeForm.feeAmount, feeForm.feeFunction ?? undefined, feeForm.taxAmount === '' ? undefined : feeForm.taxAmount, feeForm.taxPercentage === '' ? undefined : feeForm.taxPercentage, (feeForm.includeQuantity ?? '') === '' ? 0 : 1, feeForm.quantityUnit, (feeForm.isRequired ?? '') === '' ? 0 : 1, feeForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
.run(feeForm.feeCategoryId, feeForm.feeName, feeForm.feeDescription, feeForm.feeAccount, feeForm.contractTypeId === '' ? undefined : feeForm.contractTypeId, feeForm.burialSiteTypeId === '' ? undefined : feeForm.burialSiteTypeId, feeForm.feeAmount === '' ? undefined : feeForm.feeAmount, feeForm.feeFunction ?? undefined, feeForm.taxAmount === '' ? undefined : feeForm.taxAmount, feeForm.taxPercentage === '' ? undefined : feeForm.taxPercentage, (feeForm.includeQuantity ?? '') === '' ? 0 : 1, feeForm.quantityUnit, (feeForm.isRequired ?? '') === '' ? 0 : 1, feeForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||||
database.close();
|
database.release();
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
import sqlite from 'better-sqlite3'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
|
||||||
|
|
||||||
export interface AddFeeForm {
|
export interface AddFeeForm {
|
||||||
feeCategoryId: number | string
|
feeCategoryId: string | number
|
||||||
feeName: string
|
feeName: string
|
||||||
feeDescription: string
|
feeDescription: string
|
||||||
feeAccount: string
|
feeAccount: string
|
||||||
contractTypeId: number | string
|
contractTypeId: string | number
|
||||||
burialSiteTypeId: number | string
|
burialSiteTypeId: string | number
|
||||||
feeAmount?: string
|
feeAmount?: string
|
||||||
feeFunction?: string
|
feeFunction?: string
|
||||||
taxAmount?: string
|
taxAmount?: string
|
||||||
|
|
@ -19,8 +17,11 @@ export interface AddFeeForm {
|
||||||
orderNumber?: number
|
orderNumber?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function addFee(feeForm: AddFeeForm, user: User): number {
|
export default async function addFee(
|
||||||
const database = sqlite(sunriseDB)
|
feeForm: AddFeeForm,
|
||||||
|
user: User
|
||||||
|
): Promise<number> {
|
||||||
|
const database = await acquireConnection()
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
|
|
@ -59,7 +60,7 @@ export default function addFee(feeForm: AddFeeForm, user: User): number {
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
)
|
)
|
||||||
|
|
||||||
database.close()
|
database.release()
|
||||||
|
|
||||||
return result.lastInsertRowid as number
|
return result.lastInsertRowid as number
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,4 @@ export interface AddFeeCategoryForm {
|
||||||
isGroupedFee?: '1';
|
isGroupedFee?: '1';
|
||||||
orderNumber?: number;
|
orderNumber?: number;
|
||||||
}
|
}
|
||||||
export default function addFeeCategory(feeCategoryForm: AddFeeCategoryForm, user: User): number;
|
export default function addFeeCategory(feeCategoryForm: AddFeeCategoryForm, user: User): Promise<number>;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import sqlite from 'better-sqlite3';
|
import { acquireConnection } from './pool.js';
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
export default async function addFeeCategory(feeCategoryForm, user) {
|
||||||
export default function addFeeCategory(feeCategoryForm, user) {
|
const database = await acquireConnection();
|
||||||
const database = sqlite(sunriseDB);
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(`insert into FeeCategories (
|
.prepare(`insert into FeeCategories (
|
||||||
|
|
@ -11,6 +10,6 @@ export default function addFeeCategory(feeCategoryForm, user) {
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(feeCategoryForm.feeCategory, (feeCategoryForm.isGroupedFee ?? '') === '1' ? 1 : 0, feeCategoryForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
.run(feeCategoryForm.feeCategory, (feeCategoryForm.isGroupedFee ?? '') === '1' ? 1 : 0, feeCategoryForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||||
database.close();
|
database.release();
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
import sqlite from 'better-sqlite3'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
|
||||||
|
|
||||||
export interface AddFeeCategoryForm {
|
export interface AddFeeCategoryForm {
|
||||||
feeCategory: string
|
feeCategory: string
|
||||||
|
|
@ -8,11 +6,11 @@ export interface AddFeeCategoryForm {
|
||||||
orderNumber?: number
|
orderNumber?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function addFeeCategory(
|
export default async function addFeeCategory(
|
||||||
feeCategoryForm: AddFeeCategoryForm,
|
feeCategoryForm: AddFeeCategoryForm,
|
||||||
user: User
|
user: User
|
||||||
): number {
|
): Promise<number> {
|
||||||
const database = sqlite(sunriseDB)
|
const database = await acquireConnection()
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
|
|
@ -35,7 +33,7 @@ export default function addFeeCategory(
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
)
|
)
|
||||||
|
|
||||||
database.close()
|
database.release()
|
||||||
|
|
||||||
return result.lastInsertRowid as number
|
return result.lastInsertRowid as number
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
export interface AddForm {
|
export interface AddForm {
|
||||||
funeralHomeKey: string;
|
|
||||||
funeralHomeName: string;
|
funeralHomeName: string;
|
||||||
|
funeralHomeKey: string;
|
||||||
funeralHomeAddress1: string;
|
funeralHomeAddress1: string;
|
||||||
funeralHomeAddress2: string;
|
funeralHomeAddress2: string;
|
||||||
funeralHomeCity: string;
|
funeralHomeCity: string;
|
||||||
funeralHomePostalCode: string;
|
|
||||||
funeralHomeProvince: string;
|
funeralHomeProvince: string;
|
||||||
|
funeralHomePostalCode: string;
|
||||||
funeralHomePhoneNumber: string;
|
funeralHomePhoneNumber: string;
|
||||||
}
|
}
|
||||||
export default function addFuneralHome(addForm: AddForm, user: User): number;
|
export default function addFuneralHome(addForm: AddForm, user: User): Promise<number>;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import sqlite from 'better-sqlite3';
|
import { acquireConnection } from './pool.js';
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
export default async function addFuneralHome(addForm, user) {
|
||||||
export default function addFuneralHome(addForm, user) {
|
const database = await acquireConnection();
|
||||||
const database = sqlite(sunriseDB);
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(`insert into FuneralHomes (
|
.prepare(`insert into FuneralHomes (
|
||||||
|
|
@ -11,6 +10,6 @@ export default function addFuneralHome(addForm, user) {
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(addForm.funeralHomeName, addForm.funeralHomeKey, addForm.funeralHomeAddress1, addForm.funeralHomeAddress2, addForm.funeralHomeCity, addForm.funeralHomeProvince, addForm.funeralHomePostalCode, addForm.funeralHomePhoneNumber, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
.run(addForm.funeralHomeName, addForm.funeralHomeKey, addForm.funeralHomeAddress1, addForm.funeralHomeAddress2, addForm.funeralHomeCity, addForm.funeralHomeProvince, addForm.funeralHomePostalCode, addForm.funeralHomePhoneNumber, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||||
database.close();
|
database.release();
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,21 @@
|
||||||
import sqlite from 'better-sqlite3'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
|
||||||
|
|
||||||
export interface AddForm {
|
export interface AddForm {
|
||||||
funeralHomeKey: string
|
|
||||||
funeralHomeName: string
|
funeralHomeName: string
|
||||||
|
funeralHomeKey: string
|
||||||
funeralHomeAddress1: string
|
funeralHomeAddress1: string
|
||||||
funeralHomeAddress2: string
|
funeralHomeAddress2: string
|
||||||
funeralHomeCity: string
|
funeralHomeCity: string
|
||||||
funeralHomePostalCode: string
|
|
||||||
funeralHomeProvince: string
|
funeralHomeProvince: string
|
||||||
|
funeralHomePostalCode: string
|
||||||
funeralHomePhoneNumber: string
|
funeralHomePhoneNumber: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function addFuneralHome(addForm: AddForm, user: User): number {
|
export default async function addFuneralHome(
|
||||||
const database = sqlite(sunriseDB)
|
addForm: AddForm,
|
||||||
|
user: User
|
||||||
|
): Promise<number> {
|
||||||
|
const database = await acquireConnection()
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
|
|
@ -44,7 +43,7 @@ export default function addFuneralHome(addForm: AddForm, user: User): number {
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
)
|
)
|
||||||
|
|
||||||
database.close()
|
database.release()
|
||||||
|
|
||||||
return result.lastInsertRowid as number
|
return result.lastInsertRowid as number
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
export interface AddIntermentContainerTypeForm {
|
export interface AddForm {
|
||||||
intermentContainerType: string;
|
intermentContainerType: string;
|
||||||
intermentContainerTypeKey?: string;
|
intermentContainerTypeKey?: string;
|
||||||
isCremationType?: '0' | '1';
|
isCremationType?: string;
|
||||||
orderNumber?: number | string;
|
orderNumber?: number;
|
||||||
}
|
}
|
||||||
export default function addIntermentContainerType(addForm: AddIntermentContainerTypeForm, user: User): number;
|
export default function addIntermentContainerType(addForm: AddForm, user: User): Promise<number>;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import sqlite from 'better-sqlite3';
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
|
||||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||||
export default function addIntermentContainerType(addForm, user) {
|
import { acquireConnection } from './pool.js';
|
||||||
const database = sqlite(sunriseDB);
|
export default async function addIntermentContainerType(addForm, user) {
|
||||||
|
const database = await acquireConnection();
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(`insert into IntermentContainerTypes (
|
.prepare(`insert into IntermentContainerTypes (
|
||||||
|
|
@ -10,8 +9,8 @@ export default function addIntermentContainerType(addForm, user) {
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(addForm.intermentContainerType, addForm.intermentContainerTypeKey ?? '', addForm.isCremationType ?? '0', addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
.run(addForm.intermentContainerType, addForm.intermentContainerTypeKey ?? '', addForm.isCremationType === undefined ? 0 : 1, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||||
database.close();
|
database.release();
|
||||||
clearCacheByTableName('IntermentContainerTypes');
|
clearCacheByTableName('IntermentContainerTypes');
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,19 @@
|
||||||
import sqlite from 'better-sqlite3'
|
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
|
||||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||||
|
|
||||||
export interface AddIntermentContainerTypeForm {
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
|
export interface AddForm {
|
||||||
intermentContainerType: string
|
intermentContainerType: string
|
||||||
intermentContainerTypeKey?: string
|
intermentContainerTypeKey?: string
|
||||||
isCremationType?: '0' | '1'
|
isCremationType?: string
|
||||||
orderNumber?: number | string
|
orderNumber?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function addIntermentContainerType(
|
export default async function addIntermentContainerType(
|
||||||
addForm: AddIntermentContainerTypeForm,
|
addForm: AddForm,
|
||||||
user: User
|
user: User
|
||||||
): number {
|
): Promise<number> {
|
||||||
const database = sqlite(sunriseDB)
|
const database = await acquireConnection()
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
|
|
@ -29,7 +28,7 @@ export default function addIntermentContainerType(
|
||||||
.run(
|
.run(
|
||||||
addForm.intermentContainerType,
|
addForm.intermentContainerType,
|
||||||
addForm.intermentContainerTypeKey ?? '',
|
addForm.intermentContainerTypeKey ?? '',
|
||||||
addForm.isCremationType ?? '0',
|
addForm.isCremationType === undefined ? 0 : 1,
|
||||||
addForm.orderNumber ?? -1,
|
addForm.orderNumber ?? -1,
|
||||||
user.userName,
|
user.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
|
|
@ -37,7 +36,7 @@ export default function addIntermentContainerType(
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
)
|
)
|
||||||
|
|
||||||
database.close()
|
database.release()
|
||||||
|
|
||||||
clearCacheByTableName('IntermentContainerTypes')
|
clearCacheByTableName('IntermentContainerTypes')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import sqlite from 'better-sqlite3';
|
import type { PoolConnection } from 'better-sqlite-pool';
|
||||||
export interface BurialSiteFieldForm {
|
export interface BurialSiteFieldForm {
|
||||||
burialSiteId: number | string;
|
burialSiteId: string | number;
|
||||||
burialSiteTypeFieldId: number | string;
|
burialSiteTypeFieldId: string | number;
|
||||||
fieldValue: string;
|
fieldValue: string;
|
||||||
}
|
}
|
||||||
export default function addOrUpdateBurialSiteField(fieldForm: BurialSiteFieldForm, user: User, connectedDatabase?: sqlite.Database): boolean;
|
export default function addOrUpdateBurialSiteField(fieldForm: BurialSiteFieldForm, user: User, connectedDatabase?: PoolConnection): Promise<boolean>;
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,16 @@
|
||||||
import sqlite from 'better-sqlite3';
|
import { acquireConnection } from './pool.js';
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
export default async function addOrUpdateBurialSiteField(fieldForm, user, connectedDatabase) {
|
||||||
export default function addOrUpdateBurialSiteField(fieldForm, user, connectedDatabase) {
|
const database = connectedDatabase ?? (await acquireConnection());
|
||||||
const database = connectedDatabase ?? sqlite(sunriseDB);
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
let result = database
|
let result = database
|
||||||
.prepare(`update BurialSiteFields
|
.prepare(`update BurialSiteFields
|
||||||
set fieldValue = ?,
|
set fieldValue = ?,
|
||||||
recordUpdate_userName = ?,
|
recordUpdate_userName = ?,
|
||||||
recordUpdate_timeMillis = ?,
|
recordUpdate_timeMillis = ?,
|
||||||
recordDelete_userName = null,
|
recordDelete_userName = null,
|
||||||
recordDelete_timeMillis = null
|
recordDelete_timeMillis = null
|
||||||
where burialSiteId = ?
|
where burialSiteId = ?
|
||||||
and burialSiteTypeFieldId = ?`)
|
and burialSiteTypeFieldId = ?`)
|
||||||
.run(fieldForm.fieldValue, user.userName, rightNowMillis, fieldForm.burialSiteId, fieldForm.burialSiteTypeFieldId);
|
.run(fieldForm.fieldValue, user.userName, rightNowMillis, fieldForm.burialSiteId, fieldForm.burialSiteTypeFieldId);
|
||||||
if (result.changes === 0) {
|
if (result.changes === 0) {
|
||||||
result = database
|
result = database
|
||||||
|
|
@ -23,7 +22,7 @@ export default function addOrUpdateBurialSiteField(fieldForm, user, connectedDat
|
||||||
.run(fieldForm.burialSiteId, fieldForm.burialSiteTypeFieldId, fieldForm.fieldValue, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
.run(fieldForm.burialSiteId, fieldForm.burialSiteTypeFieldId, fieldForm.fieldValue, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||||
}
|
}
|
||||||
if (connectedDatabase === undefined) {
|
if (connectedDatabase === undefined) {
|
||||||
database.close();
|
database.release();
|
||||||
}
|
}
|
||||||
return result.changes > 0;
|
return result.changes > 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
import sqlite from 'better-sqlite3'
|
import type { PoolConnection } from 'better-sqlite-pool'
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface BurialSiteFieldForm {
|
export interface BurialSiteFieldForm {
|
||||||
burialSiteId: number | string
|
burialSiteId: string | number
|
||||||
burialSiteTypeFieldId: number | string
|
burialSiteTypeFieldId: string | number
|
||||||
fieldValue: string
|
fieldValue: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function addOrUpdateBurialSiteField(
|
export default async function addOrUpdateBurialSiteField(
|
||||||
fieldForm: BurialSiteFieldForm,
|
fieldForm: BurialSiteFieldForm,
|
||||||
user: User,
|
user: User,
|
||||||
connectedDatabase?: sqlite.Database
|
connectedDatabase?: PoolConnection
|
||||||
): boolean {
|
): Promise<boolean> {
|
||||||
const database = connectedDatabase ?? sqlite(sunriseDB)
|
const database = connectedDatabase ?? (await acquireConnection())
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
|
|
@ -21,12 +21,12 @@ export default function addOrUpdateBurialSiteField(
|
||||||
.prepare(
|
.prepare(
|
||||||
`update BurialSiteFields
|
`update BurialSiteFields
|
||||||
set fieldValue = ?,
|
set fieldValue = ?,
|
||||||
recordUpdate_userName = ?,
|
recordUpdate_userName = ?,
|
||||||
recordUpdate_timeMillis = ?,
|
recordUpdate_timeMillis = ?,
|
||||||
recordDelete_userName = null,
|
recordDelete_userName = null,
|
||||||
recordDelete_timeMillis = null
|
recordDelete_timeMillis = null
|
||||||
where burialSiteId = ?
|
where burialSiteId = ?
|
||||||
and burialSiteTypeFieldId = ?`
|
and burialSiteTypeFieldId = ?`
|
||||||
)
|
)
|
||||||
.run(
|
.run(
|
||||||
fieldForm.fieldValue,
|
fieldForm.fieldValue,
|
||||||
|
|
@ -57,7 +57,7 @@ export default function addOrUpdateBurialSiteField(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connectedDatabase === undefined) {
|
if (connectedDatabase === undefined) {
|
||||||
database.close()
|
database.release()
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.changes > 0
|
return result.changes > 0
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import sqlite from 'better-sqlite3';
|
import type { PoolConnection } from 'better-sqlite-pool';
|
||||||
export interface ContractFieldForm {
|
export interface ContractFieldForm {
|
||||||
contractId: number | string;
|
contractId: string | number;
|
||||||
contractTypeFieldId: number | string;
|
contractTypeFieldId: string | number;
|
||||||
fieldValue: string;
|
fieldValue: string;
|
||||||
}
|
}
|
||||||
export default function addOrUpdateContractField(fieldForm: ContractFieldForm, user: User, connectedDatabase?: sqlite.Database): boolean;
|
export default function addOrUpdateContractField(fieldForm: ContractFieldForm, user: User, connectedDatabase?: PoolConnection): Promise<boolean>;
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,16 @@
|
||||||
import sqlite from 'better-sqlite3';
|
import { acquireConnection } from './pool.js';
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
export default async function addOrUpdateContractField(fieldForm, user, connectedDatabase) {
|
||||||
export default function addOrUpdateContractField(fieldForm, user, connectedDatabase) {
|
const database = connectedDatabase ?? (await acquireConnection());
|
||||||
const database = connectedDatabase ?? sqlite(sunriseDB);
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
let result = database
|
let result = database
|
||||||
.prepare(`update ContractFields
|
.prepare(`update ContractFields
|
||||||
set fieldValue = ?,
|
set fieldValue = ?,
|
||||||
recordUpdate_userName = ?,
|
recordUpdate_userName = ?,
|
||||||
recordUpdate_timeMillis = ?,
|
recordUpdate_timeMillis = ?,
|
||||||
recordDelete_userName = null,
|
recordDelete_userName = null,
|
||||||
recordDelete_timeMillis = null
|
recordDelete_timeMillis = null
|
||||||
where contractId = ?
|
where contractId = ?
|
||||||
and contractTypeFieldId = ?`)
|
and contractTypeFieldId = ?`)
|
||||||
.run(fieldForm.fieldValue, user.userName, rightNowMillis, fieldForm.contractId, fieldForm.contractTypeFieldId);
|
.run(fieldForm.fieldValue, user.userName, rightNowMillis, fieldForm.contractId, fieldForm.contractTypeFieldId);
|
||||||
if (result.changes === 0) {
|
if (result.changes === 0) {
|
||||||
result = database
|
result = database
|
||||||
|
|
@ -23,7 +22,7 @@ export default function addOrUpdateContractField(fieldForm, user, connectedDatab
|
||||||
.run(fieldForm.contractId, fieldForm.contractTypeFieldId, fieldForm.fieldValue, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
.run(fieldForm.contractId, fieldForm.contractTypeFieldId, fieldForm.fieldValue, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||||
}
|
}
|
||||||
if (connectedDatabase === undefined) {
|
if (connectedDatabase === undefined) {
|
||||||
database.close();
|
database.release();
|
||||||
}
|
}
|
||||||
return result.changes > 0;
|
return result.changes > 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
import sqlite from 'better-sqlite3'
|
import type { PoolConnection } from 'better-sqlite-pool'
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface ContractFieldForm {
|
export interface ContractFieldForm {
|
||||||
contractId: number | string
|
contractId: string | number
|
||||||
contractTypeFieldId: number | string
|
contractTypeFieldId: string | number
|
||||||
fieldValue: string
|
fieldValue: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function addOrUpdateContractField(
|
export default async function addOrUpdateContractField(
|
||||||
fieldForm: ContractFieldForm,
|
fieldForm: ContractFieldForm,
|
||||||
user: User,
|
user: User,
|
||||||
connectedDatabase?: sqlite.Database
|
connectedDatabase?: PoolConnection
|
||||||
): boolean {
|
): Promise<boolean> {
|
||||||
const database = connectedDatabase ?? sqlite(sunriseDB)
|
const database = connectedDatabase ?? (await acquireConnection())
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
|
|
@ -21,12 +21,12 @@ export default function addOrUpdateContractField(
|
||||||
.prepare(
|
.prepare(
|
||||||
`update ContractFields
|
`update ContractFields
|
||||||
set fieldValue = ?,
|
set fieldValue = ?,
|
||||||
recordUpdate_userName = ?,
|
recordUpdate_userName = ?,
|
||||||
recordUpdate_timeMillis = ?,
|
recordUpdate_timeMillis = ?,
|
||||||
recordDelete_userName = null,
|
recordDelete_userName = null,
|
||||||
recordDelete_timeMillis = null
|
recordDelete_timeMillis = null
|
||||||
where contractId = ?
|
where contractId = ?
|
||||||
and contractTypeFieldId = ?`
|
and contractTypeFieldId = ?`
|
||||||
)
|
)
|
||||||
.run(
|
.run(
|
||||||
fieldForm.fieldValue,
|
fieldForm.fieldValue,
|
||||||
|
|
@ -57,7 +57,7 @@ export default function addOrUpdateContractField(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connectedDatabase === undefined) {
|
if (connectedDatabase === undefined) {
|
||||||
database.close()
|
database.release()
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.changes > 0
|
return result.changes > 0
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
type RecordTable = 'BurialSiteStatuses' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes';
|
type RecordTable = 'BurialSiteStatuses' | 'BurialSiteTypes' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes';
|
||||||
export default function addRecord(recordTable: RecordTable, recordName: string, orderNumber: number | string, user: User): number;
|
export default function addRecord(recordTable: RecordTable, recordName: string, orderNumber: number | string, user: User): Promise<number>;
|
||||||
export {};
|
export {};
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import sqlite from 'better-sqlite3';
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
|
||||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||||
|
import { acquireConnection } from './pool.js';
|
||||||
const recordNameColumns = new Map([
|
const recordNameColumns = new Map([
|
||||||
['BurialSiteStatuses', 'burialSiteStatus'],
|
['BurialSiteStatuses', 'burialSiteStatus'],
|
||||||
|
['BurialSiteTypes', 'burialSiteType'],
|
||||||
['WorkOrderMilestoneTypes', 'workOrderMilestoneType'],
|
['WorkOrderMilestoneTypes', 'workOrderMilestoneType'],
|
||||||
['WorkOrderTypes', 'workOrderType']
|
['WorkOrderTypes', 'workOrderType']
|
||||||
]);
|
]);
|
||||||
export default function addRecord(recordTable, recordName, orderNumber, user) {
|
export default async function addRecord(recordTable, recordName, orderNumber, user) {
|
||||||
const database = sqlite(sunriseDB);
|
const database = await acquireConnection();
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(`insert into ${recordTable} (
|
.prepare(`insert into ${recordTable} (
|
||||||
|
|
@ -17,7 +17,7 @@ export default function addRecord(recordTable, recordName, orderNumber, user) {
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?)`)
|
||||||
.run(recordName, orderNumber === '' ? -1 : orderNumber, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
.run(recordName, orderNumber === '' ? -1 : orderNumber, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||||
database.close();
|
database.release();
|
||||||
clearCacheByTableName(recordTable);
|
clearCacheByTableName(recordTable);
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,27 @@
|
||||||
import sqlite from 'better-sqlite3'
|
|
||||||
|
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
|
||||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||||
|
|
||||||
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
type RecordTable =
|
type RecordTable =
|
||||||
| 'BurialSiteStatuses'
|
| 'BurialSiteStatuses'
|
||||||
|
| 'BurialSiteTypes'
|
||||||
| 'WorkOrderMilestoneTypes'
|
| 'WorkOrderMilestoneTypes'
|
||||||
| 'WorkOrderTypes'
|
| 'WorkOrderTypes'
|
||||||
|
|
||||||
const recordNameColumns = new Map<RecordTable, string>([
|
const recordNameColumns = new Map<RecordTable, string>([
|
||||||
['BurialSiteStatuses', 'burialSiteStatus'],
|
['BurialSiteStatuses', 'burialSiteStatus'],
|
||||||
|
['BurialSiteTypes', 'burialSiteType'],
|
||||||
['WorkOrderMilestoneTypes', 'workOrderMilestoneType'],
|
['WorkOrderMilestoneTypes', 'workOrderMilestoneType'],
|
||||||
['WorkOrderTypes', 'workOrderType']
|
['WorkOrderTypes', 'workOrderType']
|
||||||
])
|
])
|
||||||
|
|
||||||
export default function addRecord(
|
export default async function addRecord(
|
||||||
recordTable: RecordTable,
|
recordTable: RecordTable,
|
||||||
recordName: string,
|
recordName: string,
|
||||||
orderNumber: number | string,
|
orderNumber: number | string,
|
||||||
user: User
|
user: User
|
||||||
): number {
|
): Promise<number> {
|
||||||
const database = sqlite(sunriseDB)
|
const database = await acquireConnection()
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
|
|
@ -42,7 +43,7 @@ export default function addRecord(
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
)
|
)
|
||||||
|
|
||||||
database.close()
|
database.release()
|
||||||
|
|
||||||
clearCacheByTableName(recordTable)
|
clearCacheByTableName(recordTable)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
export interface AddWorkOrderForm {
|
export interface AddWorkOrderForm {
|
||||||
workOrderDescription: string;
|
|
||||||
workOrderNumber?: string;
|
|
||||||
workOrderTypeId: number | string;
|
workOrderTypeId: number | string;
|
||||||
workOrderCloseDateString?: string;
|
workOrderNumber?: string;
|
||||||
|
workOrderDescription: string;
|
||||||
workOrderOpenDateString?: string;
|
workOrderOpenDateString?: string;
|
||||||
|
workOrderCloseDateString?: string;
|
||||||
contractId?: string;
|
contractId?: string;
|
||||||
}
|
}
|
||||||
export default function addWorkOrder(workOrderForm: AddWorkOrderForm, user: User): number;
|
export default function addWorkOrder(workOrderForm: AddWorkOrderForm, user: User): Promise<number>;
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue