Compare commits
73 Commits
v1.0.0-alp
...
main
| Author | SHA1 | Date |
|---|---|---|
|
|
118fc1959b | |
|
|
9830bede34 | |
|
|
302a9a4c48 | |
|
|
fe9188d1fb | |
|
|
4664366e12 | |
|
|
afcdca959b | |
|
|
434e15ba1d | |
|
|
39dc10369f | |
|
|
7371be711a | |
|
|
9048235ef2 | |
|
|
59b0fb7e5f | |
|
|
57b6dbf35e | |
|
|
c460d073e7 | |
|
|
a7ce5a99cb | |
|
|
db05999c72 | |
|
|
9c47b48abc | |
|
|
2ed7902320 | |
|
|
7887230c86 | |
|
|
18edc57f70 | |
|
|
656f1b052e | |
|
|
3c1d023ccd | |
|
|
2c506711fb | |
|
|
0dcdfaaa8a | |
|
|
ba0c9f3287 | |
|
|
ab61a3e340 | |
|
|
111663a274 | |
|
|
1c7bc96392 | |
|
|
b26e8b17b2 | |
|
|
c9b10f3696 | |
|
|
34c00b856b | |
|
|
0474631bf5 | |
|
|
927334d954 | |
|
|
50551582c1 | |
|
|
19a7c81766 | |
|
|
f96d975aa0 | |
|
|
3c4c85df19 | |
|
|
0d2f6f78ce | |
|
|
007b47a1f0 | |
|
|
62efb70542 | |
|
|
f440a35df7 | |
|
|
78cae2f964 | |
|
|
afa0286a2a | |
|
|
556a6a71b6 | |
|
|
96a41862bf | |
|
|
f35946d0a5 | |
|
|
d4670603b7 | |
|
|
09b3de1086 | |
|
|
c7640f6dfd | |
|
|
14bd8e0ea4 | |
|
|
b356d771ab | |
|
|
b359aaf564 | |
|
|
c330dff849 | |
|
|
a4522ec4d0 | |
|
|
3babad95c4 | |
|
|
5767b14f76 | |
|
|
eada41aaaa | |
|
|
e09d1ddb5d | |
|
|
f6eb3bf550 | |
|
|
dc9a9b2bcc | |
|
|
e7f79cbc4f | |
|
|
9bfed5aa4d | |
|
|
9a153bb238 | |
|
|
41761dcc8c | |
|
|
36e2b0f9cc | |
|
|
d4087caa74 | |
|
|
9c9b94199b | |
|
|
96eb7f36dc | |
|
|
4f6fc87e05 | |
|
|
38c1288856 | |
|
|
a167ef4a16 | |
|
|
3da2aad21b | |
|
|
dcbaad753b | |
|
|
d46a94db07 |
|
|
@ -10,7 +10,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node: [ 18, 20, 22, 23 ]
|
||||
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@14
|
||||
|
||||
- name: Copy Test Config
|
||||
run: cp ./data/config.testing.js ./data/config.js
|
||||
run: cp ./data/testing.config.js ./data/config.js
|
||||
|
||||
- name: Test Application Startup
|
||||
run: npm run test:startup
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ to focus exculsively on cemetery management.
|
|||
### ✔️ Cemetery Maps are NOT Required
|
||||
|
||||
Many cemetery applications rely on maps to drill down into burial sites.
|
||||
In Sunrise CMS, maps are completely optional, greatly reducing the effort needed to get started.
|
||||
In Sunrise CMS, maps are completely optional, greatly reducing the effort needed to get started,
|
||||
and reducing the maintenance work when new blocks of burial sites are introduced.
|
||||
|
||||
### ✔️ The System Requirements are Very Low
|
||||
|
||||
|
|
@ -33,14 +34,14 @@ Sunrise CMS does not need an expensive server to run.
|
|||
No separate database server is required either.
|
||||
The whole application could run on a current, modest workstation.
|
||||
|
||||
### ✔️ Track Unlimited Cemeteries and Burial Sites
|
||||
### ✔️ Track Unlimited Cemeteries, Unlimited Burial Sites, Unlimited Contracts...
|
||||
|
||||
There are no limits to the number of records that can be tracked in Sunrise CMS.
|
||||
|
||||
### ✔️ Includes a Built-In Work Order System
|
||||
### ✔️ Includes a Simple Built-In Work Order System
|
||||
|
||||
In addition to tracking data related to cemetery plots,
|
||||
Sunrise CMS can also track work order activities, like grave maintenance.
|
||||
Sunrise CMS can also track work order activities, like interments and grave maintenance.
|
||||
|
||||
### ✔️ Sunrise CMS is Free and Open Source
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
theme: jekyll-theme-cayman
|
||||
title: Sunrise Cemetery Management System
|
||||
title: Sunrise Cemetery Management System (CMS)
|
||||
6
app.js
6
app.js
|
|
@ -10,6 +10,7 @@ import rateLimit from 'express-rate-limit';
|
|||
import session from 'express-session';
|
||||
import createError from 'http-errors';
|
||||
import FileStore from 'session-file-store';
|
||||
import dataLists from './data/dataLists.js';
|
||||
import { DEBUG_NAMESPACE } from './debug.config.js';
|
||||
import * as permissionHandlers from './handlers/permissions.js';
|
||||
import { getSafeRedirectURL } from './helpers/authentication.helpers.js';
|
||||
|
|
@ -28,7 +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}`);
|
||||
const debug = Debug(`${DEBUG_NAMESPACE}:app:${process.pid.toString().padEnd(5)}`);
|
||||
/*
|
||||
* INITIALIZE APP
|
||||
*/
|
||||
|
|
@ -79,7 +80,7 @@ app.use(session({
|
|||
},
|
||||
secret: configFunctions.getConfigProperty('session.secret'),
|
||||
store: new FileStoreSession({
|
||||
logFn: Debug(`${DEBUG_NAMESPACE}:session:${process.pid}`),
|
||||
logFn: Debug(`${DEBUG_NAMESPACE}:session:${process.pid.toString().padEnd(5)}`),
|
||||
path: './data/sessions',
|
||||
retries: 20
|
||||
}),
|
||||
|
|
@ -141,6 +142,7 @@ app.use((request, response, next) => {
|
|||
response.locals.configFunctions = configFunctions;
|
||||
response.locals.printFunctions = printFunctions;
|
||||
response.locals.dateTimeFunctions = dateTimeFunctions;
|
||||
response.locals.dataLists = dataLists;
|
||||
response.locals.urlPrefix = configFunctions.getConfigProperty('reverseProxy.urlPrefix');
|
||||
next();
|
||||
});
|
||||
|
|
|
|||
7
app.ts
7
app.ts
|
|
@ -12,6 +12,7 @@ import session from 'express-session'
|
|||
import createError from 'http-errors'
|
||||
import FileStore from 'session-file-store'
|
||||
|
||||
import dataLists from './data/dataLists.js'
|
||||
import { DEBUG_NAMESPACE } from './debug.config.js'
|
||||
import * as permissionHandlers from './handlers/permissions.js'
|
||||
import { getSafeRedirectURL } from './helpers/authentication.helpers.js'
|
||||
|
|
@ -31,7 +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}`)
|
||||
const debug = Debug(`${DEBUG_NAMESPACE}:app:${process.pid.toString().padEnd(5)}`)
|
||||
|
||||
/*
|
||||
* INITIALIZE APP
|
||||
|
|
@ -107,7 +108,7 @@ app.use(
|
|||
},
|
||||
secret: configFunctions.getConfigProperty('session.secret'),
|
||||
store: new FileStoreSession({
|
||||
logFn: Debug(`${DEBUG_NAMESPACE}:session:${process.pid}`),
|
||||
logFn: Debug(`${DEBUG_NAMESPACE}:session:${process.pid.toString().padEnd(5)}`),
|
||||
path: './data/sessions',
|
||||
retries: 20
|
||||
}),
|
||||
|
|
@ -244,6 +245,8 @@ app.use((request, response, next) => {
|
|||
response.locals.printFunctions = printFunctions
|
||||
response.locals.dateTimeFunctions = dateTimeFunctions
|
||||
|
||||
response.locals.dataLists = dataLists
|
||||
|
||||
response.locals.urlPrefix = configFunctions.getConfigProperty(
|
||||
'reverseProxy.urlPrefix'
|
||||
)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import { getConfigProperty } from '../helpers/config.helpers.js';
|
|||
import version from '../version.js';
|
||||
const debug = Debug(`${DEBUG_NAMESPACE}:www:${process.pid}`);
|
||||
// INITIALIZE THE DATABASE
|
||||
await initializeDatabase();
|
||||
initializeDatabase();
|
||||
const directoryName = path.dirname(fileURLToPath(import.meta.url));
|
||||
const processCount = Math.min(getConfigProperty('application.maximumProcesses'), os.cpus().length * 2);
|
||||
const applicationName = getConfigProperty('application.applicationName');
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ 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
|
||||
await initializeDatabase()
|
||||
initializeDatabase()
|
||||
|
||||
const directoryName = path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ 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
|
||||
await initializeDatabase();
|
||||
initializeDatabase();
|
||||
}
|
||||
function onError(error) {
|
||||
if (error.syscall !== 'listen') {
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ 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
|
||||
await initializeDatabase()
|
||||
initializeDatabase()
|
||||
}
|
||||
|
||||
interface ServerError extends Error {
|
||||
|
|
|
|||
|
|
@ -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', () => {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -6,6 +6,7 @@ export const config = {
|
|||
settings: {
|
||||
adminCleanup: {},
|
||||
burialSites: {},
|
||||
burialSiteTypes: {},
|
||||
cemeteries: {},
|
||||
contracts: {},
|
||||
dynamicsGP: {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import type { Config } from '../types/configTypes.js'
|
||||
import type { Config } from '../types/config.types.js'
|
||||
|
||||
export const config: Config = {
|
||||
aliases: {},
|
||||
|
|
@ -8,6 +8,7 @@ export const config: Config = {
|
|||
settings: {
|
||||
adminCleanup: {},
|
||||
burialSites: {},
|
||||
burialSiteTypes: {},
|
||||
cemeteries: {},
|
||||
contracts: {},
|
||||
dynamicsGP: {
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
export declare const config: import("../types/configTypes.js").Config;
|
||||
export default config;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
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;
|
||||
|
|
@ -19,6 +19,7 @@ export declare const configDefaultValues: {
|
|||
'session.secret': string;
|
||||
'users.canLogin': string[];
|
||||
'users.canUpdate': string[];
|
||||
'users.canUpdateWorkOrders': string[];
|
||||
'users.isAdmin': string[];
|
||||
'users.testing': string[];
|
||||
'aliases.externalReceiptNumber': string;
|
||||
|
|
@ -32,14 +33,14 @@ export declare const configDefaultValues: {
|
|||
'settings.longitudeMax': number;
|
||||
'settings.longitudeMin': number;
|
||||
'settings.cemeteries.refreshImageChanges': boolean;
|
||||
'settings.burialSiteTypes.bodyCapacityMaxDefault': number;
|
||||
'settings.burialSiteTypes.crematedCapacityMaxDefault': number;
|
||||
'settings.burialSites.burialSiteNameSegments': ConfigBurialSiteNameSegments;
|
||||
'settings.burialSites.burialSiteNameSegments.includeCemeteryKey': boolean;
|
||||
'settings.burialSites.refreshImageChanges': boolean;
|
||||
'settings.contracts.burialSiteIdIsRequired': boolean;
|
||||
'settings.contracts.contractEndDateIsRequired': boolean;
|
||||
'settings.contracts.deathAgePeriods': string[];
|
||||
'settings.contracts.prints': string[];
|
||||
'settings.contracts.purchaserRelationships': string[];
|
||||
'settings.fees.taxPercentageDefault': number;
|
||||
'settings.workOrders.workOrderNumberLength': number;
|
||||
'settings.workOrders.calendarEmailAddress': string;
|
||||
|
|
@ -56,3 +57,4 @@ export declare const configDefaultValues: {
|
|||
'settings.dynamicsGP.itemNumbers': string[];
|
||||
'settings.dynamicsGP.trialBalanceCodes': string[];
|
||||
};
|
||||
export default configDefaultValues;
|
||||
|
|
@ -18,6 +18,7 @@ export const configDefaultValues = {
|
|||
'session.secret': 'cityssm/sunrise',
|
||||
'users.canLogin': ['administrator'],
|
||||
'users.canUpdate': [],
|
||||
'users.canUpdateWorkOrders': [],
|
||||
'users.isAdmin': ['administrator'],
|
||||
'users.testing': [],
|
||||
'aliases.externalReceiptNumber': 'External Receipt Number',
|
||||
|
|
@ -31,6 +32,10 @@ export const configDefaultValues = {
|
|||
'settings.longitudeMax': 180,
|
||||
'settings.longitudeMin': -180,
|
||||
'settings.cemeteries.refreshImageChanges': false,
|
||||
// eslint-disable-next-line no-secrets/no-secrets
|
||||
'settings.burialSiteTypes.bodyCapacityMaxDefault': 2,
|
||||
// eslint-disable-next-line no-secrets/no-secrets
|
||||
'settings.burialSiteTypes.crematedCapacityMaxDefault': 6,
|
||||
'settings.burialSites.burialSiteNameSegments': {
|
||||
includeCemeteryKey: false,
|
||||
separator: '-',
|
||||
|
|
@ -48,21 +53,7 @@ export const configDefaultValues = {
|
|||
'settings.burialSites.refreshImageChanges': false,
|
||||
'settings.contracts.burialSiteIdIsRequired': true,
|
||||
'settings.contracts.contractEndDateIsRequired': false,
|
||||
'settings.contracts.deathAgePeriods': [
|
||||
'Years',
|
||||
'Months',
|
||||
'Days',
|
||||
'Stillborn'
|
||||
],
|
||||
'settings.contracts.prints': ['screen/contract'],
|
||||
'settings.contracts.purchaserRelationships': [
|
||||
'Spouse',
|
||||
'Child',
|
||||
'Parent',
|
||||
'Sibling',
|
||||
'Friend',
|
||||
'Self'
|
||||
],
|
||||
'settings.fees.taxPercentageDefault': 0,
|
||||
'settings.workOrders.workOrderNumberLength': 6,
|
||||
'settings.workOrders.calendarEmailAddress': 'no-reply@127.0.0.1',
|
||||
|
|
@ -80,3 +71,4 @@ export const configDefaultValues = {
|
|||
'settings.dynamicsGP.itemNumbers': [],
|
||||
'settings.dynamicsGP.trialBalanceCodes': []
|
||||
};
|
||||
export default configDefaultValues;
|
||||
|
|
@ -1,13 +1,12 @@
|
|||
import type { config as MSSQLConfig } from 'mssql'
|
||||
|
||||
import { hoursToMillis } from '@cityssm/to-millis'
|
||||
import type { config as MSSQLConfig } from 'mssql'
|
||||
|
||||
import type {
|
||||
ConfigActiveDirectory,
|
||||
ConfigBurialSiteNameSegments,
|
||||
ConfigNtfyStartup,
|
||||
DynamicsGPLookup
|
||||
} from '../types/configTypes.js'
|
||||
} from '../types/config.types.js'
|
||||
|
||||
export const configDefaultValues = {
|
||||
activeDirectory: undefined as unknown as ConfigActiveDirectory,
|
||||
|
|
@ -32,6 +31,7 @@ export const configDefaultValues = {
|
|||
|
||||
'users.canLogin': ['administrator'],
|
||||
'users.canUpdate': [] as string[],
|
||||
'users.canUpdateWorkOrders': [] as string[],
|
||||
'users.isAdmin': ['administrator'],
|
||||
'users.testing': [] as string[],
|
||||
|
||||
|
|
@ -51,6 +51,12 @@ export const configDefaultValues = {
|
|||
|
||||
'settings.cemeteries.refreshImageChanges': false,
|
||||
|
||||
// eslint-disable-next-line no-secrets/no-secrets
|
||||
'settings.burialSiteTypes.bodyCapacityMaxDefault': 2,
|
||||
|
||||
// eslint-disable-next-line no-secrets/no-secrets
|
||||
'settings.burialSiteTypes.crematedCapacityMaxDefault': 6,
|
||||
|
||||
'settings.burialSites.burialSiteNameSegments': {
|
||||
includeCemeteryKey: false,
|
||||
separator: '-',
|
||||
|
|
@ -72,21 +78,8 @@ export const configDefaultValues = {
|
|||
|
||||
'settings.contracts.burialSiteIdIsRequired': true,
|
||||
'settings.contracts.contractEndDateIsRequired': false,
|
||||
'settings.contracts.deathAgePeriods': [
|
||||
'Years',
|
||||
'Months',
|
||||
'Days',
|
||||
'Stillborn'
|
||||
],
|
||||
|
||||
'settings.contracts.prints': ['screen/contract'],
|
||||
'settings.contracts.purchaserRelationships': [
|
||||
'Spouse',
|
||||
'Child',
|
||||
'Parent',
|
||||
'Sibling',
|
||||
'Friend',
|
||||
'Self'
|
||||
],
|
||||
|
||||
'settings.fees.taxPercentageDefault': 0,
|
||||
|
||||
|
|
@ -114,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;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { config as baseConfig } from './config.base.js';
|
||||
import { config as baseConfig } from './base.config.js';
|
||||
export const config = Object.assign({}, baseConfig);
|
||||
config.settings.provinceDefault = 'ON';
|
||||
config.settings.latitudeMax = 56.85;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { config as baseConfig } from './config.base.js'
|
||||
import { config as baseConfig } from './base.config.js'
|
||||
|
||||
export const config = Object.assign({}, baseConfig)
|
||||
|
||||
|
|
@ -1,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,4 +1,4 @@
|
|||
import { config as cemeteryConfig } from './config.baseOntario.js';
|
||||
import { config as cemeteryConfig } from './ontario.config.js';
|
||||
export const config = { ...cemeteryConfig };
|
||||
config.aliases.externalReceiptNumber = 'GP Receipt Number';
|
||||
config.settings.publicInternalPath =
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import type { Config } from '../types/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 }
|
||||
|
||||
|
|
@ -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,10 +1,11 @@
|
|||
import { config as cemeteryConfig } from './config.baseSsm.js';
|
||||
import { config as cemeteryConfig } from './ssm.ontario.config.js';
|
||||
export const config = { ...cemeteryConfig };
|
||||
config.application.useTestDatabases = true;
|
||||
config.session.doKeepAlive = true;
|
||||
config.users = {
|
||||
canLogin: ['*testView', '*testUpdate', '*testAdmin'],
|
||||
canUpdate: ['*testUpdate'],
|
||||
canUpdateWorkOrders: ['*testUpdate'],
|
||||
isAdmin: ['*testAdmin'],
|
||||
testing: ['*testView', '*testUpdate', '*testAdmin']
|
||||
};
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import type { Config } from '../types/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 }
|
||||
|
||||
|
|
@ -11,6 +11,7 @@ config.session.doKeepAlive = true
|
|||
config.users = {
|
||||
canLogin: ['*testView', '*testUpdate', '*testAdmin'],
|
||||
canUpdate: ['*testUpdate'],
|
||||
canUpdateWorkOrders: ['*testUpdate'],
|
||||
isAdmin: ['*testAdmin'],
|
||||
testing: ['*testView', '*testUpdate', '*testAdmin']
|
||||
}
|
||||
|
|
@ -6,11 +6,13 @@ export interface AddBurialSiteForm {
|
|||
burialSiteNameSegment5?: string;
|
||||
burialSiteStatusId: number | string;
|
||||
burialSiteTypeId: number | string;
|
||||
burialSiteImage: string;
|
||||
bodyCapacity?: number | string;
|
||||
crematedCapacity?: number | string;
|
||||
burialSiteImage?: string;
|
||||
cemeteryId: number | string;
|
||||
cemeterySvgId: string;
|
||||
burialSiteLatitude: string;
|
||||
burialSiteLongitude: string;
|
||||
cemeterySvgId?: string;
|
||||
burialSiteLatitude?: string;
|
||||
burialSiteLongitude?: string;
|
||||
burialSiteTypeFieldIds?: string;
|
||||
[fieldValue_burialSiteTypeFieldId: string]: unknown;
|
||||
}
|
||||
|
|
@ -21,4 +23,7 @@ export interface AddBurialSiteForm {
|
|||
* @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): Promise<number>;
|
||||
export default function addBurialSite(burialSiteForm: AddBurialSiteForm, user: User): {
|
||||
burialSiteId: number;
|
||||
burialSiteName: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
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';
|
||||
/**
|
||||
* Creates a new burial site.
|
||||
* @param burialSiteForm - The new burial site's information
|
||||
|
|
@ -9,12 +10,13 @@ import { acquireConnection } from './pool.js';
|
|||
* @returns The new burial site's id.
|
||||
* @throws If an active burial site with the same name already exists.
|
||||
*/
|
||||
export default async function addBurialSite(burialSiteForm, user) {
|
||||
const database = await acquireConnection();
|
||||
// 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);
|
||||
: getCemetery(burialSiteForm.cemeteryId, database);
|
||||
const burialSiteName = buildBurialSiteName(cemetery?.cemeteryKey, burialSiteForm);
|
||||
// Ensure no active burial sites share the same name
|
||||
const existingBurialSite = database
|
||||
|
|
@ -25,7 +27,7 @@ export default async function addBurialSite(burialSiteForm, user) {
|
|||
.pluck()
|
||||
.get(burialSiteName);
|
||||
if (existingBurialSite !== undefined) {
|
||||
database.release();
|
||||
database.close();
|
||||
throw new Error('An active burial site with that name already exists.');
|
||||
}
|
||||
const result = database
|
||||
|
|
@ -37,17 +39,22 @@ export default async function addBurialSite(burialSiteForm, user) {
|
|||
burialSiteNameSegment5,
|
||||
burialSiteName,
|
||||
burialSiteTypeId, burialSiteStatusId,
|
||||
bodyCapacity, crematedCapacity,
|
||||
cemeteryId, cemeterySvgId, burialSiteImage,
|
||||
burialSiteLatitude, burialSiteLongitude,
|
||||
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?,
|
||||
values (?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?)`)
|
||||
.run(burialSiteForm.burialSiteNameSegment1 ?? '', burialSiteForm.burialSiteNameSegment2 ?? '', burialSiteForm.burialSiteNameSegment3 ?? '', burialSiteForm.burialSiteNameSegment4 ?? '', burialSiteForm.burialSiteNameSegment5 ?? '', burialSiteName, burialSiteForm.burialSiteTypeId, burialSiteForm.burialSiteStatusId === ''
|
||||
? undefined
|
||||
: burialSiteForm.burialSiteStatusId, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteImage, burialSiteForm.burialSiteLatitude === ''
|
||||
: burialSiteForm.burialSiteStatusId, burialSiteForm.bodyCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.bodyCapacity, burialSiteForm.crematedCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.crematedCapacity, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteImage ?? '', burialSiteForm.burialSiteLatitude === ''
|
||||
? undefined
|
||||
: burialSiteForm.burialSiteLatitude, burialSiteForm.burialSiteLongitude === ''
|
||||
? undefined
|
||||
|
|
@ -57,13 +64,16 @@ export default async function addBurialSite(burialSiteForm, user) {
|
|||
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,8 +1,10 @@
|
|||
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
|
||||
|
|
@ -14,15 +16,18 @@ export interface AddBurialSiteForm {
|
|||
burialSiteStatusId: number | string
|
||||
burialSiteTypeId: number | string
|
||||
|
||||
burialSiteImage: string
|
||||
cemeteryId: number | string
|
||||
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
|
||||
}
|
||||
|
||||
|
|
@ -33,18 +38,19 @@ export interface AddBurialSiteForm {
|
|||
* @returns The new burial site's id.
|
||||
* @throws If an active burial site with the same name already exists.
|
||||
*/
|
||||
export default async function addBurialSite(
|
||||
// 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)
|
||||
: getCemetery(burialSiteForm.cemeteryId, database)
|
||||
|
||||
const burialSiteName = buildBurialSiteName(
|
||||
cemetery?.cemeteryKey,
|
||||
|
|
@ -64,7 +70,7 @@ export default async function addBurialSite(
|
|||
.get(burialSiteName) as number | undefined
|
||||
|
||||
if (existingBurialSite !== undefined) {
|
||||
database.release()
|
||||
database.close()
|
||||
throw new Error('An active burial site with that name already exists.')
|
||||
}
|
||||
|
||||
|
|
@ -78,12 +84,13 @@ export default async function addBurialSite(
|
|||
burialSiteNameSegment5,
|
||||
burialSiteName,
|
||||
burialSiteTypeId, burialSiteStatusId,
|
||||
bodyCapacity, crematedCapacity,
|
||||
cemeteryId, cemeterySvgId, burialSiteImage,
|
||||
burialSiteLatitude, burialSiteLongitude,
|
||||
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?,
|
||||
values (?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?)`
|
||||
)
|
||||
|
|
@ -98,9 +105,18 @@ export default async function addBurialSite(
|
|||
burialSiteForm.burialSiteStatusId === ''
|
||||
? undefined
|
||||
: burialSiteForm.burialSiteStatusId,
|
||||
|
||||
burialSiteForm.bodyCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.bodyCapacity,
|
||||
|
||||
burialSiteForm.crematedCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.crematedCapacity,
|
||||
|
||||
burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId,
|
||||
burialSiteForm.cemeterySvgId,
|
||||
burialSiteForm.burialSiteImage,
|
||||
burialSiteForm.burialSiteImage ?? '',
|
||||
burialSiteForm.burialSiteLatitude === ''
|
||||
? undefined
|
||||
: burialSiteForm.burialSiteLatitude,
|
||||
|
|
@ -125,7 +141,7 @@ export default async function addBurialSite(
|
|||
] as string | undefined
|
||||
|
||||
if ((fieldValue ?? '') !== '') {
|
||||
await addOrUpdateBurialSiteField(
|
||||
addOrUpdateBurialSiteField(
|
||||
{
|
||||
burialSiteId,
|
||||
burialSiteTypeFieldId,
|
||||
|
|
@ -137,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
|
||||
}
|
||||
|
|
@ -4,9 +4,9 @@ export interface AddBurialSiteTypeFieldForm {
|
|||
fieldType?: string;
|
||||
fieldValues?: string;
|
||||
isRequired?: string;
|
||||
pattern?: string;
|
||||
minLength?: number | string;
|
||||
maxLength?: number | string;
|
||||
minLength?: number | string;
|
||||
pattern?: string;
|
||||
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 { 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 AddBurialSiteTypeFieldForm {
|
||||
burialSiteTypeId: number | string
|
||||
|
||||
burialSiteTypeField: string
|
||||
|
||||
fieldType?: string
|
||||
fieldValues?: string
|
||||
|
||||
isRequired?: string
|
||||
pattern?: string
|
||||
minLength?: number | string
|
||||
maxLength?: number | string
|
||||
minLength?: number | string
|
||||
pattern?: string
|
||||
|
||||
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,4 +1,5 @@
|
|||
export interface AddCemeteryForm {
|
||||
import { type UpdateCemeteryDirectionsOfArrivalForm } from './updateCemeteryDirectionsOfArrival.js';
|
||||
export type AddCemeteryForm = UpdateCemeteryDirectionsOfArrivalForm & {
|
||||
cemeteryDescription: string;
|
||||
cemeteryKey: string;
|
||||
cemeteryName: string;
|
||||
|
|
@ -12,5 +13,5 @@ export interface AddCemeteryForm {
|
|||
cemeteryPostalCode: string;
|
||||
cemeteryProvince: string;
|
||||
cemeteryPhoneNumber: string;
|
||||
}
|
||||
export default function addCemetery(addForm: AddCemeteryForm, user: User): 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 (
|
||||
|
|
@ -14,6 +16,8 @@ export default async function addCemetery(addForm, user) {
|
|||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.cemeteryName, addForm.cemeteryKey, addForm.cemeteryDescription, addForm.cemeterySvg, addForm.cemeteryLatitude === '' ? undefined : addForm.cemeteryLatitude, addForm.cemeteryLongitude === '' ? undefined : addForm.cemeteryLongitude, addForm.cemeteryAddress1, addForm.cemeteryAddress2, addForm.cemeteryCity, addForm.cemeteryProvince, addForm.cemeteryPostalCode, addForm.cemeteryPhoneNumber, addForm.parentCemeteryId === '' ? undefined : addForm.parentCemeteryId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.release();
|
||||
return result.lastInsertRowid;
|
||||
const cemeteryId = result.lastInsertRowid;
|
||||
updateCemeteryDirectionsOfArrival(cemeteryId, addForm, database);
|
||||
database.close();
|
||||
return cemeteryId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
export interface AddCemeteryForm {
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
import updateCemeteryDirectionsOfArrival, {
|
||||
type UpdateCemeteryDirectionsOfArrivalForm
|
||||
} from './updateCemeteryDirectionsOfArrival.js'
|
||||
|
||||
export type AddCemeteryForm = UpdateCemeteryDirectionsOfArrivalForm & {
|
||||
cemeteryDescription: string
|
||||
cemeteryKey: string
|
||||
cemeteryName: string
|
||||
|
|
@ -19,11 +25,11 @@ export interface AddCemeteryForm {
|
|||
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()
|
||||
|
||||
|
|
@ -60,7 +66,11 @@ export default async function addCemetery(
|
|||
rightNowMillis
|
||||
)
|
||||
|
||||
database.release()
|
||||
const cemeteryId = result.lastInsertRowid as number
|
||||
|
||||
return result.lastInsertRowid as number
|
||||
updateCemeteryDirectionsOfArrival(cemeteryId, addForm, database)
|
||||
|
||||
database.close()
|
||||
|
||||
return cemeteryId
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
export interface AddForm {
|
||||
committalType: string;
|
||||
committalTypeKey?: string;
|
||||
orderNumber?: number;
|
||||
orderNumber?: number | string;
|
||||
}
|
||||
export default function addCommittalType(addForm: AddForm, user: User): Promise<number>;
|
||||
export default function addCommittalType(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 addCommittalType(addForm, user) {
|
||||
const database = await acquireConnection();
|
||||
export default function addCommittalType(addForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare(`insert into CommittalTypes (
|
||||
|
|
@ -10,7 +11,7 @@ export default async function addCommittalType(addForm, user) {
|
|||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.committalType, addForm.committalTypeKey ?? '', addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.release();
|
||||
database.close();
|
||||
clearCacheByTableName('CommittalTypes');
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
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 {
|
||||
committalType: string
|
||||
committalTypeKey?: string
|
||||
orderNumber?: number
|
||||
orderNumber?: number | string
|
||||
}
|
||||
|
||||
export default async function addCommittalType(
|
||||
addForm: AddForm,
|
||||
user: User
|
||||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
export default function addCommittalType(addForm: AddForm, user: User): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
|
|
@ -34,7 +32,7 @@ export default async function addCommittalType(
|
|||
rightNowMillis
|
||||
)
|
||||
|
||||
database.release()
|
||||
database.close()
|
||||
|
||||
clearCacheByTableName('CommittalTypes')
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
||||
import sqlite from 'better-sqlite3';
|
||||
export interface AddContractForm {
|
||||
burialSiteId: number | string;
|
||||
contractEndDateString: '' | DateString;
|
||||
|
|
@ -8,6 +8,7 @@ export interface AddContractForm {
|
|||
[fieldValue_contractTypeFieldId: `fieldValue_${string}`]: unknown;
|
||||
contractTypeFieldIds?: string;
|
||||
committalTypeId?: number | string;
|
||||
directionOfArrival?: string;
|
||||
funeralDateString?: '' | DateString;
|
||||
funeralDirectorName?: string;
|
||||
funeralHomeId?: number | string;
|
||||
|
|
@ -35,4 +36,4 @@ export interface AddContractForm {
|
|||
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 ?? ''
|
||||
|
|
@ -66,7 +67,7 @@ export default async function addContract(addForm, user, connectedDatabase) {
|
|||
: addForm.intermentContainerTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
}
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release();
|
||||
database.close();
|
||||
}
|
||||
return contractId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import {
|
||||
type DateString,
|
||||
type TimeString,
|
||||
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'
|
||||
|
||||
export interface AddContractForm {
|
||||
burialSiteId: number | string
|
||||
|
|
@ -20,6 +20,7 @@ export interface AddContractForm {
|
|||
contractTypeFieldIds?: string
|
||||
|
||||
committalTypeId?: number | string
|
||||
directionOfArrival?: string
|
||||
funeralDateString?: '' | DateString
|
||||
funeralDirectorName?: string
|
||||
funeralHomeId?: number | string
|
||||
|
|
@ -51,12 +52,12 @@ export interface AddContractForm {
|
|||
}
|
||||
|
||||
// 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()
|
||||
|
||||
|
|
@ -74,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,
|
||||
|
|
@ -103,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,
|
||||
|
|
@ -124,7 +126,7 @@ export default async function addContract(
|
|||
| undefined
|
||||
|
||||
if ((fieldValue ?? '') !== '') {
|
||||
await addOrUpdateContractField(
|
||||
addOrUpdateContractField(
|
||||
{
|
||||
contractId,
|
||||
contractTypeFieldId,
|
||||
|
|
@ -186,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: number | string;
|
||||
comment: string;
|
||||
commentDateString?: DateString;
|
||||
commentTimeString?: TimeString;
|
||||
contractId: number | 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: number | string
|
||||
|
||||
comment: string
|
||||
commentDateString?: DateString
|
||||
commentTimeString?: TimeString
|
||||
contractId: number | 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,4 +1,4 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import sqlite from 'better-sqlite3';
|
||||
export interface AddContractFeeForm {
|
||||
contractId: number | string;
|
||||
feeId: number | string;
|
||||
|
|
@ -6,4 +6,4 @@ export interface AddContractFeeForm {
|
|||
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,14 +1,14 @@
|
|||
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
|
||||
|
|
@ -22,9 +22,9 @@ export interface AddContractFeeForm {
|
|||
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()
|
||||
|
||||
|
|
@ -33,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)
|
||||
|
|
@ -65,6 +63,7 @@ export default async function addContractFee(
|
|||
| {
|
||||
feeAmount: number | null
|
||||
taxAmount: number | null
|
||||
|
||||
recordDelete_timeMillis: number | null
|
||||
}
|
||||
| undefined
|
||||
|
|
@ -156,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,19 +1,19 @@
|
|||
import { type DateString } from '@cityssm/utils-datetime';
|
||||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
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;
|
||||
deathAge: string | number;
|
||||
deathAge: number | string;
|
||||
deathAgePeriod: string;
|
||||
intermentContainerTypeId: string | number;
|
||||
intermentContainerTypeId: number | string;
|
||||
}
|
||||
export default function addContractInterment(contractForm: AddForm, user: User, connectedDatabase?: PoolConnection): 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, connectedDatabase) {
|
||||
const database = connectedDatabase ?? (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;
|
||||
|
|
@ -26,7 +27,7 @@ export default async function addContractInterment(contractForm, user, connected
|
|||
? undefined
|
||||
: contractForm.intermentContainerTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release();
|
||||
database.close();
|
||||
}
|
||||
return newIntermentNumber;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,37 +1,42 @@
|
|||
import { type DateString, dateStringToInteger } from '@cityssm/utils-datetime'
|
||||
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 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
|
||||
deathAge: string | number
|
||||
|
||||
deathAge: number | string
|
||||
deathAgePeriod: string
|
||||
intermentContainerTypeId: string | number
|
||||
|
||||
intermentContainerTypeId: number | string
|
||||
}
|
||||
|
||||
export default async function addContractInterment(
|
||||
export default function addContractInterment(
|
||||
contractForm: AddForm,
|
||||
user: User,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<number> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
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
|
||||
|
|
@ -76,7 +81,7 @@ export default async function addContractInterment(
|
|||
)
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
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 | number;
|
||||
feeCategoryId: number | string;
|
||||
feeName: string;
|
||||
feeDescription: string;
|
||||
feeAccount: string;
|
||||
contractTypeId: string | number;
|
||||
burialSiteTypeId: string | number;
|
||||
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 (
|
||||
|
|
@ -15,6 +16,6 @@ export default async function addFee(feeForm, user) {
|
|||
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.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.release();
|
||||
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 | number
|
||||
feeCategoryId: number | string
|
||||
feeName: string
|
||||
feeDescription: string
|
||||
feeAccount: string
|
||||
contractTypeId: string | number
|
||||
burialSiteTypeId: string | number
|
||||
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()
|
||||
|
||||
|
|
@ -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,11 +1,11 @@
|
|||
export interface AddForm {
|
||||
funeralHomeName: string;
|
||||
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,6 +1,7 @@
|
|||
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 (
|
||||
|
|
@ -10,6 +11,6 @@ export default async function addFuneralHome(addForm, user) {
|
|||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
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.release();
|
||||
database.close();
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,22 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
export interface AddForm {
|
||||
funeralHomeName: string
|
||||
funeralHomeKey: string
|
||||
funeralHomeName: string
|
||||
|
||||
funeralHomeAddress1: string
|
||||
funeralHomeAddress2: string
|
||||
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()
|
||||
|
||||
|
|
@ -43,7 +44,7 @@ export default async function addFuneralHome(
|
|||
rightNowMillis
|
||||
)
|
||||
|
||||
database.release()
|
||||
database.close()
|
||||
|
||||
return result.lastInsertRowid as number
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
export interface AddForm {
|
||||
export interface AddIntermentContainerTypeForm {
|
||||
intermentContainerType: string;
|
||||
intermentContainerTypeKey?: string;
|
||||
isCremationType?: string;
|
||||
orderNumber?: number;
|
||||
isCremationType?: '0' | '1';
|
||||
orderNumber?: number | string;
|
||||
}
|
||||
export default function addIntermentContainerType(addForm: AddForm, user: User): Promise<number>;
|
||||
export default function addIntermentContainerType(addForm: AddIntermentContainerTypeForm, 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 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 (
|
||||
|
|
@ -9,8 +10,8 @@ export default async function addIntermentContainerType(addForm, user) {
|
|||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.intermentContainerType, addForm.intermentContainerTypeKey ?? '', addForm.isCremationType === undefined ? 0 : 1, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.release();
|
||||
.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,19 +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 AddForm {
|
||||
export interface AddIntermentContainerTypeForm {
|
||||
intermentContainerType: string
|
||||
intermentContainerTypeKey?: string
|
||||
isCremationType?: string
|
||||
orderNumber?: number
|
||||
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()
|
||||
|
||||
|
|
@ -28,7 +29,7 @@ export default async function addIntermentContainerType(
|
|||
.run(
|
||||
addForm.intermentContainerType,
|
||||
addForm.intermentContainerTypeKey ?? '',
|
||||
addForm.isCremationType === undefined ? 0 : 1,
|
||||
addForm.isCremationType ?? '0',
|
||||
addForm.orderNumber ?? -1,
|
||||
user.userName,
|
||||
rightNowMillis,
|
||||
|
|
@ -36,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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 ContractFieldForm {
|
||||
contractId: string | number
|
||||
contractTypeFieldId: string | number
|
||||
contractId: number | string
|
||||
contractTypeFieldId: number | string
|
||||
fieldValue: string
|
||||
}
|
||||
|
||||
export default async function addOrUpdateContractField(
|
||||
export default function addOrUpdateContractField(
|
||||
fieldForm: ContractFieldForm,
|
||||
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 addOrUpdateContractField(
|
|||
.prepare(
|
||||
`update ContractFields
|
||||
set fieldValue = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
where contractId = ?
|
||||
and contractTypeFieldId = ?`
|
||||
and contractTypeFieldId = ?`
|
||||
)
|
||||
.run(
|
||||
fieldForm.fieldValue,
|
||||
|
|
@ -57,7 +57,7 @@ export default async function addOrUpdateContractField(
|
|||
}
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
database.close()
|
||||
}
|
||||
|
||||
return result.changes > 0
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
type RecordTable = 'BurialSiteStatuses' | 'BurialSiteTypes' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes';
|
||||
export default function addRecord(recordTable: RecordTable, recordName: string, orderNumber: number | string, user: User): Promise<number>;
|
||||
type RecordTable = 'BurialSiteStatuses' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes';
|
||||
export default function addRecord(recordTable: RecordTable, recordName: string, orderNumber: number | string, user: User): number;
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
const recordNameColumns = new Map([
|
||||
['BurialSiteStatuses', 'burialSiteStatus'],
|
||||
['BurialSiteTypes', 'burialSiteType'],
|
||||
['WorkOrderMilestoneTypes', 'workOrderMilestoneType'],
|
||||
['WorkOrderTypes', 'workOrderType']
|
||||
]);
|
||||
export default async function addRecord(recordTable, recordName, orderNumber, user) {
|
||||
const database = await acquireConnection();
|
||||
export default function addRecord(recordTable, recordName, orderNumber, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare(`insert into ${recordTable} (
|
||||
|
|
@ -17,7 +17,7 @@ export default async function addRecord(recordTable, recordName, orderNumber, us
|
|||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?)`)
|
||||
.run(recordName, orderNumber === '' ? -1 : orderNumber, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.release();
|
||||
database.close();
|
||||
clearCacheByTableName(recordTable);
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,26 @@
|
|||
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'
|
||||
|
||||
type RecordTable =
|
||||
| 'BurialSiteStatuses'
|
||||
| 'BurialSiteTypes'
|
||||
| 'WorkOrderMilestoneTypes'
|
||||
| 'WorkOrderTypes'
|
||||
|
||||
const recordNameColumns = new Map<RecordTable, string>([
|
||||
['BurialSiteStatuses', 'burialSiteStatus'],
|
||||
['BurialSiteTypes', 'burialSiteType'],
|
||||
['WorkOrderMilestoneTypes', 'workOrderMilestoneType'],
|
||||
['WorkOrderTypes', 'workOrderType']
|
||||
])
|
||||
|
||||
export default async function addRecord(
|
||||
export default function addRecord(
|
||||
recordTable: RecordTable,
|
||||
recordName: string,
|
||||
orderNumber: number | string,
|
||||
user: User
|
||||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
|
|
@ -43,7 +42,7 @@ export default async function addRecord(
|
|||
rightNowMillis
|
||||
)
|
||||
|
||||
database.release()
|
||||
database.close()
|
||||
|
||||
clearCacheByTableName(recordTable)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
export interface AddWorkOrderForm {
|
||||
workOrderTypeId: number | string;
|
||||
workOrderNumber?: string;
|
||||
workOrderDescription: string;
|
||||
workOrderOpenDateString?: string;
|
||||
workOrderNumber?: string;
|
||||
workOrderTypeId: number | string;
|
||||
workOrderCloseDateString?: string;
|
||||
workOrderOpenDateString?: string;
|
||||
contractId?: string;
|
||||
}
|
||||
export default function addWorkOrder(workOrderForm: AddWorkOrderForm, user: User): Promise<number>;
|
||||
export default function addWorkOrder(workOrderForm: AddWorkOrderForm, user: User): number;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
import { dateStringToInteger, dateToInteger } from '@cityssm/utils-datetime';
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import addWorkOrderContract from './addWorkOrderContract.js';
|
||||
import getNextWorkOrderNumber from './getNextWorkOrderNumber.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function addWorkOrder(workOrderForm, user) {
|
||||
const database = await acquireConnection();
|
||||
export default function addWorkOrder(workOrderForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNow = new Date();
|
||||
let workOrderNumber = workOrderForm.workOrderNumber;
|
||||
if ((workOrderNumber ?? '') === '') {
|
||||
workOrderNumber = await getNextWorkOrderNumber(database);
|
||||
workOrderNumber = getNextWorkOrderNumber(database);
|
||||
}
|
||||
const result = database
|
||||
.prepare(`insert into WorkOrders (
|
||||
|
|
@ -23,11 +24,11 @@ export default async function addWorkOrder(workOrderForm, user) {
|
|||
: dateStringToInteger(workOrderForm.workOrderCloseDateString), user.userName, rightNow.getTime(), user.userName, rightNow.getTime());
|
||||
const workOrderId = result.lastInsertRowid;
|
||||
if ((workOrderForm.contractId ?? '') !== '') {
|
||||
await addWorkOrderContract({
|
||||
addWorkOrderContract({
|
||||
contractId: workOrderForm.contractId,
|
||||
workOrderId,
|
||||
contractId: workOrderForm.contractId
|
||||
}, user, database);
|
||||
}
|
||||
database.release();
|
||||
database.close();
|
||||
return workOrderId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,32 +3,37 @@ import {
|
|||
dateStringToInteger,
|
||||
dateToInteger
|
||||
} from '@cityssm/utils-datetime'
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
|
||||
import addWorkOrderContract from './addWorkOrderContract.js'
|
||||
import getNextWorkOrderNumber from './getNextWorkOrderNumber.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export interface AddWorkOrderForm {
|
||||
workOrderTypeId: number | string
|
||||
workOrderNumber?: string
|
||||
workOrderDescription: string
|
||||
workOrderOpenDateString?: string
|
||||
workOrderNumber?: string
|
||||
|
||||
workOrderTypeId: number | string
|
||||
|
||||
workOrderCloseDateString?: string
|
||||
workOrderOpenDateString?: string
|
||||
|
||||
contractId?: string
|
||||
}
|
||||
|
||||
export default async function addWorkOrder(
|
||||
export default function addWorkOrder(
|
||||
workOrderForm: AddWorkOrderForm,
|
||||
user: User
|
||||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNow = new Date()
|
||||
|
||||
let workOrderNumber = workOrderForm.workOrderNumber
|
||||
|
||||
if ((workOrderNumber ?? '') === '') {
|
||||
workOrderNumber = await getNextWorkOrderNumber(database)
|
||||
workOrderNumber = getNextWorkOrderNumber(database)
|
||||
}
|
||||
|
||||
const result = database
|
||||
|
|
@ -63,17 +68,17 @@ export default async function addWorkOrder(
|
|||
const workOrderId = result.lastInsertRowid as number
|
||||
|
||||
if ((workOrderForm.contractId ?? '') !== '') {
|
||||
await addWorkOrderContract(
|
||||
addWorkOrderContract(
|
||||
{
|
||||
contractId: workOrderForm.contractId as string,
|
||||
workOrderId,
|
||||
contractId: workOrderForm.contractId as string
|
||||
},
|
||||
user,
|
||||
database
|
||||
)
|
||||
}
|
||||
|
||||
database.release()
|
||||
database.close()
|
||||
|
||||
return workOrderId
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export interface AddForm {
|
||||
workOrderId: number | string;
|
||||
burialSiteId: number | string;
|
||||
workOrderId: number | string;
|
||||
}
|
||||
export default function addWorkOrderBurialSite(workOrderLotForm: AddForm, user: User): Promise<boolean>;
|
||||
export default function addWorkOrderBurialSite(workOrderLotForm: AddForm, user: User): boolean;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
export default async function addWorkOrderBurialSite(workOrderLotForm, user) {
|
||||
const database = await acquireConnection();
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
export default function addWorkOrderBurialSite(workOrderLotForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const row = database
|
||||
.prepare(`select recordDelete_timeMillis
|
||||
|
|
@ -32,6 +33,6 @@ export default async function addWorkOrderBurialSite(workOrderLotForm, user) {
|
|||
.run(user.userName, rightNowMillis, user.userName, rightNowMillis, workOrderLotForm.workOrderId, workOrderLotForm.burialSiteId);
|
||||
}
|
||||
}
|
||||
database.release();
|
||||
database.close();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue