linting
parent
5276c7e962
commit
285704daab
4
app.ts
4
app.ts
|
|
@ -1,5 +1,5 @@
|
|||
import createError from 'http-errors'
|
||||
import express from 'express'
|
||||
import express, { RequestHandler } from 'express'
|
||||
|
||||
import compression from 'compression'
|
||||
import path from 'node:path'
|
||||
|
|
@ -233,7 +233,7 @@ app.get(urlPrefix + '/', sessionChecker, (_request, response) => {
|
|||
|
||||
app.use(urlPrefix + '/dashboard', sessionChecker, routerDashboard)
|
||||
|
||||
app.use(urlPrefix + '/api/:apiKey', apiGetHandler, routerApi)
|
||||
app.use(urlPrefix + '/api/:apiKey', apiGetHandler as RequestHandler, routerApi)
|
||||
|
||||
app.use(urlPrefix + '/print', sessionChecker, routerPrint)
|
||||
app.use(urlPrefix + '/maps', sessionChecker, routerMaps)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { getLotTypeSummary } from '../../helpers/lotOccupancyDB/getLotTypeSummar
|
|||
import { getLotStatusSummary } from '../../helpers/lotOccupancyDB/getLotStatusSummary.js';
|
||||
export async function handler(request, response) {
|
||||
const map = await getMap(request.params.mapId);
|
||||
if (!map) {
|
||||
if (map === undefined) {
|
||||
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/maps/?error=mapIdNotFound');
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export async function handler(
|
|||
): Promise<void> {
|
||||
const map = await getMap(request.params.mapId)
|
||||
|
||||
if (!map) {
|
||||
if (map === undefined) {
|
||||
response.redirect(
|
||||
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/maps/?error=mapIdNotFound'
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { getLotStatusSummary } from '../../helpers/lotOccupancyDB/getLotStatusSu
|
|||
import { getLotTypeSummary } from '../../helpers/lotOccupancyDB/getLotTypeSummary.js';
|
||||
export async function handler(request, response) {
|
||||
const map = await getMap(request.params.mapId);
|
||||
if (!map) {
|
||||
if (map === undefined) {
|
||||
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/maps/?error=mapIdNotFound');
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { getLotTypeSummary } from '../../helpers/lotOccupancyDB/getLotTypeSummar
|
|||
export async function handler(request: Request, response: Response): Promise<void> {
|
||||
const map = await getMap(request.params.mapId)
|
||||
|
||||
if (!map) {
|
||||
if (map === undefined) {
|
||||
response.redirect(
|
||||
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/maps/?error=mapIdNotFound'
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ async function saveApiKeys() {
|
|||
}
|
||||
}
|
||||
function generateApiKey(apiKeyPrefix) {
|
||||
return `${apiKeyPrefix}-${uuidv4()}-${Date.now()}`;
|
||||
return `${apiKeyPrefix}-${uuidv4()}-${Date.now().toString()}`;
|
||||
}
|
||||
export async function regenerateApiKey(userName) {
|
||||
apiKeys[userName] = generateApiKey(userName);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ async function saveApiKeys(): Promise<void> {
|
|||
}
|
||||
|
||||
function generateApiKey(apiKeyPrefix: string): string {
|
||||
return `${apiKeyPrefix}-${uuidv4()}-${Date.now()}`
|
||||
return `${apiKeyPrefix}-${uuidv4()}-${Date.now().toString()}`
|
||||
}
|
||||
|
||||
export async function regenerateApiKey(userName: string): Promise<void> {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export async function addLot(lotForm, requestSession) {
|
|||
const lotTypeFieldIds = (lotForm.lotTypeFieldIds ?? '').split(',');
|
||||
for (const lotTypeFieldId of lotTypeFieldIds) {
|
||||
const lotFieldValue = lotForm['lotFieldValue_' + lotTypeFieldId];
|
||||
if (lotFieldValue && lotFieldValue !== '') {
|
||||
if ((lotFieldValue ?? '') !== '') {
|
||||
await addOrUpdateLotField({
|
||||
lotId,
|
||||
lotTypeFieldId,
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ export async function addLot(
|
|||
for (const lotTypeFieldId of lotTypeFieldIds) {
|
||||
const lotFieldValue = lotForm['lotFieldValue_' + lotTypeFieldId] as string
|
||||
|
||||
if (lotFieldValue && lotFieldValue !== '') {
|
||||
if ((lotFieldValue ?? '') !== '') {
|
||||
await addOrUpdateLotField(
|
||||
{
|
||||
lotId,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export async function addLotOccupancy(lotOccupancyForm, requestSession, connecte
|
|||
const occupancyTypeFieldIds = (lotOccupancyForm.occupancyTypeFieldIds ?? '').split(',');
|
||||
for (const occupancyTypeFieldId of occupancyTypeFieldIds) {
|
||||
const lotOccupancyFieldValue = lotOccupancyForm['lotOccupancyFieldValue_' + occupancyTypeFieldId];
|
||||
if (lotOccupancyFieldValue && lotOccupancyFieldValue !== '') {
|
||||
if ((lotOccupancyFieldValue ?? '') !== '') {
|
||||
await addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId,
|
||||
occupancyTypeFieldId,
|
||||
|
|
@ -31,7 +31,7 @@ export async function addLotOccupancy(lotOccupancyForm, requestSession, connecte
|
|||
}, requestSession, database);
|
||||
}
|
||||
}
|
||||
if (lotOccupancyForm.lotOccupantTypeId) {
|
||||
if ((lotOccupancyForm.lotOccupantTypeId ?? '') !== '') {
|
||||
await addLotOccupancyOccupant({
|
||||
lotOccupancyId,
|
||||
lotOccupantTypeId: lotOccupancyForm.lotOccupantTypeId,
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ export async function addLotOccupancy(
|
|||
'lotOccupancyFieldValue_' + occupancyTypeFieldId
|
||||
] as string
|
||||
|
||||
if (lotOccupancyFieldValue && lotOccupancyFieldValue !== '') {
|
||||
if ((lotOccupancyFieldValue ?? '') !== '') {
|
||||
await addOrUpdateLotOccupancyField(
|
||||
{
|
||||
lotOccupancyId,
|
||||
|
|
@ -96,11 +96,11 @@ export async function addLotOccupancy(
|
|||
}
|
||||
}
|
||||
|
||||
if (lotOccupancyForm.lotOccupantTypeId) {
|
||||
if ((lotOccupancyForm.lotOccupantTypeId ?? '') !== '') {
|
||||
await addLotOccupancyOccupant(
|
||||
{
|
||||
lotOccupancyId,
|
||||
lotOccupantTypeId: lotOccupancyForm.lotOccupantTypeId,
|
||||
lotOccupantTypeId: lotOccupancyForm.lotOccupantTypeId!,
|
||||
occupantName: lotOccupancyForm.occupantName!,
|
||||
occupantAddress1: lotOccupancyForm.occupantAddress1!,
|
||||
occupantAddress2: lotOccupancyForm.occupantAddress2!,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export async function addLotOccupancyOccupant(lotOccupancyOccupantForm, requestS
|
|||
order by lotOccupantIndex desc
|
||||
limit 1`)
|
||||
.get(lotOccupancyOccupantForm.lotOccupancyId);
|
||||
if (maxIndexResult) {
|
||||
if (maxIndexResult !== undefined) {
|
||||
lotOccupantIndex = maxIndexResult.lotOccupantIndex + 1;
|
||||
}
|
||||
const rightNowMillis = Date.now();
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export async function addLotOccupancyOccupant(
|
|||
)
|
||||
.get(lotOccupancyOccupantForm.lotOccupancyId)
|
||||
|
||||
if (maxIndexResult) {
|
||||
if (maxIndexResult !== undefined) {
|
||||
lotOccupantIndex = maxIndexResult.lotOccupantIndex + 1
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export async function addLotOccupancyTransaction(lotOccupancyTransactionForm, re
|
|||
order by transactionIndex desc
|
||||
limit 1`)
|
||||
.get(lotOccupancyTransactionForm.lotOccupancyId);
|
||||
if (maxIndexResult) {
|
||||
if (maxIndexResult !== undefined) {
|
||||
transactionIndex = maxIndexResult.transactionIndex + 1;
|
||||
}
|
||||
const rightNow = new Date();
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export async function addLotOccupancyTransaction(
|
|||
)
|
||||
.get(lotOccupancyTransactionForm.lotOccupancyId)
|
||||
|
||||
if (maxIndexResult) {
|
||||
if (maxIndexResult !== undefined) {
|
||||
transactionIndex = maxIndexResult.transactionIndex + 1
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
|
|
|
|||
|
|
@ -8,7 +8,16 @@ export async function addWorkOrderLot(workOrderLotForm, requestSession) {
|
|||
where workOrderId = ?
|
||||
and lotId = ?`)
|
||||
.get(workOrderLotForm.workOrderId, workOrderLotForm.lotId);
|
||||
if (row) {
|
||||
if (row === undefined) {
|
||||
database
|
||||
.prepare(`insert into WorkOrderLots (
|
||||
workOrderId, lotId,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?)`)
|
||||
.run(workOrderLotForm.workOrderId, workOrderLotForm.lotId, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||
}
|
||||
else {
|
||||
if (row.recordDelete_timeMillis) {
|
||||
database
|
||||
.prepare(`update WorkOrderLots
|
||||
|
|
@ -23,15 +32,6 @@ export async function addWorkOrderLot(workOrderLotForm, requestSession) {
|
|||
.run(requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis, workOrderLotForm.workOrderId, workOrderLotForm.lotId);
|
||||
}
|
||||
}
|
||||
else {
|
||||
database
|
||||
.prepare(`insert into WorkOrderLots (
|
||||
workOrderId, lotId,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?)`)
|
||||
.run(workOrderLotForm.workOrderId, workOrderLotForm.lotId, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||
}
|
||||
database.release();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,24 @@ export async function addWorkOrderLot(
|
|||
)
|
||||
.get(workOrderLotForm.workOrderId, workOrderLotForm.lotId)
|
||||
|
||||
if (row) {
|
||||
if (row === undefined) {
|
||||
database
|
||||
.prepare(
|
||||
`insert into WorkOrderLots (
|
||||
workOrderId, lotId,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?)`
|
||||
)
|
||||
.run(
|
||||
workOrderLotForm.workOrderId,
|
||||
workOrderLotForm.lotId,
|
||||
requestSession.user!.userName,
|
||||
rightNowMillis,
|
||||
requestSession.user!.userName,
|
||||
rightNowMillis
|
||||
)
|
||||
} else {
|
||||
if (row.recordDelete_timeMillis) {
|
||||
database
|
||||
.prepare(
|
||||
|
|
@ -47,23 +64,6 @@ export async function addWorkOrderLot(
|
|||
workOrderLotForm.lotId
|
||||
)
|
||||
}
|
||||
} else {
|
||||
database
|
||||
.prepare(
|
||||
`insert into WorkOrderLots (
|
||||
workOrderId, lotId,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?)`
|
||||
)
|
||||
.run(
|
||||
workOrderLotForm.workOrderId,
|
||||
workOrderLotForm.lotId,
|
||||
requestSession.user!.userName,
|
||||
rightNowMillis,
|
||||
requestSession.user!.userName,
|
||||
rightNowMillis
|
||||
)
|
||||
}
|
||||
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -8,7 +8,16 @@ export async function addWorkOrderLotOccupancy(workOrderLotOccupancyForm, reques
|
|||
where workOrderId = ?
|
||||
and lotOccupancyId = ?`)
|
||||
.get(workOrderLotOccupancyForm.workOrderId, workOrderLotOccupancyForm.lotOccupancyId);
|
||||
if (row) {
|
||||
if (row === undefined) {
|
||||
database
|
||||
.prepare(`insert into WorkOrderLotOccupancies (
|
||||
workOrderId, lotOccupancyId,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?)`)
|
||||
.run(workOrderLotOccupancyForm.workOrderId, workOrderLotOccupancyForm.lotOccupancyId, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||
}
|
||||
else {
|
||||
if (row.recordDelete_timeMillis) {
|
||||
database
|
||||
.prepare(`update WorkOrderLotOccupancies
|
||||
|
|
@ -23,15 +32,6 @@ export async function addWorkOrderLotOccupancy(workOrderLotOccupancyForm, reques
|
|||
.run(requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis, workOrderLotOccupancyForm.workOrderId, workOrderLotOccupancyForm.lotOccupancyId);
|
||||
}
|
||||
}
|
||||
else {
|
||||
database
|
||||
.prepare(`insert into WorkOrderLotOccupancies (
|
||||
workOrderId, lotOccupancyId,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?)`)
|
||||
.run(workOrderLotOccupancyForm.workOrderId, workOrderLotOccupancyForm.lotOccupancyId, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||
}
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,24 @@ export async function addWorkOrderLotOccupancy(
|
|||
workOrderLotOccupancyForm.lotOccupancyId
|
||||
)
|
||||
|
||||
if (row) {
|
||||
if (row === undefined) {
|
||||
database
|
||||
.prepare(
|
||||
`insert into WorkOrderLotOccupancies (
|
||||
workOrderId, lotOccupancyId,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?)`
|
||||
)
|
||||
.run(
|
||||
workOrderLotOccupancyForm.workOrderId,
|
||||
workOrderLotOccupancyForm.lotOccupancyId,
|
||||
requestSession.user!.userName,
|
||||
rightNowMillis,
|
||||
requestSession.user!.userName,
|
||||
rightNowMillis
|
||||
)
|
||||
} else {
|
||||
if (row.recordDelete_timeMillis) {
|
||||
database
|
||||
.prepare(
|
||||
|
|
@ -52,23 +69,6 @@ export async function addWorkOrderLotOccupancy(
|
|||
workOrderLotOccupancyForm.lotOccupancyId
|
||||
)
|
||||
}
|
||||
} else {
|
||||
database
|
||||
.prepare(
|
||||
`insert into WorkOrderLotOccupancies (
|
||||
workOrderId, lotOccupancyId,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?)`
|
||||
)
|
||||
.run(
|
||||
workOrderLotOccupancyForm.workOrderId,
|
||||
workOrderLotOccupancyForm.lotOccupancyId,
|
||||
requestSession.user!.userName,
|
||||
rightNowMillis,
|
||||
requestSession.user!.userName,
|
||||
rightNowMillis
|
||||
)
|
||||
}
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
/* eslint-disable @typescript-eslint/indent */
|
||||
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
import {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ export async function getFeeCategories(filters, options) {
|
|||
const database = await acquireConnection();
|
||||
let sqlWhereClause = ' where recordDelete_timeMillis is null';
|
||||
const sqlParameters = [];
|
||||
if (filters.occupancyTypeId) {
|
||||
if ((filters.occupancyTypeId ?? '') !== '') {
|
||||
sqlWhereClause +=
|
||||
' and feeCategoryId in (' +
|
||||
'select feeCategoryId from Fees' +
|
||||
|
|
@ -14,7 +14,7 @@ export async function getFeeCategories(filters, options) {
|
|||
' and (occupancyTypeId is null or occupancyTypeId = ?))';
|
||||
sqlParameters.push(filters.occupancyTypeId);
|
||||
}
|
||||
if (filters.lotTypeId) {
|
||||
if ((filters.lotTypeId ?? '') !== '') {
|
||||
sqlWhereClause +=
|
||||
' and feeCategoryId in (' +
|
||||
'select feeCategoryId from Fees' +
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export async function getFeeCategories(
|
|||
|
||||
const sqlParameters: unknown[] = []
|
||||
|
||||
if (filters.occupancyTypeId) {
|
||||
if ((filters.occupancyTypeId ?? '') !== '') {
|
||||
sqlWhereClause +=
|
||||
' and feeCategoryId in (' +
|
||||
'select feeCategoryId from Fees' +
|
||||
|
|
@ -37,7 +37,7 @@ export async function getFeeCategories(
|
|||
sqlParameters.push(filters.occupancyTypeId)
|
||||
}
|
||||
|
||||
if (filters.lotTypeId) {
|
||||
if ((filters.lotTypeId ?? '') !== '') {
|
||||
sqlWhereClause +=
|
||||
' and feeCategoryId in (' +
|
||||
'select feeCategoryId from Fees' +
|
||||
|
|
@ -76,7 +76,11 @@ export async function getFeeCategories(
|
|||
|
||||
expectedOrderNumber += 1
|
||||
|
||||
feeCategory.fees = await getFees(feeCategory.feeCategoryId, filters, database)
|
||||
feeCategory.fees = await getFees(
|
||||
feeCategory.feeCategoryId,
|
||||
filters,
|
||||
database
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ const baseSQL = `select l.lotId, l.lotTypeId, t.lotType, l.lotName, l.lotStatusI
|
|||
async function _getLot(sql, lotIdOrLotName) {
|
||||
const database = await acquireConnection();
|
||||
const lot = database.prepare(sql).get(lotIdOrLotName);
|
||||
if (lot) {
|
||||
if (lot !== undefined) {
|
||||
const lotOccupancies = await getLotOccupancies({
|
||||
lotId: lot.lotId
|
||||
}, {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ async function _getLot(
|
|||
|
||||
const lot: recordTypes.Lot = database.prepare(sql).get(lotIdOrLotName)
|
||||
|
||||
if (lot) {
|
||||
if (lot !== undefined) {
|
||||
const lotOccupancies = await getLotOccupancies(
|
||||
{
|
||||
lotId: lot.lotId
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { getLotNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWher
|
|||
function buildWhereClause(filters) {
|
||||
let sqlWhereClause = ' where o.recordDelete_timeMillis is null';
|
||||
const sqlParameters = [];
|
||||
if (filters.lotId) {
|
||||
if ((filters.lotId ?? '') !== '') {
|
||||
sqlWhereClause += ' and o.lotId = ?';
|
||||
sqlParameters.push(filters.lotId);
|
||||
}
|
||||
|
|
@ -22,36 +22,36 @@ function buildWhereClause(filters) {
|
|||
')';
|
||||
sqlParameters.push(...occupantNameFilters.sqlParameters);
|
||||
}
|
||||
if (filters.occupancyTypeId) {
|
||||
if ((filters.occupancyTypeId ?? '') !== '') {
|
||||
sqlWhereClause += ' and o.occupancyTypeId = ?';
|
||||
sqlParameters.push(filters.occupancyTypeId);
|
||||
}
|
||||
const occupancyTimeFilters = getOccupancyTimeWhereClause(filters.occupancyTime ?? '', 'o');
|
||||
sqlWhereClause += occupancyTimeFilters.sqlWhereClause;
|
||||
sqlParameters.push(...occupancyTimeFilters.sqlParameters);
|
||||
if (filters.occupancyStartDateString) {
|
||||
if ((filters.occupancyStartDateString ?? '') !== '') {
|
||||
sqlWhereClause += ' and o.occupancyStartDate = ?';
|
||||
sqlParameters.push(dateStringToInteger(filters.occupancyStartDateString));
|
||||
}
|
||||
if (filters.occupancyEffectiveDateString) {
|
||||
if ((filters.occupancyEffectiveDateString ?? '') !== '') {
|
||||
sqlWhereClause +=
|
||||
' and (o.occupancyStartDate <= ? and (o.occupancyEndDate is null or o.occupancyEndDate >= ?))';
|
||||
sqlParameters.push(dateStringToInteger(filters.occupancyEffectiveDateString), dateStringToInteger(filters.occupancyEffectiveDateString));
|
||||
}
|
||||
if (filters.mapId) {
|
||||
if ((filters.mapId ?? '') !== '') {
|
||||
sqlWhereClause += ' and l.mapId = ?';
|
||||
sqlParameters.push(filters.mapId);
|
||||
}
|
||||
if (filters.lotTypeId) {
|
||||
if ((filters.lotTypeId ?? '') !== '') {
|
||||
sqlWhereClause += ' and l.lotTypeId = ?';
|
||||
sqlParameters.push(filters.lotTypeId);
|
||||
}
|
||||
if (filters.workOrderId) {
|
||||
if ((filters.workOrderId ?? '') !== '') {
|
||||
sqlWhereClause +=
|
||||
' and o.lotOccupancyId in (select lotOccupancyId from WorkOrderLotOccupancies where recordDelete_timeMillis is null and workOrderId = ?)';
|
||||
sqlParameters.push(filters.workOrderId);
|
||||
}
|
||||
if (filters.notWorkOrderId) {
|
||||
if ((filters.notWorkOrderId ?? '') !== '') {
|
||||
sqlWhereClause +=
|
||||
' and o.lotOccupancyId not in (select lotOccupancyId from WorkOrderLotOccupancies where recordDelete_timeMillis is null and workOrderId = ?)';
|
||||
sqlParameters.push(filters.notWorkOrderId);
|
||||
|
|
@ -98,7 +98,7 @@ export async function getLotOccupancies(filters, options, connectedDatabase) {
|
|||
}
|
||||
for (const lotOccupancy of lotOccupancies) {
|
||||
const occupancyType = await getOccupancyTypeById(lotOccupancy.occupancyTypeId);
|
||||
if (occupancyType) {
|
||||
if (occupancyType !== undefined) {
|
||||
lotOccupancy.printEJS = (occupancyType.occupancyTypePrints ?? []).includes('*')
|
||||
? configFunctions.getProperty('settings.lotOccupancy.prints')[0]
|
||||
: occupancyType.occupancyTypePrints[0];
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ function buildWhereClause(filters: GetLotOccupanciesFilters): {
|
|||
let sqlWhereClause = ' where o.recordDelete_timeMillis is null'
|
||||
const sqlParameters: unknown[] = []
|
||||
|
||||
if (filters.lotId) {
|
||||
if ((filters.lotId ?? '') !== '') {
|
||||
sqlWhereClause += ' and o.lotId = ?'
|
||||
sqlParameters.push(filters.lotId)
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ function buildWhereClause(filters: GetLotOccupanciesFilters): {
|
|||
sqlParameters.push(...occupantNameFilters.sqlParameters)
|
||||
}
|
||||
|
||||
if (filters.occupancyTypeId) {
|
||||
if ((filters.occupancyTypeId ?? '') !== '') {
|
||||
sqlWhereClause += ' and o.occupancyTypeId = ?'
|
||||
sqlParameters.push(filters.occupancyTypeId)
|
||||
}
|
||||
|
|
@ -85,37 +85,37 @@ function buildWhereClause(filters: GetLotOccupanciesFilters): {
|
|||
sqlWhereClause += occupancyTimeFilters.sqlWhereClause
|
||||
sqlParameters.push(...occupancyTimeFilters.sqlParameters)
|
||||
|
||||
if (filters.occupancyStartDateString) {
|
||||
if ((filters.occupancyStartDateString ?? '') !== '') {
|
||||
sqlWhereClause += ' and o.occupancyStartDate = ?'
|
||||
sqlParameters.push(dateStringToInteger(filters.occupancyStartDateString))
|
||||
sqlParameters.push(dateStringToInteger(filters.occupancyStartDateString!))
|
||||
}
|
||||
|
||||
if (filters.occupancyEffectiveDateString) {
|
||||
if ((filters.occupancyEffectiveDateString ?? '') !== '') {
|
||||
sqlWhereClause +=
|
||||
' and (o.occupancyStartDate <= ? and (o.occupancyEndDate is null or o.occupancyEndDate >= ?))'
|
||||
sqlParameters.push(
|
||||
dateStringToInteger(filters.occupancyEffectiveDateString),
|
||||
dateStringToInteger(filters.occupancyEffectiveDateString)
|
||||
dateStringToInteger(filters.occupancyEffectiveDateString!),
|
||||
dateStringToInteger(filters.occupancyEffectiveDateString!)
|
||||
)
|
||||
}
|
||||
|
||||
if (filters.mapId) {
|
||||
if ((filters.mapId ?? '') !== '') {
|
||||
sqlWhereClause += ' and l.mapId = ?'
|
||||
sqlParameters.push(filters.mapId)
|
||||
}
|
||||
|
||||
if (filters.lotTypeId) {
|
||||
if ((filters.lotTypeId ?? '') !== '') {
|
||||
sqlWhereClause += ' and l.lotTypeId = ?'
|
||||
sqlParameters.push(filters.lotTypeId)
|
||||
}
|
||||
|
||||
if (filters.workOrderId) {
|
||||
if ((filters.workOrderId ?? '') !== '') {
|
||||
sqlWhereClause +=
|
||||
' and o.lotOccupancyId in (select lotOccupancyId from WorkOrderLotOccupancies where recordDelete_timeMillis is null and workOrderId = ?)'
|
||||
sqlParameters.push(filters.workOrderId)
|
||||
}
|
||||
|
||||
if (filters.notWorkOrderId) {
|
||||
if ((filters.notWorkOrderId ?? '') !== '') {
|
||||
sqlWhereClause +=
|
||||
' and o.lotOccupancyId not in (select lotOccupancyId from WorkOrderLotOccupancies where recordDelete_timeMillis is null and workOrderId = ?)'
|
||||
sqlParameters.push(filters.notWorkOrderId)
|
||||
|
|
@ -180,9 +180,11 @@ export async function getLotOccupancies(
|
|||
}
|
||||
|
||||
for (const lotOccupancy of lotOccupancies) {
|
||||
const occupancyType = await getOccupancyTypeById(lotOccupancy.occupancyTypeId!)
|
||||
const occupancyType = await getOccupancyTypeById(
|
||||
lotOccupancy.occupancyTypeId!
|
||||
)
|
||||
|
||||
if (occupancyType) {
|
||||
if (occupancyType !== undefined) {
|
||||
lotOccupancy.printEJS = (
|
||||
occupancyType.occupancyTypePrints ?? []
|
||||
).includes('*')
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ export async function getLotOccupancy(lotOccupancyId, connectedDatabase) {
|
|||
where o.recordDelete_timeMillis is null
|
||||
and o.lotOccupancyId = ?`)
|
||||
.get(lotOccupancyId);
|
||||
if (lotOccupancy) {
|
||||
if (lotOccupancy !== undefined) {
|
||||
lotOccupancy.lotOccupancyFields = await getLotOccupancyFields(lotOccupancyId, database);
|
||||
lotOccupancy.lotOccupancyOccupants = await getLotOccupancyOccupants(lotOccupancyId, database);
|
||||
lotOccupancy.lotOccupancyComments = await getLotOccupancyComments(lotOccupancyId, database);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export async function getLotOccupancy(
|
|||
)
|
||||
.get(lotOccupancyId)
|
||||
|
||||
if (lotOccupancy) {
|
||||
if (lotOccupancy !== undefined) {
|
||||
lotOccupancy.lotOccupancyFields = await getLotOccupancyFields(
|
||||
lotOccupancyId,
|
||||
database
|
||||
|
|
|
|||
|
|
@ -5,5 +5,5 @@ interface GetFilters {
|
|||
interface LotStatusSummary extends recordTypes.LotStatus {
|
||||
lotCount: number;
|
||||
}
|
||||
export declare function getLotStatusSummary(filters?: GetFilters): Promise<LotStatusSummary[]>;
|
||||
export declare function getLotStatusSummary(filters: GetFilters): Promise<LotStatusSummary[]>;
|
||||
export default getLotStatusSummary;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ export async function getLotStatusSummary(filters) {
|
|||
const database = await acquireConnection();
|
||||
let sqlWhereClause = ' where l.recordDelete_timeMillis is null';
|
||||
const sqlParameters = [];
|
||||
if (filters?.mapId) {
|
||||
if ((filters.mapId ?? '') !== '') {
|
||||
sqlWhereClause += ' and l.mapId = ?';
|
||||
sqlParameters.push(filters.mapId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ interface LotStatusSummary extends recordTypes.LotStatus {
|
|||
}
|
||||
|
||||
export async function getLotStatusSummary(
|
||||
filters?: GetFilters
|
||||
filters: GetFilters
|
||||
): Promise<LotStatusSummary[]> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
let sqlWhereClause = ' where l.recordDelete_timeMillis is null'
|
||||
const sqlParameters: unknown[] = []
|
||||
|
||||
if (filters?.mapId) {
|
||||
if ((filters.mapId ?? '') !== '') {
|
||||
sqlWhereClause += ' and l.mapId = ?'
|
||||
sqlParameters.push(filters.mapId)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,5 +5,5 @@ interface GetFilters {
|
|||
interface LotTypeSummary extends recordTypes.LotType {
|
||||
lotCount: number;
|
||||
}
|
||||
export declare function getLotTypeSummary(filters?: GetFilters): Promise<LotTypeSummary[]>;
|
||||
export declare function getLotTypeSummary(filters: GetFilters): Promise<LotTypeSummary[]>;
|
||||
export default getLotTypeSummary;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ export async function getLotTypeSummary(filters) {
|
|||
const database = await acquireConnection();
|
||||
let sqlWhereClause = ' where l.recordDelete_timeMillis is null';
|
||||
const sqlParameters = [];
|
||||
if (filters?.mapId) {
|
||||
if ((filters.mapId ?? '') !== '') {
|
||||
sqlWhereClause += ' and l.mapId = ?';
|
||||
sqlParameters.push(filters.mapId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ interface LotTypeSummary extends recordTypes.LotType {
|
|||
}
|
||||
|
||||
export async function getLotTypeSummary(
|
||||
filters?: GetFilters
|
||||
filters: GetFilters
|
||||
): Promise<LotTypeSummary[]> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
let sqlWhereClause = ' where l.recordDelete_timeMillis is null'
|
||||
const sqlParameters: unknown[] = []
|
||||
|
||||
if (filters?.mapId) {
|
||||
if ((filters.mapId ?? '') !== '') {
|
||||
sqlWhereClause += ' and l.mapId = ?'
|
||||
sqlParameters.push(filters.mapId)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue