reformatting with prettier
parent
765bb5220b
commit
77db067a5e
|
|
@ -9,10 +9,7 @@
|
||||||
"ecmaVersion": 2020,
|
"ecmaVersion": 2020,
|
||||||
"sourceType": "module"
|
"sourceType": "module"
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": ["@typescript-eslint", "unicorn"],
|
||||||
"@typescript-eslint",
|
|
||||||
"unicorn"
|
|
||||||
],
|
|
||||||
"extends": [
|
"extends": [
|
||||||
"eslint:recommended",
|
"eslint:recommended",
|
||||||
"plugin:import/recommended",
|
"plugin:import/recommended",
|
||||||
|
|
@ -27,17 +24,16 @@
|
||||||
"unicorn/consistent-function-scoping": "warn",
|
"unicorn/consistent-function-scoping": "warn",
|
||||||
"unicorn/empty-brace-spaces": "off",
|
"unicorn/empty-brace-spaces": "off",
|
||||||
"unicorn/filename-case": [
|
"unicorn/filename-case": [
|
||||||
"error", {
|
"error",
|
||||||
|
{
|
||||||
"case": "camelCase",
|
"case": "camelCase",
|
||||||
"ignore": [
|
"ignore": ["DB", "URL"]
|
||||||
"DB",
|
|
||||||
"URL"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"unicorn/prefer-node-protocol": "off",
|
"unicorn/prefer-node-protocol": "off",
|
||||||
"unicorn/prevent-abbreviations": [
|
"unicorn/prevent-abbreviations": [
|
||||||
"error", {
|
"error",
|
||||||
|
{
|
||||||
"replacements": {
|
"replacements": {
|
||||||
"def": {
|
"def": {
|
||||||
"definition": true
|
"definition": true
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
{
|
{
|
||||||
"reject": [
|
"reject": ["@fortawesome/fontawesome-free"]
|
||||||
"@fortawesome/fontawesome-free"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
11
bin/www.ts
11
bin/www.ts
|
|
@ -11,24 +11,20 @@ import exitHook from "exit-hook";
|
||||||
import debug from "debug";
|
import debug from "debug";
|
||||||
const debugWWW = debug("lot-occupancy-system:www");
|
const debugWWW = debug("lot-occupancy-system:www");
|
||||||
|
|
||||||
|
|
||||||
let httpServer: http.Server;
|
let httpServer: http.Server;
|
||||||
|
|
||||||
|
|
||||||
interface ServerError extends Error {
|
interface ServerError extends Error {
|
||||||
syscall: string;
|
syscall: string;
|
||||||
code: string;
|
code: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const onError = (error: ServerError) => {
|
const onError = (error: ServerError) => {
|
||||||
|
|
||||||
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":
|
||||||
debugWWW("Requires elevated privileges");
|
debugWWW("Requires elevated privileges");
|
||||||
|
|
@ -48,10 +44,10 @@ const onError = (error: ServerError) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onListening = (server: http.Server) => {
|
const onListening = (server: http.Server) => {
|
||||||
|
|
||||||
const addr = server.address();
|
const addr = server.address();
|
||||||
|
|
||||||
const bind = typeof addr === "string"
|
const bind =
|
||||||
|
typeof addr === "string"
|
||||||
? "pipe " + addr
|
? "pipe " + addr
|
||||||
: "port " + addr.port.toString();
|
: "port " + addr.port.toString();
|
||||||
|
|
||||||
|
|
@ -65,7 +61,6 @@ const onListening = (server: http.Server) => {
|
||||||
const httpPort = configFunctions.getProperty("application.httpPort");
|
const httpPort = configFunctions.getProperty("application.httpPort");
|
||||||
|
|
||||||
if (httpPort) {
|
if (httpPort) {
|
||||||
|
|
||||||
httpServer = http.createServer(app);
|
httpServer = http.createServer(app);
|
||||||
|
|
||||||
httpServer.listen(httpPort);
|
httpServer.listen(httpPort);
|
||||||
|
|
@ -78,9 +73,7 @@ if (httpPort) {
|
||||||
debugWWW("HTTP listening on " + httpPort.toString());
|
debugWWW("HTTP listening on " + httpPort.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
exitHook(() => {
|
exitHook(() => {
|
||||||
|
|
||||||
if (httpServer) {
|
if (httpServer) {
|
||||||
debugWWW("Closing HTTP");
|
debugWWW("Closing HTTP");
|
||||||
httpServer.close();
|
httpServer.close();
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,6 @@
|
||||||
import {
|
import { logout } from "../../support/index.js";
|
||||||
logout
|
|
||||||
} from "../../support/index.js";
|
|
||||||
|
|
||||||
|
|
||||||
describe("Login Page", () => {
|
describe("Login Page", () => {
|
||||||
|
|
||||||
before(logout);
|
before(logout);
|
||||||
|
|
||||||
it("Has no detectable accessibility issues", () => {
|
it("Has no detectable accessibility issues", () => {
|
||||||
|
|
@ -29,7 +25,7 @@ describe("Login Page", () => {
|
||||||
.should("have.length", 1)
|
.should("have.length", 1)
|
||||||
.invoke("attr", "type")
|
.invoke("attr", "type")
|
||||||
.should("equal", "password");
|
.should("equal", "password");
|
||||||
})
|
});
|
||||||
|
|
||||||
it("Contains a help link", () => {
|
it("Contains a help link", () => {
|
||||||
cy.get("a").contains("help", {
|
cy.get("a").contains("help", {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
import type { RequestHandler } from "express";
|
import type { RequestHandler } from "express";
|
||||||
|
|
||||||
|
|
||||||
export const handler: RequestHandler = (_request, response) => {
|
export const handler: RequestHandler = (_request, response) => {
|
||||||
|
|
||||||
response.render("dashboard", {
|
response.render("dashboard", {
|
||||||
headTitle: "Dashboard"
|
headTitle: "Dashboard"
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,16 @@ 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") + "/lotOccupancies/?error=lotOccupancyIdNotFound");
|
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lotOccupancies/?error=lotOccupancyIdNotFound");
|
||||||
}
|
}
|
||||||
const occupancyTypes = getOccupancyTypes();
|
const occupancyTypes = getOccupancyTypes();
|
||||||
const lotOccupantTypes = getLotOccupantTypes();
|
const lotOccupantTypes = getLotOccupantTypes();
|
||||||
return response.render("lotOccupancy-edit", {
|
return response.render("lotOccupancy-edit", {
|
||||||
headTitle: configFunctions.getProperty("aliases.lot") + " " + configFunctions.getProperty("aliases.occupancy") + " Update",
|
headTitle: configFunctions.getProperty("aliases.lot") +
|
||||||
|
" " +
|
||||||
|
configFunctions.getProperty("aliases.occupancy") +
|
||||||
|
" Update",
|
||||||
lotOccupancy,
|
lotOccupancy,
|
||||||
occupancyTypes,
|
occupancyTypes,
|
||||||
lotOccupantTypes,
|
lotOccupantTypes,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getLotOccupantTypes,
|
getLotOccupantTypes,
|
||||||
|
|
@ -9,24 +7,27 @@ import {
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
|
||||||
import {
|
import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js";
|
||||||
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(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lotOccupancies/?error=lotOccupancyIdNotFound");
|
return response.redirect(
|
||||||
|
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lotOccupancies/?error=lotOccupancyIdNotFound"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const occupancyTypes = getOccupancyTypes();
|
const occupancyTypes = getOccupancyTypes();
|
||||||
const lotOccupantTypes = getLotOccupantTypes();
|
const lotOccupantTypes = getLotOccupantTypes();
|
||||||
|
|
||||||
return response.render("lotOccupancy-edit", {
|
return response.render("lotOccupancy-edit", {
|
||||||
headTitle: configFunctions.getProperty("aliases.lot") + " " + configFunctions.getProperty("aliases.occupancy") + " Update",
|
headTitle:
|
||||||
|
configFunctions.getProperty("aliases.lot") +
|
||||||
|
" " +
|
||||||
|
configFunctions.getProperty("aliases.occupancy") +
|
||||||
|
" Update",
|
||||||
lotOccupancy,
|
lotOccupancy,
|
||||||
|
|
||||||
occupancyTypes,
|
occupancyTypes,
|
||||||
|
|
@ -35,5 +36,4 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -17,7 +17,11 @@ export const handler = (request, response) => {
|
||||||
}
|
}
|
||||||
const occupancyTypes = getOccupancyTypes();
|
const occupancyTypes = getOccupancyTypes();
|
||||||
return response.render("lotOccupancy-edit", {
|
return response.render("lotOccupancy-edit", {
|
||||||
headTitle: "Create a New " + configFunctions.getProperty("aliases.lot") + " " + configFunctions.getProperty("aliases.occupancy") + " Record",
|
headTitle: "Create a New " +
|
||||||
|
configFunctions.getProperty("aliases.lot") +
|
||||||
|
" " +
|
||||||
|
configFunctions.getProperty("aliases.occupancy") +
|
||||||
|
" Record",
|
||||||
lotOccupancy,
|
lotOccupancy,
|
||||||
occupancyTypes,
|
occupancyTypes,
|
||||||
isCreate: true
|
isCreate: true
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,19 @@
|
||||||
|
import type { RequestHandler } from "express";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
dateToInteger,
|
dateToInteger,
|
||||||
dateToString
|
dateToString
|
||||||
} from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
} from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||||
import type {
|
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
import { getOccupancyTypes } from "../../helpers/functions.cache.js";
|
||||||
getOccupancyTypes
|
|
||||||
} from "../../helpers/functions.cache.js";
|
|
||||||
|
|
||||||
import {
|
import { getLot } from "../../helpers/lotOccupancyDB/getLot.js";
|
||||||
getLot
|
|
||||||
} from "../../helpers/lotOccupancyDB/getLot.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";
|
||||||
|
|
||||||
|
|
||||||
export const handler: RequestHandler = (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
|
|
||||||
const startDate = new Date();
|
const startDate = new Date();
|
||||||
|
|
||||||
const lotOccupancy: recordTypes.LotOccupancy = {
|
const lotOccupancy: recordTypes.LotOccupancy = {
|
||||||
|
|
@ -39,7 +32,12 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
const occupancyTypes = getOccupancyTypes();
|
const occupancyTypes = getOccupancyTypes();
|
||||||
|
|
||||||
return response.render("lotOccupancy-edit", {
|
return response.render("lotOccupancy-edit", {
|
||||||
headTitle: "Create a New " + configFunctions.getProperty("aliases.lot") + " " + configFunctions.getProperty("aliases.occupancy") + " Record",
|
headTitle:
|
||||||
|
"Create a New " +
|
||||||
|
configFunctions.getProperty("aliases.lot") +
|
||||||
|
" " +
|
||||||
|
configFunctions.getProperty("aliases.occupancy") +
|
||||||
|
" Record",
|
||||||
lotOccupancy,
|
lotOccupancy,
|
||||||
|
|
||||||
occupancyTypes,
|
occupancyTypes,
|
||||||
|
|
@ -47,5 +45,4 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -3,10 +3,14 @@ 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") + "/lotOccupancies/?error=lotOccupancyIdNotFound");
|
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lotOccupancies/?error=lotOccupancyIdNotFound");
|
||||||
}
|
}
|
||||||
return response.render("lotOccupancy-print", {
|
return response.render("lotOccupancy-print", {
|
||||||
headTitle: configFunctions.getProperty("aliases.lot") + " " + configFunctions.getProperty("aliases.occupancy") + " Print",
|
headTitle: configFunctions.getProperty("aliases.lot") +
|
||||||
|
" " +
|
||||||
|
configFunctions.getProperty("aliases.occupancy") +
|
||||||
|
" Print",
|
||||||
lotOccupancy
|
lotOccupancy
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,27 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
|
||||||
import {
|
import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js";
|
||||||
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(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lotOccupancies/?error=lotOccupancyIdNotFound");
|
return response.redirect(
|
||||||
|
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lotOccupancies/?error=lotOccupancyIdNotFound"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.render("lotOccupancy-print", {
|
return response.render("lotOccupancy-print", {
|
||||||
headTitle: configFunctions.getProperty("aliases.lot") + " " + configFunctions.getProperty("aliases.occupancy") + " Print",
|
headTitle:
|
||||||
|
configFunctions.getProperty("aliases.lot") +
|
||||||
|
" " +
|
||||||
|
configFunctions.getProperty("aliases.occupancy") +
|
||||||
|
" Print",
|
||||||
lotOccupancy
|
lotOccupancy
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,24 +1,22 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
|
||||||
|
import { getMaps } from "../../helpers/lotOccupancyDB/getMaps.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getMaps
|
getLotTypes,
|
||||||
} from "../../helpers/lotOccupancyDB/getMaps.js";
|
getOccupancyTypes
|
||||||
|
} from "../../helpers/functions.cache.js";
|
||||||
import { getLotTypes, getOccupancyTypes } from "../../helpers/functions.cache.js";
|
|
||||||
|
|
||||||
|
|
||||||
export const handler: RequestHandler = (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
|
|
||||||
const maps = getMaps();
|
const maps = getMaps();
|
||||||
const lotTypes = getLotTypes();
|
const lotTypes = getLotTypes();
|
||||||
const occupancyTypes = getOccupancyTypes();
|
const occupancyTypes = getOccupancyTypes();
|
||||||
|
|
||||||
response.render("lotOccupancy-search", {
|
response.render("lotOccupancy-search", {
|
||||||
headTitle: configFunctions.getProperty("aliases.lot") + " Occupancy Search",
|
headTitle:
|
||||||
|
configFunctions.getProperty("aliases.lot") + " Occupancy Search",
|
||||||
maps,
|
maps,
|
||||||
lotTypes,
|
lotTypes,
|
||||||
occupancyTypes,
|
occupancyTypes,
|
||||||
|
|
@ -26,5 +24,4 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -3,10 +3,14 @@ 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") + "/lotOccupancies/?error=lotOccupancyIdNotFound");
|
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lotOccupancies/?error=lotOccupancyIdNotFound");
|
||||||
}
|
}
|
||||||
return response.render("lotOccupancy-view", {
|
return response.render("lotOccupancy-view", {
|
||||||
headTitle: configFunctions.getProperty("aliases.lot") + " " + configFunctions.getProperty("aliases.occupancy") + " View",
|
headTitle: configFunctions.getProperty("aliases.lot") +
|
||||||
|
" " +
|
||||||
|
configFunctions.getProperty("aliases.occupancy") +
|
||||||
|
" View",
|
||||||
lotOccupancy
|
lotOccupancy
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,27 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
|
||||||
import {
|
import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js";
|
||||||
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(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lotOccupancies/?error=lotOccupancyIdNotFound");
|
return response.redirect(
|
||||||
|
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lotOccupancies/?error=lotOccupancyIdNotFound"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.render("lotOccupancy-view", {
|
return response.render("lotOccupancy-view", {
|
||||||
headTitle: configFunctions.getProperty("aliases.lot") + " " + configFunctions.getProperty("aliases.occupancy") + " View",
|
headTitle:
|
||||||
|
configFunctions.getProperty("aliases.lot") +
|
||||||
|
" " +
|
||||||
|
configFunctions.getProperty("aliases.occupancy") +
|
||||||
|
" View",
|
||||||
lotOccupancy
|
lotOccupancy
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,21 +1,15 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
import { addLotOccupancyComment } from "../../helpers/lotOccupancyDB/addLotOccupancyComment.js";
|
||||||
addLotOccupancyComment
|
|
||||||
} from "../../helpers/lotOccupancyDB/addLotOccupancyComment.js";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getLotOccupancyComments
|
|
||||||
} from "../../helpers/lotOccupancyDB/getLotOccupancyComments.js";
|
|
||||||
|
|
||||||
|
import { getLotOccupancyComments } from "../../helpers/lotOccupancyDB/getLotOccupancyComments.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
addLotOccupancyComment(request.body, request.session);
|
addLotOccupancyComment(request.body, request.session);
|
||||||
|
|
||||||
const lotOccupancyComments = getLotOccupancyComments(request.body.lotOccupancyId);
|
const lotOccupancyComments = getLotOccupancyComments(
|
||||||
|
request.body.lotOccupancyId
|
||||||
|
);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
success: true,
|
success: true,
|
||||||
|
|
@ -23,5 +17,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,18 +1,10 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
import { addLotOccupancyFee } from "../../helpers/lotOccupancyDB/addLotOccupancyFee.js";
|
||||||
addLotOccupancyFee
|
|
||||||
} from "../../helpers/lotOccupancyDB/addLotOccupancyFee.js";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getLotOccupancyFees
|
|
||||||
} from "../../helpers/lotOccupancyDB/getLotOccupancyFees.js";
|
|
||||||
|
|
||||||
|
import { getLotOccupancyFees } from "../../helpers/lotOccupancyDB/getLotOccupancyFees.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
addLotOccupancyFee(request.body, request.session);
|
addLotOccupancyFee(request.body, request.session);
|
||||||
|
|
||||||
const lotOccupancyFees = getLotOccupancyFees(request.body.lotOccupancyId);
|
const lotOccupancyFees = getLotOccupancyFees(request.body.lotOccupancyId);
|
||||||
|
|
@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,21 +1,15 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
import { addLotOccupancyOccupant } from "../../helpers/lotOccupancyDB/addLotOccupancyOccupant.js";
|
||||||
addLotOccupancyOccupant
|
|
||||||
} from "../../helpers/lotOccupancyDB/addLotOccupancyOccupant.js";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getLotOccupancyOccupants
|
|
||||||
} from "../../helpers/lotOccupancyDB/getLotOccupancyOccupants.js";
|
|
||||||
|
|
||||||
|
import { getLotOccupancyOccupants } from "../../helpers/lotOccupancyDB/getLotOccupancyOccupants.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
addLotOccupancyOccupant(request.body, request.session);
|
addLotOccupancyOccupant(request.body, request.session);
|
||||||
|
|
||||||
const lotOccupancyOccupants = getLotOccupancyOccupants(request.body.lotOccupancyId);
|
const lotOccupancyOccupants = getLotOccupancyOccupants(
|
||||||
|
request.body.lotOccupancyId
|
||||||
|
);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
success: true,
|
success: true,
|
||||||
|
|
@ -23,5 +17,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,21 +1,15 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
import { addLotOccupancyTransaction } from "../../helpers/lotOccupancyDB/addLotOccupancyTransaction.js";
|
||||||
addLotOccupancyTransaction
|
|
||||||
} from "../../helpers/lotOccupancyDB/addLotOccupancyTransaction.js";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getLotOccupancyTransactions
|
|
||||||
} from "../../helpers/lotOccupancyDB/getLotOccupancyTransactions.js";
|
|
||||||
|
|
||||||
|
import { getLotOccupancyTransactions } from "../../helpers/lotOccupancyDB/getLotOccupancyTransactions.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
addLotOccupancyTransaction(request.body, request.session);
|
addLotOccupancyTransaction(request.body, request.session);
|
||||||
|
|
||||||
const lotOccupancyTransactions = getLotOccupancyTransactions(request.body.lotOccupancyId);
|
const lotOccupancyTransactions = getLotOccupancyTransactions(
|
||||||
|
request.body.lotOccupancyId
|
||||||
|
);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
success: true,
|
success: true,
|
||||||
|
|
@ -23,5 +17,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,14 +1,8 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
|
||||||
addLotOccupancy
|
|
||||||
} from "../../helpers/lotOccupancyDB/addLotOccupancy.js";
|
|
||||||
|
|
||||||
|
import { addLotOccupancy } from "../../helpers/lotOccupancyDB/addLotOccupancy.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
const lotOccupancyId = addLotOccupancy(request.body, request.session);
|
const lotOccupancyId = addLotOccupancy(request.body, request.session);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
|
|
@ -17,5 +11,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,20 +1,16 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
|
||||||
deleteLotOccupancy
|
|
||||||
} from "../../helpers/lotOccupancyDB/deleteLotOccupancy.js";
|
|
||||||
|
|
||||||
|
import { deleteLotOccupancy } from "../../helpers/lotOccupancyDB/deleteLotOccupancy.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
const success = deleteLotOccupancy(
|
||||||
const success = deleteLotOccupancy(request.body.lotOccupancyId, request.session);
|
request.body.lotOccupancyId,
|
||||||
|
request.session
|
||||||
|
);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
success
|
success
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,19 +1,18 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
import { deleteLotOccupancyComment } from "../../helpers/lotOccupancyDB/deleteLotOccupancyComment.js";
|
||||||
deleteLotOccupancyComment
|
|
||||||
} from "../../helpers/lotOccupancyDB/deleteLotOccupancyComment.js";
|
|
||||||
|
|
||||||
import {getLotOccupancyComments} from "../../helpers/lotOccupancyDB/getLotOccupancyComments.js";
|
|
||||||
|
|
||||||
|
import { getLotOccupancyComments } from "../../helpers/lotOccupancyDB/getLotOccupancyComments.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
const success = deleteLotOccupancyComment(
|
||||||
|
request.body.lotOccupancyCommentId,
|
||||||
|
request.session
|
||||||
|
);
|
||||||
|
|
||||||
const success = deleteLotOccupancyComment(request.body.lotOccupancyCommentId, request.session);
|
const lotOccupancyComments = getLotOccupancyComments(
|
||||||
|
request.body.lotOccupancyId
|
||||||
const lotOccupancyComments = getLotOccupancyComments(request.body.lotOccupancyId);
|
);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
|
|
@ -21,5 +20,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,19 +1,15 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
import { deleteLotOccupancyFee } from "../../helpers/lotOccupancyDB/deleteLotOccupancyFee.js";
|
||||||
deleteLotOccupancyFee
|
|
||||||
} from "../../helpers/lotOccupancyDB/deleteLotOccupancyFee.js";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getLotOccupancyFees
|
|
||||||
} from "../../helpers/lotOccupancyDB/getLotOccupancyFees.js";
|
|
||||||
|
|
||||||
|
import { getLotOccupancyFees } from "../../helpers/lotOccupancyDB/getLotOccupancyFees.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
const success = deleteLotOccupancyFee(
|
||||||
const success = deleteLotOccupancyFee(request.body.lotOccupancyId, request.body.feeId, request.session);
|
request.body.lotOccupancyId,
|
||||||
|
request.body.feeId,
|
||||||
|
request.session
|
||||||
|
);
|
||||||
|
|
||||||
const lotOccupancyFees = getLotOccupancyFees(request.body.lotOccupancyId);
|
const lotOccupancyFees = getLotOccupancyFees(request.body.lotOccupancyId);
|
||||||
|
|
||||||
|
|
@ -23,5 +19,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,21 +1,19 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
import { deleteLotOccupancyOccupant } from "../../helpers/lotOccupancyDB/deleteLotOccupancyOccupant.js";
|
||||||
deleteLotOccupancyOccupant
|
|
||||||
} from "../../helpers/lotOccupancyDB/deleteLotOccupancyOccupant.js";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getLotOccupancyOccupants
|
|
||||||
} from "../../helpers/lotOccupancyDB/getLotOccupancyOccupants.js";
|
|
||||||
|
|
||||||
|
import { getLotOccupancyOccupants } from "../../helpers/lotOccupancyDB/getLotOccupancyOccupants.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
const success = deleteLotOccupancyOccupant(
|
||||||
|
request.body.lotOccupancyId,
|
||||||
|
request.body.lotOccupantIndex,
|
||||||
|
request.session
|
||||||
|
);
|
||||||
|
|
||||||
const success = deleteLotOccupancyOccupant(request.body.lotOccupancyId, request.body.lotOccupantIndex, request.session);
|
const lotOccupancyOccupants = getLotOccupancyOccupants(
|
||||||
|
request.body.lotOccupancyId
|
||||||
const lotOccupancyOccupants = getLotOccupancyOccupants(request.body.lotOccupancyId);
|
);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
|
|
@ -23,5 +21,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,21 +1,19 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
import { deleteLotOccupancyTransaction } from "../../helpers/lotOccupancyDB/deleteLotOccupancyTransaction.js";
|
||||||
deleteLotOccupancyTransaction
|
|
||||||
} from "../../helpers/lotOccupancyDB/deleteLotOccupancyTransaction.js";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getLotOccupancyTransactions
|
|
||||||
} from "../../helpers/lotOccupancyDB/getLotOccupancyTransactions.js";
|
|
||||||
|
|
||||||
|
import { getLotOccupancyTransactions } from "../../helpers/lotOccupancyDB/getLotOccupancyTransactions.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
const success = deleteLotOccupancyTransaction(
|
||||||
|
request.body.lotOccupancyId,
|
||||||
|
request.body.transactionIndex,
|
||||||
|
request.session
|
||||||
|
);
|
||||||
|
|
||||||
const success = deleteLotOccupancyTransaction(request.body.lotOccupancyId, request.body.transactionIndex, request.session);
|
const lotOccupancyTransactions = getLotOccupancyTransactions(
|
||||||
|
request.body.lotOccupancyId
|
||||||
const lotOccupancyTransactions = getLotOccupancyTransactions(request.body.lotOccupancyId);
|
);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
|
|
@ -23,5 +21,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -10,7 +10,7 @@ export const handler = (request, response) => {
|
||||||
includeFees: true
|
includeFees: true
|
||||||
});
|
});
|
||||||
response.json({
|
response.json({
|
||||||
feeCategories,
|
feeCategories
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,27 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js";
|
||||||
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(
|
||||||
|
{
|
||||||
occupancyTypeId: lotOccupancy.occupancyTypeId,
|
occupancyTypeId: lotOccupancy.occupancyTypeId,
|
||||||
lotTypeId: lotOccupancy.lotTypeId
|
lotTypeId: lotOccupancy.lotTypeId
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
includeFees: true
|
includeFees: true
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
feeCategories,
|
feeCategories
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,18 +1,15 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import { getOccupancyTypeById } from "../../helpers/functions.cache.js";
|
import { getOccupancyTypeById } from "../../helpers/functions.cache.js";
|
||||||
|
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
const result = getOccupancyTypeById(
|
||||||
const result = getOccupancyTypeById(Number.parseInt(request.body.occupancyTypeId, 10));
|
Number.parseInt(request.body.occupancyTypeId, 10)
|
||||||
|
);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
occupancyTypeFields: result.occupancyTypeFields
|
occupancyTypeFields: result.occupancyTypeFields
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,14 +1,8 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getLotOccupancies
|
|
||||||
} from "../../helpers/lotOccupancyDB/getLotOccupancies.js";
|
|
||||||
|
|
||||||
|
import { getLotOccupancies } from "../../helpers/lotOccupancyDB/getLotOccupancies.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
const result = getLotOccupancies(request.body, {
|
const result = getLotOccupancies(request.body, {
|
||||||
limit: request.body.limit,
|
limit: request.body.limit,
|
||||||
offset: request.body.offset,
|
offset: request.body.offset,
|
||||||
|
|
@ -21,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,14 +1,8 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
|
||||||
updateLotOccupancy
|
|
||||||
} from "../../helpers/lotOccupancyDB/updateLotOccupancy.js";
|
|
||||||
|
|
||||||
|
import { updateLotOccupancy } from "../../helpers/lotOccupancyDB/updateLotOccupancy.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
const success = updateLotOccupancy(request.body, request.session);
|
const success = updateLotOccupancy(request.body, request.session);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
|
|
@ -17,5 +11,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,19 +1,15 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
import { updateLotOccupancyComment } from "../../helpers/lotOccupancyDB/updateLotOccupancyComment.js";
|
||||||
updateLotOccupancyComment
|
|
||||||
} from "../../helpers/lotOccupancyDB/updateLotOccupancyComment.js";
|
|
||||||
|
|
||||||
import {getLotOccupancyComments} from "../../helpers/lotOccupancyDB/getLotOccupancyComments.js";
|
|
||||||
|
|
||||||
|
import { getLotOccupancyComments } from "../../helpers/lotOccupancyDB/getLotOccupancyComments.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
const success = updateLotOccupancyComment(request.body, request.session);
|
const success = updateLotOccupancyComment(request.body, request.session);
|
||||||
|
|
||||||
const lotOccupancyComments = getLotOccupancyComments(request.body.lotOccupancyId);
|
const lotOccupancyComments = getLotOccupancyComments(
|
||||||
|
request.body.lotOccupancyId
|
||||||
|
);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
|
|
@ -21,5 +17,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,21 +1,15 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
import { updateLotOccupancyOccupant } from "../../helpers/lotOccupancyDB/updateLotOccupancyOccupant.js";
|
||||||
updateLotOccupancyOccupant
|
|
||||||
} from "../../helpers/lotOccupancyDB/updateLotOccupancyOccupant.js";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getLotOccupancyOccupants
|
|
||||||
} from "../../helpers/lotOccupancyDB/getLotOccupancyOccupants.js";
|
|
||||||
|
|
||||||
|
import { getLotOccupancyOccupants } from "../../helpers/lotOccupancyDB/getLotOccupancyOccupants.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
const success = updateLotOccupancyOccupant(request.body, request.session);
|
const success = updateLotOccupancyOccupant(request.body, request.session);
|
||||||
|
|
||||||
const lotOccupancyOccupants = getLotOccupancyOccupants(request.body.lotOccupancyId);
|
const lotOccupancyOccupants = getLotOccupancyOccupants(
|
||||||
|
request.body.lotOccupancyId
|
||||||
|
);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
|
|
@ -23,5 +17,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -5,7 +5,8 @@ import * as cacheFunctions from "../../helpers/functions.cache.js";
|
||||||
export const handler = (request, response) => {
|
export const handler = (request, response) => {
|
||||||
const lot = getLot(request.params.lotId);
|
const lot = getLot(request.params.lotId);
|
||||||
if (!lot) {
|
if (!lot) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lots/?error=lotIdNotFound");
|
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lots/?error=lotIdNotFound");
|
||||||
}
|
}
|
||||||
const maps = getMaps();
|
const maps = getMaps();
|
||||||
const lotTypes = cacheFunctions.getLotTypes();
|
const lotTypes = cacheFunctions.getLotTypes();
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,13 @@ import { getMaps } from "../../helpers/lotOccupancyDB/getMaps.js";
|
||||||
import * as cacheFunctions from "../../helpers/functions.cache.js";
|
import * as cacheFunctions from "../../helpers/functions.cache.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
|
|
||||||
const lot = getLot(request.params.lotId);
|
const lot = getLot(request.params.lotId);
|
||||||
|
|
||||||
if (!lot) {
|
if (!lot) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lots/?error=lotIdNotFound");
|
return response.redirect(
|
||||||
|
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lots/?error=lotIdNotFound"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const maps = getMaps();
|
const maps = getMaps();
|
||||||
|
|
@ -28,5 +30,4 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,7 @@ import * as cacheFunctions from "../../helpers/functions.cache.js";
|
||||||
|
|
||||||
import * as recordTypes from "../../types/recordTypes";
|
import * as recordTypes from "../../types/recordTypes";
|
||||||
|
|
||||||
|
|
||||||
export const handler: RequestHandler = (_request, response) => {
|
export const handler: RequestHandler = (_request, response) => {
|
||||||
|
|
||||||
const lot: recordTypes.Lot = {
|
const lot: recordTypes.Lot = {
|
||||||
lotOccupancies: []
|
lotOccupancies: []
|
||||||
};
|
};
|
||||||
|
|
@ -28,5 +26,4 @@ export const handler: RequestHandler = (_request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,11 @@ export const handler = (request, response) => {
|
||||||
const lotId = request.params.lotId;
|
const lotId = request.params.lotId;
|
||||||
const nextLotId = getNextLotId(lotId);
|
const nextLotId = getNextLotId(lotId);
|
||||||
if (!nextLotId) {
|
if (!nextLotId) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lots/?error=noNextLotIdFound");
|
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lots/?error=noNextLotIdFound");
|
||||||
}
|
}
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lots/" + nextLotId);
|
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lots/" +
|
||||||
|
nextLotId);
|
||||||
};
|
};
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,26 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
|
||||||
import {
|
import { getNextLotId } from "../../helpers/lotOccupancyDB/getNextLotId.js";
|
||||||
getNextLotId
|
|
||||||
} from "../../helpers/lotOccupancyDB/getNextLotId.js";
|
|
||||||
|
|
||||||
|
|
||||||
export const handler: RequestHandler = (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
|
|
||||||
const lotId = request.params.lotId;
|
const lotId = request.params.lotId;
|
||||||
|
|
||||||
const nextLotId = getNextLotId(lotId);
|
const nextLotId = getNextLotId(lotId);
|
||||||
|
|
||||||
if (!nextLotId) {
|
if (!nextLotId) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lots/?error=noNextLotIdFound");
|
return response.redirect(
|
||||||
|
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lots/?error=noNextLotIdFound"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lots/" + nextLotId);
|
return response.redirect(
|
||||||
|
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lots/" +
|
||||||
|
nextLotId
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -4,8 +4,11 @@ export const handler = (request, response) => {
|
||||||
const lotId = request.params.lotId;
|
const lotId = request.params.lotId;
|
||||||
const previousLotId = getPreviousLotId(lotId);
|
const previousLotId = getPreviousLotId(lotId);
|
||||||
if (!previousLotId) {
|
if (!previousLotId) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lots/?error=noPreviousLotIdFound");
|
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lots/?error=noPreviousLotIdFound");
|
||||||
}
|
}
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lots/" + previousLotId);
|
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lots/" +
|
||||||
|
previousLotId);
|
||||||
};
|
};
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,26 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
|
||||||
import {
|
import { getPreviousLotId } from "../../helpers/lotOccupancyDB/getPreviousLotId.js";
|
||||||
getPreviousLotId
|
|
||||||
} from "../../helpers/lotOccupancyDB/getPreviousLotId.js";
|
|
||||||
|
|
||||||
|
|
||||||
export const handler: RequestHandler = (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
|
|
||||||
const lotId = request.params.lotId;
|
const lotId = request.params.lotId;
|
||||||
|
|
||||||
const previousLotId = getPreviousLotId(lotId);
|
const previousLotId = getPreviousLotId(lotId);
|
||||||
|
|
||||||
if (!previousLotId) {
|
if (!previousLotId) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lots/?error=noPreviousLotIdFound");
|
return response.redirect(
|
||||||
|
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lots/?error=noPreviousLotIdFound"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lots/" + previousLotId);
|
return response.redirect(
|
||||||
|
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lots/" +
|
||||||
|
previousLotId
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,18 +1,12 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
|
||||||
import {
|
import { getMaps } from "../../helpers/lotOccupancyDB/getMaps.js";
|
||||||
getMaps
|
|
||||||
} from "../../helpers/lotOccupancyDB/getMaps.js";
|
|
||||||
|
|
||||||
import { getLotTypes, getLotStatuses } from "../../helpers/functions.cache.js";
|
import { getLotTypes, getLotStatuses } from "../../helpers/functions.cache.js";
|
||||||
|
|
||||||
|
|
||||||
export const handler: RequestHandler = (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
|
|
||||||
const maps = getMaps();
|
const maps = getMaps();
|
||||||
const lotTypes = getLotTypes();
|
const lotTypes = getLotTypes();
|
||||||
const lotStatuses = getLotStatuses();
|
const lotStatuses = getLotStatuses();
|
||||||
|
|
@ -26,5 +20,4 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -3,7 +3,8 @@ import { getLot } from "../../helpers/lotOccupancyDB/getLot.js";
|
||||||
export const handler = (request, response) => {
|
export const handler = (request, response) => {
|
||||||
const lot = getLot(request.params.lotId);
|
const lot = getLot(request.params.lotId);
|
||||||
if (!lot) {
|
if (!lot) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lots/?error=lotIdNotFound");
|
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lots/?error=lotIdNotFound");
|
||||||
}
|
}
|
||||||
return response.render("lot-view", {
|
return response.render("lot-view", {
|
||||||
headTitle: lot.lotName,
|
headTitle: lot.lotName,
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,14 @@ import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
|
||||||
import { getLot } from "../../helpers/lotOccupancyDB/getLot.js";
|
import { getLot } from "../../helpers/lotOccupancyDB/getLot.js";
|
||||||
|
|
||||||
|
|
||||||
export const handler: RequestHandler = (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
|
|
||||||
const lot = getLot(request.params.lotId);
|
const lot = getLot(request.params.lotId);
|
||||||
|
|
||||||
if (!lot) {
|
if (!lot) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lots/?error=lotIdNotFound");
|
return response.redirect(
|
||||||
|
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/lots/?error=lotIdNotFound"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.render("lot-view", {
|
return response.render("lot-view", {
|
||||||
|
|
@ -19,5 +20,4 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,10 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
import { addLotComment } from "../../helpers/lotOccupancyDB/addLotComment.js";
|
||||||
addLotComment
|
|
||||||
} from "../../helpers/lotOccupancyDB/addLotComment.js";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getLotComments
|
|
||||||
} from "../../helpers/lotOccupancyDB/getLotComments.js";
|
|
||||||
|
|
||||||
|
import { getLotComments } from "../../helpers/lotOccupancyDB/getLotComments.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
addLotComment(request.body, request.session);
|
addLotComment(request.body, request.session);
|
||||||
|
|
||||||
const lotComments = getLotComments(request.body.lotId);
|
const lotComments = getLotComments(request.body.lotId);
|
||||||
|
|
@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,14 +1,8 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
|
||||||
addLot
|
|
||||||
} from "../../helpers/lotOccupancyDB/addLot.js";
|
|
||||||
|
|
||||||
|
import { addLot } from "../../helpers/lotOccupancyDB/addLot.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
const lotId = addLot(request.body, request.session);
|
const lotId = addLot(request.body, request.session);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
|
|
@ -17,5 +11,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,19 +1,14 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
import { deleteLotComment } from "../../helpers/lotOccupancyDB/deleteLotComment.js";
|
||||||
deleteLotComment
|
|
||||||
} from "../../helpers/lotOccupancyDB/deleteLotComment.js";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getLotComments
|
|
||||||
} from "../../helpers/lotOccupancyDB/getLotComments.js";
|
|
||||||
|
|
||||||
|
import { getLotComments } from "../../helpers/lotOccupancyDB/getLotComments.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
const success = deleteLotComment(
|
||||||
const success = deleteLotComment(request.body.lotCommentId, request.session);
|
request.body.lotCommentId,
|
||||||
|
request.session
|
||||||
|
);
|
||||||
|
|
||||||
const lotComments = getLotComments(request.body.lotId);
|
const lotComments = getLotComments(request.body.lotId);
|
||||||
|
|
||||||
|
|
@ -23,5 +18,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,14 +1,8 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getLots
|
|
||||||
} from "../../helpers/lotOccupancyDB/getLots.js";
|
|
||||||
|
|
||||||
|
import { getLots } from "../../helpers/lotOccupancyDB/getLots.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
const result = getLots(request.body, {
|
const result = getLots(request.body, {
|
||||||
limit: request.body.limit,
|
limit: request.body.limit,
|
||||||
offset: request.body.offset
|
offset: request.body.offset
|
||||||
|
|
@ -20,5 +14,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,14 +1,8 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
|
||||||
updateLot
|
|
||||||
} from "../../helpers/lotOccupancyDB/updateLot.js";
|
|
||||||
|
|
||||||
|
import { updateLot } from "../../helpers/lotOccupancyDB/updateLot.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
const success = updateLot(request.body, request.session);
|
const success = updateLot(request.body, request.session);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
|
|
@ -17,5 +11,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,18 +1,10 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
import { updateLotComment } from "../../helpers/lotOccupancyDB/updateLotComment.js";
|
||||||
updateLotComment
|
|
||||||
} from "../../helpers/lotOccupancyDB/updateLotComment.js";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getLotComments
|
|
||||||
} from "../../helpers/lotOccupancyDB/getLotComments.js";
|
|
||||||
|
|
||||||
|
import { getLotComments } from "../../helpers/lotOccupancyDB/getLotComments.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
const success = updateLotComment(request.body, request.session);
|
const success = updateLotComment(request.body, request.session);
|
||||||
|
|
||||||
const lotComments = getLotComments(request.body.lotId);
|
const lotComments = getLotComments(request.body.lotId);
|
||||||
|
|
@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -4,7 +4,8 @@ import { getMapSVGs } from "../../helpers/functions.map.js";
|
||||||
export const handler = async (request, response) => {
|
export const handler = async (request, response) => {
|
||||||
const map = getMap(request.params.mapId);
|
const map = getMap(request.params.mapId);
|
||||||
if (!map) {
|
if (!map) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/maps/?error=mapIdNotFound");
|
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/maps/?error=mapIdNotFound");
|
||||||
}
|
}
|
||||||
const mapSVGs = await getMapSVGs();
|
const mapSVGs = await getMapSVGs();
|
||||||
response.render("map-edit", {
|
response.render("map-edit", {
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,14 @@ import { getMap } from "../../helpers/lotOccupancyDB/getMap.js";
|
||||||
|
|
||||||
import { getMapSVGs } from "../../helpers/functions.map.js";
|
import { getMapSVGs } from "../../helpers/functions.map.js";
|
||||||
|
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
const map = getMap(request.params.mapId);
|
const map = getMap(request.params.mapId);
|
||||||
|
|
||||||
if (!map) {
|
if (!map) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/maps/?error=mapIdNotFound");
|
return response.redirect(
|
||||||
|
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/maps/?error=mapIdNotFound"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapSVGs = await getMapSVGs();
|
const mapSVGs = await getMapSVGs();
|
||||||
|
|
@ -25,5 +26,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,21 +1,17 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
|
||||||
import {
|
import { getMapSVGs } from "../../helpers/functions.map.js";
|
||||||
getMapSVGs
|
|
||||||
} from "../../helpers/functions.map.js";
|
|
||||||
|
|
||||||
import * as recordTypes from "../../types/recordTypes";
|
import * as recordTypes from "../../types/recordTypes";
|
||||||
|
|
||||||
|
|
||||||
export const handler: RequestHandler = async (_request, response) => {
|
export const handler: RequestHandler = async (_request, response) => {
|
||||||
|
|
||||||
const map: recordTypes.Map = {
|
const map: recordTypes.Map = {
|
||||||
mapCity: configFunctions.getProperty("settings.map.mapCityDefault"),
|
mapCity: configFunctions.getProperty("settings.map.mapCityDefault"),
|
||||||
mapProvince: configFunctions.getProperty("settings.map.mapProvinceDefault")
|
mapProvince: configFunctions.getProperty(
|
||||||
|
"settings.map.mapProvinceDefault"
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapSVGs = await getMapSVGs();
|
const mapSVGs = await getMapSVGs();
|
||||||
|
|
@ -28,5 +24,4 @@ export const handler: RequestHandler = async (_request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,16 +1,10 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
|
||||||
import {
|
import { getMaps } from "../../helpers/lotOccupancyDB/getMaps.js";
|
||||||
getMaps
|
|
||||||
} from "../../helpers/lotOccupancyDB/getMaps.js";
|
|
||||||
|
|
||||||
|
|
||||||
export const handler: RequestHandler = (_request, response) => {
|
export const handler: RequestHandler = (_request, response) => {
|
||||||
|
|
||||||
const maps = getMaps();
|
const maps = getMaps();
|
||||||
|
|
||||||
response.render("map-search", {
|
response.render("map-search", {
|
||||||
|
|
@ -19,5 +13,4 @@ export const handler: RequestHandler = (_request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -3,7 +3,8 @@ import { getMap } from "../../helpers/lotOccupancyDB/getMap.js";
|
||||||
export const handler = (request, response) => {
|
export const handler = (request, response) => {
|
||||||
const map = getMap(request.params.mapId);
|
const map = getMap(request.params.mapId);
|
||||||
if (!map) {
|
if (!map) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/maps/?error=mapIdNotFound");
|
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/maps/?error=mapIdNotFound");
|
||||||
}
|
}
|
||||||
response.render("map-view", {
|
response.render("map-view", {
|
||||||
headTitle: map.mapName,
|
headTitle: map.mapName,
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,17 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
|
||||||
import {
|
import { getMap } from "../../helpers/lotOccupancyDB/getMap.js";
|
||||||
getMap
|
|
||||||
} from "../../helpers/lotOccupancyDB/getMap.js";
|
|
||||||
|
|
||||||
|
|
||||||
export const handler: RequestHandler = (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
|
|
||||||
const map = getMap(request.params.mapId);
|
const map = getMap(request.params.mapId);
|
||||||
|
|
||||||
if (!map) {
|
if (!map) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/maps/?error=mapIdNotFound");
|
return response.redirect(
|
||||||
|
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/maps/?error=mapIdNotFound"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
response.render("map-view", {
|
response.render("map-view", {
|
||||||
|
|
@ -23,5 +20,4 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,14 +1,8 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
|
||||||
addMap
|
|
||||||
} from "../../helpers/lotOccupancyDB/addMap.js";
|
|
||||||
|
|
||||||
|
import { addMap } from "../../helpers/lotOccupancyDB/addMap.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
const mapId = addMap(request.body, request.session);
|
const mapId = addMap(request.body, request.session);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
|
|
@ -17,5 +11,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,14 +1,8 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
|
||||||
deleteMap
|
|
||||||
} from "../../helpers/lotOccupancyDB/deleteMap.js";
|
|
||||||
|
|
||||||
|
import { deleteMap } from "../../helpers/lotOccupancyDB/deleteMap.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
const success = deleteMap(request.body.mapId, request.session);
|
const success = deleteMap(request.body.mapId, request.session);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
|
|
@ -16,5 +10,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,14 +1,8 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
|
||||||
updateMap
|
|
||||||
} from "../../helpers/lotOccupancyDB/updateMap.js";
|
|
||||||
|
|
||||||
|
import { updateMap } from "../../helpers/lotOccupancyDB/updateMap.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
const success = updateMap(request.body, request.session);
|
const success = updateMap(request.body, request.session);
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
|
|
@ -17,5 +11,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -2,9 +2,7 @@ import * as configFunctions from "../helpers/functions.config.js";
|
||||||
import * as userFunctions from "../helpers/functions.user.js";
|
import * as userFunctions from "../helpers/functions.user.js";
|
||||||
const urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix");
|
const urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix");
|
||||||
export const forbiddenJSON = (response) => {
|
export const forbiddenJSON = (response) => {
|
||||||
return response
|
return response.status(403).json({
|
||||||
.status(403)
|
|
||||||
.json({
|
|
||||||
success: false,
|
success: false,
|
||||||
message: "Forbidden"
|
message: "Forbidden"
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -4,23 +4,16 @@ import * as configFunctions from "../helpers/functions.config.js";
|
||||||
|
|
||||||
import * as userFunctions from "../helpers/functions.user.js";
|
import * as userFunctions from "../helpers/functions.user.js";
|
||||||
|
|
||||||
|
|
||||||
const urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix");
|
const urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix");
|
||||||
|
|
||||||
|
|
||||||
export const forbiddenJSON = (response: Response): Response => {
|
export const forbiddenJSON = (response: Response): Response => {
|
||||||
|
return response.status(403).json({
|
||||||
return response
|
|
||||||
.status(403)
|
|
||||||
.json({
|
|
||||||
success: false,
|
success: false,
|
||||||
message: "Forbidden"
|
message: "Forbidden"
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const adminGetHandler: RequestHandler = (request, response, next) => {
|
export const adminGetHandler: RequestHandler = (request, response, next) => {
|
||||||
|
|
||||||
if (userFunctions.userIsAdmin(request)) {
|
if (userFunctions.userIsAdmin(request)) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
@ -28,9 +21,7 @@ export const adminGetHandler: RequestHandler = (request, response, next) => {
|
||||||
return response.redirect(urlPrefix + "/dashboard");
|
return response.redirect(urlPrefix + "/dashboard");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const adminPostHandler: RequestHandler = (request, response, next) => {
|
export const adminPostHandler: RequestHandler = (request, response, next) => {
|
||||||
|
|
||||||
if (userFunctions.userIsAdmin(request)) {
|
if (userFunctions.userIsAdmin(request)) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
@ -38,9 +29,7 @@ export const adminPostHandler: RequestHandler = (request, response, next) => {
|
||||||
return response.json(forbiddenJSON);
|
return response.json(forbiddenJSON);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const updateGetHandler: RequestHandler = (request, response, next) => {
|
export const updateGetHandler: RequestHandler = (request, response, next) => {
|
||||||
|
|
||||||
if (userFunctions.userCanUpdate(request)) {
|
if (userFunctions.userCanUpdate(request)) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
@ -48,9 +37,7 @@ export const updateGetHandler: RequestHandler = (request, response, next) => {
|
||||||
return response.redirect(urlPrefix + "/dashboard");
|
return response.redirect(urlPrefix + "/dashboard");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const updatePostHandler: RequestHandler = (request, response, next) => {
|
export const updatePostHandler: RequestHandler = (request, response, next) => {
|
||||||
|
|
||||||
if (userFunctions.userCanUpdate(request)) {
|
if (userFunctions.userCanUpdate(request)) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,17 @@ export const handler = (request, response) => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!rows) {
|
if (!rows) {
|
||||||
return response
|
return response.status(404).json({
|
||||||
.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);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getReportData,
|
getReportData,
|
||||||
|
|
@ -9,24 +7,19 @@ import {
|
||||||
|
|
||||||
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[];
|
||||||
|
|
||||||
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
|
return response.status(404).json({
|
||||||
.status(404)
|
|
||||||
.json({
|
|
||||||
success: false,
|
success: false,
|
||||||
message: "Report Not Found"
|
message: "Report Not Found"
|
||||||
});
|
});
|
||||||
|
|
@ -34,13 +27,18 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
|
|
||||||
const csv = papaparse.unparse(rows);
|
const csv = papaparse.unparse(rows);
|
||||||
|
|
||||||
response.setHeader("Content-Disposition",
|
response.setHeader(
|
||||||
"attachment; filename=" + reportName + "-" + Date.now().toString() + ".csv");
|
"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,12 +1,8 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import { getWorkOrderTypes } from "../../helpers/functions.cache.js";
|
import { getWorkOrderTypes } from "../../helpers/functions.cache.js";
|
||||||
|
|
||||||
|
|
||||||
export const handler: RequestHandler = (request, response) => {
|
export const handler: RequestHandler = (request, response) => {
|
||||||
|
|
||||||
const workOrderTypes = getWorkOrderTypes();
|
const workOrderTypes = getWorkOrderTypes();
|
||||||
|
|
||||||
response.render("workOrder-search", {
|
response.render("workOrder-search", {
|
||||||
|
|
@ -15,5 +11,4 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -3,7 +3,8 @@ 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);
|
||||||
if (!workOrder) {
|
if (!workOrder) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/workOrders/?error=workOrderIdNotFound");
|
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/workOrders/?error=workOrderIdNotFound");
|
||||||
}
|
}
|
||||||
response.render("workOrder-view", {
|
response.render("workOrder-view", {
|
||||||
headTitle: "Work Order #" + workOrder.workOrderNumber,
|
headTitle: "Work Order #" + workOrder.workOrderNumber,
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,17 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
|
||||||
import {
|
import { getWorkOrder } from "../../helpers/lotOccupancyDB/getWorkOrder.js";
|
||||||
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);
|
||||||
|
|
||||||
if (!workOrder) {
|
if (!workOrder) {
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/workOrders/?error=workOrderIdNotFound");
|
return response.redirect(
|
||||||
|
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/workOrders/?error=workOrderIdNotFound"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
response.render("workOrder-view", {
|
response.render("workOrder-view", {
|
||||||
|
|
@ -23,5 +20,4 @@ export const handler: RequestHandler = (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -1,14 +1,8 @@
|
||||||
import type {
|
import type { RequestHandler } from "express";
|
||||||
RequestHandler
|
|
||||||
} from "express";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getWorkOrders
|
|
||||||
} from "../../helpers/lotOccupancyDB/getWorkOrders.js";
|
|
||||||
|
|
||||||
|
import { getWorkOrders } from "../../helpers/lotOccupancyDB/getWorkOrders.js";
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
|
||||||
const result = getWorkOrders(request.body, {
|
const result = getWorkOrders(request.body, {
|
||||||
limit: request.body.limit,
|
limit: request.body.limit,
|
||||||
offset: request.body.offset
|
offset: request.body.offset
|
||||||
|
|
@ -20,5 +14,4 @@ export const handler: RequestHandler = async (request, response) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
@ -6,34 +6,35 @@ const userDomain = configFunctions.getProperty("application.userDomain");
|
||||||
|
|
||||||
const activeDirectoryConfig = configFunctions.getProperty("activeDirectory");
|
const activeDirectoryConfig = configFunctions.getProperty("activeDirectory");
|
||||||
|
|
||||||
|
const authenticateViaActiveDirectory = async (
|
||||||
|
userName: string,
|
||||||
const authenticateViaActiveDirectory = async (userName: string, password: string): Promise<boolean> => {
|
password: string
|
||||||
|
): Promise<boolean> => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ad = new ActiveDirectory(activeDirectoryConfig);
|
const ad = new ActiveDirectory(activeDirectoryConfig);
|
||||||
|
|
||||||
ad.authenticate(userDomain + "\\" + userName, password, async (error, auth) => {
|
ad.authenticate(
|
||||||
|
userDomain + "\\" + userName,
|
||||||
|
password,
|
||||||
|
async (error, auth) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
resolve(false);
|
resolve(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(auth);
|
resolve(auth);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
} catch {
|
} catch {
|
||||||
resolve(false);
|
resolve(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const authenticate = async (
|
||||||
|
userName: string,
|
||||||
export const authenticate = async (userName: string, password: string): Promise<boolean> => {
|
password: string
|
||||||
|
): Promise<boolean> => {
|
||||||
if (!userName || userName === "" || !password || password === "") {
|
if (!userName || userName === "" || !password || password === "") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import { getLotStatuses as getLotStatusesFromDatabase } from "./lotOccupancyDB/g
|
||||||
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 { getWorkOrderTypes as getWorkOrderTypesFromDatabase } from "./lotOccupancyDB/getWorkOrderTypes.js";
|
import { getWorkOrderTypes as getWorkOrderTypesFromDatabase } from "./lotOccupancyDB/getWorkOrderTypes.js";
|
||||||
import { getOccupancyType } from "./lotOccupancyDB/getOccupancyType.js";
|
|
||||||
let lotOccupantTypes;
|
let lotOccupantTypes;
|
||||||
export function getLotOccupantTypes() {
|
export function getLotOccupantTypes() {
|
||||||
if (!lotOccupantTypes) {
|
if (!lotOccupantTypes) {
|
||||||
|
|
@ -21,7 +20,8 @@ export function getLotOccupantTypesByLotOccupantType(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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
export function clearLotOccupantTypesCache() {
|
export function clearLotOccupantTypesCache() {
|
||||||
|
|
@ -74,7 +74,6 @@ export function clearLotTypesCache() {
|
||||||
lotTypes = undefined;
|
lotTypes = undefined;
|
||||||
}
|
}
|
||||||
let occupancyTypes;
|
let occupancyTypes;
|
||||||
const occupancyTypeMap = new Map();
|
|
||||||
export function getOccupancyTypes() {
|
export function getOccupancyTypes() {
|
||||||
if (!occupancyTypes) {
|
if (!occupancyTypes) {
|
||||||
occupancyTypes = getOccupancyTypesFromDatabase();
|
occupancyTypes = getOccupancyTypesFromDatabase();
|
||||||
|
|
@ -82,26 +81,21 @@ export function getOccupancyTypes() {
|
||||||
return occupancyTypes;
|
return occupancyTypes;
|
||||||
}
|
}
|
||||||
export function getOccupancyTypeById(occupancyTypeId) {
|
export function getOccupancyTypeById(occupancyTypeId) {
|
||||||
if (!occupancyTypeMap.has(occupancyTypeId)) {
|
const cachedOccupancyTypes = getOccupancyTypes();
|
||||||
const occupancyType = getOccupancyType(occupancyTypeId);
|
return cachedOccupancyTypes.find((currentOccupancyType) => {
|
||||||
occupancyTypeMap.set(occupancyTypeId, occupancyType);
|
return currentOccupancyType.occupancyTypeId === occupancyTypeId;
|
||||||
}
|
});
|
||||||
return occupancyTypeMap.get(occupancyTypeId);
|
|
||||||
}
|
}
|
||||||
export function getOccupancyTypeByOccupancyType(occupancyTypeString) {
|
export function getOccupancyTypeByOccupancyType(occupancyTypeString) {
|
||||||
const cachedOccupancyTypes = getOccupancyTypes();
|
const cachedOccupancyTypes = getOccupancyTypes();
|
||||||
const occupancyTypeLowerCase = occupancyTypeString.toLowerCase();
|
const occupancyTypeLowerCase = occupancyTypeString.toLowerCase();
|
||||||
let occupancyType = cachedOccupancyTypes.find((currentOccupancyType) => {
|
return cachedOccupancyTypes.find((currentOccupancyType) => {
|
||||||
return currentOccupancyType.occupancyType.toLowerCase() === occupancyTypeLowerCase;
|
return (currentOccupancyType.occupancyType.toLowerCase() ===
|
||||||
|
occupancyTypeLowerCase);
|
||||||
});
|
});
|
||||||
if (occupancyType) {
|
|
||||||
occupancyType = getOccupancyTypeById(occupancyType.occupancyTypeId);
|
|
||||||
}
|
|
||||||
return occupancyType;
|
|
||||||
}
|
}
|
||||||
export function clearOccupancyTypesCache() {
|
export function clearOccupancyTypesCache() {
|
||||||
occupancyTypes = undefined;
|
occupancyTypes = undefined;
|
||||||
occupancyTypeMap.clear();
|
|
||||||
}
|
}
|
||||||
let workOrderTypes;
|
let workOrderTypes;
|
||||||
export function getWorkOrderTypes() {
|
export function getWorkOrderTypes() {
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,12 @@
|
||||||
import {
|
import { getLotOccupantTypes as getLotOccupantTypesFromDatabase } from "./lotOccupancyDB/getLotOccupantTypes.js";
|
||||||
getLotOccupantTypes as getLotOccupantTypesFromDatabase
|
|
||||||
} from "./lotOccupancyDB/getLotOccupantTypes.js";
|
|
||||||
|
|
||||||
import {
|
import { getLotStatuses as getLotStatusesFromDatabase } from "./lotOccupancyDB/getLotStatuses.js";
|
||||||
getLotStatuses as getLotStatusesFromDatabase
|
|
||||||
} from "./lotOccupancyDB/getLotStatuses.js";
|
|
||||||
|
|
||||||
import {
|
import { getLotTypes as getLotTypesFromDatabase } from "./lotOccupancyDB/getLotTypes.js";
|
||||||
getLotTypes as getLotTypesFromDatabase
|
|
||||||
} from "./lotOccupancyDB/getLotTypes.js";
|
|
||||||
|
|
||||||
import {
|
import { getOccupancyTypes as getOccupancyTypesFromDatabase } from "./lotOccupancyDB/getOccupancyTypes.js";
|
||||||
getOccupancyTypes as getOccupancyTypesFromDatabase
|
|
||||||
} from "./lotOccupancyDB/getOccupancyTypes.js";
|
|
||||||
|
|
||||||
import {
|
import { getWorkOrderTypes as getWorkOrderTypesFromDatabase } from "./lotOccupancyDB/getWorkOrderTypes.js";
|
||||||
getWorkOrderTypes as getWorkOrderTypesFromDatabase
|
|
||||||
} from "./lotOccupancyDB/getWorkOrderTypes.js";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getOccupancyType
|
|
||||||
} from "./lotOccupancyDB/getOccupancyType.js";
|
|
||||||
|
|
||||||
import type * as recordTypes from "../types/recordTypes";
|
import type * as recordTypes from "../types/recordTypes";
|
||||||
|
|
||||||
|
|
@ -31,7 +17,6 @@ import type * as recordTypes from "../types/recordTypes";
|
||||||
let lotOccupantTypes: recordTypes.LotOccupantType[];
|
let lotOccupantTypes: recordTypes.LotOccupantType[];
|
||||||
|
|
||||||
export function getLotOccupantTypes() {
|
export function getLotOccupantTypes() {
|
||||||
|
|
||||||
if (!lotOccupantTypes) {
|
if (!lotOccupantTypes) {
|
||||||
lotOccupantTypes = getLotOccupantTypesFromDatabase();
|
lotOccupantTypes = getLotOccupantTypesFromDatabase();
|
||||||
}
|
}
|
||||||
|
|
@ -40,7 +25,6 @@ export function getLotOccupantTypes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLotOccupantTypeById(lotOccupantTypeId: number) {
|
export function getLotOccupantTypeById(lotOccupantTypeId: number) {
|
||||||
|
|
||||||
const cachedLotOccupantTypes = getLotOccupantTypes();
|
const cachedLotOccupantTypes = getLotOccupantTypes();
|
||||||
|
|
||||||
return cachedLotOccupantTypes.find((currentLotOccupantType) => {
|
return cachedLotOccupantTypes.find((currentLotOccupantType) => {
|
||||||
|
|
@ -49,13 +33,15 @@ export function getLotOccupantTypeById(lotOccupantTypeId: number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLotOccupantTypesByLotOccupantType(lotOccupantType: string) {
|
export function getLotOccupantTypesByLotOccupantType(lotOccupantType: string) {
|
||||||
|
|
||||||
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
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,7 +49,6 @@ export function clearLotOccupantTypesCache() {
|
||||||
lotOccupantTypes = undefined;
|
lotOccupantTypes = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lot Statuses
|
* Lot Statuses
|
||||||
*/
|
*/
|
||||||
|
|
@ -71,7 +56,6 @@ export function clearLotOccupantTypesCache() {
|
||||||
let lotStatuses: recordTypes.LotStatus[];
|
let lotStatuses: recordTypes.LotStatus[];
|
||||||
|
|
||||||
export function getLotStatuses() {
|
export function getLotStatuses() {
|
||||||
|
|
||||||
if (!lotStatuses) {
|
if (!lotStatuses) {
|
||||||
lotStatuses = getLotStatusesFromDatabase();
|
lotStatuses = getLotStatusesFromDatabase();
|
||||||
}
|
}
|
||||||
|
|
@ -80,7 +64,6 @@ export function getLotStatuses() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLotStatusById(lotStatusId: number) {
|
export function getLotStatusById(lotStatusId: number) {
|
||||||
|
|
||||||
const cachedLotStatuses = getLotStatuses();
|
const cachedLotStatuses = getLotStatuses();
|
||||||
|
|
||||||
return cachedLotStatuses.find((currentLotStatus) => {
|
return cachedLotStatuses.find((currentLotStatus) => {
|
||||||
|
|
@ -89,7 +72,6 @@ export function getLotStatusById(lotStatusId: number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLotStatusByLotStatus(lotStatus: string) {
|
export function getLotStatusByLotStatus(lotStatus: string) {
|
||||||
|
|
||||||
const cachedLotStatuses = getLotStatuses();
|
const cachedLotStatuses = getLotStatuses();
|
||||||
|
|
||||||
const lotStatusLowerCase = lotStatus.toLowerCase();
|
const lotStatusLowerCase = lotStatus.toLowerCase();
|
||||||
|
|
@ -110,7 +92,6 @@ export function clearLotStatusesCache() {
|
||||||
let lotTypes: recordTypes.LotType[];
|
let lotTypes: recordTypes.LotType[];
|
||||||
|
|
||||||
export function getLotTypes() {
|
export function getLotTypes() {
|
||||||
|
|
||||||
if (!lotTypes) {
|
if (!lotTypes) {
|
||||||
lotTypes = getLotTypesFromDatabase();
|
lotTypes = getLotTypesFromDatabase();
|
||||||
}
|
}
|
||||||
|
|
@ -119,7 +100,6 @@ export function getLotTypes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLotTypeById(lotTypeId: number) {
|
export function getLotTypeById(lotTypeId: number) {
|
||||||
|
|
||||||
const cachedLotTypes = getLotTypes();
|
const cachedLotTypes = getLotTypes();
|
||||||
|
|
||||||
return cachedLotTypes.find((currentLotType) => {
|
return cachedLotTypes.find((currentLotType) => {
|
||||||
|
|
@ -128,7 +108,6 @@ export function getLotTypeById(lotTypeId: number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLotTypesByLotType(lotType: string) {
|
export function getLotTypesByLotType(lotType: string) {
|
||||||
|
|
||||||
const cachedLotTypes = getLotTypes();
|
const cachedLotTypes = getLotTypes();
|
||||||
|
|
||||||
const lotTypeLowerCase = lotType.toLowerCase();
|
const lotTypeLowerCase = lotType.toLowerCase();
|
||||||
|
|
@ -147,11 +126,8 @@ export function clearLotTypesCache() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let occupancyTypes: recordTypes.OccupancyType[];
|
let occupancyTypes: recordTypes.OccupancyType[];
|
||||||
const occupancyTypeMap = new Map < number,
|
|
||||||
recordTypes.OccupancyType > ();
|
|
||||||
|
|
||||||
export function getOccupancyTypes() {
|
export function getOccupancyTypes() {
|
||||||
|
|
||||||
if (!occupancyTypes) {
|
if (!occupancyTypes) {
|
||||||
occupancyTypes = getOccupancyTypesFromDatabase();
|
occupancyTypes = getOccupancyTypesFromDatabase();
|
||||||
}
|
}
|
||||||
|
|
@ -160,37 +136,28 @@ export function getOccupancyTypes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getOccupancyTypeById(occupancyTypeId: number) {
|
export function getOccupancyTypeById(occupancyTypeId: number) {
|
||||||
|
const cachedOccupancyTypes = getOccupancyTypes();
|
||||||
|
|
||||||
if (!occupancyTypeMap.has(occupancyTypeId)) {
|
return cachedOccupancyTypes.find((currentOccupancyType) => {
|
||||||
|
return currentOccupancyType.occupancyTypeId === occupancyTypeId;
|
||||||
const occupancyType = getOccupancyType(occupancyTypeId);
|
});
|
||||||
occupancyTypeMap.set(occupancyTypeId, occupancyType);
|
|
||||||
}
|
|
||||||
|
|
||||||
return occupancyTypeMap.get(occupancyTypeId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getOccupancyTypeByOccupancyType(occupancyTypeString: string) {
|
export function getOccupancyTypeByOccupancyType(occupancyTypeString: string) {
|
||||||
|
|
||||||
const cachedOccupancyTypes = getOccupancyTypes();
|
const cachedOccupancyTypes = getOccupancyTypes();
|
||||||
|
|
||||||
const occupancyTypeLowerCase = occupancyTypeString.toLowerCase();
|
const occupancyTypeLowerCase = occupancyTypeString.toLowerCase();
|
||||||
|
|
||||||
let occupancyType = cachedOccupancyTypes.find((currentOccupancyType) => {
|
return cachedOccupancyTypes.find((currentOccupancyType) => {
|
||||||
return currentOccupancyType.occupancyType.toLowerCase() === occupancyTypeLowerCase;
|
return (
|
||||||
|
currentOccupancyType.occupancyType.toLowerCase() ===
|
||||||
|
occupancyTypeLowerCase
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// get object with related fields
|
|
||||||
if (occupancyType) {
|
|
||||||
occupancyType = getOccupancyTypeById(occupancyType.occupancyTypeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return occupancyType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function clearOccupancyTypesCache() {
|
export function clearOccupancyTypesCache() {
|
||||||
occupancyTypes = undefined;
|
occupancyTypes = undefined;
|
||||||
occupancyTypeMap.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -200,7 +167,6 @@ export function clearOccupancyTypesCache() {
|
||||||
let workOrderTypes: recordTypes.WorkOrderType[];
|
let workOrderTypes: recordTypes.WorkOrderType[];
|
||||||
|
|
||||||
export function getWorkOrderTypes() {
|
export function getWorkOrderTypes() {
|
||||||
|
|
||||||
if (!workOrderTypes) {
|
if (!workOrderTypes) {
|
||||||
workOrderTypes = getWorkOrderTypesFromDatabase();
|
workOrderTypes = getWorkOrderTypesFromDatabase();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,6 @@ export function getProperty(propertyName) {
|
||||||
}
|
}
|
||||||
return currentObject;
|
return currentObject;
|
||||||
}
|
}
|
||||||
export const keepAliveMillis = getProperty("session.doKeepAlive") ?
|
export const keepAliveMillis = getProperty("session.doKeepAlive")
|
||||||
Math.max(getProperty("session.maxAgeMillis") / 2, getProperty("session.maxAgeMillis") - (10 * 60 * 1000)) :
|
? Math.max(getProperty("session.maxAgeMillis") / 2, getProperty("session.maxAgeMillis") - 10 * 60 * 1000)
|
||||||
0;
|
: 0;
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,20 @@
|
||||||
/* eslint-disable node/no-unpublished-import */
|
/* eslint-disable node/no-unpublished-import */
|
||||||
|
|
||||||
import {
|
import { config } from "../data/config.js";
|
||||||
config
|
|
||||||
} from "../data/config.js";
|
|
||||||
|
|
||||||
import type * as configTypes from "../types/configTypes";
|
import type * as configTypes from "../types/configTypes";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SET UP FALLBACK VALUES
|
* SET UP FALLBACK VALUES
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const configFallbackValues = new Map < string,
|
const configFallbackValues = new Map<string, unknown>();
|
||||||
unknown > ();
|
|
||||||
|
|
||||||
configFallbackValues.set("application.applicationName", "Lot Occupancy System");
|
configFallbackValues.set("application.applicationName", "Lot Occupancy System");
|
||||||
configFallbackValues.set("application.backgroundURL", "/images/cemetery-background.jpg");
|
configFallbackValues.set(
|
||||||
|
"application.backgroundURL",
|
||||||
|
"/images/cemetery-background.jpg"
|
||||||
|
);
|
||||||
configFallbackValues.set("application.logoURL", "/images/cemetery-logo.png");
|
configFallbackValues.set("application.logoURL", "/images/cemetery-logo.png");
|
||||||
configFallbackValues.set("application.httpPort", 7000);
|
configFallbackValues.set("application.httpPort", 7000);
|
||||||
configFallbackValues.set("application.useTestDatabases", false);
|
configFallbackValues.set("application.useTestDatabases", false);
|
||||||
|
|
@ -41,37 +40,55 @@ configFallbackValues.set("aliases.occupancy", "Occupancy");
|
||||||
configFallbackValues.set("aliases.occupancies", "Occupancies");
|
configFallbackValues.set("aliases.occupancies", "Occupancies");
|
||||||
configFallbackValues.set("aliases.occupant", "Occupant");
|
configFallbackValues.set("aliases.occupant", "Occupant");
|
||||||
configFallbackValues.set("aliases.occupants", "Occupants");
|
configFallbackValues.set("aliases.occupants", "Occupants");
|
||||||
configFallbackValues.set("aliases.externalReceiptNumber", "External Receipt Number");
|
configFallbackValues.set(
|
||||||
|
"aliases.externalReceiptNumber",
|
||||||
|
"External Receipt Number"
|
||||||
|
);
|
||||||
|
|
||||||
configFallbackValues.set("settings.map.mapCityDefault", "");
|
configFallbackValues.set("settings.map.mapCityDefault", "");
|
||||||
configFallbackValues.set("settings.map.mapProvinceDefault", "");
|
configFallbackValues.set("settings.map.mapProvinceDefault", "");
|
||||||
|
|
||||||
configFallbackValues.set("settings.lot.lotNameSortNameFunction", (lotName: string) => lotName);
|
configFallbackValues.set(
|
||||||
|
"settings.lot.lotNameSortNameFunction",
|
||||||
|
(lotName: string) => lotName
|
||||||
|
);
|
||||||
|
|
||||||
configFallbackValues.set("settings.lotOccupancy.occupancyEndDateIsRequired", true);
|
configFallbackValues.set(
|
||||||
|
"settings.lotOccupancy.occupancyEndDateIsRequired",
|
||||||
|
true
|
||||||
|
);
|
||||||
configFallbackValues.set("settings.lotOccupancy.occupantCityDefault", "");
|
configFallbackValues.set("settings.lotOccupancy.occupantCityDefault", "");
|
||||||
configFallbackValues.set("settings.lotOccupancy.occupantProvinceDefault", "");
|
configFallbackValues.set("settings.lotOccupancy.occupantProvinceDefault", "");
|
||||||
|
|
||||||
configFallbackValues.set("settings.fees.taxPercentageDefault", 0);
|
configFallbackValues.set("settings.fees.taxPercentageDefault", 0);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up function overloads
|
* Set up function overloads
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function getProperty(propertyName: "application.applicationName"): string;
|
export function getProperty(
|
||||||
|
propertyName: "application.applicationName"
|
||||||
|
): string;
|
||||||
|
|
||||||
export function getProperty(propertyName: "application.logoURL"): string;
|
export function getProperty(propertyName: "application.logoURL"): string;
|
||||||
export function getProperty(propertyName: "application.httpPort"): number;
|
export function getProperty(propertyName: "application.httpPort"): number;
|
||||||
export function getProperty(propertyName: "application.userDomain"): string;
|
export function getProperty(propertyName: "application.userDomain"): string;
|
||||||
export function getProperty(propertyName: "application.useTestDatabases"): boolean;
|
export function getProperty(
|
||||||
|
propertyName: "application.useTestDatabases"
|
||||||
|
): boolean;
|
||||||
|
|
||||||
export function getProperty(propertyName: "activeDirectory"): configTypes.ConfigActiveDirectory;
|
export function getProperty(
|
||||||
|
propertyName: "activeDirectory"
|
||||||
|
): configTypes.ConfigActiveDirectory;
|
||||||
|
|
||||||
export function getProperty(propertyName: "users.canLogin"): string[];
|
export function getProperty(propertyName: "users.canLogin"): string[];
|
||||||
export function getProperty(propertyName: "users.canUpdate"): string[];
|
export function getProperty(propertyName: "users.canUpdate"): string[];
|
||||||
export function getProperty(propertyName: "users.isAdmin"): string[];
|
export function getProperty(propertyName: "users.isAdmin"): string[];
|
||||||
|
|
||||||
export function getProperty(propertyName: "reverseProxy.disableCompression"): boolean;
|
export function getProperty(
|
||||||
|
propertyName: "reverseProxy.disableCompression"
|
||||||
|
): boolean;
|
||||||
|
|
||||||
export function getProperty(propertyName: "reverseProxy.disableEtag"): boolean;
|
export function getProperty(propertyName: "reverseProxy.disableEtag"): boolean;
|
||||||
export function getProperty(propertyName: "reverseProxy.urlPrefix"): string;
|
export function getProperty(propertyName: "reverseProxy.urlPrefix"): string;
|
||||||
|
|
||||||
|
|
@ -88,29 +105,55 @@ export function getProperty(propertyName: "aliases.occupancy"): string;
|
||||||
export function getProperty(propertyName: "aliases.occupancies"): string;
|
export function getProperty(propertyName: "aliases.occupancies"): string;
|
||||||
export function getProperty(propertyName: "aliases.occupant"): string;
|
export function getProperty(propertyName: "aliases.occupant"): string;
|
||||||
export function getProperty(propertyName: "aliases.occupants"): string;
|
export function getProperty(propertyName: "aliases.occupants"): string;
|
||||||
export function getProperty(propertyName: "aliases.externalReceiptNumber"): string;
|
|
||||||
|
|
||||||
export function getProperty(propertyName: "settings.map.mapCityDefault"): string;
|
export function getProperty(
|
||||||
export function getProperty(propertyName: "settings.map.mapProvinceDefault"): string;
|
propertyName: "aliases.externalReceiptNumber"
|
||||||
|
): string;
|
||||||
|
|
||||||
export function getProperty(propertyName: "settings.lot.lotNamePattern"): RegExp;
|
export function getProperty(
|
||||||
export function getProperty(propertyName: "settings.lot.lotNameSortNameFunction"): (lotName: string) => string;
|
propertyName: "settings.map.mapCityDefault"
|
||||||
|
): string;
|
||||||
|
|
||||||
export function getProperty(propertyName: "settings.lotOccupancy.occupancyEndDateIsRequired"): boolean;
|
export function getProperty(
|
||||||
export function getProperty(propertyName: "settings.lotOccupancy.occupantCityDefault"): string;
|
propertyName: "settings.map.mapProvinceDefault"
|
||||||
export function getProperty(propertyName: "settings.lotOccupancy.occupantProvinceDefault"): string;
|
): string;
|
||||||
|
|
||||||
export function getProperty(propertyName: "settings.fees.taxPercentageDefault"): number;
|
export function getProperty(
|
||||||
|
propertyName: "settings.lot.lotNamePattern"
|
||||||
|
): RegExp;
|
||||||
|
|
||||||
|
export function getProperty(
|
||||||
|
propertyName: "settings.lot.lotNameSortNameFunction"
|
||||||
|
): (lotName: string) => string;
|
||||||
|
|
||||||
|
export function getProperty(
|
||||||
|
propertyName: "settings.lotOccupancy.occupancyEndDateIsRequired"
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
export function getProperty(
|
||||||
|
propertyName: "settings.lotOccupancy.occupantCityDefault"
|
||||||
|
): string;
|
||||||
|
|
||||||
|
export function getProperty(
|
||||||
|
propertyName: "settings.lotOccupancy.occupantProvinceDefault"
|
||||||
|
): string;
|
||||||
|
|
||||||
|
export function getProperty(
|
||||||
|
propertyName: "settings.fees.taxPercentageDefault"
|
||||||
|
): number;
|
||||||
|
|
||||||
export function getProperty(propertyName: string): unknown {
|
export function getProperty(propertyName: string): unknown {
|
||||||
|
|
||||||
const propertyNameSplit = propertyName.split(".");
|
const propertyNameSplit = propertyName.split(".");
|
||||||
|
|
||||||
let currentObject = config;
|
let currentObject = config;
|
||||||
|
|
||||||
for (const propertyNamePiece of propertyNameSplit) {
|
for (const propertyNamePiece of propertyNameSplit) {
|
||||||
|
if (
|
||||||
if (Object.prototype.hasOwnProperty.call(currentObject, propertyNamePiece)) {
|
Object.prototype.hasOwnProperty.call(
|
||||||
|
currentObject,
|
||||||
|
propertyNamePiece
|
||||||
|
)
|
||||||
|
) {
|
||||||
currentObject = currentObject[propertyNamePiece];
|
currentObject = currentObject[propertyNamePiece];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -121,10 +164,9 @@ export function getProperty(propertyName: string): unknown {
|
||||||
return currentObject;
|
return currentObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const keepAliveMillis =
|
export const keepAliveMillis = getProperty("session.doKeepAlive")
|
||||||
getProperty("session.doKeepAlive") ?
|
? Math.max(
|
||||||
Math.max(
|
|
||||||
getProperty("session.maxAgeMillis") / 2,
|
getProperty("session.maxAgeMillis") / 2,
|
||||||
getProperty("session.maxAgeMillis") - (10 * 60 * 1000)
|
getProperty("session.maxAgeMillis") - 10 * 60 * 1000
|
||||||
) :
|
)
|
||||||
0;
|
: 0;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
export const calculateFeeAmount = (fee, lotOccupancy) => {
|
export const calculateFeeAmount = (fee, lotOccupancy) => {
|
||||||
return fee.feeFunction ?
|
return fee.feeFunction ? 0 : fee.feeAmount || 0;
|
||||||
0 :
|
|
||||||
(fee.feeAmount || 0);
|
|
||||||
};
|
};
|
||||||
export const calculateTaxAmount = (fee, feeAmount) => {
|
export const calculateTaxAmount = (fee, feeAmount) => {
|
||||||
return fee.taxPercentage ?
|
return fee.taxPercentage
|
||||||
feeAmount * (fee.taxPercentage / 100) :
|
? feeAmount * (fee.taxPercentage / 100)
|
||||||
(fee.taxAmount || 0);
|
: fee.taxAmount || 0;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,14 @@
|
||||||
import * as recordTypes from "../types/recordTypes";
|
import * as recordTypes from "../types/recordTypes";
|
||||||
|
|
||||||
|
export const calculateFeeAmount = (
|
||||||
export const calculateFeeAmount = (fee: recordTypes.Fee, lotOccupancy: recordTypes.LotOccupancy): number => {
|
fee: recordTypes.Fee,
|
||||||
|
lotOccupancy: recordTypes.LotOccupancy
|
||||||
return fee.feeFunction ?
|
): number => {
|
||||||
0 :
|
return fee.feeFunction ? 0 : fee.feeAmount || 0;
|
||||||
(fee.feeAmount || 0);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const calculateTaxAmount = (fee: recordTypes.Fee, feeAmount: number) => {
|
export const calculateTaxAmount = (fee: recordTypes.Fee, feeAmount: number) => {
|
||||||
|
return fee.taxPercentage
|
||||||
return fee.taxPercentage ?
|
? feeAmount * (fee.taxPercentage / 100)
|
||||||
feeAmount * (fee.taxPercentage / 100) :
|
: fee.taxAmount || 0;
|
||||||
(fee.taxAmount || 0);
|
|
||||||
};
|
};
|
||||||
|
|
@ -2,15 +2,13 @@ import fs from "node:fs/promises";
|
||||||
|
|
||||||
let mapSVGs: string[];
|
let mapSVGs: string[];
|
||||||
|
|
||||||
export async function getMapSVGs () {
|
export async function getMapSVGs() {
|
||||||
|
|
||||||
if (!mapSVGs) {
|
if (!mapSVGs) {
|
||||||
const files = await fs.readdir("./public/images/maps/");
|
const files = await fs.readdir("./public/images/maps/");
|
||||||
|
|
||||||
const SVGs: string[] = [];
|
const SVGs: string[] = [];
|
||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
|
|
||||||
if (file.toLowerCase().endsWith(".svg")) {
|
if (file.toLowerCase().endsWith(".svg")) {
|
||||||
SVGs.push(file);
|
SVGs.push(file);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
import type { Request } from "express";
|
import type { Request } from "express";
|
||||||
|
|
||||||
|
|
||||||
export const userIsAdmin = (request: Request): boolean => {
|
export const userIsAdmin = (request: Request): boolean => {
|
||||||
|
|
||||||
const user = request.session?.user;
|
const user = request.session?.user;
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
|
|
@ -12,9 +10,7 @@ export const userIsAdmin = (request: Request): boolean => {
|
||||||
return user.userProperties.isAdmin;
|
return user.userProperties.isAdmin;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const userCanUpdate = (request: Request): boolean => {
|
export const userCanUpdate = (request: Request): boolean => {
|
||||||
|
|
||||||
const user = request.session?.user;
|
const user = request.session?.user;
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
|
|
|
||||||
|
|
@ -1,43 +1,24 @@
|
||||||
import {
|
import { lotOccupancyDB as databasePath } from "../data/databasePaths.js";
|
||||||
lotOccupancyDB as databasePath
|
|
||||||
} from "../data/databasePaths.js";
|
|
||||||
|
|
||||||
import {
|
import { initializeDatabase } from "./initializer.database.js";
|
||||||
initializeDatabase
|
|
||||||
} from "./initializer.database.js";
|
|
||||||
|
|
||||||
import {
|
import { addLotType } from "./lotOccupancyDB/addLotType.js";
|
||||||
addLotType
|
|
||||||
} from "./lotOccupancyDB/addLotType.js";
|
|
||||||
|
|
||||||
import {
|
import { addOccupancyType } from "./lotOccupancyDB/addOccupancyType.js";
|
||||||
addOccupancyType
|
|
||||||
} from "./lotOccupancyDB/addOccupancyType.js";
|
|
||||||
|
|
||||||
import {
|
import { addOccupancyTypeField } from "./lotOccupancyDB/addOccupancyTypeField.js";
|
||||||
addOccupancyTypeField
|
|
||||||
} from "./lotOccupancyDB/addOccupancyTypeField.js";
|
|
||||||
|
|
||||||
import {
|
import { addLotStatus } from "./lotOccupancyDB/addLotStatus.js";
|
||||||
addLotStatus
|
|
||||||
} from "./lotOccupancyDB/addLotStatus.js";
|
|
||||||
|
|
||||||
import {
|
import { addLotOccupantType } from "./lotOccupancyDB/addLotOccupantType.js";
|
||||||
addLotOccupantType
|
|
||||||
} from "./lotOccupancyDB/addLotOccupantType.js";
|
|
||||||
|
|
||||||
import {
|
import { addFeeCategory } from "./lotOccupancyDB/addFeeCategory.js";
|
||||||
addFeeCategory
|
|
||||||
} from "./lotOccupancyDB/addFeeCategory.js";
|
|
||||||
|
|
||||||
import type {
|
import type { PartialSession } from "../types/recordTypes.js";
|
||||||
PartialSession
|
|
||||||
} from "../types/recordTypes.js";
|
|
||||||
|
|
||||||
import Debug from "debug";
|
import Debug from "debug";
|
||||||
const debug = Debug("lot-occupancy-system:initialize");
|
const debug = Debug("lot-occupancy-system:initialize");
|
||||||
|
|
||||||
|
|
||||||
const session: PartialSession = {
|
const session: PartialSession = {
|
||||||
user: {
|
user: {
|
||||||
userName: "init.cemetery",
|
userName: "init.cemetery",
|
||||||
|
|
@ -48,9 +29,7 @@ const session: PartialSession = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const initializeCemeteryDatabase = () => {
|
const initializeCemeteryDatabase = () => {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ensure database does not already exist
|
* Ensure database does not already exist
|
||||||
*/
|
*/
|
||||||
|
|
@ -60,8 +39,10 @@ const initializeCemeteryDatabase = () => {
|
||||||
const databaseInitialized = initializeDatabase();
|
const databaseInitialized = initializeDatabase();
|
||||||
|
|
||||||
if (!databaseInitialized) {
|
if (!databaseInitialized) {
|
||||||
debug("Database already created.\n" +
|
debug(
|
||||||
"To initialize this database with cemetery types, delete the database file first, then rerun this script.");
|
"Database already created.\n" +
|
||||||
|
"To initialize this database with cemetery types, delete the database file first, then rerun this script."
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,94 +52,140 @@ const initializeCemeteryDatabase = () => {
|
||||||
* Lot Types
|
* Lot Types
|
||||||
*/
|
*/
|
||||||
|
|
||||||
addLotType({
|
addLotType(
|
||||||
|
{
|
||||||
lotType: "Casket Grave",
|
lotType: "Casket Grave",
|
||||||
orderNumber: 1
|
orderNumber: 1
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addLotType({
|
addLotType(
|
||||||
|
{
|
||||||
lotType: "Columbarium",
|
lotType: "Columbarium",
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addLotType({
|
addLotType(
|
||||||
|
{
|
||||||
lotType: "Mausoleum",
|
lotType: "Mausoleum",
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addLotType({
|
addLotType(
|
||||||
|
{
|
||||||
lotType: "Niche Wall",
|
lotType: "Niche Wall",
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addLotType({
|
addLotType(
|
||||||
|
{
|
||||||
lotType: "Urn Garden",
|
lotType: "Urn Garden",
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addLotType({
|
addLotType(
|
||||||
|
{
|
||||||
lotType: "Crematorium",
|
lotType: "Crematorium",
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lot Statuses
|
* Lot Statuses
|
||||||
*/
|
*/
|
||||||
|
|
||||||
addLotStatus({
|
addLotStatus(
|
||||||
|
{
|
||||||
lotStatus: "Available",
|
lotStatus: "Available",
|
||||||
orderNumber: 1
|
orderNumber: 1
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addLotStatus({
|
addLotStatus(
|
||||||
|
{
|
||||||
lotStatus: "Reserved",
|
lotStatus: "Reserved",
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addLotStatus({
|
addLotStatus(
|
||||||
|
{
|
||||||
lotStatus: "Taken",
|
lotStatus: "Taken",
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lot Occupant Types
|
* Lot Occupant Types
|
||||||
*/
|
*/
|
||||||
|
|
||||||
addLotOccupantType({
|
addLotOccupantType(
|
||||||
|
{
|
||||||
lotOccupantType: "Deceased",
|
lotOccupantType: "Deceased",
|
||||||
orderNumber: 1
|
orderNumber: 1
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addLotOccupantType({
|
addLotOccupantType(
|
||||||
|
{
|
||||||
lotOccupantType: "Preneed Owner",
|
lotOccupantType: "Preneed Owner",
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addLotOccupantType({
|
addLotOccupantType(
|
||||||
|
{
|
||||||
lotOccupantType: "Arranger",
|
lotOccupantType: "Arranger",
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Occupancy Types
|
* Occupancy Types
|
||||||
*/
|
*/
|
||||||
|
|
||||||
addOccupancyType({
|
addOccupancyType(
|
||||||
|
{
|
||||||
occupancyType: "Preneed",
|
occupancyType: "Preneed",
|
||||||
orderNumber: 1
|
orderNumber: 1
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
const intermentOccupancyTypeId = addOccupancyType({
|
const intermentOccupancyTypeId = addOccupancyType(
|
||||||
|
{
|
||||||
occupancyType: "Interment",
|
occupancyType: "Interment",
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addOccupancyType({
|
addOccupancyType(
|
||||||
|
{
|
||||||
occupancyType: "Cremation",
|
occupancyType: "Cremation",
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addOccupancyTypeField({
|
addOccupancyTypeField(
|
||||||
|
{
|
||||||
occupancyTypeId: intermentOccupancyTypeId,
|
occupancyTypeId: intermentOccupancyTypeId,
|
||||||
occupancyTypeField: "Death Date",
|
occupancyTypeField: "Death Date",
|
||||||
occupancyTypeFieldValues: "",
|
occupancyTypeFieldValues: "",
|
||||||
|
|
@ -167,9 +194,12 @@ const initializeCemeteryDatabase = () => {
|
||||||
minimumLength: 10,
|
minimumLength: 10,
|
||||||
maximumLength: 10,
|
maximumLength: 10,
|
||||||
orderNumber: 1
|
orderNumber: 1
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addOccupancyTypeField({
|
addOccupancyTypeField(
|
||||||
|
{
|
||||||
occupancyTypeId: intermentOccupancyTypeId,
|
occupancyTypeId: intermentOccupancyTypeId,
|
||||||
occupancyTypeField: "Death Age",
|
occupancyTypeField: "Death Age",
|
||||||
occupancyTypeFieldValues: "",
|
occupancyTypeFieldValues: "",
|
||||||
|
|
@ -178,9 +208,12 @@ const initializeCemeteryDatabase = () => {
|
||||||
minimumLength: 1,
|
minimumLength: 1,
|
||||||
maximumLength: 3,
|
maximumLength: 3,
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addOccupancyTypeField({
|
addOccupancyTypeField(
|
||||||
|
{
|
||||||
occupancyTypeId: intermentOccupancyTypeId,
|
occupancyTypeId: intermentOccupancyTypeId,
|
||||||
occupancyTypeField: "Death Age Period",
|
occupancyTypeField: "Death Age Period",
|
||||||
occupancyTypeFieldValues: "Years,Months,Days,Stillborn",
|
occupancyTypeFieldValues: "Years,Months,Days,Stillborn",
|
||||||
|
|
@ -189,9 +222,12 @@ const initializeCemeteryDatabase = () => {
|
||||||
minimumLength: 1,
|
minimumLength: 1,
|
||||||
maximumLength: 10,
|
maximumLength: 10,
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addOccupancyTypeField({
|
addOccupancyTypeField(
|
||||||
|
{
|
||||||
occupancyTypeId: intermentOccupancyTypeId,
|
occupancyTypeId: intermentOccupancyTypeId,
|
||||||
occupancyTypeField: "Funeral Home",
|
occupancyTypeField: "Funeral Home",
|
||||||
occupancyTypeFieldValues: "",
|
occupancyTypeFieldValues: "",
|
||||||
|
|
@ -200,9 +236,12 @@ const initializeCemeteryDatabase = () => {
|
||||||
minimumLength: 1,
|
minimumLength: 1,
|
||||||
maximumLength: 100,
|
maximumLength: 100,
|
||||||
orderNumber: 10
|
orderNumber: 10
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addOccupancyTypeField({
|
addOccupancyTypeField(
|
||||||
|
{
|
||||||
occupancyTypeId: intermentOccupancyTypeId,
|
occupancyTypeId: intermentOccupancyTypeId,
|
||||||
occupancyTypeField: "Funeral Date",
|
occupancyTypeField: "Funeral Date",
|
||||||
occupancyTypeFieldValues: "",
|
occupancyTypeFieldValues: "",
|
||||||
|
|
@ -211,9 +250,12 @@ const initializeCemeteryDatabase = () => {
|
||||||
minimumLength: 10,
|
minimumLength: 10,
|
||||||
maximumLength: 10,
|
maximumLength: 10,
|
||||||
orderNumber: 11
|
orderNumber: 11
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addOccupancyTypeField({
|
addOccupancyTypeField(
|
||||||
|
{
|
||||||
occupancyTypeId: intermentOccupancyTypeId,
|
occupancyTypeId: intermentOccupancyTypeId,
|
||||||
occupancyTypeField: "Container Type",
|
occupancyTypeField: "Container Type",
|
||||||
occupancyTypeFieldValues: "",
|
occupancyTypeFieldValues: "",
|
||||||
|
|
@ -222,9 +264,12 @@ const initializeCemeteryDatabase = () => {
|
||||||
minimumLength: 1,
|
minimumLength: 1,
|
||||||
maximumLength: 100,
|
maximumLength: 100,
|
||||||
orderNumber: 20
|
orderNumber: 20
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addOccupancyTypeField({
|
addOccupancyTypeField(
|
||||||
|
{
|
||||||
occupancyTypeId: intermentOccupancyTypeId,
|
occupancyTypeId: intermentOccupancyTypeId,
|
||||||
occupancyTypeField: "Committal Type",
|
occupancyTypeField: "Committal Type",
|
||||||
occupancyTypeFieldValues: "",
|
occupancyTypeFieldValues: "",
|
||||||
|
|
@ -233,37 +278,53 @@ const initializeCemeteryDatabase = () => {
|
||||||
minimumLength: 1,
|
minimumLength: 1,
|
||||||
maximumLength: 100,
|
maximumLength: 100,
|
||||||
orderNumber: 21
|
orderNumber: 21
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fee Categories
|
* Fee Categories
|
||||||
*/
|
*/
|
||||||
|
|
||||||
addFeeCategory({
|
addFeeCategory(
|
||||||
|
{
|
||||||
feeCategory: "Interment Rights",
|
feeCategory: "Interment Rights",
|
||||||
orderNumber: 1
|
orderNumber: 1
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addFeeCategory({
|
addFeeCategory(
|
||||||
|
{
|
||||||
feeCategory: "Cremation Services",
|
feeCategory: "Cremation Services",
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addFeeCategory({
|
addFeeCategory(
|
||||||
|
{
|
||||||
feeCategory: "Burial Charges",
|
feeCategory: "Burial Charges",
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addFeeCategory({
|
addFeeCategory(
|
||||||
|
{
|
||||||
feeCategory: "Disinterment of Human Remains",
|
feeCategory: "Disinterment of Human Remains",
|
||||||
orderNumber: 4
|
orderNumber: 4
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
|
|
||||||
addFeeCategory({
|
addFeeCategory(
|
||||||
|
{
|
||||||
feeCategory: "Additional Services",
|
feeCategory: "Additional Services",
|
||||||
orderNumber: 5
|
orderNumber: 5
|
||||||
}, session);
|
},
|
||||||
|
session
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
initializeCemeteryDatabase();
|
initializeCemeteryDatabase();
|
||||||
|
|
@ -15,15 +15,20 @@ export const initializeDatabase = () => {
|
||||||
.get();
|
.get();
|
||||||
if (!row) {
|
if (!row) {
|
||||||
debugSQL("Creating " + databasePath);
|
debugSQL("Creating " + databasePath);
|
||||||
lotOccupancyDB.prepare("create table if not exists LotTypes (" +
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists LotTypes (" +
|
||||||
"lotTypeId integer not null primary key autoincrement," +
|
"lotTypeId integer not null primary key autoincrement," +
|
||||||
" lotType varchar(100) not null," +
|
" lotType varchar(100) not null," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns +
|
recordColumns +
|
||||||
")").run();
|
")")
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_lottypes_ordernumber" +
|
.run();
|
||||||
" on LotTypes (orderNumber, lotType)").run();
|
lotOccupancyDB
|
||||||
lotOccupancyDB.prepare("create table if not exists LotTypeFields (" +
|
.prepare("create index if not exists idx_lottypes_ordernumber" +
|
||||||
|
" on LotTypes (orderNumber, lotType)")
|
||||||
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists LotTypeFields (" +
|
||||||
"lotTypeFieldId integer not null primary key autoincrement," +
|
"lotTypeFieldId integer not null primary key autoincrement," +
|
||||||
" lotTypeId integer not null," +
|
" lotTypeId integer not null," +
|
||||||
" lotTypeField varchar(100) not null," +
|
" lotTypeField varchar(100) not null," +
|
||||||
|
|
@ -33,20 +38,29 @@ export const initializeDatabase = () => {
|
||||||
" minimumLength smallint not null default 1 check (minimumLength >= 0)," +
|
" minimumLength smallint not null default 1 check (minimumLength >= 0)," +
|
||||||
" maximumLength smallint not null default 100 check (maximumLength >= 0)," +
|
" maximumLength smallint not null default 100 check (maximumLength >= 0)," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" foreign key (lotTypeId) references LotTypes (lotTypeId)" +
|
" foreign key (lotTypeId) references LotTypes (lotTypeId)" +
|
||||||
")").run();
|
")")
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_lottypefields_ordernumber" +
|
.run();
|
||||||
" on LotTypeFields (lotTypeId, orderNumber, lotTypeField)").run();
|
lotOccupancyDB
|
||||||
lotOccupancyDB.prepare("create table if not exists LotStatuses (" +
|
.prepare("create index if not exists idx_lottypefields_ordernumber" +
|
||||||
|
" on LotTypeFields (lotTypeId, orderNumber, lotTypeField)")
|
||||||
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists LotStatuses (" +
|
||||||
"lotStatusId integer not null primary key autoincrement," +
|
"lotStatusId integer not null primary key autoincrement," +
|
||||||
" lotStatus varchar(100) not null," +
|
" lotStatus varchar(100) not null," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns +
|
recordColumns +
|
||||||
")").run();
|
")")
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_lotstatuses_ordernumber" +
|
.run();
|
||||||
" on LotStatuses (orderNumber, lotStatus)").run();
|
lotOccupancyDB
|
||||||
lotOccupancyDB.prepare("create table if not exists Maps (" +
|
.prepare("create index if not exists idx_lotstatuses_ordernumber" +
|
||||||
|
" on LotStatuses (orderNumber, lotStatus)")
|
||||||
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists Maps (" +
|
||||||
"mapId integer not null primary key autoincrement," +
|
"mapId integer not null primary key autoincrement," +
|
||||||
" mapName varchar(200) not null," +
|
" mapName varchar(200) not null," +
|
||||||
" mapDescription text," +
|
" mapDescription text," +
|
||||||
|
|
@ -60,8 +74,10 @@ export const initializeDatabase = () => {
|
||||||
" mapPostalCode varchar(7)," +
|
" mapPostalCode varchar(7)," +
|
||||||
" mapPhoneNumber varchar(30)," +
|
" mapPhoneNumber varchar(30)," +
|
||||||
recordColumns +
|
recordColumns +
|
||||||
")").run();
|
")")
|
||||||
lotOccupancyDB.prepare("create table if not exists Lots (" +
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists Lots (" +
|
||||||
"lotId integer not null primary key autoincrement," +
|
"lotId integer not null primary key autoincrement," +
|
||||||
" lotTypeId integer not null," +
|
" lotTypeId integer not null," +
|
||||||
" lotName varchar(100)," +
|
" lotName varchar(100)," +
|
||||||
|
|
@ -70,40 +86,55 @@ export const initializeDatabase = () => {
|
||||||
" lotLatitude decimal(10, 8) check (lotLatitude between -90 and 90)," +
|
" lotLatitude decimal(10, 8) check (lotLatitude between -90 and 90)," +
|
||||||
" lotLongitude decimal(11, 8) check (lotLongitude between -180 and 180)," +
|
" lotLongitude decimal(11, 8) check (lotLongitude between -180 and 180)," +
|
||||||
" lotStatusId integer," +
|
" lotStatusId integer," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" foreign key (lotTypeId) references LotTypes (lotTypeId)," +
|
" foreign key (lotTypeId) references LotTypes (lotTypeId)," +
|
||||||
" foreign key (mapId) references Maps (mapId)," +
|
" foreign key (mapId) references Maps (mapId)," +
|
||||||
" foreign key (lotStatusId) references LotStatuses (lotStatusId)" +
|
" foreign key (lotStatusId) references LotStatuses (lotStatusId)" +
|
||||||
")").run();
|
")")
|
||||||
lotOccupancyDB.prepare("create table if not exists LotFields (" +
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists LotFields (" +
|
||||||
"lotId integer not null," +
|
"lotId integer not null," +
|
||||||
" lotTypeFieldId integer not null," +
|
" lotTypeFieldId integer not null," +
|
||||||
" lotFieldValue text not null," +
|
" lotFieldValue text not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" primary key (lotId, lotTypeFieldId)," +
|
" primary key (lotId, lotTypeFieldId)," +
|
||||||
" foreign key (lotId) references Lots (lotId)," +
|
" foreign key (lotId) references Lots (lotId)," +
|
||||||
" foreign key (lotTypeFieldId) references LotTypeFields (lotTypeFieldId)" +
|
" foreign key (lotTypeFieldId) references LotTypeFields (lotTypeFieldId)" +
|
||||||
") without rowid").run();
|
") without rowid")
|
||||||
lotOccupancyDB.prepare("create table if not exists LotComments (" +
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists LotComments (" +
|
||||||
"lotCommentId integer not null primary key autoincrement," +
|
"lotCommentId integer not null primary key autoincrement," +
|
||||||
" lotId integer not null," +
|
" lotId integer not null," +
|
||||||
" lotCommentDate integer not null check (lotCommentDate > 0)," +
|
" lotCommentDate integer not null check (lotCommentDate > 0)," +
|
||||||
" lotCommentTime integer not null check (lotCommentTime >= 0)," +
|
" lotCommentTime integer not null check (lotCommentTime >= 0)," +
|
||||||
" lotComment text not null," +
|
" lotComment text not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" foreign key (lotId) references Lots (lotId)" +
|
" foreign key (lotId) references Lots (lotId)" +
|
||||||
")").run();
|
")")
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_lotcomments_datetime" +
|
.run();
|
||||||
" on LotComments (lotId, lotCommentDate, lotCommentTime)").run();
|
lotOccupancyDB
|
||||||
lotOccupancyDB.prepare("create table if not exists OccupancyTypes (" +
|
.prepare("create index if not exists idx_lotcomments_datetime" +
|
||||||
|
" on LotComments (lotId, lotCommentDate, lotCommentTime)")
|
||||||
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists OccupancyTypes (" +
|
||||||
"occupancyTypeId integer not null primary key autoincrement," +
|
"occupancyTypeId integer not null primary key autoincrement," +
|
||||||
" occupancyType varchar(100) not null," +
|
" occupancyType varchar(100) not null," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns +
|
recordColumns +
|
||||||
")").run();
|
")")
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_occupancytypes_ordernumber" +
|
.run();
|
||||||
" on OccupancyTypes (orderNumber, occupancyType)").run();
|
lotOccupancyDB
|
||||||
lotOccupancyDB.prepare("create table if not exists OccupancyTypeFields (" +
|
.prepare("create index if not exists idx_occupancytypes_ordernumber" +
|
||||||
|
" on OccupancyTypes (orderNumber, occupancyType)")
|
||||||
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists OccupancyTypeFields (" +
|
||||||
"occupancyTypeFieldId integer not null primary key autoincrement," +
|
"occupancyTypeFieldId integer not null primary key autoincrement," +
|
||||||
" occupancyTypeId integer not null," +
|
" occupancyTypeId integer not null," +
|
||||||
" occupancyTypeField varchar(100) not null," +
|
" occupancyTypeField varchar(100) not null," +
|
||||||
|
|
@ -113,30 +144,42 @@ export const initializeDatabase = () => {
|
||||||
" minimumLength smallint not null default 1 check (minimumLength >= 0)," +
|
" minimumLength smallint not null default 1 check (minimumLength >= 0)," +
|
||||||
" maximumLength smallint not null default 100 check (maximumLength >= 0)," +
|
" maximumLength smallint not null default 100 check (maximumLength >= 0)," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId)" +
|
" foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId)" +
|
||||||
")").run();
|
")")
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_occupancytypefields_ordernumber" +
|
.run();
|
||||||
" on OccupancyTypeFields (occupancyTypeId, orderNumber, occupancyTypeField)").run();
|
lotOccupancyDB
|
||||||
lotOccupancyDB.prepare("create table if not exists LotOccupantTypes (" +
|
.prepare("create index if not exists idx_occupancytypefields_ordernumber" +
|
||||||
|
" on OccupancyTypeFields (occupancyTypeId, orderNumber, occupancyTypeField)")
|
||||||
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists LotOccupantTypes (" +
|
||||||
"lotOccupantTypeId integer not null primary key autoincrement," +
|
"lotOccupantTypeId integer not null primary key autoincrement," +
|
||||||
" lotOccupantType varchar(100) not null," +
|
" lotOccupantType varchar(100) not null," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns +
|
recordColumns +
|
||||||
")").run();
|
")")
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_lotoccupanttypes_ordernumber" +
|
.run();
|
||||||
" on LotOccupantTypes (orderNumber, lotOccupantType)").run();
|
lotOccupancyDB
|
||||||
lotOccupancyDB.prepare("create table if not exists LotOccupancies (" +
|
.prepare("create index if not exists idx_lotoccupanttypes_ordernumber" +
|
||||||
|
" on LotOccupantTypes (orderNumber, lotOccupantType)")
|
||||||
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists LotOccupancies (" +
|
||||||
"lotOccupancyId integer not null primary key autoincrement," +
|
"lotOccupancyId integer not null primary key autoincrement," +
|
||||||
" occupancyTypeId integer not null," +
|
" occupancyTypeId integer not null," +
|
||||||
" lotId integer," +
|
" lotId integer," +
|
||||||
" occupancyStartDate integer not null check (occupancyStartDate > 0)," +
|
" occupancyStartDate integer not null check (occupancyStartDate > 0)," +
|
||||||
" occupancyEndDate integer check (occupancyEndDate > 0)," +
|
" occupancyEndDate integer check (occupancyEndDate > 0)," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" foreign key (lotId) references Lots (lotId)," +
|
" foreign key (lotId) references Lots (lotId)," +
|
||||||
" foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId)" +
|
" foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId)" +
|
||||||
")").run();
|
")")
|
||||||
lotOccupancyDB.prepare("create table if not exists LotOccupancyOccupants (" +
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists LotOccupancyOccupants (" +
|
||||||
"lotOccupancyId integer not null," +
|
"lotOccupancyId integer not null," +
|
||||||
" lotOccupantIndex integer not null," +
|
" lotOccupantIndex integer not null," +
|
||||||
" occupantName varchar(200) not null," +
|
" occupantName varchar(200) not null," +
|
||||||
|
|
@ -147,38 +190,51 @@ export const initializeDatabase = () => {
|
||||||
" occupantPostalCode varchar(7)," +
|
" occupantPostalCode varchar(7)," +
|
||||||
" occupantPhoneNumber varchar(30)," +
|
" occupantPhoneNumber varchar(30)," +
|
||||||
" lotOccupantTypeId integer not null," +
|
" lotOccupantTypeId integer not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" primary key (lotOccupancyId, lotOccupantIndex)," +
|
" primary key (lotOccupancyId, lotOccupantIndex)," +
|
||||||
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)," +
|
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)," +
|
||||||
" foreign key (lotOccupantTypeId) references LotOccupantTypes (lotOccupantTypeId)" +
|
" foreign key (lotOccupantTypeId) references LotOccupantTypes (lotOccupantTypeId)" +
|
||||||
") without rowid").run();
|
") without rowid")
|
||||||
lotOccupancyDB.prepare("create table if not exists LotOccupancyFields (" +
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists LotOccupancyFields (" +
|
||||||
"lotOccupancyId integer not null," +
|
"lotOccupancyId integer not null," +
|
||||||
" occupancyTypeFieldId integer not null," +
|
" occupancyTypeFieldId integer not null," +
|
||||||
" lotOccupancyFieldValue text not null," +
|
" lotOccupancyFieldValue text not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" primary key (lotOccupancyId, occupancyTypeFieldId)," +
|
" primary key (lotOccupancyId, occupancyTypeFieldId)," +
|
||||||
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)," +
|
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)," +
|
||||||
" foreign key (occupancyTypeFieldId) references OccupancyTypeFields (occupancyTypeFieldId)" +
|
" foreign key (occupancyTypeFieldId) references OccupancyTypeFields (occupancyTypeFieldId)" +
|
||||||
") without rowid").run();
|
") without rowid")
|
||||||
lotOccupancyDB.prepare("create table if not exists LotOccupancyComments (" +
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists LotOccupancyComments (" +
|
||||||
"lotOccupancyCommentId integer not null primary key autoincrement," +
|
"lotOccupancyCommentId integer not null primary key autoincrement," +
|
||||||
" lotOccupancyId integer not null," +
|
" lotOccupancyId integer not null," +
|
||||||
" lotOccupancyCommentDate integer not null check (lotOccupancyCommentDate > 0)," +
|
" lotOccupancyCommentDate integer not null check (lotOccupancyCommentDate > 0)," +
|
||||||
" lotOccupancyCommentTime integer not null check (lotOccupancyCommentTime >= 0)," +
|
" lotOccupancyCommentTime integer not null check (lotOccupancyCommentTime >= 0)," +
|
||||||
" lotOccupancyComment text not null," +
|
" lotOccupancyComment text not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)" +
|
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)" +
|
||||||
")").run();
|
")")
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_lotoccupancycomments_datetime" +
|
.run();
|
||||||
" on LotOccupancyComments (lotOccupancyId, lotOccupancyCommentDate, lotOccupancyCommentTime)").run();
|
lotOccupancyDB
|
||||||
lotOccupancyDB.prepare("create table if not exists FeeCategories (" +
|
.prepare("create index if not exists idx_lotoccupancycomments_datetime" +
|
||||||
|
" on LotOccupancyComments (lotOccupancyId, lotOccupancyCommentDate, lotOccupancyCommentTime)")
|
||||||
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists FeeCategories (" +
|
||||||
"feeCategoryId integer not null primary key autoincrement," +
|
"feeCategoryId integer not null primary key autoincrement," +
|
||||||
" feeCategory varchar(100) not null," +
|
" feeCategory varchar(100) not null," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns +
|
recordColumns +
|
||||||
")").run();
|
")")
|
||||||
lotOccupancyDB.prepare("create table if not exists Fees (" +
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists Fees (" +
|
||||||
"feeId integer not null primary key autoincrement," +
|
"feeId integer not null primary key autoincrement," +
|
||||||
" feeCategoryId integer not null," +
|
" feeCategoryId integer not null," +
|
||||||
" feeName varchar(100) not null," +
|
" feeName varchar(100) not null," +
|
||||||
|
|
@ -193,25 +249,33 @@ export const initializeDatabase = () => {
|
||||||
" taxPercentage decimal(5, 2)," +
|
" taxPercentage decimal(5, 2)," +
|
||||||
" isRequired bit not null default 0," +
|
" isRequired bit not null default 0," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" foreign key (feeCategoryId) references FeeCategories (feeCategoryId)," +
|
" foreign key (feeCategoryId) references FeeCategories (feeCategoryId)," +
|
||||||
" foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId)," +
|
" foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId)," +
|
||||||
" foreign key (lotTypeId) references LotTypes (lotTypeId)" +
|
" foreign key (lotTypeId) references LotTypes (lotTypeId)" +
|
||||||
")").run();
|
")")
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_fees_ordernumber" +
|
.run();
|
||||||
" on Fees (orderNumber, feeName)").run();
|
lotOccupancyDB
|
||||||
lotOccupancyDB.prepare("create table if not exists LotOccupancyFees (" +
|
.prepare("create index if not exists idx_fees_ordernumber" +
|
||||||
|
" on Fees (orderNumber, feeName)")
|
||||||
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists LotOccupancyFees (" +
|
||||||
"lotOccupancyId integer not null," +
|
"lotOccupancyId integer not null," +
|
||||||
" feeId integer not null," +
|
" feeId integer not null," +
|
||||||
" quantity decimal(4, 1) not null default 1," +
|
" quantity decimal(4, 1) not null default 1," +
|
||||||
" feeAmount decimal(6, 2) not null," +
|
" feeAmount decimal(6, 2) not null," +
|
||||||
" taxAmount decmial(6, 2) not null," +
|
" taxAmount decmial(6, 2) not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" primary key (lotOccupancyId, feeId)," +
|
" primary key (lotOccupancyId, feeId)," +
|
||||||
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)," +
|
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)," +
|
||||||
" foreign key (feeId) references Fees (feeId)" +
|
" foreign key (feeId) references Fees (feeId)" +
|
||||||
") without rowid").run();
|
") without rowid")
|
||||||
lotOccupancyDB.prepare("create table if not exists LotOccupancyTransactions (" +
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists LotOccupancyTransactions (" +
|
||||||
"lotOccupancyId integer not null," +
|
"lotOccupancyId integer not null," +
|
||||||
" transactionIndex integer not null," +
|
" transactionIndex integer not null," +
|
||||||
" transactionDate integer not null check (transactionDate > 0)," +
|
" transactionDate integer not null check (transactionDate > 0)," +
|
||||||
|
|
@ -219,57 +283,79 @@ export const initializeDatabase = () => {
|
||||||
" transactionAmount decimal(6, 2) not null," +
|
" transactionAmount decimal(6, 2) not null," +
|
||||||
" externalReceiptNumber varchar(100)," +
|
" externalReceiptNumber varchar(100)," +
|
||||||
" transactionNote text," +
|
" transactionNote text," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" primary key (lotOccupancyId, transactionIndex)," +
|
" primary key (lotOccupancyId, transactionIndex)," +
|
||||||
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)" +
|
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)" +
|
||||||
") without rowid").run();
|
") without rowid")
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_lotoccupancytransactions_ordernumber" +
|
.run();
|
||||||
" on LotOccupancyTransactions (lotOccupancyId, transactionDate, transactionTime)").run();
|
lotOccupancyDB
|
||||||
lotOccupancyDB.prepare("create table if not exists WorkOrderTypes (" +
|
.prepare("create index if not exists idx_lotoccupancytransactions_ordernumber" +
|
||||||
|
" on LotOccupancyTransactions (lotOccupancyId, transactionDate, transactionTime)")
|
||||||
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists WorkOrderTypes (" +
|
||||||
"workOrderTypeId integer not null primary key autoincrement," +
|
"workOrderTypeId integer not null primary key autoincrement," +
|
||||||
" workOrderType varchar(100) not null," +
|
" workOrderType varchar(100) not null," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns +
|
recordColumns +
|
||||||
")").run();
|
")")
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_workordertypes_ordernumber" +
|
.run();
|
||||||
" on WorkOrderTypes (orderNumber, workOrderType)").run();
|
lotOccupancyDB
|
||||||
lotOccupancyDB.prepare("create table if not exists WorkOrders (" +
|
.prepare("create index if not exists idx_workordertypes_ordernumber" +
|
||||||
|
" on WorkOrderTypes (orderNumber, workOrderType)")
|
||||||
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists WorkOrders (" +
|
||||||
"workOrderId integer not null primary key autoincrement," +
|
"workOrderId integer not null primary key autoincrement," +
|
||||||
" workOrderTypeId integer not null," +
|
" workOrderTypeId integer not null," +
|
||||||
" workOrderNumber varchar(50) not null," +
|
" workOrderNumber varchar(50) not null," +
|
||||||
" workOrderDescription text," +
|
" workOrderDescription text," +
|
||||||
" workOrderOpenDate integer check (workOrderOpenDate > 0)," +
|
" workOrderOpenDate integer check (workOrderOpenDate > 0)," +
|
||||||
" workOrderCloseDate integer check (workOrderCloseDate > 0)," +
|
" workOrderCloseDate integer check (workOrderCloseDate > 0)," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" foreign key (workOrderTypeId) references WorkOrderTypes (workOrderTypeId)" +
|
" foreign key (workOrderTypeId) references WorkOrderTypes (workOrderTypeId)" +
|
||||||
")").run();
|
")")
|
||||||
lotOccupancyDB.prepare("create table if not exists WorkOrderLots (" +
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists WorkOrderLots (" +
|
||||||
"workOrderId integer not null," +
|
"workOrderId integer not null," +
|
||||||
" lotId integer not null," +
|
" lotId integer not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" primary key (workOrderId, lotId)," +
|
" primary key (workOrderId, lotId)," +
|
||||||
" foreign key (workOrderId) references WorkOrders (workOrderId)," +
|
" foreign key (workOrderId) references WorkOrders (workOrderId)," +
|
||||||
" foreign key (lotId) references Lots (lotId)" +
|
" foreign key (lotId) references Lots (lotId)" +
|
||||||
") without rowid").run();
|
") without rowid")
|
||||||
lotOccupancyDB.prepare("create table if not exists WorkOrderLotOccupancies (" +
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists WorkOrderLotOccupancies (" +
|
||||||
"workOrderId integer not null," +
|
"workOrderId integer not null," +
|
||||||
" lotOccupancyId integer not null," +
|
" lotOccupancyId integer not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" primary key (workOrderId, lotOccupancyId)," +
|
" primary key (workOrderId, lotOccupancyId)," +
|
||||||
" foreign key (workOrderId) references WorkOrders (workOrderId)," +
|
" foreign key (workOrderId) references WorkOrders (workOrderId)," +
|
||||||
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)" +
|
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)" +
|
||||||
") without rowid").run();
|
") without rowid")
|
||||||
lotOccupancyDB.prepare("create table if not exists WorkOrderComments (" +
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists WorkOrderComments (" +
|
||||||
"workOrderCommentId integer not null primary key autoincrement," +
|
"workOrderCommentId integer not null primary key autoincrement," +
|
||||||
" workOrderId integer not null," +
|
" workOrderId integer not null," +
|
||||||
" workOrderCommentDate integer not null check (workOrderCommentDate > 0)," +
|
" workOrderCommentDate integer not null check (workOrderCommentDate > 0)," +
|
||||||
" workOrderCommentTime integer not null check (workOrderCommentTime >= 0)," +
|
" workOrderCommentTime integer not null check (workOrderCommentTime >= 0)," +
|
||||||
" workOrderComment text not null," +
|
" workOrderComment text not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" foreign key (workOrderId) references WorkOrders (workOrderId)" +
|
" foreign key (workOrderId) references WorkOrders (workOrderId)" +
|
||||||
")").run();
|
")")
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_workordercomments_datetime" +
|
.run();
|
||||||
" on WorkOrderComments (workOrderId, workOrderCommentDate, workOrderCommentTime)").run();
|
lotOccupancyDB
|
||||||
|
.prepare("create index if not exists idx_workordercomments_datetime" +
|
||||||
|
" on WorkOrderComments (workOrderId, workOrderCommentDate, workOrderCommentTime)")
|
||||||
|
.run();
|
||||||
lotOccupancyDB.close();
|
lotOccupancyDB.close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,46 +1,53 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
import {
|
import { lotOccupancyDB as databasePath } from "../data/databasePaths.js";
|
||||||
lotOccupancyDB as databasePath
|
|
||||||
} from "../data/databasePaths.js";
|
|
||||||
|
|
||||||
import debug from "debug";
|
import debug from "debug";
|
||||||
const debugSQL = debug("lot-occupancy-system:databaseInitializer");
|
const debugSQL = debug("lot-occupancy-system:databaseInitializer");
|
||||||
|
|
||||||
|
const recordColumns =
|
||||||
const recordColumns = " recordCreate_userName varchar(30) not null," +
|
" recordCreate_userName varchar(30) not null," +
|
||||||
" recordCreate_timeMillis integer not null," +
|
" recordCreate_timeMillis integer not null," +
|
||||||
" recordUpdate_userName varchar(30) not null," +
|
" recordUpdate_userName varchar(30) not null," +
|
||||||
" recordUpdate_timeMillis integer not null," +
|
" recordUpdate_timeMillis integer not null," +
|
||||||
" recordDelete_userName varchar(30)," +
|
" recordDelete_userName varchar(30)," +
|
||||||
" recordDelete_timeMillis integer";
|
" recordDelete_timeMillis integer";
|
||||||
|
|
||||||
|
|
||||||
export const initializeDatabase = (): boolean => {
|
export const initializeDatabase = (): boolean => {
|
||||||
|
|
||||||
const lotOccupancyDB = sqlite(databasePath);
|
const lotOccupancyDB = sqlite(databasePath);
|
||||||
|
|
||||||
const row = lotOccupancyDB
|
const row = lotOccupancyDB
|
||||||
.prepare("select name from sqlite_master where type = 'table' and name = 'WorkOrderComments'")
|
.prepare(
|
||||||
|
"select name from sqlite_master where type = 'table' and name = 'WorkOrderComments'"
|
||||||
|
)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
if (!row) {
|
if (!row) {
|
||||||
|
|
||||||
debugSQL("Creating " + databasePath);
|
debugSQL("Creating " + databasePath);
|
||||||
|
|
||||||
// Lot Types
|
// Lot Types
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists LotTypes (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists LotTypes (" +
|
||||||
"lotTypeId integer not null primary key autoincrement," +
|
"lotTypeId integer not null primary key autoincrement," +
|
||||||
" lotType varchar(100) not null," +
|
" lotType varchar(100) not null," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns +
|
recordColumns +
|
||||||
")").run();
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_lottypes_ordernumber" +
|
lotOccupancyDB
|
||||||
" on LotTypes (orderNumber, lotType)").run();
|
.prepare(
|
||||||
|
"create index if not exists idx_lottypes_ordernumber" +
|
||||||
|
" on LotTypes (orderNumber, lotType)"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists LotTypeFields (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists LotTypeFields (" +
|
||||||
"lotTypeFieldId integer not null primary key autoincrement," +
|
"lotTypeFieldId integer not null primary key autoincrement," +
|
||||||
" lotTypeId integer not null," +
|
" lotTypeId integer not null," +
|
||||||
" lotTypeField varchar(100) not null," +
|
" lotTypeField varchar(100) not null," +
|
||||||
|
|
@ -50,99 +57,140 @@ export const initializeDatabase = (): boolean => {
|
||||||
" minimumLength smallint not null default 1 check (minimumLength >= 0)," +
|
" minimumLength smallint not null default 1 check (minimumLength >= 0)," +
|
||||||
" maximumLength smallint not null default 100 check (maximumLength >= 0)," +
|
" maximumLength smallint not null default 100 check (maximumLength >= 0)," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" foreign key (lotTypeId) references LotTypes (lotTypeId)" +
|
" foreign key (lotTypeId) references LotTypes (lotTypeId)" +
|
||||||
")").run();
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_lottypefields_ordernumber" +
|
lotOccupancyDB
|
||||||
" on LotTypeFields (lotTypeId, orderNumber, lotTypeField)").run();
|
.prepare(
|
||||||
|
"create index if not exists idx_lottypefields_ordernumber" +
|
||||||
|
" on LotTypeFields (lotTypeId, orderNumber, lotTypeField)"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists LotStatuses (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists LotStatuses (" +
|
||||||
"lotStatusId integer not null primary key autoincrement," +
|
"lotStatusId integer not null primary key autoincrement," +
|
||||||
" lotStatus varchar(100) not null," +
|
" lotStatus varchar(100) not null," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns +
|
recordColumns +
|
||||||
")").run();
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_lotstatuses_ordernumber" +
|
lotOccupancyDB
|
||||||
" on LotStatuses (orderNumber, lotStatus)").run();
|
.prepare(
|
||||||
|
"create index if not exists idx_lotstatuses_ordernumber" +
|
||||||
|
" on LotStatuses (orderNumber, lotStatus)"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
// Maps and Lots
|
// Maps and Lots
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists Maps (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists Maps (" +
|
||||||
"mapId integer not null primary key autoincrement," +
|
"mapId integer not null primary key autoincrement," +
|
||||||
" mapName varchar(200) not null," +
|
" mapName varchar(200) not null," +
|
||||||
" mapDescription text," +
|
" mapDescription text," +
|
||||||
|
|
||||||
" mapLatitude decimal(10, 8) check (mapLatitude between -90 and 90)," +
|
" mapLatitude decimal(10, 8) check (mapLatitude between -90 and 90)," +
|
||||||
" mapLongitude decimal(11, 8) check (mapLongitude between -180 and 180)," +
|
" mapLongitude decimal(11, 8) check (mapLongitude between -180 and 180)," +
|
||||||
|
|
||||||
" mapSVG varchar(50)," +
|
" mapSVG varchar(50)," +
|
||||||
|
|
||||||
" mapAddress1 varchar(50)," +
|
" mapAddress1 varchar(50)," +
|
||||||
" mapAddress2 varchar(50)," +
|
" mapAddress2 varchar(50)," +
|
||||||
" mapCity varchar(20)," +
|
" mapCity varchar(20)," +
|
||||||
" mapProvince varchar(2)," +
|
" mapProvince varchar(2)," +
|
||||||
" mapPostalCode varchar(7)," +
|
" mapPostalCode varchar(7)," +
|
||||||
" mapPhoneNumber varchar(30)," +
|
" mapPhoneNumber varchar(30)," +
|
||||||
|
|
||||||
recordColumns +
|
recordColumns +
|
||||||
")").run();
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists Lots (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists Lots (" +
|
||||||
"lotId integer not null primary key autoincrement," +
|
"lotId integer not null primary key autoincrement," +
|
||||||
" lotTypeId integer not null," +
|
" lotTypeId integer not null," +
|
||||||
" lotName varchar(100)," +
|
" lotName varchar(100)," +
|
||||||
" mapId integer," +
|
" mapId integer," +
|
||||||
" mapKey varchar(100)," +
|
" mapKey varchar(100)," +
|
||||||
|
|
||||||
" lotLatitude decimal(10, 8) check (lotLatitude between -90 and 90)," +
|
" lotLatitude decimal(10, 8) check (lotLatitude between -90 and 90)," +
|
||||||
" lotLongitude decimal(11, 8) check (lotLongitude between -180 and 180)," +
|
" lotLongitude decimal(11, 8) check (lotLongitude between -180 and 180)," +
|
||||||
|
|
||||||
" lotStatusId integer," +
|
" lotStatusId integer," +
|
||||||
|
recordColumns +
|
||||||
recordColumns + "," +
|
"," +
|
||||||
" foreign key (lotTypeId) references LotTypes (lotTypeId)," +
|
" foreign key (lotTypeId) references LotTypes (lotTypeId)," +
|
||||||
" foreign key (mapId) references Maps (mapId)," +
|
" foreign key (mapId) references Maps (mapId)," +
|
||||||
" foreign key (lotStatusId) references LotStatuses (lotStatusId)" +
|
" foreign key (lotStatusId) references LotStatuses (lotStatusId)" +
|
||||||
")").run();
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists LotFields (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists LotFields (" +
|
||||||
"lotId integer not null," +
|
"lotId integer not null," +
|
||||||
" lotTypeFieldId integer not null," +
|
" lotTypeFieldId integer not null," +
|
||||||
" lotFieldValue text not null," +
|
" lotFieldValue text not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" primary key (lotId, lotTypeFieldId)," +
|
" primary key (lotId, lotTypeFieldId)," +
|
||||||
" foreign key (lotId) references Lots (lotId)," +
|
" foreign key (lotId) references Lots (lotId)," +
|
||||||
" foreign key (lotTypeFieldId) references LotTypeFields (lotTypeFieldId)" +
|
" foreign key (lotTypeFieldId) references LotTypeFields (lotTypeFieldId)" +
|
||||||
") without rowid").run();
|
") without rowid"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists LotComments (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists LotComments (" +
|
||||||
"lotCommentId integer not null primary key autoincrement," +
|
"lotCommentId integer not null primary key autoincrement," +
|
||||||
" lotId integer not null," +
|
" lotId integer not null," +
|
||||||
" lotCommentDate integer not null check (lotCommentDate > 0)," +
|
" lotCommentDate integer not null check (lotCommentDate > 0)," +
|
||||||
" lotCommentTime integer not null check (lotCommentTime >= 0)," +
|
" lotCommentTime integer not null check (lotCommentTime >= 0)," +
|
||||||
" lotComment text not null," +
|
" lotComment text not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" foreign key (lotId) references Lots (lotId)" +
|
" foreign key (lotId) references Lots (lotId)" +
|
||||||
")").run();
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_lotcomments_datetime" +
|
lotOccupancyDB
|
||||||
" on LotComments (lotId, lotCommentDate, lotCommentTime)").run();
|
.prepare(
|
||||||
|
"create index if not exists idx_lotcomments_datetime" +
|
||||||
|
" on LotComments (lotId, lotCommentDate, lotCommentTime)"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
// Occupancies
|
// Occupancies
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists OccupancyTypes (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists OccupancyTypes (" +
|
||||||
"occupancyTypeId integer not null primary key autoincrement," +
|
"occupancyTypeId integer not null primary key autoincrement," +
|
||||||
" occupancyType varchar(100) not null," +
|
" occupancyType varchar(100) not null," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns +
|
recordColumns +
|
||||||
")").run();
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_occupancytypes_ordernumber" +
|
lotOccupancyDB
|
||||||
" on OccupancyTypes (orderNumber, occupancyType)").run();
|
.prepare(
|
||||||
|
"create index if not exists idx_occupancytypes_ordernumber" +
|
||||||
|
" on OccupancyTypes (orderNumber, occupancyType)"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists OccupancyTypeFields (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists OccupancyTypeFields (" +
|
||||||
"occupancyTypeFieldId integer not null primary key autoincrement," +
|
"occupancyTypeFieldId integer not null primary key autoincrement," +
|
||||||
" occupancyTypeId integer not null," +
|
" occupancyTypeId integer not null," +
|
||||||
" occupancyTypeField varchar(100) not null," +
|
" occupancyTypeField varchar(100) not null," +
|
||||||
|
|
@ -152,35 +200,57 @@ export const initializeDatabase = (): boolean => {
|
||||||
" minimumLength smallint not null default 1 check (minimumLength >= 0)," +
|
" minimumLength smallint not null default 1 check (minimumLength >= 0)," +
|
||||||
" maximumLength smallint not null default 100 check (maximumLength >= 0)," +
|
" maximumLength smallint not null default 100 check (maximumLength >= 0)," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId)" +
|
" foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId)" +
|
||||||
")").run();
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_occupancytypefields_ordernumber" +
|
lotOccupancyDB
|
||||||
" on OccupancyTypeFields (occupancyTypeId, orderNumber, occupancyTypeField)").run();
|
.prepare(
|
||||||
|
"create index if not exists idx_occupancytypefields_ordernumber" +
|
||||||
|
" on OccupancyTypeFields (occupancyTypeId, orderNumber, occupancyTypeField)"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists LotOccupantTypes (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists LotOccupantTypes (" +
|
||||||
"lotOccupantTypeId integer not null primary key autoincrement," +
|
"lotOccupantTypeId integer not null primary key autoincrement," +
|
||||||
" lotOccupantType varchar(100) not null," +
|
" lotOccupantType varchar(100) not null," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns +
|
recordColumns +
|
||||||
")").run();
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_lotoccupanttypes_ordernumber" +
|
lotOccupancyDB
|
||||||
" on LotOccupantTypes (orderNumber, lotOccupantType)").run();
|
.prepare(
|
||||||
|
"create index if not exists idx_lotoccupanttypes_ordernumber" +
|
||||||
|
" on LotOccupantTypes (orderNumber, lotOccupantType)"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists LotOccupancies (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists LotOccupancies (" +
|
||||||
"lotOccupancyId integer not null primary key autoincrement," +
|
"lotOccupancyId integer not null primary key autoincrement," +
|
||||||
" occupancyTypeId integer not null," +
|
" occupancyTypeId integer not null," +
|
||||||
" lotId integer," +
|
" lotId integer," +
|
||||||
" occupancyStartDate integer not null check (occupancyStartDate > 0)," +
|
" occupancyStartDate integer not null check (occupancyStartDate > 0)," +
|
||||||
" occupancyEndDate integer check (occupancyEndDate > 0)," +
|
" occupancyEndDate integer check (occupancyEndDate > 0)," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" foreign key (lotId) references Lots (lotId)," +
|
" foreign key (lotId) references Lots (lotId)," +
|
||||||
" foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId)" +
|
" foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId)" +
|
||||||
")").run();
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists LotOccupancyOccupants (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists LotOccupancyOccupants (" +
|
||||||
"lotOccupancyId integer not null," +
|
"lotOccupancyId integer not null," +
|
||||||
" lotOccupantIndex integer not null," +
|
" lotOccupantIndex integer not null," +
|
||||||
" occupantName varchar(200) not null," +
|
" occupantName varchar(200) not null," +
|
||||||
|
|
@ -191,45 +261,68 @@ export const initializeDatabase = (): boolean => {
|
||||||
" occupantPostalCode varchar(7)," +
|
" occupantPostalCode varchar(7)," +
|
||||||
" occupantPhoneNumber varchar(30)," +
|
" occupantPhoneNumber varchar(30)," +
|
||||||
" lotOccupantTypeId integer not null," +
|
" lotOccupantTypeId integer not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" primary key (lotOccupancyId, lotOccupantIndex)," +
|
" primary key (lotOccupancyId, lotOccupantIndex)," +
|
||||||
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)," +
|
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)," +
|
||||||
" foreign key (lotOccupantTypeId) references LotOccupantTypes (lotOccupantTypeId)" +
|
" foreign key (lotOccupantTypeId) references LotOccupantTypes (lotOccupantTypeId)" +
|
||||||
") without rowid").run();
|
") without rowid"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists LotOccupancyFields (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists LotOccupancyFields (" +
|
||||||
"lotOccupancyId integer not null," +
|
"lotOccupancyId integer not null," +
|
||||||
" occupancyTypeFieldId integer not null," +
|
" occupancyTypeFieldId integer not null," +
|
||||||
" lotOccupancyFieldValue text not null," +
|
" lotOccupancyFieldValue text not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" primary key (lotOccupancyId, occupancyTypeFieldId)," +
|
" primary key (lotOccupancyId, occupancyTypeFieldId)," +
|
||||||
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)," +
|
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)," +
|
||||||
" foreign key (occupancyTypeFieldId) references OccupancyTypeFields (occupancyTypeFieldId)" +
|
" foreign key (occupancyTypeFieldId) references OccupancyTypeFields (occupancyTypeFieldId)" +
|
||||||
") without rowid").run();
|
") without rowid"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists LotOccupancyComments (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists LotOccupancyComments (" +
|
||||||
"lotOccupancyCommentId integer not null primary key autoincrement," +
|
"lotOccupancyCommentId integer not null primary key autoincrement," +
|
||||||
" lotOccupancyId integer not null," +
|
" lotOccupancyId integer not null," +
|
||||||
" lotOccupancyCommentDate integer not null check (lotOccupancyCommentDate > 0)," +
|
" lotOccupancyCommentDate integer not null check (lotOccupancyCommentDate > 0)," +
|
||||||
" lotOccupancyCommentTime integer not null check (lotOccupancyCommentTime >= 0)," +
|
" lotOccupancyCommentTime integer not null check (lotOccupancyCommentTime >= 0)," +
|
||||||
" lotOccupancyComment text not null," +
|
" lotOccupancyComment text not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)" +
|
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)" +
|
||||||
")").run();
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_lotoccupancycomments_datetime" +
|
lotOccupancyDB
|
||||||
" on LotOccupancyComments (lotOccupancyId, lotOccupancyCommentDate, lotOccupancyCommentTime)").run();
|
.prepare(
|
||||||
|
"create index if not exists idx_lotoccupancycomments_datetime" +
|
||||||
|
" on LotOccupancyComments (lotOccupancyId, lotOccupancyCommentDate, lotOccupancyCommentTime)"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
// Occupancy Fees and Transactions
|
// Occupancy Fees and Transactions
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists FeeCategories (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists FeeCategories (" +
|
||||||
"feeCategoryId integer not null primary key autoincrement," +
|
"feeCategoryId integer not null primary key autoincrement," +
|
||||||
" feeCategory varchar(100) not null," +
|
" feeCategory varchar(100) not null," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns +
|
recordColumns +
|
||||||
")").run();
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists Fees (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists Fees (" +
|
||||||
"feeId integer not null primary key autoincrement," +
|
"feeId integer not null primary key autoincrement," +
|
||||||
" feeCategoryId integer not null," +
|
" feeCategoryId integer not null," +
|
||||||
" feeName varchar(100) not null," +
|
" feeName varchar(100) not null," +
|
||||||
|
|
@ -244,28 +337,42 @@ export const initializeDatabase = (): boolean => {
|
||||||
" taxPercentage decimal(5, 2)," +
|
" taxPercentage decimal(5, 2)," +
|
||||||
" isRequired bit not null default 0," +
|
" isRequired bit not null default 0," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" foreign key (feeCategoryId) references FeeCategories (feeCategoryId)," +
|
" foreign key (feeCategoryId) references FeeCategories (feeCategoryId)," +
|
||||||
" foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId)," +
|
" foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId)," +
|
||||||
" foreign key (lotTypeId) references LotTypes (lotTypeId)" +
|
" foreign key (lotTypeId) references LotTypes (lotTypeId)" +
|
||||||
")").run();
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_fees_ordernumber" +
|
lotOccupancyDB
|
||||||
" on Fees (orderNumber, feeName)").run();
|
.prepare(
|
||||||
|
"create index if not exists idx_fees_ordernumber" +
|
||||||
|
" on Fees (orderNumber, feeName)"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists LotOccupancyFees (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists LotOccupancyFees (" +
|
||||||
"lotOccupancyId integer not null," +
|
"lotOccupancyId integer not null," +
|
||||||
" feeId integer not null," +
|
" feeId integer not null," +
|
||||||
" quantity decimal(4, 1) not null default 1," +
|
" quantity decimal(4, 1) not null default 1," +
|
||||||
" feeAmount decimal(6, 2) not null," +
|
" feeAmount decimal(6, 2) not null," +
|
||||||
" taxAmount decmial(6, 2) not null," +
|
" taxAmount decmial(6, 2) not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" primary key (lotOccupancyId, feeId)," +
|
" primary key (lotOccupancyId, feeId)," +
|
||||||
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)," +
|
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)," +
|
||||||
" foreign key (feeId) references Fees (feeId)" +
|
" foreign key (feeId) references Fees (feeId)" +
|
||||||
") without rowid").run();
|
") without rowid"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists LotOccupancyTransactions (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists LotOccupancyTransactions (" +
|
||||||
"lotOccupancyId integer not null," +
|
"lotOccupancyId integer not null," +
|
||||||
" transactionIndex integer not null," +
|
" transactionIndex integer not null," +
|
||||||
" transactionDate integer not null check (transactionDate > 0)," +
|
" transactionDate integer not null check (transactionDate > 0)," +
|
||||||
|
|
@ -273,67 +380,106 @@ export const initializeDatabase = (): boolean => {
|
||||||
" transactionAmount decimal(6, 2) not null," +
|
" transactionAmount decimal(6, 2) not null," +
|
||||||
" externalReceiptNumber varchar(100)," +
|
" externalReceiptNumber varchar(100)," +
|
||||||
" transactionNote text," +
|
" transactionNote text," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" primary key (lotOccupancyId, transactionIndex)," +
|
" primary key (lotOccupancyId, transactionIndex)," +
|
||||||
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)" +
|
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)" +
|
||||||
") without rowid").run();
|
") without rowid"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_lotoccupancytransactions_ordernumber" +
|
lotOccupancyDB
|
||||||
" on LotOccupancyTransactions (lotOccupancyId, transactionDate, transactionTime)").run();
|
.prepare(
|
||||||
|
"create index if not exists idx_lotoccupancytransactions_ordernumber" +
|
||||||
|
" on LotOccupancyTransactions (lotOccupancyId, transactionDate, transactionTime)"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
// Work Orders
|
// Work Orders
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists WorkOrderTypes (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists WorkOrderTypes (" +
|
||||||
"workOrderTypeId integer not null primary key autoincrement," +
|
"workOrderTypeId integer not null primary key autoincrement," +
|
||||||
" workOrderType varchar(100) not null," +
|
" workOrderType varchar(100) not null," +
|
||||||
" orderNumber smallint not null default 0," +
|
" orderNumber smallint not null default 0," +
|
||||||
recordColumns +
|
recordColumns +
|
||||||
")").run();
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_workordertypes_ordernumber" +
|
lotOccupancyDB
|
||||||
" on WorkOrderTypes (orderNumber, workOrderType)").run();
|
.prepare(
|
||||||
|
"create index if not exists idx_workordertypes_ordernumber" +
|
||||||
|
" on WorkOrderTypes (orderNumber, workOrderType)"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists WorkOrders (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists WorkOrders (" +
|
||||||
"workOrderId integer not null primary key autoincrement," +
|
"workOrderId integer not null primary key autoincrement," +
|
||||||
" workOrderTypeId integer not null," +
|
" workOrderTypeId integer not null," +
|
||||||
" workOrderNumber varchar(50) not null," +
|
" workOrderNumber varchar(50) not null," +
|
||||||
" workOrderDescription text," +
|
" workOrderDescription text," +
|
||||||
" workOrderOpenDate integer check (workOrderOpenDate > 0)," +
|
" workOrderOpenDate integer check (workOrderOpenDate > 0)," +
|
||||||
" workOrderCloseDate integer check (workOrderCloseDate > 0)," +
|
" workOrderCloseDate integer check (workOrderCloseDate > 0)," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" foreign key (workOrderTypeId) references WorkOrderTypes (workOrderTypeId)" +
|
" foreign key (workOrderTypeId) references WorkOrderTypes (workOrderTypeId)" +
|
||||||
")").run();
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists WorkOrderLots (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists WorkOrderLots (" +
|
||||||
"workOrderId integer not null," +
|
"workOrderId integer not null," +
|
||||||
" lotId integer not null," +
|
" lotId integer not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" primary key (workOrderId, lotId)," +
|
" primary key (workOrderId, lotId)," +
|
||||||
" foreign key (workOrderId) references WorkOrders (workOrderId)," +
|
" foreign key (workOrderId) references WorkOrders (workOrderId)," +
|
||||||
" foreign key (lotId) references Lots (lotId)" +
|
" foreign key (lotId) references Lots (lotId)" +
|
||||||
") without rowid").run();
|
") without rowid"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists WorkOrderLotOccupancies (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists WorkOrderLotOccupancies (" +
|
||||||
"workOrderId integer not null," +
|
"workOrderId integer not null," +
|
||||||
" lotOccupancyId integer not null," +
|
" lotOccupancyId integer not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" primary key (workOrderId, lotOccupancyId)," +
|
" primary key (workOrderId, lotOccupancyId)," +
|
||||||
" foreign key (workOrderId) references WorkOrders (workOrderId)," +
|
" foreign key (workOrderId) references WorkOrders (workOrderId)," +
|
||||||
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)" +
|
" foreign key (lotOccupancyId) references LotOccupancies (lotOccupancyId)" +
|
||||||
") without rowid").run();
|
") without rowid"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create table if not exists WorkOrderComments (" +
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists WorkOrderComments (" +
|
||||||
"workOrderCommentId integer not null primary key autoincrement," +
|
"workOrderCommentId integer not null primary key autoincrement," +
|
||||||
" workOrderId integer not null," +
|
" workOrderId integer not null," +
|
||||||
" workOrderCommentDate integer not null check (workOrderCommentDate > 0)," +
|
" workOrderCommentDate integer not null check (workOrderCommentDate > 0)," +
|
||||||
" workOrderCommentTime integer not null check (workOrderCommentTime >= 0)," +
|
" workOrderCommentTime integer not null check (workOrderCommentTime >= 0)," +
|
||||||
" workOrderComment text not null," +
|
" workOrderComment text not null," +
|
||||||
recordColumns + "," +
|
recordColumns +
|
||||||
|
"," +
|
||||||
" foreign key (workOrderId) references WorkOrders (workOrderId)" +
|
" foreign key (workOrderId) references WorkOrders (workOrderId)" +
|
||||||
")").run();
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.prepare("create index if not exists idx_workordercomments_datetime" +
|
lotOccupancyDB
|
||||||
" on WorkOrderComments (workOrderId, workOrderCommentDate, workOrderCommentTime)").run();
|
.prepare(
|
||||||
|
"create index if not exists idx_workordercomments_datetime" +
|
||||||
|
" on WorkOrderComments (workOrderId, workOrderCommentDate, workOrderCommentTime)"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.close();
|
lotOccupancyDB.close();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ export const 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 || 0), 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 ? 1 : 0, feeForm.quantityUnit, feeForm.isRequired ? 1 : 0, feeForm.orderNumber || 0, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||||
database.close();
|
database.close();
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
|
|
||||||
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;
|
||||||
|
|
@ -20,16 +19,17 @@ interface AddFeeForm {
|
||||||
orderNumber?: number;
|
orderNumber?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const addFee = (
|
||||||
export const addFee =
|
feeForm: AddFeeForm,
|
||||||
(feeForm: AddFeeForm, requestSession: recordTypes.PartialSession): number => {
|
requestSession: recordTypes.PartialSession
|
||||||
|
): number => {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare("insert into Fees (" +
|
.prepare(
|
||||||
|
"insert into Fees (" +
|
||||||
"feeCategoryId, feeName, feeDescription," +
|
"feeCategoryId, feeName, feeDescription," +
|
||||||
" occupancyTypeId, lotTypeId," +
|
" occupancyTypeId, lotTypeId," +
|
||||||
" feeAmount, feeFunction," +
|
" feeAmount, feeFunction," +
|
||||||
|
|
@ -38,29 +38,31 @@ export const addFee =
|
||||||
" isRequired, orderNumber," +
|
" isRequired, orderNumber," +
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||||
.run(feeForm.feeCategoryId,
|
)
|
||||||
|
.run(
|
||||||
|
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 ? 1 : 0,
|
||||||
feeForm.quantityUnit,
|
feeForm.quantityUnit,
|
||||||
(feeForm.isRequired ? 1 : 0),
|
feeForm.isRequired ? 1 : 0,
|
||||||
(feeForm.orderNumber || 0),
|
feeForm.orderNumber || 0,
|
||||||
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;
|
||||||
|
|
@ -9,7 +9,7 @@ export const addFeeCategory = (feeCategoryForm, requestSession) => {
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?)")
|
||||||
.run(feeCategoryForm.feeCategory, (feeCategoryForm.orderNumber || 0), requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
.run(feeCategoryForm.feeCategory, feeCategoryForm.orderNumber || 0, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||||
database.close();
|
database.close();
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,37 +3,39 @@ import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
|
|
||||||
|
|
||||||
interface AddFeeCategoryForm {
|
interface AddFeeCategoryForm {
|
||||||
feeCategory: string;
|
feeCategory: string;
|
||||||
orderNumber?: number;
|
orderNumber?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const addFeeCategory = (
|
||||||
export const addFeeCategory =
|
feeCategoryForm: AddFeeCategoryForm,
|
||||||
(feeCategoryForm: AddFeeCategoryForm, requestSession: recordTypes.PartialSession): number => {
|
requestSession: recordTypes.PartialSession
|
||||||
|
): number => {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare("insert into FeeCategories (" +
|
.prepare(
|
||||||
|
"insert into FeeCategories (" +
|
||||||
"feeCategory, orderNumber," +
|
"feeCategory, orderNumber," +
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?)"
|
||||||
.run(feeCategoryForm.feeCategory,
|
)
|
||||||
(feeCategoryForm.orderNumber || 0),
|
.run(
|
||||||
|
feeCategoryForm.feeCategory,
|
||||||
|
feeCategoryForm.orderNumber || 0,
|
||||||
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 addFeeCategory;
|
export default addFeeCategory;
|
||||||
|
|
@ -11,7 +11,7 @@ export const 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);
|
||||||
database.close();
|
database.close();
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
import {
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
lotOccupancyDB as databasePath
|
|
||||||
} from "../../data/databasePaths.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;
|
||||||
|
|
@ -19,38 +16,41 @@ interface AddLotForm {
|
||||||
lotLongitude: string;
|
lotLongitude: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const addLot = (
|
||||||
export const addLot =
|
lotForm: AddLotForm,
|
||||||
(lotForm: AddLotForm, requestSession: recordTypes.PartialSession): number => {
|
requestSession: recordTypes.PartialSession
|
||||||
|
): number => {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare("insert into Lots (" +
|
.prepare(
|
||||||
|
"insert into Lots (" +
|
||||||
"lotName, lotTypeId, lotStatusId," +
|
"lotName, lotTypeId, lotStatusId," +
|
||||||
" mapId, mapKey," +
|
" mapId, mapKey," +
|
||||||
" lotLatitude, lotLongitude," +
|
" lotLatitude, lotLongitude," +
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||||
.run(lotForm.lotName,
|
)
|
||||||
|
.run(
|
||||||
|
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
|
||||||
|
);
|
||||||
|
|
||||||
database.close();
|
database.close();
|
||||||
|
|
||||||
return result.lastInsertRowid as number;
|
return result.lastInsertRowid as number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default addLot;
|
export default addLot;
|
||||||
|
|
@ -1,46 +1,46 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
import {
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
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 const addLotComment = (
|
||||||
export const addLotComment =
|
lotCommentForm: AddLotCommentForm,
|
||||||
(lotCommentForm: AddLotCommentForm, requestSession: recordTypes.PartialSession): number => {
|
requestSession: recordTypes.PartialSession
|
||||||
|
): number => {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
const rightNow = new Date();
|
const rightNow = new Date();
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare("insert into LotComments (" +
|
.prepare(
|
||||||
|
"insert into LotComments (" +
|
||||||
"lotId, lotCommentDate, lotCommentTime, lotComment," +
|
"lotId, lotCommentDate, lotCommentTime, lotComment," +
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?, ?, ?)"
|
||||||
.run(lotCommentForm.lotId,
|
)
|
||||||
|
.run(
|
||||||
|
lotCommentForm.lotId,
|
||||||
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;
|
||||||
|
|
@ -16,11 +16,9 @@ export const addLotOccupancy = (lotOccupancyForm, requestSession) => {
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?, ?, ?)")
|
||||||
.run(lotOccupancyForm.occupancyTypeId, (lotOccupancyForm.lotId === "" ?
|
.run(lotOccupancyForm.occupancyTypeId, lotOccupancyForm.lotId === "" ? undefined : lotOccupancyForm.lotId, occupancyStartDate, lotOccupancyForm.occupancyEndDateString === ""
|
||||||
undefined :
|
? undefined
|
||||||
lotOccupancyForm.lotId), occupancyStartDate, (lotOccupancyForm.occupancyEndDateString === "" ?
|
: dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyEndDateString), requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||||
undefined :
|
|
||||||
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) {
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,13 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
import {
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
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 {
|
import { addOrUpdateLotOccupancyField } from "./addOrUpdateLotOccupancyField.js";
|
||||||
addOrUpdateLotOccupancyField
|
|
||||||
} from "./addOrUpdateLotOccupancyField.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;
|
||||||
|
|
@ -24,62 +19,73 @@ interface AddLotOccupancyForm {
|
||||||
[lotOccupancyFieldValue_occupancyTypeFieldId: string]: unknown;
|
[lotOccupancyFieldValue_occupancyTypeFieldId: string]: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const addLotOccupancy = (
|
||||||
export const addLotOccupancy =
|
lotOccupancyForm: AddLotOccupancyForm,
|
||||||
(lotOccupancyForm: AddLotOccupancyForm, requestSession: recordTypes.PartialSession): number => {
|
requestSession: recordTypes.PartialSession
|
||||||
|
): number => {
|
||||||
const database = sqlite(databasePath);
|
const database = 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) {
|
||||||
console.error(lotOccupancyForm);
|
console.error(lotOccupancyForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare("insert into LotOccupancies (" +
|
.prepare(
|
||||||
|
"insert into LotOccupancies (" +
|
||||||
"occupancyTypeId, lotId," +
|
"occupancyTypeId, lotId," +
|
||||||
" occupancyStartDate, occupancyEndDate," +
|
" occupancyStartDate, occupancyEndDate," +
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?, ?, ?)"
|
||||||
.run(lotOccupancyForm.occupancyTypeId,
|
)
|
||||||
(lotOccupancyForm.lotId === "" ?
|
.run(
|
||||||
undefined :
|
lotOccupancyForm.occupancyTypeId,
|
||||||
lotOccupancyForm.lotId),
|
lotOccupancyForm.lotId === "" ? undefined : lotOccupancyForm.lotId,
|
||||||
occupancyStartDate,
|
occupancyStartDate,
|
||||||
(lotOccupancyForm.occupancyEndDateString === "" ?
|
lotOccupancyForm.occupancyEndDateString === ""
|
||||||
undefined :
|
? undefined
|
||||||
dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyEndDateString)),
|
: dateTimeFunctions.dateStringToInteger(
|
||||||
|
lotOccupancyForm.occupancyEndDateString
|
||||||
|
),
|
||||||
requestSession.user.userName,
|
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] as string;
|
"lotOccupancyFieldValue_" + occupancyTypeFieldId
|
||||||
|
] as string;
|
||||||
|
|
||||||
if (lotOccupancyFieldValue && lotOccupancyFieldValue !== "") {
|
if (lotOccupancyFieldValue && lotOccupancyFieldValue !== "") {
|
||||||
addOrUpdateLotOccupancyField({
|
addOrUpdateLotOccupancyField(
|
||||||
|
{
|
||||||
lotOccupancyId,
|
lotOccupancyId,
|
||||||
occupancyTypeFieldId,
|
occupancyTypeFieldId,
|
||||||
lotOccupancyFieldValue
|
lotOccupancyFieldValue
|
||||||
}, requestSession, database);
|
},
|
||||||
|
requestSession,
|
||||||
|
database
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
database.close();
|
database.close();
|
||||||
|
|
||||||
return lotOccupancyId;
|
return lotOccupancyId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default addLotOccupancy;
|
export default addLotOccupancy;
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
import {
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
lotOccupancyDB as databasePath
|
|
||||||
} from "../../data/databasePaths.js";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
dateStringToInteger,
|
dateStringToInteger,
|
||||||
|
|
@ -13,26 +11,29 @@ import {
|
||||||
|
|
||||||
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 const addLotOccupancyComment = (
|
||||||
export const addLotOccupancyComment =
|
commentForm: AddLotOccupancyCommentForm,
|
||||||
(commentForm: AddLotOccupancyCommentForm, requestSession: recordTypes.PartialSession): number => {
|
requestSession: recordTypes.PartialSession
|
||||||
|
): 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);
|
||||||
|
|
@ -41,24 +42,27 @@ export const addLotOccupancyComment =
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare("insert into LotOccupancyComments (" +
|
.prepare(
|
||||||
|
"insert into LotOccupancyComments (" +
|
||||||
"lotOccupancyId, lotOccupancyCommentDate, lotOccupancyCommentTime, lotOccupancyComment," +
|
"lotOccupancyId, lotOccupancyCommentDate, lotOccupancyCommentTime, lotOccupancyComment," +
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?, ?, ?)"
|
||||||
.run(commentForm.lotOccupancyId,
|
)
|
||||||
|
.run(
|
||||||
|
commentForm.lotOccupancyId,
|
||||||
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;
|
||||||
|
|
@ -9,8 +9,14 @@ export const addLotOccupancyFee = (lotOccupancyFeeForm, requestSession) => {
|
||||||
let feeAmount;
|
let feeAmount;
|
||||||
let taxAmount;
|
let taxAmount;
|
||||||
if (lotOccupancyFeeForm.feeAmount) {
|
if (lotOccupancyFeeForm.feeAmount) {
|
||||||
feeAmount = typeof (lotOccupancyFeeForm.feeAmount) === "string" ? Number.parseFloat(lotOccupancyFeeForm.feeAmount) : feeAmount;
|
feeAmount =
|
||||||
taxAmount = typeof (lotOccupancyFeeForm.taxAmount) === "string" ? Number.parseFloat(lotOccupancyFeeForm.taxAmount) : taxAmount;
|
typeof lotOccupancyFeeForm.feeAmount === "string"
|
||||||
|
? Number.parseFloat(lotOccupancyFeeForm.feeAmount)
|
||||||
|
: feeAmount;
|
||||||
|
taxAmount =
|
||||||
|
typeof lotOccupancyFeeForm.taxAmount === "string"
|
||||||
|
? Number.parseFloat(lotOccupancyFeeForm.taxAmount)
|
||||||
|
: taxAmount;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const lotOccupancy = getLotOccupancy(lotOccupancyFeeForm.lotOccupancyId);
|
const lotOccupancy = getLotOccupancy(lotOccupancyFeeForm.lotOccupancyId);
|
||||||
|
|
@ -18,21 +24,25 @@ export const addLotOccupancyFee = (lotOccupancyFeeForm, requestSession) => {
|
||||||
feeAmount = calculateFeeAmount(fee, lotOccupancy);
|
feeAmount = calculateFeeAmount(fee, lotOccupancy);
|
||||||
taxAmount = calculateTaxAmount(fee, feeAmount);
|
taxAmount = calculateTaxAmount(fee, feeAmount);
|
||||||
}
|
}
|
||||||
const record = database.prepare("select feeAmount, taxAmount, recordDelete_timeMillis" +
|
const record = database
|
||||||
|
.prepare("select feeAmount, taxAmount, recordDelete_timeMillis" +
|
||||||
" from LotOccupancyFees" +
|
" from LotOccupancyFees" +
|
||||||
" 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) {
|
||||||
database.prepare("delete from LotOccupancyFees" +
|
database
|
||||||
|
.prepare("delete from LotOccupancyFees" +
|
||||||
" where recordDelete_timeMillis is not null" +
|
" where recordDelete_timeMillis is not null" +
|
||||||
" 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 &&
|
||||||
database.prepare("update LotOccupancyFees" +
|
record.taxAmount === taxAmount) {
|
||||||
|
database
|
||||||
|
.prepare("update LotOccupancyFees" +
|
||||||
" set quantity = quantity + ?," +
|
" set quantity = quantity + ?," +
|
||||||
" recordUpdate_userName = ?," +
|
" recordUpdate_userName = ?," +
|
||||||
" recordUpdate_timeMillis = ?" +
|
" recordUpdate_timeMillis = ?" +
|
||||||
|
|
@ -43,10 +53,11 @@ export const 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.prepare("update LotOccupancyFees" +
|
database
|
||||||
|
.prepare("update LotOccupancyFees" +
|
||||||
" set feeAmount = (feeAmount * quantity) + ?," +
|
" set feeAmount = (feeAmount * quantity) + ?," +
|
||||||
" taxAmount = (taxAmount * quantity) + ?," +
|
" taxAmount = (taxAmount * quantity) + ?," +
|
||||||
" quantity = 1," +
|
" quantity = 1," +
|
||||||
|
|
@ -54,7 +65,7 @@ export const addLotOccupancyFee = (lotOccupancyFeeForm, requestSession) => {
|
||||||
" recordUpdate_timeMillis = ?" +
|
" recordUpdate_timeMillis = ?" +
|
||||||
" where lotOccupancyId = ?" +
|
" where lotOccupancyId = ?" +
|
||||||
" and feeId = ?")
|
" and feeId = ?")
|
||||||
.run((feeAmount * quantity), (taxAmount * quantity), requestSession.user.userName, rightNowMillis, lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId);
|
.run(feeAmount * quantity, taxAmount * quantity, requestSession.user.userName, rightNowMillis, lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId);
|
||||||
database.close();
|
database.close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,27 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
import {
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
lotOccupancyDB as databasePath
|
|
||||||
} from "../../data/databasePaths.js";
|
|
||||||
|
|
||||||
import {
|
import { calculateFeeAmount, calculateTaxAmount } from "../functions.fee.js";
|
||||||
calculateFeeAmount,
|
|
||||||
calculateTaxAmount
|
|
||||||
} from "../functions.fee.js";
|
|
||||||
|
|
||||||
import {
|
import { getFee } from "./getFee.js";
|
||||||
getFee
|
|
||||||
} from "./getFee.js";
|
|
||||||
|
|
||||||
import {
|
import { getLotOccupancy } from "./getLotOccupancy.js";
|
||||||
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 const addLotOccupancyFee = (
|
||||||
export const addLotOccupancyFee =
|
lotOccupancyFeeForm: AddLotOccupancyFeeForm,
|
||||||
(lotOccupancyFeeForm: AddLotOccupancyFeeForm, requestSession: recordTypes.PartialSession): boolean => {
|
requestSession: recordTypes.PartialSession
|
||||||
|
): boolean => {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
|
@ -42,11 +32,18 @@ export const addLotOccupancyFee =
|
||||||
let taxAmount: number;
|
let taxAmount: number;
|
||||||
|
|
||||||
if (lotOccupancyFeeForm.feeAmount) {
|
if (lotOccupancyFeeForm.feeAmount) {
|
||||||
feeAmount = typeof (lotOccupancyFeeForm.feeAmount) === "string" ? Number.parseFloat(lotOccupancyFeeForm.feeAmount) : feeAmount;
|
feeAmount =
|
||||||
taxAmount = typeof (lotOccupancyFeeForm.taxAmount) === "string" ? Number.parseFloat(lotOccupancyFeeForm.taxAmount) : taxAmount;
|
typeof lotOccupancyFeeForm.feeAmount === "string"
|
||||||
|
? Number.parseFloat(lotOccupancyFeeForm.feeAmount)
|
||||||
|
: feeAmount;
|
||||||
|
taxAmount =
|
||||||
|
typeof lotOccupancyFeeForm.taxAmount === "string"
|
||||||
|
? Number.parseFloat(lotOccupancyFeeForm.taxAmount)
|
||||||
|
: taxAmount;
|
||||||
} else {
|
} else {
|
||||||
|
const lotOccupancy = getLotOccupancy(
|
||||||
const lotOccupancy = getLotOccupancy(lotOccupancyFeeForm.lotOccupancyId);
|
lotOccupancyFeeForm.lotOccupancyId
|
||||||
|
);
|
||||||
const fee = getFee(lotOccupancyFeeForm.feeId);
|
const fee = getFee(lotOccupancyFeeForm.feeId);
|
||||||
|
|
||||||
feeAmount = calculateFeeAmount(fee, lotOccupancy);
|
feeAmount = calculateFeeAmount(fee, lotOccupancy);
|
||||||
|
|
@ -56,82 +53,100 @@ export const addLotOccupancyFee =
|
||||||
// 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.prepare("select feeAmount, taxAmount, recordDelete_timeMillis" +
|
} = database
|
||||||
|
.prepare(
|
||||||
|
"select feeAmount, taxAmount, recordDelete_timeMillis" +
|
||||||
" from LotOccupancyFees" +
|
" from LotOccupancyFees" +
|
||||||
" 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) {
|
||||||
|
database
|
||||||
database.prepare("delete from LotOccupancyFees" +
|
.prepare(
|
||||||
|
"delete from LotOccupancyFees" +
|
||||||
" where recordDelete_timeMillis is not null" +
|
" where recordDelete_timeMillis is not null" +
|
||||||
" and lotOccupancyId = ?" +
|
" and lotOccupancyId = ?" +
|
||||||
" and feeId = ?")
|
" and feeId = ?"
|
||||||
.run(lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId);
|
)
|
||||||
|
.run(
|
||||||
} else if (record.feeAmount === feeAmount && record.taxAmount === taxAmount) {
|
lotOccupancyFeeForm.lotOccupancyId,
|
||||||
|
lotOccupancyFeeForm.feeId
|
||||||
database.prepare("update LotOccupancyFees" +
|
);
|
||||||
|
} else if (
|
||||||
|
record.feeAmount === feeAmount &&
|
||||||
|
record.taxAmount === taxAmount
|
||||||
|
) {
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
"update LotOccupancyFees" +
|
||||||
" set quantity = quantity + ?," +
|
" set quantity = quantity + ?," +
|
||||||
" recordUpdate_userName = ?," +
|
" recordUpdate_userName = ?," +
|
||||||
" recordUpdate_timeMillis = ?" +
|
" recordUpdate_timeMillis = ?" +
|
||||||
" where lotOccupancyId = ?" +
|
" where lotOccupancyId = ?" +
|
||||||
" and feeId = ?")
|
" and feeId = ?"
|
||||||
|
)
|
||||||
.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 =
|
||||||
|
typeof lotOccupancyFeeForm.quantity === "string"
|
||||||
|
? Number.parseFloat(lotOccupancyFeeForm.quantity)
|
||||||
|
: lotOccupancyFeeForm.quantity;
|
||||||
|
|
||||||
const quantity = typeof (lotOccupancyFeeForm.quantity) === "string" ?
|
database
|
||||||
Number.parseFloat(lotOccupancyFeeForm.quantity) :
|
.prepare(
|
||||||
lotOccupancyFeeForm.quantity;
|
"update LotOccupancyFees" +
|
||||||
|
|
||||||
database.prepare("update LotOccupancyFees" +
|
|
||||||
" set feeAmount = (feeAmount * quantity) + ?," +
|
" set feeAmount = (feeAmount * quantity) + ?," +
|
||||||
" taxAmount = (taxAmount * quantity) + ?," +
|
" taxAmount = (taxAmount * quantity) + ?," +
|
||||||
" quantity = 1," +
|
" quantity = 1," +
|
||||||
" recordUpdate_userName = ?," +
|
" recordUpdate_userName = ?," +
|
||||||
" recordUpdate_timeMillis = ?" +
|
" recordUpdate_timeMillis = ?" +
|
||||||
" where lotOccupancyId = ?" +
|
" where lotOccupancyId = ?" +
|
||||||
" and feeId = ?")
|
" and feeId = ?"
|
||||||
|
)
|
||||||
.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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new record
|
// Create new record
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare("insert into LotOccupancyFees (" +
|
.prepare(
|
||||||
|
"insert into LotOccupancyFees (" +
|
||||||
"lotOccupancyId, feeId," +
|
"lotOccupancyId, feeId," +
|
||||||
" quantity, feeAmount, taxAmount," +
|
" quantity, feeAmount, taxAmount," +
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||||
.run(lotOccupancyFeeForm.lotOccupancyId,
|
)
|
||||||
|
.run(
|
||||||
|
lotOccupancyFeeForm.lotOccupancyId,
|
||||||
lotOccupancyFeeForm.feeId,
|
lotOccupancyFeeForm.feeId,
|
||||||
lotOccupancyFeeForm.quantity,
|
lotOccupancyFeeForm.quantity,
|
||||||
feeAmount,
|
feeAmount,
|
||||||
|
|
@ -139,12 +154,12 @@ export const addLotOccupancyFee =
|
||||||
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;
|
||||||
|
|
@ -3,7 +3,8 @@ import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
export const addLotOccupancyOccupant = (lotOccupancyOccupantForm, requestSession) => {
|
export const addLotOccupancyOccupant = (lotOccupancyOccupantForm, requestSession) => {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
let lotOccupantIndex = 0;
|
let lotOccupantIndex = 0;
|
||||||
const maxIndexResult = database.prepare("select lotOccupantIndex" +
|
const maxIndexResult = database
|
||||||
|
.prepare("select lotOccupantIndex" +
|
||||||
" from LotOccupancyOccupants" +
|
" from LotOccupancyOccupants" +
|
||||||
" where lotOccupancyId = ?" +
|
" where lotOccupancyId = ?" +
|
||||||
" order by lotOccupantIndex desc" +
|
" order by lotOccupantIndex desc" +
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
import {
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
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;
|
||||||
|
|
@ -19,19 +16,22 @@ interface AddLotOccupancyOccupantForm {
|
||||||
occupantPhoneNumber: string;
|
occupantPhoneNumber: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const addLotOccupancyOccupant = (
|
||||||
export const addLotOccupancyOccupant =
|
lotOccupancyOccupantForm: AddLotOccupancyOccupantForm,
|
||||||
(lotOccupancyOccupantForm: AddLotOccupancyOccupantForm, requestSession: recordTypes.PartialSession): number => {
|
requestSession: recordTypes.PartialSession
|
||||||
|
): number => {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
let lotOccupantIndex = 0;
|
let lotOccupantIndex = 0;
|
||||||
|
|
||||||
const maxIndexResult = database.prepare("select lotOccupantIndex" +
|
const maxIndexResult = database
|
||||||
|
.prepare(
|
||||||
|
"select lotOccupantIndex" +
|
||||||
" from LotOccupancyOccupants" +
|
" from LotOccupancyOccupants" +
|
||||||
" where lotOccupancyId = ?" +
|
" where lotOccupancyId = ?" +
|
||||||
" order by lotOccupantIndex desc" +
|
" order by lotOccupantIndex desc" +
|
||||||
" limit 1")
|
" limit 1"
|
||||||
|
)
|
||||||
.get(lotOccupancyOccupantForm.lotOccupancyId);
|
.get(lotOccupancyOccupantForm.lotOccupancyId);
|
||||||
|
|
||||||
if (maxIndexResult) {
|
if (maxIndexResult) {
|
||||||
|
|
@ -41,7 +41,8 @@ export const addLotOccupancyOccupant =
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
|
||||||
database
|
database
|
||||||
.prepare("insert into LotOccupancyOccupants (" +
|
.prepare(
|
||||||
|
"insert into LotOccupancyOccupants (" +
|
||||||
"lotOccupancyId, lotOccupantIndex," +
|
"lotOccupancyId, lotOccupantIndex," +
|
||||||
" occupantName," +
|
" occupantName," +
|
||||||
" occupantAddress1, occupantAddress2," +
|
" occupantAddress1, occupantAddress2," +
|
||||||
|
|
@ -50,8 +51,10 @@ export const addLotOccupancyOccupant =
|
||||||
" lotOccupantTypeId," +
|
" lotOccupantTypeId," +
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||||
.run(lotOccupancyOccupantForm.lotOccupancyId,
|
)
|
||||||
|
.run(
|
||||||
|
lotOccupancyOccupantForm.lotOccupancyId,
|
||||||
lotOccupantIndex,
|
lotOccupantIndex,
|
||||||
lotOccupancyOccupantForm.occupantName,
|
lotOccupancyOccupantForm.occupantName,
|
||||||
lotOccupancyOccupantForm.occupantAddress1,
|
lotOccupancyOccupantForm.occupantAddress1,
|
||||||
|
|
@ -64,12 +67,12 @@ export const addLotOccupancyOccupant =
|
||||||
requestSession.user.userName,
|
requestSession.user.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
requestSession.user.userName,
|
requestSession.user.userName,
|
||||||
rightNowMillis);
|
rightNowMillis
|
||||||
|
);
|
||||||
|
|
||||||
database.close();
|
database.close();
|
||||||
|
|
||||||
return lotOccupantIndex;
|
return lotOccupantIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default addLotOccupancyOccupant;
|
export default addLotOccupancyOccupant;
|
||||||
|
|
@ -4,7 +4,8 @@ import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInte
|
||||||
export const addLotOccupancyTransaction = (lotOccupancyTransactionForm, requestSession) => {
|
export const addLotOccupancyTransaction = (lotOccupancyTransactionForm, requestSession) => {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
let transactionIndex = 0;
|
let transactionIndex = 0;
|
||||||
const maxIndexResult = database.prepare("select transactionIndex" +
|
const maxIndexResult = database
|
||||||
|
.prepare("select transactionIndex" +
|
||||||
" from LotOccupancyTransactions" +
|
" from LotOccupancyTransactions" +
|
||||||
" where lotOccupancyId = ?" +
|
" where lotOccupancyId = ?" +
|
||||||
" order by transactionIndex desc" +
|
" order by transactionIndex desc" +
|
||||||
|
|
@ -14,12 +15,12 @@ export const addLotOccupancyTransaction = (lotOccupancyTransactionForm, requestS
|
||||||
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("insert into LotOccupancyTransactions (" +
|
.prepare("insert into LotOccupancyTransactions (" +
|
||||||
"lotOccupancyId, transactionIndex," +
|
"lotOccupancyId, transactionIndex," +
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
import {
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
lotOccupancyDB as databasePath
|
|
||||||
} from "../../data/databasePaths.js";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
dateStringToInteger,
|
dateStringToInteger,
|
||||||
|
|
@ -13,29 +11,31 @@ import {
|
||||||
|
|
||||||
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 const addLotOccupancyTransaction = (
|
||||||
export const addLotOccupancyTransaction =
|
lotOccupancyTransactionForm: AddLotOccupancyTransactionForm,
|
||||||
(lotOccupancyTransactionForm: AddLotOccupancyTransactionForm, requestSession: recordTypes.PartialSession): number => {
|
requestSession: recordTypes.PartialSession
|
||||||
|
): number => {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
let transactionIndex = 0;
|
let transactionIndex = 0;
|
||||||
|
|
||||||
const maxIndexResult = database.prepare("select transactionIndex" +
|
const maxIndexResult = database
|
||||||
|
.prepare(
|
||||||
|
"select transactionIndex" +
|
||||||
" from LotOccupancyTransactions" +
|
" from LotOccupancyTransactions" +
|
||||||
" where lotOccupancyId = ?" +
|
" where lotOccupancyId = ?" +
|
||||||
" order by transactionIndex desc" +
|
" order by transactionIndex desc" +
|
||||||
" limit 1")
|
" limit 1"
|
||||||
|
)
|
||||||
.get(lotOccupancyTransactionForm.lotOccupancyId);
|
.get(lotOccupancyTransactionForm.lotOccupancyId);
|
||||||
|
|
||||||
if (maxIndexResult) {
|
if (maxIndexResult) {
|
||||||
|
|
@ -44,24 +44,27 @@ export const addLotOccupancyTransaction =
|
||||||
|
|
||||||
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("insert into LotOccupancyTransactions (" +
|
.prepare(
|
||||||
|
"insert into LotOccupancyTransactions (" +
|
||||||
"lotOccupancyId, transactionIndex," +
|
"lotOccupancyId, transactionIndex," +
|
||||||
" transactionDate, transactionTime," +
|
" transactionDate, transactionTime," +
|
||||||
" transactionAmount, externalReceiptNumber," +
|
" transactionAmount, externalReceiptNumber," +
|
||||||
" transactionNote," +
|
" transactionNote," +
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||||
.run(lotOccupancyTransactionForm.lotOccupancyId,
|
)
|
||||||
|
.run(
|
||||||
|
lotOccupancyTransactionForm.lotOccupancyId,
|
||||||
transactionIndex,
|
transactionIndex,
|
||||||
transactionDate,
|
transactionDate,
|
||||||
transactionTime,
|
transactionTime,
|
||||||
|
|
@ -71,12 +74,12 @@ export const addLotOccupancyTransaction =
|
||||||
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;
|
||||||
|
|
@ -10,7 +10,7 @@ export const 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.orderNumber || -1), requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
.run(lotOccupantTypeForm.lotOccupantType, lotOccupantTypeForm.orderNumber || -1, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||||
database.close();
|
database.close();
|
||||||
clearLotOccupantTypesCache();
|
clearLotOccupantTypesCache();
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,45 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
import {
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
lotOccupancyDB as databasePath
|
|
||||||
} from "../../data/databasePaths.js";
|
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
import { clearLotOccupantTypesCache } from "../functions.cache.js";
|
import { clearLotOccupantTypesCache } from "../functions.cache.js";
|
||||||
|
|
||||||
|
|
||||||
interface AddLotOccupantTypeForm {
|
interface AddLotOccupantTypeForm {
|
||||||
lotOccupantType: string;
|
lotOccupantType: string;
|
||||||
orderNumber?: number;
|
orderNumber?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const addLotOccupantType = (
|
||||||
export const addLotOccupantType =
|
lotOccupantTypeForm: AddLotOccupantTypeForm,
|
||||||
(lotOccupantTypeForm: AddLotOccupantTypeForm, requestSession: recordTypes.PartialSession): number => {
|
requestSession: recordTypes.PartialSession
|
||||||
|
): number => {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare("insert into LotOccupantTypes (" +
|
.prepare(
|
||||||
|
"insert into LotOccupantTypes (" +
|
||||||
"lotOccupantType, orderNumber," +
|
"lotOccupantType, orderNumber," +
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?)"
|
||||||
.run(lotOccupantTypeForm.lotOccupantType,
|
)
|
||||||
(lotOccupantTypeForm.orderNumber || -1),
|
.run(
|
||||||
|
lotOccupantTypeForm.lotOccupantType,
|
||||||
|
lotOccupantTypeForm.orderNumber || -1,
|
||||||
requestSession.user.userName,
|
requestSession.user.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
requestSession.user.userName,
|
requestSession.user.userName,
|
||||||
rightNowMillis);
|
rightNowMillis
|
||||||
|
);
|
||||||
|
|
||||||
database.close();
|
database.close();
|
||||||
|
|
||||||
clearLotOccupantTypesCache();
|
clearLotOccupantTypesCache();
|
||||||
|
|
||||||
return result.lastInsertRowid as number;
|
return result.lastInsertRowid as number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default addLotOccupantType;
|
export default addLotOccupantType;
|
||||||
|
|
@ -10,7 +10,7 @@ export const addLotStatus = (lotStatusForm, requestSession) => {
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?)")
|
||||||
.run(lotStatusForm.lotStatus, (lotStatusForm.orderNumber || -1), requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
.run(lotStatusForm.lotStatus, lotStatusForm.orderNumber || -1, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||||
database.close();
|
database.close();
|
||||||
clearLotStatusesCache();
|
clearLotStatusesCache();
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,45 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
import {
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
lotOccupancyDB as databasePath
|
|
||||||
} from "../../data/databasePaths.js";
|
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
import { clearLotStatusesCache } from "../functions.cache.js";
|
import { clearLotStatusesCache } from "../functions.cache.js";
|
||||||
|
|
||||||
|
|
||||||
interface AddLotStatusForm {
|
interface AddLotStatusForm {
|
||||||
lotStatus: string;
|
lotStatus: string;
|
||||||
orderNumber?: number;
|
orderNumber?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const addLotStatus = (
|
||||||
export const addLotStatus =
|
lotStatusForm: AddLotStatusForm,
|
||||||
(lotStatusForm: AddLotStatusForm, requestSession: recordTypes.PartialSession): number => {
|
requestSession: recordTypes.PartialSession
|
||||||
|
): number => {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare("insert into LotStatuses (" +
|
.prepare(
|
||||||
|
"insert into LotStatuses (" +
|
||||||
"lotStatus, orderNumber," +
|
"lotStatus, orderNumber," +
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?)"
|
||||||
.run(lotStatusForm.lotStatus,
|
)
|
||||||
(lotStatusForm.orderNumber || -1),
|
.run(
|
||||||
|
lotStatusForm.lotStatus,
|
||||||
|
lotStatusForm.orderNumber || -1,
|
||||||
requestSession.user.userName,
|
requestSession.user.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
requestSession.user.userName,
|
requestSession.user.userName,
|
||||||
rightNowMillis);
|
rightNowMillis
|
||||||
|
);
|
||||||
|
|
||||||
database.close();
|
database.close();
|
||||||
|
|
||||||
clearLotStatusesCache();
|
clearLotStatusesCache();
|
||||||
|
|
||||||
return result.lastInsertRowid as number;
|
return result.lastInsertRowid as number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default addLotStatus;
|
export default addLotStatus;
|
||||||
|
|
@ -10,7 +10,7 @@ export const addLotType = (lotTypeForm, requestSession) => {
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?)")
|
||||||
.run(lotTypeForm.lotType, (lotTypeForm.orderNumber || 0), requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
.run(lotTypeForm.lotType, lotTypeForm.orderNumber || 0, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||||
database.close();
|
database.close();
|
||||||
clearLotTypesCache();
|
clearLotTypesCache();
|
||||||
return result.lastInsertRowid;
|
return result.lastInsertRowid;
|
||||||
|
|
|
||||||
|
|
@ -1,48 +1,46 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
import {
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
lotOccupancyDB as databasePath
|
|
||||||
} from "../../data/databasePaths.js";
|
|
||||||
|
|
||||||
import {
|
import { clearLotTypesCache } from "../functions.cache.js";
|
||||||
clearLotTypesCache
|
|
||||||
} from "../functions.cache.js";
|
|
||||||
|
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
|
|
||||||
|
|
||||||
interface AddLotTypeForm {
|
interface AddLotTypeForm {
|
||||||
lotType: string;
|
lotType: string;
|
||||||
orderNumber ? : number;
|
orderNumber?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const addLotType = (
|
||||||
export const addLotType =
|
lotTypeForm: AddLotTypeForm,
|
||||||
(lotTypeForm: AddLotTypeForm, requestSession: recordTypes.PartialSession): number => {
|
requestSession: recordTypes.PartialSession
|
||||||
|
): number => {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare("insert into LotTypes (" +
|
.prepare(
|
||||||
|
"insert into LotTypes (" +
|
||||||
"lotType, orderNumber," +
|
"lotType, orderNumber," +
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?)"
|
||||||
.run(lotTypeForm.lotType,
|
)
|
||||||
(lotTypeForm.orderNumber || 0),
|
.run(
|
||||||
|
lotTypeForm.lotType,
|
||||||
|
lotTypeForm.orderNumber || 0,
|
||||||
requestSession.user.userName,
|
requestSession.user.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
requestSession.user.userName,
|
requestSession.user.userName,
|
||||||
rightNowMillis);
|
rightNowMillis
|
||||||
|
);
|
||||||
|
|
||||||
database.close();
|
database.close();
|
||||||
|
|
||||||
clearLotTypesCache();
|
clearLotTypesCache();
|
||||||
|
|
||||||
return result.lastInsertRowid as number;
|
return result.lastInsertRowid as number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default addLotType;
|
export default addLotType;
|
||||||
|
|
@ -11,7 +11,7 @@ export const 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,12 +1,9 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
import {
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
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;
|
||||||
|
|
@ -21,27 +18,30 @@ interface AddMapForm {
|
||||||
mapPhoneNumber: string;
|
mapPhoneNumber: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const addMap = (
|
||||||
export const addMap =
|
mapForm: AddMapForm,
|
||||||
(mapForm: AddMapForm, requestSession: recordTypes.PartialSession): number => {
|
requestSession: recordTypes.PartialSession
|
||||||
|
): number => {
|
||||||
const database = sqlite(databasePath);
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare("insert into Maps (" +
|
.prepare(
|
||||||
|
"insert into Maps (" +
|
||||||
"mapName, mapDescription," +
|
"mapName, mapDescription," +
|
||||||
" mapSVG, mapLatitude, mapLongitude," +
|
" mapSVG, mapLatitude, mapLongitude," +
|
||||||
" mapAddress1, mapAddress2, mapCity, mapProvince, mapPostalCode, mapPhoneNumber," +
|
" mapAddress1, mapAddress2, mapCity, mapProvince, mapPostalCode, mapPhoneNumber," +
|
||||||
" recordCreate_userName, recordCreate_timeMillis," +
|
" recordCreate_userName, recordCreate_timeMillis," +
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||||
.run(mapForm.mapName,
|
)
|
||||||
|
.run(
|
||||||
|
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,
|
||||||
|
|
@ -51,12 +51,12 @@ export const addMap =
|
||||||
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;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue