linting
parent
dccb4a611c
commit
749f381ebd
|
|
@ -3,7 +3,7 @@ import { getNextLotId } from '../../helpers/functions.lots.js';
|
|||
export async function handler(request, response) {
|
||||
const lotId = Number.parseInt(request.params.lotId, 10);
|
||||
const nextLotId = await getNextLotId(lotId);
|
||||
if (!nextLotId) {
|
||||
if (nextLotId === undefined) {
|
||||
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/lots/?error=noNextLotIdFound');
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export async function handler(
|
|||
|
||||
const nextLotId = await getNextLotId(lotId)
|
||||
|
||||
if (!nextLotId) {
|
||||
if (nextLotId === undefined) {
|
||||
response.redirect(
|
||||
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/lots/?error=noNextLotIdFound'
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { getPreviousLotId } from '../../helpers/functions.lots.js';
|
|||
export async function handler(request, response) {
|
||||
const lotId = Number.parseInt(request.params.lotId, 10);
|
||||
const previousLotId = await getPreviousLotId(lotId);
|
||||
if (!previousLotId) {
|
||||
if (previousLotId === undefined) {
|
||||
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/lots/?error=noPreviousLotIdFound');
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export async function handler(
|
|||
|
||||
const previousLotId = await getPreviousLotId(lotId)
|
||||
|
||||
if (!previousLotId) {
|
||||
if (previousLotId === undefined) {
|
||||
response.redirect(
|
||||
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/lots/?error=noPreviousLotIdFound'
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
import { clearNextPreviousLotIdCache } from '../../helpers/functions.lots.js';
|
||||
import { deleteRecord } from '../../helpers/lotOccupancyDB/deleteRecord.js';
|
||||
export async function handler(request, response) {
|
||||
const success = await deleteRecord('Maps', request.body.mapId, request.session);
|
||||
response.json({
|
||||
success
|
||||
});
|
||||
response.on('finish', () => {
|
||||
clearNextPreviousLotIdCache();
|
||||
});
|
||||
}
|
||||
export default handler;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import type { Request, Response } from 'express'
|
||||
import { clearNextPreviousLotIdCache } from '../../helpers/functions.lots.js'
|
||||
|
||||
import { deleteRecord } from '../../helpers/lotOccupancyDB/deleteRecord.js'
|
||||
|
||||
|
|
@ -6,11 +7,19 @@ export async function handler(
|
|||
request: Request,
|
||||
response: Response
|
||||
): Promise<void> {
|
||||
const success = await deleteRecord('Maps', request.body.mapId, request.session)
|
||||
const success = await deleteRecord(
|
||||
'Maps',
|
||||
request.body.mapId,
|
||||
request.session
|
||||
)
|
||||
|
||||
response.json({
|
||||
success
|
||||
})
|
||||
|
||||
response.on('finish', () => {
|
||||
clearNextPreviousLotIdCache()
|
||||
})
|
||||
}
|
||||
|
||||
export default handler
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export async function handler(request, response) {
|
|||
includeComments: true,
|
||||
includeMilestones: true
|
||||
});
|
||||
if (!workOrder) {
|
||||
if (workOrder === undefined) {
|
||||
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/workOrders/?error=workOrderIdNotFound');
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ export async function handler(
|
|||
includeMilestones: true
|
||||
})
|
||||
|
||||
if (!workOrder) {
|
||||
if (workOrder === undefined) {
|
||||
response.redirect(
|
||||
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/workOrders/?error=workOrderIdNotFound'
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ export async function handler(request, response) {
|
|||
includeComments: true,
|
||||
includeMilestones: true
|
||||
});
|
||||
if (!workOrder) {
|
||||
if (workOrder === undefined) {
|
||||
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/workOrders/?error=workOrderIdNotFound');
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export async function handler(
|
|||
includeMilestones: true
|
||||
})
|
||||
|
||||
if (!workOrder) {
|
||||
if (workOrder === undefined) {
|
||||
response.redirect(
|
||||
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/workOrders/?error=workOrderIdNotFound'
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ async function authenticateViaActiveDirectory(userName, password) {
|
|||
const ad = new ActiveDirectory(activeDirectoryConfig);
|
||||
ad.authenticate(userDomain + '\\' + userName, password, (error, auth) => {
|
||||
let authenticated = false;
|
||||
if (!error) {
|
||||
if ((error ?? '') === '') {
|
||||
authenticated = auth;
|
||||
}
|
||||
resolve(authenticated);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ async function authenticateViaActiveDirectory(
|
|||
ad.authenticate(userDomain + '\\' + userName, password, (error, auth) => {
|
||||
let authenticated = false
|
||||
|
||||
if (!error) {
|
||||
if ((error ?? '') === '') {
|
||||
authenticated = auth
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,13 @@ export async function addLotOccupancyFee(lotOccupancyFeeForm, requestSession) {
|
|||
const rightNowMillis = Date.now();
|
||||
let feeAmount;
|
||||
let taxAmount;
|
||||
if (lotOccupancyFeeForm.feeAmount) {
|
||||
if ((lotOccupancyFeeForm.feeAmount ?? '') === '') {
|
||||
const lotOccupancy = (await getLotOccupancy(lotOccupancyFeeForm.lotOccupancyId));
|
||||
const fee = await getFee(lotOccupancyFeeForm.feeId);
|
||||
feeAmount = calculateFeeAmount(fee, lotOccupancy);
|
||||
taxAmount = calculateTaxAmount(fee, feeAmount);
|
||||
}
|
||||
else {
|
||||
feeAmount =
|
||||
typeof lotOccupancyFeeForm.feeAmount === 'string'
|
||||
? Number.parseFloat(lotOccupancyFeeForm.feeAmount)
|
||||
|
|
@ -17,12 +23,6 @@ export async function addLotOccupancyFee(lotOccupancyFeeForm, requestSession) {
|
|||
? Number.parseFloat(lotOccupancyFeeForm.taxAmount)
|
||||
: 0;
|
||||
}
|
||||
else {
|
||||
const lotOccupancy = (await getLotOccupancy(lotOccupancyFeeForm.lotOccupancyId));
|
||||
const fee = await getFee(lotOccupancyFeeForm.feeId);
|
||||
feeAmount = calculateFeeAmount(fee, lotOccupancy);
|
||||
taxAmount = calculateTaxAmount(fee, feeAmount);
|
||||
}
|
||||
const record = database
|
||||
.prepare(`select feeAmount, taxAmount, recordDelete_timeMillis
|
||||
from LotOccupancyFees
|
||||
|
|
|
|||
|
|
@ -28,7 +28,15 @@ export async function addLotOccupancyFee(
|
|||
let feeAmount: number
|
||||
let taxAmount: number
|
||||
|
||||
if (lotOccupancyFeeForm.feeAmount) {
|
||||
if ((lotOccupancyFeeForm.feeAmount ?? '') === '') {
|
||||
const lotOccupancy = (await getLotOccupancy(
|
||||
lotOccupancyFeeForm.lotOccupancyId
|
||||
))!
|
||||
const fee = await getFee(lotOccupancyFeeForm.feeId)
|
||||
|
||||
feeAmount = calculateFeeAmount(fee, lotOccupancy)
|
||||
taxAmount = calculateTaxAmount(fee, feeAmount)
|
||||
} else {
|
||||
feeAmount =
|
||||
typeof lotOccupancyFeeForm.feeAmount === 'string'
|
||||
? Number.parseFloat(lotOccupancyFeeForm.feeAmount)
|
||||
|
|
@ -37,14 +45,6 @@ export async function addLotOccupancyFee(
|
|||
typeof lotOccupancyFeeForm.taxAmount === 'string'
|
||||
? Number.parseFloat(lotOccupancyFeeForm.taxAmount)
|
||||
: 0
|
||||
} else {
|
||||
const lotOccupancy = (await getLotOccupancy(
|
||||
lotOccupancyFeeForm.lotOccupancyId
|
||||
))!
|
||||
const fee = await getFee(lotOccupancyFeeForm.feeId)
|
||||
|
||||
feeAmount = calculateFeeAmount(fee, lotOccupancy)
|
||||
taxAmount = calculateTaxAmount(fee, feeAmount)
|
||||
}
|
||||
|
||||
// Check if record already exists
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ export async function getFeeCategories(filters, options) {
|
|||
sqlWhereClause +
|
||||
' order by orderNumber, feeCategory')
|
||||
.all(sqlParameters);
|
||||
if (options.includeFees) {
|
||||
if (options.includeFees ?? false) {
|
||||
let expectedOrderNumber = 0;
|
||||
for (const feeCategory of feeCategories) {
|
||||
if (updateOrderNumbers &&
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ export async function getFeeCategories(
|
|||
)
|
||||
.all(sqlParameters)
|
||||
|
||||
if (options.includeFees) {
|
||||
if (options.includeFees ?? false) {
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
for (const feeCategory of feeCategories) {
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ export async function getNextLotId(lotId) {
|
|||
limit 1`)
|
||||
.get(lotId);
|
||||
database.release();
|
||||
if (result) {
|
||||
return result.lotId;
|
||||
}
|
||||
if (result === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return result.lotId;
|
||||
}
|
||||
export default getNextLotId;
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@ export async function getNextLotId(
|
|||
|
||||
database.release()
|
||||
|
||||
if (result) {
|
||||
return result.lotId
|
||||
}
|
||||
|
||||
if (result === undefined) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return result.lotId
|
||||
}
|
||||
|
||||
export default getNextLotId
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ export async function getPreviousLotId(lotId) {
|
|||
limit 1`)
|
||||
.get(lotId);
|
||||
database.release();
|
||||
if (result) {
|
||||
return result.lotId;
|
||||
}
|
||||
if (result === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return result.lotId;
|
||||
}
|
||||
export default getPreviousLotId;
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@ export async function getPreviousLotId(
|
|||
|
||||
database.release()
|
||||
|
||||
if (result) {
|
||||
return result.lotId
|
||||
}
|
||||
|
||||
if (result === undefined) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return result.lotId
|
||||
}
|
||||
|
||||
export default getPreviousLotId
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@ interface WorkOrderOptions {
|
|||
includeComments: boolean;
|
||||
includeMilestones: boolean;
|
||||
}
|
||||
export declare function getWorkOrderByWorkOrderNumber(workOrderNumber: string): Promise<recordTypes.WorkOrder>;
|
||||
export declare function getWorkOrder(workOrderId: number | string, options: WorkOrderOptions, connectedDatabase?: PoolConnection): Promise<recordTypes.WorkOrder>;
|
||||
export declare function getWorkOrderByWorkOrderNumber(workOrderNumber: string): Promise<recordTypes.WorkOrder | undefined>;
|
||||
export declare function getWorkOrder(workOrderId: number | string, options: WorkOrderOptions, connectedDatabase?: PoolConnection): Promise<recordTypes.WorkOrder | undefined>;
|
||||
export default getWorkOrder;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ async function _getWorkOrder(sql, workOrderIdOrWorkOrderNumber, options, connect
|
|||
const workOrder = database
|
||||
.prepare(sql)
|
||||
.get(workOrderIdOrWorkOrderNumber);
|
||||
if (workOrder) {
|
||||
if (workOrder !== undefined) {
|
||||
if (options.includeLotsAndLotOccupancies) {
|
||||
const workOrderLotsResults = await getLots({
|
||||
workOrderId: workOrder.workOrderId
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ async function _getWorkOrder(
|
|||
workOrderIdOrWorkOrderNumber: number | string,
|
||||
options: WorkOrderOptions,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.WorkOrder> {
|
||||
): Promise<recordTypes.WorkOrder | undefined> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
|
|
@ -43,7 +43,7 @@ async function _getWorkOrder(
|
|||
.prepare(sql)
|
||||
.get(workOrderIdOrWorkOrderNumber)
|
||||
|
||||
if (workOrder) {
|
||||
if (workOrder !== undefined) {
|
||||
if (options.includeLotsAndLotOccupancies) {
|
||||
const workOrderLotsResults = await getLots(
|
||||
{
|
||||
|
|
@ -104,7 +104,7 @@ async function _getWorkOrder(
|
|||
|
||||
export async function getWorkOrderByWorkOrderNumber(
|
||||
workOrderNumber: string
|
||||
): Promise<recordTypes.WorkOrder> {
|
||||
): Promise<recordTypes.WorkOrder | undefined> {
|
||||
return await _getWorkOrder(
|
||||
baseSQL + ' and w.workOrderNumber = ?',
|
||||
workOrderNumber,
|
||||
|
|
@ -120,7 +120,7 @@ export async function getWorkOrder(
|
|||
workOrderId: number | string,
|
||||
options: WorkOrderOptions,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.WorkOrder> {
|
||||
): Promise<recordTypes.WorkOrder | undefined> {
|
||||
return await _getWorkOrder(
|
||||
baseSQL + ' and w.workOrderId = ?',
|
||||
workOrderId,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const commaSeparatedNumbersRegex = /^\d+(,\d+)*$/;
|
|||
function buildWhereClause(filters) {
|
||||
let sqlWhereClause = ' where m.recordDelete_timeMillis is null and w.recordDelete_timeMillis is null';
|
||||
const sqlParameters = [];
|
||||
if (filters.workOrderId) {
|
||||
if ((filters.workOrderId ?? '') !== '') {
|
||||
sqlWhereClause += ' and m.workOrderId = ?';
|
||||
sqlParameters.push(filters.workOrderId);
|
||||
}
|
||||
|
|
@ -34,16 +34,16 @@ function buildWhereClause(filters) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (filters.workOrderMilestoneDateString) {
|
||||
if ((filters.workOrderMilestoneDateString ?? '') !== '') {
|
||||
sqlWhereClause += ' and m.workOrderMilestoneDate = ?';
|
||||
sqlParameters.push(dateStringToInteger(filters.workOrderMilestoneDateString));
|
||||
}
|
||||
if (filters.workOrderTypeIds &&
|
||||
if ((filters.workOrderTypeIds ?? '') !== '' &&
|
||||
commaSeparatedNumbersRegex.test(filters.workOrderTypeIds)) {
|
||||
sqlWhereClause +=
|
||||
' and w.workOrderTypeId in (' + filters.workOrderTypeIds + ')';
|
||||
}
|
||||
if (filters.workOrderMilestoneTypeIds &&
|
||||
if ((filters.workOrderMilestoneTypeIds ?? '') !== '' &&
|
||||
commaSeparatedNumbersRegex.test(filters.workOrderMilestoneTypeIds)) {
|
||||
sqlWhereClause +=
|
||||
' and m.workOrderMilestoneTypeId in (' +
|
||||
|
|
@ -63,17 +63,17 @@ export async function getWorkOrderMilestones(filters, options, connectedDatabase
|
|||
let orderByClause = '';
|
||||
switch (options.orderBy) {
|
||||
case 'completion': {
|
||||
orderByClause =
|
||||
' order by' +
|
||||
' m.workOrderMilestoneCompletionDate, m.workOrderMilestoneCompletionTime,' +
|
||||
' m.workOrderMilestoneDate, case when m.workOrderMilestoneTime = 0 then 9999 else m.workOrderMilestoneTime end,' +
|
||||
' t.orderNumber, m.workOrderMilestoneId';
|
||||
orderByClause = ` order by
|
||||
m.workOrderMilestoneCompletionDate, m.workOrderMilestoneCompletionTime,
|
||||
m.workOrderMilestoneDate,
|
||||
case when m.workOrderMilestoneTime = 0 then 9999 else m.workOrderMilestoneTime end,
|
||||
t.orderNumber, m.workOrderMilestoneId`;
|
||||
break;
|
||||
}
|
||||
case 'date': {
|
||||
orderByClause =
|
||||
' order by m.workOrderMilestoneDate, case when m.workOrderMilestoneTime = 0 then 9999 else m.workOrderMilestoneTime end,' +
|
||||
' t.orderNumber, m.workOrderId, m.workOrderMilestoneId';
|
||||
orderByClause = ` order by m.workOrderMilestoneDate,
|
||||
case when m.workOrderMilestoneTime = 0 then 9999 else m.workOrderMilestoneTime end,
|
||||
t.orderNumber, m.workOrderId, m.workOrderMilestoneId`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ export async function getWorkOrderMilestones(filters, options, connectedDatabase
|
|||
' m.workOrderMilestoneDescription,' +
|
||||
' m.workOrderMilestoneCompletionDate, userFn_dateIntegerToString(m.workOrderMilestoneCompletionDate) as workOrderMilestoneCompletionDateString,' +
|
||||
' m.workOrderMilestoneCompletionTime, userFn_timeIntegerToString(m.workOrderMilestoneCompletionTime) as workOrderMilestoneCompletionTimeString,' +
|
||||
(options.includeWorkOrders
|
||||
(options.includeWorkOrders ?? false
|
||||
? ' m.workOrderId, w.workOrderNumber, wt.workOrderType, w.workOrderDescription,' +
|
||||
' w.workOrderOpenDate, userFn_dateIntegerToString(w.workOrderOpenDate) as workOrderOpenDateString,' +
|
||||
' w.workOrderCloseDate, userFn_dateIntegerToString(w.workOrderCloseDate) as workOrderCloseDateString,' +
|
||||
|
|
@ -101,7 +101,7 @@ export async function getWorkOrderMilestones(filters, options, connectedDatabase
|
|||
const workOrderMilestones = database
|
||||
.prepare(sql)
|
||||
.all(sqlParameters);
|
||||
if (options.includeWorkOrders) {
|
||||
if (options.includeWorkOrders ?? false) {
|
||||
for (const workOrderMilestone of workOrderMilestones) {
|
||||
const workOrderLotsResults = await getLots({
|
||||
workOrderId: workOrderMilestone.workOrderId
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ function buildWhereClause(filters: WorkOrderMilestoneFilters): {
|
|||
' where m.recordDelete_timeMillis is null and w.recordDelete_timeMillis is null'
|
||||
const sqlParameters: unknown[] = []
|
||||
|
||||
if (filters.workOrderId) {
|
||||
if ((filters.workOrderId ?? '') !== '') {
|
||||
sqlWhereClause += ' and m.workOrderId = ?'
|
||||
sqlParameters.push(filters.workOrderId)
|
||||
}
|
||||
|
|
@ -83,28 +83,28 @@ function buildWhereClause(filters: WorkOrderMilestoneFilters): {
|
|||
}
|
||||
}
|
||||
|
||||
if (filters.workOrderMilestoneDateString) {
|
||||
if ((filters.workOrderMilestoneDateString ?? '') !== '') {
|
||||
sqlWhereClause += ' and m.workOrderMilestoneDate = ?'
|
||||
sqlParameters.push(
|
||||
dateStringToInteger(filters.workOrderMilestoneDateString)
|
||||
dateStringToInteger(filters.workOrderMilestoneDateString!)
|
||||
)
|
||||
}
|
||||
|
||||
if (
|
||||
filters.workOrderTypeIds &&
|
||||
commaSeparatedNumbersRegex.test(filters.workOrderTypeIds)
|
||||
(filters.workOrderTypeIds ?? '') !== '' &&
|
||||
commaSeparatedNumbersRegex.test(filters.workOrderTypeIds!)
|
||||
) {
|
||||
sqlWhereClause +=
|
||||
' and w.workOrderTypeId in (' + filters.workOrderTypeIds + ')'
|
||||
' and w.workOrderTypeId in (' + filters.workOrderTypeIds! + ')'
|
||||
}
|
||||
|
||||
if (
|
||||
filters.workOrderMilestoneTypeIds &&
|
||||
commaSeparatedNumbersRegex.test(filters.workOrderMilestoneTypeIds)
|
||||
(filters.workOrderMilestoneTypeIds ?? '') !== '' &&
|
||||
commaSeparatedNumbersRegex.test(filters.workOrderMilestoneTypeIds!)
|
||||
) {
|
||||
sqlWhereClause +=
|
||||
' and m.workOrderMilestoneTypeId in (' +
|
||||
filters.workOrderMilestoneTypeIds +
|
||||
filters.workOrderMilestoneTypeIds! +
|
||||
')'
|
||||
}
|
||||
|
||||
|
|
@ -132,18 +132,18 @@ export async function getWorkOrderMilestones(
|
|||
|
||||
switch (options.orderBy) {
|
||||
case 'completion': {
|
||||
orderByClause =
|
||||
' order by' +
|
||||
' m.workOrderMilestoneCompletionDate, m.workOrderMilestoneCompletionTime,' +
|
||||
' m.workOrderMilestoneDate, case when m.workOrderMilestoneTime = 0 then 9999 else m.workOrderMilestoneTime end,' +
|
||||
' t.orderNumber, m.workOrderMilestoneId'
|
||||
orderByClause = ` order by
|
||||
m.workOrderMilestoneCompletionDate, m.workOrderMilestoneCompletionTime,
|
||||
m.workOrderMilestoneDate,
|
||||
case when m.workOrderMilestoneTime = 0 then 9999 else m.workOrderMilestoneTime end,
|
||||
t.orderNumber, m.workOrderMilestoneId`
|
||||
break
|
||||
}
|
||||
|
||||
case 'date': {
|
||||
orderByClause =
|
||||
' order by m.workOrderMilestoneDate, case when m.workOrderMilestoneTime = 0 then 9999 else m.workOrderMilestoneTime end,' +
|
||||
' t.orderNumber, m.workOrderId, m.workOrderMilestoneId'
|
||||
orderByClause = ` order by m.workOrderMilestoneDate,
|
||||
case when m.workOrderMilestoneTime = 0 then 9999 else m.workOrderMilestoneTime end,
|
||||
t.orderNumber, m.workOrderId, m.workOrderMilestoneId`
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -157,7 +157,7 @@ export async function getWorkOrderMilestones(
|
|||
' m.workOrderMilestoneDescription,' +
|
||||
' m.workOrderMilestoneCompletionDate, userFn_dateIntegerToString(m.workOrderMilestoneCompletionDate) as workOrderMilestoneCompletionDateString,' +
|
||||
' m.workOrderMilestoneCompletionTime, userFn_timeIntegerToString(m.workOrderMilestoneCompletionTime) as workOrderMilestoneCompletionTimeString,' +
|
||||
(options.includeWorkOrders
|
||||
(options.includeWorkOrders ?? false
|
||||
? ' m.workOrderId, w.workOrderNumber, wt.workOrderType, w.workOrderDescription,' +
|
||||
' w.workOrderOpenDate, userFn_dateIntegerToString(w.workOrderOpenDate) as workOrderOpenDateString,' +
|
||||
' w.workOrderCloseDate, userFn_dateIntegerToString(w.workOrderCloseDate) as workOrderCloseDateString,' +
|
||||
|
|
@ -176,7 +176,7 @@ export async function getWorkOrderMilestones(
|
|||
.prepare(sql)
|
||||
.all(sqlParameters)
|
||||
|
||||
if (options.includeWorkOrders) {
|
||||
if (options.includeWorkOrders ?? false) {
|
||||
for (const workOrderMilestone of workOrderMilestones) {
|
||||
const workOrderLotsResults = await getLots(
|
||||
{
|
||||
|
|
|
|||
|
|
@ -82,18 +82,20 @@ export async function getWorkOrders(filters, options, connectedDatabase) {
|
|||
' group by workOrderId) m on w.workOrderId = m.workOrderId') +
|
||||
sqlWhereClause +
|
||||
' order by w.workOrderOpenDate desc, w.workOrderNumber desc' +
|
||||
(options ? ` limit ${options.limit} offset ${options.offset}` : ''))
|
||||
(options === undefined
|
||||
? ''
|
||||
: ` limit ${options.limit} offset ${options.offset}`))
|
||||
.all(sqlParameters);
|
||||
}
|
||||
if (options &&
|
||||
(options.includeComments ||
|
||||
options.includeLotsAndLotOccupancies ||
|
||||
options.includeMilestones)) {
|
||||
if (options !== undefined &&
|
||||
((options.includeComments ?? false) ||
|
||||
(options.includeLotsAndLotOccupancies ?? false) ||
|
||||
(options.includeMilestones ?? false))) {
|
||||
for (const workOrder of workOrders) {
|
||||
if (options.includeComments) {
|
||||
if (options.includeComments ?? false) {
|
||||
workOrder.workOrderComments = await getWorkOrderComments(workOrder.workOrderId, database);
|
||||
}
|
||||
if (options.includeLotsAndLotOccupancies) {
|
||||
if (options.includeLotsAndLotOccupancies ?? false) {
|
||||
const workOrderLotsResults = await getLots({
|
||||
workOrderId: workOrder.workOrderId
|
||||
}, {
|
||||
|
|
@ -110,7 +112,7 @@ export async function getWorkOrders(filters, options, connectedDatabase) {
|
|||
}, database);
|
||||
workOrder.workOrderLotOccupancies = lotOccupancies.lotOccupancies;
|
||||
}
|
||||
if (options.includeMilestones) {
|
||||
if (options.includeMilestones ?? false) {
|
||||
workOrder.workOrderMilestones = await getWorkOrderMilestones({
|
||||
workOrderId: workOrder.workOrderId
|
||||
}, {
|
||||
|
|
|
|||
|
|
@ -138,26 +138,28 @@ export async function getWorkOrders(
|
|||
' group by workOrderId) m on w.workOrderId = m.workOrderId') +
|
||||
sqlWhereClause +
|
||||
' order by w.workOrderOpenDate desc, w.workOrderNumber desc' +
|
||||
(options ? ` limit ${options.limit} offset ${options.offset}` : '')
|
||||
(options === undefined
|
||||
? ''
|
||||
: ` limit ${options.limit} offset ${options.offset}`)
|
||||
)
|
||||
.all(sqlParameters)
|
||||
}
|
||||
|
||||
if (
|
||||
options &&
|
||||
(options.includeComments ||
|
||||
options.includeLotsAndLotOccupancies ||
|
||||
options.includeMilestones)
|
||||
options !== undefined &&
|
||||
((options.includeComments ?? false) ||
|
||||
(options.includeLotsAndLotOccupancies ?? false) ||
|
||||
(options.includeMilestones ?? false))
|
||||
) {
|
||||
for (const workOrder of workOrders) {
|
||||
if (options.includeComments) {
|
||||
if (options.includeComments ?? false) {
|
||||
workOrder.workOrderComments = await getWorkOrderComments(
|
||||
workOrder.workOrderId as number,
|
||||
database
|
||||
)
|
||||
}
|
||||
|
||||
if (options.includeLotsAndLotOccupancies) {
|
||||
if (options.includeLotsAndLotOccupancies ?? false) {
|
||||
const workOrderLotsResults = await getLots(
|
||||
{
|
||||
workOrderId: workOrder.workOrderId
|
||||
|
|
@ -186,7 +188,7 @@ export async function getWorkOrders(
|
|||
workOrder.workOrderLotOccupancies = lotOccupancies.lotOccupancies
|
||||
}
|
||||
|
||||
if (options.includeMilestones) {
|
||||
if (options.includeMilestones ?? false) {
|
||||
workOrder.workOrderMilestones = await getWorkOrderMilestones(
|
||||
{
|
||||
workOrderId: workOrder.workOrderId
|
||||
|
|
|
|||
Loading…
Reference in New Issue