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