fix more test errors
parent
dce2f75a52
commit
0aa050dbae
|
|
@ -1,4 +1,5 @@
|
|||
import { type DateString } from '@cityssm/utils-datetime';
|
||||
import type { PoolConnection } from 'better-sqlite-pool';
|
||||
export interface AddForm {
|
||||
contractId: string | number;
|
||||
deceasedName: string;
|
||||
|
|
@ -11,8 +12,8 @@ export interface AddForm {
|
|||
birthPlace: string;
|
||||
deathDateString: DateString | '';
|
||||
deathPlace: string;
|
||||
deathAge: string;
|
||||
deathAge: string | number;
|
||||
deathAgePeriod: string;
|
||||
intermentContainerTypeId: string | number;
|
||||
}
|
||||
export default function addContractInterment(contractForm: AddForm, user: User): Promise<number>;
|
||||
export default function addContractInterment(contractForm: AddForm, user: User, connectedDatabase?: PoolConnection): Promise<number>;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { dateStringToInteger } from '@cityssm/utils-datetime';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function addContractInterment(contractForm, user) {
|
||||
const database = await acquireConnection();
|
||||
export default async function addContractInterment(contractForm, user, connectedDatabase) {
|
||||
const database = connectedDatabase ?? (await acquireConnection());
|
||||
const maxIntermentNumber = (database
|
||||
.prepare(`select max(intermentNumber) as maxIntermentNumber
|
||||
from ContractInterments
|
||||
|
|
@ -25,6 +25,8 @@ export default async function addContractInterment(contractForm, user) {
|
|||
: dateStringToInteger(contractForm.deathDateString), contractForm.deathPlace, contractForm.intermentContainerTypeId === ''
|
||||
? undefined
|
||||
: contractForm.intermentContainerTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release();
|
||||
}
|
||||
return newIntermentNumber;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { type DateString, dateStringToInteger } from '@cityssm/utils-datetime'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
|
|
@ -14,16 +15,17 @@ export interface AddForm {
|
|||
birthPlace: string
|
||||
deathDateString: DateString | ''
|
||||
deathPlace: string
|
||||
deathAge: string
|
||||
deathAge: string | number
|
||||
deathAgePeriod: string
|
||||
intermentContainerTypeId: string | number
|
||||
}
|
||||
|
||||
export default async function addContractInterment(
|
||||
contractForm: AddForm,
|
||||
user: User
|
||||
user: User,
|
||||
connectedDatabase?: PoolConnection
|
||||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
const database = connectedDatabase ?? (await acquireConnection())
|
||||
|
||||
const maxIntermentNumber = (database
|
||||
.prepare(
|
||||
|
|
@ -73,7 +75,9 @@ export default async function addContractInterment(
|
|||
rightNowMillis
|
||||
)
|
||||
|
||||
if (connectedDatabase === undefined) {
|
||||
database.release()
|
||||
}
|
||||
|
||||
return newIntermentNumber
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { dateToString } from '@cityssm/utils-datetime';
|
||||
import addContract from './addContract.js';
|
||||
import addContractComment from './addContractComment.js';
|
||||
// import addContractOccupant from './addContractOccupant.js'
|
||||
import addContractInterment from './addContractInterment.js';
|
||||
import getContract from './getContract.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function copyContract(oldContractId, user) {
|
||||
|
|
@ -11,7 +11,20 @@ export default async function copyContract(oldContractId, user) {
|
|||
burialSiteId: oldContract.burialSiteId ?? '',
|
||||
contractTypeId: oldContract.contractTypeId,
|
||||
contractStartDateString: dateToString(new Date()),
|
||||
contractEndDateString: ''
|
||||
contractEndDateString: '',
|
||||
purchaserName: oldContract.purchaserName,
|
||||
purchaserAddress1: oldContract.purchaserAddress1,
|
||||
purchaserAddress2: oldContract.purchaserAddress2,
|
||||
purchaserCity: oldContract.purchaserCity,
|
||||
purchaserProvince: oldContract.purchaserProvince,
|
||||
purchaserPostalCode: oldContract.purchaserPostalCode,
|
||||
purchaserPhoneNumber: oldContract.purchaserPhoneNumber,
|
||||
purchaserEmail: oldContract.purchaserEmail,
|
||||
purchaserRelationship: oldContract.purchaserRelationship,
|
||||
funeralHomeId: oldContract.funeralHomeId,
|
||||
funeralDirectorName: oldContract.funeralDirectorName,
|
||||
funeralDateString: oldContract.funeralDateString ?? '',
|
||||
funeralTimeString: oldContract.funeralTimeString ?? ''
|
||||
}, user, database);
|
||||
/*
|
||||
* Copy Fields
|
||||
|
|
@ -27,29 +40,26 @@ export default async function copyContract(oldContractId, user) {
|
|||
.run(newContractId, field.contractTypeFieldId, field.fieldValue, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
}
|
||||
/*
|
||||
* Copy Occupants
|
||||
* Copy Interments
|
||||
*/
|
||||
/*
|
||||
for (const occupant of oldContract.contractOccupants ?? []) {
|
||||
await addContractOccupant(
|
||||
{
|
||||
for (const interment of oldContract.contractInterments ?? []) {
|
||||
await addContractInterment({
|
||||
contractId: newContractId,
|
||||
lotOccupantTypeId: occupant.lotOccupantTypeId!,
|
||||
occupantName: occupant.occupantName!,
|
||||
occupantFamilyName: occupant.occupantFamilyName!,
|
||||
occupantAddress1: occupant.occupantAddress1!,
|
||||
occupantAddress2: occupant.occupantAddress2!,
|
||||
occupantCity: occupant.occupantCity!,
|
||||
occupantProvince: occupant.occupantProvince!,
|
||||
occupantPostalCode: occupant.occupantPostalCode!,
|
||||
occupantPhoneNumber: occupant.occupantPhoneNumber!,
|
||||
occupantEmailAddress: occupant.occupantEmailAddress!
|
||||
},
|
||||
user,
|
||||
database
|
||||
)
|
||||
deceasedName: interment.deceasedName ?? '',
|
||||
deceasedAddress1: interment.deceasedAddress1 ?? '',
|
||||
deceasedAddress2: interment.deceasedAddress2 ?? '',
|
||||
deceasedCity: interment.deceasedCity ?? '',
|
||||
deceasedProvince: interment.deceasedProvince ?? '',
|
||||
deceasedPostalCode: interment.deceasedPostalCode ?? '',
|
||||
birthDateString: interment.birthDateString ?? '',
|
||||
birthPlace: interment.birthPlace ?? '',
|
||||
deathDateString: interment.deathDateString ?? '',
|
||||
deathPlace: interment.deathPlace ?? '',
|
||||
deathAge: interment.deathAge ?? '',
|
||||
deathAgePeriod: interment.deathAgePeriod ?? '',
|
||||
intermentContainerTypeId: interment.intermentContainerTypeId ?? ''
|
||||
}, user, database);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
* Add Comment
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import type { Contract } from '../types/recordTypes.js'
|
|||
|
||||
import addContract from './addContract.js'
|
||||
import addContractComment from './addContractComment.js'
|
||||
// import addContractOccupant from './addContractOccupant.js'
|
||||
import addContractInterment from './addContractInterment.js'
|
||||
import getContract from './getContract.js'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
|
|
@ -14,17 +14,29 @@ export default async function copyContract(
|
|||
): Promise<number> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const oldContract = (await getContract(
|
||||
oldContractId,
|
||||
database
|
||||
)) as Contract
|
||||
const oldContract = (await getContract(oldContractId, database)) as Contract
|
||||
|
||||
const newContractId = await addContract(
|
||||
{
|
||||
burialSiteId: oldContract.burialSiteId ?? '',
|
||||
contractTypeId: oldContract.contractTypeId,
|
||||
contractStartDateString: dateToString(new Date()),
|
||||
contractEndDateString: ''
|
||||
contractEndDateString: '',
|
||||
|
||||
purchaserName: oldContract.purchaserName,
|
||||
purchaserAddress1: oldContract.purchaserAddress1,
|
||||
purchaserAddress2: oldContract.purchaserAddress2,
|
||||
purchaserCity: oldContract.purchaserCity,
|
||||
purchaserProvince: oldContract.purchaserProvince,
|
||||
purchaserPostalCode: oldContract.purchaserPostalCode,
|
||||
purchaserPhoneNumber: oldContract.purchaserPhoneNumber,
|
||||
purchaserEmail: oldContract.purchaserEmail,
|
||||
purchaserRelationship: oldContract.purchaserRelationship,
|
||||
|
||||
funeralHomeId: oldContract.funeralHomeId,
|
||||
funeralDirectorName: oldContract.funeralDirectorName,
|
||||
funeralDateString: oldContract.funeralDateString ?? '',
|
||||
funeralTimeString: oldContract.funeralTimeString ?? ''
|
||||
},
|
||||
user,
|
||||
database
|
||||
|
|
@ -57,30 +69,33 @@ export default async function copyContract(
|
|||
}
|
||||
|
||||
/*
|
||||
* Copy Occupants
|
||||
* Copy Interments
|
||||
*/
|
||||
|
||||
/*
|
||||
for (const occupant of oldContract.contractOccupants ?? []) {
|
||||
await addContractOccupant(
|
||||
for (const interment of oldContract.contractInterments ?? []) {
|
||||
await addContractInterment(
|
||||
{
|
||||
contractId: newContractId,
|
||||
lotOccupantTypeId: occupant.lotOccupantTypeId!,
|
||||
occupantName: occupant.occupantName!,
|
||||
occupantFamilyName: occupant.occupantFamilyName!,
|
||||
occupantAddress1: occupant.occupantAddress1!,
|
||||
occupantAddress2: occupant.occupantAddress2!,
|
||||
occupantCity: occupant.occupantCity!,
|
||||
occupantProvince: occupant.occupantProvince!,
|
||||
occupantPostalCode: occupant.occupantPostalCode!,
|
||||
occupantPhoneNumber: occupant.occupantPhoneNumber!,
|
||||
occupantEmailAddress: occupant.occupantEmailAddress!
|
||||
deceasedName: interment.deceasedName ?? '',
|
||||
deceasedAddress1: interment.deceasedAddress1 ?? '',
|
||||
deceasedAddress2: interment.deceasedAddress2 ?? '',
|
||||
deceasedCity: interment.deceasedCity ?? '',
|
||||
deceasedProvince: interment.deceasedProvince ?? '',
|
||||
deceasedPostalCode: interment.deceasedPostalCode ?? '',
|
||||
|
||||
birthDateString: interment.birthDateString ?? '',
|
||||
birthPlace: interment.birthPlace ?? '',
|
||||
deathDateString: interment.deathDateString ?? '',
|
||||
deathPlace: interment.deathPlace ?? '',
|
||||
|
||||
deathAge: interment.deathAge ?? '',
|
||||
deathAgePeriod: interment.deathAgePeriod ?? '',
|
||||
intermentContainerTypeId: interment.intermentContainerTypeId ?? ''
|
||||
},
|
||||
user,
|
||||
database
|
||||
)
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Add Comment
|
||||
|
|
|
|||
|
|
@ -22,20 +22,20 @@ function buildEventSummary(milestone) {
|
|||
((milestone.workOrderMilestoneTypeId ?? -1) === -1
|
||||
? milestone.workOrderMilestoneDescription ?? ''
|
||||
: milestone.workOrderMilestoneType ?? '').trim();
|
||||
let occupantCount = 0;
|
||||
let intermentCount = 0;
|
||||
for (const contract of milestone.workOrderContracts ?? []) {
|
||||
for (const occupant of contract.contractOccupants ?? []) {
|
||||
occupantCount += 1;
|
||||
if (occupantCount === 1) {
|
||||
for (const interment of contract.contractInterments ?? []) {
|
||||
intermentCount += 1;
|
||||
if (intermentCount === 1) {
|
||||
if (summary !== '') {
|
||||
summary += ': ';
|
||||
}
|
||||
summary += `${occupant.occupantName ?? ''} ${occupant.occupantFamilyName ?? ''}`;
|
||||
summary += interment.deceasedName ?? '';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (occupantCount > 1) {
|
||||
summary += ` plus ${(occupantCount - 1).toString()}`;
|
||||
if (intermentCount > 1) {
|
||||
summary += ` plus ${(intermentCount - 1).toString()}`;
|
||||
}
|
||||
return summary;
|
||||
}
|
||||
|
|
@ -53,30 +53,30 @@ function buildEventDescriptionHTML_occupancies(request, milestone) {
|
|||
<th>Burial Site</th>
|
||||
<th>Start Date</th>
|
||||
<th>End Date</th>
|
||||
<th>${escapeHTML(getConfigProperty('aliases.occupants'))}</th>
|
||||
<th>Interments</th>
|
||||
</tr></thead>
|
||||
<tbody>`;
|
||||
for (const occupancy of milestone.workOrderContracts ?? []) {
|
||||
for (const contract of milestone.workOrderContracts ?? []) {
|
||||
descriptionHTML += `<tr>
|
||||
<td>
|
||||
<a href="${urlRoot}/contracts/${occupancy.contractId}">
|
||||
${escapeHTML(occupancy.contractType ?? '')}
|
||||
<a href="${urlRoot}/contracts/${contract.contractId}">
|
||||
${escapeHTML(contract.contractType ?? '')}
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
${occupancy.burialSiteName ? escapeHTML(occupancy.burialSiteName) : '(Not Set)'}
|
||||
${contract.burialSiteName ? escapeHTML(contract.burialSiteName) : '(Not Set)'}
|
||||
</td>
|
||||
<td>
|
||||
${occupancy.contractStartDateString}
|
||||
${contract.contractStartDateString}
|
||||
</td>
|
||||
<td>
|
||||
${occupancy.contractEndDate
|
||||
? occupancy.contractEndDateString
|
||||
${contract.contractEndDate
|
||||
? contract.contractEndDateString
|
||||
: '(No End Date)'}
|
||||
</td>
|
||||
<td>`;
|
||||
for (const occupant of occupancy.contractOccupants ?? []) {
|
||||
descriptionHTML += `${escapeHTML(occupant.lotOccupantType ?? '')}: ${escapeHTML(occupant.occupantName ?? '')} ${escapeHTML(occupant.occupantFamilyName ?? '')}<br />`;
|
||||
for (const interment of contract.contractInterments ?? []) {
|
||||
descriptionHTML += `${escapeHTML(interment.deceasedName ?? '')}<br />`;
|
||||
}
|
||||
descriptionHTML += '</td></tr>';
|
||||
}
|
||||
|
|
@ -165,6 +165,7 @@ function buildEventLocation(milestone) {
|
|||
}
|
||||
return burialSiteNames.join(', ');
|
||||
}
|
||||
// eslint-disable-next-line complexity
|
||||
export default async function handler(request, response) {
|
||||
const urlRoot = getUrlRoot(request);
|
||||
/*
|
||||
|
|
@ -194,7 +195,7 @@ export default async function handler(request, response) {
|
|||
});
|
||||
if (request.query.workOrderId && workOrderMilestones.length > 0) {
|
||||
calendar.name(`Work Order #${workOrderMilestones[0].workOrderNumber}`);
|
||||
calendar.url(`${urlRoot}/workOrders/${workOrderMilestones[0].workOrderId?.toString()}`);
|
||||
calendar.url(`${urlRoot}/workOrders/${workOrderMilestones[0].workOrderId.toString()}`);
|
||||
}
|
||||
calendar.prodId({
|
||||
company: calendarCompany,
|
||||
|
|
@ -206,7 +207,7 @@ export default async function handler(request, response) {
|
|||
for (const milestone of workOrderMilestones) {
|
||||
const milestoneTimePieces = `${milestone.workOrderMilestoneDateString} ${milestone.workOrderMilestoneTimeString}`.split(timeStringSplitRegex);
|
||||
const milestoneDate = new Date(Number.parseInt(milestoneTimePieces[0], 10), Number.parseInt(milestoneTimePieces[1], 10) - 1, Number.parseInt(milestoneTimePieces[2], 10), Number.parseInt(milestoneTimePieces[3], 10), Number.parseInt(milestoneTimePieces[4], 10));
|
||||
const milestoneEndDate = new Date(milestoneDate.getTime());
|
||||
const milestoneEndDate = new Date(milestoneDate);
|
||||
milestoneEndDate.setHours(milestoneEndDate.getHours() + 1);
|
||||
// Build summary (title in Outlook)
|
||||
const summary = buildEventSummary(milestone);
|
||||
|
|
@ -250,16 +251,16 @@ export default async function handler(request, response) {
|
|||
if (milestone.workOrderContracts.length > 0) {
|
||||
let organizerSet = false;
|
||||
for (const contract of milestone.workOrderContracts ?? []) {
|
||||
for (const occupant of contract.contractOccupants ?? []) {
|
||||
for (const interment of contract.contractInterments ?? []) {
|
||||
if (organizerSet) {
|
||||
calendarEvent.createAttendee({
|
||||
name: `${occupant.occupantName ?? ''} ${occupant.occupantFamilyName ?? ''}`,
|
||||
name: interment.deceasedName ?? '',
|
||||
email: getConfigProperty('settings.workOrders.calendarEmailAddress')
|
||||
});
|
||||
}
|
||||
else {
|
||||
calendarEvent.organizer({
|
||||
name: `${occupant.occupantName ?? ''} ${occupant.occupantFamilyName ?? ''}`,
|
||||
name: interment.deceasedName ?? '',
|
||||
email: getConfigProperty('settings.workOrders.calendarEmailAddress')
|
||||
});
|
||||
organizerSet = true;
|
||||
|
|
|
|||
|
|
@ -45,24 +45,24 @@ function buildEventSummary(milestone: WorkOrderMilestone): string {
|
|||
: milestone.workOrderMilestoneType ?? ''
|
||||
).trim()
|
||||
|
||||
let occupantCount = 0
|
||||
let intermentCount = 0
|
||||
|
||||
for (const contract of milestone.workOrderContracts ?? []) {
|
||||
for (const occupant of contract.contractOccupants ?? []) {
|
||||
occupantCount += 1
|
||||
for (const interment of contract.contractInterments ?? []) {
|
||||
intermentCount += 1
|
||||
|
||||
if (occupantCount === 1) {
|
||||
if (intermentCount === 1) {
|
||||
if (summary !== '') {
|
||||
summary += ': '
|
||||
}
|
||||
|
||||
summary += `${occupant.occupantName ?? ''} ${occupant.occupantFamilyName ?? ''}`
|
||||
summary += interment.deceasedName ?? ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (occupantCount > 1) {
|
||||
summary += ` plus ${(occupantCount - 1).toString()}`
|
||||
if (intermentCount > 1) {
|
||||
summary += ` plus ${(intermentCount - 1).toString()}`
|
||||
}
|
||||
|
||||
return summary
|
||||
|
|
@ -87,38 +87,34 @@ function buildEventDescriptionHTML_occupancies(
|
|||
<th>Burial Site</th>
|
||||
<th>Start Date</th>
|
||||
<th>End Date</th>
|
||||
<th>${escapeHTML(getConfigProperty('aliases.occupants'))}</th>
|
||||
<th>Interments</th>
|
||||
</tr></thead>
|
||||
<tbody>`
|
||||
|
||||
for (const occupancy of milestone.workOrderContracts ?? []) {
|
||||
for (const contract of milestone.workOrderContracts ?? []) {
|
||||
descriptionHTML += `<tr>
|
||||
<td>
|
||||
<a href="${urlRoot}/contracts/${occupancy.contractId}">
|
||||
${escapeHTML(occupancy.contractType ?? '')}
|
||||
<a href="${urlRoot}/contracts/${contract.contractId}">
|
||||
${escapeHTML(contract.contractType ?? '')}
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
${occupancy.burialSiteName ? escapeHTML(occupancy.burialSiteName) : '(Not Set)'}
|
||||
${contract.burialSiteName ? escapeHTML(contract.burialSiteName) : '(Not Set)'}
|
||||
</td>
|
||||
<td>
|
||||
${occupancy.contractStartDateString}
|
||||
${contract.contractStartDateString}
|
||||
</td>
|
||||
<td>
|
||||
${
|
||||
occupancy.contractEndDate
|
||||
? occupancy.contractEndDateString
|
||||
contract.contractEndDate
|
||||
? contract.contractEndDateString
|
||||
: '(No End Date)'
|
||||
}
|
||||
</td>
|
||||
<td>`
|
||||
|
||||
for (const occupant of occupancy.contractOccupants ?? []) {
|
||||
descriptionHTML += `${escapeHTML(
|
||||
occupant.lotOccupantType ?? ''
|
||||
)}: ${escapeHTML(occupant.occupantName ?? '')} ${escapeHTML(
|
||||
occupant.occupantFamilyName ?? ''
|
||||
)}<br />`
|
||||
for (const interment of contract.contractInterments ?? []) {
|
||||
descriptionHTML += `${escapeHTML(interment.deceasedName ?? '')}<br />`
|
||||
}
|
||||
|
||||
descriptionHTML += '</td></tr>'
|
||||
|
|
@ -246,6 +242,7 @@ function buildEventLocation(milestone: WorkOrderMilestone): string {
|
|||
return burialSiteNames.join(', ')
|
||||
}
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
export default async function handler(
|
||||
request: Request,
|
||||
response: Response
|
||||
|
|
@ -286,7 +283,7 @@ export default async function handler(
|
|||
if (request.query.workOrderId && workOrderMilestones.length > 0) {
|
||||
calendar.name(`Work Order #${workOrderMilestones[0].workOrderNumber}`)
|
||||
calendar.url(
|
||||
`${urlRoot}/workOrders/${workOrderMilestones[0].workOrderId?.toString()}`
|
||||
`${urlRoot}/workOrders/${workOrderMilestones[0].workOrderId.toString()}`
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -312,7 +309,7 @@ export default async function handler(
|
|||
Number.parseInt(milestoneTimePieces[4], 10)
|
||||
)
|
||||
|
||||
const milestoneEndDate = new Date(milestoneDate.getTime())
|
||||
const milestoneEndDate = new Date(milestoneDate)
|
||||
milestoneEndDate.setHours(milestoneEndDate.getHours() + 1)
|
||||
|
||||
// Build summary (title in Outlook)
|
||||
|
|
@ -372,21 +369,17 @@ export default async function handler(
|
|||
if (milestone.workOrderContracts!.length > 0) {
|
||||
let organizerSet = false
|
||||
for (const contract of milestone.workOrderContracts ?? []) {
|
||||
for (const occupant of contract.contractOccupants ?? []) {
|
||||
for (const interment of contract.contractInterments ?? []) {
|
||||
if (organizerSet) {
|
||||
calendarEvent.createAttendee({
|
||||
name: `${occupant.occupantName ?? ''} ${
|
||||
occupant.occupantFamilyName ?? ''
|
||||
}`,
|
||||
name: interment.deceasedName ?? '',
|
||||
email: getConfigProperty(
|
||||
'settings.workOrders.calendarEmailAddress'
|
||||
)
|
||||
})
|
||||
} else {
|
||||
calendarEvent.organizer({
|
||||
name: `${occupant.occupantName ?? ''} ${
|
||||
occupant.occupantFamilyName ?? ''
|
||||
}`,
|
||||
name: interment.deceasedName ?? '',
|
||||
email: getConfigProperty(
|
||||
'settings.workOrders.calendarEmailAddress'
|
||||
)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
const workOrderMilestoneDateFilterElement = workOrderSearchFiltersFormElement.querySelector('#searchFilter--workOrderMilestoneDateFilter');
|
||||
const workOrderMilestoneDateStringElement = workOrderSearchFiltersFormElement.querySelector('#searchFilter--workOrderMilestoneDateString');
|
||||
const milestoneCalendarContainerElement = document.querySelector('#container--milestoneCalendar');
|
||||
// eslint-disable-next-line complexity
|
||||
function renderMilestones(workOrderMilestones) {
|
||||
if (workOrderMilestones.length === 0) {
|
||||
milestoneCalendarContainerElement.innerHTML = `<div class="message is-info">
|
||||
|
|
@ -41,26 +42,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
panelBlockElement.classList.add('has-background-warning-light');
|
||||
}
|
||||
let contractHTML = '';
|
||||
for (const lot of milestone.workOrderLots ?? []) {
|
||||
for (const burialSite of milestone.workOrderBurialSites ?? []) {
|
||||
contractHTML += `<li class="has-tooltip-left"
|
||||
data-tooltip="${cityssm.escapeHTML(lot.cemeteryName ?? '')}">
|
||||
data-tooltip="${cityssm.escapeHTML(burialSite.cemeteryName ?? '')}">
|
||||
<span class="fa-li">
|
||||
<i class="fas fa-vector-square"
|
||||
aria-label="${sunrise.escapedAliases.Lot}"></i>
|
||||
aria-label="Burial Site"></i>
|
||||
</span>
|
||||
${cityssm.escapeHTML(lot.burialSiteName ?? '')}
|
||||
${cityssm.escapeHTML(burialSite.burialSiteName ?? '')}
|
||||
</li>`;
|
||||
}
|
||||
for (const contract of milestone.workOrderContracts ?? []) {
|
||||
for (const occupant of contract.contractOccupants ?? []) {
|
||||
for (const interment of contract.contractInterments ?? []) {
|
||||
contractHTML += `<li class="has-tooltip-left"
|
||||
data-tooltip="${cityssm.escapeHTML(occupant.lotOccupantType ?? '')}">
|
||||
data-tooltip="Interment">
|
||||
<span class="fa-li">
|
||||
<i class="fas fa-user"
|
||||
aria-label="${sunrise.escapedAliases.Occupancy}"></i>
|
||||
aria-label="Interment"></i>
|
||||
</span>
|
||||
${cityssm.escapeHTML(occupant.occupantName ?? '')}
|
||||
${cityssm.escapeHTML(occupant.occupantFamilyName ?? '')}
|
||||
${cityssm.escapeHTML(interment.deceasedName ?? '')}
|
||||
</li>`;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ declare const exports: Record<string, unknown>
|
|||
'#container--milestoneCalendar'
|
||||
) as HTMLElement
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
function renderMilestones(workOrderMilestones: WorkOrderMilestone[]): void {
|
||||
if (workOrderMilestones.length === 0) {
|
||||
milestoneCalendarContainerElement.innerHTML = `<div class="message is-info">
|
||||
|
|
@ -80,29 +81,26 @@ declare const exports: Record<string, unknown>
|
|||
|
||||
let contractHTML = ''
|
||||
|
||||
for (const lot of milestone.workOrderLots ?? []) {
|
||||
for (const burialSite of milestone.workOrderBurialSites ?? []) {
|
||||
contractHTML += `<li class="has-tooltip-left"
|
||||
data-tooltip="${cityssm.escapeHTML(lot.cemeteryName ?? '')}">
|
||||
data-tooltip="${cityssm.escapeHTML(burialSite.cemeteryName ?? '')}">
|
||||
<span class="fa-li">
|
||||
<i class="fas fa-vector-square"
|
||||
aria-label="${sunrise.escapedAliases.Lot}"></i>
|
||||
aria-label="Burial Site"></i>
|
||||
</span>
|
||||
${cityssm.escapeHTML(lot.burialSiteName ?? '')}
|
||||
${cityssm.escapeHTML(burialSite.burialSiteName ?? '')}
|
||||
</li>`
|
||||
}
|
||||
|
||||
for (const contract of milestone.workOrderContracts ?? []) {
|
||||
for (const occupant of contract.contractOccupants ?? []) {
|
||||
for (const interment of contract.contractInterments ?? []) {
|
||||
contractHTML += `<li class="has-tooltip-left"
|
||||
data-tooltip="${cityssm.escapeHTML(
|
||||
occupant.lotOccupantType ?? ''
|
||||
)}">
|
||||
data-tooltip="Interment">
|
||||
<span class="fa-li">
|
||||
<i class="fas fa-user"
|
||||
aria-label="${sunrise.escapedAliases.Occupancy}"></i>
|
||||
aria-label="Interment"></i>
|
||||
</span>
|
||||
${cityssm.escapeHTML(occupant.occupantName ?? '')}
|
||||
${cityssm.escapeHTML(occupant.occupantFamilyName ?? '')}
|
||||
${cityssm.escapeHTML(interment.deceasedName ?? '')}
|
||||
</li>`
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ describe('functions.cache', () => {
|
|||
});
|
||||
});
|
||||
describe('functions.sqlFilters', () => {
|
||||
describe('LotName filter', () => {
|
||||
describe('BurialSiteName filter', () => {
|
||||
it('returns startsWith filter', () => {
|
||||
const filter = sqlFilterFunctions.getBurialSiteNameWhereClause('TEST1 TEST2', 'startsWith', 'l');
|
||||
assert.strictEqual(filter.sqlWhereClause, " and l.burialSiteName like ? || '%'");
|
||||
|
|
@ -167,11 +167,11 @@ describe('functions.sqlFilters', () => {
|
|||
assert.strictEqual(filter.sqlParameters.length, 0);
|
||||
});
|
||||
});
|
||||
describe('OccupantName filter', () => {
|
||||
describe('DeceasedName filter', () => {
|
||||
it('returns filter', () => {
|
||||
const filter = sqlFilterFunctions.getDeceasedNameWhereClause('TEST1 TEST2', 'o');
|
||||
assert.strictEqual(filter.sqlWhereClause, ' and (instr(lower(o.occupantName), ?) or instr(lower(o.occupantFamilyName), ?)) and (instr(lower(o.occupantName), ?) or instr(lower(o.occupantFamilyName), ?))');
|
||||
assert.ok(filter.sqlParameters.length === 4);
|
||||
assert.strictEqual(filter.sqlWhereClause, ' and instr(lower(o.deceasedName), ?) and instr(lower(o.deceasedName), ?)');
|
||||
assert.ok(filter.sqlParameters.length === 2);
|
||||
assert.ok(filter.sqlParameters.includes('test1'));
|
||||
assert.ok(filter.sqlParameters.includes('test2'));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ describe('functions.cache', () => {
|
|||
})
|
||||
|
||||
describe('functions.sqlFilters', () => {
|
||||
describe('LotName filter', () => {
|
||||
describe('BurialSiteName filter', () => {
|
||||
it('returns startsWith filter', () => {
|
||||
const filter = sqlFilterFunctions.getBurialSiteNameWhereClause(
|
||||
'TEST1 TEST2',
|
||||
|
|
@ -282,7 +282,7 @@ describe('functions.sqlFilters', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('OccupantName filter', () => {
|
||||
describe('DeceasedName filter', () => {
|
||||
it('returns filter', () => {
|
||||
const filter = sqlFilterFunctions.getDeceasedNameWhereClause(
|
||||
'TEST1 TEST2',
|
||||
|
|
@ -291,10 +291,10 @@ describe('functions.sqlFilters', () => {
|
|||
|
||||
assert.strictEqual(
|
||||
filter.sqlWhereClause,
|
||||
' and (instr(lower(o.occupantName), ?) or instr(lower(o.occupantFamilyName), ?)) and (instr(lower(o.occupantName), ?) or instr(lower(o.occupantFamilyName), ?))'
|
||||
' and instr(lower(o.deceasedName), ?) and instr(lower(o.deceasedName), ?)'
|
||||
)
|
||||
|
||||
assert.ok(filter.sqlParameters.length === 4)
|
||||
assert.ok(filter.sqlParameters.length === 2)
|
||||
|
||||
assert.ok(filter.sqlParameters.includes('test1'))
|
||||
assert.ok(filter.sqlParameters.includes('test2'))
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { DateString, TimeString } from "@cityssm/utils-datetime";
|
||||
export interface Record {
|
||||
recordCreate_userName?: string;
|
||||
recordCreate_timeMillis?: number;
|
||||
|
|
@ -193,10 +194,10 @@ export interface ContractInterment extends Record {
|
|||
deceasedProvince?: string;
|
||||
deceasedPostalCode?: string;
|
||||
birthDate?: number;
|
||||
birthDateString?: string;
|
||||
birthDateString?: DateString;
|
||||
birthPlace?: string;
|
||||
deathDate?: number;
|
||||
deathDateString?: string;
|
||||
deathDateString?: DateString;
|
||||
deathPlace?: string;
|
||||
deathAge?: number;
|
||||
deathAgePeriod?: string;
|
||||
|
|
@ -256,9 +257,9 @@ export interface Contract extends Record {
|
|||
funeralHomeProvince?: string;
|
||||
funeralHomePostalCode?: string;
|
||||
funeralDate?: number;
|
||||
funeralDateString?: string;
|
||||
funeralDateString?: DateString;
|
||||
funeralTime?: number;
|
||||
funeralTimeString?: string;
|
||||
funeralTimeString?: TimeString;
|
||||
committalTypeId?: number;
|
||||
committalType?: string;
|
||||
contractFields?: ContractField[];
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { DateString, TimeString } from "@cityssm/utils-datetime"
|
||||
|
||||
export interface Record {
|
||||
recordCreate_userName?: string
|
||||
recordCreate_timeMillis?: number
|
||||
|
|
@ -247,11 +249,11 @@ export interface ContractInterment extends Record {
|
|||
deceasedPostalCode?: string
|
||||
|
||||
birthDate?: number
|
||||
birthDateString?: string
|
||||
birthDateString?: DateString
|
||||
birthPlace?: string
|
||||
|
||||
deathDate?: number
|
||||
deathDateString?: string
|
||||
deathDateString?: DateString
|
||||
deathPlace?: string
|
||||
deathAge?: number
|
||||
deathAgePeriod?: string
|
||||
|
|
@ -328,9 +330,9 @@ export interface Contract extends Record {
|
|||
funeralHomePostalCode?: string
|
||||
|
||||
funeralDate?: number
|
||||
funeralDateString?: string
|
||||
funeralDateString?: DateString
|
||||
funeralTime?: number
|
||||
funeralTimeString?: string
|
||||
funeralTimeString?: TimeString
|
||||
committalTypeId?: number
|
||||
committalType?: string
|
||||
|
||||
|
|
|
|||
|
|
@ -66,30 +66,24 @@
|
|||
<table class="table is-fullwidth">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= configFunctions.getConfigProperty("aliases.occupant") %> Type</th>
|
||||
<th><%= configFunctions.getConfigProperty("aliases.occupant") %></th>
|
||||
<th>Interment</th>
|
||||
<th>Address</th>
|
||||
<th>Phone Number</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% for (const contractOccupant of contract.contractOccupants) { %>
|
||||
<% for (const contractInterment of contract.contractInterments) { %>
|
||||
<tr>
|
||||
<td><%= contractOccupant.lotOccupantType %></td>
|
||||
<td><%= contractOccupant.occupantName %> <%= contractOccupant.occupantFamilyName %></td>
|
||||
<td><%= contractInterment.deceasedName %></td>
|
||||
<td>
|
||||
<%= contractOccupant.occupantAddress1 %><br />
|
||||
<% if (contractOccupant.occupantAddress2 && contractOccupant.occupantAddress2 !== "") { %>
|
||||
<%= contractOccupant.occupantAddress2 %><br />
|
||||
<%= contractInterment.deceasedAddress1 %><br />
|
||||
<% if (contractInterment.deceasedAddress2 && contractInterment.deceasedAddress2 !== "") { %>
|
||||
<%= contractInterment.deceasedAddress2 %><br />
|
||||
<% } %>
|
||||
<% if (contractOccupant.occupantCity) { %>
|
||||
<%= contractOccupant.occupantCity %>,
|
||||
<% if (contractInterment.deceasedCity) { %>
|
||||
<%= contractInterment.deceasedCity %>,
|
||||
<% } %>
|
||||
<%= contractOccupant.occupantProvince %><br />
|
||||
<%= contractOccupant.occupantPostalCode %>
|
||||
</td>
|
||||
<td>
|
||||
<%= contractOccupant.occupantPhoneNumber %>
|
||||
<%= contractInterment.deceasedProvince %><br />
|
||||
<%= contractInterment.deceasedPostalCode %>
|
||||
</td>
|
||||
</tr>
|
||||
<% } %>
|
||||
|
|
|
|||
Loading…
Reference in New Issue