major refactoring
parent
27433ff4b0
commit
06f6874298
|
|
@ -1,5 +1,5 @@
|
||||||
export interface AddWorkOrderLotForm {
|
export interface AddWorkOrderLotForm {
|
||||||
workOrderId: number | string;
|
workOrderId: number | string;
|
||||||
lotId: number | string;
|
burialSiteId: number | string;
|
||||||
}
|
}
|
||||||
export default function addWorkOrderLot(workOrderLotForm: AddWorkOrderLotForm, user: User): Promise<boolean>;
|
export default function addWorkOrderLot(workOrderLotForm: AddWorkOrderLotForm, user: User): Promise<boolean>;
|
||||||
|
|
|
||||||
|
|
@ -4,23 +4,23 @@ export default async function addWorkOrderLot(workOrderLotForm, user) {
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const row = database
|
const row = database
|
||||||
.prepare(`select recordDelete_timeMillis
|
.prepare(`select recordDelete_timeMillis
|
||||||
from WorkOrderLots
|
from WorkOrderBurialSites
|
||||||
where workOrderId = ?
|
where workOrderId = ?
|
||||||
and lotId = ?`)
|
and burialSiteId = ?`)
|
||||||
.get(workOrderLotForm.workOrderId, workOrderLotForm.lotId);
|
.get(workOrderLotForm.workOrderId, workOrderLotForm.burialSiteId);
|
||||||
if (row === undefined) {
|
if (row === undefined) {
|
||||||
database
|
database
|
||||||
.prepare(`insert into WorkOrderLots (
|
.prepare(`insert into WorkOrderBurialSites (
|
||||||
workOrderId, lotId,
|
workOrderId, burialSiteId,
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?)`)
|
||||||
.run(workOrderLotForm.workOrderId, workOrderLotForm.lotId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
.run(workOrderLotForm.workOrderId, workOrderLotForm.burialSiteId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (row.recordDelete_timeMillis) {
|
if (row.recordDelete_timeMillis) {
|
||||||
database
|
database
|
||||||
.prepare(`update WorkOrderLots
|
.prepare(`update WorkOrderBurialSites
|
||||||
set recordCreate_userName = ?,
|
set recordCreate_userName = ?,
|
||||||
recordCreate_timeMillis = ?,
|
recordCreate_timeMillis = ?,
|
||||||
recordUpdate_userName = ?,
|
recordUpdate_userName = ?,
|
||||||
|
|
@ -28,8 +28,8 @@ export default async function addWorkOrderLot(workOrderLotForm, user) {
|
||||||
recordDelete_userName = null,
|
recordDelete_userName = null,
|
||||||
recordDelete_timeMillis = null
|
recordDelete_timeMillis = null
|
||||||
where workOrderId = ?
|
where workOrderId = ?
|
||||||
and lotId = ?`)
|
and burialSiteId = ?`)
|
||||||
.run(user.userName, rightNowMillis, user.userName, rightNowMillis, workOrderLotForm.workOrderId, workOrderLotForm.lotId);
|
.run(user.userName, rightNowMillis, user.userName, rightNowMillis, workOrderLotForm.workOrderId, workOrderLotForm.burialSiteId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
database.release();
|
database.release();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface AddWorkOrderLotForm {
|
export interface AddWorkOrderLotForm {
|
||||||
workOrderId: number | string
|
workOrderId: number | string
|
||||||
lotId: number | string
|
burialSiteId: number | string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function addWorkOrderLot(
|
export default async function addWorkOrderLot(
|
||||||
|
|
@ -16,26 +16,28 @@ export default async function addWorkOrderLot(
|
||||||
const row = database
|
const row = database
|
||||||
.prepare(
|
.prepare(
|
||||||
`select recordDelete_timeMillis
|
`select recordDelete_timeMillis
|
||||||
from WorkOrderLots
|
from WorkOrderBurialSites
|
||||||
where workOrderId = ?
|
where workOrderId = ?
|
||||||
and lotId = ?`
|
and burialSiteId = ?`
|
||||||
)
|
)
|
||||||
.get(workOrderLotForm.workOrderId, workOrderLotForm.lotId) as {
|
.get(workOrderLotForm.workOrderId, workOrderLotForm.burialSiteId) as
|
||||||
recordDelete_timeMillis?: number
|
| {
|
||||||
}
|
recordDelete_timeMillis?: number
|
||||||
|
}
|
||||||
|
| undefined
|
||||||
|
|
||||||
if (row === undefined) {
|
if (row === undefined) {
|
||||||
database
|
database
|
||||||
.prepare(
|
.prepare(
|
||||||
`insert into WorkOrderLots (
|
`insert into WorkOrderBurialSites (
|
||||||
workOrderId, lotId,
|
workOrderId, burialSiteId,
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?)`
|
values (?, ?, ?, ?, ?, ?)`
|
||||||
)
|
)
|
||||||
.run(
|
.run(
|
||||||
workOrderLotForm.workOrderId,
|
workOrderLotForm.workOrderId,
|
||||||
workOrderLotForm.lotId,
|
workOrderLotForm.burialSiteId,
|
||||||
user.userName,
|
user.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
user.userName,
|
user.userName,
|
||||||
|
|
@ -45,7 +47,7 @@ export default async function addWorkOrderLot(
|
||||||
if (row.recordDelete_timeMillis) {
|
if (row.recordDelete_timeMillis) {
|
||||||
database
|
database
|
||||||
.prepare(
|
.prepare(
|
||||||
`update WorkOrderLots
|
`update WorkOrderBurialSites
|
||||||
set recordCreate_userName = ?,
|
set recordCreate_userName = ?,
|
||||||
recordCreate_timeMillis = ?,
|
recordCreate_timeMillis = ?,
|
||||||
recordUpdate_userName = ?,
|
recordUpdate_userName = ?,
|
||||||
|
|
@ -53,7 +55,7 @@ export default async function addWorkOrderLot(
|
||||||
recordDelete_userName = null,
|
recordDelete_userName = null,
|
||||||
recordDelete_timeMillis = null
|
recordDelete_timeMillis = null
|
||||||
where workOrderId = ?
|
where workOrderId = ?
|
||||||
and lotId = ?`
|
and burialSiteId = ?`
|
||||||
)
|
)
|
||||||
.run(
|
.run(
|
||||||
user.userName,
|
user.userName,
|
||||||
|
|
@ -61,7 +63,7 @@ export default async function addWorkOrderLot(
|
||||||
user.userName,
|
user.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
workOrderLotForm.workOrderId,
|
workOrderLotForm.workOrderId,
|
||||||
workOrderLotForm.lotId
|
workOrderLotForm.burialSiteId
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,4 @@ export interface AddWorkOrderBurialSiteContractOccupancyForm {
|
||||||
workOrderId: number | string;
|
workOrderId: number | string;
|
||||||
burialSiteContractId: number | string;
|
burialSiteContractId: number | string;
|
||||||
}
|
}
|
||||||
export default function addWorkOrderLotOccupancy(addForm: AddWorkOrderBurialSiteContractOccupancyForm, user: User, connectedDatabase?: PoolConnection): Promise<boolean>;
|
export default function addWorkOrderBurialSiteContract(addForm: AddWorkOrderBurialSiteContractOccupancyForm, user: User, connectedDatabase?: PoolConnection): Promise<boolean>;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
export default async function addWorkOrderLotOccupancy(addForm, user, connectedDatabase) {
|
export default async function addWorkOrderBurialSiteContract(addForm, user, connectedDatabase) {
|
||||||
const database = connectedDatabase ?? (await acquireConnection());
|
const database = connectedDatabase ?? (await acquireConnection());
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const recordDeleteTimeMillis = database
|
const recordDeleteTimeMillis = database
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ export interface AddWorkOrderBurialSiteContractOccupancyForm {
|
||||||
burialSiteContractId: number | string
|
burialSiteContractId: number | string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function addWorkOrderLotOccupancy(
|
export default async function addWorkOrderBurialSiteContract(
|
||||||
addForm: AddWorkOrderBurialSiteContractOccupancyForm,
|
addForm: AddWorkOrderBurialSiteContractOccupancyForm,
|
||||||
user: User,
|
user: User,
|
||||||
connectedDatabase?: PoolConnection
|
connectedDatabase?: PoolConnection
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
// TODO
|
|
||||||
export default async function getNextBurialSiteId(burialSiteId) {
|
export default async function getNextBurialSiteId(burialSiteId) {
|
||||||
const database = await acquireConnection();
|
const database = await acquireConnection();
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(`select burialSiteId
|
.prepare(`select burialSiteId
|
||||||
from BurialSites
|
from BurialSites
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and userFn_lotNameSortName(lotName) > (select userFn_lotNameSortName(lotName) from Lots where lotId = ?)
|
and burialSiteName > (select burialSiteName from BurialSites where burialSiteId = ?)
|
||||||
order by userFn_lotNameSortName(lotName)
|
order by burialSiteName
|
||||||
limit 1`)
|
limit 1`)
|
||||||
.pluck()
|
.pluck()
|
||||||
.get(burialSiteId);
|
.get(burialSiteId);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { acquireConnection } from './pool.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
// TODO
|
|
||||||
export default async function getNextBurialSiteId(
|
export default async function getNextBurialSiteId(
|
||||||
burialSiteId: number | string
|
burialSiteId: number | string
|
||||||
): Promise<number | undefined> {
|
): Promise<number | undefined> {
|
||||||
|
|
@ -11,8 +10,8 @@ export default async function getNextBurialSiteId(
|
||||||
`select burialSiteId
|
`select burialSiteId
|
||||||
from BurialSites
|
from BurialSites
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and userFn_lotNameSortName(lotName) > (select userFn_lotNameSortName(lotName) from Lots where lotId = ?)
|
and burialSiteName > (select burialSiteName from BurialSites where burialSiteId = ?)
|
||||||
order by userFn_lotNameSortName(lotName)
|
order by burialSiteName
|
||||||
limit 1`
|
limit 1`
|
||||||
)
|
)
|
||||||
.pluck()
|
.pluck()
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
import type { LotOccupancyOccupant } from '../types/recordTypes.js';
|
|
||||||
export interface GetPastLotOccupancyOccupantsFilters {
|
|
||||||
searchFilter: string;
|
|
||||||
}
|
|
||||||
interface GetPastLotOccupancyOccupantsOptions {
|
|
||||||
limit: number;
|
|
||||||
}
|
|
||||||
export default function getPastLotOccupancyOccupants(filters: GetPastLotOccupancyOccupantsFilters, options: GetPastLotOccupancyOccupantsOptions): Promise<LotOccupancyOccupant[]>;
|
|
||||||
export {};
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
import { acquireConnection } from './pool.js';
|
|
||||||
export default async function getPastLotOccupancyOccupants(filters, options) {
|
|
||||||
const database = await acquireConnection();
|
|
||||||
let sqlWhereClause = ' where o.recordDelete_timeMillis is null and l.recordDelete_timeMillis is null';
|
|
||||||
const sqlParameters = [];
|
|
||||||
if (filters.searchFilter !== '') {
|
|
||||||
const searchFilterPieces = filters.searchFilter.split(' ');
|
|
||||||
for (const searchFilterPiece of searchFilterPieces) {
|
|
||||||
if (searchFilterPiece === '') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
sqlWhereClause += ` and (o.occupantName like '%' || ? || '%'
|
|
||||||
or o.occupantFamilyName like '%' || ? || '%'
|
|
||||||
or o.occupantAddress1 like '%' || ? || '%'
|
|
||||||
or o.occupantAddress2 like '%' || ? || '%'
|
|
||||||
or o.occupantCity like '%' || ? || '%')`;
|
|
||||||
sqlParameters.push(searchFilterPiece, searchFilterPiece, searchFilterPiece, searchFilterPiece, searchFilterPiece);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const sql = `select o.occupantName, o.occupantFamilyName,
|
|
||||||
o.occupantAddress1, o.occupantAddress2,
|
|
||||||
o.occupantCity, o.occupantProvince, o.occupantPostalCode,
|
|
||||||
o.occupantPhoneNumber, o.occupantEmailAddress,
|
|
||||||
count(*) as burialSiteContractIdCount,
|
|
||||||
max(o.recordUpdate_timeMillis) as recordUpdate_timeMillisMax
|
|
||||||
from LotOccupancyOccupants o
|
|
||||||
left join BurialSiteContracts l on o.burialSiteContractId = l.burialSiteContractId
|
|
||||||
${sqlWhereClause}
|
|
||||||
group by occupantName, occupantAddress1, occupantAddress2,
|
|
||||||
occupantCity, occupantProvince, occupantPostalCode,
|
|
||||||
occupantPhoneNumber, occupantEmailAddress
|
|
||||||
order by burialSiteContractIdCount desc, recordUpdate_timeMillisMax desc
|
|
||||||
limit ${options.limit}`;
|
|
||||||
const burialSiteContractOccupants = database
|
|
||||||
.prepare(sql)
|
|
||||||
.all(sqlParameters);
|
|
||||||
database.release();
|
|
||||||
return burialSiteContractOccupants;
|
|
||||||
}
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
import type { LotOccupancyOccupant } from '../types/recordTypes.js'
|
|
||||||
|
|
||||||
import { acquireConnection } from './pool.js'
|
|
||||||
|
|
||||||
export interface GetPastLotOccupancyOccupantsFilters {
|
|
||||||
searchFilter: string
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GetPastLotOccupancyOccupantsOptions {
|
|
||||||
limit: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export default async function getPastLotOccupancyOccupants(
|
|
||||||
filters: GetPastLotOccupancyOccupantsFilters,
|
|
||||||
options: GetPastLotOccupancyOccupantsOptions
|
|
||||||
): Promise<LotOccupancyOccupant[]> {
|
|
||||||
const database = await acquireConnection()
|
|
||||||
|
|
||||||
let sqlWhereClause =
|
|
||||||
' where o.recordDelete_timeMillis is null and l.recordDelete_timeMillis is null'
|
|
||||||
|
|
||||||
const sqlParameters: unknown[] = []
|
|
||||||
|
|
||||||
if (filters.searchFilter !== '') {
|
|
||||||
const searchFilterPieces = filters.searchFilter.split(' ')
|
|
||||||
|
|
||||||
for (const searchFilterPiece of searchFilterPieces) {
|
|
||||||
if (searchFilterPiece === '') {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
sqlWhereClause += ` and (o.occupantName like '%' || ? || '%'
|
|
||||||
or o.occupantFamilyName like '%' || ? || '%'
|
|
||||||
or o.occupantAddress1 like '%' || ? || '%'
|
|
||||||
or o.occupantAddress2 like '%' || ? || '%'
|
|
||||||
or o.occupantCity like '%' || ? || '%')`
|
|
||||||
|
|
||||||
sqlParameters.push(
|
|
||||||
searchFilterPiece,
|
|
||||||
searchFilterPiece,
|
|
||||||
searchFilterPiece,
|
|
||||||
searchFilterPiece,
|
|
||||||
searchFilterPiece
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const sql = `select o.occupantName, o.occupantFamilyName,
|
|
||||||
o.occupantAddress1, o.occupantAddress2,
|
|
||||||
o.occupantCity, o.occupantProvince, o.occupantPostalCode,
|
|
||||||
o.occupantPhoneNumber, o.occupantEmailAddress,
|
|
||||||
count(*) as burialSiteContractIdCount,
|
|
||||||
max(o.recordUpdate_timeMillis) as recordUpdate_timeMillisMax
|
|
||||||
from LotOccupancyOccupants o
|
|
||||||
left join BurialSiteContracts l on o.burialSiteContractId = l.burialSiteContractId
|
|
||||||
${sqlWhereClause}
|
|
||||||
group by occupantName, occupantAddress1, occupantAddress2,
|
|
||||||
occupantCity, occupantProvince, occupantPostalCode,
|
|
||||||
occupantPhoneNumber, occupantEmailAddress
|
|
||||||
order by burialSiteContractIdCount desc, recordUpdate_timeMillisMax desc
|
|
||||||
limit ${options.limit}`
|
|
||||||
|
|
||||||
const burialSiteContractOccupants = database
|
|
||||||
.prepare(sql)
|
|
||||||
.all(sqlParameters) as LotOccupancyOccupant[]
|
|
||||||
|
|
||||||
database.release()
|
|
||||||
|
|
||||||
return burialSiteContractOccupants
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export default function getPreviousBurialSiteId(burialSiteId: number | string): Promise<number | undefined>;
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { acquireConnection } from './pool.js';
|
||||||
|
export default async function getPreviousBurialSiteId(burialSiteId) {
|
||||||
|
const database = await acquireConnection();
|
||||||
|
const result = database
|
||||||
|
.prepare(`select burialSiteId from BurialSites
|
||||||
|
where recordDelete_timeMillis is null
|
||||||
|
and burialSiteName < (select burialSiteName from BurialSites where burialSiteId = ?)
|
||||||
|
order by burialSiteName desc
|
||||||
|
limit 1`)
|
||||||
|
.pluck()
|
||||||
|
.get(burialSiteId);
|
||||||
|
database.release();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
|
export default async function getPreviousBurialSiteId(
|
||||||
|
burialSiteId: number | string
|
||||||
|
): Promise<number | undefined> {
|
||||||
|
const database = await acquireConnection()
|
||||||
|
|
||||||
|
const result = database
|
||||||
|
.prepare(
|
||||||
|
`select burialSiteId from BurialSites
|
||||||
|
where recordDelete_timeMillis is null
|
||||||
|
and burialSiteName < (select burialSiteName from BurialSites where burialSiteId = ?)
|
||||||
|
order by burialSiteName desc
|
||||||
|
limit 1`
|
||||||
|
)
|
||||||
|
.pluck()
|
||||||
|
.get(burialSiteId) as number | undefined
|
||||||
|
|
||||||
|
database.release()
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export default function getPreviousLotId(lotId: number | string): Promise<number | undefined>;
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
import { getConfigProperty } from '../helpers/config.helpers.js';
|
|
||||||
import { acquireConnection } from './pool.js';
|
|
||||||
export default async function getPreviousLotId(lotId) {
|
|
||||||
const database = await acquireConnection();
|
|
||||||
database.function('userFn_lotNameSortName', getConfigProperty('settings.lot.lotNameSortNameFunction'));
|
|
||||||
const result = database
|
|
||||||
.prepare(`select lotId from Lots
|
|
||||||
where recordDelete_timeMillis is null
|
|
||||||
and userFn_lotNameSortName(lotName) < (select userFn_lotNameSortName(lotName) from Lots where lotId = ?)
|
|
||||||
order by userFn_lotNameSortName(lotName) desc
|
|
||||||
limit 1`)
|
|
||||||
.get(lotId);
|
|
||||||
database.release();
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return result.lotId;
|
|
||||||
}
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
import { getConfigProperty } from '../helpers/config.helpers.js'
|
|
||||||
|
|
||||||
import { acquireConnection } from './pool.js'
|
|
||||||
|
|
||||||
export default async function getPreviousLotId(
|
|
||||||
lotId: number | string
|
|
||||||
): Promise<number | undefined> {
|
|
||||||
const database = await acquireConnection()
|
|
||||||
|
|
||||||
database.function(
|
|
||||||
'userFn_lotNameSortName',
|
|
||||||
getConfigProperty('settings.lot.lotNameSortNameFunction')
|
|
||||||
)
|
|
||||||
|
|
||||||
const result = database
|
|
||||||
.prepare(
|
|
||||||
`select lotId from Lots
|
|
||||||
where recordDelete_timeMillis is null
|
|
||||||
and userFn_lotNameSortName(lotName) < (select userFn_lotNameSortName(lotName) from Lots where lotId = ?)
|
|
||||||
order by userFn_lotNameSortName(lotName) desc
|
|
||||||
limit 1`
|
|
||||||
)
|
|
||||||
.get(lotId) as
|
|
||||||
| {
|
|
||||||
lotId: number
|
|
||||||
}
|
|
||||||
| undefined
|
|
||||||
|
|
||||||
database.release()
|
|
||||||
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.lotId
|
|
||||||
}
|
|
||||||
|
|
@ -24,20 +24,20 @@ async function _getWorkOrder(sql, workOrderIdOrWorkOrderNumber, options, connect
|
||||||
}, {
|
}, {
|
||||||
limit: -1,
|
limit: -1,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
includeLotOccupancyCount: false
|
includeBurialSiteContractCount: false
|
||||||
}, database);
|
}, database);
|
||||||
workOrder.workOrderBurialSites = burialSiteResults.lots;
|
workOrder.workOrderBurialSites = burialSiteResults.burialSites;
|
||||||
const workOrderBurialSiteContractsResults = await getBurialSiteContracts({
|
const workOrderBurialSiteContractsResults = await getBurialSiteContracts({
|
||||||
workOrderId: workOrder.workOrderId
|
workOrderId: workOrder.workOrderId
|
||||||
}, {
|
}, {
|
||||||
limit: -1,
|
limit: -1,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
includeOccupants: true,
|
includeInterments: true,
|
||||||
includeFees: false,
|
includeFees: false,
|
||||||
includeTransactions: false
|
includeTransactions: false
|
||||||
}, database);
|
}, database);
|
||||||
workOrder.workOrderBurialSiteContracts =
|
workOrder.workOrderBurialSiteContracts =
|
||||||
workOrderBurialSiteContractsResults.BurialSiteContracts;
|
workOrderBurialSiteContractsResults.burialSiteContracts;
|
||||||
}
|
}
|
||||||
if (options.includeComments) {
|
if (options.includeComments) {
|
||||||
workOrder.workOrderComments = await getWorkOrderComments(workOrder.workOrderId, database);
|
workOrder.workOrderComments = await getWorkOrderComments(workOrder.workOrderId, database);
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,12 @@ async function _getWorkOrder(
|
||||||
{
|
{
|
||||||
limit: -1,
|
limit: -1,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
includeLotOccupancyCount: false
|
includeBurialSiteContractCount: false
|
||||||
},
|
},
|
||||||
database
|
database
|
||||||
)
|
)
|
||||||
|
|
||||||
workOrder.workOrderBurialSites = burialSiteResults.lots
|
workOrder.workOrderBurialSites = burialSiteResults.burialSites
|
||||||
|
|
||||||
const workOrderBurialSiteContractsResults = await getBurialSiteContracts(
|
const workOrderBurialSiteContractsResults = await getBurialSiteContracts(
|
||||||
{
|
{
|
||||||
|
|
@ -62,7 +62,7 @@ async function _getWorkOrder(
|
||||||
{
|
{
|
||||||
limit: -1,
|
limit: -1,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
includeOccupants: true,
|
includeInterments: true,
|
||||||
includeFees: false,
|
includeFees: false,
|
||||||
includeTransactions: false
|
includeTransactions: false
|
||||||
},
|
},
|
||||||
|
|
@ -70,7 +70,7 @@ async function _getWorkOrder(
|
||||||
)
|
)
|
||||||
|
|
||||||
workOrder.workOrderBurialSiteContracts =
|
workOrder.workOrderBurialSiteContracts =
|
||||||
workOrderBurialSiteContractsResults.BurialSiteContracts
|
workOrderBurialSiteContractsResults.burialSiteContracts
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.includeComments) {
|
if (options.includeComments) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { dateIntegerToString, dateStringToInteger, dateToInteger, timeIntegerToPeriodString, timeIntegerToString } from '@cityssm/utils-datetime';
|
import { dateIntegerToString, dateStringToInteger, dateToInteger, timeIntegerToPeriodString, timeIntegerToString } from '@cityssm/utils-datetime';
|
||||||
import { getConfigProperty } from '../helpers/config.helpers.js';
|
import { getConfigProperty } from '../helpers/config.helpers.js';
|
||||||
import getBurialSiteContracts from './getBurialSiteContracts.js';
|
import getBurialSiteContracts from './getBurialSiteContracts.js';
|
||||||
import getLots from './getLots.js';
|
import getBurialSites from './getBurialSites.js';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
// eslint-disable-next-line security/detect-unsafe-regex
|
// eslint-disable-next-line security/detect-unsafe-regex
|
||||||
const commaSeparatedNumbersRegex = /^\d+(?:,\d+)*$/;
|
const commaSeparatedNumbersRegex = /^\d+(?:,\d+)*$/;
|
||||||
|
|
@ -43,7 +43,8 @@ function buildWhereClause(filters) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (filters.workOrderMilestoneDateString !== undefined && filters.workOrderMilestoneDateString !== '') {
|
if (filters.workOrderMilestoneDateString !== undefined &&
|
||||||
|
filters.workOrderMilestoneDateString !== '') {
|
||||||
sqlWhereClause += ' and m.workOrderMilestoneDate = ?';
|
sqlWhereClause += ' and m.workOrderMilestoneDate = ?';
|
||||||
sqlParameters.push(dateStringToInteger(filters.workOrderMilestoneDateString));
|
sqlParameters.push(dateStringToInteger(filters.workOrderMilestoneDateString));
|
||||||
}
|
}
|
||||||
|
|
@ -104,9 +105,9 @@ export default async function getWorkOrderMilestones(filters, options, connected
|
||||||
userFn_timeIntegerToPeriodString(ifnull(m.workOrderMilestoneCompletionTime, 0)) as workOrderMilestoneCompletionTimePeriodString,
|
userFn_timeIntegerToPeriodString(ifnull(m.workOrderMilestoneCompletionTime, 0)) as workOrderMilestoneCompletionTimePeriodString,
|
||||||
${options.includeWorkOrders ?? false
|
${options.includeWorkOrders ?? false
|
||||||
? ` m.workOrderId, w.workOrderNumber, wt.workOrderType, w.workOrderDescription,
|
? ` m.workOrderId, w.workOrderNumber, wt.workOrderType, w.workOrderDescription,
|
||||||
w.workOrderOpenDate, userFn_dateIntegerToString(w.workOrderOpenDate) as workOrderOpenDateString,
|
w.workOrderOpenDate, userFn_dateIntegerToString(w.workOrderOpenDate) as workOrderOpenDateString,
|
||||||
w.workOrderCloseDate, userFn_dateIntegerToString(w.workOrderCloseDate) as workOrderCloseDateString,
|
w.workOrderCloseDate, userFn_dateIntegerToString(w.workOrderCloseDate) as workOrderCloseDateString,
|
||||||
w.recordUpdate_timeMillis as workOrderRecordUpdate_timeMillis,`
|
w.recordUpdate_timeMillis as workOrderRecordUpdate_timeMillis,`
|
||||||
: ''}
|
: ''}
|
||||||
m.recordCreate_userName, m.recordCreate_timeMillis,
|
m.recordCreate_userName, m.recordCreate_timeMillis,
|
||||||
m.recordUpdate_userName, m.recordUpdate_timeMillis
|
m.recordUpdate_userName, m.recordUpdate_timeMillis
|
||||||
|
|
@ -121,24 +122,25 @@ export default async function getWorkOrderMilestones(filters, options, connected
|
||||||
.all(sqlParameters);
|
.all(sqlParameters);
|
||||||
if (options.includeWorkOrders ?? false) {
|
if (options.includeWorkOrders ?? false) {
|
||||||
for (const workOrderMilestone of workOrderMilestones) {
|
for (const workOrderMilestone of workOrderMilestones) {
|
||||||
const workOrderLotsResults = await getLots({
|
const burialSites = await getBurialSites({
|
||||||
workOrderId: workOrderMilestone.workOrderId
|
workOrderId: workOrderMilestone.workOrderId
|
||||||
}, {
|
}, {
|
||||||
limit: -1,
|
limit: -1,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
includeLotOccupancyCount: false
|
includeBurialSiteContractCount: false
|
||||||
}, database);
|
}, database);
|
||||||
workOrderMilestone.workOrderLots = workOrderLotsResults.lots;
|
workOrderMilestone.workOrderBurialSites = burialSites.burialSites;
|
||||||
const BurialSiteContracts = await getBurialSiteContracts({
|
const burialSiteContracts = await getBurialSiteContracts({
|
||||||
workOrderId: workOrderMilestone.workOrderId
|
workOrderId: workOrderMilestone.workOrderId
|
||||||
}, {
|
}, {
|
||||||
limit: -1,
|
limit: -1,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
includeOccupants: true,
|
includeInterments: true,
|
||||||
includeFees: false,
|
includeFees: false,
|
||||||
includeTransactions: false
|
includeTransactions: false
|
||||||
}, database);
|
}, database);
|
||||||
workOrderMilestone.workOrderBurialSiteContracts = BurialSiteContracts.BurialSiteContracts;
|
workOrderMilestone.workOrderBurialSiteContracts =
|
||||||
|
burialSiteContracts.burialSiteContracts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (connectedDatabase === undefined) {
|
if (connectedDatabase === undefined) {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import { getConfigProperty } from '../helpers/config.helpers.js'
|
||||||
import type { WorkOrderMilestone } from '../types/recordTypes.js'
|
import type { WorkOrderMilestone } from '../types/recordTypes.js'
|
||||||
|
|
||||||
import getBurialSiteContracts from './getBurialSiteContracts.js'
|
import getBurialSiteContracts from './getBurialSiteContracts.js'
|
||||||
import getLots from './getLots.js'
|
import getBurialSites from './getBurialSites.js'
|
||||||
import { acquireConnection } from './pool.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface WorkOrderMilestoneFilters {
|
export interface WorkOrderMilestoneFilters {
|
||||||
|
|
@ -99,7 +99,10 @@ function buildWhereClause(filters: WorkOrderMilestoneFilters): {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filters.workOrderMilestoneDateString !== undefined && filters.workOrderMilestoneDateString !== '') {
|
if (
|
||||||
|
filters.workOrderMilestoneDateString !== undefined &&
|
||||||
|
filters.workOrderMilestoneDateString !== ''
|
||||||
|
) {
|
||||||
sqlWhereClause += ' and m.workOrderMilestoneDate = ?'
|
sqlWhereClause += ' and m.workOrderMilestoneDate = ?'
|
||||||
sqlParameters.push(
|
sqlParameters.push(
|
||||||
dateStringToInteger(filters.workOrderMilestoneDateString)
|
dateStringToInteger(filters.workOrderMilestoneDateString)
|
||||||
|
|
@ -184,9 +187,9 @@ export default async function getWorkOrderMilestones(
|
||||||
${
|
${
|
||||||
options.includeWorkOrders ?? false
|
options.includeWorkOrders ?? false
|
||||||
? ` m.workOrderId, w.workOrderNumber, wt.workOrderType, w.workOrderDescription,
|
? ` m.workOrderId, w.workOrderNumber, wt.workOrderType, w.workOrderDescription,
|
||||||
w.workOrderOpenDate, userFn_dateIntegerToString(w.workOrderOpenDate) as workOrderOpenDateString,
|
w.workOrderOpenDate, userFn_dateIntegerToString(w.workOrderOpenDate) as workOrderOpenDateString,
|
||||||
w.workOrderCloseDate, userFn_dateIntegerToString(w.workOrderCloseDate) as workOrderCloseDateString,
|
w.workOrderCloseDate, userFn_dateIntegerToString(w.workOrderCloseDate) as workOrderCloseDateString,
|
||||||
w.recordUpdate_timeMillis as workOrderRecordUpdate_timeMillis,`
|
w.recordUpdate_timeMillis as workOrderRecordUpdate_timeMillis,`
|
||||||
: ''
|
: ''
|
||||||
}
|
}
|
||||||
m.recordCreate_userName, m.recordCreate_timeMillis,
|
m.recordCreate_userName, m.recordCreate_timeMillis,
|
||||||
|
|
@ -204,35 +207,36 @@ export default async function getWorkOrderMilestones(
|
||||||
|
|
||||||
if (options.includeWorkOrders ?? false) {
|
if (options.includeWorkOrders ?? false) {
|
||||||
for (const workOrderMilestone of workOrderMilestones) {
|
for (const workOrderMilestone of workOrderMilestones) {
|
||||||
const workOrderLotsResults = await getLots(
|
const burialSites = await getBurialSites(
|
||||||
{
|
{
|
||||||
workOrderId: workOrderMilestone.workOrderId
|
workOrderId: workOrderMilestone.workOrderId
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
limit: -1,
|
limit: -1,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
includeLotOccupancyCount: false
|
includeBurialSiteContractCount: false
|
||||||
},
|
},
|
||||||
database
|
database
|
||||||
)
|
)
|
||||||
|
|
||||||
workOrderMilestone.workOrderLots = workOrderLotsResults.lots
|
workOrderMilestone.workOrderBurialSites = burialSites.burialSites
|
||||||
|
|
||||||
const BurialSiteContracts = await getBurialSiteContracts(
|
const burialSiteContracts = await getBurialSiteContracts(
|
||||||
{
|
{
|
||||||
workOrderId: workOrderMilestone.workOrderId
|
workOrderId: workOrderMilestone.workOrderId
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
limit: -1,
|
limit: -1,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
includeOccupants: true,
|
includeInterments: true,
|
||||||
includeFees: false,
|
includeFees: false,
|
||||||
includeTransactions: false
|
includeTransactions: false
|
||||||
},
|
},
|
||||||
database
|
database
|
||||||
)
|
)
|
||||||
|
|
||||||
workOrderMilestone.workOrderBurialSiteContracts = BurialSiteContracts.BurialSiteContracts
|
workOrderMilestone.workOrderBurialSiteContracts =
|
||||||
|
burialSiteContracts.burialSiteContracts
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export interface GetWorkOrdersFilters {
|
||||||
interface GetWorkOrdersOptions {
|
interface GetWorkOrdersOptions {
|
||||||
limit: number;
|
limit: number;
|
||||||
offset: number;
|
offset: number;
|
||||||
includeLotsAndBurialSiteContracts?: boolean;
|
includeBurialSites?: boolean;
|
||||||
includeComments?: boolean;
|
includeComments?: boolean;
|
||||||
includeMilestones?: boolean;
|
includeMilestones?: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { dateIntegerToString, dateStringToInteger } from '@cityssm/utils-datetime';
|
import { dateIntegerToString, dateStringToInteger } from '@cityssm/utils-datetime';
|
||||||
import { getBurialSiteNameWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js';
|
import { getBurialSiteNameWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js';
|
||||||
import getBurialSiteContracts from './getBurialSiteContracts.js';
|
import getBurialSiteContracts from './getBurialSiteContracts.js';
|
||||||
import getLots from './getLots.js';
|
import getBurialSites from './getBurialSites.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 { acquireConnection } from './pool.js';
|
||||||
|
|
@ -36,18 +36,18 @@ function buildWhereClause(filters) {
|
||||||
))`;
|
))`;
|
||||||
sqlParameters.push(...occupantNameFilters.sqlParameters);
|
sqlParameters.push(...occupantNameFilters.sqlParameters);
|
||||||
}
|
}
|
||||||
const lotNameFilters = getBurialSiteNameWhereClause(filters.lotName, '', 'l');
|
const burialSiteNameFilters = getBurialSiteNameWhereClause(filters.lotName, '', 'l');
|
||||||
if (lotNameFilters.sqlParameters.length > 0) {
|
if (burialSiteNameFilters.sqlParameters.length > 0) {
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
` and w.workOrderId in (
|
` and w.workOrderId in (
|
||||||
select workOrderId from WorkOrderLots
|
select workOrderId from WorkOrderBurialSites
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and lotId in (
|
and burialSiteId in (
|
||||||
select lotId from Lots l
|
select burialSiteId from BurialSites l
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
${lotNameFilters.sqlWhereClause}
|
${burialSiteNameFilters.sqlWhereClause}
|
||||||
))`;
|
))`;
|
||||||
sqlParameters.push(...lotNameFilters.sqlParameters);
|
sqlParameters.push(...burialSiteNameFilters.sqlParameters);
|
||||||
}
|
}
|
||||||
if ((filters.burialSiteContractId ?? '') !== '') {
|
if ((filters.burialSiteContractId ?? '') !== '') {
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
|
|
@ -63,30 +63,30 @@ async function addInclusions(workOrder, options, database) {
|
||||||
if (options.includeComments ?? false) {
|
if (options.includeComments ?? false) {
|
||||||
workOrder.workOrderComments = await getWorkOrderComments(workOrder.workOrderId, database);
|
workOrder.workOrderComments = await getWorkOrderComments(workOrder.workOrderId, database);
|
||||||
}
|
}
|
||||||
if (options.includeLotsAndBurialSiteContracts ?? false) {
|
if (options.includeBurialSites ?? false) {
|
||||||
if (workOrder.workOrderLotCount === 0) {
|
if (workOrder.workOrderBurialSiteCount === 0) {
|
||||||
workOrder.workOrderLots = [];
|
workOrder.workOrderBurialSites = [];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const workOrderLotsResults = await getLots({
|
const workOrderBurialSitesResults = await getBurialSites({
|
||||||
workOrderId: workOrder.workOrderId
|
workOrderId: workOrder.workOrderId
|
||||||
}, {
|
}, {
|
||||||
limit: -1,
|
limit: -1,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
includeLotOccupancyCount: false
|
includeBurialSiteContractCount: false
|
||||||
}, database);
|
}, database);
|
||||||
workOrder.workOrderLots = workOrderLotsResults.lots;
|
workOrder.workOrderBurialSites = workOrderBurialSitesResults.burialSites;
|
||||||
}
|
}
|
||||||
const BurialSiteContracts = await getBurialSiteContracts({
|
const burialSiteContracts = await getBurialSiteContracts({
|
||||||
workOrderId: workOrder.workOrderId
|
workOrderId: workOrder.workOrderId
|
||||||
}, {
|
}, {
|
||||||
limit: -1,
|
limit: -1,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
includeOccupants: true,
|
includeInterments: true,
|
||||||
includeFees: false,
|
includeFees: false,
|
||||||
includeTransactions: false
|
includeTransactions: false
|
||||||
}, database);
|
}, database);
|
||||||
workOrder.workOrderBurialSiteContracts = BurialSiteContracts.BurialSiteContracts;
|
workOrder.workOrderBurialSiteContracts = burialSiteContracts.burialSiteContracts;
|
||||||
}
|
}
|
||||||
if (options.includeMilestones ?? false) {
|
if (options.includeMilestones ?? false) {
|
||||||
workOrder.workOrderMilestones =
|
workOrder.workOrderMilestones =
|
||||||
|
|
@ -142,7 +142,7 @@ export async function getWorkOrders(filters, options, connectedDatabase) {
|
||||||
.all(sqlParameters);
|
.all(sqlParameters);
|
||||||
}
|
}
|
||||||
const hasInclusions = (options.includeComments ?? false) ||
|
const hasInclusions = (options.includeComments ?? false) ||
|
||||||
(options.includeLotsAndBurialSiteContracts ?? false) ||
|
(options.includeBurialSites ?? false) ||
|
||||||
(options.includeMilestones ?? false);
|
(options.includeMilestones ?? false);
|
||||||
if (hasInclusions) {
|
if (hasInclusions) {
|
||||||
for (const workOrder of workOrders) {
|
for (const workOrder of workOrders) {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import {
|
||||||
import type { WorkOrder } from '../types/recordTypes.js'
|
import type { WorkOrder } from '../types/recordTypes.js'
|
||||||
|
|
||||||
import getBurialSiteContracts from './getBurialSiteContracts.js'
|
import getBurialSiteContracts from './getBurialSiteContracts.js'
|
||||||
import getLots from './getLots.js'
|
import getBurialSites from './getBurialSites.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 { acquireConnection } from './pool.js'
|
||||||
|
|
@ -29,7 +29,7 @@ export interface GetWorkOrdersFilters {
|
||||||
interface GetWorkOrdersOptions {
|
interface GetWorkOrdersOptions {
|
||||||
limit: number
|
limit: number
|
||||||
offset: number
|
offset: number
|
||||||
includeLotsAndBurialSiteContracts?: boolean
|
includeBurialSites?: boolean
|
||||||
includeComments?: boolean
|
includeComments?: boolean
|
||||||
includeMilestones?: boolean
|
includeMilestones?: boolean
|
||||||
}
|
}
|
||||||
|
|
@ -77,18 +77,18 @@ function buildWhereClause(filters: GetWorkOrdersFilters): {
|
||||||
sqlParameters.push(...occupantNameFilters.sqlParameters)
|
sqlParameters.push(...occupantNameFilters.sqlParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
const lotNameFilters = getBurialSiteNameWhereClause(filters.lotName, '', 'l')
|
const burialSiteNameFilters = getBurialSiteNameWhereClause(filters.lotName, '', 'l')
|
||||||
if (lotNameFilters.sqlParameters.length > 0) {
|
if (burialSiteNameFilters.sqlParameters.length > 0) {
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
` and w.workOrderId in (
|
` and w.workOrderId in (
|
||||||
select workOrderId from WorkOrderLots
|
select workOrderId from WorkOrderBurialSites
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and lotId in (
|
and burialSiteId in (
|
||||||
select lotId from Lots l
|
select burialSiteId from BurialSites l
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
${lotNameFilters.sqlWhereClause}
|
${burialSiteNameFilters.sqlWhereClause}
|
||||||
))`
|
))`
|
||||||
sqlParameters.push(...lotNameFilters.sqlParameters)
|
sqlParameters.push(...burialSiteNameFilters.sqlParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((filters.burialSiteContractId ?? '') !== '') {
|
if ((filters.burialSiteContractId ?? '') !== '') {
|
||||||
|
|
@ -115,40 +115,40 @@ async function addInclusions(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.includeLotsAndBurialSiteContracts ?? false) {
|
if (options.includeBurialSites ?? false) {
|
||||||
if (workOrder.workOrderLotCount === 0) {
|
if (workOrder.workOrderBurialSiteCount === 0) {
|
||||||
workOrder.workOrderLots = []
|
workOrder.workOrderBurialSites = []
|
||||||
} else {
|
} else {
|
||||||
const workOrderLotsResults = await getLots(
|
const workOrderBurialSitesResults = await getBurialSites(
|
||||||
{
|
{
|
||||||
workOrderId: workOrder.workOrderId
|
workOrderId: workOrder.workOrderId
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
limit: -1,
|
limit: -1,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
includeLotOccupancyCount: false
|
includeBurialSiteContractCount: false
|
||||||
},
|
},
|
||||||
database
|
database
|
||||||
)
|
)
|
||||||
|
|
||||||
workOrder.workOrderLots = workOrderLotsResults.lots
|
workOrder.workOrderBurialSites = workOrderBurialSitesResults.burialSites
|
||||||
}
|
}
|
||||||
|
|
||||||
const BurialSiteContracts = await getBurialSiteContracts(
|
const burialSiteContracts = await getBurialSiteContracts(
|
||||||
{
|
{
|
||||||
workOrderId: workOrder.workOrderId
|
workOrderId: workOrder.workOrderId
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
limit: -1,
|
limit: -1,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
includeOccupants: true,
|
includeInterments: true,
|
||||||
includeFees: false,
|
includeFees: false,
|
||||||
includeTransactions: false
|
includeTransactions: false
|
||||||
},
|
},
|
||||||
database
|
database
|
||||||
)
|
)
|
||||||
|
|
||||||
workOrder.workOrderBurialSiteContracts = BurialSiteContracts.BurialSiteContracts
|
workOrder.workOrderBurialSiteContracts = burialSiteContracts.burialSiteContracts
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.includeMilestones ?? false) {
|
if (options.includeMilestones ?? false) {
|
||||||
|
|
@ -230,7 +230,7 @@ export async function getWorkOrders(
|
||||||
|
|
||||||
const hasInclusions =
|
const hasInclusions =
|
||||||
(options.includeComments ?? false) ||
|
(options.includeComments ?? false) ||
|
||||||
(options.includeLotsAndBurialSiteContracts ?? false) ||
|
(options.includeBurialSites ?? false) ||
|
||||||
(options.includeMilestones ?? false)
|
(options.includeMilestones ?? false)
|
||||||
|
|
||||||
if (hasInclusions) {
|
if (hasInclusions) {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
||||||
export interface BurialSiteCommentUpdateForm {
|
export interface UpdateForm {
|
||||||
burialSiteContractCommentId: string | number;
|
burialSiteContractCommentId: string | number;
|
||||||
commentDateString: DateString;
|
commentDateString: DateString;
|
||||||
commentTimeString: TimeString;
|
commentTimeString: TimeString;
|
||||||
comment: string;
|
comment: string;
|
||||||
}
|
}
|
||||||
export default function updateBurialSiteContractComment(commentForm: BurialSiteCommentUpdateForm, user: User): Promise<boolean>;
|
export default function updateBurialSiteContractComment(commentForm: UpdateForm, user: User): Promise<boolean>;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import {
|
||||||
|
|
||||||
import { acquireConnection } from './pool.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface BurialSiteCommentUpdateForm {
|
export interface UpdateForm {
|
||||||
burialSiteContractCommentId: string | number
|
burialSiteContractCommentId: string | number
|
||||||
commentDateString: DateString
|
commentDateString: DateString
|
||||||
commentTimeString: TimeString
|
commentTimeString: TimeString
|
||||||
|
|
@ -15,7 +15,7 @@ export interface BurialSiteCommentUpdateForm {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function updateBurialSiteContractComment(
|
export default async function updateBurialSiteContractComment(
|
||||||
commentForm: BurialSiteCommentUpdateForm,
|
commentForm: UpdateForm,
|
||||||
user: User
|
user: User
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const database = await acquireConnection()
|
const database = await acquireConnection()
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,4 @@ export interface UpdateLotOccupancyOccupantForm {
|
||||||
occupantEmailAddress: string;
|
occupantEmailAddress: string;
|
||||||
occupantComment: string;
|
occupantComment: string;
|
||||||
}
|
}
|
||||||
export default function updateLotOccupancyOccupant(burialSiteContractOccupantForm: UpdateLotOccupancyOccupantForm, user: User): Promise<boolean>;
|
export default function updateBurialSiteContractOccupant(burialSiteContractOccupantForm: UpdateLotOccupancyOccupantForm, user: User): Promise<boolean>;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
export default async function updateLotOccupancyOccupant(burialSiteContractOccupantForm, user) {
|
export default async function updateBurialSiteContractOccupant(burialSiteContractOccupantForm, user) {
|
||||||
const database = await acquireConnection();
|
const database = await acquireConnection();
|
||||||
const results = database
|
const results = database
|
||||||
.prepare(`update LotOccupancyOccupants
|
.prepare(`update LotOccupancyOccupants
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ export interface UpdateLotOccupancyOccupantForm {
|
||||||
occupantComment: string
|
occupantComment: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function updateLotOccupancyOccupant(
|
export default async function updateBurialSiteContractOccupant(
|
||||||
burialSiteContractOccupantForm: UpdateLotOccupancyOccupantForm,
|
burialSiteContractOccupantForm: UpdateLotOccupancyOccupantForm,
|
||||||
user: User
|
user: User
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ function buildEventSummary(milestone) {
|
||||||
? milestone.workOrderMilestoneDescription ?? ''
|
? milestone.workOrderMilestoneDescription ?? ''
|
||||||
: milestone.workOrderMilestoneType ?? '').trim();
|
: milestone.workOrderMilestoneType ?? '').trim();
|
||||||
let occupantCount = 0;
|
let occupantCount = 0;
|
||||||
for (const burialSiteContract of milestone.workOrderLotOccupancies ?? []) {
|
for (const burialSiteContract of milestone.workOrderBurialSiteContracts ?? []) {
|
||||||
for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) {
|
for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) {
|
||||||
occupantCount += 1;
|
occupantCount += 1;
|
||||||
if (occupantCount === 1) {
|
if (occupantCount === 1) {
|
||||||
|
|
@ -42,21 +42,21 @@ function buildEventSummary(milestone) {
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
function buildEventDescriptionHTML_occupancies(request, milestone) {
|
function buildEventDescriptionHTML_occupancies(request, milestone) {
|
||||||
let descriptionHTML = '';
|
let descriptionHTML = '';
|
||||||
if (milestone.workOrderLotOccupancies.length > 0) {
|
if (milestone.workOrderBurialSiteContracts.length > 0) {
|
||||||
const urlRoot = getUrlRoot(request);
|
const urlRoot = getUrlRoot(request);
|
||||||
descriptionHTML = `<h2>
|
descriptionHTML = `<h2>
|
||||||
Related ${escapeHTML(getConfigProperty('aliases.occupancies'))}
|
Related Contracts
|
||||||
</h2>
|
</h2>
|
||||||
<table border="1">
|
<table border="1">
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
<th>${escapeHTML(getConfigProperty('aliases.occupancy'))} Type</th>
|
<th>Contract Type</th>
|
||||||
<th>${escapeHTML(getConfigProperty('aliases.lot'))}</th>
|
<th>Burial Site</th>
|
||||||
<th>Start Date</th>
|
<th>Start Date</th>
|
||||||
<th>End Date</th>
|
<th>End Date</th>
|
||||||
<th>${escapeHTML(getConfigProperty('aliases.occupants'))}</th>
|
<th>${escapeHTML(getConfigProperty('aliases.occupants'))}</th>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
<tbody>`;
|
<tbody>`;
|
||||||
for (const occupancy of milestone.workOrderLotOccupancies ?? []) {
|
for (const occupancy of milestone.workOrderBurialSiteContracts ?? []) {
|
||||||
descriptionHTML += `<tr>
|
descriptionHTML += `<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="${urlRoot}/contracts/${occupancy.burialSiteContractId}">
|
<a href="${urlRoot}/contracts/${occupancy.burialSiteContractId}">
|
||||||
|
|
@ -87,34 +87,28 @@ function buildEventDescriptionHTML_occupancies(request, milestone) {
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
function buildEventDescriptionHTML_lots(request, milestone) {
|
function buildEventDescriptionHTML_lots(request, milestone) {
|
||||||
let descriptionHTML = '';
|
let descriptionHTML = '';
|
||||||
if (milestone.workOrderLots.length > 0) {
|
if ((milestone.workOrderBurialSites ?? []).length > 0) {
|
||||||
const urlRoot = getUrlRoot(request);
|
const urlRoot = getUrlRoot(request);
|
||||||
descriptionHTML += `<h2>
|
descriptionHTML += `<h2>
|
||||||
Related ${escapeHTML(getConfigProperty('aliases.lots'))}
|
Related Burial Sites
|
||||||
</h2>
|
</h2>
|
||||||
<table border="1"><thead><tr>
|
<table border="1"><thead><tr>
|
||||||
<th>
|
<th>Burial Site</th>
|
||||||
${escapeHTML(getConfigProperty('aliases.lot'))}
|
<th>Cemetery</th>
|
||||||
</th>
|
<th>Burial Site Type</th>
|
||||||
<th>
|
|
||||||
${escapeHTML(getConfigProperty('aliases.map'))}
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
${escapeHTML(getConfigProperty('aliases.lot'))} Type
|
|
||||||
</th>
|
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
<tbody>`;
|
<tbody>`;
|
||||||
for (const lot of milestone.workOrderLots ?? []) {
|
for (const burialSite of milestone.workOrderBurialSites ?? []) {
|
||||||
descriptionHTML += `<tr>
|
descriptionHTML += `<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="${urlRoot}/lots/${lot.lotId.toString()}">
|
<a href="${urlRoot}/burialSites/${burialSite.burialSiteId.toString()}">
|
||||||
${escapeHTML(lot.lotName ?? '')}
|
${escapeHTML(burialSite.burialSiteName ?? '')}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>${escapeHTML(lot.cemeteryName ?? '')}</td>
|
<td>${escapeHTML(burialSite.cemeteryName ?? '')}</td>
|
||||||
<td>${escapeHTML(lot.lotType ?? '')}</td>
|
<td>${escapeHTML(burialSite.burialSiteType ?? '')}</td>
|
||||||
<td>${escapeHTML(lot.lotStatus ?? '')}</td>
|
<td>${escapeHTML(burialSite.burialSiteStatus ?? '')}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
}
|
}
|
||||||
descriptionHTML += '</tbody></table>';
|
descriptionHTML += '</tbody></table>';
|
||||||
|
|
@ -163,13 +157,13 @@ function buildEventCategoryList(milestone) {
|
||||||
return categories;
|
return categories;
|
||||||
}
|
}
|
||||||
function buildEventLocation(milestone) {
|
function buildEventLocation(milestone) {
|
||||||
const lotNames = [];
|
const burialSiteNames = [];
|
||||||
if (milestone.workOrderLots.length > 0) {
|
if ((milestone.workOrderBurialSites ?? []).length > 0) {
|
||||||
for (const lot of milestone.workOrderLots ?? []) {
|
for (const burialSite of milestone.workOrderBurialSites ?? []) {
|
||||||
lotNames.push(`${lot.cemeteryName ?? ''}: ${lot.lotName ?? ''}`);
|
burialSiteNames.push(`${burialSite.cemeteryName ?? ''}: ${burialSite.burialSiteName ?? ''}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lotNames.join(', ');
|
return burialSiteNames.join(', ');
|
||||||
}
|
}
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const urlRoot = getUrlRoot(request);
|
const urlRoot = getUrlRoot(request);
|
||||||
|
|
@ -253,9 +247,9 @@ export default async function handler(request, response) {
|
||||||
const location = buildEventLocation(milestone);
|
const location = buildEventLocation(milestone);
|
||||||
calendarEvent.location(location);
|
calendarEvent.location(location);
|
||||||
// Set organizer / attendees
|
// Set organizer / attendees
|
||||||
if (milestone.workOrderLotOccupancies.length > 0) {
|
if (milestone.workOrderBurialSiteContracts.length > 0) {
|
||||||
let organizerSet = false;
|
let organizerSet = false;
|
||||||
for (const burialSiteContract of milestone.workOrderLotOccupancies ?? []) {
|
for (const burialSiteContract of milestone.workOrderBurialSiteContracts ?? []) {
|
||||||
for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) {
|
for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) {
|
||||||
if (organizerSet) {
|
if (organizerSet) {
|
||||||
calendarEvent.createAttendee({
|
calendarEvent.createAttendee({
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ function buildEventSummary(milestone: WorkOrderMilestone): string {
|
||||||
|
|
||||||
let occupantCount = 0
|
let occupantCount = 0
|
||||||
|
|
||||||
for (const burialSiteContract of milestone.workOrderLotOccupancies ?? []) {
|
for (const burialSiteContract of milestone.workOrderBurialSiteContracts ?? []) {
|
||||||
for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) {
|
for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) {
|
||||||
occupantCount += 1
|
occupantCount += 1
|
||||||
|
|
||||||
|
|
@ -75,23 +75,23 @@ function buildEventDescriptionHTML_occupancies(
|
||||||
): string {
|
): string {
|
||||||
let descriptionHTML = ''
|
let descriptionHTML = ''
|
||||||
|
|
||||||
if (milestone.workOrderLotOccupancies!.length > 0) {
|
if (milestone.workOrderBurialSiteContracts!.length > 0) {
|
||||||
const urlRoot = getUrlRoot(request)
|
const urlRoot = getUrlRoot(request)
|
||||||
|
|
||||||
descriptionHTML = `<h2>
|
descriptionHTML = `<h2>
|
||||||
Related ${escapeHTML(getConfigProperty('aliases.occupancies'))}
|
Related Contracts
|
||||||
</h2>
|
</h2>
|
||||||
<table border="1">
|
<table border="1">
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
<th>${escapeHTML(getConfigProperty('aliases.occupancy'))} Type</th>
|
<th>Contract Type</th>
|
||||||
<th>${escapeHTML(getConfigProperty('aliases.lot'))}</th>
|
<th>Burial Site</th>
|
||||||
<th>Start Date</th>
|
<th>Start Date</th>
|
||||||
<th>End Date</th>
|
<th>End Date</th>
|
||||||
<th>${escapeHTML(getConfigProperty('aliases.occupants'))}</th>
|
<th>${escapeHTML(getConfigProperty('aliases.occupants'))}</th>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
<tbody>`
|
<tbody>`
|
||||||
|
|
||||||
for (const occupancy of milestone.workOrderLotOccupancies ?? []) {
|
for (const occupancy of milestone.workOrderBurialSiteContracts ?? []) {
|
||||||
descriptionHTML += `<tr>
|
descriptionHTML += `<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="${urlRoot}/contracts/${occupancy.burialSiteContractId}">
|
<a href="${urlRoot}/contracts/${occupancy.burialSiteContractId}">
|
||||||
|
|
@ -137,36 +137,30 @@ function buildEventDescriptionHTML_lots(
|
||||||
): string {
|
): string {
|
||||||
let descriptionHTML = ''
|
let descriptionHTML = ''
|
||||||
|
|
||||||
if (milestone.workOrderLots!.length > 0) {
|
if ((milestone.workOrderBurialSites ?? []).length > 0) {
|
||||||
const urlRoot = getUrlRoot(request)
|
const urlRoot = getUrlRoot(request)
|
||||||
|
|
||||||
descriptionHTML += `<h2>
|
descriptionHTML += `<h2>
|
||||||
Related ${escapeHTML(getConfigProperty('aliases.lots'))}
|
Related Burial Sites
|
||||||
</h2>
|
</h2>
|
||||||
<table border="1"><thead><tr>
|
<table border="1"><thead><tr>
|
||||||
<th>
|
<th>Burial Site</th>
|
||||||
${escapeHTML(getConfigProperty('aliases.lot'))}
|
<th>Cemetery</th>
|
||||||
</th>
|
<th>Burial Site Type</th>
|
||||||
<th>
|
|
||||||
${escapeHTML(getConfigProperty('aliases.map'))}
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
${escapeHTML(getConfigProperty('aliases.lot'))} Type
|
|
||||||
</th>
|
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
<tbody>`
|
<tbody>`
|
||||||
|
|
||||||
for (const lot of milestone.workOrderLots ?? []) {
|
for (const burialSite of milestone.workOrderBurialSites ?? []) {
|
||||||
descriptionHTML += `<tr>
|
descriptionHTML += `<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="${urlRoot}/lots/${lot.lotId.toString()}">
|
<a href="${urlRoot}/burialSites/${burialSite.burialSiteId.toString()}">
|
||||||
${escapeHTML(lot.lotName ?? '')}
|
${escapeHTML(burialSite.burialSiteName ?? '')}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>${escapeHTML(lot.cemeteryName ?? '')}</td>
|
<td>${escapeHTML(burialSite.cemeteryName ?? '')}</td>
|
||||||
<td>${escapeHTML(lot.lotType ?? '')}</td>
|
<td>${escapeHTML(burialSite.burialSiteType ?? '')}</td>
|
||||||
<td>${escapeHTML(lot.lotStatus ?? '')}</td>
|
<td>${escapeHTML(burialSite.burialSiteStatus ?? '')}</td>
|
||||||
</tr>`
|
</tr>`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -242,14 +236,14 @@ function buildEventCategoryList(milestone: WorkOrderMilestone): string[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildEventLocation(milestone: WorkOrderMilestone): string {
|
function buildEventLocation(milestone: WorkOrderMilestone): string {
|
||||||
const lotNames: string[] = []
|
const burialSiteNames: string[] = []
|
||||||
|
|
||||||
if (milestone.workOrderLots!.length > 0) {
|
if ((milestone.workOrderBurialSites ?? []).length > 0) {
|
||||||
for (const lot of milestone.workOrderLots ?? []) {
|
for (const burialSite of milestone.workOrderBurialSites ?? []) {
|
||||||
lotNames.push(`${lot.cemeteryName ?? ''}: ${lot.lotName ?? ''}`)
|
burialSiteNames.push(`${burialSite.cemeteryName ?? ''}: ${burialSite.burialSiteName ?? ''}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lotNames.join(', ')
|
return burialSiteNames.join(', ')
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
|
|
@ -375,9 +369,9 @@ export default async function handler(
|
||||||
calendarEvent.location(location)
|
calendarEvent.location(location)
|
||||||
|
|
||||||
// Set organizer / attendees
|
// Set organizer / attendees
|
||||||
if (milestone.workOrderLotOccupancies!.length > 0) {
|
if (milestone.workOrderBurialSiteContracts!.length > 0) {
|
||||||
let organizerSet = false
|
let organizerSet = false
|
||||||
for (const burialSiteContract of milestone.workOrderLotOccupancies ?? []) {
|
for (const burialSiteContract of milestone.workOrderBurialSiteContracts ?? []) {
|
||||||
for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) {
|
for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) {
|
||||||
if (organizerSet) {
|
if (organizerSet) {
|
||||||
calendarEvent.createAttendee({
|
calendarEvent.createAttendee({
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
import type { Request, Response } from 'express';
|
import type { Request, Response } from 'express';
|
||||||
export default function handler(request: Request, response: Response): Promise<void>;
|
import { type GetBurialSiteContractsFilters, type GetBurialSiteContractsOptions } from '../../database/getBurialSiteContracts.js';
|
||||||
|
export default function handler(request: Request<unknown, unknown, GetBurialSiteContractsFilters & GetBurialSiteContractsOptions>, response: Response): Promise<void>;
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,15 @@ export default async function handler(request, response) {
|
||||||
const result = await getBurialSiteContracts(request.body, {
|
const result = await getBurialSiteContracts(request.body, {
|
||||||
limit: request.body.limit,
|
limit: request.body.limit,
|
||||||
offset: request.body.offset,
|
offset: request.body.offset,
|
||||||
includeOccupants: true,
|
includeInterments: true,
|
||||||
includeFees: true,
|
includeFees: true,
|
||||||
includeTransactions: true
|
includeTransactions: true
|
||||||
});
|
});
|
||||||
response.json({
|
response.json({
|
||||||
count: result.count,
|
count: result.count,
|
||||||
offset: Number.parseInt(request.body.offset, 10),
|
offset: typeof request.body.offset === 'string'
|
||||||
lotOccupancies: result.lotOccupancies
|
? Number.parseInt(request.body.offset, 10)
|
||||||
|
: request.body.offset,
|
||||||
|
burialSiteContracts: result.burialSiteContracts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,32 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import getBurialSiteContracts from '../../database/getBurialSiteContracts.js'
|
import getBurialSiteContracts, {
|
||||||
|
type GetBurialSiteContractsFilters,
|
||||||
|
type GetBurialSiteContractsOptions
|
||||||
|
} from '../../database/getBurialSiteContracts.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request<
|
||||||
|
unknown,
|
||||||
|
unknown,
|
||||||
|
GetBurialSiteContractsFilters & GetBurialSiteContractsOptions
|
||||||
|
>,
|
||||||
response: Response
|
response: Response
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const result = await getBurialSiteContracts(request.body, {
|
const result = await getBurialSiteContracts(request.body, {
|
||||||
limit: request.body.limit,
|
limit: request.body.limit,
|
||||||
offset: request.body.offset,
|
offset: request.body.offset,
|
||||||
includeOccupants: true,
|
includeInterments: true,
|
||||||
includeFees: true,
|
includeFees: true,
|
||||||
includeTransactions: true
|
includeTransactions: true
|
||||||
})
|
})
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
count: result.count,
|
count: result.count,
|
||||||
offset: Number.parseInt(request.body.offset, 10),
|
offset:
|
||||||
lotOccupancies: result.lotOccupancies
|
typeof request.body.offset === 'string'
|
||||||
|
? Number.parseInt(request.body.offset, 10)
|
||||||
|
: request.body.offset,
|
||||||
|
burialSiteContracts: result.burialSiteContracts
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
import type { Request, Response } from 'express';
|
import type { Request, Response } from 'express';
|
||||||
export default function handler(request: Request, response: Response): Promise<void>;
|
import { type UpdateBurialSiteContractForm } from '../../database/updateBurialSiteContract.js';
|
||||||
|
export default function handler(request: Request<unknown, unknown, UpdateBurialSiteContractForm>, response: Response): Promise<void>;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import updateLotOccupancy from '../../database/updateLotOccupancy.js';
|
import updateBurialSiteContract from '../../database/updateBurialSiteContract.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const success = await updateLotOccupancy(request.body, request.session.user);
|
const success = await updateBurialSiteContract(request.body, request.session.user);
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
burialSiteContractId: request.body.burialSiteContractId
|
burialSiteContractId: request.body.burialSiteContractId
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import updateLotOccupancy, {
|
import updateBurialSiteContract, {
|
||||||
type UpdateLotOccupancyForm
|
type UpdateBurialSiteContractForm
|
||||||
} from '../../database/updateLotOccupancy.js'
|
} from '../../database/updateBurialSiteContract.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request<unknown, unknown, UpdateBurialSiteContractForm>,
|
||||||
response: Response
|
response: Response
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const success = await updateLotOccupancy(
|
const success = await updateBurialSiteContract(
|
||||||
request.body as UpdateLotOccupancyForm,
|
request.body,
|
||||||
request.session.user as User
|
request.session.user as User
|
||||||
)
|
)
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
burialSiteContractId: request.body.burialSiteContractId as string
|
burialSiteContractId: request.body.burialSiteContractId
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,5 @@
|
||||||
import type { Request, Response } from 'express';
|
import type { Request, Response } from 'express';
|
||||||
export default function handler(request: Request, response: Response): Promise<void>;
|
import { type UpdateForm } from '../../database/updateBurialSiteContractComment.js';
|
||||||
|
export default function handler(request: Request<unknown, unknown, UpdateForm & {
|
||||||
|
burialSiteContractId: string;
|
||||||
|
}>, response: Response): Promise<void>;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import getBurialSiteContractComments from '../../database/getBurialSiteContractComments.js';
|
import getBurialSiteContractComments from '../../database/getBurialSiteContractComments.js';
|
||||||
import updateLotOccupancyComment from '../../database/updateLotOccupancyComment.js';
|
import updateBurialSiteContractComment from '../../database/updateBurialSiteContractComment.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const success = await updateLotOccupancyComment(request.body, request.session.user);
|
const success = await updateBurialSiteContractComment(request.body, request.session.user);
|
||||||
const burialSiteContractComments = await getBurialSiteContractComments(request.body.burialSiteContractId);
|
const burialSiteContractComments = await getBurialSiteContractComments(request.body.burialSiteContractId);
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,25 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import getBurialSiteContractComments from '../../database/getBurialSiteContractComments.js'
|
import getBurialSiteContractComments from '../../database/getBurialSiteContractComments.js'
|
||||||
import updateLotOccupancyComment, {
|
import updateBurialSiteContractComment, {
|
||||||
type UpdateLotOccupancyCommentForm
|
type UpdateForm
|
||||||
} from '../../database/updateLotOccupancyComment.js'
|
} from '../../database/updateBurialSiteContractComment.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request<
|
||||||
|
unknown,
|
||||||
|
unknown,
|
||||||
|
UpdateForm & { burialSiteContractId: string }
|
||||||
|
>,
|
||||||
response: Response
|
response: Response
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const success = await updateLotOccupancyComment(
|
const success = await updateBurialSiteContractComment(
|
||||||
request.body as UpdateLotOccupancyCommentForm,
|
request.body,
|
||||||
request.session.user as User
|
request.session.user as User
|
||||||
)
|
)
|
||||||
|
|
||||||
const burialSiteContractComments = await getBurialSiteContractComments(
|
const burialSiteContractComments = await getBurialSiteContractComments(
|
||||||
request.body.burialSiteContractId as string
|
request.body.burialSiteContractId
|
||||||
)
|
)
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
import type { Request, Response } from 'express';
|
import type { Request, Response } from 'express';
|
||||||
export default function handler(request: Request, response: Response): Promise<void>;
|
import { type UpdateBurialSiteFeeForm } from '../../database/updateBurialSiteContractFeeQuantity.js';
|
||||||
|
export default function handler(request: Request<unknown, unknown, UpdateBurialSiteFeeForm>, response: Response): Promise<void>;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import getBurialSiteContractFees from '../../database/getBurialSiteContractFees.js';
|
import getBurialSiteContractFees from '../../database/getBurialSiteContractFees.js';
|
||||||
import updateLotOccupancyFeeQuantity from '../../database/updateLotOccupancyFeeQuantity.js';
|
import updateBurialSiteContractFeeQuantity from '../../database/updateBurialSiteContractFeeQuantity.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const success = await updateLotOccupancyFeeQuantity(request.body, request.session.user);
|
const success = await updateBurialSiteContractFeeQuantity(request.body, request.session.user);
|
||||||
const burialSiteContractFees = await getBurialSiteContractFees(request.body.burialSiteContractId);
|
const burialSiteContractFees = await getBurialSiteContractFees(request.body.burialSiteContractId);
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import getBurialSiteContractFees from '../../database/getBurialSiteContractFees.js'
|
import getBurialSiteContractFees from '../../database/getBurialSiteContractFees.js'
|
||||||
import updateLotOccupancyFeeQuantity, {
|
import updateBurialSiteContractFeeQuantity, {
|
||||||
type UpdateLotOccupancyFeeQuantityForm
|
type UpdateBurialSiteFeeForm
|
||||||
} from '../../database/updateLotOccupancyFeeQuantity.js'
|
} from '../../database/updateBurialSiteContractFeeQuantity.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request<unknown, unknown, UpdateBurialSiteFeeForm>,
|
||||||
response: Response
|
response: Response
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const success = await updateLotOccupancyFeeQuantity(
|
const success = await updateBurialSiteContractFeeQuantity(
|
||||||
request.body as UpdateLotOccupancyFeeQuantityForm,
|
request.body,
|
||||||
request.session.user as User
|
request.session.user as User
|
||||||
)
|
)
|
||||||
|
|
||||||
const burialSiteContractFees = await getBurialSiteContractFees(
|
const burialSiteContractFees = await getBurialSiteContractFees(
|
||||||
request.body.burialSiteContractId as string
|
request.body.burialSiteContractId
|
||||||
)
|
)
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
import type { Request, Response } from 'express';
|
import type { Request, Response } from 'express';
|
||||||
export default function handler(request: Request, response: Response): Promise<void>;
|
import { type BurialSiteContractTransactionUpdateForm } from '../../database/updateBurialSiteContractTransaction.js';
|
||||||
|
export default function handler(request: Request<unknown, unknown, BurialSiteContractTransactionUpdateForm>, response: Response): Promise<void>;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import getBurialSiteContractTransactions from '../../database/getBurialSiteContractTransactions.js';
|
import getBurialSiteContractTransactions from '../../database/getBurialSiteContractTransactions.js';
|
||||||
import updateLotOccupancyTransaction from '../../database/updateLotOccupancyTransaction.js';
|
import updateBurialSiteContractTransaction from '../../database/updateBurialSiteContractTransaction.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
await updateLotOccupancyTransaction(request.body, request.session.user);
|
await updateBurialSiteContractTransaction(request.body, request.session.user);
|
||||||
const burialSiteContractTransactions = await getBurialSiteContractTransactions(request.body.burialSiteContractId, { includeIntegrations: true });
|
const burialSiteContractTransactions = await getBurialSiteContractTransactions(request.body.burialSiteContractId, {
|
||||||
|
includeIntegrations: true
|
||||||
|
});
|
||||||
response.json({
|
response.json({
|
||||||
success: true,
|
success: true,
|
||||||
burialSiteContractTransactions
|
burialSiteContractTransactions
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,23 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import getBurialSiteContractTransactions from '../../database/getBurialSiteContractTransactions.js'
|
import getBurialSiteContractTransactions from '../../database/getBurialSiteContractTransactions.js'
|
||||||
import updateLotOccupancyTransaction, {
|
import updateBurialSiteContractTransaction, {
|
||||||
type UpdateLotOccupancyTransactionForm
|
type BurialSiteContractTransactionUpdateForm
|
||||||
} from '../../database/updateLotOccupancyTransaction.js'
|
} from '../../database/updateBurialSiteContractTransaction.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request<unknown, unknown, BurialSiteContractTransactionUpdateForm>,
|
||||||
response: Response
|
response: Response
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await updateLotOccupancyTransaction(
|
await updateBurialSiteContractTransaction(
|
||||||
request.body as UpdateLotOccupancyTransactionForm,
|
request.body,
|
||||||
request.session.user as User
|
request.session.user as User
|
||||||
)
|
)
|
||||||
|
|
||||||
const burialSiteContractTransactions = await getBurialSiteContractTransactions(
|
const burialSiteContractTransactions =
|
||||||
request.body.burialSiteContractId as string,
|
await getBurialSiteContractTransactions(request.body.burialSiteContractId, {
|
||||||
{ includeIntegrations: true }
|
includeIntegrations: true
|
||||||
)
|
})
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
success: true,
|
success: true,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import { getPdfPrintConfig, getReportData } from '../../helpers/functions.print.
|
||||||
const attachmentOrInline = getConfigProperty('settings.printPdf.contentDisposition');
|
const attachmentOrInline = getConfigProperty('settings.printPdf.contentDisposition');
|
||||||
export async function handler(request, response, next) {
|
export async function handler(request, response, next) {
|
||||||
const printName = request.params.printName;
|
const printName = request.params.printName;
|
||||||
if (!getConfigProperty('settings.burialSiteContract.prints').includes(`pdf/${printName}`) &&
|
if (!getConfigProperty('settings.contracts.prints').includes(`pdf/${printName}`) &&
|
||||||
!getConfigProperty('settings.workOrders.prints').includes(`pdf/${printName}`)) {
|
!getConfigProperty('settings.workOrders.prints').includes(`pdf/${printName}`)) {
|
||||||
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/dashboard/?error=printConfigNotAllowed`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/dashboard/?error=printConfigNotAllowed`);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ export async function handler(
|
||||||
const printName = request.params.printName
|
const printName = request.params.printName
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!getConfigProperty('settings.burialSiteContract.prints').includes(
|
!getConfigProperty('settings.contracts.prints').includes(
|
||||||
`pdf/${printName}`
|
`pdf/${printName}`
|
||||||
) &&
|
) &&
|
||||||
!getConfigProperty('settings.workOrders.prints').includes(
|
!getConfigProperty('settings.workOrders.prints').includes(
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { getConfigProperty } from '../../helpers/config.helpers.js';
|
||||||
import { getReportData, getScreenPrintConfig } from '../../helpers/functions.print.js';
|
import { getReportData, getScreenPrintConfig } from '../../helpers/functions.print.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const printName = request.params.printName;
|
const printName = request.params.printName;
|
||||||
if (!getConfigProperty('settings.burialSiteContract.prints').includes(`screen/${printName}`) &&
|
if (!getConfigProperty('settings.contracts.prints').includes(`screen/${printName}`) &&
|
||||||
!getConfigProperty('settings.workOrders.prints').includes(`screen/${printName}`)) {
|
!getConfigProperty('settings.workOrders.prints').includes(`screen/${printName}`)) {
|
||||||
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/dashboard/?error=printConfigNotAllowed`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/dashboard/?error=printConfigNotAllowed`);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ export default async function handler(
|
||||||
const printName = request.params.printName
|
const printName = request.params.printName
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!getConfigProperty('settings.burialSiteContract.prints').includes(
|
!getConfigProperty('settings.contracts.prints').includes(
|
||||||
`screen/${printName}`
|
`screen/${printName}`
|
||||||
) &&
|
) &&
|
||||||
!getConfigProperty('settings.workOrders.prints').includes(
|
!getConfigProperty('settings.workOrders.prints').includes(
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import papaparse from 'papaparse';
|
import papaParse from 'papaparse';
|
||||||
import getReportData from '../../database/getReportData.js';
|
import getReportData from '../../database/getReportData.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const reportName = request.params.reportName;
|
const reportName = request.params.reportName;
|
||||||
|
|
@ -10,7 +10,7 @@ export default async function handler(request, response) {
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const csv = papaparse.unparse(rows);
|
const csv = papaParse.unparse(rows);
|
||||||
response.setHeader('Content-Disposition', `attachment; filename=${reportName}-${Date.now().toString()}.csv`);
|
response.setHeader('Content-Disposition', `attachment; filename=${reportName}-${Date.now().toString()}.csv`);
|
||||||
response.setHeader('Content-Type', 'text/csv');
|
response.setHeader('Content-Type', 'text/csv');
|
||||||
response.send(csv);
|
response.send(csv);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
import papaparse from 'papaparse'
|
import papaParse from 'papaparse'
|
||||||
|
|
||||||
import getReportData, {
|
import getReportData, {
|
||||||
type ReportParameters
|
type ReportParameters
|
||||||
|
|
@ -25,7 +25,7 @@ export default async function handler(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const csv = papaparse.unparse(rows)
|
const csv = papaParse.unparse(rows)
|
||||||
|
|
||||||
response.setHeader(
|
response.setHeader(
|
||||||
'Content-Disposition',
|
'Content-Disposition',
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,14 @@ import getCemeteries from '../../database/getCemeteries.js';
|
||||||
import { getBurialSiteStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js';
|
import { getBurialSiteStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js';
|
||||||
export default async function handler(_request, response) {
|
export default async function handler(_request, response) {
|
||||||
const rightNow = new Date();
|
const rightNow = new Date();
|
||||||
const maps = await getCemeteries();
|
const cemeteries = await getCemeteries();
|
||||||
const lotTypes = await getBurialSiteTypes();
|
const burialSiteTypes = await getBurialSiteTypes();
|
||||||
const lotStatuses = await getBurialSiteStatuses();
|
const burialSiteStatuses = await getBurialSiteStatuses();
|
||||||
response.render('report-search', {
|
response.render('report-search', {
|
||||||
headTitle: 'Reports',
|
headTitle: 'Reports',
|
||||||
todayDateString: dateToString(rightNow),
|
todayDateString: dateToString(rightNow),
|
||||||
maps,
|
cemeteries,
|
||||||
lotTypes,
|
burialSiteTypes,
|
||||||
lotStatuses
|
burialSiteStatuses
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,10 @@ import { dateToString } from '@cityssm/utils-datetime'
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import getCemeteries from '../../database/getCemeteries.js'
|
import getCemeteries from '../../database/getCemeteries.js'
|
||||||
import { getBurialSiteStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js'
|
import {
|
||||||
|
getBurialSiteStatuses,
|
||||||
|
getBurialSiteTypes
|
||||||
|
} from '../../helpers/functions.cache.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
_request: Request,
|
_request: Request,
|
||||||
|
|
@ -10,15 +13,15 @@ export default async function handler(
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const rightNow = new Date()
|
const rightNow = new Date()
|
||||||
|
|
||||||
const maps = await getCemeteries()
|
const cemeteries = await getCemeteries()
|
||||||
const lotTypes = await getBurialSiteTypes()
|
const burialSiteTypes = await getBurialSiteTypes()
|
||||||
const lotStatuses = await getBurialSiteStatuses()
|
const burialSiteStatuses = await getBurialSiteStatuses()
|
||||||
|
|
||||||
response.render('report-search', {
|
response.render('report-search', {
|
||||||
headTitle: 'Reports',
|
headTitle: 'Reports',
|
||||||
todayDateString: dateToString(rightNow),
|
todayDateString: dateToString(rightNow),
|
||||||
maps,
|
cemeteries,
|
||||||
lotTypes,
|
burialSiteTypes,
|
||||||
lotStatuses
|
burialSiteStatuses
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import getWorkOrder from '../../database/getWorkOrder.js';
|
import getWorkOrder from '../../database/getWorkOrder.js';
|
||||||
import { getBurialSiteStatuses, getWorkOrderMilestoneTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js';
|
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
||||||
|
import { getBurialSiteStatuses, getWorkOrderMilestoneTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const workOrder = await getWorkOrder(request.params.workOrderId, {
|
const workOrder = await getWorkOrder(request.params.workOrderId, {
|
||||||
includeLotsAndLotOccupancies: true,
|
includeBurialSites: true,
|
||||||
includeComments: true,
|
includeComments: true,
|
||||||
includeMilestones: true
|
includeMilestones: true
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import getWorkOrder from '../../database/getWorkOrder.js'
|
import getWorkOrder from '../../database/getWorkOrder.js'
|
||||||
|
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
||||||
import {
|
import {
|
||||||
getBurialSiteStatuses,
|
getBurialSiteStatuses,
|
||||||
getWorkOrderMilestoneTypes,
|
getWorkOrderMilestoneTypes,
|
||||||
getWorkOrderTypes
|
getWorkOrderTypes
|
||||||
} from '../../helpers/functions.cache.js'
|
} from '../../helpers/functions.cache.js'
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
response: Response
|
response: Response
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const workOrder = await getWorkOrder(request.params.workOrderId, {
|
const workOrder = await getWorkOrder(request.params.workOrderId, {
|
||||||
includeLotsAndLotOccupancies: true,
|
includeBurialSites: true,
|
||||||
includeComments: true,
|
includeComments: true,
|
||||||
includeMilestones: true
|
includeMilestones: true
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import getWorkOrder from '../../database/getWorkOrder.js';
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const workOrder = await getWorkOrder(request.params.workOrderId, {
|
const workOrder = await getWorkOrder(request.params.workOrderId, {
|
||||||
includeLotsAndLotOccupancies: true,
|
includeBurialSites: true,
|
||||||
includeComments: true,
|
includeComments: true,
|
||||||
includeMilestones: true
|
includeMilestones: true
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ export default async function handler(
|
||||||
response: Response
|
response: Response
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const workOrder = await getWorkOrder(request.params.workOrderId, {
|
const workOrder = await getWorkOrder(request.params.workOrderId, {
|
||||||
includeLotsAndLotOccupancies: true,
|
includeBurialSites: true,
|
||||||
includeComments: true,
|
includeComments: true,
|
||||||
includeMilestones: true
|
includeMilestones: true
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import type { Request, Response } from 'express';
|
||||||
|
export default function handler(request: Request<unknown, unknown, {
|
||||||
|
workOrderId: string;
|
||||||
|
burialSiteId: string;
|
||||||
|
}>, response: Response): Promise<void>;
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import addWorkOrderBurialSite from '../../database/addWorkOrderBurialSite.js';
|
||||||
|
import getBurialSites from '../../database/getBurialSites.js';
|
||||||
|
export default async function handler(request, response) {
|
||||||
|
const success = await addWorkOrderBurialSite({
|
||||||
|
workOrderId: request.body.workOrderId,
|
||||||
|
burialSiteId: request.body.burialSiteId
|
||||||
|
}, request.session.user);
|
||||||
|
const workOrderLotsResults = await getBurialSites({
|
||||||
|
workOrderId: request.body.workOrderId
|
||||||
|
}, {
|
||||||
|
limit: -1,
|
||||||
|
offset: 0,
|
||||||
|
includeBurialSiteContractCount: false
|
||||||
|
});
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
workOrderBurialSites: workOrderLotsResults.burialSites
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
|
import addWorkOrderBurialSite from '../../database/addWorkOrderBurialSite.js'
|
||||||
|
import getBurialSites from '../../database/getBurialSites.js'
|
||||||
|
|
||||||
|
export default async function handler(
|
||||||
|
request: Request<
|
||||||
|
unknown,
|
||||||
|
unknown,
|
||||||
|
{ workOrderId: string; burialSiteId: string }
|
||||||
|
>,
|
||||||
|
response: Response
|
||||||
|
): Promise<void> {
|
||||||
|
const success = await addWorkOrderBurialSite(
|
||||||
|
{
|
||||||
|
workOrderId: request.body.workOrderId,
|
||||||
|
burialSiteId: request.body.burialSiteId
|
||||||
|
},
|
||||||
|
request.session.user as User
|
||||||
|
)
|
||||||
|
|
||||||
|
const workOrderLotsResults = await getBurialSites(
|
||||||
|
{
|
||||||
|
workOrderId: request.body.workOrderId
|
||||||
|
},
|
||||||
|
{
|
||||||
|
limit: -1,
|
||||||
|
offset: 0,
|
||||||
|
includeBurialSiteContractCount: false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
workOrderBurialSites: workOrderLotsResults.burialSites
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import type { Request, Response } from 'express';
|
||||||
|
export default function handler(request: Request<unknown, unknown, {
|
||||||
|
workOrderId: string;
|
||||||
|
burialSiteContractId: string;
|
||||||
|
}>, response: Response): Promise<void>;
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
import addWorkOrderLotOccupancy from '../../database/addWorkOrderLotOccupancy.js';
|
import addWorkOrderBurialSiteContract from '../../database/addWorkOrderBurialSiteContract.js';
|
||||||
import getBurialSiteContracts from '../../database/getBurialSiteContracts.js';
|
import getBurialSiteContracts from '../../database/getBurialSiteContracts.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const success = await addWorkOrderLotOccupancy({
|
const success = await addWorkOrderBurialSiteContract({
|
||||||
workOrderId: request.body.workOrderId,
|
workOrderId: request.body.workOrderId,
|
||||||
burialSiteContractId: request.body.burialSiteContractId
|
burialSiteContractId: request.body.burialSiteContractId
|
||||||
}, request.session.user);
|
}, request.session.user);
|
||||||
const workOrderLotOccupanciesResults = await getBurialSiteContracts({
|
const results = await getBurialSiteContracts({
|
||||||
workOrderId: request.body.workOrderId
|
workOrderId: request.body.workOrderId
|
||||||
}, {
|
}, {
|
||||||
limit: -1,
|
limit: -1,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
includeOccupants: true,
|
includeInterments: true,
|
||||||
includeFees: false,
|
includeFees: false,
|
||||||
includeTransactions: false
|
includeTransactions: false
|
||||||
});
|
});
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
workOrderLotOccupancies: workOrderLotOccupanciesResults.lotOccupancies
|
workOrderBurialSiteContracts: results.burialSiteContracts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
|
import addWorkOrderBurialSiteContract from '../../database/addWorkOrderBurialSiteContract.js'
|
||||||
|
import getBurialSiteContracts from '../../database/getBurialSiteContracts.js'
|
||||||
|
|
||||||
|
export default async function handler(
|
||||||
|
request: Request<
|
||||||
|
unknown,
|
||||||
|
unknown,
|
||||||
|
{ workOrderId: string; burialSiteContractId: string }
|
||||||
|
>,
|
||||||
|
response: Response
|
||||||
|
): Promise<void> {
|
||||||
|
const success = await addWorkOrderBurialSiteContract(
|
||||||
|
{
|
||||||
|
workOrderId: request.body.workOrderId,
|
||||||
|
burialSiteContractId: request.body.burialSiteContractId
|
||||||
|
},
|
||||||
|
request.session.user as User
|
||||||
|
)
|
||||||
|
|
||||||
|
const results = await getBurialSiteContracts(
|
||||||
|
{
|
||||||
|
workOrderId: request.body.workOrderId
|
||||||
|
},
|
||||||
|
{
|
||||||
|
limit: -1,
|
||||||
|
offset: 0,
|
||||||
|
includeInterments: true,
|
||||||
|
includeFees: false,
|
||||||
|
includeTransactions: false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
workOrderBurialSiteContracts: results.burialSiteContracts
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
import type { Request, Response } from 'express';
|
|
||||||
export default function handler(request: Request, response: Response): Promise<void>;
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
import addWorkOrderLot from '../../database/addWorkOrderLot.js';
|
|
||||||
import getLots from '../../database/getLots.js';
|
|
||||||
export default async function handler(request, response) {
|
|
||||||
const success = await addWorkOrderLot({
|
|
||||||
workOrderId: request.body.workOrderId,
|
|
||||||
lotId: request.body.lotId
|
|
||||||
}, request.session.user);
|
|
||||||
const workOrderLotsResults = await getLots({
|
|
||||||
workOrderId: request.body.workOrderId
|
|
||||||
}, {
|
|
||||||
limit: -1,
|
|
||||||
offset: 0,
|
|
||||||
includeLotOccupancyCount: false
|
|
||||||
});
|
|
||||||
response.json({
|
|
||||||
success,
|
|
||||||
workOrderLots: workOrderLotsResults.lots
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
import type { Request, Response } from 'express'
|
|
||||||
|
|
||||||
import addWorkOrderLot from '../../database/addWorkOrderLot.js'
|
|
||||||
import getLots from '../../database/getLots.js'
|
|
||||||
|
|
||||||
export default async function handler(
|
|
||||||
request: Request,
|
|
||||||
response: Response
|
|
||||||
): Promise<void> {
|
|
||||||
const success = await addWorkOrderLot(
|
|
||||||
{
|
|
||||||
workOrderId: request.body.workOrderId as string,
|
|
||||||
lotId: request.body.lotId as string
|
|
||||||
},
|
|
||||||
request.session.user as User
|
|
||||||
)
|
|
||||||
|
|
||||||
const workOrderLotsResults = await getLots(
|
|
||||||
{
|
|
||||||
workOrderId: request.body.workOrderId as string
|
|
||||||
},
|
|
||||||
{
|
|
||||||
limit: -1,
|
|
||||||
offset: 0,
|
|
||||||
includeLotOccupancyCount: false
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
response.json({
|
|
||||||
success,
|
|
||||||
workOrderLots: workOrderLotsResults.lots
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
import type { Request, Response } from 'express';
|
|
||||||
export default function handler(request: Request, response: Response): Promise<void>;
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
import type { Request, Response } from 'express'
|
|
||||||
|
|
||||||
import addWorkOrderLotOccupancy from '../../database/addWorkOrderLotOccupancy.js'
|
|
||||||
import getBurialSiteContracts from '../../database/getBurialSiteContracts.js'
|
|
||||||
|
|
||||||
export default async function handler(
|
|
||||||
request: Request,
|
|
||||||
response: Response
|
|
||||||
): Promise<void> {
|
|
||||||
const success = await addWorkOrderLotOccupancy(
|
|
||||||
{
|
|
||||||
workOrderId: request.body.workOrderId as string,
|
|
||||||
burialSiteContractId: request.body.burialSiteContractId as string
|
|
||||||
},
|
|
||||||
request.session.user as User
|
|
||||||
)
|
|
||||||
|
|
||||||
const workOrderLotOccupanciesResults = await getBurialSiteContracts(
|
|
||||||
{
|
|
||||||
workOrderId: request.body.workOrderId as string
|
|
||||||
},
|
|
||||||
{
|
|
||||||
limit: -1,
|
|
||||||
offset: 0,
|
|
||||||
includeOccupants: true,
|
|
||||||
includeFees: false,
|
|
||||||
includeTransactions: false
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
response.json({
|
|
||||||
success,
|
|
||||||
workOrderLotOccupancies: workOrderLotOccupanciesResults.lotOccupancies
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import type { Request, Response } from 'express';
|
||||||
|
export default function handler(request: Request<unknown, unknown, {
|
||||||
|
workOrderId: string;
|
||||||
|
burialSiteId: string;
|
||||||
|
}>, response: Response): Promise<void>;
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
import deleteWorkOrderBurialSite from '../../database/deleteWorkOrderBurialSite.js';
|
||||||
|
import getBurialSites from '../../database/getBurialSites.js';
|
||||||
|
export default async function handler(request, response) {
|
||||||
|
const success = await deleteWorkOrderBurialSite(request.body.workOrderId, request.body.burialSiteId, request.session.user);
|
||||||
|
const results = await getBurialSites({
|
||||||
|
workOrderId: request.body.workOrderId
|
||||||
|
}, {
|
||||||
|
limit: -1,
|
||||||
|
offset: 0,
|
||||||
|
includeBurialSiteContractCount: false
|
||||||
|
});
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
workOrderBurialSites: results.burialSites
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
|
import deleteWorkOrderBurialSite from '../../database/deleteWorkOrderBurialSite.js'
|
||||||
|
import getBurialSites from '../../database/getBurialSites.js'
|
||||||
|
|
||||||
|
export default async function handler(
|
||||||
|
request: Request<unknown, unknown, { workOrderId: string; burialSiteId: string }>,
|
||||||
|
response: Response
|
||||||
|
): Promise<void> {
|
||||||
|
const success = await deleteWorkOrderBurialSite(
|
||||||
|
request.body.workOrderId,
|
||||||
|
request.body.burialSiteId,
|
||||||
|
request.session.user as User
|
||||||
|
)
|
||||||
|
|
||||||
|
const results = await getBurialSites(
|
||||||
|
{
|
||||||
|
workOrderId: request.body.workOrderId
|
||||||
|
},
|
||||||
|
{
|
||||||
|
limit: -1,
|
||||||
|
offset: 0,
|
||||||
|
includeBurialSiteContractCount: false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
workOrderBurialSites: results.burialSites
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import type { Request, Response } from 'express';
|
||||||
|
export default function handler(request: Request<unknown, unknown, {
|
||||||
|
workOrderId: string;
|
||||||
|
burialSiteContractId: string;
|
||||||
|
}>, response: Response): Promise<void>;
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
import deleteWorkOrderBurialSiteContract from '../../database/deleteWorkOrderBurialSiteContract.js';
|
||||||
|
import getBurialSiteContracts from '../../database/getBurialSiteContracts.js';
|
||||||
|
export default async function handler(request, response) {
|
||||||
|
const success = await deleteWorkOrderBurialSiteContract(request.body.workOrderId, request.body.burialSiteContractId, request.session.user);
|
||||||
|
const workOrderBurialSiteContracts = await getBurialSiteContracts({
|
||||||
|
workOrderId: request.body.workOrderId
|
||||||
|
}, {
|
||||||
|
limit: -1,
|
||||||
|
offset: 0,
|
||||||
|
includeInterments: true,
|
||||||
|
includeFees: false,
|
||||||
|
includeTransactions: false
|
||||||
|
});
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
workOrderBurialSiteContracts: workOrderBurialSiteContracts.burialSiteContracts
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
|
import deleteWorkOrderBurialSiteContract from '../../database/deleteWorkOrderBurialSiteContract.js'
|
||||||
|
import getBurialSiteContracts from '../../database/getBurialSiteContracts.js'
|
||||||
|
|
||||||
|
export default async function handler(
|
||||||
|
request: Request<
|
||||||
|
unknown,
|
||||||
|
unknown,
|
||||||
|
{ workOrderId: string; burialSiteContractId: string }
|
||||||
|
>,
|
||||||
|
response: Response
|
||||||
|
): Promise<void> {
|
||||||
|
const success = await deleteWorkOrderBurialSiteContract(
|
||||||
|
request.body.workOrderId,
|
||||||
|
request.body.burialSiteContractId,
|
||||||
|
request.session.user as User
|
||||||
|
)
|
||||||
|
|
||||||
|
const workOrderBurialSiteContracts = await getBurialSiteContracts(
|
||||||
|
{
|
||||||
|
workOrderId: request.body.workOrderId
|
||||||
|
},
|
||||||
|
{
|
||||||
|
limit: -1,
|
||||||
|
offset: 0,
|
||||||
|
includeInterments: true,
|
||||||
|
includeFees: false,
|
||||||
|
includeTransactions: false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
workOrderBurialSiteContracts:
|
||||||
|
workOrderBurialSiteContracts.burialSiteContracts
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
import type { Request, Response } from 'express';
|
|
||||||
export default function handler(request: Request, response: Response): Promise<void>;
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
import deleteWorkOrderLot from '../../database/deleteWorkOrderLot.js';
|
|
||||||
import getLots from '../../database/getLots.js';
|
|
||||||
export default async function handler(request, response) {
|
|
||||||
const success = await deleteWorkOrderLot(request.body.workOrderId, request.body.lotId, request.session.user);
|
|
||||||
const workOrderLotsResults = await getLots({
|
|
||||||
workOrderId: request.body.workOrderId
|
|
||||||
}, {
|
|
||||||
limit: -1,
|
|
||||||
offset: 0,
|
|
||||||
includeLotOccupancyCount: false
|
|
||||||
});
|
|
||||||
response.json({
|
|
||||||
success,
|
|
||||||
workOrderLots: workOrderLotsResults.lots
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
import type { Request, Response } from 'express'
|
|
||||||
|
|
||||||
import deleteWorkOrderLot from '../../database/deleteWorkOrderLot.js'
|
|
||||||
import getLots from '../../database/getLots.js'
|
|
||||||
|
|
||||||
export default async function handler(
|
|
||||||
request: Request,
|
|
||||||
response: Response
|
|
||||||
): Promise<void> {
|
|
||||||
const success = await deleteWorkOrderLot(
|
|
||||||
request.body.workOrderId as string,
|
|
||||||
request.body.lotId as string,
|
|
||||||
request.session.user as User
|
|
||||||
)
|
|
||||||
|
|
||||||
const workOrderLotsResults = await getLots(
|
|
||||||
{
|
|
||||||
workOrderId: request.body.workOrderId as string
|
|
||||||
},
|
|
||||||
{
|
|
||||||
limit: -1,
|
|
||||||
offset: 0,
|
|
||||||
includeLotOccupancyCount: false
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
response.json({
|
|
||||||
success,
|
|
||||||
workOrderLots: workOrderLotsResults.lots
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
import type { Request, Response } from 'express';
|
|
||||||
export default function handler(request: Request, response: Response): Promise<void>;
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
import deleteWorkOrderLotOccupancy from '../../database/deleteWorkOrderLotOccupancy.js';
|
|
||||||
import getBurialSiteContracts from '../../database/getBurialSiteContracts.js';
|
|
||||||
export default async function handler(request, response) {
|
|
||||||
const success = await deleteWorkOrderLotOccupancy(request.body.workOrderId, request.body.burialSiteContractId, request.session.user);
|
|
||||||
const workOrderLotOccupancies = await getBurialSiteContracts({
|
|
||||||
workOrderId: request.body.workOrderId
|
|
||||||
}, {
|
|
||||||
limit: -1,
|
|
||||||
offset: 0,
|
|
||||||
includeOccupants: true,
|
|
||||||
includeFees: false,
|
|
||||||
includeTransactions: false
|
|
||||||
});
|
|
||||||
response.json({
|
|
||||||
success,
|
|
||||||
workOrderLotOccupancies: workOrderLotOccupancies.lotOccupancies
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
import type { Request, Response } from 'express'
|
|
||||||
|
|
||||||
import deleteWorkOrderLotOccupancy from '../../database/deleteWorkOrderLotOccupancy.js'
|
|
||||||
import getBurialSiteContracts from '../../database/getBurialSiteContracts.js'
|
|
||||||
|
|
||||||
export default async function handler(
|
|
||||||
request: Request,
|
|
||||||
response: Response
|
|
||||||
): Promise<void> {
|
|
||||||
const success = await deleteWorkOrderLotOccupancy(
|
|
||||||
request.body.workOrderId as string,
|
|
||||||
request.body.burialSiteContractId as string,
|
|
||||||
request.session.user as User
|
|
||||||
)
|
|
||||||
|
|
||||||
const workOrderLotOccupancies = await getBurialSiteContracts(
|
|
||||||
{
|
|
||||||
workOrderId: request.body.workOrderId as string
|
|
||||||
},
|
|
||||||
{
|
|
||||||
limit: -1,
|
|
||||||
offset: 0,
|
|
||||||
includeOccupants: true,
|
|
||||||
includeFees: false,
|
|
||||||
includeTransactions: false
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
response.json({
|
|
||||||
success,
|
|
||||||
workOrderLotOccupancies: workOrderLotOccupancies.lotOccupancies
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -3,7 +3,7 @@ export default async function handler(request, response) {
|
||||||
const result = await getWorkOrders(request.body, {
|
const result = await getWorkOrders(request.body, {
|
||||||
limit: request.body.limit,
|
limit: request.body.limit,
|
||||||
offset: request.body.offset,
|
offset: request.body.offset,
|
||||||
includeLotsAndLotOccupancies: true
|
includeBurialSites: true
|
||||||
});
|
});
|
||||||
response.json({
|
response.json({
|
||||||
count: result.count,
|
count: result.count,
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ export default async function handler(
|
||||||
const result = await getWorkOrders(request.body as GetWorkOrdersFilters, {
|
const result = await getWorkOrders(request.body as GetWorkOrdersFilters, {
|
||||||
limit: request.body.limit,
|
limit: request.body.limit,
|
||||||
offset: request.body.offset,
|
offset: request.body.offset,
|
||||||
includeLotsAndLotOccupancies: true
|
includeBurialSites: true
|
||||||
})
|
})
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
import type { Request, Response } from 'express';
|
||||||
|
export default function handler(request: Request<unknown, unknown, {
|
||||||
|
lotId: string;
|
||||||
|
burialSiteStatusId: string;
|
||||||
|
workOrderId: string;
|
||||||
|
}>, response: Response): Promise<void>;
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
import getBurialSites from '../../database/getBurialSites.js';
|
||||||
|
import { updateBurialSiteStatus } from '../../database/updateBurialSite.js';
|
||||||
|
export default async function handler(request, response) {
|
||||||
|
const success = await updateBurialSiteStatus(request.body.lotId, request.body.burialSiteStatusId, request.session.user);
|
||||||
|
const results = await getBurialSites({
|
||||||
|
workOrderId: request.body.workOrderId
|
||||||
|
}, {
|
||||||
|
limit: -1,
|
||||||
|
offset: 0,
|
||||||
|
includeBurialSiteContractCount: true
|
||||||
|
});
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
workOrderBurialSites: results.burialSites
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
|
import getBurialSites from '../../database/getBurialSites.js'
|
||||||
|
import { updateBurialSiteStatus } from '../../database/updateBurialSite.js'
|
||||||
|
|
||||||
|
export default async function handler(
|
||||||
|
request: Request<
|
||||||
|
unknown,
|
||||||
|
unknown,
|
||||||
|
{ lotId: string; burialSiteStatusId: string; workOrderId: string }
|
||||||
|
>,
|
||||||
|
response: Response
|
||||||
|
): Promise<void> {
|
||||||
|
const success = await updateBurialSiteStatus(
|
||||||
|
request.body.lotId,
|
||||||
|
request.body.burialSiteStatusId,
|
||||||
|
request.session.user as User
|
||||||
|
)
|
||||||
|
|
||||||
|
const results = await getBurialSites(
|
||||||
|
{
|
||||||
|
workOrderId: request.body.workOrderId
|
||||||
|
},
|
||||||
|
{
|
||||||
|
limit: -1,
|
||||||
|
offset: 0,
|
||||||
|
includeBurialSiteContractCount: true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
workOrderBurialSites: results.burialSites
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
import type { Request, Response } from 'express';
|
|
||||||
export default function handler(request: Request, response: Response): Promise<void>;
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
import getLots from '../../database/getLots.js';
|
|
||||||
import { updateLotStatus } from '../../database/updateLot.js';
|
|
||||||
export default async function handler(request, response) {
|
|
||||||
const success = await updateLotStatus(request.body.lotId, request.body.burialSiteStatusId, request.session.user);
|
|
||||||
const workOrderLotsResults = await getLots({
|
|
||||||
workOrderId: request.body.workOrderId
|
|
||||||
}, {
|
|
||||||
limit: -1,
|
|
||||||
offset: 0,
|
|
||||||
includeLotOccupancyCount: true
|
|
||||||
});
|
|
||||||
response.json({
|
|
||||||
success,
|
|
||||||
workOrderLots: workOrderLotsResults.lots
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
import type { Request, Response } from 'express'
|
|
||||||
|
|
||||||
import getLots from '../../database/getLots.js'
|
|
||||||
import { updateLotStatus } from '../../database/updateLot.js'
|
|
||||||
|
|
||||||
export default async function handler(
|
|
||||||
request: Request,
|
|
||||||
response: Response
|
|
||||||
): Promise<void> {
|
|
||||||
const success = await updateLotStatus(
|
|
||||||
request.body.lotId as string,
|
|
||||||
request.body.burialSiteStatusId as string,
|
|
||||||
request.session.user as User
|
|
||||||
)
|
|
||||||
|
|
||||||
const workOrderLotsResults = await getLots(
|
|
||||||
{
|
|
||||||
workOrderId: request.body.workOrderId as string
|
|
||||||
},
|
|
||||||
{
|
|
||||||
limit: -1,
|
|
||||||
offset: 0,
|
|
||||||
includeLotOccupancyCount: true
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
response.json({
|
|
||||||
success,
|
|
||||||
workOrderLots: workOrderLotsResults.lots
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
import type { BurialSiteContract, BurialSiteContractFee } from '../types/recordTypes.js';
|
||||||
|
export declare function getFieldValueByContractTypeField(burialSiteContract: BurialSiteContract, occupancyTypeField: string): string | undefined;
|
||||||
|
export declare function getFeesByFeeCategory(burialSiteContract: BurialSiteContract, feeCategory: string, feeCategoryContains?: boolean): BurialSiteContractFee[];
|
||||||
|
export declare function getTransactionTotal(burialSiteContract: BurialSiteContract): number;
|
||||||
|
|
@ -1,16 +1,11 @@
|
||||||
export function filterOccupantsByLotOccupantType(burialSiteContract, lotOccupantType) {
|
export function getFieldValueByContractTypeField(burialSiteContract, occupancyTypeField) {
|
||||||
const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase();
|
|
||||||
return (burialSiteContract.burialSiteContractOccupants ?? []).filter((possibleOccupant) => possibleOccupant.lotOccupantType.toLowerCase() ===
|
|
||||||
lotOccupantTypeLowerCase);
|
|
||||||
}
|
|
||||||
export function getFieldValueByOccupancyTypeField(burialSiteContract, occupancyTypeField) {
|
|
||||||
const occupancyTypeFieldLowerCase = occupancyTypeField.toLowerCase();
|
const occupancyTypeFieldLowerCase = occupancyTypeField.toLowerCase();
|
||||||
const field = (burialSiteContract.burialSiteContractFields ?? []).find((possibleField) => possibleField.occupancyTypeField.toLowerCase() ===
|
const field = (burialSiteContract.burialSiteContractFields ?? []).find((possibleField) => possibleField.contractTypeField.toLowerCase() ===
|
||||||
occupancyTypeFieldLowerCase);
|
occupancyTypeFieldLowerCase);
|
||||||
if (field === undefined) {
|
if (field === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return field.burialSiteContractFieldValue;
|
return field.fieldValue;
|
||||||
}
|
}
|
||||||
export function getFeesByFeeCategory(burialSiteContract, feeCategory, feeCategoryContains = false) {
|
export function getFeesByFeeCategory(burialSiteContract, feeCategory, feeCategoryContains = false) {
|
||||||
const feeCategoryLowerCase = feeCategory.toLowerCase();
|
const feeCategoryLowerCase = feeCategory.toLowerCase();
|
||||||
|
|
@ -23,7 +18,8 @@ export function getFeesByFeeCategory(burialSiteContract, feeCategory, feeCategor
|
||||||
}
|
}
|
||||||
export function getTransactionTotal(burialSiteContract) {
|
export function getTransactionTotal(burialSiteContract) {
|
||||||
let transactionTotal = 0;
|
let transactionTotal = 0;
|
||||||
for (const transaction of burialSiteContract.burialSiteContractTransactions ?? []) {
|
for (const transaction of burialSiteContract.burialSiteContractTransactions ??
|
||||||
|
[]) {
|
||||||
transactionTotal += transaction.transactionAmount;
|
transactionTotal += transaction.transactionAmount;
|
||||||
}
|
}
|
||||||
return transactionTotal;
|
return transactionTotal;
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
import type {
|
||||||
|
BurialSiteContract,
|
||||||
|
BurialSiteContractFee
|
||||||
|
} from '../types/recordTypes.js'
|
||||||
|
|
||||||
|
export function getFieldValueByContractTypeField(
|
||||||
|
burialSiteContract: BurialSiteContract,
|
||||||
|
occupancyTypeField: string
|
||||||
|
): string | undefined {
|
||||||
|
const occupancyTypeFieldLowerCase = occupancyTypeField.toLowerCase()
|
||||||
|
|
||||||
|
const field = (burialSiteContract.burialSiteContractFields ?? []).find(
|
||||||
|
(possibleField) =>
|
||||||
|
(possibleField.contractTypeField as string).toLowerCase() ===
|
||||||
|
occupancyTypeFieldLowerCase
|
||||||
|
)
|
||||||
|
|
||||||
|
if (field === undefined) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
return field.fieldValue
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getFeesByFeeCategory(
|
||||||
|
burialSiteContract: BurialSiteContract,
|
||||||
|
feeCategory: string,
|
||||||
|
feeCategoryContains = false
|
||||||
|
): BurialSiteContractFee[] {
|
||||||
|
const feeCategoryLowerCase = feeCategory.toLowerCase()
|
||||||
|
|
||||||
|
return (burialSiteContract.burialSiteContractFees ?? []).filter(
|
||||||
|
(possibleFee) =>
|
||||||
|
feeCategoryContains
|
||||||
|
? (possibleFee.feeCategory as string)
|
||||||
|
.toLowerCase()
|
||||||
|
.includes(feeCategoryLowerCase)
|
||||||
|
: (possibleFee.feeCategory as string).toLowerCase() ===
|
||||||
|
feeCategoryLowerCase
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getTransactionTotal(
|
||||||
|
burialSiteContract: BurialSiteContract
|
||||||
|
): number {
|
||||||
|
let transactionTotal = 0
|
||||||
|
|
||||||
|
for (const transaction of burialSiteContract.burialSiteContractTransactions ??
|
||||||
|
[]) {
|
||||||
|
transactionTotal += transaction.transactionAmount
|
||||||
|
}
|
||||||
|
|
||||||
|
return transactionTotal
|
||||||
|
}
|
||||||
|
|
@ -17,4 +17,6 @@ export declare function getWorkOrderMilestoneTypeById(workOrderMilestoneTypeId:
|
||||||
export declare function getWorkOrderMilestoneTypeByWorkOrderMilestoneType(workOrderMilestoneTypeString: string): Promise<WorkOrderMilestoneType | undefined>;
|
export declare function getWorkOrderMilestoneTypeByWorkOrderMilestoneType(workOrderMilestoneTypeString: string): Promise<WorkOrderMilestoneType | undefined>;
|
||||||
export declare function preloadCaches(): Promise<void>;
|
export declare function preloadCaches(): Promise<void>;
|
||||||
export declare function clearCaches(): void;
|
export declare function clearCaches(): void;
|
||||||
export declare function clearCacheByTableName(tableName: string, relayMessage?: boolean): void;
|
type CacheTableNames = 'BurialSiteStatuses' | 'BurialSiteTypes' | 'BurialSiteTypeFields' | 'ContractTypes' | 'ContractTypeFields' | 'ContractTypePrints' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes';
|
||||||
|
export declare function clearCacheByTableName(tableName: CacheTableNames, relayMessage?: boolean): void;
|
||||||
|
export {};
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,7 @@ export function clearCacheByTableName(tableName, relayMessage = true) {
|
||||||
clearWorkOrderTypesCache();
|
clearWorkOrderTypesCache();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
||||||
default: {
|
default: {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -271,8 +271,18 @@ function clearWorkOrderMilestoneTypesCache(): void {
|
||||||
workOrderMilestoneTypes = undefined
|
workOrderMilestoneTypes = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CacheTableNames =
|
||||||
|
| 'BurialSiteStatuses'
|
||||||
|
| 'BurialSiteTypes'
|
||||||
|
| 'BurialSiteTypeFields'
|
||||||
|
| 'ContractTypes'
|
||||||
|
| 'ContractTypeFields'
|
||||||
|
| 'ContractTypePrints'
|
||||||
|
| 'WorkOrderMilestoneTypes'
|
||||||
|
| 'WorkOrderTypes'
|
||||||
|
|
||||||
export function clearCacheByTableName(
|
export function clearCacheByTableName(
|
||||||
tableName: string,
|
tableName: CacheTableNames,
|
||||||
relayMessage = true
|
relayMessage = true
|
||||||
): void {
|
): void {
|
||||||
switch (tableName) {
|
switch (tableName) {
|
||||||
|
|
@ -304,6 +314,7 @@ export function clearCacheByTableName(
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
||||||
default: {
|
default: {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -330,6 +341,9 @@ export function clearCacheByTableName(
|
||||||
process.on('message', (message: WorkerMessage) => {
|
process.on('message', (message: WorkerMessage) => {
|
||||||
if (message.messageType === 'clearCache' && message.pid !== process.pid) {
|
if (message.messageType === 'clearCache' && message.pid !== process.pid) {
|
||||||
debug(`Clearing cache: ${(message as ClearCacheWorkerMessage).tableName}`)
|
debug(`Clearing cache: ${(message as ClearCacheWorkerMessage).tableName}`)
|
||||||
clearCacheByTableName((message as ClearCacheWorkerMessage).tableName, false)
|
clearCacheByTableName(
|
||||||
|
(message as ClearCacheWorkerMessage).tableName as CacheTableNames,
|
||||||
|
false
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
import type { Fee, LotOccupancy } from '../types/recordTypes.js';
|
import type { BurialSiteContract, Fee } from '../types/recordTypes.js';
|
||||||
export declare function calculateFeeAmount(fee: Fee, burialSiteContract: LotOccupancy): number;
|
export declare function calculateFeeAmount(fee: Fee, burialSiteContract: BurialSiteContract): number;
|
||||||
export declare function calculateTaxAmount(fee: Fee, feeAmount: number): number;
|
export declare function calculateTaxAmount(fee: Fee, feeAmount: number): number;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import type { Fee, LotOccupancy } from '../types/recordTypes.js'
|
import type { BurialSiteContract, Fee } from '../types/recordTypes.js'
|
||||||
|
|
||||||
export function calculateFeeAmount(
|
export function calculateFeeAmount(
|
||||||
fee: Fee,
|
fee: Fee,
|
||||||
burialSiteContract: LotOccupancy
|
burialSiteContract: BurialSiteContract
|
||||||
): number {
|
): number {
|
||||||
return fee.feeFunction ? 0 : fee.feeAmount ?? 0
|
return fee.feeFunction ? 0 : fee.feeAmount ?? 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
import type { LotOccupancy, LotOccupancyFee, LotOccupancyOccupant } from '../types/recordTypes.js';
|
|
||||||
export declare function filterOccupantsByLotOccupantType(burialSiteContract: LotOccupancy, lotOccupantType: string): LotOccupancyOccupant[];
|
|
||||||
export declare function getFieldValueByOccupancyTypeField(burialSiteContract: LotOccupancy, occupancyTypeField: string): string | undefined;
|
|
||||||
export declare function getFeesByFeeCategory(burialSiteContract: LotOccupancy, feeCategory: string, feeCategoryContains?: boolean): LotOccupancyFee[];
|
|
||||||
export declare function getTransactionTotal(burialSiteContract: LotOccupancy): number;
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
import type {
|
|
||||||
LotOccupancy,
|
|
||||||
LotOccupancyFee,
|
|
||||||
LotOccupancyOccupant
|
|
||||||
} from '../types/recordTypes.js'
|
|
||||||
|
|
||||||
export function filterOccupantsByLotOccupantType(
|
|
||||||
burialSiteContract: LotOccupancy,
|
|
||||||
lotOccupantType: string
|
|
||||||
): LotOccupancyOccupant[] {
|
|
||||||
const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase()
|
|
||||||
|
|
||||||
return (burialSiteContract.burialSiteContractOccupants ?? []).filter(
|
|
||||||
(possibleOccupant) =>
|
|
||||||
(possibleOccupant.lotOccupantType as string).toLowerCase() ===
|
|
||||||
lotOccupantTypeLowerCase
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getFieldValueByOccupancyTypeField(
|
|
||||||
burialSiteContract: LotOccupancy,
|
|
||||||
occupancyTypeField: string
|
|
||||||
): string | undefined {
|
|
||||||
const occupancyTypeFieldLowerCase = occupancyTypeField.toLowerCase()
|
|
||||||
|
|
||||||
const field = (burialSiteContract.burialSiteContractFields ?? []).find(
|
|
||||||
(possibleField) =>
|
|
||||||
(possibleField.occupancyTypeField as string).toLowerCase() ===
|
|
||||||
occupancyTypeFieldLowerCase
|
|
||||||
)
|
|
||||||
|
|
||||||
if (field === undefined) {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
return field.burialSiteContractFieldValue
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getFeesByFeeCategory(
|
|
||||||
burialSiteContract: LotOccupancy,
|
|
||||||
feeCategory: string,
|
|
||||||
feeCategoryContains = false
|
|
||||||
): LotOccupancyFee[] {
|
|
||||||
const feeCategoryLowerCase = feeCategory.toLowerCase()
|
|
||||||
|
|
||||||
return (burialSiteContract.burialSiteContractFees ?? []).filter((possibleFee) =>
|
|
||||||
feeCategoryContains
|
|
||||||
? (possibleFee.feeCategory as string)
|
|
||||||
.toLowerCase()
|
|
||||||
.includes(feeCategoryLowerCase)
|
|
||||||
: (possibleFee.feeCategory as string).toLowerCase() ===
|
|
||||||
feeCategoryLowerCase
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getTransactionTotal(burialSiteContract: LotOccupancy): number {
|
|
||||||
let transactionTotal = 0
|
|
||||||
|
|
||||||
for (const transaction of burialSiteContract.burialSiteContractTransactions ?? []) {
|
|
||||||
transactionTotal += transaction.transactionAmount
|
|
||||||
}
|
|
||||||
|
|
||||||
return transactionTotal
|
|
||||||
}
|
|
||||||
|
|
@ -2,8 +2,8 @@ import * as dateTimeFunctions from '@cityssm/utils-datetime';
|
||||||
import getBurialSite from '../database/getBurialSite.js';
|
import getBurialSite from '../database/getBurialSite.js';
|
||||||
import getBurialSiteContract from '../database/getBurialSiteContract.js';
|
import getBurialSiteContract from '../database/getBurialSiteContract.js';
|
||||||
import getWorkOrder from '../database/getWorkOrder.js';
|
import getWorkOrder from '../database/getWorkOrder.js';
|
||||||
|
import * as burialSiteContractFunctions from './burialSiteContracts.helpers.js';
|
||||||
import * as configFunctions from './config.helpers.js';
|
import * as configFunctions from './config.helpers.js';
|
||||||
import * as burialSiteContractFunctions from './functions.burialSiteContract.js';
|
|
||||||
const screenPrintConfigs = {
|
const screenPrintConfigs = {
|
||||||
burialSiteContract: {
|
burialSiteContract: {
|
||||||
title: `Burial Site Contract Print`,
|
title: `Burial Site Contract Print`,
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue