linting
parent
59b04c2b8f
commit
24067317c9
|
|
@ -12,6 +12,7 @@
|
||||||
"plugins": ["@typescript-eslint", "unicorn"],
|
"plugins": ["@typescript-eslint", "unicorn"],
|
||||||
"extends": [
|
"extends": [
|
||||||
"eslint:recommended",
|
"eslint:recommended",
|
||||||
|
"standard-with-typescript",
|
||||||
"plugin:import/recommended",
|
"plugin:import/recommended",
|
||||||
"plugin:import/typescript",
|
"plugin:import/typescript",
|
||||||
"plugin:node/recommended",
|
"plugin:node/recommended",
|
||||||
|
|
@ -21,6 +22,10 @@
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"@typescript-eslint/no-extra-semi": "off",
|
"@typescript-eslint/no-extra-semi": "off",
|
||||||
|
"@typescript-eslint/no-non-null-assertion": "off",
|
||||||
|
"@typescript-eslint/restrict-plus-operands": "warn",
|
||||||
|
"@typescript-eslint/space-before-function-paren": "off",
|
||||||
|
"@typescript-eslint/strict-boolean-expressions": "warn",
|
||||||
"node/no-missing-import": "off",
|
"node/no-missing-import": "off",
|
||||||
"node/no-unpublished-import": "off",
|
"node/no-unpublished-import": "off",
|
||||||
"unicorn/consistent-function-scoping": "warn",
|
"unicorn/consistent-function-scoping": "warn",
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,6 @@
|
||||||
"trailingComma": "none",
|
"trailingComma": "none",
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"semi": false,
|
"semi": false,
|
||||||
"singleQuote": true
|
"singleQuote": true,
|
||||||
|
"bracketSpacing": true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
app.js
18
app.js
|
|
@ -30,13 +30,13 @@ import { getSafeRedirectURL } from './helpers/functions.authentication.js';
|
||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
const debugApp = debug('lot-occupancy-system:app');
|
const debugApp = debug('lot-occupancy-system:app');
|
||||||
databaseInitializer.initializeDatabase();
|
databaseInitializer.initializeDatabase();
|
||||||
const __dirname = '.';
|
const _dirname = '.';
|
||||||
export const app = express();
|
export const app = express();
|
||||||
app.disable('X-Powered-By');
|
app.disable('X-Powered-By');
|
||||||
if (!configFunctions.getProperty('reverseProxy.disableEtag')) {
|
if (!configFunctions.getProperty('reverseProxy.disableEtag')) {
|
||||||
app.set('etag', false);
|
app.set('etag', false);
|
||||||
}
|
}
|
||||||
app.set('views', path.join(__dirname, 'views'));
|
app.set('views', path.join(_dirname, 'views'));
|
||||||
app.set('view engine', 'ejs');
|
app.set('view engine', 'ejs');
|
||||||
if (!configFunctions.getProperty('reverseProxy.disableCompression')) {
|
if (!configFunctions.getProperty('reverseProxy.disableCompression')) {
|
||||||
app.use(compression());
|
app.use(compression());
|
||||||
|
|
@ -87,17 +87,20 @@ app.use(session({
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
app.use((request, response, next) => {
|
app.use((request, response, next) => {
|
||||||
if (request.cookies[sessionCookieName] && !request.session.user) {
|
if (Object.hasOwn(request.cookies, sessionCookieName) &&
|
||||||
|
!Object.hasOwn(request.session, 'user')) {
|
||||||
response.clearCookie(sessionCookieName);
|
response.clearCookie(sessionCookieName);
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
const sessionChecker = (request, response, next) => {
|
const sessionChecker = (request, response, next) => {
|
||||||
if (request.session.user && request.cookies[sessionCookieName]) {
|
if (Object.hasOwn(request.session, 'user') &&
|
||||||
return next();
|
Object.hasOwn(request.cookies, sessionCookieName)) {
|
||||||
|
next();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const redirectUrl = getSafeRedirectURL(request.originalUrl);
|
const redirectUrl = getSafeRedirectURL(request.originalUrl);
|
||||||
return response.redirect(`${urlPrefix}/login?redirect=${encodeURIComponent(redirectUrl)}`);
|
response.redirect(`${urlPrefix}/login?redirect=${encodeURIComponent(redirectUrl)}`);
|
||||||
};
|
};
|
||||||
app.use((request, response, next) => {
|
app.use((request, response, next) => {
|
||||||
response.locals.buildNumber = version;
|
response.locals.buildNumber = version;
|
||||||
|
|
@ -128,7 +131,8 @@ app.all(urlPrefix + '/keepAlive', (_request, response) => {
|
||||||
});
|
});
|
||||||
app.use(urlPrefix + '/login', routerLogin);
|
app.use(urlPrefix + '/login', routerLogin);
|
||||||
app.get(urlPrefix + '/logout', (request, response) => {
|
app.get(urlPrefix + '/logout', (request, response) => {
|
||||||
if (request.session.user && request.cookies[sessionCookieName]) {
|
if (Object.hasOwn(request.session, 'user') &&
|
||||||
|
Object.hasOwn(request.cookies, sessionCookieName)) {
|
||||||
request.session.destroy(() => {
|
request.session.destroy(() => {
|
||||||
response.clearCookie(sessionCookieName);
|
response.clearCookie(sessionCookieName);
|
||||||
response.redirect(urlPrefix + '/');
|
response.redirect(urlPrefix + '/');
|
||||||
|
|
|
||||||
61
app.ts
61
app.ts
|
|
@ -48,7 +48,7 @@ databaseInitializer.initializeDatabase()
|
||||||
* INITIALIZE APP
|
* INITIALIZE APP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const __dirname = '.'
|
const _dirname = '.'
|
||||||
|
|
||||||
export const app = express()
|
export const app = express()
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ if (!configFunctions.getProperty('reverseProxy.disableEtag')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// View engine setup
|
// View engine setup
|
||||||
app.set('views', path.join(__dirname, 'views'))
|
app.set('views', path.join(_dirname, 'views'))
|
||||||
app.set('view engine', 'ejs')
|
app.set('view engine', 'ejs')
|
||||||
|
|
||||||
if (!configFunctions.getProperty('reverseProxy.disableCompression')) {
|
if (!configFunctions.getProperty('reverseProxy.disableCompression')) {
|
||||||
|
|
@ -124,17 +124,27 @@ app.use(
|
||||||
express.static(path.join('node_modules', '@cityssm', 'bulma-webapp-js'))
|
express.static(path.join('node_modules', '@cityssm', 'bulma-webapp-js'))
|
||||||
)
|
)
|
||||||
|
|
||||||
app.use(urlPrefix + '/lib/fa', express.static(path.join('node_modules', '@fortawesome', 'fontawesome-free')))
|
app.use(
|
||||||
|
urlPrefix + '/lib/fa',
|
||||||
|
express.static(path.join('node_modules', '@fortawesome', 'fontawesome-free'))
|
||||||
|
)
|
||||||
|
|
||||||
app.use(urlPrefix + '/lib/leaflet', express.static(path.join('node_modules', 'leaflet', 'dist')))
|
app.use(
|
||||||
|
urlPrefix + '/lib/leaflet',
|
||||||
|
express.static(path.join('node_modules', 'leaflet', 'dist'))
|
||||||
|
)
|
||||||
|
|
||||||
app.use(urlPrefix + '/lib/randomcolor', express.static(path.join('node_modules', 'randomcolor')))
|
app.use(
|
||||||
|
urlPrefix + '/lib/randomcolor',
|
||||||
|
express.static(path.join('node_modules', 'randomcolor'))
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SESSION MANAGEMENT
|
* SESSION MANAGEMENT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const sessionCookieName: string = configFunctions.getProperty('session.cookieName')
|
const sessionCookieName: string =
|
||||||
|
configFunctions.getProperty('session.cookieName')
|
||||||
|
|
||||||
const FileStoreSession = FileStore(session)
|
const FileStoreSession = FileStore(session)
|
||||||
|
|
||||||
|
|
@ -160,7 +170,10 @@ app.use(
|
||||||
|
|
||||||
// Clear cookie if no corresponding session
|
// Clear cookie if no corresponding session
|
||||||
app.use((request, response, next) => {
|
app.use((request, response, next) => {
|
||||||
if (request.cookies[sessionCookieName] && !request.session.user) {
|
if (
|
||||||
|
Object.hasOwn(request.cookies, sessionCookieName) &&
|
||||||
|
!Object.hasOwn(request.session, 'user')
|
||||||
|
) {
|
||||||
response.clearCookie(sessionCookieName)
|
response.clearCookie(sessionCookieName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -168,14 +181,24 @@ app.use((request, response, next) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Redirect logged in users
|
// Redirect logged in users
|
||||||
const sessionChecker = (request: express.Request, response: express.Response, next: express.NextFunction) => {
|
const sessionChecker = (
|
||||||
if (request.session.user && request.cookies[sessionCookieName]) {
|
request: express.Request,
|
||||||
return next()
|
response: express.Response,
|
||||||
|
next: express.NextFunction
|
||||||
|
): void => {
|
||||||
|
if (
|
||||||
|
Object.hasOwn(request.session, 'user') &&
|
||||||
|
Object.hasOwn(request.cookies, sessionCookieName)
|
||||||
|
) {
|
||||||
|
next()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const redirectUrl = getSafeRedirectURL(request.originalUrl)
|
const redirectUrl = getSafeRedirectURL(request.originalUrl)
|
||||||
|
|
||||||
return response.redirect(`${urlPrefix}/login?redirect=${encodeURIComponent(redirectUrl)}`)
|
response.redirect(
|
||||||
|
`${urlPrefix}/login?redirect=${encodeURIComponent(redirectUrl)}`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -196,7 +219,9 @@ app.use((request, response, next) => {
|
||||||
response.locals.stringFunctions = stringFns
|
response.locals.stringFunctions = stringFns
|
||||||
response.locals.htmlFunctions = htmlFns
|
response.locals.htmlFunctions = htmlFns
|
||||||
|
|
||||||
response.locals.urlPrefix = configFunctions.getProperty('reverseProxy.urlPrefix')
|
response.locals.urlPrefix = configFunctions.getProperty(
|
||||||
|
'reverseProxy.urlPrefix'
|
||||||
|
)
|
||||||
|
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
|
@ -216,7 +241,12 @@ app.use(urlPrefix + '/lotOccupancies', sessionChecker, routerLotOccupancies)
|
||||||
app.use(urlPrefix + '/workOrders', sessionChecker, routerWorkOrders)
|
app.use(urlPrefix + '/workOrders', sessionChecker, routerWorkOrders)
|
||||||
|
|
||||||
app.use(urlPrefix + '/reports', sessionChecker, routerReports)
|
app.use(urlPrefix + '/reports', sessionChecker, routerReports)
|
||||||
app.use(urlPrefix + '/admin', sessionChecker, permissionHandlers.adminGetHandler, routerAdmin)
|
app.use(
|
||||||
|
urlPrefix + '/admin',
|
||||||
|
sessionChecker,
|
||||||
|
permissionHandlers.adminGetHandler,
|
||||||
|
routerAdmin
|
||||||
|
)
|
||||||
|
|
||||||
app.all(urlPrefix + '/keepAlive', (_request, response) => {
|
app.all(urlPrefix + '/keepAlive', (_request, response) => {
|
||||||
response.json(true)
|
response.json(true)
|
||||||
|
|
@ -225,7 +255,10 @@ app.all(urlPrefix + '/keepAlive', (_request, response) => {
|
||||||
app.use(urlPrefix + '/login', routerLogin)
|
app.use(urlPrefix + '/login', routerLogin)
|
||||||
|
|
||||||
app.get(urlPrefix + '/logout', (request, response) => {
|
app.get(urlPrefix + '/logout', (request, response) => {
|
||||||
if (request.session.user && request.cookies[sessionCookieName]) {
|
if (
|
||||||
|
Object.hasOwn(request.session, 'user') &&
|
||||||
|
Object.hasOwn(request.cookies, sessionCookieName)
|
||||||
|
) {
|
||||||
request.session.destroy(() => {
|
request.session.destroy(() => {
|
||||||
response.clearCookie(sessionCookieName)
|
response.clearCookie(sessionCookieName)
|
||||||
response.redirect(urlPrefix + '/')
|
response.redirect(urlPrefix + '/')
|
||||||
|
|
|
||||||
56
bin/www.js
56
bin/www.js
|
|
@ -1,21 +1,21 @@
|
||||||
import { app } from "../app.js";
|
import { app } from '../app.js';
|
||||||
import http from "node:http";
|
import http from 'node:http';
|
||||||
import * as configFunctions from "../helpers/functions.config.js";
|
import * as configFunctions from '../helpers/functions.config.js';
|
||||||
import exitHook from "exit-hook";
|
import exitHook from 'exit-hook';
|
||||||
import ntfyPublish from "@cityssm/ntfy-publish";
|
import ntfyPublish from '@cityssm/ntfy-publish';
|
||||||
import Debug from "debug";
|
import Debug from 'debug';
|
||||||
const debug = Debug("lot-occupancy-system:www");
|
const debug = Debug('lot-occupancy-system:www');
|
||||||
function onError(error) {
|
function onError(error) {
|
||||||
if (error.syscall !== "listen") {
|
if (error.syscall !== 'listen') {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
switch (error.code) {
|
switch (error.code) {
|
||||||
case "EACCES": {
|
case 'EACCES': {
|
||||||
debug("Requires elevated privileges");
|
debug('Requires elevated privileges');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
case "EADDRINUSE": {
|
case 'EADDRINUSE': {
|
||||||
debug("Port is already in use.");
|
debug('Port is already in use.');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|
@ -26,21 +26,21 @@ function onError(error) {
|
||||||
function onListening(server) {
|
function onListening(server) {
|
||||||
const addr = server.address();
|
const addr = server.address();
|
||||||
if (addr) {
|
if (addr) {
|
||||||
const bind = typeof addr === "string" ? "pipe " + addr : "port " + addr.port.toString();
|
const bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port.toString();
|
||||||
debug("Listening on " + bind);
|
debug('Listening on ' + bind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const ntfyStartupConfig = configFunctions.getProperty("application.ntfyStartup");
|
const ntfyStartupConfig = configFunctions.getProperty('application.ntfyStartup');
|
||||||
const httpPort = configFunctions.getProperty("application.httpPort");
|
const httpPort = configFunctions.getProperty('application.httpPort');
|
||||||
const httpServer = http.createServer(app);
|
const httpServer = http.createServer(app);
|
||||||
httpServer.listen(httpPort);
|
httpServer.listen(httpPort);
|
||||||
httpServer.on("error", onError);
|
httpServer.on('error', onError);
|
||||||
httpServer.on("listening", () => {
|
httpServer.on('listening', () => {
|
||||||
onListening(httpServer);
|
onListening(httpServer);
|
||||||
});
|
});
|
||||||
debug("HTTP listening on " + httpPort.toString());
|
debug('HTTP listening on ' + httpPort.toString());
|
||||||
exitHook(() => {
|
exitHook(() => {
|
||||||
debug("Closing HTTP");
|
debug('Closing HTTP');
|
||||||
httpServer.close();
|
httpServer.close();
|
||||||
});
|
});
|
||||||
if (ntfyStartupConfig) {
|
if (ntfyStartupConfig) {
|
||||||
|
|
@ -48,15 +48,15 @@ if (ntfyStartupConfig) {
|
||||||
const server = ntfyStartupConfig.server;
|
const server = ntfyStartupConfig.server;
|
||||||
const ntfyStartupMessage = {
|
const ntfyStartupMessage = {
|
||||||
topic,
|
topic,
|
||||||
title: configFunctions.getProperty("application.applicationName"),
|
title: configFunctions.getProperty('application.applicationName'),
|
||||||
message: "Application Started",
|
message: 'Application Started',
|
||||||
tags: ["arrow_up"]
|
tags: ['arrow_up']
|
||||||
};
|
};
|
||||||
const ntfyShutdownMessage = {
|
const ntfyShutdownMessage = {
|
||||||
topic,
|
topic,
|
||||||
title: configFunctions.getProperty("application.applicationName"),
|
title: configFunctions.getProperty('application.applicationName'),
|
||||||
message: "Application Shut Down",
|
message: 'Application Shut Down',
|
||||||
tags: ["arrow_down"]
|
tags: ['arrow_down']
|
||||||
};
|
};
|
||||||
if (server) {
|
if (server) {
|
||||||
ntfyStartupMessage.server = server;
|
ntfyStartupMessage.server = server;
|
||||||
|
|
@ -64,7 +64,7 @@ if (ntfyStartupConfig) {
|
||||||
}
|
}
|
||||||
await ntfyPublish(ntfyStartupMessage);
|
await ntfyPublish(ntfyStartupMessage);
|
||||||
exitHook(() => {
|
exitHook(() => {
|
||||||
debug("Sending ntfy notification");
|
debug('Sending ntfy notification');
|
||||||
ntfyPublish(ntfyShutdownMessage);
|
void ntfyPublish(ntfyShutdownMessage);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
105
bin/www.ts
105
bin/www.ts
|
|
@ -1,58 +1,59 @@
|
||||||
/* eslint-disable no-process-exit, unicorn/no-process-exit */
|
/* eslint-disable no-process-exit, unicorn/no-process-exit */
|
||||||
|
|
||||||
import { app } from "../app.js";
|
import { app } from '../app.js'
|
||||||
|
|
||||||
import http from "node:http";
|
import http from 'node:http'
|
||||||
|
|
||||||
import * as configFunctions from "../helpers/functions.config.js";
|
import * as configFunctions from '../helpers/functions.config.js'
|
||||||
|
|
||||||
import exitHook from "exit-hook";
|
import exitHook from 'exit-hook'
|
||||||
|
|
||||||
import ntfyPublish from "@cityssm/ntfy-publish";
|
import ntfyPublish from '@cityssm/ntfy-publish'
|
||||||
import type * as ntfyTypes from "@cityssm/ntfy-publish/types";
|
import type * as ntfyTypes from '@cityssm/ntfy-publish/types'
|
||||||
|
|
||||||
import Debug from "debug";
|
import Debug from 'debug'
|
||||||
const debug = Debug("lot-occupancy-system:www");
|
const debug = Debug('lot-occupancy-system:www')
|
||||||
|
|
||||||
interface ServerError extends Error {
|
interface ServerError extends Error {
|
||||||
syscall: string;
|
syscall: string
|
||||||
code: string;
|
code: string
|
||||||
}
|
}
|
||||||
|
|
||||||
function onError(error: ServerError) {
|
function onError(error: ServerError): void {
|
||||||
if (error.syscall !== "listen") {
|
if (error.syscall !== 'listen') {
|
||||||
throw error;
|
throw error
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle specific listen errors with friendly messages
|
// handle specific listen errors with friendly messages
|
||||||
switch (error.code) {
|
switch (error.code) {
|
||||||
// eslint-disable-next-line no-fallthrough
|
// eslint-disable-next-line no-fallthrough
|
||||||
case "EACCES": {
|
case 'EACCES': {
|
||||||
debug("Requires elevated privileges");
|
debug('Requires elevated privileges')
|
||||||
process.exit(1);
|
process.exit(1)
|
||||||
// break;
|
// break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-fallthrough
|
// eslint-disable-next-line no-fallthrough
|
||||||
case "EADDRINUSE": {
|
case 'EADDRINUSE': {
|
||||||
debug("Port is already in use.");
|
debug('Port is already in use.')
|
||||||
process.exit(1);
|
process.exit(1)
|
||||||
// break;
|
// break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-fallthrough
|
// eslint-disable-next-line no-fallthrough
|
||||||
default: {
|
default: {
|
||||||
throw error;
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onListening(server: http.Server) {
|
function onListening(server: http.Server): void {
|
||||||
const addr = server.address();
|
const addr = server.address()
|
||||||
|
|
||||||
if (addr) {
|
if (addr) {
|
||||||
const bind = typeof addr === "string" ? "pipe " + addr : "port " + addr.port.toString();
|
const bind =
|
||||||
debug("Listening on " + bind);
|
typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port.toString()
|
||||||
|
debug('Listening on ' + bind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,53 +61,53 @@ function onListening(server: http.Server) {
|
||||||
* Initialize HTTP
|
* Initialize HTTP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ntfyStartupConfig = configFunctions.getProperty("application.ntfyStartup");
|
const ntfyStartupConfig = configFunctions.getProperty('application.ntfyStartup')
|
||||||
|
|
||||||
const httpPort = configFunctions.getProperty("application.httpPort");
|
const httpPort = configFunctions.getProperty('application.httpPort')
|
||||||
|
|
||||||
const httpServer = http.createServer(app);
|
const httpServer = http.createServer(app)
|
||||||
|
|
||||||
httpServer.listen(httpPort);
|
httpServer.listen(httpPort)
|
||||||
|
|
||||||
httpServer.on("error", onError);
|
httpServer.on('error', onError)
|
||||||
httpServer.on("listening", () => {
|
httpServer.on('listening', () => {
|
||||||
onListening(httpServer);
|
onListening(httpServer)
|
||||||
});
|
})
|
||||||
|
|
||||||
debug("HTTP listening on " + httpPort.toString());
|
debug('HTTP listening on ' + httpPort.toString())
|
||||||
|
|
||||||
exitHook(() => {
|
exitHook(() => {
|
||||||
debug("Closing HTTP");
|
debug('Closing HTTP')
|
||||||
httpServer.close();
|
httpServer.close()
|
||||||
});
|
})
|
||||||
|
|
||||||
if (ntfyStartupConfig) {
|
if (ntfyStartupConfig) {
|
||||||
const topic = ntfyStartupConfig.topic;
|
const topic = ntfyStartupConfig.topic
|
||||||
const server = ntfyStartupConfig.server;
|
const server = ntfyStartupConfig.server
|
||||||
|
|
||||||
const ntfyStartupMessage: ntfyTypes.NtfyMessageOptions = {
|
const ntfyStartupMessage: ntfyTypes.NtfyMessageOptions = {
|
||||||
topic,
|
topic,
|
||||||
title: configFunctions.getProperty("application.applicationName"),
|
title: configFunctions.getProperty('application.applicationName'),
|
||||||
message: "Application Started",
|
message: 'Application Started',
|
||||||
tags: ["arrow_up"]
|
tags: ['arrow_up']
|
||||||
};
|
}
|
||||||
|
|
||||||
const ntfyShutdownMessage: ntfyTypes.NtfyMessageOptions = {
|
const ntfyShutdownMessage: ntfyTypes.NtfyMessageOptions = {
|
||||||
topic,
|
topic,
|
||||||
title: configFunctions.getProperty("application.applicationName"),
|
title: configFunctions.getProperty('application.applicationName'),
|
||||||
message: "Application Shut Down",
|
message: 'Application Shut Down',
|
||||||
tags: ["arrow_down"]
|
tags: ['arrow_down']
|
||||||
};
|
}
|
||||||
|
|
||||||
if (server) {
|
if (server) {
|
||||||
ntfyStartupMessage.server = server;
|
ntfyStartupMessage.server = server
|
||||||
ntfyShutdownMessage.server = server;
|
ntfyShutdownMessage.server = server
|
||||||
}
|
}
|
||||||
|
|
||||||
await ntfyPublish(ntfyStartupMessage);
|
await ntfyPublish(ntfyStartupMessage)
|
||||||
|
|
||||||
exitHook(() => {
|
exitHook(() => {
|
||||||
debug("Sending ntfy notification");
|
debug('Sending ntfy notification')
|
||||||
ntfyPublish(ntfyShutdownMessage);
|
void ntfyPublish(ntfyShutdownMessage)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,51 +1,55 @@
|
||||||
import { testAdmin } from "../../../test/_globals.js";
|
import { testAdmin } from '../../../test/_globals.js';
|
||||||
import { logout, login, ajaxDelayMillis } from "../../support/index.js";
|
import { logout, login, ajaxDelayMillis } from '../../support/index.js';
|
||||||
import * as configFunctions from "../../../helpers/functions.config.js";
|
import * as configFunctions from '../../../helpers/functions.config.js';
|
||||||
describe("Admin - Fee Management", () => {
|
describe('Admin - Fee Management', () => {
|
||||||
beforeEach("Loads page", () => {
|
beforeEach('Loads page', () => {
|
||||||
logout();
|
logout();
|
||||||
login(testAdmin);
|
login(testAdmin);
|
||||||
cy.visit("/admin/fees");
|
cy.visit('/admin/fees');
|
||||||
cy.location("pathname").should("equal", "/admin/fees");
|
cy.location('pathname').should('equal', '/admin/fees');
|
||||||
});
|
});
|
||||||
afterEach(logout);
|
afterEach(logout);
|
||||||
it("Has no detectable accessibility issues", () => {
|
it('Has no detectable accessibility issues', () => {
|
||||||
cy.injectAxe();
|
cy.injectAxe();
|
||||||
cy.checkA11y();
|
cy.checkA11y();
|
||||||
});
|
});
|
||||||
it("Creates a new fee category", () => {
|
it('Creates a new fee category', () => {
|
||||||
cy.get("[data-cy='addFeeCategory']").click();
|
cy.get("[data-cy='addFeeCategory']").click();
|
||||||
cy.get(".modal").should("be.visible");
|
cy.get('.modal').should('be.visible');
|
||||||
cy.injectAxe();
|
cy.injectAxe();
|
||||||
cy.checkA11y();
|
cy.checkA11y();
|
||||||
cy.fixture("fee.json").then((fee) => {
|
cy.fixture('fee.json').then((fee) => {
|
||||||
cy.get(".modal input[name='feeCategory']").type(fee.feeCategory);
|
cy.get(".modal input[name='feeCategory']").type(fee.feeCategory);
|
||||||
cy.get(".modal button[type='submit']").click();
|
cy.get(".modal button[type='submit']").click();
|
||||||
cy.wait(ajaxDelayMillis);
|
cy.wait(ajaxDelayMillis);
|
||||||
cy.get(".container--feeCategory .panel-heading .title").should("contain.text", fee.feeCategory);
|
cy.get('.container--feeCategory .panel-heading .title').should('contain.text', fee.feeCategory);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("Creates a new fee", () => {
|
it('Creates a new fee', () => {
|
||||||
cy.get("[data-cy='addFee']").first().click();
|
cy.get("[data-cy='addFee']").first().click();
|
||||||
cy.get(".modal").should("be.visible");
|
cy.get('.modal').should('be.visible');
|
||||||
cy.injectAxe();
|
cy.injectAxe();
|
||||||
cy.checkA11y();
|
cy.checkA11y();
|
||||||
cy.fixture("fee.json").then((fee) => {
|
cy.fixture('fee.json').then((fee) => {
|
||||||
cy.get(".modal input[name='feeName']").type(fee.feeName);
|
cy.get(".modal input[name='feeName']").type(fee.feeName);
|
||||||
cy.get(".modal textarea[name='feeDescription']").type(fee.feeDescription);
|
cy.get(".modal textarea[name='feeDescription']").type(fee.feeDescription);
|
||||||
cy.get(".modal input[name='feeAmount']").clear().type(fee.feeAmount.toString());
|
cy.get(".modal input[name='feeAmount']")
|
||||||
cy.get(".modal input[name='taxAmount']").should("be.disabled");
|
.clear()
|
||||||
|
.type(fee.feeAmount.toString());
|
||||||
|
cy.get(".modal input[name='taxAmount']").should('be.disabled');
|
||||||
cy.get(".modal input[name='taxPercentage']")
|
cy.get(".modal input[name='taxPercentage']")
|
||||||
.invoke("val")
|
.invoke('val')
|
||||||
.should("equal", configFunctions.getProperty("settings.fees.taxPercentageDefault").toString());
|
.should('equal', configFunctions
|
||||||
cy.get(".modal input[name='quantityUnit']").should("be.disabled");
|
.getProperty('settings.fees.taxPercentageDefault')
|
||||||
cy.get(".modal select[name='includeQuantity']").select("1");
|
.toString());
|
||||||
|
cy.get(".modal input[name='quantityUnit']").should('be.disabled');
|
||||||
|
cy.get(".modal select[name='includeQuantity']").select('1');
|
||||||
cy.get(".modal input[name='quantityUnit']")
|
cy.get(".modal input[name='quantityUnit']")
|
||||||
.should("not.be.disabled")
|
.should('not.be.disabled')
|
||||||
.type(fee.quantityUnit);
|
.type(fee.quantityUnit);
|
||||||
cy.get(".modal button[type='submit']").click();
|
cy.get(".modal button[type='submit']").click();
|
||||||
cy.wait(ajaxDelayMillis);
|
cy.wait(ajaxDelayMillis);
|
||||||
cy.get(".container--fee a").should("contain.text", fee.feeName);
|
cy.get('.container--fee a').should('contain.text', fee.feeName);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,88 +1,91 @@
|
||||||
/* eslint-disable unicorn/filename-case, promise/catch-or-return, promise/always-return */
|
/* eslint-disable unicorn/filename-case, promise/catch-or-return, promise/always-return, @typescript-eslint/no-non-null-assertion */
|
||||||
|
|
||||||
import { testAdmin } from "../../../test/_globals.js";
|
import { testAdmin } from '../../../test/_globals.js'
|
||||||
|
|
||||||
import { logout, login, ajaxDelayMillis } from "../../support/index.js";
|
import { logout, login, ajaxDelayMillis } from '../../support/index.js'
|
||||||
|
|
||||||
import * as configFunctions from "../../../helpers/functions.config.js";
|
import * as configFunctions from '../../../helpers/functions.config.js'
|
||||||
|
|
||||||
import type * as recordTypes from "../../../types/recordTypes";
|
import type * as recordTypes from '../../../types/recordTypes'
|
||||||
|
|
||||||
describe("Admin - Fee Management", () => {
|
describe('Admin - Fee Management', () => {
|
||||||
|
beforeEach('Loads page', () => {
|
||||||
|
logout()
|
||||||
|
login(testAdmin)
|
||||||
|
cy.visit('/admin/fees')
|
||||||
|
cy.location('pathname').should('equal', '/admin/fees')
|
||||||
|
})
|
||||||
|
|
||||||
beforeEach("Loads page", () => {
|
afterEach(logout)
|
||||||
logout();
|
|
||||||
login(testAdmin);
|
|
||||||
cy.visit("/admin/fees");
|
|
||||||
cy.location("pathname").should("equal", "/admin/fees");
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(logout);
|
it('Has no detectable accessibility issues', () => {
|
||||||
|
cy.injectAxe()
|
||||||
|
cy.checkA11y()
|
||||||
|
})
|
||||||
|
|
||||||
it("Has no detectable accessibility issues", () => {
|
it('Creates a new fee category', () => {
|
||||||
cy.injectAxe();
|
cy.get("[data-cy='addFeeCategory']").click()
|
||||||
cy.checkA11y();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Creates a new fee category", () => {
|
cy.get('.modal').should('be.visible')
|
||||||
cy.get("[data-cy='addFeeCategory']").click();
|
|
||||||
|
|
||||||
cy.get(".modal").should("be.visible");
|
cy.injectAxe()
|
||||||
|
cy.checkA11y()
|
||||||
|
|
||||||
cy.injectAxe();
|
cy.fixture('fee.json').then((fee: recordTypes.Fee) => {
|
||||||
cy.checkA11y();
|
cy.get(".modal input[name='feeCategory']").type(fee.feeCategory!)
|
||||||
|
|
||||||
cy.fixture("fee.json").then((fee: recordTypes.Fee) => {
|
cy.get(".modal button[type='submit']").click()
|
||||||
cy.get(".modal input[name='feeCategory']").type(fee.feeCategory);
|
|
||||||
|
|
||||||
cy.get(".modal button[type='submit']").click();
|
cy.wait(ajaxDelayMillis)
|
||||||
|
|
||||||
cy.wait(ajaxDelayMillis);
|
cy.get('.container--feeCategory .panel-heading .title').should(
|
||||||
|
'contain.text',
|
||||||
cy.get(".container--feeCategory .panel-heading .title").should(
|
|
||||||
"contain.text",
|
|
||||||
fee.feeCategory
|
fee.feeCategory
|
||||||
);
|
)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
it("Creates a new fee", () => {
|
it('Creates a new fee', () => {
|
||||||
cy.get("[data-cy='addFee']").first().click();
|
cy.get("[data-cy='addFee']").first().click()
|
||||||
|
|
||||||
cy.get(".modal").should("be.visible");
|
cy.get('.modal').should('be.visible')
|
||||||
|
|
||||||
cy.injectAxe();
|
cy.injectAxe()
|
||||||
cy.checkA11y();
|
cy.checkA11y()
|
||||||
|
|
||||||
cy.fixture("fee.json").then((fee: recordTypes.Fee) => {
|
cy.fixture('fee.json').then((fee: recordTypes.Fee) => {
|
||||||
cy.get(".modal input[name='feeName']").type(fee.feeName);
|
cy.get(".modal input[name='feeName']").type(fee.feeName!)
|
||||||
|
|
||||||
cy.get(".modal textarea[name='feeDescription']").type(fee.feeDescription);
|
cy.get(".modal textarea[name='feeDescription']").type(fee.feeDescription!)
|
||||||
|
|
||||||
cy.get(".modal input[name='feeAmount']").clear().type(fee.feeAmount.toString());
|
cy.get(".modal input[name='feeAmount']")
|
||||||
|
.clear()
|
||||||
|
.type(fee.feeAmount!.toString())
|
||||||
|
|
||||||
cy.get(".modal input[name='taxAmount']").should("be.disabled");
|
cy.get(".modal input[name='taxAmount']").should('be.disabled')
|
||||||
|
|
||||||
cy.get(".modal input[name='taxPercentage']")
|
cy.get(".modal input[name='taxPercentage']")
|
||||||
.invoke("val")
|
.invoke('val')
|
||||||
.should(
|
.should(
|
||||||
"equal",
|
'equal',
|
||||||
configFunctions.getProperty("settings.fees.taxPercentageDefault").toString()
|
configFunctions
|
||||||
);
|
.getProperty('settings.fees.taxPercentageDefault')
|
||||||
|
.toString()
|
||||||
|
)
|
||||||
|
|
||||||
cy.get(".modal input[name='quantityUnit']").should("be.disabled");
|
cy.get(".modal input[name='quantityUnit']").should('be.disabled')
|
||||||
|
|
||||||
cy.get(".modal select[name='includeQuantity']").select("1");
|
cy.get(".modal select[name='includeQuantity']").select('1')
|
||||||
|
|
||||||
cy.get(".modal input[name='quantityUnit']")
|
cy.get(".modal input[name='quantityUnit']")
|
||||||
.should("not.be.disabled")
|
.should('not.be.disabled')
|
||||||
.type(fee.quantityUnit);
|
.type(fee.quantityUnit!)
|
||||||
|
|
||||||
cy.get(".modal button[type='submit']").click();
|
cy.get(".modal button[type='submit']").click()
|
||||||
|
|
||||||
cy.wait(ajaxDelayMillis);
|
cy.wait(ajaxDelayMillis)
|
||||||
|
|
||||||
cy.get(".container--fee a").should("contain.text", fee.feeName);
|
cy.get('.container--fee a').should('contain.text', fee.feeName)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { testUpdate } from "../../../test/_globals.js";
|
import { testUpdate } from "../../../test/_globals.js";
|
||||||
import { logout, login } from "../../support/index.js";
|
import { logout, login } from "../../support/index.js";
|
||||||
describe("Update - Lot Occupancies", () => {
|
describe("Update - Lot Occupancies", () => {
|
||||||
beforeEach("Loads page", () => {
|
beforeEach(() => {
|
||||||
logout();
|
logout();
|
||||||
login(testUpdate);
|
login(testUpdate);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,7 @@ import { testUpdate } from "../../../test/_globals.js";
|
||||||
import { logout, login } from "../../support/index.js";
|
import { logout, login } from "../../support/index.js";
|
||||||
|
|
||||||
describe("Update - Lot Occupancies", () => {
|
describe("Update - Lot Occupancies", () => {
|
||||||
|
beforeEach(() => {
|
||||||
beforeEach("Loads page", () => {
|
|
||||||
logout();
|
logout();
|
||||||
login(testUpdate);
|
login(testUpdate);
|
||||||
});
|
});
|
||||||
|
|
@ -18,7 +17,6 @@ describe("Update - Lot Occupancies", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Update a New Lot Occupancy", () => {
|
describe("Update a New Lot Occupancy", () => {
|
||||||
|
|
||||||
it("Has no detectable accessibility issues", () => {
|
it("Has no detectable accessibility issues", () => {
|
||||||
cy.visit("/lotOccupancies/new");
|
cy.visit("/lotOccupancies/new");
|
||||||
cy.injectAxe();
|
cy.injectAxe();
|
||||||
|
|
|
||||||
|
|
@ -1,51 +1,61 @@
|
||||||
import { testUpdate } from "../../../test/_globals.js";
|
import { testUpdate } from '../../../test/_globals.js';
|
||||||
import { logout, login } from "../../support/index.js";
|
import { logout, login } from '../../support/index.js';
|
||||||
import * as configFunctions from "../../../helpers/functions.config.js";
|
import * as configFunctions from '../../../helpers/functions.config.js';
|
||||||
describe("Update - Maps", () => {
|
describe('Update - Maps', () => {
|
||||||
beforeEach("Loads page", () => {
|
beforeEach('Loads page', () => {
|
||||||
logout();
|
logout();
|
||||||
login(testUpdate);
|
login(testUpdate);
|
||||||
});
|
});
|
||||||
afterEach(logout);
|
afterEach(logout);
|
||||||
it('Has a "Create" link on the Map Search', () => {
|
it('Has a "Create" link on the Map Search', () => {
|
||||||
cy.visit("/maps");
|
cy.visit('/maps');
|
||||||
cy.location("pathname").should("equal", "/maps");
|
cy.location('pathname').should('equal', '/maps');
|
||||||
cy.get("a[href$='/maps/new']").should("exist");
|
cy.get("a[href$='/maps/new']").should('exist');
|
||||||
});
|
});
|
||||||
it("Creates a new map", () => {
|
it('Creates a new map', () => {
|
||||||
cy.visit("/maps/new");
|
cy.visit('/maps/new');
|
||||||
cy.log("Check the accessibility");
|
cy.log('Check the accessibility');
|
||||||
cy.injectAxe();
|
cy.injectAxe();
|
||||||
cy.checkA11y();
|
cy.checkA11y();
|
||||||
cy.log("Populate the fields");
|
cy.log('Populate the fields');
|
||||||
cy.fixture("map.json").then((mapJSON) => {
|
cy.fixture('map.json').then((mapJSON) => {
|
||||||
cy.get("input[name='mapName']").clear().type(mapJSON.mapName);
|
cy.get("input[name='mapName']").clear().type(mapJSON.mapName);
|
||||||
cy.get("textarea[name='mapDescription']").clear().type(mapJSON.mapDescription);
|
cy.get("textarea[name='mapDescription']")
|
||||||
|
.clear()
|
||||||
|
.type(mapJSON.mapDescription);
|
||||||
cy.get("input[name='mapAddress1']").clear().type(mapJSON.mapAddress1);
|
cy.get("input[name='mapAddress1']").clear().type(mapJSON.mapAddress1);
|
||||||
cy.get("input[name='mapAddress2']").clear().type(mapJSON.mapAddress2);
|
cy.get("input[name='mapAddress2']").clear().type(mapJSON.mapAddress2);
|
||||||
cy.get("input[name='mapPostalCode']").clear().type(mapJSON.mapPostalCode);
|
cy.get("input[name='mapPostalCode']").clear().type(mapJSON.mapPostalCode);
|
||||||
cy.get("input[name='mapPhoneNumber']").clear().type(mapJSON.mapPhoneNumber);
|
cy.get("input[name='mapPhoneNumber']")
|
||||||
cy.get("input[name='mapLatitude']").clear().type(mapJSON.mapLatitude.toString());
|
.clear()
|
||||||
cy.get("input[name='mapLongitude']").clear().type(mapJSON.mapLongitude.toString());
|
.type(mapJSON.mapPhoneNumber);
|
||||||
|
cy.get("input[name='mapLatitude']")
|
||||||
|
.clear()
|
||||||
|
.type(mapJSON.mapLatitude.toString());
|
||||||
|
cy.get("input[name='mapLongitude']")
|
||||||
|
.clear()
|
||||||
|
.type(mapJSON.mapLongitude.toString());
|
||||||
});
|
});
|
||||||
cy.log("Ensure the default city and province are used");
|
cy.log('Ensure the default city and province are used');
|
||||||
cy.get("input[name='mapCity']").should("have.value", configFunctions.getProperty("settings.map.mapCityDefault"));
|
cy.get("input[name='mapCity']").should('have.value', configFunctions.getProperty('settings.map.mapCityDefault'));
|
||||||
cy.get("input[name='mapProvince']").should("have.value", configFunctions.getProperty("settings.map.mapProvinceDefault"));
|
cy.get("input[name='mapProvince']").should('have.value', configFunctions.getProperty('settings.map.mapProvinceDefault'));
|
||||||
cy.log("Submit the form");
|
cy.log('Submit the form');
|
||||||
cy.get("#form--map").submit();
|
cy.get('#form--map').submit();
|
||||||
cy.wait(1000);
|
cy.wait(1000);
|
||||||
cy.location("pathname").should("not.contain", "/new").should("contain", "/edit");
|
cy.location('pathname')
|
||||||
cy.fixture("map.json").then((mapJSON) => {
|
.should('not.contain', '/new')
|
||||||
cy.get("input[name='mapName']").should("have.value", mapJSON.mapName);
|
.should('contain', '/edit');
|
||||||
cy.get("textarea[name='mapDescription']").should("have.value", mapJSON.mapDescription);
|
cy.fixture('map.json').then((mapJSON) => {
|
||||||
cy.get("input[name='mapAddress1']").should("have.value", mapJSON.mapAddress1);
|
cy.get("input[name='mapName']").should('have.value', mapJSON.mapName);
|
||||||
cy.get("input[name='mapAddress2']").should("have.value", mapJSON.mapAddress2);
|
cy.get("textarea[name='mapDescription']").should('have.value', mapJSON.mapDescription);
|
||||||
cy.get("input[name='mapCity']").should("have.value", configFunctions.getProperty("settings.map.mapCityDefault"));
|
cy.get("input[name='mapAddress1']").should('have.value', mapJSON.mapAddress1);
|
||||||
cy.get("input[name='mapProvince']").should("have.value", configFunctions.getProperty("settings.map.mapProvinceDefault"));
|
cy.get("input[name='mapAddress2']").should('have.value', mapJSON.mapAddress2);
|
||||||
cy.get("input[name='mapPostalCode']").should("have.value", mapJSON.mapPostalCode);
|
cy.get("input[name='mapCity']").should('have.value', configFunctions.getProperty('settings.map.mapCityDefault'));
|
||||||
cy.get("input[name='mapPhoneNumber']").should("have.value", mapJSON.mapPhoneNumber);
|
cy.get("input[name='mapProvince']").should('have.value', configFunctions.getProperty('settings.map.mapProvinceDefault'));
|
||||||
cy.get("input[name='mapLatitude']").should("have.value", mapJSON.mapLatitude.toString());
|
cy.get("input[name='mapPostalCode']").should('have.value', mapJSON.mapPostalCode);
|
||||||
cy.get("input[name='mapLongitude']").should("have.value", mapJSON.mapLongitude.toString());
|
cy.get("input[name='mapPhoneNumber']").should('have.value', mapJSON.mapPhoneNumber);
|
||||||
|
cy.get("input[name='mapLatitude']").should('have.value', mapJSON.mapLatitude.toString());
|
||||||
|
cy.get("input[name='mapLongitude']").should('have.value', mapJSON.mapLongitude.toString());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,97 +1,124 @@
|
||||||
import { testUpdate } from "../../../test/_globals.js";
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||||
|
|
||||||
import { logout, login } from "../../support/index.js";
|
import { testUpdate } from '../../../test/_globals.js'
|
||||||
|
|
||||||
import * as configFunctions from "../../../helpers/functions.config.js";
|
import { logout, login } from '../../support/index.js'
|
||||||
|
|
||||||
import type * as recordTypes from "../../../types/recordTypes";
|
import * as configFunctions from '../../../helpers/functions.config.js'
|
||||||
|
|
||||||
describe("Update - Maps", () => {
|
import type * as recordTypes from '../../../types/recordTypes'
|
||||||
beforeEach("Loads page", () => {
|
|
||||||
logout();
|
|
||||||
login(testUpdate);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(logout);
|
describe('Update - Maps', () => {
|
||||||
|
beforeEach('Loads page', () => {
|
||||||
|
logout()
|
||||||
|
login(testUpdate)
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(logout)
|
||||||
|
|
||||||
it('Has a "Create" link on the Map Search', () => {
|
it('Has a "Create" link on the Map Search', () => {
|
||||||
cy.visit("/maps");
|
cy.visit('/maps')
|
||||||
cy.location("pathname").should("equal", "/maps");
|
cy.location('pathname').should('equal', '/maps')
|
||||||
cy.get("a[href$='/maps/new']").should("exist");
|
cy.get("a[href$='/maps/new']").should('exist')
|
||||||
});
|
})
|
||||||
|
|
||||||
it("Creates a new map", () => {
|
it('Creates a new map', () => {
|
||||||
cy.visit("/maps/new");
|
cy.visit('/maps/new')
|
||||||
|
|
||||||
cy.log("Check the accessibility");
|
cy.log('Check the accessibility')
|
||||||
|
|
||||||
cy.injectAxe();
|
cy.injectAxe()
|
||||||
cy.checkA11y();
|
cy.checkA11y()
|
||||||
|
|
||||||
cy.log("Populate the fields");
|
cy.log('Populate the fields')
|
||||||
|
|
||||||
// eslint-disable-next-line promise/catch-or-return, promise/always-return
|
// eslint-disable-next-line promise/catch-or-return, promise/always-return
|
||||||
cy.fixture("map.json").then((mapJSON: recordTypes.Map) => {
|
cy.fixture('map.json').then((mapJSON: recordTypes.Map) => {
|
||||||
cy.get("input[name='mapName']").clear().type(mapJSON.mapName);
|
cy.get("input[name='mapName']").clear().type(mapJSON.mapName!)
|
||||||
cy.get("textarea[name='mapDescription']").clear().type(mapJSON.mapDescription);
|
cy.get("textarea[name='mapDescription']")
|
||||||
|
.clear()
|
||||||
|
.type(mapJSON.mapDescription!)
|
||||||
|
|
||||||
cy.get("input[name='mapAddress1']").clear().type(mapJSON.mapAddress1);
|
cy.get("input[name='mapAddress1']").clear().type(mapJSON.mapAddress1!)
|
||||||
cy.get("input[name='mapAddress2']").clear().type(mapJSON.mapAddress2);
|
cy.get("input[name='mapAddress2']").clear().type(mapJSON.mapAddress2!)
|
||||||
cy.get("input[name='mapPostalCode']").clear().type(mapJSON.mapPostalCode);
|
cy.get("input[name='mapPostalCode']").clear().type(mapJSON.mapPostalCode!)
|
||||||
cy.get("input[name='mapPhoneNumber']").clear().type(mapJSON.mapPhoneNumber);
|
cy.get("input[name='mapPhoneNumber']")
|
||||||
|
.clear()
|
||||||
|
.type(mapJSON.mapPhoneNumber!)
|
||||||
|
|
||||||
cy.get("input[name='mapLatitude']").clear().type(mapJSON.mapLatitude.toString());
|
cy.get("input[name='mapLatitude']")
|
||||||
cy.get("input[name='mapLongitude']").clear().type(mapJSON.mapLongitude.toString());
|
.clear()
|
||||||
});
|
.type(mapJSON.mapLatitude!.toString())
|
||||||
|
cy.get("input[name='mapLongitude']")
|
||||||
|
.clear()
|
||||||
|
.type(mapJSON.mapLongitude!.toString())
|
||||||
|
})
|
||||||
|
|
||||||
cy.log("Ensure the default city and province are used");
|
cy.log('Ensure the default city and province are used')
|
||||||
|
|
||||||
cy.get("input[name='mapCity']").should(
|
cy.get("input[name='mapCity']").should(
|
||||||
"have.value",
|
'have.value',
|
||||||
configFunctions.getProperty("settings.map.mapCityDefault")
|
configFunctions.getProperty('settings.map.mapCityDefault')
|
||||||
);
|
)
|
||||||
|
|
||||||
cy.get("input[name='mapProvince']").should(
|
cy.get("input[name='mapProvince']").should(
|
||||||
"have.value",
|
'have.value',
|
||||||
configFunctions.getProperty("settings.map.mapProvinceDefault")
|
configFunctions.getProperty('settings.map.mapProvinceDefault')
|
||||||
);
|
)
|
||||||
|
|
||||||
cy.log("Submit the form");
|
cy.log('Submit the form')
|
||||||
|
|
||||||
cy.get("#form--map").submit();
|
cy.get('#form--map').submit()
|
||||||
|
|
||||||
cy.wait(1000);
|
cy.wait(1000)
|
||||||
|
|
||||||
cy.location("pathname").should("not.contain", "/new").should("contain", "/edit");
|
cy.location('pathname')
|
||||||
|
.should('not.contain', '/new')
|
||||||
|
.should('contain', '/edit')
|
||||||
|
|
||||||
// eslint-disable-next-line promise/catch-or-return, promise/always-return
|
// eslint-disable-next-line promise/catch-or-return, promise/always-return
|
||||||
cy.fixture("map.json").then((mapJSON: recordTypes.Map) => {
|
cy.fixture('map.json').then((mapJSON: recordTypes.Map) => {
|
||||||
cy.get("input[name='mapName']").should("have.value", mapJSON.mapName);
|
cy.get("input[name='mapName']").should('have.value', mapJSON.mapName)
|
||||||
cy.get("textarea[name='mapDescription']").should("have.value", mapJSON.mapDescription);
|
cy.get("textarea[name='mapDescription']").should(
|
||||||
|
'have.value',
|
||||||
|
mapJSON.mapDescription
|
||||||
|
)
|
||||||
|
|
||||||
cy.get("input[name='mapAddress1']").should("have.value", mapJSON.mapAddress1);
|
cy.get("input[name='mapAddress1']").should(
|
||||||
cy.get("input[name='mapAddress2']").should("have.value", mapJSON.mapAddress2);
|
'have.value',
|
||||||
|
mapJSON.mapAddress1
|
||||||
|
)
|
||||||
|
cy.get("input[name='mapAddress2']").should(
|
||||||
|
'have.value',
|
||||||
|
mapJSON.mapAddress2
|
||||||
|
)
|
||||||
|
|
||||||
cy.get("input[name='mapCity']").should(
|
cy.get("input[name='mapCity']").should(
|
||||||
"have.value",
|
'have.value',
|
||||||
configFunctions.getProperty("settings.map.mapCityDefault")
|
configFunctions.getProperty('settings.map.mapCityDefault')
|
||||||
);
|
)
|
||||||
cy.get("input[name='mapProvince']").should(
|
cy.get("input[name='mapProvince']").should(
|
||||||
"have.value",
|
'have.value',
|
||||||
configFunctions.getProperty("settings.map.mapProvinceDefault")
|
configFunctions.getProperty('settings.map.mapProvinceDefault')
|
||||||
);
|
)
|
||||||
|
|
||||||
cy.get("input[name='mapPostalCode']").should("have.value", mapJSON.mapPostalCode);
|
cy.get("input[name='mapPostalCode']").should(
|
||||||
cy.get("input[name='mapPhoneNumber']").should("have.value", mapJSON.mapPhoneNumber);
|
'have.value',
|
||||||
|
mapJSON.mapPostalCode
|
||||||
|
)
|
||||||
|
cy.get("input[name='mapPhoneNumber']").should(
|
||||||
|
'have.value',
|
||||||
|
mapJSON.mapPhoneNumber
|
||||||
|
)
|
||||||
|
|
||||||
cy.get("input[name='mapLatitude']").should(
|
cy.get("input[name='mapLatitude']").should(
|
||||||
"have.value",
|
'have.value',
|
||||||
mapJSON.mapLatitude.toString()
|
mapJSON.mapLatitude!.toString()
|
||||||
);
|
)
|
||||||
cy.get("input[name='mapLongitude']").should(
|
cy.get("input[name='mapLongitude']").should(
|
||||||
"have.value",
|
'have.value',
|
||||||
mapJSON.mapLongitude.toString()
|
mapJSON.mapLongitude!.toString()
|
||||||
);
|
)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,22 @@ config.aliases.occupancyStartDate = "Purchase Date";
|
||||||
config.aliases.externalReceiptNumber = "GP Receipt Number";
|
config.aliases.externalReceiptNumber = "GP Receipt Number";
|
||||||
config.settings.lot.lotNamePattern =
|
config.settings.lot.lotNamePattern =
|
||||||
/^[\dA-Z]{2}-(B[\dA-Z]+-)?(R[\dA-Z]+-)?(L[\dA-Z]+-)?G[\dA-Z]+(, Interment \d+)?$/;
|
/^[\dA-Z]{2}-(B[\dA-Z]+-)?(R[\dA-Z]+-)?(L[\dA-Z]+-)?G[\dA-Z]+(, Interment \d+)?$/;
|
||||||
config.settings.lot.lotNameHelpText =
|
config.settings.lot.lotNameHelpText = `Two digit cemetery-Block-Range-Lot-Grave, Interment number\n
|
||||||
"Two digit cemetery-Block-Range-Lot-Grave, Interment number\n" +
|
ex. XX-BA-R41-L15-G3A, Interment 1`;
|
||||||
"ex. XX-BA-R41-L15-G3A, Interment 1";
|
|
||||||
config.settings.lot.lotNameSortNameFunction = (lotName) => {
|
|
||||||
const numericPadding = "00000";
|
const numericPadding = "00000";
|
||||||
|
config.settings.lot.lotNameSortNameFunction = (lotName) => {
|
||||||
|
try {
|
||||||
const lotNameSplit = lotName.toUpperCase().split("-");
|
const lotNameSplit = lotName.toUpperCase().split("-");
|
||||||
const cleanLotNamePieces = [];
|
const cleanLotNamePieces = [];
|
||||||
for (const lotNamePiece of lotNameSplit) {
|
for (let lotNamePiece of lotNameSplit) {
|
||||||
|
if (cleanLotNamePieces.length === 0) {
|
||||||
|
cleanLotNamePieces.push(lotNamePiece);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let numericPiece = numericPadding;
|
let numericPiece = numericPadding;
|
||||||
let letterPiece = "";
|
let letterPiece = "";
|
||||||
|
const firstLetter = lotNamePiece.charAt(0);
|
||||||
|
lotNamePiece = lotNamePiece.slice(1);
|
||||||
for (const letter of lotNamePiece) {
|
for (const letter of lotNamePiece) {
|
||||||
if (letterPiece === "" && "0123456789".includes(letter)) {
|
if (letterPiece === "" && "0123456789".includes(letter)) {
|
||||||
numericPiece += letter;
|
numericPiece += letter;
|
||||||
|
|
@ -22,15 +28,16 @@ config.settings.lot.lotNameSortNameFunction = (lotName) => {
|
||||||
letterPiece += letter;
|
letterPiece += letter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cleanLotNamePieces.push(numericPiece.slice(-1 * numericPadding.length) + letterPiece);
|
cleanLotNamePieces.push(firstLetter + numericPiece.slice(-1 * numericPadding.length) + letterPiece);
|
||||||
}
|
}
|
||||||
return cleanLotNamePieces.join("-");
|
return cleanLotNamePieces.join("-");
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return lotName;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
config.settings.lotOccupancy.occupantCityDefault = "Sault Ste. Marie";
|
config.settings.lotOccupancy.occupantCityDefault = "Sault Ste. Marie";
|
||||||
config.settings.lotOccupancy.prints = [
|
config.settings.lotOccupancy.prints = ["pdf/ssm.cemetery.burialPermit", "pdf/ssm.cemetery.contract"];
|
||||||
"pdf/ssm.cemetery.burialPermit",
|
|
||||||
"pdf/ssm.cemetery.contract"
|
|
||||||
];
|
|
||||||
config.settings.map.mapCityDefault = "Sault Ste. Marie";
|
config.settings.map.mapCityDefault = "Sault Ste. Marie";
|
||||||
config.settings.workOrders.workOrderNumberLength = 6;
|
config.settings.workOrders.workOrderNumberLength = 6;
|
||||||
config.settings.workOrders.workOrderMilestoneDateRecentBeforeDays = 7;
|
config.settings.workOrders.workOrderMilestoneDateRecentBeforeDays = 7;
|
||||||
|
|
|
||||||
|
|
@ -8,21 +8,29 @@ config.aliases.externalReceiptNumber = "GP Receipt Number";
|
||||||
config.settings.lot.lotNamePattern =
|
config.settings.lot.lotNamePattern =
|
||||||
/^[\dA-Z]{2}-(B[\dA-Z]+-)?(R[\dA-Z]+-)?(L[\dA-Z]+-)?G[\dA-Z]+(, Interment \d+)?$/;
|
/^[\dA-Z]{2}-(B[\dA-Z]+-)?(R[\dA-Z]+-)?(L[\dA-Z]+-)?G[\dA-Z]+(, Interment \d+)?$/;
|
||||||
|
|
||||||
config.settings.lot.lotNameHelpText =
|
config.settings.lot.lotNameHelpText = `Two digit cemetery-Block-Range-Lot-Grave, Interment number\n
|
||||||
"Two digit cemetery-Block-Range-Lot-Grave, Interment number\n" +
|
ex. XX-BA-R41-L15-G3A, Interment 1`;
|
||||||
"ex. XX-BA-R41-L15-G3A, Interment 1";
|
|
||||||
|
|
||||||
config.settings.lot.lotNameSortNameFunction = (lotName) => {
|
|
||||||
const numericPadding = "00000";
|
const numericPadding = "00000";
|
||||||
|
|
||||||
|
config.settings.lot.lotNameSortNameFunction = (lotName) => {
|
||||||
|
try {
|
||||||
const lotNameSplit = lotName.toUpperCase().split("-");
|
const lotNameSplit = lotName.toUpperCase().split("-");
|
||||||
|
|
||||||
const cleanLotNamePieces: string[] = [];
|
const cleanLotNamePieces: string[] = [];
|
||||||
|
|
||||||
for (const lotNamePiece of lotNameSplit) {
|
for (let lotNamePiece of lotNameSplit) {
|
||||||
|
if (cleanLotNamePieces.length === 0) {
|
||||||
|
cleanLotNamePieces.push(lotNamePiece);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let numericPiece = numericPadding;
|
let numericPiece = numericPadding;
|
||||||
let letterPiece = "";
|
let letterPiece = "";
|
||||||
|
|
||||||
|
const firstLetter = lotNamePiece.charAt(0);
|
||||||
|
lotNamePiece = lotNamePiece.slice(1);
|
||||||
|
|
||||||
for (const letter of lotNamePiece) {
|
for (const letter of lotNamePiece) {
|
||||||
if (letterPiece === "" && "0123456789".includes(letter)) {
|
if (letterPiece === "" && "0123456789".includes(letter)) {
|
||||||
numericPiece += letter;
|
numericPiece += letter;
|
||||||
|
|
@ -31,17 +39,19 @@ config.settings.lot.lotNameSortNameFunction = (lotName) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanLotNamePieces.push(numericPiece.slice(-1 * numericPadding.length) + letterPiece);
|
cleanLotNamePieces.push(
|
||||||
|
firstLetter + numericPiece.slice(-1 * numericPadding.length) + letterPiece
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cleanLotNamePieces.join("-");
|
return cleanLotNamePieces.join("-");
|
||||||
|
} catch {
|
||||||
|
return lotName;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
config.settings.lotOccupancy.occupantCityDefault = "Sault Ste. Marie";
|
config.settings.lotOccupancy.occupantCityDefault = "Sault Ste. Marie";
|
||||||
config.settings.lotOccupancy.prints = [
|
config.settings.lotOccupancy.prints = ["pdf/ssm.cemetery.burialPermit", "pdf/ssm.cemetery.contract"];
|
||||||
"pdf/ssm.cemetery.burialPermit",
|
|
||||||
"pdf/ssm.cemetery.contract"
|
|
||||||
];
|
|
||||||
|
|
||||||
config.settings.map.mapCityDefault = "Sault Ste. Marie";
|
config.settings.map.mapCityDefault = "Sault Ste. Marie";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express';
|
||||||
export declare const handler: RequestHandler;
|
export declare const handler: RequestHandler;
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { addFee } from "../../helpers/lotOccupancyDB/addFee.js";
|
import { addFee } from '../../helpers/lotOccupancyDB/addFee.js';
|
||||||
import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js";
|
import { getFeeCategories } from '../../helpers/lotOccupancyDB/getFeeCategories.js';
|
||||||
export const handler = async (request, response) => {
|
export const handler = (request, response) => {
|
||||||
const feeId = addFee(request.body, request.session);
|
const feeId = addFee(request.body, request.session);
|
||||||
const feeCategories = getFeeCategories({}, {
|
const feeCategories = getFeeCategories({}, {
|
||||||
includeFees: true
|
includeFees: true
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,24 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express'
|
||||||
|
|
||||||
import { addFee } from "../../helpers/lotOccupancyDB/addFee.js";
|
import { addFee } from '../../helpers/lotOccupancyDB/addFee.js'
|
||||||
|
|
||||||
import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js";
|
import { getFeeCategories } from '../../helpers/lotOccupancyDB/getFeeCategories.js'
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
const feeId = addFee(request.body, request.session);
|
const feeId = addFee(request.body, request.session)
|
||||||
|
|
||||||
const feeCategories = getFeeCategories(
|
const feeCategories = getFeeCategories(
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
includeFees: true
|
includeFees: true
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
success: true,
|
success: true,
|
||||||
feeId,
|
feeId,
|
||||||
feeCategories
|
feeCategories
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
export default handler;
|
export default handler
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express';
|
||||||
export declare const handler: RequestHandler;
|
export declare const handler: RequestHandler;
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { updateRecord } from "../../helpers/lotOccupancyDB/updateRecord.js";
|
import { updateRecord } from '../../helpers/lotOccupancyDB/updateRecord.js';
|
||||||
import { getWorkOrderTypes } from "../../helpers/functions.cache.js";
|
import { getWorkOrderTypes } from '../../helpers/functions.cache.js';
|
||||||
export const handler = async (request, response) => {
|
export const handler = (request, response) => {
|
||||||
const success = updateRecord("WorkOrderTypes", request.body.workOrderTypeId, request.body.workOrderType, request.session);
|
const success = updateRecord('WorkOrderTypes', request.body.workOrderTypeId, request.body.workOrderType, request.session);
|
||||||
const workOrderTypes = getWorkOrderTypes();
|
const workOrderTypes = getWorkOrderTypes();
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express'
|
||||||
|
|
||||||
import { updateRecord } from "../../helpers/lotOccupancyDB/updateRecord.js";
|
import { updateRecord } from '../../helpers/lotOccupancyDB/updateRecord.js'
|
||||||
import { getWorkOrderTypes } from "../../helpers/functions.cache.js";
|
import { getWorkOrderTypes } from '../../helpers/functions.cache.js'
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
const success = updateRecord(
|
const success = updateRecord(
|
||||||
"WorkOrderTypes",
|
'WorkOrderTypes',
|
||||||
request.body.workOrderTypeId,
|
request.body.workOrderTypeId,
|
||||||
request.body.workOrderType,
|
request.body.workOrderType,
|
||||||
request.session
|
request.session
|
||||||
);
|
)
|
||||||
|
|
||||||
const workOrderTypes = getWorkOrderTypes();
|
const workOrderTypes = getWorkOrderTypes()
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
workOrderTypes
|
workOrderTypes
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
export default handler;
|
export default handler
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express';
|
||||||
export declare const handler: RequestHandler;
|
export declare const handler: RequestHandler;
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,26 @@
|
||||||
import ical, { ICalEventStatus } from "ical-generator";
|
import ical, { ICalEventStatus } from 'ical-generator';
|
||||||
import { getWorkOrderMilestones } from "../../helpers/lotOccupancyDB/getWorkOrderMilestones.js";
|
import { getWorkOrderMilestones } from '../../helpers/lotOccupancyDB/getWorkOrderMilestones.js';
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from '../../helpers/functions.config.js';
|
||||||
import { getPrintConfig } from "../../helpers/functions.print.js";
|
import { getPrintConfig } from '../../helpers/functions.print.js';
|
||||||
const calendarCompany = "cityssm.github.io";
|
const calendarCompany = 'cityssm.github.io';
|
||||||
const calendarProduct = configFunctions.getProperty("application.applicationName");
|
const calendarProduct = configFunctions.getProperty('application.applicationName');
|
||||||
const timeStringSplitRegex = /[ :-]/;
|
const timeStringSplitRegex = /[ :-]/;
|
||||||
function escapeHTML(stringToEscape) {
|
function escapeHTML(stringToEscape) {
|
||||||
return stringToEscape.replace(/[^\d A-Za-z]/g, (c) => "&#" + c.codePointAt(0) + ";");
|
return stringToEscape.replace(/[^\d A-Za-z]/g, (c) => `&#${c.codePointAt(0)};`);
|
||||||
}
|
}
|
||||||
function getUrlRoot(request) {
|
function getUrlRoot(request) {
|
||||||
return ("http://" +
|
return ('http://' +
|
||||||
request.hostname +
|
request.hostname +
|
||||||
(configFunctions.getProperty("application.httpPort") === 80
|
(configFunctions.getProperty('application.httpPort') === 80
|
||||||
? ""
|
? ''
|
||||||
: ":" + configFunctions.getProperty("application.httpPort")) +
|
: `:${configFunctions.getProperty('application.httpPort')}`) +
|
||||||
configFunctions.getProperty("reverseProxy.urlPrefix"));
|
configFunctions.getProperty('reverseProxy.urlPrefix'));
|
||||||
}
|
}
|
||||||
function getWorkOrderUrl(request, milestone) {
|
function getWorkOrderUrl(request, milestone) {
|
||||||
return getUrlRoot(request) + "/workOrders/" + milestone.workOrderId;
|
return `${getUrlRoot(request)}/workOrders/${milestone.workOrderId}`;
|
||||||
}
|
}
|
||||||
function buildEventSummary(milestone) {
|
function buildEventSummary(milestone) {
|
||||||
let summary = (milestone.workOrderMilestoneCompletionDate ? "✔ " : "") +
|
let summary = (milestone.workOrderMilestoneCompletionDate ? '✔ ' : '') +
|
||||||
(milestone.workOrderMilestoneTypeId
|
(milestone.workOrderMilestoneTypeId
|
||||||
? milestone.workOrderMilestoneType
|
? milestone.workOrderMilestoneType
|
||||||
: milestone.workOrderMilestoneDescription).trim();
|
: milestone.workOrderMilestoneDescription).trim();
|
||||||
|
|
@ -29,121 +29,126 @@ function buildEventSummary(milestone) {
|
||||||
for (const occupant of lotOccupancy.lotOccupancyOccupants) {
|
for (const occupant of lotOccupancy.lotOccupancyOccupants) {
|
||||||
occupantCount += 1;
|
occupantCount += 1;
|
||||||
if (occupantCount === 1) {
|
if (occupantCount === 1) {
|
||||||
if (summary !== "") {
|
if (summary !== '') {
|
||||||
summary += ": ";
|
summary += ': ';
|
||||||
}
|
}
|
||||||
summary += occupant.occupantName;
|
summary += occupant.occupantName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (occupantCount > 1) {
|
if (occupantCount > 1) {
|
||||||
summary += " plus " + (occupantCount - 1);
|
summary += ' plus ' + (occupantCount - 1);
|
||||||
}
|
}
|
||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
function buildEventDescriptionHTML_occupancies(request, milestone) {
|
function buildEventDescriptionHTML_occupancies(request, milestone) {
|
||||||
let descriptionHTML = "";
|
let descriptionHTML = '';
|
||||||
if (milestone.workOrderLotOccupancies.length > 0) {
|
if (milestone.workOrderLotOccupancies.length > 0) {
|
||||||
const urlRoot = getUrlRoot(request);
|
const urlRoot = getUrlRoot(request);
|
||||||
descriptionHTML = `<h2>
|
descriptionHTML = `<h2>
|
||||||
Related ${escapeHTML(configFunctions.getProperty("aliases.occupancies"))}
|
Related ${escapeHTML(configFunctions.getProperty('aliases.occupancies'))}
|
||||||
</h2>
|
</h2>
|
||||||
<table border="1">
|
<table border="1">
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
<th>${escapeHTML(configFunctions.getProperty("aliases.occupancy"))} Type</th>
|
<th>${escapeHTML(configFunctions.getProperty('aliases.occupancy'))} Type</th>
|
||||||
<th>${escapeHTML(configFunctions.getProperty("aliases.lot"))}</th>
|
<th>${escapeHTML(configFunctions.getProperty('aliases.lot'))}</th>
|
||||||
<th>Start Date</th>
|
<th>Start Date</th>
|
||||||
<th>End Date</th>
|
<th>End Date</th>
|
||||||
<th>${escapeHTML(configFunctions.getProperty("aliases.occupants"))}</th>
|
<th>${escapeHTML(configFunctions.getProperty('aliases.occupants'))}</th>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
<tbody>`;
|
<tbody>`;
|
||||||
for (const occupancy of milestone.workOrderLotOccupancies) {
|
for (const occupancy of milestone.workOrderLotOccupancies) {
|
||||||
descriptionHTML +=
|
descriptionHTML += `<tr>
|
||||||
`<tr>
|
|
||||||
<td>
|
<td>
|
||||||
<a href="${urlRoot}/lotOccupancies/${occupancy.lotOccupancyId}">
|
<a href="${urlRoot}/lotOccupancies/${occupancy.lotOccupancyId}">
|
||||||
${escapeHTML(occupancy.occupancyType)}
|
${escapeHTML(occupancy.occupancyType)}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
${occupancy.lotName ? escapeHTML(occupancy.lotName) : "(Not Set)"}
|
${occupancy.lotName ? escapeHTML(occupancy.lotName) : '(Not Set)'}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
${occupancy.occupancyStartDateString}
|
${occupancy.occupancyStartDateString}
|
||||||
</td>` +
|
</td>
|
||||||
"<td>" +
|
<td>
|
||||||
(occupancy.occupancyEndDate ? occupancy.occupancyEndDateString : "(No End Date)") +
|
${occupancy.occupancyEndDate
|
||||||
"</td>" +
|
? occupancy.occupancyEndDateString
|
||||||
"<td>";
|
: '(No End Date)'}
|
||||||
|
</td>
|
||||||
|
<td>`;
|
||||||
for (const occupant of occupancy.lotOccupancyOccupants) {
|
for (const occupant of occupancy.lotOccupancyOccupants) {
|
||||||
descriptionHTML +=
|
descriptionHTML +=
|
||||||
escapeHTML(occupant.lotOccupantType) +
|
escapeHTML(occupant.lotOccupantType) +
|
||||||
": " +
|
': ' +
|
||||||
escapeHTML(occupant.occupantName) +
|
escapeHTML(occupant.occupantName) +
|
||||||
"<br />";
|
'<br />';
|
||||||
}
|
}
|
||||||
descriptionHTML += "</td></tr>";
|
descriptionHTML += '</td></tr>';
|
||||||
}
|
}
|
||||||
descriptionHTML += "</tbody></table>";
|
descriptionHTML += '</tbody></table>';
|
||||||
}
|
}
|
||||||
return descriptionHTML;
|
return descriptionHTML;
|
||||||
}
|
}
|
||||||
function buildEventDescriptionHTML_lots(request, milestone) {
|
function buildEventDescriptionHTML_lots(request, milestone) {
|
||||||
let descriptionHTML = "";
|
let descriptionHTML = '';
|
||||||
if (milestone.workOrderLots.length > 0) {
|
if (milestone.workOrderLots.length > 0) {
|
||||||
const urlRoot = getUrlRoot(request);
|
const urlRoot = getUrlRoot(request);
|
||||||
descriptionHTML +=
|
descriptionHTML +=
|
||||||
"<h2>Related " +
|
'<h2>Related ' +
|
||||||
escapeHTML(configFunctions.getProperty("aliases.lots")) +
|
escapeHTML(configFunctions.getProperty('aliases.lots')) +
|
||||||
"</h2>" +
|
'</h2>' +
|
||||||
'<table border="1"><thead><tr>' +
|
'<table border="1"><thead><tr>' +
|
||||||
`<th>
|
`<th>
|
||||||
${escapeHTML(configFunctions.getProperty("aliases.lot"))} Type
|
${escapeHTML(configFunctions.getProperty('aliases.lot'))} Type
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
${escapeHTML(configFunctions.getProperty("aliases.map"))}
|
${escapeHTML(configFunctions.getProperty('aliases.map'))}
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
${escapeHTML(configFunctions.getProperty("aliases.lot"))} Type
|
${escapeHTML(configFunctions.getProperty('aliases.lot'))} Type
|
||||||
</th>` +
|
</th>` +
|
||||||
"<th>Status</th>" +
|
'<th>Status</th>' +
|
||||||
"</tr></thead>" +
|
'</tr></thead>' +
|
||||||
"<tbody>";
|
'<tbody>';
|
||||||
for (const lot of milestone.workOrderLots) {
|
for (const lot of milestone.workOrderLots) {
|
||||||
descriptionHTML +=
|
descriptionHTML +=
|
||||||
"<tr>" +
|
'<tr>' +
|
||||||
("<td>" +
|
('<td>' +
|
||||||
'<a href="' +
|
'<a href="' +
|
||||||
urlRoot +
|
urlRoot +
|
||||||
"/lots/" +
|
'/lots/' +
|
||||||
lot.lotId +
|
lot.lotId +
|
||||||
'">' +
|
'">' +
|
||||||
escapeHTML(lot.lotName) +
|
escapeHTML(lot.lotName ?? '') +
|
||||||
"</a></td>") +
|
'</a></td>') +
|
||||||
`<td>${escapeHTML(lot.mapName)}</td>` +
|
`<td>${escapeHTML(lot.mapName ?? '')}</td>` +
|
||||||
`<td>${escapeHTML(lot.lotType)}</td>` +
|
`<td>${escapeHTML(lot.lotType ?? '')}</td>` +
|
||||||
`<td>${escapeHTML(lot.lotStatus)}</td>` +
|
`<td>${escapeHTML(lot.lotStatus ?? '')}</td>` +
|
||||||
"</tr>";
|
'</tr>';
|
||||||
}
|
}
|
||||||
descriptionHTML += "</tbody></table>";
|
descriptionHTML += '</tbody></table>';
|
||||||
}
|
}
|
||||||
return descriptionHTML;
|
return descriptionHTML;
|
||||||
}
|
}
|
||||||
function buildEventDescriptionHTML_prints(request, milestone) {
|
function buildEventDescriptionHTML_prints(request, milestone) {
|
||||||
let descriptionHTML = "";
|
let descriptionHTML = '';
|
||||||
const prints = configFunctions.getProperty("settings.workOrders.prints");
|
const prints = configFunctions.getProperty('settings.workOrders.prints');
|
||||||
if (prints.length > 0) {
|
if (prints.length > 0) {
|
||||||
const urlRoot = getUrlRoot(request);
|
const urlRoot = getUrlRoot(request);
|
||||||
descriptionHTML += "<h2>Prints</h2>";
|
descriptionHTML += '<h2>Prints</h2>';
|
||||||
for (const printName of prints) {
|
for (const printName of prints) {
|
||||||
const printConfig = getPrintConfig(printName);
|
const printConfig = getPrintConfig(printName);
|
||||||
if (printConfig) {
|
if (printConfig) {
|
||||||
descriptionHTML +=
|
descriptionHTML +=
|
||||||
"<p>" +
|
'<p>' +
|
||||||
escapeHTML(printConfig.title) +
|
escapeHTML(printConfig.title) +
|
||||||
"<br />" +
|
'<br />' +
|
||||||
(urlRoot + "/print/" + printName + "/?workOrderId=" + milestone.workOrderId) +
|
(urlRoot +
|
||||||
"</p>";
|
'/print/' +
|
||||||
|
printName +
|
||||||
|
'/?workOrderId=' +
|
||||||
|
milestone.workOrderId) +
|
||||||
|
'</p>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -152,9 +157,9 @@ function buildEventDescriptionHTML_prints(request, milestone) {
|
||||||
function buildEventDescriptionHTML(request, milestone) {
|
function buildEventDescriptionHTML(request, milestone) {
|
||||||
const workOrderUrl = getWorkOrderUrl(request, milestone);
|
const workOrderUrl = getWorkOrderUrl(request, milestone);
|
||||||
let descriptionHTML = `<h1>Milestone Description</h1>
|
let descriptionHTML = `<h1>Milestone Description</h1>
|
||||||
<p>${escapeHTML(milestone.workOrderMilestoneDescription)}</p>
|
<p>${escapeHTML(milestone.workOrderMilestoneDescription ?? '')}</p>
|
||||||
<h2>Work Order #${milestone.workOrderNumber}</h2>
|
<h2>Work Order #${milestone.workOrderNumber ?? ''}</h2>
|
||||||
<p>${escapeHTML(milestone.workOrderDescription)}</p>
|
<p>${escapeHTML(milestone.workOrderDescription ?? '')}</p>
|
||||||
<p>${workOrderUrl}</p>`;
|
<p>${workOrderUrl}</p>`;
|
||||||
descriptionHTML += buildEventDescriptionHTML_occupancies(request, milestone);
|
descriptionHTML += buildEventDescriptionHTML_occupancies(request, milestone);
|
||||||
descriptionHTML += buildEventDescriptionHTML_lots(request, milestone);
|
descriptionHTML += buildEventDescriptionHTML_lots(request, milestone);
|
||||||
|
|
@ -167,7 +172,7 @@ function buildEventCategoryList(milestone) {
|
||||||
categories.push(milestone.workOrderMilestoneType, milestone.workOrderType);
|
categories.push(milestone.workOrderMilestoneType, milestone.workOrderType);
|
||||||
}
|
}
|
||||||
if (milestone.workOrderMilestoneCompletionDate) {
|
if (milestone.workOrderMilestoneCompletionDate) {
|
||||||
categories.push("Completed");
|
categories.push('Completed');
|
||||||
}
|
}
|
||||||
return categories;
|
return categories;
|
||||||
}
|
}
|
||||||
|
|
@ -175,10 +180,10 @@ function buildEventLocation(milestone) {
|
||||||
const lotNames = [];
|
const lotNames = [];
|
||||||
if (milestone.workOrderLots.length > 0) {
|
if (milestone.workOrderLots.length > 0) {
|
||||||
for (const lot of milestone.workOrderLots) {
|
for (const lot of milestone.workOrderLots) {
|
||||||
lotNames.push(lot.mapName + ": " + lot.lotName);
|
lotNames.push(`${lot.mapName ?? ''}: ${lot.lotName ?? ''}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lotNames.join(", ");
|
return lotNames.join(', ');
|
||||||
}
|
}
|
||||||
export const handler = (request, response) => {
|
export const handler = (request, response) => {
|
||||||
const urlRoot = getUrlRoot(request);
|
const urlRoot = getUrlRoot(request);
|
||||||
|
|
@ -190,19 +195,19 @@ export const handler = (request, response) => {
|
||||||
workOrderMilestoneFilters.workOrderId = request.query.workOrderId;
|
workOrderMilestoneFilters.workOrderId = request.query.workOrderId;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
workOrderMilestoneFilters.workOrderMilestoneDateFilter = "recent";
|
workOrderMilestoneFilters.workOrderMilestoneDateFilter = 'recent';
|
||||||
}
|
}
|
||||||
const workOrderMilestones = getWorkOrderMilestones(workOrderMilestoneFilters, {
|
const workOrderMilestones = getWorkOrderMilestones(workOrderMilestoneFilters, {
|
||||||
includeWorkOrders: true,
|
includeWorkOrders: true,
|
||||||
orderBy: "date"
|
orderBy: 'date'
|
||||||
});
|
});
|
||||||
const calendar = ical({
|
const calendar = ical({
|
||||||
name: "Work Order Milestone Calendar",
|
name: 'Work Order Milestone Calendar',
|
||||||
url: urlRoot + "/workOrders"
|
url: urlRoot + '/workOrders'
|
||||||
});
|
});
|
||||||
if (request.query.workOrderId && workOrderMilestones.length > 0) {
|
if (request.query.workOrderId && workOrderMilestones.length > 0) {
|
||||||
calendar.name(`Work Order #${workOrderMilestones[0].workOrderNumber}`);
|
calendar.name(`Work Order #${workOrderMilestones[0].workOrderNumber}`);
|
||||||
calendar.url(urlRoot + "/workOrders/" + workOrderMilestones[0].workOrderId);
|
calendar.url(urlRoot + '/workOrders/' + workOrderMilestones[0].workOrderId);
|
||||||
}
|
}
|
||||||
calendar.prodId({
|
calendar.prodId({
|
||||||
company: calendarCompany,
|
company: calendarCompany,
|
||||||
|
|
@ -210,7 +215,7 @@ export const handler = (request, response) => {
|
||||||
});
|
});
|
||||||
for (const milestone of workOrderMilestones) {
|
for (const milestone of workOrderMilestones) {
|
||||||
const milestoneTimePieces = (milestone.workOrderMilestoneDateString +
|
const milestoneTimePieces = (milestone.workOrderMilestoneDateString +
|
||||||
" " +
|
' ' +
|
||||||
milestone.workOrderMilestoneTimeString).split(timeStringSplitRegex);
|
milestone.workOrderMilestoneTimeString).split(timeStringSplitRegex);
|
||||||
const milestoneDate = new Date(Number.parseInt(milestoneTimePieces[0], 10), Number.parseInt(milestoneTimePieces[1], 10) - 1, Number.parseInt(milestoneTimePieces[2], 10), Number.parseInt(milestoneTimePieces[3], 10), Number.parseInt(milestoneTimePieces[4], 10));
|
const milestoneDate = new Date(Number.parseInt(milestoneTimePieces[0], 10), Number.parseInt(milestoneTimePieces[1], 10) - 1, Number.parseInt(milestoneTimePieces[2], 10), Number.parseInt(milestoneTimePieces[3], 10), Number.parseInt(milestoneTimePieces[4], 10));
|
||||||
const milestoneEndDate = new Date(milestoneDate.getTime());
|
const milestoneEndDate = new Date(milestoneDate.getTime());
|
||||||
|
|
@ -253,13 +258,13 @@ export const handler = (request, response) => {
|
||||||
if (organizerSet) {
|
if (organizerSet) {
|
||||||
calendarEvent.createAttendee({
|
calendarEvent.createAttendee({
|
||||||
name: occupant.occupantName,
|
name: occupant.occupantName,
|
||||||
email: configFunctions.getProperty("settings.workOrders.calendarEmailAddress")
|
email: configFunctions.getProperty('settings.workOrders.calendarEmailAddress')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
calendarEvent.organizer({
|
calendarEvent.organizer({
|
||||||
name: occupant.occupantName,
|
name: occupant.occupantName,
|
||||||
email: configFunctions.getProperty("settings.workOrders.calendarEmailAddress")
|
email: configFunctions.getProperty('settings.workOrders.calendarEmailAddress')
|
||||||
});
|
});
|
||||||
organizerSet = true;
|
organizerSet = true;
|
||||||
}
|
}
|
||||||
|
|
@ -269,7 +274,7 @@ export const handler = (request, response) => {
|
||||||
else {
|
else {
|
||||||
calendarEvent.organizer({
|
calendarEvent.organizer({
|
||||||
name: milestone.recordCreate_userName,
|
name: milestone.recordCreate_userName,
|
||||||
email: configFunctions.getProperty("settings.workOrders.calendarEmailAddress")
|
email: configFunctions.getProperty('settings.workOrders.calendarEmailAddress')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,258 +1,277 @@
|
||||||
/* eslint-disable unicorn/filename-case */
|
/* eslint-disable unicorn/filename-case */
|
||||||
|
|
||||||
import ical, { ICalEventData, ICalEventStatus } from "ical-generator";
|
import ical, { ICalEventData, ICalEventStatus } from 'ical-generator'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getWorkOrderMilestones,
|
getWorkOrderMilestones,
|
||||||
WorkOrderMilestoneFilters
|
WorkOrderMilestoneFilters
|
||||||
} from "../../helpers/lotOccupancyDB/getWorkOrderMilestones.js";
|
} from '../../helpers/lotOccupancyDB/getWorkOrderMilestones.js'
|
||||||
|
|
||||||
import type { RequestHandler, Request } from "express";
|
import type { RequestHandler, Request } from 'express'
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from '../../helpers/functions.config.js'
|
||||||
import { getPrintConfig } from "../../helpers/functions.print.js";
|
import { getPrintConfig } from '../../helpers/functions.print.js'
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes'
|
||||||
|
|
||||||
const calendarCompany = "cityssm.github.io";
|
const calendarCompany = 'cityssm.github.io'
|
||||||
const calendarProduct = configFunctions.getProperty("application.applicationName");
|
const calendarProduct = configFunctions.getProperty(
|
||||||
|
'application.applicationName'
|
||||||
|
)
|
||||||
|
|
||||||
const timeStringSplitRegex = /[ :-]/;
|
const timeStringSplitRegex = /[ :-]/
|
||||||
|
|
||||||
function escapeHTML(stringToEscape: string) {
|
function escapeHTML(stringToEscape: string): string {
|
||||||
return stringToEscape.replace(/[^\d A-Za-z]/g, (c) => "&#" + c.codePointAt(0) + ";");
|
return stringToEscape.replace(
|
||||||
|
/[^\d A-Za-z]/g,
|
||||||
|
(c) => `&#${c.codePointAt(0)!};`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUrlRoot(request: Request): string {
|
function getUrlRoot(request: Request): string {
|
||||||
return (
|
return (
|
||||||
"http://" +
|
'http://' +
|
||||||
request.hostname +
|
request.hostname +
|
||||||
(configFunctions.getProperty("application.httpPort") === 80
|
(configFunctions.getProperty('application.httpPort') === 80
|
||||||
? ""
|
? ''
|
||||||
: ":" + configFunctions.getProperty("application.httpPort")) +
|
: `:${configFunctions.getProperty('application.httpPort')}`) +
|
||||||
configFunctions.getProperty("reverseProxy.urlPrefix")
|
configFunctions.getProperty('reverseProxy.urlPrefix')
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWorkOrderUrl(request: Request, milestone: recordTypes.WorkOrderMilestone) {
|
function getWorkOrderUrl(
|
||||||
return getUrlRoot(request) + "/workOrders/" + milestone.workOrderId;
|
request: Request,
|
||||||
|
milestone: recordTypes.WorkOrderMilestone
|
||||||
|
): string {
|
||||||
|
return `${getUrlRoot(request)}/workOrders/${milestone.workOrderId!}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildEventSummary(milestone: recordTypes.WorkOrderMilestone): string {
|
function buildEventSummary(milestone: recordTypes.WorkOrderMilestone): string {
|
||||||
let summary =
|
let summary =
|
||||||
(milestone.workOrderMilestoneCompletionDate ? "✔ " : "") +
|
(milestone.workOrderMilestoneCompletionDate ? '✔ ' : '') +
|
||||||
(milestone.workOrderMilestoneTypeId
|
(milestone.workOrderMilestoneTypeId
|
||||||
? milestone.workOrderMilestoneType
|
? milestone.workOrderMilestoneType
|
||||||
: milestone.workOrderMilestoneDescription
|
: milestone.workOrderMilestoneDescription
|
||||||
).trim();
|
).trim()
|
||||||
|
|
||||||
let occupantCount = 0;
|
let occupantCount = 0
|
||||||
|
|
||||||
for (const lotOccupancy of milestone.workOrderLotOccupancies) {
|
for (const lotOccupancy of milestone.workOrderLotOccupancies!) {
|
||||||
for (const occupant of lotOccupancy.lotOccupancyOccupants) {
|
for (const occupant of lotOccupancy.lotOccupancyOccupants!) {
|
||||||
occupantCount += 1;
|
occupantCount += 1
|
||||||
|
|
||||||
if (occupantCount === 1) {
|
if (occupantCount === 1) {
|
||||||
if (summary !== "") {
|
if (summary !== '') {
|
||||||
summary += ": ";
|
summary += ': '
|
||||||
}
|
}
|
||||||
|
|
||||||
summary += occupant.occupantName;
|
summary += occupant.occupantName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (occupantCount > 1) {
|
if (occupantCount > 1) {
|
||||||
summary += " plus " + (occupantCount - 1);
|
summary += ' plus ' + (occupantCount - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
return summary;
|
return summary
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildEventDescriptionHTML_occupancies(
|
function buildEventDescriptionHTML_occupancies(
|
||||||
request: Request,
|
request: Request,
|
||||||
milestone: recordTypes.WorkOrderMilestone
|
milestone: recordTypes.WorkOrderMilestone
|
||||||
): string {
|
): string {
|
||||||
let descriptionHTML = "";
|
let descriptionHTML = ''
|
||||||
|
|
||||||
if (milestone.workOrderLotOccupancies.length > 0) {
|
if (milestone.workOrderLotOccupancies!.length > 0) {
|
||||||
const urlRoot = getUrlRoot(request);
|
const urlRoot = getUrlRoot(request)
|
||||||
|
|
||||||
descriptionHTML = `<h2>
|
descriptionHTML = `<h2>
|
||||||
Related ${escapeHTML(configFunctions.getProperty("aliases.occupancies"))}
|
Related ${escapeHTML(configFunctions.getProperty('aliases.occupancies'))}
|
||||||
</h2>
|
</h2>
|
||||||
<table border="1">
|
<table border="1">
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
<th>${escapeHTML(configFunctions.getProperty("aliases.occupancy"))} Type</th>
|
<th>${escapeHTML(
|
||||||
<th>${escapeHTML(configFunctions.getProperty("aliases.lot"))}</th>
|
configFunctions.getProperty('aliases.occupancy')
|
||||||
|
)} Type</th>
|
||||||
|
<th>${escapeHTML(configFunctions.getProperty('aliases.lot'))}</th>
|
||||||
<th>Start Date</th>
|
<th>Start Date</th>
|
||||||
<th>End Date</th>
|
<th>End Date</th>
|
||||||
<th>${escapeHTML(configFunctions.getProperty("aliases.occupants"))}</th>
|
<th>${escapeHTML(configFunctions.getProperty('aliases.occupants'))}</th>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
<tbody>`;
|
<tbody>`
|
||||||
|
|
||||||
for (const occupancy of milestone.workOrderLotOccupancies) {
|
for (const occupancy of milestone.workOrderLotOccupancies!) {
|
||||||
descriptionHTML +=
|
descriptionHTML += `<tr>
|
||||||
`<tr>
|
|
||||||
<td>
|
<td>
|
||||||
<a href="${urlRoot}/lotOccupancies/${occupancy.lotOccupancyId}">
|
<a href="${urlRoot}/lotOccupancies/${occupancy.lotOccupancyId!}">
|
||||||
${escapeHTML(occupancy.occupancyType)}
|
${escapeHTML(occupancy.occupancyType!)}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
${occupancy.lotName ? escapeHTML(occupancy.lotName) : "(Not Set)"}
|
${occupancy.lotName ? escapeHTML(occupancy.lotName) : '(Not Set)'}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
${occupancy.occupancyStartDateString}
|
${occupancy.occupancyStartDateString!}
|
||||||
</td>` +
|
</td>
|
||||||
"<td>" +
|
<td>
|
||||||
(occupancy.occupancyEndDate ? occupancy.occupancyEndDateString : "(No End Date)") +
|
${
|
||||||
"</td>" +
|
occupancy.occupancyEndDate
|
||||||
"<td>";
|
? occupancy.occupancyEndDateString
|
||||||
|
: '(No End Date)'
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
<td>`
|
||||||
|
|
||||||
for (const occupant of occupancy.lotOccupancyOccupants) {
|
for (const occupant of occupancy.lotOccupancyOccupants!) {
|
||||||
descriptionHTML +=
|
descriptionHTML +=
|
||||||
escapeHTML(occupant.lotOccupantType) +
|
escapeHTML(occupant.lotOccupantType!) +
|
||||||
": " +
|
': ' +
|
||||||
escapeHTML(occupant.occupantName) +
|
escapeHTML(occupant.occupantName!) +
|
||||||
"<br />";
|
'<br />'
|
||||||
}
|
}
|
||||||
|
|
||||||
descriptionHTML += "</td></tr>";
|
descriptionHTML += '</td></tr>'
|
||||||
}
|
}
|
||||||
|
|
||||||
descriptionHTML += "</tbody></table>";
|
descriptionHTML += '</tbody></table>'
|
||||||
}
|
}
|
||||||
|
|
||||||
return descriptionHTML;
|
return descriptionHTML
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildEventDescriptionHTML_lots(
|
function buildEventDescriptionHTML_lots(
|
||||||
request: Request,
|
request: Request,
|
||||||
milestone: recordTypes.WorkOrderMilestone
|
milestone: recordTypes.WorkOrderMilestone
|
||||||
): string {
|
): string {
|
||||||
let descriptionHTML = "";
|
let descriptionHTML = ''
|
||||||
|
|
||||||
if (milestone.workOrderLots.length > 0) {
|
if (milestone.workOrderLots.length > 0) {
|
||||||
const urlRoot = getUrlRoot(request);
|
const urlRoot = getUrlRoot(request)
|
||||||
|
|
||||||
descriptionHTML +=
|
descriptionHTML +=
|
||||||
"<h2>Related " +
|
'<h2>Related ' +
|
||||||
escapeHTML(configFunctions.getProperty("aliases.lots")) +
|
escapeHTML(configFunctions.getProperty('aliases.lots')) +
|
||||||
"</h2>" +
|
'</h2>' +
|
||||||
'<table border="1"><thead><tr>' +
|
'<table border="1"><thead><tr>' +
|
||||||
`<th>
|
`<th>
|
||||||
${escapeHTML(configFunctions.getProperty("aliases.lot"))} Type
|
${escapeHTML(configFunctions.getProperty('aliases.lot'))} Type
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
${escapeHTML(configFunctions.getProperty("aliases.map"))}
|
${escapeHTML(configFunctions.getProperty('aliases.map'))}
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
${escapeHTML(configFunctions.getProperty("aliases.lot"))} Type
|
${escapeHTML(configFunctions.getProperty('aliases.lot'))} Type
|
||||||
</th>` +
|
</th>` +
|
||||||
"<th>Status</th>" +
|
'<th>Status</th>' +
|
||||||
"</tr></thead>" +
|
'</tr></thead>' +
|
||||||
"<tbody>";
|
'<tbody>'
|
||||||
|
|
||||||
for (const lot of milestone.workOrderLots) {
|
for (const lot of milestone.workOrderLots!) {
|
||||||
descriptionHTML +=
|
descriptionHTML +=
|
||||||
"<tr>" +
|
'<tr>' +
|
||||||
("<td>" +
|
('<td>' +
|
||||||
'<a href="' +
|
'<a href="' +
|
||||||
urlRoot +
|
urlRoot +
|
||||||
"/lots/" +
|
'/lots/' +
|
||||||
lot.lotId +
|
lot.lotId +
|
||||||
'">' +
|
'">' +
|
||||||
escapeHTML(lot.lotName) +
|
escapeHTML(lot.lotName ?? '') +
|
||||||
"</a></td>") +
|
'</a></td>') +
|
||||||
`<td>${escapeHTML(lot.mapName)}</td>` +
|
`<td>${escapeHTML(lot.mapName ?? '')}</td>` +
|
||||||
`<td>${escapeHTML(lot.lotType)}</td>` +
|
`<td>${escapeHTML(lot.lotType ?? '')}</td>` +
|
||||||
`<td>${escapeHTML(lot.lotStatus)}</td>` +
|
`<td>${escapeHTML(lot.lotStatus ?? '')}</td>` +
|
||||||
"</tr>";
|
'</tr>'
|
||||||
}
|
}
|
||||||
|
|
||||||
descriptionHTML += "</tbody></table>";
|
descriptionHTML += '</tbody></table>'
|
||||||
}
|
}
|
||||||
|
|
||||||
return descriptionHTML;
|
return descriptionHTML
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildEventDescriptionHTML_prints(
|
function buildEventDescriptionHTML_prints(
|
||||||
request: Request,
|
request: Request,
|
||||||
milestone: recordTypes.WorkOrderMilestone
|
milestone: recordTypes.WorkOrderMilestone
|
||||||
): string {
|
): string {
|
||||||
let descriptionHTML = "";
|
let descriptionHTML = ''
|
||||||
|
|
||||||
const prints = configFunctions.getProperty("settings.workOrders.prints");
|
const prints = configFunctions.getProperty('settings.workOrders.prints')
|
||||||
|
|
||||||
if (prints.length > 0) {
|
if (prints.length > 0) {
|
||||||
const urlRoot = getUrlRoot(request);
|
const urlRoot = getUrlRoot(request)
|
||||||
|
|
||||||
descriptionHTML += "<h2>Prints</h2>";
|
descriptionHTML += '<h2>Prints</h2>'
|
||||||
|
|
||||||
for (const printName of prints) {
|
for (const printName of prints) {
|
||||||
const printConfig = getPrintConfig(printName);
|
const printConfig = getPrintConfig(printName)
|
||||||
|
|
||||||
if (printConfig) {
|
if (printConfig) {
|
||||||
descriptionHTML +=
|
descriptionHTML +=
|
||||||
"<p>" +
|
'<p>' +
|
||||||
escapeHTML(printConfig.title) +
|
escapeHTML(printConfig.title) +
|
||||||
"<br />" +
|
'<br />' +
|
||||||
(urlRoot + "/print/" + printName + "/?workOrderId=" + milestone.workOrderId) +
|
(urlRoot +
|
||||||
"</p>";
|
'/print/' +
|
||||||
|
printName +
|
||||||
|
'/?workOrderId=' +
|
||||||
|
milestone.workOrderId) +
|
||||||
|
'</p>'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return descriptionHTML;
|
return descriptionHTML
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildEventDescriptionHTML(
|
function buildEventDescriptionHTML(
|
||||||
request: Request,
|
request: Request,
|
||||||
milestone: recordTypes.WorkOrderMilestone
|
milestone: recordTypes.WorkOrderMilestone
|
||||||
): string {
|
): string {
|
||||||
const workOrderUrl = getWorkOrderUrl(request, milestone);
|
const workOrderUrl = getWorkOrderUrl(request, milestone)
|
||||||
|
|
||||||
let descriptionHTML = `<h1>Milestone Description</h1>
|
let descriptionHTML = `<h1>Milestone Description</h1>
|
||||||
<p>${escapeHTML(milestone.workOrderMilestoneDescription)}</p>
|
<p>${escapeHTML(milestone.workOrderMilestoneDescription ?? '')}</p>
|
||||||
<h2>Work Order #${milestone.workOrderNumber}</h2>
|
<h2>Work Order #${milestone.workOrderNumber ?? ''}</h2>
|
||||||
<p>${escapeHTML(milestone.workOrderDescription)}</p>
|
<p>${escapeHTML(milestone.workOrderDescription ?? '')}</p>
|
||||||
<p>${workOrderUrl}</p>`;
|
<p>${workOrderUrl}</p>`
|
||||||
|
|
||||||
descriptionHTML += buildEventDescriptionHTML_occupancies(request, milestone);
|
descriptionHTML += buildEventDescriptionHTML_occupancies(request, milestone)
|
||||||
descriptionHTML += buildEventDescriptionHTML_lots(request, milestone);
|
descriptionHTML += buildEventDescriptionHTML_lots(request, milestone)
|
||||||
descriptionHTML += buildEventDescriptionHTML_prints(request, milestone);
|
descriptionHTML += buildEventDescriptionHTML_prints(request, milestone)
|
||||||
|
|
||||||
return descriptionHTML;
|
return descriptionHTML
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildEventCategoryList(milestone: recordTypes.WorkOrderMilestone): string[] {
|
function buildEventCategoryList(
|
||||||
const categories: string[] = [];
|
milestone: recordTypes.WorkOrderMilestone
|
||||||
|
): string[] {
|
||||||
|
const categories: string[] = []
|
||||||
|
|
||||||
if (milestone.workOrderMilestoneTypeId) {
|
if (milestone.workOrderMilestoneTypeId) {
|
||||||
categories.push(milestone.workOrderMilestoneType, milestone.workOrderType);
|
categories.push(milestone.workOrderMilestoneType, milestone.workOrderType)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (milestone.workOrderMilestoneCompletionDate) {
|
if (milestone.workOrderMilestoneCompletionDate) {
|
||||||
categories.push("Completed");
|
categories.push('Completed')
|
||||||
}
|
}
|
||||||
|
|
||||||
return categories;
|
return categories
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildEventLocation(milestone: recordTypes.WorkOrderMilestone): string {
|
function buildEventLocation(milestone: recordTypes.WorkOrderMilestone): string {
|
||||||
const lotNames = [];
|
const lotNames: string[] = []
|
||||||
|
|
||||||
if (milestone.workOrderLots.length > 0) {
|
if (milestone.workOrderLots!.length > 0) {
|
||||||
for (const lot of milestone.workOrderLots) {
|
for (const lot of milestone.workOrderLots!) {
|
||||||
lotNames.push(lot.mapName + ": " + lot.lotName);
|
lotNames.push(`${lot.mapName ?? ''}: ${lot.lotName ?? ''}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lotNames.join(", ");
|
return lotNames.join(', ')
|
||||||
}
|
}
|
||||||
|
|
||||||
export const handler: RequestHandler = (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
const urlRoot = getUrlRoot(request);
|
const urlRoot = getUrlRoot(request)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get work order milestones
|
* Get work order milestones
|
||||||
|
|
@ -261,37 +280,40 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
const workOrderMilestoneFilters: WorkOrderMilestoneFilters = {
|
const workOrderMilestoneFilters: WorkOrderMilestoneFilters = {
|
||||||
workOrderTypeIds: request.query.workOrderTypeIds as string,
|
workOrderTypeIds: request.query.workOrderTypeIds as string,
|
||||||
workOrderMilestoneTypeIds: request.query.workOrderMilestoneTypeIds as string
|
workOrderMilestoneTypeIds: request.query.workOrderMilestoneTypeIds as string
|
||||||
};
|
|
||||||
|
|
||||||
if (request.query.workOrderId) {
|
|
||||||
workOrderMilestoneFilters.workOrderId = request.query.workOrderId as string;
|
|
||||||
} else {
|
|
||||||
workOrderMilestoneFilters.workOrderMilestoneDateFilter = "recent";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const workOrderMilestones = getWorkOrderMilestones(workOrderMilestoneFilters, {
|
if (request.query.workOrderId) {
|
||||||
|
workOrderMilestoneFilters.workOrderId = request.query.workOrderId as string
|
||||||
|
} else {
|
||||||
|
workOrderMilestoneFilters.workOrderMilestoneDateFilter = 'recent'
|
||||||
|
}
|
||||||
|
|
||||||
|
const workOrderMilestones = getWorkOrderMilestones(
|
||||||
|
workOrderMilestoneFilters,
|
||||||
|
{
|
||||||
includeWorkOrders: true,
|
includeWorkOrders: true,
|
||||||
orderBy: "date"
|
orderBy: 'date'
|
||||||
});
|
}
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create calendar object
|
* Create calendar object
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const calendar = ical({
|
const calendar = ical({
|
||||||
name: "Work Order Milestone Calendar",
|
name: 'Work Order Milestone Calendar',
|
||||||
url: urlRoot + "/workOrders"
|
url: urlRoot + '/workOrders'
|
||||||
});
|
})
|
||||||
|
|
||||||
if (request.query.workOrderId && workOrderMilestones.length > 0) {
|
if (request.query.workOrderId && workOrderMilestones.length > 0) {
|
||||||
calendar.name(`Work Order #${workOrderMilestones[0].workOrderNumber}`);
|
calendar.name(`Work Order #${workOrderMilestones[0].workOrderNumber}`)
|
||||||
calendar.url(urlRoot + "/workOrders/" + workOrderMilestones[0].workOrderId);
|
calendar.url(urlRoot + '/workOrders/' + workOrderMilestones[0].workOrderId)
|
||||||
}
|
}
|
||||||
|
|
||||||
calendar.prodId({
|
calendar.prodId({
|
||||||
company: calendarCompany,
|
company: calendarCompany,
|
||||||
product: calendarProduct
|
product: calendarProduct
|
||||||
});
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Loop through milestones
|
* Loop through milestones
|
||||||
|
|
@ -300,9 +322,9 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
for (const milestone of workOrderMilestones) {
|
for (const milestone of workOrderMilestones) {
|
||||||
const milestoneTimePieces = (
|
const milestoneTimePieces = (
|
||||||
milestone.workOrderMilestoneDateString +
|
milestone.workOrderMilestoneDateString +
|
||||||
" " +
|
' ' +
|
||||||
milestone.workOrderMilestoneTimeString
|
milestone.workOrderMilestoneTimeString
|
||||||
).split(timeStringSplitRegex);
|
).split(timeStringSplitRegex)
|
||||||
|
|
||||||
const milestoneDate = new Date(
|
const milestoneDate = new Date(
|
||||||
Number.parseInt(milestoneTimePieces[0], 10),
|
Number.parseInt(milestoneTimePieces[0], 10),
|
||||||
|
|
@ -310,18 +332,18 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
Number.parseInt(milestoneTimePieces[2], 10),
|
Number.parseInt(milestoneTimePieces[2], 10),
|
||||||
Number.parseInt(milestoneTimePieces[3], 10),
|
Number.parseInt(milestoneTimePieces[3], 10),
|
||||||
Number.parseInt(milestoneTimePieces[4], 10)
|
Number.parseInt(milestoneTimePieces[4], 10)
|
||||||
);
|
)
|
||||||
|
|
||||||
const milestoneEndDate = new Date(milestoneDate.getTime());
|
const milestoneEndDate = new Date(milestoneDate.getTime())
|
||||||
milestoneEndDate.setHours(milestoneEndDate.getHours() + 1);
|
milestoneEndDate.setHours(milestoneEndDate.getHours() + 1)
|
||||||
|
|
||||||
// Build summary (title in Outlook)
|
// Build summary (title in Outlook)
|
||||||
|
|
||||||
const summary = buildEventSummary(milestone);
|
const summary = buildEventSummary(milestone)
|
||||||
|
|
||||||
// Build URL
|
// Build URL
|
||||||
|
|
||||||
const workOrderUrl = getWorkOrderUrl(request, milestone);
|
const workOrderUrl = getWorkOrderUrl(request, milestone)
|
||||||
|
|
||||||
// Create event
|
// Create event
|
||||||
|
|
||||||
|
|
@ -338,76 +360,78 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
allDay: !milestone.workOrderMilestoneTime,
|
allDay: !milestone.workOrderMilestoneTime,
|
||||||
summary,
|
summary,
|
||||||
url: workOrderUrl
|
url: workOrderUrl
|
||||||
};
|
|
||||||
|
|
||||||
if (!eventData.allDay) {
|
|
||||||
eventData.end = milestoneEndDate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const calendarEvent = calendar.createEvent(eventData);
|
if (!eventData.allDay) {
|
||||||
|
eventData.end = milestoneEndDate
|
||||||
|
}
|
||||||
|
|
||||||
|
const calendarEvent = calendar.createEvent(eventData)
|
||||||
|
|
||||||
// Build description
|
// Build description
|
||||||
|
|
||||||
const descriptionHTML = buildEventDescriptionHTML(request, milestone);
|
const descriptionHTML = buildEventDescriptionHTML(request, milestone)
|
||||||
|
|
||||||
calendarEvent.description({
|
calendarEvent.description({
|
||||||
plain: workOrderUrl,
|
plain: workOrderUrl,
|
||||||
html: descriptionHTML
|
html: descriptionHTML
|
||||||
});
|
})
|
||||||
|
|
||||||
// Set status
|
// Set status
|
||||||
|
|
||||||
if (milestone.workOrderMilestoneCompletionDate) {
|
if (milestone.workOrderMilestoneCompletionDate) {
|
||||||
calendarEvent.status(ICalEventStatus.CONFIRMED);
|
calendarEvent.status(ICalEventStatus.CONFIRMED)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add categories
|
// Add categories
|
||||||
|
|
||||||
const categories = buildEventCategoryList(milestone);
|
const categories = buildEventCategoryList(milestone)
|
||||||
for (const category of categories) {
|
for (const category of categories) {
|
||||||
calendarEvent.createCategory({
|
calendarEvent.createCategory({
|
||||||
name: category
|
name: category
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set location
|
// Set location
|
||||||
|
|
||||||
const location = buildEventLocation(milestone);
|
const location = buildEventLocation(milestone)
|
||||||
calendarEvent.location(location);
|
calendarEvent.location(location)
|
||||||
|
|
||||||
// Set organizer / attendees
|
// Set organizer / attendees
|
||||||
|
|
||||||
if (milestone.workOrderLotOccupancies.length > 0) {
|
if (milestone.workOrderLotOccupancies.length > 0) {
|
||||||
let organizerSet = false;
|
let organizerSet = false
|
||||||
for (const lotOccupancy of milestone.workOrderLotOccupancies) {
|
for (const lotOccupancy of milestone.workOrderLotOccupancies) {
|
||||||
for (const occupant of lotOccupancy.lotOccupancyOccupants) {
|
for (const occupant of lotOccupancy.lotOccupancyOccupants) {
|
||||||
if (organizerSet) {
|
if (organizerSet) {
|
||||||
calendarEvent.createAttendee({
|
calendarEvent.createAttendee({
|
||||||
name: occupant.occupantName,
|
name: occupant.occupantName,
|
||||||
email: configFunctions.getProperty(
|
email: configFunctions.getProperty(
|
||||||
"settings.workOrders.calendarEmailAddress"
|
'settings.workOrders.calendarEmailAddress'
|
||||||
)
|
)
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
calendarEvent.organizer({
|
calendarEvent.organizer({
|
||||||
name: occupant.occupantName,
|
name: occupant.occupantName,
|
||||||
email: configFunctions.getProperty(
|
email: configFunctions.getProperty(
|
||||||
"settings.workOrders.calendarEmailAddress"
|
'settings.workOrders.calendarEmailAddress'
|
||||||
)
|
)
|
||||||
});
|
})
|
||||||
organizerSet = true;
|
organizerSet = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
calendarEvent.organizer({
|
calendarEvent.organizer({
|
||||||
name: milestone.recordCreate_userName,
|
name: milestone.recordCreate_userName,
|
||||||
email: configFunctions.getProperty("settings.workOrders.calendarEmailAddress")
|
email: configFunctions.getProperty(
|
||||||
});
|
'settings.workOrders.calendarEmailAddress'
|
||||||
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
calendar.serve(response);
|
calendar.serve(response)
|
||||||
};
|
}
|
||||||
|
|
||||||
export default handler;
|
export default handler
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express';
|
||||||
export declare const handler: RequestHandler;
|
export declare const handler: RequestHandler;
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import { getLotOccupantTypes, getLotStatuses, getLotTypes, getOccupancyTypePrintsById, getOccupancyTypes, getWorkOrderTypes } from "../../helpers/functions.cache.js";
|
import { getLotOccupantTypes, getLotStatuses, getLotTypes, getOccupancyTypePrintsById, getOccupancyTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js';
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from '../../helpers/functions.config.js';
|
||||||
import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js";
|
import { getLotOccupancy } from '../../helpers/lotOccupancyDB/getLotOccupancy.js';
|
||||||
import { getMaps } from "../../helpers/lotOccupancyDB/getMaps.js";
|
import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js';
|
||||||
export const handler = (request, response) => {
|
export const handler = (request, response) => {
|
||||||
const lotOccupancy = getLotOccupancy(request.params.lotOccupancyId);
|
const lotOccupancy = getLotOccupancy(request.params.lotOccupancyId);
|
||||||
if (!lotOccupancy) {
|
if (!lotOccupancy) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
response.redirect(`${configFunctions.getProperty('reverseProxy.urlPrefix')}/lotOccupancies/?error=lotOccupancyIdNotFound`);
|
||||||
"/lotOccupancies/?error=lotOccupancyIdNotFound");
|
return;
|
||||||
}
|
}
|
||||||
const occupancyTypePrints = getOccupancyTypePrintsById(lotOccupancy.occupancyTypeId);
|
const occupancyTypePrints = getOccupancyTypePrintsById(lotOccupancy.occupancyTypeId);
|
||||||
const occupancyTypes = getOccupancyTypes();
|
const occupancyTypes = getOccupancyTypes();
|
||||||
|
|
@ -15,8 +15,8 @@ export const handler = (request, response) => {
|
||||||
const lotStatuses = getLotStatuses();
|
const lotStatuses = getLotStatuses();
|
||||||
const maps = getMaps();
|
const maps = getMaps();
|
||||||
const workOrderTypes = getWorkOrderTypes();
|
const workOrderTypes = getWorkOrderTypes();
|
||||||
return response.render("lotOccupancy-edit", {
|
response.render('lotOccupancy-edit', {
|
||||||
headTitle: `${configFunctions.getProperty("aliases.occupancy")} Update`,
|
headTitle: `${configFunctions.getProperty('aliases.occupancy')} Update`,
|
||||||
lotOccupancy,
|
lotOccupancy,
|
||||||
occupancyTypePrints,
|
occupancyTypePrints,
|
||||||
occupancyTypes,
|
occupancyTypes,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getLotOccupantTypes,
|
getLotOccupantTypes,
|
||||||
|
|
@ -7,34 +7,38 @@ import {
|
||||||
getOccupancyTypePrintsById,
|
getOccupancyTypePrintsById,
|
||||||
getOccupancyTypes,
|
getOccupancyTypes,
|
||||||
getWorkOrderTypes
|
getWorkOrderTypes
|
||||||
} from "../../helpers/functions.cache.js";
|
} from '../../helpers/functions.cache.js'
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from '../../helpers/functions.config.js'
|
||||||
|
|
||||||
import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js";
|
import { getLotOccupancy } from '../../helpers/lotOccupancyDB/getLotOccupancy.js'
|
||||||
import { getMaps } from "../../helpers/lotOccupancyDB/getMaps.js";
|
import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js'
|
||||||
|
|
||||||
export const handler: RequestHandler = (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
const lotOccupancy = getLotOccupancy(request.params.lotOccupancyId);
|
const lotOccupancy = getLotOccupancy(request.params.lotOccupancyId)
|
||||||
|
|
||||||
if (!lotOccupancy) {
|
if (!lotOccupancy) {
|
||||||
return response.redirect(
|
response.redirect(
|
||||||
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
`${configFunctions.getProperty(
|
||||||
"/lotOccupancies/?error=lotOccupancyIdNotFound"
|
'reverseProxy.urlPrefix'
|
||||||
);
|
)}/lotOccupancies/?error=lotOccupancyIdNotFound`
|
||||||
|
)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const occupancyTypePrints = getOccupancyTypePrintsById(lotOccupancy.occupancyTypeId);
|
const occupancyTypePrints = getOccupancyTypePrintsById(
|
||||||
|
lotOccupancy.occupancyTypeId!
|
||||||
|
)
|
||||||
|
|
||||||
const occupancyTypes = getOccupancyTypes();
|
const occupancyTypes = getOccupancyTypes()
|
||||||
const lotOccupantTypes = getLotOccupantTypes();
|
const lotOccupantTypes = getLotOccupantTypes()
|
||||||
const lotTypes = getLotTypes();
|
const lotTypes = getLotTypes()
|
||||||
const lotStatuses = getLotStatuses();
|
const lotStatuses = getLotStatuses()
|
||||||
const maps = getMaps();
|
const maps = getMaps()
|
||||||
const workOrderTypes = getWorkOrderTypes();
|
const workOrderTypes = getWorkOrderTypes()
|
||||||
|
|
||||||
return response.render("lotOccupancy-edit", {
|
response.render('lotOccupancy-edit', {
|
||||||
headTitle: `${configFunctions.getProperty("aliases.occupancy")} Update`,
|
headTitle: `${configFunctions.getProperty('aliases.occupancy')} Update`,
|
||||||
lotOccupancy,
|
lotOccupancy,
|
||||||
occupancyTypePrints,
|
occupancyTypePrints,
|
||||||
|
|
||||||
|
|
@ -46,7 +50,7 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
workOrderTypes,
|
workOrderTypes,
|
||||||
|
|
||||||
isCreate: false
|
isCreate: false
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
export default handler;
|
export default handler
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express';
|
||||||
export declare const handler: RequestHandler;
|
export declare const handler: RequestHandler;
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
import { getOccupancyTypePrintsById } from "../../helpers/functions.cache.js";
|
import { getOccupancyTypePrintsById } from '../../helpers/functions.cache.js';
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from '../../helpers/functions.config.js';
|
||||||
import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js";
|
import { getLotOccupancy } from '../../helpers/lotOccupancyDB/getLotOccupancy.js';
|
||||||
export const handler = (request, response) => {
|
export const handler = (request, response) => {
|
||||||
const lotOccupancy = getLotOccupancy(request.params.lotOccupancyId);
|
const lotOccupancy = getLotOccupancy(request.params.lotOccupancyId);
|
||||||
if (!lotOccupancy) {
|
if (!lotOccupancy) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||||
"/lotOccupancies/?error=lotOccupancyIdNotFound");
|
'/lotOccupancies/?error=lotOccupancyIdNotFound');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const occupancyTypePrints = getOccupancyTypePrintsById(lotOccupancy.occupancyTypeId);
|
const occupancyTypePrints = getOccupancyTypePrintsById(lotOccupancy.occupancyTypeId);
|
||||||
return response.render("lotOccupancy-view", {
|
response.render('lotOccupancy-view', {
|
||||||
headTitle: `${configFunctions.getProperty("aliases.occupancy")} View`,
|
headTitle: `${configFunctions.getProperty('aliases.occupancy')} View`,
|
||||||
lotOccupancy,
|
lotOccupancy,
|
||||||
occupancyTypePrints
|
occupancyTypePrints
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,30 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express'
|
||||||
import { getOccupancyTypePrintsById } from "../../helpers/functions.cache.js";
|
import { getOccupancyTypePrintsById } from '../../helpers/functions.cache.js'
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from '../../helpers/functions.config.js'
|
||||||
|
|
||||||
import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js";
|
import { getLotOccupancy } from '../../helpers/lotOccupancyDB/getLotOccupancy.js'
|
||||||
|
|
||||||
export const handler: RequestHandler = (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
const lotOccupancy = getLotOccupancy(request.params.lotOccupancyId);
|
const lotOccupancy = getLotOccupancy(request.params.lotOccupancyId)
|
||||||
|
|
||||||
if (!lotOccupancy) {
|
if (!lotOccupancy) {
|
||||||
return response.redirect(
|
response.redirect(
|
||||||
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||||
"/lotOccupancies/?error=lotOccupancyIdNotFound"
|
'/lotOccupancies/?error=lotOccupancyIdNotFound'
|
||||||
);
|
)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const occupancyTypePrints = getOccupancyTypePrintsById(lotOccupancy.occupancyTypeId);
|
const occupancyTypePrints = getOccupancyTypePrintsById(
|
||||||
|
lotOccupancy.occupancyTypeId!
|
||||||
|
)
|
||||||
|
|
||||||
return response.render("lotOccupancy-view", {
|
response.render('lotOccupancy-view', {
|
||||||
headTitle: `${configFunctions.getProperty("aliases.occupancy")} View`,
|
headTitle: `${configFunctions.getProperty('aliases.occupancy')} View`,
|
||||||
lotOccupancy,
|
lotOccupancy,
|
||||||
occupancyTypePrints
|
occupancyTypePrints
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
export default handler;
|
export default handler
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express';
|
||||||
export declare const handler: RequestHandler;
|
export declare const handler: RequestHandler;
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js";
|
import { getLotOccupancy } from '../../helpers/lotOccupancyDB/getLotOccupancy.js';
|
||||||
import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js";
|
import { getFeeCategories } from '../../helpers/lotOccupancyDB/getFeeCategories.js';
|
||||||
export const handler = (request, response) => {
|
export const handler = (request, response) => {
|
||||||
const lotOccupancyId = request.body.lotOccupancyId;
|
const lotOccupancyId = request.body.lotOccupancyId;
|
||||||
const lotOccupancy = getLotOccupancy(lotOccupancyId);
|
const lotOccupancy = getLotOccupancy(lotOccupancyId);
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express'
|
||||||
|
|
||||||
import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js";
|
import { getLotOccupancy } from '../../helpers/lotOccupancyDB/getLotOccupancy.js'
|
||||||
|
|
||||||
import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js";
|
import { getFeeCategories } from '../../helpers/lotOccupancyDB/getFeeCategories.js'
|
||||||
|
|
||||||
export const handler: RequestHandler = (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
const lotOccupancyId = request.body.lotOccupancyId;
|
const lotOccupancyId = request.body.lotOccupancyId
|
||||||
|
|
||||||
const lotOccupancy = getLotOccupancy(lotOccupancyId);
|
const lotOccupancy = getLotOccupancy(lotOccupancyId)!
|
||||||
|
|
||||||
const feeCategories = getFeeCategories(
|
const feeCategories = getFeeCategories(
|
||||||
{
|
{
|
||||||
|
|
@ -17,11 +17,11 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
{
|
{
|
||||||
includeFees: true
|
includeFees: true
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
feeCategories
|
feeCategories
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
export default handler;
|
export default handler
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express';
|
||||||
export declare const handler: RequestHandler;
|
export declare const handler: RequestHandler;
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { getOccupancyTypeById, getAllOccupancyTypeFields } from "../../helpers/functions.cache.js";
|
import { getOccupancyTypeById, getAllOccupancyTypeFields } from '../../helpers/functions.cache.js';
|
||||||
export const handler = async (request, response) => {
|
export const handler = (request, response) => {
|
||||||
const occupancyTypeFields = getAllOccupancyTypeFields();
|
const occupancyTypeFields = getAllOccupancyTypeFields();
|
||||||
const result = getOccupancyTypeById(Number.parseInt(request.body.occupancyTypeId, 10));
|
const result = getOccupancyTypeById(Number.parseInt(request.body.occupancyTypeId, 10));
|
||||||
occupancyTypeFields.push(...result.occupancyTypeFields);
|
occupancyTypeFields.push(...(result.occupancyTypeFields ?? []));
|
||||||
response.json({
|
response.json({
|
||||||
occupancyTypeFields
|
occupancyTypeFields
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,22 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express'
|
||||||
|
|
||||||
import { getOccupancyTypeById, getAllOccupancyTypeFields } from "../../helpers/functions.cache.js";
|
import {
|
||||||
|
getOccupancyTypeById,
|
||||||
|
getAllOccupancyTypeFields
|
||||||
|
} from '../../helpers/functions.cache.js'
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
const occupancyTypeFields = getAllOccupancyTypeFields();
|
const occupancyTypeFields = getAllOccupancyTypeFields()
|
||||||
|
|
||||||
const result = getOccupancyTypeById(Number.parseInt(request.body.occupancyTypeId, 10));
|
const result = getOccupancyTypeById(
|
||||||
|
Number.parseInt(request.body.occupancyTypeId, 10)
|
||||||
|
)!
|
||||||
|
|
||||||
occupancyTypeFields.push(...result.occupancyTypeFields);
|
occupancyTypeFields.push(...(result.occupancyTypeFields ?? []))
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
occupancyTypeFields
|
occupancyTypeFields
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
export default handler;
|
export default handler
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express';
|
||||||
export declare const handler: RequestHandler;
|
export declare const handler: RequestHandler;
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { getLotTypeById } from "../../helpers/functions.cache.js";
|
import { getLotTypeById } from '../../helpers/functions.cache.js';
|
||||||
export const handler = async (request, response) => {
|
export const handler = (request, response) => {
|
||||||
const lotType = getLotTypeById(Number.parseInt(request.body.lotTypeId, 10));
|
const lotType = getLotTypeById(Number.parseInt(request.body.lotTypeId, 10));
|
||||||
response.json({
|
response.json({
|
||||||
lotTypeFields: lotType.lotTypeFields
|
lotTypeFields: lotType.lotTypeFields
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express'
|
||||||
|
|
||||||
import { getLotTypeById } from "../../helpers/functions.cache.js";
|
import { getLotTypeById } from '../../helpers/functions.cache.js'
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
const lotType = getLotTypeById(Number.parseInt(request.body.lotTypeId, 10));
|
const lotType = getLotTypeById(Number.parseInt(request.body.lotTypeId, 10))!
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
lotTypeFields: lotType.lotTypeFields
|
lotTypeFields: lotType.lotTypeFields
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
export default handler;
|
export default handler
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express';
|
||||||
export declare const handler: RequestHandler;
|
export declare const handler: RequestHandler;
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { getReportData } from "../../helpers/lotOccupancyDB/getReportData.js";
|
import { getReportData } from '../../helpers/lotOccupancyDB/getReportData.js';
|
||||||
import papaparse from "papaparse";
|
import papaparse from 'papaparse';
|
||||||
export const handler = (request, response) => {
|
export const handler = (request, response) => {
|
||||||
const reportName = request.params.reportName;
|
const reportName = request.params.reportName;
|
||||||
let rows;
|
let rows;
|
||||||
|
|
@ -12,12 +12,12 @@ export const handler = (request, response) => {
|
||||||
if (!rows) {
|
if (!rows) {
|
||||||
return response.status(404).json({
|
return response.status(404).json({
|
||||||
success: false,
|
success: false,
|
||||||
message: "Report Not Found"
|
message: 'Report Not Found'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const csv = papaparse.unparse(rows);
|
const csv = papaparse.unparse(rows);
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=" + reportName + "-" + Date.now().toString() + ".csv");
|
response.setHeader('Content-Disposition', 'attachment; filename=' + reportName + '-' + Date.now().toString() + '.csv');
|
||||||
response.setHeader("Content-Type", "text/csv");
|
response.setHeader('Content-Type', 'text/csv');
|
||||||
response.send(csv);
|
response.send(csv);
|
||||||
};
|
};
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,41 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express'
|
||||||
|
|
||||||
import { getReportData, ReportParameters } from "../../helpers/lotOccupancyDB/getReportData.js";
|
import {
|
||||||
|
getReportData,
|
||||||
|
ReportParameters
|
||||||
|
} from '../../helpers/lotOccupancyDB/getReportData.js'
|
||||||
|
|
||||||
import papaparse from "papaparse";
|
import papaparse from 'papaparse'
|
||||||
|
|
||||||
export const handler: RequestHandler = (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
const reportName = request.params.reportName;
|
const reportName = request.params.reportName
|
||||||
|
|
||||||
let rows: unknown[];
|
let rows: unknown[] | undefined
|
||||||
|
|
||||||
switch (reportName) {
|
switch (reportName) {
|
||||||
default: {
|
default: {
|
||||||
rows = getReportData(reportName, request.query as ReportParameters);
|
rows = getReportData(reportName, request.query as ReportParameters)
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rows) {
|
if (!rows) {
|
||||||
return response.status(404).json({
|
return response.status(404).json({
|
||||||
success: false,
|
success: false,
|
||||||
message: "Report Not Found"
|
message: 'Report Not Found'
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const csv = papaparse.unparse(rows);
|
const csv = papaparse.unparse(rows)
|
||||||
|
|
||||||
response.setHeader(
|
response.setHeader(
|
||||||
"Content-Disposition",
|
'Content-Disposition',
|
||||||
"attachment; filename=" + reportName + "-" + Date.now().toString() + ".csv"
|
'attachment; filename=' + reportName + '-' + Date.now().toString() + '.csv'
|
||||||
);
|
)
|
||||||
|
|
||||||
response.setHeader("Content-Type", "text/csv");
|
response.setHeader('Content-Type', 'text/csv')
|
||||||
|
|
||||||
response.send(csv);
|
response.send(csv)
|
||||||
};
|
}
|
||||||
|
|
||||||
export default handler;
|
export default handler
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express';
|
||||||
export declare const handler: RequestHandler;
|
export declare const handler: RequestHandler;
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { getLotStatuses, getWorkOrderMilestoneTypes, getWorkOrderTypes } from "../../helpers/functions.cache.js";
|
import { getLotStatuses, getWorkOrderMilestoneTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js';
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from '../../helpers/functions.config.js';
|
||||||
import { getWorkOrder } from "../../helpers/lotOccupancyDB/getWorkOrder.js";
|
import { getWorkOrder } from '../../helpers/lotOccupancyDB/getWorkOrder.js';
|
||||||
export const handler = (request, response) => {
|
export const handler = (request, response) => {
|
||||||
const workOrder = getWorkOrder(request.params.workOrderId, {
|
const workOrder = getWorkOrder(request.params.workOrderId, {
|
||||||
includeLotsAndLotOccupancies: true,
|
includeLotsAndLotOccupancies: true,
|
||||||
|
|
@ -8,20 +8,22 @@ export const handler = (request, response) => {
|
||||||
includeMilestones: true
|
includeMilestones: true
|
||||||
});
|
});
|
||||||
if (!workOrder) {
|
if (!workOrder) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||||
"/workOrders/?error=workOrderIdNotFound");
|
'/workOrders/?error=workOrderIdNotFound');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (workOrder.workOrderCloseDate) {
|
if (workOrder.workOrderCloseDate) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||||
"/workOrders/" +
|
'/workOrders/' +
|
||||||
workOrder.workOrderId.toString() +
|
workOrder.workOrderId.toString() +
|
||||||
"/?error=workOrderIsClosed");
|
'/?error=workOrderIsClosed');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const workOrderTypes = getWorkOrderTypes();
|
const workOrderTypes = getWorkOrderTypes();
|
||||||
const workOrderMilestoneTypes = getWorkOrderMilestoneTypes();
|
const workOrderMilestoneTypes = getWorkOrderMilestoneTypes();
|
||||||
const lotStatuses = getLotStatuses();
|
const lotStatuses = getLotStatuses();
|
||||||
response.render("workOrder-edit", {
|
response.render('workOrder-edit', {
|
||||||
headTitle: "Work Order #" + workOrder.workOrderNumber,
|
headTitle: `Work Order #${workOrder.workOrderNumber}`,
|
||||||
workOrder,
|
workOrder,
|
||||||
isCreate: false,
|
isCreate: false,
|
||||||
workOrderTypes,
|
workOrderTypes,
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,54 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from 'express'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getLotStatuses,
|
getLotStatuses,
|
||||||
getWorkOrderMilestoneTypes,
|
getWorkOrderMilestoneTypes,
|
||||||
getWorkOrderTypes
|
getWorkOrderTypes
|
||||||
} from "../../helpers/functions.cache.js";
|
} from '../../helpers/functions.cache.js'
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from '../../helpers/functions.config.js'
|
||||||
|
|
||||||
import { getWorkOrder } from "../../helpers/lotOccupancyDB/getWorkOrder.js";
|
import { getWorkOrder } from '../../helpers/lotOccupancyDB/getWorkOrder.js'
|
||||||
|
|
||||||
export const handler: RequestHandler = (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
const workOrder = getWorkOrder(request.params.workOrderId, {
|
const workOrder = getWorkOrder(request.params.workOrderId, {
|
||||||
includeLotsAndLotOccupancies: true,
|
includeLotsAndLotOccupancies: true,
|
||||||
includeComments: true,
|
includeComments: true,
|
||||||
includeMilestones: true
|
includeMilestones: true
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!workOrder) {
|
if (!workOrder) {
|
||||||
return response.redirect(
|
response.redirect(
|
||||||
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||||
"/workOrders/?error=workOrderIdNotFound"
|
'/workOrders/?error=workOrderIdNotFound'
|
||||||
);
|
)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (workOrder.workOrderCloseDate) {
|
if (workOrder.workOrderCloseDate) {
|
||||||
return response.redirect(
|
response.redirect(
|
||||||
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||||
"/workOrders/" +
|
'/workOrders/' +
|
||||||
workOrder.workOrderId.toString() +
|
workOrder.workOrderId!.toString() +
|
||||||
"/?error=workOrderIsClosed"
|
'/?error=workOrderIsClosed'
|
||||||
);
|
)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const workOrderTypes = getWorkOrderTypes();
|
const workOrderTypes = getWorkOrderTypes()
|
||||||
|
|
||||||
const workOrderMilestoneTypes = getWorkOrderMilestoneTypes();
|
const workOrderMilestoneTypes = getWorkOrderMilestoneTypes()
|
||||||
|
|
||||||
const lotStatuses = getLotStatuses();
|
const lotStatuses = getLotStatuses()
|
||||||
|
|
||||||
response.render("workOrder-edit", {
|
response.render('workOrder-edit', {
|
||||||
headTitle: "Work Order #" + workOrder.workOrderNumber,
|
headTitle: `Work Order #${workOrder.workOrderNumber!}`,
|
||||||
workOrder,
|
workOrder,
|
||||||
isCreate: false,
|
isCreate: false,
|
||||||
workOrderTypes,
|
workOrderTypes,
|
||||||
workOrderMilestoneTypes,
|
workOrderMilestoneTypes,
|
||||||
lotStatuses
|
lotStatuses
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
export default handler;
|
export default handler
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import * as recordTypes from "../types/recordTypes";
|
import * as recordTypes from '../types/recordTypes';
|
||||||
export declare function regenerateApiKey(userName: string): Promise<void>;
|
export declare function regenerateApiKey(userName: string): Promise<void>;
|
||||||
export declare function getApiKey(userName: string): Promise<string>;
|
export declare function getApiKey(userName: string): Promise<string>;
|
||||||
export declare function getApiKeyFromSession(session: recordTypes.PartialSession): Promise<string>;
|
export declare function getApiKeyFromSession(session: recordTypes.PartialSession): Promise<string>;
|
||||||
export declare function getUserNameFromApiKey(apiKey: string): Promise<string>;
|
export declare function getUserNameFromApiKey(apiKey: string): Promise<string | undefined>;
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import fs from "node:fs/promises";
|
import fs from 'node:fs/promises';
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import Debug from "debug";
|
import Debug from 'debug';
|
||||||
const debug = Debug("lot-occupancy-system:functions.api");
|
const debug = Debug('lot-occupancy-system:functions.api');
|
||||||
const apiKeyPath = "data/apiKeys.json";
|
const apiKeyPath = 'data/apiKeys.json';
|
||||||
let apiKeys;
|
let apiKeys;
|
||||||
async function loadApiKeys() {
|
async function loadApiKeys() {
|
||||||
try {
|
try {
|
||||||
const fileData = await fs.readFile(apiKeyPath, "utf8");
|
const fileData = await fs.readFile(apiKeyPath, 'utf8');
|
||||||
apiKeys = JSON.parse(fileData);
|
apiKeys = JSON.parse(fileData);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|
@ -16,14 +16,14 @@ async function loadApiKeys() {
|
||||||
}
|
}
|
||||||
async function saveApiKeys() {
|
async function saveApiKeys() {
|
||||||
try {
|
try {
|
||||||
await fs.writeFile(apiKeyPath, JSON.stringify(apiKeys), "utf8");
|
await fs.writeFile(apiKeyPath, JSON.stringify(apiKeys), 'utf8');
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
debug(error);
|
debug(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function generateApiKey(apiKeyPrefix) {
|
function generateApiKey(apiKeyPrefix) {
|
||||||
return apiKeyPrefix + "-" + uuidv4() + "-" + Date.now();
|
return apiKeyPrefix + '-' + uuidv4() + '-' + Date.now();
|
||||||
}
|
}
|
||||||
export async function regenerateApiKey(userName) {
|
export async function regenerateApiKey(userName) {
|
||||||
apiKeys[userName] = generateApiKey(userName);
|
apiKeys[userName] = generateApiKey(userName);
|
||||||
|
|
|
||||||
|
|
@ -1,66 +1,70 @@
|
||||||
import fs from "node:fs/promises";
|
import fs from 'node:fs/promises'
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
|
|
||||||
import Debug from "debug";
|
import Debug from 'debug'
|
||||||
|
|
||||||
import * as recordTypes from "../types/recordTypes";
|
import * as recordTypes from '../types/recordTypes'
|
||||||
|
|
||||||
const debug = Debug("lot-occupancy-system:functions.api");
|
const debug = Debug('lot-occupancy-system:functions.api')
|
||||||
|
|
||||||
const apiKeyPath = "data/apiKeys.json";
|
const apiKeyPath = 'data/apiKeys.json'
|
||||||
let apiKeys: { [userName: string]: string };
|
let apiKeys: Record<string, string>
|
||||||
|
|
||||||
async function loadApiKeys() {
|
async function loadApiKeys(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const fileData = await fs.readFile(apiKeyPath, "utf8");
|
const fileData = await fs.readFile(apiKeyPath, 'utf8')
|
||||||
apiKeys = JSON.parse(fileData);
|
apiKeys = JSON.parse(fileData)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
debug(error);
|
debug(error)
|
||||||
apiKeys = {};
|
apiKeys = {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveApiKeys() {
|
async function saveApiKeys(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await fs.writeFile(apiKeyPath, JSON.stringify(apiKeys), "utf8");
|
await fs.writeFile(apiKeyPath, JSON.stringify(apiKeys), 'utf8')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
debug(error);
|
debug(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateApiKey(apiKeyPrefix: string) {
|
function generateApiKey(apiKeyPrefix: string): string {
|
||||||
return apiKeyPrefix + "-" + uuidv4() + "-" + Date.now();
|
return apiKeyPrefix + '-' + uuidv4() + '-' + Date.now()
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function regenerateApiKey(userName: string) {
|
export async function regenerateApiKey(userName: string): Promise<void> {
|
||||||
apiKeys[userName] = generateApiKey(userName);
|
apiKeys[userName] = generateApiKey(userName)
|
||||||
await saveApiKeys();
|
await saveApiKeys()
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getApiKey(userName: string) {
|
export async function getApiKey(userName: string): Promise<string> {
|
||||||
if (!apiKeys) {
|
if (!apiKeys) {
|
||||||
await loadApiKeys();
|
await loadApiKeys()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!apiKeys[userName]) {
|
if (!apiKeys[userName]) {
|
||||||
await regenerateApiKey(userName);
|
await regenerateApiKey(userName)
|
||||||
}
|
}
|
||||||
|
|
||||||
return apiKeys[userName];
|
return apiKeys[userName]
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getApiKeyFromSession(session: recordTypes.PartialSession) {
|
export async function getApiKeyFromSession(
|
||||||
return await getApiKey(session.user.userName);
|
session: recordTypes.PartialSession
|
||||||
|
): Promise<string> {
|
||||||
|
return await getApiKey(session.user!.userName)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getUserNameFromApiKey(apiKey: string) {
|
export async function getUserNameFromApiKey(
|
||||||
|
apiKey: string
|
||||||
|
): Promise<string | undefined> {
|
||||||
if (!apiKeys) {
|
if (!apiKeys) {
|
||||||
await loadApiKeys();
|
await loadApiKeys()
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [userName, currentApiKey] of Object.entries(apiKeys)) {
|
for (const [userName, currentApiKey] of Object.entries(apiKeys)) {
|
||||||
if (apiKey === currentApiKey) {
|
if (apiKey === currentApiKey) {
|
||||||
return userName;
|
return userName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ async function authenticateViaActiveDirectory(userName, password) {
|
||||||
resolve(auth);
|
resolve(auth);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (_a) {
|
catch {
|
||||||
resolve(false);
|
resolve(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
import type * as recordTypes from "../types/recordTypes";
|
import type * as recordTypes from '../types/recordTypes';
|
||||||
export declare function getLotOccupantTypes(): recordTypes.LotOccupantType[];
|
export declare function getLotOccupantTypes(): recordTypes.LotOccupantType[];
|
||||||
export declare function getLotOccupantTypeById(lotOccupantTypeId: number): recordTypes.LotOccupantType;
|
export declare function getLotOccupantTypeById(lotOccupantTypeId: number): recordTypes.LotOccupantType | undefined;
|
||||||
export declare function getLotOccupantTypeByLotOccupantType(lotOccupantType: string): recordTypes.LotOccupantType;
|
export declare function getLotOccupantTypeByLotOccupantType(lotOccupantType: string): recordTypes.LotOccupantType | undefined;
|
||||||
export declare function getLotStatuses(): recordTypes.LotStatus[];
|
export declare function getLotStatuses(): recordTypes.LotStatus[];
|
||||||
export declare function getLotStatusById(lotStatusId: number): recordTypes.LotStatus;
|
export declare function getLotStatusById(lotStatusId: number): recordTypes.LotStatus | undefined;
|
||||||
export declare function getLotStatusByLotStatus(lotStatus: string): recordTypes.LotStatus;
|
export declare function getLotStatusByLotStatus(lotStatus: string): recordTypes.LotStatus | undefined;
|
||||||
export declare function getLotTypes(): recordTypes.LotType[];
|
export declare function getLotTypes(): recordTypes.LotType[];
|
||||||
export declare function getLotTypeById(lotTypeId: number): recordTypes.LotType;
|
export declare function getLotTypeById(lotTypeId: number): recordTypes.LotType | undefined;
|
||||||
export declare function getLotTypesByLotType(lotType: string): recordTypes.LotType;
|
export declare function getLotTypesByLotType(lotType: string): recordTypes.LotType | undefined;
|
||||||
export declare function getOccupancyTypes(): recordTypes.OccupancyType[];
|
export declare function getOccupancyTypes(): recordTypes.OccupancyType[];
|
||||||
export declare function getAllOccupancyTypeFields(): recordTypes.OccupancyTypeField[];
|
export declare function getAllOccupancyTypeFields(): recordTypes.OccupancyTypeField[];
|
||||||
export declare function getOccupancyTypeById(occupancyTypeId: number): recordTypes.OccupancyType;
|
export declare function getOccupancyTypeById(occupancyTypeId: number): recordTypes.OccupancyType | undefined;
|
||||||
export declare function getOccupancyTypeByOccupancyType(occupancyTypeString: string): recordTypes.OccupancyType;
|
export declare function getOccupancyTypeByOccupancyType(occupancyTypeString: string): recordTypes.OccupancyType | undefined;
|
||||||
export declare function getOccupancyTypePrintsById(occupancyTypeId: number): string[];
|
export declare function getOccupancyTypePrintsById(occupancyTypeId: number): string[];
|
||||||
export declare function getWorkOrderTypes(): recordTypes.WorkOrderType[];
|
export declare function getWorkOrderTypes(): recordTypes.WorkOrderType[];
|
||||||
export declare function getWorkOrderTypeById(workOrderTypeId: number): recordTypes.WorkOrderType;
|
export declare function getWorkOrderTypeById(workOrderTypeId: number): recordTypes.WorkOrderType | undefined;
|
||||||
export declare function getWorkOrderMilestoneTypes(): recordTypes.WorkOrderMilestoneType[];
|
export declare function getWorkOrderMilestoneTypes(): recordTypes.WorkOrderMilestoneType[];
|
||||||
export declare function getWorkOrderMilestoneTypeByWorkOrderMilestoneTypeId(workOrderMilestoneTypeId: number): recordTypes.WorkOrderMilestoneType;
|
export declare function getWorkOrderMilestoneTypeByWorkOrderMilestoneTypeId(workOrderMilestoneTypeId: number): recordTypes.WorkOrderMilestoneType | undefined;
|
||||||
export declare function getWorkOrderMilestoneTypeByWorkOrderMilestoneType(workOrderMilestoneTypeString: string): recordTypes.WorkOrderMilestoneType;
|
export declare function getWorkOrderMilestoneTypeByWorkOrderMilestoneType(workOrderMilestoneTypeString: string): recordTypes.WorkOrderMilestoneType | undefined;
|
||||||
export declare function clearCacheByTableName(tableName: string): void;
|
export declare function clearCacheByTableName(tableName: string): void;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import * as configFunctions from "./functions.config.js";
|
import * as configFunctions from './functions.config.js';
|
||||||
import { getLotOccupantTypes as getLotOccupantTypesFromDatabase } from "./lotOccupancyDB/getLotOccupantTypes.js";
|
import { getLotOccupantTypes as getLotOccupantTypesFromDatabase } from './lotOccupancyDB/getLotOccupantTypes.js';
|
||||||
import { getLotStatuses as getLotStatusesFromDatabase } from "./lotOccupancyDB/getLotStatuses.js";
|
import { getLotStatuses as getLotStatusesFromDatabase } from './lotOccupancyDB/getLotStatuses.js';
|
||||||
import { getLotTypes as getLotTypesFromDatabase } from "./lotOccupancyDB/getLotTypes.js";
|
import { getLotTypes as getLotTypesFromDatabase } from './lotOccupancyDB/getLotTypes.js';
|
||||||
import { getOccupancyTypes as getOccupancyTypesFromDatabase } from "./lotOccupancyDB/getOccupancyTypes.js";
|
import { getOccupancyTypes as getOccupancyTypesFromDatabase } from './lotOccupancyDB/getOccupancyTypes.js';
|
||||||
import { getOccupancyTypeFields as getOccupancyTypeFieldsFromDatabase } from "./lotOccupancyDB/getOccupancyTypeFields.js";
|
import { getOccupancyTypeFields as getOccupancyTypeFieldsFromDatabase } from './lotOccupancyDB/getOccupancyTypeFields.js';
|
||||||
import { getWorkOrderTypes as getWorkOrderTypesFromDatabase } from "./lotOccupancyDB/getWorkOrderTypes.js";
|
import { getWorkOrderTypes as getWorkOrderTypesFromDatabase } from './lotOccupancyDB/getWorkOrderTypes.js';
|
||||||
import { getWorkOrderMilestoneTypes as getWorkOrderMilestoneTypesFromDatabase } from "./lotOccupancyDB/getWorkOrderMilestoneTypes.js";
|
import { getWorkOrderMilestoneTypes as getWorkOrderMilestoneTypesFromDatabase } from './lotOccupancyDB/getWorkOrderMilestoneTypes.js';
|
||||||
let lotOccupantTypes;
|
let lotOccupantTypes;
|
||||||
export function getLotOccupantTypes() {
|
export function getLotOccupantTypes() {
|
||||||
if (!lotOccupantTypes) {
|
if (!lotOccupantTypes) {
|
||||||
|
|
@ -23,7 +23,8 @@ export function getLotOccupantTypeByLotOccupantType(lotOccupantType) {
|
||||||
const cachedLotOccupantTypes = getLotOccupantTypes();
|
const cachedLotOccupantTypes = getLotOccupantTypes();
|
||||||
const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase();
|
const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase();
|
||||||
return cachedLotOccupantTypes.find((currentLotOccupantType) => {
|
return cachedLotOccupantTypes.find((currentLotOccupantType) => {
|
||||||
return currentLotOccupantType.lotOccupantType.toLowerCase() === lotOccupantTypeLowerCase;
|
return (currentLotOccupantType.lotOccupantType.toLowerCase() ===
|
||||||
|
lotOccupantTypeLowerCase);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function clearLotOccupantTypesCache() {
|
function clearLotOccupantTypesCache() {
|
||||||
|
|
@ -99,16 +100,18 @@ export function getOccupancyTypeByOccupancyType(occupancyTypeString) {
|
||||||
const cachedOccupancyTypes = getOccupancyTypes();
|
const cachedOccupancyTypes = getOccupancyTypes();
|
||||||
const occupancyTypeLowerCase = occupancyTypeString.toLowerCase();
|
const occupancyTypeLowerCase = occupancyTypeString.toLowerCase();
|
||||||
return cachedOccupancyTypes.find((currentOccupancyType) => {
|
return cachedOccupancyTypes.find((currentOccupancyType) => {
|
||||||
return currentOccupancyType.occupancyType.toLowerCase() === occupancyTypeLowerCase;
|
return (currentOccupancyType.occupancyType.toLowerCase() ===
|
||||||
|
occupancyTypeLowerCase);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
export function getOccupancyTypePrintsById(occupancyTypeId) {
|
export function getOccupancyTypePrintsById(occupancyTypeId) {
|
||||||
const occupancyType = getOccupancyTypeById(occupancyTypeId);
|
const occupancyType = getOccupancyTypeById(occupancyTypeId);
|
||||||
if (!occupancyType || occupancyType.occupancyTypePrints.length === 0) {
|
if (!occupancyType ||
|
||||||
|
(occupancyType.occupancyTypePrints ?? []).length === 0) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if (occupancyType.occupancyTypePrints.includes("*")) {
|
if (occupancyType.occupancyTypePrints.includes('*')) {
|
||||||
return configFunctions.getProperty("settings.lotOccupancy.prints");
|
return configFunctions.getProperty('settings.lotOccupancy.prints');
|
||||||
}
|
}
|
||||||
return occupancyType.occupancyTypePrints;
|
return occupancyType.occupancyTypePrints;
|
||||||
}
|
}
|
||||||
|
|
@ -142,7 +145,8 @@ export function getWorkOrderMilestoneTypes() {
|
||||||
export function getWorkOrderMilestoneTypeByWorkOrderMilestoneTypeId(workOrderMilestoneTypeId) {
|
export function getWorkOrderMilestoneTypeByWorkOrderMilestoneTypeId(workOrderMilestoneTypeId) {
|
||||||
const cachedWorkOrderMilestoneTypes = getWorkOrderMilestoneTypes();
|
const cachedWorkOrderMilestoneTypes = getWorkOrderMilestoneTypes();
|
||||||
return cachedWorkOrderMilestoneTypes.find((currentWorkOrderMilestoneType) => {
|
return cachedWorkOrderMilestoneTypes.find((currentWorkOrderMilestoneType) => {
|
||||||
return currentWorkOrderMilestoneType.workOrderMilestoneTypeId === workOrderMilestoneTypeId;
|
return (currentWorkOrderMilestoneType.workOrderMilestoneTypeId ===
|
||||||
|
workOrderMilestoneTypeId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
export function getWorkOrderMilestoneTypeByWorkOrderMilestoneType(workOrderMilestoneTypeString) {
|
export function getWorkOrderMilestoneTypeByWorkOrderMilestoneType(workOrderMilestoneTypeString) {
|
||||||
|
|
@ -158,30 +162,30 @@ function clearWorkOrderMilestoneTypesCache() {
|
||||||
}
|
}
|
||||||
export function clearCacheByTableName(tableName) {
|
export function clearCacheByTableName(tableName) {
|
||||||
switch (tableName) {
|
switch (tableName) {
|
||||||
case "LotOccupantTypes": {
|
case 'LotOccupantTypes': {
|
||||||
clearLotOccupantTypesCache();
|
clearLotOccupantTypesCache();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "LotStatuses": {
|
case 'LotStatuses': {
|
||||||
clearLotStatusesCache();
|
clearLotStatusesCache();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "LotTypes":
|
case 'LotTypes':
|
||||||
case "LotTypeFields": {
|
case 'LotTypeFields': {
|
||||||
clearLotTypesCache();
|
clearLotTypesCache();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "OccupancyTypes":
|
case 'OccupancyTypes':
|
||||||
case "OccupancyTypeFields":
|
case 'OccupancyTypeFields':
|
||||||
case "OccupancyTypePrints": {
|
case 'OccupancyTypePrints': {
|
||||||
clearOccupancyTypesCache();
|
clearOccupancyTypesCache();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "WorkOrderMilestoneTypes": {
|
case 'WorkOrderMilestoneTypes': {
|
||||||
clearWorkOrderMilestoneTypesCache();
|
clearWorkOrderMilestoneTypesCache();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "WorkOrderTypes": {
|
case 'WorkOrderTypes': {
|
||||||
clearWorkOrderTypesCache();
|
clearWorkOrderTypesCache();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,285 +1,320 @@
|
||||||
import * as configFunctions from "./functions.config.js";
|
import * as configFunctions from './functions.config.js'
|
||||||
|
|
||||||
import { getLotOccupantTypes as getLotOccupantTypesFromDatabase } from "./lotOccupancyDB/getLotOccupantTypes.js";
|
import { getLotOccupantTypes as getLotOccupantTypesFromDatabase } from './lotOccupancyDB/getLotOccupantTypes.js'
|
||||||
|
|
||||||
import { getLotStatuses as getLotStatusesFromDatabase } from "./lotOccupancyDB/getLotStatuses.js";
|
import { getLotStatuses as getLotStatusesFromDatabase } from './lotOccupancyDB/getLotStatuses.js'
|
||||||
|
|
||||||
import { getLotTypes as getLotTypesFromDatabase } from "./lotOccupancyDB/getLotTypes.js";
|
import { getLotTypes as getLotTypesFromDatabase } from './lotOccupancyDB/getLotTypes.js'
|
||||||
|
|
||||||
import { getOccupancyTypes as getOccupancyTypesFromDatabase } from "./lotOccupancyDB/getOccupancyTypes.js";
|
import { getOccupancyTypes as getOccupancyTypesFromDatabase } from './lotOccupancyDB/getOccupancyTypes.js'
|
||||||
import { getOccupancyTypeFields as getOccupancyTypeFieldsFromDatabase } from "./lotOccupancyDB/getOccupancyTypeFields.js";
|
import { getOccupancyTypeFields as getOccupancyTypeFieldsFromDatabase } from './lotOccupancyDB/getOccupancyTypeFields.js'
|
||||||
|
|
||||||
import { getWorkOrderTypes as getWorkOrderTypesFromDatabase } from "./lotOccupancyDB/getWorkOrderTypes.js";
|
import { getWorkOrderTypes as getWorkOrderTypesFromDatabase } from './lotOccupancyDB/getWorkOrderTypes.js'
|
||||||
|
|
||||||
import { getWorkOrderMilestoneTypes as getWorkOrderMilestoneTypesFromDatabase } from "./lotOccupancyDB/getWorkOrderMilestoneTypes.js";
|
import { getWorkOrderMilestoneTypes as getWorkOrderMilestoneTypesFromDatabase } from './lotOccupancyDB/getWorkOrderMilestoneTypes.js'
|
||||||
|
|
||||||
import type * as recordTypes from "../types/recordTypes";
|
import type * as recordTypes from '../types/recordTypes'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lot Occupant Types
|
* Lot Occupant Types
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let lotOccupantTypes: recordTypes.LotOccupantType[] | undefined;
|
let lotOccupantTypes: recordTypes.LotOccupantType[] | undefined
|
||||||
|
|
||||||
export function getLotOccupantTypes() {
|
export function getLotOccupantTypes(): recordTypes.LotOccupantType[] {
|
||||||
if (!lotOccupantTypes) {
|
if (!lotOccupantTypes) {
|
||||||
lotOccupantTypes = getLotOccupantTypesFromDatabase();
|
lotOccupantTypes = getLotOccupantTypesFromDatabase()
|
||||||
}
|
}
|
||||||
|
|
||||||
return lotOccupantTypes;
|
return lotOccupantTypes
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLotOccupantTypeById(lotOccupantTypeId: number) {
|
export function getLotOccupantTypeById(
|
||||||
const cachedLotOccupantTypes = getLotOccupantTypes();
|
lotOccupantTypeId: number
|
||||||
|
): recordTypes.LotOccupantType | undefined {
|
||||||
|
const cachedLotOccupantTypes = getLotOccupantTypes()
|
||||||
|
|
||||||
return cachedLotOccupantTypes.find((currentLotOccupantType) => {
|
return cachedLotOccupantTypes.find((currentLotOccupantType) => {
|
||||||
return currentLotOccupantType.lotOccupantTypeId === lotOccupantTypeId;
|
return currentLotOccupantType.lotOccupantTypeId === lotOccupantTypeId
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLotOccupantTypeByLotOccupantType(lotOccupantType: string) {
|
export function getLotOccupantTypeByLotOccupantType(
|
||||||
const cachedLotOccupantTypes = getLotOccupantTypes();
|
lotOccupantType: string
|
||||||
|
): recordTypes.LotOccupantType | undefined {
|
||||||
|
const cachedLotOccupantTypes = getLotOccupantTypes()
|
||||||
|
|
||||||
const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase();
|
const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase()
|
||||||
|
|
||||||
return cachedLotOccupantTypes.find((currentLotOccupantType) => {
|
return cachedLotOccupantTypes.find((currentLotOccupantType) => {
|
||||||
return currentLotOccupantType.lotOccupantType.toLowerCase() === lotOccupantTypeLowerCase;
|
return (
|
||||||
});
|
currentLotOccupantType.lotOccupantType.toLowerCase() ===
|
||||||
|
lotOccupantTypeLowerCase
|
||||||
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearLotOccupantTypesCache() {
|
function clearLotOccupantTypesCache(): void {
|
||||||
lotOccupantTypes = undefined;
|
lotOccupantTypes = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lot Statuses
|
* Lot Statuses
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let lotStatuses: recordTypes.LotStatus[] | undefined;
|
let lotStatuses: recordTypes.LotStatus[] | undefined
|
||||||
|
|
||||||
export function getLotStatuses() {
|
export function getLotStatuses(): recordTypes.LotStatus[] {
|
||||||
if (!lotStatuses) {
|
if (!lotStatuses) {
|
||||||
lotStatuses = getLotStatusesFromDatabase();
|
lotStatuses = getLotStatusesFromDatabase()
|
||||||
}
|
}
|
||||||
|
|
||||||
return lotStatuses;
|
return lotStatuses
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLotStatusById(lotStatusId: number) {
|
export function getLotStatusById(
|
||||||
const cachedLotStatuses = getLotStatuses();
|
lotStatusId: number
|
||||||
|
): recordTypes.LotStatus | undefined {
|
||||||
|
const cachedLotStatuses = getLotStatuses()
|
||||||
|
|
||||||
return cachedLotStatuses.find((currentLotStatus) => {
|
return cachedLotStatuses.find((currentLotStatus) => {
|
||||||
return currentLotStatus.lotStatusId === lotStatusId;
|
return currentLotStatus.lotStatusId === lotStatusId
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLotStatusByLotStatus(lotStatus: string) {
|
export function getLotStatusByLotStatus(
|
||||||
const cachedLotStatuses = getLotStatuses();
|
lotStatus: string
|
||||||
|
): recordTypes.LotStatus | undefined {
|
||||||
|
const cachedLotStatuses = getLotStatuses()
|
||||||
|
|
||||||
const lotStatusLowerCase = lotStatus.toLowerCase();
|
const lotStatusLowerCase = lotStatus.toLowerCase()
|
||||||
|
|
||||||
return cachedLotStatuses.find((currentLotStatus) => {
|
return cachedLotStatuses.find((currentLotStatus) => {
|
||||||
return currentLotStatus.lotStatus.toLowerCase() === lotStatusLowerCase;
|
return currentLotStatus.lotStatus.toLowerCase() === lotStatusLowerCase
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearLotStatusesCache() {
|
function clearLotStatusesCache(): void {
|
||||||
lotStatuses = undefined;
|
lotStatuses = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lot Types
|
* Lot Types
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let lotTypes: recordTypes.LotType[] | undefined;
|
let lotTypes: recordTypes.LotType[] | undefined
|
||||||
|
|
||||||
export function getLotTypes() {
|
export function getLotTypes(): recordTypes.LotType[] {
|
||||||
if (!lotTypes) {
|
if (!lotTypes) {
|
||||||
lotTypes = getLotTypesFromDatabase();
|
lotTypes = getLotTypesFromDatabase()
|
||||||
}
|
}
|
||||||
|
|
||||||
return lotTypes;
|
return lotTypes
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLotTypeById(lotTypeId: number) {
|
export function getLotTypeById(
|
||||||
const cachedLotTypes = getLotTypes();
|
lotTypeId: number
|
||||||
|
): recordTypes.LotType | undefined {
|
||||||
|
const cachedLotTypes = getLotTypes()
|
||||||
|
|
||||||
return cachedLotTypes.find((currentLotType) => {
|
return cachedLotTypes.find((currentLotType) => {
|
||||||
return currentLotType.lotTypeId === lotTypeId;
|
return currentLotType.lotTypeId === lotTypeId
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLotTypesByLotType(lotType: string) {
|
export function getLotTypesByLotType(
|
||||||
const cachedLotTypes = getLotTypes();
|
lotType: string
|
||||||
|
): recordTypes.LotType | undefined {
|
||||||
|
const cachedLotTypes = getLotTypes()
|
||||||
|
|
||||||
const lotTypeLowerCase = lotType.toLowerCase();
|
const lotTypeLowerCase = lotType.toLowerCase()
|
||||||
|
|
||||||
return cachedLotTypes.find((currentLotType) => {
|
return cachedLotTypes.find((currentLotType) => {
|
||||||
return currentLotType.lotType.toLowerCase() === lotTypeLowerCase;
|
return currentLotType.lotType.toLowerCase() === lotTypeLowerCase
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearLotTypesCache() {
|
function clearLotTypesCache(): void {
|
||||||
lotTypes = undefined;
|
lotTypes = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Occupancy Types
|
* Occupancy Types
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let occupancyTypes: recordTypes.OccupancyType[] | undefined;
|
let occupancyTypes: recordTypes.OccupancyType[] | undefined
|
||||||
let allOccupancyTypeFields: recordTypes.OccupancyTypeField[] | undefined;
|
let allOccupancyTypeFields: recordTypes.OccupancyTypeField[] | undefined
|
||||||
|
|
||||||
export function getOccupancyTypes() {
|
export function getOccupancyTypes(): recordTypes.OccupancyType[] {
|
||||||
if (!occupancyTypes) {
|
if (!occupancyTypes) {
|
||||||
occupancyTypes = getOccupancyTypesFromDatabase();
|
occupancyTypes = getOccupancyTypesFromDatabase()
|
||||||
}
|
}
|
||||||
|
|
||||||
return occupancyTypes;
|
return occupancyTypes
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAllOccupancyTypeFields() {
|
export function getAllOccupancyTypeFields(): recordTypes.OccupancyTypeField[] {
|
||||||
if (!allOccupancyTypeFields) {
|
if (!allOccupancyTypeFields) {
|
||||||
allOccupancyTypeFields = getOccupancyTypeFieldsFromDatabase();
|
allOccupancyTypeFields = getOccupancyTypeFieldsFromDatabase()
|
||||||
}
|
}
|
||||||
return allOccupancyTypeFields;
|
return allOccupancyTypeFields
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getOccupancyTypeById(occupancyTypeId: number) {
|
export function getOccupancyTypeById(
|
||||||
const cachedOccupancyTypes = getOccupancyTypes();
|
occupancyTypeId: number
|
||||||
|
): recordTypes.OccupancyType | undefined {
|
||||||
|
const cachedOccupancyTypes = getOccupancyTypes()
|
||||||
|
|
||||||
return cachedOccupancyTypes.find((currentOccupancyType) => {
|
return cachedOccupancyTypes.find((currentOccupancyType) => {
|
||||||
return currentOccupancyType.occupancyTypeId === occupancyTypeId;
|
return currentOccupancyType.occupancyTypeId === occupancyTypeId
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getOccupancyTypeByOccupancyType(occupancyTypeString: string) {
|
export function getOccupancyTypeByOccupancyType(
|
||||||
const cachedOccupancyTypes = getOccupancyTypes();
|
occupancyTypeString: string
|
||||||
|
): recordTypes.OccupancyType | undefined {
|
||||||
|
const cachedOccupancyTypes = getOccupancyTypes()
|
||||||
|
|
||||||
const occupancyTypeLowerCase = occupancyTypeString.toLowerCase();
|
const occupancyTypeLowerCase = occupancyTypeString.toLowerCase()
|
||||||
|
|
||||||
return cachedOccupancyTypes.find((currentOccupancyType) => {
|
return cachedOccupancyTypes.find((currentOccupancyType) => {
|
||||||
return currentOccupancyType.occupancyType.toLowerCase() === occupancyTypeLowerCase;
|
return (
|
||||||
});
|
currentOccupancyType.occupancyType.toLowerCase() ===
|
||||||
|
occupancyTypeLowerCase
|
||||||
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getOccupancyTypePrintsById(occupancyTypeId: number): string[] {
|
export function getOccupancyTypePrintsById(occupancyTypeId: number): string[] {
|
||||||
const occupancyType = getOccupancyTypeById(occupancyTypeId);
|
const occupancyType = getOccupancyTypeById(occupancyTypeId)
|
||||||
|
|
||||||
if (!occupancyType || occupancyType.occupancyTypePrints.length === 0) {
|
if (
|
||||||
return [];
|
!occupancyType ||
|
||||||
|
(occupancyType.occupancyTypePrints ?? []).length === 0
|
||||||
|
) {
|
||||||
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
if (occupancyType.occupancyTypePrints.includes("*")) {
|
if (occupancyType.occupancyTypePrints!.includes('*')) {
|
||||||
return configFunctions.getProperty("settings.lotOccupancy.prints");
|
return configFunctions.getProperty('settings.lotOccupancy.prints')
|
||||||
}
|
}
|
||||||
|
|
||||||
return occupancyType.occupancyTypePrints;
|
return occupancyType.occupancyTypePrints!
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearOccupancyTypesCache() {
|
function clearOccupancyTypesCache(): void {
|
||||||
occupancyTypes = undefined;
|
occupancyTypes = undefined
|
||||||
allOccupancyTypeFields = undefined;
|
allOccupancyTypeFields = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Work Order Types
|
* Work Order Types
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let workOrderTypes: recordTypes.WorkOrderType[] | undefined;
|
let workOrderTypes: recordTypes.WorkOrderType[] | undefined
|
||||||
|
|
||||||
export function getWorkOrderTypes() {
|
export function getWorkOrderTypes(): recordTypes.WorkOrderType[] {
|
||||||
if (!workOrderTypes) {
|
if (!workOrderTypes) {
|
||||||
workOrderTypes = getWorkOrderTypesFromDatabase();
|
workOrderTypes = getWorkOrderTypesFromDatabase()
|
||||||
}
|
}
|
||||||
|
|
||||||
return workOrderTypes;
|
return workOrderTypes
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getWorkOrderTypeById(workOrderTypeId: number) {
|
export function getWorkOrderTypeById(
|
||||||
const cachedWorkOrderTypes = getWorkOrderTypes();
|
workOrderTypeId: number
|
||||||
|
): recordTypes.WorkOrderType | undefined {
|
||||||
|
const cachedWorkOrderTypes = getWorkOrderTypes()
|
||||||
|
|
||||||
return cachedWorkOrderTypes.find((currentWorkOrderType) => {
|
return cachedWorkOrderTypes.find((currentWorkOrderType) => {
|
||||||
return currentWorkOrderType.workOrderTypeId === workOrderTypeId;
|
return currentWorkOrderType.workOrderTypeId === workOrderTypeId
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearWorkOrderTypesCache() {
|
function clearWorkOrderTypesCache(): void {
|
||||||
workOrderTypes = undefined;
|
workOrderTypes = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Work Order Milestone Types
|
* Work Order Milestone Types
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let workOrderMilestoneTypes: recordTypes.WorkOrderMilestoneType[] | undefined;
|
let workOrderMilestoneTypes: recordTypes.WorkOrderMilestoneType[] | undefined
|
||||||
|
|
||||||
export function getWorkOrderMilestoneTypes() {
|
export function getWorkOrderMilestoneTypes(): recordTypes.WorkOrderMilestoneType[] {
|
||||||
if (!workOrderMilestoneTypes) {
|
if (!workOrderMilestoneTypes) {
|
||||||
workOrderMilestoneTypes = getWorkOrderMilestoneTypesFromDatabase();
|
workOrderMilestoneTypes = getWorkOrderMilestoneTypesFromDatabase()
|
||||||
}
|
}
|
||||||
|
|
||||||
return workOrderMilestoneTypes;
|
return workOrderMilestoneTypes
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getWorkOrderMilestoneTypeByWorkOrderMilestoneTypeId(workOrderMilestoneTypeId: number) {
|
export function getWorkOrderMilestoneTypeByWorkOrderMilestoneTypeId(
|
||||||
const cachedWorkOrderMilestoneTypes = getWorkOrderMilestoneTypes();
|
workOrderMilestoneTypeId: number
|
||||||
|
): recordTypes.WorkOrderMilestoneType | undefined {
|
||||||
|
const cachedWorkOrderMilestoneTypes = getWorkOrderMilestoneTypes()
|
||||||
|
|
||||||
return cachedWorkOrderMilestoneTypes.find((currentWorkOrderMilestoneType) => {
|
return cachedWorkOrderMilestoneTypes.find((currentWorkOrderMilestoneType) => {
|
||||||
return currentWorkOrderMilestoneType.workOrderMilestoneTypeId === workOrderMilestoneTypeId;
|
return (
|
||||||
});
|
currentWorkOrderMilestoneType.workOrderMilestoneTypeId ===
|
||||||
|
workOrderMilestoneTypeId
|
||||||
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getWorkOrderMilestoneTypeByWorkOrderMilestoneType(workOrderMilestoneTypeString: string) {
|
export function getWorkOrderMilestoneTypeByWorkOrderMilestoneType(
|
||||||
const cachedWorkOrderMilestoneTypes = getWorkOrderMilestoneTypes();
|
workOrderMilestoneTypeString: string
|
||||||
|
): recordTypes.WorkOrderMilestoneType | undefined {
|
||||||
|
const cachedWorkOrderMilestoneTypes = getWorkOrderMilestoneTypes()
|
||||||
|
|
||||||
const workOrderMilestoneTypeLowerCase = workOrderMilestoneTypeString.toLowerCase();
|
const workOrderMilestoneTypeLowerCase =
|
||||||
|
workOrderMilestoneTypeString.toLowerCase()
|
||||||
|
|
||||||
return cachedWorkOrderMilestoneTypes.find((currentWorkOrderMilestoneType) => {
|
return cachedWorkOrderMilestoneTypes.find((currentWorkOrderMilestoneType) => {
|
||||||
return (
|
return (
|
||||||
currentWorkOrderMilestoneType.workOrderMilestoneType.toLowerCase() ===
|
currentWorkOrderMilestoneType.workOrderMilestoneType.toLowerCase() ===
|
||||||
workOrderMilestoneTypeLowerCase
|
workOrderMilestoneTypeLowerCase
|
||||||
);
|
)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearWorkOrderMilestoneTypesCache() {
|
function clearWorkOrderMilestoneTypesCache(): void {
|
||||||
workOrderMilestoneTypes = undefined;
|
workOrderMilestoneTypes = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
export function clearCacheByTableName(tableName: string) {
|
export function clearCacheByTableName(tableName: string): void {
|
||||||
switch (tableName) {
|
switch (tableName) {
|
||||||
case "LotOccupantTypes": {
|
case 'LotOccupantTypes': {
|
||||||
clearLotOccupantTypesCache();
|
clearLotOccupantTypesCache()
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
case "LotStatuses": {
|
case 'LotStatuses': {
|
||||||
clearLotStatusesCache();
|
clearLotStatusesCache()
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
case "LotTypes":
|
case 'LotTypes':
|
||||||
case "LotTypeFields": {
|
case 'LotTypeFields': {
|
||||||
clearLotTypesCache();
|
clearLotTypesCache()
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
case "OccupancyTypes":
|
case 'OccupancyTypes':
|
||||||
case "OccupancyTypeFields":
|
case 'OccupancyTypeFields':
|
||||||
case "OccupancyTypePrints": {
|
case 'OccupancyTypePrints': {
|
||||||
clearOccupancyTypesCache();
|
clearOccupancyTypesCache()
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
case "WorkOrderMilestoneTypes": {
|
case 'WorkOrderMilestoneTypes': {
|
||||||
clearWorkOrderMilestoneTypesCache();
|
clearWorkOrderMilestoneTypesCache()
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
case "WorkOrderTypes": {
|
case 'WorkOrderTypes': {
|
||||||
clearWorkOrderTypesCache();
|
clearWorkOrderTypesCache()
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import faIcons from "font-awesome-v5-icons";
|
import faIcons from 'font-awesome-v5-icons';
|
||||||
let solidIcons = [];
|
let solidIcons = [];
|
||||||
export async function getSolidIconClasses() {
|
export async function getSolidIconClasses() {
|
||||||
if (solidIcons.length === 0) {
|
if (solidIcons.length === 0) {
|
||||||
const allIcons = await faIcons.getListByKeys(["name", "styles"]);
|
const allIcons = await faIcons.getListByKeys(['name', 'styles']);
|
||||||
const list = [];
|
const list = [];
|
||||||
for (const icon of allIcons) {
|
for (const icon of allIcons) {
|
||||||
if (icon.styles.includes("solid")) {
|
if ((icon.styles ?? []).includes('solid')) {
|
||||||
list.push(icon.name);
|
list.push(icon.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
import faIcons from "font-awesome-v5-icons";
|
import faIcons from 'font-awesome-v5-icons'
|
||||||
|
|
||||||
let solidIcons: string[] = [];
|
let solidIcons: string[] = []
|
||||||
|
|
||||||
export async function getSolidIconClasses() {
|
export async function getSolidIconClasses(): Promise<string[]> {
|
||||||
if (solidIcons.length === 0) {
|
if (solidIcons.length === 0) {
|
||||||
const allIcons = await faIcons.getListByKeys(["name", "styles"]);
|
const allIcons = await faIcons.getListByKeys(['name', 'styles'])
|
||||||
|
|
||||||
const list: string[] = [];
|
const list: string[] = []
|
||||||
|
|
||||||
for (const icon of allIcons) {
|
for (const icon of allIcons) {
|
||||||
if (icon.styles.includes("solid")) {
|
if ((icon.styles ?? []).includes('solid')) {
|
||||||
list.push(icon.name);
|
list.push(icon.name!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
solidIcons = list;
|
solidIcons = list
|
||||||
}
|
}
|
||||||
|
|
||||||
return solidIcons;
|
return solidIcons
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,10 @@
|
||||||
declare type LotNameSearchType = "startsWith" | "endsWith" | "";
|
declare type LotNameSearchType = 'startsWith' | 'endsWith' | '';
|
||||||
export declare function getLotNameWhereClause(lotName: string, lotNameSearchType: LotNameSearchType, lotsTableAlias?: string): {
|
interface WhereClauseReturn {
|
||||||
sqlWhereClause: string;
|
sqlWhereClause: string;
|
||||||
sqlParameters: any[];
|
sqlParameters: unknown[];
|
||||||
};
|
}
|
||||||
declare type OccupancyTime = "" | "current" | "past" | "future";
|
export declare function getLotNameWhereClause(lotName: string, lotNameSearchType: LotNameSearchType, lotsTableAlias?: string): WhereClauseReturn;
|
||||||
export declare function getOccupancyTimeWhereClause(occupancyTime: OccupancyTime, lotOccupanciesTableAlias?: string): {
|
declare type OccupancyTime = '' | 'current' | 'past' | 'future';
|
||||||
sqlWhereClause: string;
|
export declare function getOccupancyTimeWhereClause(occupancyTime: OccupancyTime, lotOccupanciesTableAlias?: string): WhereClauseReturn;
|
||||||
sqlParameters: any[];
|
export declare function getOccupantNameWhereClause(occupantName: string, tableAlias?: string): WhereClauseReturn;
|
||||||
};
|
|
||||||
export declare function getOccupantNameWhereClause(occupantName: string, tableAlias?: string): {
|
|
||||||
sqlWhereClause: string;
|
|
||||||
sqlParameters: any[];
|
|
||||||
};
|
|
||||||
export {};
|
export {};
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,24 @@
|
||||||
import { dateToInteger } from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
import { dateToInteger } from '@cityssm/expressjs-server-js/dateTimeFns.js';
|
||||||
export function getLotNameWhereClause(lotName, lotNameSearchType, lotsTableAlias = "l") {
|
export function getLotNameWhereClause(lotName, lotNameSearchType, lotsTableAlias = 'l') {
|
||||||
let sqlWhereClause = "";
|
let sqlWhereClause = '';
|
||||||
const sqlParameters = [];
|
const sqlParameters = [];
|
||||||
if (lotName) {
|
if (lotName !== '') {
|
||||||
switch (lotNameSearchType) {
|
switch (lotNameSearchType) {
|
||||||
case "startsWith": {
|
case 'startsWith': {
|
||||||
sqlWhereClause += " and " + lotsTableAlias + ".lotName like ? || '%'";
|
sqlWhereClause += ' and ' + lotsTableAlias + ".lotName like ? || '%'";
|
||||||
sqlParameters.push(lotName);
|
sqlParameters.push(lotName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "endsWith": {
|
case 'endsWith': {
|
||||||
sqlWhereClause += " and " + lotsTableAlias + ".lotName like '%' || ?";
|
sqlWhereClause += ' and ' + lotsTableAlias + ".lotName like '%' || ?";
|
||||||
sqlParameters.push(lotName);
|
sqlParameters.push(lotName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
const lotNamePieces = lotName.toLowerCase().split(" ");
|
const lotNamePieces = lotName.toLowerCase().split(' ');
|
||||||
for (const lotNamePiece of lotNamePieces) {
|
for (const lotNamePiece of lotNamePieces) {
|
||||||
sqlWhereClause += " and instr(lower(" + lotsTableAlias + ".lotName), ?)";
|
sqlWhereClause +=
|
||||||
|
' and instr(lower(' + lotsTableAlias + '.lotName), ?)';
|
||||||
sqlParameters.push(lotNamePiece);
|
sqlParameters.push(lotNamePiece);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -28,31 +29,33 @@ export function getLotNameWhereClause(lotName, lotNameSearchType, lotsTableAlias
|
||||||
sqlParameters
|
sqlParameters
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
export function getOccupancyTimeWhereClause(occupancyTime, lotOccupanciesTableAlias = "o") {
|
export function getOccupancyTimeWhereClause(occupancyTime, lotOccupanciesTableAlias = 'o') {
|
||||||
let sqlWhereClause = "";
|
let sqlWhereClause = '';
|
||||||
const sqlParameters = [];
|
const sqlParameters = [];
|
||||||
if (occupancyTime) {
|
if (occupancyTime !== '') {
|
||||||
const currentDateString = dateToInteger(new Date());
|
const currentDateString = dateToInteger(new Date());
|
||||||
switch (occupancyTime) {
|
switch (occupancyTime) {
|
||||||
case "current": {
|
case 'current': {
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
" and " +
|
' and ' +
|
||||||
lotOccupanciesTableAlias +
|
lotOccupanciesTableAlias +
|
||||||
".occupancyStartDate <= ? and (" +
|
'.occupancyStartDate <= ? and (' +
|
||||||
lotOccupanciesTableAlias +
|
lotOccupanciesTableAlias +
|
||||||
".occupancyEndDate is null or " +
|
'.occupancyEndDate is null or ' +
|
||||||
lotOccupanciesTableAlias +
|
lotOccupanciesTableAlias +
|
||||||
".occupancyEndDate >= ?)";
|
'.occupancyEndDate >= ?)';
|
||||||
sqlParameters.push(currentDateString, currentDateString);
|
sqlParameters.push(currentDateString, currentDateString);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "past": {
|
case 'past': {
|
||||||
sqlWhereClause += " and " + lotOccupanciesTableAlias + ".occupancyEndDate < ?";
|
sqlWhereClause +=
|
||||||
|
' and ' + lotOccupanciesTableAlias + '.occupancyEndDate < ?';
|
||||||
sqlParameters.push(currentDateString);
|
sqlParameters.push(currentDateString);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "future": {
|
case 'future': {
|
||||||
sqlWhereClause += " and " + lotOccupanciesTableAlias + ".occupancyStartDate > ?";
|
sqlWhereClause +=
|
||||||
|
' and ' + lotOccupanciesTableAlias + '.occupancyStartDate > ?';
|
||||||
sqlParameters.push(currentDateString);
|
sqlParameters.push(currentDateString);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -63,13 +66,13 @@ export function getOccupancyTimeWhereClause(occupancyTime, lotOccupanciesTableAl
|
||||||
sqlParameters
|
sqlParameters
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
export function getOccupantNameWhereClause(occupantName, tableAlias = "o") {
|
export function getOccupantNameWhereClause(occupantName, tableAlias = 'o') {
|
||||||
let sqlWhereClause = "";
|
let sqlWhereClause = '';
|
||||||
const sqlParameters = [];
|
const sqlParameters = [];
|
||||||
if (occupantName) {
|
if (occupantName !== '') {
|
||||||
const occupantNamePieces = occupantName.toLowerCase().split(" ");
|
const occupantNamePieces = occupantName.toLowerCase().split(' ');
|
||||||
for (const occupantNamePiece of occupantNamePieces) {
|
for (const occupantNamePiece of occupantNamePieces) {
|
||||||
sqlWhereClause += " and instr(lower(" + tableAlias + ".occupantName), ?)";
|
sqlWhereClause += ' and instr(lower(' + tableAlias + '.occupantName), ?)';
|
||||||
sqlParameters.push(occupantNamePiece);
|
sqlParameters.push(occupantNamePiece);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,38 @@
|
||||||
import { dateToInteger } from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
import { dateToInteger } from '@cityssm/expressjs-server-js/dateTimeFns.js'
|
||||||
|
|
||||||
type LotNameSearchType = "startsWith" | "endsWith" | "";
|
type LotNameSearchType = 'startsWith' | 'endsWith' | ''
|
||||||
|
|
||||||
|
interface WhereClauseReturn {
|
||||||
|
sqlWhereClause: string
|
||||||
|
sqlParameters: unknown[]
|
||||||
|
}
|
||||||
|
|
||||||
export function getLotNameWhereClause(
|
export function getLotNameWhereClause(
|
||||||
lotName: string,
|
lotName: string,
|
||||||
lotNameSearchType: LotNameSearchType,
|
lotNameSearchType: LotNameSearchType,
|
||||||
lotsTableAlias = "l"
|
lotsTableAlias = 'l'
|
||||||
) {
|
): WhereClauseReturn {
|
||||||
let sqlWhereClause = "";
|
let sqlWhereClause = ''
|
||||||
const sqlParameters = [];
|
const sqlParameters: unknown[] = []
|
||||||
|
|
||||||
if (lotName) {
|
if (lotName !== '') {
|
||||||
switch (lotNameSearchType) {
|
switch (lotNameSearchType) {
|
||||||
case "startsWith": {
|
case 'startsWith': {
|
||||||
sqlWhereClause += " and " + lotsTableAlias + ".lotName like ? || '%'";
|
sqlWhereClause += ' and ' + lotsTableAlias + ".lotName like ? || '%'"
|
||||||
sqlParameters.push(lotName);
|
sqlParameters.push(lotName)
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
case "endsWith": {
|
case 'endsWith': {
|
||||||
sqlWhereClause += " and " + lotsTableAlias + ".lotName like '%' || ?";
|
sqlWhereClause += ' and ' + lotsTableAlias + ".lotName like '%' || ?"
|
||||||
sqlParameters.push(lotName);
|
sqlParameters.push(lotName)
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
const lotNamePieces = lotName.toLowerCase().split(" ");
|
const lotNamePieces = lotName.toLowerCase().split(' ')
|
||||||
for (const lotNamePiece of lotNamePieces) {
|
for (const lotNamePiece of lotNamePieces) {
|
||||||
sqlWhereClause += " and instr(lower(" + lotsTableAlias + ".lotName), ?)";
|
sqlWhereClause +=
|
||||||
sqlParameters.push(lotNamePiece);
|
' and instr(lower(' + lotsTableAlias + '.lotName), ?)'
|
||||||
|
sqlParameters.push(lotNamePiece)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -35,45 +41,47 @@ export function getLotNameWhereClause(
|
||||||
return {
|
return {
|
||||||
sqlWhereClause,
|
sqlWhereClause,
|
||||||
sqlParameters
|
sqlParameters
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type OccupancyTime = "" | "current" | "past" | "future";
|
type OccupancyTime = '' | 'current' | 'past' | 'future'
|
||||||
|
|
||||||
export function getOccupancyTimeWhereClause(
|
export function getOccupancyTimeWhereClause(
|
||||||
occupancyTime: OccupancyTime,
|
occupancyTime: OccupancyTime,
|
||||||
lotOccupanciesTableAlias = "o"
|
lotOccupanciesTableAlias = 'o'
|
||||||
) {
|
): WhereClauseReturn {
|
||||||
let sqlWhereClause = "";
|
let sqlWhereClause = ''
|
||||||
const sqlParameters = [];
|
const sqlParameters: unknown[] = []
|
||||||
|
|
||||||
if (occupancyTime) {
|
if (occupancyTime !== '') {
|
||||||
const currentDateString = dateToInteger(new Date());
|
const currentDateString = dateToInteger(new Date())
|
||||||
|
|
||||||
switch (occupancyTime) {
|
switch (occupancyTime) {
|
||||||
case "current": {
|
case 'current': {
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
" and " +
|
' and ' +
|
||||||
lotOccupanciesTableAlias +
|
lotOccupanciesTableAlias +
|
||||||
".occupancyStartDate <= ? and (" +
|
'.occupancyStartDate <= ? and (' +
|
||||||
lotOccupanciesTableAlias +
|
lotOccupanciesTableAlias +
|
||||||
".occupancyEndDate is null or " +
|
'.occupancyEndDate is null or ' +
|
||||||
lotOccupanciesTableAlias +
|
lotOccupanciesTableAlias +
|
||||||
".occupancyEndDate >= ?)";
|
'.occupancyEndDate >= ?)'
|
||||||
sqlParameters.push(currentDateString, currentDateString);
|
sqlParameters.push(currentDateString, currentDateString)
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
case "past": {
|
case 'past': {
|
||||||
sqlWhereClause += " and " + lotOccupanciesTableAlias + ".occupancyEndDate < ?";
|
sqlWhereClause +=
|
||||||
sqlParameters.push(currentDateString);
|
' and ' + lotOccupanciesTableAlias + '.occupancyEndDate < ?'
|
||||||
break;
|
sqlParameters.push(currentDateString)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
case "future": {
|
case 'future': {
|
||||||
sqlWhereClause += " and " + lotOccupanciesTableAlias + ".occupancyStartDate > ?";
|
sqlWhereClause +=
|
||||||
sqlParameters.push(currentDateString);
|
' and ' + lotOccupanciesTableAlias + '.occupancyStartDate > ?'
|
||||||
break;
|
sqlParameters.push(currentDateString)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -81,23 +89,26 @@ export function getOccupancyTimeWhereClause(
|
||||||
return {
|
return {
|
||||||
sqlWhereClause,
|
sqlWhereClause,
|
||||||
sqlParameters
|
sqlParameters
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getOccupantNameWhereClause(occupantName: string, tableAlias = "o") {
|
export function getOccupantNameWhereClause(
|
||||||
let sqlWhereClause = "";
|
occupantName: string,
|
||||||
const sqlParameters = [];
|
tableAlias = 'o'
|
||||||
|
): WhereClauseReturn {
|
||||||
|
let sqlWhereClause = ''
|
||||||
|
const sqlParameters: unknown[] = []
|
||||||
|
|
||||||
if (occupantName) {
|
if (occupantName !== '') {
|
||||||
const occupantNamePieces = occupantName.toLowerCase().split(" ");
|
const occupantNamePieces = occupantName.toLowerCase().split(' ')
|
||||||
for (const occupantNamePiece of occupantNamePieces) {
|
for (const occupantNamePiece of occupantNamePieces) {
|
||||||
sqlWhereClause += " and instr(lower(" + tableAlias + ".occupantName), ?)";
|
sqlWhereClause += ' and instr(lower(' + tableAlias + '.occupantName), ?)'
|
||||||
sqlParameters.push(occupantNamePiece);
|
sqlParameters.push(occupantNamePiece)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sqlWhereClause,
|
sqlWhereClause,
|
||||||
sqlParameters
|
sqlParameters
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,21 @@
|
||||||
import { getUserNameFromApiKey } from "./functions.api.js";
|
import { getUserNameFromApiKey } from "./functions.api.js";
|
||||||
import * as configFunctions from "./functions.config.js";
|
import * as configFunctions from "./functions.config.js";
|
||||||
export function userIsAdmin(request) {
|
export function userIsAdmin(request) {
|
||||||
var _a;
|
const user = request.session?.user;
|
||||||
const user = (_a = request.session) === null || _a === void 0 ? void 0 : _a.user;
|
|
||||||
if (!user || !user.userProperties) {
|
if (!user || !user.userProperties) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return user.userProperties.isAdmin;
|
return user.userProperties.isAdmin;
|
||||||
}
|
}
|
||||||
export function userCanUpdate(request) {
|
export function userCanUpdate(request) {
|
||||||
var _a;
|
const user = request.session?.user;
|
||||||
const user = (_a = request.session) === null || _a === void 0 ? void 0 : _a.user;
|
|
||||||
if (!user || !user.userProperties) {
|
if (!user || !user.userProperties) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return user.userProperties.canUpdate;
|
return user.userProperties.canUpdate;
|
||||||
}
|
}
|
||||||
export async function apiKeyIsValid(request) {
|
export async function apiKeyIsValid(request) {
|
||||||
var _a;
|
const apiKey = request.params?.apiKey;
|
||||||
const apiKey = (_a = request.params) === null || _a === void 0 ? void 0 : _a.apiKey;
|
|
||||||
if (!apiKey) {
|
if (!apiKey) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes';
|
||||||
interface AddFeeForm {
|
interface AddFeeForm {
|
||||||
feeCategoryId: string;
|
feeCategoryId: string;
|
||||||
feeName: string;
|
feeName: string;
|
||||||
|
|
@ -9,9 +9,9 @@ interface AddFeeForm {
|
||||||
feeFunction?: string;
|
feeFunction?: string;
|
||||||
taxAmount?: string;
|
taxAmount?: string;
|
||||||
taxPercentage?: string;
|
taxPercentage?: string;
|
||||||
includeQuantity: "" | "1";
|
includeQuantity: '' | '1';
|
||||||
quantityUnit?: string;
|
quantityUnit?: string;
|
||||||
isRequired: "" | "1";
|
isRequired: '' | '1';
|
||||||
orderNumber?: number;
|
orderNumber?: number;
|
||||||
}
|
}
|
||||||
export declare function addFee(feeForm: AddFeeForm, requestSession: recordTypes.PartialSession): number;
|
export declare function addFee(feeForm: AddFeeForm, requestSession: recordTypes.PartialSession): number;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3';
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||||
export function addFee(feeForm, requestSession) {
|
export function addFee(feeForm, requestSession) {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
|
@ -15,7 +15,7 @@ export function addFee(feeForm, requestSession) {
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(feeForm.feeCategoryId, feeForm.feeName, feeForm.feeDescription, feeForm.occupancyTypeId || undefined, feeForm.lotTypeId || undefined, feeForm.feeAmount || undefined, feeForm.feeFunction || undefined, feeForm.taxAmount || undefined, feeForm.taxPercentage || undefined, feeForm.includeQuantity ? 1 : 0, feeForm.quantityUnit, feeForm.isRequired ? 1 : 0, feeForm.orderNumber || -1, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
.run(feeForm.feeCategoryId, feeForm.feeName, feeForm.feeDescription, feeForm.occupancyTypeId ?? undefined, feeForm.lotTypeId ?? undefined, 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, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||||
database.close();
|
database.close();
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,33 @@
|
||||||
import sqlite from "better-sqlite3";
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import sqlite from 'better-sqlite3'
|
||||||
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||||
|
|
||||||
|
import type * as recordTypes from '../../types/recordTypes'
|
||||||
|
|
||||||
interface AddFeeForm {
|
interface AddFeeForm {
|
||||||
feeCategoryId: string;
|
feeCategoryId: string
|
||||||
feeName: string;
|
feeName: string
|
||||||
feeDescription: string;
|
feeDescription: string
|
||||||
occupancyTypeId?: string;
|
occupancyTypeId?: string
|
||||||
lotTypeId?: string;
|
lotTypeId?: string
|
||||||
feeAmount?: string;
|
feeAmount?: string
|
||||||
feeFunction?: string;
|
feeFunction?: string
|
||||||
taxAmount?: string;
|
taxAmount?: string
|
||||||
taxPercentage?: string;
|
taxPercentage?: string
|
||||||
includeQuantity: "" | "1";
|
includeQuantity: '' | '1'
|
||||||
quantityUnit?: string;
|
quantityUnit?: string
|
||||||
isRequired: "" | "1";
|
isRequired: '' | '1'
|
||||||
orderNumber?: number;
|
orderNumber?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addFee(feeForm: AddFeeForm, requestSession: recordTypes.PartialSession): number {
|
export function addFee(
|
||||||
const database = sqlite(databasePath);
|
feeForm: AddFeeForm,
|
||||||
|
requestSession: recordTypes.PartialSession
|
||||||
|
): number {
|
||||||
|
const database = sqlite(databasePath)
|
||||||
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(
|
.prepare(
|
||||||
|
|
@ -42,25 +47,25 @@ export function addFee(feeForm: AddFeeForm, requestSession: recordTypes.PartialS
|
||||||
feeForm.feeCategoryId,
|
feeForm.feeCategoryId,
|
||||||
feeForm.feeName,
|
feeForm.feeName,
|
||||||
feeForm.feeDescription,
|
feeForm.feeDescription,
|
||||||
feeForm.occupancyTypeId || undefined,
|
feeForm.occupancyTypeId ?? undefined,
|
||||||
feeForm.lotTypeId || undefined,
|
feeForm.lotTypeId ?? undefined,
|
||||||
feeForm.feeAmount || undefined,
|
feeForm.feeAmount ?? undefined,
|
||||||
feeForm.feeFunction || undefined,
|
feeForm.feeFunction ?? undefined,
|
||||||
feeForm.taxAmount || undefined,
|
feeForm.taxAmount ?? undefined,
|
||||||
feeForm.taxPercentage || undefined,
|
feeForm.taxPercentage ?? undefined,
|
||||||
feeForm.includeQuantity ? 1 : 0,
|
(feeForm.includeQuantity ?? '') === '' ? 0 : 1,
|
||||||
feeForm.quantityUnit,
|
feeForm.quantityUnit,
|
||||||
feeForm.isRequired ? 1 : 0,
|
(feeForm.isRequired ?? '') === '' ? 0 : 1,
|
||||||
feeForm.orderNumber || -1,
|
feeForm.orderNumber ?? -1,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
);
|
)
|
||||||
|
|
||||||
database.close();
|
database.close()
|
||||||
|
|
||||||
return result.lastInsertRowid as number;
|
return result.lastInsertRowid as number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default addFee;
|
export default addFee
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes';
|
||||||
interface AddLotForm {
|
interface AddLotForm {
|
||||||
lotName: string;
|
lotName: string;
|
||||||
lotTypeId: string | number;
|
lotTypeId: string | number;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3';
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||||
import { addOrUpdateLotField } from "./addOrUpdateLotField.js";
|
import { addOrUpdateLotField } from './addOrUpdateLotField.js';
|
||||||
export function addLot(lotForm, requestSession) {
|
export function addLot(lotForm, requestSession) {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
|
@ -12,12 +12,12 @@ export function addLot(lotForm, requestSession) {
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(lotForm.lotName, lotForm.lotTypeId, lotForm.lotStatusId === "" ? undefined : lotForm.lotStatusId, lotForm.mapId === "" ? undefined : lotForm.mapId, lotForm.mapKey, lotForm.lotLatitude === "" ? undefined : lotForm.lotLatitude, lotForm.lotLongitude === "" ? undefined : lotForm.lotLongitude, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
.run(lotForm.lotName, lotForm.lotTypeId, lotForm.lotStatusId === '' ? undefined : lotForm.lotStatusId, lotForm.mapId === '' ? undefined : lotForm.mapId, lotForm.mapKey, lotForm.lotLatitude === '' ? undefined : lotForm.lotLatitude, lotForm.lotLongitude === '' ? undefined : lotForm.lotLongitude, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||||
const lotId = result.lastInsertRowid;
|
const lotId = result.lastInsertRowid;
|
||||||
const lotTypeFieldIds = (lotForm.lotTypeFieldIds || "").split(",");
|
const lotTypeFieldIds = (lotForm.lotTypeFieldIds ?? '').split(',');
|
||||||
for (const lotTypeFieldId of lotTypeFieldIds) {
|
for (const lotTypeFieldId of lotTypeFieldIds) {
|
||||||
const lotFieldValue = lotForm["lotFieldValue_" + lotTypeFieldId];
|
const lotFieldValue = lotForm['lotFieldValue_' + lotTypeFieldId];
|
||||||
if (lotFieldValue && lotFieldValue !== "") {
|
if (lotFieldValue && lotFieldValue !== '') {
|
||||||
addOrUpdateLotField({
|
addOrUpdateLotField({
|
||||||
lotId,
|
lotId,
|
||||||
lotTypeFieldId,
|
lotTypeFieldId,
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,33 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3'
|
||||||
|
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||||
|
|
||||||
import { addOrUpdateLotField } from "./addOrUpdateLotField.js";
|
import { addOrUpdateLotField } from './addOrUpdateLotField.js'
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes'
|
||||||
|
|
||||||
interface AddLotForm {
|
interface AddLotForm {
|
||||||
lotName: string;
|
lotName: string
|
||||||
lotTypeId: string | number;
|
lotTypeId: string | number
|
||||||
lotStatusId: string | number;
|
lotStatusId: string | number
|
||||||
|
|
||||||
mapId: string | number;
|
mapId: string | number
|
||||||
mapKey: string;
|
mapKey: string
|
||||||
|
|
||||||
lotLatitude: string;
|
lotLatitude: string
|
||||||
lotLongitude: string;
|
lotLongitude: string
|
||||||
|
|
||||||
lotTypeFieldIds?: string;
|
lotTypeFieldIds?: string
|
||||||
[lotFieldValue_lotTypeFieldId: string]: unknown;
|
[lotFieldValue_lotTypeFieldId: string]: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addLot(lotForm: AddLotForm, requestSession: recordTypes.PartialSession): number {
|
export function addLot(
|
||||||
const database = sqlite(databasePath);
|
lotForm: AddLotForm,
|
||||||
|
requestSession: recordTypes.PartialSession
|
||||||
|
): number {
|
||||||
|
const database = sqlite(databasePath)
|
||||||
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(
|
.prepare(
|
||||||
|
|
@ -39,25 +42,25 @@ export function addLot(lotForm: AddLotForm, requestSession: recordTypes.PartialS
|
||||||
.run(
|
.run(
|
||||||
lotForm.lotName,
|
lotForm.lotName,
|
||||||
lotForm.lotTypeId,
|
lotForm.lotTypeId,
|
||||||
lotForm.lotStatusId === "" ? undefined : lotForm.lotStatusId,
|
lotForm.lotStatusId === '' ? undefined : lotForm.lotStatusId,
|
||||||
lotForm.mapId === "" ? undefined : lotForm.mapId,
|
lotForm.mapId === '' ? undefined : lotForm.mapId,
|
||||||
lotForm.mapKey,
|
lotForm.mapKey,
|
||||||
lotForm.lotLatitude === "" ? undefined : lotForm.lotLatitude,
|
lotForm.lotLatitude === '' ? undefined : lotForm.lotLatitude,
|
||||||
lotForm.lotLongitude === "" ? undefined : lotForm.lotLongitude,
|
lotForm.lotLongitude === '' ? undefined : lotForm.lotLongitude,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
);
|
)
|
||||||
|
|
||||||
const lotId = result.lastInsertRowid as number;
|
const lotId = result.lastInsertRowid as number
|
||||||
|
|
||||||
const lotTypeFieldIds = (lotForm.lotTypeFieldIds || "").split(",");
|
const lotTypeFieldIds = (lotForm.lotTypeFieldIds ?? '').split(',')
|
||||||
|
|
||||||
for (const lotTypeFieldId of lotTypeFieldIds) {
|
for (const lotTypeFieldId of lotTypeFieldIds) {
|
||||||
const lotFieldValue = lotForm["lotFieldValue_" + lotTypeFieldId] as string;
|
const lotFieldValue = lotForm['lotFieldValue_' + lotTypeFieldId] as string
|
||||||
|
|
||||||
if (lotFieldValue && lotFieldValue !== "") {
|
if (lotFieldValue && lotFieldValue !== '') {
|
||||||
addOrUpdateLotField(
|
addOrUpdateLotField(
|
||||||
{
|
{
|
||||||
lotId,
|
lotId,
|
||||||
|
|
@ -66,13 +69,13 @@ export function addLot(lotForm: AddLotForm, requestSession: recordTypes.PartialS
|
||||||
},
|
},
|
||||||
requestSession,
|
requestSession,
|
||||||
database
|
database
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
database.close();
|
database.close()
|
||||||
|
|
||||||
return lotId;
|
return lotId
|
||||||
}
|
}
|
||||||
|
|
||||||
export default addLot;
|
export default addLot
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes';
|
||||||
interface AddLotCommentForm {
|
interface AddLotCommentForm {
|
||||||
lotId: string;
|
lotId: string;
|
||||||
lotComment: string;
|
lotComment: string;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3';
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||||
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
import * as dateTimeFunctions from '@cityssm/expressjs-server-js/dateTimeFns.js';
|
||||||
export function addLotComment(lotCommentForm, requestSession) {
|
export function addLotComment(lotCommentForm, requestSession) {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
const rightNow = new Date();
|
const rightNow = new Date();
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,23 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3'
|
||||||
|
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||||
|
|
||||||
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
import * as dateTimeFunctions from '@cityssm/expressjs-server-js/dateTimeFns.js'
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes'
|
||||||
|
|
||||||
interface AddLotCommentForm {
|
interface AddLotCommentForm {
|
||||||
lotId: string;
|
lotId: string
|
||||||
lotComment: string;
|
lotComment: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addLotComment(
|
export function addLotComment(
|
||||||
lotCommentForm: AddLotCommentForm,
|
lotCommentForm: AddLotCommentForm,
|
||||||
requestSession: recordTypes.PartialSession
|
requestSession: recordTypes.PartialSession
|
||||||
): number {
|
): number {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath)
|
||||||
|
|
||||||
const rightNow = new Date();
|
const rightNow = new Date()
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(
|
.prepare(
|
||||||
|
|
@ -33,15 +33,15 @@ export function addLotComment(
|
||||||
dateTimeFunctions.dateToInteger(rightNow),
|
dateTimeFunctions.dateToInteger(rightNow),
|
||||||
dateTimeFunctions.dateToTimeInteger(rightNow),
|
dateTimeFunctions.dateToTimeInteger(rightNow),
|
||||||
lotCommentForm.lotComment,
|
lotCommentForm.lotComment,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNow.getTime(),
|
rightNow.getTime(),
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNow.getTime()
|
rightNow.getTime()
|
||||||
);
|
)
|
||||||
|
|
||||||
database.close();
|
database.close()
|
||||||
|
|
||||||
return result.lastInsertRowid as number;
|
return result.lastInsertRowid as number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default addLotComment;
|
export default addLotComment
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3';
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes';
|
||||||
interface AddLotOccupancyForm {
|
interface AddLotOccupancyForm {
|
||||||
occupancyTypeId: string | number;
|
occupancyTypeId: string | number;
|
||||||
lotId: string | number;
|
lotId: string | number;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3';
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||||
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
import * as dateTimeFunctions from '@cityssm/expressjs-server-js/dateTimeFns.js';
|
||||||
import { addOrUpdateLotOccupancyField } from "./addOrUpdateLotOccupancyField.js";
|
import { addOrUpdateLotOccupancyField } from './addOrUpdateLotOccupancyField.js';
|
||||||
import { addLotOccupancyOccupant } from "./addLotOccupancyOccupant.js";
|
import { addLotOccupancyOccupant } from './addLotOccupancyOccupant.js';
|
||||||
export function addLotOccupancy(lotOccupancyForm, requestSession, connectedDatabase) {
|
export function addLotOccupancy(lotOccupancyForm, requestSession, connectedDatabase) {
|
||||||
const database = connectedDatabase || sqlite(databasePath);
|
const database = connectedDatabase ?? sqlite(databasePath);
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const occupancyStartDate = dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyStartDateString);
|
const occupancyStartDate = dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyStartDateString);
|
||||||
if (occupancyStartDate <= 0) {
|
if (occupancyStartDate <= 0) {
|
||||||
|
|
@ -17,14 +17,14 @@ export function addLotOccupancy(lotOccupancyForm, requestSession, connectedDatab
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(lotOccupancyForm.occupancyTypeId, lotOccupancyForm.lotId === "" ? undefined : lotOccupancyForm.lotId, occupancyStartDate, lotOccupancyForm.occupancyEndDateString === ""
|
.run(lotOccupancyForm.occupancyTypeId, lotOccupancyForm.lotId === '' ? undefined : lotOccupancyForm.lotId, occupancyStartDate, lotOccupancyForm.occupancyEndDateString === ''
|
||||||
? undefined
|
? undefined
|
||||||
: dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyEndDateString), requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
: dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyEndDateString), requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||||
const lotOccupancyId = result.lastInsertRowid;
|
const lotOccupancyId = result.lastInsertRowid;
|
||||||
const occupancyTypeFieldIds = (lotOccupancyForm.occupancyTypeFieldIds || "").split(",");
|
const occupancyTypeFieldIds = (lotOccupancyForm.occupancyTypeFieldIds ?? '').split(',');
|
||||||
for (const occupancyTypeFieldId of occupancyTypeFieldIds) {
|
for (const occupancyTypeFieldId of occupancyTypeFieldIds) {
|
||||||
const lotOccupancyFieldValue = lotOccupancyForm["lotOccupancyFieldValue_" + occupancyTypeFieldId];
|
const lotOccupancyFieldValue = lotOccupancyForm['lotOccupancyFieldValue_' + occupancyTypeFieldId];
|
||||||
if (lotOccupancyFieldValue && lotOccupancyFieldValue !== "") {
|
if (lotOccupancyFieldValue && lotOccupancyFieldValue !== '') {
|
||||||
addOrUpdateLotOccupancyField({
|
addOrUpdateLotOccupancyField({
|
||||||
lotOccupancyId,
|
lotOccupancyId,
|
||||||
occupancyTypeFieldId,
|
occupancyTypeFieldId,
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,34 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3'
|
||||||
|
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||||
|
|
||||||
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
import * as dateTimeFunctions from '@cityssm/expressjs-server-js/dateTimeFns.js'
|
||||||
|
|
||||||
import { addOrUpdateLotOccupancyField } from "./addOrUpdateLotOccupancyField.js";
|
import { addOrUpdateLotOccupancyField } from './addOrUpdateLotOccupancyField.js'
|
||||||
import { addLotOccupancyOccupant } from "./addLotOccupancyOccupant.js";
|
import { addLotOccupancyOccupant } from './addLotOccupancyOccupant.js'
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes'
|
||||||
|
|
||||||
interface AddLotOccupancyForm {
|
interface AddLotOccupancyForm {
|
||||||
occupancyTypeId: string | number;
|
occupancyTypeId: string | number
|
||||||
lotId: string | number;
|
lotId: string | number
|
||||||
|
|
||||||
occupancyStartDateString: string;
|
occupancyStartDateString: string
|
||||||
occupancyEndDateString: string;
|
occupancyEndDateString: string
|
||||||
|
|
||||||
occupancyTypeFieldIds?: string;
|
occupancyTypeFieldIds?: string
|
||||||
[lotOccupancyFieldValue_occupancyTypeFieldId: string]: unknown;
|
[lotOccupancyFieldValue_occupancyTypeFieldId: string]: unknown
|
||||||
|
|
||||||
lotOccupantTypeId?: string;
|
lotOccupantTypeId?: string
|
||||||
occupantName?: string;
|
occupantName?: string
|
||||||
occupantAddress1?: string;
|
occupantAddress1?: string
|
||||||
occupantAddress2?: string;
|
occupantAddress2?: string
|
||||||
occupantCity?: string;
|
occupantCity?: string
|
||||||
occupantProvince?: string;
|
occupantProvince?: string
|
||||||
occupantPostalCode?: string;
|
occupantPostalCode?: string
|
||||||
occupantPhoneNumber?: string;
|
occupantPhoneNumber?: string
|
||||||
occupantEmailAddress?: string;
|
occupantEmailAddress?: string
|
||||||
occupantComment?: string;
|
occupantComment?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addLotOccupancy(
|
export function addLotOccupancy(
|
||||||
|
|
@ -36,18 +36,19 @@ export function addLotOccupancy(
|
||||||
requestSession: recordTypes.PartialSession,
|
requestSession: recordTypes.PartialSession,
|
||||||
connectedDatabase?: sqlite.Database
|
connectedDatabase?: sqlite.Database
|
||||||
): number {
|
): number {
|
||||||
const database = connectedDatabase || sqlite(databasePath);
|
const database = connectedDatabase ?? sqlite(databasePath)
|
||||||
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
const occupancyStartDate = dateTimeFunctions.dateStringToInteger(
|
const occupancyStartDate = dateTimeFunctions.dateStringToInteger(
|
||||||
lotOccupancyForm.occupancyStartDateString
|
lotOccupancyForm.occupancyStartDateString
|
||||||
);
|
)
|
||||||
|
|
||||||
if (occupancyStartDate <= 0) {
|
if (occupancyStartDate <= 0) {
|
||||||
console.error(lotOccupancyForm);
|
console.error(lotOccupancyForm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/indent */
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(
|
.prepare(
|
||||||
`insert into LotOccupancies (
|
`insert into LotOccupancies (
|
||||||
|
|
@ -59,27 +60,31 @@ export function addLotOccupancy(
|
||||||
)
|
)
|
||||||
.run(
|
.run(
|
||||||
lotOccupancyForm.occupancyTypeId,
|
lotOccupancyForm.occupancyTypeId,
|
||||||
lotOccupancyForm.lotId === "" ? undefined : lotOccupancyForm.lotId,
|
lotOccupancyForm.lotId === '' ? undefined : lotOccupancyForm.lotId,
|
||||||
occupancyStartDate,
|
occupancyStartDate,
|
||||||
lotOccupancyForm.occupancyEndDateString === ""
|
lotOccupancyForm.occupancyEndDateString === ''
|
||||||
? undefined
|
? undefined
|
||||||
: dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyEndDateString),
|
: dateTimeFunctions.dateStringToInteger(
|
||||||
requestSession.user.userName,
|
lotOccupancyForm.occupancyEndDateString
|
||||||
|
),
|
||||||
|
requestSession.user!.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
);
|
)
|
||||||
|
|
||||||
const lotOccupancyId = result.lastInsertRowid as number;
|
const lotOccupancyId = result.lastInsertRowid as number
|
||||||
|
|
||||||
const occupancyTypeFieldIds = (lotOccupancyForm.occupancyTypeFieldIds || "").split(",");
|
const occupancyTypeFieldIds = (
|
||||||
|
lotOccupancyForm.occupancyTypeFieldIds ?? ''
|
||||||
|
).split(',')
|
||||||
|
|
||||||
for (const occupancyTypeFieldId of occupancyTypeFieldIds) {
|
for (const occupancyTypeFieldId of occupancyTypeFieldIds) {
|
||||||
const lotOccupancyFieldValue = lotOccupancyForm[
|
const lotOccupancyFieldValue = lotOccupancyForm[
|
||||||
"lotOccupancyFieldValue_" + occupancyTypeFieldId
|
'lotOccupancyFieldValue_' + occupancyTypeFieldId
|
||||||
] as string;
|
] as string
|
||||||
|
|
||||||
if (lotOccupancyFieldValue && lotOccupancyFieldValue !== "") {
|
if (lotOccupancyFieldValue && lotOccupancyFieldValue !== '') {
|
||||||
addOrUpdateLotOccupancyField(
|
addOrUpdateLotOccupancyField(
|
||||||
{
|
{
|
||||||
lotOccupancyId,
|
lotOccupancyId,
|
||||||
|
|
@ -88,7 +93,7 @@ export function addLotOccupancy(
|
||||||
},
|
},
|
||||||
requestSession,
|
requestSession,
|
||||||
database
|
database
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,26 +102,26 @@ export function addLotOccupancy(
|
||||||
{
|
{
|
||||||
lotOccupancyId,
|
lotOccupancyId,
|
||||||
lotOccupantTypeId: lotOccupancyForm.lotOccupantTypeId,
|
lotOccupantTypeId: lotOccupancyForm.lotOccupantTypeId,
|
||||||
occupantName: lotOccupancyForm.occupantName,
|
occupantName: lotOccupancyForm.occupantName!,
|
||||||
occupantAddress1: lotOccupancyForm.occupantAddress1,
|
occupantAddress1: lotOccupancyForm.occupantAddress1!,
|
||||||
occupantAddress2: lotOccupancyForm.occupantAddress2,
|
occupantAddress2: lotOccupancyForm.occupantAddress2!,
|
||||||
occupantCity: lotOccupancyForm.occupantCity,
|
occupantCity: lotOccupancyForm.occupantCity!,
|
||||||
occupantProvince: lotOccupancyForm.occupantProvince,
|
occupantProvince: lotOccupancyForm.occupantProvince!,
|
||||||
occupantPostalCode: lotOccupancyForm.occupantPostalCode,
|
occupantPostalCode: lotOccupancyForm.occupantPostalCode!,
|
||||||
occupantPhoneNumber: lotOccupancyForm.occupantPhoneNumber,
|
occupantPhoneNumber: lotOccupancyForm.occupantPhoneNumber!,
|
||||||
occupantEmailAddress: lotOccupancyForm.occupantEmailAddress,
|
occupantEmailAddress: lotOccupancyForm.occupantEmailAddress!,
|
||||||
occupantComment: lotOccupancyForm.occupantComment
|
occupantComment: lotOccupancyForm.occupantComment!
|
||||||
},
|
},
|
||||||
requestSession,
|
requestSession,
|
||||||
database
|
database
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!connectedDatabase) {
|
if (!connectedDatabase) {
|
||||||
database.close();
|
database.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
return lotOccupancyId;
|
return lotOccupancyId
|
||||||
}
|
}
|
||||||
|
|
||||||
export default addLotOccupancy;
|
export default addLotOccupancy
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes';
|
||||||
interface AddLotOccupancyCommentForm {
|
interface AddLotOccupancyCommentForm {
|
||||||
lotOccupancyId: string | number;
|
lotOccupancyId: string | number;
|
||||||
lotOccupancyCommentDateString?: string;
|
lotOccupancyCommentDateString?: string;
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3';
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||||
import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/expressjs-server-js/dateTimeFns.js';
|
||||||
export function addLotOccupancyComment(commentForm, requestSession) {
|
export function addLotOccupancyComment(commentForm, requestSession) {
|
||||||
const rightNow = new Date();
|
const rightNow = new Date();
|
||||||
let lotOccupancyCommentDate;
|
let lotOccupancyCommentDate;
|
||||||
let lotOccupancyCommentTime;
|
let lotOccupancyCommentTime;
|
||||||
if (commentForm.lotOccupancyCommentDateString) {
|
if (commentForm.lotOccupancyCommentDateString) {
|
||||||
lotOccupancyCommentDate = dateStringToInteger(commentForm.lotOccupancyCommentDateString);
|
lotOccupancyCommentDate = dateStringToInteger(commentForm.lotOccupancyCommentDateString);
|
||||||
lotOccupancyCommentTime = timeStringToInteger(commentForm.lotOccupancyCommentTimeString);
|
lotOccupancyCommentTime = timeStringToInteger(commentForm.lotOccupancyCommentTimeString ?? '');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lotOccupancyCommentDate = dateToInteger(rightNow);
|
lotOccupancyCommentDate = dateToInteger(rightNow);
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,45 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3'
|
||||||
|
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
dateStringToInteger,
|
dateStringToInteger,
|
||||||
dateToInteger,
|
dateToInteger,
|
||||||
dateToTimeInteger,
|
dateToTimeInteger,
|
||||||
timeStringToInteger
|
timeStringToInteger
|
||||||
} from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
} from '@cityssm/expressjs-server-js/dateTimeFns.js'
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes'
|
||||||
|
|
||||||
interface AddLotOccupancyCommentForm {
|
interface AddLotOccupancyCommentForm {
|
||||||
lotOccupancyId: string | number;
|
lotOccupancyId: string | number
|
||||||
lotOccupancyCommentDateString?: string;
|
lotOccupancyCommentDateString?: string
|
||||||
lotOccupancyCommentTimeString?: string;
|
lotOccupancyCommentTimeString?: string
|
||||||
lotOccupancyComment: string;
|
lotOccupancyComment: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addLotOccupancyComment(
|
export function addLotOccupancyComment(
|
||||||
commentForm: AddLotOccupancyCommentForm,
|
commentForm: AddLotOccupancyCommentForm,
|
||||||
requestSession: recordTypes.PartialSession
|
requestSession: recordTypes.PartialSession
|
||||||
): number {
|
): number {
|
||||||
const rightNow = new Date();
|
const rightNow = new Date()
|
||||||
|
|
||||||
let lotOccupancyCommentDate: number;
|
let lotOccupancyCommentDate: number
|
||||||
let lotOccupancyCommentTime: number;
|
let lotOccupancyCommentTime: number
|
||||||
|
|
||||||
if (commentForm.lotOccupancyCommentDateString) {
|
if (commentForm.lotOccupancyCommentDateString) {
|
||||||
lotOccupancyCommentDate = dateStringToInteger(commentForm.lotOccupancyCommentDateString);
|
lotOccupancyCommentDate = dateStringToInteger(
|
||||||
lotOccupancyCommentTime = timeStringToInteger(commentForm.lotOccupancyCommentTimeString);
|
commentForm.lotOccupancyCommentDateString
|
||||||
|
)
|
||||||
|
lotOccupancyCommentTime = timeStringToInteger(
|
||||||
|
commentForm.lotOccupancyCommentTimeString ?? ''
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
lotOccupancyCommentDate = dateToInteger(rightNow);
|
lotOccupancyCommentDate = dateToInteger(rightNow)
|
||||||
lotOccupancyCommentTime = dateToTimeInteger(rightNow);
|
lotOccupancyCommentTime = dateToTimeInteger(rightNow)
|
||||||
}
|
}
|
||||||
|
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath)
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(
|
.prepare(
|
||||||
|
|
@ -52,15 +56,15 @@ export function addLotOccupancyComment(
|
||||||
lotOccupancyCommentDate,
|
lotOccupancyCommentDate,
|
||||||
lotOccupancyCommentTime,
|
lotOccupancyCommentTime,
|
||||||
commentForm.lotOccupancyComment,
|
commentForm.lotOccupancyComment,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNow.getTime(),
|
rightNow.getTime(),
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNow.getTime()
|
rightNow.getTime()
|
||||||
);
|
)
|
||||||
|
|
||||||
database.close();
|
database.close()
|
||||||
|
|
||||||
return result.lastInsertRowid as number;
|
return result.lastInsertRowid as number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default addLotOccupancyComment;
|
export default addLotOccupancyComment
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes';
|
||||||
interface AddLotOccupancyFeeForm {
|
interface AddLotOccupancyFeeForm {
|
||||||
lotOccupancyId: number | string;
|
lotOccupancyId: number | string;
|
||||||
feeId: number | string;
|
feeId: number | string;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3';
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||||
import { calculateFeeAmount, calculateTaxAmount } from "../functions.fee.js";
|
import { calculateFeeAmount, calculateTaxAmount } from '../functions.fee.js';
|
||||||
import { getFee } from "./getFee.js";
|
import { getFee } from './getFee.js';
|
||||||
import { getLotOccupancy } from "./getLotOccupancy.js";
|
import { getLotOccupancy } from './getLotOccupancy.js';
|
||||||
export function addLotOccupancyFee(lotOccupancyFeeForm, requestSession) {
|
export function addLotOccupancyFee(lotOccupancyFeeForm, requestSession) {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
|
@ -10,13 +10,13 @@ export function addLotOccupancyFee(lotOccupancyFeeForm, requestSession) {
|
||||||
let taxAmount;
|
let taxAmount;
|
||||||
if (lotOccupancyFeeForm.feeAmount) {
|
if (lotOccupancyFeeForm.feeAmount) {
|
||||||
feeAmount =
|
feeAmount =
|
||||||
typeof lotOccupancyFeeForm.feeAmount === "string"
|
typeof lotOccupancyFeeForm.feeAmount === 'string'
|
||||||
? Number.parseFloat(lotOccupancyFeeForm.feeAmount)
|
? Number.parseFloat(lotOccupancyFeeForm.feeAmount)
|
||||||
: feeAmount;
|
: 0;
|
||||||
taxAmount =
|
taxAmount =
|
||||||
typeof lotOccupancyFeeForm.taxAmount === "string"
|
typeof lotOccupancyFeeForm.taxAmount === 'string'
|
||||||
? Number.parseFloat(lotOccupancyFeeForm.taxAmount)
|
? Number.parseFloat(lotOccupancyFeeForm.taxAmount)
|
||||||
: taxAmount;
|
: 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const lotOccupancy = getLotOccupancy(lotOccupancyFeeForm.lotOccupancyId);
|
const lotOccupancy = getLotOccupancy(lotOccupancyFeeForm.lotOccupancyId);
|
||||||
|
|
@ -39,7 +39,8 @@ export function addLotOccupancyFee(lotOccupancyFeeForm, requestSession) {
|
||||||
and feeId = ?`)
|
and feeId = ?`)
|
||||||
.run(lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId);
|
.run(lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId);
|
||||||
}
|
}
|
||||||
else if (record.feeAmount === feeAmount && record.taxAmount === taxAmount) {
|
else if (record.feeAmount === feeAmount &&
|
||||||
|
record.taxAmount === taxAmount) {
|
||||||
database
|
database
|
||||||
.prepare(`update LotOccupancyFees
|
.prepare(`update LotOccupancyFees
|
||||||
set quantity = quantity + ?,
|
set quantity = quantity + ?,
|
||||||
|
|
@ -52,7 +53,7 @@ export function addLotOccupancyFee(lotOccupancyFeeForm, requestSession) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const quantity = typeof lotOccupancyFeeForm.quantity === "string"
|
const quantity = typeof lotOccupancyFeeForm.quantity === 'string'
|
||||||
? Number.parseFloat(lotOccupancyFeeForm.quantity)
|
? Number.parseFloat(lotOccupancyFeeForm.quantity)
|
||||||
: lotOccupancyFeeForm.quantity;
|
: lotOccupancyFeeForm.quantity;
|
||||||
database
|
database
|
||||||
|
|
|
||||||
|
|
@ -1,57 +1,57 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3'
|
||||||
|
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||||
|
|
||||||
import { calculateFeeAmount, calculateTaxAmount } from "../functions.fee.js";
|
import { calculateFeeAmount, calculateTaxAmount } from '../functions.fee.js'
|
||||||
|
|
||||||
import { getFee } from "./getFee.js";
|
import { getFee } from './getFee.js'
|
||||||
|
|
||||||
import { getLotOccupancy } from "./getLotOccupancy.js";
|
import { getLotOccupancy } from './getLotOccupancy.js'
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes'
|
||||||
|
|
||||||
interface AddLotOccupancyFeeForm {
|
interface AddLotOccupancyFeeForm {
|
||||||
lotOccupancyId: number | string;
|
lotOccupancyId: number | string
|
||||||
feeId: number | string;
|
feeId: number | string
|
||||||
quantity: number | string;
|
quantity: number | string
|
||||||
feeAmount?: number | string;
|
feeAmount?: number | string
|
||||||
taxAmount?: number | string;
|
taxAmount?: number | string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addLotOccupancyFee(
|
export function addLotOccupancyFee(
|
||||||
lotOccupancyFeeForm: AddLotOccupancyFeeForm,
|
lotOccupancyFeeForm: AddLotOccupancyFeeForm,
|
||||||
requestSession: recordTypes.PartialSession
|
requestSession: recordTypes.PartialSession
|
||||||
): boolean {
|
): boolean {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath)
|
||||||
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
// Calculate fee and tax (if not set)
|
// Calculate fee and tax (if not set)
|
||||||
let feeAmount: number;
|
let feeAmount: number
|
||||||
let taxAmount: number;
|
let taxAmount: number
|
||||||
|
|
||||||
if (lotOccupancyFeeForm.feeAmount) {
|
if (lotOccupancyFeeForm.feeAmount) {
|
||||||
feeAmount =
|
feeAmount =
|
||||||
typeof lotOccupancyFeeForm.feeAmount === "string"
|
typeof lotOccupancyFeeForm.feeAmount === 'string'
|
||||||
? Number.parseFloat(lotOccupancyFeeForm.feeAmount)
|
? Number.parseFloat(lotOccupancyFeeForm.feeAmount)
|
||||||
: feeAmount;
|
: 0
|
||||||
taxAmount =
|
taxAmount =
|
||||||
typeof lotOccupancyFeeForm.taxAmount === "string"
|
typeof lotOccupancyFeeForm.taxAmount === 'string'
|
||||||
? Number.parseFloat(lotOccupancyFeeForm.taxAmount)
|
? Number.parseFloat(lotOccupancyFeeForm.taxAmount)
|
||||||
: taxAmount;
|
: 0
|
||||||
} else {
|
} else {
|
||||||
const lotOccupancy = getLotOccupancy(lotOccupancyFeeForm.lotOccupancyId);
|
const lotOccupancy = getLotOccupancy(lotOccupancyFeeForm.lotOccupancyId)!
|
||||||
const fee = getFee(lotOccupancyFeeForm.feeId);
|
const fee = getFee(lotOccupancyFeeForm.feeId)
|
||||||
|
|
||||||
feeAmount = calculateFeeAmount(fee, lotOccupancy);
|
feeAmount = calculateFeeAmount(fee, lotOccupancy)
|
||||||
taxAmount = calculateTaxAmount(fee, feeAmount);
|
taxAmount = calculateTaxAmount(fee, feeAmount)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if record already exists
|
// Check if record already exists
|
||||||
const record: {
|
const record: {
|
||||||
feeAmount?: number;
|
feeAmount?: number
|
||||||
taxAmount?: number;
|
taxAmount?: number
|
||||||
recordDelete_timeMillis?: number;
|
recordDelete_timeMillis?: number
|
||||||
} = database
|
} = database
|
||||||
.prepare(
|
.prepare(
|
||||||
`select feeAmount, taxAmount, recordDelete_timeMillis
|
`select feeAmount, taxAmount, recordDelete_timeMillis
|
||||||
|
|
@ -59,7 +59,7 @@ export function addLotOccupancyFee(
|
||||||
where lotOccupancyId = ?
|
where lotOccupancyId = ?
|
||||||
and feeId = ?`
|
and feeId = ?`
|
||||||
)
|
)
|
||||||
.get(lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId);
|
.get(lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId)
|
||||||
|
|
||||||
if (record) {
|
if (record) {
|
||||||
if (record.recordDelete_timeMillis) {
|
if (record.recordDelete_timeMillis) {
|
||||||
|
|
@ -70,8 +70,11 @@ export function addLotOccupancyFee(
|
||||||
and lotOccupancyId = ?
|
and lotOccupancyId = ?
|
||||||
and feeId = ?`
|
and feeId = ?`
|
||||||
)
|
)
|
||||||
.run(lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId);
|
.run(lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId)
|
||||||
} else if (record.feeAmount === feeAmount && record.taxAmount === taxAmount) {
|
} else if (
|
||||||
|
record.feeAmount === feeAmount &&
|
||||||
|
record.taxAmount === taxAmount
|
||||||
|
) {
|
||||||
database
|
database
|
||||||
.prepare(
|
.prepare(
|
||||||
`update LotOccupancyFees
|
`update LotOccupancyFees
|
||||||
|
|
@ -83,20 +86,20 @@ export function addLotOccupancyFee(
|
||||||
)
|
)
|
||||||
.run(
|
.run(
|
||||||
lotOccupancyFeeForm.quantity,
|
lotOccupancyFeeForm.quantity,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
lotOccupancyFeeForm.lotOccupancyId,
|
lotOccupancyFeeForm.lotOccupancyId,
|
||||||
lotOccupancyFeeForm.feeId
|
lotOccupancyFeeForm.feeId
|
||||||
);
|
)
|
||||||
|
|
||||||
database.close();
|
database.close()
|
||||||
|
|
||||||
return true;
|
return true
|
||||||
} else {
|
} else {
|
||||||
const quantity =
|
const quantity =
|
||||||
typeof lotOccupancyFeeForm.quantity === "string"
|
typeof lotOccupancyFeeForm.quantity === 'string'
|
||||||
? Number.parseFloat(lotOccupancyFeeForm.quantity)
|
? Number.parseFloat(lotOccupancyFeeForm.quantity)
|
||||||
: lotOccupancyFeeForm.quantity;
|
: lotOccupancyFeeForm.quantity
|
||||||
|
|
||||||
database
|
database
|
||||||
.prepare(
|
.prepare(
|
||||||
|
|
@ -112,15 +115,15 @@ export function addLotOccupancyFee(
|
||||||
.run(
|
.run(
|
||||||
feeAmount * quantity,
|
feeAmount * quantity,
|
||||||
taxAmount * quantity,
|
taxAmount * quantity,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
lotOccupancyFeeForm.lotOccupancyId,
|
lotOccupancyFeeForm.lotOccupancyId,
|
||||||
lotOccupancyFeeForm.feeId
|
lotOccupancyFeeForm.feeId
|
||||||
);
|
)
|
||||||
|
|
||||||
database.close();
|
database.close()
|
||||||
|
|
||||||
return true;
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,15 +143,15 @@ export function addLotOccupancyFee(
|
||||||
lotOccupancyFeeForm.quantity,
|
lotOccupancyFeeForm.quantity,
|
||||||
feeAmount,
|
feeAmount,
|
||||||
taxAmount,
|
taxAmount,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
);
|
)
|
||||||
|
|
||||||
database.close();
|
database.close()
|
||||||
|
|
||||||
return result.changes > 0;
|
return result.changes > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
export default addLotOccupancyFee;
|
export default addLotOccupancyFee
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3';
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes';
|
||||||
interface AddLotOccupancyOccupantForm {
|
interface AddLotOccupancyOccupantForm {
|
||||||
lotOccupancyId: string | number;
|
lotOccupancyId: string | number;
|
||||||
lotOccupantTypeId: string | number;
|
lotOccupantTypeId: string | number;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3';
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||||
export function addLotOccupancyOccupant(lotOccupancyOccupantForm, requestSession, connectedDatabase) {
|
export function addLotOccupancyOccupant(lotOccupancyOccupantForm, requestSession, connectedDatabase) {
|
||||||
const database = connectedDatabase || sqlite(databasePath);
|
const database = connectedDatabase ?? sqlite(databasePath);
|
||||||
let lotOccupantIndex = 0;
|
let lotOccupantIndex = 0;
|
||||||
const maxIndexResult = database
|
const maxIndexResult = database
|
||||||
.prepare(`select lotOccupantIndex
|
.prepare(`select lotOccupantIndex
|
||||||
|
|
@ -26,7 +26,7 @@ export function addLotOccupancyOccupant(lotOccupancyOccupantForm, requestSession
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(lotOccupancyOccupantForm.lotOccupancyId, lotOccupantIndex, lotOccupancyOccupantForm.occupantName, lotOccupancyOccupantForm.occupantAddress1, lotOccupancyOccupantForm.occupantAddress2, lotOccupancyOccupantForm.occupantCity, lotOccupancyOccupantForm.occupantProvince, lotOccupancyOccupantForm.occupantPostalCode, lotOccupancyOccupantForm.occupantPhoneNumber, lotOccupancyOccupantForm.occupantEmailAddress, lotOccupancyOccupantForm.occupantComment || "", lotOccupancyOccupantForm.lotOccupantTypeId, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
.run(lotOccupancyOccupantForm.lotOccupancyId, lotOccupantIndex, lotOccupancyOccupantForm.occupantName, lotOccupancyOccupantForm.occupantAddress1, lotOccupancyOccupantForm.occupantAddress2, lotOccupancyOccupantForm.occupantCity, lotOccupancyOccupantForm.occupantProvince, lotOccupancyOccupantForm.occupantPostalCode, lotOccupancyOccupantForm.occupantPhoneNumber, lotOccupancyOccupantForm.occupantEmailAddress, lotOccupancyOccupantForm.occupantComment ?? '', lotOccupancyOccupantForm.lotOccupantTypeId, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||||
if (!connectedDatabase) {
|
if (!connectedDatabase) {
|
||||||
database.close();
|
database.close();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3'
|
||||||
|
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes'
|
||||||
|
|
||||||
interface AddLotOccupancyOccupantForm {
|
interface AddLotOccupancyOccupantForm {
|
||||||
lotOccupancyId: string | number;
|
lotOccupancyId: string | number
|
||||||
lotOccupantTypeId: string | number;
|
lotOccupantTypeId: string | number
|
||||||
occupantName: string;
|
occupantName: string
|
||||||
occupantAddress1: string;
|
occupantAddress1: string
|
||||||
occupantAddress2: string;
|
occupantAddress2: string
|
||||||
occupantCity: string;
|
occupantCity: string
|
||||||
occupantProvince: string;
|
occupantProvince: string
|
||||||
occupantPostalCode: string;
|
occupantPostalCode: string
|
||||||
occupantPhoneNumber: string;
|
occupantPhoneNumber: string
|
||||||
occupantEmailAddress: string;
|
occupantEmailAddress: string
|
||||||
occupantComment?: string;
|
occupantComment?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addLotOccupancyOccupant(
|
export function addLotOccupancyOccupant(
|
||||||
|
|
@ -23,9 +23,9 @@ export function addLotOccupancyOccupant(
|
||||||
requestSession: recordTypes.PartialSession,
|
requestSession: recordTypes.PartialSession,
|
||||||
connectedDatabase?: sqlite.Database
|
connectedDatabase?: sqlite.Database
|
||||||
): number {
|
): number {
|
||||||
const database = connectedDatabase || sqlite(databasePath);
|
const database = connectedDatabase ?? sqlite(databasePath)
|
||||||
|
|
||||||
let lotOccupantIndex = 0;
|
let lotOccupantIndex = 0
|
||||||
|
|
||||||
const maxIndexResult = database
|
const maxIndexResult = database
|
||||||
.prepare(
|
.prepare(
|
||||||
|
|
@ -35,13 +35,13 @@ export function addLotOccupancyOccupant(
|
||||||
order by lotOccupantIndex desc
|
order by lotOccupantIndex desc
|
||||||
limit 1`
|
limit 1`
|
||||||
)
|
)
|
||||||
.get(lotOccupancyOccupantForm.lotOccupancyId);
|
.get(lotOccupancyOccupantForm.lotOccupancyId)
|
||||||
|
|
||||||
if (maxIndexResult) {
|
if (maxIndexResult) {
|
||||||
lotOccupantIndex = maxIndexResult.lotOccupantIndex + 1;
|
lotOccupantIndex = maxIndexResult.lotOccupantIndex + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
database
|
database
|
||||||
.prepare(
|
.prepare(
|
||||||
|
|
@ -68,19 +68,19 @@ export function addLotOccupancyOccupant(
|
||||||
lotOccupancyOccupantForm.occupantPostalCode,
|
lotOccupancyOccupantForm.occupantPostalCode,
|
||||||
lotOccupancyOccupantForm.occupantPhoneNumber,
|
lotOccupancyOccupantForm.occupantPhoneNumber,
|
||||||
lotOccupancyOccupantForm.occupantEmailAddress,
|
lotOccupancyOccupantForm.occupantEmailAddress,
|
||||||
lotOccupancyOccupantForm.occupantComment || "",
|
lotOccupancyOccupantForm.occupantComment ?? '',
|
||||||
lotOccupancyOccupantForm.lotOccupantTypeId,
|
lotOccupancyOccupantForm.lotOccupantTypeId,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
);
|
)
|
||||||
|
|
||||||
if (!connectedDatabase) {
|
if (!connectedDatabase) {
|
||||||
database.close();
|
database.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
return lotOccupantIndex;
|
return lotOccupantIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
export default addLotOccupancyOccupant;
|
export default addLotOccupancyOccupant
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes';
|
||||||
interface AddLotOccupancyTransactionForm {
|
interface AddLotOccupancyTransactionForm {
|
||||||
lotOccupancyId: string | number;
|
lotOccupancyId: string | number;
|
||||||
transactionDateString?: string;
|
transactionDateString?: string;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3';
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||||
import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/expressjs-server-js/dateTimeFns.js';
|
||||||
export function addLotOccupancyTransaction(lotOccupancyTransactionForm, requestSession) {
|
export function addLotOccupancyTransaction(lotOccupancyTransactionForm, requestSession) {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
let transactionIndex = 0;
|
let transactionIndex = 0;
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,34 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3'
|
||||||
|
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
dateStringToInteger,
|
dateStringToInteger,
|
||||||
dateToInteger,
|
dateToInteger,
|
||||||
dateToTimeInteger,
|
dateToTimeInteger,
|
||||||
timeStringToInteger
|
timeStringToInteger
|
||||||
} from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
} from '@cityssm/expressjs-server-js/dateTimeFns.js'
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes'
|
||||||
|
|
||||||
interface AddLotOccupancyTransactionForm {
|
interface AddLotOccupancyTransactionForm {
|
||||||
lotOccupancyId: string | number;
|
lotOccupancyId: string | number
|
||||||
transactionDateString?: string;
|
transactionDateString?: string
|
||||||
transactionTimeString?: string;
|
transactionTimeString?: string
|
||||||
transactionAmount: string | number;
|
transactionAmount: string | number
|
||||||
externalReceiptNumber: string;
|
externalReceiptNumber: string
|
||||||
transactionNote: string;
|
transactionNote: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addLotOccupancyTransaction(
|
export function addLotOccupancyTransaction(
|
||||||
lotOccupancyTransactionForm: AddLotOccupancyTransactionForm,
|
lotOccupancyTransactionForm: AddLotOccupancyTransactionForm,
|
||||||
requestSession: recordTypes.PartialSession
|
requestSession: recordTypes.PartialSession
|
||||||
): number {
|
): number {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath)
|
||||||
|
|
||||||
let transactionIndex = 0;
|
let transactionIndex = 0
|
||||||
|
|
||||||
const maxIndexResult = database
|
const maxIndexResult: { transactionIndex: number } | undefined = database
|
||||||
.prepare(
|
.prepare(
|
||||||
`select transactionIndex
|
`select transactionIndex
|
||||||
from LotOccupancyTransactions
|
from LotOccupancyTransactions
|
||||||
|
|
@ -36,21 +36,21 @@ export function addLotOccupancyTransaction(
|
||||||
order by transactionIndex desc
|
order by transactionIndex desc
|
||||||
limit 1`
|
limit 1`
|
||||||
)
|
)
|
||||||
.get(lotOccupancyTransactionForm.lotOccupancyId);
|
.get(lotOccupancyTransactionForm.lotOccupancyId)
|
||||||
|
|
||||||
if (maxIndexResult) {
|
if (maxIndexResult) {
|
||||||
transactionIndex = maxIndexResult.transactionIndex + 1;
|
transactionIndex = maxIndexResult.transactionIndex + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
const rightNow = new Date();
|
const rightNow = new Date()
|
||||||
|
|
||||||
const transactionDate = lotOccupancyTransactionForm.transactionDateString
|
const transactionDate = lotOccupancyTransactionForm.transactionDateString
|
||||||
? dateStringToInteger(lotOccupancyTransactionForm.transactionDateString)
|
? dateStringToInteger(lotOccupancyTransactionForm.transactionDateString)
|
||||||
: dateToInteger(rightNow);
|
: dateToInteger(rightNow)
|
||||||
|
|
||||||
const transactionTime = lotOccupancyTransactionForm.transactionTimeString
|
const transactionTime = lotOccupancyTransactionForm.transactionTimeString
|
||||||
? timeStringToInteger(lotOccupancyTransactionForm.transactionTimeString)
|
? timeStringToInteger(lotOccupancyTransactionForm.transactionTimeString)
|
||||||
: dateToTimeInteger(rightNow);
|
: dateToTimeInteger(rightNow)
|
||||||
|
|
||||||
database
|
database
|
||||||
.prepare(
|
.prepare(
|
||||||
|
|
@ -70,15 +70,15 @@ export function addLotOccupancyTransaction(
|
||||||
lotOccupancyTransactionForm.transactionAmount,
|
lotOccupancyTransactionForm.transactionAmount,
|
||||||
lotOccupancyTransactionForm.externalReceiptNumber,
|
lotOccupancyTransactionForm.externalReceiptNumber,
|
||||||
lotOccupancyTransactionForm.transactionNote,
|
lotOccupancyTransactionForm.transactionNote,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNow.getTime(),
|
rightNow.getTime(),
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNow.getTime()
|
rightNow.getTime()
|
||||||
);
|
)
|
||||||
|
|
||||||
database.close();
|
database.close()
|
||||||
|
|
||||||
return transactionIndex;
|
return transactionIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
export default addLotOccupancyTransaction;
|
export default addLotOccupancyTransaction
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes';
|
||||||
interface AddLotOccupantTypeForm {
|
interface AddLotOccupantTypeForm {
|
||||||
lotOccupantType: string;
|
lotOccupantType: string;
|
||||||
fontAwesomeIconClass?: string;
|
fontAwesomeIconClass?: string;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3';
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||||
import { clearCacheByTableName } from "../functions.cache.js";
|
import { clearCacheByTableName } from '../functions.cache.js';
|
||||||
export function addLotOccupantType(lotOccupantTypeForm, requestSession) {
|
export function addLotOccupantType(lotOccupantTypeForm, requestSession) {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
|
@ -10,9 +10,9 @@ export function addLotOccupantType(lotOccupantTypeForm, requestSession) {
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(lotOccupantTypeForm.lotOccupantType, lotOccupantTypeForm.fontAwesomeIconClass || "", lotOccupantTypeForm.orderNumber || -1, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
.run(lotOccupantTypeForm.lotOccupantType, lotOccupantTypeForm.fontAwesomeIconClass ?? '', lotOccupantTypeForm.orderNumber ?? -1, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||||
database.close();
|
database.close();
|
||||||
clearCacheByTableName("LotOccupantTypes");
|
clearCacheByTableName('LotOccupantTypes');
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
}
|
}
|
||||||
export default addLotOccupantType;
|
export default addLotOccupantType;
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,23 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3'
|
||||||
|
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes'
|
||||||
import { clearCacheByTableName } from "../functions.cache.js";
|
import { clearCacheByTableName } from '../functions.cache.js'
|
||||||
|
|
||||||
interface AddLotOccupantTypeForm {
|
interface AddLotOccupantTypeForm {
|
||||||
lotOccupantType: string;
|
lotOccupantType: string
|
||||||
fontAwesomeIconClass?: string;
|
fontAwesomeIconClass?: string
|
||||||
orderNumber?: number;
|
orderNumber?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addLotOccupantType(
|
export function addLotOccupantType(
|
||||||
lotOccupantTypeForm: AddLotOccupantTypeForm,
|
lotOccupantTypeForm: AddLotOccupantTypeForm,
|
||||||
requestSession: recordTypes.PartialSession
|
requestSession: recordTypes.PartialSession
|
||||||
): number {
|
): number {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath)
|
||||||
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(
|
.prepare(
|
||||||
|
|
@ -29,19 +29,19 @@ export function addLotOccupantType(
|
||||||
)
|
)
|
||||||
.run(
|
.run(
|
||||||
lotOccupantTypeForm.lotOccupantType,
|
lotOccupantTypeForm.lotOccupantType,
|
||||||
lotOccupantTypeForm.fontAwesomeIconClass || "",
|
lotOccupantTypeForm.fontAwesomeIconClass ?? '',
|
||||||
lotOccupantTypeForm.orderNumber || -1,
|
lotOccupantTypeForm.orderNumber ?? -1,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
);
|
)
|
||||||
|
|
||||||
database.close();
|
database.close()
|
||||||
|
|
||||||
clearCacheByTableName("LotOccupantTypes");
|
clearCacheByTableName('LotOccupantTypes')
|
||||||
|
|
||||||
return result.lastInsertRowid as number;
|
return result.lastInsertRowid as number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default addLotOccupantType;
|
export default addLotOccupantType
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes';
|
||||||
interface AddLotTypeFieldForm {
|
interface AddLotTypeFieldForm {
|
||||||
lotTypeId: string | number;
|
lotTypeId: string | number;
|
||||||
lotTypeField: string;
|
lotTypeField: string;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3';
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||||
import { clearCacheByTableName } from "../functions.cache.js";
|
import { clearCacheByTableName } from '../functions.cache.js';
|
||||||
export function addLotTypeField(lotTypeFieldForm, requestSession) {
|
export function addLotTypeField(lotTypeFieldForm, requestSession) {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
|
@ -13,9 +13,9 @@ export function addLotTypeField(lotTypeFieldForm, requestSession) {
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(lotTypeFieldForm.lotTypeId, lotTypeFieldForm.lotTypeField, lotTypeFieldForm.lotTypeFieldValues || "", lotTypeFieldForm.isRequired ? 1 : 0, lotTypeFieldForm.pattern || "", lotTypeFieldForm.minimumLength || 0, lotTypeFieldForm.maximumLength || 100, lotTypeFieldForm.orderNumber || -1, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
.run(lotTypeFieldForm.lotTypeId, lotTypeFieldForm.lotTypeField, lotTypeFieldForm.lotTypeFieldValues ?? '', lotTypeFieldForm.isRequired === '' ? 0 : 1, lotTypeFieldForm.pattern ?? '', lotTypeFieldForm.minimumLength ?? 0, lotTypeFieldForm.maximumLength ?? 100, lotTypeFieldForm.orderNumber ?? -1, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||||
database.close();
|
database.close();
|
||||||
clearCacheByTableName("LotTypeFields");
|
clearCacheByTableName('LotTypeFields');
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
}
|
}
|
||||||
export default addLotTypeField;
|
export default addLotTypeField;
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,29 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3'
|
||||||
|
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||||
|
|
||||||
import { clearCacheByTableName } from "../functions.cache.js";
|
import { clearCacheByTableName } from '../functions.cache.js'
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes'
|
||||||
|
|
||||||
interface AddLotTypeFieldForm {
|
interface AddLotTypeFieldForm {
|
||||||
lotTypeId: string | number;
|
lotTypeId: string | number
|
||||||
lotTypeField: string;
|
lotTypeField: string
|
||||||
lotTypeFieldValues?: string;
|
lotTypeFieldValues?: string
|
||||||
isRequired?: string;
|
isRequired?: string
|
||||||
pattern?: string;
|
pattern?: string
|
||||||
minimumLength: string | number;
|
minimumLength: string | number
|
||||||
maximumLength: string | number;
|
maximumLength: string | number
|
||||||
orderNumber?: number;
|
orderNumber?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addLotTypeField(
|
export function addLotTypeField(
|
||||||
lotTypeFieldForm: AddLotTypeFieldForm,
|
lotTypeFieldForm: AddLotTypeFieldForm,
|
||||||
requestSession: recordTypes.PartialSession
|
requestSession: recordTypes.PartialSession
|
||||||
): number {
|
): number {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath)
|
||||||
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(
|
.prepare(
|
||||||
|
|
@ -39,23 +39,23 @@ export function addLotTypeField(
|
||||||
.run(
|
.run(
|
||||||
lotTypeFieldForm.lotTypeId,
|
lotTypeFieldForm.lotTypeId,
|
||||||
lotTypeFieldForm.lotTypeField,
|
lotTypeFieldForm.lotTypeField,
|
||||||
lotTypeFieldForm.lotTypeFieldValues || "",
|
lotTypeFieldForm.lotTypeFieldValues ?? '',
|
||||||
lotTypeFieldForm.isRequired ? 1 : 0,
|
lotTypeFieldForm.isRequired === '' ? 0 : 1,
|
||||||
lotTypeFieldForm.pattern || "",
|
lotTypeFieldForm.pattern ?? '',
|
||||||
lotTypeFieldForm.minimumLength || 0,
|
lotTypeFieldForm.minimumLength ?? 0,
|
||||||
lotTypeFieldForm.maximumLength || 100,
|
lotTypeFieldForm.maximumLength ?? 100,
|
||||||
lotTypeFieldForm.orderNumber || -1,
|
lotTypeFieldForm.orderNumber ?? -1,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
);
|
)
|
||||||
|
|
||||||
database.close();
|
database.close()
|
||||||
|
|
||||||
clearCacheByTableName("LotTypeFields");
|
clearCacheByTableName('LotTypeFields')
|
||||||
|
|
||||||
return result.lastInsertRowid as number;
|
return result.lastInsertRowid as number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default addLotTypeField;
|
export default addLotTypeField
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes';
|
||||||
interface AddMapForm {
|
interface AddMapForm {
|
||||||
mapName: string;
|
mapName: string;
|
||||||
mapDescription: string;
|
mapDescription: string;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3';
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||||
export function addMap(mapForm, requestSession) {
|
export function addMap(mapForm, requestSession) {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
|
@ -13,7 +13,7 @@ export function addMap(mapForm, requestSession) {
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
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, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
.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, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||||
database.close();
|
database.close();
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,30 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3'
|
||||||
|
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes'
|
||||||
|
|
||||||
interface AddMapForm {
|
interface AddMapForm {
|
||||||
mapName: string;
|
mapName: string
|
||||||
mapDescription: string;
|
mapDescription: string
|
||||||
mapSVG: string;
|
mapSVG: string
|
||||||
mapLatitude: string;
|
mapLatitude: string
|
||||||
mapLongitude: string;
|
mapLongitude: string
|
||||||
mapAddress1: string;
|
mapAddress1: string
|
||||||
mapAddress2: string;
|
mapAddress2: string
|
||||||
mapCity: string;
|
mapCity: string
|
||||||
mapProvince: string;
|
mapProvince: string
|
||||||
mapPostalCode: string;
|
mapPostalCode: string
|
||||||
mapPhoneNumber: string;
|
mapPhoneNumber: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addMap(mapForm: AddMapForm, requestSession: recordTypes.PartialSession): number {
|
export function addMap(
|
||||||
const database = sqlite(databasePath);
|
mapForm: AddMapForm,
|
||||||
|
requestSession: recordTypes.PartialSession
|
||||||
|
): number {
|
||||||
|
const database = sqlite(databasePath)
|
||||||
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(
|
.prepare(
|
||||||
|
|
@ -39,23 +42,23 @@ export function addMap(mapForm: AddMapForm, requestSession: recordTypes.PartialS
|
||||||
mapForm.mapName,
|
mapForm.mapName,
|
||||||
mapForm.mapDescription,
|
mapForm.mapDescription,
|
||||||
mapForm.mapSVG,
|
mapForm.mapSVG,
|
||||||
mapForm.mapLatitude === "" ? undefined : mapForm.mapLatitude,
|
mapForm.mapLatitude === '' ? undefined : mapForm.mapLatitude,
|
||||||
mapForm.mapLongitude === "" ? undefined : mapForm.mapLongitude,
|
mapForm.mapLongitude === '' ? undefined : mapForm.mapLongitude,
|
||||||
mapForm.mapAddress1,
|
mapForm.mapAddress1,
|
||||||
mapForm.mapAddress2,
|
mapForm.mapAddress2,
|
||||||
mapForm.mapCity,
|
mapForm.mapCity,
|
||||||
mapForm.mapProvince,
|
mapForm.mapProvince,
|
||||||
mapForm.mapPostalCode,
|
mapForm.mapPostalCode,
|
||||||
mapForm.mapPhoneNumber,
|
mapForm.mapPhoneNumber,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
requestSession.user.userName,
|
requestSession.user!.userName,
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
);
|
)
|
||||||
|
|
||||||
database.close();
|
database.close()
|
||||||
|
|
||||||
return result.lastInsertRowid as number;
|
return result.lastInsertRowid as number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default addMap;
|
export default addMap
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3';
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes';
|
||||||
export declare function getLotOccupancy(lotOccupancyId: number | string, connectedDatabase?: sqlite.Database): recordTypes.LotOccupancy;
|
export declare function getLotOccupancy(lotOccupancyId: number | string, connectedDatabase?: sqlite.Database): recordTypes.LotOccupancy | undefined;
|
||||||
export default getLotOccupancy;
|
export default getLotOccupancy;
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3';
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||||
import { dateIntegerToString } from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
import { dateIntegerToString } from '@cityssm/expressjs-server-js/dateTimeFns.js';
|
||||||
import { getLotOccupancyOccupants } from "./getLotOccupancyOccupants.js";
|
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js';
|
||||||
import { getLotOccupancyComments } from "./getLotOccupancyComments.js";
|
import { getLotOccupancyComments } from './getLotOccupancyComments.js';
|
||||||
import { getLotOccupancyFields } from "./getLotOccupancyFields.js";
|
import { getLotOccupancyFields } from './getLotOccupancyFields.js';
|
||||||
import { getLotOccupancyFees } from "./getLotOccupancyFees.js";
|
import { getLotOccupancyFees } from './getLotOccupancyFees.js';
|
||||||
import { getLotOccupancyTransactions } from "./getLotOccupancyTransactions.js";
|
import { getLotOccupancyTransactions } from './getLotOccupancyTransactions.js';
|
||||||
import { getWorkOrders } from "./getWorkOrders.js";
|
import { getWorkOrders } from './getWorkOrders.js';
|
||||||
export function getLotOccupancy(lotOccupancyId, connectedDatabase) {
|
export function getLotOccupancy(lotOccupancyId, connectedDatabase) {
|
||||||
const database = connectedDatabase ||
|
const database = connectedDatabase ??
|
||||||
sqlite(databasePath, {
|
sqlite(databasePath, {
|
||||||
readonly: true
|
readonly: true
|
||||||
});
|
});
|
||||||
database.function("userFn_dateIntegerToString", dateIntegerToString);
|
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
||||||
const lotOccupancy = database
|
const lotOccupancy = database
|
||||||
.prepare(`select o.lotOccupancyId,
|
.prepare(`select o.lotOccupancyId,
|
||||||
o.occupancyTypeId, t.occupancyType,
|
o.occupancyTypeId, t.occupancyType,
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,31 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from 'better-sqlite3'
|
||||||
|
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||||
|
|
||||||
import { dateIntegerToString } from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
import { dateIntegerToString } from '@cityssm/expressjs-server-js/dateTimeFns.js'
|
||||||
|
|
||||||
import { getLotOccupancyOccupants } from "./getLotOccupancyOccupants.js";
|
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js'
|
||||||
import { getLotOccupancyComments } from "./getLotOccupancyComments.js";
|
import { getLotOccupancyComments } from './getLotOccupancyComments.js'
|
||||||
import { getLotOccupancyFields } from "./getLotOccupancyFields.js";
|
import { getLotOccupancyFields } from './getLotOccupancyFields.js'
|
||||||
import { getLotOccupancyFees } from "./getLotOccupancyFees.js";
|
import { getLotOccupancyFees } from './getLotOccupancyFees.js'
|
||||||
import { getLotOccupancyTransactions } from "./getLotOccupancyTransactions.js";
|
import { getLotOccupancyTransactions } from './getLotOccupancyTransactions.js'
|
||||||
import { getWorkOrders } from "./getWorkOrders.js";
|
import { getWorkOrders } from './getWorkOrders.js'
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from '../../types/recordTypes'
|
||||||
|
|
||||||
export function getLotOccupancy(
|
export function getLotOccupancy(
|
||||||
lotOccupancyId: number | string,
|
lotOccupancyId: number | string,
|
||||||
connectedDatabase?: sqlite.Database
|
connectedDatabase?: sqlite.Database
|
||||||
): recordTypes.LotOccupancy {
|
): recordTypes.LotOccupancy | undefined {
|
||||||
const database =
|
const database =
|
||||||
connectedDatabase ||
|
connectedDatabase ??
|
||||||
sqlite(databasePath, {
|
sqlite(databasePath, {
|
||||||
readonly: true
|
readonly: true
|
||||||
});
|
})
|
||||||
|
|
||||||
database.function("userFn_dateIntegerToString", dateIntegerToString);
|
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||||
|
|
||||||
const lotOccupancy: recordTypes.LotOccupancy = database
|
const lotOccupancy: recordTypes.LotOccupancy | undefined = database
|
||||||
.prepare(
|
.prepare(
|
||||||
`select o.lotOccupancyId,
|
`select o.lotOccupancyId,
|
||||||
o.occupancyTypeId, t.occupancyType,
|
o.occupancyTypeId, t.occupancyType,
|
||||||
|
|
@ -41,17 +41,29 @@ export function getLotOccupancy(
|
||||||
where o.recordDelete_timeMillis is null
|
where o.recordDelete_timeMillis is null
|
||||||
and o.lotOccupancyId = ?`
|
and o.lotOccupancyId = ?`
|
||||||
)
|
)
|
||||||
.get(lotOccupancyId);
|
.get(lotOccupancyId)
|
||||||
|
|
||||||
if (lotOccupancy) {
|
if (lotOccupancy) {
|
||||||
lotOccupancy.lotOccupancyFields = getLotOccupancyFields(lotOccupancyId, database);
|
lotOccupancy.lotOccupancyFields = getLotOccupancyFields(
|
||||||
lotOccupancy.lotOccupancyOccupants = getLotOccupancyOccupants(lotOccupancyId, database);
|
lotOccupancyId,
|
||||||
lotOccupancy.lotOccupancyComments = getLotOccupancyComments(lotOccupancyId, database);
|
database
|
||||||
lotOccupancy.lotOccupancyFees = getLotOccupancyFees(lotOccupancyId, database);
|
)
|
||||||
|
lotOccupancy.lotOccupancyOccupants = getLotOccupancyOccupants(
|
||||||
|
lotOccupancyId,
|
||||||
|
database
|
||||||
|
)
|
||||||
|
lotOccupancy.lotOccupancyComments = getLotOccupancyComments(
|
||||||
|
lotOccupancyId,
|
||||||
|
database
|
||||||
|
)
|
||||||
|
lotOccupancy.lotOccupancyFees = getLotOccupancyFees(
|
||||||
|
lotOccupancyId,
|
||||||
|
database
|
||||||
|
)
|
||||||
lotOccupancy.lotOccupancyTransactions = getLotOccupancyTransactions(
|
lotOccupancy.lotOccupancyTransactions = getLotOccupancyTransactions(
|
||||||
lotOccupancyId,
|
lotOccupancyId,
|
||||||
database
|
database
|
||||||
);
|
)
|
||||||
|
|
||||||
lotOccupancy.workOrders = getWorkOrders(
|
lotOccupancy.workOrders = getWorkOrders(
|
||||||
{
|
{
|
||||||
|
|
@ -62,14 +74,14 @@ export function getLotOccupancy(
|
||||||
offset: 0
|
offset: 0
|
||||||
},
|
},
|
||||||
database
|
database
|
||||||
).workOrders;
|
).workOrders
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!connectedDatabase) {
|
if (!connectedDatabase) {
|
||||||
database.close();
|
database.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
return lotOccupancy;
|
return lotOccupancy
|
||||||
}
|
}
|
||||||
|
|
||||||
export default getLotOccupancy;
|
export default getLotOccupancy
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@
|
||||||
"cypress": "^12.3.0",
|
"cypress": "^12.3.0",
|
||||||
"cypress-axe": "^1.2.0",
|
"cypress-axe": "^1.2.0",
|
||||||
"eslint": "^8.31.0",
|
"eslint": "^8.31.0",
|
||||||
|
"eslint-config-standard-with-typescript": "^26.0.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-promise": "^6.1.1",
|
"eslint-plugin-promise": "^6.1.1",
|
||||||
|
|
@ -2442,6 +2443,16 @@
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/builtins": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/builtins/-/builtins-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==",
|
||||||
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"semver": "^7.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/bulma": {
|
"node_modules/bulma": {
|
||||||
"version": "0.9.4",
|
"version": "0.9.4",
|
||||||
"resolved": "https://registry.npmjs.org/bulma/-/bulma-0.9.4.tgz",
|
"resolved": "https://registry.npmjs.org/bulma/-/bulma-0.9.4.tgz",
|
||||||
|
|
@ -4020,6 +4031,50 @@
|
||||||
"url": "https://opencollective.com/eslint"
|
"url": "https://opencollective.com/eslint"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/eslint-config-standard": {
|
||||||
|
"version": "17.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-17.0.0.tgz",
|
||||||
|
"integrity": "sha512-/2ks1GKyqSOkH7JFvXJicu0iMpoojkwB+f5Du/1SC0PtBL+s8v30k9njRZ21pm2drKYm2342jFnGWzttxPmZVg==",
|
||||||
|
"dev": true,
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patreon",
|
||||||
|
"url": "https://www.patreon.com/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "consulting",
|
||||||
|
"url": "https://feross.org/support"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"peerDependencies": {
|
||||||
|
"eslint": "^8.0.1",
|
||||||
|
"eslint-plugin-import": "^2.25.2",
|
||||||
|
"eslint-plugin-n": "^15.0.0",
|
||||||
|
"eslint-plugin-promise": "^6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/eslint-config-standard-with-typescript": {
|
||||||
|
"version": "26.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-26.0.0.tgz",
|
||||||
|
"integrity": "sha512-TluIWunQo76qp4MHyYIaTT+sN2q2v/jTeE3Dj4rXsSbx27GOUEOujhJaAL3v9dHVQelAK13gZ5Jy9IWnWCyFrg==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@typescript-eslint/parser": "^5.0.0",
|
||||||
|
"eslint-config-standard": "17.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
||||||
|
"eslint": "^8.0.1",
|
||||||
|
"eslint-plugin-import": "^2.25.2",
|
||||||
|
"eslint-plugin-n": "^15.0.0",
|
||||||
|
"eslint-plugin-promise": "^6.0.0",
|
||||||
|
"typescript": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/eslint-import-resolver-node": {
|
"node_modules/eslint-import-resolver-node": {
|
||||||
"version": "0.3.6",
|
"version": "0.3.6",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz",
|
||||||
|
|
@ -4158,6 +4213,78 @@
|
||||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/eslint-plugin-n": {
|
||||||
|
"version": "15.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-15.6.1.tgz",
|
||||||
|
"integrity": "sha512-R9xw9OtCRxxaxaszTQmQAlPgM+RdGjaL1akWuY/Fv9fRAi8Wj4CUKc6iYVG8QNRjRuo8/BqVYIpfqberJUEacA==",
|
||||||
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"builtins": "^5.0.1",
|
||||||
|
"eslint-plugin-es": "^4.1.0",
|
||||||
|
"eslint-utils": "^3.0.0",
|
||||||
|
"ignore": "^5.1.1",
|
||||||
|
"is-core-module": "^2.11.0",
|
||||||
|
"minimatch": "^3.1.2",
|
||||||
|
"resolve": "^1.22.1",
|
||||||
|
"semver": "^7.3.8"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.22.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/mysticatea"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"eslint": ">=7.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/eslint-plugin-n/node_modules/eslint-plugin-es": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-GILhQTnjYE2WorX5Jyi5i4dz5ALWxBIdQECVQavL6s7cI76IZTDWleTHkxz/QT3kvcs2QlGHvKLYsSlPOlPXnQ==",
|
||||||
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"eslint-utils": "^2.0.0",
|
||||||
|
"regexpp": "^3.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.10.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/mysticatea"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"eslint": ">=4.19.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/eslint-plugin-n/node_modules/eslint-plugin-es/node_modules/eslint-utils": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==",
|
||||||
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"eslint-visitor-keys": "^1.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/mysticatea"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/eslint-plugin-n/node_modules/eslint-visitor-keys": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
|
||||||
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/eslint-plugin-node": {
|
"node_modules/eslint-plugin-node": {
|
||||||
"version": "11.1.0",
|
"version": "11.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz",
|
||||||
|
|
@ -7032,9 +7159,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/is-core-module": {
|
"node_modules/is-core-module": {
|
||||||
"version": "2.9.0",
|
"version": "2.11.0",
|
||||||
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz",
|
||||||
"integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==",
|
"integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"has": "^1.0.3"
|
"has": "^1.0.3"
|
||||||
|
|
@ -14465,6 +14592,16 @@
|
||||||
"integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==",
|
"integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"builtins": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/builtins/-/builtins-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==",
|
||||||
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
|
"requires": {
|
||||||
|
"semver": "^7.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"bulma": {
|
"bulma": {
|
||||||
"version": "0.9.4",
|
"version": "0.9.4",
|
||||||
"resolved": "https://registry.npmjs.org/bulma/-/bulma-0.9.4.tgz",
|
"resolved": "https://registry.npmjs.org/bulma/-/bulma-0.9.4.tgz",
|
||||||
|
|
@ -15761,6 +15898,23 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"eslint-config-standard": {
|
||||||
|
"version": "17.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-17.0.0.tgz",
|
||||||
|
"integrity": "sha512-/2ks1GKyqSOkH7JFvXJicu0iMpoojkwB+f5Du/1SC0PtBL+s8v30k9njRZ21pm2drKYm2342jFnGWzttxPmZVg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {}
|
||||||
|
},
|
||||||
|
"eslint-config-standard-with-typescript": {
|
||||||
|
"version": "26.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-26.0.0.tgz",
|
||||||
|
"integrity": "sha512-TluIWunQo76qp4MHyYIaTT+sN2q2v/jTeE3Dj4rXsSbx27GOUEOujhJaAL3v9dHVQelAK13gZ5Jy9IWnWCyFrg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@typescript-eslint/parser": "^5.0.0",
|
||||||
|
"eslint-config-standard": "17.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"eslint-import-resolver-node": {
|
"eslint-import-resolver-node": {
|
||||||
"version": "0.3.6",
|
"version": "0.3.6",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz",
|
||||||
|
|
@ -15877,6 +16031,55 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"eslint-plugin-n": {
|
||||||
|
"version": "15.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-15.6.1.tgz",
|
||||||
|
"integrity": "sha512-R9xw9OtCRxxaxaszTQmQAlPgM+RdGjaL1akWuY/Fv9fRAi8Wj4CUKc6iYVG8QNRjRuo8/BqVYIpfqberJUEacA==",
|
||||||
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
|
"requires": {
|
||||||
|
"builtins": "^5.0.1",
|
||||||
|
"eslint-plugin-es": "^4.1.0",
|
||||||
|
"eslint-utils": "^3.0.0",
|
||||||
|
"ignore": "^5.1.1",
|
||||||
|
"is-core-module": "^2.11.0",
|
||||||
|
"minimatch": "^3.1.2",
|
||||||
|
"resolve": "^1.22.1",
|
||||||
|
"semver": "^7.3.8"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"eslint-plugin-es": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-GILhQTnjYE2WorX5Jyi5i4dz5ALWxBIdQECVQavL6s7cI76IZTDWleTHkxz/QT3kvcs2QlGHvKLYsSlPOlPXnQ==",
|
||||||
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
|
"requires": {
|
||||||
|
"eslint-utils": "^2.0.0",
|
||||||
|
"regexpp": "^3.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"eslint-utils": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==",
|
||||||
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
|
"requires": {
|
||||||
|
"eslint-visitor-keys": "^1.1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"eslint-visitor-keys": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
|
||||||
|
"dev": true,
|
||||||
|
"peer": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"eslint-plugin-node": {
|
"eslint-plugin-node": {
|
||||||
"version": "11.1.0",
|
"version": "11.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz",
|
||||||
|
|
@ -17998,9 +18201,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"is-core-module": {
|
"is-core-module": {
|
||||||
"version": "2.9.0",
|
"version": "2.11.0",
|
||||||
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz",
|
||||||
"integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==",
|
"integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"has": "^1.0.3"
|
"has": "^1.0.3"
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,7 @@
|
||||||
"cypress": "^12.3.0",
|
"cypress": "^12.3.0",
|
||||||
"cypress-axe": "^1.2.0",
|
"cypress-axe": "^1.2.0",
|
||||||
"eslint": "^8.31.0",
|
"eslint": "^8.31.0",
|
||||||
|
"eslint-config-standard-with-typescript": "^26.0.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-promise": "^6.1.1",
|
"eslint-plugin-promise": "^6.1.1",
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,13 @@ async function importMaps() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (_a) {
|
catch {
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
try {
|
try {
|
||||||
pool.close();
|
pool.close();
|
||||||
}
|
}
|
||||||
catch (_b) {
|
catch {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ describe("lot-occupancy-system", () => {
|
||||||
try {
|
try {
|
||||||
httpServer.close();
|
httpServer.close();
|
||||||
}
|
}
|
||||||
catch (_a) {
|
catch {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("Ensure server starts on port " + portNumber.toString(), () => {
|
it("Ensure server starts on port " + portNumber.toString(), () => {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,3 @@
|
||||||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
||||||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
||||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
||||||
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
||||||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
||||||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
||||||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
||||||
function fulfill(value) { resume("next", value); }
|
|
||||||
function reject(value) { resume("throw", value); }
|
|
||||||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
||||||
};
|
|
||||||
export const testView = "*testView";
|
export const testView = "*testView";
|
||||||
export const testUpdate = "*testUpdate";
|
export const testUpdate = "*testUpdate";
|
||||||
export const testAdmin = "*testAdmin";
|
export const testAdmin = "*testAdmin";
|
||||||
|
|
@ -37,7 +25,7 @@ export const fakeAdminSession = {
|
||||||
user: undefined
|
user: undefined
|
||||||
};
|
};
|
||||||
export const fakeRequest = {
|
export const fakeRequest = {
|
||||||
[Symbol.asyncIterator]() { return __asyncGenerator(this, arguments, function* _a() { }); },
|
async *[Symbol.asyncIterator]() { },
|
||||||
_destroy: undefined,
|
_destroy: undefined,
|
||||||
_read: undefined,
|
_read: undefined,
|
||||||
aborted: undefined,
|
aborted: undefined,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es2017",
|
"target": "es2022",
|
||||||
"module": "es2022",
|
"module": "es2022",
|
||||||
"moduleResolution": "Node",
|
"moduleResolution": "Node",
|
||||||
"isolatedModules": false,
|
"isolatedModules": false,
|
||||||
|
|
@ -11,7 +11,8 @@
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"skipLibCheck": true
|
"skipLibCheck": true,
|
||||||
|
"strictNullChecks": true
|
||||||
},
|
},
|
||||||
"compileOnSave": true,
|
"compileOnSave": true,
|
||||||
"buildOnSave": true,
|
"buildOnSave": true,
|
||||||
|
|
|
||||||
|
|
@ -258,11 +258,11 @@ export interface UserProperties {
|
||||||
isAdmin: boolean;
|
isAdmin: boolean;
|
||||||
apiKey: string;
|
apiKey: string;
|
||||||
}
|
}
|
||||||
declare module "express-session" {
|
declare module 'express-session' {
|
||||||
interface Session {
|
interface Session {
|
||||||
user: User;
|
user?: User;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export interface PartialSession {
|
export interface PartialSession {
|
||||||
user: User;
|
user?: User;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue