Compare commits
192 Commits
deepsource
...
main
| Author | SHA1 | Date |
|---|---|---|
|
|
118fc1959b | |
|
|
9830bede34 | |
|
|
302a9a4c48 | |
|
|
fe9188d1fb | |
|
|
4664366e12 | |
|
|
afcdca959b | |
|
|
434e15ba1d | |
|
|
39dc10369f | |
|
|
7371be711a | |
|
|
9048235ef2 | |
|
|
59b0fb7e5f | |
|
|
57b6dbf35e | |
|
|
c460d073e7 | |
|
|
a7ce5a99cb | |
|
|
db05999c72 | |
|
|
9c47b48abc | |
|
|
2ed7902320 | |
|
|
7887230c86 | |
|
|
18edc57f70 | |
|
|
656f1b052e | |
|
|
3c1d023ccd | |
|
|
2c506711fb | |
|
|
0dcdfaaa8a | |
|
|
ba0c9f3287 | |
|
|
ab61a3e340 | |
|
|
111663a274 | |
|
|
1c7bc96392 | |
|
|
b26e8b17b2 | |
|
|
c9b10f3696 | |
|
|
34c00b856b | |
|
|
0474631bf5 | |
|
|
927334d954 | |
|
|
50551582c1 | |
|
|
19a7c81766 | |
|
|
f96d975aa0 | |
|
|
3c4c85df19 | |
|
|
0d2f6f78ce | |
|
|
007b47a1f0 | |
|
|
62efb70542 | |
|
|
f440a35df7 | |
|
|
78cae2f964 | |
|
|
afa0286a2a | |
|
|
556a6a71b6 | |
|
|
96a41862bf | |
|
|
f35946d0a5 | |
|
|
d4670603b7 | |
|
|
09b3de1086 | |
|
|
c7640f6dfd | |
|
|
14bd8e0ea4 | |
|
|
b356d771ab | |
|
|
b359aaf564 | |
|
|
c330dff849 | |
|
|
a4522ec4d0 | |
|
|
3babad95c4 | |
|
|
5767b14f76 | |
|
|
eada41aaaa | |
|
|
e09d1ddb5d | |
|
|
f6eb3bf550 | |
|
|
dc9a9b2bcc | |
|
|
e7f79cbc4f | |
|
|
9bfed5aa4d | |
|
|
9a153bb238 | |
|
|
41761dcc8c | |
|
|
36e2b0f9cc | |
|
|
d4087caa74 | |
|
|
9c9b94199b | |
|
|
96eb7f36dc | |
|
|
4f6fc87e05 | |
|
|
38c1288856 | |
|
|
a167ef4a16 | |
|
|
3da2aad21b | |
|
|
dcbaad753b | |
|
|
d46a94db07 | |
|
|
bb3100c0b0 | |
|
|
3f28571dc2 | |
|
|
8f201e05b3 | |
|
|
d5915db9bd | |
|
|
8e22ee1026 | |
|
|
9e6da86d80 | |
|
|
31837d4370 | |
|
|
880a6fd23a | |
|
|
125f1e0949 | |
|
|
d4280a3796 | |
|
|
b3e5d8e5ad | |
|
|
df3f7725d3 | |
|
|
b8c9fd723d | |
|
|
3b98ac6f15 | |
|
|
6d964eb93a | |
|
|
688e55857d | |
|
|
59ab59bb1f | |
|
|
f7ae72d40a | |
|
|
43d70d8967 | |
|
|
cd47832247 | |
|
|
966a2fc869 | |
|
|
0b767d6b88 | |
|
|
5e2b90f2a2 | |
|
|
fb5c960bc7 | |
|
|
4a17f0ecfa | |
|
|
86cc71d235 | |
|
|
a4e4a11a59 | |
|
|
20702c598a | |
|
|
6cb36c4548 | |
|
|
2176158847 | |
|
|
ebc74816c2 | |
|
|
9f661f478f | |
|
|
f652f27c5e | |
|
|
3312f70967 | |
|
|
ab6ee7a9e2 | |
|
|
cc79209eb9 | |
|
|
9a69c2e6dd | |
|
|
1e59a368a4 | |
|
|
d41117a44a | |
|
|
190d17cabd | |
|
|
9501f30b23 | |
|
|
8efea8d739 | |
|
|
9bc85e6a8b | |
|
|
ed87174c19 | |
|
|
04a4e6473b | |
|
|
a5a1c9f793 | |
|
|
7f32d0a14a | |
|
|
70c796bb41 | |
|
|
a17257a9c8 | |
|
|
0c378970ae | |
|
|
495231afd6 | |
|
|
6125ef0030 | |
|
|
58d6cc76b5 | |
|
|
4bc7d0a844 | |
|
|
4d3ba54d50 | |
|
|
1f19359195 | |
|
|
01f44f0727 | |
|
|
1dd8024e35 | |
|
|
5a1d47dd17 | |
|
|
19178a025f | |
|
|
11a78a9bc5 | |
|
|
ed96a35c94 | |
|
|
54867f1cbc | |
|
|
452565943e | |
|
|
b2da12dac1 | |
|
|
4a1f6b42b0 | |
|
|
bd23675b04 | |
|
|
ebd9f01491 | |
|
|
09f87ed3da | |
|
|
b060cbcd78 | |
|
|
9bf4a2cfee | |
|
|
ee0e79b60a | |
|
|
ac4ae20f78 | |
|
|
922603a1f2 | |
|
|
66a697e097 | |
|
|
906f8c41e5 | |
|
|
91d94b6a49 | |
|
|
542e3ceabb | |
|
|
8fa012be75 | |
|
|
061c1fa43a | |
|
|
beb57e70ab | |
|
|
7ccc56d5e0 | |
|
|
5f4aa595f2 | |
|
|
4900895f5e | |
|
|
261f1ba354 | |
|
|
16db467481 | |
|
|
2d3b8042a0 | |
|
|
b48bc3b677 | |
|
|
461a790b70 | |
|
|
92056cf6b7 | |
|
|
df44ab95f7 | |
|
|
4af21f4261 | |
|
|
669d942c0d | |
|
|
27097dc1ca | |
|
|
b16f96c74b | |
|
|
fa3e40253f | |
|
|
80fa36853d | |
|
|
d7f4cb4d3b | |
|
|
2b481c32df | |
|
|
a71c11c5e4 | |
|
|
3644bc6170 | |
|
|
f36302d492 | |
|
|
17595d6f2f | |
|
|
18b1ffa0cc | |
|
|
0dbbd3f750 | |
|
|
28fe138fb5 | |
|
|
b30c02d9c4 | |
|
|
856abc9fcf | |
|
|
478fe4518b | |
|
|
22ba4f367d | |
|
|
cf52a3daea | |
|
|
9bc27dafe8 | |
|
|
0aa050dbae | |
|
|
dce2f75a52 | |
|
|
022de4c764 | |
|
|
c16b8f0294 | |
|
|
d4aa83fd7a | |
|
|
545941e69e | |
|
|
cbdda9e602 |
|
|
@ -10,7 +10,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node: [ 18, 20, 21 ]
|
||||
node: [ 20, 22, 23 ]
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
||||
|
|
@ -25,11 +25,12 @@ jobs:
|
|||
|
||||
- name: Install Application
|
||||
run: |
|
||||
npm uninstall puppeteer
|
||||
npm ci
|
||||
npm install -g mocha c8 cypress@13
|
||||
npm install -g mocha c8 cypress@14
|
||||
|
||||
- name: Copy Test Config
|
||||
run: cp ./data/config.testing.js ./data/config.js
|
||||
run: cp ./data/testing.config.js ./data/config.js
|
||||
|
||||
- name: Test Application Startup
|
||||
run: npm run test:startup
|
||||
|
|
@ -43,14 +44,14 @@ jobs:
|
|||
run: c8 --reporter=lcov --reporter=text --reporter=text-summary mocha --timeout 10000 --exit
|
||||
|
||||
- name: Codecov
|
||||
if: ${{ github.event_name != 'pull_request' && env.CODECOV_TOKEN != '' && matrix.node == 20 }}
|
||||
if: ${{ github.event_name != 'pull_request' && env.CODECOV_TOKEN != '' && matrix.node == 22 }}
|
||||
run: |
|
||||
curl -Os https://uploader.codecov.io/latest/linux/codecov
|
||||
chmod +x codecov
|
||||
./codecov -t ${CODECOV_TOKEN}
|
||||
|
||||
- name: DeepSource
|
||||
if: ${{ github.event_name != 'pull_request' && env.DEEPSOURCE_DSN != '' && matrix.node == 20 }}
|
||||
if: ${{ github.event_name != 'pull_request' && env.DEEPSOURCE_DSN != '' && matrix.node == 22 }}
|
||||
run: |
|
||||
# Install deepsource CLI
|
||||
curl https://deepsource.io/cli | sh
|
||||
|
|
|
|||
|
|
@ -1,8 +1,3 @@
|
|||
{
|
||||
"reject": [
|
||||
"@cityssm/bulma-sticky-table",
|
||||
"@fortawesome/fontawesome-free",
|
||||
"bulma",
|
||||
"bulma-calendar"
|
||||
]
|
||||
"reject": ["puppeteer"]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Thank you for your interest in making the Lot Occupancy System better
|
||||
# Thank you for your interest in making Sunrise CMS better
|
||||
|
||||
Together, we can build high quality software that meets the needs of municipalities,
|
||||
while remaining open and budget conscious.
|
||||
|
|
|
|||
67
README.md
67
README.md
|
|
@ -1,27 +1,70 @@
|
|||
<div align=center>
|
||||
|
||||
# Sunrise Cemetery Management System (CMS)
|
||||
|
||||

|
||||
[](https://app.deepsource.com/gh/cityssm/sunrise-cms/)
|
||||
[](https://codecov.io/gh/cityssm/sunrise-cms)
|
||||
[](https://cloud.cypress.io/projects/26a4bi/runs)
|
||||
[](https://github.com/cityssm/sunrise-cms/actions/workflows/coverage.yml)
|
||||
|
||||

|
||||
|
||||
🚧 **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.**
|
||||
|
||||
</div>
|
||||

|
||||
|
||||
This is a major refactoring of the
|
||||
This is a major refactoring of the now archived
|
||||
[Lot Occupancy System](https://github.com/cityssm/lot-occupancy-system),
|
||||
originally built with multiple focuses. This fork reworks the project to focus exculsively
|
||||
on cemetery management.
|
||||
originally built with multiple focuses in mind. This fork completely reworks the project
|
||||
to focus exculsively on cemetery management.
|
||||
|
||||
[**User Documentation (In the Works)**](./docs/README.md)
|
||||
|
||||
## Why Sunrise CMS?
|
||||
|
||||
### ✔️ Cemetery Maps are NOT Required
|
||||
|
||||
Many cemetery applications rely on maps to drill down into burial sites.
|
||||
In Sunrise CMS, maps are completely optional, greatly reducing the effort needed to get started,
|
||||
and reducing the maintenance work when new blocks of burial sites are introduced.
|
||||
|
||||
### ✔️ The System Requirements are Very Low
|
||||
|
||||
Sunrise CMS does not need an expensive server to run.
|
||||
No separate database server is required either.
|
||||
The whole application could run on a current, modest workstation.
|
||||
|
||||
### ✔️ Track Unlimited Cemeteries, 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
|
||||
|
||||
There's no cost to use it.
|
||||
|
||||
## About this Project
|
||||
|
||||
- [Code of Conduct](CODE_OF_CONDUCT.md)
|
||||
- [Contributing Guidelines](CONTRIBUTING.md)
|
||||
- [Security Policy](SECURITY.md)
|
||||
- [MIT Licence](LICENSE.md)
|
||||
- 📘 [Documentation](./docs/README.md)
|
||||
- 🤗 [Code of Conduct](CODE_OF_CONDUCT.md)
|
||||
- 🥰 [Contributing Guidelines](CONTRIBUTING.md)
|
||||
- 🛡️ [Security Policy](SECURITY.md)
|
||||
- 📃 [MIT Licence](LICENSE.md)
|
||||
|
||||
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.
|
||||
|
||||
## 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
|
||||
title: Sunrise Cemetery Management System
|
||||
title: Sunrise Cemetery Management System (CMS)
|
||||
88
app.js
88
app.js
|
|
@ -1,5 +1,6 @@
|
|||
import path from 'node:path';
|
||||
import * as dateTimeFns from '@cityssm/utils-datetime';
|
||||
import { secondsToMillis } from '@cityssm/to-millis';
|
||||
import * as dateTimeFunctions from '@cityssm/utils-datetime';
|
||||
import compression from 'compression';
|
||||
import cookieParser from 'cookie-parser';
|
||||
import csurf from 'csurf';
|
||||
|
|
@ -9,12 +10,12 @@ import rateLimit from 'express-rate-limit';
|
|||
import session from 'express-session';
|
||||
import createError from 'http-errors';
|
||||
import FileStore from 'session-file-store';
|
||||
import { initializeDatabase } from './database/initializeDatabase.js';
|
||||
import dataLists from './data/dataLists.js';
|
||||
import { DEBUG_NAMESPACE } from './debug.config.js';
|
||||
import * as permissionHandlers from './handlers/permissions.js';
|
||||
import { getSafeRedirectURL } from './helpers/authentication.helpers.js';
|
||||
import * as configFunctions from './helpers/config.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 routerAdmin from './routes/admin.js';
|
||||
import routerApi from './routes/api.js';
|
||||
|
|
@ -28,11 +29,7 @@ import routerPrint from './routes/print.js';
|
|||
import routerReports from './routes/reports.js';
|
||||
import routerWorkOrders from './routes/workOrders.js';
|
||||
import { version } from './version.js';
|
||||
const debug = Debug(`${DEBUG_NAMESPACE}:app:${process.pid}`);
|
||||
/*
|
||||
* INITIALIZE THE DATABASE
|
||||
*/
|
||||
await initializeDatabase();
|
||||
const debug = Debug(`${DEBUG_NAMESPACE}:app:${process.pid.toString().padEnd(5)}`);
|
||||
/*
|
||||
* INITIALIZE APP
|
||||
*/
|
||||
|
|
@ -57,29 +54,18 @@ app.use(express.urlencoded({
|
|||
extended: false
|
||||
}));
|
||||
app.use(cookieParser());
|
||||
app.use(csurf({
|
||||
app.use(
|
||||
// eslint-disable-next-line sonarjs/insecure-cookie, sonarjs/cookie-no-httponly
|
||||
csurf({
|
||||
cookie: true
|
||||
}));
|
||||
/*
|
||||
* Rate Limiter
|
||||
*/
|
||||
app.use(rateLimit({
|
||||
windowMs: 10_000,
|
||||
max: useTestDatabases ? 1_000_000 : 200
|
||||
max: useTestDatabases ? 1_000_000 : 200,
|
||||
windowMs: secondsToMillis(10)
|
||||
}));
|
||||
/*
|
||||
* STATIC ROUTES
|
||||
*/
|
||||
const urlPrefix = configFunctions.getConfigProperty('reverseProxy.urlPrefix');
|
||||
if (urlPrefix !== '') {
|
||||
debug(`urlPrefix = ${urlPrefix}`);
|
||||
}
|
||||
app.use(urlPrefix, express.static(path.join('public')));
|
||||
app.use(`${urlPrefix}/lib/cityssm-bulma-js/bulma-js.js`, express.static(path.join('node_modules', '@cityssm', 'bulma-js', 'dist', 'bulma-js.js')));
|
||||
app.use(`${urlPrefix}/lib/cityssm-bulma-webapp-js`, express.static(path.join('node_modules', '@cityssm', 'bulma-webapp-js', 'dist')));
|
||||
app.use(`${urlPrefix}/lib/fa`, express.static(path.join('node_modules', '@fortawesome', 'fontawesome-free')));
|
||||
app.use(`${urlPrefix}/lib/leaflet`, express.static(path.join('node_modules', 'leaflet', 'dist')));
|
||||
app.use(`${urlPrefix}/lib/randomcolor/randomColor.js`, express.static(path.join('node_modules', 'randomcolor', 'randomColor.js')));
|
||||
/*
|
||||
* SESSION MANAGEMENT
|
||||
*/
|
||||
|
|
@ -87,20 +73,20 @@ const sessionCookieName = configFunctions.getConfigProperty('session.cookieName'
|
|||
const FileStoreSession = FileStore(session);
|
||||
// Initialize session
|
||||
app.use(session({
|
||||
store: new FileStoreSession({
|
||||
path: './data/sessions',
|
||||
logFn: Debug(`${DEBUG_NAMESPACE}:session:${process.pid}`),
|
||||
retries: 20
|
||||
}),
|
||||
name: sessionCookieName,
|
||||
secret: configFunctions.getConfigProperty('session.secret'),
|
||||
resave: true,
|
||||
saveUninitialized: false,
|
||||
rolling: true,
|
||||
cookie: {
|
||||
maxAge: configFunctions.getConfigProperty('session.maxAgeMillis'),
|
||||
sameSite: 'strict'
|
||||
}
|
||||
},
|
||||
secret: configFunctions.getConfigProperty('session.secret'),
|
||||
store: new FileStoreSession({
|
||||
logFn: Debug(`${DEBUG_NAMESPACE}:session:${process.pid.toString().padEnd(5)}`),
|
||||
path: './data/sessions',
|
||||
retries: 20
|
||||
}),
|
||||
resave: true,
|
||||
rolling: true,
|
||||
saveUninitialized: false
|
||||
}));
|
||||
// Clear cookie if no corresponding session
|
||||
app.use((request, response, next) => {
|
||||
|
|
@ -110,6 +96,34 @@ app.use((request, response, next) => {
|
|||
}
|
||||
next();
|
||||
});
|
||||
/*
|
||||
* STATIC ROUTES
|
||||
*/
|
||||
const urlPrefix = configFunctions.getConfigProperty('reverseProxy.urlPrefix');
|
||||
if (urlPrefix !== '') {
|
||||
debug(`urlPrefix = ${urlPrefix}`);
|
||||
}
|
||||
app.use(`${urlPrefix}/internal`, (request, response, next) => {
|
||||
if (Object.hasOwn(request.session, 'user') &&
|
||||
Object.hasOwn(request.cookies, sessionCookieName)) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
response.sendStatus(403);
|
||||
}, express.static(configFunctions.getConfigProperty('settings.publicInternalPath')));
|
||||
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-tooltip`, express.static(path.join('node_modules', 'bulma-tooltip', 'dist', 'css')));
|
||||
app.use(`${urlPrefix}/lib/cityssm-bulma-js/bulma-js.js`, express.static(path.join('node_modules', '@cityssm', 'bulma-js', 'dist', 'bulma-js.js')));
|
||||
app.use(`${urlPrefix}/lib/cityssm-fa-glow`, express.static(path.join('node_modules', '@cityssm', 'fa-glow')));
|
||||
app.use(`${urlPrefix}/lib/cityssm-bulma-sticky-table`, express.static(path.join('node_modules', '@cityssm', 'bulma-sticky-table')));
|
||||
app.use(`${urlPrefix}/lib/cityssm-bulma-webapp-js`, express.static(path.join('node_modules', '@cityssm', 'bulma-webapp-js', 'dist')));
|
||||
app.use(`${urlPrefix}/lib/fa`, express.static(path.join('node_modules', '@fortawesome', 'fontawesome-free')));
|
||||
app.use(`${urlPrefix}/lib/leaflet`, express.static(path.join('node_modules', 'leaflet', 'dist')));
|
||||
app.use(`${urlPrefix}/lib/randomcolor/randomColor.js`, express.static(path.join('node_modules', 'randomcolor', 'randomColor.js')));
|
||||
/*
|
||||
* ROUTES
|
||||
*/
|
||||
// Redirect logged in users
|
||||
const sessionChecker = (request, response, next) => {
|
||||
if (Object.hasOwn(request.session, 'user') &&
|
||||
|
|
@ -120,9 +134,6 @@ const sessionChecker = (request, response, next) => {
|
|||
const redirectUrl = getSafeRedirectURL(request.originalUrl);
|
||||
response.redirect(`${urlPrefix}/login?redirect=${encodeURIComponent(redirectUrl)}`);
|
||||
};
|
||||
/*
|
||||
* ROUTES
|
||||
*/
|
||||
// Make the user and config objects available to the templates
|
||||
app.use((request, response, next) => {
|
||||
response.locals.buildNumber = version;
|
||||
|
|
@ -130,7 +141,8 @@ app.use((request, response, next) => {
|
|||
response.locals.csrfToken = request.csrfToken();
|
||||
response.locals.configFunctions = configFunctions;
|
||||
response.locals.printFunctions = printFunctions;
|
||||
response.locals.dateTimeFunctions = dateTimeFns;
|
||||
response.locals.dateTimeFunctions = dateTimeFunctions;
|
||||
response.locals.dataLists = dataLists;
|
||||
response.locals.urlPrefix = configFunctions.getConfigProperty('reverseProxy.urlPrefix');
|
||||
next();
|
||||
});
|
||||
|
|
|
|||
146
app.ts
146
app.ts
|
|
@ -1,6 +1,7 @@
|
|||
import path from 'node:path'
|
||||
|
||||
import * as dateTimeFns from '@cityssm/utils-datetime'
|
||||
import { secondsToMillis } from '@cityssm/to-millis'
|
||||
import * as dateTimeFunctions from '@cityssm/utils-datetime'
|
||||
import compression from 'compression'
|
||||
import cookieParser from 'cookie-parser'
|
||||
import csurf from 'csurf'
|
||||
|
|
@ -11,12 +12,12 @@ import session from 'express-session'
|
|||
import createError from 'http-errors'
|
||||
import FileStore from 'session-file-store'
|
||||
|
||||
import { initializeDatabase } from './database/initializeDatabase.js'
|
||||
import dataLists from './data/dataLists.js'
|
||||
import { DEBUG_NAMESPACE } from './debug.config.js'
|
||||
import * as permissionHandlers from './handlers/permissions.js'
|
||||
import { getSafeRedirectURL } from './helpers/authentication.helpers.js'
|
||||
import * as configFunctions from './helpers/config.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 routerAdmin from './routes/admin.js'
|
||||
import routerApi from './routes/api.js'
|
||||
|
|
@ -31,13 +32,7 @@ import routerReports from './routes/reports.js'
|
|||
import routerWorkOrders from './routes/workOrders.js'
|
||||
import { version } from './version.js'
|
||||
|
||||
const debug = Debug(`${DEBUG_NAMESPACE}:app:${process.pid}`)
|
||||
|
||||
/*
|
||||
* INITIALIZE THE DATABASE
|
||||
*/
|
||||
|
||||
await initializeDatabase()
|
||||
const debug = Debug(`${DEBUG_NAMESPACE}:app:${process.pid.toString().padEnd(5)}`)
|
||||
|
||||
/*
|
||||
* INITIALIZE APP
|
||||
|
|
@ -76,6 +71,7 @@ app.use(
|
|||
|
||||
app.use(cookieParser())
|
||||
app.use(
|
||||
// eslint-disable-next-line sonarjs/insecure-cookie, sonarjs/cookie-no-httponly
|
||||
csurf({
|
||||
cookie: true
|
||||
})
|
||||
|
|
@ -87,11 +83,54 @@ app.use(
|
|||
|
||||
app.use(
|
||||
rateLimit({
|
||||
windowMs: 10_000,
|
||||
max: useTestDatabases ? 1_000_000 : 200
|
||||
max: useTestDatabases ? 1_000_000 : 200,
|
||||
windowMs: secondsToMillis(10)
|
||||
})
|
||||
)
|
||||
|
||||
/*
|
||||
* SESSION MANAGEMENT
|
||||
*/
|
||||
|
||||
const sessionCookieName: string =
|
||||
configFunctions.getConfigProperty('session.cookieName')
|
||||
|
||||
const FileStoreSession = FileStore(session)
|
||||
|
||||
// Initialize session
|
||||
app.use(
|
||||
session({
|
||||
name: sessionCookieName,
|
||||
|
||||
cookie: {
|
||||
maxAge: configFunctions.getConfigProperty('session.maxAgeMillis'),
|
||||
sameSite: 'strict'
|
||||
},
|
||||
secret: configFunctions.getConfigProperty('session.secret'),
|
||||
store: new FileStoreSession({
|
||||
logFn: Debug(`${DEBUG_NAMESPACE}:session:${process.pid.toString().padEnd(5)}`),
|
||||
path: './data/sessions',
|
||||
retries: 20
|
||||
}),
|
||||
|
||||
resave: true,
|
||||
rolling: true,
|
||||
saveUninitialized: false
|
||||
})
|
||||
)
|
||||
|
||||
// Clear cookie if no corresponding session
|
||||
app.use((request, response, next) => {
|
||||
if (
|
||||
Object.hasOwn(request.cookies, sessionCookieName) &&
|
||||
!Object.hasOwn(request.session, 'user')
|
||||
) {
|
||||
response.clearCookie(sessionCookieName)
|
||||
}
|
||||
|
||||
next()
|
||||
})
|
||||
|
||||
/*
|
||||
* STATIC ROUTES
|
||||
*/
|
||||
|
|
@ -102,8 +141,34 @@ if (urlPrefix !== '') {
|
|||
debug(`urlPrefix = ${urlPrefix}`)
|
||||
}
|
||||
|
||||
app.use(
|
||||
`${urlPrefix}/internal`,
|
||||
(request, response, next) => {
|
||||
if (
|
||||
Object.hasOwn(request.session, 'user') &&
|
||||
Object.hasOwn(request.cookies, sessionCookieName)
|
||||
) {
|
||||
next()
|
||||
return
|
||||
}
|
||||
|
||||
response.sendStatus(403)
|
||||
},
|
||||
express.static(configFunctions.getConfigProperty('settings.publicInternalPath'))
|
||||
)
|
||||
|
||||
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-tooltip`,
|
||||
express.static(path.join('node_modules', 'bulma-tooltip', 'dist', 'css'))
|
||||
)
|
||||
|
||||
app.use(
|
||||
`${urlPrefix}/lib/cityssm-bulma-js/bulma-js.js`,
|
||||
express.static(
|
||||
|
|
@ -111,6 +176,16 @@ app.use(
|
|||
)
|
||||
)
|
||||
|
||||
app.use(
|
||||
`${urlPrefix}/lib/cityssm-fa-glow`,
|
||||
express.static(path.join('node_modules', '@cityssm', 'fa-glow'))
|
||||
)
|
||||
|
||||
app.use(
|
||||
`${urlPrefix}/lib/cityssm-bulma-sticky-table`,
|
||||
express.static(path.join('node_modules', '@cityssm', 'bulma-sticky-table'))
|
||||
)
|
||||
|
||||
app.use(
|
||||
`${urlPrefix}/lib/cityssm-bulma-webapp-js`,
|
||||
express.static(
|
||||
|
|
@ -134,46 +209,9 @@ app.use(
|
|||
)
|
||||
|
||||
/*
|
||||
* SESSION MANAGEMENT
|
||||
* ROUTES
|
||||
*/
|
||||
|
||||
const sessionCookieName: string =
|
||||
configFunctions.getConfigProperty('session.cookieName')
|
||||
|
||||
const FileStoreSession = FileStore(session)
|
||||
|
||||
// Initialize session
|
||||
app.use(
|
||||
session({
|
||||
store: new FileStoreSession({
|
||||
path: './data/sessions',
|
||||
logFn: Debug(`${DEBUG_NAMESPACE}:session:${process.pid}`),
|
||||
retries: 20
|
||||
}),
|
||||
name: sessionCookieName,
|
||||
secret: configFunctions.getConfigProperty('session.secret'),
|
||||
resave: true,
|
||||
saveUninitialized: false,
|
||||
rolling: true,
|
||||
cookie: {
|
||||
maxAge: configFunctions.getConfigProperty('session.maxAgeMillis'),
|
||||
sameSite: 'strict'
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
// Clear cookie if no corresponding session
|
||||
app.use((request, response, next) => {
|
||||
if (
|
||||
Object.hasOwn(request.cookies, sessionCookieName) &&
|
||||
!Object.hasOwn(request.session, 'user')
|
||||
) {
|
||||
response.clearCookie(sessionCookieName)
|
||||
}
|
||||
|
||||
next()
|
||||
})
|
||||
|
||||
// Redirect logged in users
|
||||
const sessionChecker = (
|
||||
request: express.Request,
|
||||
|
|
@ -195,10 +233,6 @@ const sessionChecker = (
|
|||
)
|
||||
}
|
||||
|
||||
/*
|
||||
* ROUTES
|
||||
*/
|
||||
|
||||
// Make the user and config objects available to the templates
|
||||
|
||||
app.use((request, response, next) => {
|
||||
|
|
@ -209,7 +243,9 @@ app.use((request, response, next) => {
|
|||
|
||||
response.locals.configFunctions = configFunctions
|
||||
response.locals.printFunctions = printFunctions
|
||||
response.locals.dateTimeFunctions = dateTimeFns
|
||||
response.locals.dateTimeFunctions = dateTimeFunctions
|
||||
|
||||
response.locals.dataLists = dataLists
|
||||
|
||||
response.locals.urlPrefix = configFunctions.getConfigProperty(
|
||||
'reverseProxy.urlPrefix'
|
||||
|
|
|
|||
40
bin/www.js
40
bin/www.js
|
|
@ -6,19 +6,26 @@ import ntfyPublish from '@cityssm/ntfy-publish';
|
|||
import { secondsToMillis } from '@cityssm/to-millis';
|
||||
import Debug from 'debug';
|
||||
import exitHook from 'exit-hook';
|
||||
import { initializeDatabase } from '../database/initializeDatabase.js';
|
||||
import { DEBUG_NAMESPACE } from '../debug.config.js';
|
||||
import { getConfigProperty } from '../helpers/config.helpers.js';
|
||||
import version from '../version.js';
|
||||
const debug = Debug(`${DEBUG_NAMESPACE}:www:${process.pid}`);
|
||||
// INITIALIZE THE DATABASE
|
||||
initializeDatabase();
|
||||
const directoryName = path.dirname(fileURLToPath(import.meta.url));
|
||||
const processCount = Math.min(getConfigProperty('application.maximumProcesses'), os.cpus().length);
|
||||
process.title = `${getConfigProperty('application.applicationName')} (Primary)`;
|
||||
const processCount = Math.min(getConfigProperty('application.maximumProcesses'), os.cpus().length * 2);
|
||||
const applicationName = getConfigProperty('application.applicationName');
|
||||
process.title = `${applicationName} (Primary)`;
|
||||
debug(`Primary pid: ${process.pid}`);
|
||||
debug(`Primary title: ${process.title}`);
|
||||
debug(`Version: ${version}`);
|
||||
debug(`Launching ${processCount} processes`);
|
||||
const clusterSettings = {
|
||||
exec: `${directoryName}/wwwProcess.js`
|
||||
};
|
||||
cluster.setupPrimary(clusterSettings);
|
||||
let doShutdown = false;
|
||||
const activeWorkers = new Map();
|
||||
for (let index = 0; index < processCount; index += 1) {
|
||||
const worker = cluster.fork();
|
||||
|
|
@ -26,6 +33,7 @@ for (let index = 0; index < processCount; index += 1) {
|
|||
}
|
||||
cluster.on('message', (worker, message) => {
|
||||
for (const [pid, activeWorker] of activeWorkers.entries()) {
|
||||
// eslint-disable-next-line sonarjs/different-types-comparison, @typescript-eslint/no-unnecessary-condition
|
||||
if (activeWorker === undefined || pid === message.pid) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -36,24 +44,27 @@ cluster.on('message', (worker, message) => {
|
|||
cluster.on('exit', (worker) => {
|
||||
debug(`Worker ${(worker.process.pid ?? 0).toString()} has been killed`);
|
||||
activeWorkers.delete(worker.process.pid ?? 0);
|
||||
debug('Starting another worker');
|
||||
cluster.fork();
|
||||
if (!doShutdown) {
|
||||
debug('Starting another worker');
|
||||
const newWorker = cluster.fork();
|
||||
activeWorkers.set(newWorker.process.pid ?? 0, newWorker);
|
||||
}
|
||||
});
|
||||
const ntfyStartupConfig = getConfigProperty('application.ntfyStartup');
|
||||
if (ntfyStartupConfig !== undefined) {
|
||||
const topic = ntfyStartupConfig.topic;
|
||||
const server = ntfyStartupConfig.server;
|
||||
const ntfyStartupMessage = {
|
||||
topic,
|
||||
title: getConfigProperty('application.applicationName'),
|
||||
message: 'Application Started',
|
||||
tags: ['arrow_up']
|
||||
tags: ['arrow_up'],
|
||||
title: applicationName,
|
||||
topic
|
||||
};
|
||||
const ntfyShutdownMessage = {
|
||||
topic,
|
||||
title: getConfigProperty('application.applicationName'),
|
||||
message: 'Application Shut Down',
|
||||
tags: ['arrow_down']
|
||||
tags: ['arrow_down'],
|
||||
title: applicationName,
|
||||
topic
|
||||
};
|
||||
if (server !== undefined) {
|
||||
ntfyStartupMessage.server = server;
|
||||
|
|
@ -70,7 +81,16 @@ if (process.env.STARTUP_TEST === 'true') {
|
|||
debug(`Killing processes in ${killSeconds} seconds...`);
|
||||
setTimeout(() => {
|
||||
debug('Killing processes');
|
||||
doShutdown = true;
|
||||
// eslint-disable-next-line unicorn/no-process-exit
|
||||
process.exit(0);
|
||||
}, secondsToMillis(killSeconds));
|
||||
}
|
||||
exitHook(() => {
|
||||
doShutdown = true;
|
||||
debug('Shutting down...');
|
||||
for (const worker of activeWorkers.values()) {
|
||||
debug(`Killing worker ${worker.process.pid}`);
|
||||
worker.kill();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
48
bin/www.ts
48
bin/www.ts
|
|
@ -8,23 +8,31 @@ import { secondsToMillis } from '@cityssm/to-millis'
|
|||
import Debug from 'debug'
|
||||
import exitHook from 'exit-hook'
|
||||
|
||||
import { initializeDatabase } from '../database/initializeDatabase.js'
|
||||
import { DEBUG_NAMESPACE } from '../debug.config.js'
|
||||
import { getConfigProperty } from '../helpers/config.helpers.js'
|
||||
import type { WorkerMessage } from '../types/applicationTypes.js'
|
||||
import type { WorkerMessage } from '../types/application.types.js'
|
||||
import version from '../version.js'
|
||||
|
||||
const debug = Debug(`${DEBUG_NAMESPACE}:www:${process.pid}`)
|
||||
|
||||
// INITIALIZE THE DATABASE
|
||||
initializeDatabase()
|
||||
|
||||
const directoryName = path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
const processCount = Math.min(
|
||||
getConfigProperty('application.maximumProcesses'),
|
||||
os.cpus().length
|
||||
os.cpus().length * 2
|
||||
)
|
||||
|
||||
process.title = `${getConfigProperty('application.applicationName')} (Primary)`
|
||||
const applicationName = getConfigProperty('application.applicationName')
|
||||
|
||||
process.title = `${applicationName} (Primary)`
|
||||
|
||||
debug(`Primary pid: ${process.pid}`)
|
||||
debug(`Primary title: ${process.title}`)
|
||||
debug(`Version: ${version}`)
|
||||
debug(`Launching ${processCount} processes`)
|
||||
|
||||
const clusterSettings = {
|
||||
|
|
@ -33,6 +41,7 @@ const clusterSettings = {
|
|||
|
||||
cluster.setupPrimary(clusterSettings)
|
||||
|
||||
let doShutdown = false
|
||||
const activeWorkers = new Map<number, Worker>()
|
||||
|
||||
for (let index = 0; index < processCount; index += 1) {
|
||||
|
|
@ -42,6 +51,7 @@ for (let index = 0; index < processCount; index += 1) {
|
|||
|
||||
cluster.on('message', (worker, message: WorkerMessage) => {
|
||||
for (const [pid, activeWorker] of activeWorkers.entries()) {
|
||||
// eslint-disable-next-line sonarjs/different-types-comparison, @typescript-eslint/no-unnecessary-condition
|
||||
if (activeWorker === undefined || pid === message.pid) {
|
||||
continue
|
||||
}
|
||||
|
|
@ -55,8 +65,12 @@ cluster.on('exit', (worker) => {
|
|||
debug(`Worker ${(worker.process.pid ?? 0).toString()} has been killed`)
|
||||
activeWorkers.delete(worker.process.pid ?? 0)
|
||||
|
||||
debug('Starting another worker')
|
||||
cluster.fork()
|
||||
if (!doShutdown) {
|
||||
debug('Starting another worker')
|
||||
const newWorker = cluster.fork()
|
||||
|
||||
activeWorkers.set(newWorker.process.pid ?? 0, newWorker)
|
||||
}
|
||||
})
|
||||
|
||||
const ntfyStartupConfig = getConfigProperty('application.ntfyStartup')
|
||||
|
|
@ -66,17 +80,17 @@ if (ntfyStartupConfig !== undefined) {
|
|||
const server = ntfyStartupConfig.server
|
||||
|
||||
const ntfyStartupMessage: NtfyMessageOptions = {
|
||||
topic,
|
||||
title: getConfigProperty('application.applicationName'),
|
||||
message: 'Application Started',
|
||||
tags: ['arrow_up']
|
||||
tags: ['arrow_up'],
|
||||
title: applicationName,
|
||||
topic
|
||||
}
|
||||
|
||||
const ntfyShutdownMessage: NtfyMessageOptions = {
|
||||
topic,
|
||||
title: getConfigProperty('application.applicationName'),
|
||||
message: 'Application Shut Down',
|
||||
tags: ['arrow_down']
|
||||
tags: ['arrow_down'],
|
||||
title: applicationName,
|
||||
topic
|
||||
}
|
||||
|
||||
if (server !== undefined) {
|
||||
|
|
@ -100,7 +114,19 @@ if (process.env.STARTUP_TEST === 'true') {
|
|||
setTimeout(() => {
|
||||
debug('Killing processes')
|
||||
|
||||
doShutdown = true
|
||||
|
||||
// eslint-disable-next-line unicorn/no-process-exit
|
||||
process.exit(0)
|
||||
}, secondsToMillis(killSeconds))
|
||||
}
|
||||
|
||||
exitHook(() => {
|
||||
doShutdown = true
|
||||
debug('Shutting down...')
|
||||
|
||||
for (const worker of activeWorkers.values()) {
|
||||
debug(`Killing worker ${worker.process.pid}`)
|
||||
worker.kill()
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -4,9 +4,14 @@ import http from 'node:http';
|
|||
import Debug from 'debug';
|
||||
import exitHook from 'exit-hook';
|
||||
import { app } from '../app.js';
|
||||
import { initializeDatabase } from '../database/initializeDatabase.js';
|
||||
import { DEBUG_NAMESPACE } from '../debug.config.js';
|
||||
import { getConfigProperty } from '../helpers/config.helpers.js';
|
||||
const debug = Debug(`${DEBUG_NAMESPACE}:wwwProcess:${process.pid}`);
|
||||
const debug = Debug(`${DEBUG_NAMESPACE}:wwwProcess:${process.pid.toString().padEnd(5)}`);
|
||||
if (process.send === undefined) {
|
||||
// INITIALIZE THE DATABASE
|
||||
initializeDatabase();
|
||||
}
|
||||
function onError(error) {
|
||||
if (error.syscall !== 'listen') {
|
||||
throw error;
|
||||
|
|
|
|||
|
|
@ -7,14 +7,20 @@ import Debug from 'debug'
|
|||
import exitHook from 'exit-hook'
|
||||
|
||||
import { app } from '../app.js'
|
||||
import { initializeDatabase } from '../database/initializeDatabase.js'
|
||||
import { DEBUG_NAMESPACE } from '../debug.config.js'
|
||||
import { getConfigProperty } from '../helpers/config.helpers.js'
|
||||
|
||||
const debug = Debug(`${DEBUG_NAMESPACE}:wwwProcess:${process.pid}`)
|
||||
const debug = Debug(`${DEBUG_NAMESPACE}:wwwProcess:${process.pid.toString().padEnd(5)}`)
|
||||
|
||||
if (process.send === undefined) {
|
||||
// INITIALIZE THE DATABASE
|
||||
initializeDatabase()
|
||||
}
|
||||
|
||||
interface ServerError extends Error {
|
||||
syscall: string
|
||||
code: string
|
||||
syscall: string
|
||||
}
|
||||
|
||||
function onError(error: ServerError): void {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { defineConfig } from 'cypress';
|
||||
export default defineConfig({
|
||||
e2e: {
|
||||
baseUrl: 'http://localhost:7000',
|
||||
baseUrl: 'http://localhost:9000',
|
||||
projectId: '26a4bi',
|
||||
specPattern: 'cypress/e2e/**/*.cy.js',
|
||||
supportFile: false,
|
||||
projectId: '26a4bi'
|
||||
supportFile: false
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ import { defineConfig } from 'cypress'
|
|||
|
||||
export default defineConfig({
|
||||
e2e: {
|
||||
baseUrl: 'http://localhost:7000',
|
||||
baseUrl: 'http://localhost:9000',
|
||||
projectId: '26a4bi',
|
||||
specPattern: 'cypress/e2e/**/*.cy.js',
|
||||
supportFile: false,
|
||||
projectId: '26a4bi'
|
||||
supportFile: false
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { getConfigProperty } from '../../../helpers/config.helpers.js'
|
||||
import { testAdmin } from '../../../test/_globals.js'
|
||||
import type { Fee } from '../../../types/recordTypes.js'
|
||||
import type { Fee } from '../../../types/record.types.js'
|
||||
import { ajaxDelayMillis, login, logout } from '../../support/index.js'
|
||||
|
||||
describe('Admin - Fee Management', () => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { getConfigProperty } from '../../../helpers/config.helpers.js'
|
||||
import { testUpdate } from '../../../test/_globals.js'
|
||||
import type { Cemetery } from '../../../types/recordTypes.js'
|
||||
import type { Cemetery } from '../../../types/record.types.js'
|
||||
import { login, logout } from '../../support/index.js'
|
||||
|
||||
describe('Update - Cemeteries', () => {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
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/configTypes.js';
|
||||
import type { Config } from '../types/config.types.js';
|
||||
export declare const config: Config;
|
||||
export default config;
|
||||
|
|
@ -1,19 +1,21 @@
|
|||
export const config = {
|
||||
application: {},
|
||||
session: {},
|
||||
reverseProxy: {},
|
||||
users: {},
|
||||
aliases: {},
|
||||
application: {},
|
||||
reverseProxy: {},
|
||||
session: {},
|
||||
settings: {
|
||||
fees: {},
|
||||
burialSites: {},
|
||||
contracts: {},
|
||||
workOrders: {},
|
||||
adminCleanup: {},
|
||||
printPdf: {},
|
||||
burialSites: {},
|
||||
burialSiteTypes: {},
|
||||
cemeteries: {},
|
||||
contracts: {},
|
||||
dynamicsGP: {
|
||||
integrationIsEnabled: false
|
||||
}
|
||||
}
|
||||
},
|
||||
fees: {},
|
||||
printPdf: {},
|
||||
workOrders: {}
|
||||
},
|
||||
users: {}
|
||||
};
|
||||
export default config;
|
||||
|
|
@ -1,22 +1,24 @@
|
|||
import type { Config } from '../types/configTypes.js'
|
||||
import type { Config } from '../types/config.types.js'
|
||||
|
||||
export const config: Config = {
|
||||
application: {},
|
||||
session: {},
|
||||
reverseProxy: {},
|
||||
users: {},
|
||||
aliases: {},
|
||||
application: {},
|
||||
reverseProxy: {},
|
||||
session: {},
|
||||
settings: {
|
||||
fees: {},
|
||||
burialSites: {},
|
||||
contracts: {},
|
||||
workOrders: {},
|
||||
adminCleanup: {},
|
||||
printPdf: {},
|
||||
burialSites: {},
|
||||
burialSiteTypes: {},
|
||||
cemeteries: {},
|
||||
contracts: {},
|
||||
dynamicsGP: {
|
||||
integrationIsEnabled: false
|
||||
}
|
||||
}
|
||||
},
|
||||
fees: {},
|
||||
printPdf: {},
|
||||
workOrders: {}
|
||||
},
|
||||
users: {}
|
||||
}
|
||||
|
||||
export default config
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
export declare const config: import("../types/configTypes.js").Config;
|
||||
export default config;
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import { config as baseConfig } from './config.base.js';
|
||||
export const config = Object.assign({}, baseConfig);
|
||||
config.settings.provinceDefault = 'ON';
|
||||
config.settings.fees.taxPercentageDefault = 13;
|
||||
export default config;
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
import { config as baseConfig } from './config.base.js'
|
||||
|
||||
export const config = Object.assign({}, baseConfig)
|
||||
|
||||
config.settings.provinceDefault = 'ON'
|
||||
|
||||
config.settings.fees.taxPercentageDefault = 13
|
||||
|
||||
export default config
|
||||
|
|
@ -1,41 +1,54 @@
|
|||
import type { config as MSSQLConfig } from 'mssql';
|
||||
import type { ConfigActiveDirectory, ConfigBurialSiteNameSegments, ConfigNtfyStartup, DynamicsGPLookup } from '../types/configTypes.js';
|
||||
import type { ConfigActiveDirectory, ConfigBurialSiteNameSegments, ConfigNtfyStartup, DynamicsGPLookup } from '../types/config.types.js';
|
||||
export declare const configDefaultValues: {
|
||||
activeDirectory: ConfigActiveDirectory;
|
||||
'application.applicationName': string;
|
||||
'application.backgroundURL': string;
|
||||
'application.logoURL': string;
|
||||
'application.httpPort': number;
|
||||
'application.userDomain': string;
|
||||
'application.useTestDatabases': boolean;
|
||||
'application.logoURL': string;
|
||||
'application.maximumProcesses': number;
|
||||
'application.ntfyStartup': ConfigNtfyStartup | undefined;
|
||||
'application.userDomain': string;
|
||||
'application.useTestDatabases': boolean;
|
||||
'reverseProxy.disableCompression': boolean;
|
||||
'reverseProxy.disableEtag': boolean;
|
||||
'reverseProxy.urlPrefix': string;
|
||||
'session.cookieName': string;
|
||||
'session.secret': string;
|
||||
'session.maxAgeMillis': number;
|
||||
'session.doKeepAlive': boolean;
|
||||
'users.testing': string[];
|
||||
'session.maxAgeMillis': number;
|
||||
'session.secret': string;
|
||||
'users.canLogin': string[];
|
||||
'users.canUpdate': string[];
|
||||
'users.canUpdateWorkOrders': string[];
|
||||
'users.isAdmin': string[];
|
||||
'users.testing': string[];
|
||||
'aliases.externalReceiptNumber': string;
|
||||
'aliases.workOrderOpenDate': string;
|
||||
'aliases.workOrderCloseDate': string;
|
||||
'aliases.workOrderOpenDate': string;
|
||||
'settings.cityDefault': string;
|
||||
'settings.provinceDefault': string;
|
||||
'settings.publicInternalPath': string;
|
||||
'settings.latitudeMax': number;
|
||||
'settings.latitudeMin': number;
|
||||
'settings.longitudeMax': number;
|
||||
'settings.longitudeMin': number;
|
||||
'settings.cemeteries.refreshImageChanges': boolean;
|
||||
'settings.burialSiteTypes.bodyCapacityMaxDefault': number;
|
||||
'settings.burialSiteTypes.crematedCapacityMaxDefault': number;
|
||||
'settings.burialSites.burialSiteNameSegments': ConfigBurialSiteNameSegments;
|
||||
'settings.burialSites.burialSiteNameSegments.includeCemeteryKey': boolean;
|
||||
'settings.burialSites.refreshImageChanges': boolean;
|
||||
'settings.contracts.burialSiteIdIsRequired': boolean;
|
||||
'settings.contracts.contractEndDateIsRequired': boolean;
|
||||
'settings.contracts.prints': string[];
|
||||
'settings.fees.taxPercentageDefault': number;
|
||||
'settings.workOrders.workOrderNumberLength': number;
|
||||
'settings.workOrders.workOrderMilestoneDateRecentBeforeDays': number;
|
||||
'settings.workOrders.workOrderMilestoneDateRecentAfterDays': number;
|
||||
'settings.workOrders.calendarEmailAddress': string;
|
||||
'settings.workOrders.prints': string[];
|
||||
'settings.workOrders.workOrderMilestoneDateRecentAfterDays': number;
|
||||
'settings.workOrders.workOrderMilestoneDateRecentBeforeDays': number;
|
||||
'settings.adminCleanup.recordDeleteAgeDays': number;
|
||||
'settings.printPdf.browser': "chrome" | "firefox";
|
||||
'settings.printPdf.contentDisposition': "attachment" | "inline";
|
||||
'settings.dynamicsGP.integrationIsEnabled': boolean;
|
||||
'settings.dynamicsGP.mssqlConfig': MSSQLConfig;
|
||||
|
|
@ -44,3 +57,4 @@ export declare const configDefaultValues: {
|
|||
'settings.dynamicsGP.itemNumbers': string[];
|
||||
'settings.dynamicsGP.trialBalanceCodes': string[];
|
||||
};
|
||||
export default configDefaultValues;
|
||||
|
|
@ -3,49 +3,65 @@ export const configDefaultValues = {
|
|||
activeDirectory: undefined,
|
||||
'application.applicationName': 'Sunrise CMS',
|
||||
'application.backgroundURL': '/images/cemetery-background.jpg',
|
||||
'application.logoURL': '/images/sunrise-cms.png',
|
||||
'application.httpPort': 7000,
|
||||
'application.userDomain': '',
|
||||
'application.useTestDatabases': false,
|
||||
'application.httpPort': 9000,
|
||||
'application.logoURL': '/images/sunrise-cms.svg',
|
||||
'application.maximumProcesses': 4,
|
||||
'application.ntfyStartup': undefined,
|
||||
'application.userDomain': '',
|
||||
'application.useTestDatabases': false,
|
||||
'reverseProxy.disableCompression': false,
|
||||
'reverseProxy.disableEtag': false,
|
||||
'reverseProxy.urlPrefix': '',
|
||||
'session.cookieName': 'sunrise-user-sid',
|
||||
'session.secret': 'cityssm/sunrise',
|
||||
'session.maxAgeMillis': hoursToMillis(1),
|
||||
'session.doKeepAlive': false,
|
||||
'users.testing': [],
|
||||
'session.maxAgeMillis': hoursToMillis(1),
|
||||
'session.secret': 'cityssm/sunrise',
|
||||
'users.canLogin': ['administrator'],
|
||||
'users.canUpdate': [],
|
||||
'users.canUpdateWorkOrders': [],
|
||||
'users.isAdmin': ['administrator'],
|
||||
'users.testing': [],
|
||||
'aliases.externalReceiptNumber': 'External Receipt Number',
|
||||
'aliases.workOrderOpenDate': 'Order Date',
|
||||
'aliases.workOrderCloseDate': 'Completion Date',
|
||||
'aliases.workOrderOpenDate': 'Order Date',
|
||||
'settings.cityDefault': '',
|
||||
'settings.provinceDefault': '',
|
||||
'settings.publicInternalPath': 'public-internal',
|
||||
'settings.latitudeMax': 90,
|
||||
'settings.latitudeMin': -90,
|
||||
'settings.longitudeMax': 180,
|
||||
'settings.longitudeMin': -180,
|
||||
'settings.cemeteries.refreshImageChanges': false,
|
||||
// eslint-disable-next-line no-secrets/no-secrets
|
||||
'settings.burialSiteTypes.bodyCapacityMaxDefault': 2,
|
||||
// eslint-disable-next-line no-secrets/no-secrets
|
||||
'settings.burialSiteTypes.crematedCapacityMaxDefault': 6,
|
||||
'settings.burialSites.burialSiteNameSegments': {
|
||||
includeCemeteryKey: false,
|
||||
separator: '-',
|
||||
segments: {
|
||||
1: {
|
||||
isRequired: true,
|
||||
isAvailable: true,
|
||||
isRequired: true,
|
||||
label: 'Plot Number',
|
||||
minLength: 1,
|
||||
maxLength: 20
|
||||
maxLength: 20,
|
||||
minLength: 1
|
||||
}
|
||||
}
|
||||
},
|
||||
'settings.burialSites.burialSiteNameSegments.includeCemeteryKey': false,
|
||||
'settings.burialSites.refreshImageChanges': false,
|
||||
'settings.contracts.burialSiteIdIsRequired': true,
|
||||
'settings.contracts.contractEndDateIsRequired': false,
|
||||
'settings.contracts.prints': ['screen/contract'],
|
||||
'settings.fees.taxPercentageDefault': 0,
|
||||
'settings.workOrders.workOrderNumberLength': 6,
|
||||
'settings.workOrders.workOrderMilestoneDateRecentBeforeDays': 5,
|
||||
'settings.workOrders.workOrderMilestoneDateRecentAfterDays': 60,
|
||||
'settings.workOrders.calendarEmailAddress': 'no-reply@127.0.0.1',
|
||||
'settings.workOrders.prints': ['pdf/workOrder', 'pdf/workOrder-commentLog'],
|
||||
'settings.workOrders.workOrderMilestoneDateRecentAfterDays': 60,
|
||||
'settings.workOrders.workOrderMilestoneDateRecentBeforeDays': 5,
|
||||
'settings.adminCleanup.recordDeleteAgeDays': 60,
|
||||
'settings.printPdf.browser': 'chrome',
|
||||
'settings.printPdf.contentDisposition': 'attachment',
|
||||
'settings.dynamicsGP.integrationIsEnabled': false,
|
||||
'settings.dynamicsGP.mssqlConfig': undefined,
|
||||
|
|
@ -55,3 +71,4 @@ export const configDefaultValues = {
|
|||
'settings.dynamicsGP.itemNumbers': [],
|
||||
'settings.dynamicsGP.trialBalanceCodes': []
|
||||
};
|
||||
export default configDefaultValues;
|
||||
|
|
@ -6,70 +6,93 @@ import type {
|
|||
ConfigBurialSiteNameSegments,
|
||||
ConfigNtfyStartup,
|
||||
DynamicsGPLookup
|
||||
} from '../types/configTypes.js'
|
||||
} from '../types/config.types.js'
|
||||
|
||||
export const configDefaultValues = {
|
||||
activeDirectory: undefined as unknown as ConfigActiveDirectory,
|
||||
|
||||
'application.applicationName': 'Sunrise CMS',
|
||||
'application.backgroundURL': '/images/cemetery-background.jpg',
|
||||
'application.logoURL': '/images/sunrise-cms.png',
|
||||
'application.httpPort': 7000,
|
||||
'application.httpPort': 9000,
|
||||
'application.logoURL': '/images/sunrise-cms.svg',
|
||||
'application.maximumProcesses': 4,
|
||||
'application.ntfyStartup': undefined as ConfigNtfyStartup | undefined,
|
||||
'application.userDomain': '',
|
||||
'application.useTestDatabases': false,
|
||||
'application.maximumProcesses': 4,
|
||||
|
||||
'application.ntfyStartup': undefined as ConfigNtfyStartup | undefined,
|
||||
|
||||
'reverseProxy.disableCompression': false,
|
||||
'reverseProxy.disableEtag': false,
|
||||
'reverseProxy.urlPrefix': '',
|
||||
|
||||
'session.cookieName': 'sunrise-user-sid',
|
||||
'session.secret': 'cityssm/sunrise',
|
||||
'session.maxAgeMillis': hoursToMillis(1),
|
||||
'session.doKeepAlive': false,
|
||||
'session.maxAgeMillis': hoursToMillis(1),
|
||||
'session.secret': 'cityssm/sunrise',
|
||||
|
||||
'users.testing': [] as string[],
|
||||
'users.canLogin': ['administrator'],
|
||||
'users.canUpdate': [] as string[],
|
||||
'users.canUpdateWorkOrders': [] as string[],
|
||||
'users.isAdmin': ['administrator'],
|
||||
'users.testing': [] as string[],
|
||||
|
||||
'aliases.externalReceiptNumber': 'External Receipt Number',
|
||||
'aliases.workOrderOpenDate': 'Order Date',
|
||||
'aliases.workOrderCloseDate': 'Completion Date',
|
||||
'aliases.workOrderOpenDate': 'Order Date',
|
||||
|
||||
'settings.cityDefault': '',
|
||||
'settings.provinceDefault': '',
|
||||
|
||||
'settings.publicInternalPath': 'public-internal',
|
||||
|
||||
'settings.latitudeMax': 90,
|
||||
'settings.latitudeMin': -90,
|
||||
'settings.longitudeMax': 180,
|
||||
'settings.longitudeMin': -180,
|
||||
|
||||
'settings.cemeteries.refreshImageChanges': false,
|
||||
|
||||
// eslint-disable-next-line no-secrets/no-secrets
|
||||
'settings.burialSiteTypes.bodyCapacityMaxDefault': 2,
|
||||
|
||||
// eslint-disable-next-line no-secrets/no-secrets
|
||||
'settings.burialSiteTypes.crematedCapacityMaxDefault': 6,
|
||||
|
||||
'settings.burialSites.burialSiteNameSegments': {
|
||||
includeCemeteryKey: false,
|
||||
separator: '-',
|
||||
|
||||
segments: {
|
||||
1: {
|
||||
isRequired: true,
|
||||
isAvailable: true,
|
||||
isRequired: true,
|
||||
label: 'Plot Number',
|
||||
minLength: 1,
|
||||
maxLength: 20
|
||||
maxLength: 20,
|
||||
minLength: 1
|
||||
}
|
||||
}
|
||||
} as unknown as ConfigBurialSiteNameSegments,
|
||||
|
||||
'settings.burialSites.burialSiteNameSegments.includeCemeteryKey': false,
|
||||
|
||||
'settings.burialSites.refreshImageChanges': false,
|
||||
|
||||
'settings.contracts.burialSiteIdIsRequired': true,
|
||||
'settings.contracts.contractEndDateIsRequired': false,
|
||||
|
||||
'settings.contracts.prints': ['screen/contract'],
|
||||
|
||||
'settings.fees.taxPercentageDefault': 0,
|
||||
|
||||
'settings.workOrders.workOrderNumberLength': 6,
|
||||
|
||||
'settings.workOrders.workOrderMilestoneDateRecentBeforeDays': 5,
|
||||
'settings.workOrders.workOrderMilestoneDateRecentAfterDays': 60,
|
||||
'settings.workOrders.calendarEmailAddress': 'no-reply@127.0.0.1',
|
||||
'settings.workOrders.prints': ['pdf/workOrder', 'pdf/workOrder-commentLog'],
|
||||
'settings.workOrders.workOrderMilestoneDateRecentAfterDays': 60,
|
||||
'settings.workOrders.workOrderMilestoneDateRecentBeforeDays': 5,
|
||||
|
||||
'settings.adminCleanup.recordDeleteAgeDays': 60,
|
||||
|
||||
'settings.printPdf.browser': 'chrome' as 'chrome' | 'firefox',
|
||||
'settings.printPdf.contentDisposition': 'attachment' as
|
||||
| 'attachment'
|
||||
| 'inline',
|
||||
|
|
@ -84,3 +107,5 @@ export const configDefaultValues = {
|
|||
'settings.dynamicsGP.itemNumbers': [] as string[],
|
||||
'settings.dynamicsGP.trialBalanceCodes': [] as string[]
|
||||
}
|
||||
|
||||
export default configDefaultValues
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
export declare const deathAgePeriods: readonly ["Years", "Months", "Days", "Stillborn"];
|
||||
export declare const purchaserRelationships: readonly ["Spouse", "Husband", "Wife", "Child", "Parent", "Sibling", "Friend", "Self"];
|
||||
export declare const directionsOfArrival: readonly ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
|
||||
declare const _default: {
|
||||
deathAgePeriods: readonly ["Years", "Months", "Days", "Stillborn"];
|
||||
directionsOfArrival: readonly ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
|
||||
purchaserRelationships: readonly ["Spouse", "Husband", "Wife", "Child", "Parent", "Sibling", "Friend", "Self"];
|
||||
};
|
||||
export default _default;
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
export const deathAgePeriods = ['Years', 'Months', 'Days', 'Stillborn'];
|
||||
export const purchaserRelationships = [
|
||||
'Spouse',
|
||||
'Husband',
|
||||
'Wife',
|
||||
'Child',
|
||||
'Parent',
|
||||
'Sibling',
|
||||
'Friend',
|
||||
'Self'
|
||||
];
|
||||
export const directionsOfArrival = [
|
||||
'N',
|
||||
'NE',
|
||||
'E',
|
||||
'SE',
|
||||
'S',
|
||||
'SW',
|
||||
'W',
|
||||
'NW'
|
||||
];
|
||||
export default {
|
||||
deathAgePeriods,
|
||||
directionsOfArrival,
|
||||
purchaserRelationships
|
||||
};
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
export const deathAgePeriods = ['Years', 'Months', 'Days', 'Stillborn'] as const
|
||||
|
||||
export const purchaserRelationships = [
|
||||
'Spouse',
|
||||
'Husband',
|
||||
'Wife',
|
||||
'Child',
|
||||
'Parent',
|
||||
'Sibling',
|
||||
'Friend',
|
||||
'Self'
|
||||
] as const
|
||||
|
||||
export const directionsOfArrival = [
|
||||
'N',
|
||||
'NE',
|
||||
'E',
|
||||
'SE',
|
||||
'S',
|
||||
'SW',
|
||||
'W',
|
||||
'NW'
|
||||
] as const
|
||||
|
||||
export default {
|
||||
deathAgePeriods,
|
||||
directionsOfArrival,
|
||||
purchaserRelationships
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
export declare const config: import("../types/config.types.js").Config;
|
||||
export default config;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import { config as baseConfig } from './base.config.js';
|
||||
export const config = Object.assign({}, baseConfig);
|
||||
config.settings.provinceDefault = 'ON';
|
||||
config.settings.latitudeMax = 56.85;
|
||||
config.settings.latitudeMin = 41.68;
|
||||
config.settings.longitudeMax = -74;
|
||||
config.settings.longitudeMin = -95.15;
|
||||
config.settings.fees.taxPercentageDefault = 13;
|
||||
export default config;
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
import { config as baseConfig } from './base.config.js'
|
||||
|
||||
export const config = Object.assign({}, baseConfig)
|
||||
|
||||
config.settings.provinceDefault = 'ON'
|
||||
|
||||
config.settings.latitudeMax = 56.85
|
||||
config.settings.latitudeMin = 41.68
|
||||
|
||||
config.settings.longitudeMax = -74
|
||||
config.settings.longitudeMin = -95.15
|
||||
|
||||
config.settings.fees.taxPercentageDefault = 13
|
||||
|
||||
export default config
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
import type { Config } from '../types/configTypes.js';
|
||||
import type { Config } from '../types/config.types.js';
|
||||
export declare const config: Config;
|
||||
export default config;
|
||||
|
|
@ -1,45 +1,52 @@
|
|||
import { config as cemeteryConfig } from './config.baseOntario.js';
|
||||
import { config as cemeteryConfig } from './ontario.config.js';
|
||||
export const config = { ...cemeteryConfig };
|
||||
config.aliases.externalReceiptNumber = 'GP Receipt Number';
|
||||
config.settings.publicInternalPath =
|
||||
'../sunrise-cms-saultstemarie/public-internal';
|
||||
config.settings.burialSites.burialSiteNameSegments = {
|
||||
separator: '-',
|
||||
includeCemeteryKey: true,
|
||||
separator: '-',
|
||||
segments: {
|
||||
1: {
|
||||
isRequired: false,
|
||||
isAvailable: true,
|
||||
isRequired: false,
|
||||
label: 'Block',
|
||||
minLength: 1,
|
||||
maxLength: 1
|
||||
maxLength: 1,
|
||||
minLength: 1
|
||||
},
|
||||
2: {
|
||||
isRequired: true,
|
||||
isAvailable: true,
|
||||
isRequired: false,
|
||||
label: 'Range',
|
||||
minLength: 1,
|
||||
maxLength: 3
|
||||
maxLength: 3,
|
||||
minLength: 1
|
||||
},
|
||||
3: {
|
||||
isRequired: true,
|
||||
isAvailable: true,
|
||||
isRequired: true,
|
||||
label: 'Lot',
|
||||
minLength: 1,
|
||||
maxLength: 4
|
||||
maxLength: 4,
|
||||
minLength: 1
|
||||
},
|
||||
4: {
|
||||
isRequired: true,
|
||||
isAvailable: true,
|
||||
isRequired: true,
|
||||
label: 'Grave',
|
||||
minLength: 1,
|
||||
maxLength: 2
|
||||
maxLength: 2,
|
||||
minLength: 1
|
||||
}
|
||||
}
|
||||
};
|
||||
config.settings.cityDefault = 'Sault Ste. Marie';
|
||||
config.settings.latitudeMax = 46.75;
|
||||
config.settings.latitudeMin = 46.4;
|
||||
config.settings.longitudeMax = -84.2;
|
||||
config.settings.longitudeMin = -84.5;
|
||||
config.settings.contracts.prints = [
|
||||
'pdf/ssm.cemetery.burialPermit',
|
||||
'pdf/ssm.cemetery.contract'
|
||||
];
|
||||
config.settings.printPdf.browser = 'firefox';
|
||||
config.settings.workOrders.workOrderNumberLength = 6;
|
||||
config.settings.workOrders.workOrderMilestoneDateRecentBeforeDays = 7;
|
||||
config.settings.workOrders.workOrderMilestoneDateRecentAfterDays = 30;
|
||||
|
|
@ -1,53 +1,64 @@
|
|||
import type { Config } from '../types/configTypes.js'
|
||||
import type { Config } from '../types/config.types.js'
|
||||
|
||||
import { config as cemeteryConfig } from './config.baseOntario.js'
|
||||
import { config as cemeteryConfig } from './ontario.config.js'
|
||||
|
||||
export const config: Config = { ...cemeteryConfig }
|
||||
|
||||
config.aliases.externalReceiptNumber = 'GP Receipt Number'
|
||||
|
||||
config.settings.publicInternalPath =
|
||||
'../sunrise-cms-saultstemarie/public-internal'
|
||||
|
||||
config.settings.burialSites.burialSiteNameSegments = {
|
||||
separator: '-',
|
||||
includeCemeteryKey: true,
|
||||
separator: '-',
|
||||
|
||||
segments: {
|
||||
1: {
|
||||
isRequired: false,
|
||||
isAvailable: true,
|
||||
isRequired: false,
|
||||
label: 'Block',
|
||||
minLength: 1,
|
||||
maxLength: 1
|
||||
maxLength: 1,
|
||||
minLength: 1
|
||||
},
|
||||
2: {
|
||||
isRequired: true,
|
||||
isAvailable: true,
|
||||
isRequired: false,
|
||||
label: 'Range',
|
||||
minLength: 1,
|
||||
maxLength: 3
|
||||
maxLength: 3,
|
||||
minLength: 1
|
||||
},
|
||||
3: {
|
||||
isRequired: true,
|
||||
isAvailable: true,
|
||||
isRequired: true,
|
||||
label: 'Lot',
|
||||
minLength: 1,
|
||||
maxLength: 4
|
||||
maxLength: 4,
|
||||
minLength: 1
|
||||
},
|
||||
4: {
|
||||
isRequired: true,
|
||||
isAvailable: true,
|
||||
isRequired: true,
|
||||
label: 'Grave',
|
||||
minLength: 1,
|
||||
maxLength: 2
|
||||
maxLength: 2,
|
||||
minLength: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config.settings.cityDefault = 'Sault Ste. Marie'
|
||||
|
||||
config.settings.latitudeMax = 46.75
|
||||
config.settings.latitudeMin = 46.4
|
||||
config.settings.longitudeMax = -84.2
|
||||
config.settings.longitudeMin = -84.5
|
||||
|
||||
config.settings.contracts.prints = [
|
||||
'pdf/ssm.cemetery.burialPermit',
|
||||
'pdf/ssm.cemetery.contract'
|
||||
]
|
||||
|
||||
config.settings.printPdf.browser = 'firefox'
|
||||
|
||||
config.settings.workOrders.workOrderNumberLength = 6
|
||||
config.settings.workOrders.workOrderMilestoneDateRecentBeforeDays = 7
|
||||
config.settings.workOrders.workOrderMilestoneDateRecentAfterDays = 30
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
import type { Config } from '../types/configTypes.js';
|
||||
import type { Config } from '../types/config.types.js';
|
||||
export declare const config: Config;
|
||||
export default config;
|
||||
|
|
@ -1,12 +1,14 @@
|
|||
import { config as cemeteryConfig } from './config.baseSsm.js';
|
||||
import { config as cemeteryConfig } from './ssm.ontario.config.js';
|
||||
export const config = { ...cemeteryConfig };
|
||||
config.application.useTestDatabases = true;
|
||||
config.session.doKeepAlive = true;
|
||||
config.users = {
|
||||
testing: ['*testView', '*testUpdate', '*testAdmin'],
|
||||
canLogin: ['*testView', '*testUpdate', '*testAdmin'],
|
||||
canUpdate: ['*testUpdate'],
|
||||
isAdmin: ['*testAdmin']
|
||||
canUpdateWorkOrders: ['*testUpdate'],
|
||||
isAdmin: ['*testAdmin'],
|
||||
testing: ['*testView', '*testUpdate', '*testAdmin']
|
||||
};
|
||||
config.settings.publicInternalPath = 'public-internal';
|
||||
config.settings.dynamicsGP.integrationIsEnabled = false;
|
||||
export default config;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import type { Config } from '../types/configTypes.js'
|
||||
import type { Config } from '../types/config.types.js'
|
||||
|
||||
import { config as cemeteryConfig } from './config.baseSsm.js'
|
||||
import { config as cemeteryConfig } from './ssm.ontario.config.js'
|
||||
|
||||
export const config: Config = { ...cemeteryConfig }
|
||||
|
||||
|
|
@ -9,12 +9,15 @@ config.application.useTestDatabases = true
|
|||
config.session.doKeepAlive = true
|
||||
|
||||
config.users = {
|
||||
testing: ['*testView', '*testUpdate', '*testAdmin'],
|
||||
canLogin: ['*testView', '*testUpdate', '*testAdmin'],
|
||||
canUpdate: ['*testUpdate'],
|
||||
isAdmin: ['*testAdmin']
|
||||
canUpdateWorkOrders: ['*testUpdate'],
|
||||
isAdmin: ['*testAdmin'],
|
||||
testing: ['*testView', '*testUpdate', '*testAdmin']
|
||||
}
|
||||
|
||||
config.settings.publicInternalPath = 'public-internal'
|
||||
|
||||
config.settings.dynamicsGP!.integrationIsEnabled = false
|
||||
|
||||
export default config
|
||||
|
|
@ -1,16 +1,29 @@
|
|||
export interface AddBurialSiteForm {
|
||||
burialSiteNameSegment1: string;
|
||||
burialSiteNameSegment1?: string;
|
||||
burialSiteNameSegment2?: string;
|
||||
burialSiteNameSegment3?: string;
|
||||
burialSiteNameSegment4?: string;
|
||||
burialSiteNameSegment5?: string;
|
||||
burialSiteTypeId: string | number;
|
||||
burialSiteStatusId: string | number;
|
||||
cemeteryId: string | number;
|
||||
cemeterySvgId: string;
|
||||
burialSiteLatitude: string;
|
||||
burialSiteLongitude: string;
|
||||
burialSiteStatusId: number | string;
|
||||
burialSiteTypeId: number | string;
|
||||
bodyCapacity?: number | string;
|
||||
crematedCapacity?: number | string;
|
||||
burialSiteImage?: string;
|
||||
cemeteryId: number | string;
|
||||
cemeterySvgId?: string;
|
||||
burialSiteLatitude?: string;
|
||||
burialSiteLongitude?: string;
|
||||
burialSiteTypeFieldIds?: string;
|
||||
[fieldValue_burialSiteTypeFieldId: string]: unknown;
|
||||
}
|
||||
export default function addBurialSite(burialSiteForm: AddBurialSiteForm, user: User): Promise<number>;
|
||||
/**
|
||||
* Creates a new burial site.
|
||||
* @param burialSiteForm - The new burial site's information
|
||||
* @param user - The user making the request
|
||||
* @returns The new burial site's id.
|
||||
* @throws If an active burial site with the same name already exists.
|
||||
*/
|
||||
export default function addBurialSite(burialSiteForm: AddBurialSiteForm, user: User): {
|
||||
burialSiteId: number;
|
||||
burialSiteName: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,12 +1,35 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { buildBurialSiteName } from '../helpers/burialSites.helpers.js';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import addOrUpdateBurialSiteField from './addOrUpdateBurialSiteField.js';
|
||||
import getCemetery from './getCemetery.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function addBurialSite(burialSiteForm, user) {
|
||||
const database = await acquireConnection();
|
||||
/**
|
||||
* Creates a new burial site.
|
||||
* @param burialSiteForm - The new burial site's information
|
||||
* @param user - The user making the request
|
||||
* @returns The new burial site's id.
|
||||
* @throws If an active burial site with the same name already exists.
|
||||
*/
|
||||
// eslint-disable-next-line complexity
|
||||
export default function addBurialSite(burialSiteForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const cemetery = burialSiteForm.cemeteryId === '' ? undefined : await getCemetery(burialSiteForm.cemeteryId, database);
|
||||
const cemetery = burialSiteForm.cemeteryId === ''
|
||||
? undefined
|
||||
: getCemetery(burialSiteForm.cemeteryId, database);
|
||||
const burialSiteName = buildBurialSiteName(cemetery?.cemeteryKey, burialSiteForm);
|
||||
// Ensure no active burial sites share the same name
|
||||
const existingBurialSite = database
|
||||
.prepare(`select burialSiteId
|
||||
from BurialSites
|
||||
where burialSiteName = ?
|
||||
and recordDelete_timeMillis is null`)
|
||||
.pluck()
|
||||
.get(burialSiteName);
|
||||
if (existingBurialSite !== undefined) {
|
||||
database.close();
|
||||
throw new Error('An active burial site with that name already exists.');
|
||||
}
|
||||
const result = database
|
||||
.prepare(`insert into BurialSites (
|
||||
burialSiteNameSegment1,
|
||||
|
|
@ -16,27 +39,41 @@ export default async function addBurialSite(burialSiteForm, user) {
|
|||
burialSiteNameSegment5,
|
||||
burialSiteName,
|
||||
burialSiteTypeId, burialSiteStatusId,
|
||||
cemeteryId, cemeterySvgId,
|
||||
bodyCapacity, crematedCapacity,
|
||||
cemeteryId, cemeterySvgId, burialSiteImage,
|
||||
burialSiteLatitude, burialSiteLongitude,
|
||||
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?,
|
||||
values (?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?)`)
|
||||
.run(burialSiteForm.burialSiteNameSegment1, burialSiteForm.burialSiteNameSegment2 ?? '', burialSiteForm.burialSiteNameSegment3 ?? '', burialSiteForm.burialSiteNameSegment4 ?? '', burialSiteForm.burialSiteNameSegment5 ?? '', burialSiteName, burialSiteForm.burialSiteTypeId, burialSiteForm.burialSiteStatusId === '' ? undefined : burialSiteForm.burialSiteStatusId, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteLatitude === '' ? undefined : burialSiteForm.burialSiteLatitude, burialSiteForm.burialSiteLongitude === '' ? undefined : burialSiteForm.burialSiteLongitude, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
.run(burialSiteForm.burialSiteNameSegment1 ?? '', burialSiteForm.burialSiteNameSegment2 ?? '', burialSiteForm.burialSiteNameSegment3 ?? '', burialSiteForm.burialSiteNameSegment4 ?? '', burialSiteForm.burialSiteNameSegment5 ?? '', burialSiteName, burialSiteForm.burialSiteTypeId, burialSiteForm.burialSiteStatusId === ''
|
||||
? undefined
|
||||
: burialSiteForm.burialSiteStatusId, burialSiteForm.bodyCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.bodyCapacity, burialSiteForm.crematedCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.crematedCapacity, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteImage ?? '', burialSiteForm.burialSiteLatitude === ''
|
||||
? undefined
|
||||
: burialSiteForm.burialSiteLatitude, burialSiteForm.burialSiteLongitude === ''
|
||||
? undefined
|
||||
: burialSiteForm.burialSiteLongitude, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
const burialSiteId = result.lastInsertRowid;
|
||||
const burialSiteTypeFieldIds = (burialSiteForm.burialSiteTypeFieldIds ?? '').split(',');
|
||||
for (const burialSiteTypeFieldId of burialSiteTypeFieldIds) {
|
||||
const fieldValue = burialSiteForm[`burialSiteFieldValue_${burialSiteTypeFieldId}`];
|
||||
if ((fieldValue ?? '') !== '') {
|
||||
await addOrUpdateBurialSiteField({
|
||||
addOrUpdateBurialSiteField({
|
||||
burialSiteId,
|
||||
burialSiteTypeFieldId,
|
||||
fieldValue: fieldValue ?? ''
|
||||
}, user, database);
|
||||
}
|
||||
}
|
||||
database.release();
|
||||
return burialSiteId;
|
||||
database.close();
|
||||
return {
|
||||
burialSiteId,
|
||||
burialSiteName
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,42 +1,78 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { buildBurialSiteName } from '../helpers/burialSites.helpers.js'
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
import addOrUpdateBurialSiteField from './addOrUpdateBurialSiteField.js'
|
||||
import getCemetery from './getCemetery.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export interface AddBurialSiteForm {
|
||||
burialSiteNameSegment1: string
|
||||
burialSiteNameSegment1?: string
|
||||
burialSiteNameSegment2?: string
|
||||
burialSiteNameSegment3?: string
|
||||
burialSiteNameSegment4?: string
|
||||
burialSiteNameSegment5?: string
|
||||
|
||||
burialSiteTypeId: string | number
|
||||
burialSiteStatusId: string | number
|
||||
burialSiteStatusId: number | string
|
||||
burialSiteTypeId: number | string
|
||||
|
||||
cemeteryId: string | number
|
||||
cemeterySvgId: string
|
||||
bodyCapacity?: number | string
|
||||
crematedCapacity?: number | string
|
||||
|
||||
burialSiteLatitude: string
|
||||
burialSiteLongitude: string
|
||||
burialSiteImage?: string
|
||||
cemeteryId: number | string
|
||||
cemeterySvgId?: string
|
||||
|
||||
burialSiteLatitude?: string
|
||||
burialSiteLongitude?: string
|
||||
|
||||
burialSiteTypeFieldIds?: string
|
||||
|
||||
[fieldValue_burialSiteTypeFieldId: string]: unknown
|
||||
}
|
||||
|
||||
export default async function addBurialSite(
|
||||
/**
|
||||
* Creates a new burial site.
|
||||
* @param burialSiteForm - The new burial site's information
|
||||
* @param user - The user making the request
|
||||
* @returns The new burial site's id.
|
||||
* @throws If an active burial site with the same name already exists.
|
||||
*/
|
||||
// eslint-disable-next-line complexity
|
||||
export default function addBurialSite(
|
||||
burialSiteForm: AddBurialSiteForm,
|
||||
user: User
|
||||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
): { burialSiteId: number; burialSiteName: string } {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
const cemetery = burialSiteForm.cemeteryId === '' ? undefined : await getCemetery(burialSiteForm.cemeteryId, database)
|
||||
const cemetery =
|
||||
burialSiteForm.cemeteryId === ''
|
||||
? undefined
|
||||
: getCemetery(burialSiteForm.cemeteryId, database)
|
||||
|
||||
const burialSiteName = buildBurialSiteName(
|
||||
cemetery?.cemeteryKey,
|
||||
burialSiteForm)
|
||||
burialSiteForm
|
||||
)
|
||||
|
||||
// Ensure no active burial sites share the same name
|
||||
|
||||
const existingBurialSite = database
|
||||
.prepare(
|
||||
`select burialSiteId
|
||||
from BurialSites
|
||||
where burialSiteName = ?
|
||||
and recordDelete_timeMillis is null`
|
||||
)
|
||||
.pluck()
|
||||
.get(burialSiteName) as number | undefined
|
||||
|
||||
if (existingBurialSite !== undefined) {
|
||||
database.close()
|
||||
throw new Error('An active burial site with that name already exists.')
|
||||
}
|
||||
|
||||
const result = database
|
||||
.prepare(
|
||||
|
|
@ -48,28 +84,45 @@ export default async function addBurialSite(
|
|||
burialSiteNameSegment5,
|
||||
burialSiteName,
|
||||
burialSiteTypeId, burialSiteStatusId,
|
||||
cemeteryId, cemeterySvgId,
|
||||
bodyCapacity, crematedCapacity,
|
||||
cemeteryId, cemeterySvgId, burialSiteImage,
|
||||
burialSiteLatitude, burialSiteLongitude,
|
||||
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?,
|
||||
values (?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?)`
|
||||
)
|
||||
.run(
|
||||
burialSiteForm.burialSiteNameSegment1,
|
||||
burialSiteForm.burialSiteNameSegment1 ?? '',
|
||||
burialSiteForm.burialSiteNameSegment2 ?? '',
|
||||
burialSiteForm.burialSiteNameSegment3 ?? '',
|
||||
burialSiteForm.burialSiteNameSegment4 ?? '',
|
||||
burialSiteForm.burialSiteNameSegment5 ?? '',
|
||||
burialSiteName,
|
||||
burialSiteForm.burialSiteTypeId,
|
||||
burialSiteForm.burialSiteStatusId === '' ? undefined : burialSiteForm.burialSiteStatusId,
|
||||
burialSiteForm.burialSiteStatusId === ''
|
||||
? undefined
|
||||
: burialSiteForm.burialSiteStatusId,
|
||||
|
||||
burialSiteForm.bodyCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.bodyCapacity,
|
||||
|
||||
burialSiteForm.crematedCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.crematedCapacity,
|
||||
|
||||
burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId,
|
||||
burialSiteForm.cemeterySvgId,
|
||||
burialSiteForm.burialSiteLatitude === '' ? undefined : burialSiteForm.burialSiteLatitude,
|
||||
burialSiteForm.burialSiteLongitude === '' ? undefined : burialSiteForm.burialSiteLongitude,
|
||||
burialSiteForm.burialSiteImage ?? '',
|
||||
burialSiteForm.burialSiteLatitude === ''
|
||||
? undefined
|
||||
: burialSiteForm.burialSiteLatitude,
|
||||
burialSiteForm.burialSiteLongitude === ''
|
||||
? undefined
|
||||
: burialSiteForm.burialSiteLongitude,
|
||||
user.userName,
|
||||
rightNowMillis,
|
||||
user.userName,
|
||||
|
|
@ -78,13 +131,17 @@ export default async function addBurialSite(
|
|||
|
||||
const burialSiteId = result.lastInsertRowid as number
|
||||
|
||||
const burialSiteTypeFieldIds = (burialSiteForm.burialSiteTypeFieldIds ?? '').split(',')
|
||||
const burialSiteTypeFieldIds = (
|
||||
burialSiteForm.burialSiteTypeFieldIds ?? ''
|
||||
).split(',')
|
||||
|
||||
for (const burialSiteTypeFieldId of burialSiteTypeFieldIds) {
|
||||
const fieldValue = burialSiteForm[`burialSiteFieldValue_${burialSiteTypeFieldId}`] as string | undefined
|
||||
const fieldValue = burialSiteForm[
|
||||
`burialSiteFieldValue_${burialSiteTypeFieldId}`
|
||||
] as string | undefined
|
||||
|
||||
if ((fieldValue ?? '') !== '') {
|
||||
await addOrUpdateBurialSiteField(
|
||||
addOrUpdateBurialSiteField(
|
||||
{
|
||||
burialSiteId,
|
||||
burialSiteTypeFieldId,
|
||||
|
|
@ -96,7 +153,10 @@ export default async function addBurialSite(
|
|||
}
|
||||
}
|
||||
|
||||
database.release()
|
||||
database.close()
|
||||
|
||||
return burialSiteId
|
||||
return {
|
||||
burialSiteId,
|
||||
burialSiteName
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@ export interface AddBurialSiteCommentForm {
|
|||
burialSiteId: string;
|
||||
comment: string;
|
||||
}
|
||||
export default function addBurialSiteComment(commentForm: AddBurialSiteCommentForm, user: User): Promise<number>;
|
||||
export default function addBurialSiteComment(commentForm: AddBurialSiteCommentForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { dateToInteger, dateToTimeInteger } from '@cityssm/utils-datetime';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function addBurialSiteComment(commentForm, user) {
|
||||
const database = await acquireConnection();
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
export default function addBurialSiteComment(commentForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNow = new Date();
|
||||
const result = database
|
||||
.prepare(`insert into BurialSiteComments (
|
||||
|
|
@ -11,6 +12,6 @@ export default async function addBurialSiteComment(commentForm, user) {
|
|||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(commentForm.burialSiteId, dateToInteger(rightNow), dateToTimeInteger(rightNow), commentForm.comment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime());
|
||||
database.release();
|
||||
database.close();
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
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 interface AddBurialSiteCommentForm {
|
||||
burialSiteId: string
|
||||
comment: string
|
||||
}
|
||||
|
||||
export default async function addBurialSiteComment(
|
||||
export default function addBurialSiteComment(
|
||||
commentForm: AddBurialSiteCommentForm,
|
||||
user: User
|
||||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNow = new Date()
|
||||
|
||||
|
|
@ -35,7 +36,7 @@ export default async function addBurialSiteComment(
|
|||
rightNow.getTime()
|
||||
)
|
||||
|
||||
database.release()
|
||||
database.close()
|
||||
|
||||
return result.lastInsertRowid as number
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
export interface AddBurialSiteTypeForm {
|
||||
burialSiteType: string;
|
||||
bodyCapacityMax: number | string;
|
||||
crematedCapacityMax: number | string;
|
||||
orderNumber?: number | string;
|
||||
}
|
||||
export default function addBurialSiteType(addForm: AddBurialSiteTypeForm, user: User): number;
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
export default function addBurialSiteType(addForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare(`insert into BurialSiteTypes (
|
||||
burialSiteType, bodyCapacityMax, crematedCapacityMax,
|
||||
orderNumber,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.burialSiteType, addForm.bodyCapacityMax === '' ? undefined : addForm.bodyCapacityMax, addForm.crematedCapacityMax === ''
|
||||
? undefined
|
||||
: addForm.crematedCapacityMax, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.close();
|
||||
clearCacheByTableName('BurialSiteTypes');
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
|
||||
export interface AddBurialSiteTypeForm {
|
||||
burialSiteType: string
|
||||
|
||||
bodyCapacityMax: number | string
|
||||
crematedCapacityMax: number | string
|
||||
|
||||
orderNumber?: number | string
|
||||
}
|
||||
|
||||
export default function addBurialSiteType(
|
||||
addForm: AddBurialSiteTypeForm,
|
||||
user: User
|
||||
): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
const result = database
|
||||
.prepare(
|
||||
`insert into BurialSiteTypes (
|
||||
burialSiteType, bodyCapacityMax, crematedCapacityMax,
|
||||
orderNumber,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
)
|
||||
.run(
|
||||
addForm.burialSiteType,
|
||||
addForm.bodyCapacityMax === '' ? undefined : addForm.bodyCapacityMax,
|
||||
addForm.crematedCapacityMax === ''
|
||||
? undefined
|
||||
: addForm.crematedCapacityMax,
|
||||
addForm.orderNumber ?? -1,
|
||||
user.userName,
|
||||
rightNowMillis,
|
||||
user.userName,
|
||||
rightNowMillis
|
||||
)
|
||||
|
||||
database.close()
|
||||
|
||||
clearCacheByTableName('BurialSiteTypes')
|
||||
|
||||
return result.lastInsertRowid as number
|
||||
}
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
export interface AddBurialSiteTypeFieldForm {
|
||||
burialSiteTypeId: string | number;
|
||||
burialSiteTypeId: number | string;
|
||||
burialSiteTypeField: string;
|
||||
fieldType?: string;
|
||||
fieldValues?: string;
|
||||
isRequired?: string;
|
||||
maxLength?: number | string;
|
||||
minLength?: number | string;
|
||||
pattern?: string;
|
||||
minLength?: string | number;
|
||||
maxLength?: string | number;
|
||||
orderNumber?: number;
|
||||
}
|
||||
export default function addBurialSiteTypeField(addForm: AddBurialSiteTypeFieldForm, user: User): Promise<number>;
|
||||
export default function addBurialSiteTypeField(addForm: AddBurialSiteTypeFieldForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function addBurialSiteTypeField(addForm, user) {
|
||||
const database = await acquireConnection();
|
||||
export default function addBurialSiteTypeField(addForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare(`insert into BurialSiteTypeFields (
|
||||
|
|
@ -13,8 +14,10 @@ export default async function addBurialSiteTypeField(addForm, user) {
|
|||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.burialSiteTypeId, addForm.burialSiteTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0, addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.release();
|
||||
.run(addForm.burialSiteTypeId, addForm.burialSiteTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0,
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
||||
addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.close();
|
||||
clearCacheByTableName('BurialSiteTypeFields');
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,29 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export interface AddBurialSiteTypeFieldForm {
|
||||
burialSiteTypeId: string | number
|
||||
burialSiteTypeId: number | string
|
||||
|
||||
burialSiteTypeField: string
|
||||
|
||||
fieldType?: string
|
||||
fieldValues?: string
|
||||
|
||||
isRequired?: string
|
||||
maxLength?: number | string
|
||||
minLength?: number | string
|
||||
pattern?: string
|
||||
minLength?: string | number
|
||||
maxLength?: string | number
|
||||
|
||||
orderNumber?: number
|
||||
}
|
||||
|
||||
export default async function addBurialSiteTypeField(
|
||||
export default function addBurialSiteTypeField(
|
||||
addForm: AddBurialSiteTypeFieldForm,
|
||||
user: User
|
||||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
|
|
@ -42,6 +47,7 @@ export default async function addBurialSiteTypeField(
|
|||
addForm.isRequired === '' ? 0 : 1,
|
||||
addForm.pattern ?? '',
|
||||
addForm.minLength ?? 0,
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
||||
addForm.maxLength ?? 100,
|
||||
addForm.orderNumber ?? -1,
|
||||
user.userName,
|
||||
|
|
@ -50,7 +56,7 @@ export default async function addBurialSiteTypeField(
|
|||
rightNowMillis
|
||||
)
|
||||
|
||||
database.release()
|
||||
database.close()
|
||||
|
||||
clearCacheByTableName('BurialSiteTypeFields')
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
export interface AddCemeteryForm {
|
||||
cemeteryName: string;
|
||||
cemeteryKey: string;
|
||||
import { type UpdateCemeteryDirectionsOfArrivalForm } from './updateCemeteryDirectionsOfArrival.js';
|
||||
export type AddCemeteryForm = UpdateCemeteryDirectionsOfArrivalForm & {
|
||||
cemeteryDescription: string;
|
||||
cemeterySvg: string;
|
||||
cemeteryKey: string;
|
||||
cemeteryName: string;
|
||||
parentCemeteryId: string;
|
||||
cemeteryLatitude: string;
|
||||
cemeteryLongitude: string;
|
||||
cemeterySvg: string;
|
||||
cemeteryAddress1: string;
|
||||
cemeteryAddress2: string;
|
||||
cemeteryCity: string;
|
||||
cemeteryProvince: string;
|
||||
cemeteryPostalCode: string;
|
||||
cemeteryProvince: string;
|
||||
cemeteryPhoneNumber: string;
|
||||
}
|
||||
export default function addCemetery(addForm: AddCemeteryForm, user: User): Promise<number>;
|
||||
};
|
||||
export default function addCemetery(addForm: AddCemeteryForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
export default async function addCemetery(addForm, user) {
|
||||
const database = await acquireConnection();
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import updateCemeteryDirectionsOfArrival from './updateCemeteryDirectionsOfArrival.js';
|
||||
export default function addCemetery(addForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare(`insert into Cemeteries (
|
||||
|
|
@ -9,10 +11,13 @@ export default async function addCemetery(addForm, user) {
|
|||
cemeteryAddress1, cemeteryAddress2,
|
||||
cemeteryCity, cemeteryProvince, cemeteryPostalCode,
|
||||
cemeteryPhoneNumber,
|
||||
parentCemeteryId,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.cemeteryName, addForm.cemeteryKey, addForm.cemeteryDescription, addForm.cemeterySvg, addForm.cemeteryLatitude === '' ? undefined : addForm.cemeteryLatitude, addForm.cemeteryLongitude === '' ? undefined : addForm.cemeteryLongitude, addForm.cemeteryAddress1, addForm.cemeteryAddress2, addForm.cemeteryCity, addForm.cemeteryProvince, addForm.cemeteryPostalCode, addForm.cemeteryPhoneNumber, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.release();
|
||||
return result.lastInsertRowid;
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.cemeteryName, addForm.cemeteryKey, addForm.cemeteryDescription, addForm.cemeterySvg, addForm.cemeteryLatitude === '' ? undefined : addForm.cemeteryLatitude, addForm.cemeteryLongitude === '' ? undefined : addForm.cemeteryLongitude, addForm.cemeteryAddress1, addForm.cemeteryAddress2, addForm.cemeteryCity, addForm.cemeteryProvince, addForm.cemeteryPostalCode, addForm.cemeteryPhoneNumber, addForm.parentCemeteryId === '' ? undefined : addForm.parentCemeteryId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
const cemeteryId = result.lastInsertRowid;
|
||||
updateCemeteryDirectionsOfArrival(cemeteryId, addForm, database);
|
||||
database.close();
|
||||
return cemeteryId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,35 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
export interface AddCemeteryForm {
|
||||
cemeteryName: string
|
||||
cemeteryKey: string
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
import updateCemeteryDirectionsOfArrival, {
|
||||
type UpdateCemeteryDirectionsOfArrivalForm
|
||||
} from './updateCemeteryDirectionsOfArrival.js'
|
||||
|
||||
export type AddCemeteryForm = UpdateCemeteryDirectionsOfArrivalForm & {
|
||||
cemeteryDescription: string
|
||||
cemeteryKey: string
|
||||
cemeteryName: string
|
||||
parentCemeteryId: string
|
||||
|
||||
cemeterySvg: string
|
||||
cemeteryLatitude: string
|
||||
cemeteryLongitude: string
|
||||
cemeterySvg: string
|
||||
|
||||
cemeteryAddress1: string
|
||||
cemeteryAddress2: string
|
||||
cemeteryCity: string
|
||||
cemeteryProvince: string
|
||||
cemeteryPostalCode: string
|
||||
cemeteryProvince: string
|
||||
|
||||
cemeteryPhoneNumber: string
|
||||
}
|
||||
|
||||
export default async function addCemetery(
|
||||
export default function addCemetery(
|
||||
addForm: AddCemeteryForm,
|
||||
user: User
|
||||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
|
|
@ -33,9 +41,10 @@ export default async function addCemetery(
|
|||
cemeteryAddress1, cemeteryAddress2,
|
||||
cemeteryCity, cemeteryProvince, cemeteryPostalCode,
|
||||
cemeteryPhoneNumber,
|
||||
parentCemeteryId,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
)
|
||||
.run(
|
||||
addForm.cemeteryName,
|
||||
|
|
@ -50,13 +59,18 @@ export default async function addCemetery(
|
|||
addForm.cemeteryProvince,
|
||||
addForm.cemeteryPostalCode,
|
||||
addForm.cemeteryPhoneNumber,
|
||||
addForm.parentCemeteryId === '' ? undefined : addForm.parentCemeteryId,
|
||||
user.userName,
|
||||
rightNowMillis,
|
||||
user.userName,
|
||||
rightNowMillis
|
||||
)
|
||||
|
||||
database.release()
|
||||
const cemeteryId = result.lastInsertRowid as number
|
||||
|
||||
return result.lastInsertRowid as number
|
||||
updateCemeteryDirectionsOfArrival(cemeteryId, addForm, database)
|
||||
|
||||
database.close()
|
||||
|
||||
return cemeteryId
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
export interface AddForm {
|
||||
committalType: string;
|
||||
committalTypeKey?: string;
|
||||
orderNumber?: number | string;
|
||||
}
|
||||
export default function addCommittalType(addForm: AddForm, user: User): number;
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
export default function addCommittalType(addForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare(`insert into CommittalTypes (
|
||||
committalType, committalTypeKey, orderNumber,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.committalType, addForm.committalTypeKey ?? '', addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.close();
|
||||
clearCacheByTableName('CommittalTypes');
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
|
||||
export interface AddForm {
|
||||
committalType: string
|
||||
committalTypeKey?: string
|
||||
orderNumber?: number | string
|
||||
}
|
||||
|
||||
export default function addCommittalType(addForm: AddForm, user: User): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
const result = database
|
||||
.prepare(
|
||||
`insert into CommittalTypes (
|
||||
committalType, committalTypeKey, orderNumber,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?)`
|
||||
)
|
||||
.run(
|
||||
addForm.committalType,
|
||||
addForm.committalTypeKey ?? '',
|
||||
addForm.orderNumber ?? -1,
|
||||
user.userName,
|
||||
rightNowMillis,
|
||||
user.userName,
|
||||
rightNowMillis
|
||||
)
|
||||
|
||||
database.close()
|
||||
|
||||
clearCacheByTableName('CommittalTypes')
|
||||
|
||||
return result.lastInsertRowid as number
|
||||
}
|
||||
|
|
@ -1,36 +1,39 @@
|
|||
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
||||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import sqlite from 'better-sqlite3';
|
||||
export interface AddContractForm {
|
||||
contractTypeId: string | number;
|
||||
burialSiteId: string | number;
|
||||
contractStartDateString: DateString | '';
|
||||
contractEndDateString: DateString | '';
|
||||
contractTypeFieldIds?: string;
|
||||
burialSiteId: number | string;
|
||||
contractEndDateString: '' | DateString;
|
||||
contractStartDateString: '' | DateString;
|
||||
contractTypeId: number | string;
|
||||
[fieldValue_contractTypeFieldId: `fieldValue_${string}`]: unknown;
|
||||
purchaserName?: string;
|
||||
contractTypeFieldIds?: string;
|
||||
committalTypeId?: number | string;
|
||||
directionOfArrival?: string;
|
||||
funeralDateString?: '' | DateString;
|
||||
funeralDirectorName?: string;
|
||||
funeralHomeId?: number | string;
|
||||
funeralTimeString?: '' | TimeString;
|
||||
purchaserAddress1?: string;
|
||||
purchaserAddress2?: string;
|
||||
purchaserCity?: string;
|
||||
purchaserProvince?: string;
|
||||
purchaserPostalCode?: string;
|
||||
purchaserPhoneNumber?: string;
|
||||
purchaserEmail?: string;
|
||||
purchaserName?: string;
|
||||
purchaserPhoneNumber?: string;
|
||||
purchaserPostalCode?: string;
|
||||
purchaserProvince?: string;
|
||||
purchaserRelationship?: string;
|
||||
funeralHomeId?: string | number;
|
||||
funeralDirectorName?: string;
|
||||
funeralDateString?: DateString | '';
|
||||
funeralTimeString?: TimeString | '';
|
||||
committalTypeId?: string | number;
|
||||
deceasedName?: string;
|
||||
birthDateString?: '' | DateString;
|
||||
birthPlace?: string;
|
||||
deathAge?: string;
|
||||
deathAgePeriod?: string;
|
||||
deathDateString?: '' | DateString;
|
||||
deathPlace?: string;
|
||||
deceasedAddress1?: string;
|
||||
deceasedAddress2?: string;
|
||||
deceasedCity?: string;
|
||||
deceasedProvince?: string;
|
||||
deceasedName?: string;
|
||||
deceasedPostalCode?: string;
|
||||
birthDateString?: DateString | '';
|
||||
birthPlace?: string;
|
||||
deathDateString?: DateString | '';
|
||||
deathPlace?: string;
|
||||
intermentContainerTypeId?: string | number;
|
||||
deceasedProvince?: string;
|
||||
intermentContainerTypeId?: number | string;
|
||||
}
|
||||
export default function addContract(addForm: AddContractForm, user: User, connectedDatabase?: PoolConnection): Promise<number>;
|
||||
export default function addContract(addForm: AddContractForm, user: User, connectedDatabase?: sqlite.Database): number;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
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 { acquireConnection } from './pool.js';
|
||||
// eslint-disable-next-line complexity
|
||||
export default async function addContract(addForm, user, connectedDatabase) {
|
||||
const database = connectedDatabase ?? (await acquireConnection());
|
||||
export default function addContract(addForm, user, connectedDatabase) {
|
||||
const database = connectedDatabase ?? sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const contractStartDate = dateStringToInteger(addForm.contractStartDateString);
|
||||
const result = database
|
||||
|
|
@ -15,17 +16,17 @@ export default async function addContract(addForm, user, connectedDatabase) {
|
|||
purchaserPhoneNumber, purchaserEmail, purchaserRelationship,
|
||||
funeralHomeId, funeralDirectorName,
|
||||
funeralDate, funeralTime,
|
||||
committalTypeId,
|
||||
directionOfArrival, committalTypeId,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.contractTypeId, addForm.burialSiteId === '' ? undefined : addForm.burialSiteId, contractStartDate, addForm.contractEndDateString === ''
|
||||
? undefined
|
||||
: dateStringToInteger(addForm.contractEndDateString), addForm.purchaserName ?? '', addForm.purchaserAddress1 ?? '', addForm.purchaserAddress2 ?? '', addForm.purchaserCity ?? '', addForm.purchaserProvince ?? '', addForm.purchaserPostalCode ?? '', addForm.purchaserPhoneNumber ?? '', addForm.purchaserEmail ?? '', addForm.purchaserRelationship ?? '', addForm.funeralHomeId === '' ? undefined : addForm.funeralHomeId, addForm.funeralDirectorName ?? '', addForm.funeralDateString === ''
|
||||
? undefined
|
||||
: dateStringToInteger(addForm.funeralDateString), addForm.funeralTimeString === ''
|
||||
? undefined
|
||||
: timeStringToInteger(addForm.funeralTimeString), addForm.committalTypeId === '' ? undefined : addForm.committalTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
: timeStringToInteger(addForm.funeralTimeString), addForm.directionOfArrival ?? '', addForm.committalTypeId === '' ? undefined : addForm.committalTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
const contractId = result.lastInsertRowid;
|
||||
/*
|
||||
* Add contract fields
|
||||
|
|
@ -34,7 +35,7 @@ export default async function addContract(addForm, user, connectedDatabase) {
|
|||
for (const contractTypeFieldId of contractTypeFieldIds) {
|
||||
const fieldValue = addForm[`fieldValue_${contractTypeFieldId}`];
|
||||
if ((fieldValue ?? '') !== '') {
|
||||
await addOrUpdateContractField({
|
||||
addOrUpdateContractField({
|
||||
contractId,
|
||||
contractTypeFieldId,
|
||||
fieldValue: fieldValue ?? ''
|
||||
|
|
@ -52,20 +53,21 @@ export default async function addContract(addForm, user, connectedDatabase) {
|
|||
deceasedCity, deceasedProvince, deceasedPostalCode,
|
||||
birthDate, deathDate,
|
||||
birthPlace, deathPlace,
|
||||
deathAge, deathAgePeriod,
|
||||
intermentContainerTypeId,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(contractId, 1, addForm.deceasedName ?? '', addForm.deceasedAddress1 ?? '', addForm.deceasedAddress2 ?? '', addForm.deceasedCity ?? '', addForm.deceasedProvince ?? '', addForm.deceasedPostalCode ?? '', addForm.birthDateString === ''
|
||||
? undefined
|
||||
: dateStringToInteger(addForm.birthDateString), addForm.deathDateString === ''
|
||||
? undefined
|
||||
: dateStringToInteger(addForm.deathDateString), addForm.birthPlace ?? '', addForm.deathPlace ?? '', addForm.intermentContainerTypeId === ''
|
||||
: dateStringToInteger(addForm.deathDateString), addForm.birthPlace ?? '', addForm.deathPlace ?? '', addForm.deathAge ?? undefined, addForm.deathAgePeriod ?? '', addForm.intermentContainerTypeId === ''
|
||||
? undefined
|
||||
: addForm.intermentContainerTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
}
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release();
|
||||
database.close();
|
||||
}
|
||||
return contractId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,58 +4,60 @@ import {
|
|||
dateStringToInteger,
|
||||
timeStringToInteger
|
||||
} from '@cityssm/utils-datetime'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
import addOrUpdateContractField from './addOrUpdateContractField.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export interface AddContractForm {
|
||||
contractTypeId: string | number
|
||||
burialSiteId: string | number
|
||||
burialSiteId: number | string
|
||||
contractEndDateString: '' | DateString
|
||||
contractStartDateString: '' | DateString
|
||||
contractTypeId: number | string
|
||||
|
||||
contractStartDateString: DateString | ''
|
||||
contractEndDateString: DateString | ''
|
||||
|
||||
contractTypeFieldIds?: string
|
||||
[fieldValue_contractTypeFieldId: `fieldValue_${string}`]: unknown
|
||||
contractTypeFieldIds?: string
|
||||
|
||||
committalTypeId?: number | string
|
||||
directionOfArrival?: string
|
||||
funeralDateString?: '' | DateString
|
||||
funeralDirectorName?: string
|
||||
funeralHomeId?: number | string
|
||||
funeralTimeString?: '' | TimeString
|
||||
|
||||
purchaserName?: string
|
||||
purchaserAddress1?: string
|
||||
purchaserAddress2?: string
|
||||
purchaserCity?: string
|
||||
purchaserProvince?: string
|
||||
purchaserPostalCode?: string
|
||||
purchaserPhoneNumber?: string
|
||||
purchaserEmail?: string
|
||||
purchaserName?: string
|
||||
purchaserPhoneNumber?: string
|
||||
purchaserPostalCode?: string
|
||||
purchaserProvince?: string
|
||||
purchaserRelationship?: string
|
||||
|
||||
funeralHomeId?: string | number
|
||||
funeralDirectorName?: string
|
||||
funeralDateString?: DateString | ''
|
||||
funeralTimeString?: TimeString | ''
|
||||
committalTypeId?: string | number
|
||||
|
||||
deceasedName?: string
|
||||
birthDateString?: '' | DateString
|
||||
birthPlace?: string
|
||||
deathAge?: string
|
||||
deathAgePeriod?: string
|
||||
deathDateString?: '' | DateString
|
||||
deathPlace?: string
|
||||
deceasedAddress1?: string
|
||||
deceasedAddress2?: string
|
||||
deceasedCity?: string
|
||||
deceasedProvince?: string
|
||||
deceasedName?: string
|
||||
deceasedPostalCode?: string
|
||||
|
||||
birthDateString?: DateString | ''
|
||||
birthPlace?: string
|
||||
deathDateString?: DateString | ''
|
||||
deathPlace?: string
|
||||
intermentContainerTypeId?: string | number
|
||||
deceasedProvince?: string
|
||||
intermentContainerTypeId?: number | string
|
||||
}
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
export default async function addContract(
|
||||
export default function addContract(
|
||||
addForm: AddContractForm,
|
||||
user: User,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<number> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
connectedDatabase?: sqlite.Database
|
||||
): number {
|
||||
const database = connectedDatabase ?? sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
|
|
@ -73,10 +75,10 @@ export default async function addContract(
|
|||
purchaserPhoneNumber, purchaserEmail, purchaserRelationship,
|
||||
funeralHomeId, funeralDirectorName,
|
||||
funeralDate, funeralTime,
|
||||
committalTypeId,
|
||||
directionOfArrival, committalTypeId,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
)
|
||||
.run(
|
||||
addForm.contractTypeId,
|
||||
|
|
@ -102,6 +104,7 @@ export default async function addContract(
|
|||
addForm.funeralTimeString === ''
|
||||
? undefined
|
||||
: timeStringToInteger(addForm.funeralTimeString as TimeString),
|
||||
addForm.directionOfArrival ?? '',
|
||||
addForm.committalTypeId === '' ? undefined : addForm.committalTypeId,
|
||||
user.userName,
|
||||
rightNowMillis,
|
||||
|
|
@ -123,7 +126,7 @@ export default async function addContract(
|
|||
| undefined
|
||||
|
||||
if ((fieldValue ?? '') !== '') {
|
||||
await addOrUpdateContractField(
|
||||
addOrUpdateContractField(
|
||||
{
|
||||
contractId,
|
||||
contractTypeFieldId,
|
||||
|
|
@ -148,10 +151,11 @@ export default async function addContract(
|
|||
deceasedCity, deceasedProvince, deceasedPostalCode,
|
||||
birthDate, deathDate,
|
||||
birthPlace, deathPlace,
|
||||
deathAge, deathAgePeriod,
|
||||
intermentContainerTypeId,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
)
|
||||
|
||||
.run(
|
||||
|
|
@ -171,6 +175,8 @@ export default async function addContract(
|
|||
: dateStringToInteger(addForm.deathDateString as DateString),
|
||||
addForm.birthPlace ?? '',
|
||||
addForm.deathPlace ?? '',
|
||||
addForm.deathAge ?? undefined,
|
||||
addForm.deathAgePeriod ?? '',
|
||||
addForm.intermentContainerTypeId === ''
|
||||
? undefined
|
||||
: addForm.intermentContainerTypeId,
|
||||
|
|
@ -182,7 +188,7 @@ export default async function addContract(
|
|||
}
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
database.close()
|
||||
}
|
||||
|
||||
return contractId
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
||||
export interface AddContractCommentForm {
|
||||
contractId: string | number;
|
||||
contractId: number | string;
|
||||
comment: string;
|
||||
commentDateString?: DateString;
|
||||
commentTimeString?: TimeString;
|
||||
comment: string;
|
||||
}
|
||||
export default function addContractComment(commentForm: AddContractCommentForm, user: User): Promise<number>;
|
||||
export default function addContractComment(commentForm: AddContractCommentForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/utils-datetime';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function addContractComment(commentForm, user) {
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
export default function addContractComment(commentForm, user) {
|
||||
const rightNow = new Date();
|
||||
let commentDate = 0;
|
||||
let commentTime = 0;
|
||||
|
|
@ -12,7 +13,7 @@ export default async function addContractComment(commentForm, user) {
|
|||
commentDate = dateStringToInteger(commentForm.commentDateString);
|
||||
commentTime = timeStringToInteger(commentForm.commentTimeString);
|
||||
}
|
||||
const database = await acquireConnection();
|
||||
const database = sqlite(sunriseDB);
|
||||
const result = database
|
||||
.prepare(`insert into ContractComments (
|
||||
contractId,
|
||||
|
|
@ -22,6 +23,6 @@ export default async function addContractComment(commentForm, user) {
|
|||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(commentForm.contractId, commentDate, commentTime ?? 0, commentForm.comment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime());
|
||||
database.release();
|
||||
database.close();
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,20 +6,22 @@ import {
|
|||
dateToTimeInteger,
|
||||
timeStringToInteger
|
||||
} from '@cityssm/utils-datetime'
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
export interface AddContractCommentForm {
|
||||
contractId: string | number
|
||||
contractId: number | string
|
||||
|
||||
comment: string
|
||||
commentDateString?: DateString
|
||||
commentTimeString?: TimeString
|
||||
comment: string
|
||||
}
|
||||
|
||||
export default async function addContractComment(
|
||||
export default function addContractComment(
|
||||
commentForm: AddContractCommentForm,
|
||||
user: User
|
||||
): Promise<number> {
|
||||
): number {
|
||||
const rightNow = new Date()
|
||||
|
||||
let commentDate = 0
|
||||
|
|
@ -37,7 +39,7 @@ export default async function addContractComment(
|
|||
)
|
||||
}
|
||||
|
||||
const database = await acquireConnection()
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const result = database
|
||||
.prepare(
|
||||
|
|
@ -60,7 +62,7 @@ export default async function addContractComment(
|
|||
rightNow.getTime()
|
||||
)
|
||||
|
||||
database.release()
|
||||
database.close()
|
||||
|
||||
return result.lastInsertRowid as number
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import sqlite from 'better-sqlite3';
|
||||
export interface AddContractFeeForm {
|
||||
contractId: number | string;
|
||||
feeId: number | string;
|
||||
quantity: number | string;
|
||||
feeAmount?: number | string;
|
||||
quantity: number | string;
|
||||
taxAmount?: number | string;
|
||||
}
|
||||
export default function addContractFee(addFeeForm: AddContractFeeForm, user: User, connectedDatabase?: PoolConnection): Promise<boolean>;
|
||||
export default function addContractFee(addFeeForm: AddContractFeeForm, user: User, connectedDatabase?: sqlite.Database): Promise<boolean>;
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import { calculateFeeAmount, calculateTaxAmount } from '../helpers/functions.fee.js';
|
||||
import getContract from './getContract.js';
|
||||
import getFee from './getFee.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function addContractFee(addFeeForm, user, connectedDatabase) {
|
||||
const database = connectedDatabase ?? (await acquireConnection());
|
||||
const database = connectedDatabase ?? sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
// Calculate fee and tax (if not set)
|
||||
let feeAmount;
|
||||
let taxAmount;
|
||||
if ((addFeeForm.feeAmount ?? '') === '') {
|
||||
const contract = (await getContract(addFeeForm.contractId));
|
||||
const fee = (await getFee(addFeeForm.feeId));
|
||||
const fee = getFee(addFeeForm.feeId);
|
||||
feeAmount = calculateFeeAmount(fee, contract);
|
||||
taxAmount = calculateTaxAmount(fee, feeAmount);
|
||||
}
|
||||
|
|
@ -83,7 +84,7 @@ export default async function addContractFee(addFeeForm, user, connectedDatabase
|
|||
}
|
||||
finally {
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release();
|
||||
database.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,30 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
import {
|
||||
calculateFeeAmount,
|
||||
calculateTaxAmount
|
||||
} from '../helpers/functions.fee.js'
|
||||
import type { Contract, Fee } from '../types/recordTypes.js'
|
||||
import type { Contract, Fee } from '../types/record.types.js'
|
||||
|
||||
import getContract from './getContract.js'
|
||||
import getFee from './getFee.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export interface AddContractFeeForm {
|
||||
contractId: number | string
|
||||
feeId: number | string
|
||||
quantity: number | string
|
||||
|
||||
feeAmount?: number | string
|
||||
quantity: number | string
|
||||
taxAmount?: number | string
|
||||
}
|
||||
|
||||
export default async function addContractFee(
|
||||
addFeeForm: AddContractFeeForm,
|
||||
user: User,
|
||||
connectedDatabase?: PoolConnection
|
||||
connectedDatabase?: sqlite.Database
|
||||
): Promise<boolean> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
const database = connectedDatabase ?? sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
|
|
@ -32,11 +33,9 @@ export default async function addContractFee(
|
|||
let taxAmount: number
|
||||
|
||||
if ((addFeeForm.feeAmount ?? '') === '') {
|
||||
const contract = (await getContract(
|
||||
addFeeForm.contractId
|
||||
)) as Contract
|
||||
const contract = (await getContract(addFeeForm.contractId)) as Contract
|
||||
|
||||
const fee = (await getFee(addFeeForm.feeId)) as Fee
|
||||
const fee = getFee(addFeeForm.feeId) as Fee
|
||||
|
||||
feeAmount = calculateFeeAmount(fee, contract)
|
||||
taxAmount = calculateTaxAmount(fee, feeAmount)
|
||||
|
|
@ -64,6 +63,7 @@ export default async function addContractFee(
|
|||
| {
|
||||
feeAmount: number | null
|
||||
taxAmount: number | null
|
||||
|
||||
recordDelete_timeMillis: number | null
|
||||
}
|
||||
| undefined
|
||||
|
|
@ -155,7 +155,7 @@ export default async function addContractFee(
|
|||
return result.changes > 0
|
||||
} finally {
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
database.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import addContractFee from './addContractFee.js';
|
||||
import { getFeeCategory } from './getFeeCategories.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function addContractFeeCategory(addFeeCategoryForm, user) {
|
||||
const database = await acquireConnection();
|
||||
const feeCategory = await getFeeCategory(addFeeCategoryForm.feeCategoryId, database);
|
||||
const database = sqlite(sunriseDB);
|
||||
const feeCategory = getFeeCategory(addFeeCategoryForm.feeCategoryId, database);
|
||||
let addedFeeCount = 0;
|
||||
for (const fee of feeCategory?.fees ?? []) {
|
||||
const success = await addContractFee({
|
||||
|
|
@ -15,6 +16,6 @@ export default async function addContractFeeCategory(addFeeCategoryForm, user) {
|
|||
addedFeeCount += 1;
|
||||
}
|
||||
}
|
||||
database.release();
|
||||
database.close();
|
||||
return addedFeeCount;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
import addContractFee from './addContractFee.js'
|
||||
import { getFeeCategory } from './getFeeCategories.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export interface AddContractCategoryForm {
|
||||
contractId: number | string
|
||||
|
|
@ -11,12 +14,9 @@ export default async function addContractFeeCategory(
|
|||
addFeeCategoryForm: AddContractCategoryForm,
|
||||
user: User
|
||||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const feeCategory = await getFeeCategory(
|
||||
addFeeCategoryForm.feeCategoryId,
|
||||
database
|
||||
)
|
||||
const feeCategory = getFeeCategory(addFeeCategoryForm.feeCategoryId, database)
|
||||
|
||||
let addedFeeCount = 0
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ export default async function addContractFeeCategory(
|
|||
}
|
||||
}
|
||||
|
||||
database.release()
|
||||
database.close()
|
||||
|
||||
return addedFeeCount
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,19 @@
|
|||
import { type DateString } from '@cityssm/utils-datetime';
|
||||
import sqlite from 'better-sqlite3';
|
||||
export interface AddForm {
|
||||
contractId: string | number;
|
||||
contractId: number | string;
|
||||
deceasedName: string;
|
||||
deceasedAddress1: string;
|
||||
deceasedAddress2: string;
|
||||
deceasedCity: string;
|
||||
deceasedProvince: string;
|
||||
deceasedPostalCode: string;
|
||||
birthDateString: DateString | '';
|
||||
deceasedProvince: string;
|
||||
birthDateString: '' | DateString;
|
||||
birthPlace: string;
|
||||
deathDateString: DateString | '';
|
||||
deathDateString: '' | DateString;
|
||||
deathPlace: string;
|
||||
intermentContainerTypeId: string | number;
|
||||
deathAge: number | string;
|
||||
deathAgePeriod: string;
|
||||
intermentContainerTypeId: number | string;
|
||||
}
|
||||
export default function addContractInterment(contractForm: AddForm, user: User): Promise<number>;
|
||||
export default function addContractInterment(contractForm: AddForm, user: User, connectedDatabase?: sqlite.Database): number;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import { dateStringToInteger } from '@cityssm/utils-datetime';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function addContractInterment(contractForm, user) {
|
||||
const database = await acquireConnection();
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
export default function addContractInterment(contractForm, user, connectedDatabase) {
|
||||
const database = connectedDatabase ?? sqlite(sunriseDB);
|
||||
const maxIntermentNumber = (database
|
||||
.prepare(`select max(intermentNumber) as maxIntermentNumber
|
||||
from ContractInterments
|
||||
where contractId = ?`)
|
||||
from ContractInterments
|
||||
where contractId = ?`)
|
||||
.pluck()
|
||||
.get(contractForm.contractId) ?? 0);
|
||||
const newIntermentNumber = maxIntermentNumber + 1;
|
||||
|
|
@ -25,6 +26,8 @@ export default async function addContractInterment(contractForm, user) {
|
|||
: dateStringToInteger(contractForm.deathDateString), contractForm.deathPlace, contractForm.intermentContainerTypeId === ''
|
||||
? undefined
|
||||
: contractForm.intermentContainerTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.release();
|
||||
if (connectedDatabase === undefined) {
|
||||
database.close();
|
||||
}
|
||||
return newIntermentNumber;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,33 +1,42 @@
|
|||
import { type DateString, dateStringToInteger } from '@cityssm/utils-datetime'
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
export interface AddForm {
|
||||
contractId: string | number
|
||||
contractId: number | string
|
||||
|
||||
deceasedName: string
|
||||
|
||||
deceasedAddress1: string
|
||||
deceasedAddress2: string
|
||||
deceasedCity: string
|
||||
deceasedProvince: string
|
||||
deceasedPostalCode: string
|
||||
birthDateString: DateString | ''
|
||||
deceasedProvince: string
|
||||
|
||||
birthDateString: '' | DateString
|
||||
birthPlace: string
|
||||
deathDateString: DateString | ''
|
||||
deathDateString: '' | DateString
|
||||
deathPlace: string
|
||||
intermentContainerTypeId: string | number
|
||||
|
||||
deathAge: number | string
|
||||
deathAgePeriod: string
|
||||
|
||||
intermentContainerTypeId: number | string
|
||||
}
|
||||
|
||||
export default async function addContractInterment(
|
||||
export default function addContractInterment(
|
||||
contractForm: AddForm,
|
||||
user: User
|
||||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
user: User,
|
||||
connectedDatabase?: sqlite.Database
|
||||
): number {
|
||||
const database = connectedDatabase ?? sqlite(sunriseDB)
|
||||
|
||||
const maxIntermentNumber = (database
|
||||
.prepare(
|
||||
`select max(intermentNumber) as maxIntermentNumber
|
||||
from ContractInterments
|
||||
where contractId = ?`
|
||||
from ContractInterments
|
||||
where contractId = ?`
|
||||
)
|
||||
.pluck()
|
||||
.get(contractForm.contractId) ?? 0) as number
|
||||
|
|
@ -71,7 +80,9 @@ export default async function addContractInterment(
|
|||
rightNowMillis
|
||||
)
|
||||
|
||||
database.release()
|
||||
if (connectedDatabase === undefined) {
|
||||
database.close()
|
||||
}
|
||||
|
||||
return newIntermentNumber
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
||||
export interface AddTransactionForm {
|
||||
contractId: string | number;
|
||||
transactionDateString?: string;
|
||||
transactionTimeString?: string;
|
||||
transactionAmount: string | number;
|
||||
contractId: number | string;
|
||||
transactionDateString?: '' | DateString;
|
||||
transactionTimeString?: '' | TimeString;
|
||||
externalReceiptNumber: string;
|
||||
transactionAmount: number | string;
|
||||
transactionNote: string;
|
||||
}
|
||||
export default function addContractTransaction(contractTransactionForm: AddTransactionForm, user: User): Promise<number>;
|
||||
export default function addContractTransaction(contractTransactionForm: AddTransactionForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/utils-datetime';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function addContractTransaction(contractTransactionForm, user) {
|
||||
const database = await acquireConnection();
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
export default function addContractTransaction(contractTransactionForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
let transactionIndex = 0;
|
||||
const maxIndexResult = database
|
||||
.prepare(`select transactionIndex
|
||||
|
|
@ -14,12 +15,12 @@ export default async function addContractTransaction(contractTransactionForm, us
|
|||
transactionIndex = maxIndexResult.transactionIndex + 1;
|
||||
}
|
||||
const rightNow = new Date();
|
||||
const transactionDate = contractTransactionForm.transactionDateString
|
||||
? dateStringToInteger(contractTransactionForm.transactionDateString)
|
||||
: dateToInteger(rightNow);
|
||||
const transactionTime = contractTransactionForm.transactionTimeString
|
||||
? timeStringToInteger(contractTransactionForm.transactionTimeString)
|
||||
: dateToTimeInteger(rightNow);
|
||||
const transactionDate = (contractTransactionForm.transactionDateString ?? '') === ''
|
||||
? dateToInteger(rightNow)
|
||||
: dateStringToInteger(contractTransactionForm.transactionDateString);
|
||||
const transactionTime = (contractTransactionForm.transactionTimeString ?? '') === ''
|
||||
? dateToTimeInteger(rightNow)
|
||||
: timeStringToInteger(contractTransactionForm.transactionTimeString);
|
||||
database
|
||||
.prepare(`insert into ContractTransactions (
|
||||
contractId, transactionIndex,
|
||||
|
|
@ -29,6 +30,6 @@ export default async function addContractTransaction(contractTransactionForm, us
|
|||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(contractTransactionForm.contractId, transactionIndex, transactionDate, transactionTime, contractTransactionForm.transactionAmount, contractTransactionForm.externalReceiptNumber, contractTransactionForm.transactionNote, user.userName, rightNow.getTime(), user.userName, rightNow.getTime());
|
||||
database.release();
|
||||
database.close();
|
||||
return transactionIndex;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +1,31 @@
|
|||
import {
|
||||
type DateString,
|
||||
type TimeString,
|
||||
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 interface AddTransactionForm {
|
||||
contractId: string | number
|
||||
transactionDateString?: string
|
||||
transactionTimeString?: string
|
||||
transactionAmount: string | number
|
||||
contractId: number | string
|
||||
|
||||
transactionDateString?: '' | DateString
|
||||
transactionTimeString?: '' | TimeString
|
||||
|
||||
externalReceiptNumber: string
|
||||
transactionAmount: number | string
|
||||
transactionNote: string
|
||||
}
|
||||
|
||||
export default async function addContractTransaction(
|
||||
export default function addContractTransaction(
|
||||
contractTransactionForm: AddTransactionForm,
|
||||
user: User
|
||||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
let transactionIndex = 0
|
||||
|
||||
|
|
@ -42,13 +47,19 @@ export default async function addContractTransaction(
|
|||
|
||||
const rightNow = new Date()
|
||||
|
||||
const transactionDate = contractTransactionForm.transactionDateString
|
||||
? dateStringToInteger(contractTransactionForm.transactionDateString)
|
||||
: dateToInteger(rightNow)
|
||||
const transactionDate =
|
||||
(contractTransactionForm.transactionDateString ?? '') === ''
|
||||
? dateToInteger(rightNow)
|
||||
: dateStringToInteger(
|
||||
contractTransactionForm.transactionDateString as DateString
|
||||
)
|
||||
|
||||
const transactionTime = contractTransactionForm.transactionTimeString
|
||||
? timeStringToInteger(contractTransactionForm.transactionTimeString)
|
||||
: dateToTimeInteger(rightNow)
|
||||
const transactionTime =
|
||||
(contractTransactionForm.transactionTimeString ?? '') === ''
|
||||
? dateToTimeInteger(rightNow)
|
||||
: timeStringToInteger(
|
||||
contractTransactionForm.transactionTimeString as TimeString
|
||||
)
|
||||
|
||||
database
|
||||
.prepare(
|
||||
|
|
@ -74,7 +85,7 @@ export default async function addContractTransaction(
|
|||
rightNow.getTime()
|
||||
)
|
||||
|
||||
database.release()
|
||||
database.close()
|
||||
|
||||
return transactionIndex
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@ export interface AddForm {
|
|||
isPreneed?: string;
|
||||
orderNumber?: number;
|
||||
}
|
||||
export default function addContractType(addForm: AddForm, user: User): Promise<number>;
|
||||
export default function addContractType(addForm: AddForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function addContractType(addForm, user) {
|
||||
const database = await acquireConnection();
|
||||
export default function addContractType(addForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare(`insert into ContractTypes (
|
||||
|
|
@ -10,7 +11,7 @@ export default async function addContractType(addForm, user) {
|
|||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.contractType, addForm.isPreneed === undefined ? 0 : 1, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.release();
|
||||
database.close();
|
||||
clearCacheByTableName('ContractTypes');
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
|
||||
export interface AddForm {
|
||||
contractType: string
|
||||
|
|
@ -8,11 +9,8 @@ export interface AddForm {
|
|||
orderNumber?: number
|
||||
}
|
||||
|
||||
export default async function addContractType(
|
||||
addForm: AddForm,
|
||||
user: User
|
||||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
export default function addContractType(addForm: AddForm, user: User): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
|
|
@ -34,7 +32,7 @@ export default async function addContractType(
|
|||
rightNowMillis
|
||||
)
|
||||
|
||||
database.release()
|
||||
database.close()
|
||||
|
||||
clearCacheByTableName('ContractTypes')
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
export interface AddContractTypeFieldForm {
|
||||
contractTypeId?: string | number;
|
||||
contractTypeId?: number | string;
|
||||
contractTypeField: string;
|
||||
fieldValues?: string;
|
||||
fieldType?: string;
|
||||
fieldValues?: string;
|
||||
isRequired?: string;
|
||||
maxLength?: number | string;
|
||||
minLength?: number | string;
|
||||
pattern?: string;
|
||||
minLength?: string | number;
|
||||
maxLength?: string | number;
|
||||
orderNumber?: number;
|
||||
}
|
||||
export default function addContractTypeField(addForm: AddContractTypeFieldForm, user: User): Promise<number>;
|
||||
export default function addContractTypeField(addForm: AddContractTypeFieldForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function addContractTypeField(addForm, user) {
|
||||
const database = await acquireConnection();
|
||||
export default function addContractTypeField(addForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare(`insert into ContractTypeFields (
|
||||
|
|
@ -12,8 +13,10 @@ export default async function addContractTypeField(addForm, user) {
|
|||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.contractTypeId ?? undefined, addForm.contractTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0, addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.release();
|
||||
.run(addForm.contractTypeId ?? undefined, addForm.contractTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0,
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
||||
addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.close();
|
||||
clearCacheByTableName('ContractTypeFields');
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,28 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export interface AddContractTypeFieldForm {
|
||||
contractTypeId?: string | number
|
||||
contractTypeId?: number | string
|
||||
|
||||
contractTypeField: string
|
||||
fieldValues?: string
|
||||
|
||||
fieldType?: string
|
||||
fieldValues?: string
|
||||
isRequired?: string
|
||||
maxLength?: number | string
|
||||
minLength?: number | string
|
||||
pattern?: string
|
||||
minLength?: string | number
|
||||
maxLength?: string | number
|
||||
|
||||
orderNumber?: number
|
||||
}
|
||||
|
||||
export default async function addContractTypeField(
|
||||
export default function addContractTypeField(
|
||||
addForm: AddContractTypeFieldForm,
|
||||
user: User
|
||||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
|
|
@ -41,6 +45,7 @@ export default async function addContractTypeField(
|
|||
addForm.isRequired === '' ? 0 : 1,
|
||||
addForm.pattern ?? '',
|
||||
addForm.minLength ?? 0,
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
||||
addForm.maxLength ?? 100,
|
||||
addForm.orderNumber ?? -1,
|
||||
user.userName,
|
||||
|
|
@ -49,7 +54,7 @@ export default async function addContractTypeField(
|
|||
rightNowMillis
|
||||
)
|
||||
|
||||
database.release()
|
||||
database.close()
|
||||
|
||||
clearCacheByTableName('ContractTypeFields')
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
export interface AddContractTypePrintForm {
|
||||
contractTypeId: string | number;
|
||||
contractTypeId: number | string;
|
||||
printEJS: string;
|
||||
orderNumber?: number;
|
||||
}
|
||||
export default function addContractTypePrint(addForm: AddContractTypePrintForm, user: User): Promise<boolean>;
|
||||
export default function addContractTypePrint(addForm: AddContractTypePrintForm, user: User): boolean;
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function addContractTypePrint(addForm, user) {
|
||||
const database = await acquireConnection();
|
||||
export default function addContractTypePrint(addForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
let result = database
|
||||
.prepare(`update ContractTypePrints
|
||||
set recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
where contractTypeId = ?
|
||||
and printEJS = ?`)
|
||||
and printEJS = ?`)
|
||||
.run(user.userName, rightNowMillis, addForm.contractTypeId, addForm.printEJS);
|
||||
if (result.changes === 0) {
|
||||
result = database
|
||||
|
|
@ -21,7 +22,7 @@ export default async function addContractTypePrint(addForm, user) {
|
|||
values (?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.contractTypeId, addForm.printEJS, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
}
|
||||
database.release();
|
||||
database.close();
|
||||
clearCacheByTableName('ContractTypePrints');
|
||||
return result.changes > 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,20 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export interface AddContractTypePrintForm {
|
||||
contractTypeId: string | number
|
||||
contractTypeId: number | string
|
||||
printEJS: string
|
||||
|
||||
orderNumber?: number
|
||||
}
|
||||
|
||||
export default async function addContractTypePrint(
|
||||
export default function addContractTypePrint(
|
||||
addForm: AddContractTypePrintForm,
|
||||
user: User
|
||||
): Promise<boolean> {
|
||||
const database = await acquireConnection()
|
||||
): boolean {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
|
|
@ -20,11 +22,11 @@ export default async function addContractTypePrint(
|
|||
.prepare(
|
||||
`update ContractTypePrints
|
||||
set recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
where contractTypeId = ?
|
||||
and printEJS = ?`
|
||||
and printEJS = ?`
|
||||
)
|
||||
.run(
|
||||
user.userName,
|
||||
|
|
@ -53,7 +55,7 @@ export default async function addContractTypePrint(
|
|||
)
|
||||
}
|
||||
|
||||
database.release()
|
||||
database.close()
|
||||
|
||||
clearCacheByTableName('ContractTypePrints')
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
export interface AddFeeForm {
|
||||
feeCategoryId: string;
|
||||
feeCategoryId: number | string;
|
||||
feeName: string;
|
||||
feeDescription: string;
|
||||
feeAccount: string;
|
||||
contractTypeId: string;
|
||||
burialSiteTypeId: string;
|
||||
contractTypeId: number | string;
|
||||
burialSiteTypeId: number | string;
|
||||
feeAmount?: string;
|
||||
feeFunction?: string;
|
||||
taxAmount?: string;
|
||||
|
|
@ -14,4 +14,4 @@ export interface AddFeeForm {
|
|||
isRequired?: '' | '1';
|
||||
orderNumber?: number;
|
||||
}
|
||||
export default function addFee(feeForm: AddFeeForm, user: User): Promise<number>;
|
||||
export default function addFee(feeForm: AddFeeForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
export default async function addFee(feeForm, user) {
|
||||
const database = await acquireConnection();
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
export default function addFee(feeForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare(`insert into Fees (
|
||||
|
|
@ -14,7 +15,7 @@ export default async function addFee(feeForm, user) {
|
|||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(feeForm.feeCategoryId, feeForm.feeName, feeForm.feeDescription, feeForm.feeAccount, feeForm.contractTypeId === '' ? undefined : feeForm.contractTypeId, feeForm.burialSiteTypeId === '' ? undefined : feeForm.burialSiteTypeId, feeForm.feeAmount ?? undefined, feeForm.feeFunction ?? undefined, feeForm.taxAmount ?? undefined, feeForm.taxPercentage ?? undefined, (feeForm.includeQuantity ?? '') === '' ? 0 : 1, feeForm.quantityUnit, (feeForm.isRequired ?? '') === '' ? 0 : 1, feeForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.release();
|
||||
.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();
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
export interface AddFeeForm {
|
||||
feeCategoryId: string
|
||||
feeCategoryId: number | string
|
||||
feeName: string
|
||||
feeDescription: string
|
||||
feeAccount: string
|
||||
contractTypeId: string
|
||||
burialSiteTypeId: string
|
||||
contractTypeId: number | string
|
||||
burialSiteTypeId: number | string
|
||||
feeAmount?: string
|
||||
feeFunction?: string
|
||||
taxAmount?: string
|
||||
|
|
@ -17,11 +19,8 @@ export interface AddFeeForm {
|
|||
orderNumber?: number
|
||||
}
|
||||
|
||||
export default async function addFee(
|
||||
feeForm: AddFeeForm,
|
||||
user: User
|
||||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
export default function addFee(feeForm: AddFeeForm, user: User): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
|
|
@ -46,10 +45,10 @@ export default async function addFee(
|
|||
feeForm.feeAccount,
|
||||
feeForm.contractTypeId === '' ? undefined : feeForm.contractTypeId,
|
||||
feeForm.burialSiteTypeId === '' ? undefined : feeForm.burialSiteTypeId,
|
||||
feeForm.feeAmount ?? undefined,
|
||||
feeForm.feeAmount === '' ? undefined : feeForm.feeAmount,
|
||||
feeForm.feeFunction ?? undefined,
|
||||
feeForm.taxAmount ?? undefined,
|
||||
feeForm.taxPercentage ?? undefined,
|
||||
feeForm.taxAmount === '' ? undefined : feeForm.taxAmount,
|
||||
feeForm.taxPercentage === '' ? undefined : feeForm.taxPercentage,
|
||||
(feeForm.includeQuantity ?? '') === '' ? 0 : 1,
|
||||
feeForm.quantityUnit,
|
||||
(feeForm.isRequired ?? '') === '' ? 0 : 1,
|
||||
|
|
@ -60,7 +59,7 @@ export default async function addFee(
|
|||
rightNowMillis
|
||||
)
|
||||
|
||||
database.release()
|
||||
database.close()
|
||||
|
||||
return result.lastInsertRowid as number
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@ export interface AddFeeCategoryForm {
|
|||
isGroupedFee?: '1';
|
||||
orderNumber?: number;
|
||||
}
|
||||
export default function addFeeCategory(feeCategoryForm: AddFeeCategoryForm, user: User): Promise<number>;
|
||||
export default function addFeeCategory(feeCategoryForm: AddFeeCategoryForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
export default async function addFeeCategory(feeCategoryForm, user) {
|
||||
const database = await acquireConnection();
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
export default function addFeeCategory(feeCategoryForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare(`insert into FeeCategories (
|
||||
|
|
@ -10,6 +11,6 @@ export default async function addFeeCategory(feeCategoryForm, user) {
|
|||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(feeCategoryForm.feeCategory, (feeCategoryForm.isGroupedFee ?? '') === '1' ? 1 : 0, feeCategoryForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.release();
|
||||
database.close();
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
export interface AddFeeCategoryForm {
|
||||
feeCategory: string
|
||||
|
|
@ -6,11 +8,11 @@ export interface AddFeeCategoryForm {
|
|||
orderNumber?: number
|
||||
}
|
||||
|
||||
export default async function addFeeCategory(
|
||||
export default function addFeeCategory(
|
||||
feeCategoryForm: AddFeeCategoryForm,
|
||||
user: User
|
||||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
|
|
@ -33,7 +35,7 @@ export default async function addFeeCategory(
|
|||
rightNowMillis
|
||||
)
|
||||
|
||||
database.release()
|
||||
database.close()
|
||||
|
||||
return result.lastInsertRowid as number
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
export interface AddForm {
|
||||
funeralHomeKey: string;
|
||||
funeralHomeName: string;
|
||||
funeralHomeAddress1: string;
|
||||
funeralHomeAddress2: string;
|
||||
funeralHomeCity: string;
|
||||
funeralHomeProvince: string;
|
||||
funeralHomePostalCode: string;
|
||||
funeralHomeProvince: string;
|
||||
funeralHomePhoneNumber: string;
|
||||
}
|
||||
export default function addFuneralHome(addForm: AddForm, user: User): Promise<number>;
|
||||
export default function addFuneralHome(addForm: AddForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
export default async function addFuneralHome(addForm, user) {
|
||||
const database = await acquireConnection();
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
export default function addFuneralHome(addForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare(`insert into FuneralHomes (
|
||||
funeralHomeName, funeralHomeAddress1, funeralHomeAddress2,
|
||||
funeralHomeName, funeralHomeKey, funeralHomeAddress1, funeralHomeAddress2,
|
||||
funeralHomeCity, funeralHomeProvince, funeralHomePostalCode, funeralHomePhoneNumber,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.funeralHomeName, addForm.funeralHomeAddress1, addForm.funeralHomeAddress2, addForm.funeralHomeCity, addForm.funeralHomeProvince, addForm.funeralHomePostalCode, addForm.funeralHomePhoneNumber, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.release();
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.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();
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,37 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
export interface AddForm {
|
||||
funeralHomeKey: string
|
||||
funeralHomeName: string
|
||||
|
||||
funeralHomeAddress1: string
|
||||
funeralHomeAddress2: string
|
||||
funeralHomeCity: string
|
||||
funeralHomeProvince: string
|
||||
funeralHomePostalCode: string
|
||||
funeralHomeProvince: string
|
||||
|
||||
funeralHomePhoneNumber: string
|
||||
}
|
||||
|
||||
export default async function addFuneralHome(
|
||||
addForm: AddForm,
|
||||
user: User
|
||||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
export default function addFuneralHome(addForm: AddForm, user: User): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
const result = database
|
||||
.prepare(
|
||||
`insert into FuneralHomes (
|
||||
funeralHomeName, funeralHomeAddress1, funeralHomeAddress2,
|
||||
funeralHomeName, funeralHomeKey, funeralHomeAddress1, funeralHomeAddress2,
|
||||
funeralHomeCity, funeralHomeProvince, funeralHomePostalCode, funeralHomePhoneNumber,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
)
|
||||
.run(
|
||||
addForm.funeralHomeName,
|
||||
addForm.funeralHomeKey,
|
||||
addForm.funeralHomeAddress1,
|
||||
addForm.funeralHomeAddress2,
|
||||
addForm.funeralHomeCity,
|
||||
|
|
@ -41,7 +44,7 @@ export default async function addFuneralHome(
|
|||
rightNowMillis
|
||||
)
|
||||
|
||||
database.release()
|
||||
database.close()
|
||||
|
||||
return result.lastInsertRowid as number
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
export interface AddForm {
|
||||
export interface AddIntermentContainerTypeForm {
|
||||
intermentContainerType: string;
|
||||
isCremationType?: string;
|
||||
orderNumber?: number;
|
||||
intermentContainerTypeKey?: string;
|
||||
isCremationType?: '0' | '1';
|
||||
orderNumber?: number | string;
|
||||
}
|
||||
export default function addIntermentContainerType(addForm: AddForm, user: User): Promise<number>;
|
||||
export default function addIntermentContainerType(addForm: AddIntermentContainerTypeForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function addIntermentContainerType(addForm, user) {
|
||||
const database = await acquireConnection();
|
||||
export default function addIntermentContainerType(addForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare(`insert into IntermentContainerTypes (
|
||||
intermentContainerType, isCremationType, orderNumber,
|
||||
intermentContainerType, intermentContainerTypeKey, isCremationType, orderNumber,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.intermentContainerType, addForm.isCremationType === undefined ? 0 : 1, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.release();
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.intermentContainerType, addForm.intermentContainerTypeKey ?? '', addForm.isCremationType ?? '0', addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.close();
|
||||
clearCacheByTableName('IntermentContainerTypes');
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,32 +1,35 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export interface AddForm {
|
||||
export interface AddIntermentContainerTypeForm {
|
||||
intermentContainerType: string
|
||||
isCremationType?: string
|
||||
orderNumber?: number
|
||||
intermentContainerTypeKey?: string
|
||||
isCremationType?: '0' | '1'
|
||||
orderNumber?: number | string
|
||||
}
|
||||
|
||||
export default async function addIntermentContainerType(
|
||||
addForm: AddForm,
|
||||
export default function addIntermentContainerType(
|
||||
addForm: AddIntermentContainerTypeForm,
|
||||
user: User
|
||||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
const result = database
|
||||
.prepare(
|
||||
`insert into IntermentContainerTypes (
|
||||
intermentContainerType, isCremationType, orderNumber,
|
||||
intermentContainerType, intermentContainerTypeKey, isCremationType, orderNumber,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?)`
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
)
|
||||
.run(
|
||||
addForm.intermentContainerType,
|
||||
addForm.isCremationType === undefined ? 0 : 1,
|
||||
addForm.intermentContainerTypeKey ?? '',
|
||||
addForm.isCremationType ?? '0',
|
||||
addForm.orderNumber ?? -1,
|
||||
user.userName,
|
||||
rightNowMillis,
|
||||
|
|
@ -34,7 +37,7 @@ export default async function addIntermentContainerType(
|
|||
rightNowMillis
|
||||
)
|
||||
|
||||
database.release()
|
||||
database.close()
|
||||
|
||||
clearCacheByTableName('IntermentContainerTypes')
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import sqlite from 'better-sqlite3';
|
||||
export interface BurialSiteFieldForm {
|
||||
burialSiteId: string | number;
|
||||
burialSiteTypeFieldId: string | number;
|
||||
burialSiteId: number | string;
|
||||
burialSiteTypeFieldId: number | string;
|
||||
fieldValue: string;
|
||||
}
|
||||
export default function addOrUpdateBurialSiteField(fieldForm: BurialSiteFieldForm, user: User, connectedDatabase?: PoolConnection): Promise<boolean>;
|
||||
export default function addOrUpdateBurialSiteField(fieldForm: BurialSiteFieldForm, user: User, connectedDatabase?: sqlite.Database): boolean;
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
export default async function addOrUpdateBurialSiteField(fieldForm, user, connectedDatabase) {
|
||||
const database = connectedDatabase ?? (await acquireConnection());
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
export default function addOrUpdateBurialSiteField(fieldForm, user, connectedDatabase) {
|
||||
const database = connectedDatabase ?? sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
let result = database
|
||||
.prepare(`update BurialSiteFields
|
||||
set fieldValue = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
where burialSiteId = ?
|
||||
and burialSiteTypeFieldId = ?`)
|
||||
and burialSiteTypeFieldId = ?`)
|
||||
.run(fieldForm.fieldValue, user.userName, rightNowMillis, fieldForm.burialSiteId, fieldForm.burialSiteTypeFieldId);
|
||||
if (result.changes === 0) {
|
||||
result = database
|
||||
|
|
@ -22,7 +23,7 @@ export default async function addOrUpdateBurialSiteField(fieldForm, user, connec
|
|||
.run(fieldForm.burialSiteId, fieldForm.burialSiteTypeFieldId, fieldForm.fieldValue, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
}
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release();
|
||||
database.close();
|
||||
}
|
||||
return result.changes > 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
export interface BurialSiteFieldForm {
|
||||
burialSiteId: string | number
|
||||
burialSiteTypeFieldId: string | number
|
||||
burialSiteId: number | string
|
||||
burialSiteTypeFieldId: number | string
|
||||
fieldValue: string
|
||||
}
|
||||
|
||||
export default async function addOrUpdateBurialSiteField(
|
||||
export default function addOrUpdateBurialSiteField(
|
||||
fieldForm: BurialSiteFieldForm,
|
||||
user: User,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<boolean> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
connectedDatabase?: sqlite.Database
|
||||
): boolean {
|
||||
const database = connectedDatabase ?? sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
|
|
@ -21,12 +21,12 @@ export default async function addOrUpdateBurialSiteField(
|
|||
.prepare(
|
||||
`update BurialSiteFields
|
||||
set fieldValue = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
where burialSiteId = ?
|
||||
and burialSiteTypeFieldId = ?`
|
||||
and burialSiteTypeFieldId = ?`
|
||||
)
|
||||
.run(
|
||||
fieldForm.fieldValue,
|
||||
|
|
@ -57,7 +57,7 @@ export default async function addOrUpdateBurialSiteField(
|
|||
}
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
database.close()
|
||||
}
|
||||
|
||||
return result.changes > 0
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import sqlite from 'better-sqlite3';
|
||||
export interface ContractFieldForm {
|
||||
contractId: string | number;
|
||||
contractTypeFieldId: string | number;
|
||||
contractId: number | string;
|
||||
contractTypeFieldId: number | string;
|
||||
fieldValue: string;
|
||||
}
|
||||
export default function addOrUpdateContractField(fieldForm: ContractFieldForm, user: User, connectedDatabase?: PoolConnection): Promise<boolean>;
|
||||
export default function addOrUpdateContractField(fieldForm: ContractFieldForm, user: User, connectedDatabase?: sqlite.Database): boolean;
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
export default async function addOrUpdateContractField(fieldForm, user, connectedDatabase) {
|
||||
const database = connectedDatabase ?? (await acquireConnection());
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
export default function addOrUpdateContractField(fieldForm, user, connectedDatabase) {
|
||||
const database = connectedDatabase ?? sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
let result = database
|
||||
.prepare(`update ContractFields
|
||||
set fieldValue = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
where contractId = ?
|
||||
and contractTypeFieldId = ?`)
|
||||
and contractTypeFieldId = ?`)
|
||||
.run(fieldForm.fieldValue, user.userName, rightNowMillis, fieldForm.contractId, fieldForm.contractTypeFieldId);
|
||||
if (result.changes === 0) {
|
||||
result = database
|
||||
|
|
@ -22,7 +23,7 @@ export default async function addOrUpdateContractField(fieldForm, user, connecte
|
|||
.run(fieldForm.contractId, fieldForm.contractTypeFieldId, fieldForm.fieldValue, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
}
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release();
|
||||
database.close();
|
||||
}
|
||||
return result.changes > 0;
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue