linting
parent
10fe9a612e
commit
c937521807
|
|
@ -117,7 +117,7 @@ function buildEventDescriptionHTML_occupancies(
|
|||
<td>
|
||||
${
|
||||
occupancy.occupancyEndDate
|
||||
? occupancy.occupancyEndDateString
|
||||
? occupancy.occupancyEndDateString!
|
||||
: '(No End Date)'
|
||||
}
|
||||
</td>
|
||||
|
|
@ -306,7 +306,7 @@ export const handler: RequestHandler = (request, response) => {
|
|||
})
|
||||
|
||||
if (request.query.workOrderId && workOrderMilestones.length > 0) {
|
||||
calendar.name(`Work Order #${workOrderMilestones[0].workOrderNumber}`)
|
||||
calendar.name(`Work Order #${workOrderMilestones[0].workOrderNumber!}`)
|
||||
calendar.url(urlRoot + '/workOrders/' + workOrderMilestones[0].workOrderId)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ export function addWorkOrder(workOrderForm, requestSession) {
|
|||
}
|
||||
const result = database
|
||||
.prepare(`insert into WorkOrders (
|
||||
workOrderTypeId, workOrderNumber, workOrderDescription,
|
||||
workOrderOpenDate, workOrderCloseDate,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
workOrderTypeId, workOrderNumber, workOrderDescription,
|
||||
workOrderOpenDate, workOrderCloseDate,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(workOrderForm.workOrderTypeId, workOrderNumber, workOrderForm.workOrderDescription, workOrderForm.workOrderOpenDateString
|
||||
? dateStringToInteger(workOrderForm.workOrderOpenDateString)
|
||||
: dateToInteger(rightNow), workOrderForm.workOrderCloseDateString
|
||||
|
|
|
|||
|
|
@ -38,11 +38,11 @@ export function addWorkOrder(
|
|||
const result = database
|
||||
.prepare(
|
||||
`insert into WorkOrders (
|
||||
workOrderTypeId, workOrderNumber, workOrderDescription,
|
||||
workOrderOpenDate, workOrderCloseDate,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
workOrderTypeId, workOrderNumber, workOrderDescription,
|
||||
workOrderOpenDate, workOrderCloseDate,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
)
|
||||
.run(
|
||||
workOrderForm.workOrderTypeId,
|
||||
|
|
|
|||
|
|
@ -5,22 +5,22 @@ export function addWorkOrderLot(workOrderLotForm, requestSession) {
|
|||
const rightNowMillis = Date.now();
|
||||
const row = database
|
||||
.prepare(`select recordDelete_timeMillis
|
||||
from WorkOrderLots
|
||||
where workOrderId = ?
|
||||
and lotId = ?`)
|
||||
from WorkOrderLots
|
||||
where workOrderId = ?
|
||||
and lotId = ?`)
|
||||
.get(workOrderLotForm.workOrderId, workOrderLotForm.lotId);
|
||||
if (row) {
|
||||
if (row.recordDelete_timeMillis) {
|
||||
database
|
||||
.prepare(`update WorkOrderLots
|
||||
set recordCreate_userName = ?,
|
||||
recordCreate_timeMillis = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
where workOrderId = ?
|
||||
and lotId = ?`)
|
||||
set recordCreate_userName = ?,
|
||||
recordCreate_timeMillis = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
where workOrderId = ?
|
||||
and lotId = ?`)
|
||||
.run(requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis, workOrderLotForm.workOrderId, workOrderLotForm.lotId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ export function addWorkOrderLot(
|
|||
const row: { recordDelete_timeMillis?: number } = database
|
||||
.prepare(
|
||||
`select recordDelete_timeMillis
|
||||
from WorkOrderLots
|
||||
where workOrderId = ?
|
||||
and lotId = ?`
|
||||
from WorkOrderLots
|
||||
where workOrderId = ?
|
||||
and lotId = ?`
|
||||
)
|
||||
.get(workOrderLotForm.workOrderId, workOrderLotForm.lotId)
|
||||
|
||||
|
|
@ -31,14 +31,14 @@ export function addWorkOrderLot(
|
|||
database
|
||||
.prepare(
|
||||
`update WorkOrderLots
|
||||
set recordCreate_userName = ?,
|
||||
recordCreate_timeMillis = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
where workOrderId = ?
|
||||
and lotId = ?`
|
||||
set recordCreate_userName = ?,
|
||||
recordCreate_timeMillis = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?,
|
||||
recordDelete_userName = null,
|
||||
recordDelete_timeMillis = null
|
||||
where workOrderId = ?
|
||||
and lotId = ?`
|
||||
)
|
||||
.run(
|
||||
requestSession.user!.userName,
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ export function closeWorkOrder(workOrderForm, requestSession) {
|
|||
const rightNow = new Date();
|
||||
const result = database
|
||||
.prepare(`update WorkOrders
|
||||
set workOrderCloseDate = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where workOrderId = ?`)
|
||||
set workOrderCloseDate = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where workOrderId = ?`)
|
||||
.run(workOrderForm.workOrderCloseDateString
|
||||
? dateStringToInteger(workOrderForm.workOrderCloseDateString)
|
||||
: dateToInteger(new Date()), requestSession.user.userName, rightNow.getTime(), workOrderForm.workOrderId);
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ export function closeWorkOrder(
|
|||
const result = database
|
||||
.prepare(
|
||||
`update WorkOrders
|
||||
set workOrderCloseDate = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where workOrderId = ?`
|
||||
set workOrderCloseDate = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where workOrderId = ?`
|
||||
)
|
||||
.run(
|
||||
workOrderForm.workOrderCloseDateString
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ export function completeWorkOrderMilestone(milestoneForm, requestSession) {
|
|||
const database = sqlite(databasePath);
|
||||
const result = database
|
||||
.prepare(`update WorkOrderMilestones
|
||||
set workOrderMilestoneCompletionDate = ?,
|
||||
workOrderMilestoneCompletionTime = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where workOrderMilestoneId = ?`)
|
||||
set workOrderMilestoneCompletionDate = ?,
|
||||
workOrderMilestoneCompletionTime = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where workOrderMilestoneId = ?`)
|
||||
.run(milestoneForm.workOrderMilestoneCompletionDateString
|
||||
? dateStringToInteger(milestoneForm.workOrderMilestoneCompletionDateString)
|
||||
: dateToInteger(rightNow), milestoneForm.workOrderMilestoneCompletionTimeString
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ export function completeWorkOrderMilestone(
|
|||
const result = database
|
||||
.prepare(
|
||||
`update WorkOrderMilestones
|
||||
set workOrderMilestoneCompletionDate = ?,
|
||||
workOrderMilestoneCompletionTime = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where workOrderMilestoneId = ?`
|
||||
set workOrderMilestoneCompletionDate = ?,
|
||||
workOrderMilestoneCompletionTime = ?,
|
||||
recordUpdate_userName = ?,
|
||||
recordUpdate_timeMillis = ?
|
||||
where workOrderMilestoneId = ?`
|
||||
)
|
||||
.run(
|
||||
milestoneForm.workOrderMilestoneCompletionDateString
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ export function deleteWorkOrderLotOccupancy(workOrderId, lotOccupancyId, request
|
|||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare(`update WorkOrderLotOccupancies
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
where workOrderId = ?
|
||||
and lotOccupancyId = ?`)
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
where workOrderId = ?
|
||||
and lotOccupancyId = ?`)
|
||||
.run(requestSession.user.userName, rightNowMillis, workOrderId, lotOccupancyId);
|
||||
database.close();
|
||||
return result.changes > 0;
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ export function deleteWorkOrderLotOccupancy(
|
|||
const result = database
|
||||
.prepare(
|
||||
`update WorkOrderLotOccupancies
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
where workOrderId = ?
|
||||
and lotOccupancyId = ?`
|
||||
set recordDelete_userName = ?,
|
||||
recordDelete_timeMillis = ?
|
||||
where workOrderId = ?
|
||||
and lotOccupancyId = ?`
|
||||
)
|
||||
.run(
|
||||
requestSession.user!.userName,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import type * as recordTypes from '../../types/recordTypes';
|
||||
export declare function getFee(feeId: number | string, connectedDatabase?: sqlite.Database): recordTypes.Fee;
|
||||
export default getFee;
|
||||
|
|
|
|||
|
|
@ -1,26 +1,26 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
export function getFee(feeId, connectedDatabase) {
|
||||
const database = connectedDatabase ||
|
||||
const database = connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const fee = database
|
||||
.prepare(`select f.feeId,
|
||||
f.feeCategoryId, c.feeCategory,
|
||||
f.feeName, f.feeDescription,
|
||||
f.occupancyTypeId, o.occupancyType,
|
||||
f.lotTypeId, l.lotType,
|
||||
ifnull(f.feeAmount, 0) as feeAmount, f.feeFunction,
|
||||
f.taxAmount, f.taxPercentage,
|
||||
f.includeQuantity, f.quantityUnit,
|
||||
f.isRequired, f.orderNumber
|
||||
from Fees f
|
||||
left join FeeCategories c on f.feeCategoryId = c.feeCategoryId
|
||||
left join OccupancyTypes o on f.occupancyTypeId = o.occupancyTypeId
|
||||
left join LotTypes l on f.lotTypeId = l.lotTypeId
|
||||
where f.recordDelete_timeMillis is null
|
||||
and f.feeId = ?`)
|
||||
f.feeCategoryId, c.feeCategory,
|
||||
f.feeName, f.feeDescription,
|
||||
f.occupancyTypeId, o.occupancyType,
|
||||
f.lotTypeId, l.lotType,
|
||||
ifnull(f.feeAmount, 0) as feeAmount, f.feeFunction,
|
||||
f.taxAmount, f.taxPercentage,
|
||||
f.includeQuantity, f.quantityUnit,
|
||||
f.isRequired, f.orderNumber
|
||||
from Fees f
|
||||
left join FeeCategories c on f.feeCategoryId = c.feeCategoryId
|
||||
left join OccupancyTypes o on f.occupancyTypeId = o.occupancyTypeId
|
||||
left join LotTypes l on f.lotTypeId = l.lotTypeId
|
||||
where f.recordDelete_timeMillis is null
|
||||
and f.feeId = ?`)
|
||||
.get(feeId);
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
|
|
|
|||
|
|
@ -1,44 +1,44 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
|
||||
export function getFee(
|
||||
feeId: number | string,
|
||||
connectedDatabase?: sqlite.Database
|
||||
feeId: number | string,
|
||||
connectedDatabase?: sqlite.Database
|
||||
): recordTypes.Fee {
|
||||
const database =
|
||||
connectedDatabase ||
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const database =
|
||||
connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
})
|
||||
|
||||
const fee = database
|
||||
.prepare(
|
||||
`select f.feeId,
|
||||
f.feeCategoryId, c.feeCategory,
|
||||
f.feeName, f.feeDescription,
|
||||
f.occupancyTypeId, o.occupancyType,
|
||||
f.lotTypeId, l.lotType,
|
||||
ifnull(f.feeAmount, 0) as feeAmount, f.feeFunction,
|
||||
f.taxAmount, f.taxPercentage,
|
||||
f.includeQuantity, f.quantityUnit,
|
||||
f.isRequired, f.orderNumber
|
||||
from Fees f
|
||||
left join FeeCategories c on f.feeCategoryId = c.feeCategoryId
|
||||
left join OccupancyTypes o on f.occupancyTypeId = o.occupancyTypeId
|
||||
left join LotTypes l on f.lotTypeId = l.lotTypeId
|
||||
where f.recordDelete_timeMillis is null
|
||||
and f.feeId = ?`
|
||||
)
|
||||
.get(feeId);
|
||||
const fee = database
|
||||
.prepare(
|
||||
`select f.feeId,
|
||||
f.feeCategoryId, c.feeCategory,
|
||||
f.feeName, f.feeDescription,
|
||||
f.occupancyTypeId, o.occupancyType,
|
||||
f.lotTypeId, l.lotType,
|
||||
ifnull(f.feeAmount, 0) as feeAmount, f.feeFunction,
|
||||
f.taxAmount, f.taxPercentage,
|
||||
f.includeQuantity, f.quantityUnit,
|
||||
f.isRequired, f.orderNumber
|
||||
from Fees f
|
||||
left join FeeCategories c on f.feeCategoryId = c.feeCategoryId
|
||||
left join OccupancyTypes o on f.occupancyTypeId = o.occupancyTypeId
|
||||
left join LotTypes l on f.lotTypeId = l.lotTypeId
|
||||
where f.recordDelete_timeMillis is null
|
||||
and f.feeId = ?`
|
||||
)
|
||||
.get(feeId)
|
||||
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
}
|
||||
if (!connectedDatabase) {
|
||||
database.close()
|
||||
}
|
||||
|
||||
return fee;
|
||||
return fee
|
||||
}
|
||||
|
||||
export default getFee;
|
||||
export default getFee
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes';
|
||||
interface GetFeeCategoriesFilters {
|
||||
occupancyTypeId?: number | string;
|
||||
lotTypeId?: number | string;
|
||||
|
|
|
|||
|
|
@ -1,41 +1,42 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { getFees } from "./getFees.js";
|
||||
import { updateRecordOrderNumber } from "./updateRecordOrderNumber.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
import { getFees } from './getFees.js';
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
export function getFeeCategories(filters, options) {
|
||||
const updateOrderNumbers = !(filters.lotTypeId || filters.occupancyTypeId) && options.includeFees;
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: !updateOrderNumbers
|
||||
});
|
||||
let sqlWhereClause = " where recordDelete_timeMillis is null";
|
||||
let sqlWhereClause = ' where recordDelete_timeMillis is null';
|
||||
const sqlParameters = [];
|
||||
if (filters.occupancyTypeId) {
|
||||
sqlWhereClause +=
|
||||
" and feeCategoryId in (" +
|
||||
"select feeCategoryId from Fees" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" and (occupancyTypeId is null or occupancyTypeId = ?))";
|
||||
' and feeCategoryId in (' +
|
||||
'select feeCategoryId from Fees' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
' and (occupancyTypeId is null or occupancyTypeId = ?))';
|
||||
sqlParameters.push(filters.occupancyTypeId);
|
||||
}
|
||||
if (filters.lotTypeId) {
|
||||
sqlWhereClause +=
|
||||
" and feeCategoryId in (" +
|
||||
"select feeCategoryId from Fees" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" and (lotTypeId is null or lotTypeId = ?))";
|
||||
' and feeCategoryId in (' +
|
||||
'select feeCategoryId from Fees' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
' and (lotTypeId is null or lotTypeId = ?))';
|
||||
sqlParameters.push(filters.lotTypeId);
|
||||
}
|
||||
const feeCategories = database
|
||||
.prepare("select feeCategoryId, feeCategory, orderNumber" +
|
||||
" from FeeCategories" +
|
||||
.prepare('select feeCategoryId, feeCategory, orderNumber' +
|
||||
' from FeeCategories' +
|
||||
sqlWhereClause +
|
||||
" order by orderNumber, feeCategory")
|
||||
' order by orderNumber, feeCategory')
|
||||
.all(sqlParameters);
|
||||
if (options.includeFees) {
|
||||
let expectedOrderNumber = 0;
|
||||
for (const feeCategory of feeCategories) {
|
||||
if (updateOrderNumbers && feeCategory.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber("FeeCategories", feeCategory.feeCategoryId, expectedOrderNumber, database);
|
||||
if (updateOrderNumbers &&
|
||||
feeCategory.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber('FeeCategories', feeCategory.feeCategoryId, expectedOrderNumber, database);
|
||||
feeCategory.orderNumber = expectedOrderNumber;
|
||||
}
|
||||
expectedOrderNumber += 1;
|
||||
|
|
|
|||
|
|
@ -1,88 +1,92 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import { getFees } from "./getFees.js";
|
||||
import { updateRecordOrderNumber } from "./updateRecordOrderNumber.js";
|
||||
import { getFees } from './getFees.js'
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
|
||||
interface GetFeeCategoriesFilters {
|
||||
occupancyTypeId?: number | string;
|
||||
lotTypeId?: number | string;
|
||||
occupancyTypeId?: number | string
|
||||
lotTypeId?: number | string
|
||||
}
|
||||
|
||||
interface GetFeeCategoriesOptions {
|
||||
includeFees?: boolean;
|
||||
includeFees?: boolean
|
||||
}
|
||||
|
||||
export function getFeeCategories(
|
||||
filters: GetFeeCategoriesFilters,
|
||||
options: GetFeeCategoriesOptions
|
||||
filters: GetFeeCategoriesFilters,
|
||||
options: GetFeeCategoriesOptions
|
||||
): recordTypes.FeeCategory[] {
|
||||
const updateOrderNumbers = !(filters.lotTypeId || filters.occupancyTypeId) && options.includeFees;
|
||||
const updateOrderNumbers =
|
||||
!(filters.lotTypeId || filters.occupancyTypeId) && options.includeFees
|
||||
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: !updateOrderNumbers
|
||||
});
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: !updateOrderNumbers
|
||||
})
|
||||
|
||||
let sqlWhereClause = " where recordDelete_timeMillis is null";
|
||||
let sqlWhereClause = ' where recordDelete_timeMillis is null'
|
||||
|
||||
const sqlParameters: unknown[] = [];
|
||||
const sqlParameters: unknown[] = []
|
||||
|
||||
if (filters.occupancyTypeId) {
|
||||
sqlWhereClause +=
|
||||
" and feeCategoryId in (" +
|
||||
"select feeCategoryId from Fees" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" and (occupancyTypeId is null or occupancyTypeId = ?))";
|
||||
if (filters.occupancyTypeId) {
|
||||
sqlWhereClause +=
|
||||
' and feeCategoryId in (' +
|
||||
'select feeCategoryId from Fees' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
' and (occupancyTypeId is null or occupancyTypeId = ?))'
|
||||
|
||||
sqlParameters.push(filters.occupancyTypeId);
|
||||
}
|
||||
sqlParameters.push(filters.occupancyTypeId)
|
||||
}
|
||||
|
||||
if (filters.lotTypeId) {
|
||||
sqlWhereClause +=
|
||||
" and feeCategoryId in (" +
|
||||
"select feeCategoryId from Fees" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" and (lotTypeId is null or lotTypeId = ?))";
|
||||
if (filters.lotTypeId) {
|
||||
sqlWhereClause +=
|
||||
' and feeCategoryId in (' +
|
||||
'select feeCategoryId from Fees' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
' and (lotTypeId is null or lotTypeId = ?))'
|
||||
|
||||
sqlParameters.push(filters.lotTypeId);
|
||||
}
|
||||
sqlParameters.push(filters.lotTypeId)
|
||||
}
|
||||
|
||||
const feeCategories: recordTypes.FeeCategory[] = database
|
||||
.prepare(
|
||||
"select feeCategoryId, feeCategory, orderNumber" +
|
||||
" from FeeCategories" +
|
||||
sqlWhereClause +
|
||||
" order by orderNumber, feeCategory"
|
||||
const feeCategories: recordTypes.FeeCategory[] = database
|
||||
.prepare(
|
||||
'select feeCategoryId, feeCategory, orderNumber' +
|
||||
' from FeeCategories' +
|
||||
sqlWhereClause +
|
||||
' order by orderNumber, feeCategory'
|
||||
)
|
||||
.all(sqlParameters)
|
||||
|
||||
if (options.includeFees) {
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
for (const feeCategory of feeCategories) {
|
||||
if (
|
||||
updateOrderNumbers &&
|
||||
feeCategory.orderNumber !== expectedOrderNumber
|
||||
) {
|
||||
updateRecordOrderNumber(
|
||||
'FeeCategories',
|
||||
feeCategory.feeCategoryId,
|
||||
expectedOrderNumber,
|
||||
database
|
||||
)
|
||||
.all(sqlParameters);
|
||||
|
||||
if (options.includeFees) {
|
||||
let expectedOrderNumber = 0;
|
||||
feeCategory.orderNumber = expectedOrderNumber
|
||||
}
|
||||
|
||||
for (const feeCategory of feeCategories) {
|
||||
if (updateOrderNumbers && feeCategory.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber(
|
||||
"FeeCategories",
|
||||
feeCategory.feeCategoryId,
|
||||
expectedOrderNumber,
|
||||
database
|
||||
);
|
||||
expectedOrderNumber += 1
|
||||
|
||||
feeCategory.orderNumber = expectedOrderNumber;
|
||||
}
|
||||
|
||||
expectedOrderNumber += 1;
|
||||
|
||||
feeCategory.fees = getFees(feeCategory.feeCategoryId, filters, database);
|
||||
}
|
||||
feeCategory.fees = getFees(feeCategory.feeCategoryId, filters, database)
|
||||
}
|
||||
}
|
||||
|
||||
database.close();
|
||||
database.close()
|
||||
|
||||
return feeCategories;
|
||||
return feeCategories
|
||||
}
|
||||
|
||||
export default getFeeCategories;
|
||||
export default getFeeCategories
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import type * as recordTypes from '../../types/recordTypes';
|
||||
interface GetFeesFilters {
|
||||
occupancyTypeId?: number | string;
|
||||
lotTypeId?: number | string;
|
||||
|
|
|
|||
|
|
@ -1,41 +1,42 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { updateRecordOrderNumber } from "./updateRecordOrderNumber.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
export function getFees(feeCategoryId, additionalFilters, connectedDatabase) {
|
||||
const updateOrderNumbers = !(additionalFilters.lotTypeId || additionalFilters.occupancyTypeId);
|
||||
const database = connectedDatabase ||
|
||||
const database = connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: !updateOrderNumbers
|
||||
});
|
||||
let sqlWhereClause = " where f.recordDelete_timeMillis is null and f.feeCategoryId = ?";
|
||||
let sqlWhereClause = ' where f.recordDelete_timeMillis is null and f.feeCategoryId = ?';
|
||||
const sqlParameters = [feeCategoryId];
|
||||
if (additionalFilters.occupancyTypeId) {
|
||||
sqlWhereClause += " and (f.occupancyTypeId is null or f.occupancyTypeId = ?)";
|
||||
sqlWhereClause +=
|
||||
' and (f.occupancyTypeId is null or f.occupancyTypeId = ?)';
|
||||
sqlParameters.push(additionalFilters.occupancyTypeId);
|
||||
}
|
||||
if (additionalFilters.lotTypeId) {
|
||||
sqlWhereClause += " and (f.lotTypeId is null or f.lotTypeId = ?)";
|
||||
sqlWhereClause += ' and (f.lotTypeId is null or f.lotTypeId = ?)';
|
||||
sqlParameters.push(additionalFilters.lotTypeId);
|
||||
}
|
||||
const fees = database
|
||||
.prepare("select f.feeId, f.feeName, f.feeDescription," +
|
||||
" f.occupancyTypeId, o.occupancyType," +
|
||||
" f.lotTypeId, l.lotType," +
|
||||
" ifnull(f.feeAmount, 0) as feeAmount, f.feeFunction," +
|
||||
" f.taxAmount, f.taxPercentage," +
|
||||
" f.includeQuantity, f.quantityUnit," +
|
||||
" f.isRequired, f.orderNumber" +
|
||||
" from Fees f" +
|
||||
" left join OccupancyTypes o on f.occupancyTypeId = o.occupancyTypeId" +
|
||||
" left join LotTypes l on f.lotTypeId = l.lotTypeId" +
|
||||
.prepare('select f.feeId, f.feeName, f.feeDescription,' +
|
||||
' f.occupancyTypeId, o.occupancyType,' +
|
||||
' f.lotTypeId, l.lotType,' +
|
||||
' ifnull(f.feeAmount, 0) as feeAmount, f.feeFunction,' +
|
||||
' f.taxAmount, f.taxPercentage,' +
|
||||
' f.includeQuantity, f.quantityUnit,' +
|
||||
' f.isRequired, f.orderNumber' +
|
||||
' from Fees f' +
|
||||
' left join OccupancyTypes o on f.occupancyTypeId = o.occupancyTypeId' +
|
||||
' left join LotTypes l on f.lotTypeId = l.lotTypeId' +
|
||||
sqlWhereClause +
|
||||
" order by f.orderNumber, f.feeName")
|
||||
' order by f.orderNumber, f.feeName')
|
||||
.all(sqlParameters);
|
||||
if (updateOrderNumbers) {
|
||||
let expectedOrderNumber = 0;
|
||||
for (const fee of fees) {
|
||||
if (fee.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber("Fees", fee.feeId, expectedOrderNumber, database);
|
||||
updateRecordOrderNumber('Fees', fee.feeId, expectedOrderNumber, database);
|
||||
fee.orderNumber = expectedOrderNumber;
|
||||
}
|
||||
expectedOrderNumber += 1;
|
||||
|
|
|
|||
|
|
@ -1,80 +1,89 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import { updateRecordOrderNumber } from "./updateRecordOrderNumber.js";
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
|
||||
interface GetFeesFilters {
|
||||
occupancyTypeId?: number | string;
|
||||
lotTypeId?: number | string;
|
||||
occupancyTypeId?: number | string
|
||||
lotTypeId?: number | string
|
||||
}
|
||||
|
||||
export function getFees(
|
||||
feeCategoryId: number,
|
||||
additionalFilters: GetFeesFilters,
|
||||
connectedDatabase?: sqlite.Database
|
||||
feeCategoryId: number,
|
||||
additionalFilters: GetFeesFilters,
|
||||
connectedDatabase?: sqlite.Database
|
||||
): recordTypes.Fee[] {
|
||||
const updateOrderNumbers = !(additionalFilters.lotTypeId || additionalFilters.occupancyTypeId);
|
||||
const updateOrderNumbers = !(
|
||||
additionalFilters.lotTypeId || additionalFilters.occupancyTypeId
|
||||
)
|
||||
|
||||
const database =
|
||||
connectedDatabase ||
|
||||
sqlite(databasePath, {
|
||||
readonly: !updateOrderNumbers
|
||||
});
|
||||
const database =
|
||||
connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: !updateOrderNumbers
|
||||
})
|
||||
|
||||
let sqlWhereClause = " where f.recordDelete_timeMillis is null and f.feeCategoryId = ?";
|
||||
let sqlWhereClause =
|
||||
' where f.recordDelete_timeMillis is null and f.feeCategoryId = ?'
|
||||
|
||||
const sqlParameters: unknown[] = [feeCategoryId];
|
||||
const sqlParameters: unknown[] = [feeCategoryId]
|
||||
|
||||
if (additionalFilters.occupancyTypeId) {
|
||||
sqlWhereClause += " and (f.occupancyTypeId is null or f.occupancyTypeId = ?)";
|
||||
if (additionalFilters.occupancyTypeId) {
|
||||
sqlWhereClause +=
|
||||
' and (f.occupancyTypeId is null or f.occupancyTypeId = ?)'
|
||||
|
||||
sqlParameters.push(additionalFilters.occupancyTypeId);
|
||||
}
|
||||
sqlParameters.push(additionalFilters.occupancyTypeId)
|
||||
}
|
||||
|
||||
if (additionalFilters.lotTypeId) {
|
||||
sqlWhereClause += " and (f.lotTypeId is null or f.lotTypeId = ?)";
|
||||
if (additionalFilters.lotTypeId) {
|
||||
sqlWhereClause += ' and (f.lotTypeId is null or f.lotTypeId = ?)'
|
||||
|
||||
sqlParameters.push(additionalFilters.lotTypeId);
|
||||
}
|
||||
sqlParameters.push(additionalFilters.lotTypeId)
|
||||
}
|
||||
|
||||
const fees = database
|
||||
.prepare(
|
||||
"select f.feeId, f.feeName, f.feeDescription," +
|
||||
" f.occupancyTypeId, o.occupancyType," +
|
||||
" f.lotTypeId, l.lotType," +
|
||||
" ifnull(f.feeAmount, 0) as feeAmount, f.feeFunction," +
|
||||
" f.taxAmount, f.taxPercentage," +
|
||||
" f.includeQuantity, f.quantityUnit," +
|
||||
" f.isRequired, f.orderNumber" +
|
||||
" from Fees f" +
|
||||
" left join OccupancyTypes o on f.occupancyTypeId = o.occupancyTypeId" +
|
||||
" left join LotTypes l on f.lotTypeId = l.lotTypeId" +
|
||||
sqlWhereClause +
|
||||
" order by f.orderNumber, f.feeName"
|
||||
const fees = database
|
||||
.prepare(
|
||||
'select f.feeId, f.feeName, f.feeDescription,' +
|
||||
' f.occupancyTypeId, o.occupancyType,' +
|
||||
' f.lotTypeId, l.lotType,' +
|
||||
' ifnull(f.feeAmount, 0) as feeAmount, f.feeFunction,' +
|
||||
' f.taxAmount, f.taxPercentage,' +
|
||||
' f.includeQuantity, f.quantityUnit,' +
|
||||
' f.isRequired, f.orderNumber' +
|
||||
' from Fees f' +
|
||||
' left join OccupancyTypes o on f.occupancyTypeId = o.occupancyTypeId' +
|
||||
' left join LotTypes l on f.lotTypeId = l.lotTypeId' +
|
||||
sqlWhereClause +
|
||||
' order by f.orderNumber, f.feeName'
|
||||
)
|
||||
.all(sqlParameters)
|
||||
|
||||
if (updateOrderNumbers) {
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
for (const fee of fees) {
|
||||
if (fee.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber(
|
||||
'Fees',
|
||||
fee.feeId,
|
||||
expectedOrderNumber,
|
||||
database
|
||||
)
|
||||
.all(sqlParameters);
|
||||
fee.orderNumber = expectedOrderNumber
|
||||
}
|
||||
|
||||
if (updateOrderNumbers) {
|
||||
let expectedOrderNumber = 0;
|
||||
|
||||
for (const fee of fees) {
|
||||
if (fee.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber("Fees", fee.feeId, expectedOrderNumber, database);
|
||||
fee.orderNumber = expectedOrderNumber;
|
||||
}
|
||||
|
||||
expectedOrderNumber += 1;
|
||||
}
|
||||
expectedOrderNumber += 1
|
||||
}
|
||||
}
|
||||
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
}
|
||||
if (!connectedDatabase) {
|
||||
database.close()
|
||||
}
|
||||
|
||||
return fees;
|
||||
return fees
|
||||
}
|
||||
|
||||
export default getFees;
|
||||
export default getFees
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import type * as recordTypes from '../../types/recordTypes';
|
||||
export declare function getLotComments(lotId: number | string, connectedDatabase?: sqlite.Database): recordTypes.LotComment[];
|
||||
export default getLotComments;
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { dateIntegerToString, timeIntegerToString } from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
import { dateIntegerToString, timeIntegerToString } from '@cityssm/expressjs-server-js/dateTimeFns.js';
|
||||
export function getLotComments(lotId, connectedDatabase) {
|
||||
const database = connectedDatabase ||
|
||||
const database = connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
database.function("userFn_dateIntegerToString", dateIntegerToString);
|
||||
database.function("userFn_timeIntegerToString", timeIntegerToString);
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
||||
database.function('userFn_timeIntegerToString', timeIntegerToString);
|
||||
const lotComments = database
|
||||
.prepare(`select lotCommentId,
|
||||
lotCommentDate, userFn_dateIntegerToString(lotCommentDate) as lotCommentDateString,
|
||||
lotCommentTime, userFn_timeIntegerToString(lotCommentTime) as lotCommentTimeString,
|
||||
lotComment,
|
||||
recordCreate_userName, recordUpdate_userName
|
||||
from LotComments
|
||||
where recordDelete_timeMillis is null
|
||||
and lotId = ?
|
||||
order by lotCommentDate desc, lotCommentTime desc, lotCommentId desc`)
|
||||
lotCommentDate, userFn_dateIntegerToString(lotCommentDate) as lotCommentDateString,
|
||||
lotCommentTime, userFn_timeIntegerToString(lotCommentTime) as lotCommentTimeString,
|
||||
lotComment,
|
||||
recordCreate_userName, recordUpdate_userName
|
||||
from LotComments
|
||||
where recordDelete_timeMillis is null
|
||||
and lotId = ?
|
||||
order by lotCommentDate desc, lotCommentTime desc, lotCommentId desc`)
|
||||
.all(lotId);
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
|
|
|
|||
|
|
@ -1,46 +1,46 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import {
|
||||
dateIntegerToString,
|
||||
timeIntegerToString
|
||||
} from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||
dateIntegerToString,
|
||||
timeIntegerToString
|
||||
} from '@cityssm/expressjs-server-js/dateTimeFns.js'
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
|
||||
export function getLotComments(
|
||||
lotId: number | string,
|
||||
connectedDatabase?: sqlite.Database
|
||||
lotId: number | string,
|
||||
connectedDatabase?: sqlite.Database
|
||||
): recordTypes.LotComment[] {
|
||||
const database =
|
||||
connectedDatabase ||
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const database =
|
||||
connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
})
|
||||
|
||||
database.function("userFn_dateIntegerToString", dateIntegerToString);
|
||||
database.function("userFn_timeIntegerToString", timeIntegerToString);
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
database.function('userFn_timeIntegerToString', timeIntegerToString)
|
||||
|
||||
const lotComments = database
|
||||
.prepare(
|
||||
`select lotCommentId,
|
||||
lotCommentDate, userFn_dateIntegerToString(lotCommentDate) as lotCommentDateString,
|
||||
lotCommentTime, userFn_timeIntegerToString(lotCommentTime) as lotCommentTimeString,
|
||||
lotComment,
|
||||
recordCreate_userName, recordUpdate_userName
|
||||
from LotComments
|
||||
where recordDelete_timeMillis is null
|
||||
and lotId = ?
|
||||
order by lotCommentDate desc, lotCommentTime desc, lotCommentId desc`
|
||||
)
|
||||
.all(lotId);
|
||||
const lotComments = database
|
||||
.prepare(
|
||||
`select lotCommentId,
|
||||
lotCommentDate, userFn_dateIntegerToString(lotCommentDate) as lotCommentDateString,
|
||||
lotCommentTime, userFn_timeIntegerToString(lotCommentTime) as lotCommentTimeString,
|
||||
lotComment,
|
||||
recordCreate_userName, recordUpdate_userName
|
||||
from LotComments
|
||||
where recordDelete_timeMillis is null
|
||||
and lotId = ?
|
||||
order by lotCommentDate desc, lotCommentTime desc, lotCommentId desc`
|
||||
)
|
||||
.all(lotId)
|
||||
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
}
|
||||
if (!connectedDatabase) {
|
||||
database.close()
|
||||
}
|
||||
|
||||
return lotComments;
|
||||
return lotComments
|
||||
}
|
||||
|
||||
export default getLotComments;
|
||||
export default getLotComments
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import type * as recordTypes from '../../types/recordTypes';
|
||||
export declare function getLotFields(lotId: number | string, connectedDatabase?: sqlite.Database): recordTypes.LotField[];
|
||||
export default getLotFields;
|
||||
|
|
|
|||
|
|
@ -1,37 +1,37 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
export function getLotFields(lotId, connectedDatabase) {
|
||||
const database = connectedDatabase ||
|
||||
const database = connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const lotFields = database
|
||||
.prepare(`select l.lotId, l.lotTypeFieldId,
|
||||
l.lotFieldValue,
|
||||
f.lotTypeField, f.lotTypeFieldValues,
|
||||
f.isRequired, f.pattern, f.minimumLength, f.maximumLength,
|
||||
f.orderNumber, t.orderNumber as lotTypeOrderNumber
|
||||
from LotFields l
|
||||
left join LotTypeFields f on l.lotTypeFieldId = f.lotTypeFieldId
|
||||
left join LotTypes t on f.lotTypeId = t.lotTypeId
|
||||
where l.recordDelete_timeMillis is null
|
||||
and l.lotId = ?
|
||||
|
||||
union
|
||||
|
||||
select ? as lotId, f.lotTypeFieldId,
|
||||
'' as lotFieldValue,
|
||||
f.lotTypeField, f.lotTypeFieldValues,
|
||||
f.isRequired, f.pattern, f.minimumLength, f.maximumLength,
|
||||
f.orderNumber, t.orderNumber as lotTypeOrderNumber
|
||||
from LotTypeFields f
|
||||
left join LotTypes t on f.lotTypeId = t.lotTypeId
|
||||
where f.recordDelete_timeMillis is null
|
||||
and (
|
||||
f.lotTypeId is null
|
||||
or f.lotTypeId in (select lotTypeId from Lots where lotId = ?))
|
||||
and f.lotTypeFieldId not in (select lotTypeFieldId from LotFields where lotId = ? and recordDelete_timeMillis is null)
|
||||
order by lotTypeOrderNumber, f.orderNumber, f.lotTypeField`)
|
||||
l.lotFieldValue,
|
||||
f.lotTypeField, f.lotTypeFieldValues,
|
||||
f.isRequired, f.pattern, f.minimumLength, f.maximumLength,
|
||||
f.orderNumber, t.orderNumber as lotTypeOrderNumber
|
||||
from LotFields l
|
||||
left join LotTypeFields f on l.lotTypeFieldId = f.lotTypeFieldId
|
||||
left join LotTypes t on f.lotTypeId = t.lotTypeId
|
||||
where l.recordDelete_timeMillis is null
|
||||
and l.lotId = ?
|
||||
|
||||
union
|
||||
|
||||
select ? as lotId, f.lotTypeFieldId,
|
||||
'' as lotFieldValue,
|
||||
f.lotTypeField, f.lotTypeFieldValues,
|
||||
f.isRequired, f.pattern, f.minimumLength, f.maximumLength,
|
||||
f.orderNumber, t.orderNumber as lotTypeOrderNumber
|
||||
from LotTypeFields f
|
||||
left join LotTypes t on f.lotTypeId = t.lotTypeId
|
||||
where f.recordDelete_timeMillis is null
|
||||
and (
|
||||
f.lotTypeId is null
|
||||
or f.lotTypeId in (select lotTypeId from Lots where lotId = ?))
|
||||
and f.lotTypeFieldId not in (select lotTypeFieldId from LotFields where lotId = ? and recordDelete_timeMillis is null)
|
||||
order by lotTypeOrderNumber, f.orderNumber, f.lotTypeField`)
|
||||
.all(lotId, lotId, lotId, lotId);
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
|
|
|
|||
|
|
@ -1,55 +1,55 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
|
||||
export function getLotFields(
|
||||
lotId: number | string,
|
||||
connectedDatabase?: sqlite.Database
|
||||
lotId: number | string,
|
||||
connectedDatabase?: sqlite.Database
|
||||
): recordTypes.LotField[] {
|
||||
const database =
|
||||
connectedDatabase ||
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const database =
|
||||
connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
})
|
||||
|
||||
const lotFields: recordTypes.LotField[] = database
|
||||
.prepare(
|
||||
`select l.lotId, l.lotTypeFieldId,
|
||||
l.lotFieldValue,
|
||||
f.lotTypeField, f.lotTypeFieldValues,
|
||||
f.isRequired, f.pattern, f.minimumLength, f.maximumLength,
|
||||
f.orderNumber, t.orderNumber as lotTypeOrderNumber
|
||||
from LotFields l
|
||||
left join LotTypeFields f on l.lotTypeFieldId = f.lotTypeFieldId
|
||||
left join LotTypes t on f.lotTypeId = t.lotTypeId
|
||||
where l.recordDelete_timeMillis is null
|
||||
and l.lotId = ?
|
||||
|
||||
union
|
||||
|
||||
select ? as lotId, f.lotTypeFieldId,
|
||||
'' as lotFieldValue,
|
||||
f.lotTypeField, f.lotTypeFieldValues,
|
||||
f.isRequired, f.pattern, f.minimumLength, f.maximumLength,
|
||||
f.orderNumber, t.orderNumber as lotTypeOrderNumber
|
||||
from LotTypeFields f
|
||||
left join LotTypes t on f.lotTypeId = t.lotTypeId
|
||||
where f.recordDelete_timeMillis is null
|
||||
and (
|
||||
f.lotTypeId is null
|
||||
or f.lotTypeId in (select lotTypeId from Lots where lotId = ?))
|
||||
and f.lotTypeFieldId not in (select lotTypeFieldId from LotFields where lotId = ? and recordDelete_timeMillis is null)
|
||||
order by lotTypeOrderNumber, f.orderNumber, f.lotTypeField`
|
||||
)
|
||||
.all(lotId, lotId, lotId, lotId);
|
||||
const lotFields: recordTypes.LotField[] = database
|
||||
.prepare(
|
||||
`select l.lotId, l.lotTypeFieldId,
|
||||
l.lotFieldValue,
|
||||
f.lotTypeField, f.lotTypeFieldValues,
|
||||
f.isRequired, f.pattern, f.minimumLength, f.maximumLength,
|
||||
f.orderNumber, t.orderNumber as lotTypeOrderNumber
|
||||
from LotFields l
|
||||
left join LotTypeFields f on l.lotTypeFieldId = f.lotTypeFieldId
|
||||
left join LotTypes t on f.lotTypeId = t.lotTypeId
|
||||
where l.recordDelete_timeMillis is null
|
||||
and l.lotId = ?
|
||||
|
||||
union
|
||||
|
||||
select ? as lotId, f.lotTypeFieldId,
|
||||
'' as lotFieldValue,
|
||||
f.lotTypeField, f.lotTypeFieldValues,
|
||||
f.isRequired, f.pattern, f.minimumLength, f.maximumLength,
|
||||
f.orderNumber, t.orderNumber as lotTypeOrderNumber
|
||||
from LotTypeFields f
|
||||
left join LotTypes t on f.lotTypeId = t.lotTypeId
|
||||
where f.recordDelete_timeMillis is null
|
||||
and (
|
||||
f.lotTypeId is null
|
||||
or f.lotTypeId in (select lotTypeId from Lots where lotId = ?))
|
||||
and f.lotTypeFieldId not in (select lotTypeFieldId from LotFields where lotId = ? and recordDelete_timeMillis is null)
|
||||
order by lotTypeOrderNumber, f.orderNumber, f.lotTypeField`
|
||||
)
|
||||
.all(lotId, lotId, lotId, lotId)
|
||||
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
}
|
||||
if (!connectedDatabase) {
|
||||
database.close()
|
||||
}
|
||||
|
||||
return lotFields;
|
||||
return lotFields
|
||||
}
|
||||
|
||||
export default getLotFields;
|
||||
export default getLotFields
|
||||
|
|
|
|||
|
|
@ -15,18 +15,18 @@ export function getLotOccupancy(lotOccupancyId, connectedDatabase) {
|
|||
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
||||
const lotOccupancy = database
|
||||
.prepare(`select o.lotOccupancyId,
|
||||
o.occupancyTypeId, t.occupancyType,
|
||||
o.lotId, l.lotName, l.lotTypeId,
|
||||
l.mapId, m.mapName,
|
||||
o.occupancyStartDate, userFn_dateIntegerToString(o.occupancyStartDate) as occupancyStartDateString,
|
||||
o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString,
|
||||
o.recordUpdate_timeMillis
|
||||
from LotOccupancies o
|
||||
left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId
|
||||
left join Lots l on o.lotId = l.lotId
|
||||
left join Maps m on l.mapId = m.mapId
|
||||
where o.recordDelete_timeMillis is null
|
||||
and o.lotOccupancyId = ?`)
|
||||
o.occupancyTypeId, t.occupancyType,
|
||||
o.lotId, l.lotName, l.lotTypeId,
|
||||
l.mapId, m.mapName,
|
||||
o.occupancyStartDate, userFn_dateIntegerToString(o.occupancyStartDate) as occupancyStartDateString,
|
||||
o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString,
|
||||
o.recordUpdate_timeMillis
|
||||
from LotOccupancies o
|
||||
left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId
|
||||
left join Lots l on o.lotId = l.lotId
|
||||
left join Maps m on l.mapId = m.mapId
|
||||
where o.recordDelete_timeMillis is null
|
||||
and o.lotOccupancyId = ?`)
|
||||
.get(lotOccupancyId);
|
||||
if (lotOccupancy) {
|
||||
lotOccupancy.lotOccupancyFields = getLotOccupancyFields(lotOccupancyId, database);
|
||||
|
|
|
|||
|
|
@ -28,18 +28,18 @@ export function getLotOccupancy(
|
|||
const lotOccupancy: recordTypes.LotOccupancy | undefined = database
|
||||
.prepare(
|
||||
`select o.lotOccupancyId,
|
||||
o.occupancyTypeId, t.occupancyType,
|
||||
o.lotId, l.lotName, l.lotTypeId,
|
||||
l.mapId, m.mapName,
|
||||
o.occupancyStartDate, userFn_dateIntegerToString(o.occupancyStartDate) as occupancyStartDateString,
|
||||
o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString,
|
||||
o.recordUpdate_timeMillis
|
||||
from LotOccupancies o
|
||||
left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId
|
||||
left join Lots l on o.lotId = l.lotId
|
||||
left join Maps m on l.mapId = m.mapId
|
||||
where o.recordDelete_timeMillis is null
|
||||
and o.lotOccupancyId = ?`
|
||||
o.occupancyTypeId, t.occupancyType,
|
||||
o.lotId, l.lotName, l.lotTypeId,
|
||||
l.mapId, m.mapName,
|
||||
o.occupancyStartDate, userFn_dateIntegerToString(o.occupancyStartDate) as occupancyStartDateString,
|
||||
o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString,
|
||||
o.recordUpdate_timeMillis
|
||||
from LotOccupancies o
|
||||
left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId
|
||||
left join Lots l on o.lotId = l.lotId
|
||||
left join Maps m on l.mapId = m.mapId
|
||||
where o.recordDelete_timeMillis is null
|
||||
and o.lotOccupancyId = ?`
|
||||
)
|
||||
.get(lotOccupancyId)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import type * as recordTypes from '../../types/recordTypes';
|
||||
export declare function getLotOccupancyFees(lotOccupancyId: number | string, connectedDatabase?: sqlite.Database): recordTypes.LotOccupancyFee[];
|
||||
export default getLotOccupancyFees;
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
export function getLotOccupancyFees(lotOccupancyId, connectedDatabase) {
|
||||
const database = connectedDatabase ||
|
||||
const database = connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const lotOccupancyFees = database
|
||||
.prepare(`select o.lotOccupancyId, o.feeId,
|
||||
c.feeCategory, f.feeName,
|
||||
f.includeQuantity, o.feeAmount, o.taxAmount, o.quantity
|
||||
from LotOccupancyFees o
|
||||
left join Fees f on o.feeId = f.feeId
|
||||
left join FeeCategories c on f.feeCategoryId = c.feeCategoryId
|
||||
where o.recordDelete_timeMillis is null
|
||||
and o.lotOccupancyId = ?
|
||||
order by o.recordCreate_timeMillis`)
|
||||
c.feeCategory, f.feeName,
|
||||
f.includeQuantity, o.feeAmount, o.taxAmount, o.quantity
|
||||
from LotOccupancyFees o
|
||||
left join Fees f on o.feeId = f.feeId
|
||||
left join FeeCategories c on f.feeCategoryId = c.feeCategoryId
|
||||
where o.recordDelete_timeMillis is null
|
||||
and o.lotOccupancyId = ?
|
||||
order by o.recordCreate_timeMillis`)
|
||||
.all(lotOccupancyId);
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
|
|
|
|||
|
|
@ -1,38 +1,38 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
|
||||
export function getLotOccupancyFees(
|
||||
lotOccupancyId: number | string,
|
||||
connectedDatabase?: sqlite.Database
|
||||
lotOccupancyId: number | string,
|
||||
connectedDatabase?: sqlite.Database
|
||||
): recordTypes.LotOccupancyFee[] {
|
||||
const database =
|
||||
connectedDatabase ||
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const database =
|
||||
connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
})
|
||||
|
||||
const lotOccupancyFees: recordTypes.LotOccupancyFee[] = database
|
||||
.prepare(
|
||||
`select o.lotOccupancyId, o.feeId,
|
||||
c.feeCategory, f.feeName,
|
||||
f.includeQuantity, o.feeAmount, o.taxAmount, o.quantity
|
||||
from LotOccupancyFees o
|
||||
left join Fees f on o.feeId = f.feeId
|
||||
left join FeeCategories c on f.feeCategoryId = c.feeCategoryId
|
||||
where o.recordDelete_timeMillis is null
|
||||
and o.lotOccupancyId = ?
|
||||
order by o.recordCreate_timeMillis`
|
||||
)
|
||||
.all(lotOccupancyId);
|
||||
const lotOccupancyFees: recordTypes.LotOccupancyFee[] = database
|
||||
.prepare(
|
||||
`select o.lotOccupancyId, o.feeId,
|
||||
c.feeCategory, f.feeName,
|
||||
f.includeQuantity, o.feeAmount, o.taxAmount, o.quantity
|
||||
from LotOccupancyFees o
|
||||
left join Fees f on o.feeId = f.feeId
|
||||
left join FeeCategories c on f.feeCategoryId = c.feeCategoryId
|
||||
where o.recordDelete_timeMillis is null
|
||||
and o.lotOccupancyId = ?
|
||||
order by o.recordCreate_timeMillis`
|
||||
)
|
||||
.all(lotOccupancyId)
|
||||
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
}
|
||||
if (!connectedDatabase) {
|
||||
database.close()
|
||||
}
|
||||
|
||||
return lotOccupancyFees;
|
||||
return lotOccupancyFees
|
||||
}
|
||||
|
||||
export default getLotOccupancyFees;
|
||||
export default getLotOccupancyFees
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import type * as recordTypes from '../../types/recordTypes';
|
||||
export declare function getLotOccupancyFields(lotOccupancyId: number | string, connectedDatabase?: sqlite.Database): recordTypes.LotOccupancyField[];
|
||||
export default getLotOccupancyFields;
|
||||
|
|
|
|||
|
|
@ -1,34 +1,34 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
export function getLotOccupancyFields(lotOccupancyId, connectedDatabase) {
|
||||
const database = connectedDatabase ||
|
||||
const database = connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const lotOccupancyFields = database
|
||||
.prepare(`select o.lotOccupancyId, o.occupancyTypeFieldId,
|
||||
o.lotOccupancyFieldValue, f.occupancyTypeField, f.occupancyTypeFieldValues,
|
||||
f.isRequired, f.pattern, f.minimumLength, f.maximumLength,
|
||||
f.orderNumber, t.orderNumber as occupancyTypeOrderNumber
|
||||
from LotOccupancyFields o
|
||||
left join OccupancyTypeFields f on o.occupancyTypeFieldId = f.occupancyTypeFieldId
|
||||
left join OccupancyTypes t on f.occupancyTypeId = t.occupancyTypeId
|
||||
where o.recordDelete_timeMillis is null
|
||||
and o.lotOccupancyId = ?
|
||||
|
||||
union
|
||||
|
||||
select ? as lotOccupancyId, f.occupancyTypeFieldId,
|
||||
'' as lotOccupancyFieldValue, f.occupancyTypeField, f.occupancyTypeFieldValues,
|
||||
f.isRequired, f.pattern, f.minimumLength, f.maximumLength,
|
||||
f.orderNumber, t.orderNumber as occupancyTypeOrderNumber
|
||||
from OccupancyTypeFields f
|
||||
left join OccupancyTypes t on f.occupancyTypeId = t.occupancyTypeId
|
||||
where f.recordDelete_timeMillis is null and (
|
||||
f.occupancyTypeId is null
|
||||
or f.occupancyTypeId in (select occupancyTypeId from LotOccupancies where lotOccupancyId = ?))
|
||||
and f.occupancyTypeFieldId not in (select occupancyTypeFieldId from LotOccupancyFields where lotOccupancyId = ? and recordDelete_timeMillis is null)
|
||||
order by occupancyTypeOrderNumber, f.orderNumber, f.occupancyTypeField`)
|
||||
o.lotOccupancyFieldValue, f.occupancyTypeField, f.occupancyTypeFieldValues,
|
||||
f.isRequired, f.pattern, f.minimumLength, f.maximumLength,
|
||||
f.orderNumber, t.orderNumber as occupancyTypeOrderNumber
|
||||
from LotOccupancyFields o
|
||||
left join OccupancyTypeFields f on o.occupancyTypeFieldId = f.occupancyTypeFieldId
|
||||
left join OccupancyTypes t on f.occupancyTypeId = t.occupancyTypeId
|
||||
where o.recordDelete_timeMillis is null
|
||||
and o.lotOccupancyId = ?
|
||||
|
||||
union
|
||||
|
||||
select ? as lotOccupancyId, f.occupancyTypeFieldId,
|
||||
'' as lotOccupancyFieldValue, f.occupancyTypeField, f.occupancyTypeFieldValues,
|
||||
f.isRequired, f.pattern, f.minimumLength, f.maximumLength,
|
||||
f.orderNumber, t.orderNumber as occupancyTypeOrderNumber
|
||||
from OccupancyTypeFields f
|
||||
left join OccupancyTypes t on f.occupancyTypeId = t.occupancyTypeId
|
||||
where f.recordDelete_timeMillis is null and (
|
||||
f.occupancyTypeId is null
|
||||
or f.occupancyTypeId in (select occupancyTypeId from LotOccupancies where lotOccupancyId = ?))
|
||||
and f.occupancyTypeFieldId not in (select occupancyTypeFieldId from LotOccupancyFields where lotOccupancyId = ? and recordDelete_timeMillis is null)
|
||||
order by occupancyTypeOrderNumber, f.orderNumber, f.occupancyTypeField`)
|
||||
.all(lotOccupancyId, lotOccupancyId, lotOccupancyId, lotOccupancyId);
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
|
|
|
|||
|
|
@ -1,52 +1,52 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
|
||||
export function getLotOccupancyFields(
|
||||
lotOccupancyId: number | string,
|
||||
connectedDatabase?: sqlite.Database
|
||||
lotOccupancyId: number | string,
|
||||
connectedDatabase?: sqlite.Database
|
||||
): recordTypes.LotOccupancyField[] {
|
||||
const database =
|
||||
connectedDatabase ||
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const database =
|
||||
connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
})
|
||||
|
||||
const lotOccupancyFields: recordTypes.LotOccupancyField[] = database
|
||||
.prepare(
|
||||
`select o.lotOccupancyId, o.occupancyTypeFieldId,
|
||||
o.lotOccupancyFieldValue, f.occupancyTypeField, f.occupancyTypeFieldValues,
|
||||
f.isRequired, f.pattern, f.minimumLength, f.maximumLength,
|
||||
f.orderNumber, t.orderNumber as occupancyTypeOrderNumber
|
||||
from LotOccupancyFields o
|
||||
left join OccupancyTypeFields f on o.occupancyTypeFieldId = f.occupancyTypeFieldId
|
||||
left join OccupancyTypes t on f.occupancyTypeId = t.occupancyTypeId
|
||||
where o.recordDelete_timeMillis is null
|
||||
and o.lotOccupancyId = ?
|
||||
|
||||
union
|
||||
|
||||
select ? as lotOccupancyId, f.occupancyTypeFieldId,
|
||||
'' as lotOccupancyFieldValue, f.occupancyTypeField, f.occupancyTypeFieldValues,
|
||||
f.isRequired, f.pattern, f.minimumLength, f.maximumLength,
|
||||
f.orderNumber, t.orderNumber as occupancyTypeOrderNumber
|
||||
from OccupancyTypeFields f
|
||||
left join OccupancyTypes t on f.occupancyTypeId = t.occupancyTypeId
|
||||
where f.recordDelete_timeMillis is null and (
|
||||
f.occupancyTypeId is null
|
||||
or f.occupancyTypeId in (select occupancyTypeId from LotOccupancies where lotOccupancyId = ?))
|
||||
and f.occupancyTypeFieldId not in (select occupancyTypeFieldId from LotOccupancyFields where lotOccupancyId = ? and recordDelete_timeMillis is null)
|
||||
order by occupancyTypeOrderNumber, f.orderNumber, f.occupancyTypeField`
|
||||
)
|
||||
.all(lotOccupancyId, lotOccupancyId, lotOccupancyId, lotOccupancyId);
|
||||
const lotOccupancyFields: recordTypes.LotOccupancyField[] = database
|
||||
.prepare(
|
||||
`select o.lotOccupancyId, o.occupancyTypeFieldId,
|
||||
o.lotOccupancyFieldValue, f.occupancyTypeField, f.occupancyTypeFieldValues,
|
||||
f.isRequired, f.pattern, f.minimumLength, f.maximumLength,
|
||||
f.orderNumber, t.orderNumber as occupancyTypeOrderNumber
|
||||
from LotOccupancyFields o
|
||||
left join OccupancyTypeFields f on o.occupancyTypeFieldId = f.occupancyTypeFieldId
|
||||
left join OccupancyTypes t on f.occupancyTypeId = t.occupancyTypeId
|
||||
where o.recordDelete_timeMillis is null
|
||||
and o.lotOccupancyId = ?
|
||||
|
||||
union
|
||||
|
||||
select ? as lotOccupancyId, f.occupancyTypeFieldId,
|
||||
'' as lotOccupancyFieldValue, f.occupancyTypeField, f.occupancyTypeFieldValues,
|
||||
f.isRequired, f.pattern, f.minimumLength, f.maximumLength,
|
||||
f.orderNumber, t.orderNumber as occupancyTypeOrderNumber
|
||||
from OccupancyTypeFields f
|
||||
left join OccupancyTypes t on f.occupancyTypeId = t.occupancyTypeId
|
||||
where f.recordDelete_timeMillis is null and (
|
||||
f.occupancyTypeId is null
|
||||
or f.occupancyTypeId in (select occupancyTypeId from LotOccupancies where lotOccupancyId = ?))
|
||||
and f.occupancyTypeFieldId not in (select occupancyTypeFieldId from LotOccupancyFields where lotOccupancyId = ? and recordDelete_timeMillis is null)
|
||||
order by occupancyTypeOrderNumber, f.orderNumber, f.occupancyTypeField`
|
||||
)
|
||||
.all(lotOccupancyId, lotOccupancyId, lotOccupancyId, lotOccupancyId)
|
||||
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
}
|
||||
if (!connectedDatabase) {
|
||||
database.close()
|
||||
}
|
||||
|
||||
return lotOccupancyFields;
|
||||
return lotOccupancyFields
|
||||
}
|
||||
|
||||
export default getLotOccupancyFields;
|
||||
export default getLotOccupancyFields
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import type * as recordTypes from '../../types/recordTypes';
|
||||
export declare function getLotOccupancyOccupants(lotOccupancyId: number | string, connectedDatabase?: sqlite.Database): recordTypes.LotOccupancyOccupant[];
|
||||
export default getLotOccupancyOccupants;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
export function getLotOccupancyOccupants(lotOccupancyId, connectedDatabase) {
|
||||
const database = connectedDatabase ||
|
||||
const database = connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
|
||||
export function getLotOccupancyOccupants(
|
||||
lotOccupancyId: number | string,
|
||||
connectedDatabase?: sqlite.Database
|
||||
lotOccupancyId: number | string,
|
||||
connectedDatabase?: sqlite.Database
|
||||
): recordTypes.LotOccupancyOccupant[] {
|
||||
const database =
|
||||
connectedDatabase ||
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const database =
|
||||
connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
})
|
||||
|
||||
const lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[] = database
|
||||
.prepare(
|
||||
`select o.lotOccupancyId, o.lotOccupantIndex,
|
||||
const lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[] = database
|
||||
.prepare(
|
||||
`select o.lotOccupancyId, o.lotOccupantIndex,
|
||||
o.occupantName,
|
||||
o.occupantAddress1, o.occupantAddress2,
|
||||
o.occupantCity, o.occupantProvince, o.occupantPostalCode,
|
||||
|
|
@ -29,14 +29,14 @@ export function getLotOccupancyOccupants(
|
|||
where o.recordDelete_timeMillis is null
|
||||
and o.lotOccupancyId = ?
|
||||
order by t.orderNumber, t.lotOccupantType, o.occupantName, o.lotOccupantIndex`
|
||||
)
|
||||
.all(lotOccupancyId);
|
||||
)
|
||||
.all(lotOccupancyId)
|
||||
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
}
|
||||
if (!connectedDatabase) {
|
||||
database.close()
|
||||
}
|
||||
|
||||
return lotOccupancyOccupants;
|
||||
return lotOccupancyOccupants
|
||||
}
|
||||
|
||||
export default getLotOccupancyOccupants;
|
||||
export default getLotOccupancyOccupants
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import type * as recordTypes from '../../types/recordTypes';
|
||||
export declare function getLotOccupancyTransactions(lotOccupancyId: number | string, connectedDatabase?: sqlite.Database): recordTypes.LotOccupancyTransaction[];
|
||||
export default getLotOccupancyTransactions;
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { dateIntegerToString, timeIntegerToString } from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
import { dateIntegerToString, timeIntegerToString } from '@cityssm/expressjs-server-js/dateTimeFns.js';
|
||||
export function getLotOccupancyTransactions(lotOccupancyId, connectedDatabase) {
|
||||
const database = connectedDatabase ||
|
||||
const database = connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
database.function("userFn_dateIntegerToString", dateIntegerToString);
|
||||
database.function("userFn_timeIntegerToString", timeIntegerToString);
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
||||
database.function('userFn_timeIntegerToString', timeIntegerToString);
|
||||
const lotOccupancyTransactions = database
|
||||
.prepare(`select lotOccupancyId, transactionIndex,
|
||||
transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString,
|
||||
transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString,
|
||||
transactionAmount, externalReceiptNumber, transactionNote
|
||||
from LotOccupancyTransactions
|
||||
where recordDelete_timeMillis is null
|
||||
and lotOccupancyId = ?
|
||||
order by transactionDate, transactionTime, transactionIndex`)
|
||||
transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString,
|
||||
transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString,
|
||||
transactionAmount, externalReceiptNumber, transactionNote
|
||||
from LotOccupancyTransactions
|
||||
where recordDelete_timeMillis is null
|
||||
and lotOccupancyId = ?
|
||||
order by transactionDate, transactionTime, transactionIndex`)
|
||||
.all(lotOccupancyId);
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
|
|
|
|||
|
|
@ -1,45 +1,46 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import {
|
||||
dateIntegerToString,
|
||||
timeIntegerToString
|
||||
} from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||
dateIntegerToString,
|
||||
timeIntegerToString
|
||||
} from '@cityssm/expressjs-server-js/dateTimeFns.js'
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
|
||||
export function getLotOccupancyTransactions(
|
||||
lotOccupancyId: number | string,
|
||||
connectedDatabase?: sqlite.Database
|
||||
lotOccupancyId: number | string,
|
||||
connectedDatabase?: sqlite.Database
|
||||
): recordTypes.LotOccupancyTransaction[] {
|
||||
const database =
|
||||
connectedDatabase ||
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const database =
|
||||
connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
})
|
||||
|
||||
database.function("userFn_dateIntegerToString", dateIntegerToString);
|
||||
database.function("userFn_timeIntegerToString", timeIntegerToString);
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
database.function('userFn_timeIntegerToString', timeIntegerToString)
|
||||
|
||||
const lotOccupancyTransactions: recordTypes.LotOccupancyTransaction[] = database
|
||||
.prepare(
|
||||
`select lotOccupancyId, transactionIndex,
|
||||
transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString,
|
||||
transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString,
|
||||
transactionAmount, externalReceiptNumber, transactionNote
|
||||
from LotOccupancyTransactions
|
||||
where recordDelete_timeMillis is null
|
||||
and lotOccupancyId = ?
|
||||
order by transactionDate, transactionTime, transactionIndex`
|
||||
)
|
||||
.all(lotOccupancyId);
|
||||
const lotOccupancyTransactions: recordTypes.LotOccupancyTransaction[] =
|
||||
database
|
||||
.prepare(
|
||||
`select lotOccupancyId, transactionIndex,
|
||||
transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString,
|
||||
transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString,
|
||||
transactionAmount, externalReceiptNumber, transactionNote
|
||||
from LotOccupancyTransactions
|
||||
where recordDelete_timeMillis is null
|
||||
and lotOccupancyId = ?
|
||||
order by transactionDate, transactionTime, transactionIndex`
|
||||
)
|
||||
.all(lotOccupancyId)
|
||||
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
}
|
||||
if (!connectedDatabase) {
|
||||
database.close()
|
||||
}
|
||||
|
||||
return lotOccupancyTransactions;
|
||||
return lotOccupancyTransactions
|
||||
}
|
||||
|
||||
export default getLotOccupancyTransactions;
|
||||
export default getLotOccupancyTransactions
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes';
|
||||
export declare function getLotOccupantTypes(): recordTypes.LotOccupantType[];
|
||||
export default getLotOccupantTypes;
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { updateRecordOrderNumber } from "./updateRecordOrderNumber.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
export function getLotOccupantTypes() {
|
||||
const database = sqlite(databasePath);
|
||||
const lotOccupantTypes = database
|
||||
.prepare(`select lotOccupantTypeId, lotOccupantType, fontAwesomeIconClass, orderNumber
|
||||
from LotOccupantTypes
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotOccupantType`)
|
||||
from LotOccupantTypes
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotOccupantType`)
|
||||
.all();
|
||||
let expectedOrderNumber = 0;
|
||||
for (const lotOccupantType of lotOccupantTypes) {
|
||||
if (lotOccupantType.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber("LotOccupantTypes", lotOccupantType.lotOccupantTypeId, expectedOrderNumber, database);
|
||||
updateRecordOrderNumber('LotOccupantTypes', lotOccupantType.lotOccupantTypeId, expectedOrderNumber, database);
|
||||
lotOccupantType.orderNumber = expectedOrderNumber;
|
||||
}
|
||||
expectedOrderNumber += 1;
|
||||
|
|
|
|||
|
|
@ -1,43 +1,43 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import { updateRecordOrderNumber } from "./updateRecordOrderNumber.js";
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
|
||||
export function getLotOccupantTypes(): recordTypes.LotOccupantType[] {
|
||||
const database = sqlite(databasePath);
|
||||
const database = sqlite(databasePath)
|
||||
|
||||
const lotOccupantTypes: recordTypes.LotOccupantType[] = database
|
||||
.prepare(
|
||||
`select lotOccupantTypeId, lotOccupantType, fontAwesomeIconClass, orderNumber
|
||||
from LotOccupantTypes
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotOccupantType`
|
||||
)
|
||||
.all();
|
||||
const lotOccupantTypes: recordTypes.LotOccupantType[] = database
|
||||
.prepare(
|
||||
`select lotOccupantTypeId, lotOccupantType, fontAwesomeIconClass, orderNumber
|
||||
from LotOccupantTypes
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotOccupantType`
|
||||
)
|
||||
.all()
|
||||
|
||||
let expectedOrderNumber = 0;
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
for (const lotOccupantType of lotOccupantTypes) {
|
||||
if (lotOccupantType.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber(
|
||||
"LotOccupantTypes",
|
||||
lotOccupantType.lotOccupantTypeId,
|
||||
expectedOrderNumber,
|
||||
database
|
||||
);
|
||||
for (const lotOccupantType of lotOccupantTypes) {
|
||||
if (lotOccupantType.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber(
|
||||
'LotOccupantTypes',
|
||||
lotOccupantType.lotOccupantTypeId,
|
||||
expectedOrderNumber,
|
||||
database
|
||||
)
|
||||
|
||||
lotOccupantType.orderNumber = expectedOrderNumber;
|
||||
}
|
||||
|
||||
expectedOrderNumber += 1;
|
||||
lotOccupantType.orderNumber = expectedOrderNumber
|
||||
}
|
||||
|
||||
database.close();
|
||||
expectedOrderNumber += 1
|
||||
}
|
||||
|
||||
return lotOccupantTypes;
|
||||
database.close()
|
||||
|
||||
return lotOccupantTypes
|
||||
}
|
||||
|
||||
export default getLotOccupantTypes;
|
||||
export default getLotOccupantTypes
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes';
|
||||
interface GetFilters {
|
||||
mapId?: number | string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
export function getLotStatusSummary(filters) {
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
let sqlWhereClause = " where l.recordDelete_timeMillis is null";
|
||||
let sqlWhereClause = ' where l.recordDelete_timeMillis is null';
|
||||
const sqlParameters = [];
|
||||
if (filters && filters.mapId) {
|
||||
sqlWhereClause += " and l.mapId = ?";
|
||||
if (filters?.mapId) {
|
||||
sqlWhereClause += ' and l.mapId = ?';
|
||||
sqlParameters.push(filters.mapId);
|
||||
}
|
||||
const lotStatuses = database
|
||||
.prepare("select s.lotStatusId, s.lotStatus, count(l.lotId) as lotCount" +
|
||||
" from Lots l" +
|
||||
" left join LotStatuses s on l.lotStatusId = s.lotStatusId" +
|
||||
.prepare('select s.lotStatusId, s.lotStatus, count(l.lotId) as lotCount' +
|
||||
' from Lots l' +
|
||||
' left join LotStatuses s on l.lotStatusId = s.lotStatusId' +
|
||||
sqlWhereClause +
|
||||
" group by s.lotStatusId, s.lotStatus, s.orderNumber" +
|
||||
" order by s.orderNumber")
|
||||
' group by s.lotStatusId, s.lotStatus, s.orderNumber' +
|
||||
' order by s.orderNumber')
|
||||
.all(sqlParameters);
|
||||
database.close();
|
||||
return lotStatuses;
|
||||
|
|
|
|||
|
|
@ -1,44 +1,44 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
|
||||
interface GetFilters {
|
||||
mapId?: number | string;
|
||||
mapId?: number | string
|
||||
}
|
||||
|
||||
interface LotStatusSummary extends recordTypes.LotStatus {
|
||||
lotCount: number;
|
||||
lotCount: number
|
||||
}
|
||||
|
||||
export function getLotStatusSummary(filters?: GetFilters): LotStatusSummary[] {
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
})
|
||||
|
||||
let sqlWhereClause = " where l.recordDelete_timeMillis is null";
|
||||
const sqlParameters: unknown[] = [];
|
||||
let sqlWhereClause = ' where l.recordDelete_timeMillis is null'
|
||||
const sqlParameters: unknown[] = []
|
||||
|
||||
if (filters && filters.mapId) {
|
||||
sqlWhereClause += " and l.mapId = ?";
|
||||
sqlParameters.push(filters.mapId);
|
||||
}
|
||||
if (filters?.mapId) {
|
||||
sqlWhereClause += ' and l.mapId = ?'
|
||||
sqlParameters.push(filters.mapId)
|
||||
}
|
||||
|
||||
const lotStatuses: LotStatusSummary[] = database
|
||||
.prepare(
|
||||
"select s.lotStatusId, s.lotStatus, count(l.lotId) as lotCount" +
|
||||
" from Lots l" +
|
||||
" left join LotStatuses s on l.lotStatusId = s.lotStatusId" +
|
||||
sqlWhereClause +
|
||||
" group by s.lotStatusId, s.lotStatus, s.orderNumber" +
|
||||
" order by s.orderNumber"
|
||||
)
|
||||
.all(sqlParameters);
|
||||
const lotStatuses: LotStatusSummary[] = database
|
||||
.prepare(
|
||||
'select s.lotStatusId, s.lotStatus, count(l.lotId) as lotCount' +
|
||||
' from Lots l' +
|
||||
' left join LotStatuses s on l.lotStatusId = s.lotStatusId' +
|
||||
sqlWhereClause +
|
||||
' group by s.lotStatusId, s.lotStatus, s.orderNumber' +
|
||||
' order by s.orderNumber'
|
||||
)
|
||||
.all(sqlParameters)
|
||||
|
||||
database.close();
|
||||
database.close()
|
||||
|
||||
return lotStatuses;
|
||||
return lotStatuses
|
||||
}
|
||||
|
||||
export default getLotStatusSummary;
|
||||
export default getLotStatusSummary
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes';
|
||||
export declare function getLotStatuses(): recordTypes.LotStatus[];
|
||||
export default getLotStatuses;
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { updateRecordOrderNumber } from "./updateRecordOrderNumber.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
export function getLotStatuses() {
|
||||
const database = sqlite(databasePath);
|
||||
const lotStatuses = database
|
||||
.prepare(`select lotStatusId, lotStatus, orderNumber
|
||||
from LotStatuses
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotStatus`)
|
||||
from LotStatuses
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotStatus`)
|
||||
.all();
|
||||
let expectedOrderNumber = 0;
|
||||
for (const lotStatus of lotStatuses) {
|
||||
if (lotStatus.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber("LotStatuses", lotStatus.lotStatusId, expectedOrderNumber, database);
|
||||
updateRecordOrderNumber('LotStatuses', lotStatus.lotStatusId, expectedOrderNumber, database);
|
||||
lotStatus.orderNumber = expectedOrderNumber;
|
||||
}
|
||||
expectedOrderNumber += 1;
|
||||
|
|
|
|||
|
|
@ -1,37 +1,42 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import { updateRecordOrderNumber } from "./updateRecordOrderNumber.js";
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
|
||||
export function getLotStatuses(): recordTypes.LotStatus[] {
|
||||
const database = sqlite(databasePath);
|
||||
const database = sqlite(databasePath)
|
||||
|
||||
const lotStatuses: recordTypes.LotStatus[] = database
|
||||
.prepare(
|
||||
`select lotStatusId, lotStatus, orderNumber
|
||||
from LotStatuses
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotStatus`
|
||||
)
|
||||
.all();
|
||||
const lotStatuses: recordTypes.LotStatus[] = database
|
||||
.prepare(
|
||||
`select lotStatusId, lotStatus, orderNumber
|
||||
from LotStatuses
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotStatus`
|
||||
)
|
||||
.all()
|
||||
|
||||
let expectedOrderNumber = 0;
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
for (const lotStatus of lotStatuses) {
|
||||
if (lotStatus.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber("LotStatuses", lotStatus.lotStatusId, expectedOrderNumber, database);
|
||||
lotStatus.orderNumber = expectedOrderNumber;
|
||||
}
|
||||
|
||||
expectedOrderNumber += 1;
|
||||
for (const lotStatus of lotStatuses) {
|
||||
if (lotStatus.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber(
|
||||
'LotStatuses',
|
||||
lotStatus.lotStatusId,
|
||||
expectedOrderNumber,
|
||||
database
|
||||
)
|
||||
lotStatus.orderNumber = expectedOrderNumber
|
||||
}
|
||||
|
||||
database.close();
|
||||
expectedOrderNumber += 1
|
||||
}
|
||||
|
||||
return lotStatuses;
|
||||
database.close()
|
||||
|
||||
return lotStatuses
|
||||
}
|
||||
|
||||
export default getLotStatuses;
|
||||
export default getLotStatuses
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import type * as recordTypes from '../../types/recordTypes';
|
||||
export declare function getLotTypeFields(lotTypeId: number, connectedDatabase?: sqlite.Database): recordTypes.LotTypeField[];
|
||||
export default getLotTypeFields;
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { updateRecordOrderNumber } from "./updateRecordOrderNumber.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
export function getLotTypeFields(lotTypeId, connectedDatabase) {
|
||||
const database = connectedDatabase || sqlite(databasePath);
|
||||
const database = connectedDatabase ?? sqlite(databasePath);
|
||||
const lotTypeFields = database
|
||||
.prepare(`select lotTypeFieldId,
|
||||
lotTypeField, lotTypeFieldValues,
|
||||
isRequired, pattern, minimumLength, maximumLength, orderNumber
|
||||
from LotTypeFields
|
||||
where recordDelete_timeMillis is null
|
||||
and lotTypeId = ?
|
||||
order by orderNumber, lotTypeField`)
|
||||
lotTypeField, lotTypeFieldValues,
|
||||
isRequired, pattern, minimumLength, maximumLength, orderNumber
|
||||
from LotTypeFields
|
||||
where recordDelete_timeMillis is null
|
||||
and lotTypeId = ?
|
||||
order by orderNumber, lotTypeField`)
|
||||
.all(lotTypeId);
|
||||
let expectedOrderNumber = 0;
|
||||
for (const lotTypeField of lotTypeFields) {
|
||||
if (lotTypeField.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber("LotTypeFields", lotTypeField.lotTypeFieldId, expectedOrderNumber, database);
|
||||
updateRecordOrderNumber('LotTypeFields', lotTypeField.lotTypeFieldId, expectedOrderNumber, database);
|
||||
lotTypeField.orderNumber = expectedOrderNumber;
|
||||
}
|
||||
expectedOrderNumber += 1;
|
||||
|
|
|
|||
|
|
@ -1,50 +1,50 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import { updateRecordOrderNumber } from "./updateRecordOrderNumber.js";
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
export function getLotTypeFields(
|
||||
lotTypeId: number,
|
||||
connectedDatabase?: sqlite.Database
|
||||
lotTypeId: number,
|
||||
connectedDatabase?: sqlite.Database
|
||||
): recordTypes.LotTypeField[] {
|
||||
const database = connectedDatabase || sqlite(databasePath);
|
||||
const database = connectedDatabase ?? sqlite(databasePath)
|
||||
|
||||
const lotTypeFields: recordTypes.LotTypeField[] = database
|
||||
.prepare(
|
||||
`select lotTypeFieldId,
|
||||
lotTypeField, lotTypeFieldValues,
|
||||
isRequired, pattern, minimumLength, maximumLength, orderNumber
|
||||
from LotTypeFields
|
||||
where recordDelete_timeMillis is null
|
||||
and lotTypeId = ?
|
||||
order by orderNumber, lotTypeField`
|
||||
)
|
||||
.all(lotTypeId);
|
||||
const lotTypeFields: recordTypes.LotTypeField[] = database
|
||||
.prepare(
|
||||
`select lotTypeFieldId,
|
||||
lotTypeField, lotTypeFieldValues,
|
||||
isRequired, pattern, minimumLength, maximumLength, orderNumber
|
||||
from LotTypeFields
|
||||
where recordDelete_timeMillis is null
|
||||
and lotTypeId = ?
|
||||
order by orderNumber, lotTypeField`
|
||||
)
|
||||
.all(lotTypeId)
|
||||
|
||||
let expectedOrderNumber = 0;
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
for (const lotTypeField of lotTypeFields) {
|
||||
if (lotTypeField.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber(
|
||||
"LotTypeFields",
|
||||
lotTypeField.lotTypeFieldId,
|
||||
expectedOrderNumber,
|
||||
database
|
||||
);
|
||||
for (const lotTypeField of lotTypeFields) {
|
||||
if (lotTypeField.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber(
|
||||
'LotTypeFields',
|
||||
lotTypeField.lotTypeFieldId,
|
||||
expectedOrderNumber,
|
||||
database
|
||||
)
|
||||
|
||||
lotTypeField.orderNumber = expectedOrderNumber;
|
||||
}
|
||||
|
||||
expectedOrderNumber += 1;
|
||||
lotTypeField.orderNumber = expectedOrderNumber
|
||||
}
|
||||
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
}
|
||||
expectedOrderNumber += 1
|
||||
}
|
||||
|
||||
return lotTypeFields;
|
||||
if (!connectedDatabase) {
|
||||
database.close()
|
||||
}
|
||||
|
||||
return lotTypeFields
|
||||
}
|
||||
|
||||
export default getLotTypeFields;
|
||||
export default getLotTypeFields
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes';
|
||||
interface GetFilters {
|
||||
mapId?: number | string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
export function getLotTypeSummary(filters) {
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
let sqlWhereClause = " where l.recordDelete_timeMillis is null";
|
||||
let sqlWhereClause = ' where l.recordDelete_timeMillis is null';
|
||||
const sqlParameters = [];
|
||||
if (filters && filters.mapId) {
|
||||
sqlWhereClause += " and l.mapId = ?";
|
||||
if (filters?.mapId) {
|
||||
sqlWhereClause += ' and l.mapId = ?';
|
||||
sqlParameters.push(filters.mapId);
|
||||
}
|
||||
const lotTypes = database
|
||||
.prepare("select t.lotTypeId, t.lotType, count(l.lotId) as lotCount" +
|
||||
" from Lots l" +
|
||||
" left join LotTypes t on l.lotTypeId = t.lotTypeId" +
|
||||
.prepare('select t.lotTypeId, t.lotType, count(l.lotId) as lotCount' +
|
||||
' from Lots l' +
|
||||
' left join LotTypes t on l.lotTypeId = t.lotTypeId' +
|
||||
sqlWhereClause +
|
||||
" group by t.lotTypeId, t.lotType, t.orderNumber" +
|
||||
" order by t.orderNumber")
|
||||
' group by t.lotTypeId, t.lotType, t.orderNumber' +
|
||||
' order by t.orderNumber')
|
||||
.all(sqlParameters);
|
||||
database.close();
|
||||
return lotTypes;
|
||||
|
|
|
|||
|
|
@ -1,44 +1,44 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
|
||||
interface GetFilters {
|
||||
mapId?: number | string;
|
||||
mapId?: number | string
|
||||
}
|
||||
|
||||
interface LotTypeSummary extends recordTypes.LotType {
|
||||
lotCount: number;
|
||||
lotCount: number
|
||||
}
|
||||
|
||||
export function getLotTypeSummary(filters?: GetFilters): LotTypeSummary[] {
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
})
|
||||
|
||||
let sqlWhereClause = " where l.recordDelete_timeMillis is null";
|
||||
const sqlParameters: unknown[] = [];
|
||||
let sqlWhereClause = ' where l.recordDelete_timeMillis is null'
|
||||
const sqlParameters: unknown[] = []
|
||||
|
||||
if (filters && filters.mapId) {
|
||||
sqlWhereClause += " and l.mapId = ?";
|
||||
sqlParameters.push(filters.mapId);
|
||||
}
|
||||
if (filters?.mapId) {
|
||||
sqlWhereClause += ' and l.mapId = ?'
|
||||
sqlParameters.push(filters.mapId)
|
||||
}
|
||||
|
||||
const lotTypes: LotTypeSummary[] = database
|
||||
.prepare(
|
||||
"select t.lotTypeId, t.lotType, count(l.lotId) as lotCount" +
|
||||
" from Lots l" +
|
||||
" left join LotTypes t on l.lotTypeId = t.lotTypeId" +
|
||||
sqlWhereClause +
|
||||
" group by t.lotTypeId, t.lotType, t.orderNumber" +
|
||||
" order by t.orderNumber"
|
||||
)
|
||||
.all(sqlParameters);
|
||||
const lotTypes: LotTypeSummary[] = database
|
||||
.prepare(
|
||||
'select t.lotTypeId, t.lotType, count(l.lotId) as lotCount' +
|
||||
' from Lots l' +
|
||||
' left join LotTypes t on l.lotTypeId = t.lotTypeId' +
|
||||
sqlWhereClause +
|
||||
' group by t.lotTypeId, t.lotType, t.orderNumber' +
|
||||
' order by t.orderNumber'
|
||||
)
|
||||
.all(sqlParameters)
|
||||
|
||||
database.close();
|
||||
database.close()
|
||||
|
||||
return lotTypes;
|
||||
return lotTypes
|
||||
}
|
||||
|
||||
export default getLotTypeSummary;
|
||||
export default getLotTypeSummary
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes';
|
||||
export declare function getLotTypes(): recordTypes.LotType[];
|
||||
export default getLotTypes;
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { getLotTypeFields } from "./getLotTypeFields.js";
|
||||
import { updateRecordOrderNumber } from "./updateRecordOrderNumber.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
import { getLotTypeFields } from './getLotTypeFields.js';
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
export function getLotTypes() {
|
||||
const database = sqlite(databasePath);
|
||||
const lotTypes = database
|
||||
.prepare(`select lotTypeId, lotType, orderNumber
|
||||
from LotTypes
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotType`)
|
||||
from LotTypes
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotType`)
|
||||
.all();
|
||||
let expectedTypeOrderNumber = -1;
|
||||
for (const lotType of lotTypes) {
|
||||
expectedTypeOrderNumber += 1;
|
||||
if (lotType.orderNumber !== expectedTypeOrderNumber) {
|
||||
updateRecordOrderNumber("LotTypes", lotType.lotTypeId, expectedTypeOrderNumber, database);
|
||||
updateRecordOrderNumber('LotTypes', lotType.lotTypeId, expectedTypeOrderNumber, database);
|
||||
lotType.orderNumber = expectedTypeOrderNumber;
|
||||
}
|
||||
lotType.lotTypeFields = getLotTypeFields(lotType.lotTypeId, database);
|
||||
|
|
|
|||
|
|
@ -1,41 +1,49 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import { getLotTypeFields } from "./getLotTypeFields.js";
|
||||
import { getLotTypeFields } from './getLotTypeFields.js'
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import { updateRecordOrderNumber } from "./updateRecordOrderNumber.js";
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
export function getLotTypes(): recordTypes.LotType[] {
|
||||
const database = sqlite(databasePath);
|
||||
const database = sqlite(databasePath)
|
||||
|
||||
const lotTypes: recordTypes.LotType[] = database
|
||||
.prepare(
|
||||
`select lotTypeId, lotType, orderNumber
|
||||
from LotTypes
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotType`
|
||||
)
|
||||
.all();
|
||||
const lotTypes: recordTypes.LotType[] = database
|
||||
.prepare(
|
||||
`select lotTypeId, lotType, orderNumber
|
||||
from LotTypes
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotType`
|
||||
)
|
||||
.all()
|
||||
|
||||
let expectedTypeOrderNumber = -1;
|
||||
let expectedTypeOrderNumber = -1
|
||||
|
||||
for (const lotType of lotTypes) {
|
||||
expectedTypeOrderNumber += 1;
|
||||
for (const lotType of lotTypes) {
|
||||
expectedTypeOrderNumber += 1
|
||||
|
||||
if (lotType.orderNumber !== expectedTypeOrderNumber) {
|
||||
updateRecordOrderNumber("LotTypes", lotType.lotTypeId, expectedTypeOrderNumber, database);
|
||||
if (lotType.orderNumber !== expectedTypeOrderNumber) {
|
||||
updateRecordOrderNumber(
|
||||
'LotTypes',
|
||||
lotType.lotTypeId,
|
||||
expectedTypeOrderNumber,
|
||||
database
|
||||
)
|
||||
|
||||
lotType.orderNumber = expectedTypeOrderNumber;
|
||||
}
|
||||
|
||||
lotType.lotTypeFields = getLotTypeFields(lotType.lotTypeId as number, database);
|
||||
lotType.orderNumber = expectedTypeOrderNumber
|
||||
}
|
||||
|
||||
database.close();
|
||||
lotType.lotTypeFields = getLotTypeFields(
|
||||
lotType.lotTypeId,
|
||||
database
|
||||
)
|
||||
}
|
||||
|
||||
return lotTypes;
|
||||
database.close()
|
||||
|
||||
return lotTypes
|
||||
}
|
||||
|
||||
export default getLotTypes;
|
||||
export default getLotTypes
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes';
|
||||
export declare function getMap(mapId: number | string): recordTypes.Map;
|
||||
export default getMap;
|
||||
|
|
|
|||
|
|
@ -1,28 +1,28 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
export function getMap(mapId) {
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const map = database
|
||||
.prepare(`select m.mapId, m.mapName, m.mapDescription,
|
||||
m.mapLatitude, m.mapLongitude, m.mapSVG,
|
||||
m.mapAddress1, m.mapAddress2, m.mapCity, m.mapProvince, m.mapPostalCode,
|
||||
m.mapPhoneNumber,
|
||||
m.recordCreate_userName, m.recordCreate_timeMillis,
|
||||
m.recordUpdate_userName, m.recordUpdate_timeMillis,
|
||||
m.recordDelete_userName, m.recordDelete_timeMillis,
|
||||
count(l.lotId) as lotCount
|
||||
from Maps m
|
||||
left join Lots l on m.mapId = l.mapId and l.recordDelete_timeMillis is null
|
||||
where m.mapId = ?
|
||||
group by m.mapId, m.mapName, m.mapDescription,
|
||||
m.mapLatitude, m.mapLongitude, m.mapSVG,
|
||||
m.mapAddress1, m.mapAddress2, m.mapCity, m.mapProvince, m.mapPostalCode,
|
||||
m.mapPhoneNumber,
|
||||
m.recordCreate_userName, m.recordCreate_timeMillis,
|
||||
m.recordUpdate_userName, m.recordUpdate_timeMillis,
|
||||
m.recordDelete_userName, m.recordDelete_timeMillis`)
|
||||
m.mapLatitude, m.mapLongitude, m.mapSVG,
|
||||
m.mapAddress1, m.mapAddress2, m.mapCity, m.mapProvince, m.mapPostalCode,
|
||||
m.mapPhoneNumber,
|
||||
m.recordCreate_userName, m.recordCreate_timeMillis,
|
||||
m.recordUpdate_userName, m.recordUpdate_timeMillis,
|
||||
m.recordDelete_userName, m.recordDelete_timeMillis,
|
||||
count(l.lotId) as lotCount
|
||||
from Maps m
|
||||
left join Lots l on m.mapId = l.mapId and l.recordDelete_timeMillis is null
|
||||
where m.mapId = ?
|
||||
group by m.mapId, m.mapName, m.mapDescription,
|
||||
m.mapLatitude, m.mapLongitude, m.mapSVG,
|
||||
m.mapAddress1, m.mapAddress2, m.mapCity, m.mapProvince, m.mapPostalCode,
|
||||
m.mapPhoneNumber,
|
||||
m.recordCreate_userName, m.recordCreate_timeMillis,
|
||||
m.recordUpdate_userName, m.recordUpdate_timeMillis,
|
||||
m.recordDelete_userName, m.recordDelete_timeMillis`)
|
||||
.get(mapId);
|
||||
database.close();
|
||||
return map;
|
||||
|
|
|
|||
|
|
@ -1,40 +1,40 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
|
||||
export function getMap(mapId: number | string): recordTypes.Map {
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
})
|
||||
|
||||
const map: recordTypes.Map = database
|
||||
.prepare(
|
||||
`select m.mapId, m.mapName, m.mapDescription,
|
||||
m.mapLatitude, m.mapLongitude, m.mapSVG,
|
||||
m.mapAddress1, m.mapAddress2, m.mapCity, m.mapProvince, m.mapPostalCode,
|
||||
m.mapPhoneNumber,
|
||||
m.recordCreate_userName, m.recordCreate_timeMillis,
|
||||
m.recordUpdate_userName, m.recordUpdate_timeMillis,
|
||||
m.recordDelete_userName, m.recordDelete_timeMillis,
|
||||
count(l.lotId) as lotCount
|
||||
from Maps m
|
||||
left join Lots l on m.mapId = l.mapId and l.recordDelete_timeMillis is null
|
||||
where m.mapId = ?
|
||||
group by m.mapId, m.mapName, m.mapDescription,
|
||||
m.mapLatitude, m.mapLongitude, m.mapSVG,
|
||||
m.mapAddress1, m.mapAddress2, m.mapCity, m.mapProvince, m.mapPostalCode,
|
||||
m.mapPhoneNumber,
|
||||
m.recordCreate_userName, m.recordCreate_timeMillis,
|
||||
m.recordUpdate_userName, m.recordUpdate_timeMillis,
|
||||
m.recordDelete_userName, m.recordDelete_timeMillis`
|
||||
)
|
||||
.get(mapId);
|
||||
const map: recordTypes.Map = database
|
||||
.prepare(
|
||||
`select m.mapId, m.mapName, m.mapDescription,
|
||||
m.mapLatitude, m.mapLongitude, m.mapSVG,
|
||||
m.mapAddress1, m.mapAddress2, m.mapCity, m.mapProvince, m.mapPostalCode,
|
||||
m.mapPhoneNumber,
|
||||
m.recordCreate_userName, m.recordCreate_timeMillis,
|
||||
m.recordUpdate_userName, m.recordUpdate_timeMillis,
|
||||
m.recordDelete_userName, m.recordDelete_timeMillis,
|
||||
count(l.lotId) as lotCount
|
||||
from Maps m
|
||||
left join Lots l on m.mapId = l.mapId and l.recordDelete_timeMillis is null
|
||||
where m.mapId = ?
|
||||
group by m.mapId, m.mapName, m.mapDescription,
|
||||
m.mapLatitude, m.mapLongitude, m.mapSVG,
|
||||
m.mapAddress1, m.mapAddress2, m.mapCity, m.mapProvince, m.mapPostalCode,
|
||||
m.mapPhoneNumber,
|
||||
m.recordCreate_userName, m.recordCreate_timeMillis,
|
||||
m.recordUpdate_userName, m.recordUpdate_timeMillis,
|
||||
m.recordDelete_userName, m.recordDelete_timeMillis`
|
||||
)
|
||||
.get(mapId)
|
||||
|
||||
database.close();
|
||||
database.close()
|
||||
|
||||
return map;
|
||||
return map
|
||||
}
|
||||
|
||||
export default getMap;
|
||||
export default getMap
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes';
|
||||
export declare function getMaps(): recordTypes.Map[];
|
||||
export default getMaps;
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
export function getMaps() {
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const maps = database
|
||||
.prepare(`select m.mapId, m.mapName, m.mapDescription,
|
||||
m.mapLatitude, m.mapLongitude, m.mapSVG,
|
||||
m.mapAddress1, m.mapAddress2, m.mapCity, m.mapProvince, m.mapPostalCode,
|
||||
m.mapPhoneNumber,
|
||||
ifnull(l.lotCount,0) as lotCount
|
||||
from Maps m
|
||||
left join (
|
||||
select mapId, count(lotId) as lotCount
|
||||
from Lots
|
||||
where recordDelete_timeMillis is null group by mapId
|
||||
) l on m.mapId = l.mapId
|
||||
where m.recordDelete_timeMillis is null order by m.mapName, m.mapId`)
|
||||
m.mapLatitude, m.mapLongitude, m.mapSVG,
|
||||
m.mapAddress1, m.mapAddress2, m.mapCity, m.mapProvince, m.mapPostalCode,
|
||||
m.mapPhoneNumber,
|
||||
ifnull(l.lotCount,0) as lotCount
|
||||
from Maps m
|
||||
left join (
|
||||
select mapId, count(lotId) as lotCount
|
||||
from Lots
|
||||
where recordDelete_timeMillis is null group by mapId
|
||||
) l on m.mapId = l.mapId
|
||||
where m.recordDelete_timeMillis is null order by m.mapName, m.mapId`)
|
||||
.all();
|
||||
database.close();
|
||||
return maps;
|
||||
|
|
|
|||
|
|
@ -1,34 +1,34 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
|
||||
export function getMaps(): recordTypes.Map[] {
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
})
|
||||
|
||||
const maps: recordTypes.Map[] = database
|
||||
.prepare(
|
||||
`select m.mapId, m.mapName, m.mapDescription,
|
||||
m.mapLatitude, m.mapLongitude, m.mapSVG,
|
||||
m.mapAddress1, m.mapAddress2, m.mapCity, m.mapProvince, m.mapPostalCode,
|
||||
m.mapPhoneNumber,
|
||||
ifnull(l.lotCount,0) as lotCount
|
||||
from Maps m
|
||||
left join (
|
||||
select mapId, count(lotId) as lotCount
|
||||
from Lots
|
||||
where recordDelete_timeMillis is null group by mapId
|
||||
) l on m.mapId = l.mapId
|
||||
where m.recordDelete_timeMillis is null order by m.mapName, m.mapId`
|
||||
)
|
||||
.all();
|
||||
const maps: recordTypes.Map[] = database
|
||||
.prepare(
|
||||
`select m.mapId, m.mapName, m.mapDescription,
|
||||
m.mapLatitude, m.mapLongitude, m.mapSVG,
|
||||
m.mapAddress1, m.mapAddress2, m.mapCity, m.mapProvince, m.mapPostalCode,
|
||||
m.mapPhoneNumber,
|
||||
ifnull(l.lotCount,0) as lotCount
|
||||
from Maps m
|
||||
left join (
|
||||
select mapId, count(lotId) as lotCount
|
||||
from Lots
|
||||
where recordDelete_timeMillis is null group by mapId
|
||||
) l on m.mapId = l.mapId
|
||||
where m.recordDelete_timeMillis is null order by m.mapName, m.mapId`
|
||||
)
|
||||
.all()
|
||||
|
||||
database.close();
|
||||
database.close()
|
||||
|
||||
return maps;
|
||||
return maps
|
||||
}
|
||||
|
||||
export default getMaps;
|
||||
export default getMaps
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import * as configFunctions from "../functions.config.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
import * as configFunctions from '../functions.config.js';
|
||||
export function getNextLotId(lotId) {
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
database.function("userFn_lotNameSortName", configFunctions.getProperty("settings.lot.lotNameSortNameFunction"));
|
||||
database.function('userFn_lotNameSortName', configFunctions.getProperty('settings.lot.lotNameSortNameFunction'));
|
||||
const result = database
|
||||
.prepare(`select lotId
|
||||
from Lots
|
||||
where recordDelete_timeMillis is null
|
||||
and userFn_lotNameSortName(lotName) > (select userFn_lotNameSortName(lotName) from Lots where lotId = ?)
|
||||
order by userFn_lotNameSortName(lotName)
|
||||
limit 1`)
|
||||
from Lots
|
||||
where recordDelete_timeMillis is null
|
||||
and userFn_lotNameSortName(lotName) > (select userFn_lotNameSortName(lotName) from Lots where lotId = ?)
|
||||
order by userFn_lotNameSortName(lotName)
|
||||
limit 1`)
|
||||
.get(lotId);
|
||||
database.close();
|
||||
if (result) {
|
||||
|
|
|
|||
|
|
@ -1,39 +1,39 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import * as configFunctions from "../functions.config.js";
|
||||
import * as configFunctions from '../functions.config.js'
|
||||
|
||||
export function getNextLotId(lotId: number | string): number | undefined {
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
})
|
||||
|
||||
database.function(
|
||||
"userFn_lotNameSortName",
|
||||
configFunctions.getProperty("settings.lot.lotNameSortNameFunction")
|
||||
);
|
||||
database.function(
|
||||
'userFn_lotNameSortName',
|
||||
configFunctions.getProperty('settings.lot.lotNameSortNameFunction')
|
||||
)
|
||||
|
||||
const result: {
|
||||
lotId: number;
|
||||
} = database
|
||||
.prepare(
|
||||
`select lotId
|
||||
from Lots
|
||||
where recordDelete_timeMillis is null
|
||||
and userFn_lotNameSortName(lotName) > (select userFn_lotNameSortName(lotName) from Lots where lotId = ?)
|
||||
order by userFn_lotNameSortName(lotName)
|
||||
limit 1`
|
||||
)
|
||||
.get(lotId);
|
||||
const result: {
|
||||
lotId: number
|
||||
} = database
|
||||
.prepare(
|
||||
`select lotId
|
||||
from Lots
|
||||
where recordDelete_timeMillis is null
|
||||
and userFn_lotNameSortName(lotName) > (select userFn_lotNameSortName(lotName) from Lots where lotId = ?)
|
||||
order by userFn_lotNameSortName(lotName)
|
||||
limit 1`
|
||||
)
|
||||
.get(lotId)
|
||||
|
||||
database.close();
|
||||
database.close()
|
||||
|
||||
if (result) {
|
||||
return result.lotId;
|
||||
}
|
||||
if (result) {
|
||||
return result.lotId
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return undefined
|
||||
}
|
||||
|
||||
export default getNextLotId;
|
||||
export default getNextLotId
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3';
|
||||
export declare function getNextWorkOrderNumber(connectedDatabase?: sqlite.Database): string;
|
||||
export default getNextWorkOrderNumber;
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import * as configFunctions from "../functions.config.js";
|
||||
import sqlite from 'better-sqlite3';
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
|
||||
import * as configFunctions from '../functions.config.js';
|
||||
export function getNextWorkOrderNumber(connectedDatabase) {
|
||||
const database = connectedDatabase ||
|
||||
const database = connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
const paddingLength = configFunctions.getProperty("settings.workOrders.workOrderNumberLength");
|
||||
const paddingLength = configFunctions.getProperty('settings.workOrders.workOrderNumberLength');
|
||||
const currentYearString = new Date().getFullYear().toString();
|
||||
const regex = new RegExp("^" + currentYearString + "-\\d+$");
|
||||
database.function("userFn_matchesWorkOrderNumberSyntax", (workOrderNumber) => {
|
||||
const regex = new RegExp('^' + currentYearString + '-\\d+$');
|
||||
database.function('userFn_matchesWorkOrderNumberSyntax', (workOrderNumber) => {
|
||||
return regex.test(workOrderNumber) ? 1 : 0;
|
||||
});
|
||||
const workOrderNumberRecord = database
|
||||
.prepare("select workOrderNumber from WorkOrders" +
|
||||
" where userFn_matchesWorkOrderNumberSyntax(workOrderNumber) = 1" +
|
||||
.prepare('select workOrderNumber from WorkOrders' +
|
||||
' where userFn_matchesWorkOrderNumberSyntax(workOrderNumber) = 1' +
|
||||
" order by cast(substr(workOrderNumber, instr(workOrderNumber, '-') + 1) as integer) desc")
|
||||
.get();
|
||||
if (!connectedDatabase) {
|
||||
|
|
@ -22,9 +22,11 @@ export function getNextWorkOrderNumber(connectedDatabase) {
|
|||
}
|
||||
let workOrderNumberIndex = 0;
|
||||
if (workOrderNumberRecord) {
|
||||
workOrderNumberIndex = Number.parseInt(workOrderNumberRecord.workOrderNumber.split("-")[1], 10);
|
||||
workOrderNumberIndex = Number.parseInt(workOrderNumberRecord.workOrderNumber.split('-')[1], 10);
|
||||
}
|
||||
workOrderNumberIndex += 1;
|
||||
return currentYearString + "-" + workOrderNumberIndex.toString().padStart(paddingLength, "0");
|
||||
return (currentYearString +
|
||||
'-' +
|
||||
workOrderNumberIndex.toString().padStart(paddingLength, '0'));
|
||||
}
|
||||
export default getNextWorkOrderNumber;
|
||||
|
|
|
|||
|
|
@ -1,49 +1,60 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
|
||||
|
||||
import * as configFunctions from "../functions.config.js";
|
||||
import * as configFunctions from '../functions.config.js'
|
||||
|
||||
export function getNextWorkOrderNumber(connectedDatabase?: sqlite.Database): string {
|
||||
const database =
|
||||
connectedDatabase ||
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
});
|
||||
export function getNextWorkOrderNumber(
|
||||
connectedDatabase?: sqlite.Database
|
||||
): string {
|
||||
const database =
|
||||
connectedDatabase ??
|
||||
sqlite(databasePath, {
|
||||
readonly: true
|
||||
})
|
||||
|
||||
const paddingLength = configFunctions.getProperty("settings.workOrders.workOrderNumberLength");
|
||||
const currentYearString = new Date().getFullYear().toString();
|
||||
const paddingLength = configFunctions.getProperty(
|
||||
'settings.workOrders.workOrderNumberLength'
|
||||
)
|
||||
const currentYearString = new Date().getFullYear().toString()
|
||||
|
||||
const regex = new RegExp("^" + currentYearString + "-\\d+$");
|
||||
const regex = new RegExp('^' + currentYearString + '-\\d+$')
|
||||
|
||||
database.function("userFn_matchesWorkOrderNumberSyntax", (workOrderNumber: string) => {
|
||||
return regex.test(workOrderNumber) ? 1 : 0;
|
||||
});
|
||||
|
||||
const workOrderNumberRecord = database
|
||||
.prepare(
|
||||
"select workOrderNumber from WorkOrders" +
|
||||
" where userFn_matchesWorkOrderNumberSyntax(workOrderNumber) = 1" +
|
||||
" order by cast(substr(workOrderNumber, instr(workOrderNumber, '-') + 1) as integer) desc"
|
||||
)
|
||||
.get();
|
||||
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
database.function(
|
||||
'userFn_matchesWorkOrderNumberSyntax',
|
||||
(workOrderNumber: string) => {
|
||||
return regex.test(workOrderNumber) ? 1 : 0
|
||||
}
|
||||
)
|
||||
|
||||
let workOrderNumberIndex = 0;
|
||||
const workOrderNumberRecord = database
|
||||
.prepare(
|
||||
'select workOrderNumber from WorkOrders' +
|
||||
' where userFn_matchesWorkOrderNumberSyntax(workOrderNumber) = 1' +
|
||||
" order by cast(substr(workOrderNumber, instr(workOrderNumber, '-') + 1) as integer) desc"
|
||||
)
|
||||
.get()
|
||||
|
||||
if (workOrderNumberRecord) {
|
||||
workOrderNumberIndex = Number.parseInt(
|
||||
workOrderNumberRecord.workOrderNumber.split("-")[1],
|
||||
10
|
||||
);
|
||||
}
|
||||
if (!connectedDatabase) {
|
||||
database.close()
|
||||
}
|
||||
|
||||
workOrderNumberIndex += 1;
|
||||
let workOrderNumberIndex = 0
|
||||
|
||||
return currentYearString + "-" + workOrderNumberIndex.toString().padStart(paddingLength, "0");
|
||||
if (workOrderNumberRecord) {
|
||||
workOrderNumberIndex = Number.parseInt(
|
||||
workOrderNumberRecord.workOrderNumber.split('-')[1],
|
||||
10
|
||||
)
|
||||
}
|
||||
|
||||
workOrderNumberIndex += 1
|
||||
|
||||
return (
|
||||
currentYearString +
|
||||
'-' +
|
||||
workOrderNumberIndex.toString().padStart(paddingLength, '0')
|
||||
)
|
||||
}
|
||||
|
||||
export default getNextWorkOrderNumber;
|
||||
export default getNextWorkOrderNumber
|
||||
|
|
|
|||
|
|
@ -215,5 +215,4 @@ span.button.is-static {
|
|||
box-shadow: 0 -2px 0 0 #f5f5f5;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -30,10 +30,10 @@ describe('lot-occupancy-system', () => {
|
|||
cypressCommand += ' --record';
|
||||
}
|
||||
const childProcess = exec(cypressCommand);
|
||||
childProcess.stdout.on('data', (data) => {
|
||||
childProcess.stdout?.on('data', (data) => {
|
||||
console.log(data);
|
||||
});
|
||||
childProcess.stderr.on('data', (data) => {
|
||||
childProcess.stderr?.on('data', (data) => {
|
||||
console.error(data);
|
||||
});
|
||||
childProcess.on('exit', (code) => {
|
||||
|
|
|
|||
|
|
@ -48,11 +48,11 @@ describe('lot-occupancy-system', () => {
|
|||
|
||||
const childProcess = exec(cypressCommand)
|
||||
|
||||
childProcess.stdout.on('data', (data) => {
|
||||
childProcess.stdout?.on('data', (data) => {
|
||||
console.log(data)
|
||||
})
|
||||
|
||||
childProcess.stderr.on('data', (data) => {
|
||||
childProcess.stderr?.on('data', (data) => {
|
||||
console.error(data)
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/// <reference types="qs" />
|
||||
import type { Request } from "express";
|
||||
import type { Session } from "express-session";
|
||||
import type { Request } from 'express';
|
||||
import type { Session } from 'express-session';
|
||||
export declare const testView = "*testView";
|
||||
export declare const testUpdate = "*testUpdate";
|
||||
export declare const testAdmin = "*testAdmin";
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
export const testView = "*testView";
|
||||
export const testUpdate = "*testUpdate";
|
||||
export const testAdmin = "*testAdmin";
|
||||
export const testView = '*testView';
|
||||
export const testUpdate = '*testUpdate';
|
||||
export const testAdmin = '*testAdmin';
|
||||
export const portNumber = 7000;
|
||||
export const fakeViewOnlySession = {
|
||||
id: "",
|
||||
id: '',
|
||||
cookie: undefined,
|
||||
destroy: undefined,
|
||||
regenerate: undefined,
|
||||
|
|
@ -14,7 +14,7 @@ export const fakeViewOnlySession = {
|
|||
user: undefined
|
||||
};
|
||||
export const fakeAdminSession = {
|
||||
id: "",
|
||||
id: '',
|
||||
cookie: undefined,
|
||||
destroy: undefined,
|
||||
regenerate: undefined,
|
||||
|
|
|
|||
238
test/_globals.ts
238
test/_globals.ts
|
|
@ -1,132 +1,132 @@
|
|||
import type { Request } from "express";
|
||||
import type { Request } from 'express'
|
||||
|
||||
import type { Session } from "express-session";
|
||||
import type { Session } from 'express-session'
|
||||
|
||||
export const testView = "*testView";
|
||||
export const testUpdate = "*testUpdate";
|
||||
export const testAdmin = "*testAdmin";
|
||||
export const testView = '*testView'
|
||||
export const testUpdate = '*testUpdate'
|
||||
export const testAdmin = '*testAdmin'
|
||||
|
||||
export const portNumber = 7000;
|
||||
export const portNumber = 7000
|
||||
|
||||
export const fakeViewOnlySession: Session = {
|
||||
id: "",
|
||||
cookie: undefined,
|
||||
destroy: undefined,
|
||||
regenerate: undefined,
|
||||
reload: undefined,
|
||||
resetMaxAge: undefined,
|
||||
save: undefined,
|
||||
touch: undefined,
|
||||
user: undefined
|
||||
};
|
||||
id: '',
|
||||
cookie: undefined,
|
||||
destroy: undefined,
|
||||
regenerate: undefined,
|
||||
reload: undefined,
|
||||
resetMaxAge: undefined,
|
||||
save: undefined,
|
||||
touch: undefined,
|
||||
user: undefined
|
||||
}
|
||||
|
||||
export const fakeAdminSession: Session = {
|
||||
id: "",
|
||||
cookie: undefined,
|
||||
destroy: undefined,
|
||||
regenerate: undefined,
|
||||
reload: undefined,
|
||||
resetMaxAge: undefined,
|
||||
save: undefined,
|
||||
touch: undefined,
|
||||
user: undefined
|
||||
};
|
||||
id: '',
|
||||
cookie: undefined,
|
||||
destroy: undefined,
|
||||
regenerate: undefined,
|
||||
reload: undefined,
|
||||
resetMaxAge: undefined,
|
||||
save: undefined,
|
||||
touch: undefined,
|
||||
user: undefined
|
||||
}
|
||||
|
||||
export const fakeRequest: Request = {
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
async *[Symbol.asyncIterator]() {},
|
||||
_destroy: undefined,
|
||||
_read: undefined,
|
||||
aborted: undefined,
|
||||
accepted: undefined,
|
||||
accepts: undefined,
|
||||
acceptsCharsets: undefined,
|
||||
acceptsEncodings: undefined,
|
||||
acceptsLanguages: undefined,
|
||||
addListener: undefined,
|
||||
app: undefined,
|
||||
baseUrl: undefined,
|
||||
body: undefined,
|
||||
cookies: undefined,
|
||||
complete: undefined,
|
||||
connection: undefined,
|
||||
csrfToken: undefined,
|
||||
destroy: undefined,
|
||||
destroyed: undefined,
|
||||
emit: undefined,
|
||||
eventNames: undefined,
|
||||
fresh: undefined,
|
||||
get: undefined,
|
||||
getMaxListeners: undefined,
|
||||
header: undefined,
|
||||
headers: undefined,
|
||||
host: undefined,
|
||||
hostname: undefined,
|
||||
httpVersion: undefined,
|
||||
httpVersionMajor: undefined,
|
||||
httpVersionMinor: undefined,
|
||||
ip: undefined,
|
||||
ips: undefined,
|
||||
is: undefined,
|
||||
isPaused: undefined,
|
||||
listenerCount: undefined,
|
||||
listeners: undefined,
|
||||
method: undefined,
|
||||
off: undefined,
|
||||
on: undefined,
|
||||
once: undefined,
|
||||
originalUrl: undefined,
|
||||
param: undefined,
|
||||
params: undefined,
|
||||
path: undefined,
|
||||
pause: undefined,
|
||||
pipe: undefined,
|
||||
prependListener: undefined,
|
||||
prependOnceListener: undefined,
|
||||
protocol: undefined,
|
||||
push: undefined,
|
||||
query: undefined,
|
||||
range: undefined,
|
||||
rawHeaders: undefined,
|
||||
rawListeners: undefined,
|
||||
rawTrailers: undefined,
|
||||
read: undefined,
|
||||
readable: undefined,
|
||||
readableAborted: undefined,
|
||||
readableDidRead: undefined,
|
||||
readableEncoding: undefined,
|
||||
readableEnded: undefined,
|
||||
readableFlowing: undefined,
|
||||
readableLength: undefined,
|
||||
readableHighWaterMark: undefined,
|
||||
readableObjectMode: undefined,
|
||||
removeAllListeners: undefined,
|
||||
removeListener: undefined,
|
||||
resume: undefined,
|
||||
route: undefined,
|
||||
secure: undefined,
|
||||
session: undefined,
|
||||
sessionID: undefined,
|
||||
sessionStore: undefined,
|
||||
setEncoding: undefined,
|
||||
setMaxListeners: undefined,
|
||||
setTimeout: undefined,
|
||||
signedCookies: undefined,
|
||||
socket: undefined,
|
||||
stale: undefined,
|
||||
subdomains: undefined,
|
||||
trailers: undefined,
|
||||
unpipe: undefined,
|
||||
unshift: undefined,
|
||||
url: undefined,
|
||||
wrap: undefined,
|
||||
xhr: undefined
|
||||
};
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
async *[Symbol.asyncIterator]() {},
|
||||
_destroy: undefined,
|
||||
_read: undefined,
|
||||
aborted: undefined,
|
||||
accepted: undefined,
|
||||
accepts: undefined,
|
||||
acceptsCharsets: undefined,
|
||||
acceptsEncodings: undefined,
|
||||
acceptsLanguages: undefined,
|
||||
addListener: undefined,
|
||||
app: undefined,
|
||||
baseUrl: undefined,
|
||||
body: undefined,
|
||||
cookies: undefined,
|
||||
complete: undefined,
|
||||
connection: undefined,
|
||||
csrfToken: undefined,
|
||||
destroy: undefined,
|
||||
destroyed: undefined,
|
||||
emit: undefined,
|
||||
eventNames: undefined,
|
||||
fresh: undefined,
|
||||
get: undefined,
|
||||
getMaxListeners: undefined,
|
||||
header: undefined,
|
||||
headers: undefined,
|
||||
host: undefined,
|
||||
hostname: undefined,
|
||||
httpVersion: undefined,
|
||||
httpVersionMajor: undefined,
|
||||
httpVersionMinor: undefined,
|
||||
ip: undefined,
|
||||
ips: undefined,
|
||||
is: undefined,
|
||||
isPaused: undefined,
|
||||
listenerCount: undefined,
|
||||
listeners: undefined,
|
||||
method: undefined,
|
||||
off: undefined,
|
||||
on: undefined,
|
||||
once: undefined,
|
||||
originalUrl: undefined,
|
||||
param: undefined,
|
||||
params: undefined,
|
||||
path: undefined,
|
||||
pause: undefined,
|
||||
pipe: undefined,
|
||||
prependListener: undefined,
|
||||
prependOnceListener: undefined,
|
||||
protocol: undefined,
|
||||
push: undefined,
|
||||
query: undefined,
|
||||
range: undefined,
|
||||
rawHeaders: undefined,
|
||||
rawListeners: undefined,
|
||||
rawTrailers: undefined,
|
||||
read: undefined,
|
||||
readable: undefined,
|
||||
readableAborted: undefined,
|
||||
readableDidRead: undefined,
|
||||
readableEncoding: undefined,
|
||||
readableEnded: undefined,
|
||||
readableFlowing: undefined,
|
||||
readableLength: undefined,
|
||||
readableHighWaterMark: undefined,
|
||||
readableObjectMode: undefined,
|
||||
removeAllListeners: undefined,
|
||||
removeListener: undefined,
|
||||
resume: undefined,
|
||||
route: undefined,
|
||||
secure: undefined,
|
||||
session: undefined,
|
||||
sessionID: undefined,
|
||||
sessionStore: undefined,
|
||||
setEncoding: undefined,
|
||||
setMaxListeners: undefined,
|
||||
setTimeout: undefined,
|
||||
signedCookies: undefined,
|
||||
socket: undefined,
|
||||
stale: undefined,
|
||||
subdomains: undefined,
|
||||
trailers: undefined,
|
||||
unpipe: undefined,
|
||||
unshift: undefined,
|
||||
url: undefined,
|
||||
wrap: undefined,
|
||||
xhr: undefined
|
||||
}
|
||||
|
||||
export const fakeViewOnlyRequest = Object.assign({}, fakeRequest, {
|
||||
session: fakeViewOnlySession
|
||||
});
|
||||
session: fakeViewOnlySession
|
||||
})
|
||||
|
||||
export const fakeAdminRequest = Object.assign({}, fakeRequest, {
|
||||
session: fakeAdminSession
|
||||
});
|
||||
session: fakeAdminSession
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue