updated type syntax
parent
7ba2712d93
commit
93de43ae62
|
|
@ -48,18 +48,18 @@ export async function addLotOccupancyFee(
|
|||
}
|
||||
|
||||
// Check if record already exists
|
||||
const record: {
|
||||
feeAmount?: number
|
||||
taxAmount?: number
|
||||
recordDelete_timeMillis?: number
|
||||
} = database
|
||||
const record = database
|
||||
.prepare(
|
||||
`select feeAmount, taxAmount, recordDelete_timeMillis
|
||||
from LotOccupancyFees
|
||||
where lotOccupancyId = ?
|
||||
and feeId = ?`
|
||||
)
|
||||
.get(lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId)
|
||||
.get(lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId) as {
|
||||
feeAmount?: number
|
||||
taxAmount?: number
|
||||
recordDelete_timeMillis?: number
|
||||
}
|
||||
|
||||
if (record) {
|
||||
if (record.recordDelete_timeMillis) {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export async function addLotOccupancyOccupant(
|
|||
|
||||
let lotOccupantIndex = 0
|
||||
|
||||
const maxIndexResult: { lotOccupantIndex: number } | undefined = database
|
||||
const maxIndexResult = database
|
||||
.prepare(
|
||||
`select lotOccupantIndex
|
||||
from LotOccupancyOccupants
|
||||
|
|
@ -35,7 +35,9 @@ export async function addLotOccupancyOccupant(
|
|||
order by lotOccupantIndex desc
|
||||
limit 1`
|
||||
)
|
||||
.get(lotOccupancyOccupantForm.lotOccupancyId)
|
||||
.get(lotOccupancyOccupantForm.lotOccupancyId) as
|
||||
| { lotOccupantIndex: number }
|
||||
| undefined
|
||||
|
||||
if (maxIndexResult !== undefined) {
|
||||
lotOccupantIndex = maxIndexResult.lotOccupantIndex + 1
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export async function addLotOccupancyTransaction(
|
|||
|
||||
let transactionIndex = 0
|
||||
|
||||
const maxIndexResult: { transactionIndex: number } | undefined = database
|
||||
const maxIndexResult = database
|
||||
.prepare(
|
||||
`select transactionIndex
|
||||
from LotOccupancyTransactions
|
||||
|
|
@ -34,7 +34,9 @@ export async function addLotOccupancyTransaction(
|
|||
order by transactionIndex desc
|
||||
limit 1`
|
||||
)
|
||||
.get(lotOccupancyTransactionForm.lotOccupancyId)
|
||||
.get(lotOccupancyTransactionForm.lotOccupancyId) as
|
||||
| { transactionIndex: number }
|
||||
| undefined
|
||||
|
||||
if (maxIndexResult !== undefined) {
|
||||
transactionIndex = maxIndexResult.transactionIndex + 1
|
||||
|
|
|
|||
|
|
@ -15,14 +15,16 @@ export async function addWorkOrderLot(
|
|||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
const row: { recordDelete_timeMillis?: number } = database
|
||||
const row = database
|
||||
.prepare(
|
||||
`select recordDelete_timeMillis
|
||||
from WorkOrderLots
|
||||
where workOrderId = ?
|
||||
and lotId = ?`
|
||||
)
|
||||
.get(workOrderLotForm.workOrderId, workOrderLotForm.lotId)
|
||||
.get(workOrderLotForm.workOrderId, workOrderLotForm.lotId) as {
|
||||
recordDelete_timeMillis?: number
|
||||
}
|
||||
|
||||
if (row === undefined) {
|
||||
database
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export async function getFee(
|
|||
where f.recordDelete_timeMillis is null
|
||||
and f.feeId = ?`
|
||||
)
|
||||
.get(feeId)
|
||||
.get(feeId) as recordTypes.Fee
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -47,14 +47,14 @@ export async function getFeeCategories(
|
|||
sqlParameters.push(filters.lotTypeId)
|
||||
}
|
||||
|
||||
const feeCategories: recordTypes.FeeCategory[] = database
|
||||
const feeCategories = database
|
||||
.prepare(
|
||||
'select feeCategoryId, feeCategory, orderNumber' +
|
||||
' from FeeCategories' +
|
||||
sqlWhereClause +
|
||||
' order by orderNumber, feeCategory'
|
||||
)
|
||||
.all(sqlParameters)
|
||||
.all(sqlParameters) as recordTypes.FeeCategory[]
|
||||
|
||||
if (options.includeFees ?? false) {
|
||||
let expectedOrderNumber = 0
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ export async function getFees(
|
|||
sqlParameters.push(additionalFilters.lotTypeId)
|
||||
}
|
||||
|
||||
const fees: recordTypes.Fee[] = database
|
||||
const fees = database
|
||||
.prepare(
|
||||
`select f.feeId, f.feeName, f.feeDescription,
|
||||
f.occupancyTypeId, o.occupancyType,
|
||||
|
|
@ -62,7 +62,7 @@ export async function getFees(
|
|||
${sqlWhereClause}
|
||||
order by f.orderNumber, f.feeName`
|
||||
)
|
||||
.all(sqlParameters)
|
||||
.all(sqlParameters) as recordTypes.Fee[]
|
||||
|
||||
if (updateOrderNumbers) {
|
||||
let expectedOrderNumber = 0
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ async function _getLot(
|
|||
): Promise<recordTypes.Lot | undefined> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const lot: recordTypes.Lot = database.prepare(sql).get(lotIdOrLotName)
|
||||
const lot = database.prepare(sql).get(lotIdOrLotName) as recordTypes.Lot | undefined
|
||||
|
||||
if (lot !== undefined) {
|
||||
const lotOccupancies = await getLotOccupancies(
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export async function getLotComments(
|
|||
and lotId = ?
|
||||
order by lotCommentDate desc, lotCommentTime desc, lotCommentId desc`
|
||||
)
|
||||
.all(lotId)
|
||||
.all(lotId) as recordTypes.LotComment[]
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export async function getLotFields(
|
|||
): Promise<recordTypes.LotField[]> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
const lotFields: recordTypes.LotField[] = database
|
||||
const lotFields = database
|
||||
.prepare(
|
||||
`select l.lotId, l.lotTypeFieldId,
|
||||
l.lotFieldValue,
|
||||
|
|
@ -38,7 +38,7 @@ export async function getLotFields(
|
|||
and f.lotTypeFieldId not in (select lotTypeFieldId from LotFields where lotId = ? and recordDelete_timeMillis is null)
|
||||
order by lotTypeOrderNumber, f.orderNumber, f.lotTypeField`
|
||||
)
|
||||
.all(lotId, lotId, lotId, lotId)
|
||||
.all(lotId, lotId, lotId, lotId) as recordTypes.LotField[]
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -180,14 +180,16 @@ export async function getLotOccupancies(
|
|||
const isLimited = options.limit !== -1
|
||||
|
||||
if (isLimited) {
|
||||
count = database
|
||||
.prepare(
|
||||
`select count(*) as recordCount
|
||||
count = (
|
||||
database
|
||||
.prepare(
|
||||
`select count(*) as recordCount
|
||||
from LotOccupancies o
|
||||
left join Lots l on o.lotId = l.lotId
|
||||
${sqlWhereClause}`
|
||||
)
|
||||
.get(sqlParameters).recordCount
|
||||
)
|
||||
.get(sqlParameters) as { recordCount: number }
|
||||
).recordCount
|
||||
}
|
||||
|
||||
let lotOccupancies: recordTypes.LotOccupancy[] = []
|
||||
|
|
@ -210,7 +212,7 @@ export async function getLotOccupancies(
|
|||
order by o.occupancyStartDate desc, ifnull(o.occupancyEndDate, 99999999) desc, l.lotName, o.lotId, o.lotOccupancyId desc` +
|
||||
(isLimited ? ` limit ${options.limit} offset ${options.offset}` : '')
|
||||
)
|
||||
.all(sqlParameters)
|
||||
.all(sqlParameters) as recordTypes.LotOccupancy[]
|
||||
|
||||
if (!isLimited) {
|
||||
count = lotOccupancies.length
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ export async function getLotOccupancy(
|
|||
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
|
||||
const lotOccupancy: recordTypes.LotOccupancy | undefined = database
|
||||
const lotOccupancy = database
|
||||
.prepare(
|
||||
`select o.lotOccupancyId,
|
||||
o.occupancyTypeId, t.occupancyType,
|
||||
|
|
@ -36,7 +36,7 @@ export async function getLotOccupancy(
|
|||
where o.recordDelete_timeMillis is null
|
||||
and o.lotOccupancyId = ?`
|
||||
)
|
||||
.get(lotOccupancyId)
|
||||
.get(lotOccupancyId) as recordTypes.LotOccupancy | undefined
|
||||
|
||||
if (lotOccupancy !== undefined) {
|
||||
lotOccupancy.lotOccupancyFields = await getLotOccupancyFields(
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export async function getLotOccupancyComments(
|
|||
and lotOccupancyId = ?
|
||||
order by lotOccupancyCommentDate desc, lotOccupancyCommentTime desc, lotOccupancyCommentId desc`
|
||||
)
|
||||
.all(lotOccupancyId)
|
||||
.all(lotOccupancyId) as recordTypes.LotOccupancyComment[]
|
||||
|
||||
if (connectedDatabase === null) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export async function getLotOccupancyFees(
|
|||
): Promise<recordTypes.LotOccupancyFee[]> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
const lotOccupancyFees: recordTypes.LotOccupancyFee[] = database
|
||||
const lotOccupancyFees = database
|
||||
.prepare(
|
||||
`select o.lotOccupancyId, o.feeId,
|
||||
c.feeCategory, f.feeName,
|
||||
|
|
@ -21,7 +21,7 @@ export async function getLotOccupancyFees(
|
|||
and o.lotOccupancyId = ?
|
||||
order by o.recordCreate_timeMillis`
|
||||
)
|
||||
.all(lotOccupancyId)
|
||||
.all(lotOccupancyId) as recordTypes.LotOccupancyFee[]
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export async function getLotOccupancyFields(
|
|||
): Promise<recordTypes.LotOccupancyField[]> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
const lotOccupancyFields: recordTypes.LotOccupancyField[] = database
|
||||
const lotOccupancyFields = database
|
||||
.prepare(
|
||||
`select o.lotOccupancyId, o.occupancyTypeFieldId,
|
||||
o.lotOccupancyFieldValue, f.occupancyTypeField, f.occupancyTypeFieldValues,
|
||||
|
|
@ -35,7 +35,7 @@ export async function getLotOccupancyFields(
|
|||
and f.occupancyTypeFieldId not in (select occupancyTypeFieldId from LotOccupancyFields where lotOccupancyId = ? and recordDelete_timeMillis is null)
|
||||
order by occupancyTypeOrderNumber, f.orderNumber, f.occupancyTypeField`
|
||||
)
|
||||
.all(lotOccupancyId, lotOccupancyId, lotOccupancyId, lotOccupancyId)
|
||||
.all(lotOccupancyId, lotOccupancyId, lotOccupancyId, lotOccupancyId) as recordTypes.LotOccupancyField[]
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export async function getLotOccupancyOccupants(
|
|||
): Promise<recordTypes.LotOccupancyOccupant[]> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
const lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[] = database
|
||||
const lotOccupancyOccupants = database
|
||||
.prepare(
|
||||
`select o.lotOccupancyId, o.lotOccupantIndex,
|
||||
o.occupantName, o.occupantFamilyName,
|
||||
|
|
@ -25,7 +25,7 @@ export async function getLotOccupancyOccupants(
|
|||
and o.lotOccupancyId = ?
|
||||
order by t.orderNumber, t.lotOccupantType, o.occupantName, o.lotOccupantIndex`
|
||||
)
|
||||
.all(lotOccupancyId)
|
||||
.all(lotOccupancyId) as recordTypes.LotOccupancyOccupant[]
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -20,10 +20,9 @@ export async function getLotOccupancyTransactions(
|
|||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
database.function('userFn_timeIntegerToString', timeIntegerToString)
|
||||
|
||||
const lotOccupancyTransactions: recordTypes.LotOccupancyTransaction[] =
|
||||
database
|
||||
.prepare(
|
||||
`select lotOccupancyId, transactionIndex,
|
||||
const lotOccupancyTransactions = database
|
||||
.prepare(
|
||||
`select lotOccupancyId, transactionIndex,
|
||||
transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString,
|
||||
transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString,
|
||||
transactionAmount, externalReceiptNumber, transactionNote
|
||||
|
|
@ -31,8 +30,8 @@ export async function getLotOccupancyTransactions(
|
|||
where recordDelete_timeMillis is null
|
||||
and lotOccupancyId = ?
|
||||
order by transactionDate, transactionTime, transactionIndex`
|
||||
)
|
||||
.all(lotOccupancyId)
|
||||
)
|
||||
.all(lotOccupancyId) as recordTypes.LotOccupancyTransaction[]
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export async function getLotOccupantTypes(): Promise<
|
|||
> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const lotOccupantTypes: recordTypes.LotOccupantType[] = database
|
||||
const lotOccupantTypes = database
|
||||
.prepare(
|
||||
`select lotOccupantTypeId, lotOccupantType, fontAwesomeIconClass, occupantCommentTitle,
|
||||
orderNumber
|
||||
|
|
@ -19,7 +19,7 @@ export async function getLotOccupantTypes(): Promise<
|
|||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotOccupantType`
|
||||
)
|
||||
.all()
|
||||
.all() as recordTypes.LotOccupantType[]
|
||||
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export async function getLotStatusSummary(
|
|||
sqlParameters.push(filters.mapId)
|
||||
}
|
||||
|
||||
const lotStatuses: LotStatusSummary[] = database
|
||||
const lotStatuses = database
|
||||
.prepare(
|
||||
`select s.lotStatusId, s.lotStatus, count(l.lotId) as lotCount
|
||||
from Lots l
|
||||
|
|
@ -32,7 +32,7 @@ export async function getLotStatusSummary(
|
|||
group by s.lotStatusId, s.lotStatus, s.orderNumber
|
||||
order by s.orderNumber`
|
||||
)
|
||||
.all(sqlParameters)
|
||||
.all(sqlParameters) as LotStatusSummary[]
|
||||
|
||||
database.release()
|
||||
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@ import type * as recordTypes from '../../types/recordTypes'
|
|||
export async function getLotStatuses(): Promise<recordTypes.LotStatus[]> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const lotStatuses: recordTypes.LotStatus[] = database
|
||||
const lotStatuses = database
|
||||
.prepare(
|
||||
`select lotStatusId, lotStatus, orderNumber
|
||||
from LotStatuses
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotStatus`
|
||||
)
|
||||
.all()
|
||||
.all() as recordTypes.LotStatus[]
|
||||
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export async function getLotTypeFields(
|
|||
): Promise<recordTypes.LotTypeField[]> {
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
const lotTypeFields: recordTypes.LotTypeField[] = database
|
||||
const lotTypeFields = database
|
||||
.prepare(
|
||||
`select lotTypeFieldId,
|
||||
lotTypeField, lotTypeFieldValues,
|
||||
|
|
@ -20,7 +20,7 @@ export async function getLotTypeFields(
|
|||
and lotTypeId = ?
|
||||
order by orderNumber, lotTypeField`
|
||||
)
|
||||
.all(lotTypeId)
|
||||
.all(lotTypeId) as recordTypes.LotTypeField[]
|
||||
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export async function getLotTypeSummary(
|
|||
sqlParameters.push(filters.mapId)
|
||||
}
|
||||
|
||||
const lotTypes: LotTypeSummary[] = database
|
||||
const lotTypes = database
|
||||
.prepare(
|
||||
`select t.lotTypeId, t.lotType, count(l.lotId) as lotCount
|
||||
from Lots l
|
||||
|
|
@ -32,7 +32,7 @@ export async function getLotTypeSummary(
|
|||
group by t.lotTypeId, t.lotType, t.orderNumber
|
||||
order by t.orderNumber`
|
||||
)
|
||||
.all(sqlParameters)
|
||||
.all(sqlParameters) as LotTypeSummary[]
|
||||
|
||||
database.release()
|
||||
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@ import { updateRecordOrderNumber } from './updateRecordOrderNumber.js'
|
|||
export async function getLotTypes(): Promise<recordTypes.LotType[]> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const lotTypes: recordTypes.LotType[] = database
|
||||
const lotTypes = database
|
||||
.prepare(
|
||||
`select lotTypeId, lotType, orderNumber
|
||||
from LotTypes
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, lotType`
|
||||
)
|
||||
.all()
|
||||
.all() as recordTypes.LotType[]
|
||||
|
||||
let expectedTypeOrderNumber = -1
|
||||
|
||||
|
|
|
|||
|
|
@ -91,9 +91,10 @@ export async function getLots(
|
|||
let count = 0
|
||||
|
||||
if (options.limit !== -1) {
|
||||
count = database
|
||||
.prepare(
|
||||
`select count(*) as recordCount
|
||||
count = (
|
||||
database
|
||||
.prepare(
|
||||
`select count(*) as recordCount
|
||||
from Lots l
|
||||
left join (
|
||||
select lotId, count(lotOccupancyId) as lotOccupancyCount from LotOccupancies
|
||||
|
|
@ -103,8 +104,9 @@ export async function getLots(
|
|||
group by lotId
|
||||
) o on l.lotId = o.lotId
|
||||
${sqlWhereClause}`
|
||||
)
|
||||
.get(sqlParameters).recordCount
|
||||
)
|
||||
.get(sqlParameters) as { recordCount: number }
|
||||
).recordCount
|
||||
}
|
||||
|
||||
let lots: recordTypes.Lot[] = []
|
||||
|
|
@ -155,7 +157,7 @@ export async function getLots(
|
|||
: ` limit ${options.limit.toString()} offset ${options.offset.toString()}`
|
||||
}`
|
||||
)
|
||||
.all(sqlParameters)
|
||||
.all(sqlParameters) as recordTypes.Lot[]
|
||||
|
||||
if (options.limit === -1) {
|
||||
count = lots.length
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export async function getMap(
|
|||
): Promise<recordTypes.Map | undefined> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const map: recordTypes.Map = database
|
||||
const map = database
|
||||
.prepare(
|
||||
`select m.mapId, m.mapName, m.mapDescription,
|
||||
m.mapLatitude, m.mapLongitude, m.mapSVG,
|
||||
|
|
@ -29,7 +29,7 @@ export async function getMap(
|
|||
m.recordUpdate_userName, m.recordUpdate_timeMillis,
|
||||
m.recordDelete_userName, m.recordDelete_timeMillis`
|
||||
)
|
||||
.get(mapId)
|
||||
.get(mapId) as recordTypes.Map | undefined
|
||||
|
||||
database.release()
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import type * as recordTypes from '../../types/recordTypes'
|
|||
export async function getMaps(): Promise<recordTypes.Map[]> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const maps: recordTypes.Map[] = database
|
||||
const maps = database
|
||||
.prepare(
|
||||
`select m.mapId, m.mapName, m.mapDescription,
|
||||
m.mapLatitude, m.mapLongitude, m.mapSVG,
|
||||
|
|
@ -20,7 +20,7 @@ export async function getMaps(): Promise<recordTypes.Map[]> {
|
|||
) l on m.mapId = l.mapId
|
||||
where m.recordDelete_timeMillis is null order by m.mapName, m.mapId`
|
||||
)
|
||||
.all()
|
||||
.all() as recordTypes.Map[]
|
||||
|
||||
database.release()
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ export async function getNextLotId(
|
|||
configFunctions.getProperty('settings.lot.lotNameSortNameFunction')
|
||||
)
|
||||
|
||||
const result: {
|
||||
lotId: number
|
||||
} = database
|
||||
const result = database
|
||||
.prepare(
|
||||
`select lotId
|
||||
from Lots
|
||||
|
|
@ -23,7 +21,9 @@ export async function getNextLotId(
|
|||
order by userFn_lotNameSortName(lotName)
|
||||
limit 1`
|
||||
)
|
||||
.get(lotId)
|
||||
.get(lotId) as {
|
||||
lotId: number
|
||||
}
|
||||
|
||||
database.release()
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ export async function getNextMapId(
|
|||
): Promise<number | undefined> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const result: {
|
||||
mapId: number
|
||||
} = database
|
||||
const result = database
|
||||
.prepare(
|
||||
`select mapId
|
||||
from Maps
|
||||
|
|
@ -16,7 +14,9 @@ export async function getNextMapId(
|
|||
order by mapName
|
||||
limit 1`
|
||||
)
|
||||
.get(mapId)
|
||||
.get(mapId) as {
|
||||
mapId: number
|
||||
}
|
||||
|
||||
database.release()
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@ export async function getNextWorkOrderNumber(
|
|||
where userFn_matchesWorkOrderNumberSyntax(workOrderNumber) = 1
|
||||
order by cast(substr(workOrderNumber, instr(workOrderNumber, '-') + 1) as integer) desc`
|
||||
)
|
||||
.get()
|
||||
.get() as {
|
||||
workOrderNumber: string
|
||||
}
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export async function getOccupancyTypeFields(
|
|||
sqlParameters.push(occupancyTypeId)
|
||||
}
|
||||
|
||||
const occupancyTypeFields: recordTypes.OccupancyTypeField[] = database
|
||||
const occupancyTypeFields = database
|
||||
.prepare(
|
||||
'select occupancyTypeFieldId,' +
|
||||
' occupancyTypeField, occupancyTypeFieldValues, isRequired, pattern,' +
|
||||
|
|
@ -29,7 +29,7 @@ export async function getOccupancyTypeFields(
|
|||
: ' and occupancyTypeId = ?') +
|
||||
' order by orderNumber, occupancyTypeField'
|
||||
)
|
||||
.all(sqlParameters)
|
||||
.all(sqlParameters) as recordTypes.OccupancyTypeField[]
|
||||
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export async function getOccupancyTypePrints(
|
|||
userFunction_configContainsPrintEJS
|
||||
)
|
||||
|
||||
const results: Array<{ printEJS: string; orderNumber: number }> = database
|
||||
const results = database
|
||||
.prepare(
|
||||
`select printEJS, orderNumber
|
||||
from OccupancyTypePrints
|
||||
|
|
@ -36,7 +36,7 @@ export async function getOccupancyTypePrints(
|
|||
and userFn_configContainsPrintEJS(printEJS) = 1
|
||||
order by orderNumber, printEJS`
|
||||
)
|
||||
.all(occupancyTypeId)
|
||||
.all(occupancyTypeId) as Array<{ printEJS: string; orderNumber: number }>
|
||||
|
||||
let expectedOrderNumber = -1
|
||||
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ export async function getOccupancyTypes(): Promise<
|
|||
> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const occupancyTypes: recordTypes.OccupancyType[] = database
|
||||
const occupancyTypes = database
|
||||
.prepare(
|
||||
`select occupancyTypeId, occupancyType, orderNumber
|
||||
from OccupancyTypes
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, occupancyType`
|
||||
)
|
||||
.all()
|
||||
.all() as recordTypes.OccupancyType[]
|
||||
|
||||
let expectedTypeOrderNumber = -1
|
||||
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ export async function getPastLotOccupancyOccupants(
|
|||
order by lotOccupancyIdCount desc, recordUpdate_timeMillisMax desc
|
||||
limit ${options.limit}`
|
||||
|
||||
const lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[] = database
|
||||
const lotOccupancyOccupants = database
|
||||
.prepare(sql)
|
||||
.all(sqlParameters)
|
||||
.all(sqlParameters) as recordTypes.LotOccupancyOccupant[]
|
||||
|
||||
database.release()
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ export async function getPreviousLotId(
|
|||
configFunctions.getProperty('settings.lot.lotNameSortNameFunction')
|
||||
)
|
||||
|
||||
const result: {
|
||||
lotId: number
|
||||
} = database
|
||||
const result = database
|
||||
.prepare(
|
||||
`select lotId from Lots
|
||||
where recordDelete_timeMillis is null
|
||||
|
|
@ -22,7 +20,9 @@ export async function getPreviousLotId(
|
|||
order by userFn_lotNameSortName(lotName) desc
|
||||
limit 1`
|
||||
)
|
||||
.get(lotId)
|
||||
.get(lotId) as {
|
||||
lotId: number
|
||||
}
|
||||
|
||||
database.release()
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ export async function getPreviousMapId(
|
|||
): Promise<number | undefined> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const result: {
|
||||
mapId: number
|
||||
} = database
|
||||
const result = database
|
||||
.prepare(
|
||||
`select mapId from Maps
|
||||
where recordDelete_timeMillis is null
|
||||
|
|
@ -15,7 +13,9 @@ export async function getPreviousMapId(
|
|||
order by mapName desc
|
||||
limit 1`
|
||||
)
|
||||
.get(mapId)
|
||||
.get(mapId) as {
|
||||
mapId: number
|
||||
}
|
||||
|
||||
database.release()
|
||||
|
||||
|
|
|
|||
|
|
@ -16,9 +16,7 @@ const baseSQL = `select w.workOrderId,
|
|||
async function _getWorkOrder(sql, workOrderIdOrWorkOrderNumber, options, connectedDatabase) {
|
||||
const database = connectedDatabase ?? (await acquireConnection());
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
||||
const workOrder = database
|
||||
.prepare(sql)
|
||||
.get(workOrderIdOrWorkOrderNumber);
|
||||
const workOrder = database.prepare(sql).get(workOrderIdOrWorkOrderNumber);
|
||||
if (workOrder !== undefined) {
|
||||
if (options.includeLotsAndLotOccupancies) {
|
||||
const workOrderLotsResults = await getLots({
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ async function _getWorkOrder(
|
|||
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
|
||||
const workOrder: recordTypes.WorkOrder = database
|
||||
.prepare(sql)
|
||||
.get(workOrderIdOrWorkOrderNumber)
|
||||
const workOrder = database.prepare(sql).get(workOrderIdOrWorkOrderNumber) as
|
||||
| recordTypes.WorkOrder
|
||||
| undefined
|
||||
|
||||
if (workOrder !== undefined) {
|
||||
if (options.includeLotsAndLotOccupancies) {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export async function getWorkOrderComments(
|
|||
and workOrderId = ?
|
||||
order by workOrderCommentDate desc, workOrderCommentTime desc, workOrderCommentId desc`
|
||||
)
|
||||
.all(workOrderId)
|
||||
.all(workOrderId) as recordTypes.WorkOrderComment[]
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@ import type * as recordTypes from '../../types/recordTypes'
|
|||
export async function getWorkOrderMilestoneTypes(): Promise<recordTypes.WorkOrderMilestoneType[]> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const workOrderMilestoneTypes: recordTypes.WorkOrderMilestoneType[] = database
|
||||
const workOrderMilestoneTypes = database
|
||||
.prepare(
|
||||
`select workOrderMilestoneTypeId, workOrderMilestoneType, orderNumber
|
||||
from WorkOrderMilestoneTypes
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, workOrderMilestoneType`
|
||||
)
|
||||
.all()
|
||||
.all() as recordTypes.WorkOrderMilestoneType[]
|
||||
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
/* eslint-disable @typescript-eslint/indent */
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
|
|
@ -18,7 +20,12 @@ import type * as recordTypes from '../../types/recordTypes'
|
|||
|
||||
export interface WorkOrderMilestoneFilters {
|
||||
workOrderId?: number | string
|
||||
workOrderMilestoneDateFilter?: 'upcomingMissed' | 'recent' | 'date' | 'blank' | 'notBlank'
|
||||
workOrderMilestoneDateFilter?:
|
||||
| 'upcomingMissed'
|
||||
| 'recent'
|
||||
| 'date'
|
||||
| 'blank'
|
||||
| 'notBlank'
|
||||
workOrderMilestoneDateString?: string
|
||||
workOrderTypeIds?: string
|
||||
workOrderMilestoneTypeIds?: string
|
||||
|
|
@ -134,7 +141,10 @@ export async function getWorkOrderMilestones(
|
|||
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
database.function('userFn_timeIntegerToString', timeIntegerToString)
|
||||
database.function('userFn_timeIntegerToPeriodString', timeIntegerToPeriodString)
|
||||
database.function(
|
||||
'userFn_timeIntegerToPeriodString',
|
||||
timeIntegerToPeriodString
|
||||
)
|
||||
|
||||
// Filters
|
||||
const { sqlWhereClause, sqlParameters } = buildWhereClause(filters)
|
||||
|
|
@ -188,9 +198,9 @@ export async function getWorkOrderMilestones(
|
|||
sqlWhereClause +
|
||||
orderByClause
|
||||
|
||||
const workOrderMilestones: recordTypes.WorkOrderMilestone[] = database
|
||||
const workOrderMilestones = database
|
||||
.prepare(sql)
|
||||
.all(sqlParameters)
|
||||
.all(sqlParameters) as recordTypes.WorkOrderMilestone[]
|
||||
|
||||
if (options.includeWorkOrders ?? false) {
|
||||
for (const workOrderMilestone of workOrderMilestones) {
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ export async function getWorkOrderTypes(): Promise<
|
|||
> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const workOrderTypes: recordTypes.WorkOrderType[] = database
|
||||
const workOrderTypes = database
|
||||
.prepare(
|
||||
`select workOrderTypeId, workOrderType, orderNumber
|
||||
from WorkOrderTypes
|
||||
where recordDelete_timeMillis is null
|
||||
order by orderNumber, workOrderType`
|
||||
)
|
||||
.all()
|
||||
.all() as recordTypes.WorkOrderType[]
|
||||
|
||||
let expectedOrderNumber = 0
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ export async function getWorkOrderTypes(): Promise<
|
|||
if (workOrderType.orderNumber !== expectedOrderNumber) {
|
||||
updateRecordOrderNumber(
|
||||
'WorkOrderTypes',
|
||||
workOrderType.workOrderTypeId!,
|
||||
workOrderType.workOrderTypeId,
|
||||
expectedOrderNumber,
|
||||
database
|
||||
)
|
||||
|
|
|
|||
|
|
@ -176,13 +176,15 @@ export async function getWorkOrders(
|
|||
|
||||
const { sqlWhereClause, sqlParameters } = buildWhereClause(filters)
|
||||
|
||||
const count: number = database
|
||||
.prepare(
|
||||
`select count(*) as recordCount
|
||||
const count: number = (
|
||||
database
|
||||
.prepare(
|
||||
`select count(*) as recordCount
|
||||
from WorkOrders w
|
||||
${sqlWhereClause}`
|
||||
)
|
||||
.get(sqlParameters).recordCount
|
||||
)
|
||||
.get(sqlParameters) as { recordCount: number }
|
||||
).recordCount
|
||||
|
||||
let workOrders: recordTypes.WorkOrder[] = []
|
||||
|
||||
|
|
@ -219,7 +221,7 @@ export async function getWorkOrders(
|
|||
: ` limit ${options.limit} offset ${options.offset}`
|
||||
}`
|
||||
)
|
||||
.all(sqlParameters)
|
||||
.all(sqlParameters) as recordTypes.WorkOrder[]
|
||||
}
|
||||
|
||||
const hasInclusions =
|
||||
|
|
|
|||
|
|
@ -37,14 +37,16 @@ export async function moveFeeDownToBottom(
|
|||
|
||||
const currentFee = await getFee(feeId, database)
|
||||
|
||||
const maxOrderNumber: number = database
|
||||
.prepare(
|
||||
`select max(orderNumber) as maxOrderNumber
|
||||
const maxOrderNumber = (
|
||||
database
|
||||
.prepare(
|
||||
`select max(orderNumber) as maxOrderNumber
|
||||
from Fees
|
||||
where recordDelete_timeMillis is null
|
||||
and feeCategoryId = ?`
|
||||
)
|
||||
.get(currentFee.feeCategoryId).maxOrderNumber
|
||||
)
|
||||
.get(currentFee.feeCategoryId) as { maxOrderNumber: number }
|
||||
).maxOrderNumber
|
||||
|
||||
if (currentFee.orderNumber !== maxOrderNumber) {
|
||||
updateRecordOrderNumber('Fees', feeId, maxOrderNumber + 1, database)
|
||||
|
|
|
|||
|
|
@ -8,17 +8,18 @@ function getCurrentField(
|
|||
lotTypeFieldId: number | string,
|
||||
connectedDatabase: PoolConnection
|
||||
): { lotTypeId?: number; orderNumber: number } {
|
||||
const currentField: { lotTypeId?: number; orderNumber: number } =
|
||||
connectedDatabase
|
||||
.prepare(
|
||||
'select lotTypeId, orderNumber from LotTypeFields where lotTypeFieldId = ?'
|
||||
)
|
||||
.get(lotTypeFieldId)
|
||||
const currentField = connectedDatabase
|
||||
.prepare(
|
||||
'select lotTypeId, orderNumber from LotTypeFields where lotTypeFieldId = ?'
|
||||
)
|
||||
.get(lotTypeFieldId) as { lotTypeId?: number; orderNumber: number }
|
||||
|
||||
return currentField
|
||||
}
|
||||
|
||||
export async function moveLotTypeFieldDown(lotTypeFieldId: number | string): Promise<boolean> {
|
||||
export async function moveLotTypeFieldDown(
|
||||
lotTypeFieldId: number | string
|
||||
): Promise<boolean> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const currentField = getCurrentField(lotTypeFieldId, database)
|
||||
|
|
@ -53,14 +54,16 @@ export async function moveLotTypeFieldDownToBottom(
|
|||
|
||||
const currentField = getCurrentField(lotTypeFieldId, database)
|
||||
|
||||
const maxOrderNumber: number = database
|
||||
.prepare(
|
||||
`select max(orderNumber) as maxOrderNumber
|
||||
const maxOrderNumber = (
|
||||
database
|
||||
.prepare(
|
||||
`select max(orderNumber) as maxOrderNumber
|
||||
from LotTypeFields
|
||||
where recordDelete_timeMillis is null
|
||||
and lotTypeId = ?`
|
||||
)
|
||||
.get(currentField.lotTypeId).maxOrderNumber
|
||||
)
|
||||
.get(currentField.lotTypeId) as { maxOrderNumber: number }
|
||||
).maxOrderNumber
|
||||
|
||||
if (currentField.orderNumber !== maxOrderNumber) {
|
||||
updateRecordOrderNumber(
|
||||
|
|
@ -88,7 +91,9 @@ export async function moveLotTypeFieldDownToBottom(
|
|||
return true
|
||||
}
|
||||
|
||||
export async function moveLotTypeFieldUp(lotTypeFieldId: number | string): Promise<boolean> {
|
||||
export async function moveLotTypeFieldUp(
|
||||
lotTypeFieldId: number | string
|
||||
): Promise<boolean> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const currentField = getCurrentField(lotTypeFieldId, database)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ export async function moveOccupancyTypeFieldDown(occupancyTypeFieldId) {
|
|||
' set orderNumber = orderNumber - 1' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
(currentField.occupancyTypeId
|
||||
? " and occupancyTypeId = '" + currentField.occupancyTypeId.toString() + "'"
|
||||
? " and occupancyTypeId = '" +
|
||||
currentField.occupancyTypeId.toString() +
|
||||
"'"
|
||||
: ' and occupancyTypeId is null') +
|
||||
' and orderNumber = ? + 1')
|
||||
.run(currentField.orderNumber);
|
||||
|
|
@ -70,7 +72,9 @@ export async function moveOccupancyTypeFieldUp(occupancyTypeFieldId) {
|
|||
' set orderNumber = orderNumber + 1' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
(currentField.occupancyTypeId
|
||||
? " and occupancyTypeId = '" + currentField.occupancyTypeId.toString() + "'"
|
||||
? " and occupancyTypeId = '" +
|
||||
currentField.occupancyTypeId.toString() +
|
||||
"'"
|
||||
: ' and occupancyTypeId is null') +
|
||||
' and orderNumber = ? - 1')
|
||||
.run(currentField.orderNumber);
|
||||
|
|
|
|||
|
|
@ -8,14 +8,16 @@ function getCurrentField(
|
|||
occupancyTypeFieldId: number,
|
||||
connectedDatabase: PoolConnection
|
||||
): { occupancyTypeId?: number; orderNumber: number } {
|
||||
const currentField: { occupancyTypeId?: number; orderNumber: number } =
|
||||
connectedDatabase
|
||||
.prepare(
|
||||
`select occupancyTypeId, orderNumber
|
||||
const currentField = connectedDatabase
|
||||
.prepare(
|
||||
`select occupancyTypeId, orderNumber
|
||||
from OccupancyTypeFields
|
||||
where occupancyTypeFieldId = ?`
|
||||
)
|
||||
.get(occupancyTypeFieldId)
|
||||
)
|
||||
.get(occupancyTypeFieldId) as {
|
||||
occupancyTypeId?: number
|
||||
orderNumber: number
|
||||
}
|
||||
|
||||
return currentField
|
||||
}
|
||||
|
|
@ -33,7 +35,9 @@ export async function moveOccupancyTypeFieldDown(
|
|||
' set orderNumber = orderNumber - 1' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
(currentField.occupancyTypeId
|
||||
? " and occupancyTypeId = '" + currentField.occupancyTypeId.toString() + "'"
|
||||
? " and occupancyTypeId = '" +
|
||||
currentField.occupancyTypeId.toString() +
|
||||
"'"
|
||||
: ' and occupancyTypeId is null') +
|
||||
' and orderNumber = ? + 1'
|
||||
)
|
||||
|
|
@ -66,16 +70,18 @@ export async function moveOccupancyTypeFieldDownToBottom(
|
|||
occupancyTypeParameters.push(currentField.occupancyTypeId)
|
||||
}
|
||||
|
||||
const maxOrderNumber: number = database
|
||||
.prepare(
|
||||
'select max(orderNumber) as maxOrderNumber' +
|
||||
' from OccupancyTypeFields' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
(currentField.occupancyTypeId
|
||||
? ' and occupancyTypeId = ?'
|
||||
: ' and occupancyTypeId is null')
|
||||
)
|
||||
.get(occupancyTypeParameters).maxOrderNumber
|
||||
const maxOrderNumber: number = (
|
||||
database
|
||||
.prepare(
|
||||
'select max(orderNumber) as maxOrderNumber' +
|
||||
' from OccupancyTypeFields' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
(currentField.occupancyTypeId
|
||||
? ' and occupancyTypeId = ?'
|
||||
: ' and occupancyTypeId is null')
|
||||
)
|
||||
.get(occupancyTypeParameters) as { maxOrderNumber: number }
|
||||
).maxOrderNumber
|
||||
|
||||
if (currentField.orderNumber !== maxOrderNumber) {
|
||||
updateRecordOrderNumber(
|
||||
|
|
@ -125,7 +131,9 @@ export async function moveOccupancyTypeFieldUp(
|
|||
' set orderNumber = orderNumber + 1' +
|
||||
' where recordDelete_timeMillis is null' +
|
||||
(currentField.occupancyTypeId
|
||||
? " and occupancyTypeId = '" + currentField.occupancyTypeId.toString() + "'"
|
||||
? " and occupancyTypeId = '" +
|
||||
currentField.occupancyTypeId.toString() +
|
||||
"'"
|
||||
: ' and occupancyTypeId is null') +
|
||||
' and orderNumber = ? - 1'
|
||||
)
|
||||
|
|
|
|||
|
|
@ -8,11 +8,13 @@ export async function moveOccupancyTypePrintDown(
|
|||
): Promise<boolean> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const currentOrderNumber = database
|
||||
.prepare(
|
||||
'select orderNumber from OccupancyTypePrints where occupancyTypeId = ? and printEJS = ?'
|
||||
)
|
||||
.get(occupancyTypeId, printEJS).orderNumber
|
||||
const currentOrderNumber = (
|
||||
database
|
||||
.prepare(
|
||||
'select orderNumber from OccupancyTypePrints where occupancyTypeId = ? and printEJS = ?'
|
||||
)
|
||||
.get(occupancyTypeId, printEJS) as { orderNumber: number }
|
||||
).orderNumber
|
||||
|
||||
database
|
||||
.prepare(
|
||||
|
|
@ -43,20 +45,24 @@ export async function moveOccupancyTypePrintDownToBottom(
|
|||
): Promise<boolean> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const currentOrderNumber = database
|
||||
.prepare(
|
||||
'select orderNumber from OccupancyTypePrints where occupancyTypeId = ? and printEJS = ?'
|
||||
)
|
||||
.get(occupancyTypeId, printEJS).orderNumber
|
||||
const currentOrderNumber = (
|
||||
database
|
||||
.prepare(
|
||||
'select orderNumber from OccupancyTypePrints where occupancyTypeId = ? and printEJS = ?'
|
||||
)
|
||||
.get(occupancyTypeId, printEJS) as { orderNumber: number }
|
||||
).orderNumber
|
||||
|
||||
const maxOrderNumber: number = database
|
||||
.prepare(
|
||||
`select max(orderNumber) as maxOrderNumber
|
||||
const maxOrderNumber: number = (
|
||||
database
|
||||
.prepare(
|
||||
`select max(orderNumber) as maxOrderNumber
|
||||
from OccupancyTypePrints
|
||||
where recordDelete_timeMillis is null
|
||||
and occupancyTypeId = ?`
|
||||
)
|
||||
.get(occupancyTypeId).maxOrderNumber
|
||||
)
|
||||
.get(occupancyTypeId) as { maxOrderNumber: number }
|
||||
).maxOrderNumber
|
||||
|
||||
if (currentOrderNumber !== maxOrderNumber) {
|
||||
database
|
||||
|
|
|
|||
|
|
@ -8,11 +8,13 @@ export async function moveOccupancyTypePrintUp(
|
|||
): Promise<boolean> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const currentOrderNumber = database
|
||||
.prepare(
|
||||
'select orderNumber from OccupancyTypePrints where occupancyTypeId = ? and printEJS = ?'
|
||||
)
|
||||
.get(occupancyTypeId, printEJS).orderNumber
|
||||
const currentOrderNumber = (
|
||||
database
|
||||
.prepare(
|
||||
'select orderNumber from OccupancyTypePrints where occupancyTypeId = ? and printEJS = ?'
|
||||
)
|
||||
.get(occupancyTypeId, printEJS) as { orderNumber: number }
|
||||
).orderNumber
|
||||
|
||||
if (currentOrderNumber <= 0) {
|
||||
database.release()
|
||||
|
|
@ -48,11 +50,13 @@ export async function moveOccupancyTypePrintUpToTop(
|
|||
): Promise<boolean> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const currentOrderNumber = database
|
||||
.prepare(
|
||||
'select orderNumber from OccupancyTypePrints where occupancyTypeId = ? and printEJS = ?'
|
||||
)
|
||||
.get(occupancyTypeId, printEJS).orderNumber
|
||||
const currentOrderNumber = (
|
||||
database
|
||||
.prepare(
|
||||
'select orderNumber from OccupancyTypePrints where occupancyTypeId = ? and printEJS = ?'
|
||||
)
|
||||
.get(occupancyTypeId, printEJS) as { orderNumber: number }
|
||||
).orderNumber
|
||||
|
||||
if (currentOrderNumber > 0) {
|
||||
database
|
||||
|
|
|
|||
|
|
@ -27,13 +27,15 @@ function getCurrentOrderNumber(
|
|||
recordId: number | string,
|
||||
database: sqlite.Database
|
||||
): number {
|
||||
const currentOrderNumber: number = database
|
||||
.prepare(
|
||||
`select orderNumber
|
||||
const currentOrderNumber: number = (
|
||||
database
|
||||
.prepare(
|
||||
`select orderNumber
|
||||
from ${recordTable}
|
||||
where ${recordIdColumns.get(recordTable)!} = ?`
|
||||
)
|
||||
.get(recordId).orderNumber
|
||||
)
|
||||
.get(recordId) as { orderNumber: number }
|
||||
).orderNumber
|
||||
|
||||
return currentOrderNumber
|
||||
}
|
||||
|
|
@ -85,13 +87,15 @@ export async function moveRecordDownToBottom(
|
|||
database
|
||||
)
|
||||
|
||||
const maxOrderNumber: number = database
|
||||
.prepare(
|
||||
`select max(orderNumber) as maxOrderNumber
|
||||
const maxOrderNumber = (
|
||||
database
|
||||
.prepare(
|
||||
`select max(orderNumber) as maxOrderNumber
|
||||
from ${recordTable}
|
||||
where recordDelete_timeMillis is null`
|
||||
)
|
||||
.get().maxOrderNumber
|
||||
)
|
||||
.get() as { maxOrderNumber: number }
|
||||
).maxOrderNumber
|
||||
|
||||
if (currentOrderNumber !== maxOrderNumber) {
|
||||
updateRecordOrderNumber(recordTable, recordId, maxOrderNumber + 1, database)
|
||||
|
|
|
|||
Loading…
Reference in New Issue