code cleanup
parent
40fb015d98
commit
8b4a7c9937
|
|
@ -1,5 +1,6 @@
|
|||
# Lot Occupancy System
|
||||
|
||||
[](https://app.deepsource.com/gh/cityssm/lot-occupancy-system/)
|
||||
[](https://codeclimate.com/github/cityssm/lot-occupancy-system/maintainability)
|
||||
[](https://codecov.io/gh/cityssm/lot-occupancy-system)
|
||||
[](https://github.com/cityssm/lot-occupancy-system/actions/workflows/coverage.yml)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getFee(feeId: number | string, connectedDatabase?: PoolConnection): Promise<recordTypes.Fee>;
|
||||
import type { Fee } from '../types/recordTypes.js';
|
||||
export declare function getFee(feeId: number | string, connectedDatabase?: PoolConnection): Promise<Fee | undefined>;
|
||||
export default getFee;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import type { Fee } from '../types/recordTypes.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function getFee(
|
||||
feeId: number | string,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.Fee> {
|
||||
): Promise<Fee | undefined> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
const fee = database
|
||||
|
|
@ -27,7 +28,7 @@ export async function getFee(
|
|||
where f.recordDelete_timeMillis is null
|
||||
and f.feeId = ?`
|
||||
)
|
||||
.get(feeId) as recordTypes.Fee
|
||||
.get(feeId) as Fee | undefined
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
import type { FeeCategory } from '../types/recordTypes.js';
|
||||
interface GetFeeCategoriesFilters {
|
||||
occupancyTypeId?: number | string;
|
||||
lotTypeId?: number | string;
|
||||
|
|
@ -6,5 +6,5 @@ interface GetFeeCategoriesFilters {
|
|||
interface GetFeeCategoriesOptions {
|
||||
includeFees?: boolean;
|
||||
}
|
||||
export declare function getFeeCategories(filters: GetFeeCategoriesFilters, options: GetFeeCategoriesOptions): Promise<recordTypes.FeeCategory[]>;
|
||||
export declare function getFeeCategories(filters: GetFeeCategoriesFilters, options: GetFeeCategoriesOptions): Promise<FeeCategory[]>;
|
||||
export default getFeeCategories;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { getFees } from './getFees.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
export async function getFeeCategories(filters, options) {
|
||||
const updateOrderNumbers = !(filters.lotTypeId || filters.occupancyTypeId) && options.includeFees;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { FeeCategory } from '../types/recordTypes.js'
|
||||
|
||||
import { getFees } from './getFees.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
|
||||
interface GetFeeCategoriesFilters {
|
||||
occupancyTypeId?: number | string
|
||||
lotTypeId?: number | string
|
||||
|
|
@ -17,7 +16,7 @@ interface GetFeeCategoriesOptions {
|
|||
export async function getFeeCategories(
|
||||
filters: GetFeeCategoriesFilters,
|
||||
options: GetFeeCategoriesOptions
|
||||
): Promise<recordTypes.FeeCategory[]> {
|
||||
): Promise<FeeCategory[]> {
|
||||
const updateOrderNumbers =
|
||||
!(filters.lotTypeId || filters.occupancyTypeId) && options.includeFees
|
||||
|
||||
|
|
@ -54,7 +53,7 @@ export async function getFeeCategories(
|
|||
sqlWhereClause +
|
||||
' order by orderNumber, feeCategory'
|
||||
)
|
||||
.all(sqlParameters) as recordTypes.FeeCategory[]
|
||||
.all(sqlParameters) as FeeCategory[]
|
||||
|
||||
if (options.includeFees ?? false) {
|
||||
let expectedOrderNumber = 0
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
import type { Fee } from '../types/recordTypes.js';
|
||||
interface GetFeesFilters {
|
||||
occupancyTypeId?: number | string;
|
||||
lotTypeId?: number | string;
|
||||
}
|
||||
export declare function getFees(feeCategoryId: number, additionalFilters: GetFeesFilters, connectedDatabase?: PoolConnection): Promise<recordTypes.Fee[]>;
|
||||
export declare function getFees(feeCategoryId: number, additionalFilters: GetFeesFilters, connectedDatabase?: PoolConnection): Promise<Fee[]>;
|
||||
export default getFees;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
import type { Fee } from '../types/recordTypes.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
interface GetFeesFilters {
|
||||
occupancyTypeId?: number | string
|
||||
|
|
@ -14,7 +14,7 @@ export async function getFees(
|
|||
feeCategoryId: number,
|
||||
additionalFilters: GetFeesFilters,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.Fee[]> {
|
||||
): Promise<Fee[]> {
|
||||
const updateOrderNumbers = !(
|
||||
additionalFilters.lotTypeId || additionalFilters.occupancyTypeId
|
||||
)
|
||||
|
|
@ -63,7 +63,7 @@ export async function getFees(
|
|||
${sqlWhereClause}
|
||||
order by f.orderNumber, f.feeName`
|
||||
)
|
||||
.all(sqlParameters) as recordTypes.Fee[]
|
||||
.all(sqlParameters) as Fee[]
|
||||
|
||||
if (updateOrderNumbers) {
|
||||
let expectedOrderNumber = 0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getLotByLotName(lotName: string): Promise<recordTypes.Lot | undefined>;
|
||||
export declare function getLot(lotId: number | string): Promise<recordTypes.Lot | undefined>;
|
||||
import type { Lot } from '../types/recordTypes.js';
|
||||
export declare function getLotByLotName(lotName: string): Promise<Lot | undefined>;
|
||||
export declare function getLot(lotId: number | string): Promise<Lot | undefined>;
|
||||
export default getLot;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { getLotFields } from './getLotFields.js';
|
||||
import { getLotComments } from './getLotComments.js';
|
||||
import { getLotFields } from './getLotFields.js';
|
||||
import { getLotOccupancies } from './getLotOccupancies.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
const baseSQL = `select l.lotId, l.lotTypeId, t.lotType, l.lotName, l.lotStatusId, s.lotStatus,
|
||||
l.mapId, m.mapName, m.mapSVG, l.mapKey,
|
||||
l.lotLatitude, l.lotLongitude
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
|
||||
import { getLotFields } from './getLotFields.js'
|
||||
import type { Lot } from '../types/recordTypes.js'
|
||||
|
||||
import { getLotComments } from './getLotComments.js'
|
||||
|
||||
import { getLotFields } from './getLotFields.js'
|
||||
import { getLotOccupancies } from './getLotOccupancies.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
const baseSQL = `select l.lotId, l.lotTypeId, t.lotType, l.lotName, l.lotStatusId, s.lotStatus,
|
||||
l.mapId, m.mapName, m.mapSVG, l.mapKey,
|
||||
|
|
@ -20,10 +17,10 @@ const baseSQL = `select l.lotId, l.lotTypeId, t.lotType, l.lotName, l.lotStatusI
|
|||
async function _getLot(
|
||||
sql: string,
|
||||
lotIdOrLotName: number | string
|
||||
): Promise<recordTypes.Lot | undefined> {
|
||||
): Promise<Lot | undefined> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const lot = database.prepare(sql).get(lotIdOrLotName) as recordTypes.Lot | undefined
|
||||
const lot = database.prepare(sql).get(lotIdOrLotName) as Lot | undefined
|
||||
|
||||
if (lot !== undefined) {
|
||||
const lotOccupancies = await getLotOccupancies(
|
||||
|
|
@ -54,13 +51,11 @@ async function _getLot(
|
|||
|
||||
export async function getLotByLotName(
|
||||
lotName: string
|
||||
): Promise<recordTypes.Lot | undefined> {
|
||||
): Promise<Lot | undefined> {
|
||||
return await _getLot(baseSQL + ' and l.lotName = ?', lotName)
|
||||
}
|
||||
|
||||
export async function getLot(
|
||||
lotId: number | string
|
||||
): Promise<recordTypes.Lot | undefined> {
|
||||
export async function getLot(lotId: number | string): Promise<Lot | undefined> {
|
||||
return await _getLot(baseSQL + ' and l.lotId = ?', lotId)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getLotComments(lotId: number | string, connectedDatabase?: PoolConnection): Promise<recordTypes.LotComment[]>;
|
||||
import type { LotComment } from '../types/recordTypes.js';
|
||||
export declare function getLotComments(lotId: number | string, connectedDatabase?: PoolConnection): Promise<LotComment[]>;
|
||||
export default getLotComments;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { dateIntegerToString, timeIntegerToString, timeIntegerToPeriodString } from '@cityssm/utils-datetime';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export async function getLotComments(lotId, connectedDatabase) {
|
||||
const database = connectedDatabase ?? (await acquireConnection());
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
||||
|
|
|
|||
|
|
@ -1,23 +1,26 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import {
|
||||
dateIntegerToString,
|
||||
timeIntegerToString,
|
||||
timeIntegerToPeriodString
|
||||
} from '@cityssm/utils-datetime'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import type { LotComment } from '../types/recordTypes.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function getLotComments(
|
||||
lotId: number | string,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.LotComment[]> {
|
||||
): Promise<LotComment[]> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
database.function('userFn_timeIntegerToString', timeIntegerToString)
|
||||
database.function('userFn_timeIntegerToPeriodString', timeIntegerToPeriodString)
|
||||
database.function(
|
||||
'userFn_timeIntegerToPeriodString',
|
||||
timeIntegerToPeriodString
|
||||
)
|
||||
|
||||
const lotComments = database
|
||||
.prepare(
|
||||
|
|
@ -33,7 +36,7 @@ export async function getLotComments(
|
|||
and lotId = ?
|
||||
order by lotCommentDate desc, lotCommentTime desc, lotCommentId desc`
|
||||
)
|
||||
.all(lotId) as recordTypes.LotComment[]
|
||||
.all(lotId) as LotComment[]
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getLotFields(lotId: number | string, connectedDatabase?: PoolConnection): Promise<recordTypes.LotField[]>;
|
||||
import type { LotField } from '../types/recordTypes.js';
|
||||
export declare function getLotFields(lotId: number | string, connectedDatabase?: PoolConnection): Promise<LotField[]>;
|
||||
export default getLotFields;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import type { LotField } from '../types/recordTypes.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function getLotFields(
|
||||
lotId: number | string,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.LotField[]> {
|
||||
): Promise<LotField[]> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
const lotFields = database
|
||||
|
|
@ -38,7 +39,7 @@ export async function getLotFields(
|
|||
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) as recordTypes.LotField[]
|
||||
.all(lotId, lotId, lotId, lotId) as LotField[]
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
import type { LotOccupancy } from '../types/recordTypes.js';
|
||||
interface GetLotOccupanciesFilters {
|
||||
lotId?: number | string;
|
||||
occupancyTime?: '' | 'past' | 'current' | 'future';
|
||||
|
|
@ -23,6 +23,6 @@ interface GetLotOccupanciesOptions {
|
|||
}
|
||||
export declare function getLotOccupancies(filters: GetLotOccupanciesFilters, options: GetLotOccupanciesOptions, connectedDatabase?: PoolConnection): Promise<{
|
||||
count: number;
|
||||
lotOccupancies: recordTypes.LotOccupancy[];
|
||||
lotOccupancies: LotOccupancy[];
|
||||
}>;
|
||||
export default getLotOccupancies;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { dateIntegerToString, dateStringToInteger } from '@cityssm/utils-datetime';
|
||||
import * as configFunctions from '../helpers/functions.config.js';
|
||||
import { getOccupancyTypeById } from '../helpers/functions.cache.js';
|
||||
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js';
|
||||
import { getLotOccupancyFees } from './getLotOccupancyFees.js';
|
||||
import { getLotOccupancyTransactions } from './getLotOccupancyTransactions.js';
|
||||
import * as configFunctions from '../helpers/functions.config.js';
|
||||
import { getLotNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js';
|
||||
import { getLotOccupancyFees } from './getLotOccupancyFees.js';
|
||||
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js';
|
||||
import { getLotOccupancyTransactions } from './getLotOccupancyTransactions.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
function buildWhereClause(filters) {
|
||||
let sqlWhereClause = ' where o.recordDelete_timeMillis is null';
|
||||
const sqlParameters = [];
|
||||
|
|
|
|||
|
|
@ -1,28 +1,22 @@
|
|||
/* eslint-disable @typescript-eslint/indent */
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import {
|
||||
dateIntegerToString,
|
||||
dateStringToInteger
|
||||
} from '@cityssm/utils-datetime'
|
||||
|
||||
import * as configFunctions from '../helpers/functions.config.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import { getOccupancyTypeById } from '../helpers/functions.cache.js'
|
||||
|
||||
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js'
|
||||
import { getLotOccupancyFees } from './getLotOccupancyFees.js'
|
||||
import { getLotOccupancyTransactions } from './getLotOccupancyTransactions.js'
|
||||
|
||||
import * as configFunctions from '../helpers/functions.config.js'
|
||||
import {
|
||||
getLotNameWhereClause,
|
||||
getOccupancyTimeWhereClause,
|
||||
getOccupantNameWhereClause
|
||||
} from '../helpers/functions.sqlFilters.js'
|
||||
import type { LotOccupancy } from '../types/recordTypes.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import { getLotOccupancyFees } from './getLotOccupancyFees.js'
|
||||
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js'
|
||||
import { getLotOccupancyTransactions } from './getLotOccupancyTransactions.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
interface GetLotOccupanciesFilters {
|
||||
lotId?: number | string
|
||||
|
|
@ -136,10 +130,10 @@ function buildWhereClause(filters: GetLotOccupanciesFilters): {
|
|||
}
|
||||
|
||||
async function addInclusions(
|
||||
lotOccupancy: recordTypes.LotOccupancy,
|
||||
lotOccupancy: LotOccupancy,
|
||||
options: GetLotOccupanciesOptions,
|
||||
database: PoolConnection
|
||||
): Promise<recordTypes.LotOccupancy> {
|
||||
): Promise<LotOccupancy> {
|
||||
if (options.includeFees) {
|
||||
lotOccupancy.lotOccupancyFees = await getLotOccupancyFees(
|
||||
lotOccupancy.lotOccupancyId!,
|
||||
|
|
@ -169,7 +163,7 @@ export async function getLotOccupancies(
|
|||
filters: GetLotOccupanciesFilters,
|
||||
options: GetLotOccupanciesOptions,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<{ count: number; lotOccupancies: recordTypes.LotOccupancy[] }> {
|
||||
): Promise<{ count: number; lotOccupancies: LotOccupancy[] }> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
|
|
@ -193,7 +187,7 @@ export async function getLotOccupancies(
|
|||
).recordCount
|
||||
}
|
||||
|
||||
let lotOccupancies: recordTypes.LotOccupancy[] = []
|
||||
let lotOccupancies: LotOccupancy[] = []
|
||||
|
||||
if (count !== 0) {
|
||||
lotOccupancies = database
|
||||
|
|
@ -213,7 +207,7 @@ export async function getLotOccupancies(
|
|||
order by o.occupancyStartDate desc, ifnull(o.occupancyEndDate, 99999999) desc, l.lotName, o.lotId, o.lotOccupancyId desc` +
|
||||
(isLimited ? ` limit ${options.limit} offset ${options.offset}` : '')
|
||||
)
|
||||
.all(sqlParameters) as recordTypes.LotOccupancy[]
|
||||
.all(sqlParameters) as LotOccupancy[]
|
||||
|
||||
if (!isLimited) {
|
||||
count = lotOccupancies.length
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getLotOccupancy(lotOccupancyId: number | string, connectedDatabase?: PoolConnection): Promise<recordTypes.LotOccupancy | undefined>;
|
||||
import type { LotOccupancy } from '../types/recordTypes.js';
|
||||
export declare function getLotOccupancy(lotOccupancyId: number | string, connectedDatabase?: PoolConnection): Promise<LotOccupancy | undefined>;
|
||||
export default getLotOccupancy;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { dateIntegerToString } from '@cityssm/utils-datetime';
|
||||
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js';
|
||||
import { getLotOccupancyComments } from './getLotOccupancyComments.js';
|
||||
import { getLotOccupancyFields } from './getLotOccupancyFields.js';
|
||||
import { getLotOccupancyFees } from './getLotOccupancyFees.js';
|
||||
import { getLotOccupancyFields } from './getLotOccupancyFields.js';
|
||||
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js';
|
||||
import { getLotOccupancyTransactions } from './getLotOccupancyTransactions.js';
|
||||
import { getWorkOrders } from './getWorkOrders.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export async function getLotOccupancy(lotOccupancyId, connectedDatabase) {
|
||||
const database = connectedDatabase ?? (await acquireConnection());
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
||||
|
|
|
|||
|
|
@ -1,21 +1,20 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import { dateIntegerToString } from '@cityssm/utils-datetime'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import { dateIntegerToString } from '@cityssm/utils-datetime'
|
||||
import type { LotOccupancy } from '../types/recordTypes.js'
|
||||
|
||||
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js'
|
||||
import { getLotOccupancyComments } from './getLotOccupancyComments.js'
|
||||
import { getLotOccupancyFields } from './getLotOccupancyFields.js'
|
||||
import { getLotOccupancyFees } from './getLotOccupancyFees.js'
|
||||
import { getLotOccupancyFields } from './getLotOccupancyFields.js'
|
||||
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js'
|
||||
import { getLotOccupancyTransactions } from './getLotOccupancyTransactions.js'
|
||||
import { getWorkOrders } from './getWorkOrders.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function getLotOccupancy(
|
||||
lotOccupancyId: number | string,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.LotOccupancy | undefined> {
|
||||
): Promise<LotOccupancy | undefined> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
|
|
@ -36,7 +35,7 @@ export async function getLotOccupancy(
|
|||
where o.recordDelete_timeMillis is null
|
||||
and o.lotOccupancyId = ?`
|
||||
)
|
||||
.get(lotOccupancyId) as recordTypes.LotOccupancy | undefined
|
||||
.get(lotOccupancyId) as LotOccupancy | undefined
|
||||
|
||||
if (lotOccupancy !== undefined) {
|
||||
lotOccupancy.lotOccupancyFields = await getLotOccupancyFields(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getLotOccupancyComments(lotOccupancyId: number | string, connectedDatabase?: PoolConnection): Promise<recordTypes.LotOccupancyComment[]>;
|
||||
import type { LotOccupancyComment } from '../types/recordTypes.js';
|
||||
export declare function getLotOccupancyComments(lotOccupancyId: number | string, connectedDatabase?: PoolConnection): Promise<LotOccupancyComment[]>;
|
||||
export default getLotOccupancyComments;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { dateIntegerToString, timeIntegerToString, timeIntegerToPeriodString } from '@cityssm/utils-datetime';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export async function getLotOccupancyComments(lotOccupancyId, connectedDatabase) {
|
||||
const database = connectedDatabase ?? (await acquireConnection());
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
||||
|
|
|
|||
|
|
@ -1,23 +1,26 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import {
|
||||
dateIntegerToString,
|
||||
timeIntegerToString,
|
||||
timeIntegerToPeriodString
|
||||
} from '@cityssm/utils-datetime'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import type { LotOccupancyComment } from '../types/recordTypes.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function getLotOccupancyComments(
|
||||
lotOccupancyId: number | string,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.LotOccupancyComment[]> {
|
||||
): Promise<LotOccupancyComment[]> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
database.function('userFn_timeIntegerToString', timeIntegerToString)
|
||||
database.function('userFn_timeIntegerToPeriodString', timeIntegerToPeriodString)
|
||||
database.function(
|
||||
'userFn_timeIntegerToPeriodString',
|
||||
timeIntegerToPeriodString
|
||||
)
|
||||
|
||||
const lotComments = database
|
||||
.prepare(
|
||||
|
|
@ -33,7 +36,7 @@ export async function getLotOccupancyComments(
|
|||
and lotOccupancyId = ?
|
||||
order by lotOccupancyCommentDate desc, lotOccupancyCommentTime desc, lotOccupancyCommentId desc`
|
||||
)
|
||||
.all(lotOccupancyId) as recordTypes.LotOccupancyComment[]
|
||||
.all(lotOccupancyId) as LotOccupancyComment[]
|
||||
|
||||
if (connectedDatabase === null) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getLotOccupancyFees(lotOccupancyId: number | string, connectedDatabase?: PoolConnection): Promise<recordTypes.LotOccupancyFee[]>;
|
||||
import type { LotOccupancyFee } from '../types/recordTypes.js';
|
||||
export declare function getLotOccupancyFees(lotOccupancyId: number | string, connectedDatabase?: PoolConnection): Promise<LotOccupancyFee[]>;
|
||||
export default getLotOccupancyFees;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import type { LotOccupancyFee } from '../types/recordTypes.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function getLotOccupancyFees(
|
||||
lotOccupancyId: number | string,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.LotOccupancyFee[]> {
|
||||
): Promise<LotOccupancyFee[]> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
const lotOccupancyFees = database
|
||||
|
|
@ -21,7 +22,7 @@ export async function getLotOccupancyFees(
|
|||
and o.lotOccupancyId = ?
|
||||
order by o.recordCreate_timeMillis`
|
||||
)
|
||||
.all(lotOccupancyId) as recordTypes.LotOccupancyFee[]
|
||||
.all(lotOccupancyId) as LotOccupancyFee[]
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getLotOccupancyFields(lotOccupancyId: number | string, connectedDatabase?: PoolConnection): Promise<recordTypes.LotOccupancyField[]>;
|
||||
import type { LotOccupancyField } from '../types/recordTypes.js';
|
||||
export declare function getLotOccupancyFields(lotOccupancyId: number | string, connectedDatabase?: PoolConnection): Promise<LotOccupancyField[]>;
|
||||
export default getLotOccupancyFields;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import type { LotOccupancyField } from '../types/recordTypes.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function getLotOccupancyFields(
|
||||
lotOccupancyId: number | string,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.LotOccupancyField[]> {
|
||||
): Promise<LotOccupancyField[]> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
const lotOccupancyFields = database
|
||||
|
|
@ -35,7 +36,12 @@ export async function getLotOccupancyFields(
|
|||
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) as recordTypes.LotOccupancyField[]
|
||||
.all(
|
||||
lotOccupancyId,
|
||||
lotOccupancyId,
|
||||
lotOccupancyId,
|
||||
lotOccupancyId
|
||||
) as LotOccupancyField[]
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getLotOccupancyOccupants(lotOccupancyId: number | string, connectedDatabase?: PoolConnection): Promise<recordTypes.LotOccupancyOccupant[]>;
|
||||
import type { LotOccupancyOccupant } from '../types/recordTypes.js';
|
||||
export declare function getLotOccupancyOccupants(lotOccupancyId: number | string, connectedDatabase?: PoolConnection): Promise<LotOccupancyOccupant[]>;
|
||||
export default getLotOccupancyOccupants;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import type { LotOccupancyOccupant } from '../types/recordTypes.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function getLotOccupancyOccupants(
|
||||
lotOccupancyId: number | string,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.LotOccupancyOccupant[]> {
|
||||
): Promise<LotOccupancyOccupant[]> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
const lotOccupancyOccupants = database
|
||||
|
|
@ -25,7 +26,7 @@ export async function getLotOccupancyOccupants(
|
|||
and o.lotOccupancyId = ?
|
||||
order by t.orderNumber, t.lotOccupantType, o.occupantName, o.lotOccupantIndex`
|
||||
)
|
||||
.all(lotOccupancyId) as recordTypes.LotOccupancyOccupant[]
|
||||
.all(lotOccupancyId) as LotOccupancyOccupant[]
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
import type { LotOccupancyTransaction } from '../types/recordTypes.js';
|
||||
export declare function getLotOccupancyTransactions(lotOccupancyId: number | string, options: {
|
||||
includeIntegrations: boolean;
|
||||
}, connectedDatabase?: PoolConnection): Promise<recordTypes.LotOccupancyTransaction[]>;
|
||||
}, connectedDatabase?: PoolConnection): Promise<LotOccupancyTransaction[]>;
|
||||
export default getLotOccupancyTransactions;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { dateIntegerToString, timeIntegerToString } from '@cityssm/utils-datetime';
|
||||
import * as configFunctions from '../helpers/functions.config.js';
|
||||
import * as gpFunctions from '../helpers/functions.dynamicsGP.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export async function getLotOccupancyTransactions(lotOccupancyId, options, connectedDatabase) {
|
||||
const database = connectedDatabase ?? (await acquireConnection());
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
||||
|
|
@ -23,7 +23,7 @@ export async function getLotOccupancyTransactions(lotOccupancyId, options, conne
|
|||
configFunctions.getProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
||||
for (const transaction of lotOccupancyTransactions) {
|
||||
if ((transaction.externalReceiptNumber ?? '') !== '') {
|
||||
const gpDocument = await gpFunctions.getDynamicsGPDocument(transaction.externalReceiptNumber);
|
||||
const gpDocument = await gpFunctions.getDynamicsGPDocument(transaction.externalReceiptNumber ?? '');
|
||||
if (gpDocument !== undefined) {
|
||||
transaction.dynamicsGPDocument = gpDocument;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import {
|
||||
dateIntegerToString,
|
||||
timeIntegerToString
|
||||
} from '@cityssm/utils-datetime'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import * as configFunctions from '../helpers/functions.config.js'
|
||||
import * as gpFunctions from '../helpers/functions.dynamicsGP.js'
|
||||
import type { LotOccupancyTransaction } from '../types/recordTypes.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function getLotOccupancyTransactions(
|
||||
lotOccupancyId: number | string,
|
||||
|
|
@ -17,7 +16,7 @@ export async function getLotOccupancyTransactions(
|
|||
includeIntegrations: boolean
|
||||
},
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.LotOccupancyTransaction[]> {
|
||||
): Promise<LotOccupancyTransaction[]> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
|
|
@ -34,7 +33,7 @@ export async function getLotOccupancyTransactions(
|
|||
and lotOccupancyId = ?
|
||||
order by transactionDate, transactionTime, transactionIndex`
|
||||
)
|
||||
.all(lotOccupancyId) as recordTypes.LotOccupancyTransaction[]
|
||||
.all(lotOccupancyId) as LotOccupancyTransaction[]
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
|
|
@ -47,7 +46,7 @@ export async function getLotOccupancyTransactions(
|
|||
for (const transaction of lotOccupancyTransactions) {
|
||||
if ((transaction.externalReceiptNumber ?? '') !== '') {
|
||||
const gpDocument = await gpFunctions.getDynamicsGPDocument(
|
||||
transaction.externalReceiptNumber!
|
||||
transaction.externalReceiptNumber ?? ''
|
||||
)
|
||||
|
||||
if (gpDocument !== undefined) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getLotOccupantTypes(): Promise<recordTypes.LotOccupantType[]>;
|
||||
import type { LotOccupantType } from '../types/recordTypes.js';
|
||||
export declare function getLotOccupantTypes(): Promise<LotOccupantType[]>;
|
||||
export default getLotOccupantTypes;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,9 @@
|
|||
/* eslint-disable @typescript-eslint/indent */
|
||||
import type { LotOccupantType } from '../types/recordTypes.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
|
||||
export async function getLotOccupantTypes(): Promise<
|
||||
recordTypes.LotOccupantType[]
|
||||
> {
|
||||
export async function getLotOccupantTypes(): Promise<LotOccupantType[]> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const lotOccupantTypes = database
|
||||
|
|
@ -19,7 +14,7 @@ export async function getLotOccupantTypes(): Promise<
|
|||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotOccupantType`
|
||||
)
|
||||
.all() as recordTypes.LotOccupantType[]
|
||||
.all() as LotOccupantType[]
|
||||
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
import type { LotStatus } from '../types/recordTypes.js';
|
||||
interface GetFilters {
|
||||
mapId?: number | string;
|
||||
}
|
||||
interface LotStatusSummary extends recordTypes.LotStatus {
|
||||
interface LotStatusSummary extends LotStatus {
|
||||
lotCount: number;
|
||||
}
|
||||
export declare function getLotStatusSummary(filters: GetFilters): Promise<LotStatusSummary[]>;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { LotStatus } from '../types/recordTypes.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
interface GetFilters {
|
||||
mapId?: number | string
|
||||
}
|
||||
|
||||
interface LotStatusSummary extends recordTypes.LotStatus {
|
||||
interface LotStatusSummary extends LotStatus {
|
||||
lotCount: number
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getLotStatuses(): Promise<recordTypes.LotStatus[]>;
|
||||
import type { LotStatus } from '../types/recordTypes.js';
|
||||
export declare function getLotStatuses(): Promise<LotStatus[]>;
|
||||
export default getLotStatuses;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { LotStatus } from '../types/recordTypes.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
|
||||
export async function getLotStatuses(): Promise<recordTypes.LotStatus[]> {
|
||||
export async function getLotStatuses(): Promise<LotStatus[]> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const lotStatuses = database
|
||||
|
|
@ -14,7 +13,7 @@ export async function getLotStatuses(): Promise<recordTypes.LotStatus[]> {
|
|||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotStatus`
|
||||
)
|
||||
.all() as recordTypes.LotStatus[]
|
||||
.all() as LotStatus[]
|
||||
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getLotTypeFields(lotTypeId: number, connectedDatabase?: PoolConnection): Promise<recordTypes.LotTypeField[]>;
|
||||
import type { LotTypeField } from '../types/recordTypes.js';
|
||||
export declare function getLotTypeFields(lotTypeId: number, connectedDatabase?: PoolConnection): Promise<LotTypeField[]>;
|
||||
export default getLotTypeFields;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import type { LotTypeField } from '../types/recordTypes.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
export async function getLotTypeFields(
|
||||
lotTypeId: number,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.LotTypeField[]> {
|
||||
): Promise<LotTypeField[]> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
const lotTypeFields = database
|
||||
|
|
@ -20,7 +21,7 @@ export async function getLotTypeFields(
|
|||
and lotTypeId = ?
|
||||
order by orderNumber, lotTypeField`
|
||||
)
|
||||
.all(lotTypeId) as recordTypes.LotTypeField[]
|
||||
.all(lotTypeId) as LotTypeField[]
|
||||
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
import type { LotType } from '../types/recordTypes.js';
|
||||
interface GetFilters {
|
||||
mapId?: number | string;
|
||||
}
|
||||
interface LotTypeSummary extends recordTypes.LotType {
|
||||
interface LotTypeSummary extends LotType {
|
||||
lotCount: number;
|
||||
}
|
||||
export declare function getLotTypeSummary(filters: GetFilters): Promise<LotTypeSummary[]>;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { LotType } from '../types/recordTypes.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
interface GetFilters {
|
||||
mapId?: number | string
|
||||
}
|
||||
|
||||
interface LotTypeSummary extends recordTypes.LotType {
|
||||
interface LotTypeSummary extends LotType {
|
||||
lotCount: number
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getLotTypes(): Promise<recordTypes.LotType[]>;
|
||||
import type { LotType } from '../types/recordTypes.js';
|
||||
export declare function getLotTypes(): Promise<LotType[]>;
|
||||
export default getLotTypes;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { getLotTypeFields } from './getLotTypeFields.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
export async function getLotTypes() {
|
||||
const database = await acquireConnection();
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { LotType } from '../types/recordTypes.js'
|
||||
|
||||
import { getLotTypeFields } from './getLotTypeFields.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
export async function getLotTypes(): Promise<recordTypes.LotType[]> {
|
||||
export async function getLotTypes(): Promise<LotType[]> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const lotTypes = database
|
||||
|
|
@ -15,7 +14,7 @@ export async function getLotTypes(): Promise<recordTypes.LotType[]> {
|
|||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotType`
|
||||
)
|
||||
.all() as recordTypes.LotType[]
|
||||
.all() as LotType[]
|
||||
|
||||
let expectedTypeOrderNumber = -1
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
import type { Lot } from '../types/recordTypes.js';
|
||||
interface GetLotsFilters {
|
||||
lotNameSearchType?: '' | 'startsWith' | 'endsWith';
|
||||
lotName?: string;
|
||||
|
|
@ -16,6 +16,6 @@ interface GetLotsOptions {
|
|||
}
|
||||
export declare function getLots(filters: GetLotsFilters, options: GetLotsOptions, connectedDatabase?: PoolConnection): Promise<{
|
||||
count: number;
|
||||
lots: recordTypes.Lot[];
|
||||
lots: Lot[];
|
||||
}>;
|
||||
export default getLots;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { dateToInteger } from '@cityssm/utils-datetime';
|
||||
import * as configFunctions from '../helpers/functions.config.js';
|
||||
import { getLotNameWhereClause } from '../helpers/functions.sqlFilters.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
function buildWhereClause(filters) {
|
||||
let sqlWhereClause = ' where l.recordDelete_timeMillis is null';
|
||||
const sqlParameters = [];
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
/* eslint-disable @typescript-eslint/indent */
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { dateToInteger } from '@cityssm/utils-datetime'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import { dateToInteger } from '@cityssm/utils-datetime'
|
||||
|
||||
import * as configFunctions from '../helpers/functions.config.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import { getLotNameWhereClause } from '../helpers/functions.sqlFilters.js'
|
||||
import type { Lot } from '../types/recordTypes.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
interface GetLotsFilters {
|
||||
lotNameSearchType?: '' | 'startsWith' | 'endsWith'
|
||||
|
|
@ -81,7 +78,7 @@ export async function getLots(
|
|||
filters: GetLotsFilters,
|
||||
options: GetLotsOptions,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<{ count: number; lots: recordTypes.Lot[] }> {
|
||||
): Promise<{ count: number; lots: Lot[] }> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
const { sqlWhereClause, sqlParameters } = buildWhereClause(filters)
|
||||
|
|
@ -109,7 +106,7 @@ export async function getLots(
|
|||
).recordCount
|
||||
}
|
||||
|
||||
let lots: recordTypes.Lot[] = []
|
||||
let lots: Lot[] = []
|
||||
|
||||
if (options.limit === -1 || count > 0) {
|
||||
const includeLotOccupancyCount = options.includeLotOccupancyCount ?? true
|
||||
|
|
@ -157,7 +154,7 @@ export async function getLots(
|
|||
: ` limit ${options.limit.toString()} offset ${options.offset.toString()}`
|
||||
}`
|
||||
)
|
||||
.all(sqlParameters) as recordTypes.Lot[]
|
||||
.all(sqlParameters) as Lot[]
|
||||
|
||||
if (options.limit === -1) {
|
||||
count = lots.length
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import * as configFunctions from '../helpers/functions.config.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export async function getNextLotId(lotId) {
|
||||
const database = await acquireConnection();
|
||||
database.function('userFn_lotNameSortName', configFunctions.getProperty('settings.lot.lotNameSortNameFunction'));
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
|
||||
import * as configFunctions from '../helpers/functions.config.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function getNextLotId(
|
||||
lotId: number | string
|
||||
): Promise<number | undefined> {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import * as configFunctions from '../helpers/functions.config.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export async function getNextWorkOrderNumber(connectedDatabase) {
|
||||
const database = connectedDatabase ?? (await acquireConnection());
|
||||
const paddingLength = configFunctions.getProperty('settings.workOrders.workOrderNumberLength');
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import * as configFunctions from '../helpers/functions.config.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function getNextWorkOrderNumber(
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<string> {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getOccupancyTypeFields(occupancyTypeId?: number, connectedDatabase?: PoolConnection): Promise<recordTypes.OccupancyTypeField[]>;
|
||||
import type { OccupancyTypeField } from '../types/recordTypes.js';
|
||||
export declare function getOccupancyTypeFields(occupancyTypeId?: number, connectedDatabase?: PoolConnection): Promise<OccupancyTypeField[]>;
|
||||
export default getOccupancyTypeFields;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import type { OccupancyTypeField } from '../types/recordTypes.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
export async function getOccupancyTypeFields(
|
||||
occupancyTypeId?: number,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.OccupancyTypeField[]> {
|
||||
): Promise<OccupancyTypeField[]> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
const sqlParameters: unknown[] = []
|
||||
|
|
@ -29,7 +30,7 @@ export async function getOccupancyTypeFields(
|
|||
: ' and occupancyTypeId = ?') +
|
||||
' order by orderNumber, occupancyTypeField'
|
||||
)
|
||||
.all(sqlParameters) as recordTypes.OccupancyTypeField[]
|
||||
.all(sqlParameters) as OccupancyTypeField[]
|
||||
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
|
|
@ -37,7 +38,7 @@ export async function getOccupancyTypeFields(
|
|||
if (occupancyTypeField.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber(
|
||||
'OccupancyTypeFields',
|
||||
occupancyTypeField.occupancyTypeFieldId!,
|
||||
occupancyTypeField.occupancyTypeFieldId,
|
||||
expectedOrderNumber,
|
||||
database
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import * as configFunctions from '../helpers/functions.config.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
const availablePrints = configFunctions.getProperty('settings.lotOccupancy.prints');
|
||||
const userFunction_configContainsPrintEJS = (printEJS) => {
|
||||
if (printEJS === '*' || availablePrints.includes(printEJS)) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import * as configFunctions from '../helpers/functions.config.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
const availablePrints = configFunctions.getProperty(
|
||||
'settings.lotOccupancy.prints'
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getOccupancyTypes(): Promise<recordTypes.OccupancyType[]>;
|
||||
import type { OccupancyType } from '../types/recordTypes.js';
|
||||
export declare function getOccupancyTypes(): Promise<OccupancyType[]>;
|
||||
export default getOccupancyTypes;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { getOccupancyTypeFields } from './getOccupancyTypeFields.js';
|
||||
import { getOccupancyTypePrints } from './getOccupancyTypePrints.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
export async function getOccupancyTypes() {
|
||||
const database = await acquireConnection();
|
||||
|
|
|
|||
|
|
@ -1,16 +1,11 @@
|
|||
/* eslint-disable @typescript-eslint/indent */
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import type { OccupancyType } from '../types/recordTypes.js'
|
||||
|
||||
import { getOccupancyTypeFields } from './getOccupancyTypeFields.js'
|
||||
import { getOccupancyTypePrints } from './getOccupancyTypePrints.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
export async function getOccupancyTypes(): Promise<
|
||||
recordTypes.OccupancyType[]
|
||||
> {
|
||||
export async function getOccupancyTypes(): Promise<OccupancyType[]> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const occupancyTypes = database
|
||||
|
|
@ -20,7 +15,7 @@ export async function getOccupancyTypes(): Promise<
|
|||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, occupancyType`
|
||||
)
|
||||
.all() as recordTypes.OccupancyType[]
|
||||
.all() as OccupancyType[]
|
||||
|
||||
let expectedTypeOrderNumber = -1
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
import type { LotOccupancyOccupant } from '../types/recordTypes.js';
|
||||
interface GetPastLotOccupancyOccupantsFilters {
|
||||
searchFilter: string;
|
||||
}
|
||||
interface GetPastLotOccupancyOccupantsOptions {
|
||||
limit: number;
|
||||
}
|
||||
export declare function getPastLotOccupancyOccupants(filters: GetPastLotOccupancyOccupantsFilters, options: GetPastLotOccupancyOccupantsOptions): Promise<recordTypes.LotOccupancyOccupant[]>;
|
||||
export declare function getPastLotOccupancyOccupants(filters: GetPastLotOccupancyOccupantsFilters, options: GetPastLotOccupancyOccupantsOptions): Promise<LotOccupancyOccupant[]>;
|
||||
export default getPastLotOccupancyOccupants;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { LotOccupancyOccupant } from '../types/recordTypes.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
interface GetPastLotOccupancyOccupantsFilters {
|
||||
searchFilter: string
|
||||
|
|
@ -13,7 +13,7 @@ interface GetPastLotOccupancyOccupantsOptions {
|
|||
export async function getPastLotOccupancyOccupants(
|
||||
filters: GetPastLotOccupancyOccupantsFilters,
|
||||
options: GetPastLotOccupancyOccupantsOptions
|
||||
): Promise<recordTypes.LotOccupancyOccupant[]> {
|
||||
): Promise<LotOccupancyOccupant[]> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
let sqlWhereClause =
|
||||
|
|
@ -63,7 +63,7 @@ export async function getPastLotOccupancyOccupants(
|
|||
|
||||
const lotOccupancyOccupants = database
|
||||
.prepare(sql)
|
||||
.all(sqlParameters) as recordTypes.LotOccupancyOccupant[]
|
||||
.all(sqlParameters) as LotOccupancyOccupant[]
|
||||
|
||||
database.release()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import * as configFunctions from '../helpers/functions.config.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export async function getPreviousLotId(lotId) {
|
||||
const database = await acquireConnection();
|
||||
database.function('userFn_lotNameSortName', configFunctions.getProperty('settings.lot.lotNameSortNameFunction'));
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
|
||||
import * as configFunctions from '../helpers/functions.config.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function getPreviousLotId(
|
||||
lotId: number | string
|
||||
): Promise<number | undefined> {
|
||||
|
|
|
|||
|
|
@ -1,40 +1,40 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import * as configFunctions from '../helpers/functions.config.js';
|
||||
import * as dateTimeFunctions from '@cityssm/utils-datetime';
|
||||
import camelCase from 'camelcase';
|
||||
import * as configFunctions from '../helpers/functions.config.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
const mapCamelCase = camelCase(configFunctions.getProperty('aliases.map'));
|
||||
const mapNameAlias = mapCamelCase + 'Name';
|
||||
const mapDescriptionAlias = mapCamelCase + 'Description';
|
||||
const mapAddress1Alias = mapCamelCase + 'Address1';
|
||||
const mapAddress2Alias = mapCamelCase + 'Address2';
|
||||
const mapCityAlias = mapCamelCase + 'City';
|
||||
const mapProvinceAlias = mapCamelCase + 'Province';
|
||||
const mapPostalCodeAlias = mapCamelCase + 'PostalCode';
|
||||
const mapPhoneNumberAlias = mapCamelCase + 'PhoneNumber';
|
||||
const mapNameAlias = `${mapCamelCase}Name`;
|
||||
const mapDescriptionAlias = `${mapCamelCase}Description`;
|
||||
const mapAddress1Alias = `${mapCamelCase}Address1`;
|
||||
const mapAddress2Alias = `${mapCamelCase}Address2`;
|
||||
const mapCityAlias = `${mapCamelCase}City`;
|
||||
const mapProvinceAlias = `${mapCamelCase}Province`;
|
||||
const mapPostalCodeAlias = `${mapCamelCase}PostalCode`;
|
||||
const mapPhoneNumberAlias = `${mapCamelCase}PhoneNumber`;
|
||||
const lotCamelCase = camelCase(configFunctions.getProperty('aliases.lot'));
|
||||
const lotIdAlias = lotCamelCase + 'Id';
|
||||
const lotNameAlias = lotCamelCase + 'Name';
|
||||
const lotTypeAlias = lotCamelCase + 'Type';
|
||||
const lotStatusAlias = lotCamelCase + 'Status';
|
||||
const lotIdAlias = `${lotCamelCase}Id`;
|
||||
const lotNameAlias = `${lotCamelCase}Name`;
|
||||
const lotTypeAlias = `${lotCamelCase}Type`;
|
||||
const lotStatusAlias = `${lotCamelCase}Status`;
|
||||
const occupancyCamelCase = camelCase(configFunctions.getProperty('aliases.occupancy'));
|
||||
const lotOccupancyIdAlias = occupancyCamelCase + 'Id';
|
||||
const occupancyTypeAlias = occupancyCamelCase + 'Type';
|
||||
const occupancyStartDateAlias = occupancyCamelCase + 'StartDate';
|
||||
const occupancyEndDateAlias = occupancyCamelCase + 'EndDate';
|
||||
const lotOccupancyIdAlias = `${occupancyCamelCase}Id`;
|
||||
const occupancyTypeAlias = `${occupancyCamelCase}Type`;
|
||||
const occupancyStartDateAlias = `${occupancyCamelCase}StartDate`;
|
||||
const occupancyEndDateAlias = `${occupancyCamelCase}EndDate`;
|
||||
const occupantCamelCase = camelCase(configFunctions.getProperty('aliases.occupant'));
|
||||
const lotOccupantIndexAlias = occupantCamelCase + 'Index';
|
||||
const lotOccupantTypeAlias = occupantCamelCase + 'Type';
|
||||
const occupantNameAlias = occupantCamelCase + 'Name';
|
||||
const occupantFamilyNameAlias = occupantCamelCase + 'FamilyName';
|
||||
const occupantAddress1Alias = occupantCamelCase + 'Address1';
|
||||
const occupantAddress2Alias = occupantCamelCase + 'Address2';
|
||||
const occupantCityAlias = occupantCamelCase + 'City';
|
||||
const occupantProvinceAlias = occupantCamelCase + 'Province';
|
||||
const occupantPostalCodeAlias = occupantCamelCase + 'PostalCode';
|
||||
const occupantPhoneNumberAlias = occupantCamelCase + 'PhoneNumber';
|
||||
const occupantEmailAddressAlias = occupantCamelCase + 'EmailAddress';
|
||||
const occupantCommentTitleAlias = occupantCamelCase + 'CommentTitle';
|
||||
const occupantCommentAlias = occupantCamelCase + 'Comment';
|
||||
const lotOccupantIndexAlias = `${occupantCamelCase}Index`;
|
||||
const lotOccupantTypeAlias = `${occupantCamelCase}Type`;
|
||||
const occupantNameAlias = `${occupantCamelCase}Name`;
|
||||
const occupantFamilyNameAlias = `${occupantCamelCase}FamilyName`;
|
||||
const occupantAddress1Alias = `${occupantCamelCase}Address1`;
|
||||
const occupantAddress2Alias = `${occupantCamelCase}Address2`;
|
||||
const occupantCityAlias = `${occupantCamelCase}City`;
|
||||
const occupantProvinceAlias = `${occupantCamelCase}Province`;
|
||||
const occupantPostalCodeAlias = `${occupantCamelCase}PostalCode`;
|
||||
const occupantPhoneNumberAlias = `${occupantCamelCase}PhoneNumber`;
|
||||
const occupantEmailAddressAlias = `${occupantCamelCase}EmailAddress`;
|
||||
const occupantCommentTitleAlias = `${occupantCamelCase}CommentTitle`;
|
||||
const occupantCommentAlias = `${occupantCamelCase}Comment`;
|
||||
export async function getReportData(reportName, reportParameters = {}) {
|
||||
let sql;
|
||||
const sqlParameters = [];
|
||||
|
|
|
|||
|
|
@ -1,54 +1,55 @@
|
|||
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
||||
/* eslint-disable no-case-declarations */
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import * as dateTimeFunctions from '@cityssm/utils-datetime'
|
||||
import camelCase from 'camelcase'
|
||||
|
||||
import * as configFunctions from '../helpers/functions.config.js'
|
||||
import * as dateTimeFunctions from '@cityssm/utils-datetime'
|
||||
|
||||
import camelCase from 'camelcase'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export type ReportParameters = Record<string, string | number>
|
||||
|
||||
const mapCamelCase = camelCase(configFunctions.getProperty('aliases.map'))
|
||||
const mapNameAlias = mapCamelCase + 'Name'
|
||||
const mapDescriptionAlias = mapCamelCase + 'Description'
|
||||
const mapAddress1Alias = mapCamelCase + 'Address1'
|
||||
const mapAddress2Alias = mapCamelCase + 'Address2'
|
||||
const mapCityAlias = mapCamelCase + 'City'
|
||||
const mapProvinceAlias = mapCamelCase + 'Province'
|
||||
const mapPostalCodeAlias = mapCamelCase + 'PostalCode'
|
||||
const mapPhoneNumberAlias = mapCamelCase + 'PhoneNumber'
|
||||
const mapNameAlias = `${mapCamelCase}Name`
|
||||
const mapDescriptionAlias = `${mapCamelCase}Description`
|
||||
const mapAddress1Alias = `${mapCamelCase}Address1`
|
||||
const mapAddress2Alias = `${mapCamelCase}Address2`
|
||||
const mapCityAlias = `${mapCamelCase}City`
|
||||
const mapProvinceAlias = `${mapCamelCase}Province`
|
||||
const mapPostalCodeAlias = `${mapCamelCase}PostalCode`
|
||||
const mapPhoneNumberAlias = `${mapCamelCase}PhoneNumber`
|
||||
|
||||
const lotCamelCase = camelCase(configFunctions.getProperty('aliases.lot'))
|
||||
const lotIdAlias = lotCamelCase + 'Id'
|
||||
const lotNameAlias = lotCamelCase + 'Name'
|
||||
const lotTypeAlias = lotCamelCase + 'Type'
|
||||
const lotStatusAlias = lotCamelCase + 'Status'
|
||||
const lotIdAlias = `${lotCamelCase}Id`
|
||||
const lotNameAlias = `${lotCamelCase}Name`
|
||||
const lotTypeAlias = `${lotCamelCase}Type`
|
||||
const lotStatusAlias = `${lotCamelCase}Status`
|
||||
|
||||
const occupancyCamelCase = camelCase(
|
||||
configFunctions.getProperty('aliases.occupancy')
|
||||
)
|
||||
const lotOccupancyIdAlias = occupancyCamelCase + 'Id'
|
||||
const occupancyTypeAlias = occupancyCamelCase + 'Type'
|
||||
const occupancyStartDateAlias = occupancyCamelCase + 'StartDate'
|
||||
const occupancyEndDateAlias = occupancyCamelCase + 'EndDate'
|
||||
const lotOccupancyIdAlias = `${occupancyCamelCase}Id`
|
||||
const occupancyTypeAlias = `${occupancyCamelCase}Type`
|
||||
const occupancyStartDateAlias = `${occupancyCamelCase}StartDate`
|
||||
const occupancyEndDateAlias = `${occupancyCamelCase}EndDate`
|
||||
|
||||
const occupantCamelCase = camelCase(
|
||||
configFunctions.getProperty('aliases.occupant')
|
||||
)
|
||||
const lotOccupantIndexAlias = occupantCamelCase + 'Index'
|
||||
const lotOccupantTypeAlias = occupantCamelCase + 'Type'
|
||||
const occupantNameAlias = occupantCamelCase + 'Name'
|
||||
const occupantFamilyNameAlias = occupantCamelCase + 'FamilyName'
|
||||
const occupantAddress1Alias = occupantCamelCase + 'Address1'
|
||||
const occupantAddress2Alias = occupantCamelCase + 'Address2'
|
||||
const occupantCityAlias = occupantCamelCase + 'City'
|
||||
const occupantProvinceAlias = occupantCamelCase + 'Province'
|
||||
const occupantPostalCodeAlias = occupantCamelCase + 'PostalCode'
|
||||
const occupantPhoneNumberAlias = occupantCamelCase + 'PhoneNumber'
|
||||
const occupantEmailAddressAlias = occupantCamelCase + 'EmailAddress'
|
||||
const occupantCommentTitleAlias = occupantCamelCase + 'CommentTitle'
|
||||
const occupantCommentAlias = occupantCamelCase + 'Comment'
|
||||
const lotOccupantIndexAlias = `${occupantCamelCase}Index`
|
||||
const lotOccupantTypeAlias = `${occupantCamelCase}Type`
|
||||
const occupantNameAlias = `${occupantCamelCase}Name`
|
||||
const occupantFamilyNameAlias = `${occupantCamelCase}FamilyName`
|
||||
const occupantAddress1Alias = `${occupantCamelCase}Address1`
|
||||
const occupantAddress2Alias = `${occupantCamelCase}Address2`
|
||||
const occupantCityAlias = `${occupantCamelCase}City`
|
||||
const occupantProvinceAlias = `${occupantCamelCase}Province`
|
||||
const occupantPostalCodeAlias = `${occupantCamelCase}PostalCode`
|
||||
const occupantPhoneNumberAlias = `${occupantCamelCase}PhoneNumber`
|
||||
const occupantEmailAddressAlias = `${occupantCamelCase}EmailAddress`
|
||||
const occupantCommentTitleAlias = `${occupantCamelCase}CommentTitle`
|
||||
const occupantCommentAlias = `${occupantCamelCase}Comment`
|
||||
|
||||
export async function getReportData(
|
||||
reportName: string,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
import type { WorkOrder } from '../types/recordTypes.js';
|
||||
interface WorkOrderOptions {
|
||||
includeLotsAndLotOccupancies: boolean;
|
||||
includeComments: boolean;
|
||||
includeMilestones: boolean;
|
||||
}
|
||||
export declare function getWorkOrderByWorkOrderNumber(workOrderNumber: string): Promise<recordTypes.WorkOrder | undefined>;
|
||||
export declare function getWorkOrder(workOrderId: number | string, options: WorkOrderOptions, connectedDatabase?: PoolConnection): Promise<recordTypes.WorkOrder | undefined>;
|
||||
export declare function getWorkOrderByWorkOrderNumber(workOrderNumber: string): Promise<WorkOrder | undefined>;
|
||||
export declare function getWorkOrder(workOrderId: number | string, options: WorkOrderOptions, connectedDatabase?: PoolConnection): Promise<WorkOrder | undefined>;
|
||||
export default getWorkOrder;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { dateIntegerToString } from '@cityssm/utils-datetime';
|
||||
import { getLots } from './getLots.js';
|
||||
import { getLotOccupancies } from './getLotOccupancies.js';
|
||||
import { getLots } from './getLots.js';
|
||||
import { getWorkOrderComments } from './getWorkOrderComments.js';
|
||||
import { getWorkOrderMilestones } from './getWorkOrderMilestones.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
const baseSQL = `select w.workOrderId,
|
||||
w.workOrderTypeId, t.workOrderType,
|
||||
w.workOrderNumber, w.workOrderDescription,
|
||||
|
|
|
|||
|
|
@ -1,17 +1,13 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import { dateIntegerToString } from '@cityssm/utils-datetime'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import { dateIntegerToString } from '@cityssm/utils-datetime'
|
||||
|
||||
import { getLots } from './getLots.js'
|
||||
import type { WorkOrder } from '../types/recordTypes.js'
|
||||
|
||||
import { getLotOccupancies } from './getLotOccupancies.js'
|
||||
|
||||
import { getLots } from './getLots.js'
|
||||
import { getWorkOrderComments } from './getWorkOrderComments.js'
|
||||
|
||||
import { getWorkOrderMilestones } from './getWorkOrderMilestones.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
interface WorkOrderOptions {
|
||||
includeLotsAndLotOccupancies: boolean
|
||||
|
|
@ -34,13 +30,13 @@ async function _getWorkOrder(
|
|||
workOrderIdOrWorkOrderNumber: number | string,
|
||||
options: WorkOrderOptions,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.WorkOrder | undefined> {
|
||||
): Promise<WorkOrder | undefined> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
|
||||
const workOrder = database.prepare(sql).get(workOrderIdOrWorkOrderNumber) as
|
||||
| recordTypes.WorkOrder
|
||||
| WorkOrder
|
||||
| undefined
|
||||
|
||||
if (workOrder !== undefined) {
|
||||
|
|
@ -79,7 +75,7 @@ async function _getWorkOrder(
|
|||
|
||||
if (options.includeComments) {
|
||||
workOrder.workOrderComments = await getWorkOrderComments(
|
||||
workOrder.workOrderId as number,
|
||||
workOrder.workOrderId,
|
||||
database
|
||||
)
|
||||
}
|
||||
|
|
@ -107,7 +103,7 @@ async function _getWorkOrder(
|
|||
|
||||
export async function getWorkOrderByWorkOrderNumber(
|
||||
workOrderNumber: string
|
||||
): Promise<recordTypes.WorkOrder | undefined> {
|
||||
): Promise<WorkOrder | undefined> {
|
||||
return await _getWorkOrder(
|
||||
baseSQL + ' and w.workOrderNumber = ?',
|
||||
workOrderNumber,
|
||||
|
|
@ -123,7 +119,7 @@ export async function getWorkOrder(
|
|||
workOrderId: number | string,
|
||||
options: WorkOrderOptions,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.WorkOrder | undefined> {
|
||||
): Promise<WorkOrder | undefined> {
|
||||
return await _getWorkOrder(
|
||||
baseSQL + ' and w.workOrderId = ?',
|
||||
workOrderId,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getWorkOrderComments(workOrderId: number | string, connectedDatabase?: PoolConnection): Promise<recordTypes.WorkOrderComment[]>;
|
||||
import type { WorkOrderComment } from '../types/recordTypes.js';
|
||||
export declare function getWorkOrderComments(workOrderId: number | string, connectedDatabase?: PoolConnection): Promise<WorkOrderComment[]>;
|
||||
export default getWorkOrderComments;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { dateIntegerToString, timeIntegerToString, timeIntegerToPeriodString } from '@cityssm/utils-datetime';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export async function getWorkOrderComments(workOrderId, connectedDatabase) {
|
||||
const database = connectedDatabase ?? (await acquireConnection());
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
||||
|
|
|
|||
|
|
@ -1,23 +1,26 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import {
|
||||
dateIntegerToString,
|
||||
timeIntegerToString,
|
||||
timeIntegerToPeriodString
|
||||
} from '@cityssm/utils-datetime'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import type { WorkOrderComment } from '../types/recordTypes.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function getWorkOrderComments(
|
||||
workOrderId: number | string,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.WorkOrderComment[]> {
|
||||
): Promise<WorkOrderComment[]> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
database.function('userFn_timeIntegerToString', timeIntegerToString)
|
||||
database.function('userFn_timeIntegerToPeriodString', timeIntegerToPeriodString)
|
||||
database.function(
|
||||
'userFn_timeIntegerToPeriodString',
|
||||
timeIntegerToPeriodString
|
||||
)
|
||||
|
||||
const workOrderComments = database
|
||||
.prepare(
|
||||
|
|
@ -33,7 +36,7 @@ export async function getWorkOrderComments(
|
|||
and workOrderId = ?
|
||||
order by workOrderCommentDate desc, workOrderCommentTime desc, workOrderCommentId desc`
|
||||
)
|
||||
.all(workOrderId) as recordTypes.WorkOrderComment[]
|
||||
.all(workOrderId) as WorkOrderComment[]
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getWorkOrderMilestoneTypes(): Promise<recordTypes.WorkOrderMilestoneType[]>;
|
||||
import type { WorkOrderMilestoneType } from '../types/recordTypes.js';
|
||||
export declare function getWorkOrderMilestoneTypes(): Promise<WorkOrderMilestoneType[]>;
|
||||
export default getWorkOrderMilestoneTypes;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
||||
/* eslint-disable @typescript-eslint/indent */
|
||||
|
||||
import type { WorkOrderMilestoneType } from '../types/recordTypes.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
|
||||
export async function getWorkOrderMilestoneTypes(): Promise<recordTypes.WorkOrderMilestoneType[]> {
|
||||
export async function getWorkOrderMilestoneTypes(): Promise<
|
||||
WorkOrderMilestoneType[]
|
||||
> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const workOrderMilestoneTypes = database
|
||||
|
|
@ -14,7 +18,7 @@ export async function getWorkOrderMilestoneTypes(): Promise<recordTypes.WorkOrde
|
|||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, workOrderMilestoneType`
|
||||
)
|
||||
.all() as recordTypes.WorkOrderMilestoneType[]
|
||||
.all() as WorkOrderMilestoneType[]
|
||||
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
import type { WorkOrderMilestone } from '../types/recordTypes.js';
|
||||
export interface WorkOrderMilestoneFilters {
|
||||
workOrderId?: number | string;
|
||||
workOrderMilestoneDateFilter?: 'upcomingMissed' | 'recent' | 'date' | 'blank' | 'notBlank';
|
||||
|
|
@ -11,5 +11,5 @@ interface WorkOrderMilestoneOptions {
|
|||
includeWorkOrders?: boolean;
|
||||
orderBy: 'completion' | 'date';
|
||||
}
|
||||
export declare function getWorkOrderMilestones(filters: WorkOrderMilestoneFilters, options: WorkOrderMilestoneOptions, connectedDatabase?: PoolConnection): Promise<recordTypes.WorkOrderMilestone[]>;
|
||||
export declare function getWorkOrderMilestones(filters: WorkOrderMilestoneFilters, options: WorkOrderMilestoneOptions, connectedDatabase?: PoolConnection): Promise<WorkOrderMilestone[]>;
|
||||
export default getWorkOrderMilestones;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { dateIntegerToString, dateStringToInteger, dateToInteger, timeIntegerToString, timeIntegerToPeriodString } from '@cityssm/utils-datetime';
|
||||
import * as configFunctions from '../helpers/functions.config.js';
|
||||
import { getLots } from './getLots.js';
|
||||
import { getLotOccupancies } from './getLotOccupancies.js';
|
||||
import { getLots } from './getLots.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
const commaSeparatedNumbersRegex = /^\d+(,\d+)*$/;
|
||||
function buildWhereClause(filters) {
|
||||
let sqlWhereClause = ' where m.recordDelete_timeMillis is null and w.recordDelete_timeMillis is null';
|
||||
|
|
@ -86,31 +86,33 @@ export async function getWorkOrderMilestones(filters, options, connectedDatabase
|
|||
break;
|
||||
}
|
||||
}
|
||||
const sql = 'select m.workOrderMilestoneId,' +
|
||||
' m.workOrderMilestoneTypeId, t.workOrderMilestoneType,' +
|
||||
' m.workOrderMilestoneDate, userFn_dateIntegerToString(m.workOrderMilestoneDate) as workOrderMilestoneDateString,' +
|
||||
' m.workOrderMilestoneTime,' +
|
||||
' userFn_timeIntegerToString(m.workOrderMilestoneTime) as workOrderMilestoneTimeString,' +
|
||||
' userFn_timeIntegerToPeriodString(m.workOrderMilestoneTime) as workOrderMilestoneTimePeriodString,' +
|
||||
' m.workOrderMilestoneDescription,' +
|
||||
' m.workOrderMilestoneCompletionDate, userFn_dateIntegerToString(m.workOrderMilestoneCompletionDate) as workOrderMilestoneCompletionDateString,' +
|
||||
' m.workOrderMilestoneCompletionTime,' +
|
||||
' userFn_timeIntegerToString(m.workOrderMilestoneCompletionTime) as workOrderMilestoneCompletionTimeString,' +
|
||||
' userFn_timeIntegerToPeriodString(m.workOrderMilestoneCompletionTime) as workOrderMilestoneCompletionTimePeriodString,' +
|
||||
(options.includeWorkOrders ?? false
|
||||
? ' m.workOrderId, w.workOrderNumber, wt.workOrderType, w.workOrderDescription,' +
|
||||
' w.workOrderOpenDate, userFn_dateIntegerToString(w.workOrderOpenDate) as workOrderOpenDateString,' +
|
||||
' w.workOrderCloseDate, userFn_dateIntegerToString(w.workOrderCloseDate) as workOrderCloseDateString,' +
|
||||
' w.recordUpdate_timeMillis as workOrderRecordUpdate_timeMillis,'
|
||||
: '') +
|
||||
' m.recordCreate_userName, m.recordCreate_timeMillis,' +
|
||||
' m.recordUpdate_userName, m.recordUpdate_timeMillis' +
|
||||
' from WorkOrderMilestones m' +
|
||||
' left join WorkOrderMilestoneTypes t on m.workOrderMilestoneTypeId = t.workOrderMilestoneTypeId' +
|
||||
' left join WorkOrders w on m.workOrderId = w.workOrderId' +
|
||||
' left join WorkOrderTypes wt on w.workOrderTypeId = wt.workOrderTypeId' +
|
||||
sqlWhereClause +
|
||||
orderByClause;
|
||||
const sql = `select m.workOrderMilestoneId,
|
||||
m.workOrderMilestoneTypeId, t.workOrderMilestoneType,
|
||||
m.workOrderMilestoneDate,
|
||||
userFn_dateIntegerToString(m.workOrderMilestoneDate) as workOrderMilestoneDateString,
|
||||
m.workOrderMilestoneTime,
|
||||
userFn_timeIntegerToString(m.workOrderMilestoneTime) as workOrderMilestoneTimeString,
|
||||
userFn_timeIntegerToPeriodString(m.workOrderMilestoneTime) as workOrderMilestoneTimePeriodString,
|
||||
m.workOrderMilestoneDescription,
|
||||
m.workOrderMilestoneCompletionDate,
|
||||
userFn_dateIntegerToString(m.workOrderMilestoneCompletionDate) as workOrderMilestoneCompletionDateString,
|
||||
m.workOrderMilestoneCompletionTime,
|
||||
userFn_timeIntegerToString(m.workOrderMilestoneCompletionTime) as workOrderMilestoneCompletionTimeString,
|
||||
userFn_timeIntegerToPeriodString(m.workOrderMilestoneCompletionTime) as workOrderMilestoneCompletionTimePeriodString,
|
||||
${options.includeWorkOrders ?? false
|
||||
? ` m.workOrderId, w.workOrderNumber, wt.workOrderType, w.workOrderDescription,
|
||||
w.workOrderOpenDate, userFn_dateIntegerToString(w.workOrderOpenDate) as workOrderOpenDateString,
|
||||
w.workOrderCloseDate, userFn_dateIntegerToString(w.workOrderCloseDate) as workOrderCloseDateString,
|
||||
w.recordUpdate_timeMillis as workOrderRecordUpdate_timeMillis,`
|
||||
: ''}
|
||||
m.recordCreate_userName, m.recordCreate_timeMillis,
|
||||
m.recordUpdate_userName, m.recordUpdate_timeMillis
|
||||
from WorkOrderMilestones m
|
||||
left join WorkOrderMilestoneTypes t on m.workOrderMilestoneTypeId = t.workOrderMilestoneTypeId
|
||||
left join WorkOrders w on m.workOrderId = w.workOrderId
|
||||
left join WorkOrderTypes wt on w.workOrderTypeId = wt.workOrderTypeId
|
||||
${sqlWhereClause}
|
||||
${orderByClause}`;
|
||||
const workOrderMilestones = database
|
||||
.prepare(sql)
|
||||
.all(sqlParameters);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
||||
/* eslint-disable @typescript-eslint/indent */
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import {
|
||||
dateIntegerToString,
|
||||
dateStringToInteger,
|
||||
|
|
@ -10,13 +8,14 @@ import {
|
|||
timeIntegerToString,
|
||||
timeIntegerToPeriodString
|
||||
} from '@cityssm/utils-datetime'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import * as configFunctions from '../helpers/functions.config.js'
|
||||
import type { WorkOrderMilestone } from '../types/recordTypes.js'
|
||||
|
||||
import { getLots } from './getLots.js'
|
||||
import { getLotOccupancies } from './getLotOccupancies.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import { getLots } from './getLots.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export interface WorkOrderMilestoneFilters {
|
||||
workOrderId?: number | string
|
||||
|
|
@ -136,7 +135,7 @@ export async function getWorkOrderMilestones(
|
|||
filters: WorkOrderMilestoneFilters,
|
||||
options: WorkOrderMilestoneOptions,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<recordTypes.WorkOrderMilestone[]> {
|
||||
): Promise<WorkOrderMilestone[]> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
|
|
@ -171,36 +170,39 @@ export async function getWorkOrderMilestones(
|
|||
}
|
||||
|
||||
// Query
|
||||
const sql =
|
||||
'select m.workOrderMilestoneId,' +
|
||||
' m.workOrderMilestoneTypeId, t.workOrderMilestoneType,' +
|
||||
' m.workOrderMilestoneDate, userFn_dateIntegerToString(m.workOrderMilestoneDate) as workOrderMilestoneDateString,' +
|
||||
' m.workOrderMilestoneTime,' +
|
||||
' userFn_timeIntegerToString(m.workOrderMilestoneTime) as workOrderMilestoneTimeString,' +
|
||||
' userFn_timeIntegerToPeriodString(m.workOrderMilestoneTime) as workOrderMilestoneTimePeriodString,' +
|
||||
' m.workOrderMilestoneDescription,' +
|
||||
' m.workOrderMilestoneCompletionDate, userFn_dateIntegerToString(m.workOrderMilestoneCompletionDate) as workOrderMilestoneCompletionDateString,' +
|
||||
' m.workOrderMilestoneCompletionTime,' +
|
||||
' userFn_timeIntegerToString(m.workOrderMilestoneCompletionTime) as workOrderMilestoneCompletionTimeString,' +
|
||||
' userFn_timeIntegerToPeriodString(m.workOrderMilestoneCompletionTime) as workOrderMilestoneCompletionTimePeriodString,' +
|
||||
(options.includeWorkOrders ?? false
|
||||
? ' m.workOrderId, w.workOrderNumber, wt.workOrderType, w.workOrderDescription,' +
|
||||
' w.workOrderOpenDate, userFn_dateIntegerToString(w.workOrderOpenDate) as workOrderOpenDateString,' +
|
||||
' w.workOrderCloseDate, userFn_dateIntegerToString(w.workOrderCloseDate) as workOrderCloseDateString,' +
|
||||
' w.recordUpdate_timeMillis as workOrderRecordUpdate_timeMillis,'
|
||||
: '') +
|
||||
' m.recordCreate_userName, m.recordCreate_timeMillis,' +
|
||||
' m.recordUpdate_userName, m.recordUpdate_timeMillis' +
|
||||
' from WorkOrderMilestones m' +
|
||||
' left join WorkOrderMilestoneTypes t on m.workOrderMilestoneTypeId = t.workOrderMilestoneTypeId' +
|
||||
' left join WorkOrders w on m.workOrderId = w.workOrderId' +
|
||||
' left join WorkOrderTypes wt on w.workOrderTypeId = wt.workOrderTypeId' +
|
||||
sqlWhereClause +
|
||||
orderByClause
|
||||
const sql = `select m.workOrderMilestoneId,
|
||||
m.workOrderMilestoneTypeId, t.workOrderMilestoneType,
|
||||
m.workOrderMilestoneDate,
|
||||
userFn_dateIntegerToString(m.workOrderMilestoneDate) as workOrderMilestoneDateString,
|
||||
m.workOrderMilestoneTime,
|
||||
userFn_timeIntegerToString(m.workOrderMilestoneTime) as workOrderMilestoneTimeString,
|
||||
userFn_timeIntegerToPeriodString(m.workOrderMilestoneTime) as workOrderMilestoneTimePeriodString,
|
||||
m.workOrderMilestoneDescription,
|
||||
m.workOrderMilestoneCompletionDate,
|
||||
userFn_dateIntegerToString(m.workOrderMilestoneCompletionDate) as workOrderMilestoneCompletionDateString,
|
||||
m.workOrderMilestoneCompletionTime,
|
||||
userFn_timeIntegerToString(m.workOrderMilestoneCompletionTime) as workOrderMilestoneCompletionTimeString,
|
||||
userFn_timeIntegerToPeriodString(m.workOrderMilestoneCompletionTime) as workOrderMilestoneCompletionTimePeriodString,
|
||||
${
|
||||
options.includeWorkOrders ?? false
|
||||
? ` m.workOrderId, w.workOrderNumber, wt.workOrderType, w.workOrderDescription,
|
||||
w.workOrderOpenDate, userFn_dateIntegerToString(w.workOrderOpenDate) as workOrderOpenDateString,
|
||||
w.workOrderCloseDate, userFn_dateIntegerToString(w.workOrderCloseDate) as workOrderCloseDateString,
|
||||
w.recordUpdate_timeMillis as workOrderRecordUpdate_timeMillis,`
|
||||
: ''
|
||||
}
|
||||
m.recordCreate_userName, m.recordCreate_timeMillis,
|
||||
m.recordUpdate_userName, m.recordUpdate_timeMillis
|
||||
from WorkOrderMilestones m
|
||||
left join WorkOrderMilestoneTypes t on m.workOrderMilestoneTypeId = t.workOrderMilestoneTypeId
|
||||
left join WorkOrders w on m.workOrderId = w.workOrderId
|
||||
left join WorkOrderTypes wt on w.workOrderTypeId = wt.workOrderTypeId
|
||||
${sqlWhereClause}
|
||||
${orderByClause}`
|
||||
|
||||
const workOrderMilestones = database
|
||||
.prepare(sql)
|
||||
.all(sqlParameters) as recordTypes.WorkOrderMilestone[]
|
||||
.all(sqlParameters) as WorkOrderMilestone[]
|
||||
|
||||
if (options.includeWorkOrders ?? false) {
|
||||
for (const workOrderMilestone of workOrderMilestones) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
export declare function getWorkOrderTypes(): Promise<recordTypes.WorkOrderType[]>;
|
||||
import type { WorkOrderType } from '../types/recordTypes.js';
|
||||
export declare function getWorkOrderTypes(): Promise<WorkOrderType[]>;
|
||||
export default getWorkOrderTypes;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
||||
/* eslint-disable @typescript-eslint/indent */
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import type { WorkOrderType } from '../types/recordTypes.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
|
||||
export async function getWorkOrderTypes(): Promise<
|
||||
recordTypes.WorkOrderType[]
|
||||
> {
|
||||
export async function getWorkOrderTypes(): Promise<WorkOrderType[]> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const workOrderTypes = database
|
||||
|
|
@ -18,7 +16,7 @@ export async function getWorkOrderTypes(): Promise<
|
|||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, workOrderType`
|
||||
)
|
||||
.all() as recordTypes.WorkOrderType[]
|
||||
.all() as WorkOrderType[]
|
||||
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
import type * as recordTypes from '../types/recordTypes.js';
|
||||
import type { WorkOrder } from '../types/recordTypes.js';
|
||||
interface GetWorkOrdersFilters {
|
||||
workOrderTypeId?: number | string;
|
||||
workOrderOpenStatus?: '' | 'open' | 'closed';
|
||||
|
|
@ -17,6 +17,6 @@ interface GetWorkOrdersOptions {
|
|||
}
|
||||
export declare function getWorkOrders(filters: GetWorkOrdersFilters, options: GetWorkOrdersOptions, connectedDatabase?: PoolConnection): Promise<{
|
||||
count: number;
|
||||
workOrders: recordTypes.WorkOrder[];
|
||||
workOrders: WorkOrder[];
|
||||
}>;
|
||||
export default getWorkOrders;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { dateIntegerToString, dateStringToInteger } from '@cityssm/utils-datetime';
|
||||
import { getWorkOrderComments } from './getWorkOrderComments.js';
|
||||
import { getLots } from './getLots.js';
|
||||
import { getLotOccupancies } from './getLotOccupancies.js';
|
||||
import { getWorkOrderMilestones } from './getWorkOrderMilestones.js';
|
||||
import { getLotNameWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js';
|
||||
import { getLotOccupancies } from './getLotOccupancies.js';
|
||||
import { getLots } from './getLots.js';
|
||||
import { getWorkOrderComments } from './getWorkOrderComments.js';
|
||||
import { getWorkOrderMilestones } from './getWorkOrderMilestones.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
function buildWhereClause(filters) {
|
||||
let sqlWhereClause = ' where w.recordDelete_timeMillis is null';
|
||||
const sqlParameters = [];
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
||||
/* eslint-disable @typescript-eslint/indent */
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import {
|
||||
dateIntegerToString,
|
||||
dateStringToInteger
|
||||
} from '@cityssm/utils-datetime'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import { getWorkOrderComments } from './getWorkOrderComments.js'
|
||||
import { getLots } from './getLots.js'
|
||||
import { getLotOccupancies } from './getLotOccupancies.js'
|
||||
import { getWorkOrderMilestones } from './getWorkOrderMilestones.js'
|
||||
|
||||
import type * as recordTypes from '../types/recordTypes.js'
|
||||
import {
|
||||
getLotNameWhereClause,
|
||||
getOccupantNameWhereClause
|
||||
} from '../helpers/functions.sqlFilters.js'
|
||||
import type { WorkOrder } from '../types/recordTypes.js'
|
||||
|
||||
import { getLotOccupancies } from './getLotOccupancies.js'
|
||||
import { getLots } from './getLots.js'
|
||||
import { getWorkOrderComments } from './getWorkOrderComments.js'
|
||||
import { getWorkOrderMilestones } from './getWorkOrderMilestones.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
interface GetWorkOrdersFilters {
|
||||
workOrderTypeId?: number | string
|
||||
|
|
@ -100,10 +100,10 @@ function buildWhereClause(filters: GetWorkOrdersFilters): {
|
|||
}
|
||||
|
||||
async function addInclusions(
|
||||
workOrder: recordTypes.WorkOrder,
|
||||
workOrder: WorkOrder,
|
||||
options: GetWorkOrdersOptions,
|
||||
database: PoolConnection
|
||||
): Promise<recordTypes.WorkOrder> {
|
||||
): Promise<WorkOrder> {
|
||||
if (options.includeComments ?? false) {
|
||||
workOrder.workOrderComments = await getWorkOrderComments(
|
||||
workOrder.workOrderId!,
|
||||
|
|
@ -169,7 +169,7 @@ export async function getWorkOrders(
|
|||
filters: GetWorkOrdersFilters,
|
||||
options: GetWorkOrdersOptions,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<{ count: number; workOrders: recordTypes.WorkOrder[] }> {
|
||||
): Promise<{ count: number; workOrders: WorkOrder[] }> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
|
|
@ -186,7 +186,7 @@ export async function getWorkOrders(
|
|||
.get(sqlParameters) as { recordCount: number }
|
||||
).recordCount
|
||||
|
||||
let workOrders: recordTypes.WorkOrder[] = []
|
||||
let workOrders: WorkOrder[] = []
|
||||
|
||||
if (count > 0) {
|
||||
workOrders = database
|
||||
|
|
@ -221,7 +221,7 @@ export async function getWorkOrders(
|
|||
: ` limit ${options.limit} offset ${options.offset}`
|
||||
}`
|
||||
)
|
||||
.all(sqlParameters) as recordTypes.WorkOrder[]
|
||||
.all(sqlParameters) as WorkOrder[]
|
||||
}
|
||||
|
||||
const hasInclusions =
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { getFee } from './getFee.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
export async function moveFeeDown(feeId) {
|
||||
const database = await acquireConnection();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
|
||||
import { getFee } from './getFee.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
export async function moveFeeDown(feeId: number | string): Promise<boolean> {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
function getCurrentField(lotTypeFieldId, connectedDatabase) {
|
||||
const currentField = connectedDatabase
|
||||
return connectedDatabase
|
||||
.prepare('select lotTypeId, orderNumber from LotTypeFields where lotTypeFieldId = ?')
|
||||
.get(lotTypeFieldId);
|
||||
return currentField;
|
||||
}
|
||||
export async function moveLotTypeFieldDown(lotTypeFieldId) {
|
||||
const database = await acquireConnection();
|
||||
|
|
|
|||
|
|
@ -1,20 +1,19 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
function getCurrentField(
|
||||
lotTypeFieldId: number | string,
|
||||
connectedDatabase: PoolConnection
|
||||
): { lotTypeId?: number; orderNumber: number } {
|
||||
const currentField = connectedDatabase
|
||||
return connectedDatabase
|
||||
.prepare(
|
||||
'select lotTypeId, orderNumber from LotTypeFields where lotTypeFieldId = ?'
|
||||
)
|
||||
.get(lotTypeFieldId) as { lotTypeId?: number; orderNumber: number }
|
||||
|
||||
return currentField
|
||||
}
|
||||
|
||||
export async function moveLotTypeFieldDown(
|
||||
|
|
|
|||
|
|
@ -1,27 +1,24 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
function getCurrentField(occupancyTypeFieldId, connectedDatabase) {
|
||||
const currentField = connectedDatabase
|
||||
return connectedDatabase
|
||||
.prepare(`select occupancyTypeId, orderNumber
|
||||
from OccupancyTypeFields
|
||||
where occupancyTypeFieldId = ?`)
|
||||
.get(occupancyTypeFieldId);
|
||||
return currentField;
|
||||
}
|
||||
export async function moveOccupancyTypeFieldDown(occupancyTypeFieldId) {
|
||||
const database = await acquireConnection();
|
||||
const currentField = getCurrentField(occupancyTypeFieldId, database);
|
||||
database
|
||||
.prepare('update OccupancyTypeFields' +
|
||||
' set orderNumber = orderNumber - 1' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
(currentField.occupancyTypeId
|
||||
? " and occupancyTypeId = '" +
|
||||
currentField.occupancyTypeId.toString() +
|
||||
"'"
|
||||
: ' and occupancyTypeId is null') +
|
||||
' and orderNumber = ? + 1')
|
||||
.prepare(`update OccupancyTypeFields
|
||||
set orderNumber = orderNumber - 1
|
||||
where recordDelete_timeMillis is null
|
||||
${currentField.occupancyTypeId === undefined
|
||||
? ' and occupancyTypeId is null'
|
||||
: ` and occupancyTypeId = '${currentField.occupancyTypeId.toString()}'`}
|
||||
and orderNumber = ? + 1`)
|
||||
.run(currentField.orderNumber);
|
||||
const success = updateRecordOrderNumber('OccupancyTypeFields', occupancyTypeFieldId, currentField.orderNumber + 1, database);
|
||||
database.release();
|
||||
|
|
@ -36,24 +33,23 @@ export async function moveOccupancyTypeFieldDownToBottom(occupancyTypeFieldId) {
|
|||
occupancyTypeParameters.push(currentField.occupancyTypeId);
|
||||
}
|
||||
const maxOrderNumber = database
|
||||
.prepare('select max(orderNumber) as maxOrderNumber' +
|
||||
' from OccupancyTypeFields' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
(currentField.occupancyTypeId
|
||||
? ' and occupancyTypeId = ?'
|
||||
: ' and occupancyTypeId is null'))
|
||||
.prepare(`select max(orderNumber) as maxOrderNumber
|
||||
from OccupancyTypeFields
|
||||
where recordDelete_timeMillis is null
|
||||
${currentField.occupancyTypeId === undefined
|
||||
? ' and occupancyTypeId is null'
|
||||
: ' and occupancyTypeId = ?'}`)
|
||||
.get(occupancyTypeParameters).maxOrderNumber;
|
||||
if (currentField.orderNumber !== maxOrderNumber) {
|
||||
updateRecordOrderNumber('OccupancyTypeFields', occupancyTypeFieldId, maxOrderNumber + 1, database);
|
||||
occupancyTypeParameters.push(currentField.orderNumber);
|
||||
database
|
||||
.prepare('update OccupancyTypeFields' +
|
||||
' set orderNumber = orderNumber - 1' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
(currentField.occupancyTypeId
|
||||
? ' and occupancyTypeId = ?'
|
||||
: ' and occupancyTypeId is null') +
|
||||
' and orderNumber > ?')
|
||||
.prepare(`update OccupancyTypeFields set orderNumber = orderNumber - 1
|
||||
where recordDelete_timeMillis is null
|
||||
${currentField.occupancyTypeId === undefined
|
||||
? ' and occupancyTypeId is null'
|
||||
: ' and occupancyTypeId = ?'}
|
||||
and orderNumber > ?`)
|
||||
.run(occupancyTypeParameters);
|
||||
}
|
||||
database.release();
|
||||
|
|
@ -68,15 +64,13 @@ export async function moveOccupancyTypeFieldUp(occupancyTypeFieldId) {
|
|||
return true;
|
||||
}
|
||||
database
|
||||
.prepare('update OccupancyTypeFields' +
|
||||
' set orderNumber = orderNumber + 1' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
(currentField.occupancyTypeId
|
||||
? " and occupancyTypeId = '" +
|
||||
currentField.occupancyTypeId.toString() +
|
||||
"'"
|
||||
: ' and occupancyTypeId is null') +
|
||||
' and orderNumber = ? - 1')
|
||||
.prepare(`update OccupancyTypeFields
|
||||
set orderNumber = orderNumber + 1
|
||||
where recordDelete_timeMillis is null
|
||||
${currentField.occupancyTypeId === undefined
|
||||
? ' and occupancyTypeId is null'
|
||||
: ` and occupancyTypeId = '${currentField.occupancyTypeId.toString()}'`}
|
||||
and orderNumber = ? - 1`)
|
||||
.run(currentField.orderNumber);
|
||||
const success = updateRecordOrderNumber('OccupancyTypeFields', occupancyTypeFieldId, currentField.orderNumber - 1, database);
|
||||
database.release();
|
||||
|
|
@ -94,13 +88,12 @@ export async function moveOccupancyTypeFieldUpToTop(occupancyTypeFieldId) {
|
|||
}
|
||||
occupancyTypeParameters.push(currentField.orderNumber);
|
||||
database
|
||||
.prepare('update OccupancyTypeFields' +
|
||||
' set orderNumber = orderNumber + 1' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
(currentField.occupancyTypeId
|
||||
.prepare(`update OccupancyTypeFields
|
||||
set orderNumber = orderNumber + 1
|
||||
where recordDelete_timeMillis is null
|
||||
${currentField.occupancyTypeId
|
||||
? ' and occupancyTypeId = ?'
|
||||
: ' and occupancyTypeId is null') +
|
||||
' and orderNumber < ?')
|
||||
: ' and occupancyTypeId is null'} and orderNumber < ?`)
|
||||
.run(occupancyTypeParameters);
|
||||
}
|
||||
database.release();
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
function getCurrentField(
|
||||
occupancyTypeFieldId: number,
|
||||
connectedDatabase: PoolConnection
|
||||
): { occupancyTypeId?: number; orderNumber: number } {
|
||||
const currentField = connectedDatabase
|
||||
return connectedDatabase
|
||||
.prepare(
|
||||
`select occupancyTypeId, orderNumber
|
||||
from OccupancyTypeFields
|
||||
|
|
@ -18,8 +19,6 @@ function getCurrentField(
|
|||
occupancyTypeId?: number
|
||||
orderNumber: number
|
||||
}
|
||||
|
||||
return currentField
|
||||
}
|
||||
|
||||
export async function moveOccupancyTypeFieldDown(
|
||||
|
|
@ -31,15 +30,15 @@ export async function moveOccupancyTypeFieldDown(
|
|||
|
||||
database
|
||||
.prepare(
|
||||
'update OccupancyTypeFields' +
|
||||
' set orderNumber = orderNumber - 1' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
(currentField.occupancyTypeId
|
||||
? " and occupancyTypeId = '" +
|
||||
currentField.occupancyTypeId.toString() +
|
||||
"'"
|
||||
: ' and occupancyTypeId is null') +
|
||||
' and orderNumber = ? + 1'
|
||||
`update OccupancyTypeFields
|
||||
set orderNumber = orderNumber - 1
|
||||
where recordDelete_timeMillis is null
|
||||
${
|
||||
currentField.occupancyTypeId === undefined
|
||||
? ' and occupancyTypeId is null'
|
||||
: ` and occupancyTypeId = '${currentField.occupancyTypeId.toString()}'`
|
||||
}
|
||||
and orderNumber = ? + 1`
|
||||
)
|
||||
.run(currentField.orderNumber)
|
||||
|
||||
|
|
@ -73,12 +72,14 @@ export async function moveOccupancyTypeFieldDownToBottom(
|
|||
const maxOrderNumber: number = (
|
||||
database
|
||||
.prepare(
|
||||
'select max(orderNumber) as maxOrderNumber' +
|
||||
' from OccupancyTypeFields' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
(currentField.occupancyTypeId
|
||||
? ' and occupancyTypeId = ?'
|
||||
: ' and occupancyTypeId is null')
|
||||
`select max(orderNumber) as maxOrderNumber
|
||||
from OccupancyTypeFields
|
||||
where recordDelete_timeMillis is null
|
||||
${
|
||||
currentField.occupancyTypeId === undefined
|
||||
? ' and occupancyTypeId is null'
|
||||
: ' and occupancyTypeId = ?'
|
||||
}`
|
||||
)
|
||||
.get(occupancyTypeParameters) as { maxOrderNumber: number }
|
||||
).maxOrderNumber
|
||||
|
|
@ -95,13 +96,14 @@ export async function moveOccupancyTypeFieldDownToBottom(
|
|||
|
||||
database
|
||||
.prepare(
|
||||
'update OccupancyTypeFields' +
|
||||
' set orderNumber = orderNumber - 1' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
(currentField.occupancyTypeId
|
||||
? ' and occupancyTypeId = ?'
|
||||
: ' and occupancyTypeId is null') +
|
||||
' and orderNumber > ?'
|
||||
`update OccupancyTypeFields set orderNumber = orderNumber - 1
|
||||
where recordDelete_timeMillis is null
|
||||
${
|
||||
currentField.occupancyTypeId === undefined
|
||||
? ' and occupancyTypeId is null'
|
||||
: ' and occupancyTypeId = ?'
|
||||
}
|
||||
and orderNumber > ?`
|
||||
)
|
||||
.run(occupancyTypeParameters)
|
||||
}
|
||||
|
|
@ -127,15 +129,15 @@ export async function moveOccupancyTypeFieldUp(
|
|||
|
||||
database
|
||||
.prepare(
|
||||
'update OccupancyTypeFields' +
|
||||
' set orderNumber = orderNumber + 1' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
(currentField.occupancyTypeId
|
||||
? " and occupancyTypeId = '" +
|
||||
currentField.occupancyTypeId.toString() +
|
||||
"'"
|
||||
: ' and occupancyTypeId is null') +
|
||||
' and orderNumber = ? - 1'
|
||||
`update OccupancyTypeFields
|
||||
set orderNumber = orderNumber + 1
|
||||
where recordDelete_timeMillis is null
|
||||
${
|
||||
currentField.occupancyTypeId === undefined
|
||||
? ' and occupancyTypeId is null'
|
||||
: ` and occupancyTypeId = '${currentField.occupancyTypeId.toString()}'`
|
||||
}
|
||||
and orderNumber = ? - 1`
|
||||
)
|
||||
.run(currentField.orderNumber)
|
||||
|
||||
|
|
@ -178,13 +180,14 @@ export async function moveOccupancyTypeFieldUpToTop(
|
|||
|
||||
database
|
||||
.prepare(
|
||||
'update OccupancyTypeFields' +
|
||||
' set orderNumber = orderNumber + 1' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
(currentField.occupancyTypeId
|
||||
`update OccupancyTypeFields
|
||||
set orderNumber = orderNumber + 1
|
||||
where recordDelete_timeMillis is null
|
||||
${
|
||||
currentField.occupancyTypeId
|
||||
? ' and occupancyTypeId = ?'
|
||||
: ' and occupancyTypeId is null') +
|
||||
' and orderNumber < ?'
|
||||
: ' and occupancyTypeId is null'
|
||||
} and orderNumber < ?`
|
||||
)
|
||||
.run(occupancyTypeParameters)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export async function moveOccupancyTypePrintDown(occupancyTypeId, printEJS) {
|
||||
const database = await acquireConnection();
|
||||
const currentOrderNumber = database
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function moveOccupancyTypePrintDown(
|
||||
occupancyTypeId: number | string,
|
||||
printEJS: string
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export async function moveOccupancyTypePrintUp(occupancyTypeId, printEJS) {
|
||||
const database = await acquireConnection();
|
||||
const currentOrderNumber = database
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function moveOccupancyTypePrintUp(
|
||||
occupancyTypeId: number | string,
|
||||
printEJS: string
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { acquireConnection } from './pool.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
const recordIdColumns = new Map();
|
||||
recordIdColumns.set('FeeCategories', 'feeCategoryId');
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import type sqlite from 'better-sqlite3'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
||||
|
||||
type RecordTable =
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
import { Pool } from 'better-sqlite-pool';
|
||||
import { lotOccupancyDB as databasePath } from '../data/databasePaths.js';
|
||||
import exitHook from 'exit-hook';
|
||||
import Debug from 'debug';
|
||||
import exitHook from 'exit-hook';
|
||||
import { lotOccupancyDB as databasePath } from '../data/databasePaths.js';
|
||||
const debug = Debug('lot-occupancy-system:lotOccupancyDB:pool');
|
||||
const pool = new Pool(databasePath);
|
||||
export async function acquireConnection() {
|
||||
const connection = await pool.acquire();
|
||||
return connection;
|
||||
return await pool.acquire();
|
||||
}
|
||||
exitHook(() => {
|
||||
debug('Closing database pool');
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
import { Pool, type PoolConnection } from 'better-sqlite-pool'
|
||||
import Debug from 'debug'
|
||||
import exitHook from 'exit-hook'
|
||||
|
||||
import { lotOccupancyDB as databasePath } from '../data/databasePaths.js'
|
||||
|
||||
import exitHook from 'exit-hook'
|
||||
|
||||
import Debug from 'debug'
|
||||
const debug = Debug('lot-occupancy-system:lotOccupancyDB:pool')
|
||||
|
||||
const pool = new Pool(databasePath)
|
||||
|
||||
export async function acquireConnection(): Promise<PoolConnection> {
|
||||
const connection = await pool.acquire()
|
||||
return connection
|
||||
return await pool.acquire()
|
||||
}
|
||||
|
||||
exitHook(() => {
|
||||
|
|
|
|||
|
|
@ -20,13 +20,13 @@ export async function updateLot(lotForm, user) {
|
|||
if (result.changes > 0) {
|
||||
const lotTypeFieldIds = (lotForm.lotTypeFieldIds ?? '').split(',');
|
||||
for (const lotTypeFieldId of lotTypeFieldIds) {
|
||||
const lotFieldValue = lotForm['lotFieldValue_' + lotTypeFieldId];
|
||||
const lotFieldValue = lotForm[`lotFieldValue_${lotTypeFieldId}`];
|
||||
await ((lotFieldValue ?? '') === ''
|
||||
? deleteLotField(lotForm.lotId, lotTypeFieldId, user, database)
|
||||
: addOrUpdateLotField({
|
||||
lotId: lotForm.lotId,
|
||||
lotTypeFieldId,
|
||||
lotFieldValue: lotFieldValue
|
||||
lotFieldValue: lotFieldValue ?? ''
|
||||
}, user, database));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ export async function updateLot(
|
|||
const lotTypeFieldIds = (lotForm.lotTypeFieldIds ?? '').split(',')
|
||||
|
||||
for (const lotTypeFieldId of lotTypeFieldIds) {
|
||||
const lotFieldValue = lotForm['lotFieldValue_' + lotTypeFieldId] as
|
||||
const lotFieldValue = lotForm[`lotFieldValue_${lotTypeFieldId}`] as
|
||||
| string
|
||||
| undefined
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ export async function updateLot(
|
|||
{
|
||||
lotId: lotForm.lotId,
|
||||
lotTypeFieldId,
|
||||
lotFieldValue: lotFieldValue!
|
||||
lotFieldValue: lotFieldValue ?? ''
|
||||
},
|
||||
user,
|
||||
database
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ export async function updateLotOccupancy(lotOccupancyForm, user) {
|
|||
if (result.changes > 0) {
|
||||
const occupancyTypeFieldIds = (lotOccupancyForm.occupancyTypeFieldIds ?? '').split(',');
|
||||
for (const occupancyTypeFieldId of occupancyTypeFieldIds) {
|
||||
const lotOccupancyFieldValue = lotOccupancyForm['lotOccupancyFieldValue_' + occupancyTypeFieldId];
|
||||
const lotOccupancyFieldValue = lotOccupancyForm[`lotOccupancyFieldValue_${occupancyTypeFieldId}`];
|
||||
await ((lotOccupancyFieldValue ?? '') === ''
|
||||
? deleteLotOccupancyField(lotOccupancyForm.lotOccupancyId, occupancyTypeFieldId, user, database)
|
||||
: addOrUpdateLotOccupancyField({
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue