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