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