major refactoring
parent
27e606d9f1
commit
27433ff4b0
|
|
@ -9,11 +9,11 @@ describe('Update - Lot Occupancies', () => {
|
||||||
it('Has a "Create" link on the Lot Occupancy Search', () => {
|
it('Has a "Create" link on the Lot Occupancy Search', () => {
|
||||||
cy.visit('/lotOccupancies');
|
cy.visit('/lotOccupancies');
|
||||||
cy.location('pathname').should('equal', '/lotOccupancies');
|
cy.location('pathname').should('equal', '/lotOccupancies');
|
||||||
cy.get("a[href$='/lotOccupancies/new']").should('exist');
|
cy.get("a[href$='/contracts/new']").should('exist');
|
||||||
});
|
});
|
||||||
describe('Update a New Lot Occupancy', () => {
|
describe('Update a New Lot Occupancy', () => {
|
||||||
it('Has no detectable accessibility issues', () => {
|
it('Has no detectable accessibility issues', () => {
|
||||||
cy.visit('/lotOccupancies/new');
|
cy.visit('/contracts/new');
|
||||||
cy.injectAxe();
|
cy.injectAxe();
|
||||||
cy.checkA11y();
|
cy.checkA11y();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,12 @@ describe('Update - Lot Occupancies', () => {
|
||||||
it('Has a "Create" link on the Lot Occupancy Search', () => {
|
it('Has a "Create" link on the Lot Occupancy Search', () => {
|
||||||
cy.visit('/lotOccupancies')
|
cy.visit('/lotOccupancies')
|
||||||
cy.location('pathname').should('equal', '/lotOccupancies')
|
cy.location('pathname').should('equal', '/lotOccupancies')
|
||||||
cy.get("a[href$='/lotOccupancies/new']").should('exist')
|
cy.get("a[href$='/contracts/new']").should('exist')
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Update a New Lot Occupancy', () => {
|
describe('Update a New Lot Occupancy', () => {
|
||||||
it('Has no detectable accessibility issues', () => {
|
it('Has no detectable accessibility issues', () => {
|
||||||
cy.visit('/lotOccupancies/new')
|
cy.visit('/contracts/new')
|
||||||
cy.injectAxe()
|
cy.injectAxe()
|
||||||
cy.checkA11y()
|
cy.checkA11y()
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ export const config = {
|
||||||
settings: {
|
settings: {
|
||||||
fees: {},
|
fees: {},
|
||||||
cemeteries: {},
|
cemeteries: {},
|
||||||
|
burialSites: {},
|
||||||
contracts: {},
|
contracts: {},
|
||||||
workOrders: {},
|
workOrders: {},
|
||||||
adminCleanup: {},
|
adminCleanup: {},
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ export const config: Config = {
|
||||||
settings: {
|
settings: {
|
||||||
fees: {},
|
fees: {},
|
||||||
cemeteries: {},
|
cemeteries: {},
|
||||||
|
burialSites: {},
|
||||||
contracts: {},
|
contracts: {},
|
||||||
workOrders: {},
|
workOrders: {},
|
||||||
adminCleanup: {},
|
adminCleanup: {},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,39 @@
|
||||||
import { config as cemeteryConfig } from './config.baseOntario.js';
|
import { config as cemeteryConfig } from './config.baseOntario.js';
|
||||||
export const config = { ...cemeteryConfig };
|
export const config = { ...cemeteryConfig };
|
||||||
config.aliases.externalReceiptNumber = 'GP Receipt Number';
|
config.aliases.externalReceiptNumber = 'GP Receipt Number';
|
||||||
|
config.settings.burialSites.burialSiteNameSegments = {
|
||||||
|
separator: '-',
|
||||||
|
segments: {
|
||||||
|
1: {
|
||||||
|
isRequired: true,
|
||||||
|
isAvailable: true,
|
||||||
|
label: 'Block',
|
||||||
|
minLength: 1,
|
||||||
|
maxLength: 3
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
isRequired: true,
|
||||||
|
isAvailable: true,
|
||||||
|
label: 'Range',
|
||||||
|
minLength: 1,
|
||||||
|
maxLength: 3
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
isRequired: true,
|
||||||
|
isAvailable: true,
|
||||||
|
label: 'Lot',
|
||||||
|
minLength: 1,
|
||||||
|
maxLength: 3
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
isRequired: true,
|
||||||
|
isAvailable: true,
|
||||||
|
label: 'Grave',
|
||||||
|
minLength: 1,
|
||||||
|
maxLength: 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
config.settings.contracts.cityDefault = 'Sault Ste. Marie';
|
config.settings.contracts.cityDefault = 'Sault Ste. Marie';
|
||||||
config.settings.contracts.prints = [
|
config.settings.contracts.prints = [
|
||||||
'pdf/ssm.cemetery.burialPermit',
|
'pdf/ssm.cemetery.burialPermit',
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,40 @@ export const config: Config = { ...cemeteryConfig }
|
||||||
|
|
||||||
config.aliases.externalReceiptNumber = 'GP Receipt Number'
|
config.aliases.externalReceiptNumber = 'GP Receipt Number'
|
||||||
|
|
||||||
|
config.settings.burialSites.burialSiteNameSegments = {
|
||||||
|
separator: '-',
|
||||||
|
segments: {
|
||||||
|
1: {
|
||||||
|
isRequired: true,
|
||||||
|
isAvailable: true,
|
||||||
|
label: 'Block',
|
||||||
|
minLength: 1,
|
||||||
|
maxLength: 3
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
isRequired: true,
|
||||||
|
isAvailable: true,
|
||||||
|
label: 'Range',
|
||||||
|
minLength: 1,
|
||||||
|
maxLength: 3
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
isRequired: true,
|
||||||
|
isAvailable: true,
|
||||||
|
label: 'Lot',
|
||||||
|
minLength: 1,
|
||||||
|
maxLength: 3
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
isRequired: true,
|
||||||
|
isAvailable: true,
|
||||||
|
label: 'Grave',
|
||||||
|
minLength: 1,
|
||||||
|
maxLength: 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
config.settings.contracts.cityDefault = 'Sault Ste. Marie'
|
config.settings.contracts.cityDefault = 'Sault Ste. Marie'
|
||||||
config.settings.contracts.prints = [
|
config.settings.contracts.prints = [
|
||||||
'pdf/ssm.cemetery.burialPermit',
|
'pdf/ssm.cemetery.burialPermit',
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import type { config as MSSQLConfig } from 'mssql';
|
import type { config as MSSQLConfig } from 'mssql';
|
||||||
import type { ConfigActiveDirectory, ConfigNtfyStartup, DynamicsGPLookup } from '../types/configTypes.js';
|
import type { ConfigActiveDirectory, ConfigBurialSiteNameSegments, ConfigNtfyStartup, DynamicsGPLookup } from '../types/configTypes.js';
|
||||||
export declare const configDefaultValues: {
|
export declare const configDefaultValues: {
|
||||||
activeDirectory: ConfigActiveDirectory;
|
activeDirectory: ConfigActiveDirectory;
|
||||||
'application.applicationName': string;
|
'application.applicationName': string;
|
||||||
|
|
@ -26,6 +26,7 @@ export declare const configDefaultValues: {
|
||||||
'aliases.workOrderCloseDate': string;
|
'aliases.workOrderCloseDate': string;
|
||||||
'settings.cemeteries.cityDefault': string;
|
'settings.cemeteries.cityDefault': string;
|
||||||
'settings.cemeteries.provinceDefault': string;
|
'settings.cemeteries.provinceDefault': string;
|
||||||
|
'settings.burialSites.burialSiteNameSegments': ConfigBurialSiteNameSegments;
|
||||||
'settings.contracts.burialSiteIdIsRequired': boolean;
|
'settings.contracts.burialSiteIdIsRequired': boolean;
|
||||||
'settings.contracts.cityDefault': string;
|
'settings.contracts.cityDefault': string;
|
||||||
'settings.contracts.provinceDefault': string;
|
'settings.contracts.provinceDefault': string;
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,18 @@ export const configDefaultValues = {
|
||||||
'aliases.workOrderCloseDate': 'Completion Date',
|
'aliases.workOrderCloseDate': 'Completion Date',
|
||||||
'settings.cemeteries.cityDefault': '',
|
'settings.cemeteries.cityDefault': '',
|
||||||
'settings.cemeteries.provinceDefault': '',
|
'settings.cemeteries.provinceDefault': '',
|
||||||
|
'settings.burialSites.burialSiteNameSegments': {
|
||||||
|
separator: '-',
|
||||||
|
segments: {
|
||||||
|
1: {
|
||||||
|
isRequired: true,
|
||||||
|
isAvailable: true,
|
||||||
|
label: 'Plot Number',
|
||||||
|
minLength: 1,
|
||||||
|
maxLength: 20
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
'settings.contracts.burialSiteIdIsRequired': true,
|
'settings.contracts.burialSiteIdIsRequired': true,
|
||||||
'settings.contracts.cityDefault': '',
|
'settings.contracts.cityDefault': '',
|
||||||
'settings.contracts.provinceDefault': '',
|
'settings.contracts.provinceDefault': '',
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import type { config as MSSQLConfig } from 'mssql'
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
ConfigActiveDirectory,
|
ConfigActiveDirectory,
|
||||||
|
ConfigBurialSiteNameSegments,
|
||||||
ConfigNtfyStartup,
|
ConfigNtfyStartup,
|
||||||
DynamicsGPLookup
|
DynamicsGPLookup
|
||||||
} from '../types/configTypes.js'
|
} from '../types/configTypes.js'
|
||||||
|
|
@ -41,6 +42,20 @@ export const configDefaultValues = {
|
||||||
'settings.cemeteries.cityDefault': '',
|
'settings.cemeteries.cityDefault': '',
|
||||||
'settings.cemeteries.provinceDefault': '',
|
'settings.cemeteries.provinceDefault': '',
|
||||||
|
|
||||||
|
'settings.burialSites.burialSiteNameSegments': {
|
||||||
|
separator: '-',
|
||||||
|
segments: {
|
||||||
|
1: {
|
||||||
|
isRequired: true,
|
||||||
|
isAvailable: true,
|
||||||
|
label: 'Plot Number',
|
||||||
|
minLength: 1,
|
||||||
|
maxLength: 20
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} as unknown as ConfigBurialSiteNameSegments,
|
||||||
|
|
||||||
|
|
||||||
'settings.contracts.burialSiteIdIsRequired': true,
|
'settings.contracts.burialSiteIdIsRequired': true,
|
||||||
'settings.contracts.cityDefault': '',
|
'settings.contracts.cityDefault': '',
|
||||||
'settings.contracts.provinceDefault': '',
|
'settings.contracts.provinceDefault': '',
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
|
import { buildBurialSiteName } from '../helpers/burialSites.helpers.js';
|
||||||
import addOrUpdateBurialSiteField from './addOrUpdateBurialSiteField.js';
|
import addOrUpdateBurialSiteField from './addOrUpdateBurialSiteField.js';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
export default async function addLot(burialSiteForm, user) {
|
export default async function addLot(burialSiteForm, user) {
|
||||||
const database = await acquireConnection();
|
const database = await acquireConnection();
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
const burialSiteName = buildBurialSiteName(burialSiteForm);
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(`insert into BurialSites (
|
.prepare(`insert into BurialSites (
|
||||||
burialSiteNameSegment1,
|
burialSiteNameSegment1,
|
||||||
|
|
@ -10,16 +12,17 @@ export default async function addLot(burialSiteForm, user) {
|
||||||
burialSiteNameSegment3,
|
burialSiteNameSegment3,
|
||||||
burialSiteNameSegment4,
|
burialSiteNameSegment4,
|
||||||
burialSiteNameSegment5,
|
burialSiteNameSegment5,
|
||||||
|
burialSiteName,
|
||||||
burialSiteTypeId, burialSiteStatusId,
|
burialSiteTypeId, burialSiteStatusId,
|
||||||
cemeteryId, cemeterySvgId,
|
cemeteryId, cemeterySvgId,
|
||||||
burialSiteLatitude, burialSiteLongitude,
|
burialSiteLatitude, burialSiteLongitude,
|
||||||
|
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?,
|
values (?, ?,
|
||||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||||
?, ?, ?, ?)`)
|
?, ?, ?, ?)`)
|
||||||
.run(burialSiteForm.burialSiteNameSegment1, burialSiteForm.burialSiteNameSegment2 ?? '', burialSiteForm.burialSiteNameSegment3 ?? '', burialSiteForm.burialSiteNameSegment4 ?? '', burialSiteForm.burialSiteNameSegment5 ?? '', burialSiteForm.burialSiteTypeId, burialSiteForm.burialSiteStatusId === '' ? undefined : burialSiteForm.burialSiteStatusId, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteLatitude === '' ? undefined : burialSiteForm.burialSiteLatitude, burialSiteForm.burialSiteLongitude === '' ? undefined : burialSiteForm.burialSiteLongitude, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
.run(burialSiteForm.burialSiteNameSegment1, burialSiteForm.burialSiteNameSegment2 ?? '', burialSiteForm.burialSiteNameSegment3 ?? '', burialSiteForm.burialSiteNameSegment4 ?? '', burialSiteForm.burialSiteNameSegment5 ?? '', burialSiteName, burialSiteForm.burialSiteTypeId, burialSiteForm.burialSiteStatusId === '' ? undefined : burialSiteForm.burialSiteStatusId, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteLatitude === '' ? undefined : burialSiteForm.burialSiteLatitude, burialSiteForm.burialSiteLongitude === '' ? undefined : burialSiteForm.burialSiteLongitude, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||||
const burialSiteId = result.lastInsertRowid;
|
const burialSiteId = result.lastInsertRowid;
|
||||||
const burialSiteTypeFieldIds = (burialSiteForm.burialSiteTypeFieldIds ?? '').split(',');
|
const burialSiteTypeFieldIds = (burialSiteForm.burialSiteTypeFieldIds ?? '').split(',');
|
||||||
for (const burialSiteTypeFieldId of burialSiteTypeFieldIds) {
|
for (const burialSiteTypeFieldId of burialSiteTypeFieldIds) {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { buildBurialSiteName } from '../helpers/burialSites.helpers.js'
|
||||||
|
|
||||||
import addOrUpdateBurialSiteField from './addOrUpdateBurialSiteField.js'
|
import addOrUpdateBurialSiteField from './addOrUpdateBurialSiteField.js'
|
||||||
import { acquireConnection } from './pool.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
|
|
@ -29,6 +31,8 @@ export default async function addLot(
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
||||||
|
const burialSiteName = buildBurialSiteName(burialSiteForm)
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(
|
.prepare(
|
||||||
`insert into BurialSites (
|
`insert into BurialSites (
|
||||||
|
|
@ -37,13 +41,14 @@ export default async function addLot(
|
||||||
burialSiteNameSegment3,
|
burialSiteNameSegment3,
|
||||||
burialSiteNameSegment4,
|
burialSiteNameSegment4,
|
||||||
burialSiteNameSegment5,
|
burialSiteNameSegment5,
|
||||||
|
burialSiteName,
|
||||||
burialSiteTypeId, burialSiteStatusId,
|
burialSiteTypeId, burialSiteStatusId,
|
||||||
cemeteryId, cemeterySvgId,
|
cemeteryId, cemeterySvgId,
|
||||||
burialSiteLatitude, burialSiteLongitude,
|
burialSiteLatitude, burialSiteLongitude,
|
||||||
|
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?,
|
values (?, ?,
|
||||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||||
?, ?, ?, ?)`
|
?, ?, ?, ?)`
|
||||||
)
|
)
|
||||||
|
|
@ -53,6 +58,7 @@ export default async function addLot(
|
||||||
burialSiteForm.burialSiteNameSegment3 ?? '',
|
burialSiteForm.burialSiteNameSegment3 ?? '',
|
||||||
burialSiteForm.burialSiteNameSegment4 ?? '',
|
burialSiteForm.burialSiteNameSegment4 ?? '',
|
||||||
burialSiteForm.burialSiteNameSegment5 ?? '',
|
burialSiteForm.burialSiteNameSegment5 ?? '',
|
||||||
|
burialSiteName,
|
||||||
burialSiteForm.burialSiteTypeId,
|
burialSiteForm.burialSiteTypeId,
|
||||||
burialSiteForm.burialSiteStatusId === '' ? undefined : burialSiteForm.burialSiteStatusId,
|
burialSiteForm.burialSiteStatusId === '' ? undefined : burialSiteForm.burialSiteStatusId,
|
||||||
burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId,
|
burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId,
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,4 @@ export interface AddBurialSiteContractForm {
|
||||||
occupantEmailAddress?: string;
|
occupantEmailAddress?: string;
|
||||||
occupantComment?: string;
|
occupantComment?: string;
|
||||||
}
|
}
|
||||||
export default function addLotOccupancy(addForm: AddBurialSiteContractForm, user: User, connectedDatabase?: PoolConnection): Promise<number>;
|
export default function addBurialSiteContract(addForm: AddBurialSiteContractForm, user: User, connectedDatabase?: PoolConnection): Promise<number>;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { dateStringToInteger } from '@cityssm/utils-datetime';
|
import { dateStringToInteger } from '@cityssm/utils-datetime';
|
||||||
import addLotOccupancyOccupant from './addLotOccupancyOccupant.js';
|
import addBurialSiteContractOccupant from './addBurialSiteContractOccupant.js';
|
||||||
import addOrUpdateBurialSiteContractField from './addOrUpdateBurialSiteContractField.js';
|
import addOrUpdateBurialSiteContractField from './addOrUpdateBurialSiteContractField.js';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
export default async function addLotOccupancy(addForm, user, connectedDatabase) {
|
export default async function addBurialSiteContract(addForm, user, connectedDatabase) {
|
||||||
const database = connectedDatabase ?? (await acquireConnection());
|
const database = connectedDatabase ?? (await acquireConnection());
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const contractStartDate = dateStringToInteger(addForm.contractStartDateString);
|
const contractStartDate = dateStringToInteger(addForm.contractStartDateString);
|
||||||
|
|
@ -22,17 +22,17 @@ export default async function addLotOccupancy(addForm, user, connectedDatabase)
|
||||||
const burialSiteContractId = result.lastInsertRowid;
|
const burialSiteContractId = result.lastInsertRowid;
|
||||||
const contractTypeFieldIds = (addForm.contractTypeFieldIds ?? '').split(',');
|
const contractTypeFieldIds = (addForm.contractTypeFieldIds ?? '').split(',');
|
||||||
for (const contractTypeFieldId of contractTypeFieldIds) {
|
for (const contractTypeFieldId of contractTypeFieldIds) {
|
||||||
const lotOccupancyFieldValue = addForm[`lotOccupancyFieldValue_${contractTypeFieldId}`];
|
const burialSiteContractFieldValue = addForm[`burialSiteContractFieldValue_${contractTypeFieldId}`];
|
||||||
if ((lotOccupancyFieldValue ?? '') !== '') {
|
if ((burialSiteContractFieldValue ?? '') !== '') {
|
||||||
await addOrUpdateBurialSiteContractField({
|
await addOrUpdateBurialSiteContractField({
|
||||||
burialSiteContractId,
|
burialSiteContractId,
|
||||||
contractTypeFieldId,
|
contractTypeFieldId,
|
||||||
lotOccupancyFieldValue: lotOccupancyFieldValue ?? ''
|
burialSiteContractFieldValue: burialSiteContractFieldValue ?? ''
|
||||||
}, user, database);
|
}, user, database);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((addForm.lotOccupantTypeId ?? '') !== '') {
|
if ((addForm.lotOccupantTypeId ?? '') !== '') {
|
||||||
await addLotOccupancyOccupant({
|
await addBurialSiteContractOccupant({
|
||||||
burialSiteContractId,
|
burialSiteContractId,
|
||||||
lotOccupantTypeId: addForm.lotOccupantTypeId ?? '',
|
lotOccupantTypeId: addForm.lotOccupantTypeId ?? '',
|
||||||
occupantName: addForm.occupantName ?? '',
|
occupantName: addForm.occupantName ?? '',
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { type DateString, dateStringToInteger } from '@cityssm/utils-datetime'
|
import { type DateString, dateStringToInteger } from '@cityssm/utils-datetime'
|
||||||
import type { PoolConnection } from 'better-sqlite-pool'
|
import type { PoolConnection } from 'better-sqlite-pool'
|
||||||
|
|
||||||
import addLotOccupancyOccupant from './addLotOccupancyOccupant.js'
|
import addBurialSiteContractOccupant from './addBurialSiteContractOccupant.js'
|
||||||
import addOrUpdateBurialSiteContractField from './addOrUpdateBurialSiteContractField.js'
|
import addOrUpdateBurialSiteContractField from './addOrUpdateBurialSiteContractField.js'
|
||||||
import { acquireConnection } from './pool.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ export interface AddBurialSiteContractForm {
|
||||||
occupantComment?: string
|
occupantComment?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function addLotOccupancy(
|
export default async function addBurialSiteContract(
|
||||||
addForm: AddBurialSiteContractForm,
|
addForm: AddBurialSiteContractForm,
|
||||||
user: User,
|
user: User,
|
||||||
connectedDatabase?: PoolConnection
|
connectedDatabase?: PoolConnection
|
||||||
|
|
@ -76,16 +76,16 @@ export default async function addLotOccupancy(
|
||||||
).split(',')
|
).split(',')
|
||||||
|
|
||||||
for (const contractTypeFieldId of contractTypeFieldIds) {
|
for (const contractTypeFieldId of contractTypeFieldIds) {
|
||||||
const lotOccupancyFieldValue = addForm[
|
const burialSiteContractFieldValue = addForm[
|
||||||
`lotOccupancyFieldValue_${contractTypeFieldId}`
|
`burialSiteContractFieldValue_${contractTypeFieldId}`
|
||||||
] as string | undefined
|
] as string | undefined
|
||||||
|
|
||||||
if ((lotOccupancyFieldValue ?? '') !== '') {
|
if ((burialSiteContractFieldValue ?? '') !== '') {
|
||||||
await addOrUpdateBurialSiteContractField(
|
await addOrUpdateBurialSiteContractField(
|
||||||
{
|
{
|
||||||
burialSiteContractId,
|
burialSiteContractId,
|
||||||
contractTypeFieldId,
|
contractTypeFieldId,
|
||||||
lotOccupancyFieldValue: lotOccupancyFieldValue ?? ''
|
burialSiteContractFieldValue: burialSiteContractFieldValue ?? ''
|
||||||
},
|
},
|
||||||
user,
|
user,
|
||||||
database
|
database
|
||||||
|
|
@ -94,7 +94,7 @@ export default async function addLotOccupancy(
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((addForm.lotOccupantTypeId ?? '') !== '') {
|
if ((addForm.lotOccupantTypeId ?? '') !== '') {
|
||||||
await addLotOccupancyOccupant(
|
await addBurialSiteContractOccupant(
|
||||||
{
|
{
|
||||||
burialSiteContractId,
|
burialSiteContractId,
|
||||||
lotOccupantTypeId: addForm.lotOccupantTypeId ?? '',
|
lotOccupantTypeId: addForm.lotOccupantTypeId ?? '',
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,4 @@ export interface AddBurialSiteContractCommentForm {
|
||||||
commentTimeString?: TimeString;
|
commentTimeString?: TimeString;
|
||||||
comment: string;
|
comment: string;
|
||||||
}
|
}
|
||||||
export default function addLotOccupancyComment(commentForm: AddBurialSiteContractCommentForm, user: User): Promise<number>;
|
export default function addBurialSiteContractComment(commentForm: AddBurialSiteContractCommentForm, user: User): Promise<number>;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/utils-datetime';
|
import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/utils-datetime';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
export default async function addLotOccupancyComment(commentForm, user) {
|
export default async function addBurialSiteContractComment(commentForm, user) {
|
||||||
const rightNow = new Date();
|
const rightNow = new Date();
|
||||||
let commentDate = 0;
|
let commentDate = 0;
|
||||||
let commentTime = 0;
|
let commentTime = 0;
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ export interface AddBurialSiteContractCommentForm {
|
||||||
comment: string
|
comment: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function addLotOccupancyComment(
|
export default async function addBurialSiteContractComment(
|
||||||
commentForm: AddBurialSiteContractCommentForm,
|
commentForm: AddBurialSiteContractCommentForm,
|
||||||
user: User
|
user: User
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ export default async function addBurialSiteContractFee(addFeeForm, user, connect
|
||||||
let feeAmount;
|
let feeAmount;
|
||||||
let taxAmount;
|
let taxAmount;
|
||||||
if ((addFeeForm.feeAmount ?? '') === '') {
|
if ((addFeeForm.feeAmount ?? '') === '') {
|
||||||
const lotOccupancy = (await getBurialSiteContract(addFeeForm.burialSiteContractId));
|
const burialSiteContract = (await getBurialSiteContract(addFeeForm.burialSiteContractId));
|
||||||
const fee = (await getFee(addFeeForm.feeId));
|
const fee = (await getFee(addFeeForm.feeId));
|
||||||
feeAmount = calculateFeeAmount(fee, lotOccupancy);
|
feeAmount = calculateFeeAmount(fee, burialSiteContract);
|
||||||
taxAmount = calculateTaxAmount(fee, feeAmount);
|
taxAmount = calculateTaxAmount(fee, feeAmount);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,13 @@ export default async function addBurialSiteContractFee(
|
||||||
let taxAmount: number
|
let taxAmount: number
|
||||||
|
|
||||||
if ((addFeeForm.feeAmount ?? '') === '') {
|
if ((addFeeForm.feeAmount ?? '') === '') {
|
||||||
const lotOccupancy = (await getBurialSiteContract(
|
const burialSiteContract = (await getBurialSiteContract(
|
||||||
addFeeForm.burialSiteContractId
|
addFeeForm.burialSiteContractId
|
||||||
)) as BurialSiteContract
|
)) as BurialSiteContract
|
||||||
|
|
||||||
const fee = (await getFee(addFeeForm.feeId)) as Fee
|
const fee = (await getFee(addFeeForm.feeId)) as Fee
|
||||||
|
|
||||||
feeAmount = calculateFeeAmount(fee, lotOccupancy)
|
feeAmount = calculateFeeAmount(fee, burialSiteContract)
|
||||||
taxAmount = calculateTaxAmount(fee, feeAmount)
|
taxAmount = calculateTaxAmount(fee, feeAmount)
|
||||||
} else {
|
} else {
|
||||||
feeAmount =
|
feeAmount =
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,4 @@ export interface AddBurialSiteContractCategoryForm {
|
||||||
burialSiteContractId: number | string;
|
burialSiteContractId: number | string;
|
||||||
feeCategoryId: number | string;
|
feeCategoryId: number | string;
|
||||||
}
|
}
|
||||||
export default function addLotOccupancyFeeCategory(addFeeCategoryForm: AddBurialSiteContractCategoryForm, user: User): Promise<number>;
|
export default function addBurialSiteContractFeeCategory(addFeeCategoryForm: AddBurialSiteContractCategoryForm, user: User): Promise<number>;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import addBurialSiteContractFee from './addBurialSiteContractFee.js';
|
import addBurialSiteContractFee from './addBurialSiteContractFee.js';
|
||||||
import { getFeeCategory } from './getFeeCategories.js';
|
import { getFeeCategory } from './getFeeCategories.js';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
export default async function addLotOccupancyFeeCategory(addFeeCategoryForm, user) {
|
export default async function addBurialSiteContractFeeCategory(addFeeCategoryForm, user) {
|
||||||
const database = await acquireConnection();
|
const database = await acquireConnection();
|
||||||
const feeCategory = await getFeeCategory(addFeeCategoryForm.feeCategoryId, database);
|
const feeCategory = await getFeeCategory(addFeeCategoryForm.feeCategoryId, database);
|
||||||
let addedFeeCount = 0;
|
let addedFeeCount = 0;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ export interface AddBurialSiteContractCategoryForm {
|
||||||
feeCategoryId: number | string
|
feeCategoryId: number | string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function addLotOccupancyFeeCategory(
|
export default async function addBurialSiteContractFeeCategory(
|
||||||
addFeeCategoryForm: AddBurialSiteContractCategoryForm,
|
addFeeCategoryForm: AddBurialSiteContractCategoryForm,
|
||||||
user: User
|
user: User
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
export interface AddLotOccupancyTransactionForm {
|
export interface AddTransactionForm {
|
||||||
burialSiteContractId: string | number;
|
burialSiteContractId: string | number;
|
||||||
transactionDateString?: string;
|
transactionDateString?: string;
|
||||||
transactionTimeString?: string;
|
transactionTimeString?: string;
|
||||||
|
|
@ -6,4 +6,4 @@ export interface AddLotOccupancyTransactionForm {
|
||||||
externalReceiptNumber: string;
|
externalReceiptNumber: string;
|
||||||
transactionNote: string;
|
transactionNote: string;
|
||||||
}
|
}
|
||||||
export default function addLotOccupancyTransaction(lotOccupancyTransactionForm: AddLotOccupancyTransactionForm, user: User): Promise<number>;
|
export default function addBurialSiteContractTransaction(burialSiteContractTransactionForm: AddTransactionForm, user: User): Promise<number>;
|
||||||
|
|
@ -1,34 +1,34 @@
|
||||||
import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/utils-datetime';
|
import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/utils-datetime';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
export default async function addLotOccupancyTransaction(lotOccupancyTransactionForm, user) {
|
export default async function addBurialSiteContractTransaction(burialSiteContractTransactionForm, user) {
|
||||||
const database = await acquireConnection();
|
const database = await acquireConnection();
|
||||||
let transactionIndex = 0;
|
let transactionIndex = 0;
|
||||||
const maxIndexResult = database
|
const maxIndexResult = database
|
||||||
.prepare(`select transactionIndex
|
.prepare(`select transactionIndex
|
||||||
from LotOccupancyTransactions
|
from BurialSiteContractTransactions
|
||||||
where burialSiteContractId = ?
|
where burialSiteContractId = ?
|
||||||
order by transactionIndex desc
|
order by transactionIndex desc
|
||||||
limit 1`)
|
limit 1`)
|
||||||
.get(lotOccupancyTransactionForm.burialSiteContractId);
|
.get(burialSiteContractTransactionForm.burialSiteContractId);
|
||||||
if (maxIndexResult !== undefined) {
|
if (maxIndexResult !== undefined) {
|
||||||
transactionIndex = maxIndexResult.transactionIndex + 1;
|
transactionIndex = maxIndexResult.transactionIndex + 1;
|
||||||
}
|
}
|
||||||
const rightNow = new Date();
|
const rightNow = new Date();
|
||||||
const transactionDate = lotOccupancyTransactionForm.transactionDateString
|
const transactionDate = burialSiteContractTransactionForm.transactionDateString
|
||||||
? dateStringToInteger(lotOccupancyTransactionForm.transactionDateString)
|
? dateStringToInteger(burialSiteContractTransactionForm.transactionDateString)
|
||||||
: dateToInteger(rightNow);
|
: dateToInteger(rightNow);
|
||||||
const transactionTime = lotOccupancyTransactionForm.transactionTimeString
|
const transactionTime = burialSiteContractTransactionForm.transactionTimeString
|
||||||
? timeStringToInteger(lotOccupancyTransactionForm.transactionTimeString)
|
? timeStringToInteger(burialSiteContractTransactionForm.transactionTimeString)
|
||||||
: dateToTimeInteger(rightNow);
|
: dateToTimeInteger(rightNow);
|
||||||
database
|
database
|
||||||
.prepare(`insert into LotOccupancyTransactions (
|
.prepare(`insert into BurialSiteContractTransactions (
|
||||||
burialSiteContractId, transactionIndex,
|
burialSiteContractId, transactionIndex,
|
||||||
transactionDate, transactionTime,
|
transactionDate, transactionTime,
|
||||||
transactionAmount, externalReceiptNumber, transactionNote,
|
transactionAmount, externalReceiptNumber, transactionNote,
|
||||||
recordCreate_userName, recordCreate_timeMillis,
|
recordCreate_userName, recordCreate_timeMillis,
|
||||||
recordUpdate_userName, recordUpdate_timeMillis)
|
recordUpdate_userName, recordUpdate_timeMillis)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||||
.run(lotOccupancyTransactionForm.burialSiteContractId, transactionIndex, transactionDate, transactionTime, lotOccupancyTransactionForm.transactionAmount, lotOccupancyTransactionForm.externalReceiptNumber, lotOccupancyTransactionForm.transactionNote, user.userName, rightNow.getTime(), user.userName, rightNow.getTime());
|
.run(burialSiteContractTransactionForm.burialSiteContractId, transactionIndex, transactionDate, transactionTime, burialSiteContractTransactionForm.transactionAmount, burialSiteContractTransactionForm.externalReceiptNumber, burialSiteContractTransactionForm.transactionNote, user.userName, rightNow.getTime(), user.userName, rightNow.getTime());
|
||||||
database.release();
|
database.release();
|
||||||
return transactionIndex;
|
return transactionIndex;
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,7 @@ import {
|
||||||
|
|
||||||
import { acquireConnection } from './pool.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export interface AddLotOccupancyTransactionForm {
|
export interface AddTransactionForm {
|
||||||
burialSiteContractId: string | number
|
burialSiteContractId: string | number
|
||||||
transactionDateString?: string
|
transactionDateString?: string
|
||||||
transactionTimeString?: string
|
transactionTimeString?: string
|
||||||
|
|
@ -16,8 +16,8 @@ export interface AddLotOccupancyTransactionForm {
|
||||||
transactionNote: string
|
transactionNote: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function addLotOccupancyTransaction(
|
export default async function addBurialSiteContractTransaction(
|
||||||
lotOccupancyTransactionForm: AddLotOccupancyTransactionForm,
|
burialSiteContractTransactionForm: AddTransactionForm,
|
||||||
user: User
|
user: User
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
const database = await acquireConnection()
|
const database = await acquireConnection()
|
||||||
|
|
@ -27,12 +27,12 @@ export default async function addLotOccupancyTransaction(
|
||||||
const maxIndexResult = database
|
const maxIndexResult = database
|
||||||
.prepare(
|
.prepare(
|
||||||
`select transactionIndex
|
`select transactionIndex
|
||||||
from LotOccupancyTransactions
|
from BurialSiteContractTransactions
|
||||||
where burialSiteContractId = ?
|
where burialSiteContractId = ?
|
||||||
order by transactionIndex desc
|
order by transactionIndex desc
|
||||||
limit 1`
|
limit 1`
|
||||||
)
|
)
|
||||||
.get(lotOccupancyTransactionForm.burialSiteContractId) as
|
.get(burialSiteContractTransactionForm.burialSiteContractId) as
|
||||||
| { transactionIndex: number }
|
| { transactionIndex: number }
|
||||||
| undefined
|
| undefined
|
||||||
|
|
||||||
|
|
@ -42,17 +42,17 @@ export default async function addLotOccupancyTransaction(
|
||||||
|
|
||||||
const rightNow = new Date()
|
const rightNow = new Date()
|
||||||
|
|
||||||
const transactionDate = lotOccupancyTransactionForm.transactionDateString
|
const transactionDate = burialSiteContractTransactionForm.transactionDateString
|
||||||
? dateStringToInteger(lotOccupancyTransactionForm.transactionDateString)
|
? dateStringToInteger(burialSiteContractTransactionForm.transactionDateString)
|
||||||
: dateToInteger(rightNow)
|
: dateToInteger(rightNow)
|
||||||
|
|
||||||
const transactionTime = lotOccupancyTransactionForm.transactionTimeString
|
const transactionTime = burialSiteContractTransactionForm.transactionTimeString
|
||||||
? timeStringToInteger(lotOccupancyTransactionForm.transactionTimeString)
|
? timeStringToInteger(burialSiteContractTransactionForm.transactionTimeString)
|
||||||
: dateToTimeInteger(rightNow)
|
: dateToTimeInteger(rightNow)
|
||||||
|
|
||||||
database
|
database
|
||||||
.prepare(
|
.prepare(
|
||||||
`insert into LotOccupancyTransactions (
|
`insert into BurialSiteContractTransactions (
|
||||||
burialSiteContractId, transactionIndex,
|
burialSiteContractId, transactionIndex,
|
||||||
transactionDate, transactionTime,
|
transactionDate, transactionTime,
|
||||||
transactionAmount, externalReceiptNumber, transactionNote,
|
transactionAmount, externalReceiptNumber, transactionNote,
|
||||||
|
|
@ -61,13 +61,13 @@ export default async function addLotOccupancyTransaction(
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||||
)
|
)
|
||||||
.run(
|
.run(
|
||||||
lotOccupancyTransactionForm.burialSiteContractId,
|
burialSiteContractTransactionForm.burialSiteContractId,
|
||||||
transactionIndex,
|
transactionIndex,
|
||||||
transactionDate,
|
transactionDate,
|
||||||
transactionTime,
|
transactionTime,
|
||||||
lotOccupancyTransactionForm.transactionAmount,
|
burialSiteContractTransactionForm.transactionAmount,
|
||||||
lotOccupancyTransactionForm.externalReceiptNumber,
|
burialSiteContractTransactionForm.externalReceiptNumber,
|
||||||
lotOccupancyTransactionForm.transactionNote,
|
burialSiteContractTransactionForm.transactionNote,
|
||||||
user.userName,
|
user.userName,
|
||||||
rightNow.getTime(),
|
rightNow.getTime(),
|
||||||
user.userName,
|
user.userName,
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { dateToString } from '@cityssm/utils-datetime';
|
import { dateToString } from '@cityssm/utils-datetime';
|
||||||
import addBurialSiteContract from './addBurialSiteContract.js';
|
import addBurialSiteContract from './addBurialSiteContract.js';
|
||||||
import addBurialSiteContractComment from './addBurialSiteContractComment.js';
|
import addBurialSiteContractComment from './addBurialSiteContractComment.js';
|
||||||
// import addLotOccupancyOccupant from './addLotOccupancyOccupant.js'
|
// import addBurialSiteContractOccupant from './addBurialSiteContractOccupant.js'
|
||||||
import getBurialSiteContract from './getBurialSiteContract.js';
|
import getBurialSiteContract from './getBurialSiteContract.js';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
export default async function copyBurialSiteContract(oldBurialSiteContractId, user) {
|
export default async function copyBurialSiteContract(oldBurialSiteContractId, user) {
|
||||||
|
|
@ -30,8 +30,8 @@ export default async function copyBurialSiteContract(oldBurialSiteContractId, us
|
||||||
* Copy Occupants
|
* Copy Occupants
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
for (const occupant of oldBurialSiteContract.lotOccupancyOccupants ?? []) {
|
for (const occupant of oldBurialSiteContract.burialSiteContractOccupants ?? []) {
|
||||||
await addLotOccupancyOccupant(
|
await addBurialSiteContractOccupant(
|
||||||
{
|
{
|
||||||
burialSiteContractId: newBurialSiteContractId,
|
burialSiteContractId: newBurialSiteContractId,
|
||||||
lotOccupantTypeId: occupant.lotOccupantTypeId!,
|
lotOccupantTypeId: occupant.lotOccupantTypeId!,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import type { BurialSiteContract } from '../types/recordTypes.js'
|
||||||
|
|
||||||
import addBurialSiteContract from './addBurialSiteContract.js'
|
import addBurialSiteContract from './addBurialSiteContract.js'
|
||||||
import addBurialSiteContractComment from './addBurialSiteContractComment.js'
|
import addBurialSiteContractComment from './addBurialSiteContractComment.js'
|
||||||
// import addLotOccupancyOccupant from './addLotOccupancyOccupant.js'
|
// import addBurialSiteContractOccupant from './addBurialSiteContractOccupant.js'
|
||||||
import getBurialSiteContract from './getBurialSiteContract.js'
|
import getBurialSiteContract from './getBurialSiteContract.js'
|
||||||
import { acquireConnection } from './pool.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
|
|
@ -58,8 +58,8 @@ export default async function copyBurialSiteContract(
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
for (const occupant of oldBurialSiteContract.lotOccupancyOccupants ?? []) {
|
for (const occupant of oldBurialSiteContract.burialSiteContractOccupants ?? []) {
|
||||||
await addLotOccupancyOccupant(
|
await addBurialSiteContractOccupant(
|
||||||
{
|
{
|
||||||
burialSiteContractId: newBurialSiteContractId,
|
burialSiteContractId: newBurialSiteContractId,
|
||||||
lotOccupantTypeId: occupant.lotOccupantTypeId!,
|
lotOccupantTypeId: occupant.lotOccupantTypeId!,
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
export declare function getLotByLotName(lotName: string): Promise<Lot | undefined>;
|
import type { BurialSite } from '../types/recordTypes.js';
|
||||||
export default function getLot(burialSiteId: number | string): Promise<Lot | undefined>;
|
export declare function getBurialSiteByBurialSiteName(burialSiteName: string): Promise<BurialSite | undefined>;
|
||||||
|
export default function getBurialSite(burialSiteId: number | string): Promise<BurialSite | undefined>;
|
||||||
|
|
|
||||||
|
|
@ -9,40 +9,40 @@ const baseSQL = `select l.burialSiteId,
|
||||||
l.burialSiteNameSegment3,
|
l.burialSiteNameSegment3,
|
||||||
l.burialSiteNameSegment4,
|
l.burialSiteNameSegment4,
|
||||||
l.burialSiteNameSegment5,
|
l.burialSiteNameSegment5,
|
||||||
|
l.burialSiteName,
|
||||||
l.burialSiteStatusId, s.burialSiteStatus,
|
l.burialSiteStatusId, s.burialSiteStatus,
|
||||||
l.cemeteryId, m.cemeteryName,
|
l.cemeteryId, m.cemeteryName,
|
||||||
m.cemeterySvg, l.cemeterySvgId,
|
m.cemeterySvg, l.cemeterySvgId,
|
||||||
l.burialSiteLatitude, l.burialSiteLongitude,
|
l.burialSiteLatitude, l.burialSiteLongitude,
|
||||||
|
|
||||||
from BurialSites l
|
from BurialSites l
|
||||||
left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId
|
left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId
|
||||||
left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId
|
left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId
|
||||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||||
where l.recordDelete_timeMillis is null`;
|
where l.recordDelete_timeMillis is null`;
|
||||||
async function _getBurialSite(sql, burialSiteIdOrLotName) {
|
async function _getBurialSite(sql, burialSiteIdOrLotName) {
|
||||||
const database = await acquireConnection();
|
const database = await acquireConnection();
|
||||||
const burialSite = database.prepare(sql).get(burialSiteIdOrLotName);
|
const burialSite = database.prepare(sql).get(burialSiteIdOrLotName);
|
||||||
if (burialSite !== undefined) {
|
if (burialSite !== undefined) {
|
||||||
const BurialSiteContracts = await getBurialSiteInterments({
|
const burialSiteContracts = await getBurialSiteInterments({
|
||||||
burialSiteId: burialSite.burialSiteId
|
burialSiteId: burialSite.burialSiteId
|
||||||
}, {
|
}, {
|
||||||
includeOccupants: true,
|
includeInterments: true,
|
||||||
includeFees: false,
|
includeFees: false,
|
||||||
includeTransactions: false,
|
includeTransactions: false,
|
||||||
limit: -1,
|
limit: -1,
|
||||||
offset: 0
|
offset: 0
|
||||||
}, database);
|
}, database);
|
||||||
burialSite.burialSiteContracts = BurialSiteContracts.BurialSiteContracts;
|
burialSite.burialSiteContracts = burialSiteContracts.burialSiteContracts;
|
||||||
burialSite.burialSiteFields = await getBurialSiteFields(burialSite.burialSiteId, database);
|
burialSite.burialSiteFields = await getBurialSiteFields(burialSite.burialSiteId, database);
|
||||||
burialSite.burialSiteComments = await getBurialSiteComments(burialSite.burialSiteId, database);
|
burialSite.burialSiteComments = await getBurialSiteComments(burialSite.burialSiteId, database);
|
||||||
}
|
}
|
||||||
database.release();
|
database.release();
|
||||||
return burialSite;
|
return burialSite;
|
||||||
}
|
}
|
||||||
// TODO
|
export async function getBurialSiteByBurialSiteName(burialSiteName) {
|
||||||
export async function getLotByLotName(lotName) {
|
return await _getBurialSite(`${baseSQL} and l.burialSiteName = ?`, burialSiteName);
|
||||||
return await _getBurialSite(`${baseSQL} and l.lotName = ?`, lotName);
|
|
||||||
}
|
}
|
||||||
export default async function getLot(burialSiteId) {
|
export default async function getBurialSite(burialSiteId) {
|
||||||
return await _getBurialSite(`${baseSQL} and l.burialSiteId = ?`, burialSiteId);
|
return await _getBurialSite(`${baseSQL} and l.burialSiteId = ?`, burialSiteId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,16 +12,17 @@ const baseSQL = `select l.burialSiteId,
|
||||||
l.burialSiteNameSegment3,
|
l.burialSiteNameSegment3,
|
||||||
l.burialSiteNameSegment4,
|
l.burialSiteNameSegment4,
|
||||||
l.burialSiteNameSegment5,
|
l.burialSiteNameSegment5,
|
||||||
|
l.burialSiteName,
|
||||||
l.burialSiteStatusId, s.burialSiteStatus,
|
l.burialSiteStatusId, s.burialSiteStatus,
|
||||||
l.cemeteryId, m.cemeteryName,
|
l.cemeteryId, m.cemeteryName,
|
||||||
m.cemeterySvg, l.cemeterySvgId,
|
m.cemeterySvg, l.cemeterySvgId,
|
||||||
l.burialSiteLatitude, l.burialSiteLongitude,
|
l.burialSiteLatitude, l.burialSiteLongitude,
|
||||||
|
|
||||||
from BurialSites l
|
from BurialSites l
|
||||||
left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId
|
left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId
|
||||||
left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId
|
left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId
|
||||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||||
where l.recordDelete_timeMillis is null`
|
where l.recordDelete_timeMillis is null`
|
||||||
|
|
||||||
async function _getBurialSite(
|
async function _getBurialSite(
|
||||||
sql: string,
|
sql: string,
|
||||||
|
|
@ -32,12 +33,12 @@ async function _getBurialSite(
|
||||||
const burialSite = database.prepare(sql).get(burialSiteIdOrLotName) as BurialSite | undefined
|
const burialSite = database.prepare(sql).get(burialSiteIdOrLotName) as BurialSite | undefined
|
||||||
|
|
||||||
if (burialSite !== undefined) {
|
if (burialSite !== undefined) {
|
||||||
const BurialSiteContracts = await getBurialSiteInterments(
|
const burialSiteContracts = await getBurialSiteInterments(
|
||||||
{
|
{
|
||||||
burialSiteId: burialSite.burialSiteId
|
burialSiteId: burialSite.burialSiteId
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
includeOccupants: true,
|
includeInterments: true,
|
||||||
includeFees: false,
|
includeFees: false,
|
||||||
includeTransactions: false,
|
includeTransactions: false,
|
||||||
limit: -1,
|
limit: -1,
|
||||||
|
|
@ -46,7 +47,7 @@ async function _getBurialSite(
|
||||||
database
|
database
|
||||||
)
|
)
|
||||||
|
|
||||||
burialSite.burialSiteContracts = BurialSiteContracts.BurialSiteContracts
|
burialSite.burialSiteContracts = burialSiteContracts.burialSiteContracts
|
||||||
|
|
||||||
burialSite.burialSiteFields = await getBurialSiteFields(burialSite.burialSiteId, database)
|
burialSite.burialSiteFields = await getBurialSiteFields(burialSite.burialSiteId, database)
|
||||||
|
|
||||||
|
|
@ -58,15 +59,14 @@ async function _getBurialSite(
|
||||||
return burialSite
|
return burialSite
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
export async function getBurialSiteByBurialSiteName(
|
||||||
export async function getLotByLotName(
|
burialSiteName: string
|
||||||
lotName: string
|
): Promise<BurialSite | undefined> {
|
||||||
): Promise<Lot | undefined> {
|
return await _getBurialSite(`${baseSQL} and l.burialSiteName = ?`, burialSiteName)
|
||||||
return await _getBurialSite(`${baseSQL} and l.lotName = ?`, lotName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function getLot(
|
export default async function getBurialSite(
|
||||||
burialSiteId: number | string
|
burialSiteId: number | string
|
||||||
): Promise<Lot | undefined> {
|
): Promise<BurialSite | undefined> {
|
||||||
return await _getBurialSite(`${baseSQL} and l.burialSiteId = ?`, burialSiteId)
|
return await _getBurialSite(`${baseSQL} and l.burialSiteId = ?`, burialSiteId)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
import type { PoolConnection } from 'better-sqlite-pool';
|
import type { PoolConnection } from 'better-sqlite-pool';
|
||||||
import type { BurialSiteContract } from '../types/recordTypes.js';
|
import type { BurialSiteContract } from '../types/recordTypes.js';
|
||||||
export default function getLotOccupancy(burialSiteContractId: number | string, connectedDatabase?: PoolConnection): Promise<BurialSiteContract | undefined>;
|
export default function getBurialSiteContract(burialSiteContractId: number | string, connectedDatabase?: PoolConnection): Promise<BurialSiteContract | undefined>;
|
||||||
|
|
|
||||||
|
|
@ -2,22 +2,18 @@ import { dateIntegerToString } from '@cityssm/utils-datetime';
|
||||||
import getBurialSiteContractComments from './getBurialSiteContractComments.js';
|
import getBurialSiteContractComments from './getBurialSiteContractComments.js';
|
||||||
import getBurialSiteContractFees from './getBurialSiteContractFees.js';
|
import getBurialSiteContractFees from './getBurialSiteContractFees.js';
|
||||||
import getBurialSiteContractFields from './getBurialSiteContractFields.js';
|
import getBurialSiteContractFields from './getBurialSiteContractFields.js';
|
||||||
// import getLotOccupancyOccupants from './getLotOccupancyOccupants.js'
|
// import getBurialSiteContractOccupants from './getBurialSiteContractOccupants.js'
|
||||||
import getBurialSiteContractTransactions from './getBurialSiteContractTransactions.js';
|
import getBurialSiteContractTransactions from './getBurialSiteContractTransactions.js';
|
||||||
import { getWorkOrders } from './getWorkOrders.js';
|
import { getWorkOrders } from './getWorkOrders.js';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
export default async function getLotOccupancy(burialSiteContractId, connectedDatabase) {
|
export default async function getBurialSiteContract(burialSiteContractId, connectedDatabase) {
|
||||||
const database = connectedDatabase ?? (await acquireConnection());
|
const database = connectedDatabase ?? (await acquireConnection());
|
||||||
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
||||||
const contract = database
|
const contract = database
|
||||||
.prepare(`select o.burialSiteContractId,
|
.prepare(`select o.burialSiteContractId,
|
||||||
o.contractTypeId, t.contractType,
|
o.contractTypeId, t.contractType,
|
||||||
o.burialSiteId,
|
o.burialSiteId,
|
||||||
l.burialSiteNameSegment1,
|
l.burialSiteName,
|
||||||
l.burialSiteNameSegment2,
|
|
||||||
l.burialSiteNameSegment3,
|
|
||||||
l.burialSiteNameSegment4,
|
|
||||||
l.burialSiteNameSegment5,
|
|
||||||
l.burialSiteTypeId,
|
l.burialSiteTypeId,
|
||||||
l.cemeteryId, m.cemeteryName,
|
l.cemeteryId, m.cemeteryName,
|
||||||
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
||||||
|
|
@ -33,7 +29,7 @@ export default async function getLotOccupancy(burialSiteContractId, connectedDat
|
||||||
if (contract !== undefined) {
|
if (contract !== undefined) {
|
||||||
contract.burialSiteContractFields = await getBurialSiteContractFields(burialSiteContractId, database);
|
contract.burialSiteContractFields = await getBurialSiteContractFields(burialSiteContractId, database);
|
||||||
/*
|
/*
|
||||||
contract.burialSiteContractInterments = await getLotOccupancyOccupants(
|
contract.burialSiteContractInterments = await getBurialSiteContractOccupants(
|
||||||
burialSiteContractId,
|
burialSiteContractId,
|
||||||
database
|
database
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@ import type { BurialSiteContract } from '../types/recordTypes.js'
|
||||||
import getBurialSiteContractComments from './getBurialSiteContractComments.js'
|
import getBurialSiteContractComments from './getBurialSiteContractComments.js'
|
||||||
import getBurialSiteContractFees from './getBurialSiteContractFees.js'
|
import getBurialSiteContractFees from './getBurialSiteContractFees.js'
|
||||||
import getBurialSiteContractFields from './getBurialSiteContractFields.js'
|
import getBurialSiteContractFields from './getBurialSiteContractFields.js'
|
||||||
// import getLotOccupancyOccupants from './getLotOccupancyOccupants.js'
|
// import getBurialSiteContractOccupants from './getBurialSiteContractOccupants.js'
|
||||||
import getBurialSiteContractTransactions from './getBurialSiteContractTransactions.js'
|
import getBurialSiteContractTransactions from './getBurialSiteContractTransactions.js'
|
||||||
import { getWorkOrders } from './getWorkOrders.js'
|
import { getWorkOrders } from './getWorkOrders.js'
|
||||||
import { acquireConnection } from './pool.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export default async function getLotOccupancy(
|
export default async function getBurialSiteContract(
|
||||||
burialSiteContractId: number | string,
|
burialSiteContractId: number | string,
|
||||||
connectedDatabase?: PoolConnection
|
connectedDatabase?: PoolConnection
|
||||||
): Promise<BurialSiteContract | undefined> {
|
): Promise<BurialSiteContract | undefined> {
|
||||||
|
|
@ -24,11 +24,7 @@ export default async function getLotOccupancy(
|
||||||
`select o.burialSiteContractId,
|
`select o.burialSiteContractId,
|
||||||
o.contractTypeId, t.contractType,
|
o.contractTypeId, t.contractType,
|
||||||
o.burialSiteId,
|
o.burialSiteId,
|
||||||
l.burialSiteNameSegment1,
|
l.burialSiteName,
|
||||||
l.burialSiteNameSegment2,
|
|
||||||
l.burialSiteNameSegment3,
|
|
||||||
l.burialSiteNameSegment4,
|
|
||||||
l.burialSiteNameSegment5,
|
|
||||||
l.burialSiteTypeId,
|
l.burialSiteTypeId,
|
||||||
l.cemeteryId, m.cemeteryName,
|
l.cemeteryId, m.cemeteryName,
|
||||||
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
||||||
|
|
@ -49,7 +45,7 @@ export default async function getLotOccupancy(
|
||||||
database
|
database
|
||||||
)
|
)
|
||||||
/*
|
/*
|
||||||
contract.burialSiteContractInterments = await getLotOccupancyOccupants(
|
contract.burialSiteContractInterments = await getBurialSiteContractOccupants(
|
||||||
burialSiteContractId,
|
burialSiteContractId,
|
||||||
database
|
database
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ export default async function GetBurialSiteContractTransactions(burialSiteContra
|
||||||
const database = connectedDatabase ?? (await acquireConnection());
|
const database = connectedDatabase ?? (await acquireConnection());
|
||||||
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
||||||
database.function('userFn_timeIntegerToString', timeIntegerToString);
|
database.function('userFn_timeIntegerToString', timeIntegerToString);
|
||||||
const lotOccupancyTransactions = database
|
const burialSiteContractTransactions = database
|
||||||
.prepare(`select burialSiteContractId, transactionIndex,
|
.prepare(`select burialSiteContractId, transactionIndex,
|
||||||
transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString,
|
transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString,
|
||||||
transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString,
|
transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString,
|
||||||
|
|
@ -21,7 +21,7 @@ export default async function GetBurialSiteContractTransactions(burialSiteContra
|
||||||
}
|
}
|
||||||
if (options.includeIntegrations &&
|
if (options.includeIntegrations &&
|
||||||
getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
||||||
for (const transaction of lotOccupancyTransactions) {
|
for (const transaction of burialSiteContractTransactions) {
|
||||||
if ((transaction.externalReceiptNumber ?? '') !== '') {
|
if ((transaction.externalReceiptNumber ?? '') !== '') {
|
||||||
const gpDocument = await getDynamicsGPDocument(transaction.externalReceiptNumber ?? '');
|
const gpDocument = await getDynamicsGPDocument(transaction.externalReceiptNumber ?? '');
|
||||||
if (gpDocument !== undefined) {
|
if (gpDocument !== undefined) {
|
||||||
|
|
@ -30,5 +30,5 @@ export default async function GetBurialSiteContractTransactions(burialSiteContra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lotOccupancyTransactions;
|
return burialSiteContractTransactions;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ export default async function GetBurialSiteContractTransactions(
|
||||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||||
database.function('userFn_timeIntegerToString', timeIntegerToString)
|
database.function('userFn_timeIntegerToString', timeIntegerToString)
|
||||||
|
|
||||||
const lotOccupancyTransactions = database
|
const burialSiteContractTransactions = database
|
||||||
.prepare(
|
.prepare(
|
||||||
`select burialSiteContractId, transactionIndex,
|
`select burialSiteContractId, transactionIndex,
|
||||||
transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString,
|
transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString,
|
||||||
|
|
@ -43,7 +43,7 @@ export default async function GetBurialSiteContractTransactions(
|
||||||
options.includeIntegrations &&
|
options.includeIntegrations &&
|
||||||
getConfigProperty('settings.dynamicsGP.integrationIsEnabled')
|
getConfigProperty('settings.dynamicsGP.integrationIsEnabled')
|
||||||
) {
|
) {
|
||||||
for (const transaction of lotOccupancyTransactions) {
|
for (const transaction of burialSiteContractTransactions) {
|
||||||
if ((transaction.externalReceiptNumber ?? '') !== '') {
|
if ((transaction.externalReceiptNumber ?? '') !== '') {
|
||||||
const gpDocument = await getDynamicsGPDocument(
|
const gpDocument = await getDynamicsGPDocument(
|
||||||
transaction.externalReceiptNumber ?? ''
|
transaction.externalReceiptNumber ?? ''
|
||||||
|
|
@ -56,5 +56,5 @@ export default async function GetBurialSiteContractTransactions(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return lotOccupancyTransactions
|
return burialSiteContractTransactions
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { type DateString } from '@cityssm/utils-datetime';
|
import { type DateString } from '@cityssm/utils-datetime';
|
||||||
import type { PoolConnection } from 'better-sqlite-pool';
|
import type { PoolConnection } from 'better-sqlite-pool';
|
||||||
import type { BurialSiteContract } from '../types/recordTypes.js';
|
import type { BurialSiteContract } from '../types/recordTypes.js';
|
||||||
interface GetBurialSiteContractsFilters {
|
export interface GetBurialSiteContractsFilters {
|
||||||
burialSiteId?: number | string;
|
burialSiteId?: number | string;
|
||||||
occupancyTime?: '' | 'past' | 'current' | 'future';
|
occupancyTime?: '' | 'past' | 'current' | 'future';
|
||||||
contractStartDateString?: DateString;
|
contractStartDateString?: DateString;
|
||||||
|
|
@ -15,10 +15,10 @@ interface GetBurialSiteContractsFilters {
|
||||||
workOrderId?: number | string;
|
workOrderId?: number | string;
|
||||||
notWorkOrderId?: number | string;
|
notWorkOrderId?: number | string;
|
||||||
}
|
}
|
||||||
interface GetBurialSiteContractsOptions {
|
export interface GetBurialSiteContractsOptions {
|
||||||
/** -1 for no limit */
|
/** -1 for no limit */
|
||||||
limit: number;
|
limit: number | string;
|
||||||
offset: number;
|
offset: number | string;
|
||||||
includeInterments: boolean;
|
includeInterments: boolean;
|
||||||
includeFees: boolean;
|
includeFees: boolean;
|
||||||
includeTransactions: boolean;
|
includeTransactions: boolean;
|
||||||
|
|
@ -27,4 +27,3 @@ export default function getBurialSiteContracts(filters: GetBurialSiteContractsFi
|
||||||
count: number;
|
count: number;
|
||||||
burialSiteContracts: BurialSiteContract[];
|
burialSiteContracts: BurialSiteContract[];
|
||||||
}>;
|
}>;
|
||||||
export {};
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { dateIntegerToString, dateStringToInteger } from '@cityssm/utils-datetime';
|
import { dateIntegerToString, dateStringToInteger } from '@cityssm/utils-datetime';
|
||||||
import { getConfigProperty } from '../helpers/config.helpers.js';
|
import { getConfigProperty } from '../helpers/config.helpers.js';
|
||||||
import { getContractTypeById } from '../helpers/functions.cache.js';
|
import { getContractTypeById } from '../helpers/functions.cache.js';
|
||||||
import { getLotNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js';
|
import { getBurialSiteNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js';
|
||||||
import getBurialSiteContractFees from './getBurialSiteContractFees.js';
|
import getBurialSiteContractFees from './getBurialSiteContractFees.js';
|
||||||
// import getLotOccupancyOccupants from './getLotOccupancyOccupants.js'
|
// import getBurialSiteContractOccupants from './getBurialSiteContractOccupants.js'
|
||||||
import getBurialSiteContractTransactions from './getBurialSiteContractTransactions.js';
|
import getBurialSiteContractTransactions from './getBurialSiteContractTransactions.js';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
function buildWhereClause(filters) {
|
function buildWhereClause(filters) {
|
||||||
|
|
@ -13,7 +13,7 @@ function buildWhereClause(filters) {
|
||||||
sqlWhereClause += ' and o.lotId = ?';
|
sqlWhereClause += ' and o.lotId = ?';
|
||||||
sqlParameters.push(filters.burialSiteId);
|
sqlParameters.push(filters.burialSiteId);
|
||||||
}
|
}
|
||||||
const lotNameFilters = getLotNameWhereClause(filters.burialSiteName, filters.burialSiteNameSearchType ?? '', 'l');
|
const lotNameFilters = getBurialSiteNameWhereClause(filters.burialSiteName, filters.burialSiteNameSearchType ?? '', 'l');
|
||||||
sqlWhereClause += lotNameFilters.sqlWhereClause;
|
sqlWhereClause += lotNameFilters.sqlWhereClause;
|
||||||
sqlParameters.push(...lotNameFilters.sqlParameters);
|
sqlParameters.push(...lotNameFilters.sqlParameters);
|
||||||
const occupantNameFilters = getOccupantNameWhereClause(filters.occupantName, 'o');
|
const occupantNameFilters = getOccupantNameWhereClause(filters.occupantName, 'o');
|
||||||
|
|
@ -76,7 +76,7 @@ async function addInclusions(burialSiteContract, options, database) {
|
||||||
/*
|
/*
|
||||||
if (options.includeInterments) {
|
if (options.includeInterments) {
|
||||||
burialSiteContract.burialSiteContractInterments =
|
burialSiteContract.burialSiteContractInterments =
|
||||||
await getLotOccupancyOccupants(
|
await getBurialSiteContractOccupants(
|
||||||
burialSiteContract.burialSiteContractId,
|
burialSiteContract.burialSiteContractId,
|
||||||
database
|
database
|
||||||
)
|
)
|
||||||
|
|
@ -88,7 +88,9 @@ export default async function getBurialSiteContracts(filters, options, connected
|
||||||
const database = connectedDatabase ?? (await acquireConnection());
|
const database = connectedDatabase ?? (await acquireConnection());
|
||||||
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
||||||
const { sqlWhereClause, sqlParameters } = buildWhereClause(filters);
|
const { sqlWhereClause, sqlParameters } = buildWhereClause(filters);
|
||||||
let count = options.limit;
|
let count = typeof options.limit === 'string'
|
||||||
|
? Number.parseInt(options.limit, 10)
|
||||||
|
: options.limit;
|
||||||
const isLimited = options.limit !== -1;
|
const isLimited = options.limit !== -1;
|
||||||
if (isLimited) {
|
if (isLimited) {
|
||||||
count = database
|
count = database
|
||||||
|
|
@ -104,11 +106,7 @@ export default async function getBurialSiteContracts(filters, options, connected
|
||||||
.prepare(`select o.burialSiteContractId,
|
.prepare(`select o.burialSiteContractId,
|
||||||
o.contractTypeId, t.contractType,
|
o.contractTypeId, t.contractType,
|
||||||
o.burialSiteId, lt.burialSiteType,
|
o.burialSiteId, lt.burialSiteType,
|
||||||
l.burialSiteNameSegment1,
|
l.burialSiteName,
|
||||||
l.burialSiteNameSegment2,
|
|
||||||
l.burialSiteNameSegment3,
|
|
||||||
l.burialSiteNameSegment4,
|
|
||||||
l.burialSiteNameSegment5,
|
|
||||||
l.cemeteryId, m.cemeteryName,
|
l.cemeteryId, m.cemeteryName,
|
||||||
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
||||||
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString
|
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString
|
||||||
|
|
|
||||||
|
|
@ -8,18 +8,18 @@ import type { PoolConnection } from 'better-sqlite-pool'
|
||||||
import { getConfigProperty } from '../helpers/config.helpers.js'
|
import { getConfigProperty } from '../helpers/config.helpers.js'
|
||||||
import { getContractTypeById } from '../helpers/functions.cache.js'
|
import { getContractTypeById } from '../helpers/functions.cache.js'
|
||||||
import {
|
import {
|
||||||
getLotNameWhereClause,
|
getBurialSiteNameWhereClause,
|
||||||
getOccupancyTimeWhereClause,
|
getOccupancyTimeWhereClause,
|
||||||
getOccupantNameWhereClause
|
getOccupantNameWhereClause
|
||||||
} from '../helpers/functions.sqlFilters.js'
|
} from '../helpers/functions.sqlFilters.js'
|
||||||
import type { BurialSiteContract } from '../types/recordTypes.js'
|
import type { BurialSiteContract } from '../types/recordTypes.js'
|
||||||
|
|
||||||
import getBurialSiteContractFees from './getBurialSiteContractFees.js'
|
import getBurialSiteContractFees from './getBurialSiteContractFees.js'
|
||||||
// import getLotOccupancyOccupants from './getLotOccupancyOccupants.js'
|
// import getBurialSiteContractOccupants from './getBurialSiteContractOccupants.js'
|
||||||
import getBurialSiteContractTransactions from './getBurialSiteContractTransactions.js'
|
import getBurialSiteContractTransactions from './getBurialSiteContractTransactions.js'
|
||||||
import { acquireConnection } from './pool.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
interface GetBurialSiteContractsFilters {
|
export interface GetBurialSiteContractsFilters {
|
||||||
burialSiteId?: number | string
|
burialSiteId?: number | string
|
||||||
occupancyTime?: '' | 'past' | 'current' | 'future'
|
occupancyTime?: '' | 'past' | 'current' | 'future'
|
||||||
contractStartDateString?: DateString
|
contractStartDateString?: DateString
|
||||||
|
|
@ -34,10 +34,10 @@ interface GetBurialSiteContractsFilters {
|
||||||
notWorkOrderId?: number | string
|
notWorkOrderId?: number | string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GetBurialSiteContractsOptions {
|
export interface GetBurialSiteContractsOptions {
|
||||||
/** -1 for no limit */
|
/** -1 for no limit */
|
||||||
limit: number
|
limit: number | string
|
||||||
offset: number
|
offset: number | string
|
||||||
includeInterments: boolean
|
includeInterments: boolean
|
||||||
includeFees: boolean
|
includeFees: boolean
|
||||||
includeTransactions: boolean
|
includeTransactions: boolean
|
||||||
|
|
@ -55,7 +55,7 @@ function buildWhereClause(filters: GetBurialSiteContractsFilters): {
|
||||||
sqlParameters.push(filters.burialSiteId)
|
sqlParameters.push(filters.burialSiteId)
|
||||||
}
|
}
|
||||||
|
|
||||||
const lotNameFilters = getLotNameWhereClause(
|
const lotNameFilters = getBurialSiteNameWhereClause(
|
||||||
filters.burialSiteName,
|
filters.burialSiteName,
|
||||||
filters.burialSiteNameSearchType ?? '',
|
filters.burialSiteNameSearchType ?? '',
|
||||||
'l'
|
'l'
|
||||||
|
|
@ -157,7 +157,7 @@ async function addInclusions(
|
||||||
/*
|
/*
|
||||||
if (options.includeInterments) {
|
if (options.includeInterments) {
|
||||||
burialSiteContract.burialSiteContractInterments =
|
burialSiteContract.burialSiteContractInterments =
|
||||||
await getLotOccupancyOccupants(
|
await getBurialSiteContractOccupants(
|
||||||
burialSiteContract.burialSiteContractId,
|
burialSiteContract.burialSiteContractId,
|
||||||
database
|
database
|
||||||
)
|
)
|
||||||
|
|
@ -178,7 +178,10 @@ export default async function getBurialSiteContracts(
|
||||||
|
|
||||||
const { sqlWhereClause, sqlParameters } = buildWhereClause(filters)
|
const { sqlWhereClause, sqlParameters } = buildWhereClause(filters)
|
||||||
|
|
||||||
let count = options.limit
|
let count =
|
||||||
|
typeof options.limit === 'string'
|
||||||
|
? Number.parseInt(options.limit, 10)
|
||||||
|
: options.limit
|
||||||
|
|
||||||
const isLimited = options.limit !== -1
|
const isLimited = options.limit !== -1
|
||||||
|
|
||||||
|
|
@ -203,11 +206,7 @@ export default async function getBurialSiteContracts(
|
||||||
`select o.burialSiteContractId,
|
`select o.burialSiteContractId,
|
||||||
o.contractTypeId, t.contractType,
|
o.contractTypeId, t.contractType,
|
||||||
o.burialSiteId, lt.burialSiteType,
|
o.burialSiteId, lt.burialSiteType,
|
||||||
l.burialSiteNameSegment1,
|
l.burialSiteName,
|
||||||
l.burialSiteNameSegment2,
|
|
||||||
l.burialSiteNameSegment3,
|
|
||||||
l.burialSiteNameSegment4,
|
|
||||||
l.burialSiteNameSegment5,
|
|
||||||
l.cemeteryId, m.cemeteryName,
|
l.cemeteryId, m.cemeteryName,
|
||||||
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
||||||
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString
|
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString
|
||||||
|
|
@ -236,7 +235,7 @@ export default async function getBurialSiteContracts(
|
||||||
|
|
||||||
for (const burialSiteContract of burialSiteContracts) {
|
for (const burialSiteContract of burialSiteContracts) {
|
||||||
const contractType = await getContractTypeById(
|
const contractType = await getContractTypeById(
|
||||||
burialSiteContract.contractTypeId!
|
burialSiteContract.contractTypeId
|
||||||
)
|
)
|
||||||
|
|
||||||
if (contractType !== undefined) {
|
if (contractType !== undefined) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import type { PoolConnection } from 'better-sqlite-pool';
|
import type { PoolConnection } from 'better-sqlite-pool';
|
||||||
import type { BurialSite } from '../types/recordTypes.js';
|
import type { BurialSite } from '../types/recordTypes.js';
|
||||||
interface GetBurialSitesFilters {
|
export interface GetBurialSitesFilters {
|
||||||
burialSiteNameSearchType?: '' | 'startsWith' | 'endsWith';
|
burialSiteNameSearchType?: '' | 'startsWith' | 'endsWith';
|
||||||
burialSiteName?: string;
|
burialSiteName?: string;
|
||||||
cemeteryId?: number | string;
|
cemeteryId?: number | string;
|
||||||
|
|
@ -9,14 +9,13 @@ interface GetBurialSitesFilters {
|
||||||
contractStatus?: '' | 'occupied' | 'unoccupied';
|
contractStatus?: '' | 'occupied' | 'unoccupied';
|
||||||
workOrderId?: number | string;
|
workOrderId?: number | string;
|
||||||
}
|
}
|
||||||
interface GetBurialSitesOptions {
|
export interface GetBurialSitesOptions {
|
||||||
/** -1 for no limit */
|
/** -1 for no limit */
|
||||||
limit: number;
|
limit: number;
|
||||||
offset: number;
|
offset: string | number;
|
||||||
includeBurialSiteContractCount?: boolean;
|
includeBurialSiteContractCount?: boolean;
|
||||||
}
|
}
|
||||||
export default function getBurialSites(filters: GetBurialSitesFilters, options: GetBurialSitesOptions, connectedDatabase?: PoolConnection): Promise<{
|
export default function getBurialSites(filters: GetBurialSitesFilters, options: GetBurialSitesOptions, connectedDatabase?: PoolConnection): Promise<{
|
||||||
count: number;
|
count: number;
|
||||||
burialSites: BurialSite[];
|
burialSites: BurialSite[];
|
||||||
}>;
|
}>;
|
||||||
export {};
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import { dateToInteger } from '@cityssm/utils-datetime';
|
import { dateToInteger } from '@cityssm/utils-datetime';
|
||||||
import { getLotNameWhereClause } from '../helpers/functions.sqlFilters.js';
|
import { getBurialSiteNameWhereClause } from '../helpers/functions.sqlFilters.js';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
function buildWhereClause(filters) {
|
function buildWhereClause(filters) {
|
||||||
let sqlWhereClause = ' where l.recordDelete_timeMillis is null';
|
let sqlWhereClause = ' where l.recordDelete_timeMillis is null';
|
||||||
const sqlParameters = [];
|
const sqlParameters = [];
|
||||||
const lotNameFilters = getLotNameWhereClause(filters.burialSiteName, filters.burialSiteNameSearchType ?? '', 'l');
|
const burialSiteNameFilters = getBurialSiteNameWhereClause(filters.burialSiteName, filters.burialSiteNameSearchType ?? '', 'l');
|
||||||
sqlWhereClause += lotNameFilters.sqlWhereClause;
|
sqlWhereClause += burialSiteNameFilters.sqlWhereClause;
|
||||||
sqlParameters.push(...lotNameFilters.sqlParameters);
|
sqlParameters.push(...burialSiteNameFilters.sqlParameters);
|
||||||
if ((filters.cemeteryId ?? '') !== '') {
|
if ((filters.cemeteryId ?? '') !== '') {
|
||||||
sqlWhereClause += ' and l.cemeteryId = ?';
|
sqlWhereClause += ' and l.cemeteryId = ?';
|
||||||
sqlParameters.push(filters.cemeteryId);
|
sqlParameters.push(filters.cemeteryId);
|
||||||
|
|
@ -21,16 +21,16 @@ function buildWhereClause(filters) {
|
||||||
}
|
}
|
||||||
if ((filters.contractStatus ?? '') !== '') {
|
if ((filters.contractStatus ?? '') !== '') {
|
||||||
if (filters.contractStatus === 'occupied') {
|
if (filters.contractStatus === 'occupied') {
|
||||||
sqlWhereClause += ' and lotOccupancyCount > 0';
|
sqlWhereClause += ' and burialSiteContractCount > 0';
|
||||||
}
|
}
|
||||||
else if (filters.contractStatus === 'unoccupied') {
|
else if (filters.contractStatus === 'unoccupied') {
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
' and (lotOccupancyCount is null or lotOccupancyCount = 0)';
|
' and (burialSiteContractCount is null or burialSiteContractCount = 0)';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((filters.workOrderId ?? '') !== '') {
|
if ((filters.workOrderId ?? '') !== '') {
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
' and l.lotId in (select lotId from WorkOrderLots where recordDelete_timeMillis is null and workOrderId = ?)';
|
' and l.burialSiteId in (select burialSiteId from WorkOrderBurialSites where recordDelete_timeMillis is null and workOrderId = ?)';
|
||||||
sqlParameters.push(filters.workOrderId);
|
sqlParameters.push(filters.workOrderId);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import { dateToInteger } from '@cityssm/utils-datetime'
|
import { dateToInteger } from '@cityssm/utils-datetime'
|
||||||
import type { PoolConnection } from 'better-sqlite-pool'
|
import type { PoolConnection } from 'better-sqlite-pool'
|
||||||
|
|
||||||
import { getLotNameWhereClause } from '../helpers/functions.sqlFilters.js'
|
import { getBurialSiteNameWhereClause } from '../helpers/functions.sqlFilters.js'
|
||||||
import type { BurialSite } from '../types/recordTypes.js'
|
import type { BurialSite } from '../types/recordTypes.js'
|
||||||
|
|
||||||
import { acquireConnection } from './pool.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
interface GetBurialSitesFilters {
|
export interface GetBurialSitesFilters {
|
||||||
burialSiteNameSearchType?: '' | 'startsWith' | 'endsWith'
|
burialSiteNameSearchType?: '' | 'startsWith' | 'endsWith'
|
||||||
burialSiteName?: string
|
burialSiteName?: string
|
||||||
cemeteryId?: number | string
|
cemeteryId?: number | string
|
||||||
|
|
@ -16,10 +16,10 @@ interface GetBurialSitesFilters {
|
||||||
workOrderId?: number | string
|
workOrderId?: number | string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GetBurialSitesOptions {
|
export interface GetBurialSitesOptions {
|
||||||
/** -1 for no limit */
|
/** -1 for no limit */
|
||||||
limit: number
|
limit: number
|
||||||
offset: number
|
offset: string | number
|
||||||
includeBurialSiteContractCount?: boolean
|
includeBurialSiteContractCount?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,13 +30,13 @@ function buildWhereClause(filters: GetBurialSitesFilters): {
|
||||||
let sqlWhereClause = ' where l.recordDelete_timeMillis is null'
|
let sqlWhereClause = ' where l.recordDelete_timeMillis is null'
|
||||||
const sqlParameters: unknown[] = []
|
const sqlParameters: unknown[] = []
|
||||||
|
|
||||||
const lotNameFilters = getLotNameWhereClause(
|
const burialSiteNameFilters = getBurialSiteNameWhereClause(
|
||||||
filters.burialSiteName,
|
filters.burialSiteName,
|
||||||
filters.burialSiteNameSearchType ?? '',
|
filters.burialSiteNameSearchType ?? '',
|
||||||
'l'
|
'l'
|
||||||
)
|
)
|
||||||
sqlWhereClause += lotNameFilters.sqlWhereClause
|
sqlWhereClause += burialSiteNameFilters.sqlWhereClause
|
||||||
sqlParameters.push(...lotNameFilters.sqlParameters)
|
sqlParameters.push(...burialSiteNameFilters.sqlParameters)
|
||||||
|
|
||||||
if ((filters.cemeteryId ?? '') !== '') {
|
if ((filters.cemeteryId ?? '') !== '') {
|
||||||
sqlWhereClause += ' and l.cemeteryId = ?'
|
sqlWhereClause += ' and l.cemeteryId = ?'
|
||||||
|
|
@ -55,16 +55,16 @@ function buildWhereClause(filters: GetBurialSitesFilters): {
|
||||||
|
|
||||||
if ((filters.contractStatus ?? '') !== '') {
|
if ((filters.contractStatus ?? '') !== '') {
|
||||||
if (filters.contractStatus === 'occupied') {
|
if (filters.contractStatus === 'occupied') {
|
||||||
sqlWhereClause += ' and lotOccupancyCount > 0'
|
sqlWhereClause += ' and burialSiteContractCount > 0'
|
||||||
} else if (filters.contractStatus === 'unoccupied') {
|
} else if (filters.contractStatus === 'unoccupied') {
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
' and (lotOccupancyCount is null or lotOccupancyCount = 0)'
|
' and (burialSiteContractCount is null or burialSiteContractCount = 0)'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((filters.workOrderId ?? '') !== '') {
|
if ((filters.workOrderId ?? '') !== '') {
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
' and l.lotId in (select lotId from WorkOrderLots where recordDelete_timeMillis is null and workOrderId = ?)'
|
' and l.burialSiteId in (select burialSiteId from WorkOrderBurialSites where recordDelete_timeMillis is null and workOrderId = ?)'
|
||||||
sqlParameters.push(filters.workOrderId)
|
sqlParameters.push(filters.workOrderId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@ export default async function getPastLotOccupancyOccupants(filters, options) {
|
||||||
occupantPhoneNumber, occupantEmailAddress
|
occupantPhoneNumber, occupantEmailAddress
|
||||||
order by burialSiteContractIdCount desc, recordUpdate_timeMillisMax desc
|
order by burialSiteContractIdCount desc, recordUpdate_timeMillisMax desc
|
||||||
limit ${options.limit}`;
|
limit ${options.limit}`;
|
||||||
const lotOccupancyOccupants = database
|
const burialSiteContractOccupants = database
|
||||||
.prepare(sql)
|
.prepare(sql)
|
||||||
.all(sqlParameters);
|
.all(sqlParameters);
|
||||||
database.release();
|
database.release();
|
||||||
return lotOccupancyOccupants;
|
return burialSiteContractOccupants;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,11 +60,11 @@ export default async function getPastLotOccupancyOccupants(
|
||||||
order by burialSiteContractIdCount desc, recordUpdate_timeMillisMax desc
|
order by burialSiteContractIdCount desc, recordUpdate_timeMillisMax desc
|
||||||
limit ${options.limit}`
|
limit ${options.limit}`
|
||||||
|
|
||||||
const lotOccupancyOccupants = database
|
const burialSiteContractOccupants = database
|
||||||
.prepare(sql)
|
.prepare(sql)
|
||||||
.all(sqlParameters) as LotOccupancyOccupant[]
|
.all(sqlParameters) as LotOccupancyOccupant[]
|
||||||
|
|
||||||
database.release()
|
database.release()
|
||||||
|
|
||||||
return lotOccupancyOccupants
|
return burialSiteContractOccupants
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { dateIntegerToString, dateStringToInteger } from '@cityssm/utils-datetime';
|
import { dateIntegerToString, dateStringToInteger } from '@cityssm/utils-datetime';
|
||||||
import { getLotNameWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js';
|
import { getBurialSiteNameWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js';
|
||||||
import getBurialSiteContracts from './getBurialSiteContracts.js';
|
import getBurialSiteContracts from './getBurialSiteContracts.js';
|
||||||
import getLots from './getLots.js';
|
import getLots from './getLots.js';
|
||||||
import getWorkOrderComments from './getWorkOrderComments.js';
|
import getWorkOrderComments from './getWorkOrderComments.js';
|
||||||
|
|
@ -36,7 +36,7 @@ function buildWhereClause(filters) {
|
||||||
))`;
|
))`;
|
||||||
sqlParameters.push(...occupantNameFilters.sqlParameters);
|
sqlParameters.push(...occupantNameFilters.sqlParameters);
|
||||||
}
|
}
|
||||||
const lotNameFilters = getLotNameWhereClause(filters.lotName, '', 'l');
|
const lotNameFilters = getBurialSiteNameWhereClause(filters.lotName, '', 'l');
|
||||||
if (lotNameFilters.sqlParameters.length > 0) {
|
if (lotNameFilters.sqlParameters.length > 0) {
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
` and w.workOrderId in (
|
` and w.workOrderId in (
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import {
|
||||||
import type { PoolConnection } from 'better-sqlite-pool'
|
import type { PoolConnection } from 'better-sqlite-pool'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getLotNameWhereClause,
|
getBurialSiteNameWhereClause,
|
||||||
getOccupantNameWhereClause
|
getOccupantNameWhereClause
|
||||||
} from '../helpers/functions.sqlFilters.js'
|
} from '../helpers/functions.sqlFilters.js'
|
||||||
import type { WorkOrder } from '../types/recordTypes.js'
|
import type { WorkOrder } from '../types/recordTypes.js'
|
||||||
|
|
@ -77,7 +77,7 @@ function buildWhereClause(filters: GetWorkOrdersFilters): {
|
||||||
sqlParameters.push(...occupantNameFilters.sqlParameters)
|
sqlParameters.push(...occupantNameFilters.sqlParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
const lotNameFilters = getLotNameWhereClause(filters.lotName, '', 'l')
|
const lotNameFilters = getBurialSiteNameWhereClause(filters.lotName, '', 'l')
|
||||||
if (lotNameFilters.sqlParameters.length > 0) {
|
if (lotNameFilters.sqlParameters.length > 0) {
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
` and w.workOrderId in (
|
` and w.workOrderId in (
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ const createStatements = [
|
||||||
fieldValues text,
|
fieldValues text,
|
||||||
isRequired bit not null default 0,
|
isRequired bit not null default 0,
|
||||||
pattern varchar(100),
|
pattern varchar(100),
|
||||||
minimumLength smallint not null default 1 check (minimumLength >= 0),
|
minLength smallint not null default 1 check (minLength >= 0),
|
||||||
maximumLength smallint not null default 100 check (maximumLength >= 0),
|
maxLength smallint not null default 100 check (maxLength >= 0),
|
||||||
orderNumber smallint not null default 0,
|
orderNumber smallint not null default 0,
|
||||||
${recordColumns},
|
${recordColumns},
|
||||||
foreign key (burialSiteTypeId) references BurialSiteTypes (burialSiteTypeId))`,
|
foreign key (burialSiteTypeId) references BurialSiteTypes (burialSiteTypeId))`,
|
||||||
|
|
@ -55,6 +55,7 @@ const createStatements = [
|
||||||
`create table if not exists Cemeteries (
|
`create table if not exists Cemeteries (
|
||||||
cemeteryId integer not null primary key autoincrement,
|
cemeteryId integer not null primary key autoincrement,
|
||||||
cemeteryName varchar(200) not null,
|
cemeteryName varchar(200) not null,
|
||||||
|
cemeteryKey varchar(20) not null,
|
||||||
cemeteryDescription text,
|
cemeteryDescription text,
|
||||||
cemeteryLatitude decimal(10, 8)
|
cemeteryLatitude decimal(10, 8)
|
||||||
check (cemeteryLatitude between -90 and 90),
|
check (cemeteryLatitude between -90 and 90),
|
||||||
|
|
@ -75,11 +76,12 @@ const createStatements = [
|
||||||
burialSiteId integer not null primary key autoincrement,
|
burialSiteId integer not null primary key autoincrement,
|
||||||
burialSiteTypeId integer not null,
|
burialSiteTypeId integer not null,
|
||||||
|
|
||||||
burialSiteNameSegment1 varchar(20),
|
burialSiteNameSegment1 varchar(20) not null,
|
||||||
burialSiteNameSegment2 varchar(20),
|
burialSiteNameSegment2 varchar(20) not null,
|
||||||
burialSiteNameSegment3 varchar(20),
|
burialSiteNameSegment3 varchar(20) not null,
|
||||||
burialSiteNameSegment4 varchar(20),
|
burialSiteNameSegment4 varchar(20) not null,
|
||||||
burialSiteNameSegment5 varchar(20),
|
burialSiteNameSegment5 varchar(20) not null,
|
||||||
|
burialSiteName varchar(200) not null,
|
||||||
|
|
||||||
cemeteryId integer,
|
cemeteryId integer,
|
||||||
cemeterySvgId varchar(100),
|
cemeterySvgId varchar(100),
|
||||||
|
|
@ -142,8 +144,8 @@ const createStatements = [
|
||||||
fieldValues text,
|
fieldValues text,
|
||||||
isRequired bit not null default 0,
|
isRequired bit not null default 0,
|
||||||
pattern varchar(100),
|
pattern varchar(100),
|
||||||
minimumLength smallint not null default 1 check (minimumLength >= 0),
|
minLength smallint not null default 1 check (minLength >= 0),
|
||||||
maximumLength smallint not null default 100 check (maximumLength >= 0),
|
maxLength smallint not null default 100 check (maxLength >= 0),
|
||||||
orderNumber smallint not null default 0,
|
orderNumber smallint not null default 0,
|
||||||
${recordColumns},
|
${recordColumns},
|
||||||
foreign key (contractTypeId) references ContractTypes (contractTypeId))`,
|
foreign key (contractTypeId) references ContractTypes (contractTypeId))`,
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@ const createStatements = [
|
||||||
fieldValues text,
|
fieldValues text,
|
||||||
isRequired bit not null default 0,
|
isRequired bit not null default 0,
|
||||||
pattern varchar(100),
|
pattern varchar(100),
|
||||||
minimumLength smallint not null default 1 check (minimumLength >= 0),
|
minLength smallint not null default 1 check (minLength >= 0),
|
||||||
maximumLength smallint not null default 100 check (maximumLength >= 0),
|
maxLength smallint not null default 100 check (maxLength >= 0),
|
||||||
orderNumber smallint not null default 0,
|
orderNumber smallint not null default 0,
|
||||||
${recordColumns},
|
${recordColumns},
|
||||||
foreign key (burialSiteTypeId) references BurialSiteTypes (burialSiteTypeId))`,
|
foreign key (burialSiteTypeId) references BurialSiteTypes (burialSiteTypeId))`,
|
||||||
|
|
@ -70,6 +70,7 @@ const createStatements = [
|
||||||
`create table if not exists Cemeteries (
|
`create table if not exists Cemeteries (
|
||||||
cemeteryId integer not null primary key autoincrement,
|
cemeteryId integer not null primary key autoincrement,
|
||||||
cemeteryName varchar(200) not null,
|
cemeteryName varchar(200) not null,
|
||||||
|
cemeteryKey varchar(20) not null,
|
||||||
cemeteryDescription text,
|
cemeteryDescription text,
|
||||||
cemeteryLatitude decimal(10, 8)
|
cemeteryLatitude decimal(10, 8)
|
||||||
check (cemeteryLatitude between -90 and 90),
|
check (cemeteryLatitude between -90 and 90),
|
||||||
|
|
@ -92,11 +93,12 @@ const createStatements = [
|
||||||
burialSiteId integer not null primary key autoincrement,
|
burialSiteId integer not null primary key autoincrement,
|
||||||
burialSiteTypeId integer not null,
|
burialSiteTypeId integer not null,
|
||||||
|
|
||||||
burialSiteNameSegment1 varchar(20),
|
burialSiteNameSegment1 varchar(20) not null,
|
||||||
burialSiteNameSegment2 varchar(20),
|
burialSiteNameSegment2 varchar(20) not null,
|
||||||
burialSiteNameSegment3 varchar(20),
|
burialSiteNameSegment3 varchar(20) not null,
|
||||||
burialSiteNameSegment4 varchar(20),
|
burialSiteNameSegment4 varchar(20) not null,
|
||||||
burialSiteNameSegment5 varchar(20),
|
burialSiteNameSegment5 varchar(20) not null,
|
||||||
|
burialSiteName varchar(200) not null,
|
||||||
|
|
||||||
cemeteryId integer,
|
cemeteryId integer,
|
||||||
cemeterySvgId varchar(100),
|
cemeterySvgId varchar(100),
|
||||||
|
|
@ -168,8 +170,8 @@ const createStatements = [
|
||||||
fieldValues text,
|
fieldValues text,
|
||||||
isRequired bit not null default 0,
|
isRequired bit not null default 0,
|
||||||
pattern varchar(100),
|
pattern varchar(100),
|
||||||
minimumLength smallint not null default 1 check (minimumLength >= 0),
|
minLength smallint not null default 1 check (minLength >= 0),
|
||||||
maximumLength smallint not null default 100 check (maximumLength >= 0),
|
maxLength smallint not null default 100 check (maxLength >= 0),
|
||||||
orderNumber smallint not null default 0,
|
orderNumber smallint not null default 0,
|
||||||
${recordColumns},
|
${recordColumns},
|
||||||
foreign key (contractTypeId) references ContractTypes (contractTypeId))`,
|
foreign key (contractTypeId) references ContractTypes (contractTypeId))`,
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,4 @@ export interface UpdateLotOccupancyOccupantForm {
|
||||||
occupantEmailAddress: string;
|
occupantEmailAddress: string;
|
||||||
occupantComment: string;
|
occupantComment: string;
|
||||||
}
|
}
|
||||||
export default function updateLotOccupancyOccupant(lotOccupancyOccupantForm: UpdateLotOccupancyOccupantForm, user: User): Promise<boolean>;
|
export default function updateLotOccupancyOccupant(burialSiteContractOccupantForm: UpdateLotOccupancyOccupantForm, user: User): Promise<boolean>;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
export default async function updateLotOccupancyOccupant(lotOccupancyOccupantForm, user) {
|
export default async function updateLotOccupancyOccupant(burialSiteContractOccupantForm, user) {
|
||||||
const database = await acquireConnection();
|
const database = await acquireConnection();
|
||||||
const results = database
|
const results = database
|
||||||
.prepare(`update LotOccupancyOccupants
|
.prepare(`update LotOccupancyOccupants
|
||||||
|
|
@ -19,7 +19,7 @@ export default async function updateLotOccupancyOccupant(lotOccupancyOccupantFor
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and burialSiteContractId = ?
|
and burialSiteContractId = ?
|
||||||
and lotOccupantIndex = ?`)
|
and lotOccupantIndex = ?`)
|
||||||
.run(lotOccupancyOccupantForm.occupantName, lotOccupancyOccupantForm.occupantFamilyName, lotOccupancyOccupantForm.occupantAddress1, lotOccupancyOccupantForm.occupantAddress2, lotOccupancyOccupantForm.occupantCity, lotOccupancyOccupantForm.occupantProvince, lotOccupancyOccupantForm.occupantPostalCode, lotOccupancyOccupantForm.occupantPhoneNumber, lotOccupancyOccupantForm.occupantEmailAddress, lotOccupancyOccupantForm.occupantComment, lotOccupancyOccupantForm.lotOccupantTypeId, user.userName, Date.now(), lotOccupancyOccupantForm.burialSiteContractId, lotOccupancyOccupantForm.lotOccupantIndex);
|
.run(burialSiteContractOccupantForm.occupantName, burialSiteContractOccupantForm.occupantFamilyName, burialSiteContractOccupantForm.occupantAddress1, burialSiteContractOccupantForm.occupantAddress2, burialSiteContractOccupantForm.occupantCity, burialSiteContractOccupantForm.occupantProvince, burialSiteContractOccupantForm.occupantPostalCode, burialSiteContractOccupantForm.occupantPhoneNumber, burialSiteContractOccupantForm.occupantEmailAddress, burialSiteContractOccupantForm.occupantComment, burialSiteContractOccupantForm.lotOccupantTypeId, user.userName, Date.now(), burialSiteContractOccupantForm.burialSiteContractId, burialSiteContractOccupantForm.lotOccupantIndex);
|
||||||
database.release();
|
database.release();
|
||||||
return results.changes > 0;
|
return results.changes > 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ export interface UpdateLotOccupancyOccupantForm {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function updateLotOccupancyOccupant(
|
export default async function updateLotOccupancyOccupant(
|
||||||
lotOccupancyOccupantForm: UpdateLotOccupancyOccupantForm,
|
burialSiteContractOccupantForm: UpdateLotOccupancyOccupantForm,
|
||||||
user: User
|
user: User
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const database = await acquireConnection()
|
const database = await acquireConnection()
|
||||||
|
|
@ -43,21 +43,21 @@ export default async function updateLotOccupancyOccupant(
|
||||||
and lotOccupantIndex = ?`
|
and lotOccupantIndex = ?`
|
||||||
)
|
)
|
||||||
.run(
|
.run(
|
||||||
lotOccupancyOccupantForm.occupantName,
|
burialSiteContractOccupantForm.occupantName,
|
||||||
lotOccupancyOccupantForm.occupantFamilyName,
|
burialSiteContractOccupantForm.occupantFamilyName,
|
||||||
lotOccupancyOccupantForm.occupantAddress1,
|
burialSiteContractOccupantForm.occupantAddress1,
|
||||||
lotOccupancyOccupantForm.occupantAddress2,
|
burialSiteContractOccupantForm.occupantAddress2,
|
||||||
lotOccupancyOccupantForm.occupantCity,
|
burialSiteContractOccupantForm.occupantCity,
|
||||||
lotOccupancyOccupantForm.occupantProvince,
|
burialSiteContractOccupantForm.occupantProvince,
|
||||||
lotOccupancyOccupantForm.occupantPostalCode,
|
burialSiteContractOccupantForm.occupantPostalCode,
|
||||||
lotOccupancyOccupantForm.occupantPhoneNumber,
|
burialSiteContractOccupantForm.occupantPhoneNumber,
|
||||||
lotOccupancyOccupantForm.occupantEmailAddress,
|
burialSiteContractOccupantForm.occupantEmailAddress,
|
||||||
lotOccupancyOccupantForm.occupantComment,
|
burialSiteContractOccupantForm.occupantComment,
|
||||||
lotOccupancyOccupantForm.lotOccupantTypeId,
|
burialSiteContractOccupantForm.lotOccupantTypeId,
|
||||||
user.userName,
|
user.userName,
|
||||||
Date.now(),
|
Date.now(),
|
||||||
lotOccupancyOccupantForm.burialSiteContractId,
|
burialSiteContractOccupantForm.burialSiteContractId,
|
||||||
lotOccupancyOccupantForm.lotOccupantIndex
|
burialSiteContractOccupantForm.lotOccupantIndex
|
||||||
)
|
)
|
||||||
|
|
||||||
database.release()
|
database.release()
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ import updateBurialSiteTypeField from '../../database/updateBurialSiteTypeField.
|
||||||
import { getBurialSiteTypes } from '../../helpers/functions.cache.js';
|
import { getBurialSiteTypes } from '../../helpers/functions.cache.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const success = await updateBurialSiteTypeField(request.body, request.session.user);
|
const success = await updateBurialSiteTypeField(request.body, request.session.user);
|
||||||
const lotTypes = await getBurialSiteTypes();
|
const burialSiteTypes = await getBurialSiteTypes();
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
lotTypes
|
burialSiteTypes
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -14,10 +14,10 @@ export default async function handler(
|
||||||
request.session.user as User
|
request.session.user as User
|
||||||
)
|
)
|
||||||
|
|
||||||
const lotTypes = await getBurialSiteTypes()
|
const burialSiteTypes = await getBurialSiteTypes()
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
lotTypes
|
burialSiteTypes
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import type { Request, Response } from 'express';
|
import type { Request, Response } from 'express';
|
||||||
export default function handler(request: Request<unknown, unknown, {
|
export default function handler(request: Request<unknown, unknown, {
|
||||||
contractTypeId: string;
|
contractTypeId: string;
|
||||||
occupancyType: string;
|
contractType: string;
|
||||||
}>, response: Response): Promise<void>;
|
}>, response: Response): Promise<void>;
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import { updateRecord } from '../../database/updateRecord.js';
|
import { updateRecord } from '../../database/updateRecord.js';
|
||||||
import { getAllContractTypeFields, getContractTypes } from '../../helpers/functions.cache.js';
|
import { getAllContractTypeFields, getContractTypes } from '../../helpers/functions.cache.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const success = await updateRecord('OccupancyTypes', request.body.contractTypeId, request.body.occupancyType, request.session.user);
|
const success = await updateRecord('ContractTypes', request.body.contractTypeId, request.body.contractType, request.session.user);
|
||||||
const occupancyTypes = await getContractTypes();
|
const contractTypes = await getContractTypes();
|
||||||
const allContractTypeFields = await getAllContractTypeFields();
|
const allContractTypeFields = await getAllContractTypeFields();
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
occupancyTypes,
|
contractTypes,
|
||||||
allContractTypeFields
|
allContractTypeFields
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -10,23 +10,23 @@ export default async function handler(
|
||||||
request: Request<
|
request: Request<
|
||||||
unknown,
|
unknown,
|
||||||
unknown,
|
unknown,
|
||||||
{ contractTypeId: string; occupancyType: string }
|
{ contractTypeId: string; contractType: string }
|
||||||
>,
|
>,
|
||||||
response: Response
|
response: Response
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const success = await updateRecord(
|
const success = await updateRecord(
|
||||||
'OccupancyTypes',
|
'ContractTypes',
|
||||||
request.body.contractTypeId,
|
request.body.contractTypeId,
|
||||||
request.body.occupancyType,
|
request.body.contractType,
|
||||||
request.session.user as User
|
request.session.user as User
|
||||||
)
|
)
|
||||||
|
|
||||||
const occupancyTypes = await getContractTypes()
|
const contractTypes = await getContractTypes()
|
||||||
const allContractTypeFields = await getAllContractTypeFields()
|
const allContractTypeFields = await getAllContractTypeFields()
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
occupancyTypes,
|
contractTypes,
|
||||||
allContractTypeFields
|
allContractTypeFields
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import type { Request, Response } from 'express';
|
||||||
|
import { type UpdateContractTypeFieldForm } from '../../database/updateContractTypeField.js';
|
||||||
|
export default function handler(request: Request<unknown, unknown, UpdateContractTypeFieldForm>, response: Response): Promise<void>;
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import updateOccupancyTypeField from '../../database/updateOccupancyTypeField.js';
|
import updateContractTypeField from '../../database/updateContractTypeField.js';
|
||||||
import { getAllContractTypeFields, getContractTypes } from '../../helpers/functions.cache.js';
|
import { getAllContractTypeFields, getContractTypes } from '../../helpers/functions.cache.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const success = await updateOccupancyTypeField(request.body, request.session.user);
|
const success = await updateContractTypeField(request.body, request.session.user);
|
||||||
const occupancyTypes = await getContractTypes();
|
const contractTypes = await getContractTypes();
|
||||||
const allContractTypeFields = await getAllContractTypeFields();
|
const allContractTypeFields = await getAllContractTypeFields();
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
occupancyTypes,
|
contractTypes,
|
||||||
allContractTypeFields
|
allContractTypeFields
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1,28 +1,28 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import updateOccupancyTypeField, {
|
import updateContractTypeField, {
|
||||||
type UpdateOccupancyTypeFieldForm
|
type UpdateContractTypeFieldForm
|
||||||
} from '../../database/updateOccupancyTypeField.js'
|
} from '../../database/updateContractTypeField.js'
|
||||||
import {
|
import {
|
||||||
getAllContractTypeFields,
|
getAllContractTypeFields,
|
||||||
getContractTypes
|
getContractTypes
|
||||||
} from '../../helpers/functions.cache.js'
|
} from '../../helpers/functions.cache.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request<unknown, unknown, UpdateContractTypeFieldForm>,
|
||||||
response: Response
|
response: Response
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const success = await updateOccupancyTypeField(
|
const success = await updateContractTypeField(
|
||||||
request.body as UpdateOccupancyTypeFieldForm,
|
request.body,
|
||||||
request.session.user as User
|
request.session.user as User
|
||||||
)
|
)
|
||||||
|
|
||||||
const occupancyTypes = await getContractTypes()
|
const contractTypes = await getContractTypes()
|
||||||
const allContractTypeFields = await getAllContractTypeFields()
|
const allContractTypeFields = await getAllContractTypeFields()
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
success,
|
success,
|
||||||
occupancyTypes,
|
contractTypes,
|
||||||
allContractTypeFields
|
allContractTypeFields
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -23,8 +23,8 @@ function buildEventSummary(milestone) {
|
||||||
? milestone.workOrderMilestoneDescription ?? ''
|
? milestone.workOrderMilestoneDescription ?? ''
|
||||||
: milestone.workOrderMilestoneType ?? '').trim();
|
: milestone.workOrderMilestoneType ?? '').trim();
|
||||||
let occupantCount = 0;
|
let occupantCount = 0;
|
||||||
for (const lotOccupancy of milestone.workOrderLotOccupancies ?? []) {
|
for (const burialSiteContract of milestone.workOrderLotOccupancies ?? []) {
|
||||||
for (const occupant of lotOccupancy.lotOccupancyOccupants ?? []) {
|
for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) {
|
||||||
occupantCount += 1;
|
occupantCount += 1;
|
||||||
if (occupantCount === 1) {
|
if (occupantCount === 1) {
|
||||||
if (summary !== '') {
|
if (summary !== '') {
|
||||||
|
|
@ -59,7 +59,7 @@ function buildEventDescriptionHTML_occupancies(request, milestone) {
|
||||||
for (const occupancy of milestone.workOrderLotOccupancies ?? []) {
|
for (const occupancy of milestone.workOrderLotOccupancies ?? []) {
|
||||||
descriptionHTML += `<tr>
|
descriptionHTML += `<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="${urlRoot}/lotOccupancies/${occupancy.burialSiteContractId}">
|
<a href="${urlRoot}/contracts/${occupancy.burialSiteContractId}">
|
||||||
${escapeHTML(occupancy.occupancyType ?? '')}
|
${escapeHTML(occupancy.occupancyType ?? '')}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
@ -75,7 +75,7 @@ function buildEventDescriptionHTML_occupancies(request, milestone) {
|
||||||
: '(No End Date)'}
|
: '(No End Date)'}
|
||||||
</td>
|
</td>
|
||||||
<td>`;
|
<td>`;
|
||||||
for (const occupant of occupancy.lotOccupancyOccupants ?? []) {
|
for (const occupant of occupancy.burialSiteContractOccupants ?? []) {
|
||||||
descriptionHTML += `${escapeHTML(occupant.lotOccupantType ?? '')}: ${escapeHTML(occupant.occupantName ?? '')} ${escapeHTML(occupant.occupantFamilyName ?? '')}<br />`;
|
descriptionHTML += `${escapeHTML(occupant.lotOccupantType ?? '')}: ${escapeHTML(occupant.occupantName ?? '')} ${escapeHTML(occupant.occupantFamilyName ?? '')}<br />`;
|
||||||
}
|
}
|
||||||
descriptionHTML += '</td></tr>';
|
descriptionHTML += '</td></tr>';
|
||||||
|
|
@ -255,8 +255,8 @@ export default async function handler(request, response) {
|
||||||
// Set organizer / attendees
|
// Set organizer / attendees
|
||||||
if (milestone.workOrderLotOccupancies.length > 0) {
|
if (milestone.workOrderLotOccupancies.length > 0) {
|
||||||
let organizerSet = false;
|
let organizerSet = false;
|
||||||
for (const lotOccupancy of milestone.workOrderLotOccupancies ?? []) {
|
for (const burialSiteContract of milestone.workOrderLotOccupancies ?? []) {
|
||||||
for (const occupant of lotOccupancy.lotOccupancyOccupants ?? []) {
|
for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) {
|
||||||
if (organizerSet) {
|
if (organizerSet) {
|
||||||
calendarEvent.createAttendee({
|
calendarEvent.createAttendee({
|
||||||
name: `${occupant.occupantName ?? ''} ${occupant.occupantFamilyName ?? ''}`,
|
name: `${occupant.occupantName ?? ''} ${occupant.occupantFamilyName ?? ''}`,
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@ function buildEventSummary(milestone: WorkOrderMilestone): string {
|
||||||
|
|
||||||
let occupantCount = 0
|
let occupantCount = 0
|
||||||
|
|
||||||
for (const lotOccupancy of milestone.workOrderLotOccupancies ?? []) {
|
for (const burialSiteContract of milestone.workOrderLotOccupancies ?? []) {
|
||||||
for (const occupant of lotOccupancy.lotOccupancyOccupants ?? []) {
|
for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) {
|
||||||
occupantCount += 1
|
occupantCount += 1
|
||||||
|
|
||||||
if (occupantCount === 1) {
|
if (occupantCount === 1) {
|
||||||
|
|
@ -94,7 +94,7 @@ function buildEventDescriptionHTML_occupancies(
|
||||||
for (const occupancy of milestone.workOrderLotOccupancies ?? []) {
|
for (const occupancy of milestone.workOrderLotOccupancies ?? []) {
|
||||||
descriptionHTML += `<tr>
|
descriptionHTML += `<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="${urlRoot}/lotOccupancies/${occupancy.burialSiteContractId}">
|
<a href="${urlRoot}/contracts/${occupancy.burialSiteContractId}">
|
||||||
${escapeHTML(occupancy.occupancyType ?? '')}
|
${escapeHTML(occupancy.occupancyType ?? '')}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
@ -113,7 +113,7 @@ function buildEventDescriptionHTML_occupancies(
|
||||||
</td>
|
</td>
|
||||||
<td>`
|
<td>`
|
||||||
|
|
||||||
for (const occupant of occupancy.lotOccupancyOccupants ?? []) {
|
for (const occupant of occupancy.burialSiteContractOccupants ?? []) {
|
||||||
descriptionHTML += `${escapeHTML(
|
descriptionHTML += `${escapeHTML(
|
||||||
occupant.lotOccupantType ?? ''
|
occupant.lotOccupantType ?? ''
|
||||||
)}: ${escapeHTML(occupant.occupantName ?? '')} ${escapeHTML(
|
)}: ${escapeHTML(occupant.occupantName ?? '')} ${escapeHTML(
|
||||||
|
|
@ -377,8 +377,8 @@ export default async function handler(
|
||||||
// Set organizer / attendees
|
// Set organizer / attendees
|
||||||
if (milestone.workOrderLotOccupancies!.length > 0) {
|
if (milestone.workOrderLotOccupancies!.length > 0) {
|
||||||
let organizerSet = false
|
let organizerSet = false
|
||||||
for (const lotOccupancy of milestone.workOrderLotOccupancies ?? []) {
|
for (const burialSiteContract of milestone.workOrderLotOccupancies ?? []) {
|
||||||
for (const occupant of lotOccupancy.lotOccupancyOccupants ?? []) {
|
for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) {
|
||||||
if (organizerSet) {
|
if (organizerSet) {
|
||||||
calendarEvent.createAttendee({
|
calendarEvent.createAttendee({
|
||||||
name: `${occupant.occupantName ?? ''} ${
|
name: `${occupant.occupantName ?? ''} ${
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
import getLot from '../../database/getLot.js';
|
import getBurialSite from '../../database/getBurialSite.js';
|
||||||
import getMaps from '../../database/getMaps.js';
|
import getCemeteries from '../../database/getCemeteries.js';
|
||||||
import { getLotStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js';
|
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
||||||
|
import { getBurialSiteStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const lot = await getLot(request.params.lotId);
|
const burialSite = await getBurialSite(request.params.burialSiteId);
|
||||||
if (lot === undefined) {
|
if (burialSite === undefined) {
|
||||||
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=lotIdNotFound`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/?error=burialSiteIdNotFound`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const maps = await getMaps();
|
const cemeteries = await getCemeteries();
|
||||||
const lotTypes = await getBurialSiteTypes();
|
const burialSiteTypes = await getBurialSiteTypes();
|
||||||
const lotStatuses = await getLotStatuses();
|
const burialSiteStatuses = await getBurialSiteStatuses();
|
||||||
response.render('lot-edit', {
|
response.render('burialSite-edit', {
|
||||||
headTitle: lot.lotName,
|
headTitle: burialSite.burialSiteName,
|
||||||
lot,
|
burialSite,
|
||||||
isCreate: false,
|
isCreate: false,
|
||||||
maps,
|
cemeteries,
|
||||||
lotTypes,
|
burialSiteTypes,
|
||||||
lotStatuses
|
burialSiteStatuses
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,36 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import getLot from '../../database/getLot.js'
|
import getBurialSite from '../../database/getBurialSite.js'
|
||||||
import getMaps from '../../database/getMaps.js'
|
import getCemeteries from '../../database/getCemeteries.js'
|
||||||
import { getLotStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js'
|
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
||||||
|
import {
|
||||||
|
getBurialSiteStatuses,
|
||||||
|
getBurialSiteTypes
|
||||||
|
} from '../../helpers/functions.cache.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
response: Response
|
response: Response
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const lot = await getLot(request.params.lotId)
|
const burialSite = await getBurialSite(request.params.burialSiteId)
|
||||||
|
|
||||||
if (lot === undefined) {
|
if (burialSite === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=lotIdNotFound`
|
`${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/?error=burialSiteIdNotFound`
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const maps = await getMaps()
|
const cemeteries = await getCemeteries()
|
||||||
const lotTypes = await getBurialSiteTypes()
|
const burialSiteTypes = await getBurialSiteTypes()
|
||||||
const lotStatuses = await getLotStatuses()
|
const burialSiteStatuses = await getBurialSiteStatuses()
|
||||||
|
|
||||||
response.render('lot-edit', {
|
response.render('burialSite-edit', {
|
||||||
headTitle: lot.lotName,
|
headTitle: burialSite.burialSiteName,
|
||||||
lot,
|
burialSite,
|
||||||
isCreate: false,
|
isCreate: false,
|
||||||
maps,
|
cemeteries,
|
||||||
lotTypes,
|
burialSiteTypes,
|
||||||
lotStatuses
|
burialSiteStatuses
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,27 @@
|
||||||
import getMaps from '../../database/getMaps.js';
|
import getCemeteries from '../../database/getCemeteries.js';
|
||||||
import { getLotStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js';
|
import { getBurialSiteStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js';
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const lot = {
|
const burialSite = {
|
||||||
lotId: -1,
|
burialSiteId: -1,
|
||||||
lotOccupancies: []
|
burialSiteContracts: []
|
||||||
};
|
};
|
||||||
const maps = await getMaps();
|
const cemeteries = await getCemeteries();
|
||||||
if (request.query.cemeteryId !== undefined) {
|
if (request.query.cemeteryId !== undefined) {
|
||||||
const cemeteryId = Number.parseInt(request.query.cemeteryId, 10);
|
const cemeteryId = Number.parseInt(request.query.cemeteryId, 10);
|
||||||
const map = maps.find((possibleMap) => {
|
const cemetery = cemeteries.find((possibleMatch) => cemeteryId === possibleMatch.cemeteryId);
|
||||||
return cemeteryId === possibleMap.cemeteryId;
|
if (cemetery !== undefined) {
|
||||||
});
|
burialSite.cemeteryId = cemetery.cemeteryId;
|
||||||
if (map !== undefined) {
|
burialSite.cemeteryName = cemetery.cemeteryName;
|
||||||
lot.cemeteryId = map.cemeteryId;
|
|
||||||
lot.cemeteryName = map.cemeteryName;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const lotTypes = await getBurialSiteTypes();
|
const burialSiteTypes = await getBurialSiteTypes();
|
||||||
const lotStatuses = await getLotStatuses();
|
const burialSiteStatuses = await getBurialSiteStatuses();
|
||||||
response.render('lot-edit', {
|
response.render('burialSite-edit', {
|
||||||
headTitle: `Create a New ${getConfigProperty('aliases.lot')}`,
|
headTitle: 'Create a New Burial Site',
|
||||||
lot,
|
burialSite,
|
||||||
isCreate: true,
|
isCreate: true,
|
||||||
maps,
|
cemeteries,
|
||||||
lotTypes,
|
burialSiteTypes,
|
||||||
lotStatuses
|
burialSiteStatuses
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,43 +1,45 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import getMaps from '../../database/getMaps.js'
|
import getCemeteries from '../../database/getCemeteries.js'
|
||||||
import { getLotStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js'
|
import {
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
getBurialSiteStatuses,
|
||||||
import type { Lot } from '../../types/recordTypes.js'
|
getBurialSiteTypes
|
||||||
|
} from '../../helpers/functions.cache.js'
|
||||||
|
import type { BurialSite } from '../../types/recordTypes.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
response: Response
|
response: Response
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const lot: Lot = {
|
const burialSite: BurialSite = {
|
||||||
lotId: -1,
|
burialSiteId: -1,
|
||||||
lotOccupancies: []
|
burialSiteContracts: []
|
||||||
}
|
}
|
||||||
|
|
||||||
const maps = await getMaps()
|
const cemeteries = await getCemeteries()
|
||||||
|
|
||||||
if (request.query.cemeteryId !== undefined) {
|
if (request.query.cemeteryId !== undefined) {
|
||||||
const cemeteryId = Number.parseInt(request.query.cemeteryId as string, 10)
|
const cemeteryId = Number.parseInt(request.query.cemeteryId as string, 10)
|
||||||
|
|
||||||
const map = maps.find((possibleMap) => {
|
const cemetery = cemeteries.find(
|
||||||
return cemeteryId === possibleMap.cemeteryId
|
(possibleMatch) => cemeteryId === possibleMatch.cemeteryId
|
||||||
})
|
)
|
||||||
|
|
||||||
if (map !== undefined) {
|
if (cemetery !== undefined) {
|
||||||
lot.cemeteryId = map.cemeteryId
|
burialSite.cemeteryId = cemetery.cemeteryId
|
||||||
lot.cemeteryName = map.cemeteryName
|
burialSite.cemeteryName = cemetery.cemeteryName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const lotTypes = await getBurialSiteTypes()
|
const burialSiteTypes = await getBurialSiteTypes()
|
||||||
const lotStatuses = await getLotStatuses()
|
const burialSiteStatuses = await getBurialSiteStatuses()
|
||||||
|
|
||||||
response.render('lot-edit', {
|
response.render('burialSite-edit', {
|
||||||
headTitle: `Create a New ${getConfigProperty('aliases.lot')}`,
|
headTitle: 'Create a New Burial Site',
|
||||||
lot,
|
burialSite,
|
||||||
isCreate: true,
|
isCreate: true,
|
||||||
maps,
|
cemeteries,
|
||||||
lotTypes,
|
burialSiteTypes,
|
||||||
lotStatuses
|
burialSiteStatuses
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
|
import { getNextBurialSiteId } from '../../helpers/burialSites.helpers.js';
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
||||||
import { getNextLotId } from '../../helpers/functions.lots.js';
|
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const lotId = Number.parseInt(request.params.lotId, 10);
|
const burialSiteId = Number.parseInt(request.params.burialSiteId, 10);
|
||||||
const nextLotId = await getNextLotId(lotId);
|
const nextBurialSiteId = await getNextBurialSiteId(burialSiteId);
|
||||||
if (nextLotId === undefined) {
|
if (nextBurialSiteId === undefined) {
|
||||||
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=noNextLotIdFound`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/?error=noNextBurialSiteIdFound`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/${nextLotId.toString()}`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/${nextBurialSiteId.toString()}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
|
import { getNextBurialSiteId } from '../../helpers/burialSites.helpers.js'
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
||||||
import { getNextLotId } from '../../helpers/functions.lots.js'
|
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
response: Response
|
response: Response
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const lotId = Number.parseInt(request.params.lotId, 10)
|
const burialSiteId = Number.parseInt(request.params.burialSiteId, 10)
|
||||||
|
|
||||||
const nextLotId = await getNextLotId(lotId)
|
const nextBurialSiteId = await getNextBurialSiteId(burialSiteId)
|
||||||
|
|
||||||
if (nextLotId === undefined) {
|
if (nextBurialSiteId === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/lots/?error=noNextLotIdFound`
|
)}/burialSites/?error=noNextBurialSiteIdFound`
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -23,6 +23,6 @@ export default async function handler(
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/lots/${nextLotId.toString()}`
|
)}/burialSites/${nextBurialSiteId.toString()}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
|
import { getPreviousBurialSiteId } from '../../helpers/burialSites.helpers.js';
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
||||||
import { getPreviousLotId } from '../../helpers/functions.lots.js';
|
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const lotId = Number.parseInt(request.params.lotId, 10);
|
const burialSiteId = Number.parseInt(request.params.burialSiteId, 10);
|
||||||
const previousLotId = await getPreviousLotId(lotId);
|
const previousBurialSiteId = await getPreviousBurialSiteId(burialSiteId);
|
||||||
if (previousLotId === undefined) {
|
if (previousBurialSiteId === undefined) {
|
||||||
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=noPreviousLotIdFound`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/?error=noPreviousBurialSiteIdFound`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/${previousLotId.toString()}`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/${previousBurialSiteId.toString()}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
|
import { getPreviousBurialSiteId } from '../../helpers/burialSites.helpers.js'
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
||||||
import { getPreviousLotId } from '../../helpers/functions.lots.js'
|
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
response: Response
|
response: Response
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const lotId = Number.parseInt(request.params.lotId, 10)
|
const burialSiteId = Number.parseInt(request.params.burialSiteId, 10)
|
||||||
|
|
||||||
const previousLotId = await getPreviousLotId(lotId)
|
const previousBurialSiteId = await getPreviousBurialSiteId(burialSiteId)
|
||||||
|
|
||||||
if (previousLotId === undefined) {
|
if (previousBurialSiteId === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/lots/?error=noPreviousLotIdFound`
|
)}/burialSites/?error=noPreviousBurialSiteIdFound`
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -23,6 +23,6 @@ export default async function handler(
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/lots/${previousLotId.toString()}`
|
)}/burialSites/${previousBurialSiteId.toString()}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,14 @@
|
||||||
import getMaps from '../../database/getMaps.js';
|
import getCemeteries from '../../database/getCemeteries.js';
|
||||||
import { getLotStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js';
|
import { getBurialSiteStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js';
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const maps = await getMaps();
|
const cemeteries = await getCemeteries();
|
||||||
const lotTypes = await getBurialSiteTypes();
|
const burialSiteTypes = await getBurialSiteTypes();
|
||||||
const lotStatuses = await getLotStatuses();
|
const burialSiteStatuses = await getBurialSiteStatuses();
|
||||||
response.render('lot-search', {
|
response.render('burialSite-search', {
|
||||||
headTitle: `${getConfigProperty('aliases.lot')} Search`,
|
headTitle: `Burial Site Search`,
|
||||||
maps,
|
cemeteries,
|
||||||
lotTypes,
|
burialSiteTypes,
|
||||||
lotStatuses,
|
burialSiteStatuses,
|
||||||
cemeteryId: request.query.cemeteryId,
|
cemeteryId: request.query.cemeteryId,
|
||||||
burialSiteTypeId: request.query.burialSiteTypeId,
|
burialSiteTypeId: request.query.burialSiteTypeId,
|
||||||
burialSiteStatusId: request.query.burialSiteStatusId
|
burialSiteStatusId: request.query.burialSiteStatusId
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,24 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import getMaps from '../../database/getMaps.js'
|
import getCemeteries from '../../database/getCemeteries.js'
|
||||||
import { getLotStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js'
|
import {
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
getBurialSiteStatuses,
|
||||||
|
getBurialSiteTypes
|
||||||
|
} from '../../helpers/functions.cache.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
response: Response
|
response: Response
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const maps = await getMaps()
|
const cemeteries = await getCemeteries()
|
||||||
const lotTypes = await getBurialSiteTypes()
|
const burialSiteTypes = await getBurialSiteTypes()
|
||||||
const lotStatuses = await getLotStatuses()
|
const burialSiteStatuses = await getBurialSiteStatuses()
|
||||||
|
|
||||||
response.render('lot-search', {
|
response.render('burialSite-search', {
|
||||||
headTitle: `${getConfigProperty('aliases.lot')} Search`,
|
headTitle: `Burial Site Search`,
|
||||||
maps,
|
cemeteries,
|
||||||
lotTypes,
|
burialSiteTypes,
|
||||||
lotStatuses,
|
burialSiteStatuses,
|
||||||
cemeteryId: request.query.cemeteryId,
|
cemeteryId: request.query.cemeteryId,
|
||||||
burialSiteTypeId: request.query.burialSiteTypeId,
|
burialSiteTypeId: request.query.burialSiteTypeId,
|
||||||
burialSiteStatusId: request.query.burialSiteStatusId
|
burialSiteStatusId: request.query.burialSiteStatusId
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
import getLot from '../../database/getLot.js';
|
import getBurialSite from '../../database/getBurialSite.js';
|
||||||
|
import { getNextBurialSiteId, getPreviousBurialSiteId } from '../../helpers/burialSites.helpers.js';
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
||||||
import { getNextLotId, getPreviousLotId } from '../../helpers/functions.lots.js';
|
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const lot = await getLot(request.params.lotId);
|
const burialSite = await getBurialSite(request.params.burialSiteId);
|
||||||
if (lot === undefined) {
|
if (burialSite === undefined) {
|
||||||
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=lotIdNotFound`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/?error=burialSiteIdNotFound`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
response.render('lot-view', {
|
response.render('burialSite-view', {
|
||||||
headTitle: lot.lotName,
|
headTitle: burialSite.burialSiteName,
|
||||||
lot
|
lot: burialSite
|
||||||
});
|
});
|
||||||
response.on('finish', () => {
|
response.on('finish', () => {
|
||||||
void getNextLotId(lot.lotId);
|
void getNextBurialSiteId(burialSite.burialSiteId);
|
||||||
void getPreviousLotId(lot.lotId);
|
void getPreviousBurialSiteId(burialSite.burialSiteId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,32 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import getLot from '../../database/getLot.js'
|
import getBurialSite from '../../database/getBurialSite.js'
|
||||||
|
import {
|
||||||
|
getNextBurialSiteId,
|
||||||
|
getPreviousBurialSiteId
|
||||||
|
} from '../../helpers/burialSites.helpers.js'
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
||||||
import { getNextLotId, getPreviousLotId } from '../../helpers/functions.lots.js'
|
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
response: Response
|
response: Response
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const lot = await getLot(request.params.lotId)
|
const burialSite = await getBurialSite(request.params.burialSiteId)
|
||||||
|
|
||||||
if (lot === undefined) {
|
if (burialSite === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=lotIdNotFound`
|
`${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/?error=burialSiteIdNotFound`
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.render('lot-view', {
|
response.render('burialSite-view', {
|
||||||
headTitle: lot.lotName,
|
headTitle: burialSite.burialSiteName,
|
||||||
lot
|
lot: burialSite
|
||||||
})
|
})
|
||||||
|
|
||||||
response.on('finish', () => {
|
response.on('finish', () => {
|
||||||
void getNextLotId(lot.lotId)
|
void getNextBurialSiteId(burialSite.burialSiteId)
|
||||||
void getPreviousLotId(lot.lotId)
|
void getPreviousBurialSiteId(burialSite.burialSiteId)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import type { Request, Response } from 'express';
|
||||||
|
import { type AddBurialSiteCommentForm } from '../../database/addBurialSiteComment.js';
|
||||||
|
export default function handler(request: Request<unknown, unknown, AddBurialSiteCommentForm>, response: Response): Promise<void>;
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
import addBurialSiteComment from '../../database/addBurialSiteComment.js';
|
||||||
|
import getBurialSiteComments from '../../database/getBurialSiteComments.js';
|
||||||
|
export default async function handler(request, response) {
|
||||||
|
await addBurialSiteComment(request.body, request.session.user);
|
||||||
|
const burialSiteComments = await getBurialSiteComments(request.body.burialSiteId);
|
||||||
|
response.json({
|
||||||
|
success: true,
|
||||||
|
burialSiteComments
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
|
import addBurialSiteComment, {
|
||||||
|
type AddBurialSiteCommentForm
|
||||||
|
} from '../../database/addBurialSiteComment.js'
|
||||||
|
import getBurialSiteComments from '../../database/getBurialSiteComments.js'
|
||||||
|
|
||||||
|
export default async function handler(
|
||||||
|
request: Request<unknown, unknown, AddBurialSiteCommentForm>,
|
||||||
|
response: Response
|
||||||
|
): Promise<void> {
|
||||||
|
await addBurialSiteComment(request.body, request.session.user as User)
|
||||||
|
|
||||||
|
const burialSiteComments = await getBurialSiteComments(
|
||||||
|
request.body.burialSiteId
|
||||||
|
)
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
success: true,
|
||||||
|
burialSiteComments
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
import addLotComment from '../../database/addLotComment.js';
|
|
||||||
import getLotComments from '../../database/getLotComments.js';
|
|
||||||
export default async function handler(request, response) {
|
|
||||||
await addLotComment(request.body, request.session.user);
|
|
||||||
const lotComments = await getLotComments(request.body.lotId);
|
|
||||||
response.json({
|
|
||||||
success: true,
|
|
||||||
lotComments
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
import type { Request, Response } from 'express'
|
|
||||||
|
|
||||||
import addLotComment, {
|
|
||||||
type AddLotCommentForm
|
|
||||||
} from '../../database/addLotComment.js'
|
|
||||||
import getLotComments from '../../database/getLotComments.js'
|
|
||||||
|
|
||||||
export default async function handler(
|
|
||||||
request: Request,
|
|
||||||
response: Response
|
|
||||||
): Promise<void> {
|
|
||||||
await addLotComment(
|
|
||||||
request.body as AddLotCommentForm,
|
|
||||||
request.session.user as User
|
|
||||||
)
|
|
||||||
|
|
||||||
const lotComments = await getLotComments(request.body.lotId as string)
|
|
||||||
|
|
||||||
response.json({
|
|
||||||
success: true,
|
|
||||||
lotComments
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import type { Request, Response } from 'express';
|
||||||
|
import { type AddBurialSiteForm } from '../../database/addBurialSite.js';
|
||||||
|
export default function handler(request: Request<unknown, unknown, AddBurialSiteForm>, response: Response): Promise<void>;
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
import addBurialSite from '../../database/addBurialSite.js';
|
||||||
|
import { clearNextPreviousBurialSiteIdCache } from '../../helpers/burialSites.helpers.js';
|
||||||
|
export default async function handler(request, response) {
|
||||||
|
const burialSiteId = await addBurialSite(request.body, request.session.user);
|
||||||
|
response.json({
|
||||||
|
success: true,
|
||||||
|
burialSiteId
|
||||||
|
});
|
||||||
|
response.on('finish', () => {
|
||||||
|
clearNextPreviousBurialSiteIdCache(-1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
|
import addBurialSite, {
|
||||||
|
type AddBurialSiteForm
|
||||||
|
} from '../../database/addBurialSite.js'
|
||||||
|
import { clearNextPreviousBurialSiteIdCache } from '../../helpers/burialSites.helpers.js'
|
||||||
|
|
||||||
|
export default async function handler(
|
||||||
|
request: Request<unknown, unknown, AddBurialSiteForm>,
|
||||||
|
response: Response
|
||||||
|
): Promise<void> {
|
||||||
|
const burialSiteId = await addBurialSite(
|
||||||
|
request.body,
|
||||||
|
request.session.user as User
|
||||||
|
)
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
success: true,
|
||||||
|
burialSiteId
|
||||||
|
})
|
||||||
|
|
||||||
|
response.on('finish', () => {
|
||||||
|
clearNextPreviousBurialSiteIdCache(-1)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
import addLot from '../../database/addLot.js';
|
|
||||||
import { clearNextPreviousLotIdCache } from '../../helpers/functions.lots.js';
|
|
||||||
export default async function handler(request, response) {
|
|
||||||
const lotId = await addLot(request.body, request.session.user);
|
|
||||||
response.json({
|
|
||||||
success: true,
|
|
||||||
lotId
|
|
||||||
});
|
|
||||||
response.on('finish', () => {
|
|
||||||
clearNextPreviousLotIdCache(-1);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
import type { Request, Response } from 'express'
|
|
||||||
|
|
||||||
import addLot, { type AddLotForm } from '../../database/addLot.js'
|
|
||||||
import { clearNextPreviousLotIdCache } from '../../helpers/functions.lots.js'
|
|
||||||
|
|
||||||
export default async function handler(
|
|
||||||
request: Request,
|
|
||||||
response: Response
|
|
||||||
): Promise<void> {
|
|
||||||
const lotId = await addLot(
|
|
||||||
request.body as AddLotForm,
|
|
||||||
request.session.user as User
|
|
||||||
)
|
|
||||||
|
|
||||||
response.json({
|
|
||||||
success: true,
|
|
||||||
lotId
|
|
||||||
})
|
|
||||||
|
|
||||||
response.on('finish', () => {
|
|
||||||
clearNextPreviousLotIdCache(-1)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
import type { Request, Response } from 'express';
|
||||||
|
export default function handler(request: Request<unknown, unknown, {
|
||||||
|
burialSiteId: string;
|
||||||
|
}>, response: Response): Promise<void>;
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { deleteRecord } from '../../database/deleteRecord.js';
|
||||||
|
import { clearNextPreviousBurialSiteIdCache } from '../../helpers/burialSites.helpers.js';
|
||||||
|
export default async function handler(request, response) {
|
||||||
|
const burialSiteId = Number.parseInt(request.body.burialSiteId, 10);
|
||||||
|
const success = await deleteRecord('BurialSites', burialSiteId, request.session.user);
|
||||||
|
response.json({
|
||||||
|
success
|
||||||
|
});
|
||||||
|
response.on('finish', () => {
|
||||||
|
clearNextPreviousBurialSiteIdCache(burialSiteId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
|
import { deleteRecord } from '../../database/deleteRecord.js'
|
||||||
|
import { clearNextPreviousBurialSiteIdCache } from '../../helpers/burialSites.helpers.js'
|
||||||
|
|
||||||
|
export default async function handler(
|
||||||
|
request: Request<unknown, unknown, { burialSiteId: string }>,
|
||||||
|
response: Response
|
||||||
|
): Promise<void> {
|
||||||
|
const burialSiteId = Number.parseInt(request.body.burialSiteId, 10)
|
||||||
|
|
||||||
|
const success = await deleteRecord(
|
||||||
|
'BurialSites',
|
||||||
|
burialSiteId,
|
||||||
|
request.session.user as User
|
||||||
|
)
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
success
|
||||||
|
})
|
||||||
|
|
||||||
|
response.on('finish', () => {
|
||||||
|
clearNextPreviousBurialSiteIdCache(burialSiteId)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import type { Request, Response } from 'express';
|
||||||
|
export default function handler(request: Request<unknown, unknown, {
|
||||||
|
burialSiteId: string;
|
||||||
|
burialSiteCommentId: string;
|
||||||
|
}>, response: Response): Promise<void>;
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
import { deleteRecord } from '../../database/deleteRecord.js';
|
||||||
|
import getBurialSiteComments from '../../database/getBurialSiteComments.js';
|
||||||
|
export default async function handler(request, response) {
|
||||||
|
const success = await deleteRecord('BurialSiteComments', request.body.burialSiteCommentId, request.session.user);
|
||||||
|
const burialSiteComments = await getBurialSiteComments(request.body.burialSiteId);
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
burialSiteComments
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
|
import { deleteRecord } from '../../database/deleteRecord.js'
|
||||||
|
import getBurialSiteComments from '../../database/getBurialSiteComments.js'
|
||||||
|
|
||||||
|
export default async function handler(
|
||||||
|
request: Request<
|
||||||
|
unknown,
|
||||||
|
unknown,
|
||||||
|
{ burialSiteId: string; burialSiteCommentId: string }
|
||||||
|
>,
|
||||||
|
response: Response
|
||||||
|
): Promise<void> {
|
||||||
|
const success = await deleteRecord(
|
||||||
|
'BurialSiteComments',
|
||||||
|
request.body.burialSiteCommentId,
|
||||||
|
request.session.user as User
|
||||||
|
)
|
||||||
|
|
||||||
|
const burialSiteComments = await getBurialSiteComments(
|
||||||
|
request.body.burialSiteId as string
|
||||||
|
)
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
success,
|
||||||
|
burialSiteComments
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
import { clearNextPreviousLotIdCache } from '../../helpers/functions.lots.js';
|
|
||||||
import { deleteRecord } from '../../database/deleteRecord.js';
|
|
||||||
export default async function handler(request, response) {
|
|
||||||
const lotId = Number.parseInt(request.body.lotId, 10);
|
|
||||||
const success = await deleteRecord('Lots', lotId, request.session.user);
|
|
||||||
response.json({
|
|
||||||
success
|
|
||||||
});
|
|
||||||
response.on('finish', () => {
|
|
||||||
clearNextPreviousLotIdCache(lotId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
import type { Request, Response } from 'express'
|
|
||||||
|
|
||||||
import { clearNextPreviousLotIdCache } from '../../helpers/functions.lots.js'
|
|
||||||
import { deleteRecord } from '../../database/deleteRecord.js'
|
|
||||||
|
|
||||||
export default async function handler(
|
|
||||||
request: Request,
|
|
||||||
response: Response
|
|
||||||
): Promise<void> {
|
|
||||||
const lotId = Number.parseInt(request.body.lotId, 10)
|
|
||||||
|
|
||||||
const success = await deleteRecord('Lots', lotId, request.session.user as User)
|
|
||||||
|
|
||||||
response.json({
|
|
||||||
success
|
|
||||||
})
|
|
||||||
|
|
||||||
response.on('finish', () => {
|
|
||||||
clearNextPreviousLotIdCache(lotId)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
import { deleteRecord } from '../../database/deleteRecord.js';
|
|
||||||
import getLotComments from '../../database/getLotComments.js';
|
|
||||||
export default async function handler(request, response) {
|
|
||||||
const success = await deleteRecord('LotComments', request.body.lotCommentId, request.session.user);
|
|
||||||
const lotComments = await getLotComments(request.body.lotId);
|
|
||||||
response.json({
|
|
||||||
success,
|
|
||||||
lotComments
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
import type { Request, Response } from 'express'
|
|
||||||
|
|
||||||
import { deleteRecord } from '../../database/deleteRecord.js'
|
|
||||||
import getLotComments from '../../database/getLotComments.js'
|
|
||||||
|
|
||||||
export default async function handler(
|
|
||||||
request: Request,
|
|
||||||
response: Response
|
|
||||||
): Promise<void> {
|
|
||||||
const success = await deleteRecord(
|
|
||||||
'LotComments',
|
|
||||||
request.body.lotCommentId as string,
|
|
||||||
request.session.user as User
|
|
||||||
)
|
|
||||||
|
|
||||||
const lotComments = await getLotComments(request.body.lotId as string)
|
|
||||||
|
|
||||||
response.json({
|
|
||||||
success,
|
|
||||||
lotComments
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
import type { Request, Response } from 'express';
|
||||||
|
export default function handler(request: Request<unknown, unknown, {
|
||||||
|
burialSiteTypeId: string;
|
||||||
|
}>, response: Response): Promise<void>;
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
import { getBurialSiteTypeById } from '../../helpers/functions.cache.js';
|
||||||
|
export default async function handler(request, response) {
|
||||||
|
const burialSiteType = await getBurialSiteTypeById(Number.parseInt(request.body.burialSiteTypeId, 10));
|
||||||
|
response.json({
|
||||||
|
burialSiteTypeFields: burialSiteType?.burialSiteTypeFields ?? []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
|
import { getBurialSiteTypeById } from '../../helpers/functions.cache.js'
|
||||||
|
|
||||||
|
export default async function handler(
|
||||||
|
request: Request<unknown, unknown, { burialSiteTypeId: string }>,
|
||||||
|
response: Response
|
||||||
|
): Promise<void> {
|
||||||
|
const burialSiteType = await getBurialSiteTypeById(
|
||||||
|
Number.parseInt(request.body.burialSiteTypeId, 10)
|
||||||
|
)
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
burialSiteTypeFields: burialSiteType?.burialSiteTypeFields ?? []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
import type { Request, Response } from 'express';
|
|
||||||
export default function handler(request: Request, response: Response): Promise<void>;
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
import { getLotTypeById } from '../../helpers/functions.cache.js';
|
|
||||||
export default async function handler(request, response) {
|
|
||||||
const lotType = (await getLotTypeById(Number.parseInt(request.body.burialSiteTypeId, 10)));
|
|
||||||
response.json({
|
|
||||||
BurialSiteTypeFields: lotType.BurialSiteTypeFields
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
import type { Request, Response } from 'express'
|
|
||||||
|
|
||||||
import { getLotTypeById } from '../../helpers/functions.cache.js'
|
|
||||||
|
|
||||||
export default async function handler(
|
|
||||||
request: Request,
|
|
||||||
response: Response
|
|
||||||
): Promise<void> {
|
|
||||||
const lotType = (await getLotTypeById(
|
|
||||||
Number.parseInt(request.body.burialSiteTypeId, 10)
|
|
||||||
))!
|
|
||||||
|
|
||||||
response.json({
|
|
||||||
BurialSiteTypeFields: lotType.BurialSiteTypeFields
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import type { Request, Response } from 'express';
|
||||||
|
import { type GetBurialSitesFilters, type GetBurialSitesOptions } from '../../database/getBurialSites.js';
|
||||||
|
export default function handler(request: Request<unknown, unknown, GetBurialSitesFilters & GetBurialSitesOptions>, response: Response): Promise<void>;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue