diff --git a/.codeclimate.yml b/.codeclimate.yml deleted file mode 100644 index b838579f..00000000 --- a/.codeclimate.yml +++ /dev/null @@ -1,18 +0,0 @@ -version: "2" -checks: - file-lines: - config: - threshold: 1500 - method-complexity: - config: - threshold: 20 - method-lines: - config: - threshold: 500 -exclude_patterns: -- "cypress/" -- "**/node_modules/" -- "temp/" -- "test/" -- "**/*.d.ts" -- "**/*.js" \ No newline at end of file diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index d1b9d32e..00000000 --- a/.eslintignore +++ /dev/null @@ -1,3 +0,0 @@ -**/*.d.ts -**/*.ejs -**/*.js diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index 50fdedfe..00000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: Coverage Testing - -on: [workflow_dispatch, push, pull_request] - -permissions: read-all - -jobs: - Coverage: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - node: [ 18, 20, 21 ] - env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }} - name: Node ${{ matrix.node }} - steps: - - uses: actions/checkout@v4 - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - - - name: Install Application - run: | - npm ci - npm install -g mocha c8 cypress@13 - - - name: Copy Test Config - run: cp ./data/config.testing.js ./data/config.js - - - name: Test Application Startup - run: npm run test:startup - - - name: Code Climate (Before) - if: ${{ github.event_name != 'pull_request' && env.CC_TEST_REPORTER_ID != '' && matrix.node == 20 }} - run: | - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./codeclimate-test-reporter - chmod +x codeclimate-test-reporter - ./codeclimate-test-reporter before-build - - - name: Verify Cypress - run: cypress verify - env: - CYPRESS_VERIFY_TIMEOUT: 600000 - - - name: Run Coverage Testing - run: c8 --reporter=lcov --reporter=text --reporter=text-summary mocha --timeout 10000 --exit - - - name: Code Climate (After) - if: ${{ github.event_name != 'pull_request' && env.CC_TEST_REPORTER_ID != '' && matrix.node == 20 }} - run: | - ./codeclimate-test-reporter after-build -t lcov --exit-code $? - - - name: Codecov - if: ${{ github.event_name != 'pull_request' && env.CODECOV_TOKEN != '' && matrix.node == 20 }} - run: | - curl -Os https://uploader.codecov.io/latest/linux/codecov - chmod +x codecov - ./codecov -t ${CODECOV_TOKEN} - - - name: DeepSource - if: ${{ github.event_name != 'pull_request' && env.DEEPSOURCE_DSN != '' && matrix.node == 20 }} - run: | - # Install deepsource CLI - curl https://deepsource.io/cli | sh - - # From the root directory, run the report coverage command - ./bin/deepsource report --analyzer test-coverage --key javascript --value-file ./coverage/lcov.info \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md index a9435528..e10515e9 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ -MIT License +# MIT License -Copyright (c) 2023 The City of Sault Ste. Marie +Copyright (c) 2025 The City of Sault Ste. Marie Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index fc393b30..953b3d4e 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,13 @@ -# Lot Occupancy System +# Sunrise Cemetery Management System (CMS) -[![DeepSource](https://app.deepsource.com/gh/cityssm/lot-occupancy-system.svg/?label=active+issues&show_trend=true&token=8rYoZ1g7FoZHstfQmOzvlBn7)](https://app.deepsource.com/gh/cityssm/lot-occupancy-system/) -[![Maintainability](https://api.codeclimate.com/v1/badges/11a8975b332f66e6eec7/maintainability)](https://codeclimate.com/github/cityssm/lot-occupancy-system/maintainability) -[![codecov](https://codecov.io/gh/cityssm/lot-occupancy-system/branch/main/graph/badge.svg?token=1M38ZVCLKE)](https://codecov.io/gh/cityssm/lot-occupancy-system) -[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/cityssm/lot-occupancy-system/coverage.yml?branch=main)](https://github.com/cityssm/lot-occupancy-system/actions/workflows/coverage.yml) -[![lot-occupancy-system](https://img.shields.io/endpoint?url=https://cloud.cypress.io/badge/simple/xya1fn&style=flat&logo=cypress)](https://cloud.cypress.io/projects/xya1fn/runs) +🚧 **In development** 🚧 -**In development** +**A web-based application that allows cemetery managers to manage their cemetery records** -![Lot View](docs/images/lotView.png) - -A system for managing the occupancy of lots. - -Built with **cemetery management** in mind, but flexible enough to handle marinas and campgrounds as well. - -[**User Documentation**](docs/) (In The Works) - -## Key Features - -**Maps are optional!**
-Many systems of this type start with a map, and drill down into the data from it. -This can result in a huge amount of effort to get started. -This system can run "out-of-the-box" without maps, with the option to add them when it makes sense. +This is a major refactoring of the +[Lot Occupancy System](https://github.com/cityssm/lot-occupancy-system), +originally built with multiple focuses. This fork reworks the project to focus exculsively +on cemetery management. ## About this Project diff --git a/_config.yml b/_config.yml index a6192c77..36ec6895 100644 --- a/_config.yml +++ b/_config.yml @@ -1,2 +1,2 @@ theme: jekyll-theme-cayman -title: Lot Occupancy System \ No newline at end of file +title: Sunrise Cemetery Management System \ No newline at end of file diff --git a/app.js b/app.js index 43ba3d3f..3e8d577c 100644 --- a/app.js +++ b/app.js @@ -10,11 +10,12 @@ import session from 'express-session'; import createError from 'http-errors'; import FileStore from 'session-file-store'; import { useTestDatabases } from './data/databasePaths.js'; +import { DEBUG_NAMESPACE } from './debug.config.js'; import * as permissionHandlers from './handlers/permissions.js'; import { getSafeRedirectURL } from './helpers/functions.authentication.js'; -import * as configFunctions from './helpers/functions.config.js'; +import * as configFunctions from './helpers/config.helpers.js'; import * as printFunctions from './helpers/functions.print.js'; -import { initializeDatabase } from './helpers/initializer.database.js'; +import { initializeDatabase } from './helpers/helpers.database.js'; import routerAdmin from './routes/admin.js'; import routerApi from './routes/api.js'; import routerDashboard from './routes/dashboard.js'; @@ -26,11 +27,11 @@ 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(`lot-occupancy-system:app:${process.pid}`); +const debug = Debug(`${DEBUG_NAMESPACE}:app:${process.pid}`); /* * INITIALIZE THE DATABASE */ -initializeDatabase(); +await initializeDatabase(); /* * INITIALIZE APP */ @@ -88,7 +89,7 @@ const FileStoreSession = FileStore(session); app.use(session({ store: new FileStoreSession({ path: './data/sessions', - logFn: Debug(`lot-occupancy-system:session:${process.pid}`), + logFn: Debug(`${DEBUG_NAMESPACE}:session:${process.pid}`), retries: 20 }), name: sessionCookieName, diff --git a/app.ts b/app.ts index c0a0b704..91831643 100644 --- a/app.ts +++ b/app.ts @@ -12,11 +12,12 @@ import createError from 'http-errors' import FileStore from 'session-file-store' import { useTestDatabases } from './data/databasePaths.js' +import { DEBUG_NAMESPACE } from './debug.config.js' import * as permissionHandlers from './handlers/permissions.js' import { getSafeRedirectURL } from './helpers/functions.authentication.js' -import * as configFunctions from './helpers/functions.config.js' +import * as configFunctions from './helpers/config.helpers.js' import * as printFunctions from './helpers/functions.print.js' -import { initializeDatabase } from './helpers/initializer.database.js' +import { initializeDatabase } from './helpers/helpers.database.js' import routerAdmin from './routes/admin.js' import routerApi from './routes/api.js' import routerDashboard from './routes/dashboard.js' @@ -29,13 +30,13 @@ import routerReports from './routes/reports.js' import routerWorkOrders from './routes/workOrders.js' import { version } from './version.js' -const debug = Debug(`lot-occupancy-system:app:${process.pid}`) +const debug = Debug(`${DEBUG_NAMESPACE}:app:${process.pid}`) /* * INITIALIZE THE DATABASE */ -initializeDatabase() +await initializeDatabase() /* * INITIALIZE APP @@ -150,7 +151,7 @@ app.use( session({ store: new FileStoreSession({ path: './data/sessions', - logFn: Debug(`lot-occupancy-system:session:${process.pid}`), + logFn: Debug(`${DEBUG_NAMESPACE}:session:${process.pid}`), retries: 20 }), name: sessionCookieName, @@ -227,11 +228,7 @@ app.get(`${urlPrefix}/`, sessionChecker, (_request, response) => { app.use(`${urlPrefix}/dashboard`, sessionChecker, routerDashboard) -app.use( - `${urlPrefix}/api/:apiKey`, - permissionHandlers.apiGetHandler, - routerApi -) +app.use(`${urlPrefix}/api/:apiKey`, permissionHandlers.apiGetHandler, routerApi) app.use(`${urlPrefix}/print`, sessionChecker, routerPrint) app.use(`${urlPrefix}/maps`, sessionChecker, routerMaps) diff --git a/bin/www.js b/bin/www.js index f2714086..7b84d712 100644 --- a/bin/www.js +++ b/bin/www.js @@ -6,8 +6,9 @@ import ntfyPublish from '@cityssm/ntfy-publish'; import { secondsToMillis } from '@cityssm/to-millis'; import Debug from 'debug'; import exitHook from 'exit-hook'; -import { getConfigProperty } from '../helpers/functions.config.js'; -const debug = Debug(`lot-occupancy-system:www:${process.pid}`); +import { DEBUG_NAMESPACE } from '../debug.config.js'; +import { getConfigProperty } from '../helpers/config.helpers.js'; +const debug = Debug(`${DEBUG_NAMESPACE}:www:${process.pid}`); const directoryName = path.dirname(fileURLToPath(import.meta.url)); const processCount = Math.min(getConfigProperty('application.maximumProcesses'), os.cpus().length); process.title = `${getConfigProperty('application.applicationName')} (Primary)`; diff --git a/bin/www.ts b/bin/www.ts index ea8752ee..ade1101f 100644 --- a/bin/www.ts +++ b/bin/www.ts @@ -8,10 +8,11 @@ import { secondsToMillis } from '@cityssm/to-millis' import Debug from 'debug' import exitHook from 'exit-hook' -import { getConfigProperty } from '../helpers/functions.config.js' +import { DEBUG_NAMESPACE } from '../debug.config.js' +import { getConfigProperty } from '../helpers/config.helpers.js' import type { WorkerMessage } from '../types/applicationTypes.js' -const debug = Debug(`lot-occupancy-system:www:${process.pid}`) +const debug = Debug(`${DEBUG_NAMESPACE}:www:${process.pid}`) const directoryName = path.dirname(fileURLToPath(import.meta.url)) diff --git a/bin/wwwProcess.js b/bin/wwwProcess.js index 51dd0c23..70fc4b88 100644 --- a/bin/wwwProcess.js +++ b/bin/wwwProcess.js @@ -4,8 +4,9 @@ import http from 'node:http'; import Debug from 'debug'; import exitHook from 'exit-hook'; import { app } from '../app.js'; -import { getConfigProperty } from '../helpers/functions.config.js'; -const debug = Debug(`lot-occupancy-system:wwwProcess:${process.pid}`); +import { DEBUG_NAMESPACE } from '../debug.config.js'; +import { getConfigProperty } from '../helpers/config.helpers.js'; +const debug = Debug(`${DEBUG_NAMESPACE}:wwwProcess:${process.pid}`); function onError(error) { if (error.syscall !== 'listen') { throw error; diff --git a/bin/wwwProcess.ts b/bin/wwwProcess.ts index 395f56a5..9bbb9111 100644 --- a/bin/wwwProcess.ts +++ b/bin/wwwProcess.ts @@ -7,9 +7,10 @@ import Debug from 'debug' import exitHook from 'exit-hook' import { app } from '../app.js' -import { getConfigProperty } from '../helpers/functions.config.js' +import { DEBUG_NAMESPACE } from '../debug.config.js' +import { getConfigProperty } from '../helpers/config.helpers.js' -const debug = Debug(`lot-occupancy-system:wwwProcess:${process.pid}`) +const debug = Debug(`${DEBUG_NAMESPACE}:wwwProcess:${process.pid}`) interface ServerError extends Error { syscall: string @@ -57,9 +58,7 @@ function onListening(server: http.Server): void { * Initialize HTTP */ -process.title = `${getConfigProperty( - 'application.applicationName' -)} (Worker)` +process.title = `${getConfigProperty('application.applicationName')} (Worker)` const httpPort = getConfigProperty('application.httpPort') diff --git a/cypress/e2e/01-admin/feeManagement.cy.js b/cypress/e2e/01-admin/feeManagement.cy.js index f3f0c111..1e16b986 100644 --- a/cypress/e2e/01-admin/feeManagement.cy.js +++ b/cypress/e2e/01-admin/feeManagement.cy.js @@ -1,4 +1,4 @@ -import { getConfigProperty } from '../../../helpers/functions.config.js'; +import { getConfigProperty } from '../../../helpers/config.helpers.js'; import { testAdmin } from '../../../test/_globals.js'; import { ajaxDelayMillis, login, logout } from '../../support/index.js'; describe('Admin - Fee Management', () => { diff --git a/cypress/e2e/01-admin/feeManagement.cy.ts b/cypress/e2e/01-admin/feeManagement.cy.ts index 21a193e8..b2ada34d 100644 --- a/cypress/e2e/01-admin/feeManagement.cy.ts +++ b/cypress/e2e/01-admin/feeManagement.cy.ts @@ -1,4 +1,4 @@ -import { getConfigProperty } from '../../../helpers/functions.config.js' +import { getConfigProperty } from '../../../helpers/config.helpers.js' import { testAdmin } from '../../../test/_globals.js' import type { Fee } from '../../../types/recordTypes.js' import { ajaxDelayMillis, login, logout } from '../../support/index.js' diff --git a/cypress/e2e/02-update/maps.cy.js b/cypress/e2e/02-update/maps.cy.js index ce90d3c8..f8c424d9 100644 --- a/cypress/e2e/02-update/maps.cy.js +++ b/cypress/e2e/02-update/maps.cy.js @@ -1,4 +1,4 @@ -import { getConfigProperty } from '../../../helpers/functions.config.js'; +import { getConfigProperty } from '../../../helpers/config.helpers.js'; import { testUpdate } from '../../../test/_globals.js'; import { login, logout } from '../../support/index.js'; describe('Update - Maps', () => { diff --git a/cypress/e2e/02-update/maps.cy.ts b/cypress/e2e/02-update/maps.cy.ts index c2c70129..903b1a35 100644 --- a/cypress/e2e/02-update/maps.cy.ts +++ b/cypress/e2e/02-update/maps.cy.ts @@ -1,4 +1,4 @@ -import { getConfigProperty } from '../../../helpers/functions.config.js' +import { getConfigProperty } from '../../../helpers/config.helpers.js' import { testUpdate } from '../../../test/_globals.js' import type { MapRecord } from '../../../types/recordTypes.js' import { login, logout } from '../../support/index.js' diff --git a/cypress/e2e/xx-other/keepAlive.cy.d.ts b/cypress/e2e/xx-other/keepAlive.cy.d.ts index e69de29b..cb0ff5c3 100644 --- a/cypress/e2e/xx-other/keepAlive.cy.d.ts +++ b/cypress/e2e/xx-other/keepAlive.cy.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/cypress/e2e/xx-other/keepAlive.cy.js b/cypress/e2e/xx-other/keepAlive.cy.js index 0741cb75..1ea89760 100644 --- a/cypress/e2e/xx-other/keepAlive.cy.js +++ b/cypress/e2e/xx-other/keepAlive.cy.js @@ -5,3 +5,4 @@ describe('Keep Alive', () => { }); }); }); +export {}; diff --git a/data/config.base.js b/data/config.base.js index c6098c58..ca7dc17c 100644 --- a/data/config.base.js +++ b/data/config.base.js @@ -6,9 +6,8 @@ export const config = { aliases: {}, settings: { fees: {}, - map: {}, - lot: {}, - lotOccupancy: {}, + cemeteries: {}, + contracts: {}, workOrders: {}, adminCleanup: {}, printPdf: {}, diff --git a/data/config.base.ts b/data/config.base.ts index f122f4c7..cc0a2f13 100644 --- a/data/config.base.ts +++ b/data/config.base.ts @@ -8,9 +8,8 @@ export const config: Config = { aliases: {}, settings: { fees: {}, - map: {}, - lot: {}, - lotOccupancy: {}, + cemeteries: {}, + contracts: {}, workOrders: {}, adminCleanup: {}, printPdf: {}, diff --git a/data/config.cemetery.ontario.d.ts b/data/config.baseOntario.d.ts similarity index 100% rename from data/config.cemetery.ontario.d.ts rename to data/config.baseOntario.d.ts diff --git a/data/config.baseOntario.js b/data/config.baseOntario.js new file mode 100644 index 00000000..a8498898 --- /dev/null +++ b/data/config.baseOntario.js @@ -0,0 +1,6 @@ +import { config as baseConfig } from './config.base.js'; +export const config = Object.assign({}, baseConfig); +config.settings.contracts.provinceDefault = 'ON'; +config.settings.cemeteries.provinceDefault = 'ON'; +config.settings.fees.taxPercentageDefault = 13; +export default config; diff --git a/data/config.baseOntario.ts b/data/config.baseOntario.ts new file mode 100644 index 00000000..ee30a862 --- /dev/null +++ b/data/config.baseOntario.ts @@ -0,0 +1,11 @@ +import { config as baseConfig } from './config.base.js' + +export const config = Object.assign({}, baseConfig) + +config.settings.contracts.provinceDefault = 'ON' + +config.settings.cemeteries.provinceDefault = 'ON' + +config.settings.fees.taxPercentageDefault = 13 + +export default config diff --git a/data/config.cemetery.d.ts b/data/config.baseSsm.d.ts similarity index 100% rename from data/config.cemetery.d.ts rename to data/config.baseSsm.d.ts diff --git a/data/config.baseSsm.js b/data/config.baseSsm.js new file mode 100644 index 00000000..f3350dd6 --- /dev/null +++ b/data/config.baseSsm.js @@ -0,0 +1,17 @@ +import { config as cemeteryConfig } from './config.baseOntario.js'; +export const config = { ...cemeteryConfig }; +config.aliases.externalReceiptNumber = 'GP Receipt Number'; +config.settings.contracts.cityDefault = 'Sault Ste. Marie'; +config.settings.contracts.prints = [ + 'pdf/ssm.cemetery.burialPermit', + 'pdf/ssm.cemetery.contract' +]; +config.settings.cemeteries.cityDefault = 'Sault Ste. Marie'; +config.settings.workOrders.workOrderNumberLength = 6; +config.settings.workOrders.workOrderMilestoneDateRecentBeforeDays = 7; +config.settings.workOrders.workOrderMilestoneDateRecentAfterDays = 30; +config.settings.dynamicsGP = { + integrationIsEnabled: true, + lookupOrder: ['diamond/cashReceipt', 'diamond/extendedInvoice'] +}; +export default config; diff --git a/data/config.baseSsm.ts b/data/config.baseSsm.ts new file mode 100644 index 00000000..4f269582 --- /dev/null +++ b/data/config.baseSsm.ts @@ -0,0 +1,26 @@ +import type { Config } from '../types/configTypes.js' + +import { config as cemeteryConfig } from './config.baseOntario.js' + +export const config: Config = { ...cemeteryConfig } + +config.aliases.externalReceiptNumber = 'GP Receipt Number' + +config.settings.contracts.cityDefault = 'Sault Ste. Marie' +config.settings.contracts.prints = [ + 'pdf/ssm.cemetery.burialPermit', + 'pdf/ssm.cemetery.contract' +] + +config.settings.cemeteries.cityDefault = 'Sault Ste. Marie' + +config.settings.workOrders.workOrderNumberLength = 6 +config.settings.workOrders.workOrderMilestoneDateRecentBeforeDays = 7 +config.settings.workOrders.workOrderMilestoneDateRecentAfterDays = 30 + +config.settings.dynamicsGP = { + integrationIsEnabled: true, + lookupOrder: ['diamond/cashReceipt', 'diamond/extendedInvoice'] +} + +export default config diff --git a/data/config.cemetery.js b/data/config.cemetery.js deleted file mode 100644 index 4111fbe6..00000000 --- a/data/config.cemetery.js +++ /dev/null @@ -1,19 +0,0 @@ -import { config as baseConfig } from './config.base.js'; -export const config = { ...baseConfig }; -config.application = { - applicationName: 'Cemetery Management System', - backgroundURL: '/images/cemetery-background.jpg', - logoURL: '/images/cemetery-logo.svg' -}; -config.aliases.lot = 'Burial Site'; -config.aliases.lots = 'Burial Sites'; -config.aliases.map = 'Cemetery'; -config.aliases.maps = 'Cemeteries'; -config.aliases.occupancy = 'Contract'; -config.aliases.occupancies = 'Contracts'; -config.aliases.occupant = 'Customer'; -config.aliases.occupants = 'Customers'; -config.aliases.workOrderOpenDate = 'Order Date'; -config.aliases.workOrderCloseDate = 'Completion Date'; -config.settings.lotOccupancy.occupancyEndDateIsRequired = false; -export default config; diff --git a/data/config.cemetery.ontario.js b/data/config.cemetery.ontario.js deleted file mode 100644 index b788099e..00000000 --- a/data/config.cemetery.ontario.js +++ /dev/null @@ -1,6 +0,0 @@ -import { config as cemeteryConfig } from './config.cemetery.js'; -export const config = Object.assign({}, cemeteryConfig); -config.settings.lotOccupancy.occupantProvinceDefault = 'ON'; -config.settings.map.mapProvinceDefault = 'ON'; -config.settings.fees.taxPercentageDefault = 13; -export default config; diff --git a/data/config.cemetery.ontario.ts b/data/config.cemetery.ontario.ts deleted file mode 100644 index 59d36276..00000000 --- a/data/config.cemetery.ontario.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { config as cemeteryConfig } from './config.cemetery.js' - -export const config = Object.assign({}, cemeteryConfig) - -config.settings.lotOccupancy.occupantProvinceDefault = 'ON' - -config.settings.map.mapProvinceDefault = 'ON' - -config.settings.fees.taxPercentageDefault = 13 - -export default config diff --git a/data/config.cemetery.ssm.d.ts b/data/config.cemetery.ssm.d.ts deleted file mode 100644 index f4b7dd5f..00000000 --- a/data/config.cemetery.ssm.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { Config } from '../types/configTypes.js'; -export declare const config: Config; -export declare function lotNameSortNameFunction(lotName: string): string; -export default config; diff --git a/data/config.cemetery.ssm.js b/data/config.cemetery.ssm.js deleted file mode 100644 index e0fa7845..00000000 --- a/data/config.cemetery.ssm.js +++ /dev/null @@ -1,65 +0,0 @@ -import NodeCache from 'node-cache'; -import { config as cemeteryConfig } from './config.cemetery.ontario.js'; -export const config = { ...cemeteryConfig }; -config.aliases.occupancyStartDate = 'Purchase Date'; -config.aliases.externalReceiptNumber = 'GP Receipt Number'; -config.settings.lot.lotNamePattern = - /^[\dA-Z]{2}-(B[\dA-Z]+-)?(R[\dA-Z]+-)?(L[\dA-Z]+-)?G[\dA-Z]+(, Interment \d+)?$/; -config.settings.lot.lotNameHelpText = `Two digit cemetery-Block-Range-Lot-Grave, Interment number\n - ex. XX-BA-R41-L15-G3A, Interment 1`; -const numericPadding = '00000'; -const lotNameSortNameCache = new NodeCache({ - stdTTL: 5 * 60, - useClones: false -}); -export function lotNameSortNameFunction(lotName) { - let sortName = lotNameSortNameCache.get(lotName) ?? ''; - if (sortName === '') { - try { - const lotNameSplit = lotName.toUpperCase().split('-'); - const cleanLotNamePieces = []; - for (let lotNamePiece of lotNameSplit) { - if (cleanLotNamePieces.length === 0) { - cleanLotNamePieces.push(lotNamePiece); - continue; - } - let numericPiece = numericPadding; - let letterPiece = ''; - const firstLetter = lotNamePiece.charAt(0); - lotNamePiece = lotNamePiece.slice(1); - for (const letter of lotNamePiece) { - if (letterPiece === '' && '0123456789'.includes(letter)) { - numericPiece += letter; - } - else { - letterPiece += letter; - } - } - cleanLotNamePieces.push(firstLetter + - numericPiece.slice(-1 * numericPadding.length) + - letterPiece); - } - sortName = cleanLotNamePieces.join('-'); - } - catch { - sortName = lotName; - } - lotNameSortNameCache.set(lotName, sortName); - } - return sortName; -} -config.settings.lot.lotNameSortNameFunction = lotNameSortNameFunction; -config.settings.lotOccupancy.occupantCityDefault = 'Sault Ste. Marie'; -config.settings.lotOccupancy.prints = [ - 'pdf/ssm.cemetery.burialPermit', - 'pdf/ssm.cemetery.contract' -]; -config.settings.map.mapCityDefault = 'Sault Ste. Marie'; -config.settings.workOrders.workOrderNumberLength = 6; -config.settings.workOrders.workOrderMilestoneDateRecentBeforeDays = 7; -config.settings.workOrders.workOrderMilestoneDateRecentAfterDays = 30; -config.settings.dynamicsGP = { - integrationIsEnabled: true, - lookupOrder: ['diamond/cashReceipt', 'diamond/extendedInvoice'] -}; -export default config; diff --git a/data/config.cemetery.ssm.ts b/data/config.cemetery.ssm.ts deleted file mode 100644 index 63ef6cf4..00000000 --- a/data/config.cemetery.ssm.ts +++ /dev/null @@ -1,91 +0,0 @@ -import NodeCache from 'node-cache' - -import type { Config } from '../types/configTypes.js' - -import { config as cemeteryConfig } from './config.cemetery.ontario.js' - -export const config: Config = { ...cemeteryConfig} - -config.aliases.occupancyStartDate = 'Purchase Date' -config.aliases.externalReceiptNumber = 'GP Receipt Number' - -config.settings.lot.lotNamePattern = - /^[\dA-Z]{2}-(B[\dA-Z]+-)?(R[\dA-Z]+-)?(L[\dA-Z]+-)?G[\dA-Z]+(, Interment \d+)?$/ - -config.settings.lot.lotNameHelpText = `Two digit cemetery-Block-Range-Lot-Grave, Interment number\n - ex. XX-BA-R41-L15-G3A, Interment 1` - -const numericPadding = '00000' - -const lotNameSortNameCache = new NodeCache({ - stdTTL: 5 * 60, - useClones: false -}) - -export function lotNameSortNameFunction(lotName: string): string { - let sortName: string = lotNameSortNameCache.get(lotName) ?? '' - - if (sortName === '') { - try { - const lotNameSplit = lotName.toUpperCase().split('-') - - const cleanLotNamePieces: string[] = [] - - for (let lotNamePiece of lotNameSplit) { - if (cleanLotNamePieces.length === 0) { - cleanLotNamePieces.push(lotNamePiece) - continue - } - - let numericPiece = numericPadding - let letterPiece = '' - - const firstLetter = lotNamePiece.charAt(0) - lotNamePiece = lotNamePiece.slice(1) - - for (const letter of lotNamePiece) { - if (letterPiece === '' && '0123456789'.includes(letter)) { - numericPiece += letter - } else { - letterPiece += letter - } - } - - cleanLotNamePieces.push( - firstLetter + - numericPiece.slice(-1 * numericPadding.length) + - letterPiece - ) - } - - sortName = cleanLotNamePieces.join('-') - } catch { - sortName = lotName - } - - lotNameSortNameCache.set(lotName, sortName) - } - - return sortName -} - -config.settings.lot.lotNameSortNameFunction = lotNameSortNameFunction - -config.settings.lotOccupancy.occupantCityDefault = 'Sault Ste. Marie' -config.settings.lotOccupancy.prints = [ - 'pdf/ssm.cemetery.burialPermit', - 'pdf/ssm.cemetery.contract' -] - -config.settings.map.mapCityDefault = 'Sault Ste. Marie' - -config.settings.workOrders.workOrderNumberLength = 6 -config.settings.workOrders.workOrderMilestoneDateRecentBeforeDays = 7 -config.settings.workOrders.workOrderMilestoneDateRecentAfterDays = 30 - -config.settings.dynamicsGP = { - integrationIsEnabled: true, - lookupOrder: ['diamond/cashReceipt', 'diamond/extendedInvoice'] -} - -export default config diff --git a/data/config.cemetery.ts b/data/config.cemetery.ts deleted file mode 100644 index 024baaff..00000000 --- a/data/config.cemetery.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { Config } from '../types/configTypes.js' - -import { config as baseConfig } from './config.base.js' - -export const config: Config = { ...baseConfig } - -config.application = { - applicationName: 'Cemetery Management System', - backgroundURL: '/images/cemetery-background.jpg', - logoURL: '/images/cemetery-logo.svg' -} - -config.aliases.lot = 'Burial Site' -config.aliases.lots = 'Burial Sites' -config.aliases.map = 'Cemetery' -config.aliases.maps = 'Cemeteries' -config.aliases.occupancy = 'Contract' -config.aliases.occupancies = 'Contracts' -config.aliases.occupant = 'Customer' -config.aliases.occupants = 'Customers' -config.aliases.workOrderOpenDate = 'Order Date' -config.aliases.workOrderCloseDate = 'Completion Date' - -config.settings.lotOccupancy.occupancyEndDateIsRequired = false - -export default config diff --git a/data/config.defaultValues.d.ts b/data/config.defaultValues.d.ts index 03982e18..df329499 100644 --- a/data/config.defaultValues.d.ts +++ b/data/config.defaultValues.d.ts @@ -21,15 +21,6 @@ export declare const configDefaultValues: { 'users.canLogin': string[]; 'users.canUpdate': string[]; 'users.isAdmin': string[]; - 'aliases.lot': string; - 'aliases.lots': string; - 'aliases.map': string; - 'aliases.maps': string; - 'aliases.occupancy': string; - 'aliases.occupancies': string; - 'aliases.occupancyStartDate': string; - 'aliases.occupant': string; - 'aliases.occupants': string; 'aliases.externalReceiptNumber': string; 'aliases.workOrderOpenDate': string; 'aliases.workOrderCloseDate': string; diff --git a/data/config.defaultValues.js b/data/config.defaultValues.js index 889a9599..1ab54e3d 100644 --- a/data/config.defaultValues.js +++ b/data/config.defaultValues.js @@ -1,7 +1,7 @@ import { hoursToMillis } from '@cityssm/to-millis'; export const configDefaultValues = { activeDirectory: undefined, - 'application.applicationName': 'Lot Occupancy System', + 'application.applicationName': 'Sunrise CMS', 'application.backgroundURL': '/images/cemetery-background.jpg', 'application.logoURL': '/images/cemetery-logo.png', 'application.httpPort': 7000, @@ -12,26 +12,17 @@ export const configDefaultValues = { 'reverseProxy.disableCompression': false, 'reverseProxy.disableEtag': false, 'reverseProxy.urlPrefix': '', - 'session.cookieName': 'lot-occupancy-system-user-sid', - 'session.secret': 'cityssm/lot-occupancy-system', + 'session.cookieName': 'sunrise-user-sid', + 'session.secret': 'cityssm/sunrise', 'session.maxAgeMillis': hoursToMillis(1), 'session.doKeepAlive': false, 'users.testing': [], 'users.canLogin': ['administrator'], 'users.canUpdate': [], 'users.isAdmin': ['administrator'], - 'aliases.lot': 'Lot', - 'aliases.lots': 'Lots', - 'aliases.map': 'Map', - 'aliases.maps': 'Maps', - 'aliases.occupancy': 'Occupancy', - 'aliases.occupancies': 'Occupancies', - 'aliases.occupancyStartDate': 'Start Date', - 'aliases.occupant': 'Occupant', - 'aliases.occupants': 'Occupants', 'aliases.externalReceiptNumber': 'External Receipt Number', - 'aliases.workOrderOpenDate': 'Open Date', - 'aliases.workOrderCloseDate': 'Close Date', + 'aliases.workOrderOpenDate': 'Order Date', + 'aliases.workOrderCloseDate': 'Completion Date', 'settings.map.mapCityDefault': '', 'settings.map.mapProvinceDefault': '', 'settings.lot.lotNamePattern': undefined, diff --git a/data/config.defaultValues.ts b/data/config.defaultValues.ts index 8b34ff96..ebeb330d 100644 --- a/data/config.defaultValues.ts +++ b/data/config.defaultValues.ts @@ -10,7 +10,7 @@ import type { export const configDefaultValues = { activeDirectory: undefined as unknown as ConfigActiveDirectory, - 'application.applicationName': 'Lot Occupancy System', + 'application.applicationName': 'Sunrise CMS', 'application.backgroundURL': '/images/cemetery-background.jpg', 'application.logoURL': '/images/cemetery-logo.png', 'application.httpPort': 7000, @@ -24,8 +24,8 @@ export const configDefaultValues = { 'reverseProxy.disableEtag': false, 'reverseProxy.urlPrefix': '', - 'session.cookieName': 'lot-occupancy-system-user-sid', - 'session.secret': 'cityssm/lot-occupancy-system', + 'session.cookieName': 'sunrise-user-sid', + 'session.secret': 'cityssm/sunrise', 'session.maxAgeMillis': hoursToMillis(1), 'session.doKeepAlive': false, @@ -34,19 +34,9 @@ export const configDefaultValues = { 'users.canUpdate': [] as string[], 'users.isAdmin': ['administrator'], - 'aliases.lot': 'Lot', - 'aliases.lots': 'Lots', - 'aliases.map': 'Map', - 'aliases.maps': 'Maps', - 'aliases.occupancy': 'Occupancy', - 'aliases.occupancies': 'Occupancies', - 'aliases.occupancyStartDate': 'Start Date', - 'aliases.occupant': 'Occupant', - 'aliases.occupants': 'Occupants', - 'aliases.externalReceiptNumber': 'External Receipt Number', - 'aliases.workOrderOpenDate': 'Open Date', - 'aliases.workOrderCloseDate': 'Close Date', + 'aliases.workOrderOpenDate': 'Order Date', + 'aliases.workOrderCloseDate': 'Completion Date', 'settings.map.mapCityDefault': '', 'settings.map.mapProvinceDefault': '', diff --git a/data/config.testing.js b/data/config.testing.js index d7923bd7..58ea5d30 100644 --- a/data/config.testing.js +++ b/data/config.testing.js @@ -1,4 +1,4 @@ -import { config as cemeteryConfig } from './config.cemetery.ssm.js'; +import { config as cemeteryConfig } from './config.baseSsm.js'; export const config = { ...cemeteryConfig }; config.application.useTestDatabases = true; config.session.doKeepAlive = true; diff --git a/data/config.testing.ts b/data/config.testing.ts index 7e908edd..330e0a03 100644 --- a/data/config.testing.ts +++ b/data/config.testing.ts @@ -1,6 +1,6 @@ import type { Config } from '../types/configTypes.js' -import { config as cemeteryConfig } from './config.cemetery.ssm.js' +import { config as cemeteryConfig } from './config.baseSsm.js' export const config: Config = { ...cemeteryConfig } diff --git a/data/databasePaths.d.ts b/data/databasePaths.d.ts deleted file mode 100644 index 2b563041..00000000 --- a/data/databasePaths.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export declare const useTestDatabases: boolean; -export declare const lotOccupancyDBLive = "data/lotOccupancy.db"; -export declare const lotOccupancyDBTesting = "data/lotOccupancy-testing.db"; -export declare const lotOccupancyDB: string; -export declare const backupFolder = "data/backups"; diff --git a/data/databasePaths.js b/data/databasePaths.js deleted file mode 100644 index c3ef2a1c..00000000 --- a/data/databasePaths.js +++ /dev/null @@ -1,15 +0,0 @@ -import Debug from 'debug'; -import { getConfigProperty } from '../helpers/functions.config.js'; -const debug = Debug('lot-occupancy-system:databasePaths'); -// Determine if test databases should be used -export const useTestDatabases = getConfigProperty('application.useTestDatabases') || - process.env.TEST_DATABASES === 'true'; -if (useTestDatabases) { - debug('Using "-testing" databases.'); -} -export const lotOccupancyDBLive = 'data/lotOccupancy.db'; -export const lotOccupancyDBTesting = 'data/lotOccupancy-testing.db'; -export const lotOccupancyDB = useTestDatabases - ? lotOccupancyDBTesting - : lotOccupancyDBLive; -export const backupFolder = 'data/backups'; diff --git a/data/databasePaths.ts b/data/databasePaths.ts deleted file mode 100644 index 093de9a8..00000000 --- a/data/databasePaths.ts +++ /dev/null @@ -1,24 +0,0 @@ -import Debug from 'debug' - -import { getConfigProperty } from '../helpers/functions.config.js' - -const debug = Debug('lot-occupancy-system:databasePaths') - -// Determine if test databases should be used - -export const useTestDatabases = - getConfigProperty('application.useTestDatabases') || - process.env.TEST_DATABASES === 'true' - -if (useTestDatabases) { - debug('Using "-testing" databases.') -} - -export const lotOccupancyDBLive = 'data/lotOccupancy.db' -export const lotOccupancyDBTesting = 'data/lotOccupancy-testing.db' - -export const lotOccupancyDB = useTestDatabases - ? lotOccupancyDBTesting - : lotOccupancyDBLive - -export const backupFolder = 'data/backups' diff --git a/database/addLot.d.ts b/database/addBurialSite.d.ts similarity index 100% rename from database/addLot.d.ts rename to database/addBurialSite.d.ts diff --git a/database/addLot.js b/database/addBurialSite.js similarity index 100% rename from database/addLot.js rename to database/addBurialSite.js diff --git a/database/addLot.ts b/database/addBurialSite.ts similarity index 100% rename from database/addLot.ts rename to database/addBurialSite.ts diff --git a/database/addBurialSiteComment.d.ts b/database/addBurialSiteComment.d.ts new file mode 100644 index 00000000..0324c67e --- /dev/null +++ b/database/addBurialSiteComment.d.ts @@ -0,0 +1,5 @@ +export interface AddBurialSiteCommentForm { + burialSiteId: string; + comment: string; +} +export default function addBurialSiteComment(commentForm: AddBurialSiteCommentForm, user: User): Promise; diff --git a/database/addLotComment.js b/database/addBurialSiteComment.js similarity index 54% rename from database/addLotComment.js rename to database/addBurialSiteComment.js index 078d8849..808d0a5a 100644 --- a/database/addLotComment.js +++ b/database/addBurialSiteComment.js @@ -1,16 +1,16 @@ import { dateToInteger, dateToTimeInteger } from '@cityssm/utils-datetime'; import { acquireConnection } from './pool.js'; -export default async function addLotComment(lotCommentForm, user) { +export default async function addBurialSiteComment(commentForm, user) { const database = await acquireConnection(); const rightNow = new Date(); const result = database - .prepare(`insert into LotComments ( - lotId, - lotCommentDate, lotCommentTime, lotComment, + .prepare(`insert into BurialSiteComments ( + burialSiteId, + commentDate, commentTime, comment, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?, ?)`) - .run(lotCommentForm.lotId, dateToInteger(rightNow), dateToTimeInteger(rightNow), lotCommentForm.lotComment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime()); + .run(commentForm.burialSiteId, dateToInteger(rightNow), dateToTimeInteger(rightNow), commentForm.comment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime()); database.release(); return result.lastInsertRowid; } diff --git a/database/addLotComment.ts b/database/addBurialSiteComment.ts similarity index 66% rename from database/addLotComment.ts rename to database/addBurialSiteComment.ts index b55ceb11..aa54cc35 100644 --- a/database/addLotComment.ts +++ b/database/addBurialSiteComment.ts @@ -2,13 +2,13 @@ import { dateToInteger, dateToTimeInteger } from '@cityssm/utils-datetime' import { acquireConnection } from './pool.js' -export interface AddLotCommentForm { - lotId: string - lotComment: string +export interface AddBurialSiteCommentForm { + burialSiteId: string + comment: string } -export default async function addLotComment( - lotCommentForm: AddLotCommentForm, +export default async function addBurialSiteComment( + commentForm: AddBurialSiteCommentForm, user: User ): Promise { const database = await acquireConnection() @@ -17,18 +17,18 @@ export default async function addLotComment( const result = database .prepare( - `insert into LotComments ( - lotId, - lotCommentDate, lotCommentTime, lotComment, + `insert into BurialSiteComments ( + burialSiteId, + commentDate, commentTime, comment, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?, ?)` ) .run( - lotCommentForm.lotId, + commentForm.burialSiteId, dateToInteger(rightNow), dateToTimeInteger(rightNow), - lotCommentForm.lotComment, + commentForm.comment, user.userName, rightNow.getTime(), user.userName, diff --git a/database/addBurialSiteContractComment.d.ts b/database/addBurialSiteContractComment.d.ts new file mode 100644 index 00000000..b48ab570 --- /dev/null +++ b/database/addBurialSiteContractComment.d.ts @@ -0,0 +1,8 @@ +import { type DateString, type TimeString } from '@cityssm/utils-datetime'; +export interface AddBurialSiteContractCommentForm { + burialSiteContractId: string | number; + commentDateString?: DateString; + commentTimeString?: TimeString; + comment: string; +} +export default function addLotOccupancyComment(commentForm: AddBurialSiteContractCommentForm, user: User): Promise; diff --git a/database/addBurialSiteContractComment.js b/database/addBurialSiteContractComment.js new file mode 100644 index 00000000..2a0a133a --- /dev/null +++ b/database/addBurialSiteContractComment.js @@ -0,0 +1,27 @@ +import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/utils-datetime'; +import { acquireConnection } from './pool.js'; +export default async function addLotOccupancyComment(commentForm, user) { + const rightNow = new Date(); + let commentDate = 0; + let commentTime = 0; + if (commentForm.commentDateString === undefined) { + commentDate = dateToInteger(rightNow); + commentTime = dateToTimeInteger(rightNow); + } + else { + commentDate = dateStringToInteger(commentForm.commentDateString); + commentTime = timeStringToInteger(commentForm.commentTimeString); + } + const database = await acquireConnection(); + const result = database + .prepare(`insert into BurialSiteContactComments ( + burialSiteContractId, + commentDate, commentTime, + comment, + recordCreate_userName, recordCreate_timeMillis, + recordUpdate_userName, recordUpdate_timeMillis) + values (?, ?, ?, ?, ?, ?, ?, ?)`) + .run(commentForm.burialSiteContractId, commentDate, commentTime ?? 0, commentForm.comment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime()); + database.release(); + return result.lastInsertRowid; +} diff --git a/database/addBurialSiteContractComment.ts b/database/addBurialSiteContractComment.ts new file mode 100644 index 00000000..19ede41c --- /dev/null +++ b/database/addBurialSiteContractComment.ts @@ -0,0 +1,66 @@ +import { + type DateString, + type TimeString, + dateStringToInteger, + dateToInteger, + dateToTimeInteger, + timeStringToInteger +} from '@cityssm/utils-datetime' + +import { acquireConnection } from './pool.js' + +export interface AddBurialSiteContractCommentForm { + burialSiteContractId: string | number + commentDateString?: DateString + commentTimeString?: TimeString + comment: string +} + +export default async function addLotOccupancyComment( + commentForm: AddBurialSiteContractCommentForm, + user: User +): Promise { + const rightNow = new Date() + + let commentDate = 0 + let commentTime: number | undefined = 0 + + if (commentForm.commentDateString === undefined) { + commentDate = dateToInteger(rightNow) + commentTime = dateToTimeInteger(rightNow) + } else { + commentDate = dateStringToInteger( + commentForm.commentDateString as DateString + ) + commentTime = timeStringToInteger( + commentForm.commentTimeString as TimeString + ) + } + + const database = await acquireConnection() + + const result = database + .prepare( + `insert into BurialSiteContactComments ( + burialSiteContractId, + commentDate, commentTime, + comment, + recordCreate_userName, recordCreate_timeMillis, + recordUpdate_userName, recordUpdate_timeMillis) + values (?, ?, ?, ?, ?, ?, ?, ?)` + ) + .run( + commentForm.burialSiteContractId, + commentDate, + commentTime ?? 0, + commentForm.comment, + user.userName, + rightNow.getTime(), + user.userName, + rightNow.getTime() + ) + + database.release() + + return result.lastInsertRowid as number +} diff --git a/database/addBurialSiteTypeField.d.ts b/database/addBurialSiteTypeField.d.ts new file mode 100644 index 00000000..682b1531 --- /dev/null +++ b/database/addBurialSiteTypeField.d.ts @@ -0,0 +1,12 @@ +export interface AddBurialSiteTypeFieldForm { + burialSiteTypeId: string | number; + burialSiteTypeField: string; + fieldType?: string; + fieldValues?: string; + isRequired?: string; + pattern?: string; + minimumLength?: string | number; + maximumLength?: string | number; + orderNumber?: number; +} +export default function addBurialSiteTypeField(addForm: AddBurialSiteTypeFieldForm, user: User): Promise; diff --git a/database/addBurialSiteTypeField.js b/database/addBurialSiteTypeField.js new file mode 100644 index 00000000..66b3f6cb --- /dev/null +++ b/database/addBurialSiteTypeField.js @@ -0,0 +1,20 @@ +import { clearCacheByTableName } from '../helpers/functions.cache.js'; +import { acquireConnection } from './pool.js'; +export default async function addBurialSiteTypeField(addForm, user) { + const database = await acquireConnection(); + const rightNowMillis = Date.now(); + const result = database + .prepare(`insert into BurialSiteTypeFields ( + burialSiteTypeId, burialSiteTypeField, + fieldType, fieldValues, + isRequired, pattern, + minimumLength, maximumLength, + orderNumber, + 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.minimumLength ?? 0, addForm.maximumLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); + database.release(); + clearCacheByTableName('BurialSiteTypeFields'); + return result.lastInsertRowid; +} diff --git a/database/addLotTypeField.ts b/database/addBurialSiteTypeField.ts similarity index 54% rename from database/addLotTypeField.ts rename to database/addBurialSiteTypeField.ts index d6926c9f..730ebfd0 100644 --- a/database/addLotTypeField.ts +++ b/database/addBurialSiteTypeField.ts @@ -2,11 +2,11 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js' import { acquireConnection } from './pool.js' -export interface AddLotTypeFieldForm { - lotTypeId: string | number - lotTypeField: string +export interface AddBurialSiteTypeFieldForm { + burialSiteTypeId: string | number + burialSiteTypeField: string fieldType?: string - lotTypeFieldValues?: string + fieldValues?: string isRequired?: string pattern?: string minimumLength?: string | number @@ -14,8 +14,8 @@ export interface AddLotTypeFieldForm { orderNumber?: number } -export default async function addLotTypeField( - lotTypeFieldForm: AddLotTypeFieldForm, +export default async function addBurialSiteTypeField( + addForm: AddBurialSiteTypeFieldForm, user: User ): Promise { const database = await acquireConnection() @@ -24,8 +24,9 @@ export default async function addLotTypeField( const result = database .prepare( - `insert into LotTypeFields ( - lotTypeId, lotTypeField, fieldType, lotTypeFieldValues, + `insert into BurialSiteTypeFields ( + burialSiteTypeId, burialSiteTypeField, + fieldType, fieldValues, isRequired, pattern, minimumLength, maximumLength, orderNumber, @@ -34,15 +35,15 @@ export default async function addLotTypeField( values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` ) .run( - lotTypeFieldForm.lotTypeId, - lotTypeFieldForm.lotTypeField, - lotTypeFieldForm.fieldType ?? 'text', - lotTypeFieldForm.lotTypeFieldValues ?? '', - lotTypeFieldForm.isRequired === '' ? 0 : 1, - lotTypeFieldForm.pattern ?? '', - lotTypeFieldForm.minimumLength ?? 0, - lotTypeFieldForm.maximumLength ?? 100, - lotTypeFieldForm.orderNumber ?? -1, + addForm.burialSiteTypeId, + addForm.burialSiteTypeField, + addForm.fieldType ?? 'text', + addForm.fieldValues ?? '', + addForm.isRequired === '' ? 0 : 1, + addForm.pattern ?? '', + addForm.minimumLength ?? 0, + addForm.maximumLength ?? 100, + addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, @@ -51,7 +52,7 @@ export default async function addLotTypeField( database.release() - clearCacheByTableName('LotTypeFields') + clearCacheByTableName('BurialSiteTypeFields') return result.lastInsertRowid as number } diff --git a/database/addCemetery.d.ts b/database/addCemetery.d.ts new file mode 100644 index 00000000..50178e6c --- /dev/null +++ b/database/addCemetery.d.ts @@ -0,0 +1,14 @@ +export interface AddCemeteryForm { + cemeteryName: string; + cemeteryDescription: string; + cemeterySvg: string; + cemeteryLatitude: string; + cemeteryLongitude: string; + cemeteryAddress1: string; + cemeteryAddress2: string; + cemeteryCity: string; + cemeteryProvince: string; + cemeteryPostalCode: string; + cemeteryPhoneNumber: string; +} +export default function addCemetery(addForm: AddCemeteryForm, user: User): Promise; diff --git a/database/addCemetery.js b/database/addCemetery.js new file mode 100644 index 00000000..93ab4baa --- /dev/null +++ b/database/addCemetery.js @@ -0,0 +1,18 @@ +import { acquireConnection } from './pool.js'; +export default async function addCemetery(addForm, user) { + const database = await acquireConnection(); + const rightNowMillis = Date.now(); + const result = database + .prepare(`insert into Cemeteries ( + cemeteryName, cemeteryDescription, + cemeterySvg, cemeteryLatitude, cemeteryLongitude, + cemeteryAddress1, cemeteryAddress2, + cemeteryCity, cemeteryProvince, cemeteryPostalCode, + cemeteryPhoneNumber, + recordCreate_userName, recordCreate_timeMillis, + recordUpdate_userName, recordUpdate_timeMillis) + values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`) + .run(addForm.cemeteryName, addForm.cemeteryDescription, addForm.cemeterySvg, addForm.cemeteryLatitude === '' ? undefined : addForm.cemeteryLatitude, addForm.cemeteryLongitude === '' ? undefined : addForm.cemeteryLongitude, addForm.cemeteryAddress1, addForm.cemeteryAddress2, addForm.cemeteryCity, addForm.cemeteryProvince, addForm.cemeteryPostalCode, addForm.cemeteryPhoneNumber, user.userName, rightNowMillis, user.userName, rightNowMillis); + database.release(); + return result.lastInsertRowid; +} diff --git a/database/addCemetery.ts b/database/addCemetery.ts new file mode 100644 index 00000000..8d17271a --- /dev/null +++ b/database/addCemetery.ts @@ -0,0 +1,60 @@ +import { acquireConnection } from './pool.js' + +export interface AddCemeteryForm { + cemeteryName: string + cemeteryDescription: string + + cemeterySvg: string + cemeteryLatitude: string + cemeteryLongitude: string + + cemeteryAddress1: string + cemeteryAddress2: string + cemeteryCity: string + cemeteryProvince: string + cemeteryPostalCode: string + cemeteryPhoneNumber: string +} + +export default async function addCemetery( + addForm: AddCemeteryForm, + user: User +): Promise { + const database = await acquireConnection() + + const rightNowMillis = Date.now() + + const result = database + .prepare( + `insert into Cemeteries ( + cemeteryName, cemeteryDescription, + cemeterySvg, cemeteryLatitude, cemeteryLongitude, + cemeteryAddress1, cemeteryAddress2, + cemeteryCity, cemeteryProvince, cemeteryPostalCode, + cemeteryPhoneNumber, + recordCreate_userName, recordCreate_timeMillis, + recordUpdate_userName, recordUpdate_timeMillis) + values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` + ) + .run( + addForm.cemeteryName, + addForm.cemeteryDescription, + addForm.cemeterySvg, + addForm.cemeteryLatitude === '' ? undefined : addForm.cemeteryLatitude, + addForm.cemeteryLongitude === '' ? undefined : addForm.cemeteryLongitude, + addForm.cemeteryAddress1, + addForm.cemeteryAddress2, + addForm.cemeteryCity, + addForm.cemeteryProvince, + addForm.cemeteryPostalCode, + addForm.cemeteryPhoneNumber, + user.userName, + rightNowMillis, + user.userName, + rightNowMillis + ) + + database.release() + + return result.lastInsertRowid as number +} diff --git a/database/addContractTypeField.d.ts b/database/addContractTypeField.d.ts new file mode 100644 index 00000000..1597c31c --- /dev/null +++ b/database/addContractTypeField.d.ts @@ -0,0 +1,12 @@ +export interface AddContractTypeFieldForm { + contractTypeId?: string | number; + contractTypeField: string; + fieldValues?: string; + fieldType?: string; + isRequired?: string; + pattern?: string; + minimumLength?: string | number; + maximumLength?: string | number; + orderNumber?: number; +} +export default function addContractTypeField(addForm: AddContractTypeFieldForm, user: User): Promise; diff --git a/database/addContractTypeField.js b/database/addContractTypeField.js new file mode 100644 index 00000000..525fd210 --- /dev/null +++ b/database/addContractTypeField.js @@ -0,0 +1,19 @@ +import { clearCacheByTableName } from '../helpers/functions.cache.js'; +import { acquireConnection } from './pool.js'; +export default async function addContractTypeField(addForm, user) { + const database = await acquireConnection(); + const rightNowMillis = Date.now(); + const result = database + .prepare(`insert into ContractTypeFields ( + contractTypeId, contractTypeField, fieldType, + fieldValues, isRequired, pattern, + minimumLength, maximumLength, + orderNumber, + 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.minimumLength ?? 0, addForm.maximumLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); + database.release(); + clearCacheByTableName('OccupancyTypeFields'); + return result.lastInsertRowid; +} diff --git a/database/addOccupancyTypeField.ts b/database/addContractTypeField.ts similarity index 50% rename from database/addOccupancyTypeField.ts rename to database/addContractTypeField.ts index c46e009c..eefc7a94 100644 --- a/database/addOccupancyTypeField.ts +++ b/database/addContractTypeField.ts @@ -2,10 +2,10 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js' import { acquireConnection } from './pool.js' -export interface AddOccupancyTypeFieldForm { - occupancyTypeId?: string | number - occupancyTypeField: string - occupancyTypeFieldValues?: string +export interface AddContractTypeFieldForm { + contractTypeId?: string | number + contractTypeField: string + fieldValues?: string fieldType?: string isRequired?: string pattern?: string @@ -14,8 +14,8 @@ export interface AddOccupancyTypeFieldForm { orderNumber?: number } -export default async function addOccupancyTypeField( - occupancyTypeFieldForm: AddOccupancyTypeFieldForm, +export default async function addContractTypeField( + addForm: AddContractTypeFieldForm, user: User ): Promise { const database = await acquireConnection() @@ -24,9 +24,9 @@ export default async function addOccupancyTypeField( const result = database .prepare( - `insert into OccupancyTypeFields ( - occupancyTypeId, occupancyTypeField, fieldType, - occupancyTypeFieldValues, isRequired, pattern, + `insert into ContractTypeFields ( + contractTypeId, contractTypeField, fieldType, + fieldValues, isRequired, pattern, minimumLength, maximumLength, orderNumber, recordCreate_userName, recordCreate_timeMillis, @@ -34,15 +34,15 @@ export default async function addOccupancyTypeField( values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` ) .run( - occupancyTypeFieldForm.occupancyTypeId ?? undefined, - occupancyTypeFieldForm.occupancyTypeField, - occupancyTypeFieldForm.fieldType ?? 'text', - occupancyTypeFieldForm.occupancyTypeFieldValues ?? '', - occupancyTypeFieldForm.isRequired === '' ? 0 : 1, - occupancyTypeFieldForm.pattern ?? '', - occupancyTypeFieldForm.minimumLength ?? 0, - occupancyTypeFieldForm.maximumLength ?? 100, - occupancyTypeFieldForm.orderNumber ?? -1, + addForm.contractTypeId ?? undefined, + addForm.contractTypeField, + addForm.fieldType ?? 'text', + addForm.fieldValues ?? '', + addForm.isRequired === '' ? 0 : 1, + addForm.pattern ?? '', + addForm.minimumLength ?? 0, + addForm.maximumLength ?? 100, + addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, diff --git a/database/addContractTypePrint.d.ts b/database/addContractTypePrint.d.ts new file mode 100644 index 00000000..e399846b --- /dev/null +++ b/database/addContractTypePrint.d.ts @@ -0,0 +1,6 @@ +export interface AddContractTypePrintForm { + contractTypeId: string | number; + printEJS: string; + orderNumber?: number; +} +export default function addContractTypePrint(addForm: AddContractTypePrintForm, user: User): Promise; diff --git a/database/addOccupancyTypePrint.js b/database/addContractTypePrint.js similarity index 52% rename from database/addOccupancyTypePrint.js rename to database/addContractTypePrint.js index 21acd5cf..cb2314d4 100644 --- a/database/addOccupancyTypePrint.js +++ b/database/addContractTypePrint.js @@ -1,27 +1,27 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js'; import { acquireConnection } from './pool.js'; -export default async function addOccupancyTypePrint(occupancyTypePrintForm, user) { +export default async function addContractTypePrint(addForm, user) { const database = await acquireConnection(); const rightNowMillis = Date.now(); let result = database - .prepare(`update OccupancyTypePrints + .prepare(`update ContractTypePrints set recordUpdate_userName = ?, recordUpdate_timeMillis = ?, recordDelete_userName = null, recordDelete_timeMillis = null - where occupancyTypeId = ? + where contractTypeId = ? and printEJS = ?`) - .run(user.userName, rightNowMillis, occupancyTypePrintForm.occupancyTypeId, occupancyTypePrintForm.printEJS); + .run(user.userName, rightNowMillis, addForm.contractTypeId, addForm.printEJS); if (result.changes === 0) { result = database - .prepare(`insert into OccupancyTypePrints ( - occupancyTypeId, printEJS, orderNumber, + .prepare(`insert into ContractTypePrints ( + contractTypeId, printEJS, orderNumber, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?)`) - .run(occupancyTypePrintForm.occupancyTypeId, occupancyTypePrintForm.printEJS, occupancyTypePrintForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); + .run(addForm.contractTypeId, addForm.printEJS, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); } database.release(); - clearCacheByTableName('OccupancyTypePrints'); + clearCacheByTableName('ContractTypePrints'); return result.changes > 0; } diff --git a/database/addOccupancyTypePrint.ts b/database/addContractTypePrint.ts similarity index 61% rename from database/addOccupancyTypePrint.ts rename to database/addContractTypePrint.ts index 72a72ef1..d978c529 100644 --- a/database/addOccupancyTypePrint.ts +++ b/database/addContractTypePrint.ts @@ -2,14 +2,14 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js' import { acquireConnection } from './pool.js' -export interface AddOccupancyTypePrintForm { - occupancyTypeId: string | number +export interface AddContractTypePrintForm { + contractTypeId: string | number printEJS: string orderNumber?: number } -export default async function addOccupancyTypePrint( - occupancyTypePrintForm: AddOccupancyTypePrintForm, +export default async function addContractTypePrint( + addForm: AddContractTypePrintForm, user: User ): Promise { const database = await acquireConnection() @@ -18,34 +18,34 @@ export default async function addOccupancyTypePrint( let result = database .prepare( - `update OccupancyTypePrints + `update ContractTypePrints set recordUpdate_userName = ?, recordUpdate_timeMillis = ?, recordDelete_userName = null, recordDelete_timeMillis = null - where occupancyTypeId = ? + where contractTypeId = ? and printEJS = ?` ) .run( user.userName, rightNowMillis, - occupancyTypePrintForm.occupancyTypeId, - occupancyTypePrintForm.printEJS + addForm.contractTypeId, + addForm.printEJS ) if (result.changes === 0) { result = database .prepare( - `insert into OccupancyTypePrints ( - occupancyTypeId, printEJS, orderNumber, + `insert into ContractTypePrints ( + contractTypeId, printEJS, orderNumber, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?)` ) .run( - occupancyTypePrintForm.occupancyTypeId, - occupancyTypePrintForm.printEJS, - occupancyTypePrintForm.orderNumber ?? -1, + addForm.contractTypeId, + addForm.printEJS, + addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, @@ -55,7 +55,7 @@ export default async function addOccupancyTypePrint( database.release() - clearCacheByTableName('OccupancyTypePrints') + clearCacheByTableName('ContractTypePrints') return result.changes > 0 } diff --git a/database/addFee.d.ts b/database/addFee.d.ts index 8d48739a..eee8c6b3 100644 --- a/database/addFee.d.ts +++ b/database/addFee.d.ts @@ -3,15 +3,15 @@ export interface AddFeeForm { feeName: string; feeDescription: string; feeAccount: string; - occupancyTypeId: string; - lotTypeId: string; + contractTypeId: string; + burialSiteTypeId: string; feeAmount?: string; - feeFunction: string; + feeFunction?: string; taxAmount?: string; taxPercentage?: string; - includeQuantity: '' | '1'; + includeQuantity?: '' | '1'; quantityUnit?: string; - isRequired: '' | '1'; + isRequired?: '' | '1'; orderNumber?: number; } export default function addFee(feeForm: AddFeeForm, user: User): Promise; diff --git a/database/addFee.js b/database/addFee.js index c20ba0b8..ebdba8fd 100644 --- a/database/addFee.js +++ b/database/addFee.js @@ -6,7 +6,7 @@ export default async function addFee(feeForm, user) { .prepare(`insert into Fees ( feeCategoryId, feeName, feeDescription, feeAccount, - occupancyTypeId, lotTypeId, + contractTypeId, burialSiteTypeId, feeAmount, feeFunction, taxAmount, taxPercentage, includeQuantity, quantityUnit, @@ -14,7 +14,7 @@ export default async function addFee(feeForm, user) { recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`) - .run(feeForm.feeCategoryId, feeForm.feeName, feeForm.feeDescription, feeForm.feeAccount, feeForm.occupancyTypeId === '' ? undefined : feeForm.occupancyTypeId, feeForm.lotTypeId === '' ? undefined : feeForm.lotTypeId, feeForm.feeAmount ?? undefined, feeForm.feeFunction ?? undefined, feeForm.taxAmount ?? undefined, feeForm.taxPercentage ?? undefined, (feeForm.includeQuantity ?? '') === '' ? 0 : 1, feeForm.quantityUnit, (feeForm.isRequired ?? '') === '' ? 0 : 1, feeForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); + .run(feeForm.feeCategoryId, feeForm.feeName, feeForm.feeDescription, feeForm.feeAccount, feeForm.contractTypeId === '' ? undefined : feeForm.contractTypeId, feeForm.burialSiteTypeId === '' ? undefined : feeForm.burialSiteTypeId, feeForm.feeAmount ?? undefined, feeForm.feeFunction ?? undefined, feeForm.taxAmount ?? undefined, feeForm.taxPercentage ?? undefined, (feeForm.includeQuantity ?? '') === '' ? 0 : 1, feeForm.quantityUnit, (feeForm.isRequired ?? '') === '' ? 0 : 1, feeForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); database.release(); return result.lastInsertRowid; } diff --git a/database/addFee.ts b/database/addFee.ts index 5c26065b..954adb43 100644 --- a/database/addFee.ts +++ b/database/addFee.ts @@ -5,15 +5,15 @@ export interface AddFeeForm { feeName: string feeDescription: string feeAccount: string - occupancyTypeId: string - lotTypeId: string + contractTypeId: string + burialSiteTypeId: string feeAmount?: string - feeFunction: string + feeFunction?: string taxAmount?: string taxPercentage?: string - includeQuantity: '' | '1' + includeQuantity?: '' | '1' quantityUnit?: string - isRequired: '' | '1' + isRequired?: '' | '1' orderNumber?: number } @@ -30,7 +30,7 @@ export default async function addFee( `insert into Fees ( feeCategoryId, feeName, feeDescription, feeAccount, - occupancyTypeId, lotTypeId, + contractTypeId, burialSiteTypeId, feeAmount, feeFunction, taxAmount, taxPercentage, includeQuantity, quantityUnit, @@ -44,8 +44,8 @@ export default async function addFee( feeForm.feeName, feeForm.feeDescription, feeForm.feeAccount, - feeForm.occupancyTypeId === '' ? undefined : feeForm.occupancyTypeId, - feeForm.lotTypeId === '' ? undefined : feeForm.lotTypeId, + feeForm.contractTypeId === '' ? undefined : feeForm.contractTypeId, + feeForm.burialSiteTypeId === '' ? undefined : feeForm.burialSiteTypeId, feeForm.feeAmount ?? undefined, feeForm.feeFunction ?? undefined, feeForm.taxAmount ?? undefined, diff --git a/database/addLotComment.d.ts b/database/addLotComment.d.ts deleted file mode 100644 index 933a7bfe..00000000 --- a/database/addLotComment.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface AddLotCommentForm { - lotId: string; - lotComment: string; -} -export default function addLotComment(lotCommentForm: AddLotCommentForm, user: User): Promise; diff --git a/database/addLotOccupancyComment.d.ts b/database/addLotOccupancyComment.d.ts deleted file mode 100644 index 07bbd7b2..00000000 --- a/database/addLotOccupancyComment.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface AddLotOccupancyCommentForm { - lotOccupancyId: string | number; - lotOccupancyCommentDateString?: string; - lotOccupancyCommentTimeString?: string; - lotOccupancyComment: string; -} -export default function addLotOccupancyComment(commentForm: AddLotOccupancyCommentForm, user: User): Promise; diff --git a/database/addLotOccupancyComment.js b/database/addLotOccupancyComment.js deleted file mode 100644 index 7e46d9ce..00000000 --- a/database/addLotOccupancyComment.js +++ /dev/null @@ -1,27 +0,0 @@ -import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/utils-datetime'; -import { acquireConnection } from './pool.js'; -export default async function addLotOccupancyComment(commentForm, user) { - const rightNow = new Date(); - let lotOccupancyCommentDate; - let lotOccupancyCommentTime; - if (commentForm.lotOccupancyCommentDateString) { - lotOccupancyCommentDate = dateStringToInteger(commentForm.lotOccupancyCommentDateString); - lotOccupancyCommentTime = timeStringToInteger(commentForm.lotOccupancyCommentTimeString ?? ''); - } - else { - lotOccupancyCommentDate = dateToInteger(rightNow); - lotOccupancyCommentTime = dateToTimeInteger(rightNow); - } - const database = await acquireConnection(); - const result = database - .prepare(`insert into LotOccupancyComments ( - lotOccupancyId, - lotOccupancyCommentDate, lotOccupancyCommentTime, - lotOccupancyComment, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?, ?, ?)`) - .run(commentForm.lotOccupancyId, lotOccupancyCommentDate, lotOccupancyCommentTime ?? 0, commentForm.lotOccupancyComment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime()); - database.release(); - return result.lastInsertRowid; -} diff --git a/database/addLotOccupancyComment.ts b/database/addLotOccupancyComment.ts deleted file mode 100644 index 8503fd33..00000000 --- a/database/addLotOccupancyComment.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { - type DateString, - type TimeString, - dateStringToInteger, - dateToInteger, - dateToTimeInteger, - timeStringToInteger -} from '@cityssm/utils-datetime' - -import { acquireConnection } from './pool.js' - -export interface AddLotOccupancyCommentForm { - lotOccupancyId: string | number - lotOccupancyCommentDateString?: string - lotOccupancyCommentTimeString?: string - lotOccupancyComment: string -} - -export default async function addLotOccupancyComment( - commentForm: AddLotOccupancyCommentForm, - user: User -): Promise { - const rightNow = new Date() - - let lotOccupancyCommentDate: number - let lotOccupancyCommentTime: number | undefined - - if (commentForm.lotOccupancyCommentDateString) { - lotOccupancyCommentDate = dateStringToInteger( - commentForm.lotOccupancyCommentDateString as DateString - ) - lotOccupancyCommentTime = timeStringToInteger( - (commentForm.lotOccupancyCommentTimeString as TimeString) ?? '' - ) - } else { - lotOccupancyCommentDate = dateToInteger(rightNow) - lotOccupancyCommentTime = dateToTimeInteger(rightNow) - } - - const database = await acquireConnection() - - const result = database - .prepare( - `insert into LotOccupancyComments ( - lotOccupancyId, - lotOccupancyCommentDate, lotOccupancyCommentTime, - lotOccupancyComment, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?, ?, ?)` - ) - .run( - commentForm.lotOccupancyId, - lotOccupancyCommentDate, - lotOccupancyCommentTime ?? 0, - commentForm.lotOccupancyComment, - user.userName, - rightNow.getTime(), - user.userName, - rightNow.getTime() - ) - - database.release() - - return result.lastInsertRowid as number -} diff --git a/database/addLotOccupancyOccupant.d.ts b/database/addLotOccupancyOccupant.d.ts deleted file mode 100644 index 199b2ae8..00000000 --- a/database/addLotOccupancyOccupant.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { PoolConnection } from 'better-sqlite-pool'; -export interface AddLotOccupancyOccupantForm { - lotOccupancyId: string | number; - lotOccupantTypeId: string | number; - occupantName: string; - occupantFamilyName: string; - occupantAddress1: string; - occupantAddress2: string; - occupantCity: string; - occupantProvince: string; - occupantPostalCode: string; - occupantPhoneNumber: string; - occupantEmailAddress: string; - occupantComment?: string; -} -export default function addLotOccupancyOccupant(lotOccupancyOccupantForm: AddLotOccupancyOccupantForm, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/addLotOccupancyOccupant.js b/database/addLotOccupancyOccupant.js deleted file mode 100644 index e60cfe6b..00000000 --- a/database/addLotOccupancyOccupant.js +++ /dev/null @@ -1,33 +0,0 @@ -import { acquireConnection } from './pool.js'; -export default async function addLotOccupancyOccupant(lotOccupancyOccupantForm, user, connectedDatabase) { - const database = connectedDatabase ?? (await acquireConnection()); - let lotOccupantIndex = 0; - const maxIndexResult = database - .prepare(`select lotOccupantIndex - from LotOccupancyOccupants - where lotOccupancyId = ? - order by lotOccupantIndex desc - limit 1`) - .get(lotOccupancyOccupantForm.lotOccupancyId); - if (maxIndexResult !== undefined) { - lotOccupantIndex = maxIndexResult.lotOccupantIndex + 1; - } - const rightNowMillis = Date.now(); - database - .prepare(`insert into LotOccupancyOccupants ( - lotOccupancyId, lotOccupantIndex, - occupantName, occupantFamilyName, - occupantAddress1, occupantAddress2, - occupantCity, occupantProvince, occupantPostalCode, - occupantPhoneNumber, occupantEmailAddress, - occupantComment, - lotOccupantTypeId, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`) - .run(lotOccupancyOccupantForm.lotOccupancyId, lotOccupantIndex, lotOccupancyOccupantForm.occupantName, lotOccupancyOccupantForm.occupantFamilyName, lotOccupancyOccupantForm.occupantAddress1, lotOccupancyOccupantForm.occupantAddress2, lotOccupancyOccupantForm.occupantCity, lotOccupancyOccupantForm.occupantProvince, lotOccupancyOccupantForm.occupantPostalCode, lotOccupancyOccupantForm.occupantPhoneNumber, lotOccupancyOccupantForm.occupantEmailAddress, lotOccupancyOccupantForm.occupantComment ?? '', lotOccupancyOccupantForm.lotOccupantTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis); - if (connectedDatabase === undefined) { - database.release(); - } - return lotOccupantIndex; -} diff --git a/database/addLotOccupancyOccupant.ts b/database/addLotOccupancyOccupant.ts deleted file mode 100644 index 53fc749b..00000000 --- a/database/addLotOccupancyOccupant.ts +++ /dev/null @@ -1,86 +0,0 @@ -import type { PoolConnection } from 'better-sqlite-pool' - -import { acquireConnection } from './pool.js' - -export interface AddLotOccupancyOccupantForm { - lotOccupancyId: string | number - lotOccupantTypeId: string | number - occupantName: string - occupantFamilyName: string - occupantAddress1: string - occupantAddress2: string - occupantCity: string - occupantProvince: string - occupantPostalCode: string - occupantPhoneNumber: string - occupantEmailAddress: string - occupantComment?: string -} - -export default async function addLotOccupancyOccupant( - lotOccupancyOccupantForm: AddLotOccupancyOccupantForm, - user: User, - connectedDatabase?: PoolConnection -): Promise { - const database = connectedDatabase ?? (await acquireConnection()) - - let lotOccupantIndex = 0 - - const maxIndexResult = database - .prepare( - `select lotOccupantIndex - from LotOccupancyOccupants - where lotOccupancyId = ? - order by lotOccupantIndex desc - limit 1` - ) - .get(lotOccupancyOccupantForm.lotOccupancyId) as - | { lotOccupantIndex: number } - | undefined - - if (maxIndexResult !== undefined) { - lotOccupantIndex = maxIndexResult.lotOccupantIndex + 1 - } - - const rightNowMillis = Date.now() - - database - .prepare( - `insert into LotOccupancyOccupants ( - lotOccupancyId, lotOccupantIndex, - occupantName, occupantFamilyName, - occupantAddress1, occupantAddress2, - occupantCity, occupantProvince, occupantPostalCode, - occupantPhoneNumber, occupantEmailAddress, - occupantComment, - lotOccupantTypeId, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` - ) - .run( - lotOccupancyOccupantForm.lotOccupancyId, - lotOccupantIndex, - lotOccupancyOccupantForm.occupantName, - lotOccupancyOccupantForm.occupantFamilyName, - lotOccupancyOccupantForm.occupantAddress1, - lotOccupancyOccupantForm.occupantAddress2, - lotOccupancyOccupantForm.occupantCity, - lotOccupancyOccupantForm.occupantProvince, - lotOccupancyOccupantForm.occupantPostalCode, - lotOccupancyOccupantForm.occupantPhoneNumber, - lotOccupancyOccupantForm.occupantEmailAddress, - lotOccupancyOccupantForm.occupantComment ?? '', - lotOccupancyOccupantForm.lotOccupantTypeId, - user.userName, - rightNowMillis, - user.userName, - rightNowMillis - ) - - if (connectedDatabase === undefined) { - database.release() - } - - return lotOccupantIndex -} diff --git a/database/addLotOccupantType.d.ts b/database/addLotOccupantType.d.ts deleted file mode 100644 index 3ab9a367..00000000 --- a/database/addLotOccupantType.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface AddLotOccupantTypeForm { - lotOccupantType: string; - fontAwesomeIconClass?: string; - occupantCommentTitle?: string; - orderNumber?: number; -} -export default function addLotOccupantType(lotOccupantTypeForm: AddLotOccupantTypeForm, user: User): Promise; diff --git a/database/addLotOccupantType.js b/database/addLotOccupantType.js deleted file mode 100644 index 8f3d68b6..00000000 --- a/database/addLotOccupantType.js +++ /dev/null @@ -1,16 +0,0 @@ -import { clearCacheByTableName } from '../helpers/functions.cache.js'; -import { acquireConnection } from './pool.js'; -export default async function addLotOccupantType(lotOccupantTypeForm, user) { - const database = await acquireConnection(); - const rightNowMillis = Date.now(); - const result = database - .prepare(`insert into LotOccupantTypes ( - lotOccupantType, fontAwesomeIconClass, occupantCommentTitle, orderNumber, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?, ?, ?)`) - .run(lotOccupantTypeForm.lotOccupantType, lotOccupantTypeForm.fontAwesomeIconClass ?? '', lotOccupantTypeForm.occupantCommentTitle ?? '', lotOccupantTypeForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); - database.release(); - clearCacheByTableName('LotOccupantTypes'); - return result.lastInsertRowid; -} diff --git a/database/addLotOccupantType.ts b/database/addLotOccupantType.ts deleted file mode 100644 index 1e0b6ed5..00000000 --- a/database/addLotOccupantType.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { clearCacheByTableName } from '../helpers/functions.cache.js' - -import { acquireConnection } from './pool.js' - -export interface AddLotOccupantTypeForm { - lotOccupantType: string - fontAwesomeIconClass?: string - occupantCommentTitle?: string - orderNumber?: number -} - -export default async function addLotOccupantType( - lotOccupantTypeForm: AddLotOccupantTypeForm, - user: User -): Promise { - const database = await acquireConnection() - - const rightNowMillis = Date.now() - - const result = database - .prepare( - `insert into LotOccupantTypes ( - lotOccupantType, fontAwesomeIconClass, occupantCommentTitle, orderNumber, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?, ?, ?)` - ) - .run( - lotOccupantTypeForm.lotOccupantType, - lotOccupantTypeForm.fontAwesomeIconClass ?? '', - lotOccupantTypeForm.occupantCommentTitle ?? '', - lotOccupantTypeForm.orderNumber ?? -1, - user.userName, - rightNowMillis, - user.userName, - rightNowMillis - ) - - database.release() - - clearCacheByTableName('LotOccupantTypes') - - return result.lastInsertRowid as number -} diff --git a/database/addLotTypeField.d.ts b/database/addLotTypeField.d.ts deleted file mode 100644 index a596b9dd..00000000 --- a/database/addLotTypeField.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -export interface AddLotTypeFieldForm { - lotTypeId: string | number; - lotTypeField: string; - fieldType?: string; - lotTypeFieldValues?: string; - isRequired?: string; - pattern?: string; - minimumLength?: string | number; - maximumLength?: string | number; - orderNumber?: number; -} -export default function addLotTypeField(lotTypeFieldForm: AddLotTypeFieldForm, user: User): Promise; diff --git a/database/addLotTypeField.js b/database/addLotTypeField.js deleted file mode 100644 index 3d2cc17f..00000000 --- a/database/addLotTypeField.js +++ /dev/null @@ -1,19 +0,0 @@ -import { clearCacheByTableName } from '../helpers/functions.cache.js'; -import { acquireConnection } from './pool.js'; -export default async function addLotTypeField(lotTypeFieldForm, user) { - const database = await acquireConnection(); - const rightNowMillis = Date.now(); - const result = database - .prepare(`insert into LotTypeFields ( - lotTypeId, lotTypeField, fieldType, lotTypeFieldValues, - isRequired, pattern, - minimumLength, maximumLength, - orderNumber, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`) - .run(lotTypeFieldForm.lotTypeId, lotTypeFieldForm.lotTypeField, lotTypeFieldForm.fieldType ?? 'text', lotTypeFieldForm.lotTypeFieldValues ?? '', lotTypeFieldForm.isRequired === '' ? 0 : 1, lotTypeFieldForm.pattern ?? '', lotTypeFieldForm.minimumLength ?? 0, lotTypeFieldForm.maximumLength ?? 100, lotTypeFieldForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); - database.release(); - clearCacheByTableName('LotTypeFields'); - return result.lastInsertRowid; -} diff --git a/database/addMap.d.ts b/database/addMap.d.ts deleted file mode 100644 index 6f6e2509..00000000 --- a/database/addMap.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -export interface AddMapForm { - mapName: string; - mapDescription: string; - mapSVG: string; - mapLatitude: string; - mapLongitude: string; - mapAddress1: string; - mapAddress2: string; - mapCity: string; - mapProvince: string; - mapPostalCode: string; - mapPhoneNumber: string; -} -export default function addMap(mapForm: AddMapForm, user: User): Promise; diff --git a/database/addMap.js b/database/addMap.js deleted file mode 100644 index 9e13a904..00000000 --- a/database/addMap.js +++ /dev/null @@ -1,18 +0,0 @@ -import { acquireConnection } from './pool.js'; -export default async function addMap(mapForm, user) { - const database = await acquireConnection(); - const rightNowMillis = Date.now(); - const result = database - .prepare(`insert into Maps ( - mapName, mapDescription, - mapSVG, mapLatitude, mapLongitude, - mapAddress1, mapAddress2, - mapCity, mapProvince, mapPostalCode, - mapPhoneNumber, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`) - .run(mapForm.mapName, mapForm.mapDescription, mapForm.mapSVG, mapForm.mapLatitude === '' ? undefined : mapForm.mapLatitude, mapForm.mapLongitude === '' ? undefined : mapForm.mapLongitude, mapForm.mapAddress1, mapForm.mapAddress2, mapForm.mapCity, mapForm.mapProvince, mapForm.mapPostalCode, mapForm.mapPhoneNumber, user.userName, rightNowMillis, user.userName, rightNowMillis); - database.release(); - return result.lastInsertRowid; -} diff --git a/database/addMap.ts b/database/addMap.ts deleted file mode 100644 index e5c8f0f1..00000000 --- a/database/addMap.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { acquireConnection } from './pool.js' - -export interface AddMapForm { - mapName: string - mapDescription: string - mapSVG: string - mapLatitude: string - mapLongitude: string - mapAddress1: string - mapAddress2: string - mapCity: string - mapProvince: string - mapPostalCode: string - mapPhoneNumber: string -} - -export default async function addMap( - mapForm: AddMapForm, - user: User -): Promise { - const database = await acquireConnection() - - const rightNowMillis = Date.now() - - const result = database - .prepare( - `insert into Maps ( - mapName, mapDescription, - mapSVG, mapLatitude, mapLongitude, - mapAddress1, mapAddress2, - mapCity, mapProvince, mapPostalCode, - mapPhoneNumber, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` - ) - .run( - mapForm.mapName, - mapForm.mapDescription, - mapForm.mapSVG, - mapForm.mapLatitude === '' ? undefined : mapForm.mapLatitude, - mapForm.mapLongitude === '' ? undefined : mapForm.mapLongitude, - mapForm.mapAddress1, - mapForm.mapAddress2, - mapForm.mapCity, - mapForm.mapProvince, - mapForm.mapPostalCode, - mapForm.mapPhoneNumber, - user.userName, - rightNowMillis, - user.userName, - rightNowMillis - ) - - database.release() - - return result.lastInsertRowid as number -} diff --git a/database/addOccupancyTypeField.d.ts b/database/addOccupancyTypeField.d.ts deleted file mode 100644 index e619da02..00000000 --- a/database/addOccupancyTypeField.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -export interface AddOccupancyTypeFieldForm { - occupancyTypeId?: string | number; - occupancyTypeField: string; - occupancyTypeFieldValues?: string; - fieldType?: string; - isRequired?: string; - pattern?: string; - minimumLength?: string | number; - maximumLength?: string | number; - orderNumber?: number; -} -export default function addOccupancyTypeField(occupancyTypeFieldForm: AddOccupancyTypeFieldForm, user: User): Promise; diff --git a/database/addOccupancyTypeField.js b/database/addOccupancyTypeField.js deleted file mode 100644 index 93fd2718..00000000 --- a/database/addOccupancyTypeField.js +++ /dev/null @@ -1,19 +0,0 @@ -import { clearCacheByTableName } from '../helpers/functions.cache.js'; -import { acquireConnection } from './pool.js'; -export default async function addOccupancyTypeField(occupancyTypeFieldForm, user) { - const database = await acquireConnection(); - const rightNowMillis = Date.now(); - const result = database - .prepare(`insert into OccupancyTypeFields ( - occupancyTypeId, occupancyTypeField, fieldType, - occupancyTypeFieldValues, isRequired, pattern, - minimumLength, maximumLength, - orderNumber, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`) - .run(occupancyTypeFieldForm.occupancyTypeId ?? undefined, occupancyTypeFieldForm.occupancyTypeField, occupancyTypeFieldForm.fieldType ?? 'text', occupancyTypeFieldForm.occupancyTypeFieldValues ?? '', occupancyTypeFieldForm.isRequired === '' ? 0 : 1, occupancyTypeFieldForm.pattern ?? '', occupancyTypeFieldForm.minimumLength ?? 0, occupancyTypeFieldForm.maximumLength ?? 100, occupancyTypeFieldForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); - database.release(); - clearCacheByTableName('OccupancyTypeFields'); - return result.lastInsertRowid; -} diff --git a/database/addOccupancyTypePrint.d.ts b/database/addOccupancyTypePrint.d.ts deleted file mode 100644 index 283e86aa..00000000 --- a/database/addOccupancyTypePrint.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface AddOccupancyTypePrintForm { - occupancyTypeId: string | number; - printEJS: string; - orderNumber?: number; -} -export default function addOccupancyTypePrint(occupancyTypePrintForm: AddOccupancyTypePrintForm, user: User): Promise; diff --git a/database/addOrUpdateBurialSiteContractField.d.ts b/database/addOrUpdateBurialSiteContractField.d.ts new file mode 100644 index 00000000..f47a7d00 --- /dev/null +++ b/database/addOrUpdateBurialSiteContractField.d.ts @@ -0,0 +1,7 @@ +import type { PoolConnection } from 'better-sqlite-pool'; +export interface BurialSiteContractFieldForm { + burialSiteContractId: string | number; + contractTypeFieldId: string | number; + fieldValue: string; +} +export default function addOrUpdateBurialSiteContractField(fieldForm: BurialSiteContractFieldForm, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/addOrUpdateBurialSiteContractField.js b/database/addOrUpdateBurialSiteContractField.js new file mode 100644 index 00000000..67f38213 --- /dev/null +++ b/database/addOrUpdateBurialSiteContractField.js @@ -0,0 +1,28 @@ +import { acquireConnection } from './pool.js'; +export default async function addOrUpdateBurialSiteContractField(fieldForm, user, connectedDatabase) { + const database = connectedDatabase ?? (await acquireConnection()); + const rightNowMillis = Date.now(); + let result = database + .prepare(`update BurialSiteContractFields + set fieldValue = ?, + recordUpdate_userName = ?, + recordUpdate_timeMillis = ?, + recordDelete_userName = null, + recordDelete_timeMillis = null + where burialSiteContractId = ? + and contractTypeFieldId = ?`) + .run(fieldForm.fieldValue, user.userName, rightNowMillis, fieldForm.burialSiteContractId, fieldForm.contractTypeFieldId); + if (result.changes === 0) { + result = database + .prepare(`insert into BurialSiteContractFields ( + burialSiteContractId, contractTypeFieldId, fieldValue, + recordCreate_userName, recordCreate_timeMillis, + recordUpdate_userName, recordUpdate_timeMillis) + values (?, ?, ?, ?, ?, ?, ?)`) + .run(fieldForm.burialSiteContractId, fieldForm.contractTypeFieldId, fieldForm.fieldValue, user.userName, rightNowMillis, user.userName, rightNowMillis); + } + if (connectedDatabase === undefined) { + database.release(); + } + return result.changes > 0; +} diff --git a/database/addOrUpdateLotOccupancyField.ts b/database/addOrUpdateBurialSiteContractField.ts similarity index 54% rename from database/addOrUpdateLotOccupancyField.ts rename to database/addOrUpdateBurialSiteContractField.ts index 7e70d4d8..2fbb6567 100644 --- a/database/addOrUpdateLotOccupancyField.ts +++ b/database/addOrUpdateBurialSiteContractField.ts @@ -2,14 +2,14 @@ import type { PoolConnection } from 'better-sqlite-pool' import { acquireConnection } from './pool.js' -export interface LotOccupancyFieldForm { - lotOccupancyId: string | number - occupancyTypeFieldId: string | number - lotOccupancyFieldValue: string +export interface BurialSiteContractFieldForm { + burialSiteContractId: string | number + contractTypeFieldId: string | number + fieldValue: string } -export default async function addOrUpdateLotOccupancyField( - lotOccupancyFieldForm: LotOccupancyFieldForm, +export default async function addOrUpdateBurialSiteContractField( + fieldForm: BurialSiteContractFieldForm, user: User, connectedDatabase?: PoolConnection ): Promise { @@ -19,36 +19,36 @@ export default async function addOrUpdateLotOccupancyField( let result = database .prepare( - `update LotOccupancyFields - set lotOccupancyFieldValue = ?, + `update BurialSiteContractFields + set fieldValue = ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ?, recordDelete_userName = null, recordDelete_timeMillis = null - where lotOccupancyId = ? - and occupancyTypeFieldId = ?` + where burialSiteContractId = ? + and contractTypeFieldId = ?` ) .run( - lotOccupancyFieldForm.lotOccupancyFieldValue, + fieldForm.fieldValue, user.userName, rightNowMillis, - lotOccupancyFieldForm.lotOccupancyId, - lotOccupancyFieldForm.occupancyTypeFieldId + fieldForm.burialSiteContractId, + fieldForm.contractTypeFieldId ) if (result.changes === 0) { result = database .prepare( - `insert into LotOccupancyFields ( - lotOccupancyId, occupancyTypeFieldId, lotOccupancyFieldValue, + `insert into BurialSiteContractFields ( + burialSiteContractId, contractTypeFieldId, fieldValue, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?)` ) .run( - lotOccupancyFieldForm.lotOccupancyId, - lotOccupancyFieldForm.occupancyTypeFieldId, - lotOccupancyFieldForm.lotOccupancyFieldValue, + fieldForm.burialSiteContractId, + fieldForm.contractTypeFieldId, + fieldForm.fieldValue, user.userName, rightNowMillis, user.userName, diff --git a/database/addOrUpdateBurialSiteField.d.ts b/database/addOrUpdateBurialSiteField.d.ts new file mode 100644 index 00000000..321f71a9 --- /dev/null +++ b/database/addOrUpdateBurialSiteField.d.ts @@ -0,0 +1,7 @@ +import type { PoolConnection } from 'better-sqlite-pool'; +export interface BurialSiteFieldForm { + burialSiteId: string | number; + burialSiteTypeFieldId: string | number; + fieldValue: string; +} +export default function addOrUpdateBurialSiteField(fieldForm: BurialSiteFieldForm, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/addOrUpdateLotField.js b/database/addOrUpdateBurialSiteField.js similarity index 51% rename from database/addOrUpdateLotField.js rename to database/addOrUpdateBurialSiteField.js index 81466e88..de3296cc 100644 --- a/database/addOrUpdateLotField.js +++ b/database/addOrUpdateBurialSiteField.js @@ -1,25 +1,25 @@ import { acquireConnection } from './pool.js'; -export default async function addOrUpdateLotField(lotFieldForm, user, connectedDatabase) { +export default async function addOrUpdateBurialSiteField(fieldForm, user, connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); const rightNowMillis = Date.now(); let result = database - .prepare(`update LotFields - set lotFieldValue = ?, + .prepare(`update BurialSiteFields + set fieldValue = ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ?, recordDelete_userName = null, recordDelete_timeMillis = null - where lotId = ? - and lotTypeFieldId = ?`) - .run(lotFieldForm.lotFieldValue, user.userName, rightNowMillis, lotFieldForm.lotId, lotFieldForm.lotTypeFieldId); + where burialSiteId = ? + and burialSiteTypeFieldId = ?`) + .run(fieldForm.fieldValue, user.userName, rightNowMillis, fieldForm.burialSiteId, fieldForm.burialSiteTypeFieldId); if (result.changes === 0) { result = database - .prepare(`insert into LotFields ( - lotId, lotTypeFieldId, lotFieldValue, + .prepare(`insert into BurialSiteFields ( + burialSiteId, burialSiteTypeFieldId, fieldValue, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?)`) - .run(lotFieldForm.lotId, lotFieldForm.lotTypeFieldId, lotFieldForm.lotFieldValue, user.userName, rightNowMillis, user.userName, rightNowMillis); + .run(fieldForm.burialSiteId, fieldForm.burialSiteTypeFieldId, fieldForm.fieldValue, user.userName, rightNowMillis, user.userName, rightNowMillis); } if (connectedDatabase === undefined) { database.release(); diff --git a/database/addOrUpdateLotField.ts b/database/addOrUpdateBurialSiteField.ts similarity index 60% rename from database/addOrUpdateLotField.ts rename to database/addOrUpdateBurialSiteField.ts index fa55122d..3307740b 100644 --- a/database/addOrUpdateLotField.ts +++ b/database/addOrUpdateBurialSiteField.ts @@ -2,14 +2,14 @@ import type { PoolConnection } from 'better-sqlite-pool' import { acquireConnection } from './pool.js' -export interface LotFieldForm { - lotId: string | number - lotTypeFieldId: string | number - lotFieldValue: string +export interface BurialSiteFieldForm { + burialSiteId: string | number + burialSiteTypeFieldId: string | number + fieldValue: string } -export default async function addOrUpdateLotField( - lotFieldForm: LotFieldForm, +export default async function addOrUpdateBurialSiteField( + fieldForm: BurialSiteFieldForm, user: User, connectedDatabase?: PoolConnection ): Promise { @@ -19,36 +19,36 @@ export default async function addOrUpdateLotField( let result = database .prepare( - `update LotFields - set lotFieldValue = ?, + `update BurialSiteFields + set fieldValue = ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ?, recordDelete_userName = null, recordDelete_timeMillis = null - where lotId = ? - and lotTypeFieldId = ?` + where burialSiteId = ? + and burialSiteTypeFieldId = ?` ) .run( - lotFieldForm.lotFieldValue, + fieldForm.fieldValue, user.userName, rightNowMillis, - lotFieldForm.lotId, - lotFieldForm.lotTypeFieldId + fieldForm.burialSiteId, + fieldForm.burialSiteTypeFieldId ) if (result.changes === 0) { result = database .prepare( - `insert into LotFields ( - lotId, lotTypeFieldId, lotFieldValue, + `insert into BurialSiteFields ( + burialSiteId, burialSiteTypeFieldId, fieldValue, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?)` ) .run( - lotFieldForm.lotId, - lotFieldForm.lotTypeFieldId, - lotFieldForm.lotFieldValue, + fieldForm.burialSiteId, + fieldForm.burialSiteTypeFieldId, + fieldForm.fieldValue, user.userName, rightNowMillis, user.userName, diff --git a/database/addOrUpdateLotField.d.ts b/database/addOrUpdateLotField.d.ts deleted file mode 100644 index 08bbcce8..00000000 --- a/database/addOrUpdateLotField.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { PoolConnection } from 'better-sqlite-pool'; -export interface LotFieldForm { - lotId: string | number; - lotTypeFieldId: string | number; - lotFieldValue: string; -} -export default function addOrUpdateLotField(lotFieldForm: LotFieldForm, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/addOrUpdateLotOccupancyField.d.ts b/database/addOrUpdateLotOccupancyField.d.ts deleted file mode 100644 index 624ec917..00000000 --- a/database/addOrUpdateLotOccupancyField.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { PoolConnection } from 'better-sqlite-pool'; -export interface LotOccupancyFieldForm { - lotOccupancyId: string | number; - occupancyTypeFieldId: string | number; - lotOccupancyFieldValue: string; -} -export default function addOrUpdateLotOccupancyField(lotOccupancyFieldForm: LotOccupancyFieldForm, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/addOrUpdateLotOccupancyField.js b/database/addOrUpdateLotOccupancyField.js deleted file mode 100644 index 09511cdb..00000000 --- a/database/addOrUpdateLotOccupancyField.js +++ /dev/null @@ -1,28 +0,0 @@ -import { acquireConnection } from './pool.js'; -export default async function addOrUpdateLotOccupancyField(lotOccupancyFieldForm, user, connectedDatabase) { - const database = connectedDatabase ?? (await acquireConnection()); - const rightNowMillis = Date.now(); - let result = database - .prepare(`update LotOccupancyFields - set lotOccupancyFieldValue = ?, - recordUpdate_userName = ?, - recordUpdate_timeMillis = ?, - recordDelete_userName = null, - recordDelete_timeMillis = null - where lotOccupancyId = ? - and occupancyTypeFieldId = ?`) - .run(lotOccupancyFieldForm.lotOccupancyFieldValue, user.userName, rightNowMillis, lotOccupancyFieldForm.lotOccupancyId, lotOccupancyFieldForm.occupancyTypeFieldId); - if (result.changes === 0) { - result = database - .prepare(`insert into LotOccupancyFields ( - lotOccupancyId, occupancyTypeFieldId, lotOccupancyFieldValue, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?, ?)`) - .run(lotOccupancyFieldForm.lotOccupancyId, lotOccupancyFieldForm.occupancyTypeFieldId, lotOccupancyFieldForm.lotOccupancyFieldValue, user.userName, rightNowMillis, user.userName, rightNowMillis); - } - if (connectedDatabase === undefined) { - database.release(); - } - return result.changes > 0; -} diff --git a/database/addRecord.d.ts b/database/addRecord.d.ts index 988739f0..d1527b6e 100644 --- a/database/addRecord.d.ts +++ b/database/addRecord.d.ts @@ -1,3 +1,3 @@ -type RecordTable = 'LotStatuses' | 'LotTypes' | 'OccupancyTypes' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes'; -export declare function addRecord(recordTable: RecordTable, recordName: string, orderNumber: number | string, user: User): Promise; +type RecordTable = 'BurialSiteStatuses' | 'BurialSiteTypes' | 'ContractTypes' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes'; +export default function addRecord(recordTable: RecordTable, recordName: string, orderNumber: number | string, user: User): Promise; export {}; diff --git a/database/addRecord.js b/database/addRecord.js index 819fdec2..97387734 100644 --- a/database/addRecord.js +++ b/database/addRecord.js @@ -1,12 +1,12 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js'; import { acquireConnection } from './pool.js'; const recordNameColumns = new Map(); -recordNameColumns.set('LotStatuses', 'lotStatus'); -recordNameColumns.set('LotTypes', 'lotType'); -recordNameColumns.set('OccupancyTypes', 'occupancyType'); +recordNameColumns.set('BurialSiteStatuses', 'burialSiteStatus'); +recordNameColumns.set('BurialSiteTypes', 'burialSiteType'); +recordNameColumns.set('ContractTypes', 'contractType'); recordNameColumns.set('WorkOrderMilestoneTypes', 'workOrderMilestoneType'); recordNameColumns.set('WorkOrderTypes', 'workOrderType'); -export async function addRecord(recordTable, recordName, orderNumber, user) { +export default async function addRecord(recordTable, recordName, orderNumber, user) { const database = await acquireConnection(); const rightNowMillis = Date.now(); const result = database diff --git a/database/addRecord.ts b/database/addRecord.ts index ace4111e..ff050ed5 100644 --- a/database/addRecord.ts +++ b/database/addRecord.ts @@ -3,20 +3,20 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js' import { acquireConnection } from './pool.js' type RecordTable = - | 'LotStatuses' - | 'LotTypes' - | 'OccupancyTypes' + | 'BurialSiteStatuses' + | 'BurialSiteTypes' + | 'ContractTypes' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes' const recordNameColumns = new Map() -recordNameColumns.set('LotStatuses', 'lotStatus') -recordNameColumns.set('LotTypes', 'lotType') -recordNameColumns.set('OccupancyTypes', 'occupancyType') +recordNameColumns.set('BurialSiteStatuses', 'burialSiteStatus') +recordNameColumns.set('BurialSiteTypes', 'burialSiteType') +recordNameColumns.set('ContractTypes', 'contractType') recordNameColumns.set('WorkOrderMilestoneTypes', 'workOrderMilestoneType') recordNameColumns.set('WorkOrderTypes', 'workOrderType') -export async function addRecord( +export default async function addRecord( recordTable: RecordTable, recordName: string, orderNumber: number | string, diff --git a/database/addWorkOrder.d.ts b/database/addWorkOrder.d.ts index ce7d4171..4c96d69b 100644 --- a/database/addWorkOrder.d.ts +++ b/database/addWorkOrder.d.ts @@ -4,6 +4,6 @@ export interface AddWorkOrderForm { workOrderDescription: string; workOrderOpenDateString?: string; workOrderCloseDateString?: string; - lotOccupancyId?: string; + burialSiteContractId?: string; } export default function addWorkOrder(workOrderForm: AddWorkOrderForm, user: User): Promise; diff --git a/database/addWorkOrder.js b/database/addWorkOrder.js index 73d2d5c4..9a91b40e 100644 --- a/database/addWorkOrder.js +++ b/database/addWorkOrder.js @@ -1,5 +1,5 @@ import { dateStringToInteger, dateToInteger } from '@cityssm/utils-datetime'; -import addWorkOrderLotOccupancy from './addWorkOrderLotOccupancy.js'; +import addWorkOrderBurialSiteContract from './addWorkOrderBurialSiteContract.js'; import getNextWorkOrderNumber from './getNextWorkOrderNumber.js'; import { acquireConnection } from './pool.js'; export default async function addWorkOrder(workOrderForm, user) { @@ -22,10 +22,10 @@ export default async function addWorkOrder(workOrderForm, user) { ? undefined : dateStringToInteger(workOrderForm.workOrderCloseDateString), user.userName, rightNow.getTime(), user.userName, rightNow.getTime()); const workOrderId = result.lastInsertRowid; - if ((workOrderForm.lotOccupancyId ?? '') !== '') { - await addWorkOrderLotOccupancy({ + if ((workOrderForm.burialSiteContractId ?? '') !== '') { + await addWorkOrderBurialSiteContract({ workOrderId, - lotOccupancyId: workOrderForm.lotOccupancyId + burialSiteContractId: workOrderForm.burialSiteContractId }, user, database); } database.release(); diff --git a/database/addWorkOrder.ts b/database/addWorkOrder.ts index 983375e4..5255045a 100644 --- a/database/addWorkOrder.ts +++ b/database/addWorkOrder.ts @@ -4,7 +4,7 @@ import { dateToInteger } from '@cityssm/utils-datetime' -import addWorkOrderLotOccupancy from './addWorkOrderLotOccupancy.js' +import addWorkOrderBurialSiteContract from './addWorkOrderBurialSiteContract.js' import getNextWorkOrderNumber from './getNextWorkOrderNumber.js' import { acquireConnection } from './pool.js' @@ -14,7 +14,7 @@ export interface AddWorkOrderForm { workOrderDescription: string workOrderOpenDateString?: string workOrderCloseDateString?: string - lotOccupancyId?: string + burialSiteContractId?: string } export default async function addWorkOrder( @@ -62,11 +62,11 @@ export default async function addWorkOrder( const workOrderId = result.lastInsertRowid as number - if ((workOrderForm.lotOccupancyId ?? '') !== '') { - await addWorkOrderLotOccupancy( + if ((workOrderForm.burialSiteContractId ?? '') !== '') { + await addWorkOrderBurialSiteContract( { workOrderId, - lotOccupancyId: workOrderForm.lotOccupancyId! + burialSiteContractId: workOrderForm.burialSiteContractId as string }, user, database diff --git a/database/addWorkOrderLot.d.ts b/database/addWorkOrderBurialSite.d.ts similarity index 100% rename from database/addWorkOrderLot.d.ts rename to database/addWorkOrderBurialSite.d.ts diff --git a/database/addWorkOrderLot.js b/database/addWorkOrderBurialSite.js similarity index 100% rename from database/addWorkOrderLot.js rename to database/addWorkOrderBurialSite.js diff --git a/database/addWorkOrderLot.ts b/database/addWorkOrderBurialSite.ts similarity index 100% rename from database/addWorkOrderLot.ts rename to database/addWorkOrderBurialSite.ts diff --git a/database/addWorkOrderBurialSiteContract.d.ts b/database/addWorkOrderBurialSiteContract.d.ts new file mode 100644 index 00000000..4c6da837 --- /dev/null +++ b/database/addWorkOrderBurialSiteContract.d.ts @@ -0,0 +1,6 @@ +import type { PoolConnection } from 'better-sqlite-pool'; +export interface AddWorkOrderBurialSiteContractOccupancyForm { + workOrderId: number | string; + burialSiteContractId: number | string; +} +export default function addWorkOrderLotOccupancy(addForm: AddWorkOrderBurialSiteContractOccupancyForm, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/addWorkOrderLotOccupancy.js b/database/addWorkOrderBurialSiteContract.js similarity index 51% rename from database/addWorkOrderLotOccupancy.js rename to database/addWorkOrderBurialSiteContract.js index 63b5dd19..92f8f262 100644 --- a/database/addWorkOrderLotOccupancy.js +++ b/database/addWorkOrderBurialSiteContract.js @@ -1,26 +1,27 @@ import { acquireConnection } from './pool.js'; -export default async function addWorkOrderLotOccupancy(workOrderLotOccupancyForm, user, connectedDatabase) { +export default async function addWorkOrderLotOccupancy(addForm, user, connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); const rightNowMillis = Date.now(); - const row = database + const recordDeleteTimeMillis = database .prepare(`select recordDelete_timeMillis - from WorkOrderLotOccupancies + from WorkOrderBurialSiteContracts where workOrderId = ? - and lotOccupancyId = ?`) - .get(workOrderLotOccupancyForm.workOrderId, workOrderLotOccupancyForm.lotOccupancyId); - if (row === undefined) { + and burialSiteContractId = ?`) + .pluck() + .get(addForm.workOrderId, addForm.burialSiteContractId); + if (recordDeleteTimeMillis === undefined) { database - .prepare(`insert into WorkOrderLotOccupancies ( - workOrderId, lotOccupancyId, + .prepare(`insert into WorkOrderBurialSiteContracts ( + workOrderId, burialSiteContractId, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?)`) - .run(workOrderLotOccupancyForm.workOrderId, workOrderLotOccupancyForm.lotOccupancyId, user.userName, rightNowMillis, user.userName, rightNowMillis); + .run(addForm.workOrderId, addForm.burialSiteContractId, user.userName, rightNowMillis, user.userName, rightNowMillis); } else { - if (row.recordDelete_timeMillis !== null) { + if (recordDeleteTimeMillis !== null) { database - .prepare(`update WorkOrderLotOccupancies + .prepare(`update WorkOrderBurialSiteContracts set recordCreate_userName = ?, recordCreate_timeMillis = ?, recordUpdate_userName = ?, @@ -28,8 +29,8 @@ export default async function addWorkOrderLotOccupancy(workOrderLotOccupancyForm recordDelete_userName = null, recordDelete_timeMillis = null where workOrderId = ? - and lotOccupancyId = ?`) - .run(user.userName, rightNowMillis, user.userName, rightNowMillis, workOrderLotOccupancyForm.workOrderId, workOrderLotOccupancyForm.lotOccupancyId); + and burialSiteContractId = ?`) + .run(user.userName, rightNowMillis, user.userName, rightNowMillis, addForm.workOrderId, addForm.burialSiteContractId); } } if (connectedDatabase === undefined) { diff --git a/database/addWorkOrderLotOccupancy.ts b/database/addWorkOrderBurialSiteContract.ts similarity index 61% rename from database/addWorkOrderLotOccupancy.ts rename to database/addWorkOrderBurialSiteContract.ts index 9435174c..da96fdb7 100644 --- a/database/addWorkOrderLotOccupancy.ts +++ b/database/addWorkOrderBurialSiteContract.ts @@ -2,13 +2,13 @@ import type { PoolConnection } from 'better-sqlite-pool' import { acquireConnection } from './pool.js' -export interface AddWorkOrderLotOccupancyForm { +export interface AddWorkOrderBurialSiteContractOccupancyForm { workOrderId: number | string - lotOccupancyId: number | string + burialSiteContractId: number | string } export default async function addWorkOrderLotOccupancy( - workOrderLotOccupancyForm: AddWorkOrderLotOccupancyForm, + addForm: AddWorkOrderBurialSiteContractOccupancyForm, user: User, connectedDatabase?: PoolConnection ): Promise { @@ -16,40 +16,41 @@ export default async function addWorkOrderLotOccupancy( const rightNowMillis = Date.now() - const row = database + const recordDeleteTimeMillis: number | null | undefined = database .prepare( `select recordDelete_timeMillis - from WorkOrderLotOccupancies + from WorkOrderBurialSiteContracts where workOrderId = ? - and lotOccupancyId = ?` + and burialSiteContractId = ?` ) + .pluck() .get( - workOrderLotOccupancyForm.workOrderId, - workOrderLotOccupancyForm.lotOccupancyId - ) as { recordDelete_timeMillis?: number } + addForm.workOrderId, + addForm.burialSiteContractId + ) as number | null | undefined - if (row === undefined) { + if (recordDeleteTimeMillis === undefined) { database .prepare( - `insert into WorkOrderLotOccupancies ( - workOrderId, lotOccupancyId, + `insert into WorkOrderBurialSiteContracts ( + workOrderId, burialSiteContractId, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?)` ) .run( - workOrderLotOccupancyForm.workOrderId, - workOrderLotOccupancyForm.lotOccupancyId, + addForm.workOrderId, + addForm.burialSiteContractId, user.userName, rightNowMillis, user.userName, rightNowMillis ) } else { - if (row.recordDelete_timeMillis !== null) { + if (recordDeleteTimeMillis !== null) { database .prepare( - `update WorkOrderLotOccupancies + `update WorkOrderBurialSiteContracts set recordCreate_userName = ?, recordCreate_timeMillis = ?, recordUpdate_userName = ?, @@ -57,15 +58,15 @@ export default async function addWorkOrderLotOccupancy( recordDelete_userName = null, recordDelete_timeMillis = null where workOrderId = ? - and lotOccupancyId = ?` + and burialSiteContractId = ?` ) .run( user.userName, rightNowMillis, user.userName, rightNowMillis, - workOrderLotOccupancyForm.workOrderId, - workOrderLotOccupancyForm.lotOccupancyId + addForm.workOrderId, + addForm.burialSiteContractId ) } } diff --git a/database/addWorkOrderLotOccupancy.d.ts b/database/addWorkOrderLotOccupancy.d.ts deleted file mode 100644 index 6c97ae94..00000000 --- a/database/addWorkOrderLotOccupancy.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { PoolConnection } from 'better-sqlite-pool'; -export interface AddWorkOrderLotOccupancyForm { - workOrderId: number | string; - lotOccupancyId: number | string; -} -export default function addWorkOrderLotOccupancy(workOrderLotOccupancyForm: AddWorkOrderLotOccupancyForm, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/cleanupDatabase.js b/database/cleanupDatabase.js index 1e80a4cf..9e813098 100644 --- a/database/cleanupDatabase.js +++ b/database/cleanupDatabase.js @@ -1,12 +1,11 @@ -import { getConfigProperty } from '../helpers/functions.config.js'; +import { daysToMillis } from '@cityssm/to-millis'; +import { getConfigProperty } from '../helpers/config.helpers.js'; import { acquireConnection } from './pool.js'; export default async function cleanupDatabase(user) { const database = await acquireConnection(); const rightNowMillis = Date.now(); const recordDeleteTimeMillisMin = rightNowMillis - - getConfigProperty('settings.adminCleanup.recordDeleteAgeDays') * - 86_400 * - 1000; + daysToMillis(getConfigProperty('settings.adminCleanup.recordDeleteAgeDays')); let inactivatedRecordCount = 0; let purgedRecordCount = 0; /* @@ -24,10 +23,10 @@ export default async function cleanupDatabase(user) { .prepare('delete from WorkOrderComments where recordDelete_timeMillis <= ?') .run(recordDeleteTimeMillisMin).changes; /* - * Work Order Lot Occupancies + * Work Order Burial Site Contracts */ inactivatedRecordCount += database - .prepare(`update WorkOrderLotOccupancies + .prepare(`update WorkOrderBurialSiteContracts set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null @@ -35,13 +34,13 @@ export default async function cleanupDatabase(user) { select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database - .prepare('delete from WorkOrderLotOccupancies where recordDelete_timeMillis <= ?') + .prepare('delete from WorkOrderBurialSiteContracts where recordDelete_timeMillis <= ?') .run(recordDeleteTimeMillisMin).changes; /* - * Work Order Lots + * Work Order Burial Sites */ inactivatedRecordCount += database - .prepare(`update WorkOrderLots + .prepare(`update WorkOrderBurialSites set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null @@ -49,7 +48,7 @@ export default async function cleanupDatabase(user) { select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database - .prepare('delete from WorkOrderLots where recordDelete_timeMillis <= ?') + .prepare('delete from WorkOrderBurialSites where recordDelete_timeMillis <= ?') .run(recordDeleteTimeMillisMin).changes; /* * Work Order Milestones @@ -72,8 +71,8 @@ export default async function cleanupDatabase(user) { .prepare(`delete from WorkOrders where recordDelete_timeMillis <= ? and workOrderId not in (select workOrderId from WorkOrderComments) - and workOrderId not in (select workOrderId from WorkOrderLotOccupancies) - and workOrderId not in (select workOrderId from WorkOrderLots) + and workOrderId not in (select workOrderId from WorkOrderBurialSiteContracts) + and workOrderId not in (select workOrderId from WorkOrderBurialSites) and workOrderId not in (select workOrderId from WorkOrderMilestones)`) .run(recordDeleteTimeMillisMin).changes; /* @@ -94,67 +93,54 @@ export default async function cleanupDatabase(user) { and workOrderTypeId not in (select workOrderTypeId from WorkOrders)`) .run(recordDeleteTimeMillisMin).changes; /* - * Lot Occupancy Comments + * Burial Site Contract Comments */ inactivatedRecordCount += database - .prepare(`update LotOccupancyComments + .prepare(`update BurialSiteContractComments set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and lotOccupancyId in ( - select lotOccupancyId from LotOccupancies where recordDelete_timeMillis is not null)`) + and burialSiteContractId in ( + select burialSiteContractId from BurialSiteContracts where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database - .prepare('delete from LotOccupancyComments where recordDelete_timeMillis <= ?') + .prepare('delete from BurialSiteContractComments where recordDelete_timeMillis <= ?') .run(recordDeleteTimeMillisMin).changes; /* - * Lot Occupancy Fields + * Burial Site Contract Fields */ inactivatedRecordCount += database - .prepare(`update LotOccupancyFields + .prepare(`update BurialSiteContractFields set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and lotOccupancyId in (select lotOccupancyId from LotOccupancies where recordDelete_timeMillis is not null)`) + and burialSiteContractId in (select burialSiteContractId from BurialSiteContracts where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database - .prepare('delete from LotOccupancyFields where recordDelete_timeMillis <= ?') + .prepare('delete from BurialSiteContractFields where recordDelete_timeMillis <= ?') .run(recordDeleteTimeMillisMin).changes; /* - * Lot Occupancy Occupants - */ - inactivatedRecordCount += database - .prepare(`update LotOccupancyOccupants - set recordDelete_userName = ?, - recordDelete_timeMillis = ? - where recordDelete_timeMillis is null - and lotOccupancyId in (select lotOccupancyId from LotOccupancies where recordDelete_timeMillis is not null)`) - .run(user.userName, rightNowMillis).changes; - purgedRecordCount += database - .prepare('delete from LotOccupancyOccupants where recordDelete_timeMillis <= ?') - .run(recordDeleteTimeMillisMin).changes; - /* - * Lot Occupancy Fees/Transactions + * Burial Site Contract Fees/Transactions * - Maintain financials, do not delete related. */ purgedRecordCount += database - .prepare('delete from LotOccupancyFees where recordDelete_timeMillis <= ?') + .prepare('delete from BurialSiteContractFees where recordDelete_timeMillis <= ?') .run(recordDeleteTimeMillisMin).changes; purgedRecordCount += database - .prepare('delete from LotOccupancyTransactions where recordDelete_timeMillis <= ?') + .prepare('delete from BurialSiteContractTransactions where recordDelete_timeMillis <= ?') .run(recordDeleteTimeMillisMin).changes; /* - * Lot Occupancies + * Burial Site Contracts */ purgedRecordCount += database - .prepare(`delete from LotOccupancies + .prepare(`delete from BurialSiteContracts where recordDelete_timeMillis <= ? - and lotOccupancyId not in (select lotOccupancyId from LotOccupancyComments) - and lotOccupancyId not in (select lotOccupancyId from LotOccupancyFees) - and lotOccupancyId not in (select lotOccupancyId from LotOccupancyFields) - and lotOccupancyId not in (select lotOccupancyId from LotOccupancyOccupants) - and lotOccupancyId not in (select lotOccupancyId from LotOccupancyTransactions) - and lotOccupancyId not in (select lotOccupancyId from WorkOrderLotOccupancies)`) + and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractComments) + and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractFees) + and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractFields) + and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractInterments) + and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractTransactions) + and burialSiteContractId not in (select burialSiteContractId from WorkOrderBurialSiteContracts)`) .run(recordDeleteTimeMillisMin).changes; /* * Fees @@ -169,7 +155,7 @@ export default async function cleanupDatabase(user) { purgedRecordCount += database .prepare(`delete from Fees where recordDelete_timeMillis <= ? - and feeId not in (select feeId from LotOccupancyFees)`) + and feeId not in (select feeId from BurialSiteContractFees)`) .run(recordDeleteTimeMillisMin).changes; /* * Fee Categories @@ -180,126 +166,118 @@ export default async function cleanupDatabase(user) { and feeCategoryId not in (select feeCategoryId from Fees)`) .run(recordDeleteTimeMillisMin).changes; /* - * Occupancy Type Fields + * Contract Type Fields */ inactivatedRecordCount += database - .prepare(`update OccupancyTypeFields + .prepare(`update ContractTypeFields set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and occupancyTypeId in (select occupancyTypeId from OccupancyTypes where recordDelete_timeMillis is not null)`) + and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database - .prepare(`delete from OccupancyTypeFields + .prepare(`delete from ContractTypeFields where recordDelete_timeMillis <= ? - and occupancyTypeFieldId not in (select occupancyTypeFieldId from LotOccupancyFields)`) + and contractTypeFieldId not in (select contractTypeFieldId from BurialSiteContractFields)`) .run(recordDeleteTimeMillisMin).changes; /* * Occupancy Type Prints */ inactivatedRecordCount += database - .prepare(`update OccupancyTypePrints + .prepare(`update ContractTypePrints set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and occupancyTypeId in (select occupancyTypeId from OccupancyTypes where recordDelete_timeMillis is not null)`) + and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database - .prepare('delete from OccupancyTypePrints where recordDelete_timeMillis <= ?') + .prepare('delete from ContractTypePrints where recordDelete_timeMillis <= ?') .run(recordDeleteTimeMillisMin).changes; /* - * Occupancy Types + * Contract Types */ purgedRecordCount += database - .prepare(`delete from OccupancyTypes + .prepare(`delete from ContractTypes where recordDelete_timeMillis <= ? - and occupancyTypeId not in (select occupancyTypeId from OccupancyTypeFields) - and occupancyTypeId not in (select occupancyTypeId from OccupancyTypePrints) - and occupancyTypeId not in (select occupancyTypeId from LotOccupancies) - and occupancyTypeId not in (select occupancyTypeId from Fees)`) + and contractTypeId not in (select contractTypeId from ContractTypeFields) + and contractTypeId not in (select contractTypeId from ContractTypePrints) + and contractTypeId not in (select contractTypeId from BurialSiteContracts) + and contractTypeId not in (select contractTypeId from Fees)`) .run(recordDeleteTimeMillisMin).changes; /* - * Lot Occupant Types - */ - purgedRecordCount += database - .prepare(`delete from LotOccupantTypes - where recordDelete_timeMillis <= ? - and lotOccupantTypeId not in (select lotOccupantTypeId from LotOccupancyOccupants)`) - .run(recordDeleteTimeMillisMin).changes; - /* - * Lot Comments + * Burial Site Comments */ inactivatedRecordCount += database - .prepare(`update LotComments + .prepare(`update BurialSiteComments set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and lotId in (select lotId from Lots where recordDelete_timeMillis is not null)`) + and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database - .prepare('delete from LotComments where recordDelete_timeMillis <= ?') + .prepare('delete from BurialSiteComments where recordDelete_timeMillis <= ?') .run(recordDeleteTimeMillisMin).changes; /* - * Lot Fields + * Burial Site Fields */ inactivatedRecordCount += database - .prepare(`update LotFields + .prepare(`update BurialSiteFields set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and lotId in (select lotId from Lots where recordDelete_timeMillis is not null)`) + and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database - .prepare('delete from LotFields where recordDelete_timeMillis <= ?') + .prepare('delete from BurialSiteFields where recordDelete_timeMillis <= ?') .run(recordDeleteTimeMillisMin).changes; /* - * Lots + * Burial Sites */ inactivatedRecordCount += database - .prepare(`update Lots + .prepare(`update BurialSites set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and mapId in (select mapId from Maps where recordDelete_timeMillis is not null)`) + and cemeteryId in (select cemeteryId from Cemeteries where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database - .prepare(`delete from Lots + .prepare(`delete from BurialSites where recordDelete_timeMillis <= ? - and lotId not in (select lotId from LotComments) - and lotId not in (select lotId from LotFields) - and lotId not in (select lotId from LotOccupancies) - and lotId not in (select lotId from WorkOrderLots)`) + and burialSiteId not in (select burialSiteId from BurialSiteComments) + and burialSiteId not in (select burialSiteId from BurialSiteFields) + and burialSiteId not in (select burialSiteId from BurialSiteContracts) + and burialSiteId not in (select burialSiteId from WorkOrderLots)`) .run(recordDeleteTimeMillisMin).changes; /* - * Lot Statuses + * Burial Site Statuses */ purgedRecordCount += database - .prepare(`delete from LotStatuses + .prepare(`delete from BurialSiteStatuses where recordDelete_timeMillis <= ? - and lotStatusId not in (select lotStatusId from Lots)`) + and burialSiteStatusId not in (select burialSiteStatusId from BurialSites)`) .run(recordDeleteTimeMillisMin).changes; /* - * Lot Type Fields + * Burial Site Type Fields */ inactivatedRecordCount += database - .prepare(`update LotTypeFields + .prepare(`update BurialSiteTypeFields set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and lotTypeId in (select lotTypeId from LotTypes where recordDelete_timeMillis is not null)`) + and burialSiteTypeId in (select burialSiteTypeId from BurialSiteTypes where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database - .prepare(`delete from LotTypeFields + .prepare(`delete from BurialSiteTypeFields where recordDelete_timeMillis <= ? - and lotTypeFieldId not in (select lotTypeFieldId from LotFields)`) + and burialSiteTypeFieldId not in (select burialSiteTypeFieldId from BurialSiteFields)`) .run(recordDeleteTimeMillisMin).changes; /* - * Lot Types + * Burial Site Types */ purgedRecordCount += database - .prepare(`delete from LotTypes + .prepare(`delete from BurialSiteTypes where recordDelete_timeMillis <= ? - and lotTypeId not in (select lotTypeId from Lots)`) + and burialSiteTypeId not in (select burialSiteTypeId from BurialSites)`) .run(recordDeleteTimeMillisMin).changes; database.release(); return { diff --git a/database/cleanupDatabase.ts b/database/cleanupDatabase.ts index 8e851401..f16fbc25 100644 --- a/database/cleanupDatabase.ts +++ b/database/cleanupDatabase.ts @@ -1,4 +1,6 @@ -import { getConfigProperty } from '../helpers/functions.config.js' +import { daysToMillis } from '@cityssm/to-millis' + +import { getConfigProperty } from '../helpers/config.helpers.js' import { acquireConnection } from './pool.js' @@ -10,9 +12,7 @@ export default async function cleanupDatabase( const rightNowMillis = Date.now() const recordDeleteTimeMillisMin = rightNowMillis - - getConfigProperty('settings.adminCleanup.recordDeleteAgeDays') * - 86_400 * - 1000 + daysToMillis(getConfigProperty('settings.adminCleanup.recordDeleteAgeDays')) let inactivatedRecordCount = 0 let purgedRecordCount = 0 @@ -37,12 +37,12 @@ export default async function cleanupDatabase( .run(recordDeleteTimeMillisMin).changes /* - * Work Order Lot Occupancies + * Work Order Burial Site Contracts */ inactivatedRecordCount += database .prepare( - `update WorkOrderLotOccupancies + `update WorkOrderBurialSiteContracts set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null @@ -53,17 +53,17 @@ export default async function cleanupDatabase( purgedRecordCount += database .prepare( - 'delete from WorkOrderLotOccupancies where recordDelete_timeMillis <= ?' + 'delete from WorkOrderBurialSiteContracts where recordDelete_timeMillis <= ?' ) .run(recordDeleteTimeMillisMin).changes /* - * Work Order Lots + * Work Order Burial Sites */ inactivatedRecordCount += database .prepare( - `update WorkOrderLots + `update WorkOrderBurialSites set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null @@ -73,7 +73,9 @@ export default async function cleanupDatabase( .run(user.userName, rightNowMillis).changes purgedRecordCount += database - .prepare('delete from WorkOrderLots where recordDelete_timeMillis <= ?') + .prepare( + 'delete from WorkOrderBurialSites where recordDelete_timeMillis <= ?' + ) .run(recordDeleteTimeMillisMin).changes /* @@ -106,8 +108,8 @@ export default async function cleanupDatabase( `delete from WorkOrders where recordDelete_timeMillis <= ? and workOrderId not in (select workOrderId from WorkOrderComments) - and workOrderId not in (select workOrderId from WorkOrderLotOccupancies) - and workOrderId not in (select workOrderId from WorkOrderLots) + and workOrderId not in (select workOrderId from WorkOrderBurialSiteContracts) + and workOrderId not in (select workOrderId from WorkOrderBurialSites) and workOrderId not in (select workOrderId from WorkOrderMilestones)` ) .run(recordDeleteTimeMillisMin).changes @@ -138,95 +140,77 @@ export default async function cleanupDatabase( .run(recordDeleteTimeMillisMin).changes /* - * Lot Occupancy Comments + * Burial Site Contract Comments */ inactivatedRecordCount += database .prepare( - `update LotOccupancyComments + `update BurialSiteContractComments set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and lotOccupancyId in ( - select lotOccupancyId from LotOccupancies where recordDelete_timeMillis is not null)` + and burialSiteContractId in ( + select burialSiteContractId from BurialSiteContracts where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes purgedRecordCount += database .prepare( - 'delete from LotOccupancyComments where recordDelete_timeMillis <= ?' + 'delete from BurialSiteContractComments where recordDelete_timeMillis <= ?' ) .run(recordDeleteTimeMillisMin).changes /* - * Lot Occupancy Fields + * Burial Site Contract Fields */ inactivatedRecordCount += database .prepare( - `update LotOccupancyFields + `update BurialSiteContractFields set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and lotOccupancyId in (select lotOccupancyId from LotOccupancies where recordDelete_timeMillis is not null)` + and burialSiteContractId in (select burialSiteContractId from BurialSiteContracts where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes purgedRecordCount += database .prepare( - 'delete from LotOccupancyFields where recordDelete_timeMillis <= ?' + 'delete from BurialSiteContractFields where recordDelete_timeMillis <= ?' ) .run(recordDeleteTimeMillisMin).changes /* - * Lot Occupancy Occupants - */ - - inactivatedRecordCount += database - .prepare( - `update LotOccupancyOccupants - set recordDelete_userName = ?, - recordDelete_timeMillis = ? - where recordDelete_timeMillis is null - and lotOccupancyId in (select lotOccupancyId from LotOccupancies where recordDelete_timeMillis is not null)` - ) - .run(user.userName, rightNowMillis).changes - - purgedRecordCount += database - .prepare( - 'delete from LotOccupancyOccupants where recordDelete_timeMillis <= ?' - ) - .run(recordDeleteTimeMillisMin).changes - - /* - * Lot Occupancy Fees/Transactions + * Burial Site Contract Fees/Transactions * - Maintain financials, do not delete related. */ purgedRecordCount += database - .prepare('delete from LotOccupancyFees where recordDelete_timeMillis <= ?') + .prepare( + 'delete from BurialSiteContractFees where recordDelete_timeMillis <= ?' + ) .run(recordDeleteTimeMillisMin).changes purgedRecordCount += database .prepare( - 'delete from LotOccupancyTransactions where recordDelete_timeMillis <= ?' + 'delete from BurialSiteContractTransactions where recordDelete_timeMillis <= ?' ) .run(recordDeleteTimeMillisMin).changes /* - * Lot Occupancies + * Burial Site Contracts */ purgedRecordCount += database .prepare( - `delete from LotOccupancies + `delete from BurialSiteContracts where recordDelete_timeMillis <= ? - and lotOccupancyId not in (select lotOccupancyId from LotOccupancyComments) - and lotOccupancyId not in (select lotOccupancyId from LotOccupancyFees) - and lotOccupancyId not in (select lotOccupancyId from LotOccupancyFields) - and lotOccupancyId not in (select lotOccupancyId from LotOccupancyOccupants) - and lotOccupancyId not in (select lotOccupancyId from LotOccupancyTransactions) - and lotOccupancyId not in (select lotOccupancyId from WorkOrderLotOccupancies)` + and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractComments) + and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractFees) + and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractFields) + and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractInterments) + and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractTransactions) + and burialSiteContractId not in (select burialSiteContractId from WorkOrderBurialSiteContracts)` ) .run(recordDeleteTimeMillisMin).changes @@ -248,7 +232,7 @@ export default async function cleanupDatabase( .prepare( `delete from Fees where recordDelete_timeMillis <= ? - and feeId not in (select feeId from LotOccupancyFees)` + and feeId not in (select feeId from BurialSiteContractFees)` ) .run(recordDeleteTimeMillisMin).changes @@ -265,24 +249,24 @@ export default async function cleanupDatabase( .run(recordDeleteTimeMillisMin).changes /* - * Occupancy Type Fields + * Contract Type Fields */ inactivatedRecordCount += database .prepare( - `update OccupancyTypeFields + `update ContractTypeFields set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and occupancyTypeId in (select occupancyTypeId from OccupancyTypes where recordDelete_timeMillis is not null)` + and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes purgedRecordCount += database .prepare( - `delete from OccupancyTypeFields + `delete from ContractTypeFields where recordDelete_timeMillis <= ? - and occupancyTypeFieldId not in (select occupancyTypeFieldId from LotOccupancyFields)` + and contractTypeFieldId not in (select contractTypeFieldId from BurialSiteContractFields)` ) .run(recordDeleteTimeMillisMin).changes @@ -292,151 +276,141 @@ export default async function cleanupDatabase( inactivatedRecordCount += database .prepare( - `update OccupancyTypePrints + `update ContractTypePrints set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and occupancyTypeId in (select occupancyTypeId from OccupancyTypes where recordDelete_timeMillis is not null)` + and contractTypeId in (select contractTypeId from ContractTypes where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes purgedRecordCount += database .prepare( - 'delete from OccupancyTypePrints where recordDelete_timeMillis <= ?' + 'delete from ContractTypePrints where recordDelete_timeMillis <= ?' ) .run(recordDeleteTimeMillisMin).changes /* - * Occupancy Types + * Contract Types */ purgedRecordCount += database .prepare( - `delete from OccupancyTypes + `delete from ContractTypes where recordDelete_timeMillis <= ? - and occupancyTypeId not in (select occupancyTypeId from OccupancyTypeFields) - and occupancyTypeId not in (select occupancyTypeId from OccupancyTypePrints) - and occupancyTypeId not in (select occupancyTypeId from LotOccupancies) - and occupancyTypeId not in (select occupancyTypeId from Fees)` + and contractTypeId not in (select contractTypeId from ContractTypeFields) + and contractTypeId not in (select contractTypeId from ContractTypePrints) + and contractTypeId not in (select contractTypeId from BurialSiteContracts) + and contractTypeId not in (select contractTypeId from Fees)` ) .run(recordDeleteTimeMillisMin).changes /* - * Lot Occupant Types - */ - - purgedRecordCount += database - .prepare( - `delete from LotOccupantTypes - where recordDelete_timeMillis <= ? - and lotOccupantTypeId not in (select lotOccupantTypeId from LotOccupancyOccupants)` - ) - .run(recordDeleteTimeMillisMin).changes - - /* - * Lot Comments + * Burial Site Comments */ inactivatedRecordCount += database .prepare( - `update LotComments + `update BurialSiteComments set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and lotId in (select lotId from Lots where recordDelete_timeMillis is not null)` + and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes purgedRecordCount += database - .prepare('delete from LotComments where recordDelete_timeMillis <= ?') + .prepare( + 'delete from BurialSiteComments where recordDelete_timeMillis <= ?' + ) .run(recordDeleteTimeMillisMin).changes /* - * Lot Fields + * Burial Site Fields */ inactivatedRecordCount += database .prepare( - `update LotFields + `update BurialSiteFields set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and lotId in (select lotId from Lots where recordDelete_timeMillis is not null)` + and burialSiteId in (select burialSiteId from BurialSites where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes purgedRecordCount += database - .prepare('delete from LotFields where recordDelete_timeMillis <= ?') + .prepare('delete from BurialSiteFields where recordDelete_timeMillis <= ?') .run(recordDeleteTimeMillisMin).changes /* - * Lots + * Burial Sites */ inactivatedRecordCount += database .prepare( - `update Lots + `update BurialSites set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and mapId in (select mapId from Maps where recordDelete_timeMillis is not null)` + and cemeteryId in (select cemeteryId from Cemeteries where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes purgedRecordCount += database .prepare( - `delete from Lots + `delete from BurialSites where recordDelete_timeMillis <= ? - and lotId not in (select lotId from LotComments) - and lotId not in (select lotId from LotFields) - and lotId not in (select lotId from LotOccupancies) - and lotId not in (select lotId from WorkOrderLots)` + and burialSiteId not in (select burialSiteId from BurialSiteComments) + and burialSiteId not in (select burialSiteId from BurialSiteFields) + and burialSiteId not in (select burialSiteId from BurialSiteContracts) + and burialSiteId not in (select burialSiteId from WorkOrderLots)` ) .run(recordDeleteTimeMillisMin).changes /* - * Lot Statuses + * Burial Site Statuses */ purgedRecordCount += database .prepare( - `delete from LotStatuses + `delete from BurialSiteStatuses where recordDelete_timeMillis <= ? - and lotStatusId not in (select lotStatusId from Lots)` + and burialSiteStatusId not in (select burialSiteStatusId from BurialSites)` ) .run(recordDeleteTimeMillisMin).changes /* - * Lot Type Fields + * Burial Site Type Fields */ inactivatedRecordCount += database .prepare( - `update LotTypeFields + `update BurialSiteTypeFields set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and lotTypeId in (select lotTypeId from LotTypes where recordDelete_timeMillis is not null)` + and burialSiteTypeId in (select burialSiteTypeId from BurialSiteTypes where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes purgedRecordCount += database .prepare( - `delete from LotTypeFields + `delete from BurialSiteTypeFields where recordDelete_timeMillis <= ? - and lotTypeFieldId not in (select lotTypeFieldId from LotFields)` + and burialSiteTypeFieldId not in (select burialSiteTypeFieldId from BurialSiteFields)` ) .run(recordDeleteTimeMillisMin).changes /* - * Lot Types + * Burial Site Types */ purgedRecordCount += database .prepare( - `delete from LotTypes + `delete from BurialSiteTypes where recordDelete_timeMillis <= ? - and lotTypeId not in (select lotTypeId from Lots)` + and burialSiteTypeId not in (select burialSiteTypeId from BurialSites)` ) .run(recordDeleteTimeMillisMin).changes diff --git a/database/deleteBurialSiteContractFee.d.ts b/database/deleteBurialSiteContractFee.d.ts new file mode 100644 index 00000000..9ad5a7fc --- /dev/null +++ b/database/deleteBurialSiteContractFee.d.ts @@ -0,0 +1 @@ +export default function deleteBurialSiteContractFee(burialSiteContractId: number | string, feeId: number | string, user: User): Promise; diff --git a/database/deleteLotOccupancyFee.js b/database/deleteBurialSiteContractFee.js similarity index 52% rename from database/deleteLotOccupancyFee.js rename to database/deleteBurialSiteContractFee.js index 40e60737..85c3a41d 100644 --- a/database/deleteLotOccupancyFee.js +++ b/database/deleteBurialSiteContractFee.js @@ -1,13 +1,13 @@ import { acquireConnection } from './pool.js'; -export default async function deleteLotOccupancyFee(lotOccupancyId, feeId, user) { +export default async function deleteBurialSiteContractFee(burialSiteContractId, feeId, user) { const database = await acquireConnection(); const result = database - .prepare(`update LotOccupancyFees + .prepare(`update BurialSteContractFees set recordDelete_userName = ?, recordDelete_timeMillis = ? - where lotOccupancyId = ? + where burialSiteContractId = ? and feeId = ?`) - .run(user.userName, Date.now(), lotOccupancyId, feeId); + .run(user.userName, Date.now(), burialSiteContractId, feeId); database.release(); return result.changes > 0; } diff --git a/database/deleteLotOccupancyFee.ts b/database/deleteBurialSiteContractFee.ts similarity index 59% rename from database/deleteLotOccupancyFee.ts rename to database/deleteBurialSiteContractFee.ts index 67293547..c3c52a9a 100644 --- a/database/deleteLotOccupancyFee.ts +++ b/database/deleteBurialSiteContractFee.ts @@ -1,7 +1,7 @@ import { acquireConnection } from './pool.js' -export default async function deleteLotOccupancyFee( - lotOccupancyId: number | string, +export default async function deleteBurialSiteContractFee( + burialSiteContractId: number | string, feeId: number | string, user: User ): Promise { @@ -9,13 +9,13 @@ export default async function deleteLotOccupancyFee( const result = database .prepare( - `update LotOccupancyFees + `update BurialSteContractFees set recordDelete_userName = ?, recordDelete_timeMillis = ? - where lotOccupancyId = ? + where burialSiteContractId = ? and feeId = ?` ) - .run(user.userName, Date.now(), lotOccupancyId, feeId) + .run(user.userName, Date.now(), burialSiteContractId, feeId) database.release() diff --git a/database/deleteBurialSiteContractField.d.ts b/database/deleteBurialSiteContractField.d.ts new file mode 100644 index 00000000..6a71c485 --- /dev/null +++ b/database/deleteBurialSiteContractField.d.ts @@ -0,0 +1,2 @@ +import type { PoolConnection } from 'better-sqlite-pool'; +export default function deleteBurialSiteContractField(burialSiteContractId: number | string, contractTypeFieldId: number | string, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/deleteBurialSiteContractField.js b/database/deleteBurialSiteContractField.js new file mode 100644 index 00000000..388e9e94 --- /dev/null +++ b/database/deleteBurialSiteContractField.js @@ -0,0 +1,15 @@ +import { acquireConnection } from './pool.js'; +export default async function deleteBurialSiteContractField(burialSiteContractId, contractTypeFieldId, user, connectedDatabase) { + const database = connectedDatabase ?? (await acquireConnection()); + const result = database + .prepare(`update BurialSiteContractFields + set recordDelete_userName = ?, + recordDelete_timeMillis = ? + where burialSiteContractId = ? + and contractTypeFieldId = ?`) + .run(user.userName, Date.now(), burialSiteContractId, contractTypeFieldId); + if (connectedDatabase === undefined) { + database.release(); + } + return result.changes > 0; +} diff --git a/database/deleteLotOccupancyField.ts b/database/deleteBurialSiteContractField.ts similarity index 58% rename from database/deleteLotOccupancyField.ts rename to database/deleteBurialSiteContractField.ts index f7332d46..d9067bc8 100644 --- a/database/deleteLotOccupancyField.ts +++ b/database/deleteBurialSiteContractField.ts @@ -2,9 +2,9 @@ import type { PoolConnection } from 'better-sqlite-pool' import { acquireConnection } from './pool.js' -export default async function deleteLotOccupancyField( - lotOccupancyId: number | string, - occupancyTypeFieldId: number | string, +export default async function deleteBurialSiteContractField( + burialSiteContractId: number | string, + contractTypeFieldId: number | string, user: User, connectedDatabase?: PoolConnection ): Promise { @@ -12,13 +12,13 @@ export default async function deleteLotOccupancyField( const result = database .prepare( - `update LotOccupancyFields + `update BurialSiteContractFields set recordDelete_userName = ?, recordDelete_timeMillis = ? - where lotOccupancyId = ? - and occupancyTypeFieldId = ?` + where burialSiteContractId = ? + and contractTypeFieldId = ?` ) - .run(user.userName, Date.now(), lotOccupancyId, occupancyTypeFieldId) + .run(user.userName, Date.now(), burialSiteContractId, contractTypeFieldId) if (connectedDatabase === undefined) { database.release() diff --git a/database/deleteBurialSiteContractInterment.d.ts b/database/deleteBurialSiteContractInterment.d.ts new file mode 100644 index 00000000..7961bfa4 --- /dev/null +++ b/database/deleteBurialSiteContractInterment.d.ts @@ -0,0 +1 @@ +export default function deleteBurialSiteContractInterment(burialSiteContractId: number | string, intermentNumber: number | string, user: User): Promise; diff --git a/database/deleteBurialSiteContractInterment.js b/database/deleteBurialSiteContractInterment.js new file mode 100644 index 00000000..31e5afb4 --- /dev/null +++ b/database/deleteBurialSiteContractInterment.js @@ -0,0 +1,13 @@ +import { acquireConnection } from './pool.js'; +export default async function deleteBurialSiteContractInterment(burialSiteContractId, intermentNumber, user) { + const database = await acquireConnection(); + const result = database + .prepare(`update BurialSiteContractInterments + set recordDelete_userName = ?, + recordDelete_timeMillis = ? + where burialSiteContractId = ? + and intermentNumber = ?`) + .run(user.userName, Date.now(), burialSiteContractId, intermentNumber); + database.release(); + return result.changes > 0; +} diff --git a/database/deleteBurialSiteContractInterment.ts b/database/deleteBurialSiteContractInterment.ts new file mode 100644 index 00000000..d59e92a0 --- /dev/null +++ b/database/deleteBurialSiteContractInterment.ts @@ -0,0 +1,23 @@ +import { acquireConnection } from './pool.js' + +export default async function deleteBurialSiteContractInterment( + burialSiteContractId: number | string, + intermentNumber: number | string, + user: User +): Promise { + const database = await acquireConnection() + + const result = database + .prepare( + `update BurialSiteContractInterments + set recordDelete_userName = ?, + recordDelete_timeMillis = ? + where burialSiteContractId = ? + and intermentNumber = ?` + ) + .run(user.userName, Date.now(), burialSiteContractId, intermentNumber) + + database.release() + + return result.changes > 0 +} diff --git a/database/deleteBurialSiteContractTransaction.d.ts b/database/deleteBurialSiteContractTransaction.d.ts new file mode 100644 index 00000000..12a0577c --- /dev/null +++ b/database/deleteBurialSiteContractTransaction.d.ts @@ -0,0 +1 @@ +export default function deleteBurialSiteContractTransaction(burialSiteContractId: number | string, transactionIndex: number | string, user: User): Promise; diff --git a/database/deleteLotOccupancyTransaction.js b/database/deleteBurialSiteContractTransaction.js similarity index 50% rename from database/deleteLotOccupancyTransaction.js rename to database/deleteBurialSiteContractTransaction.js index 0a7bb9e4..c7f72852 100644 --- a/database/deleteLotOccupancyTransaction.js +++ b/database/deleteBurialSiteContractTransaction.js @@ -1,13 +1,13 @@ import { acquireConnection } from './pool.js'; -export default async function deleteLotOccupancyTransaction(lotOccupancyId, transactionIndex, user) { +export default async function deleteBurialSiteContractTransaction(burialSiteContractId, transactionIndex, user) { const database = await acquireConnection(); const result = database - .prepare(`update LotOccupancyTransactions + .prepare(`update BurialSiteContractTransactions set recordDelete_userName = ?, recordDelete_timeMillis = ? - where lotOccupancyId = ? + where burialSiteContractId = ? and transactionIndex = ?`) - .run(user.userName, Date.now(), lotOccupancyId, transactionIndex); + .run(user.userName, Date.now(), burialSiteContractId, transactionIndex); database.release(); return result.changes > 0; } diff --git a/database/deleteLotOccupancyTransaction.ts b/database/deleteBurialSiteContractTransaction.ts similarity index 58% rename from database/deleteLotOccupancyTransaction.ts rename to database/deleteBurialSiteContractTransaction.ts index 6301265c..b4c991cf 100644 --- a/database/deleteLotOccupancyTransaction.ts +++ b/database/deleteBurialSiteContractTransaction.ts @@ -1,7 +1,7 @@ import { acquireConnection } from './pool.js' -export default async function deleteLotOccupancyTransaction( - lotOccupancyId: number | string, +export default async function deleteBurialSiteContractTransaction( + burialSiteContractId: number | string, transactionIndex: number | string, user: User ): Promise { @@ -9,13 +9,13 @@ export default async function deleteLotOccupancyTransaction( const result = database .prepare( - `update LotOccupancyTransactions + `update BurialSiteContractTransactions set recordDelete_userName = ?, recordDelete_timeMillis = ? - where lotOccupancyId = ? + where burialSiteContractId = ? and transactionIndex = ?` ) - .run(user.userName, Date.now(), lotOccupancyId, transactionIndex) + .run(user.userName, Date.now(), burialSiteContractId, transactionIndex) database.release() diff --git a/database/deleteBurialSiteField.d.ts b/database/deleteBurialSiteField.d.ts new file mode 100644 index 00000000..5385343b --- /dev/null +++ b/database/deleteBurialSiteField.d.ts @@ -0,0 +1,2 @@ +import type { PoolConnection } from 'better-sqlite-pool'; +export default function deleteBurialSiteField(burialSiteId: number | string, burialSiteTypeFieldId: number | string, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/deleteLotField.js b/database/deleteBurialSiteField.js similarity index 51% rename from database/deleteLotField.js rename to database/deleteBurialSiteField.js index c52d59c3..56fa109a 100644 --- a/database/deleteLotField.js +++ b/database/deleteBurialSiteField.js @@ -1,13 +1,13 @@ import { acquireConnection } from './pool.js'; -export default async function deleteLotField(lotId, lotTypeFieldId, user, connectedDatabase) { +export default async function deleteBurialSiteField(burialSiteId, burialSiteTypeFieldId, user, connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); const result = database - .prepare(`update LotFields + .prepare(`update BurialSiteFields set recordDelete_userName = ?, recordDelete_timeMillis = ? - where lotId = ? - and lotTypeFieldId = ?`) - .run(user.userName, Date.now(), lotId, lotTypeFieldId); + where burialSiteId = ? + and burialSiteTypeFieldId = ?`) + .run(user.userName, Date.now(), burialSiteId, burialSiteTypeFieldId); if (connectedDatabase === undefined) { database.release(); } diff --git a/database/deleteLotField.ts b/database/deleteBurialSiteField.ts similarity index 60% rename from database/deleteLotField.ts rename to database/deleteBurialSiteField.ts index 3ac93c9d..41b49629 100644 --- a/database/deleteLotField.ts +++ b/database/deleteBurialSiteField.ts @@ -2,9 +2,9 @@ import type { PoolConnection } from 'better-sqlite-pool' import { acquireConnection } from './pool.js' -export default async function deleteLotField( - lotId: number | string, - lotTypeFieldId: number | string, +export default async function deleteBurialSiteField( + burialSiteId: number | string, + burialSiteTypeFieldId: number | string, user: User, connectedDatabase?: PoolConnection ): Promise { @@ -12,13 +12,13 @@ export default async function deleteLotField( const result = database .prepare( - `update LotFields + `update BurialSiteFields set recordDelete_userName = ?, recordDelete_timeMillis = ? - where lotId = ? - and lotTypeFieldId = ?` + where burialSiteId = ? + and burialSiteTypeFieldId = ?` ) - .run(user.userName, Date.now(), lotId, lotTypeFieldId) + .run(user.userName, Date.now(), burialSiteId, burialSiteTypeFieldId) if (connectedDatabase === undefined) { database.release() diff --git a/database/deleteContractTypePrint.d.ts b/database/deleteContractTypePrint.d.ts new file mode 100644 index 00000000..58058ccd --- /dev/null +++ b/database/deleteContractTypePrint.d.ts @@ -0,0 +1 @@ +export default function deleteContractTypePrint(contractTypeId: number | string, printEJS: string, user: User): Promise; diff --git a/database/deleteOccupancyTypePrint.js b/database/deleteContractTypePrint.js similarity index 55% rename from database/deleteOccupancyTypePrint.js rename to database/deleteContractTypePrint.js index dc436560..776edb6f 100644 --- a/database/deleteOccupancyTypePrint.js +++ b/database/deleteContractTypePrint.js @@ -1,15 +1,15 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js'; import { acquireConnection } from './pool.js'; -export default async function deleteOccupancyTypePrint(occupancyTypeId, printEJS, user) { +export default async function deleteContractTypePrint(contractTypeId, printEJS, user) { const database = await acquireConnection(); const result = database - .prepare(`update OccupancyTypePrints + .prepare(`update ContractTypePrints set recordDelete_userName = ?, recordDelete_timeMillis = ? - where occupancyTypeId = ? + where contractTypeId = ? and printEJS = ?`) - .run(user.userName, Date.now(), occupancyTypeId, printEJS); + .run(user.userName, Date.now(), contractTypeId, printEJS); database.release(); - clearCacheByTableName('OccupancyTypePrints'); + clearCacheByTableName('ContractTypePrints'); return result.changes > 0; } diff --git a/database/deleteOccupancyTypePrint.ts b/database/deleteContractTypePrint.ts similarity index 60% rename from database/deleteOccupancyTypePrint.ts rename to database/deleteContractTypePrint.ts index 087a9e11..840ed211 100644 --- a/database/deleteOccupancyTypePrint.ts +++ b/database/deleteContractTypePrint.ts @@ -2,8 +2,8 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js' import { acquireConnection } from './pool.js' -export default async function deleteOccupancyTypePrint( - occupancyTypeId: number | string, +export default async function deleteContractTypePrint( + contractTypeId: number | string, printEJS: string, user: User ): Promise { @@ -11,17 +11,17 @@ export default async function deleteOccupancyTypePrint( const result = database .prepare( - `update OccupancyTypePrints + `update ContractTypePrints set recordDelete_userName = ?, recordDelete_timeMillis = ? - where occupancyTypeId = ? + where contractTypeId = ? and printEJS = ?` ) - .run(user.userName, Date.now(), occupancyTypeId, printEJS) + .run(user.userName, Date.now(), contractTypeId, printEJS) database.release() - clearCacheByTableName('OccupancyTypePrints') + clearCacheByTableName('ContractTypePrints') return result.changes > 0 } diff --git a/database/deleteLotField.d.ts b/database/deleteLotField.d.ts deleted file mode 100644 index 1d3d7a93..00000000 --- a/database/deleteLotField.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { PoolConnection } from 'better-sqlite-pool'; -export default function deleteLotField(lotId: number | string, lotTypeFieldId: number | string, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/deleteLotOccupancyFee.d.ts b/database/deleteLotOccupancyFee.d.ts deleted file mode 100644 index 83d67eed..00000000 --- a/database/deleteLotOccupancyFee.d.ts +++ /dev/null @@ -1 +0,0 @@ -export default function deleteLotOccupancyFee(lotOccupancyId: number | string, feeId: number | string, user: User): Promise; diff --git a/database/deleteLotOccupancyField.d.ts b/database/deleteLotOccupancyField.d.ts deleted file mode 100644 index e7228f85..00000000 --- a/database/deleteLotOccupancyField.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { PoolConnection } from 'better-sqlite-pool'; -export default function deleteLotOccupancyField(lotOccupancyId: number | string, occupancyTypeFieldId: number | string, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/deleteLotOccupancyField.js b/database/deleteLotOccupancyField.js deleted file mode 100644 index 04f0130c..00000000 --- a/database/deleteLotOccupancyField.js +++ /dev/null @@ -1,15 +0,0 @@ -import { acquireConnection } from './pool.js'; -export default async function deleteLotOccupancyField(lotOccupancyId, occupancyTypeFieldId, user, connectedDatabase) { - const database = connectedDatabase ?? (await acquireConnection()); - const result = database - .prepare(`update LotOccupancyFields - set recordDelete_userName = ?, - recordDelete_timeMillis = ? - where lotOccupancyId = ? - and occupancyTypeFieldId = ?`) - .run(user.userName, Date.now(), lotOccupancyId, occupancyTypeFieldId); - if (connectedDatabase === undefined) { - database.release(); - } - return result.changes > 0; -} diff --git a/database/deleteLotOccupancyOccupant.d.ts b/database/deleteLotOccupancyOccupant.d.ts deleted file mode 100644 index 8f7d456e..00000000 --- a/database/deleteLotOccupancyOccupant.d.ts +++ /dev/null @@ -1 +0,0 @@ -export default function deleteLotOccupancyOccupant(lotOccupancyId: number | string, lotOccupantIndex: number | string, user: User): Promise; diff --git a/database/deleteLotOccupancyOccupant.js b/database/deleteLotOccupancyOccupant.js deleted file mode 100644 index 59965934..00000000 --- a/database/deleteLotOccupancyOccupant.js +++ /dev/null @@ -1,13 +0,0 @@ -import { acquireConnection } from './pool.js'; -export default async function deleteLotOccupancyOccupant(lotOccupancyId, lotOccupantIndex, user) { - const database = await acquireConnection(); - const result = database - .prepare(`update LotOccupancyOccupants - set recordDelete_userName = ?, - recordDelete_timeMillis = ? - where lotOccupancyId = ? - and lotOccupantIndex = ?`) - .run(user.userName, Date.now(), lotOccupancyId, lotOccupantIndex); - database.release(); - return result.changes > 0; -} diff --git a/database/deleteLotOccupancyOccupant.ts b/database/deleteLotOccupancyOccupant.ts deleted file mode 100644 index 1e37eaf6..00000000 --- a/database/deleteLotOccupancyOccupant.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { acquireConnection } from './pool.js' - -export default async function deleteLotOccupancyOccupant( - lotOccupancyId: number | string, - lotOccupantIndex: number | string, - user: User -): Promise { - const database = await acquireConnection() - - const result = database - .prepare( - `update LotOccupancyOccupants - set recordDelete_userName = ?, - recordDelete_timeMillis = ? - where lotOccupancyId = ? - and lotOccupantIndex = ?` - ) - .run(user.userName, Date.now(), lotOccupancyId, lotOccupantIndex) - - database.release() - - return result.changes > 0 -} diff --git a/database/deleteLotOccupancyTransaction.d.ts b/database/deleteLotOccupancyTransaction.d.ts deleted file mode 100644 index 38324ddc..00000000 --- a/database/deleteLotOccupancyTransaction.d.ts +++ /dev/null @@ -1 +0,0 @@ -export default function deleteLotOccupancyTransaction(lotOccupancyId: number | string, transactionIndex: number | string, user: User): Promise; diff --git a/database/deleteOccupancyTypePrint.d.ts b/database/deleteOccupancyTypePrint.d.ts deleted file mode 100644 index 64ce0a3b..00000000 --- a/database/deleteOccupancyTypePrint.d.ts +++ /dev/null @@ -1 +0,0 @@ -export default function deleteOccupancyTypePrint(occupancyTypeId: number | string, printEJS: string, user: User): Promise; diff --git a/database/deleteRecord.d.ts b/database/deleteRecord.d.ts index 434506f3..5bb92ae1 100644 --- a/database/deleteRecord.d.ts +++ b/database/deleteRecord.d.ts @@ -1,3 +1,3 @@ -type RecordTable = 'FeeCategories' | 'Fees' | 'Lots' | 'LotComments' | 'LotOccupancies' | 'LotOccupancyComments' | 'LotOccupantTypes' | 'LotStatuses' | 'LotTypes' | 'LotTypeFields' | 'Maps' | 'OccupancyTypes' | 'OccupancyTypeFields' | 'WorkOrders' | 'WorkOrderComments' | 'WorkOrderMilestones' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes'; +type RecordTable = 'FeeCategories' | 'Fees' | 'BurialSites' | 'BurialSiteComments' | 'BurialSiteContracts' | 'BurialSiteContractComments' | 'BurialSiteStatuses' | 'BurialSiteTypes' | 'BurialSiteTypeFields' | 'Cemeteries' | 'ContractTypes' | 'ContractTypeFields' | 'WorkOrders' | 'WorkOrderComments' | 'WorkOrderMilestones' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes'; export declare function deleteRecord(recordTable: RecordTable, recordId: number | string, user: User): Promise; export {}; diff --git a/database/deleteRecord.js b/database/deleteRecord.js index 5102341a..5356517f 100644 --- a/database/deleteRecord.js +++ b/database/deleteRecord.js @@ -3,17 +3,16 @@ import { acquireConnection } from './pool.js'; const recordIdColumns = new Map(); recordIdColumns.set('FeeCategories', 'feeCategoryId'); recordIdColumns.set('Fees', 'feeId'); -recordIdColumns.set('Lots', 'lotId'); -recordIdColumns.set('LotComments', 'lotCommentId'); -recordIdColumns.set('LotOccupancies', 'lotOccupancyId'); -recordIdColumns.set('LotOccupancyComments', 'lotOccupancyCommentId'); -recordIdColumns.set('LotOccupantTypes', 'lotOccupantTypeId'); -recordIdColumns.set('LotStatuses', 'lotStatusId'); -recordIdColumns.set('LotTypes', 'lotTypeId'); -recordIdColumns.set('LotTypeFields', 'lotTypeId'); -recordIdColumns.set('Maps', 'mapId'); -recordIdColumns.set('OccupancyTypes', 'occupancyTypeId'); -recordIdColumns.set('OccupancyTypeFields', 'occupancyTypeFieldId'); +recordIdColumns.set('BurialSites', 'burialSiteId'); +recordIdColumns.set('BurialSiteComments', 'burialSiteCommentId'); +recordIdColumns.set('BurialSiteContracts', 'burialSiteContractId'); +recordIdColumns.set('BurialSiteContractComments', 'burialSiteContractCommentId'); +recordIdColumns.set('BurialSiteStatuses', 'burialSiteStatusId'); +recordIdColumns.set('BurialSiteTypes', 'burialSiteTypeId'); +recordIdColumns.set('BurialSiteTypeFields', 'burialSiteFieldTypeId'); +recordIdColumns.set('Cemeteries', 'cemeteryId'); +recordIdColumns.set('ContractTypes', 'contractTypeId'); +recordIdColumns.set('ContractTypeFields', 'contractTypeFieldId'); recordIdColumns.set('WorkOrders', 'workOrderId'); recordIdColumns.set('WorkOrderComments', 'workOrderCommentId'); recordIdColumns.set('WorkOrderMilestones', 'workOrderMilestoneId'); @@ -21,18 +20,14 @@ recordIdColumns.set('WorkOrderMilestoneTypes', 'workOrderMilestoneTypeId'); recordIdColumns.set('WorkOrderTypes', 'workOrderTypeId'); const relatedTables = new Map(); relatedTables.set('FeeCategories', ['Fees']); -relatedTables.set('Lots', ['LotFields', 'LotComments']); -relatedTables.set('LotOccupancies', [ - 'LotOccupancyOccupants', - 'LotOccupancyFields', - 'LotOccupancyComments' -]); -relatedTables.set('LotTypes', ['LotTypeFields']); -relatedTables.set('Maps', ['Lots']); -relatedTables.set('OccupancyTypes', [ - 'OccupancyTypePrints', - 'OccupancyTypeFields' +relatedTables.set('BurialSites', ['BurialSiteFields', 'BurialSiteComments']); +relatedTables.set('BurialSiteContracts', [ + 'BurialSiteContractFields', + 'BurialSiteContractComments' ]); +relatedTables.set('BurialSiteTypes', ['BurialSiteTypeFields']); +relatedTables.set('Cemeteries', ['BurialSites']); +relatedTables.set('ContractTypes', ['ContractTypePrints', 'ContractTypeFields']); relatedTables.set('WorkOrders', [ 'WorkOrderMilestones', 'WorkOrderLots', diff --git a/database/deleteRecord.ts b/database/deleteRecord.ts index f8d02017..7e3d364e 100644 --- a/database/deleteRecord.ts +++ b/database/deleteRecord.ts @@ -5,17 +5,16 @@ import { acquireConnection } from './pool.js' type RecordTable = | 'FeeCategories' | 'Fees' - | 'Lots' - | 'LotComments' - | 'LotOccupancies' - | 'LotOccupancyComments' - | 'LotOccupantTypes' - | 'LotStatuses' - | 'LotTypes' - | 'LotTypeFields' - | 'Maps' - | 'OccupancyTypes' - | 'OccupancyTypeFields' + | 'BurialSites' + | 'BurialSiteComments' + | 'BurialSiteContracts' + | 'BurialSiteContractComments' + | 'BurialSiteStatuses' + | 'BurialSiteTypes' + | 'BurialSiteTypeFields' + | 'Cemeteries' + | 'ContractTypes' + | 'ContractTypeFields' | 'WorkOrders' | 'WorkOrderComments' | 'WorkOrderMilestones' @@ -25,17 +24,16 @@ type RecordTable = const recordIdColumns = new Map() recordIdColumns.set('FeeCategories', 'feeCategoryId') recordIdColumns.set('Fees', 'feeId') -recordIdColumns.set('Lots', 'lotId') -recordIdColumns.set('LotComments', 'lotCommentId') -recordIdColumns.set('LotOccupancies', 'lotOccupancyId') -recordIdColumns.set('LotOccupancyComments', 'lotOccupancyCommentId') -recordIdColumns.set('LotOccupantTypes', 'lotOccupantTypeId') -recordIdColumns.set('LotStatuses', 'lotStatusId') -recordIdColumns.set('LotTypes', 'lotTypeId') -recordIdColumns.set('LotTypeFields', 'lotTypeId') -recordIdColumns.set('Maps', 'mapId') -recordIdColumns.set('OccupancyTypes', 'occupancyTypeId') -recordIdColumns.set('OccupancyTypeFields', 'occupancyTypeFieldId') +recordIdColumns.set('BurialSites', 'burialSiteId') +recordIdColumns.set('BurialSiteComments', 'burialSiteCommentId') +recordIdColumns.set('BurialSiteContracts', 'burialSiteContractId') +recordIdColumns.set('BurialSiteContractComments', 'burialSiteContractCommentId') +recordIdColumns.set('BurialSiteStatuses', 'burialSiteStatusId') +recordIdColumns.set('BurialSiteTypes', 'burialSiteTypeId') +recordIdColumns.set('BurialSiteTypeFields', 'burialSiteFieldTypeId') +recordIdColumns.set('Cemeteries', 'cemeteryId') +recordIdColumns.set('ContractTypes', 'contractTypeId') +recordIdColumns.set('ContractTypeFields', 'contractTypeFieldId') recordIdColumns.set('WorkOrders', 'workOrderId') recordIdColumns.set('WorkOrderComments', 'workOrderCommentId') recordIdColumns.set('WorkOrderMilestones', 'workOrderMilestoneId') @@ -44,18 +42,14 @@ recordIdColumns.set('WorkOrderTypes', 'workOrderTypeId') const relatedTables = new Map() relatedTables.set('FeeCategories', ['Fees']) -relatedTables.set('Lots', ['LotFields', 'LotComments']) -relatedTables.set('LotOccupancies', [ - 'LotOccupancyOccupants', - 'LotOccupancyFields', - 'LotOccupancyComments' -]) -relatedTables.set('LotTypes', ['LotTypeFields']) -relatedTables.set('Maps', ['Lots']) -relatedTables.set('OccupancyTypes', [ - 'OccupancyTypePrints', - 'OccupancyTypeFields' +relatedTables.set('BurialSites', ['BurialSiteFields', 'BurialSiteComments']) +relatedTables.set('BurialSiteContracts', [ + 'BurialSiteContractFields', + 'BurialSiteContractComments' ]) +relatedTables.set('BurialSiteTypes', ['BurialSiteTypeFields']) +relatedTables.set('Cemeteries', ['BurialSites']) +relatedTables.set('ContractTypes', ['ContractTypePrints', 'ContractTypeFields']) relatedTables.set('WorkOrders', [ 'WorkOrderMilestones', 'WorkOrderLots', diff --git a/database/deleteWorkOrderBurialSite.d.ts b/database/deleteWorkOrderBurialSite.d.ts new file mode 100644 index 00000000..d4ba162c --- /dev/null +++ b/database/deleteWorkOrderBurialSite.d.ts @@ -0,0 +1 @@ +export default function deleteWorkOrderBurialSite(workOrderId: number | string, burialSiteId: number | string, user: User): Promise; diff --git a/database/deleteWorkOrderLot.js b/database/deleteWorkOrderBurialSite.js similarity index 54% rename from database/deleteWorkOrderLot.js rename to database/deleteWorkOrderBurialSite.js index 9f8b16cf..5fcd6b58 100644 --- a/database/deleteWorkOrderLot.js +++ b/database/deleteWorkOrderBurialSite.js @@ -1,13 +1,13 @@ import { acquireConnection } from './pool.js'; -export default async function deleteWorkOrderLot(workOrderId, lotId, user) { +export default async function deleteWorkOrderBurialSite(workOrderId, burialSiteId, user) { const database = await acquireConnection(); const result = database - .prepare(`update WorkOrderLots + .prepare(`update WorkOrderBurialSites set recordDelete_userName = ?, recordDelete_timeMillis = ? where workOrderId = ? - and lotId = ?`) - .run(user.userName, Date.now(), workOrderId, lotId); + and burialSiteId = ?`) + .run(user.userName, Date.now(), workOrderId, burialSiteId); database.release(); return result.changes > 0; } diff --git a/database/deleteWorkOrderLot.ts b/database/deleteWorkOrderBurialSite.ts similarity index 62% rename from database/deleteWorkOrderLot.ts rename to database/deleteWorkOrderBurialSite.ts index 827f7162..df99f5ac 100644 --- a/database/deleteWorkOrderLot.ts +++ b/database/deleteWorkOrderBurialSite.ts @@ -1,21 +1,21 @@ import { acquireConnection } from './pool.js' -export default async function deleteWorkOrderLot( +export default async function deleteWorkOrderBurialSite( workOrderId: number | string, - lotId: number | string, + burialSiteId: number | string, user: User ): Promise { const database = await acquireConnection() const result = database .prepare( - `update WorkOrderLots + `update WorkOrderBurialSites set recordDelete_userName = ?, recordDelete_timeMillis = ? where workOrderId = ? - and lotId = ?` + and burialSiteId = ?` ) - .run(user.userName, Date.now(), workOrderId, lotId) + .run(user.userName, Date.now(), workOrderId, burialSiteId) database.release() diff --git a/database/deleteWorkOrderBurialSiteContract.d.ts b/database/deleteWorkOrderBurialSiteContract.d.ts new file mode 100644 index 00000000..8a834a14 --- /dev/null +++ b/database/deleteWorkOrderBurialSiteContract.d.ts @@ -0,0 +1 @@ +export default function deleteWorkOrderBurialSiteContract(workOrderId: number | string, burialSiteContractId: number | string, user: User): Promise; diff --git a/database/deleteWorkOrderLotOccupancy.js b/database/deleteWorkOrderBurialSiteContract.js similarity index 50% rename from database/deleteWorkOrderLotOccupancy.js rename to database/deleteWorkOrderBurialSiteContract.js index c877c2c3..b403f460 100644 --- a/database/deleteWorkOrderLotOccupancy.js +++ b/database/deleteWorkOrderBurialSiteContract.js @@ -1,13 +1,13 @@ import { acquireConnection } from './pool.js'; -export default async function deleteWorkOrderLotOccupancy(workOrderId, lotOccupancyId, user) { +export default async function deleteWorkOrderBurialSiteContract(workOrderId, burialSiteContractId, user) { const database = await acquireConnection(); const result = database - .prepare(`update WorkOrderLotOccupancies + .prepare(`update WorkOrderBurialSiteContracts set recordDelete_userName = ?, recordDelete_timeMillis = ? where workOrderId = ? - and lotOccupancyId = ?`) - .run(user.userName, Date.now(), workOrderId, lotOccupancyId); + and burialSiteContractId = ?`) + .run(user.userName, Date.now(), workOrderId, burialSiteContractId); database.release(); return result.changes > 0; } diff --git a/database/deleteWorkOrderLotOccupancy.ts b/database/deleteWorkOrderBurialSiteContract.ts similarity index 58% rename from database/deleteWorkOrderLotOccupancy.ts rename to database/deleteWorkOrderBurialSiteContract.ts index 82be9e0f..3ec5fa82 100644 --- a/database/deleteWorkOrderLotOccupancy.ts +++ b/database/deleteWorkOrderBurialSiteContract.ts @@ -1,21 +1,21 @@ import { acquireConnection } from './pool.js' -export default async function deleteWorkOrderLotOccupancy( +export default async function deleteWorkOrderBurialSiteContract( workOrderId: number | string, - lotOccupancyId: number | string, + burialSiteContractId: number | string, user: User ): Promise { const database = await acquireConnection() const result = database .prepare( - `update WorkOrderLotOccupancies + `update WorkOrderBurialSiteContracts set recordDelete_userName = ?, recordDelete_timeMillis = ? where workOrderId = ? - and lotOccupancyId = ?` + and burialSiteContractId = ?` ) - .run(user.userName, Date.now(), workOrderId, lotOccupancyId) + .run(user.userName, Date.now(), workOrderId, burialSiteContractId) database.release() diff --git a/database/deleteWorkOrderLot.d.ts b/database/deleteWorkOrderLot.d.ts deleted file mode 100644 index 7da5b373..00000000 --- a/database/deleteWorkOrderLot.d.ts +++ /dev/null @@ -1 +0,0 @@ -export default function deleteWorkOrderLot(workOrderId: number | string, lotId: number | string, user: User): Promise; diff --git a/database/deleteWorkOrderLotOccupancy.d.ts b/database/deleteWorkOrderLotOccupancy.d.ts deleted file mode 100644 index c253668d..00000000 --- a/database/deleteWorkOrderLotOccupancy.d.ts +++ /dev/null @@ -1 +0,0 @@ -export default function deleteWorkOrderLotOccupancy(workOrderId: number | string, lotOccupancyId: number | string, user: User): Promise; diff --git a/database/getLot.d.ts b/database/getBurialSite.d.ts similarity index 60% rename from database/getLot.d.ts rename to database/getBurialSite.d.ts index 5ef6a0fb..d5f2d2fd 100644 --- a/database/getLot.d.ts +++ b/database/getBurialSite.d.ts @@ -1,3 +1,3 @@ import type { Lot } from '../types/recordTypes.js'; export declare function getLotByLotName(lotName: string): Promise; -export default function getLot(lotId: number | string): Promise; +export default function getLot(burialSiteId: number | string): Promise; diff --git a/database/getBurialSite.js b/database/getBurialSite.js new file mode 100644 index 00000000..25c12557 --- /dev/null +++ b/database/getBurialSite.js @@ -0,0 +1,48 @@ +import getLotComments from './getLotComments.js'; +import getLotFields from './getLotFields.js'; +import getBurialSiteInterments from './getLotOccupancies.js'; +import { acquireConnection } from './pool.js'; +const baseSQL = `select l.burialSiteId, + l.burialSiteTypeId, t.burialSiteType, + l.burialSiteNameSegment1, + l.burialSiteNameSegment2, + l.burialSiteNameSegment3, + l.burialSiteNameSegment4, + l.burialSiteNameSegment5, + l.burialSiteStatusId, s.burialSiteStatus, + l.cemeteryId, m.cemeteryName, + m.cemeterySvg, l.cemeterySvgId, + l.burialSiteLatitude, l.burialSiteLongitude, + + from BurialSites l + left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId + left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId + left join Cemeteries m on l.cemeteryId = m.cemeteryId + where l.recordDelete_timeMillis is null`; +async function _getBurialSite(sql, burialSiteIdOrLotName) { + const database = await acquireConnection(); + const burialSite = database.prepare(sql).get(burialSiteIdOrLotName); + if (burialSite !== undefined) { + const lotOccupancies = await getBurialSiteInterments({ + lotId: burialSite.lotId + }, { + includeOccupants: true, + includeFees: false, + includeTransactions: false, + limit: -1, + offset: 0 + }, database); + burialSite.lotOccupancies = lotOccupancies.lotOccupancies; + burialSite.lotFields = await getLotFields(burialSite.lotId, database); + burialSite.lotComments = await getLotComments(burialSite.lotId, database); + } + database.release(); + return burialSite; +} +// TODO +export async function getLotByLotName(lotName) { + return await _getBurialSite(`${baseSQL} and l.lotName = ?`, lotName); +} +export default async function getLot(burialSiteId) { + return await _getBurialSite(`${baseSQL} and l.burialSiteId = ?`, burialSiteId); +} diff --git a/database/getBurialSite.ts b/database/getBurialSite.ts new file mode 100644 index 00000000..dd8affa9 --- /dev/null +++ b/database/getBurialSite.ts @@ -0,0 +1,72 @@ +import type { Lot } from '../types/recordTypes.js' + +import getLotComments from './getLotComments.js' +import getLotFields from './getLotFields.js' +import getBurialSiteInterments from './getLotOccupancies.js' +import { acquireConnection } from './pool.js' + +const baseSQL = `select l.burialSiteId, + l.burialSiteTypeId, t.burialSiteType, + l.burialSiteNameSegment1, + l.burialSiteNameSegment2, + l.burialSiteNameSegment3, + l.burialSiteNameSegment4, + l.burialSiteNameSegment5, + l.burialSiteStatusId, s.burialSiteStatus, + l.cemeteryId, m.cemeteryName, + m.cemeterySvg, l.cemeterySvgId, + l.burialSiteLatitude, l.burialSiteLongitude, + + from BurialSites l + left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId + left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId + left join Cemeteries m on l.cemeteryId = m.cemeteryId + where l.recordDelete_timeMillis is null` + +async function _getBurialSite( + sql: string, + burialSiteIdOrLotName: number | string +): Promise { + const database = await acquireConnection() + + const burialSite = database.prepare(sql).get(burialSiteIdOrLotName) as Lot | undefined + + if (burialSite !== undefined) { + const lotOccupancies = await getBurialSiteInterments( + { + lotId: burialSite.lotId + }, + { + includeOccupants: true, + includeFees: false, + includeTransactions: false, + limit: -1, + offset: 0 + }, + database + ) + + burialSite.lotOccupancies = lotOccupancies.lotOccupancies + + burialSite.lotFields = await getLotFields(burialSite.lotId, database) + + burialSite.lotComments = await getLotComments(burialSite.lotId, database) + } + + database.release() + + return burialSite +} + +// TODO +export async function getLotByLotName( + lotName: string +): Promise { + return await _getBurialSite(`${baseSQL} and l.lotName = ?`, lotName) +} + +export default async function getLot( + burialSiteId: number | string +): Promise { + return await _getBurialSite(`${baseSQL} and l.burialSiteId = ?`, burialSiteId) +} diff --git a/database/getFee.js b/database/getFee.js index bbde8a5d..a1ab35bc 100644 --- a/database/getFee.js +++ b/database/getFee.js @@ -5,16 +5,16 @@ export default async function getFee(feeId, connectedDatabase) { .prepare(`select f.feeId, f.feeCategoryId, c.feeCategory, f.feeName, f.feeDescription, f.feeAccount, - f.occupancyTypeId, o.occupancyType, - f.lotTypeId, l.lotType, + f.contractTypeId, o.contractType, + f.burialSiteTypeId, l.burialSiteType, ifnull(f.feeAmount, 0) as feeAmount, f.feeFunction, f.taxAmount, f.taxPercentage, f.includeQuantity, f.quantityUnit, f.isRequired, f.orderNumber from Fees f left join FeeCategories c on f.feeCategoryId = c.feeCategoryId - left join OccupancyTypes o on f.occupancyTypeId = o.occupancyTypeId - left join LotTypes l on f.lotTypeId = l.lotTypeId + left join ContractTypes o on f.contractTypeId = o.contractTypeId + left join BurialSiteTypes l on f.burialSiteTypeId = l.burialSiteTypeId where f.recordDelete_timeMillis is null and f.feeId = ?`) .get(feeId); diff --git a/database/getFee.ts b/database/getFee.ts index 596f4c1b..73c24953 100644 --- a/database/getFee.ts +++ b/database/getFee.ts @@ -15,16 +15,16 @@ export default async function getFee( `select f.feeId, f.feeCategoryId, c.feeCategory, f.feeName, f.feeDescription, f.feeAccount, - f.occupancyTypeId, o.occupancyType, - f.lotTypeId, l.lotType, + f.contractTypeId, o.contractType, + f.burialSiteTypeId, l.burialSiteType, ifnull(f.feeAmount, 0) as feeAmount, f.feeFunction, f.taxAmount, f.taxPercentage, f.includeQuantity, f.quantityUnit, f.isRequired, f.orderNumber from Fees f left join FeeCategories c on f.feeCategoryId = c.feeCategoryId - left join OccupancyTypes o on f.occupancyTypeId = o.occupancyTypeId - left join LotTypes l on f.lotTypeId = l.lotTypeId + left join ContractTypes o on f.contractTypeId = o.contractTypeId + left join BurialSiteTypes l on f.burialSiteTypeId = l.burialSiteTypeId where f.recordDelete_timeMillis is null and f.feeId = ?` ) diff --git a/database/getFeeCategories.d.ts b/database/getFeeCategories.d.ts index bf967192..60845f88 100644 --- a/database/getFeeCategories.d.ts +++ b/database/getFeeCategories.d.ts @@ -1,8 +1,8 @@ import type { PoolConnection } from 'better-sqlite-pool'; import type { FeeCategory } from '../types/recordTypes.js'; interface GetFeeCategoriesFilters { - occupancyTypeId?: number | string; - lotTypeId?: number | string; + contractTypeId?: number | string; + burialSiteTypeId?: number | string; feeCategoryId?: number | string; } interface GetFeeCategoriesOptions { diff --git a/database/getFeeCategories.js b/database/getFeeCategories.js index 88cb9421..c9bf8ee1 100644 --- a/database/getFeeCategories.js +++ b/database/getFeeCategories.js @@ -2,19 +2,19 @@ import getFees from './getFees.js'; import { acquireConnection } from './pool.js'; import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'; export default async function getFeeCategories(filters, options, connectedDatabase) { - const updateOrderNumbers = !(filters.lotTypeId || filters.occupancyTypeId) && options.includeFees; + const updateOrderNumbers = !(filters.burialSiteTypeId || filters.contractTypeId) && options.includeFees; const database = await acquireConnection(); let sqlWhereClause = ' where recordDelete_timeMillis is null'; const sqlParameters = []; - if ((filters.occupancyTypeId ?? '') !== '') { + if ((filters.contractTypeId ?? '') !== '') { sqlWhereClause += ` and feeCategoryId in ( - select feeCategoryId from Fees where recordDelete_timeMillis is null and (occupancyTypeId is null or occupancyTypeId = ?))`; - sqlParameters.push(filters.occupancyTypeId); + select feeCategoryId from Fees where recordDelete_timeMillis is null and (contractTypeId is null or contractTypeId = ?))`; + sqlParameters.push(filters.contractTypeId); } - if ((filters.lotTypeId ?? '') !== '') { + if ((filters.burialSiteTypeId ?? '') !== '') { sqlWhereClause += ` and feeCategoryId in ( - select feeCategoryId from Fees where recordDelete_timeMillis is null and (lotTypeId is null or lotTypeId = ?))`; - sqlParameters.push(filters.lotTypeId); + select feeCategoryId from Fees where recordDelete_timeMillis is null and (burialSiteTypeId is null or burialSiteTypeId = ?))`; + sqlParameters.push(filters.burialSiteTypeId); } const feeCategories = database .prepare(`select feeCategoryId, feeCategory, isGroupedFee, orderNumber diff --git a/database/getFeeCategories.ts b/database/getFeeCategories.ts index 30f16593..6a931f11 100644 --- a/database/getFeeCategories.ts +++ b/database/getFeeCategories.ts @@ -7,8 +7,8 @@ import { acquireConnection } from './pool.js' import { updateRecordOrderNumber } from './updateRecordOrderNumber.js' interface GetFeeCategoriesFilters { - occupancyTypeId?: number | string - lotTypeId?: number | string + contractTypeId?: number | string + burialSiteTypeId?: number | string feeCategoryId?: number | string } @@ -22,7 +22,7 @@ export default async function getFeeCategories( connectedDatabase?: PoolConnection ): Promise { const updateOrderNumbers = - !(filters.lotTypeId || filters.occupancyTypeId) && options.includeFees + !(filters.burialSiteTypeId || filters.contractTypeId) && options.includeFees const database = await acquireConnection() @@ -30,18 +30,18 @@ export default async function getFeeCategories( const sqlParameters: unknown[] = [] - if ((filters.occupancyTypeId ?? '') !== '') { + if ((filters.contractTypeId ?? '') !== '') { sqlWhereClause += ` and feeCategoryId in ( - select feeCategoryId from Fees where recordDelete_timeMillis is null and (occupancyTypeId is null or occupancyTypeId = ?))` + select feeCategoryId from Fees where recordDelete_timeMillis is null and (contractTypeId is null or contractTypeId = ?))` - sqlParameters.push(filters.occupancyTypeId) + sqlParameters.push(filters.contractTypeId) } - if ((filters.lotTypeId ?? '') !== '') { + if ((filters.burialSiteTypeId ?? '') !== '') { sqlWhereClause += ` and feeCategoryId in ( - select feeCategoryId from Fees where recordDelete_timeMillis is null and (lotTypeId is null or lotTypeId = ?))` + select feeCategoryId from Fees where recordDelete_timeMillis is null and (burialSiteTypeId is null or burialSiteTypeId = ?))` - sqlParameters.push(filters.lotTypeId) + sqlParameters.push(filters.burialSiteTypeId) } const feeCategories = database diff --git a/database/getFees.d.ts b/database/getFees.d.ts index 41e3583f..97dace36 100644 --- a/database/getFees.d.ts +++ b/database/getFees.d.ts @@ -1,8 +1,8 @@ import type { PoolConnection } from 'better-sqlite-pool'; import type { Fee } from '../types/recordTypes.js'; interface GetFeesFilters { - occupancyTypeId?: number | string; - lotTypeId?: number | string; + contractTypeId?: number | string; + burialSiteTypeId?: number | string; } export default function getFees(feeCategoryId: number, additionalFilters: GetFeesFilters, connectedDatabase?: PoolConnection): Promise; export {}; diff --git a/database/getFees.js b/database/getFees.js index aeb784a5..270dd077 100644 --- a/database/getFees.js +++ b/database/getFees.js @@ -1,39 +1,39 @@ import { acquireConnection } from './pool.js'; import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'; export default async function getFees(feeCategoryId, additionalFilters, connectedDatabase) { - const updateOrderNumbers = !(additionalFilters.lotTypeId || additionalFilters.occupancyTypeId); + const updateOrderNumbers = !(additionalFilters.burialSiteTypeId || additionalFilters.contractTypeId); const database = connectedDatabase ?? (await acquireConnection()); let sqlWhereClause = ' where f.recordDelete_timeMillis is null and f.feeCategoryId = ?'; const sqlParameters = [feeCategoryId]; - if (additionalFilters.occupancyTypeId) { + if (additionalFilters.contractTypeId) { sqlWhereClause += - ' and (f.occupancyTypeId is null or f.occupancyTypeId = ?)'; - sqlParameters.push(additionalFilters.occupancyTypeId); + ' and (f.contractTypeId is null or f.contractTypeId = ?)'; + sqlParameters.push(additionalFilters.contractTypeId); } - if (additionalFilters.lotTypeId) { - sqlWhereClause += ' and (f.lotTypeId is null or f.lotTypeId = ?)'; - sqlParameters.push(additionalFilters.lotTypeId); + if (additionalFilters.burialSiteTypeId) { + sqlWhereClause += ' and (f.burialSiteTypeId is null or f.burialSiteTypeId = ?)'; + sqlParameters.push(additionalFilters.burialSiteTypeId); } const fees = database .prepare(`select f.feeId, f.feeCategoryId, f.feeName, f.feeDescription, f.feeAccount, - f.occupancyTypeId, o.occupancyType, - f.lotTypeId, l.lotType, + f.contractTypeId, o.contractType, + f.burialSiteTypeId, l.burialSiteType, ifnull(f.feeAmount, 0) as feeAmount, f.feeFunction, f.taxAmount, f.taxPercentage, f.includeQuantity, f.quantityUnit, f.isRequired, f.orderNumber, - ifnull(lo.lotOccupancyFeeCount, 0) as lotOccupancyFeeCount + ifnull(lo.burialSiteContractFeeCount, 0) as burialSiteContractFeeCount from Fees f left join ( - select feeId, count(lotOccupancyId) as lotOccupancyFeeCount - from LotOccupancyFees + select feeId, count(burialSiteContractId) as burialSiteContractFeeCount + from BurialSiteContractFees where recordDelete_timeMillis is null group by feeId ) lo on f.feeId = lo.feeId - left join OccupancyTypes o on f.occupancyTypeId = o.occupancyTypeId - left join LotTypes l on f.lotTypeId = l.lotTypeId + left join ContractTypes o on f.contractTypeId = o.contractTypeId + left join BurialSiteTypes l on f.burialSiteTypeId = l.burialSiteTypeId ${sqlWhereClause} order by f.orderNumber, f.feeName`) .all(sqlParameters); diff --git a/database/getFees.ts b/database/getFees.ts index 1f204eed..311faf20 100644 --- a/database/getFees.ts +++ b/database/getFees.ts @@ -6,8 +6,8 @@ import { acquireConnection } from './pool.js' import { updateRecordOrderNumber } from './updateRecordOrderNumber.js' interface GetFeesFilters { - occupancyTypeId?: number | string - lotTypeId?: number | string + contractTypeId?: number | string + burialSiteTypeId?: number | string } export default async function getFees( @@ -16,7 +16,7 @@ export default async function getFees( connectedDatabase?: PoolConnection ): Promise { const updateOrderNumbers = !( - additionalFilters.lotTypeId || additionalFilters.occupancyTypeId + additionalFilters.burialSiteTypeId || additionalFilters.contractTypeId ) const database = connectedDatabase ?? (await acquireConnection()) @@ -26,40 +26,40 @@ export default async function getFees( const sqlParameters: unknown[] = [feeCategoryId] - if (additionalFilters.occupancyTypeId) { + if (additionalFilters.contractTypeId) { sqlWhereClause += - ' and (f.occupancyTypeId is null or f.occupancyTypeId = ?)' + ' and (f.contractTypeId is null or f.contractTypeId = ?)' - sqlParameters.push(additionalFilters.occupancyTypeId) + sqlParameters.push(additionalFilters.contractTypeId) } - if (additionalFilters.lotTypeId) { - sqlWhereClause += ' and (f.lotTypeId is null or f.lotTypeId = ?)' + if (additionalFilters.burialSiteTypeId) { + sqlWhereClause += ' and (f.burialSiteTypeId is null or f.burialSiteTypeId = ?)' - sqlParameters.push(additionalFilters.lotTypeId) + sqlParameters.push(additionalFilters.burialSiteTypeId) } const fees = database .prepare( `select f.feeId, f.feeCategoryId, f.feeName, f.feeDescription, f.feeAccount, - f.occupancyTypeId, o.occupancyType, - f.lotTypeId, l.lotType, + f.contractTypeId, o.contractType, + f.burialSiteTypeId, l.burialSiteType, ifnull(f.feeAmount, 0) as feeAmount, f.feeFunction, f.taxAmount, f.taxPercentage, f.includeQuantity, f.quantityUnit, f.isRequired, f.orderNumber, - ifnull(lo.lotOccupancyFeeCount, 0) as lotOccupancyFeeCount + ifnull(lo.burialSiteContractFeeCount, 0) as burialSiteContractFeeCount from Fees f left join ( - select feeId, count(lotOccupancyId) as lotOccupancyFeeCount - from LotOccupancyFees + select feeId, count(burialSiteContractId) as burialSiteContractFeeCount + from BurialSiteContractFees where recordDelete_timeMillis is null group by feeId ) lo on f.feeId = lo.feeId - left join OccupancyTypes o on f.occupancyTypeId = o.occupancyTypeId - left join LotTypes l on f.lotTypeId = l.lotTypeId + left join ContractTypes o on f.contractTypeId = o.contractTypeId + left join BurialSiteTypes l on f.burialSiteTypeId = l.burialSiteTypeId ${sqlWhereClause} order by f.orderNumber, f.feeName` ) diff --git a/database/getLot.js b/database/getLot.js deleted file mode 100644 index 868208fb..00000000 --- a/database/getLot.js +++ /dev/null @@ -1,38 +0,0 @@ -import getLotComments from './getLotComments.js'; -import getLotFields from './getLotFields.js'; -import getLotOccupancies from './getLotOccupancies.js'; -import { acquireConnection } from './pool.js'; -const baseSQL = `select l.lotId, l.lotTypeId, t.lotType, l.lotName, l.lotStatusId, s.lotStatus, - l.mapId, m.mapName, m.mapSVG, l.mapKey, - l.lotLatitude, l.lotLongitude - from Lots l - left join LotTypes t on l.lotTypeId = t.lotTypeId - left join LotStatuses s on l.lotStatusId = s.lotStatusId - left join Maps m on l.mapId = m.mapId - where l.recordDelete_timeMillis is null`; -async function _getLot(sql, lotIdOrLotName) { - const database = await acquireConnection(); - const lot = database.prepare(sql).get(lotIdOrLotName); - if (lot !== undefined) { - const lotOccupancies = await getLotOccupancies({ - lotId: lot.lotId - }, { - includeOccupants: true, - includeFees: false, - includeTransactions: false, - limit: -1, - offset: 0 - }, database); - lot.lotOccupancies = lotOccupancies.lotOccupancies; - lot.lotFields = await getLotFields(lot.lotId, database); - lot.lotComments = await getLotComments(lot.lotId, database); - } - database.release(); - return lot; -} -export async function getLotByLotName(lotName) { - return await _getLot(`${baseSQL} and l.lotName = ?`, lotName); -} -export default async function getLot(lotId) { - return await _getLot(`${baseSQL} and l.lotId = ?`, lotId); -} diff --git a/database/getLot.ts b/database/getLot.ts deleted file mode 100644 index 9ff9c53b..00000000 --- a/database/getLot.ts +++ /dev/null @@ -1,62 +0,0 @@ -import type { Lot } from '../types/recordTypes.js' - -import getLotComments from './getLotComments.js' -import getLotFields from './getLotFields.js' -import getLotOccupancies from './getLotOccupancies.js' -import { acquireConnection } from './pool.js' - -const baseSQL = `select l.lotId, l.lotTypeId, t.lotType, l.lotName, l.lotStatusId, s.lotStatus, - l.mapId, m.mapName, m.mapSVG, l.mapKey, - l.lotLatitude, l.lotLongitude - from Lots l - left join LotTypes t on l.lotTypeId = t.lotTypeId - left join LotStatuses s on l.lotStatusId = s.lotStatusId - left join Maps m on l.mapId = m.mapId - where l.recordDelete_timeMillis is null` - -async function _getLot( - sql: string, - lotIdOrLotName: number | string -): Promise { - const database = await acquireConnection() - - const lot = database.prepare(sql).get(lotIdOrLotName) as Lot | undefined - - if (lot !== undefined) { - const lotOccupancies = await getLotOccupancies( - { - lotId: lot.lotId - }, - { - includeOccupants: true, - includeFees: false, - includeTransactions: false, - limit: -1, - offset: 0 - }, - database - ) - - lot.lotOccupancies = lotOccupancies.lotOccupancies - - lot.lotFields = await getLotFields(lot.lotId, database) - - lot.lotComments = await getLotComments(lot.lotId, database) - } - - database.release() - - return lot -} - -export async function getLotByLotName( - lotName: string -): Promise { - return await _getLot(`${baseSQL} and l.lotName = ?`, lotName) -} - -export default async function getLot( - lotId: number | string -): Promise { - return await _getLot(`${baseSQL} and l.lotId = ?`, lotId) -} diff --git a/database/getLotOccupancies.js b/database/getLotOccupancies.js index 8ac3257e..04556fe0 100644 --- a/database/getLotOccupancies.js +++ b/database/getLotOccupancies.js @@ -1,6 +1,6 @@ import { dateIntegerToString, dateStringToInteger } from '@cityssm/utils-datetime'; import { getOccupancyTypeById } from '../helpers/functions.cache.js'; -import { getConfigProperty } from '../helpers/functions.config.js'; +import { getConfigProperty } from '../helpers/config.helpers.js'; import { getLotNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js'; import getLotOccupancyFees from './getLotOccupancyFees.js'; import getLotOccupancyOccupants from './getLotOccupancyOccupants.js'; diff --git a/database/getLotOccupancies.ts b/database/getLotOccupancies.ts index 18f769a0..41df0061 100644 --- a/database/getLotOccupancies.ts +++ b/database/getLotOccupancies.ts @@ -6,7 +6,7 @@ import { import type { PoolConnection } from 'better-sqlite-pool' import { getOccupancyTypeById } from '../helpers/functions.cache.js' -import { getConfigProperty } from '../helpers/functions.config.js' +import { getConfigProperty } from '../helpers/config.helpers.js' import { getLotNameWhereClause, getOccupancyTimeWhereClause, diff --git a/database/getLotOccupancyTransactions.js b/database/getLotOccupancyTransactions.js index 51907597..4ba45b62 100644 --- a/database/getLotOccupancyTransactions.js +++ b/database/getLotOccupancyTransactions.js @@ -1,5 +1,5 @@ import { dateIntegerToString, timeIntegerToString } from '@cityssm/utils-datetime'; -import { getConfigProperty } from '../helpers/functions.config.js'; +import { getConfigProperty } from '../helpers/config.helpers.js'; import { getDynamicsGPDocument } from '../helpers/functions.dynamicsGP.js'; import { acquireConnection } from './pool.js'; export default async function getLotOccupancyTransactions(lotOccupancyId, options, connectedDatabase) { diff --git a/database/getLotOccupancyTransactions.ts b/database/getLotOccupancyTransactions.ts index 00a619bc..66ed93f3 100644 --- a/database/getLotOccupancyTransactions.ts +++ b/database/getLotOccupancyTransactions.ts @@ -4,7 +4,7 @@ import { } from '@cityssm/utils-datetime' import type { PoolConnection } from 'better-sqlite-pool' -import { getConfigProperty } from '../helpers/functions.config.js' +import { getConfigProperty } from '../helpers/config.helpers.js' import { getDynamicsGPDocument } from '../helpers/functions.dynamicsGP.js' import type { LotOccupancyTransaction } from '../types/recordTypes.js' diff --git a/database/getLots.js b/database/getLots.js index 2c82df05..5b8c22c2 100644 --- a/database/getLots.js +++ b/database/getLots.js @@ -1,5 +1,5 @@ import { dateToInteger } from '@cityssm/utils-datetime'; -import { getConfigProperty } from '../helpers/functions.config.js'; +import { getConfigProperty } from '../helpers/config.helpers.js'; import { getLotNameWhereClause } from '../helpers/functions.sqlFilters.js'; import { acquireConnection } from './pool.js'; function buildWhereClause(filters) { diff --git a/database/getLots.ts b/database/getLots.ts index b750f614..74b53ed3 100644 --- a/database/getLots.ts +++ b/database/getLots.ts @@ -1,7 +1,7 @@ import { dateToInteger } from '@cityssm/utils-datetime' import type { PoolConnection } from 'better-sqlite-pool' -import { getConfigProperty } from '../helpers/functions.config.js' +import { getConfigProperty } from '../helpers/config.helpers.js' import { getLotNameWhereClause } from '../helpers/functions.sqlFilters.js' import type { Lot } from '../types/recordTypes.js' diff --git a/database/getNextBurialSiteId.d.ts b/database/getNextBurialSiteId.d.ts new file mode 100644 index 00000000..806f1a31 --- /dev/null +++ b/database/getNextBurialSiteId.d.ts @@ -0,0 +1 @@ +export default function getNextBurialSiteId(burialSiteId: number | string): Promise; diff --git a/database/getNextLotId.js b/database/getNextBurialSiteId.js similarity index 57% rename from database/getNextLotId.js rename to database/getNextBurialSiteId.js index 4a89c761..ef586f07 100644 --- a/database/getNextLotId.js +++ b/database/getNextBurialSiteId.js @@ -1,19 +1,19 @@ -import { getConfigProperty } from '../helpers/functions.config.js'; import { acquireConnection } from './pool.js'; -export default async function getNextLotId(lotId) { +// TODO +export default async function getNextBurialSiteId(burialSiteId) { const database = await acquireConnection(); - database.function('userFn_lotNameSortName', getConfigProperty('settings.lot.lotNameSortNameFunction')); const result = database - .prepare(`select lotId - from Lots + .prepare(`select burialSiteId + from BurialSites where recordDelete_timeMillis is null and userFn_lotNameSortName(lotName) > (select userFn_lotNameSortName(lotName) from Lots where lotId = ?) order by userFn_lotNameSortName(lotName) limit 1`) - .get(lotId); + .pluck() + .get(burialSiteId); database.release(); if (result === undefined) { return undefined; } - return result.lotId; + return result; } diff --git a/database/getNextLotId.ts b/database/getNextBurialSiteId.ts similarity index 57% rename from database/getNextLotId.ts rename to database/getNextBurialSiteId.ts index a1df8ff4..2f9a8966 100644 --- a/database/getNextLotId.ts +++ b/database/getNextBurialSiteId.ts @@ -1,29 +1,22 @@ -import { getConfigProperty } from '../helpers/functions.config.js' - import { acquireConnection } from './pool.js' -export default async function getNextLotId( - lotId: number | string +// TODO +export default async function getNextBurialSiteId( + burialSiteId: number | string ): Promise { const database = await acquireConnection() - database.function( - 'userFn_lotNameSortName', - getConfigProperty('settings.lot.lotNameSortNameFunction') - ) - const result = database .prepare( - `select lotId - from Lots + `select burialSiteId + from BurialSites where recordDelete_timeMillis is null and userFn_lotNameSortName(lotName) > (select userFn_lotNameSortName(lotName) from Lots where lotId = ?) order by userFn_lotNameSortName(lotName) limit 1` ) - .get(lotId) as { - lotId: number - } + .pluck() + .get(burialSiteId) as number | undefined database.release() @@ -31,5 +24,5 @@ export default async function getNextLotId( return undefined } - return result.lotId + return result } diff --git a/database/getNextLotId.d.ts b/database/getNextLotId.d.ts deleted file mode 100644 index e5f1aca9..00000000 --- a/database/getNextLotId.d.ts +++ /dev/null @@ -1 +0,0 @@ -export default function getNextLotId(lotId: number | string): Promise; diff --git a/database/getNextWorkOrderNumber.js b/database/getNextWorkOrderNumber.js index ab9420ab..40af1a1b 100644 --- a/database/getNextWorkOrderNumber.js +++ b/database/getNextWorkOrderNumber.js @@ -1,4 +1,4 @@ -import { getConfigProperty } from '../helpers/functions.config.js'; +import { getConfigProperty } from '../helpers/config.helpers.js'; import { acquireConnection } from './pool.js'; export default async function getNextWorkOrderNumber(connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); diff --git a/database/getNextWorkOrderNumber.ts b/database/getNextWorkOrderNumber.ts index 3944aa9d..2ae7f1dc 100644 --- a/database/getNextWorkOrderNumber.ts +++ b/database/getNextWorkOrderNumber.ts @@ -1,6 +1,6 @@ import type { PoolConnection } from 'better-sqlite-pool' -import { getConfigProperty } from '../helpers/functions.config.js' +import { getConfigProperty } from '../helpers/config.helpers.js' import { acquireConnection } from './pool.js' diff --git a/database/getOccupancyTypePrints.js b/database/getOccupancyTypePrints.js index 2d1602ba..6eb16583 100644 --- a/database/getOccupancyTypePrints.js +++ b/database/getOccupancyTypePrints.js @@ -1,4 +1,4 @@ -import { getConfigProperty } from '../helpers/functions.config.js'; +import { getConfigProperty } from '../helpers/config.helpers.js'; import { acquireConnection } from './pool.js'; const availablePrints = getConfigProperty('settings.lotOccupancy.prints'); // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/database/getOccupancyTypePrints.ts b/database/getOccupancyTypePrints.ts index 36f4aa27..38ec2dc3 100644 --- a/database/getOccupancyTypePrints.ts +++ b/database/getOccupancyTypePrints.ts @@ -1,6 +1,6 @@ import type { PoolConnection } from 'better-sqlite-pool' -import { getConfigProperty } from '../helpers/functions.config.js' +import { getConfigProperty } from '../helpers/config.helpers.js' import { acquireConnection } from './pool.js' diff --git a/database/getPreviousLotId.js b/database/getPreviousLotId.js index 25a5243b..796edaa7 100644 --- a/database/getPreviousLotId.js +++ b/database/getPreviousLotId.js @@ -1,4 +1,4 @@ -import { getConfigProperty } from '../helpers/functions.config.js'; +import { getConfigProperty } from '../helpers/config.helpers.js'; import { acquireConnection } from './pool.js'; export default async function getPreviousLotId(lotId) { const database = await acquireConnection(); diff --git a/database/getPreviousLotId.ts b/database/getPreviousLotId.ts index 7fdefabd..48b6172e 100644 --- a/database/getPreviousLotId.ts +++ b/database/getPreviousLotId.ts @@ -1,4 +1,4 @@ -import { getConfigProperty } from '../helpers/functions.config.js' +import { getConfigProperty } from '../helpers/config.helpers.js' import { acquireConnection } from './pool.js' diff --git a/database/getReportData.js b/database/getReportData.js index 51a0b580..9e88ffe9 100644 --- a/database/getReportData.js +++ b/database/getReportData.js @@ -1,188 +1,142 @@ import { dateIntegerToString, dateStringToInteger, dateToInteger, timeIntegerToString } from '@cityssm/utils-datetime'; -import camelCase from 'camelcase'; -import { getConfigProperty } from '../helpers/functions.config.js'; import { acquireConnection } from './pool.js'; -const mapCamelCase = camelCase(getConfigProperty('aliases.map')); -const mapNameAlias = `${mapCamelCase}Name`; -const mapDescriptionAlias = `${mapCamelCase}Description`; -const mapAddress1Alias = `${mapCamelCase}Address1`; -const mapAddress2Alias = `${mapCamelCase}Address2`; -const mapCityAlias = `${mapCamelCase}City`; -const mapProvinceAlias = `${mapCamelCase}Province`; -const mapPostalCodeAlias = `${mapCamelCase}PostalCode`; -const mapPhoneNumberAlias = `${mapCamelCase}PhoneNumber`; -const lotCamelCase = camelCase(getConfigProperty('aliases.lot')); -const lotIdAlias = `${lotCamelCase}Id`; -const lotNameAlias = `${lotCamelCase}Name`; -const lotTypeAlias = `${lotCamelCase}Type`; -const lotStatusAlias = `${lotCamelCase}Status`; -const occupancyCamelCase = camelCase(getConfigProperty('aliases.occupancy')); -const lotOccupancyIdAlias = `${occupancyCamelCase}Id`; -const occupancyTypeAlias = `${occupancyCamelCase}Type`; -const occupancyStartDateAlias = `${occupancyCamelCase}StartDate`; -const occupancyEndDateAlias = `${occupancyCamelCase}EndDate`; -const occupantCamelCase = camelCase(getConfigProperty('aliases.occupant')); -const lotOccupantIndexAlias = `${occupantCamelCase}Index`; -const lotOccupantTypeAlias = `${occupantCamelCase}Type`; -const occupantNameAlias = `${occupantCamelCase}Name`; -const occupantFamilyNameAlias = `${occupantCamelCase}FamilyName`; -const occupantAddress1Alias = `${occupantCamelCase}Address1`; -const occupantAddress2Alias = `${occupantCamelCase}Address2`; -const occupantCityAlias = `${occupantCamelCase}City`; -const occupantProvinceAlias = `${occupantCamelCase}Province`; -const occupantPostalCodeAlias = `${occupantCamelCase}PostalCode`; -const occupantPhoneNumberAlias = `${occupantCamelCase}PhoneNumber`; -const occupantEmailAddressAlias = `${occupantCamelCase}EmailAddress`; -const occupantCommentTitleAlias = `${occupantCamelCase}CommentTitle`; -const occupantCommentAlias = `${occupantCamelCase}Comment`; +// eslint-disable-next-line complexity export default async function getReportData(reportName, reportParameters = {}) { let sql = ''; const sqlParameters = []; - // eslint-disable-next-line sonarjs/max-switch-cases switch (reportName) { - case 'maps-all': { + case 'cemeteries-all': { sql = 'select * from Maps'; break; } - case 'maps-formatted': { - sql = `select mapName as ${mapNameAlias}, - mapDescription as ${mapDescriptionAlias}, - mapAddress1 as ${mapAddress1Alias}, - mapAddress2 as ${mapAddress2Alias}, - mapCity as ${mapCityAlias}, - mapProvince as ${mapProvinceAlias}, - mapPostalCode as ${mapPostalCodeAlias}, - mapPhoneNumber as ${mapPhoneNumberAlias} - from Maps + case 'cemeteries-formatted': { + sql = `select cemeteryName, + cemeteryDescription, + cemeteryAddress1, cemeteryAddress2, + cemeteryCity, cemeteryProvince, + cemeteryPostalCode, + cemeteryPhoneNumber + from Cemeteries where recordDelete_timeMillis is null - order by mapName`; + order by cemeteryName`; break; } - case 'lots-all': { - sql = 'select * from Lots'; + case 'burialSites-all': { + sql = 'select * from BurialSites'; break; } - case 'lots-byLotTypeId': { - sql = `select l.lotId as ${lotIdAlias}, - m.mapName as ${mapNameAlias}, - l.lotName as ${lotNameAlias}, - t.lotType as ${lotTypeAlias}, - s.lotStatus as ${lotStatusAlias} - from Lots l - left join LotTypes t on l.lotTypeId = t.lotTypeId - left join LotStatuses s on l.lotStatusId = s.lotStatusId - left join Maps m on l.mapId = m.mapId + case 'burialSites-byBurialSiteTypeId': { + sql = `select l.burialSiteId, + m.cemeteryName, + l.burialSiteNameSegment1, + l.burialSiteNameSegment2, + l.burialSiteNameSegment3, + l.burialSiteNameSegment4, + l.burialSiteNameSegment5, + t.burialSiteType, + s.burialSiteStatus + from BurialSites l + left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId + left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId + left join Cemeteries m on l.cemeteryId = m.cemeteryId where l.recordDelete_timeMillis is null - and l.lotTypeId = ?`; - sqlParameters.push(reportParameters.lotTypeId); + and l.burialSiteTypeId = ?`; + sqlParameters.push(reportParameters.burialSiteTypeId); break; } - case 'lots-byLotStatusId': { - sql = `select l.lotId as ${lotIdAlias}, - m.mapName as ${mapNameAlias}, - l.lotName as ${lotNameAlias}, - t.lotType as ${lotTypeAlias}, - s.lotStatus as ${lotStatusAlias} - from Lots l - left join LotTypes t on l.lotTypeId = t.lotTypeId - left join LotStatuses s on l.lotStatusId = s.lotStatusId - left join Maps m on l.mapId = m.mapId + case 'burialSites-byBurialSiteStatusId': { + sql = `select l.burialSiteId, + m.cemeteryName, + l.burialSiteNameSegment1, + l.burialSiteNameSegment2, + l.burialSiteNameSegment3, + l.burialSiteNameSegment4, + l.burialSiteNameSegment5, + t.burialSiteType, + s.burialSiteStatus + from BurialSites l + left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId + left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId + left join Cemeteries m on l.cemeteryId = m.cemeteryId where l.recordDelete_timeMillis is null - and l.lotStatusId = ?`; - sqlParameters.push(reportParameters.lotStatusId); + and l.burialSiteStatusId = ?`; + sqlParameters.push(reportParameters.burialSiteStatusId); break; } - case 'lots-byMapId': { - sql = `select l.lotId as ${lotIdAlias}, - m.mapName as ${mapNameAlias}, - l.lotName as ${lotNameAlias}, - t.lotType as ${lotTypeAlias}, - s.lotStatus as ${lotStatusAlias} - from Lots l - left join LotTypes t on l.lotTypeId = t.lotTypeId - left join LotStatuses s on l.lotStatusId = s.lotStatusId - left join Maps m on l.mapId = m.mapId + case 'burialSites-byCemeteryId': { + sql = `select l.burialSiteId, + m.cemeteryName, + l.burialSiteNameSegment1, + l.burialSiteNameSegment2, + l.burialSiteNameSegment3, + l.burialSiteNameSegment4, + l.burialSiteNameSegment5, + t.burialSiteType, + s.burialSiteStatus + from BurialSites l + left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId + left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId + left join Cemeteries m on l.cemeteryId = m.cemeteryId where l.recordDelete_timeMillis is null - and l.mapId = ?`; - sqlParameters.push(reportParameters.mapId); + and l.cemeteryId = ?`; + sqlParameters.push(reportParameters.cemeteryId); break; } - case 'lotComments-all': { - sql = 'select * from LotComments'; + case 'burialSiteComments-all': { + sql = 'select * from BurialSiteComments'; break; } - case 'lotFields-all': { - sql = 'select * from LotFields'; + case 'burialSiteFields-all': { + sql = 'select * from BurialSiteFields'; break; } - case 'lotOccupancies-all': { - sql = 'select * from LotOccupancies'; + case 'burialSiteContracts-all': { + sql = 'select * from BurialSiteContracts'; break; } - case 'lotOccupancies-current-byMapId': { - sql = `select o.lotOccupancyId as ${lotOccupancyIdAlias}, - l.lotName as ${lotNameAlias}, - m.mapName as ${mapNameAlias}, - ot.occupancyType as ${occupancyTypeAlias}, - o.occupancyStartDate as ${occupancyStartDateAlias}, - o.occupancyEndDate as ${occupancyEndDateAlias} - from LotOccupancies o - left join OccupancyTypes ot on o.occupancyTypeId = ot.occupancyTypeId - left join Lots l on o.lotId = l.lotId - left join Maps m on l.mapId = m.mapId + case 'burialSiteContracts-current-byCemeteryId': { + sql = `select o.burialSiteContractId, + l.burialSiteNameSegment1, + l.burialSiteNameSegment2, + l.burialSiteNameSegment3, + l.burialSiteNameSegment4, + l.burialSiteNameSegment5, + m.cemeteryName, + ot.contractType, + o.contractStartDate, + o.contractEndDate + from BurialSiteContracts o + left join ContractTypes ot on o.contractTypeId = ot.contractTypeId + left join BurialSites l on o.burialSiteId = l.burialSiteId + left join Cemeteries m on l.cemeteryId = m.cemeteryId where o.recordDelete_timeMillis is null - and (o.occupancyEndDate is null or o.occupancyEndDate >= ?) - and l.mapId = ?`; - sqlParameters.push(dateToInteger(new Date()), reportParameters.mapId); + and (o.contractEndDate is null or o.contractEndDate >= ?) + and l.cemeteryId = ?`; + sqlParameters.push(dateToInteger(new Date()), reportParameters.cemeteryId); break; } - case 'lotOccupancyComments-all': { - sql = 'select * from LotOccupancyComments'; + case 'burialSiteContractComments-all': { + sql = 'select * from BurialSiteContractComments'; break; } - case 'lotOccupancyFees-all': { - sql = 'select * from LotOccupancyFees'; + case 'burialSiteContractFees-all': { + sql = 'select * from BurialSiteContractFees'; break; } - case 'lotOccupancyFields-all': { - sql = 'select * from LotOccupancyFields'; + case 'burialSiteContractFields-all': { + sql = 'select * from BurialSiteContractFields'; break; } - case 'lotOccupancyOccupants-all': { - sql = 'select * from LotOccupancyOccupants'; + case 'burialSiteContractTransactions-all': { + sql = 'select * from BurialSiteContractTransactions'; break; } - case 'lotOccupancyOccupants-byLotOccupancyId': { - sql = `select o.lotOccupantIndex as ${lotOccupantIndexAlias}, - t.lotOccupantType as ${lotOccupantTypeAlias}, - o.occupantName as ${occupantNameAlias}, - o.occupantFamilyName as ${occupantFamilyNameAlias}, - o.occupantAddress1 as ${occupantAddress1Alias}, - o.occupantAddress2 as ${occupantAddress2Alias}, - o.occupantCity as ${occupantCityAlias}, - o.occupantProvince as ${occupantProvinceAlias}, - o.occupantPostalCode as ${occupantPostalCodeAlias}, - o.occupantPhoneNumber as ${occupantPhoneNumberAlias}, - o.occupantEmailAddress as ${occupantEmailAddressAlias}, - t.occupantCommentTitle as ${occupantCommentTitleAlias}, - o.occupantComment as ${occupantCommentAlias} - from LotOccupancyOccupants o - left join LotOccupantTypes t on o.lotOccupantTypeId = t.lotOccupantTypeId - where o.recordDelete_timeMillis is null - and o.lotOccupancyId = ?`; - sqlParameters.push(reportParameters.lotOccupancyId); - break; - } - case 'lotOccupancyTransactions-all': { - sql = 'select * from LotOccupancyTransactions'; - break; - } - case 'lotOccupancyTransactions-byTransactionDateString': { - sql = `select t.lotOccupancyId, t.transactionIndex, + case 'burialSiteContractTransactions-byTransactionDateString': { + sql = `select t.burialSiteContractId, t.transactionIndex, t.transactionDate, t.transactionTime, t.transactionAmount, t.externalReceiptNumber, t.transactionNote - from LotOccupancyTransactions t + from BurialSiteContractTransactions t where t.recordDelete_timeMillis is null and t.transactionDate = ?`; sqlParameters.push(dateStringToInteger(reportParameters.transactionDateString)); @@ -245,28 +199,24 @@ export default async function getReportData(reportName, reportParameters = {}) { sql = 'select * from FeeCategories'; break; } - case 'lotTypes-all': { - sql = 'select * from LotTypes'; + case 'burialSiteTypes-all': { + sql = 'select * from BurialSiteTypes'; break; } - case 'lotTypeFields-all': { - sql = 'select * from LotTypeFields'; + case 'burialSiteTypeFields-all': { + sql = 'select * from BurialSiteTypeFields'; break; } - case 'lotStatuses-all': { - sql = 'select * from LotStatuses'; + case 'burialSiteStatuses-all': { + sql = 'select * from BurialSiteStatuses'; break; } - case 'occupancyTypes-all': { - sql = 'select * from OccupancyTypes'; + case 'contractTypes-all': { + sql = 'select * from ContractTypes'; break; } - case 'occupancyTypeFields-all': { - sql = 'select * from OccupancyTypeFields'; - break; - } - case 'lotOccupantTypes-all': { - sql = 'select * from LotOccupantTypes'; + case 'contractTypeFields-all': { + sql = 'select * from ContractTypeFields'; break; } case 'workOrderTypes-all': { diff --git a/database/getReportData.ts b/database/getReportData.ts index 61f5767b..f175b69c 100644 --- a/database/getReportData.ts +++ b/database/getReportData.ts @@ -5,51 +5,12 @@ import { dateToInteger, timeIntegerToString } from '@cityssm/utils-datetime' -import camelCase from 'camelcase' - -import { getConfigProperty } from '../helpers/functions.config.js' import { acquireConnection } from './pool.js' export type ReportParameters = Record -const mapCamelCase = camelCase(getConfigProperty('aliases.map')) -const mapNameAlias = `${mapCamelCase}Name` -const mapDescriptionAlias = `${mapCamelCase}Description` -const mapAddress1Alias = `${mapCamelCase}Address1` -const mapAddress2Alias = `${mapCamelCase}Address2` -const mapCityAlias = `${mapCamelCase}City` -const mapProvinceAlias = `${mapCamelCase}Province` -const mapPostalCodeAlias = `${mapCamelCase}PostalCode` -const mapPhoneNumberAlias = `${mapCamelCase}PhoneNumber` - -const lotCamelCase = camelCase(getConfigProperty('aliases.lot')) -const lotIdAlias = `${lotCamelCase}Id` -const lotNameAlias = `${lotCamelCase}Name` -const lotTypeAlias = `${lotCamelCase}Type` -const lotStatusAlias = `${lotCamelCase}Status` - -const occupancyCamelCase = camelCase(getConfigProperty('aliases.occupancy')) -const lotOccupancyIdAlias = `${occupancyCamelCase}Id` -const occupancyTypeAlias = `${occupancyCamelCase}Type` -const occupancyStartDateAlias = `${occupancyCamelCase}StartDate` -const occupancyEndDateAlias = `${occupancyCamelCase}EndDate` - -const occupantCamelCase = camelCase(getConfigProperty('aliases.occupant')) -const lotOccupantIndexAlias = `${occupantCamelCase}Index` -const lotOccupantTypeAlias = `${occupantCamelCase}Type` -const occupantNameAlias = `${occupantCamelCase}Name` -const occupantFamilyNameAlias = `${occupantCamelCase}FamilyName` -const occupantAddress1Alias = `${occupantCamelCase}Address1` -const occupantAddress2Alias = `${occupantCamelCase}Address2` -const occupantCityAlias = `${occupantCamelCase}City` -const occupantProvinceAlias = `${occupantCamelCase}Province` -const occupantPostalCodeAlias = `${occupantCamelCase}PostalCode` -const occupantPhoneNumberAlias = `${occupantCamelCase}PhoneNumber` -const occupantEmailAddressAlias = `${occupantCamelCase}EmailAddress` -const occupantCommentTitleAlias = `${occupantCamelCase}CommentTitle` -const occupantCommentAlias = `${occupantCamelCase}Comment` - +// eslint-disable-next-line complexity export default async function getReportData( reportName: string, reportParameters: ReportParameters = {} @@ -57,176 +18,162 @@ export default async function getReportData( let sql = '' const sqlParameters: unknown[] = [] - // eslint-disable-next-line sonarjs/max-switch-cases switch (reportName) { - case 'maps-all': { + case 'cemeteries-all': { sql = 'select * from Maps' break } - case 'maps-formatted': { - sql = `select mapName as ${mapNameAlias}, - mapDescription as ${mapDescriptionAlias}, - mapAddress1 as ${mapAddress1Alias}, - mapAddress2 as ${mapAddress2Alias}, - mapCity as ${mapCityAlias}, - mapProvince as ${mapProvinceAlias}, - mapPostalCode as ${mapPostalCodeAlias}, - mapPhoneNumber as ${mapPhoneNumberAlias} - from Maps + case 'cemeteries-formatted': { + sql = `select cemeteryName, + cemeteryDescription, + cemeteryAddress1, cemeteryAddress2, + cemeteryCity, cemeteryProvince, + cemeteryPostalCode, + cemeteryPhoneNumber + from Cemeteries where recordDelete_timeMillis is null - order by mapName` + order by cemeteryName` break } - case 'lots-all': { - sql = 'select * from Lots' + case 'burialSites-all': { + sql = 'select * from BurialSites' break } - case 'lots-byLotTypeId': { - sql = `select l.lotId as ${lotIdAlias}, - m.mapName as ${mapNameAlias}, - l.lotName as ${lotNameAlias}, - t.lotType as ${lotTypeAlias}, - s.lotStatus as ${lotStatusAlias} - from Lots l - left join LotTypes t on l.lotTypeId = t.lotTypeId - left join LotStatuses s on l.lotStatusId = s.lotStatusId - left join Maps m on l.mapId = m.mapId + case 'burialSites-byBurialSiteTypeId': { + sql = `select l.burialSiteId, + m.cemeteryName, + l.burialSiteNameSegment1, + l.burialSiteNameSegment2, + l.burialSiteNameSegment3, + l.burialSiteNameSegment4, + l.burialSiteNameSegment5, + t.burialSiteType, + s.burialSiteStatus + from BurialSites l + left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId + left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId + left join Cemeteries m on l.cemeteryId = m.cemeteryId where l.recordDelete_timeMillis is null - and l.lotTypeId = ?` + and l.burialSiteTypeId = ?` - sqlParameters.push(reportParameters.lotTypeId) + sqlParameters.push(reportParameters.burialSiteTypeId) break } - case 'lots-byLotStatusId': { - sql = `select l.lotId as ${lotIdAlias}, - m.mapName as ${mapNameAlias}, - l.lotName as ${lotNameAlias}, - t.lotType as ${lotTypeAlias}, - s.lotStatus as ${lotStatusAlias} - from Lots l - left join LotTypes t on l.lotTypeId = t.lotTypeId - left join LotStatuses s on l.lotStatusId = s.lotStatusId - left join Maps m on l.mapId = m.mapId + case 'burialSites-byBurialSiteStatusId': { + sql = `select l.burialSiteId, + m.cemeteryName, + l.burialSiteNameSegment1, + l.burialSiteNameSegment2, + l.burialSiteNameSegment3, + l.burialSiteNameSegment4, + l.burialSiteNameSegment5, + t.burialSiteType, + s.burialSiteStatus + from BurialSites l + left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId + left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId + left join Cemeteries m on l.cemeteryId = m.cemeteryId where l.recordDelete_timeMillis is null - and l.lotStatusId = ?` + and l.burialSiteStatusId = ?` - sqlParameters.push(reportParameters.lotStatusId) + sqlParameters.push(reportParameters.burialSiteStatusId) break } - case 'lots-byMapId': { - sql = `select l.lotId as ${lotIdAlias}, - m.mapName as ${mapNameAlias}, - l.lotName as ${lotNameAlias}, - t.lotType as ${lotTypeAlias}, - s.lotStatus as ${lotStatusAlias} - from Lots l - left join LotTypes t on l.lotTypeId = t.lotTypeId - left join LotStatuses s on l.lotStatusId = s.lotStatusId - left join Maps m on l.mapId = m.mapId + case 'burialSites-byCemeteryId': { + sql = `select l.burialSiteId, + m.cemeteryName, + l.burialSiteNameSegment1, + l.burialSiteNameSegment2, + l.burialSiteNameSegment3, + l.burialSiteNameSegment4, + l.burialSiteNameSegment5, + t.burialSiteType, + s.burialSiteStatus + from BurialSites l + left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId + left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId + left join Cemeteries m on l.cemeteryId = m.cemeteryId where l.recordDelete_timeMillis is null - and l.mapId = ?` + and l.cemeteryId = ?` - sqlParameters.push(reportParameters.mapId) + sqlParameters.push(reportParameters.cemeteryId) break } - case 'lotComments-all': { - sql = 'select * from LotComments' + case 'burialSiteComments-all': { + sql = 'select * from BurialSiteComments' break } - case 'lotFields-all': { - sql = 'select * from LotFields' + case 'burialSiteFields-all': { + sql = 'select * from BurialSiteFields' break } - case 'lotOccupancies-all': { - sql = 'select * from LotOccupancies' + case 'burialSiteContracts-all': { + sql = 'select * from BurialSiteContracts' break } - case 'lotOccupancies-current-byMapId': { - sql = `select o.lotOccupancyId as ${lotOccupancyIdAlias}, - l.lotName as ${lotNameAlias}, - m.mapName as ${mapNameAlias}, - ot.occupancyType as ${occupancyTypeAlias}, - o.occupancyStartDate as ${occupancyStartDateAlias}, - o.occupancyEndDate as ${occupancyEndDateAlias} - from LotOccupancies o - left join OccupancyTypes ot on o.occupancyTypeId = ot.occupancyTypeId - left join Lots l on o.lotId = l.lotId - left join Maps m on l.mapId = m.mapId + case 'burialSiteContracts-current-byCemeteryId': { + sql = `select o.burialSiteContractId, + l.burialSiteNameSegment1, + l.burialSiteNameSegment2, + l.burialSiteNameSegment3, + l.burialSiteNameSegment4, + l.burialSiteNameSegment5, + m.cemeteryName, + ot.contractType, + o.contractStartDate, + o.contractEndDate + from BurialSiteContracts o + left join ContractTypes ot on o.contractTypeId = ot.contractTypeId + left join BurialSites l on o.burialSiteId = l.burialSiteId + left join Cemeteries m on l.cemeteryId = m.cemeteryId where o.recordDelete_timeMillis is null - and (o.occupancyEndDate is null or o.occupancyEndDate >= ?) - and l.mapId = ?` + and (o.contractEndDate is null or o.contractEndDate >= ?) + and l.cemeteryId = ?` - sqlParameters.push(dateToInteger(new Date()), reportParameters.mapId) + sqlParameters.push(dateToInteger(new Date()), reportParameters.cemeteryId) break } - case 'lotOccupancyComments-all': { - sql = 'select * from LotOccupancyComments' + case 'burialSiteContractComments-all': { + sql = 'select * from BurialSiteContractComments' break } - case 'lotOccupancyFees-all': { - sql = 'select * from LotOccupancyFees' + case 'burialSiteContractFees-all': { + sql = 'select * from BurialSiteContractFees' break } - case 'lotOccupancyFields-all': { - sql = 'select * from LotOccupancyFields' + case 'burialSiteContractFields-all': { + sql = 'select * from BurialSiteContractFields' break } - case 'lotOccupancyOccupants-all': { - sql = 'select * from LotOccupancyOccupants' + case 'burialSiteContractTransactions-all': { + sql = 'select * from BurialSiteContractTransactions' break } - case 'lotOccupancyOccupants-byLotOccupancyId': { - sql = `select o.lotOccupantIndex as ${lotOccupantIndexAlias}, - t.lotOccupantType as ${lotOccupantTypeAlias}, - o.occupantName as ${occupantNameAlias}, - o.occupantFamilyName as ${occupantFamilyNameAlias}, - o.occupantAddress1 as ${occupantAddress1Alias}, - o.occupantAddress2 as ${occupantAddress2Alias}, - o.occupantCity as ${occupantCityAlias}, - o.occupantProvince as ${occupantProvinceAlias}, - o.occupantPostalCode as ${occupantPostalCodeAlias}, - o.occupantPhoneNumber as ${occupantPhoneNumberAlias}, - o.occupantEmailAddress as ${occupantEmailAddressAlias}, - t.occupantCommentTitle as ${occupantCommentTitleAlias}, - o.occupantComment as ${occupantCommentAlias} - from LotOccupancyOccupants o - left join LotOccupantTypes t on o.lotOccupantTypeId = t.lotOccupantTypeId - where o.recordDelete_timeMillis is null - and o.lotOccupancyId = ?` - sqlParameters.push(reportParameters.lotOccupancyId) - break - } - - case 'lotOccupancyTransactions-all': { - sql = 'select * from LotOccupancyTransactions' - break - } - - case 'lotOccupancyTransactions-byTransactionDateString': { - sql = `select t.lotOccupancyId, t.transactionIndex, + case 'burialSiteContractTransactions-byTransactionDateString': { + sql = `select t.burialSiteContractId, t.transactionIndex, t.transactionDate, t.transactionTime, t.transactionAmount, t.externalReceiptNumber, t.transactionNote - from LotOccupancyTransactions t + from BurialSiteContractTransactions t where t.recordDelete_timeMillis is null and t.transactionDate = ?` @@ -303,33 +250,28 @@ export default async function getReportData( break } - case 'lotTypes-all': { - sql = 'select * from LotTypes' + case 'burialSiteTypes-all': { + sql = 'select * from BurialSiteTypes' break } - case 'lotTypeFields-all': { - sql = 'select * from LotTypeFields' + case 'burialSiteTypeFields-all': { + sql = 'select * from BurialSiteTypeFields' break } - case 'lotStatuses-all': { - sql = 'select * from LotStatuses' + case 'burialSiteStatuses-all': { + sql = 'select * from BurialSiteStatuses' break } - case 'occupancyTypes-all': { - sql = 'select * from OccupancyTypes' + case 'contractTypes-all': { + sql = 'select * from ContractTypes' break } - case 'occupancyTypeFields-all': { - sql = 'select * from OccupancyTypeFields' - break - } - - case 'lotOccupantTypes-all': { - sql = 'select * from LotOccupantTypes' + case 'contractTypeFields-all': { + sql = 'select * from ContractTypeFields' break } diff --git a/database/getWorkOrderMilestones.js b/database/getWorkOrderMilestones.js index 382513b2..4dabecda 100644 --- a/database/getWorkOrderMilestones.js +++ b/database/getWorkOrderMilestones.js @@ -1,5 +1,5 @@ import { dateIntegerToString, dateStringToInteger, dateToInteger, timeIntegerToPeriodString, timeIntegerToString } from '@cityssm/utils-datetime'; -import { getConfigProperty } from '../helpers/functions.config.js'; +import { getConfigProperty } from '../helpers/config.helpers.js'; import getLotOccupancies from './getLotOccupancies.js'; import getLots from './getLots.js'; import { acquireConnection } from './pool.js'; diff --git a/database/getWorkOrderMilestones.ts b/database/getWorkOrderMilestones.ts index 82938e83..f7189a48 100644 --- a/database/getWorkOrderMilestones.ts +++ b/database/getWorkOrderMilestones.ts @@ -8,7 +8,7 @@ import { } from '@cityssm/utils-datetime' import type { PoolConnection } from 'better-sqlite-pool' -import { getConfigProperty } from '../helpers/functions.config.js' +import { getConfigProperty } from '../helpers/config.helpers.js' import type { WorkOrderMilestone } from '../types/recordTypes.js' import getLotOccupancies from './getLotOccupancies.js' diff --git a/database/initializeDatabase.d.ts b/database/initializeDatabase.d.ts new file mode 100644 index 00000000..8f5f5727 --- /dev/null +++ b/database/initializeDatabase.d.ts @@ -0,0 +1 @@ +export declare function initializeDatabase(): Promise; diff --git a/database/initializeDatabase.js b/database/initializeDatabase.js new file mode 100644 index 00000000..06358054 --- /dev/null +++ b/database/initializeDatabase.js @@ -0,0 +1,428 @@ +// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair +/* eslint-disable no-secrets/no-secrets */ +import sqlite from 'better-sqlite3'; +import Debug from 'debug'; +import { DEBUG_NAMESPACE } from '../debug.config.js'; +import { sunriseDB as databasePath } from '../helpers/database.helpers.js'; +import addFeeCategory from './addFeeCategory.js'; +import addRecord from './addRecord.js'; +const debug = Debug(`${DEBUG_NAMESPACE}:database/initializeDatabase`); +const recordColumns = `recordCreate_userName varchar(30) not null, + recordCreate_timeMillis integer not null, + recordUpdate_userName varchar(30) not null, + recordUpdate_timeMillis integer not null, + recordDelete_userName varchar(30), + recordDelete_timeMillis integer`; +const createStatements = [ + /* + * Burial Site Types + */ + `create table if not exists BurialSiteTypes ( + burialSiteTypeId integer not null primary key autoincrement, + burialSiteType varchar(100) not null, + orderNumber smallint not null default 0, + ${recordColumns})`, + `create index if not exists idx_BurialSiteTypes_orderNumber + on LotTypes (orderNumber, burialSiteType)`, + `create table if not exists BurialSiteTypeFields ( + burialSiteTypeFieldId integer not null primary key autoincrement, + burialSiteTypeId integer not null, + burialSiteTypeField varchar(100) not null, + fieldType varchar(15) not null default 'text', + fieldValues text, + isRequired bit not null default 0, + pattern varchar(100), + minimumLength smallint not null default 1 check (minimumLength >= 0), + maximumLength smallint not null default 100 check (maximumLength >= 0), + orderNumber smallint not null default 0, + ${recordColumns}, + foreign key (burialSiteTypeId) references BurialSiteTypes (burialSiteTypeId))`, + `create index if not exists idx_BurialSiteTypeFields_orderNumber + on BurialSiteTypeFields (burialSiteTypeId, orderNumber, burialSiteTypeField)`, + /* + * Burial Site Statuses + */ + `create table if not exists BurialSiteStatuses ( + burialSiteStatusId integer not null primary key autoincrement, + burialSiteStatus varchar(100) not null, + orderNumber smallint not null default 0, + ${recordColumns})`, + `create index if not exists idx_BurialSiteStatuses_orderNumber + on BurialSiteStatuses (orderNumber, burialSiteStatus)`, + /* + * Cemeteries + */ + `create table if not exists Cemeteries ( + cemeteryId integer not null primary key autoincrement, + cemeteryName varchar(200) not null, + cemeteryDescription text, + cemeteryLatitude decimal(10, 8) + check (cemeteryLatitude between -90 and 90), + cemeteryLongitude decimal(11, 8) + check (cemeteryLongitude between -180 and 180), + cemeterySvg varchar(50), + cemeteryAddress1 varchar(50), + cemeteryAddress2 varchar(50), + cemeteryCity varchar(20), + cemeteryProvince varchar(2), + cemeteryPostalCode varchar(7), + cemeteryPhoneNumber varchar(30), + ${recordColumns})`, + /* + * Burial Sites + */ + `create table if not exists BurialSites ( + burialSiteId integer not null primary key autoincrement, + burialSiteTypeId integer not null, + + burialSiteNameSegment1 varchar(20), + burialSiteNameSegment2 varchar(20), + burialSiteNameSegment3 varchar(20), + burialSiteNameSegment4 varchar(20), + burialSiteNameSegment5 varchar(20), + + cemeteryId integer, + cemeterySvgId varchar(100), + burialSiteLatitude decimal(10, 8) + check (burialSiteLatitude between -90 and 90), + burialSiteLongitude decimal(11, 8) + check (burialSiteLongitude between -180 and 180), + burialSiteStatusId integer, + ${recordColumns}, + foreign key (burialSiteTypeId) references BurialSiteTypes (burialSiteTypeId), + foreign key (cemeteryId) references Cemeteries (cemeteryId), + foreign key (burialSiteStatusId) references BurialSiteStatuses (burialSiteStatusId), + unique (cemeteryId, burialSiteNameSegment1, burialSiteNameSegment2, burialSiteNameSegment3, burialSiteNameSegment4, burialSiteNameSegment5))`, + `create table if not exists BurialSiteFields ( + burialSiteId integer not null, + burialSiteTypeFieldId integer not null, + fieldValue text not null, + ${recordColumns}, + primary key (burialSiteId, burialSiteTypeFieldId), + foreign key (burialSiteId) references BurialSites (burialSiteId), + foreign key (burialSiteTypeFieldId) references BurialSiteTypeFields (burialSiteTypeFieldId)) without rowid`, + `create table if not exists BurialSiteComments ( + burialSiteCommentId integer not null primary key autoincrement, + burialSiteId integer not null, + commentDate integer not null check (commentDate > 0), + commentTime integer not null check (commentTime >= 0), + comment text not null, + ${recordColumns}, + foreign key (lotId) references BurialSites (burialSiteId))`, + `create index if not exists idx_BurialSiteComments_datetime + on BurialSiteComments (burialSiteId, commentDate, commentTime)`, + /* + * Funeral Homes + */ + `create table if not exists FuneralHomes ( + funeralHomeId integer not null primary key autoincrement, + funeralHomeName varchar(200) not null, + funeralHomeAddress1 varchar(50), + funeralHomeAddress2 varchar(50), + funeralHomeCity varchar(20), + funeralHomeProvince varchar(2), + funeralHomePostalCode varchar(7), + funeralHomePhoneNumber varchar(30), + ${recordColumns})`, + /* + * Contracts + */ + `create table if not exists ContractTypes ( + contractTypeId integer not null primary key autoincrement, + contractType varchar(100) not null, + orderNumber smallint not null default 0, + ${recordColumns})`, + `create index if not exists idx_ContractTypes_orderNumber + on ContractTypes (orderNumber, contractType)`, + `create table if not exists ContractTypeFields ( + contractTypeFieldId integer not null primary key autoincrement, + contractTypeId integer, + contractTypeField varchar(100) not null, + fieldType varchar(15) not null default 'text', + fieldValues text, + isRequired bit not null default 0, + pattern varchar(100), + minimumLength smallint not null default 1 check (minimumLength >= 0), + maximumLength smallint not null default 100 check (maximumLength >= 0), + orderNumber smallint not null default 0, + ${recordColumns}, + foreign key (contractTypeId) references ContractTypes (contractTypeId))`, + `create index if not exists idx_ContractTypeFields_orderNumber + on ContractTypeFields (contractTypeId, orderNumber, contractTypeField)`, + `create table if not exists ContractTypePrints ( + contractTypeId integer not null, + printEJS varchar(100) not null, + orderNumber smallint not null default 0, + ${recordColumns}, + primary key (contractTypeId, printEJS), + foreign key (contractTypeId) references ContractTypes (contractTypeId))`, + `create index if not exists idx_ContractTypePrints_orderNumber + on ContractTypePrints (contractTypeId, orderNumber, printEJS)`, + `create table if not exists BurialSiteContracts ( + burialSiteContractId integer not null primary key autoincrement, + contractTypeId integer not null, + burialSiteId integer, + contractStartDate integer not null check (contractStartDate > 0), + contractEndDate integer check (contractEndDate > 0), + + purchaserName varchar(100) not null, + purchaserAddress1 varchar(50), + purchaserAddress2 varchar(50), + purchaserCity varchar(20), + purchaserProvince varchar(2), + purchaserPostalCode varchar(7), + purchaserPhoneNumber varchar(30), + purchaserEmail varchar(100), + + funeralHomeId integer, + funeralDirectorName varchar(100), + + ${recordColumns}, + foreign key (burialSiteId) references BurialSites (burialSiteId), + foreign key (contractTypeId) references ContractTypes (contractTypeId), + foreign key (funeralHomeId) references FuneralHomes (funeralHomeId))`, + `create table if not exists BurialSiteContractFields ( + burialSiteContractId integer not null, + contractTypeFieldId integer not null, + fieldValue text not null, + ${recordColumns}, + primary key (burialSiteContractId, contractTypeFieldId), + foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId), + foreign key (contractTypeFieldId) references ContractTypeFields (contractTypeFieldId)) without rowid`, + `create table if not exists BurialSiteContractComments ( + burialSiteContractCommentId integer not null primary key autoincrement, + burialSiteContractId integer not null, + commentDate integer not null check (commentDate > 0), + commentTime integer not null check (commentTime >= 0), + comment text not null, + ${recordColumns}, + foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId))`, + `create index if not exists idx_BurialSiteContractComments_datetime + on BurialSiteContractComments (burialSiteContractId, commentDate, commentTime)`, + /* + * Interments + */ + `create table if not exists IntermentContainerTypes ( + intermentContainerTypeId integer not null primary key autoincrement, + intermentContainerType varchar(100) not null, + orderNumber smallint not null default 0, + ${recordColumns})`, + `create index if not exists idx_IntermentContainerTypes_orderNumber + on IntermentContainerTypes (orderNumber, intermentContainerType)`, + `create table if not exists IntermentCommittalTypes ( + intermentCommittalTypeId integer not null primary key autoincrement, + intermentCommittalType varchar(100) not null, + orderNumber smallint not null default 0, + ${recordColumns})`, + `create index if not exists idx_IntermentCommittalType_orderNumber + on IntermentCommittalTypes (orderNumber, intermentCommittalType)`, + `create table if not exists BurialSiteContractInterments ( + burialSiteContractId integer not null, + intermentNumber integer not null, + isCremated bit not null default 0, + + deceasedName varchar(50) not null, + + birthDate integer, + birthPlace varchar(100), + + deathDate integer, + deathPlace varchar(100), + + intermentDate integer check (intermentDate > 0), + intermentTime integer check (intermentTime >= 0), + + intermentContainerTypeId integer, + intermentCommittalTypeId integer, + + ${recordColumns}, + primary key (burialSiteContractId, intermentNumber), + foreign key (burialSiteId) references BurialSites (burialSiteId), + foreign key (intermentContainerTypeId) references IntermentContainerTypes (intermentContainerTypeId), + foreign key (intermentCommittalTypeId) references IntermentCommittalTypes (intermentCommittalTypeId)) without rowid`, + /* + * Fees and Transactions + */ + `create table if not exists FeeCategories ( + feeCategoryId integer not null primary key autoincrement, + feeCategory varchar(100) not null, + isGroupedFee bit not null default 0, + orderNumber smallint not null default 0, + ${recordColumns})`, + `create table if not exists Fees ( + feeId integer not null primary key autoincrement, + feeCategoryId integer not null, + feeName varchar(100) not null, + feeDescription text, + feeAccount varchar(20), + + contractTypeId integer, + burialSiteTypeId integer, + + includeQuantity boolean not null default 0, + quantityUnit varchar(30), + feeAmount decimal(8, 2), + feeFunction varchar(100), + taxAmount decimal(6, 2), + taxPercentage decimal(5, 2), + isRequired bit not null default 0, + orderNumber smallint not null default 0, + ${recordColumns}, + foreign key (feeCategoryId) references FeeCategories (feeCategoryId), + foreign key (contractTypeId) references ContractTypes (contractTypeId), + foreign key (burialSiteTypeId) references BurialSiteTypes (burialSiteTypeId))`, + 'create index if not exists idx_Fees_orderNumber on Fees (orderNumber, feeName)', + `create table if not exists BurialSiteContractFees ( + burialSiteContractId integer not null, + feeId integer not null, + quantity decimal(4, 1) not null default 1, + feeAmount decimal(8, 2) not null, + taxAmount decimal(8, 2) not null, + ${recordColumns}, + primary key (burialSiteContractId, feeId), + foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId), + foreign key (feeId) references Fees (feeId)) without rowid`, + `create table if not exists BurialSiteContractTransactions ( + burialSiteContractId integer not null, + transactionIndex integer not null, + transactionDate integer not null check (transactionDate > 0), + transactionTime integer not null check (transactionTime >= 0), + transactionAmount decimal(8, 2) not null, + externalReceiptNumber varchar(100), + transactionNote text, + ${recordColumns}, + primary key (burialSiteContractId, transactionIndex), + foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId)) without rowid`, + `create index if not exists idx_BurialSiteContractTransactions_orderNumber + on BurialSiteContractTransactions (burialSiteContractId, transactionDate, transactionTime)`, + /* + * Work Orders + */ + `create table if not exists WorkOrderTypes ( + workOrderTypeId integer not null primary key autoincrement, + workOrderType varchar(100) not null, + orderNumber smallint not null default 0, + ${recordColumns})`, + `create index if not exists idx_WorkOrderTypes_orderNumber + on WorkOrderTypes (orderNumber, workOrderType)`, + `create table if not exists WorkOrders ( + workOrderId integer not null primary key autoincrement, + workOrderTypeId integer not null, + workOrderNumber varchar(50) not null, + workOrderDescription text, + workOrderOpenDate integer check (workOrderOpenDate > 0), + workOrderCloseDate integer check (workOrderCloseDate > 0), + ${recordColumns}, + foreign key (workOrderTypeId) references WorkOrderTypes (workOrderTypeId))`, + `create table if not exists WorkOrderBurialSites ( + workOrderId integer not null, + burialSiteId integer not null, + ${recordColumns}, + primary key (workOrderId, burialSiteId), + foreign key (workOrderId) references WorkOrders (workOrderId), + foreign key (burialSiteId) references BurialSites (burialSiteId)) without rowid`, + `create table if not exists WorkOrderBurialSiteContracts ( + workOrderId integer not null, + burialSiteContractId integer not null, + ${recordColumns}, + primary key (workOrderId, burialSiteContractId), + foreign key (workOrderId) references WorkOrders (workOrderId), + foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId)) without rowid`, + `create table if not exists WorkOrderComments ( + workOrderCommentId integer not null primary key autoincrement, + workOrderId integer not null, + commentDate integer not null check (commentDate > 0), + commentTime integer not null check (commentTime >= 0), + comment text not null, + ${recordColumns}, + foreign key (workOrderId) references WorkOrders (workOrderId))`, + `create index if not exists idx_WorkOrderComments_datetime + on WorkOrderComments (workOrderId, commentDate, commentTime)`, + `create table if not exists WorkOrderMilestoneTypes ( + workOrderMilestoneTypeId integer not null primary key autoincrement, + workOrderMilestoneType varchar(100) not null, + orderNumber smallint not null default 0, + ${recordColumns})`, + `create table if not exists WorkOrderMilestones ( + workOrderMilestoneId integer not null primary key autoincrement, + workOrderId integer not null, + workOrderMilestoneTypeId integer, + workOrderMilestoneDate integer not null check (workOrderMilestoneDate >= 0), + workOrderMilestoneTime integer not null check (workOrderMilestoneTime >= 0), + workOrderMilestoneDescription text not null, + workOrderMilestoneCompletionDate integer check (workOrderMilestoneCompletionDate > 0), + workOrderMilestoneCompletionTime integer check (workOrderMilestoneCompletionTime >= 0), + ${recordColumns}, + foreign key (workOrderId) references WorkOrders (workOrderId), + foreign key (workOrderMilestoneTypeId) references WorkOrderMilestoneTypes (workOrderMilestoneTypeId))` +]; +const initializingUser = { + userName: 'databaseInit', + userProperties: { + canUpdate: true, + isAdmin: true, + apiKey: '' + } +}; +export async function initializeDatabase() { + const sunriseDB = sqlite(databasePath); + const row = sunriseDB + .prepare("select name from sqlite_master where type = 'table' and name = 'WorkOrderMilestones'") + .get(); + if (row !== undefined) { + return false; + } + debug(`Creating ${databasePath} tables...`); + for (const sql of createStatements) { + sunriseDB.prepare(sql).run(); + } + sunriseDB.close(); + await initializeData(); + return true; +} +async function initializeData() { + debug(`Initializing data...`); + await addRecord('BurialSiteTypes', 'Casket Grave', 1, initializingUser); + await addRecord('BurialSiteTypes', 'Columbarium', 2, initializingUser); + await addRecord('BurialSiteTypes', 'Mausoleum', 2, initializingUser); + await addRecord('BurialSiteTypes', 'Niche Wall', 2, initializingUser); + await addRecord('BurialSiteTypes', 'Urn Garden', 2, initializingUser); + await addRecord('BurialSiteTypes', 'Crematorium', 2, initializingUser); + await addRecord('BurialSiteStatuses', 'Available', 1, initializingUser); + await addRecord('BurialSiteStatuses', 'Reserved', 2, initializingUser); + await addRecord('BurialSiteStatuses', 'Taken', 3, initializingUser); + await addRecord('ContractTypes', 'Preneed', 1, initializingUser); + await addRecord('ContractTypes', 'Interment', 2, initializingUser); + await addRecord('ContractTypes', 'Cremation', 3, initializingUser); + /* + * Fee Categories + */ + await addFeeCategory({ + feeCategory: 'Interment Rights', + orderNumber: 1 + }, initializingUser); + await addFeeCategory({ + feeCategory: 'Cremation Services', + orderNumber: 2 + }, initializingUser); + await addFeeCategory({ + feeCategory: 'Burial Charges', + orderNumber: 3 + }, initializingUser); + await addFeeCategory({ + feeCategory: 'Disinterment of Human Remains', + orderNumber: 4 + }, initializingUser); + await addFeeCategory({ + feeCategory: 'Additional Services', + orderNumber: 5 + }, initializingUser); + /* + * Work Orders + */ + await addRecord('WorkOrderTypes', 'Cemetery Work Order', 1, initializingUser); + await addRecord('WorkOrderMilestoneTypes', 'Funeral', 1, initializingUser); + await addRecord('WorkOrderMilestoneTypes', 'Arrival', 2, initializingUser); + await addRecord('WorkOrderMilestoneTypes', 'Cremation', 3, initializingUser); + await addRecord('WorkOrderMilestoneTypes', 'Interment', 4, initializingUser); +} diff --git a/database/initializeDatabase.ts b/database/initializeDatabase.ts new file mode 100644 index 00000000..e285d8e2 --- /dev/null +++ b/database/initializeDatabase.ts @@ -0,0 +1,523 @@ +// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair +/* eslint-disable no-secrets/no-secrets */ + +import sqlite from 'better-sqlite3' +import Debug from 'debug' + +import { DEBUG_NAMESPACE } from '../debug.config.js' +import { sunriseDB as databasePath } from '../helpers/database.helpers.js' + +import addFeeCategory from './addFeeCategory.js' +import addRecord from './addRecord.js' + +const debug = Debug(`${DEBUG_NAMESPACE}:database/initializeDatabase`) + +const recordColumns = `recordCreate_userName varchar(30) not null, + recordCreate_timeMillis integer not null, + recordUpdate_userName varchar(30) not null, + recordUpdate_timeMillis integer not null, + recordDelete_userName varchar(30), + recordDelete_timeMillis integer` + +const createStatements = [ + /* + * Burial Site Types + */ + + `create table if not exists BurialSiteTypes ( + burialSiteTypeId integer not null primary key autoincrement, + burialSiteType varchar(100) not null, + orderNumber smallint not null default 0, + ${recordColumns})`, + + `create index if not exists idx_BurialSiteTypes_orderNumber + on LotTypes (orderNumber, burialSiteType)`, + + `create table if not exists BurialSiteTypeFields ( + burialSiteTypeFieldId integer not null primary key autoincrement, + burialSiteTypeId integer not null, + burialSiteTypeField varchar(100) not null, + fieldType varchar(15) not null default 'text', + fieldValues text, + isRequired bit not null default 0, + pattern varchar(100), + minimumLength smallint not null default 1 check (minimumLength >= 0), + maximumLength smallint not null default 100 check (maximumLength >= 0), + orderNumber smallint not null default 0, + ${recordColumns}, + foreign key (burialSiteTypeId) references BurialSiteTypes (burialSiteTypeId))`, + + `create index if not exists idx_BurialSiteTypeFields_orderNumber + on BurialSiteTypeFields (burialSiteTypeId, orderNumber, burialSiteTypeField)`, + + /* + * Burial Site Statuses + */ + + `create table if not exists BurialSiteStatuses ( + burialSiteStatusId integer not null primary key autoincrement, + burialSiteStatus varchar(100) not null, + orderNumber smallint not null default 0, + ${recordColumns})`, + + `create index if not exists idx_BurialSiteStatuses_orderNumber + on BurialSiteStatuses (orderNumber, burialSiteStatus)`, + + /* + * Cemeteries + */ + + `create table if not exists Cemeteries ( + cemeteryId integer not null primary key autoincrement, + cemeteryName varchar(200) not null, + cemeteryDescription text, + cemeteryLatitude decimal(10, 8) + check (cemeteryLatitude between -90 and 90), + cemeteryLongitude decimal(11, 8) + check (cemeteryLongitude between -180 and 180), + cemeterySvg varchar(50), + cemeteryAddress1 varchar(50), + cemeteryAddress2 varchar(50), + cemeteryCity varchar(20), + cemeteryProvince varchar(2), + cemeteryPostalCode varchar(7), + cemeteryPhoneNumber varchar(30), + ${recordColumns})`, + + /* + * Burial Sites + */ + + `create table if not exists BurialSites ( + burialSiteId integer not null primary key autoincrement, + burialSiteTypeId integer not null, + + burialSiteNameSegment1 varchar(20), + burialSiteNameSegment2 varchar(20), + burialSiteNameSegment3 varchar(20), + burialSiteNameSegment4 varchar(20), + burialSiteNameSegment5 varchar(20), + + cemeteryId integer, + cemeterySvgId varchar(100), + burialSiteLatitude decimal(10, 8) + check (burialSiteLatitude between -90 and 90), + burialSiteLongitude decimal(11, 8) + check (burialSiteLongitude between -180 and 180), + burialSiteStatusId integer, + ${recordColumns}, + foreign key (burialSiteTypeId) references BurialSiteTypes (burialSiteTypeId), + foreign key (cemeteryId) references Cemeteries (cemeteryId), + foreign key (burialSiteStatusId) references BurialSiteStatuses (burialSiteStatusId), + unique (cemeteryId, burialSiteNameSegment1, burialSiteNameSegment2, burialSiteNameSegment3, burialSiteNameSegment4, burialSiteNameSegment5))`, + + `create table if not exists BurialSiteFields ( + burialSiteId integer not null, + burialSiteTypeFieldId integer not null, + fieldValue text not null, + ${recordColumns}, + primary key (burialSiteId, burialSiteTypeFieldId), + foreign key (burialSiteId) references BurialSites (burialSiteId), + foreign key (burialSiteTypeFieldId) references BurialSiteTypeFields (burialSiteTypeFieldId)) without rowid`, + + `create table if not exists BurialSiteComments ( + burialSiteCommentId integer not null primary key autoincrement, + burialSiteId integer not null, + commentDate integer not null check (commentDate > 0), + commentTime integer not null check (commentTime >= 0), + comment text not null, + ${recordColumns}, + foreign key (lotId) references BurialSites (burialSiteId))`, + + `create index if not exists idx_BurialSiteComments_datetime + on BurialSiteComments (burialSiteId, commentDate, commentTime)`, + + /* + * Funeral Homes + */ + + `create table if not exists FuneralHomes ( + funeralHomeId integer not null primary key autoincrement, + funeralHomeName varchar(200) not null, + funeralHomeAddress1 varchar(50), + funeralHomeAddress2 varchar(50), + funeralHomeCity varchar(20), + funeralHomeProvince varchar(2), + funeralHomePostalCode varchar(7), + funeralHomePhoneNumber varchar(30), + ${recordColumns})`, + + /* + * Contracts + */ + + `create table if not exists ContractTypes ( + contractTypeId integer not null primary key autoincrement, + contractType varchar(100) not null, + orderNumber smallint not null default 0, + ${recordColumns})`, + + `create index if not exists idx_ContractTypes_orderNumber + on ContractTypes (orderNumber, contractType)`, + + `create table if not exists ContractTypeFields ( + contractTypeFieldId integer not null primary key autoincrement, + contractTypeId integer, + contractTypeField varchar(100) not null, + fieldType varchar(15) not null default 'text', + fieldValues text, + isRequired bit not null default 0, + pattern varchar(100), + minimumLength smallint not null default 1 check (minimumLength >= 0), + maximumLength smallint not null default 100 check (maximumLength >= 0), + orderNumber smallint not null default 0, + ${recordColumns}, + foreign key (contractTypeId) references ContractTypes (contractTypeId))`, + + `create index if not exists idx_ContractTypeFields_orderNumber + on ContractTypeFields (contractTypeId, orderNumber, contractTypeField)`, + + `create table if not exists ContractTypePrints ( + contractTypeId integer not null, + printEJS varchar(100) not null, + orderNumber smallint not null default 0, + ${recordColumns}, + primary key (contractTypeId, printEJS), + foreign key (contractTypeId) references ContractTypes (contractTypeId))`, + + `create index if not exists idx_ContractTypePrints_orderNumber + on ContractTypePrints (contractTypeId, orderNumber, printEJS)`, + + `create table if not exists BurialSiteContracts ( + burialSiteContractId integer not null primary key autoincrement, + contractTypeId integer not null, + burialSiteId integer, + contractStartDate integer not null check (contractStartDate > 0), + contractEndDate integer check (contractEndDate > 0), + + purchaserName varchar(100) not null, + purchaserAddress1 varchar(50), + purchaserAddress2 varchar(50), + purchaserCity varchar(20), + purchaserProvince varchar(2), + purchaserPostalCode varchar(7), + purchaserPhoneNumber varchar(30), + purchaserEmail varchar(100), + + funeralHomeId integer, + funeralDirectorName varchar(100), + + ${recordColumns}, + foreign key (burialSiteId) references BurialSites (burialSiteId), + foreign key (contractTypeId) references ContractTypes (contractTypeId), + foreign key (funeralHomeId) references FuneralHomes (funeralHomeId))`, + + `create table if not exists BurialSiteContractFields ( + burialSiteContractId integer not null, + contractTypeFieldId integer not null, + fieldValue text not null, + ${recordColumns}, + primary key (burialSiteContractId, contractTypeFieldId), + foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId), + foreign key (contractTypeFieldId) references ContractTypeFields (contractTypeFieldId)) without rowid`, + + `create table if not exists BurialSiteContractComments ( + burialSiteContractCommentId integer not null primary key autoincrement, + burialSiteContractId integer not null, + commentDate integer not null check (commentDate > 0), + commentTime integer not null check (commentTime >= 0), + comment text not null, + ${recordColumns}, + foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId))`, + + `create index if not exists idx_BurialSiteContractComments_datetime + on BurialSiteContractComments (burialSiteContractId, commentDate, commentTime)`, + + /* + * Interments + */ + + `create table if not exists IntermentContainerTypes ( + intermentContainerTypeId integer not null primary key autoincrement, + intermentContainerType varchar(100) not null, + orderNumber smallint not null default 0, + ${recordColumns})`, + + `create index if not exists idx_IntermentContainerTypes_orderNumber + on IntermentContainerTypes (orderNumber, intermentContainerType)`, + + `create table if not exists IntermentCommittalTypes ( + intermentCommittalTypeId integer not null primary key autoincrement, + intermentCommittalType varchar(100) not null, + orderNumber smallint not null default 0, + ${recordColumns})`, + + `create index if not exists idx_IntermentCommittalType_orderNumber + on IntermentCommittalTypes (orderNumber, intermentCommittalType)`, + + `create table if not exists BurialSiteContractInterments ( + burialSiteContractId integer not null, + intermentNumber integer not null, + isCremated bit not null default 0, + + deceasedName varchar(50) not null, + + birthDate integer, + birthPlace varchar(100), + + deathDate integer, + deathPlace varchar(100), + + intermentDate integer check (intermentDate > 0), + intermentTime integer check (intermentTime >= 0), + + intermentContainerTypeId integer, + intermentCommittalTypeId integer, + + ${recordColumns}, + primary key (burialSiteContractId, intermentNumber), + foreign key (burialSiteId) references BurialSites (burialSiteId), + foreign key (intermentContainerTypeId) references IntermentContainerTypes (intermentContainerTypeId), + foreign key (intermentCommittalTypeId) references IntermentCommittalTypes (intermentCommittalTypeId)) without rowid`, + + /* + * Fees and Transactions + */ + + `create table if not exists FeeCategories ( + feeCategoryId integer not null primary key autoincrement, + feeCategory varchar(100) not null, + isGroupedFee bit not null default 0, + orderNumber smallint not null default 0, + ${recordColumns})`, + + `create table if not exists Fees ( + feeId integer not null primary key autoincrement, + feeCategoryId integer not null, + feeName varchar(100) not null, + feeDescription text, + feeAccount varchar(20), + + contractTypeId integer, + burialSiteTypeId integer, + + includeQuantity boolean not null default 0, + quantityUnit varchar(30), + feeAmount decimal(8, 2), + feeFunction varchar(100), + taxAmount decimal(6, 2), + taxPercentage decimal(5, 2), + isRequired bit not null default 0, + orderNumber smallint not null default 0, + ${recordColumns}, + foreign key (feeCategoryId) references FeeCategories (feeCategoryId), + foreign key (contractTypeId) references ContractTypes (contractTypeId), + foreign key (burialSiteTypeId) references BurialSiteTypes (burialSiteTypeId))`, + + 'create index if not exists idx_Fees_orderNumber on Fees (orderNumber, feeName)', + + `create table if not exists BurialSiteContractFees ( + burialSiteContractId integer not null, + feeId integer not null, + quantity decimal(4, 1) not null default 1, + feeAmount decimal(8, 2) not null, + taxAmount decimal(8, 2) not null, + ${recordColumns}, + primary key (burialSiteContractId, feeId), + foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId), + foreign key (feeId) references Fees (feeId)) without rowid`, + + `create table if not exists BurialSiteContractTransactions ( + burialSiteContractId integer not null, + transactionIndex integer not null, + transactionDate integer not null check (transactionDate > 0), + transactionTime integer not null check (transactionTime >= 0), + transactionAmount decimal(8, 2) not null, + externalReceiptNumber varchar(100), + transactionNote text, + ${recordColumns}, + primary key (burialSiteContractId, transactionIndex), + foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId)) without rowid`, + + `create index if not exists idx_BurialSiteContractTransactions_orderNumber + on BurialSiteContractTransactions (burialSiteContractId, transactionDate, transactionTime)`, + + /* + * Work Orders + */ + + `create table if not exists WorkOrderTypes ( + workOrderTypeId integer not null primary key autoincrement, + workOrderType varchar(100) not null, + orderNumber smallint not null default 0, + ${recordColumns})`, + + `create index if not exists idx_WorkOrderTypes_orderNumber + on WorkOrderTypes (orderNumber, workOrderType)`, + + `create table if not exists WorkOrders ( + workOrderId integer not null primary key autoincrement, + workOrderTypeId integer not null, + workOrderNumber varchar(50) not null, + workOrderDescription text, + workOrderOpenDate integer check (workOrderOpenDate > 0), + workOrderCloseDate integer check (workOrderCloseDate > 0), + ${recordColumns}, + foreign key (workOrderTypeId) references WorkOrderTypes (workOrderTypeId))`, + + `create table if not exists WorkOrderBurialSites ( + workOrderId integer not null, + burialSiteId integer not null, + ${recordColumns}, + primary key (workOrderId, burialSiteId), + foreign key (workOrderId) references WorkOrders (workOrderId), + foreign key (burialSiteId) references BurialSites (burialSiteId)) without rowid`, + + `create table if not exists WorkOrderBurialSiteContracts ( + workOrderId integer not null, + burialSiteContractId integer not null, + ${recordColumns}, + primary key (workOrderId, burialSiteContractId), + foreign key (workOrderId) references WorkOrders (workOrderId), + foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId)) without rowid`, + + `create table if not exists WorkOrderComments ( + workOrderCommentId integer not null primary key autoincrement, + workOrderId integer not null, + commentDate integer not null check (commentDate > 0), + commentTime integer not null check (commentTime >= 0), + comment text not null, + ${recordColumns}, + foreign key (workOrderId) references WorkOrders (workOrderId))`, + + `create index if not exists idx_WorkOrderComments_datetime + on WorkOrderComments (workOrderId, commentDate, commentTime)`, + + `create table if not exists WorkOrderMilestoneTypes ( + workOrderMilestoneTypeId integer not null primary key autoincrement, + workOrderMilestoneType varchar(100) not null, + orderNumber smallint not null default 0, + ${recordColumns})`, + + `create table if not exists WorkOrderMilestones ( + workOrderMilestoneId integer not null primary key autoincrement, + workOrderId integer not null, + workOrderMilestoneTypeId integer, + workOrderMilestoneDate integer not null check (workOrderMilestoneDate >= 0), + workOrderMilestoneTime integer not null check (workOrderMilestoneTime >= 0), + workOrderMilestoneDescription text not null, + workOrderMilestoneCompletionDate integer check (workOrderMilestoneCompletionDate > 0), + workOrderMilestoneCompletionTime integer check (workOrderMilestoneCompletionTime >= 0), + ${recordColumns}, + foreign key (workOrderId) references WorkOrders (workOrderId), + foreign key (workOrderMilestoneTypeId) references WorkOrderMilestoneTypes (workOrderMilestoneTypeId))` +] + +const initializingUser: User = { + userName: 'databaseInit', + userProperties: { + canUpdate: true, + isAdmin: true, + apiKey: '' + } +} + +export async function initializeDatabase(): Promise { + const sunriseDB = sqlite(databasePath) + + const row = sunriseDB + .prepare( + "select name from sqlite_master where type = 'table' and name = 'WorkOrderMilestones'" + ) + .get() + + if (row !== undefined) { + return false + } + + debug(`Creating ${databasePath} tables...`) + + for (const sql of createStatements) { + sunriseDB.prepare(sql).run() + } + + sunriseDB.close() + + await initializeData() + + return true +} + +async function initializeData(): Promise { + debug(`Initializing data...`) + + await addRecord('BurialSiteTypes', 'Casket Grave', 1, initializingUser) + await addRecord('BurialSiteTypes', 'Columbarium', 2, initializingUser) + await addRecord('BurialSiteTypes', 'Mausoleum', 2, initializingUser) + await addRecord('BurialSiteTypes', 'Niche Wall', 2, initializingUser) + await addRecord('BurialSiteTypes', 'Urn Garden', 2, initializingUser) + await addRecord('BurialSiteTypes', 'Crematorium', 2, initializingUser) + + await addRecord('BurialSiteStatuses', 'Available', 1, initializingUser) + await addRecord('BurialSiteStatuses', 'Reserved', 2, initializingUser) + await addRecord('BurialSiteStatuses', 'Taken', 3, initializingUser) + + await addRecord('ContractTypes', 'Preneed', 1, initializingUser) + await addRecord('ContractTypes', 'Interment', 2, initializingUser) + await addRecord('ContractTypes', 'Cremation', 3, initializingUser) + + /* + * Fee Categories + */ + + await addFeeCategory( + { + feeCategory: 'Interment Rights', + orderNumber: 1 + }, + initializingUser + ) + + await addFeeCategory( + { + feeCategory: 'Cremation Services', + orderNumber: 2 + }, + initializingUser + ) + + await addFeeCategory( + { + feeCategory: 'Burial Charges', + orderNumber: 3 + }, + initializingUser + ) + + await addFeeCategory( + { + feeCategory: 'Disinterment of Human Remains', + orderNumber: 4 + }, + initializingUser + ) + + await addFeeCategory( + { + feeCategory: 'Additional Services', + orderNumber: 5 + }, + initializingUser + ) + + /* + * Work Orders + */ + + await addRecord('WorkOrderTypes', 'Cemetery Work Order', 1, initializingUser) + + await addRecord('WorkOrderMilestoneTypes', 'Funeral', 1, initializingUser) + await addRecord('WorkOrderMilestoneTypes', 'Arrival', 2, initializingUser) + await addRecord('WorkOrderMilestoneTypes', 'Cremation', 3, initializingUser) + await addRecord('WorkOrderMilestoneTypes', 'Interment', 4, initializingUser) +} diff --git a/database/pool.js b/database/pool.js index 2bcd4a3d..f4f0a526 100644 --- a/database/pool.js +++ b/database/pool.js @@ -1,8 +1,9 @@ import { Pool } from 'better-sqlite-pool'; import Debug from 'debug'; import exitHook from 'exit-hook'; -import { lotOccupancyDB as databasePath } from '../data/databasePaths.js'; -const debug = Debug('lot-occupancy-system:lotOccupancyDB:pool'); +import { DEBUG_NAMESPACE } from '../debug.config.js'; +import { sunriseDB as databasePath } from '../helpers/database.helpers.js'; +const debug = Debug(`${DEBUG_NAMESPACE}:sunriseDB:pool`); const pool = new Pool(databasePath); export async function acquireConnection() { return await pool.acquire(); diff --git a/database/pool.ts b/database/pool.ts index fdce4bb3..9d5c38b7 100644 --- a/database/pool.ts +++ b/database/pool.ts @@ -2,9 +2,10 @@ import { Pool, type PoolConnection } from 'better-sqlite-pool' import Debug from 'debug' import exitHook from 'exit-hook' -import { lotOccupancyDB as databasePath } from '../data/databasePaths.js' +import { DEBUG_NAMESPACE } from '../debug.config.js' +import { sunriseDB as databasePath } from '../helpers/database.helpers.js' -const debug = Debug('lot-occupancy-system:lotOccupancyDB:pool') +const debug = Debug(`${DEBUG_NAMESPACE}:sunriseDB:pool`) const pool = new Pool(databasePath) diff --git a/debug.config.d.ts b/debug.config.d.ts new file mode 100644 index 00000000..7901ca7b --- /dev/null +++ b/debug.config.d.ts @@ -0,0 +1,2 @@ +export declare const DEBUG_NAMESPACE = "sunrise"; +export declare const DEBUG_ENABLE_NAMESPACES: string; diff --git a/debug.config.js b/debug.config.js new file mode 100644 index 00000000..381e10ff --- /dev/null +++ b/debug.config.js @@ -0,0 +1,6 @@ +import { DEBUG_ENABLE_NAMESPACES as DEBUG_ENABLE_NAMESPACES_DYNAMICS } from '@cityssm/dynamics-gp/debug'; +export const DEBUG_NAMESPACE = 'sunrise'; +export const DEBUG_ENABLE_NAMESPACES = [ + `${DEBUG_NAMESPACE}:*`, + DEBUG_ENABLE_NAMESPACES_DYNAMICS +].join(','); diff --git a/debug.config.ts b/debug.config.ts new file mode 100644 index 00000000..e05b0c35 --- /dev/null +++ b/debug.config.ts @@ -0,0 +1,8 @@ +import { DEBUG_ENABLE_NAMESPACES as DEBUG_ENABLE_NAMESPACES_DYNAMICS } from '@cityssm/dynamics-gp/debug' + +export const DEBUG_NAMESPACE = 'sunrise' + +export const DEBUG_ENABLE_NAMESPACES = [ + `${DEBUG_NAMESPACE}:*`, + DEBUG_ENABLE_NAMESPACES_DYNAMICS +].join(',') diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index 5a13c4cf..00000000 --- a/docs/README.md +++ /dev/null @@ -1,43 +0,0 @@ -[Home](https://cityssm.github.io/lot-occupancy-system/) - -# Help Documentation - -**Thank you for taking the time to read the documentation.** - -![Lot Occupancy View](images/lotOccupancyView.png) - -## 👶 Getting Started - -[**Terminology**](terminology.md)
-Understanding the key terms used in the Lot Occupancy System. - -## 👩 User Documentation - -[**Lot Occupancies**](lotOccupancies.md)
-What are occupancy records? - -[**Work Orders**](workOrders.md)
-What are work orders? How do they work? - -## 🦸‍♀️ Power User Documentation - -[**Keyboard Shortcuts**](shortcuts.md)
-Shortcuts to speed through tasks in the Lot Occupancy System. - -## 💼 Administrator Documentation - -[**Fee Management**](adminFees.md)
-Administer fees that apply to occupancy records. - -[**Occupancy Type Management**](adminOccupancyTypes.md)
-Maintain the types available for occupancy records. - -[**Lot Type Management**](adminLotTypes.md)
-Maintain the types available for lots. - -[**Config Table Management**](adminConfigTables.md)
-Maintain simpler, list-like tables include work order types, -work order milestone types, lot statuses, and lot occupant types. - -[**Map Images**](mapImages.md)
-How to create images compatible with the Lot Occupancy System. diff --git a/docs/adminConfigTables.md b/docs/adminConfigTables.md deleted file mode 100644 index 5e8cb3f1..00000000 --- a/docs/adminConfigTables.md +++ /dev/null @@ -1,25 +0,0 @@ -[Home](https://cityssm.github.io/lot-occupancy-system/) -• -[Help](https://cityssm.github.io/lot-occupancy-system/docs/) - -# Config Table Management - -![Config Table Management](images/adminConfigTables.png) - -The Config Table Management page updates simpler configuration tables -that are, for the most part, list-like. - -The tables that can be updated on this page include: - -- Work Order Types -- Work Order Milestone Types -- Lot Statuses (referred to as "Burial Site Statuses" in the screenshot) -- Lot Occupant Types (referred to as "Burial Site Occupant Types" in the screenshot) - -When updating any list items, it is important not to change the meaning of the items. -When in doubt, rather than renaming a list item, delete it, and create a new one instead. - -## Related Links - -- [Occupancy Type Management](adminOccupancyTypes.md) -- [Lot Type Management](adminLotTypes.md) diff --git a/docs/adminFees.md b/docs/adminFees.md deleted file mode 100644 index 91134625..00000000 --- a/docs/adminFees.md +++ /dev/null @@ -1,19 +0,0 @@ -[Home](https://cityssm.github.io/lot-occupancy-system/) -• -[Help](https://cityssm.github.io/lot-occupancy-system/docs/) - -# Fee Management - -![Fee Management](images/adminFees.png) - -Fees can be applied to [occupancy records](lotOccupancies.md). -Each fee includes the following properties. - -- A category, name, and description. -- Filter options by occupancy type and/or lot type. -- Fee and tax amounts. - -## Related Links - -- [Occupancy Type Management](adminOccupancyTypes.md) -- [Lot Type Management](adminLotTypes.md) diff --git a/docs/adminLotTypes.md b/docs/adminLotTypes.md deleted file mode 100644 index 8b25011e..00000000 --- a/docs/adminLotTypes.md +++ /dev/null @@ -1,10 +0,0 @@ -[Home](https://cityssm.github.io/lot-occupancy-system/) -• -[Help](https://cityssm.github.io/lot-occupancy-system/docs/) - -# Lot Type Management - -![Lot Type Management](images/adminLotTypes.png) - -Each lot record, refered to as a "burial site" in the screenshot, is assigned a type. -Those types can have custom data fields associated with them. diff --git a/docs/adminOccupancyTypes.md b/docs/adminOccupancyTypes.md deleted file mode 100644 index e5005d41..00000000 --- a/docs/adminOccupancyTypes.md +++ /dev/null @@ -1,14 +0,0 @@ -[Home](https://cityssm.github.io/lot-occupancy-system/) -• -[Help](https://cityssm.github.io/lot-occupancy-system/docs/) - -# Occupancy Type Management - -![Occupancy Type Management](images/adminOccupancyTypes.png) - -Each occupancy record is assigned a type. -Those types can have custom data fields associated with them. - -## Related Links - -- [Lot Occupancies](lotOccupancies.md) diff --git a/docs/cemeteryWorkflowDeceased.md b/docs/cemeteryWorkflowDeceased.md deleted file mode 100644 index 9a6a87cc..00000000 --- a/docs/cemeteryWorkflowDeceased.md +++ /dev/null @@ -1,33 +0,0 @@ -[Home](https://cityssm.github.io/lot-occupancy-system/) -• -[Help](https://cityssm.github.io/lot-occupancy-system/docs/) - -# Cemetery Management System Workflow - Newly Deceased - -_The following workflow describes a process that can be used when the Lot Occupancy System is used -as a Cemetery Management System._ - -## Step 1: Search for a Related Preneed Occupancy Record - -![Occupancy Search](images/lotOccupancySearch.png) - -If the deceased purchased preneed services, find them now. - -![Occupancy View](images/lotOccupancyView.png) - -It is important to note what services have been paid for, -and who is entitled to the services. - -## Step 2: Create the New Interment or Cremation Occupancy Record - -![Occupancy Edit - More Options](images/lotOccupancyEdit-moreOptions.png) - -If a preneed occupancy record exists, you can save time by copying the preneed record as a new record. - -If no preneed occupancy record exists, a new occupancy record should be created. - -## Step 3: Create a Work Order Associated with the Occupancy Record - -Ensure the necessary milestones are included. - -## Step 4: Complete the Work Order \ No newline at end of file diff --git a/docs/images/adminConfigTables.png b/docs/images/adminConfigTables.png deleted file mode 100644 index 553bc301..00000000 Binary files a/docs/images/adminConfigTables.png and /dev/null differ diff --git a/docs/images/adminFees.png b/docs/images/adminFees.png deleted file mode 100644 index 220845c2..00000000 Binary files a/docs/images/adminFees.png and /dev/null differ diff --git a/docs/images/adminLotTypes.png b/docs/images/adminLotTypes.png deleted file mode 100644 index d85e6c70..00000000 Binary files a/docs/images/adminLotTypes.png and /dev/null differ diff --git a/docs/images/adminOccupancyTypes.png b/docs/images/adminOccupancyTypes.png deleted file mode 100644 index 5fe5e679..00000000 Binary files a/docs/images/adminOccupancyTypes.png and /dev/null differ diff --git a/docs/images/configTableSorting.png b/docs/images/configTableSorting.png deleted file mode 100644 index 1e80cbcd..00000000 Binary files a/docs/images/configTableSorting.png and /dev/null differ diff --git a/docs/images/lotOccupancyAddFee.png b/docs/images/lotOccupancyAddFee.png deleted file mode 100644 index 569dfa83..00000000 Binary files a/docs/images/lotOccupancyAddFee.png and /dev/null differ diff --git a/docs/images/lotOccupancyEdit-moreOptions.png b/docs/images/lotOccupancyEdit-moreOptions.png deleted file mode 100644 index b1fb2b66..00000000 Binary files a/docs/images/lotOccupancyEdit-moreOptions.png and /dev/null differ diff --git a/docs/images/lotOccupancyEdit.png b/docs/images/lotOccupancyEdit.png deleted file mode 100644 index 7cf3e7df..00000000 Binary files a/docs/images/lotOccupancyEdit.png and /dev/null differ diff --git a/docs/images/lotOccupancySearch.png b/docs/images/lotOccupancySearch.png deleted file mode 100644 index 4b071d2d..00000000 Binary files a/docs/images/lotOccupancySearch.png and /dev/null differ diff --git a/docs/images/lotOccupancyView.png b/docs/images/lotOccupancyView.png deleted file mode 100644 index 295333e7..00000000 Binary files a/docs/images/lotOccupancyView.png and /dev/null differ diff --git a/docs/images/lotView.png b/docs/images/lotView.png deleted file mode 100644 index 4319080e..00000000 Binary files a/docs/images/lotView.png and /dev/null differ diff --git a/docs/images/mapImageLotConfig.png b/docs/images/mapImageLotConfig.png deleted file mode 100644 index a2c9e02c..00000000 Binary files a/docs/images/mapImageLotConfig.png and /dev/null differ diff --git a/docs/images/mapImageStructure.png b/docs/images/mapImageStructure.png deleted file mode 100644 index b0b19210..00000000 Binary files a/docs/images/mapImageStructure.png and /dev/null differ diff --git a/docs/images/workOrderEdit.png b/docs/images/workOrderEdit.png deleted file mode 100644 index 0d1eb771..00000000 Binary files a/docs/images/workOrderEdit.png and /dev/null differ diff --git a/docs/images/workOrderMilestoneEdit.png b/docs/images/workOrderMilestoneEdit.png deleted file mode 100644 index bc875dbf..00000000 Binary files a/docs/images/workOrderMilestoneEdit.png and /dev/null differ diff --git a/docs/lotOccupancies.md b/docs/lotOccupancies.md deleted file mode 100644 index bc34bff9..00000000 --- a/docs/lotOccupancies.md +++ /dev/null @@ -1,60 +0,0 @@ -[Home](https://cityssm.github.io/lot-occupancy-system/) -• -[Help](https://cityssm.github.io/lot-occupancy-system/docs/) - -# Lot Occupancies - -![Lot Occupancy Edit](images/lotOccupancyEdit.png) - -Lot occupancies records track the people who occupy lots. -In the context of a cemetery management system, occupancy records can track the names of -preneed owners or those interred in burial sites. - -## Main Details - -Occupancy records include the following details. - -**Occupancy Type**
-Occupancy types are [completely customizable](adminOccupancyTypes.md), -and can be used to categorize the nature of the occupancy. - -**Lot**
-_"Burial Site" in the screenshot._
-The location where the occupancy is taking place. - -**Start Date**
-_"Interment Date" in the screenshot._
-The date when the lot is considered occupied. - -**End Date**
-The date when the lot is no longer considered occupied. - -**Additional Fields**
-Additional fields can be added to the occupancy record depending on the selected occupancy type. - -## Occupants - -Occupancy records can have any number of people associated with them. -In the context of a cemetery management system, -occupants may be preneed owners, funeral directors, or the deceased. -Each occupant can include an occupant type, name, address, phone number, and email address. - -## Comments - -Comments offer open logging that can track various details that arise throughout the occupancy. - -## Fees - -![Add Fee](images/lotOccupancyAddFee.png) - -Occupancies can have fees associated with them. The available fees depend on the set occupancy type -and the related lot type. - -## Transactions - -Transactions are used to pay down applied fees. - -## Related Links - -- [Occupancy Type Management](adminOccupancyTypes.md) -- [Fee Management](adminFees.md) diff --git a/docs/mapImages.md b/docs/mapImages.md deleted file mode 100644 index 2d57de47..00000000 --- a/docs/mapImages.md +++ /dev/null @@ -1,42 +0,0 @@ -[Home](https://cityssm.github.io/lot-occupancy-system/) -• -[Help](https://cityssm.github.io/lot-occupancy-system/docs/) - -# Map Images - -Map images rely on SVG (Scalable Vector Graphics) files. - -While many SVG editors exist, we recommend [Inkscape](https://inkscape.org/), -a free and open source vector graphics editor. - -## Structuring the SVG Files - -The SVG format has the ability to group together elements using a `` tag, -and to set an `id` attribute on `` and `` tags. -These two features are heavilty relied on by the Lot Occupancy System. - -![Screenshot of Map Image Structure](images/mapImageStructure.png) - -Take the screenshot above. - -- The map has two main sections, D and E. -- Within each section, there are groups 1, 2, and 3. -- Each group has a north side (N) and a south side (S). -- Each side has 3 or 6 lots. - -The `id` for the top leftmost lot is `E-1-N-1`. -The `id` for the bottom rightmost lot is `D-3-S-3`. - -![Lot Image Configuration](images/mapImageLotConfig.png) - -In order to link the lot record in the application to the lot path in the image, -the `id` attribute of the `` tag should match the Map SVG ID set on the lot record. - -Non-exact matching can also be done. If all lot paths in the SVG image are grouped, -and those groups have their `id` attributes set, the application will for the first matching -path or group, removing pieces from the end of the configured Map SVG ID. - -For example, if the application comes across a new lot with Map SVG ID `E-1-N-7`, -there is no exact match. The application will then look for `E-1-N`, -which will match a group of six lots. The six lots will be highlighted -until the map is revised with the new lot. diff --git a/docs/shortcuts.md b/docs/shortcuts.md deleted file mode 100644 index 4ae151eb..00000000 --- a/docs/shortcuts.md +++ /dev/null @@ -1,63 +0,0 @@ -[Home](https://cityssm.github.io/lot-occupancy-system/) -• -[Help](https://cityssm.github.io/lot-occupancy-system/docs/) - -# Keyboard Shortcuts - -Note that the key combinations needed to access the keyboard shortcuts -vary by browser and operating system. - -For example, the Mozilla Firefox web browser running on Windows uses Shift + Alt, -while most web browsers running on Mac machines use Control + Option. - -See [MDN's documentation on the accesskeys](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey) -for assistance identifying the combination for your web browser - operating system combination. - -## All Pages - -| Shortcut Key | Description | -| ------------ | ------------------------------------ | -| 0 | Go to main dashboard. | -| 1 | Go to Work Order search. | -| 2 | Go to Occupancy search. | -| 3 | Go to Lot search. | -| 4 | Go to Map search. | -| h | Open the Help website. | -| x | Log out of the Lot Occupancy System. | - -## Search Pages - -| Shortcut Key | Description | -| ------------ | --------------------------------- | -| n | Create a new record. | -| f | Focus on the first search filter. | - -## View Pages - -| Shortcut Key | Description | -| ------------------------------ | ----------------------------------------- | -| e | Switch to edit mode. | -| , (or <) | Move to previous record (when available). | -| . (or >) | Move to next record (when available). | - -## Edit Pages - -| Shortcut Key | Description | -| ------------ | ---------------------------------- | -| f | Focus on the first editable field. | -| v | Switch to view mode. | - -## Other Shortcuts - -### Quick Sorting - -![Configuration Tables](images/configTableSorting.png) - -Configuration tables with up and down arrow buttons can be reordered one position at a time -by clicking the arrow buttons. - -To send an item to the bottom of the list, -hold the Shift key when clicking the down arrow button. - -Similarly, to send an item to the top of the list, -hold the Shift key when clicking the up arrow button. diff --git a/docs/terminology.md b/docs/terminology.md deleted file mode 100644 index 3d2ee2d9..00000000 --- a/docs/terminology.md +++ /dev/null @@ -1,26 +0,0 @@ -[Home](https://cityssm.github.io/lot-occupancy-system/) -• -[Help](https://cityssm.github.io/lot-occupancy-system/docs/) - -# Terminology - -_Note that is is possible to substitute the default terminology using the application's config file._ - -| Term | Description | Cemetery System Alias Example | -| --------- | ---------------------------------------------- | ----------------------------- | -| Map | The highest level object, a group of lots. | Cemetery | -| Lot | The smallest occupiable piece of land. | Burial Site | -| Occupancy | A reservation on a lot for a specific purpose. | Occupancy | -| Occupant | A person associated with a lot occupancy. | Occupant | - -For example in the context of a cemetery system, John Doe has passed away and has been interred. - -- John Doe would be considered an **occupant**. -- An **occupancy** record would be created with **no end date** and associated with his **burial site (lot)** of choice. -- The **burial site (lot)** is associated with the **cemetery (map)** where John is buried. - -For example in the context of a marina, Jane Smith and her boat are renting a slip for a week. - -- Jane Smith, and possibly the others on her boat, would be considered **renters (occupants)**. -- A **reservation (occupancy)** record would be created for the duration of her stay, and associated with the **slip (lot)** of choice. -- The **slip (lot)** is associated with the **marina (map)** where the slip is located. diff --git a/docs/workOrders.md b/docs/workOrders.md deleted file mode 100644 index a727d222..00000000 --- a/docs/workOrders.md +++ /dev/null @@ -1,59 +0,0 @@ -[Home](https://cityssm.github.io/lot-occupancy-system/) -• -[Help](https://cityssm.github.io/lot-occupancy-system/docs/) - -# Work Orders - -![Work Order Edit](images/workOrderEdit.png) - -Work orders track tasks associated with lots and/or occupancies on lots. -There are several sections that make up each work order, -and can be used to track various details associated with the work. - -## Main Details - -Work orders include the following main details. - -**Work Order Number**
-Note that when creating a work order, if the work order number field is left blank, -a new work order number can be generated based on the format of your choice. - -**Work Order Type**
-The work order types are [completely customizable](adminConfigTables.md) -and can be used to categorize work orders. - -**Description**
-The work order description can describe the overall theme of the work order, -and include details that may not fit into other places on the work order. - -**Open Date**
-The starting date for the work order. - -**Close Date**
-The date the work order is considered complete. -Further updates to the work order are not permitted after the work order is closed. - -## Related Lots and Occupancies - -In order to track where the work is taking place and who is affected by the work, -work orders can be linked to lots (burial sites in the example above) -and occupancies. - -## Comments - -Comments offer open logging that can track various details that arise throughout the work order. - -## Milestones - -![Work Order Milestone Edit](images/workOrderMilestoneEdit.png) - -Work orders can be broken up into actionable items, called milestones. -Milestone types are completely customizable and can be used to categorize milestones. -The date, and optional time, track when the milestone is scheduled to be completed. - -Milestones appear on the main application dashboard, -and can be linked to calendar applications like Microsoft Outlook. - -## Related Links - -- [Config Table Management](adminConfigTables.md) diff --git a/eslint.config.d.ts b/eslint.config.d.ts index 54ee6e2d..6b517f8e 100644 --- a/eslint.config.d.ts +++ b/eslint.config.d.ts @@ -1,2 +1,2 @@ -export declare const config: import("@typescript-eslint/utils/dist/ts-eslint").FlatConfig.ConfigArray; +export declare const config: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray; export default config; diff --git a/eslint.config.js b/eslint.config.js index ed780fd8..b0e667fc 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -11,10 +11,11 @@ export const config = tseslint.config(...configWebApp, { 'warn', { cspell: { - words: [...cspellWords, 'ical', 'preneed', 'ntfy'] + words: [...cspellWords, 'autoincrement', 'ical', 'preneed', 'ntfy'] } } - ] + ], + '@typescript-eslint/no-unsafe-type-assertion': 'off', } }); export default config; diff --git a/eslint.config.ts b/eslint.config.ts index 284789c5..03645d8e 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -12,10 +12,11 @@ export const config = tseslint.config(...configWebApp, { 'warn', { cspell: { - words: [...cspellWords, 'ical', 'preneed', 'ntfy'] + words: [...cspellWords, 'autoincrement', 'ical', 'preneed', 'ntfy'] } } - ] + ], + '@typescript-eslint/no-unsafe-type-assertion': 'off', } }) diff --git a/handlers/admin-get/lotTypes.d.ts b/handlers/admin-get/burialSiteTypes.d.ts similarity index 100% rename from handlers/admin-get/lotTypes.d.ts rename to handlers/admin-get/burialSiteTypes.d.ts diff --git a/handlers/admin-get/lotTypes.js b/handlers/admin-get/burialSiteTypes.js similarity index 81% rename from handlers/admin-get/lotTypes.js rename to handlers/admin-get/burialSiteTypes.js index 5fd2443d..706f49f0 100644 --- a/handlers/admin-get/lotTypes.js +++ b/handlers/admin-get/burialSiteTypes.js @@ -1,5 +1,5 @@ import { getLotTypes } from '../../helpers/functions.cache.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; export default async function handler(_request, response) { const lotTypes = await getLotTypes(); response.render('admin-lotTypes', { diff --git a/handlers/admin-get/lotTypes.ts b/handlers/admin-get/burialSiteTypes.ts similarity index 84% rename from handlers/admin-get/lotTypes.ts rename to handlers/admin-get/burialSiteTypes.ts index afd91b2f..07ad006b 100644 --- a/handlers/admin-get/lotTypes.ts +++ b/handlers/admin-get/burialSiteTypes.ts @@ -1,7 +1,7 @@ import type { Request, Response } from 'express' import { getLotTypes } from '../../helpers/functions.cache.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' export default async function handler( _request: Request, diff --git a/handlers/admin-get/ntfyStartup.js b/handlers/admin-get/ntfyStartup.js index 4381f40f..dadc634b 100644 --- a/handlers/admin-get/ntfyStartup.js +++ b/handlers/admin-get/ntfyStartup.js @@ -1,4 +1,4 @@ -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; export default function handler(_request, response) { if (getConfigProperty('application.ntfyStartup') === undefined) { response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/dashboard/?error=ntfyNotConfigured`); diff --git a/handlers/admin-get/ntfyStartup.ts b/handlers/admin-get/ntfyStartup.ts index ced61ee8..2d3c1659 100644 --- a/handlers/admin-get/ntfyStartup.ts +++ b/handlers/admin-get/ntfyStartup.ts @@ -1,6 +1,6 @@ import type { Request, Response } from 'express' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' export default function handler(_request: Request, response: Response): void { if (getConfigProperty('application.ntfyStartup') === undefined) { diff --git a/handlers/admin-get/occupancyTypes.js b/handlers/admin-get/occupancyTypes.js index 7d32b2d1..686813b1 100644 --- a/handlers/admin-get/occupancyTypes.js +++ b/handlers/admin-get/occupancyTypes.js @@ -1,5 +1,5 @@ import { getAllOccupancyTypeFields, getOccupancyTypes } from '../../helpers/functions.cache.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; import { getPrintConfig } from '../../helpers/functions.print.js'; export default async function handler(_request, response) { const occupancyTypes = await getOccupancyTypes(); diff --git a/handlers/admin-get/occupancyTypes.ts b/handlers/admin-get/occupancyTypes.ts index c24ec75b..b2c6a40f 100644 --- a/handlers/admin-get/occupancyTypes.ts +++ b/handlers/admin-get/occupancyTypes.ts @@ -4,7 +4,7 @@ import { getAllOccupancyTypeFields, getOccupancyTypes } from '../../helpers/functions.cache.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' import { getPrintConfig } from '../../helpers/functions.print.js' export default async function handler( diff --git a/handlers/api-get/milestoneICS.js b/handlers/api-get/milestoneICS.js index 28c3b160..6644a6e3 100644 --- a/handlers/api-get/milestoneICS.js +++ b/handlers/api-get/milestoneICS.js @@ -1,7 +1,7 @@ /* eslint-disable unicorn/filename-case, @eslint-community/eslint-comments/disable-enable-pair */ import ical, { ICalEventStatus } from 'ical-generator'; import getWorkOrderMilestones from '../../database/getWorkOrderMilestones.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; import { getPrintConfig } from '../../helpers/functions.print.js'; const calendarCompany = 'cityssm.github.io'; const calendarProduct = getConfigProperty('application.applicationName'); diff --git a/handlers/api-get/milestoneICS.ts b/handlers/api-get/milestoneICS.ts index 9ab4d492..69ec8f2a 100644 --- a/handlers/api-get/milestoneICS.ts +++ b/handlers/api-get/milestoneICS.ts @@ -6,7 +6,7 @@ import ical, { type ICalEventData, ICalEventStatus } from 'ical-generator' import getWorkOrderMilestones, { type WorkOrderMilestoneFilters } from '../../database/getWorkOrderMilestones.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' import { getPrintConfig } from '../../helpers/functions.print.js' import type { WorkOrderMilestone } from '../../types/recordTypes.js' diff --git a/handlers/lotOccupancies-get/edit.d.ts b/handlers/burialSites-get/edit.d.ts similarity index 100% rename from handlers/lotOccupancies-get/edit.d.ts rename to handlers/burialSites-get/edit.d.ts diff --git a/handlers/lots-get/edit.js b/handlers/burialSites-get/edit.js similarity index 91% rename from handlers/lots-get/edit.js rename to handlers/burialSites-get/edit.js index 4238823f..3c2b4949 100644 --- a/handlers/lots-get/edit.js +++ b/handlers/burialSites-get/edit.js @@ -1,7 +1,7 @@ import getLot from '../../database/getLot.js'; import getMaps from '../../database/getMaps.js'; import { getLotStatuses, getLotTypes } from '../../helpers/functions.cache.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; export default async function handler(request, response) { const lot = await getLot(request.params.lotId); if (lot === undefined) { diff --git a/handlers/lots-get/edit.ts b/handlers/burialSites-get/edit.ts similarity index 91% rename from handlers/lots-get/edit.ts rename to handlers/burialSites-get/edit.ts index 18ef8d5a..faedae2d 100644 --- a/handlers/lots-get/edit.ts +++ b/handlers/burialSites-get/edit.ts @@ -3,7 +3,7 @@ import type { Request, Response } from 'express' import getLot from '../../database/getLot.js' import getMaps from '../../database/getMaps.js' import { getLotStatuses, getLotTypes } from '../../helpers/functions.cache.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' export default async function handler( request: Request, diff --git a/handlers/lotOccupancies-get/new.d.ts b/handlers/burialSites-get/new.d.ts similarity index 100% rename from handlers/lotOccupancies-get/new.d.ts rename to handlers/burialSites-get/new.d.ts diff --git a/handlers/lots-get/new.js b/handlers/burialSites-get/new.js similarity index 92% rename from handlers/lots-get/new.js rename to handlers/burialSites-get/new.js index 37ae6159..99c88404 100644 --- a/handlers/lots-get/new.js +++ b/handlers/burialSites-get/new.js @@ -1,6 +1,6 @@ import getMaps from '../../database/getMaps.js'; import { getLotStatuses, getLotTypes } from '../../helpers/functions.cache.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; export default async function handler(request, response) { const lot = { lotId: -1, diff --git a/handlers/lots-get/new.ts b/handlers/burialSites-get/new.ts similarity index 93% rename from handlers/lots-get/new.ts rename to handlers/burialSites-get/new.ts index c3f50a14..f9fbb7ac 100644 --- a/handlers/lots-get/new.ts +++ b/handlers/burialSites-get/new.ts @@ -2,7 +2,7 @@ import type { Request, Response } from 'express' import getMaps from '../../database/getMaps.js' import { getLotStatuses, getLotTypes } from '../../helpers/functions.cache.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' import type { Lot } from '../../types/recordTypes.js' export default async function handler( diff --git a/handlers/lots-get/next.d.ts b/handlers/burialSites-get/next.d.ts similarity index 100% rename from handlers/lots-get/next.d.ts rename to handlers/burialSites-get/next.d.ts diff --git a/handlers/lots-get/next.js b/handlers/burialSites-get/next.js similarity index 87% rename from handlers/lots-get/next.js rename to handlers/burialSites-get/next.js index 821aec81..805d3774 100644 --- a/handlers/lots-get/next.js +++ b/handlers/burialSites-get/next.js @@ -1,4 +1,4 @@ -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; import { getNextLotId } from '../../helpers/functions.lots.js'; export default async function handler(request, response) { const lotId = Number.parseInt(request.params.lotId, 10); diff --git a/handlers/lots-get/next.ts b/handlers/burialSites-get/next.ts similarity index 89% rename from handlers/lots-get/next.ts rename to handlers/burialSites-get/next.ts index 555c8f25..56ec09c7 100644 --- a/handlers/lots-get/next.ts +++ b/handlers/burialSites-get/next.ts @@ -1,6 +1,6 @@ import type { Request, Response } from 'express' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' import { getNextLotId } from '../../helpers/functions.lots.js' export default async function handler( diff --git a/handlers/lots-get/previous.d.ts b/handlers/burialSites-get/previous.d.ts similarity index 100% rename from handlers/lots-get/previous.d.ts rename to handlers/burialSites-get/previous.d.ts diff --git a/handlers/lots-get/previous.js b/handlers/burialSites-get/previous.js similarity index 88% rename from handlers/lots-get/previous.js rename to handlers/burialSites-get/previous.js index 01b95241..fa956542 100644 --- a/handlers/lots-get/previous.js +++ b/handlers/burialSites-get/previous.js @@ -1,4 +1,4 @@ -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; import { getPreviousLotId } from '../../helpers/functions.lots.js'; export default async function handler(request, response) { const lotId = Number.parseInt(request.params.lotId, 10); diff --git a/handlers/lots-get/previous.ts b/handlers/burialSites-get/previous.ts similarity index 90% rename from handlers/lots-get/previous.ts rename to handlers/burialSites-get/previous.ts index 79cd0f47..572e2aa1 100644 --- a/handlers/lots-get/previous.ts +++ b/handlers/burialSites-get/previous.ts @@ -1,6 +1,6 @@ import type { Request, Response } from 'express' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' import { getPreviousLotId } from '../../helpers/functions.lots.js' export default async function handler( diff --git a/handlers/lotOccupancies-get/search.d.ts b/handlers/burialSites-get/search.d.ts similarity index 100% rename from handlers/lotOccupancies-get/search.d.ts rename to handlers/burialSites-get/search.d.ts diff --git a/handlers/lots-get/search.js b/handlers/burialSites-get/search.js similarity index 89% rename from handlers/lots-get/search.js rename to handlers/burialSites-get/search.js index 570ddfb7..f590ccc6 100644 --- a/handlers/lots-get/search.js +++ b/handlers/burialSites-get/search.js @@ -1,6 +1,6 @@ import getMaps from '../../database/getMaps.js'; import { getLotStatuses, getLotTypes } from '../../helpers/functions.cache.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; export default async function handler(request, response) { const maps = await getMaps(); const lotTypes = await getLotTypes(); diff --git a/handlers/lots-get/search.ts b/handlers/burialSites-get/search.ts similarity index 90% rename from handlers/lots-get/search.ts rename to handlers/burialSites-get/search.ts index 0695f7b0..5d023aed 100644 --- a/handlers/lots-get/search.ts +++ b/handlers/burialSites-get/search.ts @@ -2,7 +2,7 @@ import type { Request, Response } from 'express' import getMaps from '../../database/getMaps.js' import { getLotStatuses, getLotTypes } from '../../helpers/functions.cache.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' export default async function handler( request: Request, diff --git a/handlers/lotOccupancies-get/view.d.ts b/handlers/burialSites-get/view.d.ts similarity index 100% rename from handlers/lotOccupancies-get/view.d.ts rename to handlers/burialSites-get/view.d.ts diff --git a/handlers/lots-get/view.js b/handlers/burialSites-get/view.js similarity index 89% rename from handlers/lots-get/view.js rename to handlers/burialSites-get/view.js index 9b3f2f3b..f11ecd5f 100644 --- a/handlers/lots-get/view.js +++ b/handlers/burialSites-get/view.js @@ -1,5 +1,5 @@ import getLot from '../../database/getLot.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; import { getNextLotId, getPreviousLotId } from '../../helpers/functions.lots.js'; export default async function handler(request, response) { const lot = await getLot(request.params.lotId); diff --git a/handlers/lots-get/view.ts b/handlers/burialSites-get/view.ts similarity index 90% rename from handlers/lots-get/view.ts rename to handlers/burialSites-get/view.ts index a5d9d197..b89517ca 100644 --- a/handlers/lots-get/view.ts +++ b/handlers/burialSites-get/view.ts @@ -1,7 +1,7 @@ import type { Request, Response } from 'express' import getLot from '../../database/getLot.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' import { getNextLotId, getPreviousLotId } from '../../helpers/functions.lots.js' export default async function handler( diff --git a/handlers/lotOccupancies-post/doAddLotOccupancyComment.d.ts b/handlers/burialSites-post/doAddLotComment.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doAddLotOccupancyComment.d.ts rename to handlers/burialSites-post/doAddLotComment.d.ts diff --git a/handlers/burialSites-post/doAddLotComment.js b/handlers/burialSites-post/doAddLotComment.js new file mode 100644 index 00000000..4bcec715 --- /dev/null +++ b/handlers/burialSites-post/doAddLotComment.js @@ -0,0 +1,10 @@ +import addLotComment from '../../database/addLotComment.js'; +import getLotComments from '../../database/getLotComments.js'; +export default async function handler(request, response) { + await addLotComment(request.body, request.session.user); + const lotComments = await getLotComments(request.body.lotId); + response.json({ + success: true, + lotComments + }); +} diff --git a/handlers/lots-post/doAddLotComment.ts b/handlers/burialSites-post/doAddLotComment.ts similarity index 100% rename from handlers/lots-post/doAddLotComment.ts rename to handlers/burialSites-post/doAddLotComment.ts diff --git a/handlers/lotOccupancies-post/doAddLotOccupancyFee.d.ts b/handlers/burialSites-post/doCreateLot.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doAddLotOccupancyFee.d.ts rename to handlers/burialSites-post/doCreateLot.d.ts diff --git a/handlers/burialSites-post/doCreateLot.js b/handlers/burialSites-post/doCreateLot.js new file mode 100644 index 00000000..2737f657 --- /dev/null +++ b/handlers/burialSites-post/doCreateLot.js @@ -0,0 +1,12 @@ +import addLot from '../../database/addLot.js'; +import { clearNextPreviousLotIdCache } from '../../helpers/functions.lots.js'; +export default async function handler(request, response) { + const lotId = await addLot(request.body, request.session.user); + response.json({ + success: true, + lotId + }); + response.on('finish', () => { + clearNextPreviousLotIdCache(-1); + }); +} diff --git a/handlers/lots-post/doCreateLot.ts b/handlers/burialSites-post/doCreateLot.ts similarity index 100% rename from handlers/lots-post/doCreateLot.ts rename to handlers/burialSites-post/doCreateLot.ts diff --git a/handlers/lotOccupancies-post/doAddLotOccupancyFeeCategory.d.ts b/handlers/burialSites-post/doDeleteLot.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doAddLotOccupancyFeeCategory.d.ts rename to handlers/burialSites-post/doDeleteLot.d.ts diff --git a/handlers/burialSites-post/doDeleteLot.js b/handlers/burialSites-post/doDeleteLot.js new file mode 100644 index 00000000..f0d87eee --- /dev/null +++ b/handlers/burialSites-post/doDeleteLot.js @@ -0,0 +1,12 @@ +import { clearNextPreviousLotIdCache } from '../../helpers/functions.lots.js'; +import { deleteRecord } from '../../database/deleteRecord.js'; +export default async function handler(request, response) { + const lotId = Number.parseInt(request.body.lotId, 10); + const success = await deleteRecord('Lots', lotId, request.session.user); + response.json({ + success + }); + response.on('finish', () => { + clearNextPreviousLotIdCache(lotId); + }); +} diff --git a/handlers/lots-post/doDeleteLot.ts b/handlers/burialSites-post/doDeleteLot.ts similarity index 100% rename from handlers/lots-post/doDeleteLot.ts rename to handlers/burialSites-post/doDeleteLot.ts diff --git a/handlers/lotOccupancies-post/doAddLotOccupancyOccupant.d.ts b/handlers/burialSites-post/doDeleteLotComment.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doAddLotOccupancyOccupant.d.ts rename to handlers/burialSites-post/doDeleteLotComment.d.ts diff --git a/handlers/burialSites-post/doDeleteLotComment.js b/handlers/burialSites-post/doDeleteLotComment.js new file mode 100644 index 00000000..69b8e818 --- /dev/null +++ b/handlers/burialSites-post/doDeleteLotComment.js @@ -0,0 +1,10 @@ +import { deleteRecord } from '../../database/deleteRecord.js'; +import getLotComments from '../../database/getLotComments.js'; +export default async function handler(request, response) { + const success = await deleteRecord('LotComments', request.body.lotCommentId, request.session.user); + const lotComments = await getLotComments(request.body.lotId); + response.json({ + success, + lotComments + }); +} diff --git a/handlers/lots-post/doDeleteLotComment.ts b/handlers/burialSites-post/doDeleteLotComment.ts similarity index 100% rename from handlers/lots-post/doDeleteLotComment.ts rename to handlers/burialSites-post/doDeleteLotComment.ts diff --git a/handlers/lots-post/doGetLotTypeFields.d.ts b/handlers/burialSites-post/doGetLotTypeFields.d.ts similarity index 100% rename from handlers/lots-post/doGetLotTypeFields.d.ts rename to handlers/burialSites-post/doGetLotTypeFields.d.ts diff --git a/handlers/lots-post/doGetLotTypeFields.js b/handlers/burialSites-post/doGetLotTypeFields.js similarity index 100% rename from handlers/lots-post/doGetLotTypeFields.js rename to handlers/burialSites-post/doGetLotTypeFields.js diff --git a/handlers/lots-post/doGetLotTypeFields.ts b/handlers/burialSites-post/doGetLotTypeFields.ts similarity index 100% rename from handlers/lots-post/doGetLotTypeFields.ts rename to handlers/burialSites-post/doGetLotTypeFields.ts diff --git a/handlers/lots-post/doSearchLots.d.ts b/handlers/burialSites-post/doSearchLots.d.ts similarity index 100% rename from handlers/lots-post/doSearchLots.d.ts rename to handlers/burialSites-post/doSearchLots.d.ts diff --git a/handlers/lots-post/doSearchLots.js b/handlers/burialSites-post/doSearchLots.js similarity index 100% rename from handlers/lots-post/doSearchLots.js rename to handlers/burialSites-post/doSearchLots.js diff --git a/handlers/lots-post/doSearchLots.ts b/handlers/burialSites-post/doSearchLots.ts similarity index 100% rename from handlers/lots-post/doSearchLots.ts rename to handlers/burialSites-post/doSearchLots.ts diff --git a/handlers/lotOccupancies-post/doAddLotOccupancyTransaction.d.ts b/handlers/burialSites-post/doUpdateLot.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doAddLotOccupancyTransaction.d.ts rename to handlers/burialSites-post/doUpdateLot.d.ts diff --git a/handlers/lots-post/doUpdateLot.js b/handlers/burialSites-post/doUpdateLot.js similarity index 100% rename from handlers/lots-post/doUpdateLot.js rename to handlers/burialSites-post/doUpdateLot.js diff --git a/handlers/lots-post/doUpdateLot.ts b/handlers/burialSites-post/doUpdateLot.ts similarity index 100% rename from handlers/lots-post/doUpdateLot.ts rename to handlers/burialSites-post/doUpdateLot.ts diff --git a/handlers/lots-post/doUpdateLotComment.d.ts b/handlers/burialSites-post/doUpdateLotComment.d.ts similarity index 100% rename from handlers/lots-post/doUpdateLotComment.d.ts rename to handlers/burialSites-post/doUpdateLotComment.d.ts diff --git a/handlers/lots-post/doUpdateLotComment.js b/handlers/burialSites-post/doUpdateLotComment.js similarity index 100% rename from handlers/lots-post/doUpdateLotComment.js rename to handlers/burialSites-post/doUpdateLotComment.js diff --git a/handlers/lots-post/doUpdateLotComment.ts b/handlers/burialSites-post/doUpdateLotComment.ts similarity index 100% rename from handlers/lots-post/doUpdateLotComment.ts rename to handlers/burialSites-post/doUpdateLotComment.ts diff --git a/handlers/lots-get/edit.d.ts b/handlers/cemeteries-get/edit.d.ts similarity index 100% rename from handlers/lots-get/edit.d.ts rename to handlers/cemeteries-get/edit.d.ts diff --git a/handlers/maps-get/edit.js b/handlers/cemeteries-get/edit.js similarity index 92% rename from handlers/maps-get/edit.js rename to handlers/cemeteries-get/edit.js index d5d5ecfc..1862c0ed 100644 --- a/handlers/maps-get/edit.js +++ b/handlers/cemeteries-get/edit.js @@ -1,7 +1,7 @@ import getLotStatusSummary from '../../database/getLotStatusSummary.js'; import getLotTypeSummary from '../../database/getLotTypeSummary.js'; import getMap from '../../database/getMap.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; import { getMapSVGs } from '../../helpers/functions.map.js'; export default async function handler(request, response) { const map = await getMap(request.params.mapId); diff --git a/handlers/maps-get/edit.ts b/handlers/cemeteries-get/edit.ts similarity index 93% rename from handlers/maps-get/edit.ts rename to handlers/cemeteries-get/edit.ts index 7997b9a0..7f8f7a81 100644 --- a/handlers/maps-get/edit.ts +++ b/handlers/cemeteries-get/edit.ts @@ -3,7 +3,7 @@ import type { Request, Response } from 'express' import getLotStatusSummary from '../../database/getLotStatusSummary.js' import getLotTypeSummary from '../../database/getLotTypeSummary.js' import getMap from '../../database/getMap.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' import { getMapSVGs } from '../../helpers/functions.map.js' export default async function handler( diff --git a/handlers/maps-get/new.d.ts b/handlers/cemeteries-get/new.d.ts similarity index 100% rename from handlers/maps-get/new.d.ts rename to handlers/cemeteries-get/new.d.ts diff --git a/handlers/maps-get/new.js b/handlers/cemeteries-get/new.js similarity index 87% rename from handlers/maps-get/new.js rename to handlers/cemeteries-get/new.js index eb3d7ea3..ff091619 100644 --- a/handlers/maps-get/new.js +++ b/handlers/cemeteries-get/new.js @@ -1,4 +1,4 @@ -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; import { getMapSVGs } from '../../helpers/functions.map.js'; export default async function handler(_request, response) { const map = { diff --git a/handlers/maps-get/new.ts b/handlers/cemeteries-get/new.ts similarity index 89% rename from handlers/maps-get/new.ts rename to handlers/cemeteries-get/new.ts index 691fa3a9..6930f9d3 100644 --- a/handlers/maps-get/new.ts +++ b/handlers/cemeteries-get/new.ts @@ -1,6 +1,6 @@ import type { Request, Response } from 'express' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' import { getMapSVGs } from '../../helpers/functions.map.js' import type { MapRecord } from '../../types/recordTypes.js' diff --git a/handlers/maps-get/next.d.ts b/handlers/cemeteries-get/next.d.ts similarity index 100% rename from handlers/maps-get/next.d.ts rename to handlers/cemeteries-get/next.d.ts diff --git a/handlers/maps-get/next.js b/handlers/cemeteries-get/next.js similarity index 87% rename from handlers/maps-get/next.js rename to handlers/cemeteries-get/next.js index ddccde04..1fe5922c 100644 --- a/handlers/maps-get/next.js +++ b/handlers/cemeteries-get/next.js @@ -1,5 +1,5 @@ import getNextMapId from '../../database/getNextMapId.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; export default async function handler(request, response) { const mapId = Number.parseInt(request.params.mapId, 10); const nextMapId = await getNextMapId(mapId); diff --git a/handlers/maps-get/next.ts b/handlers/cemeteries-get/next.ts similarity index 89% rename from handlers/maps-get/next.ts rename to handlers/cemeteries-get/next.ts index fc059e0f..3e12d9be 100644 --- a/handlers/maps-get/next.ts +++ b/handlers/cemeteries-get/next.ts @@ -1,7 +1,7 @@ import type { Request, Response } from 'express' import getNextMapId from '../../database/getNextMapId.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' export default async function handler( request: Request, diff --git a/handlers/maps-get/previous.d.ts b/handlers/cemeteries-get/previous.d.ts similarity index 100% rename from handlers/maps-get/previous.d.ts rename to handlers/cemeteries-get/previous.d.ts diff --git a/handlers/maps-get/previous.js b/handlers/cemeteries-get/previous.js similarity index 88% rename from handlers/maps-get/previous.js rename to handlers/cemeteries-get/previous.js index da0f7988..4037474f 100644 --- a/handlers/maps-get/previous.js +++ b/handlers/cemeteries-get/previous.js @@ -1,5 +1,5 @@ import getPreviousMapId from '../../database/getPreviousMapId.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; export default async function handler(request, response) { const mapId = Number.parseInt(request.params.mapId, 10); const previousMapId = await getPreviousMapId(mapId); diff --git a/handlers/maps-get/previous.ts b/handlers/cemeteries-get/previous.ts similarity index 90% rename from handlers/maps-get/previous.ts rename to handlers/cemeteries-get/previous.ts index d40f3854..ffa9de55 100644 --- a/handlers/maps-get/previous.ts +++ b/handlers/cemeteries-get/previous.ts @@ -1,7 +1,7 @@ import type { Request, Response } from 'express' import getPreviousMapId from '../../database/getPreviousMapId.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' export default async function handler( request: Request, diff --git a/handlers/maps-get/search.d.ts b/handlers/cemeteries-get/search.d.ts similarity index 100% rename from handlers/maps-get/search.d.ts rename to handlers/cemeteries-get/search.d.ts diff --git a/handlers/maps-get/search.js b/handlers/cemeteries-get/search.js similarity index 78% rename from handlers/maps-get/search.js rename to handlers/cemeteries-get/search.js index cda635f0..a1793296 100644 --- a/handlers/maps-get/search.js +++ b/handlers/cemeteries-get/search.js @@ -1,5 +1,5 @@ import getMaps from '../../database/getMaps.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; export default async function handler(_request, response) { const maps = await getMaps(); response.render('map-search', { diff --git a/handlers/maps-get/search.ts b/handlers/cemeteries-get/search.ts similarity index 83% rename from handlers/maps-get/search.ts rename to handlers/cemeteries-get/search.ts index f54a4614..60e3566a 100644 --- a/handlers/maps-get/search.ts +++ b/handlers/cemeteries-get/search.ts @@ -1,7 +1,7 @@ import type { Request, Response } from 'express' import getMaps from '../../database/getMaps.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' export default async function handler( _request: Request, diff --git a/handlers/lots-get/view.d.ts b/handlers/cemeteries-get/view.d.ts similarity index 100% rename from handlers/lots-get/view.d.ts rename to handlers/cemeteries-get/view.d.ts diff --git a/handlers/maps-get/view.js b/handlers/cemeteries-get/view.js similarity index 91% rename from handlers/maps-get/view.js rename to handlers/cemeteries-get/view.js index 6c193ec6..2c2d7539 100644 --- a/handlers/maps-get/view.js +++ b/handlers/cemeteries-get/view.js @@ -1,7 +1,7 @@ import getLotStatusSummary from '../../database/getLotStatusSummary.js'; import getLotTypeSummary from '../../database/getLotTypeSummary.js'; import getMap from '../../database/getMap.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; export default async function handler(request, response) { const map = await getMap(request.params.mapId); if (map === undefined) { diff --git a/handlers/maps-get/view.ts b/handlers/cemeteries-get/view.ts similarity index 92% rename from handlers/maps-get/view.ts rename to handlers/cemeteries-get/view.ts index 155ee2d9..b44653e6 100644 --- a/handlers/maps-get/view.ts +++ b/handlers/cemeteries-get/view.ts @@ -3,7 +3,7 @@ import type { Request, Response } from 'express' import getLotStatusSummary from '../../database/getLotStatusSummary.js' import getLotTypeSummary from '../../database/getLotTypeSummary.js' import getMap from '../../database/getMap.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' export default async function handler( request: Request, diff --git a/handlers/lotOccupancies-post/doCopyLotOccupancy.d.ts b/handlers/cemeteries-post/doCreateCemetery.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doCopyLotOccupancy.d.ts rename to handlers/cemeteries-post/doCreateCemetery.d.ts diff --git a/handlers/maps-post/doCreateMap.js b/handlers/cemeteries-post/doCreateCemetery.js similarity index 100% rename from handlers/maps-post/doCreateMap.js rename to handlers/cemeteries-post/doCreateCemetery.js diff --git a/handlers/maps-post/doCreateMap.ts b/handlers/cemeteries-post/doCreateCemetery.ts similarity index 100% rename from handlers/maps-post/doCreateMap.ts rename to handlers/cemeteries-post/doCreateCemetery.ts diff --git a/handlers/lotOccupancies-post/doCreateLotOccupancy.d.ts b/handlers/cemeteries-post/doDeleteCemetery.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doCreateLotOccupancy.d.ts rename to handlers/cemeteries-post/doDeleteCemetery.d.ts diff --git a/handlers/maps-post/doDeleteMap.js b/handlers/cemeteries-post/doDeleteCemetery.js similarity index 100% rename from handlers/maps-post/doDeleteMap.js rename to handlers/cemeteries-post/doDeleteCemetery.js diff --git a/handlers/maps-post/doDeleteMap.ts b/handlers/cemeteries-post/doDeleteCemetery.ts similarity index 100% rename from handlers/maps-post/doDeleteMap.ts rename to handlers/cemeteries-post/doDeleteCemetery.ts diff --git a/handlers/maps-post/doUpdateMap.d.ts b/handlers/cemeteries-post/doUpdateMap.d.ts similarity index 100% rename from handlers/maps-post/doUpdateMap.d.ts rename to handlers/cemeteries-post/doUpdateMap.d.ts diff --git a/handlers/maps-post/doUpdateMap.js b/handlers/cemeteries-post/doUpdateMap.js similarity index 100% rename from handlers/maps-post/doUpdateMap.js rename to handlers/cemeteries-post/doUpdateMap.js diff --git a/handlers/maps-post/doUpdateMap.ts b/handlers/cemeteries-post/doUpdateMap.ts similarity index 100% rename from handlers/maps-post/doUpdateMap.ts rename to handlers/cemeteries-post/doUpdateMap.ts diff --git a/handlers/maps-get/edit.d.ts b/handlers/contracts-get/edit.d.ts similarity index 100% rename from handlers/maps-get/edit.d.ts rename to handlers/contracts-get/edit.d.ts diff --git a/handlers/lotOccupancies-get/edit.js b/handlers/contracts-get/edit.js similarity index 94% rename from handlers/lotOccupancies-get/edit.js rename to handlers/contracts-get/edit.js index aa5ab17e..bee627d0 100644 --- a/handlers/lotOccupancies-get/edit.js +++ b/handlers/contracts-get/edit.js @@ -1,7 +1,7 @@ import getLotOccupancy from '../../database/getLotOccupancy.js'; import getMaps from '../../database/getMaps.js'; import { getLotOccupantTypes, getLotStatuses, getLotTypes, getOccupancyTypePrintsById, getOccupancyTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; export default async function handler(request, response) { const lotOccupancy = await getLotOccupancy(request.params.lotOccupancyId); if (lotOccupancy === undefined) { diff --git a/handlers/lotOccupancies-get/edit.ts b/handlers/contracts-get/edit.ts similarity index 95% rename from handlers/lotOccupancies-get/edit.ts rename to handlers/contracts-get/edit.ts index a0a24ccf..5b8830fc 100644 --- a/handlers/lotOccupancies-get/edit.ts +++ b/handlers/contracts-get/edit.ts @@ -10,7 +10,7 @@ import { getOccupancyTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' export default async function handler( request: Request, diff --git a/handlers/lots-get/new.d.ts b/handlers/contracts-get/new.d.ts similarity index 100% rename from handlers/lots-get/new.d.ts rename to handlers/contracts-get/new.d.ts diff --git a/handlers/lotOccupancies-get/new.js b/handlers/contracts-get/new.js similarity index 95% rename from handlers/lotOccupancies-get/new.js rename to handlers/contracts-get/new.js index 08f9cd1f..8f22d07a 100644 --- a/handlers/lotOccupancies-get/new.js +++ b/handlers/contracts-get/new.js @@ -2,7 +2,7 @@ import { dateToInteger, dateToString } from '@cityssm/utils-datetime'; import getLot from '../../database/getLot.js'; import getMaps from '../../database/getMaps.js'; import { getLotOccupantTypes, getLotStatuses, getLotTypes, getOccupancyTypes } from '../../helpers/functions.cache.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; export default async function handler(request, response) { const startDate = new Date(); const lotOccupancy = { diff --git a/handlers/lotOccupancies-get/new.ts b/handlers/contracts-get/new.ts similarity index 95% rename from handlers/lotOccupancies-get/new.ts rename to handlers/contracts-get/new.ts index bdfdc7b8..aa672696 100644 --- a/handlers/lotOccupancies-get/new.ts +++ b/handlers/contracts-get/new.ts @@ -9,7 +9,7 @@ import { getLotTypes, getOccupancyTypes } from '../../helpers/functions.cache.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' import type { LotOccupancy } from '../../types/recordTypes.js' export default async function handler( diff --git a/handlers/lots-get/search.d.ts b/handlers/contracts-get/search.d.ts similarity index 100% rename from handlers/lots-get/search.d.ts rename to handlers/contracts-get/search.d.ts diff --git a/handlers/lotOccupancies-get/search.js b/handlers/contracts-get/search.js similarity index 88% rename from handlers/lotOccupancies-get/search.js rename to handlers/contracts-get/search.js index 00a7f6b4..09a0732d 100644 --- a/handlers/lotOccupancies-get/search.js +++ b/handlers/contracts-get/search.js @@ -1,6 +1,6 @@ import getMaps from '../../database/getMaps.js'; import { getLotTypes, getOccupancyTypes } from '../../helpers/functions.cache.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; export default async function handler(request, response) { const maps = await getMaps(); const lotTypes = await getLotTypes(); diff --git a/handlers/lotOccupancies-get/search.ts b/handlers/contracts-get/search.ts similarity index 89% rename from handlers/lotOccupancies-get/search.ts rename to handlers/contracts-get/search.ts index cde30194..b259434b 100644 --- a/handlers/lotOccupancies-get/search.ts +++ b/handlers/contracts-get/search.ts @@ -5,7 +5,7 @@ import { getLotTypes, getOccupancyTypes } from '../../helpers/functions.cache.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' export default async function handler( request: Request, diff --git a/handlers/maps-get/view.d.ts b/handlers/contracts-get/view.d.ts similarity index 100% rename from handlers/maps-get/view.d.ts rename to handlers/contracts-get/view.d.ts diff --git a/handlers/lotOccupancies-get/view.js b/handlers/contracts-get/view.js similarity index 91% rename from handlers/lotOccupancies-get/view.js rename to handlers/contracts-get/view.js index 252510fb..7a6dd4d4 100644 --- a/handlers/lotOccupancies-get/view.js +++ b/handlers/contracts-get/view.js @@ -1,6 +1,6 @@ import getLotOccupancy from '../../database/getLotOccupancy.js'; import { getOccupancyTypePrintsById } from '../../helpers/functions.cache.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; export default async function handler(request, response) { const lotOccupancy = await getLotOccupancy(request.params.lotOccupancyId); if (lotOccupancy === undefined) { diff --git a/handlers/lotOccupancies-get/view.ts b/handlers/contracts-get/view.ts similarity index 92% rename from handlers/lotOccupancies-get/view.ts rename to handlers/contracts-get/view.ts index 4686072e..5c8fe6b2 100644 --- a/handlers/lotOccupancies-get/view.ts +++ b/handlers/contracts-get/view.ts @@ -2,7 +2,7 @@ import type { Request, Response } from 'express' import getLotOccupancy from '../../database/getLotOccupancy.js' import { getOccupancyTypePrintsById } from '../../helpers/functions.cache.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' export default async function handler( request: Request, diff --git a/handlers/lotOccupancies-post/doDeleteLotOccupancy.d.ts b/handlers/contracts-post/doAddLotOccupancyComment.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doDeleteLotOccupancy.d.ts rename to handlers/contracts-post/doAddLotOccupancyComment.d.ts diff --git a/handlers/lotOccupancies-post/doAddLotOccupancyComment.js b/handlers/contracts-post/doAddLotOccupancyComment.js similarity index 100% rename from handlers/lotOccupancies-post/doAddLotOccupancyComment.js rename to handlers/contracts-post/doAddLotOccupancyComment.js diff --git a/handlers/lotOccupancies-post/doAddLotOccupancyComment.ts b/handlers/contracts-post/doAddLotOccupancyComment.ts similarity index 100% rename from handlers/lotOccupancies-post/doAddLotOccupancyComment.ts rename to handlers/contracts-post/doAddLotOccupancyComment.ts diff --git a/handlers/lotOccupancies-post/doDeleteLotOccupancyComment.d.ts b/handlers/contracts-post/doAddLotOccupancyFee.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doDeleteLotOccupancyComment.d.ts rename to handlers/contracts-post/doAddLotOccupancyFee.d.ts diff --git a/handlers/lotOccupancies-post/doAddLotOccupancyFee.js b/handlers/contracts-post/doAddLotOccupancyFee.js similarity index 100% rename from handlers/lotOccupancies-post/doAddLotOccupancyFee.js rename to handlers/contracts-post/doAddLotOccupancyFee.js diff --git a/handlers/lotOccupancies-post/doAddLotOccupancyFee.ts b/handlers/contracts-post/doAddLotOccupancyFee.ts similarity index 100% rename from handlers/lotOccupancies-post/doAddLotOccupancyFee.ts rename to handlers/contracts-post/doAddLotOccupancyFee.ts diff --git a/handlers/lotOccupancies-post/doDeleteLotOccupancyFee.d.ts b/handlers/contracts-post/doAddLotOccupancyFeeCategory.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doDeleteLotOccupancyFee.d.ts rename to handlers/contracts-post/doAddLotOccupancyFeeCategory.d.ts diff --git a/handlers/lotOccupancies-post/doAddLotOccupancyFeeCategory.js b/handlers/contracts-post/doAddLotOccupancyFeeCategory.js similarity index 100% rename from handlers/lotOccupancies-post/doAddLotOccupancyFeeCategory.js rename to handlers/contracts-post/doAddLotOccupancyFeeCategory.js diff --git a/handlers/lotOccupancies-post/doAddLotOccupancyFeeCategory.ts b/handlers/contracts-post/doAddLotOccupancyFeeCategory.ts similarity index 100% rename from handlers/lotOccupancies-post/doAddLotOccupancyFeeCategory.ts rename to handlers/contracts-post/doAddLotOccupancyFeeCategory.ts diff --git a/handlers/lotOccupancies-post/doDeleteLotOccupancyOccupant.d.ts b/handlers/contracts-post/doAddLotOccupancyOccupant.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doDeleteLotOccupancyOccupant.d.ts rename to handlers/contracts-post/doAddLotOccupancyOccupant.d.ts diff --git a/handlers/lotOccupancies-post/doAddLotOccupancyOccupant.js b/handlers/contracts-post/doAddLotOccupancyOccupant.js similarity index 100% rename from handlers/lotOccupancies-post/doAddLotOccupancyOccupant.js rename to handlers/contracts-post/doAddLotOccupancyOccupant.js diff --git a/handlers/lotOccupancies-post/doAddLotOccupancyOccupant.ts b/handlers/contracts-post/doAddLotOccupancyOccupant.ts similarity index 100% rename from handlers/lotOccupancies-post/doAddLotOccupancyOccupant.ts rename to handlers/contracts-post/doAddLotOccupancyOccupant.ts diff --git a/handlers/lotOccupancies-post/doDeleteLotOccupancyTransaction.d.ts b/handlers/contracts-post/doAddLotOccupancyTransaction.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doDeleteLotOccupancyTransaction.d.ts rename to handlers/contracts-post/doAddLotOccupancyTransaction.d.ts diff --git a/handlers/lotOccupancies-post/doAddLotOccupancyTransaction.js b/handlers/contracts-post/doAddLotOccupancyTransaction.js similarity index 100% rename from handlers/lotOccupancies-post/doAddLotOccupancyTransaction.js rename to handlers/contracts-post/doAddLotOccupancyTransaction.js diff --git a/handlers/lotOccupancies-post/doAddLotOccupancyTransaction.ts b/handlers/contracts-post/doAddLotOccupancyTransaction.ts similarity index 100% rename from handlers/lotOccupancies-post/doAddLotOccupancyTransaction.ts rename to handlers/contracts-post/doAddLotOccupancyTransaction.ts diff --git a/handlers/lotOccupancies-post/doGetDynamicsGPDocument.d.ts b/handlers/contracts-post/doCopyLotOccupancy.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doGetDynamicsGPDocument.d.ts rename to handlers/contracts-post/doCopyLotOccupancy.d.ts diff --git a/handlers/lotOccupancies-post/doCopyLotOccupancy.js b/handlers/contracts-post/doCopyLotOccupancy.js similarity index 100% rename from handlers/lotOccupancies-post/doCopyLotOccupancy.js rename to handlers/contracts-post/doCopyLotOccupancy.js diff --git a/handlers/lotOccupancies-post/doCopyLotOccupancy.ts b/handlers/contracts-post/doCopyLotOccupancy.ts similarity index 100% rename from handlers/lotOccupancies-post/doCopyLotOccupancy.ts rename to handlers/contracts-post/doCopyLotOccupancy.ts diff --git a/handlers/lotOccupancies-post/doGetFees.d.ts b/handlers/contracts-post/doCreateLotOccupancy.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doGetFees.d.ts rename to handlers/contracts-post/doCreateLotOccupancy.d.ts diff --git a/handlers/lotOccupancies-post/doCreateLotOccupancy.js b/handlers/contracts-post/doCreateLotOccupancy.js similarity index 100% rename from handlers/lotOccupancies-post/doCreateLotOccupancy.js rename to handlers/contracts-post/doCreateLotOccupancy.js diff --git a/handlers/lotOccupancies-post/doCreateLotOccupancy.ts b/handlers/contracts-post/doCreateLotOccupancy.ts similarity index 100% rename from handlers/lotOccupancies-post/doCreateLotOccupancy.ts rename to handlers/contracts-post/doCreateLotOccupancy.ts diff --git a/handlers/lotOccupancies-post/doGetOccupancyTypeFields.d.ts b/handlers/contracts-post/doDeleteLotOccupancy.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doGetOccupancyTypeFields.d.ts rename to handlers/contracts-post/doDeleteLotOccupancy.d.ts diff --git a/handlers/lotOccupancies-post/doDeleteLotOccupancy.js b/handlers/contracts-post/doDeleteLotOccupancy.js similarity index 100% rename from handlers/lotOccupancies-post/doDeleteLotOccupancy.js rename to handlers/contracts-post/doDeleteLotOccupancy.js diff --git a/handlers/lotOccupancies-post/doDeleteLotOccupancy.ts b/handlers/contracts-post/doDeleteLotOccupancy.ts similarity index 100% rename from handlers/lotOccupancies-post/doDeleteLotOccupancy.ts rename to handlers/contracts-post/doDeleteLotOccupancy.ts diff --git a/handlers/lotOccupancies-post/doSearchLotOccupancies.d.ts b/handlers/contracts-post/doDeleteLotOccupancyComment.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doSearchLotOccupancies.d.ts rename to handlers/contracts-post/doDeleteLotOccupancyComment.d.ts diff --git a/handlers/lotOccupancies-post/doDeleteLotOccupancyComment.js b/handlers/contracts-post/doDeleteLotOccupancyComment.js similarity index 100% rename from handlers/lotOccupancies-post/doDeleteLotOccupancyComment.js rename to handlers/contracts-post/doDeleteLotOccupancyComment.js diff --git a/handlers/lotOccupancies-post/doDeleteLotOccupancyComment.ts b/handlers/contracts-post/doDeleteLotOccupancyComment.ts similarity index 100% rename from handlers/lotOccupancies-post/doDeleteLotOccupancyComment.ts rename to handlers/contracts-post/doDeleteLotOccupancyComment.ts diff --git a/handlers/lotOccupancies-post/doSearchPastOccupants.d.ts b/handlers/contracts-post/doDeleteLotOccupancyFee.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doSearchPastOccupants.d.ts rename to handlers/contracts-post/doDeleteLotOccupancyFee.d.ts diff --git a/handlers/lotOccupancies-post/doDeleteLotOccupancyFee.js b/handlers/contracts-post/doDeleteLotOccupancyFee.js similarity index 100% rename from handlers/lotOccupancies-post/doDeleteLotOccupancyFee.js rename to handlers/contracts-post/doDeleteLotOccupancyFee.js diff --git a/handlers/lotOccupancies-post/doDeleteLotOccupancyFee.ts b/handlers/contracts-post/doDeleteLotOccupancyFee.ts similarity index 100% rename from handlers/lotOccupancies-post/doDeleteLotOccupancyFee.ts rename to handlers/contracts-post/doDeleteLotOccupancyFee.ts diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancy.d.ts b/handlers/contracts-post/doDeleteLotOccupancyOccupant.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doUpdateLotOccupancy.d.ts rename to handlers/contracts-post/doDeleteLotOccupancyOccupant.d.ts diff --git a/handlers/lotOccupancies-post/doDeleteLotOccupancyOccupant.js b/handlers/contracts-post/doDeleteLotOccupancyOccupant.js similarity index 100% rename from handlers/lotOccupancies-post/doDeleteLotOccupancyOccupant.js rename to handlers/contracts-post/doDeleteLotOccupancyOccupant.js diff --git a/handlers/lotOccupancies-post/doDeleteLotOccupancyOccupant.ts b/handlers/contracts-post/doDeleteLotOccupancyOccupant.ts similarity index 100% rename from handlers/lotOccupancies-post/doDeleteLotOccupancyOccupant.ts rename to handlers/contracts-post/doDeleteLotOccupancyOccupant.ts diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancyComment.d.ts b/handlers/contracts-post/doDeleteLotOccupancyTransaction.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doUpdateLotOccupancyComment.d.ts rename to handlers/contracts-post/doDeleteLotOccupancyTransaction.d.ts diff --git a/handlers/lotOccupancies-post/doDeleteLotOccupancyTransaction.js b/handlers/contracts-post/doDeleteLotOccupancyTransaction.js similarity index 100% rename from handlers/lotOccupancies-post/doDeleteLotOccupancyTransaction.js rename to handlers/contracts-post/doDeleteLotOccupancyTransaction.js diff --git a/handlers/lotOccupancies-post/doDeleteLotOccupancyTransaction.ts b/handlers/contracts-post/doDeleteLotOccupancyTransaction.ts similarity index 100% rename from handlers/lotOccupancies-post/doDeleteLotOccupancyTransaction.ts rename to handlers/contracts-post/doDeleteLotOccupancyTransaction.ts diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.d.ts b/handlers/contracts-post/doGetDynamicsGPDocument.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.d.ts rename to handlers/contracts-post/doGetDynamicsGPDocument.d.ts diff --git a/handlers/lotOccupancies-post/doGetDynamicsGPDocument.js b/handlers/contracts-post/doGetDynamicsGPDocument.js similarity index 100% rename from handlers/lotOccupancies-post/doGetDynamicsGPDocument.js rename to handlers/contracts-post/doGetDynamicsGPDocument.js diff --git a/handlers/lotOccupancies-post/doGetDynamicsGPDocument.ts b/handlers/contracts-post/doGetDynamicsGPDocument.ts similarity index 100% rename from handlers/lotOccupancies-post/doGetDynamicsGPDocument.ts rename to handlers/contracts-post/doGetDynamicsGPDocument.ts diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancyOccupant.d.ts b/handlers/contracts-post/doGetFees.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doUpdateLotOccupancyOccupant.d.ts rename to handlers/contracts-post/doGetFees.d.ts diff --git a/handlers/lotOccupancies-post/doGetFees.js b/handlers/contracts-post/doGetFees.js similarity index 100% rename from handlers/lotOccupancies-post/doGetFees.js rename to handlers/contracts-post/doGetFees.js diff --git a/handlers/lotOccupancies-post/doGetFees.ts b/handlers/contracts-post/doGetFees.ts similarity index 100% rename from handlers/lotOccupancies-post/doGetFees.ts rename to handlers/contracts-post/doGetFees.ts diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancyTransaction.d.ts b/handlers/contracts-post/doGetOccupancyTypeFields.d.ts similarity index 100% rename from handlers/lotOccupancies-post/doUpdateLotOccupancyTransaction.d.ts rename to handlers/contracts-post/doGetOccupancyTypeFields.d.ts diff --git a/handlers/lotOccupancies-post/doGetOccupancyTypeFields.js b/handlers/contracts-post/doGetOccupancyTypeFields.js similarity index 100% rename from handlers/lotOccupancies-post/doGetOccupancyTypeFields.js rename to handlers/contracts-post/doGetOccupancyTypeFields.js diff --git a/handlers/lotOccupancies-post/doGetOccupancyTypeFields.ts b/handlers/contracts-post/doGetOccupancyTypeFields.ts similarity index 100% rename from handlers/lotOccupancies-post/doGetOccupancyTypeFields.ts rename to handlers/contracts-post/doGetOccupancyTypeFields.ts diff --git a/handlers/maps-post/doCreateMap.d.ts b/handlers/contracts-post/doSearchLotOccupancies.d.ts similarity index 100% rename from handlers/maps-post/doCreateMap.d.ts rename to handlers/contracts-post/doSearchLotOccupancies.d.ts diff --git a/handlers/lotOccupancies-post/doSearchLotOccupancies.js b/handlers/contracts-post/doSearchLotOccupancies.js similarity index 100% rename from handlers/lotOccupancies-post/doSearchLotOccupancies.js rename to handlers/contracts-post/doSearchLotOccupancies.js diff --git a/handlers/lotOccupancies-post/doSearchLotOccupancies.ts b/handlers/contracts-post/doSearchLotOccupancies.ts similarity index 100% rename from handlers/lotOccupancies-post/doSearchLotOccupancies.ts rename to handlers/contracts-post/doSearchLotOccupancies.ts diff --git a/handlers/maps-post/doDeleteMap.d.ts b/handlers/contracts-post/doSearchPastOccupants.d.ts similarity index 100% rename from handlers/maps-post/doDeleteMap.d.ts rename to handlers/contracts-post/doSearchPastOccupants.d.ts diff --git a/handlers/lotOccupancies-post/doSearchPastOccupants.js b/handlers/contracts-post/doSearchPastOccupants.js similarity index 100% rename from handlers/lotOccupancies-post/doSearchPastOccupants.js rename to handlers/contracts-post/doSearchPastOccupants.js diff --git a/handlers/lotOccupancies-post/doSearchPastOccupants.ts b/handlers/contracts-post/doSearchPastOccupants.ts similarity index 100% rename from handlers/lotOccupancies-post/doSearchPastOccupants.ts rename to handlers/contracts-post/doSearchPastOccupants.ts diff --git a/handlers/contracts-post/doUpdateLotOccupancy.d.ts b/handlers/contracts-post/doUpdateLotOccupancy.d.ts new file mode 100644 index 00000000..19d32e4d --- /dev/null +++ b/handlers/contracts-post/doUpdateLotOccupancy.d.ts @@ -0,0 +1,2 @@ +import type { Request, Response } from 'express'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancy.js b/handlers/contracts-post/doUpdateLotOccupancy.js similarity index 100% rename from handlers/lotOccupancies-post/doUpdateLotOccupancy.js rename to handlers/contracts-post/doUpdateLotOccupancy.js diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancy.ts b/handlers/contracts-post/doUpdateLotOccupancy.ts similarity index 100% rename from handlers/lotOccupancies-post/doUpdateLotOccupancy.ts rename to handlers/contracts-post/doUpdateLotOccupancy.ts diff --git a/handlers/contracts-post/doUpdateLotOccupancyComment.d.ts b/handlers/contracts-post/doUpdateLotOccupancyComment.d.ts new file mode 100644 index 00000000..19d32e4d --- /dev/null +++ b/handlers/contracts-post/doUpdateLotOccupancyComment.d.ts @@ -0,0 +1,2 @@ +import type { Request, Response } from 'express'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancyComment.js b/handlers/contracts-post/doUpdateLotOccupancyComment.js similarity index 100% rename from handlers/lotOccupancies-post/doUpdateLotOccupancyComment.js rename to handlers/contracts-post/doUpdateLotOccupancyComment.js diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancyComment.ts b/handlers/contracts-post/doUpdateLotOccupancyComment.ts similarity index 100% rename from handlers/lotOccupancies-post/doUpdateLotOccupancyComment.ts rename to handlers/contracts-post/doUpdateLotOccupancyComment.ts diff --git a/handlers/contracts-post/doUpdateLotOccupancyFeeQuantity.d.ts b/handlers/contracts-post/doUpdateLotOccupancyFeeQuantity.d.ts new file mode 100644 index 00000000..19d32e4d --- /dev/null +++ b/handlers/contracts-post/doUpdateLotOccupancyFeeQuantity.d.ts @@ -0,0 +1,2 @@ +import type { Request, Response } from 'express'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.js b/handlers/contracts-post/doUpdateLotOccupancyFeeQuantity.js similarity index 100% rename from handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.js rename to handlers/contracts-post/doUpdateLotOccupancyFeeQuantity.js diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.ts b/handlers/contracts-post/doUpdateLotOccupancyFeeQuantity.ts similarity index 100% rename from handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.ts rename to handlers/contracts-post/doUpdateLotOccupancyFeeQuantity.ts diff --git a/handlers/contracts-post/doUpdateLotOccupancyOccupant.d.ts b/handlers/contracts-post/doUpdateLotOccupancyOccupant.d.ts new file mode 100644 index 00000000..19d32e4d --- /dev/null +++ b/handlers/contracts-post/doUpdateLotOccupancyOccupant.d.ts @@ -0,0 +1,2 @@ +import type { Request, Response } from 'express'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancyOccupant.js b/handlers/contracts-post/doUpdateLotOccupancyOccupant.js similarity index 100% rename from handlers/lotOccupancies-post/doUpdateLotOccupancyOccupant.js rename to handlers/contracts-post/doUpdateLotOccupancyOccupant.js diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancyOccupant.ts b/handlers/contracts-post/doUpdateLotOccupancyOccupant.ts similarity index 100% rename from handlers/lotOccupancies-post/doUpdateLotOccupancyOccupant.ts rename to handlers/contracts-post/doUpdateLotOccupancyOccupant.ts diff --git a/handlers/contracts-post/doUpdateLotOccupancyTransaction.d.ts b/handlers/contracts-post/doUpdateLotOccupancyTransaction.d.ts new file mode 100644 index 00000000..19d32e4d --- /dev/null +++ b/handlers/contracts-post/doUpdateLotOccupancyTransaction.d.ts @@ -0,0 +1,2 @@ +import type { Request, Response } from 'express'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancyTransaction.js b/handlers/contracts-post/doUpdateLotOccupancyTransaction.js similarity index 100% rename from handlers/lotOccupancies-post/doUpdateLotOccupancyTransaction.js rename to handlers/contracts-post/doUpdateLotOccupancyTransaction.js diff --git a/handlers/lotOccupancies-post/doUpdateLotOccupancyTransaction.ts b/handlers/contracts-post/doUpdateLotOccupancyTransaction.ts similarity index 100% rename from handlers/lotOccupancies-post/doUpdateLotOccupancyTransaction.ts rename to handlers/contracts-post/doUpdateLotOccupancyTransaction.ts diff --git a/handlers/permissions.js b/handlers/permissions.js index f2d6adfa..63f769b2 100644 --- a/handlers/permissions.js +++ b/handlers/permissions.js @@ -1,4 +1,4 @@ -import { getConfigProperty } from '../helpers/functions.config.js'; +import { getConfigProperty } from '../helpers/config.helpers.js'; import { apiKeyIsValid, userCanUpdate, userIsAdmin } from '../helpers/functions.user.js'; const urlPrefix = getConfigProperty('reverseProxy.urlPrefix'); const forbiddenStatus = 403; diff --git a/handlers/permissions.ts b/handlers/permissions.ts index fd7985d8..bb345b1e 100644 --- a/handlers/permissions.ts +++ b/handlers/permissions.ts @@ -1,6 +1,6 @@ import type { NextFunction, Request, Response } from 'express' -import { getConfigProperty } from '../helpers/functions.config.js' +import { getConfigProperty } from '../helpers/config.helpers.js' import { apiKeyIsValid, userCanUpdate, diff --git a/handlers/print-get/pdf.js b/handlers/print-get/pdf.js index e6347635..1fde905a 100644 --- a/handlers/print-get/pdf.js +++ b/handlers/print-get/pdf.js @@ -2,7 +2,7 @@ import path from 'node:path'; import { convertHTMLToPDF } from '@cityssm/pdf-puppeteer'; import camelcase from 'camelcase'; import { renderFile as renderEjsFile } from 'ejs'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; import { getPdfPrintConfig, getReportData } from '../../helpers/functions.print.js'; const attachmentOrInline = getConfigProperty('settings.printPdf.contentDisposition'); export async function handler(request, response, next) { diff --git a/handlers/print-get/pdf.ts b/handlers/print-get/pdf.ts index 2e237ef8..038195dc 100644 --- a/handlers/print-get/pdf.ts +++ b/handlers/print-get/pdf.ts @@ -5,7 +5,7 @@ import camelcase from 'camelcase' import { renderFile as renderEjsFile } from 'ejs' import type { NextFunction, Request, Response } from 'express' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' import { getPdfPrintConfig, getReportData diff --git a/handlers/print-get/screen.js b/handlers/print-get/screen.js index c550d358..10f0f75f 100644 --- a/handlers/print-get/screen.js +++ b/handlers/print-get/screen.js @@ -1,4 +1,4 @@ -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; import { getReportData, getScreenPrintConfig } from '../../helpers/functions.print.js'; export default async function handler(request, response) { const printName = request.params.printName; diff --git a/handlers/print-get/screen.ts b/handlers/print-get/screen.ts index 0b980489..93c55107 100644 --- a/handlers/print-get/screen.ts +++ b/handlers/print-get/screen.ts @@ -1,6 +1,6 @@ import type { Request, Response } from 'express' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' import { getReportData, getScreenPrintConfig diff --git a/handlers/workOrders-get/edit.js b/handlers/workOrders-get/edit.js index 9bdde438..9199d2a0 100644 --- a/handlers/workOrders-get/edit.js +++ b/handlers/workOrders-get/edit.js @@ -1,6 +1,6 @@ import getWorkOrder from '../../database/getWorkOrder.js'; import { getLotStatuses, getWorkOrderMilestoneTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; export default async function handler(request, response) { const workOrder = await getWorkOrder(request.params.workOrderId, { includeLotsAndLotOccupancies: true, diff --git a/handlers/workOrders-get/edit.ts b/handlers/workOrders-get/edit.ts index ae5e65c0..13eb2e2b 100644 --- a/handlers/workOrders-get/edit.ts +++ b/handlers/workOrders-get/edit.ts @@ -6,7 +6,7 @@ import { getWorkOrderMilestoneTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' export default async function handler( request: Request, diff --git a/handlers/workOrders-get/view.js b/handlers/workOrders-get/view.js index 1ede1db2..817777e0 100644 --- a/handlers/workOrders-get/view.js +++ b/handlers/workOrders-get/view.js @@ -1,5 +1,5 @@ import getWorkOrder from '../../database/getWorkOrder.js'; -import { getConfigProperty } from '../../helpers/functions.config.js'; +import { getConfigProperty } from '../../helpers/config.helpers.js'; export default async function handler(request, response) { const workOrder = await getWorkOrder(request.params.workOrderId, { includeLotsAndLotOccupancies: true, diff --git a/handlers/workOrders-get/view.ts b/handlers/workOrders-get/view.ts index 9fb9b141..fd9b1e42 100644 --- a/handlers/workOrders-get/view.ts +++ b/handlers/workOrders-get/view.ts @@ -1,7 +1,7 @@ import type { Request, Response } from 'express' import getWorkOrder from '../../database/getWorkOrder.js' -import { getConfigProperty } from '../../helpers/functions.config.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' export default async function handler( request: Request, diff --git a/helpers/burialSites.helpers.d.ts b/helpers/burialSites.helpers.d.ts new file mode 100644 index 00000000..a686d2f1 --- /dev/null +++ b/helpers/burialSites.helpers.d.ts @@ -0,0 +1,3 @@ +export declare function getNextBurialSiteId(burialSiteId: number): Promise; +export declare function getPreviousBurialSiteId(burialSiteId: number): Promise; +export declare function clearNextPreviousBurialSiteIdCache(burialSiteId?: number, relayMessage?: boolean): void; diff --git a/helpers/burialSites.helpers.js b/helpers/burialSites.helpers.js new file mode 100644 index 00000000..e6460acd --- /dev/null +++ b/helpers/burialSites.helpers.js @@ -0,0 +1,99 @@ +import cluster from 'node:cluster'; +import Debug from 'debug'; +import NodeCache from 'node-cache'; +import getNextBurialSiteIdFromDatabase from '../database/getNextBurialSiteId.js'; +import getPreviousLotIdFromDatabase from '../database/getPreviousLotId.js'; +import { DEBUG_NAMESPACE } from '../debug.config.js'; +const debug = Debug(`${DEBUG_NAMESPACE}:burialSites.helpers:${process.pid}`); +const cacheOptions = { + stdTTL: 2 * 60, // two minutes + useClones: false +}; +const previousBurialSiteIdCache = new NodeCache(cacheOptions); +const nextBurialSiteIdCache = new NodeCache(cacheOptions); +function cacheBurialSiteIds(burialSiteId, nextBurialSiteId, relayMessage = true) { + previousBurialSiteIdCache.set(nextBurialSiteId, burialSiteId); + nextBurialSiteIdCache.set(burialSiteId, nextBurialSiteId); + try { + if (relayMessage && cluster.isWorker && process.send !== undefined) { + const workerMessage = { + messageType: 'cacheBurialSiteIds', + burialSiteId, + nextBurialSiteId, + timeMillis: Date.now(), + pid: process.pid + }; + debug(`Sending cache burial site ids from worker: (${burialSiteId}, ${nextBurialSiteId})`); + process.send(workerMessage); + } + } + catch { } +} +export async function getNextBurialSiteId(burialSiteId) { + let nextBurialSiteId = nextBurialSiteIdCache.get(burialSiteId); + if (nextBurialSiteId === undefined) { + nextBurialSiteId = await getNextBurialSiteIdFromDatabase(burialSiteId); + if (nextBurialSiteId !== undefined) { + cacheBurialSiteIds(burialSiteId, nextBurialSiteId); + } + } + return nextBurialSiteId; +} +export async function getPreviousBurialSiteId(burialSiteId) { + let previousBurialSiteId = previousBurialSiteIdCache.get(burialSiteId); + if (previousBurialSiteId === undefined) { + previousBurialSiteId = await getPreviousLotIdFromDatabase(burialSiteId); + if (previousBurialSiteId !== undefined) { + cacheBurialSiteIds(previousBurialSiteId, burialSiteId); + } + } + return previousBurialSiteId; +} +export function clearNextPreviousBurialSiteIdCache(burialSiteId = -1, relayMessage = true) { + if (burialSiteId === -1) { + previousBurialSiteIdCache.flushAll(); + nextBurialSiteIdCache.flushAll(); + return; + } + const previousBurialSiteId = previousBurialSiteIdCache.get(burialSiteId); + if (previousBurialSiteId !== undefined) { + nextBurialSiteIdCache.del(previousBurialSiteId); + previousBurialSiteIdCache.del(burialSiteId); + } + const nextBurialSiteId = nextBurialSiteIdCache.get(burialSiteId); + if (nextBurialSiteId !== undefined) { + previousBurialSiteIdCache.del(nextBurialSiteId); + nextBurialSiteIdCache.del(burialSiteId); + } + try { + if (relayMessage && cluster.isWorker && process.send !== undefined) { + const workerMessage = { + // eslint-disable-next-line no-secrets/no-secrets + messageType: 'clearNextPreviousBurialSiteIdCache', + burialSiteId, + timeMillis: Date.now(), + pid: process.pid + }; + debug(`Sending clear next/previous burial site cache from worker: ${burialSiteId}`); + process.send(workerMessage); + } + } + catch { } +} +process.on('message', (message) => { + if (message.pid !== process.pid) { + switch (message.messageType) { + case 'cacheBurialSiteIds': { + debug(`Caching burial site ids: (${message.burialSiteId}, ${message.nextBurialSiteId})`); + cacheBurialSiteIds(message.burialSiteId, message.nextBurialSiteId, false); + break; + } + // eslint-disable-next-line no-secrets/no-secrets + case 'clearNextPreviousBurialSiteIdCache': { + debug(`Clearing next/previous burial site cache: ${message.burialSiteId}`); + clearNextPreviousBurialSiteIdCache(message.burialSiteId, false); + break; + } + } + } +}); diff --git a/helpers/burialSites.helpers.ts b/helpers/burialSites.helpers.ts new file mode 100644 index 00000000..c3964491 --- /dev/null +++ b/helpers/burialSites.helpers.ts @@ -0,0 +1,162 @@ +import cluster from 'node:cluster' + +import Debug from 'debug' +import NodeCache from 'node-cache' + +import getNextBurialSiteIdFromDatabase from '../database/getNextBurialSiteId.js' +import getPreviousLotIdFromDatabase from '../database/getPreviousLotId.js' +import { DEBUG_NAMESPACE } from '../debug.config.js' +import type { + CacheBurialSiteIdsWorkerMessage, + ClearNextPreviousBurialSiteIdsCacheWorkerMessage +} from '../types/applicationTypes.js' + +const debug = Debug(`${DEBUG_NAMESPACE}:burialSites.helpers:${process.pid}`) + +const cacheOptions: NodeCache.Options = { + stdTTL: 2 * 60, // two minutes + useClones: false +} + +const previousBurialSiteIdCache = new NodeCache(cacheOptions) + +const nextBurialSiteIdCache = new NodeCache(cacheOptions) + +function cacheBurialSiteIds( + burialSiteId: number, + nextBurialSiteId: number, + relayMessage = true +): void { + previousBurialSiteIdCache.set(nextBurialSiteId, burialSiteId) + nextBurialSiteIdCache.set(burialSiteId, nextBurialSiteId) + + try { + if (relayMessage && cluster.isWorker && process.send !== undefined) { + const workerMessage: CacheBurialSiteIdsWorkerMessage = { + messageType: 'cacheBurialSiteIds', + burialSiteId, + nextBurialSiteId, + timeMillis: Date.now(), + pid: process.pid + } + + debug( + `Sending cache burial site ids from worker: (${burialSiteId}, ${nextBurialSiteId})` + ) + + process.send(workerMessage) + } + } catch {} +} + +export async function getNextBurialSiteId( + burialSiteId: number +): Promise { + let nextBurialSiteId: number | undefined = + nextBurialSiteIdCache.get(burialSiteId) + + if (nextBurialSiteId === undefined) { + nextBurialSiteId = await getNextBurialSiteIdFromDatabase(burialSiteId) + + if (nextBurialSiteId !== undefined) { + cacheBurialSiteIds(burialSiteId, nextBurialSiteId) + } + } + + return nextBurialSiteId +} + +export async function getPreviousBurialSiteId( + burialSiteId: number +): Promise { + let previousBurialSiteId: number | undefined = + previousBurialSiteIdCache.get(burialSiteId) + + if (previousBurialSiteId === undefined) { + previousBurialSiteId = await getPreviousLotIdFromDatabase(burialSiteId) + + if (previousBurialSiteId !== undefined) { + cacheBurialSiteIds(previousBurialSiteId, burialSiteId) + } + } + + return previousBurialSiteId +} + +export function clearNextPreviousBurialSiteIdCache( + burialSiteId = -1, + relayMessage = true +): void { + if (burialSiteId === -1) { + previousBurialSiteIdCache.flushAll() + nextBurialSiteIdCache.flushAll() + return + } + + const previousBurialSiteId: number | undefined = + previousBurialSiteIdCache.get(burialSiteId) + + if (previousBurialSiteId !== undefined) { + nextBurialSiteIdCache.del(previousBurialSiteId) + previousBurialSiteIdCache.del(burialSiteId) + } + + const nextBurialSiteId: number | undefined = + nextBurialSiteIdCache.get(burialSiteId) + + if (nextBurialSiteId !== undefined) { + previousBurialSiteIdCache.del(nextBurialSiteId) + nextBurialSiteIdCache.del(burialSiteId) + } + + try { + if (relayMessage && cluster.isWorker && process.send !== undefined) { + const workerMessage: ClearNextPreviousBurialSiteIdsCacheWorkerMessage = { + // eslint-disable-next-line no-secrets/no-secrets + messageType: 'clearNextPreviousBurialSiteIdCache', + burialSiteId, + timeMillis: Date.now(), + pid: process.pid + } + + debug( + `Sending clear next/previous burial site cache from worker: ${burialSiteId}` + ) + + process.send(workerMessage) + } + } catch {} +} + +process.on( + 'message', + ( + message: + | ClearNextPreviousBurialSiteIdsCacheWorkerMessage + | CacheBurialSiteIdsWorkerMessage + ) => { + if (message.pid !== process.pid) { + switch (message.messageType) { + case 'cacheBurialSiteIds': { + debug( + `Caching burial site ids: (${message.burialSiteId}, ${message.nextBurialSiteId})` + ) + cacheBurialSiteIds( + message.burialSiteId, + message.nextBurialSiteId, + false + ) + break + } + // eslint-disable-next-line no-secrets/no-secrets + case 'clearNextPreviousBurialSiteIdCache': { + debug( + `Clearing next/previous burial site cache: ${message.burialSiteId}` + ) + clearNextPreviousBurialSiteIdCache(message.burialSiteId, false) + break + } + } + } + } +) diff --git a/helpers/cemeteries.helpers.d.ts b/helpers/cemeteries.helpers.d.ts new file mode 100644 index 00000000..5e21009a --- /dev/null +++ b/helpers/cemeteries.helpers.d.ts @@ -0,0 +1 @@ +export declare function getCemeterySVGs(): Promise; diff --git a/helpers/cemeteries.helpers.js b/helpers/cemeteries.helpers.js new file mode 100644 index 00000000..28dbe1ca --- /dev/null +++ b/helpers/cemeteries.helpers.js @@ -0,0 +1,15 @@ +import fs from 'node:fs/promises'; +let cemeterySVGs; +export async function getCemeterySVGs() { + if (cemeterySVGs === undefined) { + const files = await fs.readdir('./public/images/cemeteries/'); + const SVGs = []; + for (const file of files) { + if (file.toLowerCase().endsWith('.svg')) { + SVGs.push(file); + } + } + cemeterySVGs = SVGs; + } + return cemeterySVGs; +} diff --git a/helpers/cemeteries.helpers.ts b/helpers/cemeteries.helpers.ts new file mode 100644 index 00000000..eff252dd --- /dev/null +++ b/helpers/cemeteries.helpers.ts @@ -0,0 +1,21 @@ +import fs from 'node:fs/promises' + +let cemeterySVGs: string[] | undefined + +export async function getCemeterySVGs(): Promise { + if (cemeterySVGs === undefined) { + const files = await fs.readdir('./public/images/cemeteries/') + + const SVGs: string[] = [] + + for (const file of files) { + if (file.toLowerCase().endsWith('.svg')) { + SVGs.push(file) + } + } + + cemeterySVGs = SVGs + } + + return cemeterySVGs +} diff --git a/helpers/functions.config.d.ts b/helpers/config.helpers.d.ts similarity index 74% rename from helpers/functions.config.d.ts rename to helpers/config.helpers.d.ts index 0350a7fa..fe84a5ca 100644 --- a/helpers/functions.config.d.ts +++ b/helpers/config.helpers.d.ts @@ -1,3 +1,7 @@ import { configDefaultValues } from '../data/config.defaultValues.js'; export declare function getConfigProperty(propertyName: K, fallbackValue?: (typeof configDefaultValues)[K]): (typeof configDefaultValues)[K]; +declare const _default: { + getConfigProperty: typeof getConfigProperty; +}; +export default _default; export declare const keepAliveMillis: number; diff --git a/helpers/functions.config.js b/helpers/config.helpers.js similarity index 93% rename from helpers/functions.config.js rename to helpers/config.helpers.js index 3450932c..afb47f5d 100644 --- a/helpers/functions.config.js +++ b/helpers/config.helpers.js @@ -6,6 +6,9 @@ const configurator = new Configurator(configDefaultValues, config); export function getConfigProperty(propertyName, fallbackValue) { return configurator.getConfigProperty(propertyName, fallbackValue); } +export default { + getConfigProperty +}; export const keepAliveMillis = getConfigProperty('session.doKeepAlive') ? Math.max(getConfigProperty('session.maxAgeMillis') / 2, getConfigProperty('session.maxAgeMillis') - secondsToMillis(10)) : 0; diff --git a/helpers/functions.config.ts b/helpers/config.helpers.ts similarity index 94% rename from helpers/functions.config.ts rename to helpers/config.helpers.ts index a42b0c20..b86ac409 100644 --- a/helpers/functions.config.ts +++ b/helpers/config.helpers.ts @@ -19,9 +19,13 @@ export function getConfigProperty( ) as (typeof configDefaultValues)[K] } +export default { + getConfigProperty +} + export const keepAliveMillis = getConfigProperty('session.doKeepAlive') ? Math.max( getConfigProperty('session.maxAgeMillis') / 2, - getConfigProperty('session.maxAgeMillis') - secondsToMillis (10) + getConfigProperty('session.maxAgeMillis') - secondsToMillis(10) ) : 0 diff --git a/helpers/database.helpers.d.ts b/helpers/database.helpers.d.ts new file mode 100644 index 00000000..73c0839e --- /dev/null +++ b/helpers/database.helpers.d.ts @@ -0,0 +1,5 @@ +export declare const useTestDatabases: boolean; +export declare const sunriseDBLive = "data/sunrise.db"; +export declare const sunriseDBTesting = "data/sunrise-testing.db"; +export declare const sunriseDB: string; +export declare const backupFolder = "data/backups"; diff --git a/helpers/database.helpers.js b/helpers/database.helpers.js new file mode 100644 index 00000000..6a1637bd --- /dev/null +++ b/helpers/database.helpers.js @@ -0,0 +1,13 @@ +import Debug from 'debug'; +import { DEBUG_NAMESPACE } from '../debug.config.js'; +import { getConfigProperty } from './config.helpers.js'; +const debug = Debug(`${DEBUG_NAMESPACE}:database.helpers`); +export const useTestDatabases = getConfigProperty('application.useTestDatabases') || + process.env.TEST_DATABASES === 'true'; +if (useTestDatabases) { + debug('Using "-testing" databases.'); +} +export const sunriseDBLive = 'data/sunrise.db'; +export const sunriseDBTesting = 'data/sunrise-testing.db'; +export const sunriseDB = useTestDatabases ? sunriseDBTesting : sunriseDBLive; +export const backupFolder = 'data/backups'; diff --git a/helpers/database.helpers.ts b/helpers/database.helpers.ts new file mode 100644 index 00000000..6c3359db --- /dev/null +++ b/helpers/database.helpers.ts @@ -0,0 +1,22 @@ +import Debug from 'debug' + +import { DEBUG_NAMESPACE } from '../debug.config.js' + +import { getConfigProperty } from './config.helpers.js' + +const debug = Debug(`${DEBUG_NAMESPACE}:database.helpers`) + +export const useTestDatabases = + getConfigProperty('application.useTestDatabases') || + process.env.TEST_DATABASES === 'true' + +if (useTestDatabases) { + debug('Using "-testing" databases.') +} + +export const sunriseDBLive = 'data/sunrise.db' +export const sunriseDBTesting = 'data/sunrise-testing.db' + +export const sunriseDB = useTestDatabases ? sunriseDBTesting : sunriseDBLive + +export const backupFolder = 'data/backups' diff --git a/helpers/functions.api.js b/helpers/functions.api.js index bbe6c1af..151190ae 100644 --- a/helpers/functions.api.js +++ b/helpers/functions.api.js @@ -1,7 +1,8 @@ import fs from 'node:fs/promises'; import Debug from 'debug'; import { v4 as uuidV4 } from 'uuid'; -const debug = Debug('lot-occupancy-system:functions.api'); +import { DEBUG_NAMESPACE } from '../debug.config.js'; +const debug = Debug(`${DEBUG_NAMESPACE}:functions.api`); const apiKeyPath = 'data/apiKeys.json'; let apiKeys; async function loadApiKeys() { diff --git a/helpers/functions.api.ts b/helpers/functions.api.ts index 10086564..3ba3a764 100644 --- a/helpers/functions.api.ts +++ b/helpers/functions.api.ts @@ -3,7 +3,9 @@ import fs from 'node:fs/promises' import Debug from 'debug' import { v4 as uuidV4 } from 'uuid' -const debug = Debug('lot-occupancy-system:functions.api') +import { DEBUG_NAMESPACE } from '../debug.config.js' + +const debug = Debug(`${DEBUG_NAMESPACE}:functions.api`) const apiKeyPath = 'data/apiKeys.json' let apiKeys: Record | undefined diff --git a/helpers/functions.authentication.js b/helpers/functions.authentication.js index d5198394..88a140f0 100644 --- a/helpers/functions.authentication.js +++ b/helpers/functions.authentication.js @@ -1,5 +1,5 @@ import ActiveDirectory from 'activedirectory2'; -import { getConfigProperty } from './functions.config.js'; +import { getConfigProperty } from './config.helpers.js'; const userDomain = getConfigProperty('application.userDomain'); const activeDirectoryConfig = getConfigProperty('activeDirectory'); async function authenticateViaActiveDirectory(userName, password) { diff --git a/helpers/functions.authentication.ts b/helpers/functions.authentication.ts index fe668470..d4e44bc2 100644 --- a/helpers/functions.authentication.ts +++ b/helpers/functions.authentication.ts @@ -1,6 +1,6 @@ import ActiveDirectory from 'activedirectory2' -import { getConfigProperty } from './functions.config.js' +import { getConfigProperty } from './config.helpers.js' const userDomain = getConfigProperty('application.userDomain') diff --git a/helpers/functions.cache.js b/helpers/functions.cache.js index 9fee0366..433fb644 100644 --- a/helpers/functions.cache.js +++ b/helpers/functions.cache.js @@ -9,8 +9,9 @@ import getOccupancyTypeFieldsFromDatabase from '../database/getOccupancyTypeFiel import getOccupancyTypesFromDatabase from '../database/getOccupancyTypes.js'; import getWorkOrderMilestoneTypesFromDatabase from '../database/getWorkOrderMilestoneTypes.js'; import getWorkOrderTypesFromDatabase from '../database/getWorkOrderTypes.js'; -import { getConfigProperty } from './functions.config.js'; -const debug = Debug(`lot-occupancy-system:functions.cache:${process.pid}`); +import { DEBUG_NAMESPACE } from '../debug.config.js'; +import { getConfigProperty } from './config.helpers.js'; +const debug = Debug(`${DEBUG_NAMESPACE}:functions.cache:${process.pid}`); /* * Lot Occupant Types */ diff --git a/helpers/functions.cache.ts b/helpers/functions.cache.ts index 29c4203c..b266c27e 100644 --- a/helpers/functions.cache.ts +++ b/helpers/functions.cache.ts @@ -12,6 +12,7 @@ import getOccupancyTypeFieldsFromDatabase from '../database/getOccupancyTypeFiel import getOccupancyTypesFromDatabase from '../database/getOccupancyTypes.js' import getWorkOrderMilestoneTypesFromDatabase from '../database/getWorkOrderMilestoneTypes.js' import getWorkOrderTypesFromDatabase from '../database/getWorkOrderTypes.js' +import { DEBUG_NAMESPACE } from '../debug.config.js' import type { ClearCacheWorkerMessage, WorkerMessage @@ -26,9 +27,9 @@ import type { WorkOrderType } from '../types/recordTypes.js' -import { getConfigProperty } from './functions.config.js' +import { getConfigProperty } from './config.helpers.js' -const debug = Debug(`lot-occupancy-system:functions.cache:${process.pid}`) +const debug = Debug(`${DEBUG_NAMESPACE}:functions.cache:${process.pid}`) /* * Lot Occupant Types diff --git a/helpers/functions.database.js b/helpers/functions.database.js index b5a19f18..cd6d1b04 100644 --- a/helpers/functions.database.js +++ b/helpers/functions.database.js @@ -1,5 +1,5 @@ import fs from 'node:fs/promises'; -import { backupFolder, lotOccupancyDB as databasePath } from '../data/databasePaths.js'; +import { backupFolder, sunriseDB as databasePath } from '../helpers/database.helpers.js'; export async function backupDatabase() { const databasePathSplit = databasePath.split(/[/\\]/); const backupDatabasePath = `${backupFolder}/${databasePathSplit.at(-1)}.${Date.now().toString()}`; diff --git a/helpers/functions.database.ts b/helpers/functions.database.ts index 96e710bc..95bc0f53 100644 --- a/helpers/functions.database.ts +++ b/helpers/functions.database.ts @@ -2,8 +2,8 @@ import fs from 'node:fs/promises' import { backupFolder, - lotOccupancyDB as databasePath -} from '../data/databasePaths.js' + sunriseDB as databasePath +} from '../helpers/database.helpers.js' export async function backupDatabase(): Promise { const databasePathSplit = databasePath.split(/[/\\]/) diff --git a/helpers/functions.dynamicsGP.js b/helpers/functions.dynamicsGP.js index d71a95ee..a815d63d 100644 --- a/helpers/functions.dynamicsGP.js +++ b/helpers/functions.dynamicsGP.js @@ -1,5 +1,5 @@ import { DynamicsGP } from '@cityssm/dynamics-gp'; -import { getConfigProperty } from './functions.config.js'; +import { getConfigProperty } from './config.helpers.js'; // eslint-disable-next-line @typescript-eslint/init-declarations let gp; if (getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) { diff --git a/helpers/functions.dynamicsGP.ts b/helpers/functions.dynamicsGP.ts index acc8a2ef..2564c705 100644 --- a/helpers/functions.dynamicsGP.ts +++ b/helpers/functions.dynamicsGP.ts @@ -8,7 +8,7 @@ import { import type { DynamicsGPLookup } from '../types/configTypes.js' import type { DynamicsGPDocument } from '../types/recordTypes.js' -import { getConfigProperty } from './functions.config.js' +import { getConfigProperty } from './config.helpers.js' // eslint-disable-next-line @typescript-eslint/init-declarations let gp: DynamicsGP diff --git a/helpers/functions.lotOccupancy.d.ts b/helpers/functions.lotOccupancy.d.ts index d147f9b6..d3813651 100644 --- a/helpers/functions.lotOccupancy.d.ts +++ b/helpers/functions.lotOccupancy.d.ts @@ -1,4 +1,4 @@ -import type { LotOccupancy, LotOccupancyFee, LotOccupancyOccupant } from '../types/recordTypes'; +import type { LotOccupancy, LotOccupancyFee, LotOccupancyOccupant } from '../types/recordTypes.js'; export declare function filterOccupantsByLotOccupantType(lotOccupancy: LotOccupancy, lotOccupantType: string): LotOccupancyOccupant[]; export declare function getFieldValueByOccupancyTypeField(lotOccupancy: LotOccupancy, occupancyTypeField: string): string | undefined; export declare function getFeesByFeeCategory(lotOccupancy: LotOccupancy, feeCategory: string, feeCategoryContains?: boolean): LotOccupancyFee[]; diff --git a/helpers/functions.lotOccupancy.ts b/helpers/functions.lotOccupancy.ts index d4bb2cd8..d55a41c9 100644 --- a/helpers/functions.lotOccupancy.ts +++ b/helpers/functions.lotOccupancy.ts @@ -2,7 +2,7 @@ import type { LotOccupancy, LotOccupancyFee, LotOccupancyOccupant -} from '../types/recordTypes' +} from '../types/recordTypes.js' export function filterOccupantsByLotOccupantType( lotOccupancy: LotOccupancy, diff --git a/helpers/functions.lots.d.ts b/helpers/functions.lots.d.ts deleted file mode 100644 index e43ad87b..00000000 --- a/helpers/functions.lots.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export declare function getNextLotId(lotId: number): Promise; -export declare function getPreviousLotId(lotId: number): Promise; -export declare function clearNextPreviousLotIdCache(lotId: number | -1, relayMessage?: boolean): void; diff --git a/helpers/functions.lots.js b/helpers/functions.lots.js deleted file mode 100644 index e75afd60..00000000 --- a/helpers/functions.lots.js +++ /dev/null @@ -1,96 +0,0 @@ -import cluster from 'node:cluster'; -import Debug from 'debug'; -import NodeCache from 'node-cache'; -import getNextLotIdFromDatabase from '../database/getNextLotId.js'; -import getPreviousLotIdFromDatabase from '../database/getPreviousLotId.js'; -const debug = Debug(`lot-occupancy-system:functions.lots:${process.pid}`); -const cacheOptions = { - stdTTL: 2 * 60, // two minutes - useClones: false -}; -const previousLotIdCache = new NodeCache(cacheOptions); -const nextLotIdCache = new NodeCache(cacheOptions); -function cacheLotIds(lotId, nextLotId, relayMessage = true) { - previousLotIdCache.set(nextLotId, lotId); - nextLotIdCache.set(lotId, nextLotId); - try { - if (relayMessage && cluster.isWorker) { - const workerMessage = { - messageType: 'cacheLotIds', - lotId, - nextLotId, - timeMillis: Date.now(), - pid: process.pid - }; - debug(`Sending cache lot ids from worker: (${lotId}, ${nextLotId})`); - process.send(workerMessage); - } - } - catch { } -} -export async function getNextLotId(lotId) { - let nextLotId = nextLotIdCache.get(lotId); - if (nextLotId === undefined) { - nextLotId = await getNextLotIdFromDatabase(lotId); - if (nextLotId !== undefined) { - cacheLotIds(lotId, nextLotId); - } - } - return nextLotId; -} -export async function getPreviousLotId(lotId) { - let previousLotId = previousLotIdCache.get(lotId); - if (previousLotId === undefined) { - previousLotId = await getPreviousLotIdFromDatabase(lotId); - if (previousLotId !== undefined) { - cacheLotIds(previousLotId, lotId); - } - } - return previousLotId; -} -export function clearNextPreviousLotIdCache(lotId, relayMessage = true) { - if (lotId === undefined || lotId === -1) { - previousLotIdCache.flushAll(); - nextLotIdCache.flushAll(); - return; - } - const previousLotId = previousLotIdCache.get(lotId); - if (previousLotId !== undefined) { - nextLotIdCache.del(previousLotId); - previousLotIdCache.del(lotId); - } - const nextLotId = nextLotIdCache.get(lotId); - if (nextLotId !== undefined) { - previousLotIdCache.del(nextLotId); - nextLotIdCache.del(lotId); - } - try { - if (relayMessage && cluster.isWorker) { - const workerMessage = { - messageType: 'clearNextPreviousLotIdCache', - lotId, - timeMillis: Date.now(), - pid: process.pid - }; - debug(`Sending clear next/previous lot cache from worker: ${lotId}`); - process.send(workerMessage); - } - } - catch { } -} -process.on('message', (message) => { - if (message.pid !== process.pid) { - switch (message.messageType) { - case 'cacheLotIds': { - debug(`Caching lot ids: (${message.lotId}, ${message.nextLotId})`); - cacheLotIds(message.lotId, message.nextLotId, false); - break; - } - case 'clearNextPreviousLotIdCache': { - debug(`Clearing next/previous lot cache: ${message.lotId}`); - clearNextPreviousLotIdCache(message.lotId, false); - break; - } - } - } -}); diff --git a/helpers/functions.lots.ts b/helpers/functions.lots.ts deleted file mode 100644 index 6987b158..00000000 --- a/helpers/functions.lots.ts +++ /dev/null @@ -1,141 +0,0 @@ -import cluster from 'node:cluster' - -import Debug from 'debug' -import NodeCache from 'node-cache' - -import getNextLotIdFromDatabase from '../database/getNextLotId.js' -import getPreviousLotIdFromDatabase from '../database/getPreviousLotId.js' -import type { - CacheLotIdsWorkerMessage, - ClearNextPreviousLotIdsCacheWorkerMessage -} from '../types/applicationTypes.js' - -const debug = Debug(`lot-occupancy-system:functions.lots:${process.pid}`) - -const cacheOptions: NodeCache.Options = { - stdTTL: 2 * 60, // two minutes - useClones: false -} - -const previousLotIdCache = new NodeCache(cacheOptions) - -const nextLotIdCache = new NodeCache(cacheOptions) - -function cacheLotIds( - lotId: number, - nextLotId: number, - relayMessage = true -): void { - previousLotIdCache.set(nextLotId, lotId) - nextLotIdCache.set(lotId, nextLotId) - - try { - if (relayMessage && cluster.isWorker) { - const workerMessage: CacheLotIdsWorkerMessage = { - messageType: 'cacheLotIds', - lotId, - nextLotId, - timeMillis: Date.now(), - pid: process.pid - } - - debug(`Sending cache lot ids from worker: (${lotId}, ${nextLotId})`) - - process.send!(workerMessage) - } - } catch {} -} - -export async function getNextLotId(lotId: number): Promise { - let nextLotId: number | undefined = nextLotIdCache.get(lotId) - - if (nextLotId === undefined) { - nextLotId = await getNextLotIdFromDatabase(lotId) - - if (nextLotId !== undefined) { - cacheLotIds(lotId, nextLotId) - } - } - - return nextLotId -} - -export async function getPreviousLotId( - lotId: number -): Promise { - let previousLotId: number | undefined = previousLotIdCache.get(lotId) - - if (previousLotId === undefined) { - previousLotId = await getPreviousLotIdFromDatabase(lotId) - - if (previousLotId !== undefined) { - cacheLotIds(previousLotId, lotId) - } - } - - return previousLotId -} - -export function clearNextPreviousLotIdCache( - lotId: number | -1, - relayMessage = true -): void { - if (lotId === undefined || lotId === -1) { - previousLotIdCache.flushAll() - nextLotIdCache.flushAll() - return - } - - const previousLotId: number | undefined = previousLotIdCache.get(lotId) - - if (previousLotId !== undefined) { - nextLotIdCache.del(previousLotId) - previousLotIdCache.del(lotId) - } - - const nextLotId: number | undefined = nextLotIdCache.get(lotId) - - if (nextLotId !== undefined) { - previousLotIdCache.del(nextLotId) - nextLotIdCache.del(lotId) - } - - try { - if (relayMessage && cluster.isWorker) { - const workerMessage: ClearNextPreviousLotIdsCacheWorkerMessage = { - messageType: 'clearNextPreviousLotIdCache', - lotId, - timeMillis: Date.now(), - pid: process.pid - } - - debug(`Sending clear next/previous lot cache from worker: ${lotId}`) - - process.send!(workerMessage) - } - } catch {} -} - -process.on( - 'message', - ( - message: - | ClearNextPreviousLotIdsCacheWorkerMessage - | CacheLotIdsWorkerMessage - ) => { - if (message.pid !== process.pid) { - switch (message.messageType) { - case 'cacheLotIds': { - debug(`Caching lot ids: (${message.lotId}, ${message.nextLotId})`) - cacheLotIds(message.lotId, message.nextLotId, false) - break - } - case 'clearNextPreviousLotIdCache': { - debug(`Clearing next/previous lot cache: ${message.lotId}`) - clearNextPreviousLotIdCache(message.lotId, false) - break - } - } - } - } -) diff --git a/helpers/functions.map.d.ts b/helpers/functions.map.d.ts deleted file mode 100644 index 89887016..00000000 --- a/helpers/functions.map.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function getMapSVGs(): Promise; diff --git a/helpers/functions.map.js b/helpers/functions.map.js deleted file mode 100644 index eb9d869b..00000000 --- a/helpers/functions.map.js +++ /dev/null @@ -1,15 +0,0 @@ -import fs from 'node:fs/promises'; -let mapSVGs; -export async function getMapSVGs() { - if (mapSVGs === undefined) { - const files = await fs.readdir('./public/images/maps/'); - const SVGs = []; - for (const file of files) { - if (file.toLowerCase().endsWith('.svg')) { - SVGs.push(file); - } - } - mapSVGs = SVGs; - } - return mapSVGs; -} diff --git a/helpers/functions.map.ts b/helpers/functions.map.ts deleted file mode 100644 index 56b89566..00000000 --- a/helpers/functions.map.ts +++ /dev/null @@ -1,21 +0,0 @@ -import fs from 'node:fs/promises' - -let mapSVGs: string[] | undefined - -export async function getMapSVGs(): Promise { - if (mapSVGs === undefined) { - const files = await fs.readdir('./public/images/maps/') - - const SVGs: string[] = [] - - for (const file of files) { - if (file.toLowerCase().endsWith('.svg')) { - SVGs.push(file) - } - } - - mapSVGs = SVGs - } - - return mapSVGs -} diff --git a/helpers/functions.print.js b/helpers/functions.print.js index ac6a5073..73a1d94b 100644 --- a/helpers/functions.print.js +++ b/helpers/functions.print.js @@ -2,7 +2,7 @@ import * as dateTimeFunctions from '@cityssm/utils-datetime'; import getLot from '../database/getLot.js'; import getLotOccupancy from '../database/getLotOccupancy.js'; import getWorkOrder from '../database/getWorkOrder.js'; -import * as configFunctions from './functions.config.js'; +import * as configFunctions from './config.helpers.js'; import * as lotOccupancyFunctions from './functions.lotOccupancy.js'; const screenPrintConfigs = { lotOccupancy: { diff --git a/helpers/functions.print.ts b/helpers/functions.print.ts index 5f2fe29c..020aacb3 100644 --- a/helpers/functions.print.ts +++ b/helpers/functions.print.ts @@ -5,7 +5,7 @@ import getLotOccupancy from '../database/getLotOccupancy.js' import getWorkOrder from '../database/getWorkOrder.js' import type { Lot, LotOccupancy, WorkOrder } from '../types/recordTypes.js' -import * as configFunctions from './functions.config.js' +import * as configFunctions from './config.helpers.js' import * as lotOccupancyFunctions from './functions.lotOccupancy.js' interface PrintConfig { diff --git a/helpers/functions.user.js b/helpers/functions.user.js index c259b894..0863eba2 100644 --- a/helpers/functions.user.js +++ b/helpers/functions.user.js @@ -1,5 +1,5 @@ import { getUserNameFromApiKey } from './functions.api.js'; -import { getConfigProperty } from './functions.config.js'; +import { getConfigProperty } from './config.helpers.js'; export function userIsAdmin(request) { return request.session?.user?.userProperties?.isAdmin ?? false; } diff --git a/helpers/functions.user.ts b/helpers/functions.user.ts index 2eaabf14..2533ab1a 100644 --- a/helpers/functions.user.ts +++ b/helpers/functions.user.ts @@ -1,5 +1,5 @@ import { getUserNameFromApiKey } from './functions.api.js' -import { getConfigProperty } from './functions.config.js' +import { getConfigProperty } from './config.helpers.js' export interface UserRequest { session?: { diff --git a/helpers/initializer.database.cemetery.d.ts b/helpers/initializer.database.cemetery.d.ts deleted file mode 100644 index bd4e162f..00000000 --- a/helpers/initializer.database.cemetery.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function initializeCemeteryDatabase(): Promise; diff --git a/helpers/initializer.database.cemetery.js b/helpers/initializer.database.cemetery.js deleted file mode 100644 index 589f452c..00000000 --- a/helpers/initializer.database.cemetery.js +++ /dev/null @@ -1,245 +0,0 @@ -// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair -/* eslint-disable @typescript-eslint/no-magic-numbers */ -import Debug from 'debug'; -import { lotOccupancyDB as databasePath } from '../data/databasePaths.js'; -import addFeeCategory from '../database/addFeeCategory.js'; -import addLotOccupantType from '../database/addLotOccupantType.js'; -import addOccupancyTypeField from '../database/addOccupancyTypeField.js'; -import { addRecord } from '../database/addRecord.js'; -import { initializeDatabase } from './initializer.database.js'; -const debug = Debug('lot-occupancy-system:initialize'); -const user = { - userName: 'init.cemetery', - userProperties: { - canUpdate: true, - isAdmin: true, - apiKey: '' - } -}; -export async function initializeCemeteryDatabase() { - /* - * Ensure database does not already exist - */ - debug(`Checking for ${databasePath}...`); - const databaseInitialized = initializeDatabase(); - if (!databaseInitialized) { - debug('Database already created.\n' + - 'To initialize this database with cemetery types, delete the database file first, then rerun this script.'); - return false; - } - debug('New database file created. Proceeding with initialization.'); - /* - * Lot Types - */ - await addRecord('LotTypes', 'Casket Grave', 1, user); - await addRecord('LotTypes', 'Columbarium', 2, user); - await addRecord('LotTypes', 'Mausoleum', 2, user); - await addRecord('LotTypes', 'Niche Wall', 2, user); - await addRecord('LotTypes', 'Urn Garden', 2, user); - await addRecord('LotTypes', 'Crematorium', 2, user); - /* - * Lot Statuses - */ - await addRecord('LotStatuses', 'Available', 1, user); - await addRecord('LotStatuses', 'Reserved', 2, user); - await addRecord('LotStatuses', 'Taken', 3, user); - /* - * Lot Occupant Types - */ - await addLotOccupantType({ - lotOccupantType: 'Deceased', - fontAwesomeIconClass: 'cross', - orderNumber: 1 - }, user); - await addLotOccupantType({ - lotOccupantType: 'Funeral Director', - fontAwesomeIconClass: 'church', - orderNumber: 2 - }, user); - await addLotOccupantType({ - lotOccupantType: 'Preneed Owner', - fontAwesomeIconClass: 'user', - orderNumber: 3 - }, user); - await addLotOccupantType({ - lotOccupantType: 'Purchaser', - fontAwesomeIconClass: 'hand-holding-usd', - occupantCommentTitle: 'Relationship to Owner/Deceased', - orderNumber: 4 - }, user); - /* - * Occupancy Types - */ - await addRecord('OccupancyTypes', 'Preneed', 1, user); - const intermentOccupancyTypeId = await addRecord('OccupancyTypes', 'Interment', 2, user); - const cremationOccupancyTypeId = await addRecord('OccupancyTypes', 'Cremation', 3, user); - // Birth Date - const birthDateField = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Birth Date', - occupancyTypeFieldValues: '', - pattern: String.raw `\d{4}-\d{2}-\d{2}`, - isRequired: '', - minimumLength: 10, - maximumLength: 10, - orderNumber: 1 - }; - await addOccupancyTypeField(birthDateField, user); - await addOccupancyTypeField(Object.assign(birthDateField, { - occupancyTypeId: cremationOccupancyTypeId - }), user); - // Birth Place - const birthPlace = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Birth Place', - occupancyTypeFieldValues: '', - pattern: '', - isRequired: '', - minimumLength: 1, - maximumLength: 100, - orderNumber: 2 - }; - await addOccupancyTypeField(birthPlace, user); - await addOccupancyTypeField(Object.assign(birthPlace, { occupancyTypeId: cremationOccupancyTypeId }), user); - // Death Date - const deathDateField = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Death Date', - occupancyTypeFieldValues: '', - pattern: String.raw `\d{4}-\d{2}-\d{2}`, - isRequired: '', - minimumLength: 10, - maximumLength: 10, - orderNumber: 3 - }; - await addOccupancyTypeField(deathDateField, user); - await addOccupancyTypeField(Object.assign(deathDateField, { - occupancyTypeId: cremationOccupancyTypeId - }), user); - // Death Age - const deathAgeField = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Death Age', - occupancyTypeFieldValues: '', - pattern: String.raw `\d+`, - isRequired: '', - minimumLength: 1, - maximumLength: 3, - orderNumber: 4 - }; - await addOccupancyTypeField(deathAgeField, user); - await addOccupancyTypeField(Object.assign(deathAgeField, { occupancyTypeId: cremationOccupancyTypeId }), user); - // Death Age Period - const deathAgePeriod = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Death Age Period', - fieldType: 'select', - occupancyTypeFieldValues: 'Years\nMonths\nDays\nStillborn', - pattern: '', - isRequired: '', - minimumLength: 1, - maximumLength: 10, - orderNumber: 5 - }; - await addOccupancyTypeField(deathAgePeriod, user); - await addOccupancyTypeField(Object.assign(deathAgePeriod, { - occupancyTypeId: cremationOccupancyTypeId - }), user); - // Death Place - const deathPlace = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Death Place', - occupancyTypeFieldValues: '', - pattern: '', - isRequired: '', - minimumLength: 1, - maximumLength: 100, - orderNumber: 6 - }; - await addOccupancyTypeField(deathPlace, user); - await addOccupancyTypeField(Object.assign(deathPlace, { occupancyTypeId: cremationOccupancyTypeId }), user); - // Funeral Home - const funeralHome = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Funeral Home', - occupancyTypeFieldValues: '', - pattern: '', - isRequired: '', - minimumLength: 1, - maximumLength: 100, - orderNumber: 10 - }; - await addOccupancyTypeField(funeralHome, user); - await addOccupancyTypeField(Object.assign(funeralHome, { occupancyTypeId: cremationOccupancyTypeId }), user); - // Funeral Date - const funeralDate = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Funeral Date', - occupancyTypeFieldValues: '', - pattern: String.raw `\d{4}-\d{2}-\d{2}`, - isRequired: '', - minimumLength: 10, - maximumLength: 10, - orderNumber: 11 - }; - await addOccupancyTypeField(funeralDate, user); - await addOccupancyTypeField(Object.assign(funeralDate, { occupancyTypeId: cremationOccupancyTypeId }), user); - // Container Type - const containerType = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Container Type', - occupancyTypeFieldValues: '', - pattern: '', - isRequired: '', - minimumLength: 1, - maximumLength: 100, - orderNumber: 20 - }; - await addOccupancyTypeField(containerType, user); - await addOccupancyTypeField(Object.assign(containerType, { occupancyTypeId: cremationOccupancyTypeId }), user); - // Committal Type - const committalType = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Committal Type', - occupancyTypeFieldValues: '', - pattern: '', - isRequired: '', - minimumLength: 1, - maximumLength: 100, - orderNumber: 21 - }; - await addOccupancyTypeField(committalType, user); - await addOccupancyTypeField(Object.assign(committalType, { occupancyTypeId: cremationOccupancyTypeId }), user); - /* - * Fee Categories - */ - await addFeeCategory({ - feeCategory: 'Interment Rights', - orderNumber: 1 - }, user); - await addFeeCategory({ - feeCategory: 'Cremation Services', - orderNumber: 2 - }, user); - await addFeeCategory({ - feeCategory: 'Burial Charges', - orderNumber: 3 - }, user); - await addFeeCategory({ - feeCategory: 'Disinterment of Human Remains', - orderNumber: 4 - }, user); - await addFeeCategory({ - feeCategory: 'Additional Services', - orderNumber: 5 - }, user); - /* - * Work Orders - */ - await addRecord('WorkOrderTypes', 'Cemetery Work Order', 1, user); - await addRecord('WorkOrderMilestoneTypes', 'Funeral', 1, user); - await addRecord('WorkOrderMilestoneTypes', 'Arrival', 2, user); - await addRecord('WorkOrderMilestoneTypes', 'Cremation', 3, user); - await addRecord('WorkOrderMilestoneTypes', 'Interment', 4, user); - return true; -} diff --git a/helpers/initializer.database.cemetery.ts b/helpers/initializer.database.cemetery.ts deleted file mode 100644 index 63d2ad92..00000000 --- a/helpers/initializer.database.cemetery.ts +++ /dev/null @@ -1,383 +0,0 @@ -// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair -/* eslint-disable @typescript-eslint/no-magic-numbers */ - -import Debug from 'debug' - -import { lotOccupancyDB as databasePath } from '../data/databasePaths.js' -import addFeeCategory from '../database/addFeeCategory.js' -import addLotOccupantType from '../database/addLotOccupantType.js' -import addOccupancyTypeField from '../database/addOccupancyTypeField.js' -import { addRecord } from '../database/addRecord.js' - -import { initializeDatabase } from './initializer.database.js' - -const debug = Debug('lot-occupancy-system:initialize') - -const user: User = { - userName: 'init.cemetery', - userProperties: { - canUpdate: true, - isAdmin: true, - apiKey: '' - } -} - -export async function initializeCemeteryDatabase(): Promise { - /* - * Ensure database does not already exist - */ - debug(`Checking for ${databasePath}...`) - - const databaseInitialized = initializeDatabase() - - if (!databaseInitialized) { - debug( - 'Database already created.\n' + - 'To initialize this database with cemetery types, delete the database file first, then rerun this script.' - ) - return false - } - - debug('New database file created. Proceeding with initialization.') - - /* - * Lot Types - */ - - await addRecord('LotTypes', 'Casket Grave', 1, user) - await addRecord('LotTypes', 'Columbarium', 2, user) - await addRecord('LotTypes', 'Mausoleum', 2, user) - await addRecord('LotTypes', 'Niche Wall', 2, user) - await addRecord('LotTypes', 'Urn Garden', 2, user) - await addRecord('LotTypes', 'Crematorium', 2, user) - - /* - * Lot Statuses - */ - - await addRecord('LotStatuses', 'Available', 1, user) - await addRecord('LotStatuses', 'Reserved', 2, user) - await addRecord('LotStatuses', 'Taken', 3, user) - - /* - * Lot Occupant Types - */ - - await addLotOccupantType( - { - lotOccupantType: 'Deceased', - fontAwesomeIconClass: 'cross', - orderNumber: 1 - }, - user - ) - - await addLotOccupantType( - { - lotOccupantType: 'Funeral Director', - fontAwesomeIconClass: 'church', - orderNumber: 2 - }, - user - ) - - await addLotOccupantType( - { - lotOccupantType: 'Preneed Owner', - fontAwesomeIconClass: 'user', - orderNumber: 3 - }, - user - ) - - await addLotOccupantType( - { - lotOccupantType: 'Purchaser', - fontAwesomeIconClass: 'hand-holding-usd', - occupantCommentTitle: 'Relationship to Owner/Deceased', - orderNumber: 4 - }, - user - ) - - /* - * Occupancy Types - */ - - await addRecord('OccupancyTypes', 'Preneed', 1, user) - const intermentOccupancyTypeId = await addRecord( - 'OccupancyTypes', - 'Interment', - 2, - user - ) - const cremationOccupancyTypeId = await addRecord( - 'OccupancyTypes', - 'Cremation', - 3, - user - ) - - // Birth Date - - const birthDateField = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Birth Date', - occupancyTypeFieldValues: '', - pattern: String.raw`\d{4}-\d{2}-\d{2}`, - isRequired: '', - minimumLength: 10, - maximumLength: 10, - orderNumber: 1 - } - - await addOccupancyTypeField(birthDateField, user) - - await addOccupancyTypeField( - Object.assign(birthDateField, { - occupancyTypeId: cremationOccupancyTypeId - }), - user - ) - - // Birth Place - - const birthPlace = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Birth Place', - occupancyTypeFieldValues: '', - pattern: '', - isRequired: '', - minimumLength: 1, - maximumLength: 100, - orderNumber: 2 - } - - await addOccupancyTypeField(birthPlace, user) - - await addOccupancyTypeField( - Object.assign(birthPlace, { occupancyTypeId: cremationOccupancyTypeId }), - user - ) - - - // Death Date - - const deathDateField = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Death Date', - occupancyTypeFieldValues: '', - pattern: String.raw`\d{4}-\d{2}-\d{2}`, - isRequired: '', - minimumLength: 10, - maximumLength: 10, - orderNumber: 3 - } - - await addOccupancyTypeField(deathDateField, user) - - await addOccupancyTypeField( - Object.assign(deathDateField, { - occupancyTypeId: cremationOccupancyTypeId - }), - user - ) - - // Death Age - - const deathAgeField = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Death Age', - occupancyTypeFieldValues: '', - pattern: String.raw`\d+`, - isRequired: '', - minimumLength: 1, - maximumLength: 3, - orderNumber: 4 - } - - await addOccupancyTypeField(deathAgeField, user) - - await addOccupancyTypeField( - Object.assign(deathAgeField, { occupancyTypeId: cremationOccupancyTypeId }), - user - ) - - // Death Age Period - - const deathAgePeriod = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Death Age Period', - fieldType: 'select', - occupancyTypeFieldValues: 'Years\nMonths\nDays\nStillborn', - pattern: '', - isRequired: '', - minimumLength: 1, - maximumLength: 10, - orderNumber: 5 - } - - await addOccupancyTypeField(deathAgePeriod, user) - - await addOccupancyTypeField( - Object.assign(deathAgePeriod, { - occupancyTypeId: cremationOccupancyTypeId - }), - user - ) - - // Death Place - - const deathPlace = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Death Place', - occupancyTypeFieldValues: '', - pattern: '', - isRequired: '', - minimumLength: 1, - maximumLength: 100, - orderNumber: 6 - } - - await addOccupancyTypeField(deathPlace, user) - - await addOccupancyTypeField( - Object.assign(deathPlace, { occupancyTypeId: cremationOccupancyTypeId }), - user - ) - - // Funeral Home - - const funeralHome = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Funeral Home', - occupancyTypeFieldValues: '', - pattern: '', - isRequired: '', - minimumLength: 1, - maximumLength: 100, - orderNumber: 10 - } - - await addOccupancyTypeField(funeralHome, user) - - await addOccupancyTypeField( - Object.assign(funeralHome, { occupancyTypeId: cremationOccupancyTypeId }), - user - ) - - // Funeral Date - - const funeralDate = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Funeral Date', - occupancyTypeFieldValues: '', - pattern: String.raw`\d{4}-\d{2}-\d{2}`, - isRequired: '', - minimumLength: 10, - maximumLength: 10, - orderNumber: 11 - } - - await addOccupancyTypeField(funeralDate, user) - - await addOccupancyTypeField( - Object.assign(funeralDate, { occupancyTypeId: cremationOccupancyTypeId }), - user - ) - - // Container Type - const containerType = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Container Type', - occupancyTypeFieldValues: '', - pattern: '', - isRequired: '', - minimumLength: 1, - maximumLength: 100, - orderNumber: 20 - } - - await addOccupancyTypeField(containerType, user) - - await addOccupancyTypeField( - Object.assign(containerType, { occupancyTypeId: cremationOccupancyTypeId }), - user - ) - - // Committal Type - const committalType = { - occupancyTypeId: intermentOccupancyTypeId, - occupancyTypeField: 'Committal Type', - occupancyTypeFieldValues: '', - pattern: '', - isRequired: '', - minimumLength: 1, - maximumLength: 100, - orderNumber: 21 - } - - await addOccupancyTypeField(committalType, user) - - await addOccupancyTypeField( - Object.assign(committalType, { occupancyTypeId: cremationOccupancyTypeId }), - user - ) - - /* - * Fee Categories - */ - - await addFeeCategory( - { - feeCategory: 'Interment Rights', - orderNumber: 1 - }, - user - ) - - await addFeeCategory( - { - feeCategory: 'Cremation Services', - orderNumber: 2 - }, - user - ) - - await addFeeCategory( - { - feeCategory: 'Burial Charges', - orderNumber: 3 - }, - user - ) - - await addFeeCategory( - { - feeCategory: 'Disinterment of Human Remains', - orderNumber: 4 - }, - user - ) - - await addFeeCategory( - { - feeCategory: 'Additional Services', - orderNumber: 5 - }, - user - ) - - /* - * Work Orders - */ - - await addRecord('WorkOrderTypes', 'Cemetery Work Order', 1, user) - - await addRecord('WorkOrderMilestoneTypes', 'Funeral', 1, user) - await addRecord('WorkOrderMilestoneTypes', 'Arrival', 2, user) - await addRecord('WorkOrderMilestoneTypes', 'Cremation', 3, user) - await addRecord('WorkOrderMilestoneTypes', 'Interment', 4, user) - - return true -} diff --git a/helpers/initializer.database.d.ts b/helpers/initializer.database.d.ts deleted file mode 100644 index cab8f5f1..00000000 --- a/helpers/initializer.database.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function initializeDatabase(): boolean; diff --git a/helpers/initializer.database.js b/helpers/initializer.database.js deleted file mode 100644 index 9458960c..00000000 --- a/helpers/initializer.database.js +++ /dev/null @@ -1,127 +0,0 @@ -// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair -/* eslint-disable @cspell/spellchecker, no-secrets/no-secrets */ -import sqlite from 'better-sqlite3'; -import debug from 'debug'; -import { lotOccupancyDB as databasePath } from '../data/databasePaths.js'; -const debugSQL = debug('lot-occupancy-system:databaseInitializer'); -const recordColumns = `recordCreate_userName varchar(30) not null, - recordCreate_timeMillis integer not null, - recordUpdate_userName varchar(30) not null, - recordUpdate_timeMillis integer not null, - recordDelete_userName varchar(30), - recordDelete_timeMillis integer`; -const createStatements = [ - /* - * Lot Types - */ - `create table if not exists LotTypes ( - lotTypeId integer not null primary key autoincrement, lotType varchar(100) not null, orderNumber smallint not null default 0, ${recordColumns})`, - 'create index if not exists idx_lottypes_ordernumber on LotTypes (orderNumber, lotType)', - `create table if not exists LotTypeFields ( - lotTypeFieldId integer not null primary key autoincrement, lotTypeId integer not null, lotTypeField varchar(100) not null, - fieldType varchar(15) not null default 'text', - lotTypeFieldValues text, isRequired bit not null default 0, pattern varchar(100), - minimumLength smallint not null default 1 check (minimumLength >= 0), maximumLength smallint not null default 100 check (maximumLength >= 0), orderNumber smallint not null default 0, ${recordColumns}, - foreign key (lotTypeId) references LotTypes (lotTypeId))`, - 'create index if not exists idx_lottypefields_ordernumber on LotTypeFields (lotTypeId, orderNumber, lotTypeField)', - /* - * Lot Statuses - */ - `create table if not exists LotStatuses (lotStatusId integer not null primary key autoincrement, lotStatus varchar(100) not null, orderNumber smallint not null default 0, ${recordColumns})`, - 'create index if not exists idx_lotstatuses_ordernumber on LotStatuses (orderNumber, lotStatus)', - /* - * Maps and Lots - */ - `create table if not exists Maps (mapId integer not null primary key autoincrement, mapName varchar(200) not null, mapDescription text, mapLatitude decimal(10, 8) check (mapLatitude between -90 and 90), mapLongitude decimal(11, 8) check (mapLongitude between -180 and 180), mapSVG varchar(50), mapAddress1 varchar(50), mapAddress2 varchar(50), mapCity varchar(20), mapProvince varchar(2), mapPostalCode varchar(7), mapPhoneNumber varchar(30), ${recordColumns})`, - `create table if not exists Lots (lotId integer not null primary key autoincrement, lotTypeId integer not null, lotName varchar(100), mapId integer, mapKey varchar(100), lotLatitude decimal(10, 8) check (lotLatitude between -90 and 90), lotLongitude decimal(11, 8) check (lotLongitude between -180 and 180), lotStatusId integer, ${recordColumns}, foreign key (lotTypeId) references LotTypes (lotTypeId), foreign key (mapId) references Maps (mapId), foreign key (lotStatusId) references LotStatuses (lotStatusId))`, - `create table if not exists LotFields (lotId integer not null, lotTypeFieldId integer not null, lotFieldValue text not null, ${recordColumns}, primary key (lotId, lotTypeFieldId), foreign key (lotId) references Lots (lotId), foreign key (lotTypeFieldId) references LotTypeFields (lotTypeFieldId)) without rowid`, - `create table if not exists LotComments (lotCommentId integer not null primary key autoincrement, lotId integer not null, lotCommentDate integer not null check (lotCommentDate > 0), lotCommentTime integer not null check (lotCommentTime >= 0), lotComment text not null, ${recordColumns}, foreign key (lotId) references Lots (lotId))`, - 'create index if not exists idx_lotcomments_datetime on LotComments (lotId, lotCommentDate, lotCommentTime)', - /* - * Occupancies - */ - `create table if not exists OccupancyTypes (occupancyTypeId integer not null primary key autoincrement, occupancyType varchar(100) not null, orderNumber smallint not null default 0, ${recordColumns})`, - 'create index if not exists idx_occupancytypes_ordernumber on OccupancyTypes (orderNumber, occupancyType)', - `create table if not exists OccupancyTypeFields ( - occupancyTypeFieldId integer not null primary key autoincrement, occupancyTypeId integer, occupancyTypeField varchar(100) not null, - fieldType varchar(15) not null default 'text', - occupancyTypeFieldValues text, isRequired bit not null default 0, pattern varchar(100), - minimumLength smallint not null default 1 check (minimumLength >= 0), maximumLength smallint not null default 100 check (maximumLength >= 0), orderNumber smallint not null default 0, ${recordColumns}, - foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId))`, - 'create index if not exists idx_occupancytypefields_ordernumber on OccupancyTypeFields (occupancyTypeId, orderNumber, occupancyTypeField)', - `create table if not exists OccupancyTypePrints (occupancyTypeId integer not null, printEJS varchar(100) not null, orderNumber smallint not null default 0, ${recordColumns}, primary key (occupancyTypeId, printEJS), foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId))`, - 'create index if not exists idx_occupancytypeprints_ordernumber on OccupancyTypePrints (occupancyTypeId, orderNumber, printEJS)', - `create table if not exists LotOccupantTypes ( - lotOccupantTypeId integer not null primary key autoincrement, - lotOccupantType varchar(100) not null, - fontAwesomeIconClass varchar(50) not null default '', - occupantCommentTitle varchar(50) not null default '', - orderNumber smallint not null default 0, - ${recordColumns})`, - 'create index if not exists idx_lotoccupanttypes_ordernumber on LotOccupantTypes (orderNumber, lotOccupantType)', - `create table if not exists LotOccupancies (lotOccupancyId integer not null primary key autoincrement, occupancyTypeId integer not null, lotId integer, occupancyStartDate integer not null check (occupancyStartDate > 0), occupancyEndDate integer check (occupancyEndDate > 0), ${recordColumns}, foreign key (lotId) references Lots (lotId), foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId))`, - `create table if not exists LotOccupancyOccupants (lotOccupancyId integer not null, lotOccupantIndex integer not null, occupantName varchar(200) not null, occupantAddress1 varchar(50), occupantAddress2 varchar(50), occupantCity varchar(20), occupantProvince varchar(2), occupantPostalCode varchar(7), occupantPhoneNumber varchar(30), occupantEmailAddress varchar(200), lotOccupantTypeId integer not null, occupantComment text not null default '', ${recordColumns}, primary key (lotOccupancyId, lotOccupantIndex), foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId), foreign key (lotOccupantTypeId) references LotOccupantTypes (lotOccupantTypeId)) without rowid`, - `create table if not exists LotOccupancyFields (lotOccupancyId integer not null, occupancyTypeFieldId integer not null, lotOccupancyFieldValue text not null, ${recordColumns}, primary key (lotOccupancyId, occupancyTypeFieldId), foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId), foreign key (occupancyTypeFieldId) references OccupancyTypeFields (occupancyTypeFieldId)) without rowid`, - `create table if not exists LotOccupancyComments (lotOccupancyCommentId integer not null primary key autoincrement, lotOccupancyId integer not null, lotOccupancyCommentDate integer not null check (lotOccupancyCommentDate > 0), lotOccupancyCommentTime integer not null check (lotOccupancyCommentTime >= 0), lotOccupancyComment text not null, ${recordColumns}, foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId))`, - 'create index if not exists idx_lotoccupancycomments_datetime on LotOccupancyComments (lotOccupancyId, lotOccupancyCommentDate, lotOccupancyCommentTime)', - /* - * Fees and Transactions - */ - `create table if not exists FeeCategories ( - feeCategoryId integer not null primary key autoincrement, - feeCategory varchar(100) not null, - isGroupedFee bit not null default 0, - orderNumber smallint not null default 0, - ${recordColumns})`, - `create table if not exists Fees ( - feeId integer not null primary key autoincrement, - feeCategoryId integer not null, - feeName varchar(100) not null, - feeDescription text, - feeAccount varchar(20), - occupancyTypeId integer, - lotTypeId integer, - includeQuantity boolean not null default 0, - quantityUnit varchar(30), - feeAmount decimal(8, 2), - feeFunction varchar(100), - taxAmount decimal(6, 2), - taxPercentage decimal(5, 2), - isRequired bit not null default 0, - orderNumber smallint not null default 0, - ${recordColumns}, - foreign key (feeCategoryId) references FeeCategories (feeCategoryId), - foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId), - foreign key (lotTypeId) references LotTypes (lotTypeId))`, - 'create index if not exists idx_fees_ordernumber on Fees (orderNumber, feeName)', - `create table if not exists LotOccupancyFees (lotOccupancyId integer not null, feeId integer not null, quantity decimal(4, 1) not null default 1, feeAmount decimal(8, 2) not null, taxAmount decmial(8, 2) not null, ${recordColumns}, primary key (lotOccupancyId, feeId), foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId), foreign key (feeId) references Fees (feeId)) without rowid`, - `create table if not exists LotOccupancyTransactions (lotOccupancyId integer not null, transactionIndex integer not null, transactionDate integer not null check (transactionDate > 0), transactionTime integer not null check (transactionTime >= 0), transactionAmount decimal(8, 2) not null, externalReceiptNumber varchar(100), transactionNote text, ${recordColumns}, primary key (lotOccupancyId, transactionIndex), foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)) without rowid`, - 'create index if not exists idx_lotoccupancytransactions_ordernumber on LotOccupancyTransactions (lotOccupancyId, transactionDate, transactionTime)', - /* - * Work Orders - */ - `create table if not exists WorkOrderTypes (workOrderTypeId integer not null primary key autoincrement, workOrderType varchar(100) not null, orderNumber smallint not null default 0, ${recordColumns})`, - 'create index if not exists idx_workordertypes_ordernumber on WorkOrderTypes (orderNumber, workOrderType)', - `create table if not exists WorkOrders (workOrderId integer not null primary key autoincrement, workOrderTypeId integer not null, workOrderNumber varchar(50) not null, workOrderDescription text, workOrderOpenDate integer check (workOrderOpenDate > 0), workOrderCloseDate integer check (workOrderCloseDate > 0), ${recordColumns}, foreign key (workOrderTypeId) references WorkOrderTypes (workOrderTypeId))`, - `create table if not exists WorkOrderLots (workOrderId integer not null, lotId integer not null, ${recordColumns}, primary key (workOrderId, lotId), foreign key (workOrderId) references WorkOrders (workOrderId), foreign key (lotId) references Lots (lotId)) without rowid`, - `create table if not exists WorkOrderLotOccupancies (workOrderId integer not null, lotOccupancyId integer not null, ${recordColumns}, primary key (workOrderId, lotOccupancyId), foreign key (workOrderId) references WorkOrders (workOrderId), foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)) without rowid`, - `create table if not exists WorkOrderComments (workOrderCommentId integer not null primary key autoincrement, workOrderId integer not null, workOrderCommentDate integer not null check (workOrderCommentDate > 0), workOrderCommentTime integer not null check (workOrderCommentTime >= 0), workOrderComment text not null, ${recordColumns}, foreign key (workOrderId) references WorkOrders (workOrderId))`, - 'create index if not exists idx_workordercomments_datetime on WorkOrderComments (workOrderId, workOrderCommentDate, workOrderCommentTime)', - `create table if not exists WorkOrderMilestoneTypes (workOrderMilestoneTypeId integer not null primary key autoincrement, workOrderMilestoneType varchar(100) not null, orderNumber smallint not null default 0, ${recordColumns})`, - `create table if not exists WorkOrderMilestones (workOrderMilestoneId integer not null primary key autoincrement, workOrderId integer not null, workOrderMilestoneTypeId integer, workOrderMilestoneDate integer not null check (workOrderMilestoneDate >= 0), workOrderMilestoneTime integer not null check (workOrderMilestoneTime >= 0), workOrderMilestoneDescription text not null, workOrderMilestoneCompletionDate integer check (workOrderMilestoneCompletionDate > 0), workOrderMilestoneCompletionTime integer check (workOrderMilestoneCompletionTime >= 0), ${recordColumns}, foreign key (workOrderId) references WorkOrders (workOrderId), foreign key (workOrderMilestoneTypeId) references WorkOrderMilestoneTypes (workOrderMilestoneTypeId))` -]; -export function initializeDatabase() { - const lotOccupancyDB = sqlite(databasePath); - const row = lotOccupancyDB - .prepare("select name from sqlite_master where type = 'table' and name = 'WorkOrderMilestones'") - .get(); - if (row === undefined) { - debugSQL(`Creating ${databasePath}`); - for (const sql of createStatements) { - lotOccupancyDB.prepare(sql).run(); - } - lotOccupancyDB.close(); - return true; - } - return false; -} diff --git a/helpers/initializer.database.ts b/helpers/initializer.database.ts deleted file mode 100644 index 304446a5..00000000 --- a/helpers/initializer.database.ts +++ /dev/null @@ -1,159 +0,0 @@ -// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair -/* eslint-disable @cspell/spellchecker, no-secrets/no-secrets */ - -import sqlite from 'better-sqlite3' -import debug from 'debug' - -import { lotOccupancyDB as databasePath } from '../data/databasePaths.js' - -const debugSQL = debug('lot-occupancy-system:databaseInitializer') - -const recordColumns = `recordCreate_userName varchar(30) not null, - recordCreate_timeMillis integer not null, - recordUpdate_userName varchar(30) not null, - recordUpdate_timeMillis integer not null, - recordDelete_userName varchar(30), - recordDelete_timeMillis integer` - -const createStatements = [ - /* - * Lot Types - */ - - `create table if not exists LotTypes ( - lotTypeId integer not null primary key autoincrement, lotType varchar(100) not null, orderNumber smallint not null default 0, ${recordColumns})`, - - 'create index if not exists idx_lottypes_ordernumber on LotTypes (orderNumber, lotType)', - - `create table if not exists LotTypeFields ( - lotTypeFieldId integer not null primary key autoincrement, lotTypeId integer not null, lotTypeField varchar(100) not null, - fieldType varchar(15) not null default 'text', - lotTypeFieldValues text, isRequired bit not null default 0, pattern varchar(100), - minimumLength smallint not null default 1 check (minimumLength >= 0), maximumLength smallint not null default 100 check (maximumLength >= 0), orderNumber smallint not null default 0, ${recordColumns}, - foreign key (lotTypeId) references LotTypes (lotTypeId))`, - - 'create index if not exists idx_lottypefields_ordernumber on LotTypeFields (lotTypeId, orderNumber, lotTypeField)', - - /* - * Lot Statuses - */ - - `create table if not exists LotStatuses (lotStatusId integer not null primary key autoincrement, lotStatus varchar(100) not null, orderNumber smallint not null default 0, ${recordColumns})`, - 'create index if not exists idx_lotstatuses_ordernumber on LotStatuses (orderNumber, lotStatus)', - - /* - * Maps and Lots - */ - - `create table if not exists Maps (mapId integer not null primary key autoincrement, mapName varchar(200) not null, mapDescription text, mapLatitude decimal(10, 8) check (mapLatitude between -90 and 90), mapLongitude decimal(11, 8) check (mapLongitude between -180 and 180), mapSVG varchar(50), mapAddress1 varchar(50), mapAddress2 varchar(50), mapCity varchar(20), mapProvince varchar(2), mapPostalCode varchar(7), mapPhoneNumber varchar(30), ${recordColumns})`, - `create table if not exists Lots (lotId integer not null primary key autoincrement, lotTypeId integer not null, lotName varchar(100), mapId integer, mapKey varchar(100), lotLatitude decimal(10, 8) check (lotLatitude between -90 and 90), lotLongitude decimal(11, 8) check (lotLongitude between -180 and 180), lotStatusId integer, ${recordColumns}, foreign key (lotTypeId) references LotTypes (lotTypeId), foreign key (mapId) references Maps (mapId), foreign key (lotStatusId) references LotStatuses (lotStatusId))`, - `create table if not exists LotFields (lotId integer not null, lotTypeFieldId integer not null, lotFieldValue text not null, ${recordColumns}, primary key (lotId, lotTypeFieldId), foreign key (lotId) references Lots (lotId), foreign key (lotTypeFieldId) references LotTypeFields (lotTypeFieldId)) without rowid`, - `create table if not exists LotComments (lotCommentId integer not null primary key autoincrement, lotId integer not null, lotCommentDate integer not null check (lotCommentDate > 0), lotCommentTime integer not null check (lotCommentTime >= 0), lotComment text not null, ${recordColumns}, foreign key (lotId) references Lots (lotId))`, - 'create index if not exists idx_lotcomments_datetime on LotComments (lotId, lotCommentDate, lotCommentTime)', - - /* - * Occupancies - */ - - `create table if not exists OccupancyTypes (occupancyTypeId integer not null primary key autoincrement, occupancyType varchar(100) not null, orderNumber smallint not null default 0, ${recordColumns})`, - 'create index if not exists idx_occupancytypes_ordernumber on OccupancyTypes (orderNumber, occupancyType)', - - `create table if not exists OccupancyTypeFields ( - occupancyTypeFieldId integer not null primary key autoincrement, occupancyTypeId integer, occupancyTypeField varchar(100) not null, - fieldType varchar(15) not null default 'text', - occupancyTypeFieldValues text, isRequired bit not null default 0, pattern varchar(100), - minimumLength smallint not null default 1 check (minimumLength >= 0), maximumLength smallint not null default 100 check (maximumLength >= 0), orderNumber smallint not null default 0, ${recordColumns}, - foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId))`, - - 'create index if not exists idx_occupancytypefields_ordernumber on OccupancyTypeFields (occupancyTypeId, orderNumber, occupancyTypeField)', - `create table if not exists OccupancyTypePrints (occupancyTypeId integer not null, printEJS varchar(100) not null, orderNumber smallint not null default 0, ${recordColumns}, primary key (occupancyTypeId, printEJS), foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId))`, - 'create index if not exists idx_occupancytypeprints_ordernumber on OccupancyTypePrints (occupancyTypeId, orderNumber, printEJS)', - `create table if not exists LotOccupantTypes ( - lotOccupantTypeId integer not null primary key autoincrement, - lotOccupantType varchar(100) not null, - fontAwesomeIconClass varchar(50) not null default '', - occupantCommentTitle varchar(50) not null default '', - orderNumber smallint not null default 0, - ${recordColumns})`, - - 'create index if not exists idx_lotoccupanttypes_ordernumber on LotOccupantTypes (orderNumber, lotOccupantType)', - `create table if not exists LotOccupancies (lotOccupancyId integer not null primary key autoincrement, occupancyTypeId integer not null, lotId integer, occupancyStartDate integer not null check (occupancyStartDate > 0), occupancyEndDate integer check (occupancyEndDate > 0), ${recordColumns}, foreign key (lotId) references Lots (lotId), foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId))`, - `create table if not exists LotOccupancyOccupants (lotOccupancyId integer not null, lotOccupantIndex integer not null, occupantName varchar(200) not null, occupantAddress1 varchar(50), occupantAddress2 varchar(50), occupantCity varchar(20), occupantProvince varchar(2), occupantPostalCode varchar(7), occupantPhoneNumber varchar(30), occupantEmailAddress varchar(200), lotOccupantTypeId integer not null, occupantComment text not null default '', ${recordColumns}, primary key (lotOccupancyId, lotOccupantIndex), foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId), foreign key (lotOccupantTypeId) references LotOccupantTypes (lotOccupantTypeId)) without rowid`, - `create table if not exists LotOccupancyFields (lotOccupancyId integer not null, occupancyTypeFieldId integer not null, lotOccupancyFieldValue text not null, ${recordColumns}, primary key (lotOccupancyId, occupancyTypeFieldId), foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId), foreign key (occupancyTypeFieldId) references OccupancyTypeFields (occupancyTypeFieldId)) without rowid`, - `create table if not exists LotOccupancyComments (lotOccupancyCommentId integer not null primary key autoincrement, lotOccupancyId integer not null, lotOccupancyCommentDate integer not null check (lotOccupancyCommentDate > 0), lotOccupancyCommentTime integer not null check (lotOccupancyCommentTime >= 0), lotOccupancyComment text not null, ${recordColumns}, foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId))`, - 'create index if not exists idx_lotoccupancycomments_datetime on LotOccupancyComments (lotOccupancyId, lotOccupancyCommentDate, lotOccupancyCommentTime)', - - /* - * Fees and Transactions - */ - - `create table if not exists FeeCategories ( - feeCategoryId integer not null primary key autoincrement, - feeCategory varchar(100) not null, - isGroupedFee bit not null default 0, - orderNumber smallint not null default 0, - ${recordColumns})`, - - `create table if not exists Fees ( - feeId integer not null primary key autoincrement, - feeCategoryId integer not null, - feeName varchar(100) not null, - feeDescription text, - feeAccount varchar(20), - occupancyTypeId integer, - lotTypeId integer, - includeQuantity boolean not null default 0, - quantityUnit varchar(30), - feeAmount decimal(8, 2), - feeFunction varchar(100), - taxAmount decimal(6, 2), - taxPercentage decimal(5, 2), - isRequired bit not null default 0, - orderNumber smallint not null default 0, - ${recordColumns}, - foreign key (feeCategoryId) references FeeCategories (feeCategoryId), - foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId), - foreign key (lotTypeId) references LotTypes (lotTypeId))`, - 'create index if not exists idx_fees_ordernumber on Fees (orderNumber, feeName)', - `create table if not exists LotOccupancyFees (lotOccupancyId integer not null, feeId integer not null, quantity decimal(4, 1) not null default 1, feeAmount decimal(8, 2) not null, taxAmount decmial(8, 2) not null, ${recordColumns}, primary key (lotOccupancyId, feeId), foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId), foreign key (feeId) references Fees (feeId)) without rowid`, - `create table if not exists LotOccupancyTransactions (lotOccupancyId integer not null, transactionIndex integer not null, transactionDate integer not null check (transactionDate > 0), transactionTime integer not null check (transactionTime >= 0), transactionAmount decimal(8, 2) not null, externalReceiptNumber varchar(100), transactionNote text, ${recordColumns}, primary key (lotOccupancyId, transactionIndex), foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)) without rowid`, - 'create index if not exists idx_lotoccupancytransactions_ordernumber on LotOccupancyTransactions (lotOccupancyId, transactionDate, transactionTime)', - - /* - * Work Orders - */ - - `create table if not exists WorkOrderTypes (workOrderTypeId integer not null primary key autoincrement, workOrderType varchar(100) not null, orderNumber smallint not null default 0, ${recordColumns})`, - 'create index if not exists idx_workordertypes_ordernumber on WorkOrderTypes (orderNumber, workOrderType)', - `create table if not exists WorkOrders (workOrderId integer not null primary key autoincrement, workOrderTypeId integer not null, workOrderNumber varchar(50) not null, workOrderDescription text, workOrderOpenDate integer check (workOrderOpenDate > 0), workOrderCloseDate integer check (workOrderCloseDate > 0), ${recordColumns}, foreign key (workOrderTypeId) references WorkOrderTypes (workOrderTypeId))`, - `create table if not exists WorkOrderLots (workOrderId integer not null, lotId integer not null, ${recordColumns}, primary key (workOrderId, lotId), foreign key (workOrderId) references WorkOrders (workOrderId), foreign key (lotId) references Lots (lotId)) without rowid`, - `create table if not exists WorkOrderLotOccupancies (workOrderId integer not null, lotOccupancyId integer not null, ${recordColumns}, primary key (workOrderId, lotOccupancyId), foreign key (workOrderId) references WorkOrders (workOrderId), foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)) without rowid`, - `create table if not exists WorkOrderComments (workOrderCommentId integer not null primary key autoincrement, workOrderId integer not null, workOrderCommentDate integer not null check (workOrderCommentDate > 0), workOrderCommentTime integer not null check (workOrderCommentTime >= 0), workOrderComment text not null, ${recordColumns}, foreign key (workOrderId) references WorkOrders (workOrderId))`, - 'create index if not exists idx_workordercomments_datetime on WorkOrderComments (workOrderId, workOrderCommentDate, workOrderCommentTime)', - `create table if not exists WorkOrderMilestoneTypes (workOrderMilestoneTypeId integer not null primary key autoincrement, workOrderMilestoneType varchar(100) not null, orderNumber smallint not null default 0, ${recordColumns})`, - `create table if not exists WorkOrderMilestones (workOrderMilestoneId integer not null primary key autoincrement, workOrderId integer not null, workOrderMilestoneTypeId integer, workOrderMilestoneDate integer not null check (workOrderMilestoneDate >= 0), workOrderMilestoneTime integer not null check (workOrderMilestoneTime >= 0), workOrderMilestoneDescription text not null, workOrderMilestoneCompletionDate integer check (workOrderMilestoneCompletionDate > 0), workOrderMilestoneCompletionTime integer check (workOrderMilestoneCompletionTime >= 0), ${recordColumns}, foreign key (workOrderId) references WorkOrders (workOrderId), foreign key (workOrderMilestoneTypeId) references WorkOrderMilestoneTypes (workOrderMilestoneTypeId))` -] - -export function initializeDatabase(): boolean { - const lotOccupancyDB = sqlite(databasePath) - - const row = lotOccupancyDB - .prepare( - "select name from sqlite_master where type = 'table' and name = 'WorkOrderMilestones'" - ) - .get() - - if (row === undefined) { - debugSQL(`Creating ${databasePath}`) - - for (const sql of createStatements) { - lotOccupancyDB.prepare(sql).run() - } - - lotOccupancyDB.close() - - return true - } - - return false -} diff --git a/package-lock.json b/package-lock.json index bc78a85d..b2ffe7ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "lot-occupancy-system", - "version": "1.0.0-alpha.14", + "name": "sunrise-cms", + "version": "1.0.0-dev", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "lot-occupancy-system", - "version": "1.0.0-alpha.14", + "name": "sunrise-cms", + "version": "1.0.0-dev", "license": "MIT", "dependencies": { "@cityssm/bulma-js": "^0.5.0", @@ -426,6 +426,7 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/@cityssm/configurator/-/configurator-0.1.0.tgz", "integrity": "sha512-MGklw25IFyovef5/pYXF3XePkbLDuW0DxKoqPlD8Cwmk/ySXDBhKsDdVgKVcGVRD70k8538PhN5vA4U9cVhtQw==", + "license": "MIT", "engines": { "node": ">=18.0.0" } diff --git a/package.json b/package.json index 212ebef9..75e6fb56 100644 --- a/package.json +++ b/package.json @@ -1,36 +1,36 @@ { - "name": "lot-occupancy-system", - "version": "1.0.0-alpha.14", + "name": "sunrise-cms", + "version": "1.0.0-dev", "type": "module", - "description": "A system for managing the occupancy of lots. (i.e. Cemetery management)", + "description": "Sunrise Cemetery Management System, a web-based application that allows cemetery managers to manage their cemetery records.", "exports": "./app.js", "engines": { "node": ">=18.0.0" }, "scripts": { "start": "cross-env NODE_ENV=production node ./bin/www.js", - "dev:test": "cross-env NODE_ENV=dev DEBUG=lot-occupancy-system:*,dynamics-gp:* TEST_DATABASES=true nodemon --inspect ./bin/www.js", - "dev:test:process": "cross-env NODE_ENV=dev DEBUG=lot-occupancy-system:* TEST_DATABASES=true nodemon --inspect ./bin/wwwProcess.js", - "dev:live": "cross-env NODE_ENV=dev DEBUG=lot-occupancy-system:* nodemon --inspect ./bin/www.js", + "dev:test": "cross-env NODE_ENV=dev DEBUG=sunrise:*,dynamics-gp:* TEST_DATABASES=true nodemon --inspect ./bin/www.js", + "dev:test:process": "cross-env NODE_ENV=dev DEBUG=sunrise:* TEST_DATABASES=true nodemon --inspect ./bin/wwwProcess.js", + "dev:live": "cross-env NODE_ENV=dev DEBUG=sunrise:* nodemon --inspect ./bin/www.js", "cy:open": "cypress open --config-file cypress.config.js", "cy:run": "cypress run --config-file cypress.config.js", "cy:run:firefox": "cypress run --config-file cypress.config.js --browser firefox", - "test": "cross-env NODE_ENV=dev DEBUG=lot-occupancy-system:* TEST_DATABASES=true mocha --timeout 30000 --exit", - "test:startup": "cross-env NODE_ENV=dev DEBUG=lot-occupancy-system:* TEST_DATABASES=true STARTUP_TEST=true node ./bin/www.js", - "coverage": "cross-env NODE_ENV=dev DEBUG=lot-occupancy-system:* TEST_DATABASES=true c8 --reporter=lcov --reporter=text --reporter=text-summary mocha --timeout 30000 --exit", - "temp:legacy:importFromCsv": "cross-env NODE_ENV=dev DEBUG=lot-occupancy-system:* TEST_DATABASES=true node ./temp/legacy.importFromCsv.js", + "test": "cross-env NODE_ENV=dev DEBUG=sunrise:* TEST_DATABASES=true mocha --timeout 30000 --exit", + "test:startup": "cross-env NODE_ENV=dev DEBUG=sunrise:* TEST_DATABASES=true STARTUP_TEST=true node ./bin/www.js", + "coverage": "cross-env NODE_ENV=dev DEBUG=sunrise:* TEST_DATABASES=true c8 --reporter=lcov --reporter=text --reporter=text-summary mocha --timeout 30000 --exit", + "temp:legacy:importFromCsv": "cross-env NODE_ENV=dev DEBUG=sunrise:* TEST_DATABASES=true node ./temp/legacy.importFromCsv.js", "temp:so:exportMaps": "node ./temp/so.exportMaps.js" }, "repository": { "type": "git", - "url": "git+https://github.com/cityssm/lot-occupancy-manager.git" + "url": "git+https://github.com/cityssm/sunrise-cms.git" }, "author": "The Corporation of the City of Sault Ste. Marie", "license": "MIT", "bugs": { - "url": "https://github.com/cityssm/lot-occupancy-manager/issues" + "url": "https://github.com/cityssm/sunrise-cms/issues" }, - "homepage": "https://github.com/cityssm/lot-occupancy-manager#readme", + "homepage": "https://github.com/cityssm/sunrise-cms#readme", "private": true, "dependencies": { "@cityssm/bulma-js": "^0.5.0", diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-A-rows-1-52.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-A-rows-1-52.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-A-rows-1-52.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-A-rows-1-52.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-A-rows-53-97.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-A-rows-53-97.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-A-rows-53-97.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-A-rows-53-97.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-A-rows-B-T.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-A-rows-B-T.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-A-rows-B-T.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-A-rows-B-T.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-A-urnRanges-52A-53A.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-A-urnRanges-52A-53A.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-A-urnRanges-52A-53A.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-A-urnRanges-52A-53A.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-A-urnRanges-72A-73A.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-A-urnRanges-72A-73A.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-A-urnRanges-72A-73A.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-A-urnRanges-72A-73A.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-A-urnRanges-97A-97B.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-A-urnRanges-97A-97B.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-A-urnRanges-97A-97B.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-A-urnRanges-97A-97B.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-B-rows-1-52.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-B-rows-1-52.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-B-rows-1-52.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-B-rows-1-52.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-B-rows-53-97.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-B-rows-53-97.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-B-rows-53-97.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-B-rows-53-97.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-B-rows-B-T.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-B-rows-B-T.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-B-rows-B-T.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-B-rows-B-T.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-C-rows-1-36.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-C-rows-1-36.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-C-rows-1-36.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-C-rows-1-36.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-C-rows-B-U.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-C-rows-B-U.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-C-rows-B-U.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-C-rows-B-U.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-D-babyShrine.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-D-babyShrine.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-D-babyShrine.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-D-babyShrine.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-D-rows-A-L.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-D-rows-A-L.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-D-rows-A-L.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-D-rows-A-L.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-D-rows-M-V.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-D-rows-M-V.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-D-rows-M-V.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-D-rows-M-V.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-E-sectionCenter.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-E-sectionCenter.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-E-sectionCenter.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-E-sectionCenter.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-E-sectionEast.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-E-sectionEast.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-E-sectionEast.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-E-sectionEast.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-E-sectionWest.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-E-sectionWest.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-E-sectionWest.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-E-sectionWest.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-F-rows-1-22.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-F-rows-1-22.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-F-rows-1-22.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-F-rows-1-22.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-G-rows-1-32.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-G-rows-1-32.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-G-rows-1-32.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-G-rows-1-32.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-H-rows-1-16.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-H-rows-1-16.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-H-rows-1-16.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-H-rows-1-16.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-J-rows-1-18.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-J-rows-1-18.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-J-rows-1-18.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-J-rows-1-18.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-block-K-rows-1-19.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-block-K-rows-1-19.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-block-K-rows-1-19.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-block-K-rows-1-19.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-columbarium-O-P.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-columbarium-O-P.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-columbarium-O-P.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-columbarium-O-P.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-columbarium-S.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-columbarium-S.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-columbarium-S.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-columbarium-S.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-columbarium-T.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-columbarium-T.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-columbarium-T.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-columbarium-T.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-columbarium-U.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-columbarium-U.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-columbarium-U.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-columbarium-U.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-columbarium-V.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-columbarium-V.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-columbarium-V.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-columbarium-V.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-columbarium-W.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-columbarium-W.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-columbarium-W.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-columbarium-W.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-image.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-image.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-image.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-image.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-mausoleum-east.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-east.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-mausoleum-east.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-east.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-mausoleum-image.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-image.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-mausoleum-image.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-image.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-mausoleum-niche-J-E.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-niche-J-E.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-mausoleum-niche-J-E.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-niche-J-E.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-mausoleum-niche-J-W.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-niche-J-W.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-mausoleum-niche-J-W.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-niche-J-W.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-mausoleum-niche-L-E.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-niche-L-E.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-mausoleum-niche-L-E.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-niche-L-E.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-mausoleum-niche-L-W.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-niche-L-W.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-mausoleum-niche-L-W.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-niche-L-W.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-mausoleum-niche-L.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-niche-L.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-mausoleum-niche-L.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-niche-L.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-mausoleum-niche-M-E.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-niche-M-E.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-mausoleum-niche-M-E.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-niche-M-E.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-mausoleum-niche-M-W.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-niche-M-W.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-mausoleum-niche-M-W.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-niche-M-W.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-mausoleum-niche-M.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-niche-M.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-mausoleum-niche-M.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-niche-M.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-mausoleum-section-T.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-section-T.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-mausoleum-section-T.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-section-T.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-mausoleum-section-U.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-section-U.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-mausoleum-section-U.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-section-U.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-mausoleum-west.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-west.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-mausoleum-west.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-mausoleum-west.svg diff --git a/public/images/maps/ssm.cemetery.holySepulchre-overview.svg b/public/images/cemeteries/ssm.cemetery.holySepulchre-overview.svg similarity index 100% rename from public/images/maps/ssm.cemetery.holySepulchre-overview.svg rename to public/images/cemeteries/ssm.cemetery.holySepulchre-overview.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-columbarium-A.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-A.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-columbarium-A.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-A.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-columbarium-B.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-B.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-columbarium-B.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-B.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-columbarium-C.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-C.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-columbarium-C.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-C.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-columbarium-D.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-D.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-columbarium-D.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-D.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-columbarium-E.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-E.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-columbarium-E.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-E.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-columbarium-F.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-F.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-columbarium-F.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-F.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-columbarium-G.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-G.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-columbarium-G.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-G.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-columbarium-H.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-H.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-columbarium-H.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-H.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-columbarium-I.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-I.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-columbarium-I.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-I.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-columbarium-J.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-J.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-columbarium-J.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-J.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-columbarium-K.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-K.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-columbarium-K.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-K.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-columbarium-L.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-L.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-columbarium-L.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-L.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-columbarium-M.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-M.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-columbarium-M.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-M.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-columbarium-N.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-N.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-columbarium-N.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-columbarium-N.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-image.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-image.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-image.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-image.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-infantsSection.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-infantsSection.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-infantsSection.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-infantsSection.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-nicheWall-1-40.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-nicheWall-1-40.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-nicheWall-1-40.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-nicheWall-1-40.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-nicheWall-41-80.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-nicheWall-41-80.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-nicheWall-41-80.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-nicheWall-41-80.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-nicheWall-81-106.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-nicheWall-81-106.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-nicheWall-81-106.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-nicheWall-81-106.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-overview.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-overview.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-overview.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-overview.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-rows-1-31-lots 3-21.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-rows-1-31-lots 3-21.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-rows-1-31-lots 3-21.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-rows-1-31-lots 3-21.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-rows-1-31-lots-22-46.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-rows-1-31-lots-22-46.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-rows-1-31-lots-22-46.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-rows-1-31-lots-22-46.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-rows-25-61-lots-47-59.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-rows-25-61-lots-47-59.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-rows-25-61-lots-47-59.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-rows-25-61-lots-47-59.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-rows-33-60-lots-4-21A.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-rows-33-60-lots-4-21A.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-rows-33-60-lots-4-21A.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-rows-33-60-lots-4-21A.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-rows-33-61-lots-22-46.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-rows-33-61-lots-22-46.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-rows-33-61-lots-22-46.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-rows-33-61-lots-22-46.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-rows-63-94-lots-24-40.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-rows-63-94-lots-24-40.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-rows-63-94-lots-24-40.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-rows-63-94-lots-24-40.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-rows-63-94-lots-47-59.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-rows-63-94-lots-47-59.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-rows-63-94-lots-47-59.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-rows-63-94-lots-47-59.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-rows-66-95-lots-12-24.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-rows-66-95-lots-12-24.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-rows-66-95-lots-12-24.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-rows-66-95-lots-12-24.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-urnGarden.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-urnGarden.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-urnGarden.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-urnGarden.svg diff --git a/public/images/maps/ssm.cemetery.newGreenwood-veteransSection.svg b/public/images/cemeteries/ssm.cemetery.newGreenwood-veteransSection.svg similarity index 100% rename from public/images/maps/ssm.cemetery.newGreenwood-veteransSection.svg rename to public/images/cemeteries/ssm.cemetery.newGreenwood-veteransSection.svg diff --git a/public/images/maps/ssm.cemetery.oldGreenwood-babySection.svg b/public/images/cemeteries/ssm.cemetery.oldGreenwood-babySection.svg similarity index 100% rename from public/images/maps/ssm.cemetery.oldGreenwood-babySection.svg rename to public/images/cemeteries/ssm.cemetery.oldGreenwood-babySection.svg diff --git a/public/images/maps/ssm.cemetery.oldGreenwood-eastNorth-rows-1-18-lots-1-11.svg b/public/images/cemeteries/ssm.cemetery.oldGreenwood-eastNorth-rows-1-18-lots-1-11.svg similarity index 100% rename from public/images/maps/ssm.cemetery.oldGreenwood-eastNorth-rows-1-18-lots-1-11.svg rename to public/images/cemeteries/ssm.cemetery.oldGreenwood-eastNorth-rows-1-18-lots-1-11.svg diff --git a/public/images/maps/ssm.cemetery.oldGreenwood-eastNorth-rows-1-18-lots-12-17.svg b/public/images/cemeteries/ssm.cemetery.oldGreenwood-eastNorth-rows-1-18-lots-12-17.svg similarity index 100% rename from public/images/maps/ssm.cemetery.oldGreenwood-eastNorth-rows-1-18-lots-12-17.svg rename to public/images/cemeteries/ssm.cemetery.oldGreenwood-eastNorth-rows-1-18-lots-12-17.svg diff --git a/public/images/maps/ssm.cemetery.oldGreenwood-eastNorth-rows-19-38-lots-1-11.svg b/public/images/cemeteries/ssm.cemetery.oldGreenwood-eastNorth-rows-19-38-lots-1-11.svg similarity index 100% rename from public/images/maps/ssm.cemetery.oldGreenwood-eastNorth-rows-19-38-lots-1-11.svg rename to public/images/cemeteries/ssm.cemetery.oldGreenwood-eastNorth-rows-19-38-lots-1-11.svg diff --git a/public/images/maps/ssm.cemetery.oldGreenwood-eastNorth-rows-19-38-lots-12-17.svg b/public/images/cemeteries/ssm.cemetery.oldGreenwood-eastNorth-rows-19-38-lots-12-17.svg similarity index 100% rename from public/images/maps/ssm.cemetery.oldGreenwood-eastNorth-rows-19-38-lots-12-17.svg rename to public/images/cemeteries/ssm.cemetery.oldGreenwood-eastNorth-rows-19-38-lots-12-17.svg diff --git a/public/images/maps/ssm.cemetery.oldGreenwood-eastSouthA-rows-1-18-lots 23-31.svg b/public/images/cemeteries/ssm.cemetery.oldGreenwood-eastSouthA-rows-1-18-lots 23-31.svg similarity index 100% rename from public/images/maps/ssm.cemetery.oldGreenwood-eastSouthA-rows-1-18-lots 23-31.svg rename to public/images/cemeteries/ssm.cemetery.oldGreenwood-eastSouthA-rows-1-18-lots 23-31.svg diff --git a/public/images/maps/ssm.cemetery.oldGreenwood-eastSouthA-rows-1-18-lots-1-22.svg b/public/images/cemeteries/ssm.cemetery.oldGreenwood-eastSouthA-rows-1-18-lots-1-22.svg similarity index 100% rename from public/images/maps/ssm.cemetery.oldGreenwood-eastSouthA-rows-1-18-lots-1-22.svg rename to public/images/cemeteries/ssm.cemetery.oldGreenwood-eastSouthA-rows-1-18-lots-1-22.svg diff --git a/public/images/maps/ssm.cemetery.oldGreenwood-eastSouthA-rows-19-32-lots-1-22.svg b/public/images/cemeteries/ssm.cemetery.oldGreenwood-eastSouthA-rows-19-32-lots-1-22.svg similarity index 100% rename from public/images/maps/ssm.cemetery.oldGreenwood-eastSouthA-rows-19-32-lots-1-22.svg rename to public/images/cemeteries/ssm.cemetery.oldGreenwood-eastSouthA-rows-19-32-lots-1-22.svg diff --git a/public/images/maps/ssm.cemetery.oldGreenwood-eastSouthA-rows-19-32-lots-23-31.svg b/public/images/cemeteries/ssm.cemetery.oldGreenwood-eastSouthA-rows-19-32-lots-23-31.svg similarity index 100% rename from public/images/maps/ssm.cemetery.oldGreenwood-eastSouthA-rows-19-32-lots-23-31.svg rename to public/images/cemeteries/ssm.cemetery.oldGreenwood-eastSouthA-rows-19-32-lots-23-31.svg diff --git a/public/images/maps/ssm.cemetery.oldGreenwood-eastSouthB-lots-33-45-rows-1-22.svg b/public/images/cemeteries/ssm.cemetery.oldGreenwood-eastSouthB-lots-33-45-rows-1-22.svg similarity index 100% rename from public/images/maps/ssm.cemetery.oldGreenwood-eastSouthB-lots-33-45-rows-1-22.svg rename to public/images/cemeteries/ssm.cemetery.oldGreenwood-eastSouthB-lots-33-45-rows-1-22.svg diff --git a/public/images/maps/ssm.cemetery.oldGreenwood-eastSouthB-rows-33-57-lots 23-31.svg b/public/images/cemeteries/ssm.cemetery.oldGreenwood-eastSouthB-rows-33-57-lots 23-31.svg similarity index 100% rename from public/images/maps/ssm.cemetery.oldGreenwood-eastSouthB-rows-33-57-lots 23-31.svg rename to public/images/cemeteries/ssm.cemetery.oldGreenwood-eastSouthB-rows-33-57-lots 23-31.svg diff --git a/public/images/maps/ssm.cemetery.oldGreenwood-eastSouthB-rows-46-57-lots-11-24.svg b/public/images/cemeteries/ssm.cemetery.oldGreenwood-eastSouthB-rows-46-57-lots-11-24.svg similarity index 100% rename from public/images/maps/ssm.cemetery.oldGreenwood-eastSouthB-rows-46-57-lots-11-24.svg rename to public/images/cemeteries/ssm.cemetery.oldGreenwood-eastSouthB-rows-46-57-lots-11-24.svg diff --git a/public/images/maps/ssm.cemetery.oldGreenwood-image.svg b/public/images/cemeteries/ssm.cemetery.oldGreenwood-image.svg similarity index 100% rename from public/images/maps/ssm.cemetery.oldGreenwood-image.svg rename to public/images/cemeteries/ssm.cemetery.oldGreenwood-image.svg diff --git a/public/images/maps/ssm.cemetery.oldGreenwood-overview.svg b/public/images/cemeteries/ssm.cemetery.oldGreenwood-overview.svg similarity index 100% rename from public/images/maps/ssm.cemetery.oldGreenwood-overview.svg rename to public/images/cemeteries/ssm.cemetery.oldGreenwood-overview.svg diff --git a/public/images/maps/ssm.cemetery.oldGreenwood-westSection-image.svg b/public/images/cemeteries/ssm.cemetery.oldGreenwood-westSection-image.svg similarity index 100% rename from public/images/maps/ssm.cemetery.oldGreenwood-westSection-image.svg rename to public/images/cemeteries/ssm.cemetery.oldGreenwood-westSection-image.svg diff --git a/public/images/maps/ssm.cemetery.oldGreenwood-westSection.svg b/public/images/cemeteries/ssm.cemetery.oldGreenwood-westSection.svg similarity index 100% rename from public/images/maps/ssm.cemetery.oldGreenwood-westSection.svg rename to public/images/cemeteries/ssm.cemetery.oldGreenwood-westSection.svg diff --git a/public/images/maps/ssm.cemetery.pineGrove-overview.svg b/public/images/cemeteries/ssm.cemetery.pineGrove-overview.svg similarity index 100% rename from public/images/maps/ssm.cemetery.pineGrove-overview.svg rename to public/images/cemeteries/ssm.cemetery.pineGrove-overview.svg diff --git a/public/images/maps/ssm.cemetery.westKorah-eastSection.svg b/public/images/cemeteries/ssm.cemetery.westKorah-eastSection.svg similarity index 100% rename from public/images/maps/ssm.cemetery.westKorah-eastSection.svg rename to public/images/cemeteries/ssm.cemetery.westKorah-eastSection.svg diff --git a/public/images/maps/ssm.cemetery.westKorah-northSection.svg b/public/images/cemeteries/ssm.cemetery.westKorah-northSection.svg similarity index 100% rename from public/images/maps/ssm.cemetery.westKorah-northSection.svg rename to public/images/cemeteries/ssm.cemetery.westKorah-northSection.svg diff --git a/public/images/maps/ssm.cemetery.westKorah-overview.svg b/public/images/cemeteries/ssm.cemetery.westKorah-overview.svg similarity index 100% rename from public/images/maps/ssm.cemetery.westKorah-overview.svg rename to public/images/cemeteries/ssm.cemetery.westKorah-overview.svg diff --git a/public/images/maps/ssm.cemetery.westKorah-westSection.svg b/public/images/cemeteries/ssm.cemetery.westKorah-westSection.svg similarity index 100% rename from public/images/maps/ssm.cemetery.westKorah-westSection.svg rename to public/images/cemeteries/ssm.cemetery.westKorah-westSection.svg diff --git a/routes/admin.js b/routes/admin.js index a62ef439..33ce2ab0 100644 --- a/routes/admin.js +++ b/routes/admin.js @@ -1,7 +1,7 @@ import { Router } from 'express'; +import handler_burialSiteTypes from '../handlers/admin-get/burialSiteTypes.js'; import handler_database from '../handlers/admin-get/database.js'; import handler_fees from '../handlers/admin-get/fees.js'; -import handler_lotTypes from '../handlers/admin-get/lotTypes.js'; import handler_ntfyStartup from '../handlers/admin-get/ntfyStartup.js'; import handler_occupancyTypes from '../handlers/admin-get/occupancyTypes.js'; import handler_tables from '../handlers/admin-get/tables.js'; @@ -102,7 +102,7 @@ router.post('/doDeleteOccupancyTypePrint', handler_doDeleteOccupancyTypePrint); /* * Lot Type Management */ -router.get('/lotTypes', handler_lotTypes); +router.get('/lotTypes', handler_burialSiteTypes); router.post('/doAddLotType', handler_doAddLotType); router.post('/doUpdateLotType', handler_doUpdateLotType); router.post('/doMoveLotTypeUp', handler_doMoveLotTypeUp); diff --git a/routes/admin.ts b/routes/admin.ts index 45d1ffa6..7896e4cd 100644 --- a/routes/admin.ts +++ b/routes/admin.ts @@ -1,8 +1,8 @@ import { Router } from 'express' +import handler_burialSiteTypes from '../handlers/admin-get/burialSiteTypes.js' import handler_database from '../handlers/admin-get/database.js' import handler_fees from '../handlers/admin-get/fees.js' -import handler_lotTypes from '../handlers/admin-get/lotTypes.js' import handler_ntfyStartup from '../handlers/admin-get/ntfyStartup.js' import handler_occupancyTypes from '../handlers/admin-get/occupancyTypes.js' import handler_tables from '../handlers/admin-get/tables.js' @@ -144,7 +144,7 @@ router.post('/doDeleteOccupancyTypePrint', handler_doDeleteOccupancyTypePrint) * Lot Type Management */ -router.get('/lotTypes', handler_lotTypes) +router.get('/lotTypes', handler_burialSiteTypes) router.post('/doAddLotType', handler_doAddLotType) diff --git a/routes/lotOccupancies.d.ts b/routes/burialSites.d.ts similarity index 100% rename from routes/lotOccupancies.d.ts rename to routes/burialSites.d.ts diff --git a/routes/lots.js b/routes/burialSites.js similarity index 100% rename from routes/lots.js rename to routes/burialSites.js diff --git a/routes/lots.ts b/routes/burialSites.ts similarity index 100% rename from routes/lots.ts rename to routes/burialSites.ts diff --git a/routes/lots.d.ts b/routes/cemeteries.d.ts similarity index 100% rename from routes/lots.d.ts rename to routes/cemeteries.d.ts diff --git a/routes/cemeteries.js b/routes/cemeteries.js new file mode 100644 index 00000000..1f8a6779 --- /dev/null +++ b/routes/cemeteries.js @@ -0,0 +1,22 @@ +import { Router } from 'express'; +import handler_edit from '../handlers/cemeteries-get/edit.js'; +import handler_new from '../handlers/cemeteries-get/new.js'; +import handler_next from '../handlers/cemeteries-get/next.js'; +import handler_previous from '../handlers/cemeteries-get/previous.js'; +import handler_search from '../handlers/cemeteries-get/search.js'; +import handler_view from '../handlers/cemeteries-get/view.js'; +import handler_doCreateMap from '../handlers/cemeteries-post/doCreateCemetery.js'; +import handler_doDeleteMap from '../handlers/cemeteries-post/doDeleteMap.js'; +import handler_doUpdateMap from '../handlers/cemeteries-post/doUpdateMap.js'; +import { updateGetHandler, updatePostHandler } from '../handlers/permissions.js'; +export const router = Router(); +router.get('/', handler_search); +router.get('/new', updateGetHandler, handler_new); +router.get('/:cemeteryId', handler_view); +router.get('/:cemeteryId/next', handler_next); +router.get('/:cemeteryId/previous', handler_previous); +router.get('/:cemeteryId/edit', updateGetHandler, handler_edit); +router.post('/doCreateCemetery', updatePostHandler, handler_doCreateMap); +router.post('/doUpdateCemetery', updatePostHandler, handler_doUpdateMap); +router.post('/doDeleteCemetery', updatePostHandler, handler_doDeleteMap); +export default router; diff --git a/routes/cemeteries.ts b/routes/cemeteries.ts new file mode 100644 index 00000000..11574fce --- /dev/null +++ b/routes/cemeteries.ts @@ -0,0 +1,46 @@ +import { type RequestHandler, Router } from 'express' + +import handler_edit from '../handlers/cemeteries-get/edit.js' +import handler_new from '../handlers/cemeteries-get/new.js' +import handler_next from '../handlers/cemeteries-get/next.js' +import handler_previous from '../handlers/cemeteries-get/previous.js' +import handler_search from '../handlers/cemeteries-get/search.js' +import handler_view from '../handlers/cemeteries-get/view.js' +import handler_doCreateMap from '../handlers/cemeteries-post/doCreateCemetery.js' +import handler_doDeleteMap from '../handlers/cemeteries-post/doDeleteMap.js' +import handler_doUpdateMap from '../handlers/cemeteries-post/doUpdateMap.js' +import { updateGetHandler, updatePostHandler } from '../handlers/permissions.js' + +export const router = Router() + +router.get('/', handler_search) + +router.get('/new', updateGetHandler, handler_new) + +router.get('/:cemeteryId', handler_view) + +router.get('/:cemeteryId/next', handler_next) + +router.get('/:cemeteryId/previous', handler_previous) + +router.get('/:cemeteryId/edit', updateGetHandler, handler_edit) + +router.post( + '/doCreateCemetery', + updatePostHandler, + handler_doCreateMap +) + +router.post( + '/doUpdateCemetery', + updatePostHandler, + handler_doUpdateMap +) + +router.post( + '/doDeleteCemetery', + updatePostHandler, + handler_doDeleteMap +) + +export default router diff --git a/routes/maps.d.ts b/routes/contracts.d.ts similarity index 100% rename from routes/maps.d.ts rename to routes/contracts.d.ts diff --git a/routes/lotOccupancies.js b/routes/contracts.js similarity index 98% rename from routes/lotOccupancies.js rename to routes/contracts.js index ac856039..a25e0049 100644 --- a/routes/lotOccupancies.js +++ b/routes/contracts.js @@ -26,7 +26,7 @@ import handler_doUpdateLotOccupancyFeeQuantity from '../handlers/lotOccupancies- import handler_doUpdateLotOccupancyOccupant from '../handlers/lotOccupancies-post/doUpdateLotOccupancyOccupant.js'; import handler_doUpdateLotOccupancyTransaction from '../handlers/lotOccupancies-post/doUpdateLotOccupancyTransaction.js'; import { updateGetHandler, updatePostHandler } from '../handlers/permissions.js'; -import { getConfigProperty } from '../helpers/functions.config.js'; +import { getConfigProperty } from '../helpers/config.helpers.js'; export const router = Router(); // Search router.get('/', handler_search); diff --git a/routes/lotOccupancies.ts b/routes/contracts.ts similarity index 98% rename from routes/lotOccupancies.ts rename to routes/contracts.ts index ffd59e00..a60cb4ca 100644 --- a/routes/lotOccupancies.ts +++ b/routes/contracts.ts @@ -27,7 +27,7 @@ import handler_doUpdateLotOccupancyFeeQuantity from '../handlers/lotOccupancies- import handler_doUpdateLotOccupancyOccupant from '../handlers/lotOccupancies-post/doUpdateLotOccupancyOccupant.js' import handler_doUpdateLotOccupancyTransaction from '../handlers/lotOccupancies-post/doUpdateLotOccupancyTransaction.js' import { updateGetHandler, updatePostHandler } from '../handlers/permissions.js' -import { getConfigProperty } from '../helpers/functions.config.js' +import { getConfigProperty } from '../helpers/config.helpers.js' export const router = Router() diff --git a/routes/login.js b/routes/login.js index 1bacf1d3..6f823918 100644 --- a/routes/login.js +++ b/routes/login.js @@ -1,10 +1,11 @@ import Debug from 'debug'; import { Router } from 'express'; -import { useTestDatabases } from '../data/databasePaths.js'; +import { DEBUG_NAMESPACE } from '../debug.config.js'; +import { getConfigProperty } from '../helpers/config.helpers.js'; +import { useTestDatabases } from '../helpers/database.helpers.js'; import { getApiKey } from '../helpers/functions.api.js'; import { authenticate, getSafeRedirectURL } from '../helpers/functions.authentication.js'; -import { getConfigProperty } from '../helpers/functions.config.js'; -const debug = Debug('lot-occupancy-system:login'); +const debug = Debug(`${DEBUG_NAMESPACE}:login`); export const router = Router(); function getHandler(request, response) { const sessionCookieName = getConfigProperty('session.cookieName'); diff --git a/routes/login.ts b/routes/login.ts index ffc085cd..eee9a88f 100644 --- a/routes/login.ts +++ b/routes/login.ts @@ -1,15 +1,16 @@ import Debug from 'debug' import { type Request, type Response, Router } from 'express' -import { useTestDatabases } from '../data/databasePaths.js' +import { DEBUG_NAMESPACE } from '../debug.config.js' +import { getConfigProperty } from '../helpers/config.helpers.js' +import { useTestDatabases } from '../helpers/database.helpers.js' import { getApiKey } from '../helpers/functions.api.js' import { authenticate, getSafeRedirectURL } from '../helpers/functions.authentication.js' -import { getConfigProperty } from '../helpers/functions.config.js' -const debug = Debug('lot-occupancy-system:login') +const debug = Debug(`${DEBUG_NAMESPACE}:login`) export const router = Router() diff --git a/routes/maps.js b/routes/maps.js deleted file mode 100644 index ed1711db..00000000 --- a/routes/maps.js +++ /dev/null @@ -1,22 +0,0 @@ -import { Router } from 'express'; -import handler_edit from '../handlers/maps-get/edit.js'; -import handler_new from '../handlers/maps-get/new.js'; -import handler_next from '../handlers/maps-get/next.js'; -import handler_previous from '../handlers/maps-get/previous.js'; -import handler_search from '../handlers/maps-get/search.js'; -import handler_view from '../handlers/maps-get/view.js'; -import handler_doCreateMap from '../handlers/maps-post/doCreateMap.js'; -import handler_doDeleteMap from '../handlers/maps-post/doDeleteMap.js'; -import handler_doUpdateMap from '../handlers/maps-post/doUpdateMap.js'; -import { updateGetHandler, updatePostHandler } from '../handlers/permissions.js'; -export const router = Router(); -router.get('/', handler_search); -router.get('/new', updateGetHandler, handler_new); -router.get('/:mapId', handler_view); -router.get('/:mapId/next', handler_next); -router.get('/:mapId/previous', handler_previous); -router.get('/:mapId/edit', updateGetHandler, handler_edit); -router.post('/doCreateMap', updatePostHandler, handler_doCreateMap); -router.post('/doUpdateMap', updatePostHandler, handler_doUpdateMap); -router.post('/doDeleteMap', updatePostHandler, handler_doDeleteMap); -export default router; diff --git a/routes/maps.ts b/routes/maps.ts deleted file mode 100644 index 429e53b1..00000000 --- a/routes/maps.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { type RequestHandler, Router } from 'express' - -import handler_edit from '../handlers/maps-get/edit.js' -import handler_new from '../handlers/maps-get/new.js' -import handler_next from '../handlers/maps-get/next.js' -import handler_previous from '../handlers/maps-get/previous.js' -import handler_search from '../handlers/maps-get/search.js' -import handler_view from '../handlers/maps-get/view.js' -import handler_doCreateMap from '../handlers/maps-post/doCreateMap.js' -import handler_doDeleteMap from '../handlers/maps-post/doDeleteMap.js' -import handler_doUpdateMap from '../handlers/maps-post/doUpdateMap.js' -import { updateGetHandler, updatePostHandler } from '../handlers/permissions.js' - -export const router = Router() - -router.get('/', handler_search) - -router.get('/new', updateGetHandler, handler_new) - -router.get('/:mapId', handler_view) - -router.get('/:mapId/next', handler_next) - -router.get('/:mapId/previous', handler_previous) - -router.get('/:mapId/edit', updateGetHandler, handler_edit) - -router.post( - '/doCreateMap', - updatePostHandler, - handler_doCreateMap -) - -router.post( - '/doUpdateMap', - updatePostHandler, - handler_doUpdateMap -) - -router.post( - '/doDeleteMap', - updatePostHandler, - handler_doDeleteMap -) - -export default router diff --git a/temp/legacy.importFromCSV.js b/temp/legacy.importFromCSV.js index 89aec412..71092363 100644 --- a/temp/legacy.importFromCSV.js +++ b/temp/legacy.importFromCSV.js @@ -2,7 +2,7 @@ import fs from 'node:fs'; import { dateIntegerToString, dateToString } from '@cityssm/utils-datetime'; import sqlite from 'better-sqlite3'; import papa from 'papaparse'; -import { lotOccupancyDB as databasePath } from '../data/databasePaths.js'; +import { sunriseDB as databasePath } from '../data/databasePaths.js'; import addLot from '../database/addLot.js'; import addLotOccupancy from '../database/addLotOccupancy.js'; import addLotOccupancyComment from '../database/addLotOccupancyComment.js'; @@ -301,18 +301,14 @@ async function importFromMasterCSV() { const lotOccupancyFieldValue = formatDateString(masterRow.CM_DEATH_YR, masterRow.CM_DEATH_MON, masterRow.CM_DEATH_DAY); await addOrUpdateLotOccupancyField({ lotOccupancyId: deceasedLotOccupancyId, - occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === 'Death Date'; - }).occupancyTypeFieldId, + occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Date').occupancyTypeFieldId, lotOccupancyFieldValue }, user); } if (masterRow.CM_AGE !== '') { await addOrUpdateLotOccupancyField({ lotOccupancyId: deceasedLotOccupancyId, - occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === 'Death Age'; - }).occupancyTypeFieldId, + occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Age').occupancyTypeFieldId, lotOccupancyFieldValue: masterRow.CM_AGE }, user); } @@ -320,9 +316,7 @@ async function importFromMasterCSV() { const period = importData.getDeathAgePeriod(masterRow.CM_PERIOD); await addOrUpdateLotOccupancyField({ lotOccupancyId: deceasedLotOccupancyId, - occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return (occupancyTypeField.occupancyTypeField === 'Death Age Period'); - }).occupancyTypeFieldId, + occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => (occupancyTypeField.occupancyTypeField === 'Death Age Period')).occupancyTypeFieldId, lotOccupancyFieldValue: period }, user); } @@ -360,9 +354,7 @@ async function importFromMasterCSV() { const lotOccupancyFieldValue = formatDateString(masterRow.CM_FUNERAL_YR, masterRow.CM_FUNERAL_MON, masterRow.CM_FUNERAL_DAY); await addOrUpdateLotOccupancyField({ lotOccupancyId: deceasedLotOccupancyId, - occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return (occupancyTypeField.occupancyTypeField === 'Funeral Date'); - }).occupancyTypeFieldId, + occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => (occupancyTypeField.occupancyTypeField === 'Funeral Date')).occupancyTypeFieldId, lotOccupancyFieldValue }, user); } @@ -370,9 +362,7 @@ async function importFromMasterCSV() { if (masterRow.CM_CONTAINER_TYPE !== '') { await addOrUpdateLotOccupancyField({ lotOccupancyId: deceasedLotOccupancyId, - occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return (occupancyTypeField.occupancyTypeField === 'Container Type'); - }).occupancyTypeFieldId, + occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => (occupancyTypeField.occupancyTypeField === 'Container Type')).occupancyTypeFieldId, lotOccupancyFieldValue: masterRow.CM_CONTAINER_TYPE }, user); } @@ -383,9 +373,7 @@ async function importFromMasterCSV() { } await addOrUpdateLotOccupancyField({ lotOccupancyId: deceasedLotOccupancyId, - occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return (occupancyTypeField.occupancyTypeField === 'Committal Type'); - }).occupancyTypeFieldId, + occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => (occupancyTypeField.occupancyTypeField === 'Committal Type')).occupancyTypeFieldId, lotOccupancyFieldValue: commitalType }, user); } @@ -516,14 +504,12 @@ async function importFromPrepaidCSV() { possibleLotOccupancies.lotOccupancies[0].lotOccupancyId; } } - if (!lotOccupancyId) { - lotOccupancyId = await addLotOccupancy({ - lotId: lot ? lot.lotId : '', - occupancyTypeId: importIds.preneedOccupancyType.occupancyTypeId, - occupancyStartDateString, - occupancyEndDateString: '' - }, user); - } + lotOccupancyId ||= await addLotOccupancy({ + lotId: lot ? lot.lotId : '', + occupancyTypeId: importIds.preneedOccupancyType.occupancyTypeId, + occupancyStartDateString, + occupancyEndDateString: '' + }, user); await addLotOccupancyOccupant({ lotOccupancyId, lotOccupantTypeId: importIds.preneedOwnerLotOccupantTypeId, @@ -745,9 +731,7 @@ async function importFromWorkOrderCSV() { }, user); lot = await getLot(lotId); } - const workOrderContainsLot = workOrder.workOrderLots.find((possibleLot) => { - return (possibleLot.lotId = lot.lotId); - }); + const workOrderContainsLot = workOrder.workOrderLots.find((possibleLot) => (possibleLot.lotId = lot.lotId)); if (!workOrderContainsLot) { await addWorkOrderLot({ workOrderId: workOrder.workOrderId, @@ -786,27 +770,21 @@ async function importFromWorkOrderCSV() { const lotOccupancyFieldValue = formatDateString(workOrderRow.WO_DEATH_YR, workOrderRow.WO_DEATH_MON, workOrderRow.WO_DEATH_DAY); await addOrUpdateLotOccupancyField({ lotOccupancyId, - occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === 'Death Date'; - }).occupancyTypeFieldId, + occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Date').occupancyTypeFieldId, lotOccupancyFieldValue }, user); } if (workOrderRow.WO_DEATH_PLACE !== '') { await addOrUpdateLotOccupancyField({ lotOccupancyId, - occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === 'Death Place'; - }).occupancyTypeFieldId, + occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Place').occupancyTypeFieldId, lotOccupancyFieldValue: workOrderRow.WO_DEATH_PLACE }, user); } if (workOrderRow.WO_AGE !== '') { await addOrUpdateLotOccupancyField({ lotOccupancyId, - occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === 'Death Age'; - }).occupancyTypeFieldId, + occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Age').occupancyTypeFieldId, lotOccupancyFieldValue: workOrderRow.WO_AGE }, user); } @@ -814,9 +792,7 @@ async function importFromWorkOrderCSV() { const period = importData.getDeathAgePeriod(workOrderRow.WO_PERIOD); await addOrUpdateLotOccupancyField({ lotOccupancyId, - occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return (occupancyTypeField.occupancyTypeField === 'Death Age Period'); - }).occupancyTypeFieldId, + occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => (occupancyTypeField.occupancyTypeField === 'Death Age Period')).occupancyTypeFieldId, lotOccupancyFieldValue: period }, user); } @@ -852,9 +828,7 @@ async function importFromWorkOrderCSV() { const lotOccupancyFieldValue = formatDateString(workOrderRow.WO_FUNERAL_YR, workOrderRow.WO_FUNERAL_MON, workOrderRow.WO_FUNERAL_DAY); await addOrUpdateLotOccupancyField({ lotOccupancyId, - occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === 'Funeral Date'; - }).occupancyTypeFieldId, + occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Funeral Date').occupancyTypeFieldId, lotOccupancyFieldValue }, user); } @@ -862,9 +836,7 @@ async function importFromWorkOrderCSV() { if (workOrderRow.WO_CONTAINER_TYPE !== '') { await addOrUpdateLotOccupancyField({ lotOccupancyId, - occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return (occupancyTypeField.occupancyTypeField === 'Container Type'); - }).occupancyTypeFieldId, + occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => (occupancyTypeField.occupancyTypeField === 'Container Type')).occupancyTypeFieldId, lotOccupancyFieldValue: workOrderRow.WO_CONTAINER_TYPE }, user); } @@ -875,9 +847,7 @@ async function importFromWorkOrderCSV() { } await addOrUpdateLotOccupancyField({ lotOccupancyId, - occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return (occupancyTypeField.occupancyTypeField === 'Committal Type'); - }).occupancyTypeFieldId, + occupancyTypeFieldId: occupancyType.occupancyTypeFields.find((occupancyTypeField) => (occupancyTypeField.occupancyTypeField === 'Committal Type')).occupancyTypeFieldId, lotOccupancyFieldValue: commitalType }, user); } diff --git a/temp/legacy.importFromCSV.ts b/temp/legacy.importFromCSV.ts index 2ce975fc..4cd0b63f 100644 --- a/temp/legacy.importFromCSV.ts +++ b/temp/legacy.importFromCSV.ts @@ -9,7 +9,7 @@ import { import sqlite from 'better-sqlite3' import papa from 'papaparse' -import { lotOccupancyDB as databasePath } from '../data/databasePaths.js' +import { sunriseDB as databasePath } from '../data/databasePaths.js' import addLot from '../database/addLot.js' import addLotOccupancy from '../database/addLotOccupancy.js' import addLotOccupancyComment from '../database/addLotOccupancyComment.js' @@ -31,7 +31,6 @@ import getWorkOrder, { } from '../database/getWorkOrder.js' import reopenWorkOrder from '../database/reopenWorkOrder.js' import { updateLotStatus } from '../database/updateLot.js' -// eslint-disable-next-line import/namespace import type * as recordTypes from '../types/recordTypes.js' import * as importData from './legacy.importFromCsv.data.js' @@ -600,9 +599,7 @@ async function importFromMasterCSV(): Promise { { lotOccupancyId: deceasedLotOccupancyId, occupancyTypeFieldId: occupancyType.occupancyTypeFields!.find( - (occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === 'Death Date' - } + (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Date' )!.occupancyTypeFieldId!, lotOccupancyFieldValue }, @@ -615,9 +612,7 @@ async function importFromMasterCSV(): Promise { { lotOccupancyId: deceasedLotOccupancyId, occupancyTypeFieldId: occupancyType.occupancyTypeFields!.find( - (occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === 'Death Age' - } + (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Age' )!.occupancyTypeFieldId!, lotOccupancyFieldValue: masterRow.CM_AGE }, @@ -632,11 +627,9 @@ async function importFromMasterCSV(): Promise { { lotOccupancyId: deceasedLotOccupancyId, occupancyTypeFieldId: occupancyType.occupancyTypeFields!.find( - (occupancyTypeField) => { - return ( + (occupancyTypeField) => ( occupancyTypeField.occupancyTypeField === 'Death Age Period' ) - } )!.occupancyTypeFieldId!, lotOccupancyFieldValue: period }, @@ -694,11 +687,9 @@ async function importFromMasterCSV(): Promise { { lotOccupancyId: deceasedLotOccupancyId, occupancyTypeFieldId: occupancyType.occupancyTypeFields!.find( - (occupancyTypeField) => { - return ( + (occupancyTypeField) => ( occupancyTypeField.occupancyTypeField === 'Funeral Date' ) - } )!.occupancyTypeFieldId!, lotOccupancyFieldValue }, @@ -712,11 +703,9 @@ async function importFromMasterCSV(): Promise { { lotOccupancyId: deceasedLotOccupancyId, occupancyTypeFieldId: occupancyType.occupancyTypeFields!.find( - (occupancyTypeField) => { - return ( + (occupancyTypeField) => ( occupancyTypeField.occupancyTypeField === 'Container Type' ) - } )!.occupancyTypeFieldId!, lotOccupancyFieldValue: masterRow.CM_CONTAINER_TYPE }, @@ -735,11 +724,9 @@ async function importFromMasterCSV(): Promise { { lotOccupancyId: deceasedLotOccupancyId, occupancyTypeFieldId: occupancyType.occupancyTypeFields!.find( - (occupancyTypeField) => { - return ( + (occupancyTypeField) => ( occupancyTypeField.occupancyTypeField === 'Committal Type' ) - } )!.occupancyTypeFieldId!, lotOccupancyFieldValue: commitalType }, @@ -921,8 +908,7 @@ async function importFromPrepaidCSV(): Promise { } } - if (!lotOccupancyId) { - lotOccupancyId = await addLotOccupancy( + lotOccupancyId ||= await addLotOccupancy( { lotId: lot ? lot.lotId : '', occupancyTypeId: importIds.preneedOccupancyType.occupancyTypeId, @@ -930,8 +916,7 @@ async function importFromPrepaidCSV(): Promise { occupancyEndDateString: '' }, user - ) - } + ); await addLotOccupancyOccupant( { @@ -1240,9 +1225,7 @@ async function importFromWorkOrderCSV(): Promise { } const workOrderContainsLot = workOrder.workOrderLots!.find( - (possibleLot) => { - return (possibleLot.lotId = lot.lotId) - } + (possibleLot) => (possibleLot.lotId = lot.lotId) ) if (!workOrderContainsLot) { @@ -1310,9 +1293,7 @@ async function importFromWorkOrderCSV(): Promise { { lotOccupancyId, occupancyTypeFieldId: occupancyType.occupancyTypeFields!.find( - (occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === 'Death Date' - } + (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Date' )!.occupancyTypeFieldId!, lotOccupancyFieldValue }, @@ -1325,9 +1306,7 @@ async function importFromWorkOrderCSV(): Promise { { lotOccupancyId, occupancyTypeFieldId: occupancyType.occupancyTypeFields!.find( - (occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === 'Death Place' - } + (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Place' )!.occupancyTypeFieldId!, lotOccupancyFieldValue: workOrderRow.WO_DEATH_PLACE }, @@ -1340,9 +1319,7 @@ async function importFromWorkOrderCSV(): Promise { { lotOccupancyId, occupancyTypeFieldId: occupancyType.occupancyTypeFields!.find( - (occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === 'Death Age' - } + (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Age' )!.occupancyTypeFieldId!, lotOccupancyFieldValue: workOrderRow.WO_AGE }, @@ -1357,11 +1334,9 @@ async function importFromWorkOrderCSV(): Promise { { lotOccupancyId, occupancyTypeFieldId: occupancyType.occupancyTypeFields!.find( - (occupancyTypeField) => { - return ( + (occupancyTypeField) => ( occupancyTypeField.occupancyTypeField === 'Death Age Period' ) - } )!.occupancyTypeFieldId!, lotOccupancyFieldValue: period }, @@ -1417,9 +1392,7 @@ async function importFromWorkOrderCSV(): Promise { { lotOccupancyId, occupancyTypeFieldId: occupancyType.occupancyTypeFields!.find( - (occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === 'Funeral Date' - } + (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Funeral Date' )!.occupancyTypeFieldId!, lotOccupancyFieldValue }, @@ -1433,11 +1406,9 @@ async function importFromWorkOrderCSV(): Promise { { lotOccupancyId, occupancyTypeFieldId: occupancyType.occupancyTypeFields!.find( - (occupancyTypeField) => { - return ( + (occupancyTypeField) => ( occupancyTypeField.occupancyTypeField === 'Container Type' ) - } )!.occupancyTypeFieldId!, lotOccupancyFieldValue: workOrderRow.WO_CONTAINER_TYPE }, @@ -1456,11 +1427,9 @@ async function importFromWorkOrderCSV(): Promise { { lotOccupancyId, occupancyTypeFieldId: occupancyType.occupancyTypeFields!.find( - (occupancyTypeField) => { - return ( + (occupancyTypeField) => ( occupancyTypeField.occupancyTypeField === 'Committal Type' ) - } )!.occupancyTypeFieldId!, lotOccupancyFieldValue: commitalType }, diff --git a/temp/legacy.importFromCsv.ids.d.ts b/temp/legacy.importFromCsv.ids.d.ts index cfeda03c..e77e264e 100644 --- a/temp/legacy.importFromCsv.ids.d.ts +++ b/temp/legacy.importFromCsv.ids.d.ts @@ -3,9 +3,9 @@ export declare const preneedOwnerLotOccupantTypeId: number; export declare const funeralDirectorLotOccupantTypeId: number; export declare const deceasedLotOccupantTypeId: number; export declare const purchaserLotOccupantTypeId: number; -export declare const availableLotStatusId: number; -export declare const reservedLotStatusId: number; -export declare const takenLotStatusId: number; +export declare const availableLotStatusId: any; +export declare const reservedLotStatusId: any; +export declare const takenLotStatusId: any; export declare function getLotTypeId(dataRow: { cemetery: string; }): number; diff --git a/temp/legacy.importFromCsv.ids.js b/temp/legacy.importFromCsv.ids.js index 75ca6ec4..240443ea 100644 --- a/temp/legacy.importFromCsv.ids.js +++ b/temp/legacy.importFromCsv.ids.js @@ -1,7 +1,7 @@ // eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair /* eslint-disable unicorn/no-await-expression-member */ import sqlite from 'better-sqlite3'; -import { lotOccupancyDB as databasePath } from '../data/databasePaths.js'; +import { sunriseDB as databasePath } from '../data/databasePaths.js'; import * as cacheFunctions from '../helpers/functions.cache.js'; /* * Fee IDs diff --git a/temp/legacy.importFromCsv.ids.ts b/temp/legacy.importFromCsv.ids.ts index 69ee2e2a..467bfc03 100644 --- a/temp/legacy.importFromCsv.ids.ts +++ b/temp/legacy.importFromCsv.ids.ts @@ -3,7 +3,7 @@ import sqlite from 'better-sqlite3' -import { lotOccupancyDB as databasePath } from '../data/databasePaths.js' +import { sunriseDB as databasePath } from '../data/databasePaths.js' import * as cacheFunctions from '../helpers/functions.cache.js' /* diff --git a/test/1_serverCypress.js b/test/1_serverCypress.js index be8bc7e3..d23e9e19 100644 --- a/test/1_serverCypress.js +++ b/test/1_serverCypress.js @@ -23,7 +23,7 @@ function runCypress(browser, done) { done(); }); } -describe('lot-occupancy-system', () => { +describe('sunrise-cms', () => { const httpServer = http.createServer(app); let serverStarted = false; before(() => { diff --git a/test/1_serverCypress.ts b/test/1_serverCypress.ts index 09c8f3e8..a6dbcfda 100644 --- a/test/1_serverCypress.ts +++ b/test/1_serverCypress.ts @@ -34,7 +34,7 @@ function runCypress(browser: 'chrome' | 'firefox', done: () => void): void { }) } -describe('lot-occupancy-system', () => { +describe('sunrise-cms', () => { const httpServer = http.createServer(app) let serverStarted = false diff --git a/test/functions.js b/test/functions.js index 570d3b11..46fe46f2 100644 --- a/test/functions.js +++ b/test/functions.js @@ -1,19 +1,11 @@ import assert from 'node:assert'; import fs from 'node:fs'; -import { lotNameSortNameFunction } from '../data/config.cemetery.ssm.js'; // skipcq: JS-C1003 - Testing functions import * as cacheFunctions from '../helpers/functions.cache.js'; // skipcq: JS-C1003 - Testing functions import * as sqlFilterFunctions from '../helpers/functions.sqlFilters.js'; // skipcq: JS-C1003 - Testing functions import * as userFunctions from '../helpers/functions.user.js'; -describe('config.cemetery.ssm', () => { - it('Sorts burial site names', () => { - const grave2 = 'XX-B1-G2A'; - const grave10 = 'XX-B1-G10'; - assert.ok(lotNameSortNameFunction(grave2) < lotNameSortNameFunction(grave10)); - }); -}); describe('functions.cache', () => { const badId = -3; // eslint-disable-next-line no-secrets/no-secrets diff --git a/test/functions.ts b/test/functions.ts index 51c1863c..03f6a20c 100644 --- a/test/functions.ts +++ b/test/functions.ts @@ -1,7 +1,6 @@ import assert from 'node:assert' import fs from 'node:fs' -import { lotNameSortNameFunction } from '../data/config.cemetery.ssm.js' // skipcq: JS-C1003 - Testing functions import * as cacheFunctions from '../helpers/functions.cache.js' // skipcq: JS-C1003 - Testing functions @@ -9,17 +8,6 @@ import * as sqlFilterFunctions from '../helpers/functions.sqlFilters.js' // skipcq: JS-C1003 - Testing functions import * as userFunctions from '../helpers/functions.user.js' -describe('config.cemetery.ssm', () => { - it('Sorts burial site names', () => { - const grave2 = 'XX-B1-G2A' - const grave10 = 'XX-B1-G10' - - assert.ok( - lotNameSortNameFunction(grave2) < lotNameSortNameFunction(grave10) - ) - }) -}) - describe('functions.cache', () => { const badId = -3 // eslint-disable-next-line no-secrets/no-secrets diff --git a/tsconfig.json b/tsconfig.json index 8690f26b..b0402b2c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { - "target": "es2022", - "module": "es2022", - "moduleResolution": "Node", + "target": "ES2022", + "module": "Node16", + "moduleResolution": "Node16", "isolatedModules": false, "declaration": true, "noImplicitAny": false, diff --git a/types/applicationTypes.d.ts b/types/applicationTypes.d.ts index b904732f..e946681c 100644 --- a/types/applicationTypes.d.ts +++ b/types/applicationTypes.d.ts @@ -7,12 +7,12 @@ export interface ClearCacheWorkerMessage extends WorkerMessage { messageType: 'clearCache'; tableName: string; } -export interface CacheLotIdsWorkerMessage extends WorkerMessage { - messageType: 'cacheLotIds'; - lotId: number; - nextLotId: number; +export interface CacheBurialSiteIdsWorkerMessage extends WorkerMessage { + messageType: 'cacheBurialSiteIds'; + burialSiteId: number; + nextBurialSiteId: number; } -export interface ClearNextPreviousLotIdsCacheWorkerMessage extends WorkerMessage { - messageType: 'clearNextPreviousLotIdCache'; - lotId: number; +export interface ClearNextPreviousBurialSiteIdsCacheWorkerMessage extends WorkerMessage { + messageType: 'clearNextPreviousBurialSiteIdCache'; + burialSiteId: number; } diff --git a/types/applicationTypes.ts b/types/applicationTypes.ts index 1f379d70..95f926f3 100644 --- a/types/applicationTypes.ts +++ b/types/applicationTypes.ts @@ -9,15 +9,15 @@ export interface ClearCacheWorkerMessage extends WorkerMessage { tableName: string } -export interface CacheLotIdsWorkerMessage extends WorkerMessage { - messageType: 'cacheLotIds' - lotId: number - nextLotId: number +export interface CacheBurialSiteIdsWorkerMessage extends WorkerMessage { + messageType: 'cacheBurialSiteIds' + burialSiteId: number + nextBurialSiteId: number } -export interface ClearNextPreviousLotIdsCacheWorkerMessage +export interface ClearNextPreviousBurialSiteIdsCacheWorkerMessage extends WorkerMessage { // eslint-disable-next-line no-secrets/no-secrets - messageType: 'clearNextPreviousLotIdCache' - lotId: number + messageType: 'clearNextPreviousBurialSiteIdCache' + burialSiteId: number } diff --git a/types/configTypes.d.ts b/types/configTypes.d.ts index 74aad457..1575bb68 100644 --- a/types/configTypes.d.ts +++ b/types/configTypes.d.ts @@ -15,15 +15,6 @@ export interface Config { isAdmin?: string[]; }; aliases: { - lot?: string; - lots?: string; - map?: string; - maps?: string; - occupancy?: string; - occupancies?: string; - occupancyStartDate?: string; - occupant?: string; - occupants?: string; externalReceiptNumber?: string; workOrderOpenDate?: string; workOrderCloseDate?: string; @@ -32,20 +23,14 @@ export interface Config { fees: { taxPercentageDefault?: number; }; - map: { - mapCityDefault?: string; - mapProvinceDefault?: string; + cemeteries: { + cityDefault?: string; + provinceDefault?: string; }; - lot: { - lotNamePattern?: RegExp; - lotNameHelpText?: string; - lotNameSortNameFunction?: (lotName: string) => string; - }; - lotOccupancy: { - lotIdIsRequired?: boolean; - occupancyEndDateIsRequired?: boolean; - occupantCityDefault?: string; - occupantProvinceDefault?: string; + contracts: { + burialSiteIdIsRequired?: boolean; + cityDefault?: string; + provinceDefault?: string; prints?: string[]; }; workOrders: { diff --git a/types/configTypes.ts b/types/configTypes.ts index d4d336fc..af05ddd7 100644 --- a/types/configTypes.ts +++ b/types/configTypes.ts @@ -16,15 +16,6 @@ export interface Config { isAdmin?: string[] } aliases: { - lot?: string - lots?: string - map?: string - maps?: string - occupancy?: string - occupancies?: string - occupancyStartDate?: string - occupant?: string - occupants?: string externalReceiptNumber?: string workOrderOpenDate?: string workOrderCloseDate?: string @@ -33,20 +24,14 @@ export interface Config { fees: { taxPercentageDefault?: number } - map: { - mapCityDefault?: string - mapProvinceDefault?: string + cemeteries: { + cityDefault?: string + provinceDefault?: string } - lot: { - lotNamePattern?: RegExp - lotNameHelpText?: string - lotNameSortNameFunction?: (lotName: string) => string - } - lotOccupancy: { - lotIdIsRequired?: boolean - occupancyEndDateIsRequired?: boolean - occupantCityDefault?: string - occupantProvinceDefault?: string + contracts: { + burialSiteIdIsRequired?: boolean + cityDefault?: string + provinceDefault?: string prints?: string[] } workOrders: { diff --git a/types/recordTypes.d.ts b/types/recordTypes.d.ts index 465fc143..c59ee60e 100644 --- a/types/recordTypes.d.ts +++ b/types/recordTypes.d.ts @@ -10,77 +10,77 @@ export interface Record { recordDelete_timeMillis?: number; recordDelete_dateString?: string; } -export interface MapRecord extends Record { - mapId?: number; - mapName?: string; - mapDescription?: string; - mapLatitude?: number; - mapLongitude?: number; - mapSVG?: string; - mapAddress1?: string; - mapAddress2?: string; - mapCity?: string; - mapProvince?: string; - mapPostalCode?: string; - mapPhoneNumber?: string; - lotCount?: number; +export interface CemeteryRecord extends Record { + cemeteryId?: number; + cemeteryName?: string; + cemeteryDescription?: string; + cemeteryLatitude?: number; + cemeteryLongitude?: number; + cemeterySvg?: string; + cemeteryAddress1?: string; + cemeteryAddress2?: string; + cemeteryCity?: string; + cemeteryProvince?: string; + cemeteryPostalCode?: string; + cemeteryPhoneNumber?: string; + burialSiteCount?: number; } -export interface LotType extends Record { - lotTypeId: number; - lotType: string; +export interface BurialSiteType extends Record { + burialSiteTypeId: number; + burialSiteType: string; orderNumber?: number; - lotTypeFields?: LotTypeField[]; + burialSiteTypeFields?: BurialSiteTypeField[]; } -export interface LotTypeField extends Record { - lotTypeFieldId: number; - lotTypeField?: string; - lotTypeId?: number; - lotType: LotType; +export interface BurialSiteTypeField extends Record { + burialSiteTypeFieldId: number; + burialSiteTypeField?: string; + burialSiteTypeId?: number; + burialSiteType: BurialSiteType; fieldType: string; - lotTypeFieldValues?: string; + fieldValues?: string; isRequired?: boolean; pattern?: string; minimumLength?: number; maximumLength?: number; orderNumber?: number; } -export interface LotStatus extends Record { - lotStatusId: number; - lotStatus: string; +export interface BurialSiteStatus extends Record { + burialSiteStatusId: number; + burialSiteStatus: string; orderNumber?: number; } -export interface Lot extends Record { - lotId: number; - lotName?: string; - lotTypeId?: number; - lotType?: string; - mapId?: number; - mapName?: string; - map?: MapRecord; - mapSVG?: string; - mapKey?: string; - lotLatitude?: number; - lotLongitude?: number; - lotStatusId?: number; - lotStatus?: string; - lotFields?: LotField[]; - lotOccupancyCount?: number; - lotOccupancies?: LotOccupancy[]; - lotComments?: LotComment[]; +export interface BurialSite extends Record { + burialSiteId: number; + burialSiteName?: string; + burialSiteTypeId?: number; + burialSiteType?: string; + cemeteryId?: number; + cemeteryName?: string; + cemetery?: CemeteryRecord; + cemeterySvg?: string; + cemeterySvgId?: string; + burialSiteLatitude?: number; + burialSiteLongitude?: number; + burialSiteStatusId?: number; + burialSiteStatus?: string; + burialSiteFields?: LotField[]; + burialSiteContractCount?: number; + burialSiteContracts?: LotOccupancy[]; + burialSiteComments?: BurialSiteComment[]; } -export interface LotComment extends Record { - lotCommentId?: number; - lotId?: number; - lotCommentDate?: number; - lotCommentDateString?: string; - lotCommentTime?: number; - lotCommentTimeString?: string; - lotCommentTimePeriodString?: string; - lotComment?: string; +export interface BurialSiteComment extends Record { + burialSiteCommentId?: number; + burialSiteId?: number; + commentDate?: number; + commentDateString?: string; + commentTime?: number; + commentTimeString?: string; + commentTimePeriodString?: string; + comment?: string; } -export interface LotField extends LotTypeField, Record { - lotId?: number; - lotFieldValue?: string; +export interface LotField extends BurialSiteTypeField, Record { + burialSiteId?: number; + burialSiteFieldValue?: string; } export interface OccupancyType extends Record { occupancyTypeId: number; diff --git a/types/recordTypes.ts b/types/recordTypes.ts index 872f935a..c8d5d63d 100644 --- a/types/recordTypes.ts +++ b/types/recordTypes.ts @@ -14,44 +14,44 @@ export interface Record { } /* - * LOT OCCUPANCY DB TYPES + * SUNRISE DB TYPES */ -export interface MapRecord extends Record { - mapId?: number - mapName?: string - mapDescription?: string +export interface CemeteryRecord extends Record { + cemeteryId?: number + cemeteryName?: string + cemeteryDescription?: string - mapLatitude?: number - mapLongitude?: number - mapSVG?: string + cemeteryLatitude?: number + cemeteryLongitude?: number + cemeterySvg?: string - mapAddress1?: string - mapAddress2?: string - mapCity?: string - mapProvince?: string - mapPostalCode?: string - mapPhoneNumber?: string + cemeteryAddress1?: string + cemeteryAddress2?: string + cemeteryCity?: string + cemeteryProvince?: string + cemeteryPostalCode?: string + cemeteryPhoneNumber?: string - lotCount?: number + burialSiteCount?: number } -export interface LotType extends Record { - lotTypeId: number - lotType: string +export interface BurialSiteType extends Record { + burialSiteTypeId: number + burialSiteType: string orderNumber?: number - lotTypeFields?: LotTypeField[] + burialSiteTypeFields?: BurialSiteTypeField[] } -export interface LotTypeField extends Record { - lotTypeFieldId: number - lotTypeField?: string +export interface BurialSiteTypeField extends Record { + burialSiteTypeFieldId: number + burialSiteTypeField?: string - lotTypeId?: number - lotType: LotType + burialSiteTypeId?: number + burialSiteType: BurialSiteType fieldType: string - lotTypeFieldValues?: string + fieldValues?: string isRequired?: boolean pattern?: string minimumLength?: number @@ -60,56 +60,56 @@ export interface LotTypeField extends Record { orderNumber?: number } -export interface LotStatus extends Record { - lotStatusId: number - lotStatus: string +export interface BurialSiteStatus extends Record { + burialSiteStatusId: number + burialSiteStatus: string orderNumber?: number } -export interface Lot extends Record { - lotId: number - lotName?: string +export interface BurialSite extends Record { + burialSiteId: number + burialSiteName?: string - lotTypeId?: number - lotType?: string + burialSiteTypeId?: number + burialSiteType?: string - mapId?: number - mapName?: string - map?: MapRecord - mapSVG?: string - mapKey?: string + cemeteryId?: number + cemeteryName?: string + cemetery?: CemeteryRecord + cemeterySvg?: string + cemeterySvgId?: string - lotLatitude?: number - lotLongitude?: number + burialSiteLatitude?: number + burialSiteLongitude?: number - lotStatusId?: number - lotStatus?: string + burialSiteStatusId?: number + burialSiteStatus?: string - lotFields?: LotField[] + burialSiteFields?: LotField[] - lotOccupancyCount?: number - lotOccupancies?: LotOccupancy[] + burialSiteContractCount?: number + burialSiteContracts?: LotOccupancy[] - lotComments?: LotComment[] + burialSiteComments?: BurialSiteComment[] } -export interface LotComment extends Record { - lotCommentId?: number - lotId?: number +export interface BurialSiteComment extends Record { + burialSiteCommentId?: number + burialSiteId?: number - lotCommentDate?: number - lotCommentDateString?: string + commentDate?: number + commentDateString?: string - lotCommentTime?: number - lotCommentTimeString?: string - lotCommentTimePeriodString?: string + commentTime?: number + commentTimeString?: string + commentTimePeriodString?: string - lotComment?: string + comment?: string } -export interface LotField extends LotTypeField, Record { - lotId?: number - lotFieldValue?: string +export interface LotField extends BurialSiteTypeField, Record { + burialSiteId?: number + burialSiteFieldValue?: string } export interface OccupancyType extends Record { diff --git a/version.d.ts b/version.d.ts index 97fda101..07bdd71f 100644 --- a/version.d.ts +++ b/version.d.ts @@ -1,2 +1,2 @@ -export declare const version = "1.0.0-alpha.14"; +export declare const version = "1.0.0-dev"; export default version; diff --git a/version.js b/version.js index 1032a449..1ee79cfc 100644 --- a/version.js +++ b/version.js @@ -1,2 +1,2 @@ -export const version = '1.0.0-alpha.14'; +export const version = '1.0.0-dev'; export default version; diff --git a/version.ts b/version.ts index fe9b811a..6bd74350 100644 --- a/version.ts +++ b/version.ts @@ -1,3 +1,3 @@ -export const version = '1.0.0-alpha.14' +export const version = '1.0.0-dev' export default version diff --git a/views/_header.ejs b/views/_header.ejs index 806e4a12..2f6eea51 100644 --- a/views/_header.ejs +++ b/views/_header.ejs @@ -83,7 +83,7 @@ Reports - diff --git a/views/_menu-workOrders.ejs b/views/_menu-workOrders.ejs index dea3b747..538af9e5 100644 --- a/views/_menu-workOrders.ejs +++ b/views/_menu-workOrders.ejs @@ -33,15 +33,4 @@ - - \ No newline at end of file diff --git a/views/dashboard.ejs b/views/dashboard.ejs index 63f431a9..408e7280 100644 --- a/views/dashboard.ejs +++ b/views/dashboard.ejs @@ -262,30 +262,12 @@
diff --git a/views/login.ejs b/views/login.ejs index 1a4fc15b..4445d2f9 100644 --- a/views/login.ejs +++ b/views/login.ejs @@ -77,11 +77,7 @@
Build <%= buildNumber %>
- - - Help - - + GitHub diff --git a/views/lot-edit.ejs b/views/lot-edit.ejs index 55db7e04..37878ca5 100644 --- a/views/lot-edit.ejs +++ b/views/lot-edit.ejs @@ -321,25 +321,19 @@
- +
- -
- -
-

- - - What is the SVG ID? - -

+ +
+ +
diff --git a/windowsService.js b/windowsService.js index 7bc8b43a..c2c0ba59 100644 --- a/windowsService.js +++ b/windowsService.js @@ -1,7 +1,7 @@ import path from 'node:path'; const _dirname = '.'; export const serviceConfig = { - name: 'Lot Occupancy Manager', - description: 'A system for managing the occupancy of lots. (i.e. Cemetery management)', + name: 'Sunrise CMS', + description: 'Sunrise Cemetery Management System, a web-based application that allows cemetery managers to manage their cemetery records.', script: path.join(_dirname, 'bin', 'www.js') }; diff --git a/windowsService.ts b/windowsService.ts index 7ec83813..816908c2 100644 --- a/windowsService.ts +++ b/windowsService.ts @@ -5,8 +5,8 @@ import type { ServiceConfig } from 'node-windows' const _dirname = '.' export const serviceConfig: ServiceConfig = { - name: 'Lot Occupancy Manager', + name: 'Sunrise CMS', description: - 'A system for managing the occupancy of lots. (i.e. Cemetery management)', + 'Sunrise Cemetery Management System, a web-based application that allows cemetery managers to manage their cemetery records.', script: path.join(_dirname, 'bin', 'www.js') }