refactoring contracts

deepsource-autofix-76c6eb20
Dan Gowans 2025-03-04 15:45:10 -05:00
parent 44119638c2
commit 48262b2d92
59 changed files with 3313 additions and 2637 deletions

View File

@ -1,21 +1,35 @@
import { type DateString } from '@cityssm/utils-datetime';
import type { PoolConnection } from 'better-sqlite-pool'; import type { PoolConnection } from 'better-sqlite-pool';
export interface AddContractForm { export interface AddContractForm {
contractTypeId: string | number; contractTypeId: string | number;
burialSiteId: string | number; burialSiteId: string | number;
contractStartDateString: string; contractStartDateString: DateString | '';
contractEndDateString: string; contractEndDateString: DateString | '';
contractTypeFieldIds?: string; contractTypeFieldIds?: string;
[fieldValue_contractTypeFieldId: string]: unknown; [fieldValue_contractTypeFieldId: `fieldValue_${string}`]: unknown;
lotOccupantTypeId?: string; purchaserName?: string;
occupantName?: string; purchaserAddress1?: string;
occupantFamilyName?: string; purchaserAddress2?: string;
occupantAddress1?: string; purchaserCity?: string;
occupantAddress2?: string; purchaserProvince?: string;
occupantCity?: string; purchaserPostalCode?: string;
occupantProvince?: string; purchaserPhoneNumber?: string;
occupantPostalCode?: string; purchaserEmail?: string;
occupantPhoneNumber?: string; purchaserRelationship?: string;
occupantEmailAddress?: string; funeralHomeId?: string | number;
occupantComment?: string; funeralDirectorName?: string;
deceasedName?: string;
deceasedAddress1?: string;
deceasedAddress2?: string;
deceasedCity?: string;
deceasedProvince?: string;
deceasedPostalCode?: string;
birthDateString?: DateString | '';
birthPlace?: string;
deathDateString?: DateString | '';
deathPlace?: string;
intermentDateString?: DateString | '';
intermentContainerTypeId?: string | number;
intermentCommittalTypeId?: string | number;
} }
export default function addContract(addForm: AddContractForm, user: User, connectedDatabase?: PoolConnection): Promise<number>; export default function addContract(addForm: AddContractForm, user: User, connectedDatabase?: PoolConnection): Promise<number>;

View File

@ -1,21 +1,29 @@
import { dateStringToInteger } from '@cityssm/utils-datetime'; import { dateStringToInteger } from '@cityssm/utils-datetime';
import addOrUpdateContractField from './addOrUpdateContractField.js'; import addOrUpdateContractField from './addOrUpdateContractField.js';
import { acquireConnection } from './pool.js'; import { acquireConnection } from './pool.js';
// eslint-disable-next-line complexity
export default async function addContract(addForm, user, connectedDatabase) { export default async function addContract(addForm, user, connectedDatabase) {
const database = connectedDatabase ?? (await acquireConnection()); const database = connectedDatabase ?? (await acquireConnection());
const rightNowMillis = Date.now(); const rightNowMillis = Date.now();
const contractStartDate = dateStringToInteger(addForm.contractStartDateString); const contractStartDate = dateStringToInteger(addForm.contractStartDateString);
const result = database const result = database
.prepare(`insert into Contracts ( .prepare(`insert into Contracts (
contractTypeId, lotId, contractTypeId, burialSiteId,
contractStartDate, contractEndDate, contractStartDate, contractEndDate,
purchaserName, purchaserAddress1, purchaserAddress2,
purchaserCity, purchaserProvince, purchaserPostalCode,
purchaserPhoneNumber, purchaserEmail, purchaserRelationship,
funeralHomeId, funeralDirectorName,
recordCreate_userName, recordCreate_timeMillis, recordCreate_userName, recordCreate_timeMillis,
recordUpdate_userName, recordUpdate_timeMillis) recordUpdate_userName, recordUpdate_timeMillis)
values (?, ?, ?, ?, ?, ?, ?, ?)`) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
.run(addForm.contractTypeId, addForm.burialSiteId === '' ? undefined : addForm.burialSiteId, contractStartDate, addForm.contractEndDateString === '' .run(addForm.contractTypeId, addForm.burialSiteId === '' ? undefined : addForm.burialSiteId, contractStartDate, addForm.contractEndDateString === ''
? undefined ? undefined
: dateStringToInteger(addForm.contractEndDateString), user.userName, rightNowMillis, user.userName, rightNowMillis); : dateStringToInteger(addForm.contractEndDateString), addForm.purchaserName ?? '', addForm.purchaserAddress1 ?? '', addForm.purchaserAddress2 ?? '', addForm.purchaserCity ?? '', addForm.purchaserProvince ?? '', addForm.purchaserPostalCode ?? '', addForm.purchaserPhoneNumber ?? '', addForm.purchaserEmail ?? '', addForm.purchaserRelationship ?? '', addForm.funeralHomeId === '' ? undefined : addForm.funeralHomeId, addForm.funeralDirectorName ?? '', user.userName, rightNowMillis, user.userName, rightNowMillis);
const contractId = result.lastInsertRowid; const contractId = result.lastInsertRowid;
/*
* Add contract fields
*/
const contractTypeFieldIds = (addForm.contractTypeFieldIds ?? '').split(','); const contractTypeFieldIds = (addForm.contractTypeFieldIds ?? '').split(',');
for (const contractTypeFieldId of contractTypeFieldIds) { for (const contractTypeFieldId of contractTypeFieldIds) {
const fieldValue = addForm[`fieldValue_${contractTypeFieldId}`]; const fieldValue = addForm[`fieldValue_${contractTypeFieldId}`];
@ -27,6 +35,34 @@ export default async function addContract(addForm, user, connectedDatabase) {
}, user, database); }, user, database);
} }
} }
/*
* Add deceased information
*/
if ((addForm.deceasedName ?? '') !== '') {
database
.prepare(`insert into ContractInterments (
contractId, intermentNumber,
deceasedName, deceasedAddress1, deceasedAddress2,
deceasedCity, deceasedProvince, deceasedPostalCode,
birthDate, deathDate,
birthPlace, deathPlace,
intermentDate,
intermentContainerTypeId, intermentCommittalTypeId,
recordCreate_userName, recordCreate_timeMillis,
recordUpdate_userName, recordUpdate_timeMillis)
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
.run(contractId, 1, addForm.deceasedName ?? '', addForm.deceasedAddress1 ?? '', addForm.deceasedAddress2 ?? '', addForm.deceasedCity ?? '', addForm.deceasedProvince ?? '', addForm.deceasedPostalCode ?? '', addForm.birthDateString === ''
? undefined
: dateStringToInteger(addForm.birthDateString), addForm.deathDateString === ''
? undefined
: dateStringToInteger(addForm.deathDateString), addForm.birthPlace ?? '', addForm.deathPlace ?? '', addForm.intermentDateString === ''
? undefined
: dateStringToInteger(addForm.intermentDateString), addForm.intermentContainerTypeId === ''
? undefined
: addForm.intermentContainerTypeId, addForm.intermentCommittalTypeId === ''
? undefined
: addForm.intermentCommittalTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis);
}
if (connectedDatabase === undefined) { if (connectedDatabase === undefined) {
database.release(); database.release();
} }

View File

@ -1,4 +1,7 @@
import { type DateString, dateStringToInteger } from '@cityssm/utils-datetime' import {
type DateString,
dateStringToInteger
} from '@cityssm/utils-datetime'
import type { PoolConnection } from 'better-sqlite-pool' import type { PoolConnection } from 'better-sqlite-pool'
import addOrUpdateContractField from './addOrUpdateContractField.js' import addOrUpdateContractField from './addOrUpdateContractField.js'
@ -8,25 +11,42 @@ export interface AddContractForm {
contractTypeId: string | number contractTypeId: string | number
burialSiteId: string | number burialSiteId: string | number
contractStartDateString: string contractStartDateString: DateString | ''
contractEndDateString: string contractEndDateString: DateString | ''
contractTypeFieldIds?: string contractTypeFieldIds?: string
[fieldValue_contractTypeFieldId: string]: unknown [fieldValue_contractTypeFieldId: `fieldValue_${string}`]: unknown
lotOccupantTypeId?: string purchaserName?: string
occupantName?: string purchaserAddress1?: string
occupantFamilyName?: string purchaserAddress2?: string
occupantAddress1?: string purchaserCity?: string
occupantAddress2?: string purchaserProvince?: string
occupantCity?: string purchaserPostalCode?: string
occupantProvince?: string purchaserPhoneNumber?: string
occupantPostalCode?: string purchaserEmail?: string
occupantPhoneNumber?: string purchaserRelationship?: string
occupantEmailAddress?: string
occupantComment?: string funeralHomeId?: string | number
funeralDirectorName?: string
deceasedName?: string
deceasedAddress1?: string
deceasedAddress2?: string
deceasedCity?: string
deceasedProvince?: string
deceasedPostalCode?: string
birthDateString?: DateString | ''
birthPlace?: string
deathDateString?: DateString | ''
deathPlace?: string
intermentDateString?: DateString | ''
intermentContainerTypeId?: string | number
intermentCommittalTypeId?: string | number
} }
// eslint-disable-next-line complexity
export default async function addContract( export default async function addContract(
addForm: AddContractForm, addForm: AddContractForm,
user: User, user: User,
@ -43,11 +63,15 @@ export default async function addContract(
const result = database const result = database
.prepare( .prepare(
`insert into Contracts ( `insert into Contracts (
contractTypeId, lotId, contractTypeId, burialSiteId,
contractStartDate, contractEndDate, contractStartDate, contractEndDate,
purchaserName, purchaserAddress1, purchaserAddress2,
purchaserCity, purchaserProvince, purchaserPostalCode,
purchaserPhoneNumber, purchaserEmail, purchaserRelationship,
funeralHomeId, funeralDirectorName,
recordCreate_userName, recordCreate_timeMillis, recordCreate_userName, recordCreate_timeMillis,
recordUpdate_userName, recordUpdate_timeMillis) recordUpdate_userName, recordUpdate_timeMillis)
values (?, ?, ?, ?, ?, ?, ?, ?)` values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
) )
.run( .run(
addForm.contractTypeId, addForm.contractTypeId,
@ -56,6 +80,17 @@ export default async function addContract(
addForm.contractEndDateString === '' addForm.contractEndDateString === ''
? undefined ? undefined
: dateStringToInteger(addForm.contractEndDateString as DateString), : dateStringToInteger(addForm.contractEndDateString as DateString),
addForm.purchaserName ?? '',
addForm.purchaserAddress1 ?? '',
addForm.purchaserAddress2 ?? '',
addForm.purchaserCity ?? '',
addForm.purchaserProvince ?? '',
addForm.purchaserPostalCode ?? '',
addForm.purchaserPhoneNumber ?? '',
addForm.purchaserEmail ?? '',
addForm.purchaserRelationship ?? '',
addForm.funeralHomeId === '' ? undefined : addForm.funeralHomeId,
addForm.funeralDirectorName ?? '',
user.userName, user.userName,
rightNowMillis, rightNowMillis,
user.userName, user.userName,
@ -64,6 +99,10 @@ export default async function addContract(
const contractId = result.lastInsertRowid as number const contractId = result.lastInsertRowid as number
/*
* Add contract fields
*/
const contractTypeFieldIds = (addForm.contractTypeFieldIds ?? '').split(',') const contractTypeFieldIds = (addForm.contractTypeFieldIds ?? '').split(',')
for (const contractTypeFieldId of contractTypeFieldIds) { for (const contractTypeFieldId of contractTypeFieldIds) {
@ -84,6 +123,59 @@ export default async function addContract(
} }
} }
/*
* Add deceased information
*/
if ((addForm.deceasedName ?? '') !== '') {
database
.prepare(
`insert into ContractInterments (
contractId, intermentNumber,
deceasedName, deceasedAddress1, deceasedAddress2,
deceasedCity, deceasedProvince, deceasedPostalCode,
birthDate, deathDate,
birthPlace, deathPlace,
intermentDate,
intermentContainerTypeId, intermentCommittalTypeId,
recordCreate_userName, recordCreate_timeMillis,
recordUpdate_userName, recordUpdate_timeMillis)
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
)
.run(
contractId,
1,
addForm.deceasedName ?? '',
addForm.deceasedAddress1 ?? '',
addForm.deceasedAddress2 ?? '',
addForm.deceasedCity ?? '',
addForm.deceasedProvince ?? '',
addForm.deceasedPostalCode ?? '',
addForm.birthDateString === ''
? undefined
: dateStringToInteger(addForm.birthDateString as DateString),
addForm.deathDateString === ''
? undefined
: dateStringToInteger(addForm.deathDateString as DateString),
addForm.birthPlace ?? '',
addForm.deathPlace ?? '',
addForm.intermentDateString === ''
? undefined
: dateStringToInteger(addForm.intermentDateString as DateString),
addForm.intermentContainerTypeId === ''
? undefined
: addForm.intermentContainerTypeId,
addForm.intermentCommittalTypeId === ''
? undefined
: addForm.intermentCommittalTypeId,
user.userName,
rightNowMillis,
user.userName,
rightNowMillis
)
}
if (connectedDatabase === undefined) { if (connectedDatabase === undefined) {
database.release() database.release()
} }

6
database/addContractType.d.ts vendored 100644
View File

@ -0,0 +1,6 @@
export interface AddForm {
contractType: string;
isPreneed?: string;
orderNumber?: number;
}
export default function addContractType(addForm: AddForm, user: User): Promise<number>;

View File

@ -0,0 +1,16 @@
import { clearCacheByTableName } from '../helpers/functions.cache.js';
import { acquireConnection } from './pool.js';
export default async function addContractType(addForm, user) {
const database = await acquireConnection();
const rightNowMillis = Date.now();
const result = database
.prepare(`insert into ContractTypes (
contractType, isPreneed, orderNumber,
recordCreate_userName, recordCreate_timeMillis,
recordUpdate_userName, recordUpdate_timeMillis)
values (?, ?, ?, ?, ?, ?, ?)`)
.run(addForm.contractType, addForm.isPreneed === undefined ? 0 : 1, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
database.release();
clearCacheByTableName('ContractTypes');
return result.lastInsertRowid;
}

View File

@ -0,0 +1,41 @@
import { clearCacheByTableName } from '../helpers/functions.cache.js'
import { acquireConnection } from './pool.js'
export interface AddForm {
contractType: string
isPreneed?: string
orderNumber?: number
}
export default async function addContractType(
addForm: AddForm,
user: User
): Promise<number> {
const database = await acquireConnection()
const rightNowMillis = Date.now()
const result = database
.prepare(
`insert into ContractTypes (
contractType, isPreneed, orderNumber,
recordCreate_userName, recordCreate_timeMillis,
recordUpdate_userName, recordUpdate_timeMillis)
values (?, ?, ?, ?, ?, ?, ?)`
)
.run(
addForm.contractType,
addForm.isPreneed === undefined ? 0 : 1,
addForm.orderNumber ?? -1,
user.userName,
rightNowMillis,
user.userName,
rightNowMillis
)
database.release()
clearCacheByTableName('ContractTypes')
return result.lastInsertRowid as number
}

View File

@ -1,3 +1,3 @@
type RecordTable = 'BurialSiteStatuses' | 'BurialSiteTypes' | 'ContractTypes' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes'; type RecordTable = 'BurialSiteStatuses' | 'BurialSiteTypes' | 'IntermentContainerTypes' | 'IntermentCommittalTypes' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes';
export default function addRecord(recordTable: RecordTable, recordName: string, orderNumber: number | string, user: User): Promise<number>; export default function addRecord(recordTable: RecordTable, recordName: string, orderNumber: number | string, user: User): Promise<number>;
export {}; export {};

View File

@ -3,7 +3,8 @@ import { acquireConnection } from './pool.js';
const recordNameColumns = new Map(); const recordNameColumns = new Map();
recordNameColumns.set('BurialSiteStatuses', 'burialSiteStatus'); recordNameColumns.set('BurialSiteStatuses', 'burialSiteStatus');
recordNameColumns.set('BurialSiteTypes', 'burialSiteType'); recordNameColumns.set('BurialSiteTypes', 'burialSiteType');
recordNameColumns.set('ContractTypes', 'contractType'); recordNameColumns.set('IntermentContainerTypes', 'intermentContainerType');
recordNameColumns.set('IntermentCommittalTypes', 'intermentCommittalType');
recordNameColumns.set('WorkOrderMilestoneTypes', 'workOrderMilestoneType'); recordNameColumns.set('WorkOrderMilestoneTypes', 'workOrderMilestoneType');
recordNameColumns.set('WorkOrderTypes', 'workOrderType'); recordNameColumns.set('WorkOrderTypes', 'workOrderType');
export default async function addRecord(recordTable, recordName, orderNumber, user) { export default async function addRecord(recordTable, recordName, orderNumber, user) {

View File

@ -5,14 +5,16 @@ import { acquireConnection } from './pool.js'
type RecordTable = type RecordTable =
| 'BurialSiteStatuses' | 'BurialSiteStatuses'
| 'BurialSiteTypes' | 'BurialSiteTypes'
| 'ContractTypes' | 'IntermentContainerTypes'
| 'IntermentCommittalTypes'
| 'WorkOrderMilestoneTypes' | 'WorkOrderMilestoneTypes'
| 'WorkOrderTypes' | 'WorkOrderTypes'
const recordNameColumns = new Map<RecordTable, string>() const recordNameColumns = new Map<RecordTable, string>()
recordNameColumns.set('BurialSiteStatuses', 'burialSiteStatus') recordNameColumns.set('BurialSiteStatuses', 'burialSiteStatus')
recordNameColumns.set('BurialSiteTypes', 'burialSiteType') recordNameColumns.set('BurialSiteTypes', 'burialSiteType')
recordNameColumns.set('ContractTypes', 'contractType') recordNameColumns.set('IntermentContainerTypes', 'intermentContainerType')
recordNameColumns.set('IntermentCommittalTypes', 'intermentCommittalType')
recordNameColumns.set('WorkOrderMilestoneTypes', 'workOrderMilestoneType') recordNameColumns.set('WorkOrderMilestoneTypes', 'workOrderMilestoneType')
recordNameColumns.set('WorkOrderTypes', 'workOrderType') recordNameColumns.set('WorkOrderTypes', 'workOrderType')

View File

@ -2,7 +2,7 @@ import { dateIntegerToString } from '@cityssm/utils-datetime';
import getContractComments from './getContractComments.js'; import getContractComments from './getContractComments.js';
import getContractFees from './getContractFees.js'; import getContractFees from './getContractFees.js';
import getContractFields from './getContractFields.js'; import getContractFields from './getContractFields.js';
// import getContractOccupants from './getContractOccupants.js' import getContractInterments from './getContractInterments.js';
import getContractTransactions from './getContractTransactions.js'; import getContractTransactions from './getContractTransactions.js';
import { getWorkOrders } from './getWorkOrders.js'; import { getWorkOrders } from './getWorkOrders.js';
import { acquireConnection } from './pool.js'; import { acquireConnection } from './pool.js';
@ -11,29 +11,26 @@ export default async function getContract(contractId, connectedDatabase) {
database.function('userFn_dateIntegerToString', dateIntegerToString); database.function('userFn_dateIntegerToString', dateIntegerToString);
const contract = database const contract = database
.prepare(`select o.contractId, .prepare(`select o.contractId,
o.contractTypeId, t.contractType, o.contractTypeId, t.contractType, t.isPreneed,
o.burialSiteId, o.burialSiteId, l.burialSiteName, l.burialSiteTypeId,
l.burialSiteName,
l.burialSiteTypeId,
l.cemeteryId, m.cemeteryName, l.cemeteryId, m.cemeteryName,
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString, o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString, o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,
o.purchaserName, o.purchaserAddress1, o.purchaserAddress2,
o.purchaserCity, o.purchaserProvince, o.purchaserPostalCode,
o.purchaserPhoneNumber, o.purchaserEmail, o.purchaserRelationship,
o.funeralHomeId, o.funeralDirectorName,
o.recordUpdate_timeMillis o.recordUpdate_timeMillis
from Contracts o from Contracts o
left join ContractTypes t on o.contractTypeId = t.contractTypeId left join ContractTypes t on o.contractTypeId = t.contractTypeId
left join BurialSites l on o.burialSiteId = l.burialSiteId left join BurialSites l on o.burialSiteId = l.burialSiteId
left join Maps m on l.cemeteryId = m.cemeteryId left join Cemeteries m on l.cemeteryId = m.cemeteryId
where o.recordDelete_timeMillis is null where o.recordDelete_timeMillis is null
and o.contractId = ?`) and o.contractId = ?`)
.get(contractId); .get(contractId);
if (contract !== undefined) { if (contract !== undefined) {
contract.contractFields = await getContractFields(contractId, database); contract.contractFields = await getContractFields(contractId, database);
/* contract.contractInterments = await getContractInterments(contractId, database);
contract.contractInterments = await getContractOccupants(
contractId,
database
)
*/
contract.contractComments = await getContractComments(contractId, database); contract.contractComments = await getContractComments(contractId, database);
contract.contractFees = await getContractFees(contractId, database); contract.contractFees = await getContractFees(contractId, database);
contract.contractTransactions = await getContractTransactions(contractId, { includeIntegrations: true }, database); contract.contractTransactions = await getContractTransactions(contractId, { includeIntegrations: true }, database);

View File

@ -6,7 +6,7 @@ import type { Contract } from '../types/recordTypes.js'
import getContractComments from './getContractComments.js' import getContractComments from './getContractComments.js'
import getContractFees from './getContractFees.js' import getContractFees from './getContractFees.js'
import getContractFields from './getContractFields.js' import getContractFields from './getContractFields.js'
// import getContractOccupants from './getContractOccupants.js' import getContractInterments from './getContractInterments.js'
import getContractTransactions from './getContractTransactions.js' import getContractTransactions from './getContractTransactions.js'
import { getWorkOrders } from './getWorkOrders.js' import { getWorkOrders } from './getWorkOrders.js'
import { acquireConnection } from './pool.js' import { acquireConnection } from './pool.js'
@ -22,42 +22,35 @@ export default async function getContract(
const contract = database const contract = database
.prepare( .prepare(
`select o.contractId, `select o.contractId,
o.contractTypeId, t.contractType, o.contractTypeId, t.contractType, t.isPreneed,
o.burialSiteId, o.burialSiteId, l.burialSiteName, l.burialSiteTypeId,
l.burialSiteName,
l.burialSiteTypeId,
l.cemeteryId, m.cemeteryName, l.cemeteryId, m.cemeteryName,
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString, o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString, o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,
o.purchaserName, o.purchaserAddress1, o.purchaserAddress2,
o.purchaserCity, o.purchaserProvince, o.purchaserPostalCode,
o.purchaserPhoneNumber, o.purchaserEmail, o.purchaserRelationship,
o.funeralHomeId, o.funeralDirectorName,
o.recordUpdate_timeMillis o.recordUpdate_timeMillis
from Contracts o from Contracts o
left join ContractTypes t on o.contractTypeId = t.contractTypeId left join ContractTypes t on o.contractTypeId = t.contractTypeId
left join BurialSites l on o.burialSiteId = l.burialSiteId left join BurialSites l on o.burialSiteId = l.burialSiteId
left join Maps m on l.cemeteryId = m.cemeteryId left join Cemeteries m on l.cemeteryId = m.cemeteryId
where o.recordDelete_timeMillis is null where o.recordDelete_timeMillis is null
and o.contractId = ?` and o.contractId = ?`
) )
.get(contractId) as Contract | undefined .get(contractId) as Contract | undefined
if (contract !== undefined) { if (contract !== undefined) {
contract.contractFields = await getContractFields( contract.contractFields = await getContractFields(contractId, database)
contractId,
database contract.contractInterments = await getContractInterments(
)
/*
contract.contractInterments = await getContractOccupants(
contractId,
database
)
*/
contract.contractComments = await getContractComments(
contractId,
database
)
contract.contractFees = await getContractFees(
contractId, contractId,
database database
) )
contract.contractComments = await getContractComments(contractId, database)
contract.contractFees = await getContractFees(contractId, database)
contract.contractTransactions = await getContractTransactions( contract.contractTransactions = await getContractTransactions(
contractId, contractId,
{ includeIntegrations: true }, { includeIntegrations: true },

View File

@ -1,23 +1,21 @@
import { dateIntegerToString, timeIntegerToString } from '@cityssm/utils-datetime'; import { dateIntegerToString } from '@cityssm/utils-datetime';
import { acquireConnection } from './pool.js'; import { acquireConnection } from './pool.js';
export default async function getContractInterments(contractId, connectedDatabase) { export default async function getContractInterments(contractId, connectedDatabase) {
const database = connectedDatabase ?? (await acquireConnection()); const database = connectedDatabase ?? (await acquireConnection());
database.function('userFn_dateIntegerToString', dateIntegerToString); database.function('userFn_dateIntegerToString', dateIntegerToString);
database.function('userFn_timeIntegerToString', timeIntegerToString);
const interments = database const interments = database
.prepare(`select o.contractId, o.intermentNumber, .prepare(`select o.contractId, o.intermentNumber,
o.isCremated, o.isCremated,
o.deceasedName, o.deceasedName,
birthDate, userFn_dateIntegerToString(birthDate) as birthDateString, o.birthDate, userFn_dateIntegerToString(o.birthDate) as birthDateString,
birthPlace, o.birthPlace,
deathDate, userFn_dateIntegerToString(deathDate) as deathDateString, o.deathDate, userFn_dateIntegerToString(o.deathDate) as deathDateString,
deathPlace, o.deathPlace,
intermentDate, userFn_dateIntegerToString(intermentDate) as intermentDateString, o.intermentDate, userFn_dateIntegerToString(o.intermentDate) as intermentDateString,
intermentTime, userFn_timeIntegerToString(intermentTime) as intermentTimeString,
intermentContainerTypeId, t.intermentContainerType, o.intermentContainerTypeId, t.intermentContainerType,
intermentCommittalTypeId, c.intermentCommittalType o.intermentCommittalTypeId, c.intermentCommittalType
from ContractInterments o from ContractInterments o
left join IntermentContainerTypes t on o.intermentContainerTypeId = t.intermentContainerTypeId left join IntermentContainerTypes t on o.intermentContainerTypeId = t.intermentContainerTypeId

View File

@ -1,6 +1,5 @@
import { import {
dateIntegerToString, dateIntegerToString
timeIntegerToString
} from '@cityssm/utils-datetime' } from '@cityssm/utils-datetime'
import type { PoolConnection } from 'better-sqlite-pool' import type { PoolConnection } from 'better-sqlite-pool'
@ -15,23 +14,21 @@ export default async function getContractInterments(
const database = connectedDatabase ?? (await acquireConnection()) const database = connectedDatabase ?? (await acquireConnection())
database.function('userFn_dateIntegerToString', dateIntegerToString) database.function('userFn_dateIntegerToString', dateIntegerToString)
database.function('userFn_timeIntegerToString', timeIntegerToString)
const interments = database const interments = database
.prepare( .prepare(
`select o.contractId, o.intermentNumber, `select o.contractId, o.intermentNumber,
o.isCremated, o.isCremated,
o.deceasedName, o.deceasedName,
birthDate, userFn_dateIntegerToString(birthDate) as birthDateString, o.birthDate, userFn_dateIntegerToString(o.birthDate) as birthDateString,
birthPlace, o.birthPlace,
deathDate, userFn_dateIntegerToString(deathDate) as deathDateString, o.deathDate, userFn_dateIntegerToString(o.deathDate) as deathDateString,
deathPlace, o.deathPlace,
intermentDate, userFn_dateIntegerToString(intermentDate) as intermentDateString, o.intermentDate, userFn_dateIntegerToString(o.intermentDate) as intermentDateString,
intermentTime, userFn_timeIntegerToString(intermentTime) as intermentTimeString,
intermentContainerTypeId, t.intermentContainerType, o.intermentContainerTypeId, t.intermentContainerType,
intermentCommittalTypeId, c.intermentCommittalType o.intermentCommittalTypeId, c.intermentCommittalType
from ContractInterments o from ContractInterments o
left join IntermentContainerTypes t on o.intermentContainerTypeId = t.intermentContainerTypeId left join IntermentContainerTypes t on o.intermentContainerTypeId = t.intermentContainerTypeId

View File

@ -5,7 +5,7 @@ import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
export default async function getContractTypes() { export default async function getContractTypes() {
const database = await acquireConnection(); const database = await acquireConnection();
const contractTypes = database const contractTypes = database
.prepare(`select contractTypeId, contractType, orderNumber .prepare(`select contractTypeId, contractType, isPreneed, orderNumber
from ContractTypes from ContractTypes
where recordDelete_timeMillis is null where recordDelete_timeMillis is null
order by orderNumber, contractType`) order by orderNumber, contractType`)

View File

@ -10,7 +10,7 @@ export default async function getContractTypes(): Promise<ContractType[]> {
const contractTypes = database const contractTypes = database
.prepare( .prepare(
`select contractTypeId, contractType, orderNumber `select contractTypeId, contractType, isPreneed, orderNumber
from ContractTypes from ContractTypes
where recordDelete_timeMillis is null where recordDelete_timeMillis is null
order by orderNumber, contractType` order by orderNumber, contractType`

View File

@ -3,7 +3,7 @@ import { getConfigProperty } from '../helpers/config.helpers.js';
import { getContractTypeById } from '../helpers/functions.cache.js'; import { getContractTypeById } from '../helpers/functions.cache.js';
import { getBurialSiteNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js'; import { getBurialSiteNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js';
import getContractFees from './getContractFees.js'; import getContractFees from './getContractFees.js';
// import getContractOccupants from './getContractOccupants.js' import getContractInterments from './getContractInterments.js';
import getContractTransactions from './getContractTransactions.js'; import getContractTransactions from './getContractTransactions.js';
import { acquireConnection } from './pool.js'; import { acquireConnection } from './pool.js';
function buildWhereClause(filters) { function buildWhereClause(filters) {
@ -70,18 +70,11 @@ async function addInclusions(contract, options, database) {
contract.contractFees = await getContractFees(contract.contractId, database); contract.contractFees = await getContractFees(contract.contractId, database);
} }
if (options.includeTransactions) { if (options.includeTransactions) {
contract.contractTransactions = contract.contractTransactions = await getContractTransactions(contract.contractId, { includeIntegrations: false }, database);
await getContractTransactions(contract.contractId, { includeIntegrations: false }, database);
} }
/*
if (options.includeInterments) { if (options.includeInterments) {
contract.contractInterments = contract.contractInterments = await getContractInterments(contract.contractId, database);
await getContractOccupants(
contract.contractId,
database
)
} }
*/
return contract; return contract;
} }
export default async function getContracts(filters, options, connectedDatabase) { export default async function getContracts(filters, options, connectedDatabase) {
@ -104,12 +97,15 @@ export default async function getContracts(filters, options, connectedDatabase)
if (count !== 0) { if (count !== 0) {
contracts = database contracts = database
.prepare(`select o.contractId, .prepare(`select o.contractId,
o.contractTypeId, t.contractType, o.contractTypeId, t.contractType, t.isPreneed,
o.burialSiteId, lt.burialSiteType, o.burialSiteId, lt.burialSiteType, l.burialSiteName,
l.burialSiteName,
l.cemeteryId, m.cemeteryName, l.cemeteryId, m.cemeteryName,
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString, o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,
o.purchaserName, o.purchaserAddress1, o.purchaserAddress2,
o.purchaserCity, o.purchaserProvince, o.purchaserPostalCode,
o.purchaserPhoneNumber, o.purchaserEmail, o.purchaserRelationship,
o.funeralHomeId, o.funeralDirectorName
from Contracts o from Contracts o
left join ContractTypes t on o.contractTypeId = t.contractTypeId left join ContractTypes t on o.contractTypeId = t.contractTypeId
left join BurialSites l on o.burialSiteId = l.burialSiteId left join BurialSites l on o.burialSiteId = l.burialSiteId

View File

@ -15,7 +15,7 @@ import {
import type { Contract } from '../types/recordTypes.js' import type { Contract } from '../types/recordTypes.js'
import getContractFees from './getContractFees.js' import getContractFees from './getContractFees.js'
// import getContractOccupants from './getContractOccupants.js' import getContractInterments from './getContractInterments.js'
import getContractTransactions from './getContractTransactions.js' import getContractTransactions from './getContractTransactions.js'
import { acquireConnection } from './pool.js' import { acquireConnection } from './pool.js'
@ -139,30 +139,23 @@ async function addInclusions(
database: PoolConnection database: PoolConnection
): Promise<Contract> { ): Promise<Contract> {
if (options.includeFees) { if (options.includeFees) {
contract.contractFees = await getContractFees( contract.contractFees = await getContractFees(contract.contractId, database)
contract.contractId,
database
)
} }
if (options.includeTransactions) { if (options.includeTransactions) {
contract.contractTransactions = contract.contractTransactions = await getContractTransactions(
await getContractTransactions(
contract.contractId, contract.contractId,
{ includeIntegrations: false }, { includeIntegrations: false },
database database
) )
} }
/*
if (options.includeInterments) { if (options.includeInterments) {
contract.contractInterments = contract.contractInterments = await getContractInterments(
await getContractOccupants(
contract.contractId, contract.contractId,
database database
) )
} }
*/
return contract return contract
} }
@ -204,12 +197,15 @@ export default async function getContracts(
contracts = database contracts = database
.prepare( .prepare(
`select o.contractId, `select o.contractId,
o.contractTypeId, t.contractType, o.contractTypeId, t.contractType, t.isPreneed,
o.burialSiteId, lt.burialSiteType, o.burialSiteId, lt.burialSiteType, l.burialSiteName,
l.burialSiteName,
l.cemeteryId, m.cemeteryName, l.cemeteryId, m.cemeteryName,
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString, o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,
o.purchaserName, o.purchaserAddress1, o.purchaserAddress2,
o.purchaserCity, o.purchaserProvince, o.purchaserPostalCode,
o.purchaserPhoneNumber, o.purchaserEmail, o.purchaserRelationship,
o.funeralHomeId, o.funeralDirectorName
from Contracts o from Contracts o
left join ContractTypes t on o.contractTypeId = t.contractTypeId left join ContractTypes t on o.contractTypeId = t.contractTypeId
left join BurialSites l on o.burialSiteId = l.burialSiteId left join BurialSites l on o.burialSiteId = l.burialSiteId
@ -234,14 +230,12 @@ export default async function getContracts(
} }
for (const contract of contracts) { for (const contract of contracts) {
const contractType = await getContractTypeById( const contractType = await getContractTypeById(contract.contractTypeId)
contract.contractTypeId
)
if (contractType !== undefined) { if (contractType !== undefined) {
contract.printEJS = ( contract.printEJS = (contractType.contractTypePrints ?? []).includes(
contractType.contractTypePrints ?? [] '*'
).includes('*') )
? getConfigProperty('settings.contracts.prints')[0] ? getConfigProperty('settings.contracts.prints')[0]
: (contractType.contractTypePrints ?? [])[0] : (contractType.contractTypePrints ?? [])[0]
} }

View File

@ -0,0 +1,2 @@
import type { IntermentCommittalType } from '../types/recordTypes.js';
export default function getIntermentCommittalTypes(): Promise<IntermentCommittalType[]>;

View File

@ -0,0 +1,12 @@
import { acquireConnection } from './pool.js';
export default async function getIntermentCommittalTypes() {
const database = await acquireConnection();
const committalTypes = database
.prepare(`select intermentCommittalTypeId, intermentCommittalType, orderNumber
from IntermentCommittalTypes
where recordDelete_timeMillis is null
order by orderNumber, intermentCommittalType, intermentCommittalTypeId`)
.all();
database.release();
return committalTypes;
}

View File

@ -0,0 +1,22 @@
import type { IntermentCommittalType } from '../types/recordTypes.js'
import { acquireConnection } from './pool.js'
export default async function getIntermentCommittalTypes(): Promise<
IntermentCommittalType[]
> {
const database = await acquireConnection()
const committalTypes = database
.prepare(
`select intermentCommittalTypeId, intermentCommittalType, orderNumber
from IntermentCommittalTypes
where recordDelete_timeMillis is null
order by orderNumber, intermentCommittalType, intermentCommittalTypeId`
)
.all() as IntermentCommittalType[]
database.release()
return committalTypes
}

View File

@ -0,0 +1,2 @@
import type { IntermentContainerType } from '../types/recordTypes.js';
export default function getIntermentContainerTypes(): Promise<IntermentContainerType[]>;

View File

@ -0,0 +1,12 @@
import { acquireConnection } from './pool.js';
export default async function getIntermentContainerTypes() {
const database = await acquireConnection();
const containerTypes = database
.prepare(`select intermentContainerTypeId, intermentContainerType, orderNumber
from IntermentContainerTypes
where recordDelete_timeMillis is null
order by orderNumber, intermentContainerType, intermentContainerTypeId`)
.all();
database.release();
return containerTypes;
}

View File

@ -0,0 +1,22 @@
import type { IntermentContainerType } from '../types/recordTypes.js'
import { acquireConnection } from './pool.js'
export default async function getIntermentContainerTypes(): Promise<
IntermentContainerType[]
> {
const database = await acquireConnection()
const containerTypes = database
.prepare(
`select intermentContainerTypeId, intermentContainerType, orderNumber
from IntermentContainerTypes
where recordDelete_timeMillis is null
order by orderNumber, intermentContainerType, intermentContainerTypeId`
)
.all() as IntermentContainerType[]
database.release()
return containerTypes
}

View File

@ -4,6 +4,7 @@ import sqlite from 'better-sqlite3';
import Debug from 'debug'; import Debug from 'debug';
import { DEBUG_NAMESPACE } from '../debug.config.js'; import { DEBUG_NAMESPACE } from '../debug.config.js';
import { sunriseDB as databasePath } from '../helpers/database.helpers.js'; import { sunriseDB as databasePath } from '../helpers/database.helpers.js';
import addContractType from './addContractType.js';
import addFeeCategory from './addFeeCategory.js'; import addFeeCategory from './addFeeCategory.js';
import addRecord from './addRecord.js'; import addRecord from './addRecord.js';
const debug = Debug(`${DEBUG_NAMESPACE}:database/initializeDatabase`); const debug = Debug(`${DEBUG_NAMESPACE}:database/initializeDatabase`);
@ -132,6 +133,7 @@ const createStatements = [
`create table if not exists ContractTypes ( `create table if not exists ContractTypes (
contractTypeId integer not null primary key autoincrement, contractTypeId integer not null primary key autoincrement,
contractType varchar(100) not null, contractType varchar(100) not null,
isPreneed bit not null default 0,
orderNumber smallint not null default 0, orderNumber smallint not null default 0,
${recordColumns})`, ${recordColumns})`,
`create index if not exists idx_ContractTypes_orderNumber `create index if not exists idx_ContractTypes_orderNumber
@ -175,6 +177,7 @@ const createStatements = [
purchaserPostalCode varchar(7), purchaserPostalCode varchar(7),
purchaserPhoneNumber varchar(30), purchaserPhoneNumber varchar(30),
purchaserEmail varchar(100), purchaserEmail varchar(100),
purchaserRelationship varchar(50),
funeralHomeId integer, funeralHomeId integer,
funeralDirectorName varchar(100), funeralDirectorName varchar(100),
@ -225,6 +228,12 @@ const createStatements = [
deceasedName varchar(50) not null, deceasedName varchar(50) not null,
isCremated bit not null default 0, isCremated bit not null default 0,
deceasedAddress1 varchar(50),
deceasedAddress2 varchar(50),
deceasedCity varchar(20),
deceasedProvince varchar(2),
deceasedPostalCode varchar(7),
birthDate integer, birthDate integer,
birthPlace varchar(100), birthPlace varchar(100),
@ -393,9 +402,30 @@ async function initializeData() {
await addRecord('BurialSiteStatuses', 'Available', 1, initializingUser); await addRecord('BurialSiteStatuses', 'Available', 1, initializingUser);
await addRecord('BurialSiteStatuses', 'Reserved', 2, initializingUser); await addRecord('BurialSiteStatuses', 'Reserved', 2, initializingUser);
await addRecord('BurialSiteStatuses', 'Taken', 3, initializingUser); await addRecord('BurialSiteStatuses', 'Taken', 3, initializingUser);
await addRecord('ContractTypes', 'Preneed', 1, initializingUser); await addContractType({
await addRecord('ContractTypes', 'Interment', 2, initializingUser); contractType: 'Preneed',
await addRecord('ContractTypes', 'Cremation', 3, initializingUser); isPreneed: '1',
orderNumber: 1
}, initializingUser);
await addContractType({
contractType: 'Interment',
isPreneed: '0',
orderNumber: 2
}, initializingUser);
await addContractType({
contractType: 'Cremation',
isPreneed: '0',
orderNumber: 3
}, initializingUser);
await addRecord('IntermentContainerTypes', 'No Shell', 1, initializingUser);
await addRecord('IntermentContainerTypes', 'Concrete Liner', 2, initializingUser);
await addRecord('IntermentContainerTypes', 'Unpainted Vault', 3, initializingUser);
await addRecord('IntermentContainerTypes', 'Concrete Vault', 4, initializingUser);
await addRecord('IntermentContainerTypes', 'Wooden Shell', 5, initializingUser);
await addRecord('IntermentContainerTypes', 'Steel Vault', 6, initializingUser);
await addRecord('IntermentCommittalTypes', 'Graveside', 1, initializingUser);
await addRecord('IntermentCommittalTypes', 'Chapel', 2, initializingUser);
await addRecord('IntermentCommittalTypes', 'Church', 3, initializingUser);
/* /*
* Fee Categories * Fee Categories
*/ */

View File

@ -7,6 +7,7 @@ import Debug from 'debug'
import { DEBUG_NAMESPACE } from '../debug.config.js' import { DEBUG_NAMESPACE } from '../debug.config.js'
import { sunriseDB as databasePath } from '../helpers/database.helpers.js' import { sunriseDB as databasePath } from '../helpers/database.helpers.js'
import addContractType from './addContractType.js'
import addFeeCategory from './addFeeCategory.js' import addFeeCategory from './addFeeCategory.js'
import addRecord from './addRecord.js' import addRecord from './addRecord.js'
@ -156,6 +157,7 @@ const createStatements = [
`create table if not exists ContractTypes ( `create table if not exists ContractTypes (
contractTypeId integer not null primary key autoincrement, contractTypeId integer not null primary key autoincrement,
contractType varchar(100) not null, contractType varchar(100) not null,
isPreneed bit not null default 0,
orderNumber smallint not null default 0, orderNumber smallint not null default 0,
${recordColumns})`, ${recordColumns})`,
@ -205,6 +207,7 @@ const createStatements = [
purchaserPostalCode varchar(7), purchaserPostalCode varchar(7),
purchaserPhoneNumber varchar(30), purchaserPhoneNumber varchar(30),
purchaserEmail varchar(100), purchaserEmail varchar(100),
purchaserRelationship varchar(50),
funeralHomeId integer, funeralHomeId integer,
funeralDirectorName varchar(100), funeralDirectorName varchar(100),
@ -264,6 +267,12 @@ const createStatements = [
deceasedName varchar(50) not null, deceasedName varchar(50) not null,
isCremated bit not null default 0, isCremated bit not null default 0,
deceasedAddress1 varchar(50),
deceasedAddress2 varchar(50),
deceasedCity varchar(20),
deceasedProvince varchar(2),
deceasedPostalCode varchar(7),
birthDate integer, birthDate integer,
birthPlace varchar(100), birthPlace varchar(100),
@ -464,9 +473,43 @@ async function initializeData(): Promise<void> {
await addRecord('BurialSiteStatuses', 'Reserved', 2, initializingUser) await addRecord('BurialSiteStatuses', 'Reserved', 2, initializingUser)
await addRecord('BurialSiteStatuses', 'Taken', 3, initializingUser) await addRecord('BurialSiteStatuses', 'Taken', 3, initializingUser)
await addRecord('ContractTypes', 'Preneed', 1, initializingUser) await addContractType(
await addRecord('ContractTypes', 'Interment', 2, initializingUser) {
await addRecord('ContractTypes', 'Cremation', 3, initializingUser) contractType: 'Preneed',
isPreneed: '1',
orderNumber: 1
},
initializingUser
)
await addContractType(
{
contractType: 'Interment',
isPreneed: '0',
orderNumber: 2
},
initializingUser
)
await addContractType(
{
contractType: 'Cremation',
isPreneed: '0',
orderNumber: 3
},
initializingUser
)
await addRecord('IntermentContainerTypes', 'No Shell', 1, initializingUser)
await addRecord('IntermentContainerTypes', 'Concrete Liner', 2, initializingUser)
await addRecord('IntermentContainerTypes', 'Unpainted Vault', 3, initializingUser)
await addRecord('IntermentContainerTypes', 'Concrete Vault', 4, initializingUser)
await addRecord('IntermentContainerTypes', 'Wooden Shell', 5, initializingUser)
await addRecord('IntermentContainerTypes', 'Steel Vault', 6, initializingUser)
await addRecord('IntermentCommittalTypes', 'Graveside', 1, initializingUser)
await addRecord('IntermentCommittalTypes', 'Chapel', 2, initializingUser)
await addRecord('IntermentCommittalTypes', 'Church', 3, initializingUser)
/* /*
* Fee Categories * Fee Categories

View File

@ -5,7 +5,18 @@ export interface UpdateContractForm {
burialSiteId: string | number; burialSiteId: string | number;
contractStartDateString: DateString; contractStartDateString: DateString;
contractEndDateString: DateString | ''; contractEndDateString: DateString | '';
funeralHomeId?: string | number;
funeralDirectorName?: string;
purchaserName?: string;
purchaserAddress1?: string;
purchaserAddress2?: string;
purchaserCity?: string;
purchaserProvince?: string;
purchaserPostalCode?: string;
purchaserPhoneNumber?: string;
purchaserEmail?: string;
purchaserRelationship?: string;
contractTypeFieldIds?: string; contractTypeFieldIds?: string;
[fieldValue_contractTypeFieldId: string]: unknown; [fieldValue_contractTypeFieldId: `fieldValue_${string}`]: unknown;
} }
export default function updateContract(updateForm: UpdateContractForm, user: User): Promise<boolean>; export default function updateContract(updateForm: UpdateContractForm, user: User): Promise<boolean>;

View File

@ -10,13 +10,24 @@ export default async function updateContract(updateForm, user) {
burialSiteId = ?, burialSiteId = ?,
contractStartDate = ?, contractStartDate = ?,
contractEndDate = ?, contractEndDate = ?,
funeralHomeId = ?,
funeralDirectorName = ?,
purchaserName = ?,
purchaserAddress1 = ?,
purchaserAddress2 = ?,
purchaserCity = ?,
purchaserProvince = ?,
purchaserPostalCode = ?,
purchaserPhoneNumber = ?,
purchaserEmail = ?,
purchaserRelationship = ?,
recordUpdate_userName = ?, recordUpdate_userName = ?,
recordUpdate_timeMillis = ? recordUpdate_timeMillis = ?
where contractId = ? where contractId = ?
and recordDelete_timeMillis is null`) and recordDelete_timeMillis is null`)
.run(updateForm.contractTypeId, updateForm.burialSiteId === '' ? undefined : updateForm.burialSiteId, dateStringToInteger(updateForm.contractStartDateString), updateForm.contractEndDateString === '' .run(updateForm.contractTypeId, updateForm.burialSiteId === '' ? undefined : updateForm.burialSiteId, dateStringToInteger(updateForm.contractStartDateString), updateForm.contractEndDateString === ''
? undefined ? undefined
: dateStringToInteger(updateForm.contractEndDateString), user.userName, Date.now(), updateForm.contractId); : dateStringToInteger(updateForm.contractEndDateString), updateForm.funeralHomeId === '' ? undefined : updateForm.funeralHomeId, updateForm.funeralDirectorName ?? '', updateForm.purchaserName ?? '', updateForm.purchaserAddress1 ?? '', updateForm.purchaserAddress2 ?? '', updateForm.purchaserCity ?? '', updateForm.purchaserProvince ?? '', updateForm.purchaserPostalCode ?? '', updateForm.purchaserPhoneNumber ?? '', updateForm.purchaserEmail ?? '', updateForm.purchaserRelationship ?? '', user.userName, Date.now(), updateForm.contractId);
if (result.changes > 0) { if (result.changes > 0) {
const contractTypeFieldIds = (updateForm.contractTypeFieldIds ?? '').split(','); const contractTypeFieldIds = (updateForm.contractTypeFieldIds ?? '').split(',');
for (const contractTypeFieldId of contractTypeFieldIds) { for (const contractTypeFieldId of contractTypeFieldIds) {

View File

@ -12,8 +12,21 @@ export interface UpdateContractForm {
contractStartDateString: DateString contractStartDateString: DateString
contractEndDateString: DateString | '' contractEndDateString: DateString | ''
funeralHomeId?: string | number
funeralDirectorName?: string
purchaserName?: string
purchaserAddress1?: string
purchaserAddress2?: string
purchaserCity?: string
purchaserProvince?: string
purchaserPostalCode?: string
purchaserPhoneNumber?: string
purchaserEmail?: string
purchaserRelationship?: string
contractTypeFieldIds?: string contractTypeFieldIds?: string
[fieldValue_contractTypeFieldId: string]: unknown [fieldValue_contractTypeFieldId: `fieldValue_${string}`]: unknown
} }
export default async function updateContract( export default async function updateContract(
@ -29,6 +42,17 @@ export default async function updateContract(
burialSiteId = ?, burialSiteId = ?,
contractStartDate = ?, contractStartDate = ?,
contractEndDate = ?, contractEndDate = ?,
funeralHomeId = ?,
funeralDirectorName = ?,
purchaserName = ?,
purchaserAddress1 = ?,
purchaserAddress2 = ?,
purchaserCity = ?,
purchaserProvince = ?,
purchaserPostalCode = ?,
purchaserPhoneNumber = ?,
purchaserEmail = ?,
purchaserRelationship = ?,
recordUpdate_userName = ?, recordUpdate_userName = ?,
recordUpdate_timeMillis = ? recordUpdate_timeMillis = ?
where contractId = ? where contractId = ?
@ -41,6 +65,17 @@ export default async function updateContract(
updateForm.contractEndDateString === '' updateForm.contractEndDateString === ''
? undefined ? undefined
: dateStringToInteger(updateForm.contractEndDateString), : dateStringToInteger(updateForm.contractEndDateString),
updateForm.funeralHomeId === '' ? undefined : updateForm.funeralHomeId,
updateForm.funeralDirectorName ?? '',
updateForm.purchaserName ?? '',
updateForm.purchaserAddress1 ?? '',
updateForm.purchaserAddress2 ?? '',
updateForm.purchaserCity ?? '',
updateForm.purchaserProvince ?? '',
updateForm.purchaserPostalCode ?? '',
updateForm.purchaserPhoneNumber ?? '',
updateForm.purchaserEmail ?? '',
updateForm.purchaserRelationship ?? '',
user.userName, user.userName,
Date.now(), Date.now(),
updateForm.contractId updateForm.contractId

View File

@ -0,0 +1,6 @@
export interface UpdateForm {
contractTypeId: number | string;
contractType: string;
isPreneed?: string;
}
export default function updateContractType(updateForm: UpdateForm, user: User): Promise<boolean>;

View File

@ -0,0 +1,18 @@
import { clearCacheByTableName } from '../helpers/functions.cache.js';
import { acquireConnection } from './pool.js';
export default async function updateContractType(updateForm, user) {
const database = await acquireConnection();
const rightNowMillis = Date.now();
const result = database
.prepare(`update ContractTypes
set contractType = ?,
isPreneed = ?,
recordUpdate_userName = ?,
recordUpdate_timeMillis = ?
where recordDelete_timeMillis is null
and contractTypeId = ?`)
.run(updateForm.contractType, updateForm.isPreneed === undefined ? 0 : 1, user.userName, rightNowMillis, updateForm.contractTypeId);
database.release();
clearCacheByTableName('ContractTypes');
return result.changes > 0;
}

View File

@ -0,0 +1,42 @@
import { clearCacheByTableName } from '../helpers/functions.cache.js'
import { acquireConnection } from './pool.js'
export interface UpdateForm {
contractTypeId: number | string
contractType: string
isPreneed?: string
}
export default async function updateContractType(
updateForm: UpdateForm,
user: User
): Promise<boolean> {
const database = await acquireConnection()
const rightNowMillis = Date.now()
const result = database
.prepare(
`update ContractTypes
set contractType = ?,
isPreneed = ?,
recordUpdate_userName = ?,
recordUpdate_timeMillis = ?
where recordDelete_timeMillis is null
and contractTypeId = ?`
)
.run(
updateForm.contractType,
updateForm.isPreneed === undefined ? 0 : 1,
user.userName,
rightNowMillis,
updateForm.contractTypeId
)
database.release()
clearCacheByTableName('ContractTypes')
return result.changes > 0
}

View File

@ -1,3 +1,3 @@
type RecordTable = 'BurialSiteStatuses' | 'BurialSiteTypes' | 'ContractTypes' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes'; type RecordTable = 'BurialSiteStatuses' | 'BurialSiteTypes' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes';
export declare function updateRecord(recordTable: RecordTable, recordId: number | string, recordName: string, user: User): Promise<boolean>; export declare function updateRecord(recordTable: RecordTable, recordId: number | string, recordName: string, user: User): Promise<boolean>;
export {}; export {};

View File

@ -1,9 +1,14 @@
import { clearCacheByTableName } from '../helpers/functions.cache.js'; import { clearCacheByTableName } from '../helpers/functions.cache.js';
import { acquireConnection } from './pool.js'; import { acquireConnection } from './pool.js';
const recordNameIdColumns = new Map(); const recordNameIdColumns = new Map();
recordNameIdColumns.set('BurialSiteStatuses', ['burialSiteStatus', 'burialSiteStatusId']); recordNameIdColumns.set('BurialSiteStatuses', [
recordNameIdColumns.set('BurialSiteTypes', ['burialSiteType', 'burialSiteTypeId']); 'burialSiteStatus',
recordNameIdColumns.set('ContractTypes', ['contractType', 'contractTypeId']); 'burialSiteStatusId'
]);
recordNameIdColumns.set('BurialSiteTypes', [
'burialSiteType',
'burialSiteTypeId'
]);
recordNameIdColumns.set('WorkOrderMilestoneTypes', [ recordNameIdColumns.set('WorkOrderMilestoneTypes', [
'workOrderMilestoneType', 'workOrderMilestoneType',
'workOrderMilestoneTypeId' 'workOrderMilestoneTypeId'

View File

@ -5,14 +5,18 @@ import { acquireConnection } from './pool.js'
type RecordTable = type RecordTable =
| 'BurialSiteStatuses' | 'BurialSiteStatuses'
| 'BurialSiteTypes' | 'BurialSiteTypes'
| 'ContractTypes'
| 'WorkOrderMilestoneTypes' | 'WorkOrderMilestoneTypes'
| 'WorkOrderTypes' | 'WorkOrderTypes'
const recordNameIdColumns = new Map<RecordTable, string[]>() const recordNameIdColumns = new Map<RecordTable, string[]>()
recordNameIdColumns.set('BurialSiteStatuses', ['burialSiteStatus', 'burialSiteStatusId']) recordNameIdColumns.set('BurialSiteStatuses', [
recordNameIdColumns.set('BurialSiteTypes', ['burialSiteType', 'burialSiteTypeId']) 'burialSiteStatus',
recordNameIdColumns.set('ContractTypes', ['contractType', 'contractTypeId']) 'burialSiteStatusId'
])
recordNameIdColumns.set('BurialSiteTypes', [
'burialSiteType',
'burialSiteTypeId'
])
recordNameIdColumns.set('WorkOrderMilestoneTypes', [ recordNameIdColumns.set('WorkOrderMilestoneTypes', [
'workOrderMilestoneType', 'workOrderMilestoneType',
'workOrderMilestoneTypeId' 'workOrderMilestoneTypeId'

View File

@ -1,5 +1,3 @@
import type { Request, Response } from 'express'; import type { Request, Response } from 'express';
export default function handler(request: Request<unknown, unknown, { import { type AddForm } from '../../database/addContractType.js';
contractType: string; export default function handler(request: Request<unknown, unknown, AddForm>, response: Response): Promise<void>;
orderNumber?: number | string;
}>, response: Response): Promise<void>;

View File

@ -1,7 +1,7 @@
import addRecord from '../../database/addRecord.js'; import addContractType from '../../database/addContractType.js';
import { getAllContractTypeFields, getContractTypes } from '../../helpers/functions.cache.js'; import { getAllContractTypeFields, getContractTypes } from '../../helpers/functions.cache.js';
export default async function handler(request, response) { export default async function handler(request, response) {
const contractTypeId = await addRecord('ContractTypes', request.body.contractType, request.body.orderNumber ?? -1, request.session.user); const contractTypeId = await addContractType(request.body, request.session.user);
const contractTypes = await getContractTypes(); const contractTypes = await getContractTypes();
const allContractTypeFields = await getAllContractTypeFields(); const allContractTypeFields = await getAllContractTypeFields();
response.json({ response.json({

View File

@ -1,23 +1,19 @@
import type { Request, Response } from 'express' import type { Request, Response } from 'express'
import addRecord from '../../database/addRecord.js' import addContractType, {
type AddForm
} from '../../database/addContractType.js'
import { import {
getAllContractTypeFields, getAllContractTypeFields,
getContractTypes getContractTypes
} from '../../helpers/functions.cache.js' } from '../../helpers/functions.cache.js'
export default async function handler( export default async function handler(
request: Request< request: Request<unknown, unknown, AddForm>,
unknown,
unknown,
{ contractType: string; orderNumber?: number | string }
>,
response: Response response: Response
): Promise<void> { ): Promise<void> {
const contractTypeId = await addRecord( const contractTypeId = await addContractType(
'ContractTypes', request.body,
request.body.contractType,
request.body.orderNumber ?? -1,
request.session.user as User request.session.user as User
) )

View File

@ -1,5 +1,3 @@
import type { Request, Response } from 'express'; import type { Request, Response } from 'express';
export default function handler(request: Request<unknown, unknown, { import { type UpdateForm } from '../../database/updateContractType.js';
contractTypeId: string; export default function handler(request: Request<unknown, unknown, UpdateForm>, response: Response): Promise<void>;
contractType: string;
}>, response: Response): Promise<void>;

View File

@ -1,7 +1,7 @@
import { updateRecord } from '../../database/updateRecord.js'; import updateContractType from '../../database/updateContractType.js';
import { getAllContractTypeFields, getContractTypes } from '../../helpers/functions.cache.js'; import { getAllContractTypeFields, getContractTypes } from '../../helpers/functions.cache.js';
export default async function handler(request, response) { export default async function handler(request, response) {
const success = await updateRecord('ContractTypes', request.body.contractTypeId, request.body.contractType, request.session.user); const success = await updateContractType(request.body, request.session.user);
const contractTypes = await getContractTypes(); const contractTypes = await getContractTypes();
const allContractTypeFields = await getAllContractTypeFields(); const allContractTypeFields = await getAllContractTypeFields();
response.json({ response.json({

View File

@ -1,23 +1,19 @@
import type { Request, Response } from 'express' import type { Request, Response } from 'express'
import { updateRecord } from '../../database/updateRecord.js' import updateContractType, {
type UpdateForm
} from '../../database/updateContractType.js'
import { import {
getAllContractTypeFields, getAllContractTypeFields,
getContractTypes getContractTypes
} from '../../helpers/functions.cache.js' } from '../../helpers/functions.cache.js'
export default async function handler( export default async function handler(
request: Request< request: Request<unknown, unknown, UpdateForm>,
unknown,
unknown,
{ contractTypeId: string; contractType: string }
>,
response: Response response: Response
): Promise<void> { ): Promise<void> {
const success = await updateRecord( const success = await updateContractType(
'ContractTypes', request.body,
request.body.contractTypeId,
request.body.contractType,
request.session.user as User request.session.user as User
) )

View File

@ -1,7 +1,7 @@
import getCemeteries from '../../database/getCemeteries.js';
import getContract from '../../database/getContract.js'; import getContract from '../../database/getContract.js';
import getFuneralHomes from '../../database/getFuneralHomes.js';
import { getConfigProperty } from '../../helpers/config.helpers.js'; import { getConfigProperty } from '../../helpers/config.helpers.js';
import { getBurialSiteStatuses, getBurialSiteTypes, getContractTypePrintsById, getContractTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js'; import { getContractTypePrintsById, getContractTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js';
export default async function handler(request, response) { export default async function handler(request, response) {
const contract = await getContract(request.params.contractId); const contract = await getContract(request.params.contractId);
if (contract === undefined) { if (contract === undefined) {
@ -10,18 +10,14 @@ export default async function handler(request, response) {
} }
const contractTypePrints = await getContractTypePrintsById(contract.contractTypeId); const contractTypePrints = await getContractTypePrintsById(contract.contractTypeId);
const contractTypes = await getContractTypes(); const contractTypes = await getContractTypes();
const burialSiteTypes = await getBurialSiteTypes(); const funeralHomes = await getFuneralHomes();
const burialSiteStatuses = await getBurialSiteStatuses();
const cemeteries = await getCemeteries();
const workOrderTypes = await getWorkOrderTypes(); const workOrderTypes = await getWorkOrderTypes();
response.render('contract-edit', { response.render('contract-edit', {
headTitle: 'Contract Update', headTitle: 'Contract Update',
contract, contract,
contractTypePrints, contractTypePrints,
contractTypes, contractTypes,
burialSiteTypes, funeralHomes,
burialSiteStatuses,
cemeteries,
workOrderTypes, workOrderTypes,
isCreate: false isCreate: false
}); });

View File

@ -1,11 +1,9 @@
import type { Request, Response } from 'express' import type { Request, Response } from 'express'
import getCemeteries from '../../database/getCemeteries.js'
import getContract from '../../database/getContract.js' import getContract from '../../database/getContract.js'
import getFuneralHomes from '../../database/getFuneralHomes.js'
import { getConfigProperty } from '../../helpers/config.helpers.js' import { getConfigProperty } from '../../helpers/config.helpers.js'
import { import {
getBurialSiteStatuses,
getBurialSiteTypes,
getContractTypePrintsById, getContractTypePrintsById,
getContractTypes, getContractTypes,
getWorkOrderTypes getWorkOrderTypes
@ -33,9 +31,7 @@ export default async function handler(
) )
const contractTypes = await getContractTypes() const contractTypes = await getContractTypes()
const burialSiteTypes = await getBurialSiteTypes() const funeralHomes = await getFuneralHomes()
const burialSiteStatuses = await getBurialSiteStatuses()
const cemeteries = await getCemeteries()
const workOrderTypes = await getWorkOrderTypes() const workOrderTypes = await getWorkOrderTypes()
response.render('contract-edit', { response.render('contract-edit', {
@ -44,9 +40,7 @@ export default async function handler(
contractTypePrints, contractTypePrints,
contractTypes, contractTypes,
burialSiteTypes, funeralHomes,
burialSiteStatuses,
cemeteries,
workOrderTypes, workOrderTypes,
isCreate: false isCreate: false

View File

@ -1,12 +1,16 @@
import { dateToInteger, dateToString } from '@cityssm/utils-datetime'; import { dateToInteger, dateToString } from '@cityssm/utils-datetime';
import getBurialSite from '../../database/getBurialSite.js'; import getBurialSite from '../../database/getBurialSite.js';
import getCemeteries from '../../database/getCemeteries.js'; import getFuneralHomes from '../../database/getFuneralHomes.js';
import { getBurialSiteStatuses, getBurialSiteTypes, getContractTypes } from '../../helpers/functions.cache.js'; import { getConfigProperty } from '../../helpers/config.helpers.js';
import { getContractTypes } from '../../helpers/functions.cache.js';
export default async function handler(request, response) { export default async function handler(request, response) {
const startDate = new Date(); const startDate = new Date();
const contract = { const contract = {
isPreneed: false,
contractStartDate: dateToInteger(startDate), contractStartDate: dateToInteger(startDate),
contractStartDateString: dateToString(startDate) contractStartDateString: dateToString(startDate),
purchaserCity: getConfigProperty('settings.cityDefault'),
purchaserProvince: getConfigProperty('settings.provinceDefault')
}; };
if (request.query.burialSiteId !== undefined) { if (request.query.burialSiteId !== undefined) {
const burialSite = await getBurialSite(request.query.burialSiteId); const burialSite = await getBurialSite(request.query.burialSiteId);
@ -18,16 +22,12 @@ export default async function handler(request, response) {
} }
} }
const contractTypes = await getContractTypes(); const contractTypes = await getContractTypes();
const burialSiteTypes = await getBurialSiteTypes(); const funeralHomes = await getFuneralHomes();
const burialSiteStatuses = await getBurialSiteStatuses();
const cemeteries = await getCemeteries();
response.render('contract-edit', { response.render('contract-edit', {
headTitle: 'Create a New Contract', headTitle: 'Create a New Contract',
contract, contract,
contractTypes, contractTypes,
burialSiteTypes, funeralHomes,
burialSiteStatuses,
cemeteries,
isCreate: true isCreate: true
}); });
} }

View File

@ -2,12 +2,9 @@ import { dateToInteger, dateToString } from '@cityssm/utils-datetime'
import type { Request, Response } from 'express' import type { Request, Response } from 'express'
import getBurialSite from '../../database/getBurialSite.js' import getBurialSite from '../../database/getBurialSite.js'
import getCemeteries from '../../database/getCemeteries.js' import getFuneralHomes from '../../database/getFuneralHomes.js'
import { import { getConfigProperty } from '../../helpers/config.helpers.js'
getBurialSiteStatuses, import { getContractTypes } from '../../helpers/functions.cache.js'
getBurialSiteTypes,
getContractTypes
} from '../../helpers/functions.cache.js'
import type { Contract } from '../../types/recordTypes.js' import type { Contract } from '../../types/recordTypes.js'
export default async function handler( export default async function handler(
@ -17,8 +14,11 @@ export default async function handler(
const startDate = new Date() const startDate = new Date()
const contract: Partial<Contract> = { const contract: Partial<Contract> = {
isPreneed: false,
contractStartDate: dateToInteger(startDate), contractStartDate: dateToInteger(startDate),
contractStartDateString: dateToString(startDate) contractStartDateString: dateToString(startDate),
purchaserCity: getConfigProperty('settings.cityDefault'),
purchaserProvince: getConfigProperty('settings.provinceDefault')
} }
if (request.query.burialSiteId !== undefined) { if (request.query.burialSiteId !== undefined) {
@ -33,18 +33,14 @@ export default async function handler(
} }
const contractTypes = await getContractTypes() const contractTypes = await getContractTypes()
const burialSiteTypes = await getBurialSiteTypes() const funeralHomes = await getFuneralHomes()
const burialSiteStatuses = await getBurialSiteStatuses()
const cemeteries = await getCemeteries()
response.render('contract-edit', { response.render('contract-edit', {
headTitle: 'Create a New Contract', headTitle: 'Create a New Contract',
contract, contract,
contractTypes, contractTypes,
burialSiteTypes, funeralHomes,
burialSiteStatuses,
cemeteries,
isCreate: true isCreate: true
}) })

View File

@ -1,4 +1,4 @@
import type { BurialSiteStatus, BurialSiteType, ContractType, ContractTypeField, WorkOrderMilestoneType, WorkOrderType } from '../types/recordTypes.js'; import type { BurialSiteStatus, BurialSiteType, ContractType, ContractTypeField, IntermentCommittalType, IntermentContainerType, WorkOrderMilestoneType, WorkOrderType } from '../types/recordTypes.js';
export declare function getBurialSiteStatuses(): Promise<BurialSiteStatus[]>; export declare function getBurialSiteStatuses(): Promise<BurialSiteStatus[]>;
export declare function getBurialSiteStatusById(burialSiteStatusId: number): Promise<BurialSiteStatus | undefined>; export declare function getBurialSiteStatusById(burialSiteStatusId: number): Promise<BurialSiteStatus | undefined>;
export declare function getBurialSiteStatusByBurialSiteStatus(burialSiteStatus: string): Promise<BurialSiteStatus | undefined>; export declare function getBurialSiteStatusByBurialSiteStatus(burialSiteStatus: string): Promise<BurialSiteStatus | undefined>;
@ -10,6 +10,10 @@ export declare function getAllContractTypeFields(): Promise<ContractTypeField[]>
export declare function getContractTypeById(contractTypeId: number): Promise<ContractType | undefined>; export declare function getContractTypeById(contractTypeId: number): Promise<ContractType | undefined>;
export declare function getContractTypeByContractType(contractTypeString: string): Promise<ContractType | undefined>; export declare function getContractTypeByContractType(contractTypeString: string): Promise<ContractType | undefined>;
export declare function getContractTypePrintsById(contractTypeId: number): Promise<string[]>; export declare function getContractTypePrintsById(contractTypeId: number): Promise<string[]>;
export declare function getIntermentContainerTypes(): Promise<IntermentContainerType[]>;
export declare function getIntermentContainerTypeById(intermentContainerTypeId: number): Promise<IntermentContainerType | undefined>;
export declare function getIntermentCommittalTypes(): Promise<IntermentCommittalType[]>;
export declare function getIntermentCommittalTypeById(intermentCommittalTypeId: number): Promise<IntermentCommittalType | undefined>;
export declare function getWorkOrderTypes(): Promise<WorkOrderType[]>; export declare function getWorkOrderTypes(): Promise<WorkOrderType[]>;
export declare function getWorkOrderTypeById(workOrderTypeId: number): Promise<WorkOrderType | undefined>; export declare function getWorkOrderTypeById(workOrderTypeId: number): Promise<WorkOrderType | undefined>;
export declare function getWorkOrderMilestoneTypes(): Promise<WorkOrderMilestoneType[]>; export declare function getWorkOrderMilestoneTypes(): Promise<WorkOrderMilestoneType[]>;
@ -17,6 +21,6 @@ export declare function getWorkOrderMilestoneTypeById(workOrderMilestoneTypeId:
export declare function getWorkOrderMilestoneTypeByWorkOrderMilestoneType(workOrderMilestoneTypeString: string): Promise<WorkOrderMilestoneType | undefined>; export declare function getWorkOrderMilestoneTypeByWorkOrderMilestoneType(workOrderMilestoneTypeString: string): Promise<WorkOrderMilestoneType | undefined>;
export declare function preloadCaches(): Promise<void>; export declare function preloadCaches(): Promise<void>;
export declare function clearCaches(): void; export declare function clearCaches(): void;
type CacheTableNames = 'BurialSiteStatuses' | 'BurialSiteTypes' | 'BurialSiteTypeFields' | 'ContractTypes' | 'ContractTypeFields' | 'ContractTypePrints' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes' | 'FeeCategories' | 'Fees'; type CacheTableNames = 'BurialSiteStatuses' | 'BurialSiteTypes' | 'BurialSiteTypeFields' | 'ContractTypes' | 'ContractTypeFields' | 'ContractTypePrints' | 'IntermentContainerTypes' | 'IntermentCommittalTypes' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes' | 'FeeCategories' | 'Fees';
export declare function clearCacheByTableName(tableName: CacheTableNames, relayMessage?: boolean): void; export declare function clearCacheByTableName(tableName: CacheTableNames, relayMessage?: boolean): void;
export {}; export {};

View File

@ -6,6 +6,8 @@ import getBurialSiteStatusesFromDatabase from '../database/getBurialSiteStatuses
import getBurialSiteTypesFromDatabase from '../database/getBurialSiteTypes.js'; import getBurialSiteTypesFromDatabase from '../database/getBurialSiteTypes.js';
import getContractTypeFieldsFromDatabase from '../database/getContractTypeFields.js'; import getContractTypeFieldsFromDatabase from '../database/getContractTypeFields.js';
import getContractTypesFromDatabase from '../database/getContractTypes.js'; import getContractTypesFromDatabase from '../database/getContractTypes.js';
import getIntermentCommittalTypesFromDatabase from '../database/getIntermentCommittalTypes.js';
import getIntermentContainerTypesFromDatabase from '../database/getIntermentContainerTypes.js';
import getWorkOrderMilestoneTypesFromDatabase from '../database/getWorkOrderMilestoneTypes.js'; import getWorkOrderMilestoneTypesFromDatabase from '../database/getWorkOrderMilestoneTypes.js';
import getWorkOrderTypesFromDatabase from '../database/getWorkOrderTypes.js'; import getWorkOrderTypesFromDatabase from '../database/getWorkOrderTypes.js';
import { DEBUG_NAMESPACE } from '../debug.config.js'; import { DEBUG_NAMESPACE } from '../debug.config.js';
@ -96,6 +98,40 @@ function clearContractTypesCache() {
contractTypes = undefined; contractTypes = undefined;
allContractTypeFields = undefined; allContractTypeFields = undefined;
} }
/*
* Interment Container Types
*/
let intermentContainerTypes;
export async function getIntermentContainerTypes() {
if (intermentContainerTypes === undefined) {
intermentContainerTypes = await getIntermentContainerTypesFromDatabase();
}
return intermentContainerTypes;
}
export async function getIntermentContainerTypeById(intermentContainerTypeId) {
const cachedContainerTypes = await getIntermentContainerTypes();
return cachedContainerTypes.find((currentContainerType) => currentContainerType.intermentContainerTypeId === intermentContainerTypeId);
}
function clearIntermentContainerTypesCache() {
intermentContainerTypes = undefined;
}
/*
* Interment Committal Types
*/
let intermentCommittalTypes;
export async function getIntermentCommittalTypes() {
if (intermentCommittalTypes === undefined) {
intermentCommittalTypes = await getIntermentCommittalTypesFromDatabase();
}
return intermentCommittalTypes;
}
export async function getIntermentCommittalTypeById(intermentCommittalTypeId) {
const cachedCommittalTypes = await getIntermentCommittalTypes();
return cachedCommittalTypes.find((currentCommittalType) => currentCommittalType.intermentCommittalTypeId === intermentCommittalTypeId);
}
function clearIntermentCommittalTypesCache() {
intermentCommittalTypes = undefined;
}
/* /*
* Work Order Types * Work Order Types
*/ */
@ -169,6 +205,14 @@ export function clearCacheByTableName(tableName, relayMessage = true) {
clearContractTypesCache(); clearContractTypesCache();
break; break;
} }
case 'IntermentContainerTypes': {
clearIntermentContainerTypesCache();
break;
}
case 'IntermentCommittalTypes': {
clearIntermentCommittalTypesCache();
break;
}
case 'WorkOrderMilestoneTypes': { case 'WorkOrderMilestoneTypes': {
clearWorkOrderMilestoneTypesCache(); clearWorkOrderMilestoneTypesCache();
break; break;

View File

@ -9,6 +9,8 @@ import getBurialSiteStatusesFromDatabase from '../database/getBurialSiteStatuses
import getBurialSiteTypesFromDatabase from '../database/getBurialSiteTypes.js' import getBurialSiteTypesFromDatabase from '../database/getBurialSiteTypes.js'
import getContractTypeFieldsFromDatabase from '../database/getContractTypeFields.js' import getContractTypeFieldsFromDatabase from '../database/getContractTypeFields.js'
import getContractTypesFromDatabase from '../database/getContractTypes.js' import getContractTypesFromDatabase from '../database/getContractTypes.js'
import getIntermentCommittalTypesFromDatabase from '../database/getIntermentCommittalTypes.js'
import getIntermentContainerTypesFromDatabase from '../database/getIntermentContainerTypes.js'
import getWorkOrderMilestoneTypesFromDatabase from '../database/getWorkOrderMilestoneTypes.js' import getWorkOrderMilestoneTypesFromDatabase from '../database/getWorkOrderMilestoneTypes.js'
import getWorkOrderTypesFromDatabase from '../database/getWorkOrderTypes.js' import getWorkOrderTypesFromDatabase from '../database/getWorkOrderTypes.js'
import { DEBUG_NAMESPACE } from '../debug.config.js' import { DEBUG_NAMESPACE } from '../debug.config.js'
@ -21,6 +23,8 @@ import type {
BurialSiteType, BurialSiteType,
ContractType, ContractType,
ContractTypeField, ContractTypeField,
IntermentCommittalType,
IntermentContainerType,
WorkOrderMilestoneType, WorkOrderMilestoneType,
WorkOrderType WorkOrderType
} from '../types/recordTypes.js' } from '../types/recordTypes.js'
@ -178,6 +182,68 @@ function clearContractTypesCache(): void {
allContractTypeFields = undefined allContractTypeFields = undefined
} }
/*
* Interment Container Types
*/
let intermentContainerTypes: IntermentContainerType[] | undefined
export async function getIntermentContainerTypes(): Promise<
IntermentContainerType[]
> {
if (intermentContainerTypes === undefined) {
intermentContainerTypes = await getIntermentContainerTypesFromDatabase()
}
return intermentContainerTypes
}
export async function getIntermentContainerTypeById(
intermentContainerTypeId: number
): Promise<IntermentContainerType | undefined> {
const cachedContainerTypes = await getIntermentContainerTypes()
return cachedContainerTypes.find(
(currentContainerType) =>
currentContainerType.intermentContainerTypeId === intermentContainerTypeId
)
}
function clearIntermentContainerTypesCache(): void {
intermentContainerTypes = undefined
}
/*
* Interment Committal Types
*/
let intermentCommittalTypes: IntermentCommittalType[] | undefined
export async function getIntermentCommittalTypes(): Promise<
IntermentCommittalType[]
> {
if (intermentCommittalTypes === undefined) {
intermentCommittalTypes = await getIntermentCommittalTypesFromDatabase()
}
return intermentCommittalTypes
}
export async function getIntermentCommittalTypeById(
intermentCommittalTypeId: number
): Promise<IntermentCommittalType | undefined> {
const cachedCommittalTypes = await getIntermentCommittalTypes()
return cachedCommittalTypes.find(
(currentCommittalType) =>
currentCommittalType.intermentCommittalTypeId === intermentCommittalTypeId
)
}
function clearIntermentCommittalTypesCache(): void {
intermentCommittalTypes = undefined
}
/* /*
* Work Order Types * Work Order Types
*/ */
@ -278,6 +344,8 @@ type CacheTableNames =
| 'ContractTypes' | 'ContractTypes'
| 'ContractTypeFields' | 'ContractTypeFields'
| 'ContractTypePrints' | 'ContractTypePrints'
| 'IntermentContainerTypes'
| 'IntermentCommittalTypes'
| 'WorkOrderMilestoneTypes' | 'WorkOrderMilestoneTypes'
| 'WorkOrderTypes' | 'WorkOrderTypes'
| 'FeeCategories' | 'FeeCategories'
@ -306,6 +374,16 @@ export function clearCacheByTableName(
break break
} }
case 'IntermentContainerTypes': {
clearIntermentContainerTypesCache()
break
}
case 'IntermentCommittalTypes': {
clearIntermentCommittalTypesCache()
break
}
case 'WorkOrderMilestoneTypes': { case 'WorkOrderMilestoneTypes': {
clearWorkOrderMilestoneTypesCache() clearWorkOrderMilestoneTypesCache()
break break

View File

@ -13,6 +13,8 @@
</header> </header>
<section class="modal-card-body"> <section class="modal-card-body">
<form id="form--contractTypeAdd"> <form id="form--contractTypeAdd">
<div class="columns">
<div class="column">
<div class="field"> <div class="field">
<label class="label" for="contractTypeAdd--contractType" <label class="label" for="contractTypeAdd--contractType"
>Contract Type</label >Contract Type</label
@ -28,6 +30,22 @@
/> />
</div> </div>
</div> </div>
</div>
<div class="column">
<label class="checkbox">
<input
type="checkbox"
id="contractTypeAdd--isPreneed"
name="isPreneed"
/>
Contract Type is Preneed
</label>
<p class="help">
When checked, interments associated with the contract
will be considered reserved, not occupied.
</p>
</div>
</div>
</form> </form>
</section> </section>
<footer class="modal-card-foot justify-right"> <footer class="modal-card-foot justify-right">

View File

@ -2,9 +2,7 @@
<div class="modal-background"></div> <div class="modal-background"></div>
<div class="modal-card has-width-900"> <div class="modal-card has-width-900">
<header class="modal-card-head"> <header class="modal-card-head">
<h3 class="modal-card-title"> <h3 class="modal-card-title">Update Contract Type</h3>
Update Contract Type
</h3>
<button <button
class="delete is-close-modal-button" class="delete is-close-modal-button"
aria-label="close" aria-label="close"
@ -19,6 +17,8 @@
name="contractTypeId" name="contractTypeId"
type="hidden" type="hidden"
/> />
<div class="columns">
<div class="column">
<div class="field"> <div class="field">
<label class="label" for="contractTypeEdit--contractType" <label class="label" for="contractTypeEdit--contractType"
>Contract Type</label >Contract Type</label
@ -34,6 +34,22 @@
/> />
</div> </div>
</div> </div>
</div>
<div class="column">
<label class="checkbox">
<input
type="checkbox"
id="contractTypeEdit--isPreneed"
name="isPreneed"
/>
Contract Type is Preneed
</label>
<p class="help">
When checked, interments associated with the contract will be
considered reserved, not occupied.
</p>
</div>
</div>
</form> </form>
</section> </section>
<footer class="modal-card-foot justify-right"> <footer class="modal-card-foot justify-right">
@ -43,9 +59,7 @@
form="form--contractTypeEdit" form="form--contractTypeEdit"
> >
<span class="icon"><i class="fas fa-save" aria-hidden="true"></i></span> <span class="icon"><i class="fas fa-save" aria-hidden="true"></i></span>
<span <span>Update Contract Type</span>
>Update Contract Type</span
>
</button> </button>
<button class="button is-close-modal-button" type="button">Cancel</button> <button class="button is-close-modal-button" type="button">Cancel</button>
</footer> </footer>

View File

@ -3,7 +3,7 @@
<div class="modal-card"> <div class="modal-card">
<header class="modal-card-head"> <header class="modal-card-head">
<h3 class="modal-card-title"> <h3 class="modal-card-title">
Select a <span class="alias" data-alias="Lot"></span> Select a Burial Site
</h3> </h3>
<button <button
class="delete is-close-modal-button" class="delete is-close-modal-button"
@ -12,28 +12,16 @@
></button> ></button>
</header> </header>
<section class="modal-card-body"> <section class="modal-card-body">
<div class="tabs is-boxed">
<ul>
<li class="is-active">
<a href="#tab--lotSelect">From Existing</a>
</li>
<li>
<a href="#tab--lotCreate">Create New</a>
</li>
</ul>
</div>
<div class="tab-container">
<div id="tab--lotSelect">
<div class="box"> <div class="box">
<form id="form--lotSelect"> <form id="form--burialSiteSelect">
<input name="limit" type="hidden" value="100" /> <input name="limit" type="hidden" value="100" />
<input name="offset" type="hidden" value="0" /> <input name="offset" type="hidden" value="0" />
<div class="field"> <div class="field">
<div class="control has-icons-left"> <div class="control has-icons-left">
<input <input
class="input" class="input"
id="lotSelect--lotName" id="burialSiteSelect--burialSiteName"
name="lotName" name="burialSiteName"
type="text" type="text"
/> />
<span class="icon is-small is-left"> <span class="icon is-small is-left">
@ -45,7 +33,7 @@
<div class="control has-icons-left"> <div class="control has-icons-left">
<div class="select is-fullwidth"> <div class="select is-fullwidth">
<select <select
id="lotSelect--occupancyStatus" id="burialSiteSelect--occupancyStatus"
name="occupancyStatus" name="occupancyStatus"
> >
<option value="">(All Statuses)</option> <option value="">(All Statuses)</option>
@ -62,93 +50,7 @@
</div> </div>
</form> </form>
</div> </div>
<div id="resultsContainer--lotSelect"></div> <div id="resultsContainer--burialSiteSelect"></div>
</div>
<div class="is-hidden" id="tab--lotCreate">
<div class="message is-info is-small">
<p class="message-body">
Be sure to confirm if the
<span class="alias" data-alias="lot"></span> exists before
creating a new one.
</p>
</div>
<form id="form--lotCreate">
<input name="mapKey" type="hidden" value="" />
<input name="lotLatitude" type="hidden" value="" />
<input name="lotLongitude" type="hidden" value="" />
<div class="field">
<label class="label" for="lotCreate--lotName"
>New <span class="alias" data-alias="Lot"></span> Name</label
>
<div class="control">
<input
class="input"
id="lotCreate--lotName"
name="lotName"
maxlength="100"
required
/>
</div>
</div>
<div class="columns">
<div class="column">
<div class="field">
<label class="label" for="lotCreate--burialSiteTypeId"
><span class="alias" data-alias="Lot"></span> Type</label
>
<div class="control">
<div class="select is-fullwidth">
<select
id="lotCreate--burialSiteTypeId"
name="burialSiteTypeId"
required
>
<option value="">(No Type)</option>
</select>
</div>
</div>
</div>
</div>
<div class="column">
<div class="field">
<label class="label" for="lotCreate--burialSiteStatusId"
><span class="alias" data-alias="Lot"></span> Status</label
>
<div class="control">
<div class="select is-fullwidth">
<select id="lotCreate--burialSiteStatusId" name="burialSiteStatusId">
<option value="">(No Status)</option>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="field">
<label class="label" for="lotCreate--mapId"
><span class="alias" data-alias="Map"></span
></label>
<div class="control">
<div class="select is-fullwidth">
<select id="lotCreate--mapId" name="mapId">
<option value="">(None Selected)</option>
</select>
</div>
</div>
</div>
<div class="has-text-right">
<button class="button is-success" type="submit">
<span class="icon"
><i class="fas fa-plus" aria-hidden="true"></i
></span>
<span
>Create New&nbsp;<span class="alias" data-alias="Lot"></span
></span>
</button>
</div>
</form>
</div>
</div>
</section> </section>
<footer class="modal-card-foot justify-right"> <footer class="modal-card-foot justify-right">
<button class="button is-close-modal-button" type="button">Cancel</button> <button class="button is-close-modal-button" type="button">Cancel</button>

View File

@ -1,4 +1,6 @@
"use strict"; "use strict";
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable max-lines */
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
(() => { (() => {
const sunrise = exports.sunrise; const sunrise = exports.sunrise;
@ -192,6 +194,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
if (isCreate) { if (isCreate) {
const contractFieldsContainerElement = document.querySelector('#container--contractFields'); const contractFieldsContainerElement = document.querySelector('#container--contractFields');
contractTypeIdElement.addEventListener('change', () => { contractTypeIdElement.addEventListener('change', () => {
const recipientOrPreneedElements = document.querySelectorAll('.is-recipient-or-deceased');
const isPreneed = contractTypeIdElement.selectedOptions[0].dataset.isPreneed === 'true';
for (const recipientOrPreneedElement of recipientOrPreneedElements) {
recipientOrPreneedElement.textContent = isPreneed
? 'Recipient'
: 'Deceased';
}
if (contractTypeIdElement.value === '') { if (contractTypeIdElement.value === '') {
contractFieldsContainerElement.innerHTML = `<div class="message is-info"> contractFieldsContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">Select the contract type to load the available fields.</p> <p class="message-body">Select the contract type to load the available fields.</p>
@ -291,7 +300,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
const currentBurialSiteName = clickEvent.currentTarget const currentBurialSiteName = clickEvent.currentTarget
.value; .value;
let burialSiteSelectCloseModalFunction; let burialSiteSelectCloseModalFunction;
let burialSiteSelectModalElement;
let burialSiteSelectFormElement; let burialSiteSelectFormElement;
let burialSiteSelectResultsElement; let burialSiteSelectResultsElement;
function renderSelectedBurialSiteAndClose(burialSiteId, burialSiteName) { function renderSelectedBurialSiteAndClose(burialSiteId, burialSiteName) {
@ -303,8 +311,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
function selectExistingBurialSite(clickEvent) { function selectExistingBurialSite(clickEvent) {
clickEvent.preventDefault(); clickEvent.preventDefault();
const selectedLotElement = clickEvent.currentTarget; const selectedBurialSiteElement = clickEvent.currentTarget;
renderSelectedBurialSiteAndClose(selectedLotElement.dataset.burialSiteId ?? '', selectedLotElement.dataset.burialSiteName ?? ''); renderSelectedBurialSiteAndClose(selectedBurialSiteElement.dataset.burialSiteId ?? '', selectedBurialSiteElement.dataset.burialSiteName ?? '');
} }
function searchBurialSites() { function searchBurialSites() {
// eslint-disable-next-line no-unsanitized/property // eslint-disable-next-line no-unsanitized/property
@ -326,7 +334,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
panelBlockElement.href = '#'; panelBlockElement.href = '#';
panelBlockElement.dataset.burialSiteId = panelBlockElement.dataset.burialSiteId =
burialSite.burialSiteId.toString(); burialSite.burialSiteId.toString();
panelBlockElement.dataset.lotName = burialSite.burialSiteName; panelBlockElement.dataset.burialSiteName = burialSite.burialSiteName;
// eslint-disable-next-line no-unsanitized/property // eslint-disable-next-line no-unsanitized/property
panelBlockElement.innerHTML = `<div class="columns"> panelBlockElement.innerHTML = `<div class="columns">
<div class="column"> <div class="column">
@ -347,33 +355,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
burialSiteSelectResultsElement.append(panelElement); burialSiteSelectResultsElement.append(panelElement);
}); });
} }
function createBurialSiteAndSelect(submitEvent) {
submitEvent.preventDefault();
const burialSiteName = burialSiteSelectModalElement.querySelector('#burialSiteCreate--burialSiteName').value;
cityssm.postJSON(`${sunrise.urlPrefix}/burialSites/doCreateBurialSite`, submitEvent.currentTarget, (rawResponseJSON) => {
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
renderSelectedBurialSiteAndClose(responseJSON.burialSiteId ?? '', burialSiteName);
}
else {
bulmaJS.alert({
title: `Error Creating Burial Site`,
message: responseJSON.errorMessage ?? '',
contextualColorName: 'danger'
});
}
});
}
cityssm.openHtmlModal('contract-selectBurialSite', { cityssm.openHtmlModal('contract-selectBurialSite', {
onshow(modalElement) { onshow(modalElement) {
sunrise.populateAliases(modalElement); sunrise.populateAliases(modalElement);
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
burialSiteSelectModalElement = modalElement;
burialSiteSelectCloseModalFunction = closeModalFunction; burialSiteSelectCloseModalFunction = closeModalFunction;
bulmaJS.init(modalElement); bulmaJS.init(modalElement);
// search Tab // Search Tab
const burialSiteNameFilterElement = modalElement.querySelector('#burialSiteSelect--burialSiteName'); const burialSiteNameFilterElement = modalElement.querySelector('#burialSiteSelect--burialSiteName');
if (document.querySelector('#contract--burialSiteId').value !== '') { if (document.querySelector('#contract--burialSiteId').value !== '') {
burialSiteNameFilterElement.value = currentBurialSiteName; burialSiteNameFilterElement.value = currentBurialSiteName;
@ -391,32 +381,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
submitEvent.preventDefault(); submitEvent.preventDefault();
}); });
searchBurialSites(); searchBurialSites();
const burialSiteTypeElement = modalElement.querySelector('#burialSiteCreate--burialSiteTypeId');
for (const burialSiteType of exports.burialSiteTypes) {
const optionElement = document.createElement('option');
optionElement.value = burialSiteType.burialSiteTypeId.toString();
optionElement.textContent = burialSiteType.burialSiteType;
burialSiteTypeElement.append(optionElement);
}
const burialSiteStatusElement = modalElement.querySelector('#burialSiteCreate--burialSiteStatusId');
for (const burialSiteStatus of exports.burialSiteStatuses) {
const optionElement = document.createElement('option');
optionElement.value = burialSiteStatus.burialSiteStatusId.toString();
optionElement.textContent = burialSiteStatus.burialSiteStatus;
burialSiteStatusElement.append(optionElement);
}
const mapElement = modalElement.querySelector('#burialSiteCreate--cemeteryId');
for (const cemetery of exports.cemeteries) {
const optionElement = document.createElement('option');
optionElement.value = cemetery.cemeteryId.toString();
optionElement.textContent =
(cemetery.cemeteryName ?? '') === ''
? '(No Name)'
: cemetery.cemeteryName ?? '';
mapElement.append(optionElement);
}
;
modalElement.querySelector('#form--burialSiteCreate').addEventListener('submit', createBurialSiteAndSelect);
}, },
onremoved() { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
@ -462,30 +426,56 @@ Object.defineProperty(exports, "__esModule", { value: true });
endDatePicker.refresh(); endDatePicker.refresh();
}); });
sunrise.initializeUnlockFieldButtons(formElement); sunrise.initializeUnlockFieldButtons(formElement);
if (!isCreate) { if (isCreate) {
/*
* Deceased
*/
document
.querySelector('#button--copyFromPurchaser')
?.addEventListener('click', () => {
const fieldsToCopy = [
'Name',
'Address1',
'Address2',
'City',
'Province',
'PostalCode'
];
for (const fieldToCopy of fieldsToCopy) {
const purchaserFieldElement = document.querySelector(`#contract--purchaser${fieldToCopy}`);
const deceasedFieldElement = document.querySelector(`#contract--deceased${fieldToCopy}`);
deceasedFieldElement.value = purchaserFieldElement.value;
}
setUnsavedChanges();
});
}
else {
/**
* Interments
*/
let contractInterments = exports.contractInterments;
delete exports.contractInterments;
function renderContractInterments() {
}
/** /**
* Comments * Comments
*/ */
;
(() => {
let contractComments = exports.contractComments; let contractComments = exports.contractComments;
delete exports.contractComments; delete exports.contractComments;
function openEditLotOccupancyComment(clickEvent) { function openEditContractComment(clickEvent) {
const contractCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset const contractCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset
.contractCommentId ?? '', 10); .contractCommentId ?? '', 10);
const contractComment = contractComments.find((currentLotOccupancyComment) => { const contractComment = contractComments.find((currentComment) => currentComment.contractCommentId === contractCommentId);
return (currentLotOccupancyComment.contractCommentId === contractCommentId);
});
let editFormElement; let editFormElement;
let editCloseModalFunction; let editCloseModalFunction;
function editComment(submitEvent) { function editContractComment(submitEvent) {
submitEvent.preventDefault(); submitEvent.preventDefault();
cityssm.postJSON(`${sunrise.urlPrefix}/contracts/doUpdateContractComment`, editFormElement, (rawResponseJSON) => { cityssm.postJSON(`${sunrise.urlPrefix}/contracts/doUpdateContractComment`, editFormElement, (rawResponseJSON) => {
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
contractComments = responseJSON.contractComments ?? []; contractComments = responseJSON.contractComments ?? [];
editCloseModalFunction(); editCloseModalFunction();
renderLotOccupancyComments(); renderContractComments();
} }
else { else {
bulmaJS.alert({ bulmaJS.alert({
@ -517,7 +507,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
sunrise.initializeDatePickers(modalElement); sunrise.initializeDatePickers(modalElement);
modalElement.querySelector('#contractCommentEdit--contractComment').focus(); modalElement.querySelector('#contractCommentEdit--contractComment').focus();
editFormElement = modalElement.querySelector('form'); editFormElement = modalElement.querySelector('form');
editFormElement.addEventListener('submit', editComment); editFormElement.addEventListener('submit', editContractComment);
editCloseModalFunction = closeModalFunction; editCloseModalFunction = closeModalFunction;
}, },
onremoved() { onremoved() {
@ -525,7 +515,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
}); });
} }
function deleteLotOccupancyComment(clickEvent) { function deleteContractComment(clickEvent) {
const contractCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset const contractCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset
.contractCommentId ?? '', 10); .contractCommentId ?? '', 10);
function doDelete() { function doDelete() {
@ -536,7 +526,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
contractComments = responseJSON.contractComments; contractComments = responseJSON.contractComments;
renderLotOccupancyComments(); renderContractComments();
} }
else { else {
bulmaJS.alert({ bulmaJS.alert({
@ -557,7 +547,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
contextualColorName: 'warning' contextualColorName: 'warning'
}); });
} }
function renderLotOccupancyComments() { function renderContractComments() {
const containerElement = document.querySelector('#container--contractComments'); const containerElement = document.querySelector('#container--contractComments');
if (contractComments.length === 0) { if (contractComments.length === 0) {
containerElement.innerHTML = `<div class="message is-info"> containerElement.innerHTML = `<div class="message is-info">
@ -568,7 +558,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const tableElement = document.createElement('table'); const tableElement = document.createElement('table');
tableElement.className = 'table is-fullwidth is-striped is-hoverable'; tableElement.className = 'table is-fullwidth is-striped is-hoverable';
tableElement.innerHTML = `<thead><tr> tableElement.innerHTML = `<thead><tr>
<th>Commentor</th> <th>Author</th>
<th>Comment Date</th> <th>Comment Date</th>
<th>Comment</th> <th>Comment</th>
<th class="is-hidden-print"><span class="is-sr-only">Options</span></th> <th class="is-hidden-print"><span class="is-sr-only">Options</span></th>
@ -599,10 +589,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
</td>`; </td>`;
tableRowElement tableRowElement
.querySelector('.button--edit') .querySelector('.button--edit')
?.addEventListener('click', openEditLotOccupancyComment); ?.addEventListener('click', openEditContractComment);
tableRowElement tableRowElement
.querySelector('.button--delete') .querySelector('.button--delete')
?.addEventListener('click', deleteLotOccupancyComment); ?.addEventListener('click', deleteContractComment);
tableElement.querySelector('tbody')?.append(tableRowElement); tableElement.querySelector('tbody')?.append(tableRowElement);
} }
containerElement.innerHTML = ''; containerElement.innerHTML = '';
@ -620,7 +610,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
if (responseJSON.success) { if (responseJSON.success) {
contractComments = responseJSON.contractComments; contractComments = responseJSON.contractComments;
addCloseModalFunction(); addCloseModalFunction();
renderLotOccupancyComments(); renderContractComments();
} }
else { else {
bulmaJS.alert({ bulmaJS.alert({
@ -638,20 +628,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
modalElement.querySelector('#contractCommentAdd--contractComment').focus(); modalElement.querySelector('#contractCommentAdd--comment').focus();
addFormElement = modalElement.querySelector('form'); addFormElement = modalElement.querySelector('form');
addFormElement.addEventListener('submit', addComment); addFormElement.addEventListener('submit', addComment);
addCloseModalFunction = closeModalFunction; addCloseModalFunction = closeModalFunction;
}, },
onremoved: () => { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
document.querySelector('#button--addComment').focus(); document.querySelector('#button--addComment').focus();
} }
}); });
}); });
renderLotOccupancyComments(); renderContractComments();
})(); /**
(() => { * Fees
*/
let contractFees = exports.contractFees; let contractFees = exports.contractFees;
delete exports.contractFees; delete exports.contractFees;
const contractFeesContainerElement = document.querySelector('#container--contractFees'); const contractFeesContainerElement = document.querySelector('#container--contractFees');
@ -664,12 +655,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
return feeGrandTotal; return feeGrandTotal;
} }
function editLotOccupancyFeeQuantity(clickEvent) { function editContractFeeQuantity(clickEvent) {
const feeId = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset const feeId = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset
.feeId ?? '', 10); .feeId ?? '', 10);
const fee = contractFees.find((possibleFee) => { const fee = contractFees.find((possibleFee) => possibleFee.feeId === feeId);
return possibleFee.feeId === feeId;
});
let updateCloseModalFunction; let updateCloseModalFunction;
function doUpdateQuantity(formEvent) { function doUpdateQuantity(formEvent) {
formEvent.preventDefault(); formEvent.preventDefault();
@ -677,7 +666,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
contractFees = responseJSON.contractFees; contractFees = responseJSON.contractFees;
renderLotOccupancyFees(); renderContractFees();
updateCloseModalFunction(); updateCloseModalFunction();
} }
else { else {
@ -720,7 +709,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
contractFees = responseJSON.contractFees; contractFees = responseJSON.contractFees;
renderLotOccupancyFees(); renderContractFees();
} }
else { else {
bulmaJS.alert({ bulmaJS.alert({
@ -741,15 +730,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
}); });
} }
function renderLotOccupancyFees() { // eslint-disable-next-line complexity
function renderContractFees() {
if (contractFees.length === 0) { if (contractFees.length === 0) {
contractFeesContainerElement.innerHTML = `<div class="message is-info"> contractFeesContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no fees associated with this record.</p> <p class="message-body">There are no fees associated with this record.</p>
</div>`; </div>`;
renderLotOccupancyTransactions(); renderContractTransactions();
return; return;
} }
// eslint-disable-next-line no-secrets/no-secrets
contractFeesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable"> contractFeesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr> <thead><tr>
<th>Fee</th> <th>Fee</th>
@ -813,7 +802,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
</td>`; </td>`;
tableRowElement tableRowElement
.querySelector('.button--editQuantity') .querySelector('.button--editQuantity')
?.addEventListener('click', editLotOccupancyFeeQuantity); ?.addEventListener('click', editContractFeeQuantity);
tableRowElement tableRowElement
.querySelector('.button--delete') .querySelector('.button--delete')
?.addEventListener('click', deleteContractFee); ?.addEventListener('click', deleteContractFee);
@ -829,7 +818,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
contractFeesContainerElement.querySelector('#contractFees--feeAmountTotal').textContent = `$${feeAmountTotal.toFixed(2)}`; contractFeesContainerElement.querySelector('#contractFees--feeAmountTotal').textContent = `$${feeAmountTotal.toFixed(2)}`;
contractFeesContainerElement.querySelector('#contractFees--taxAmountTotal').textContent = `$${taxAmountTotal.toFixed(2)}`; contractFeesContainerElement.querySelector('#contractFees--taxAmountTotal').textContent = `$${taxAmountTotal.toFixed(2)}`;
contractFeesContainerElement.querySelector('#contractFees--grandTotal').textContent = `$${(feeAmountTotal + taxAmountTotal).toFixed(2)}`; contractFeesContainerElement.querySelector('#contractFees--grandTotal').textContent = `$${(feeAmountTotal + taxAmountTotal).toFixed(2)}`;
renderLotOccupancyTransactions(); renderContractTransactions();
} }
const addFeeButtonElement = document.querySelector('#button--addFee'); const addFeeButtonElement = document.querySelector('#button--addFee');
addFeeButtonElement.addEventListener('click', () => { addFeeButtonElement.addEventListener('click', () => {
@ -845,8 +834,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
let feeFilterResultsElement; let feeFilterResultsElement;
function doAddFeeCategory(clickEvent) { function doAddFeeCategory(clickEvent) {
clickEvent.preventDefault(); clickEvent.preventDefault();
const feeCategoryId = Number.parseInt(clickEvent.currentTarget.dataset.feeCategoryId ?? const feeCategoryId = Number.parseInt(clickEvent.currentTarget.dataset.feeCategoryId ?? '', 10);
'', 10);
cityssm.postJSON(`${sunrise.urlPrefix}/contracts/doAddContractFeeCategory`, { cityssm.postJSON(`${sunrise.urlPrefix}/contracts/doAddContractFeeCategory`, {
contractId, contractId,
feeCategoryId feeCategoryId
@ -854,7 +842,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
contractFees = responseJSON.contractFees; contractFees = responseJSON.contractFees;
renderLotOccupancyFees(); renderContractFees();
bulmaJS.alert({ bulmaJS.alert({
message: 'Fee Group Added Successfully', message: 'Fee Group Added Successfully',
contextualColorName: 'success' contextualColorName: 'success'
@ -870,7 +858,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
}); });
} }
function doAddFee(feeId, quantity = 1) { function doAddFee(feeId, quantity = 1) {
cityssm.postJSON(`${sunrise.urlPrefix}/contracts/doAddLotOccupancyFee`, { cityssm.postJSON(`${sunrise.urlPrefix}/contracts/doAddContractFee`, {
contractId, contractId,
feeId, feeId,
quantity quantity
@ -878,7 +866,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
contractFees = responseJSON.contractFees; contractFees = responseJSON.contractFees;
renderLotOccupancyFees(); renderContractFees();
filterFees(); filterFees();
} }
else { else {
@ -915,14 +903,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
function tryAddFee(clickEvent) { function tryAddFee(clickEvent) {
clickEvent.preventDefault(); clickEvent.preventDefault();
const feeId = Number.parseInt(clickEvent.currentTarget.dataset.feeId ?? '', 10); const feeId = Number.parseInt(clickEvent.currentTarget.dataset.feeId ?? '', 10);
const feeCategoryId = Number.parseInt(clickEvent.currentTarget.dataset.feeCategoryId ?? const feeCategoryId = Number.parseInt(clickEvent.currentTarget.dataset.feeCategoryId ?? '', 10);
'', 10); const feeCategory = feeCategories.find((currentFeeCategory) => currentFeeCategory.feeCategoryId === feeCategoryId);
const feeCategory = feeCategories.find((currentFeeCategory) => { const fee = feeCategory.fees.find((currentFee) => currentFee.feeId === feeId);
return currentFeeCategory.feeCategoryId === feeCategoryId;
});
const fee = feeCategory.fees.find((currentFee) => {
return currentFee.feeId === feeId;
});
if (fee.includeQuantity ?? false) { if (fee.includeQuantity ?? false) {
doSetQuantityAndAddFee(fee); doSetQuantityAndAddFee(fee);
} }
@ -982,17 +965,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
hasFees = true; hasFees = true;
const panelBlockElement = document.createElement(feeCategory.isGroupedFee ? 'div' : 'a'); const panelBlockElement = document.createElement(feeCategory.isGroupedFee ? 'div' : 'a');
panelBlockElement.className = panelBlockElement.className = 'panel-block is-block container--fee';
'panel-block is-block container--fee';
panelBlockElement.dataset.feeId = fee.feeId.toString(); panelBlockElement.dataset.feeId = fee.feeId.toString();
panelBlockElement.dataset.feeCategoryId = panelBlockElement.dataset.feeCategoryId =
feeCategory.feeCategoryId.toString(); feeCategory.feeCategoryId.toString();
// eslint-disable-next-line no-unsanitized/property // eslint-disable-next-line no-unsanitized/property
panelBlockElement.innerHTML = `<strong>${cityssm.escapeHTML(fee.feeName ?? '')}</strong><br /> panelBlockElement.innerHTML = `<strong>${cityssm.escapeHTML(fee.feeName ?? '')}</strong><br />
<small> <small>
${ ${cityssm
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
cityssm
.escapeHTML(fee.feeDescription ?? '') .escapeHTML(fee.feeDescription ?? '')
.replaceAll('\n', '<br />')} .replaceAll('\n', '<br />')}
</small>`; </small>`;
@ -1028,7 +1008,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
}, },
onhidden() { onhidden() {
renderLotOccupancyFees(); renderContractFees();
}, },
onremoved() { onremoved() {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
@ -1046,12 +1026,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
return transactionGrandTotal; return transactionGrandTotal;
} }
function editLotOccupancyTransaction(clickEvent) { function editContractTransaction(clickEvent) {
const transactionIndex = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset const transactionIndex = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset
.transactionIndex ?? '', 10); .transactionIndex ?? '', 10);
const transaction = contractTransactions.find((possibleTransaction) => { const transaction = contractTransactions.find((possibleTransaction) => possibleTransaction.transactionIndex === transactionIndex);
return possibleTransaction.transactionIndex === transactionIndex;
});
let editCloseModalFunction; let editCloseModalFunction;
function doEdit(formEvent) { function doEdit(formEvent) {
formEvent.preventDefault(); formEvent.preventDefault();
@ -1059,7 +1037,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
contractTransactions = responseJSON.contractTransactions; contractTransactions = responseJSON.contractTransactions;
renderLotOccupancyTransactions(); renderContractTransactions();
editCloseModalFunction(); editCloseModalFunction();
} }
else { else {
@ -1086,9 +1064,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
sunrise.initializeDatePickers(modalElement); sunrise.initializeDatePickers(modalElement);
modalElement.querySelector('#contractTransactionEdit--transactionAmount').focus(); modalElement.querySelector('#contractTransactionEdit--transactionAmount').focus();
modalElement modalElement.querySelector('form')?.addEventListener('submit', doEdit);
.querySelector('form')
?.addEventListener('submit', doEdit);
editCloseModalFunction = closeModalFunction; editCloseModalFunction = closeModalFunction;
}, },
onremoved() { onremoved() {
@ -1106,7 +1082,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
contractTransactions = responseJSON.contractTransactions; contractTransactions = responseJSON.contractTransactions;
renderLotOccupancyTransactions(); renderContractTransactions();
} }
else { else {
bulmaJS.alert({ bulmaJS.alert({
@ -1127,7 +1103,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
}); });
} }
function renderLotOccupancyTransactions() { function renderContractTransactions() {
if (contractTransactions.length === 0) { if (contractTransactions.length === 0) {
// eslint-disable-next-line no-unsanitized/property // eslint-disable-next-line no-unsanitized/property
contractTransactionsContainerElement.innerHTML = `<div class="message ${contractFees.length === 0 ? 'is-info' : 'is-warning'}"> contractTransactionsContainerElement.innerHTML = `<div class="message ${contractFees.length === 0 ? 'is-info' : 'is-warning'}">
@ -1203,7 +1179,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
</td>`; </td>`;
tableRowElement tableRowElement
.querySelector('.button--edit') .querySelector('.button--edit')
?.addEventListener('click', editLotOccupancyTransaction); ?.addEventListener('click', editContractTransaction);
tableRowElement tableRowElement
.querySelector('.button--delete') .querySelector('.button--delete')
?.addEventListener('click', deleteContractTransaction); ?.addEventListener('click', deleteContractTransaction);
@ -1237,12 +1213,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
let addCloseModalFunction; let addCloseModalFunction;
function doAddTransaction(submitEvent) { function doAddTransaction(submitEvent) {
submitEvent.preventDefault(); submitEvent.preventDefault();
cityssm.postJSON(`${sunrise.urlPrefix}/contracts/doAddLotOccupancyTransaction`, submitEvent.currentTarget, (rawResponseJSON) => { cityssm.postJSON(`${sunrise.urlPrefix}/contracts/doAddContractTransaction`, submitEvent.currentTarget, (rawResponseJSON) => {
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
contractTransactions = responseJSON.contractTransactions; contractTransactions = responseJSON.contractTransactions;
addCloseModalFunction(); addCloseModalFunction();
renderLotOccupancyTransactions(); renderContractTransactions();
} }
else { else {
bulmaJS.confirm({ bulmaJS.confirm({
@ -1302,9 +1278,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
transactionAmountElement.max = Math.max(feeGrandTotal - transactionGrandTotal, 0).toFixed(2); transactionAmountElement.max = Math.max(feeGrandTotal - transactionGrandTotal, 0).toFixed(2);
transactionAmountElement.value = Math.max(feeGrandTotal - transactionGrandTotal, 0).toFixed(2); transactionAmountElement.value = Math.max(feeGrandTotal - transactionGrandTotal, 0).toFixed(2);
if (sunrise.dynamicsGPIntegrationIsEnabled) { if (sunrise.dynamicsGPIntegrationIsEnabled) {
externalReceiptNumberElement = modalElement.querySelector( externalReceiptNumberElement = modalElement.querySelector('#contractTransactionAdd--externalReceiptNumber');
// eslint-disable-next-line no-secrets/no-secrets
'#contractTransactionAdd--externalReceiptNumber');
const externalReceiptNumberControlElement = externalReceiptNumberElement.closest('.control'); const externalReceiptNumberControlElement = externalReceiptNumberElement.closest('.control');
externalReceiptNumberControlElement.classList.add('has-icons-right'); externalReceiptNumberControlElement.classList.add('has-icons-right');
externalReceiptNumberControlElement.insertAdjacentHTML('beforeend', '<span class="icon is-small is-right"></span>'); externalReceiptNumberControlElement.insertAdjacentHTML('beforeend', '<span class="icon is-small is-right"></span>');
@ -1328,7 +1302,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
}); });
}); });
renderLotOccupancyFees(); renderContractFees();
})();
} }
})(); })();

View File

@ -1,13 +1,15 @@
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable max-lines */ /* eslint-disable max-lines */
import type { BulmaJS } from '@cityssm/bulma-js/types.js' import type { BulmaJS } from '@cityssm/bulma-js/types.js'
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js' import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js'
import type { import type {
BurialSite, BurialSite,
BurialSiteStatus, ContractComment,
BurialSiteType, ContractFee,
Cemetery,
ContractInterment, ContractInterment,
ContractTransaction,
ContractTypeField, ContractTypeField,
DynamicsGPDocument, DynamicsGPDocument,
Fee, Fee,
@ -309,6 +311,19 @@ declare const exports: Record<string, unknown>
) as HTMLElement ) as HTMLElement
contractTypeIdElement.addEventListener('change', () => { contractTypeIdElement.addEventListener('change', () => {
const recipientOrPreneedElements = document.querySelectorAll(
'.is-recipient-or-deceased'
)
const isPreneed =
contractTypeIdElement.selectedOptions[0].dataset.isPreneed === 'true'
for (const recipientOrPreneedElement of recipientOrPreneedElements) {
recipientOrPreneedElement.textContent = isPreneed
? 'Recipient'
: 'Deceased'
}
if (contractTypeIdElement.value === '') { if (contractTypeIdElement.value === '') {
contractFieldsContainerElement.innerHTML = `<div class="message is-info"> contractFieldsContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">Select the contract type to load the available fields.</p> <p class="message-body">Select the contract type to load the available fields.</p>
@ -457,7 +472,6 @@ declare const exports: Record<string, unknown>
.value .value
let burialSiteSelectCloseModalFunction: () => void let burialSiteSelectCloseModalFunction: () => void
let burialSiteSelectModalElement: HTMLElement
let burialSiteSelectFormElement: HTMLFormElement let burialSiteSelectFormElement: HTMLFormElement
let burialSiteSelectResultsElement: HTMLElement let burialSiteSelectResultsElement: HTMLElement
@ -480,11 +494,11 @@ declare const exports: Record<string, unknown>
function selectExistingBurialSite(clickEvent: Event): void { function selectExistingBurialSite(clickEvent: Event): void {
clickEvent.preventDefault() clickEvent.preventDefault()
const selectedLotElement = clickEvent.currentTarget as HTMLElement const selectedBurialSiteElement = clickEvent.currentTarget as HTMLElement
renderSelectedBurialSiteAndClose( renderSelectedBurialSiteAndClose(
selectedLotElement.dataset.burialSiteId ?? '', selectedBurialSiteElement.dataset.burialSiteId ?? '',
selectedLotElement.dataset.burialSiteName ?? '' selectedBurialSiteElement.dataset.burialSiteName ?? ''
) )
} }
@ -520,7 +534,7 @@ declare const exports: Record<string, unknown>
panelBlockElement.dataset.burialSiteId = panelBlockElement.dataset.burialSiteId =
burialSite.burialSiteId.toString() burialSite.burialSiteId.toString()
panelBlockElement.dataset.lotName = burialSite.burialSiteName panelBlockElement.dataset.burialSiteName = burialSite.burialSiteName
// eslint-disable-next-line no-unsanitized/property // eslint-disable-next-line no-unsanitized/property
panelBlockElement.innerHTML = `<div class="columns"> panelBlockElement.innerHTML = `<div class="columns">
@ -550,41 +564,6 @@ declare const exports: Record<string, unknown>
) )
} }
function createBurialSiteAndSelect(submitEvent: SubmitEvent): void {
submitEvent.preventDefault()
const burialSiteName = (
burialSiteSelectModalElement.querySelector(
'#burialSiteCreate--burialSiteName'
) as HTMLInputElement
).value
cityssm.postJSON(
`${sunrise.urlPrefix}/burialSites/doCreateBurialSite`,
submitEvent.currentTarget,
(rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
burialSiteId?: number
}
if (responseJSON.success) {
renderSelectedBurialSiteAndClose(
responseJSON.burialSiteId ?? '',
burialSiteName
)
} else {
bulmaJS.alert({
title: `Error Creating Burial Site`,
message: responseJSON.errorMessage ?? '',
contextualColorName: 'danger'
})
}
}
)
}
cityssm.openHtmlModal('contract-selectBurialSite', { cityssm.openHtmlModal('contract-selectBurialSite', {
onshow(modalElement) { onshow(modalElement) {
sunrise.populateAliases(modalElement) sunrise.populateAliases(modalElement)
@ -592,12 +571,11 @@ declare const exports: Record<string, unknown>
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped() bulmaJS.toggleHtmlClipped()
burialSiteSelectModalElement = modalElement
burialSiteSelectCloseModalFunction = closeModalFunction burialSiteSelectCloseModalFunction = closeModalFunction
bulmaJS.init(modalElement) bulmaJS.init(modalElement)
// search Tab // Search Tab
const burialSiteNameFilterElement = modalElement.querySelector( const burialSiteNameFilterElement = modalElement.querySelector(
'#burialSiteSelect--burialSiteName' '#burialSiteSelect--burialSiteName'
@ -646,48 +624,6 @@ declare const exports: Record<string, unknown>
) )
searchBurialSites() searchBurialSites()
const burialSiteTypeElement = modalElement.querySelector(
'#burialSiteCreate--burialSiteTypeId'
) as HTMLSelectElement
for (const burialSiteType of exports.burialSiteTypes as BurialSiteType[]) {
const optionElement = document.createElement('option')
optionElement.value = burialSiteType.burialSiteTypeId.toString()
optionElement.textContent = burialSiteType.burialSiteType
burialSiteTypeElement.append(optionElement)
}
const burialSiteStatusElement = modalElement.querySelector(
'#burialSiteCreate--burialSiteStatusId'
) as HTMLSelectElement
for (const burialSiteStatus of exports.burialSiteStatuses as BurialSiteStatus[]) {
const optionElement = document.createElement('option')
optionElement.value = burialSiteStatus.burialSiteStatusId.toString()
optionElement.textContent = burialSiteStatus.burialSiteStatus
burialSiteStatusElement.append(optionElement)
}
const mapElement = modalElement.querySelector(
'#burialSiteCreate--cemeteryId'
) as HTMLSelectElement
for (const cemetery of exports.cemeteries as Cemetery[]) {
const optionElement = document.createElement('option')
optionElement.value = cemetery.cemeteryId!.toString()
optionElement.textContent =
(cemetery.cemeteryName ?? '') === ''
? '(No Name)'
: cemetery.cemeteryName ?? ''
mapElement.append(optionElement)
}
;(
modalElement.querySelector(
'#form--burialSiteCreate'
) as HTMLFormElement
).addEventListener('submit', createBurialSiteAndSelect)
}, },
onremoved() { onremoved() {
bulmaJS.toggleHtmlClipped() bulmaJS.toggleHtmlClipped()
@ -754,15 +690,57 @@ declare const exports: Record<string, unknown>
sunrise.initializeUnlockFieldButtons(formElement) sunrise.initializeUnlockFieldButtons(formElement)
if (!isCreate) { if (isCreate) {
/*
* Deceased
*/
document
.querySelector('#button--copyFromPurchaser')
?.addEventListener('click', () => {
const fieldsToCopy = [
'Name',
'Address1',
'Address2',
'City',
'Province',
'PostalCode'
]
for (const fieldToCopy of fieldsToCopy) {
const purchaserFieldElement = document.querySelector(
`#contract--purchaser${fieldToCopy}`
) as HTMLInputElement
const deceasedFieldElement = document.querySelector(
`#contract--deceased${fieldToCopy}`
) as HTMLInputElement
deceasedFieldElement.value = purchaserFieldElement.value
}
setUnsavedChanges()
})
} else {
/**
* Interments
*/
let contractInterments = exports.contractInterments as ContractInterment[]
delete exports.contractInterments
function renderContractInterments(): void {
}
/** /**
* Comments * Comments
*/ */
;(() => {
let contractComments = exports.contractComments as LotOccupancyComment[] let contractComments = exports.contractComments as ContractComment[]
delete exports.contractComments delete exports.contractComments
function openEditLotOccupancyComment(clickEvent: Event): void { function openEditContractComment(clickEvent: Event): void {
const contractCommentId = Number.parseInt( const contractCommentId = Number.parseInt(
(clickEvent.currentTarget as HTMLElement).closest('tr')?.dataset (clickEvent.currentTarget as HTMLElement).closest('tr')?.dataset
.contractCommentId ?? '', .contractCommentId ?? '',
@ -770,17 +748,14 @@ declare const exports: Record<string, unknown>
) )
const contractComment = contractComments.find( const contractComment = contractComments.find(
(currentLotOccupancyComment) => { (currentComment) =>
return ( currentComment.contractCommentId === contractCommentId
currentLotOccupancyComment.contractCommentId === contractCommentId ) as ContractComment
)
}
) as LotOccupancyComment
let editFormElement: HTMLFormElement let editFormElement: HTMLFormElement
let editCloseModalFunction: () => void let editCloseModalFunction: () => void
function editComment(submitEvent: SubmitEvent): void { function editContractComment(submitEvent: SubmitEvent): void {
submitEvent.preventDefault() submitEvent.preventDefault()
cityssm.postJSON( cityssm.postJSON(
@ -790,13 +765,13 @@ declare const exports: Record<string, unknown>
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
success: boolean success: boolean
errorMessage?: string errorMessage?: string
contractComments?: LotOccupancyComment[] contractComments?: ContractComment[]
} }
if (responseJSON.success) { if (responseJSON.success) {
contractComments = responseJSON.contractComments ?? [] contractComments = responseJSON.contractComments ?? []
editCloseModalFunction() editCloseModalFunction()
renderLotOccupancyComments() renderContractComments()
} else { } else {
bulmaJS.alert({ bulmaJS.alert({
title: 'Error Updating Comment', title: 'Error Updating Comment',
@ -860,7 +835,7 @@ declare const exports: Record<string, unknown>
'form' 'form'
) as HTMLFormElement ) as HTMLFormElement
editFormElement.addEventListener('submit', editComment) editFormElement.addEventListener('submit', editContractComment)
editCloseModalFunction = closeModalFunction editCloseModalFunction = closeModalFunction
}, },
@ -870,7 +845,7 @@ declare const exports: Record<string, unknown>
}) })
} }
function deleteLotOccupancyComment(clickEvent: Event): void { function deleteContractComment(clickEvent: Event): void {
const contractCommentId = Number.parseInt( const contractCommentId = Number.parseInt(
(clickEvent.currentTarget as HTMLElement).closest('tr')?.dataset (clickEvent.currentTarget as HTMLElement).closest('tr')?.dataset
.contractCommentId ?? '', .contractCommentId ?? '',
@ -888,12 +863,12 @@ declare const exports: Record<string, unknown>
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
success: boolean success: boolean
errorMessage?: string errorMessage?: string
contractComments: LotOccupancyComment[] contractComments: ContractComment[]
} }
if (responseJSON.success) { if (responseJSON.success) {
contractComments = responseJSON.contractComments contractComments = responseJSON.contractComments
renderLotOccupancyComments() renderContractComments()
} else { } else {
bulmaJS.alert({ bulmaJS.alert({
title: 'Error Removing Comment', title: 'Error Removing Comment',
@ -916,7 +891,7 @@ declare const exports: Record<string, unknown>
}) })
} }
function renderLotOccupancyComments(): void { function renderContractComments(): void {
const containerElement = document.querySelector( const containerElement = document.querySelector(
'#container--contractComments' '#container--contractComments'
) as HTMLElement ) as HTMLElement
@ -931,7 +906,7 @@ declare const exports: Record<string, unknown>
const tableElement = document.createElement('table') const tableElement = document.createElement('table')
tableElement.className = 'table is-fullwidth is-striped is-hoverable' tableElement.className = 'table is-fullwidth is-striped is-hoverable'
tableElement.innerHTML = `<thead><tr> tableElement.innerHTML = `<thead><tr>
<th>Commentor</th> <th>Author</th>
<th>Comment Date</th> <th>Comment Date</th>
<th>Comment</th> <th>Comment</th>
<th class="is-hidden-print"><span class="is-sr-only">Options</span></th> <th class="is-hidden-print"><span class="is-sr-only">Options</span></th>
@ -967,11 +942,11 @@ declare const exports: Record<string, unknown>
tableRowElement tableRowElement
.querySelector('.button--edit') .querySelector('.button--edit')
?.addEventListener('click', openEditLotOccupancyComment) ?.addEventListener('click', openEditContractComment)
tableRowElement tableRowElement
.querySelector('.button--delete') .querySelector('.button--delete')
?.addEventListener('click', deleteLotOccupancyComment) ?.addEventListener('click', deleteContractComment)
tableElement.querySelector('tbody')?.append(tableRowElement) tableElement.querySelector('tbody')?.append(tableRowElement)
} }
@ -996,13 +971,13 @@ declare const exports: Record<string, unknown>
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
success: boolean success: boolean
errorMessage?: string errorMessage?: string
contractComments: LotOccupancyComment[] contractComments: ContractComment[]
} }
if (responseJSON.success) { if (responseJSON.success) {
contractComments = responseJSON.contractComments contractComments = responseJSON.contractComments
addCloseModalFunction() addCloseModalFunction()
renderLotOccupancyComments() renderContractComments()
} else { } else {
bulmaJS.alert({ bulmaJS.alert({
title: 'Error Adding Comment', title: 'Error Adding Comment',
@ -1027,7 +1002,7 @@ declare const exports: Record<string, unknown>
bulmaJS.toggleHtmlClipped() bulmaJS.toggleHtmlClipped()
;( ;(
modalElement.querySelector( modalElement.querySelector(
'#contractCommentAdd--contractComment' '#contractCommentAdd--comment'
) as HTMLTextAreaElement ) as HTMLTextAreaElement
).focus() ).focus()
@ -1039,25 +1014,22 @@ declare const exports: Record<string, unknown>
addCloseModalFunction = closeModalFunction addCloseModalFunction = closeModalFunction
}, },
onremoved: () => { onremoved() {
bulmaJS.toggleHtmlClipped() bulmaJS.toggleHtmlClipped()
;( ;(
document.querySelector( document.querySelector('#button--addComment') as HTMLButtonElement
'#button--addComment'
) as HTMLButtonElement
).focus() ).focus()
} }
}) })
}) })
renderLotOccupancyComments() renderContractComments()
})()
/** /**
* Fees * Fees
*/ */
;(() => {
let contractFees = exports.contractFees as LotOccupancyFee[] let contractFees = exports.contractFees as ContractFee[]
delete exports.contractFees delete exports.contractFees
const contractFeesContainerElement = document.querySelector( const contractFeesContainerElement = document.querySelector(
@ -1076,16 +1048,16 @@ declare const exports: Record<string, unknown>
return feeGrandTotal return feeGrandTotal
} }
function editLotOccupancyFeeQuantity(clickEvent: Event): void { function editContractFeeQuantity(clickEvent: Event): void {
const feeId = Number.parseInt( const feeId = Number.parseInt(
(clickEvent.currentTarget as HTMLButtonElement).closest('tr')?.dataset (clickEvent.currentTarget as HTMLButtonElement).closest('tr')?.dataset
.feeId ?? '', .feeId ?? '',
10 10
) )
const fee = contractFees.find((possibleFee) => { const fee = contractFees.find(
return possibleFee.feeId === feeId (possibleFee) => possibleFee.feeId === feeId
}) as LotOccupancyFee ) as ContractFee
let updateCloseModalFunction: () => void let updateCloseModalFunction: () => void
@ -1098,12 +1070,12 @@ declare const exports: Record<string, unknown>
(rawResponseJSON) => { (rawResponseJSON) => {
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
success: boolean success: boolean
contractFees: LotOccupancyFee[] contractFees: ContractFee[]
} }
if (responseJSON.success) { if (responseJSON.success) {
contractFees = responseJSON.contractFees contractFees = responseJSON.contractFees
renderLotOccupancyFees() renderContractFees()
updateCloseModalFunction() updateCloseModalFunction()
} else { } else {
bulmaJS.alert({ bulmaJS.alert({
@ -1177,12 +1149,12 @@ declare const exports: Record<string, unknown>
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
success: boolean success: boolean
errorMessage?: string errorMessage?: string
contractFees: LotOccupancyFee[] contractFees: ContractFee[]
} }
if (responseJSON.success) { if (responseJSON.success) {
contractFees = responseJSON.contractFees contractFees = responseJSON.contractFees
renderLotOccupancyFees() renderContractFees()
} else { } else {
bulmaJS.alert({ bulmaJS.alert({
title: 'Error Deleting Fee', title: 'Error Deleting Fee',
@ -1205,18 +1177,18 @@ declare const exports: Record<string, unknown>
}) })
} }
function renderLotOccupancyFees(): void { // eslint-disable-next-line complexity
function renderContractFees(): void {
if (contractFees.length === 0) { if (contractFees.length === 0) {
contractFeesContainerElement.innerHTML = `<div class="message is-info"> contractFeesContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no fees associated with this record.</p> <p class="message-body">There are no fees associated with this record.</p>
</div>` </div>`
renderLotOccupancyTransactions() renderContractTransactions()
return return
} }
// eslint-disable-next-line no-secrets/no-secrets
contractFeesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable"> contractFeesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr> <thead><tr>
<th>Fee</th> <th>Fee</th>
@ -1288,7 +1260,7 @@ declare const exports: Record<string, unknown>
tableRowElement tableRowElement
.querySelector('.button--editQuantity') .querySelector('.button--editQuantity')
?.addEventListener('click', editLotOccupancyFeeQuantity) ?.addEventListener('click', editContractFeeQuantity)
tableRowElement tableRowElement
.querySelector('.button--delete') .querySelector('.button--delete')
@ -1321,7 +1293,7 @@ declare const exports: Record<string, unknown>
) as HTMLElement ) as HTMLElement
).textContent = `$${(feeAmountTotal + taxAmountTotal).toFixed(2)}` ).textContent = `$${(feeAmountTotal + taxAmountTotal).toFixed(2)}`
renderLotOccupancyTransactions() renderContractTransactions()
} }
const addFeeButtonElement = document.querySelector( const addFeeButtonElement = document.querySelector(
@ -1346,8 +1318,7 @@ declare const exports: Record<string, unknown>
clickEvent.preventDefault() clickEvent.preventDefault()
const feeCategoryId = Number.parseInt( const feeCategoryId = Number.parseInt(
(clickEvent.currentTarget as HTMLElement).dataset.feeCategoryId ?? (clickEvent.currentTarget as HTMLElement).dataset.feeCategoryId ?? '',
'',
10 10
) )
@ -1361,12 +1332,12 @@ declare const exports: Record<string, unknown>
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
success: boolean success: boolean
errorMessage?: string errorMessage?: string
contractFees: LotOccupancyFee[] contractFees: ContractFee[]
} }
if (responseJSON.success) { if (responseJSON.success) {
contractFees = responseJSON.contractFees contractFees = responseJSON.contractFees
renderLotOccupancyFees() renderContractFees()
bulmaJS.alert({ bulmaJS.alert({
message: 'Fee Group Added Successfully', message: 'Fee Group Added Successfully',
@ -1385,7 +1356,7 @@ declare const exports: Record<string, unknown>
function doAddFee(feeId: number, quantity: number | string = 1): void { function doAddFee(feeId: number, quantity: number | string = 1): void {
cityssm.postJSON( cityssm.postJSON(
`${sunrise.urlPrefix}/contracts/doAddLotOccupancyFee`, `${sunrise.urlPrefix}/contracts/doAddContractFee`,
{ {
contractId, contractId,
feeId, feeId,
@ -1395,12 +1366,12 @@ declare const exports: Record<string, unknown>
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
success: boolean success: boolean
errorMessage?: string errorMessage?: string
contractFees: LotOccupancyFee[] contractFees: ContractFee[]
} }
if (responseJSON.success) { if (responseJSON.success) {
contractFees = responseJSON.contractFees contractFees = responseJSON.contractFees
renderLotOccupancyFees() renderContractFees()
filterFees() filterFees()
} else { } else {
bulmaJS.alert({ bulmaJS.alert({
@ -1453,18 +1424,18 @@ declare const exports: Record<string, unknown>
10 10
) )
const feeCategoryId = Number.parseInt( const feeCategoryId = Number.parseInt(
(clickEvent.currentTarget as HTMLElement).dataset.feeCategoryId ?? (clickEvent.currentTarget as HTMLElement).dataset.feeCategoryId ?? '',
'',
10 10
) )
const feeCategory = feeCategories.find((currentFeeCategory) => { const feeCategory = feeCategories.find(
return currentFeeCategory.feeCategoryId === feeCategoryId (currentFeeCategory) =>
}) as FeeCategory currentFeeCategory.feeCategoryId === feeCategoryId
) as FeeCategory
const fee = feeCategory.fees.find((currentFee) => { const fee = feeCategory.fees.find(
return currentFee.feeId === feeId (currentFee) => currentFee.feeId === feeId
}) as Fee ) as Fee
if (fee.includeQuantity ?? false) { if (fee.includeQuantity ?? false) {
doSetQuantityAndAddFee(fee) doSetQuantityAndAddFee(fee)
@ -1550,8 +1521,7 @@ declare const exports: Record<string, unknown>
const panelBlockElement = document.createElement( const panelBlockElement = document.createElement(
feeCategory.isGroupedFee ? 'div' : 'a' feeCategory.isGroupedFee ? 'div' : 'a'
) )
panelBlockElement.className = panelBlockElement.className = 'panel-block is-block container--fee'
'panel-block is-block container--fee'
panelBlockElement.dataset.feeId = fee.feeId.toString() panelBlockElement.dataset.feeId = fee.feeId.toString()
panelBlockElement.dataset.feeCategoryId = panelBlockElement.dataset.feeCategoryId =
feeCategory.feeCategoryId.toString() feeCategory.feeCategoryId.toString()
@ -1560,7 +1530,6 @@ declare const exports: Record<string, unknown>
panelBlockElement.innerHTML = `<strong>${cityssm.escapeHTML(fee.feeName ?? '')}</strong><br /> panelBlockElement.innerHTML = `<strong>${cityssm.escapeHTML(fee.feeName ?? '')}</strong><br />
<small> <small>
${ ${
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
cityssm cityssm
.escapeHTML(fee.feeDescription ?? '') .escapeHTML(fee.feeDescription ?? '')
.replaceAll('\n', '<br />') .replaceAll('\n', '<br />')
@ -1616,7 +1585,7 @@ declare const exports: Record<string, unknown>
bulmaJS.toggleHtmlClipped() bulmaJS.toggleHtmlClipped()
}, },
onhidden() { onhidden() {
renderLotOccupancyFees() renderContractFees()
}, },
onremoved() { onremoved() {
bulmaJS.toggleHtmlClipped() bulmaJS.toggleHtmlClipped()
@ -1626,7 +1595,7 @@ declare const exports: Record<string, unknown>
}) })
let contractTransactions = let contractTransactions =
exports.contractTransactions as LotOccupancyTransaction[] exports.contractTransactions as ContractTransaction[]
delete exports.contractTransactions delete exports.contractTransactions
const contractTransactionsContainerElement = document.querySelector( const contractTransactionsContainerElement = document.querySelector(
@ -1643,16 +1612,14 @@ declare const exports: Record<string, unknown>
return transactionGrandTotal return transactionGrandTotal
} }
function editLotOccupancyTransaction(clickEvent: Event): void { function editContractTransaction(clickEvent: Event): void {
const transactionIndex = Number.parseInt( const transactionIndex = Number.parseInt(
(clickEvent.currentTarget as HTMLButtonElement).closest('tr')?.dataset (clickEvent.currentTarget as HTMLButtonElement).closest('tr')?.dataset
.transactionIndex ?? '', .transactionIndex ?? '',
10 10
) )
const transaction = contractTransactions.find((possibleTransaction) => { const transaction = contractTransactions.find((possibleTransaction) => possibleTransaction.transactionIndex === transactionIndex) as ContractTransaction
return possibleTransaction.transactionIndex === transactionIndex
}) as LotOccupancyTransaction
let editCloseModalFunction: () => void let editCloseModalFunction: () => void
@ -1665,12 +1632,12 @@ declare const exports: Record<string, unknown>
(rawResponseJSON) => { (rawResponseJSON) => {
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
success: boolean success: boolean
contractTransactions: LotOccupancyTransaction[] contractTransactions: ContractTransaction[]
} }
if (responseJSON.success) { if (responseJSON.success) {
contractTransactions = responseJSON.contractTransactions contractTransactions = responseJSON.contractTransactions
renderLotOccupancyTransactions() renderContractTransactions()
editCloseModalFunction() editCloseModalFunction()
} else { } else {
bulmaJS.alert({ bulmaJS.alert({
@ -1732,9 +1699,7 @@ declare const exports: Record<string, unknown>
) as HTMLInputElement ) as HTMLInputElement
).focus() ).focus()
modalElement modalElement.querySelector('form')?.addEventListener('submit', doEdit)
.querySelector('form')
?.addEventListener('submit', doEdit)
editCloseModalFunction = closeModalFunction editCloseModalFunction = closeModalFunction
}, },
@ -1762,12 +1727,12 @@ declare const exports: Record<string, unknown>
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
success: boolean success: boolean
errorMessage?: string errorMessage?: string
contractTransactions: LotOccupancyTransaction[] contractTransactions: ContractTransaction[]
} }
if (responseJSON.success) { if (responseJSON.success) {
contractTransactions = responseJSON.contractTransactions contractTransactions = responseJSON.contractTransactions
renderLotOccupancyTransactions() renderContractTransactions()
} else { } else {
bulmaJS.alert({ bulmaJS.alert({
title: 'Error Deleting Transaction', title: 'Error Deleting Transaction',
@ -1790,7 +1755,7 @@ declare const exports: Record<string, unknown>
}) })
} }
function renderLotOccupancyTransactions(): void { function renderContractTransactions(): void {
if (contractTransactions.length === 0) { if (contractTransactions.length === 0) {
// eslint-disable-next-line no-unsanitized/property // eslint-disable-next-line no-unsanitized/property
contractTransactionsContainerElement.innerHTML = `<div class="message ${contractFees.length === 0 ? 'is-info' : 'is-warning'}"> contractTransactionsContainerElement.innerHTML = `<div class="message ${contractFees.length === 0 ? 'is-info' : 'is-warning'}">
@ -1885,7 +1850,7 @@ declare const exports: Record<string, unknown>
tableRowElement tableRowElement
.querySelector('.button--edit') .querySelector('.button--edit')
?.addEventListener('click', editLotOccupancyTransaction) ?.addEventListener('click', editContractTransaction)
tableRowElement tableRowElement
.querySelector('.button--delete') .querySelector('.button--delete')
@ -1938,19 +1903,19 @@ declare const exports: Record<string, unknown>
submitEvent.preventDefault() submitEvent.preventDefault()
cityssm.postJSON( cityssm.postJSON(
`${sunrise.urlPrefix}/contracts/doAddLotOccupancyTransaction`, `${sunrise.urlPrefix}/contracts/doAddContractTransaction`,
submitEvent.currentTarget, submitEvent.currentTarget,
(rawResponseJSON) => { (rawResponseJSON) => {
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
success: boolean success: boolean
errorMessage?: string errorMessage?: string
contractTransactions: LotOccupancyTransaction[] contractTransactions: ContractTransaction[]
} }
if (responseJSON.success) { if (responseJSON.success) {
contractTransactions = responseJSON.contractTransactions contractTransactions = responseJSON.contractTransactions
addCloseModalFunction() addCloseModalFunction()
renderLotOccupancyTransactions() renderContractTransactions()
} else { } else {
bulmaJS.confirm({ bulmaJS.confirm({
title: 'Error Adding Transaction', title: 'Error Adding Transaction',
@ -2031,9 +1996,7 @@ declare const exports: Record<string, unknown>
'#contractTransactionAdd--transactionAmount' '#contractTransactionAdd--transactionAmount'
) as HTMLInputElement ) as HTMLInputElement
transactionAmountElement.min = (-1 * transactionGrandTotal).toFixed( transactionAmountElement.min = (-1 * transactionGrandTotal).toFixed(2)
2
)
transactionAmountElement.max = Math.max( transactionAmountElement.max = Math.max(
feeGrandTotal - transactionGrandTotal, feeGrandTotal - transactionGrandTotal,
@ -2047,16 +2010,13 @@ declare const exports: Record<string, unknown>
if (sunrise.dynamicsGPIntegrationIsEnabled) { if (sunrise.dynamicsGPIntegrationIsEnabled) {
externalReceiptNumberElement = modalElement.querySelector( externalReceiptNumberElement = modalElement.querySelector(
// eslint-disable-next-line no-secrets/no-secrets
'#contractTransactionAdd--externalReceiptNumber' '#contractTransactionAdd--externalReceiptNumber'
) as HTMLInputElement ) as HTMLInputElement
const externalReceiptNumberControlElement = const externalReceiptNumberControlElement =
externalReceiptNumberElement.closest('.control') as HTMLElement externalReceiptNumberElement.closest('.control') as HTMLElement
externalReceiptNumberControlElement.classList.add( externalReceiptNumberControlElement.classList.add('has-icons-right')
'has-icons-right'
)
externalReceiptNumberControlElement.insertAdjacentHTML( externalReceiptNumberControlElement.insertAdjacentHTML(
'beforeend', 'beforeend',
@ -2099,7 +2059,6 @@ declare const exports: Record<string, unknown>
}) })
}) })
renderLotOccupancyFees() renderContractFees()
})()
} }
})() })()

View File

@ -1,7 +1,9 @@
"use strict"; "use strict";
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable max-lines */
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
(() => { (() => {
const los = exports.sunrise; const sunrise = exports.sunrise;
const contractTypesContainerElement = document.querySelector('#container--contractTypes'); const contractTypesContainerElement = document.querySelector('#container--contractTypes');
const contractTypePrintsContainerElement = document.querySelector('#container--contractTypePrints'); const contractTypePrintsContainerElement = document.querySelector('#container--contractTypePrints');
let contractTypes = exports.contractTypes; let contractTypes = exports.contractTypes;
@ -46,7 +48,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
function deleteContractType(clickEvent) { function deleteContractType(clickEvent) {
const contractTypeId = Number.parseInt(clickEvent.currentTarget.closest('.container--contractType').dataset.contractTypeId ?? '', 10); const contractTypeId = Number.parseInt(clickEvent.currentTarget.closest('.container--contractType').dataset.contractTypeId ?? '', 10);
function doDelete() { function doDelete() {
cityssm.postJSON(`${los.urlPrefix}/admin/doDeleteContractType`, { cityssm.postJSON(`${sunrise.urlPrefix}/admin/doDeleteContractType`, {
contractTypeId contractTypeId
}, contractTypeResponseHandler); }, contractTypeResponseHandler);
} }
@ -66,7 +68,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
let editCloseModalFunction; let editCloseModalFunction;
function doEdit(submitEvent) { function doEdit(submitEvent) {
submitEvent.preventDefault(); submitEvent.preventDefault();
cityssm.postJSON(`${los.urlPrefix}/admin/doUpdateContractType`, submitEvent.currentTarget, (rawResponseJSON) => { cityssm.postJSON(`${sunrise.urlPrefix}/admin/doUpdateContractType`, submitEvent.currentTarget, (rawResponseJSON) => {
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
contractTypeResponseHandler(responseJSON); contractTypeResponseHandler(responseJSON);
if (responseJSON.success) { if (responseJSON.success) {
@ -76,9 +78,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
cityssm.openHtmlModal('adminContractTypes-edit', { cityssm.openHtmlModal('adminContractTypes-edit', {
onshow(modalElement) { onshow(modalElement) {
los.populateAliases(modalElement); sunrise.populateAliases(modalElement);
modalElement.querySelector('#contractTypeEdit--contractTypeId').value = contractTypeId.toString(); modalElement.querySelector('#contractTypeEdit--contractTypeId').value = contractTypeId.toString();
modalElement.querySelector('#contractTypeEdit--contractType').value = contractType.contractType; modalElement.querySelector('#contractTypeEdit--contractType').value = contractType.contractType;
if (contractType.isPreneed) {
;
modalElement.querySelector('#contractTypeEdit--isPreneed').checked = true;
}
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
editCloseModalFunction = closeModalFunction; editCloseModalFunction = closeModalFunction;
@ -96,7 +102,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
let addCloseModalFunction; let addCloseModalFunction;
function doAdd(submitEvent) { function doAdd(submitEvent) {
submitEvent.preventDefault(); submitEvent.preventDefault();
cityssm.postJSON(`${los.urlPrefix}/admin/doAddContractTypeField`, submitEvent.currentTarget, (rawResponseJSON) => { cityssm.postJSON(`${sunrise.urlPrefix}/admin/doAddContractTypeField`, submitEvent.currentTarget, (rawResponseJSON) => {
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
expandedContractTypes.add(contractTypeId); expandedContractTypes.add(contractTypeId);
contractTypeResponseHandler(responseJSON); contractTypeResponseHandler(responseJSON);
@ -108,7 +114,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
cityssm.openHtmlModal('adminContractTypes-addField', { cityssm.openHtmlModal('adminContractTypes-addField', {
onshow(modalElement) { onshow(modalElement) {
los.populateAliases(modalElement); sunrise.populateAliases(modalElement);
if (contractTypeId) { if (contractTypeId) {
; ;
modalElement.querySelector('#contractTypeFieldAdd--contractTypeId').value = contractTypeId.toString(); modalElement.querySelector('#contractTypeFieldAdd--contractTypeId').value = contractTypeId.toString();
@ -128,7 +134,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
function moveContractType(clickEvent) { function moveContractType(clickEvent) {
const buttonElement = clickEvent.currentTarget; const buttonElement = clickEvent.currentTarget;
const contractTypeId = clickEvent.currentTarget.closest('.container--contractType').dataset.contractTypeId; const contractTypeId = clickEvent.currentTarget.closest('.container--contractType').dataset.contractTypeId;
cityssm.postJSON(`${los.urlPrefix}/admin/${buttonElement.dataset.direction === 'up' cityssm.postJSON(`${sunrise.urlPrefix}/admin/${buttonElement.dataset.direction === 'up'
? 'doMoveContractTypeUp' ? 'doMoveContractTypeUp'
: 'doMoveContractTypeDown'}`, { : 'doMoveContractTypeDown'}`, {
contractTypeId, contractTypeId,
@ -179,7 +185,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
function doUpdate(submitEvent) { function doUpdate(submitEvent) {
submitEvent.preventDefault(); submitEvent.preventDefault();
cityssm.postJSON(`${los.urlPrefix}/admin/doUpdateContractTypeField`, submitEvent.currentTarget, (rawResponseJSON) => { cityssm.postJSON(`${sunrise.urlPrefix}/admin/doUpdateContractTypeField`, submitEvent.currentTarget, (rawResponseJSON) => {
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
contractTypeResponseHandler(responseJSON); contractTypeResponseHandler(responseJSON);
if (responseJSON.success) { if (responseJSON.success) {
@ -188,7 +194,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
}); });
} }
function doDelete() { function doDelete() {
cityssm.postJSON(`${los.urlPrefix}/admin/doDeleteContractTypeField`, { cityssm.postJSON(`${sunrise.urlPrefix}/admin/doDeleteContractTypeField`, {
contractTypeFieldId contractTypeFieldId
}, (rawResponseJSON) => { }, (rawResponseJSON) => {
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
@ -211,7 +217,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
cityssm.openHtmlModal('adminContractTypes-editField', { cityssm.openHtmlModal('adminContractTypes-editField', {
onshow(modalElement) { onshow(modalElement) {
los.populateAliases(modalElement); sunrise.populateAliases(modalElement);
modalElement.querySelector('#contractTypeFieldEdit--contractTypeFieldId').value = contractTypeField.contractTypeFieldId.toString(); modalElement.querySelector('#contractTypeFieldEdit--contractTypeFieldId').value = contractTypeField.contractTypeFieldId.toString();
modalElement.querySelector('#contractTypeFieldEdit--contractTypeField').value = contractTypeField.contractTypeField ?? ''; modalElement.querySelector('#contractTypeFieldEdit--contractTypeField').value = contractTypeField.contractTypeField ?? '';
modalElement.querySelector('#contractTypeFieldEdit--isRequired').value = contractTypeField.isRequired ?? false ? '1' : '0'; modalElement.querySelector('#contractTypeFieldEdit--isRequired').value = contractTypeField.isRequired ?? false ? '1' : '0';
@ -257,7 +263,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
function moveContractTypeField(clickEvent) { function moveContractTypeField(clickEvent) {
const buttonElement = clickEvent.currentTarget; const buttonElement = clickEvent.currentTarget;
const contractTypeFieldId = clickEvent.currentTarget.closest('.container--contractTypeField').dataset.contractTypeFieldId; const contractTypeFieldId = clickEvent.currentTarget.closest('.container--contractTypeField').dataset.contractTypeFieldId;
cityssm.postJSON(`${los.urlPrefix}/admin/${buttonElement.dataset.direction === 'up' cityssm.postJSON(`${sunrise.urlPrefix}/admin/${buttonElement.dataset.direction === 'up'
? // eslint-disable-next-line no-secrets/no-secrets ? // eslint-disable-next-line no-secrets/no-secrets
'doMoveContractTypeFieldUp' 'doMoveContractTypeFieldUp'
: // eslint-disable-next-line no-secrets/no-secrets : // eslint-disable-next-line no-secrets/no-secrets
@ -296,7 +302,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
</div> </div>
<div class="level-right"> <div class="level-right">
<div class="level-item"> <div class="level-item">
${los.getMoveUpDownButtonFieldHTML('button--moveContractTypeFieldUp', 'button--moveContractTypeFieldDown')} ${sunrise.getMoveUpDownButtonFieldHTML('button--moveContractTypeFieldUp', 'button--moveContractTypeFieldDown')}
</div> </div>
</div> </div>
</div>`; </div>`;
@ -314,7 +320,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
let closeAddModalFunction; let closeAddModalFunction;
function doAdd(formEvent) { function doAdd(formEvent) {
formEvent.preventDefault(); formEvent.preventDefault();
cityssm.postJSON(`${los.urlPrefix}/admin/doAddContractTypePrint`, formEvent.currentTarget, (rawResponseJSON) => { cityssm.postJSON(`${sunrise.urlPrefix}/admin/doAddContractTypePrint`, formEvent.currentTarget, (rawResponseJSON) => {
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
closeAddModalFunction(); closeAddModalFunction();
@ -324,7 +330,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
cityssm.openHtmlModal('adminContractTypes-addPrint', { cityssm.openHtmlModal('adminContractTypes-addPrint', {
onshow(modalElement) { onshow(modalElement) {
los.populateAliases(modalElement); sunrise.populateAliases(modalElement);
modalElement.querySelector('#contractTypePrintAdd--contractTypeId').value = contractTypeId; modalElement.querySelector('#contractTypePrintAdd--contractTypeId').value = contractTypeId;
const printSelectElement = modalElement.querySelector('#contractTypePrintAdd--printEJS'); const printSelectElement = modalElement.querySelector('#contractTypePrintAdd--printEJS');
for (const [printEJS, printTitle] of Object.entries(exports.contractTypePrintTitles)) { for (const [printEJS, printTitle] of Object.entries(exports.contractTypePrintTitles)) {
@ -344,7 +350,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const buttonElement = clickEvent.currentTarget; const buttonElement = clickEvent.currentTarget;
const printEJS = buttonElement.closest('.container--contractTypePrint').dataset.printEJS; const printEJS = buttonElement.closest('.container--contractTypePrint').dataset.printEJS;
const contractTypeId = buttonElement.closest('.container--contractTypePrintList').dataset.contractTypeId; const contractTypeId = buttonElement.closest('.container--contractTypePrintList').dataset.contractTypeId;
cityssm.postJSON(`${los.urlPrefix}/admin/${buttonElement.dataset.direction === 'up' cityssm.postJSON(`${sunrise.urlPrefix}/admin/${buttonElement.dataset.direction === 'up'
? 'doMoveContractTypePrintUp' ? 'doMoveContractTypePrintUp'
: 'doMoveContractTypePrintDown'}`, { : 'doMoveContractTypePrintDown'}`, {
contractTypeId, contractTypeId,
@ -357,7 +363,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const printEJS = clickEvent.currentTarget.closest('.container--contractTypePrint').dataset.printEJS; const printEJS = clickEvent.currentTarget.closest('.container--contractTypePrint').dataset.printEJS;
const contractTypeId = clickEvent.currentTarget.closest('.container--contractTypePrintList').dataset.contractTypeId; const contractTypeId = clickEvent.currentTarget.closest('.container--contractTypePrintList').dataset.contractTypeId;
function doDelete() { function doDelete() {
cityssm.postJSON(`${los.urlPrefix}/admin/doDeleteContractTypePrint`, { cityssm.postJSON(`${sunrise.urlPrefix}/admin/doDeleteContractTypePrint`, {
contractTypeId, contractTypeId,
printEJS printEJS
}, contractTypeResponseHandler); }, contractTypeResponseHandler);
@ -408,7 +414,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
</div> </div>
<div class="level-right"> <div class="level-right">
<div class="level-item"> <div class="level-item">
${los.getMoveUpDownButtonFieldHTML('button--moveContractTypePrintUp', 'button--moveContractTypePrintDown')} ${sunrise.getMoveUpDownButtonFieldHTML('button--moveContractTypePrintUp', 'button--moveContractTypePrintDown')}
</div> </div>
<div class="level-item"> <div class="level-item">
<button class="button is-small is-danger button--deleteContractTypePrint" data-tooltip="Delete" type="button" aria-label="Delete Print"> <button class="button is-small is-danger button--deleteContractTypePrint" data-tooltip="Delete" type="button" aria-label="Delete Print">
@ -482,6 +488,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
<div class="level-item"> <div class="level-item">
<h2 class="title is-4">${cityssm.escapeHTML(contractType.contractType)}</h2> <h2 class="title is-4">${cityssm.escapeHTML(contractType.contractType)}</h2>
</div> </div>
${contractType.isPreneed
? `<div class="level-item">
<span class="tag is-info">Preneed</span>
</div>`
: ''}
</div> </div>
<div class="level-right"> <div class="level-right">
<div class="level-item"> <div class="level-item">
@ -503,7 +514,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
</button> </button>
</div> </div>
<div class="level-item"> <div class="level-item">
${los.getMoveUpDownButtonFieldHTML('button--moveContractTypeUp', 'button--moveContractTypeDown')} ${sunrise.getMoveUpDownButtonFieldHTML('button--moveContractTypeUp', 'button--moveContractTypeDown')}
</div> </div>
</div> </div>
</div> </div>
@ -562,7 +573,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
let addCloseModalFunction; let addCloseModalFunction;
function doAdd(submitEvent) { function doAdd(submitEvent) {
submitEvent.preventDefault(); submitEvent.preventDefault();
cityssm.postJSON(`${los.urlPrefix}/admin/doAddContractType`, submitEvent.currentTarget, (rawResponseJSON) => { cityssm.postJSON(`${sunrise.urlPrefix}/admin/doAddContractType`, submitEvent.currentTarget, (rawResponseJSON) => {
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
addCloseModalFunction(); addCloseModalFunction();
@ -580,7 +591,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
cityssm.openHtmlModal('adminContractTypes-add', { cityssm.openHtmlModal('adminContractTypes-add', {
onshow(modalElement) { onshow(modalElement) {
los.populateAliases(modalElement); sunrise.populateAliases(modalElement);
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
addCloseModalFunction = closeModalFunction; addCloseModalFunction = closeModalFunction;

View File

@ -1,4 +1,6 @@
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable max-lines */ /* eslint-disable max-lines */
import type { BulmaJS } from '@cityssm/bulma-js/types.js' import type { BulmaJS } from '@cityssm/bulma-js/types.js'
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js' import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js'
@ -26,7 +28,7 @@ type ResponseJSON =
errorMessage?: string errorMessage?: string
} }
;(() => { ;(() => {
const los = exports.sunrise as Sunrise const sunrise = exports.sunrise as Sunrise
const contractTypesContainerElement = document.querySelector( const contractTypesContainerElement = document.querySelector(
'#container--contractTypes' '#container--contractTypes'
@ -104,7 +106,7 @@ type ResponseJSON =
function doDelete(): void { function doDelete(): void {
cityssm.postJSON( cityssm.postJSON(
`${los.urlPrefix}/admin/doDeleteContractType`, `${sunrise.urlPrefix}/admin/doDeleteContractType`,
{ {
contractTypeId contractTypeId
}, },
@ -144,7 +146,7 @@ type ResponseJSON =
submitEvent.preventDefault() submitEvent.preventDefault()
cityssm.postJSON( cityssm.postJSON(
`${los.urlPrefix}/admin/doUpdateContractType`, `${sunrise.urlPrefix}/admin/doUpdateContractType`,
submitEvent.currentTarget, submitEvent.currentTarget,
(rawResponseJSON) => { (rawResponseJSON) => {
const responseJSON = rawResponseJSON as ResponseJSON const responseJSON = rawResponseJSON as ResponseJSON
@ -159,7 +161,7 @@ type ResponseJSON =
cityssm.openHtmlModal('adminContractTypes-edit', { cityssm.openHtmlModal('adminContractTypes-edit', {
onshow(modalElement) { onshow(modalElement) {
los.populateAliases(modalElement) sunrise.populateAliases(modalElement)
;( ;(
modalElement.querySelector( modalElement.querySelector(
'#contractTypeEdit--contractTypeId' '#contractTypeEdit--contractTypeId'
@ -170,6 +172,14 @@ type ResponseJSON =
'#contractTypeEdit--contractType' '#contractTypeEdit--contractType'
) as HTMLInputElement ) as HTMLInputElement
).value = contractType.contractType ).value = contractType.contractType
if (contractType.isPreneed) {
;(
modalElement.querySelector(
'#contractTypeEdit--isPreneed'
) as HTMLInputElement
).checked = true
}
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
editCloseModalFunction = closeModalFunction editCloseModalFunction = closeModalFunction
@ -205,7 +215,7 @@ type ResponseJSON =
submitEvent.preventDefault() submitEvent.preventDefault()
cityssm.postJSON( cityssm.postJSON(
`${los.urlPrefix}/admin/doAddContractTypeField`, `${sunrise.urlPrefix}/admin/doAddContractTypeField`,
submitEvent.currentTarget, submitEvent.currentTarget,
(rawResponseJSON) => { (rawResponseJSON) => {
const responseJSON = rawResponseJSON as ResponseJSON const responseJSON = rawResponseJSON as ResponseJSON
@ -226,7 +236,7 @@ type ResponseJSON =
cityssm.openHtmlModal('adminContractTypes-addField', { cityssm.openHtmlModal('adminContractTypes-addField', {
onshow(modalElement) { onshow(modalElement) {
los.populateAliases(modalElement) sunrise.populateAliases(modalElement)
if (contractTypeId) { if (contractTypeId) {
;( ;(
@ -264,7 +274,7 @@ type ResponseJSON =
).dataset.contractTypeId ).dataset.contractTypeId
cityssm.postJSON( cityssm.postJSON(
`${los.urlPrefix}/admin/${ `${sunrise.urlPrefix}/admin/${
buttonElement.dataset.direction === 'up' buttonElement.dataset.direction === 'up'
? 'doMoveContractTypeUp' ? 'doMoveContractTypeUp'
: 'doMoveContractTypeDown' : 'doMoveContractTypeDown'
@ -341,7 +351,7 @@ type ResponseJSON =
submitEvent.preventDefault() submitEvent.preventDefault()
cityssm.postJSON( cityssm.postJSON(
`${los.urlPrefix}/admin/doUpdateContractTypeField`, `${sunrise.urlPrefix}/admin/doUpdateContractTypeField`,
submitEvent.currentTarget, submitEvent.currentTarget,
(rawResponseJSON) => { (rawResponseJSON) => {
const responseJSON = rawResponseJSON as ResponseJSON const responseJSON = rawResponseJSON as ResponseJSON
@ -356,7 +366,7 @@ type ResponseJSON =
function doDelete(): void { function doDelete(): void {
cityssm.postJSON( cityssm.postJSON(
`${los.urlPrefix}/admin/doDeleteContractTypeField`, `${sunrise.urlPrefix}/admin/doDeleteContractTypeField`,
{ {
contractTypeFieldId contractTypeFieldId
}, },
@ -386,7 +396,7 @@ type ResponseJSON =
cityssm.openHtmlModal('adminContractTypes-editField', { cityssm.openHtmlModal('adminContractTypes-editField', {
onshow(modalElement) { onshow(modalElement) {
los.populateAliases(modalElement) sunrise.populateAliases(modalElement)
;( ;(
modalElement.querySelector( modalElement.querySelector(
'#contractTypeFieldEdit--contractTypeFieldId' '#contractTypeFieldEdit--contractTypeFieldId'
@ -496,7 +506,7 @@ type ResponseJSON =
).dataset.contractTypeFieldId ).dataset.contractTypeFieldId
cityssm.postJSON( cityssm.postJSON(
`${los.urlPrefix}/admin/${ `${sunrise.urlPrefix}/admin/${
buttonElement.dataset.direction === 'up' buttonElement.dataset.direction === 'up'
? // eslint-disable-next-line no-secrets/no-secrets ? // eslint-disable-next-line no-secrets/no-secrets
'doMoveContractTypeFieldUp' 'doMoveContractTypeFieldUp'
@ -552,7 +562,7 @@ type ResponseJSON =
</div> </div>
<div class="level-right"> <div class="level-right">
<div class="level-item"> <div class="level-item">
${los.getMoveUpDownButtonFieldHTML( ${sunrise.getMoveUpDownButtonFieldHTML(
'button--moveContractTypeFieldUp', 'button--moveContractTypeFieldUp',
'button--moveContractTypeFieldDown' 'button--moveContractTypeFieldDown'
)} )}
@ -593,7 +603,7 @@ type ResponseJSON =
formEvent.preventDefault() formEvent.preventDefault()
cityssm.postJSON( cityssm.postJSON(
`${los.urlPrefix}/admin/doAddContractTypePrint`, `${sunrise.urlPrefix}/admin/doAddContractTypePrint`,
formEvent.currentTarget, formEvent.currentTarget,
(rawResponseJSON) => { (rawResponseJSON) => {
const responseJSON = rawResponseJSON as ResponseJSON const responseJSON = rawResponseJSON as ResponseJSON
@ -609,7 +619,7 @@ type ResponseJSON =
cityssm.openHtmlModal('adminContractTypes-addPrint', { cityssm.openHtmlModal('adminContractTypes-addPrint', {
onshow(modalElement) { onshow(modalElement) {
los.populateAliases(modalElement) sunrise.populateAliases(modalElement)
;( ;(
modalElement.querySelector( modalElement.querySelector(
'#contractTypePrintAdd--contractTypeId' '#contractTypePrintAdd--contractTypeId'
@ -649,7 +659,7 @@ type ResponseJSON =
).dataset.contractTypeId ).dataset.contractTypeId
cityssm.postJSON( cityssm.postJSON(
`${los.urlPrefix}/admin/${ `${sunrise.urlPrefix}/admin/${
buttonElement.dataset.direction === 'up' buttonElement.dataset.direction === 'up'
? 'doMoveContractTypePrintUp' ? 'doMoveContractTypePrintUp'
: 'doMoveContractTypePrintDown' : 'doMoveContractTypePrintDown'
@ -680,7 +690,7 @@ type ResponseJSON =
function doDelete(): void { function doDelete(): void {
cityssm.postJSON( cityssm.postJSON(
`${los.urlPrefix}/admin/doDeleteContractTypePrint`, `${sunrise.urlPrefix}/admin/doDeleteContractTypePrint`,
{ {
contractTypeId, contractTypeId,
printEJS printEJS
@ -749,7 +759,7 @@ type ResponseJSON =
</div> </div>
<div class="level-right"> <div class="level-right">
<div class="level-item"> <div class="level-item">
${los.getMoveUpDownButtonFieldHTML( ${sunrise.getMoveUpDownButtonFieldHTML(
'button--moveContractTypePrintUp', 'button--moveContractTypePrintUp',
'button--moveContractTypePrintDown' 'button--moveContractTypePrintDown'
)} )}
@ -862,6 +872,13 @@ type ResponseJSON =
<div class="level-item"> <div class="level-item">
<h2 class="title is-4">${cityssm.escapeHTML(contractType.contractType)}</h2> <h2 class="title is-4">${cityssm.escapeHTML(contractType.contractType)}</h2>
</div> </div>
${
contractType.isPreneed
? `<div class="level-item">
<span class="tag is-info">Preneed</span>
</div>`
: ''
}
</div> </div>
<div class="level-right"> <div class="level-right">
<div class="level-item"> <div class="level-item">
@ -883,7 +900,7 @@ type ResponseJSON =
</button> </button>
</div> </div>
<div class="level-item"> <div class="level-item">
${los.getMoveUpDownButtonFieldHTML( ${sunrise.getMoveUpDownButtonFieldHTML(
'button--moveContractTypeUp', 'button--moveContractTypeUp',
'button--moveContractTypeDown' 'button--moveContractTypeDown'
)} )}
@ -979,7 +996,7 @@ type ResponseJSON =
submitEvent.preventDefault() submitEvent.preventDefault()
cityssm.postJSON( cityssm.postJSON(
`${los.urlPrefix}/admin/doAddContractType`, `${sunrise.urlPrefix}/admin/doAddContractType`,
submitEvent.currentTarget, submitEvent.currentTarget,
(rawResponseJSON) => { (rawResponseJSON) => {
const responseJSON = rawResponseJSON as ResponseJSON const responseJSON = rawResponseJSON as ResponseJSON
@ -1001,7 +1018,7 @@ type ResponseJSON =
cityssm.openHtmlModal('adminContractTypes-add', { cityssm.openHtmlModal('adminContractTypes-add', {
onshow(modalElement) { onshow(modalElement) {
los.populateAliases(modalElement) sunrise.populateAliases(modalElement)
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
addCloseModalFunction = closeModalFunction addCloseModalFunction = closeModalFunction

View File

@ -90,7 +90,7 @@ function formatTimeString(hour, minute) {
const formattedMinute = `00${minute}`.slice(-2); const formattedMinute = `00${minute}`.slice(-2);
return `${formattedHour}:${formattedMinute}`; return `${formattedHour}:${formattedMinute}`;
} }
const cemeteryTocemeteryName = { const cemeteryToCemeteryName = {
'00': 'Crematorium', '00': 'Crematorium',
GC: 'New Greenwood - Columbarium', GC: 'New Greenwood - Columbarium',
HC: 'Holy Sepulchre - Columbarium', HC: 'Holy Sepulchre - Columbarium',
@ -119,7 +119,7 @@ async function getCemetery(dataRow) {
if (cemetery === undefined) { if (cemetery === undefined) {
console.log(`Creating cemetery: ${dataRow.cemetery}`); console.log(`Creating cemetery: ${dataRow.cemetery}`);
const cemeteryId = await addCemetery({ const cemeteryId = await addCemetery({
cemeteryName: cemeteryTocemeteryName[dataRow.cemetery] ?? dataRow.cemetery, cemeteryName: cemeteryToCemeteryName[dataRow.cemetery] ?? dataRow.cemetery,
cemeteryDescription: dataRow.cemetery, cemeteryDescription: dataRow.cemetery,
cemeterySvg: '', cemeterySvg: '',
cemeteryLatitude: '', cemeteryLatitude: '',
@ -352,7 +352,7 @@ async function importFromMasterCSV() {
if (masterRow.CM_CONTAINER_TYPE !== '') { if (masterRow.CM_CONTAINER_TYPE !== '') {
await addOrUpdateContractField({ await addOrUpdateContractField({
contractId: deceasedcontractId, contractId: deceasedcontractId,
contractTypeFieldId: contractType.ContractTypeFields.find((contractTypeField) => contractTypeField.contractTypeField === 'Container Type').contractTypeFieldId, contractTypeFieldId: contractType.contractTypeFields.find((contractTypeField) => contractTypeField.contractTypeField === 'Container Type').contractTypeFieldId,
contractFieldValue: masterRow.CM_CONTAINER_TYPE contractFieldValue: masterRow.CM_CONTAINER_TYPE
}, user); }, user);
} }

View File

@ -272,7 +272,7 @@ function formatTimeString(hour: string, minute: string): TimeString {
return `${formattedHour}:${formattedMinute}` as TimeString return `${formattedHour}:${formattedMinute}` as TimeString
} }
const cemeteryTocemeteryName = { const cemeteryToCemeteryName = {
'00': 'Crematorium', '00': 'Crematorium',
GC: 'New Greenwood - Columbarium', GC: 'New Greenwood - Columbarium',
HC: 'Holy Sepulchre - Columbarium', HC: 'Holy Sepulchre - Columbarium',
@ -312,7 +312,7 @@ async function getCemetery(dataRow: {
const cemeteryId = await addCemetery( const cemeteryId = await addCemetery(
{ {
cemeteryName: cemeteryName:
cemeteryTocemeteryName[dataRow.cemetery] ?? dataRow.cemetery, cemeteryToCemeteryName[dataRow.cemetery] ?? dataRow.cemetery,
cemeteryDescription: dataRow.cemetery, cemeteryDescription: dataRow.cemetery,
cemeterySvg: '', cemeterySvg: '',
cemeteryLatitude: '', cemeteryLatitude: '',
@ -702,7 +702,7 @@ async function importFromMasterCSV(): Promise<void> {
await addOrUpdateContractField( await addOrUpdateContractField(
{ {
contractId: deceasedcontractId, contractId: deceasedcontractId,
contractTypeFieldId: contractType.ContractTypeFields!.find( contractTypeFieldId: contractType.contractTypeFields!.find(
(contractTypeField) => (contractTypeField) =>
contractTypeField.contractTypeField === 'Container Type' contractTypeField.contractTypeField === 'Container Type'
)!.contractTypeFieldId!, )!.contractTypeFieldId!,

View File

@ -101,6 +101,7 @@ export interface BurialSiteField extends BurialSiteTypeField, Record {
export interface ContractType extends Record { export interface ContractType extends Record {
contractTypeId: number; contractTypeId: number;
contractType: string; contractType: string;
isPreneed: boolean;
orderNumber?: number; orderNumber?: number;
contractTypeFields?: ContractTypeField[]; contractTypeFields?: ContractTypeField[];
contractTypePrints?: string[]; contractTypePrints?: string[];
@ -168,11 +169,26 @@ export interface DynamicsGPDocument {
documentDescription: string[]; documentDescription: string[];
documentTotal: number; documentTotal: number;
} }
export interface IntermentContainerType extends Record {
intermentContainerTypeId: number;
intermentContainerType: string;
orderNumber?: number;
}
export interface IntermentCommittalType extends Record {
intermentCommittalTypeId: number;
intermentCommittalType: string;
orderNumber?: number;
}
export interface ContractInterment extends Record { export interface ContractInterment extends Record {
contractId?: number; contractId?: number;
intermentNumber?: number; intermentNumber?: number;
isCremated?: boolean;
deceasedName?: string; deceasedName?: string;
isCremated?: boolean;
deceasedAddress1?: string;
deceasedAddress2?: string;
deceasedCity?: string;
deceasedProvince?: string;
deceasedPostalCode?: string;
birthDate?: number; birthDate?: number;
birthDateString?: string; birthDateString?: string;
birthPlace?: string; birthPlace?: string;
@ -181,8 +197,6 @@ export interface ContractInterment extends Record {
deathPlace?: string; deathPlace?: string;
intermentDate?: number; intermentDate?: number;
intermentDateString?: string; intermentDateString?: string;
intermentTime?: number;
intermentTimeString?: string;
intermentContainerTypeId?: number; intermentContainerTypeId?: number;
intermentContainerType?: string; intermentContainerType?: string;
intermentCommittalTypeId?: number; intermentCommittalTypeId?: number;
@ -209,6 +223,7 @@ export interface Contract extends Record {
contractId: number; contractId: number;
contractTypeId: number; contractTypeId: number;
contractType?: string; contractType?: string;
isPreneed?: boolean;
printEJS?: string; printEJS?: string;
burialSiteId?: number; burialSiteId?: number;
burialSiteTypeId?: number; burialSiteTypeId?: number;
@ -228,9 +243,10 @@ export interface Contract extends Record {
purchaserPostalCode?: string; purchaserPostalCode?: string;
purchaserPhoneNumber?: string; purchaserPhoneNumber?: string;
purchaserEmail?: string; purchaserEmail?: string;
purchaserRelationship?: string;
funeralHomeId?: number; funeralHomeId?: number;
funeralHomeDirectorName?: string;
funeralHomeName?: string; funeralHomeName?: string;
funeralDirectorName?: string;
contractFields?: ContractField[]; contractFields?: ContractField[];
contractComments?: ContractComment[]; contractComments?: ContractComment[];
contractInterments?: ContractInterment[]; contractInterments?: ContractInterment[];

View File

@ -133,6 +133,7 @@ export interface BurialSiteField extends BurialSiteTypeField, Record {
export interface ContractType extends Record { export interface ContractType extends Record {
contractTypeId: number contractTypeId: number
contractType: string contractType: string
isPreneed: boolean
orderNumber?: number orderNumber?: number
contractTypeFields?: ContractTypeField[] contractTypeFields?: ContractTypeField[]
contractTypePrints?: string[] contractTypePrints?: string[]
@ -218,12 +219,30 @@ export interface DynamicsGPDocument {
documentTotal: number documentTotal: number
} }
export interface IntermentContainerType extends Record {
intermentContainerTypeId: number
intermentContainerType: string
orderNumber?: number
}
export interface IntermentCommittalType extends Record {
intermentCommittalTypeId: number
intermentCommittalType: string
orderNumber?: number
}
export interface ContractInterment extends Record { export interface ContractInterment extends Record {
contractId?: number contractId?: number
intermentNumber?: number intermentNumber?: number
isCremated?: boolean
deceasedName?: string deceasedName?: string
isCremated?: boolean
deceasedAddress1?: string
deceasedAddress2?: string
deceasedCity?: string
deceasedProvince?: string
deceasedPostalCode?: string
birthDate?: number birthDate?: number
birthDateString?: string birthDateString?: string
@ -236,9 +255,6 @@ export interface ContractInterment extends Record {
intermentDate?: number intermentDate?: number
intermentDateString?: string intermentDateString?: string
intermentTime?: number
intermentTimeString?: string
intermentContainerTypeId?: number intermentContainerTypeId?: number
intermentContainerType?: string intermentContainerType?: string
@ -274,6 +290,8 @@ export interface Contract extends Record {
contractTypeId: number contractTypeId: number
contractType?: string contractType?: string
isPreneed?: boolean
printEJS?: string printEJS?: string
burialSiteId?: number burialSiteId?: number
@ -298,10 +316,11 @@ export interface Contract extends Record {
purchaserPostalCode?: string purchaserPostalCode?: string
purchaserPhoneNumber?: string purchaserPhoneNumber?: string
purchaserEmail?: string purchaserEmail?: string
purchaserRelationship?: string
funeralHomeId?: number funeralHomeId?: number
funeralHomeDirectorName?: string
funeralHomeName?: string funeralHomeName?: string
funeralDirectorName?: string
contractFields?: ContractField[] contractFields?: ContractField[]
contractComments?: ContractComment[] contractComments?: ContractComment[]

View File

@ -129,7 +129,7 @@
<span> <span>
<%= (isCreate ? "Create" : "Update") %> <%= (isCreate ? "Create" : "Update") %>
<span class="is-hidden-touch"> <span class="is-hidden-touch">
Contract Record Contract
</span> </span>
</span> </span>
</button> </button>
@ -158,7 +158,7 @@
required accesskey="f" required accesskey="f"
<%= (isCreate ? " autofocus" : "") %>> <%= (isCreate ? " autofocus" : "") %>>
<% if (isCreate) { %> <% if (isCreate) { %>
<option value="">(No Type)</option> <option value="" data-is-preneed="false">(No Type)</option>
<% } %> <% } %>
<% let typeIsFound = false; %> <% let typeIsFound = false; %>
<% for (const contractType of contractTypes) { %> <% for (const contractType of contractTypes) { %>
@ -168,13 +168,16 @@
} }
%> %>
<option value="<%= contractType.contractTypeId %>" <option value="<%= contractType.contractTypeId %>"
<%= (contract.contractTypeId === contractType.contractTypeId ? " selected" : "") %> <%- (contractType.isPreneed ? ' data-is-preneed="true"' : ' data-is-preneed="false"') %>
<%= (contract.contractTypeId === contractType.contractTypeId ? ' selected' : '') %>
<%= (!isCreate && contract.contractTypeId !== contractType.contractTypeId ? " disabled" : "") %>> <%= (!isCreate && contract.contractTypeId !== contractType.contractTypeId ? " disabled" : "") %>>
<%= contractType.contractType %> <%= contractType.contractType %>
</option> </option>
<% } %> <% } %>
<% if (contract.contractTypeId && !typeIsFound) { %> <% if (contract.contractTypeId && !typeIsFound) { %>
<option value="<%= contract.contractTypeId %>" selected> <option value="<%= contract.contractTypeId %>"
<%- (contract.isPreneed ? ' data-is-preneed="true"' : ' data-is-preneed="false"') %>
selected>
<%= contract.contractType %> <%= contract.contractType %>
</option> </option>
<% } %> <% } %>
@ -201,7 +204,7 @@
<%= (isCreate ? "" : " disabled readonly") %> /> <%= (isCreate ? "" : " disabled readonly") %> />
</div> </div>
<div class="control is-hidden-print"> <div class="control is-hidden-print">
<button class="button is-clear-lot-button" data-tooltip="Clear" type="button" aria-label="Clear Burial Site Field"> <button class="button is-clear-burial-site-button" data-tooltip="Clear" type="button" aria-label="Clear Burial Site Field">
<i class="fas fa-eraser" aria-hidden="true"></i> <i class="fas fa-eraser" aria-hidden="true"></i>
</button> </button>
</div> </div>
@ -211,7 +214,7 @@
</button> </button>
</div> </div>
<div class="control is-hidden-print"> <div class="control is-hidden-print">
<button class="button is-lot-view-button" data-tooltip="Open Burial Site" type="button" aria-label="Open Burial Site"> <button class="button is-burial-site-view-button" data-tooltip="Open Burial Site" type="button" aria-label="Open Burial Site">
<i class="fas fa-external-link-alt" aria-hidden="true"></i> <i class="fas fa-external-link-alt" aria-hidden="true"></i>
</button> </button>
</div> </div>
@ -304,7 +307,8 @@
<% } %> <% } %>
minlength="<%= contractField.minLength %>" minlength="<%= contractField.minLength %>"
maxlength="<%= contractField.maxLength %>" maxlength="<%= contractField.maxLength %>"
<%= contractField.isRequired ? " required" : "" %> /> <%= contractField.isRequired ? " required" : "" %>
/>
<% } %> <% } %>
</div> </div>
</div> </div>
@ -317,6 +321,44 @@
</div> </div>
</div> </div>
<div class="panel">
<h2 class="panel-heading">Funeral Home</h2>
<div class="panel-block is-block">
<div class="columns">
<div class="column">
<div class="field">
<label class="label" for="contract--funeralHomeId">
Funeral Home
</label>
<div class="control">
<div class="select is-fullwidth">
<select id="contract--funeralHomeId" name="funeralHomeId">
<option value="">(No Funeral Home)</option>
<% for (const funeralHome of funeralHomes) { %>
<option value="<%= funeralHome.funeralHomeId %>"
<%= (contract.funeralHomeId === funeralHome.funeralHomeId ? " selected" : "") %>>
<%= funeralHome.funeralHomeName %>
</option>
<% } %>
</select>
</div>
</div>
</div>
</div>
<div class="column">
<div class="field">
<label class="label" for="contract--funeralDirectorName">
Funeral Director's Name
</label>
<div class="control">
<input class="input" id="contract--funeralDirectorName" name="funeralDirectorName" type="text" maxlength="100" autocomplete="off" value="<%= contract.funeralDirectorName %>" />
</div>
</div>
</div>
</div>
</div>
</div>
<div class="columns"> <div class="columns">
<div class="column"> <div class="column">
<div class="panel"> <div class="panel">
@ -330,7 +372,6 @@
<input class="input" id="contract--purchaserName" name="purchaserName" type="text" maxlength="100" autocomplete="off" required value="<%= contract.purchaserName %>" /> <input class="input" id="contract--purchaserName" name="purchaserName" type="text" maxlength="100" autocomplete="off" required value="<%= contract.purchaserName %>" />
</div> </div>
</div> </div>
<div class="field"> <div class="field">
<label class="label" for="contract--purchaserAddress1">Address</label> <label class="label" for="contract--purchaserAddress1">Address</label>
<div class="control"> <div class="control">
@ -373,56 +414,232 @@
<div class="field"> <div class="field">
<label class="label" for="contract--purchaserPhoneNumber">Phone Number</label> <label class="label" for="contract--purchaserPhoneNumber">Phone Number</label>
<div class="control"> <div class="control">
<input class="input" id="contract--purchaserPhoneNumber" name="purchaserPhoneNumber" type="text" maxlength="30" autocomplete="off" /> <input class="input" id="contract--purchaserPhoneNumber" name="purchaserPhoneNumber" type="text" maxlength="30" autocomplete="off" value="<%= contract.purchaserPhoneNumber %>" />
</div> </div>
</div> </div>
</div> </div>
<div class="column"> <div class="column">
<div class="field"> <div class="field">
<label class="label" for="contract--purchaserEmailAddress">Email Address</label> <label class="label" for="contract--purchaserEmail">Email Address</label>
<div class="control"> <div class="control">
<input class="input" id="contract--purchaserEmailAddress" name="purchaserEmailAddress" type="email" maxlength="100" autocomplete="off" /> <input class="input" id="contract--purchaserEmail" name="purchaserEmail" type="email" maxlength="100" autocomplete="off" value="<%= contract.purchaserEmail %>" />
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="field">
<label class="label" for="contract--purchaserRelationship">
Relationship to Deceased
</label>
<div class="control">
<input class="input" id="contract--purchaserRelationship" name="purchaserRelationship" type="text" maxlength="100" autocomplete="off" value="<%= contract.purchaserRelationship %>" />
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="column"> <div class="column">
<div class="panel"> <% if (isCreate) { %>
<h2 class="panel-heading">Deceased</h2>
</div>
<div class="panel">
<h2 class="panel-heading">Funeral Home</h2>
</div>
</div>
</div>
</form>
<% if (!isCreate) { %>
<div class="panel"> <div class="panel">
<div class="panel-heading"> <div class="panel-heading">
<div class="level is-mobile"> <div class="level is-mobile">
<div class="level-left"> <div class="level-left">
<div class="level-item"> <div class="level-item">
<h2 class="has-text-weight-bold is-size-5">Comments</h2> <h2 class="has-text-weight-bold is-size-5 is-recipient-or-deceased">
<%= (contract.isPreneed ? "Recipient" : "Deceased") %>
</h2>
</div> </div>
</div> </div>
<div class="level-right"> <div class="level-right">
<div class="level-item"> <div class="level-item">
<button class="button is-small is-success is-hidden-print" id="button--addComment" type="button"> <button class="button is-small is-hidden-print" id="button--copyFromPurchaser" type="button">
<span class="icon is-small"><i class="fas fa-plus" aria-hidden="true"></i></span> <span class="icon is-small"><i class="far fa-copy" aria-hidden="true"></i></span>
<span>Add Comment</span> <span>Copy from Purchaser</span>
</button> </button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="panel-block is-block" id="container--contractComments"></div> <div class="panel-block is-block">
<div class="field">
<label class="label" for="contract--deceasedName">
<span class="is-recipient-or-deceased"><%= (contract.isPreneed ? "Recipient" : "Deceased") %></span>
Name
</label>
<div class="control">
<input class="input" id="contract--deceasedName" name="deceasedName" type="text" maxlength="100" autocomplete="off" required value="<%= contract.deceasedName %>" />
</div>
</div>
<div class="field">
<label class="label" for="contract--deceasedAddress1">Address</label>
<div class="control">
<input class="input" id="contract--deceasedAddress1" name="deceasedAddress1" type="text" maxlength="50" placeholder="Line 1" autocomplete="off" value="<%= contract.deceasedAddress1 %>" />
</div>
</div>
<div class="field">
<div class="control">
<input class="input" id="contract--deceasedAddress2" name="deceasedAddress2" type="text" maxlength="50" placeholder="Line 2" autocomplete="off" aria-label="Address Line 2" value="<%= contract.deceasedAddress2 %>" />
</div>
</div>
<div class="columns">
<div class="column">
<div class="field">
<label class="label" for="contract--deceasedCity">City</label>
<div class="control">
<input class="input" id="contract--deceasedCity" name="deceasedCity" type="text" maxlength="20" value="<%= contract.deceasedCity %>" />
</div>
</div>
</div>
<div class="column">
<div class="field">
<label class="label" for="contract--deceasedProvince">Province</label>
<div class="control">
<input class="input" id="contract--deceasedProvince" name="deceasedProvince" type="text" maxlength="2" value="<%= contract.deceasedProvince %>" />
</div>
</div>
</div>
<div class="column">
<div class="field">
<label class="label" for="contract--deceasedPostalCode">Postal Code</label>
<div class="control">
<input class="input" id="contract--deceasedPostalCode" name="deceasedPostalCode" type="text" maxlength="7" autocomplete="off" value="<%= contract.deceasedPostalCode %>" />
</div>
</div>
</div>
</div>
<div class="columns">
<div class="column">
<div class="field">
<label class="label" for="contract--birthDateString">
Date of Birth
</label>
<div class="control has-icons-left">
<input class="input" id="contract--birthDateString" name="birthDateString" type="date" value="<%= contract.birthDateString %>" />
<span class="icon is-left">
<i class="fas fa-calendar" aria-hidden="true"></i>
</span>
</div>
</div>
</div>
<div class="column">
<div class="field">
<label class="label" for="contract--birthPlace">
Place of Birth
</label>
<div class="control">
<input class="input" id="contract--birthPlace" name="birthPlace" type="text" maxlength="100" autocomplete="off" value="<%= contract.deceasedPlaceOfBirth %>" />
</div>
</div>
</div>
</div>
<div class="columns">
<div class="column">
<div class="field">
<label class="label" for="contract--deathDateString">
Date of Death
</label>
<div class="control has-icons-left">
<input class="input" id="contract--deathDateString" name="deathDateString" type="date" value="<%= contract.deceasedDateOfDeathString %>" />
<span class="icon is-left">
<i class="fas fa-calendar" aria-hidden="true"></i>
</span>
</div>
</div>
</div>
<div class="column">
<div class="field">
<label class="label" for="contract--deathPlace">
Place of Death
</label>
<div class="control">
<input class="input" id="contract--deathPlace" name="deathPlace" type="text" maxlength="100" autocomplete="off" value="<%= contract.deceasedPlaceOfDeath %>" />
</div>
</div>
</div>
</div>
<div class="message is-info is-small">
<p class="message-body">
Any additional interments associated with this contract can be added after the contract is created.
</p>
</div>
</div>
</div>
<% } else { %>
<div class="panel">
<div class="panel-heading">
<div class="level is-mobile">
<div class="level-left">
<div class="level-item">
<h2 class="has-text-weight-bold is-size-5">
<%= (contract.isPreneed ? "Recipient" : "Deceased") %>
</h2>
</div>
</div>
<div class="level-right">
<div class="level-item">
<button class="button is-small is-success is-hidden-print" id="button--addInterment" type="button">
<span class="icon is-small"><i class="fas fa-plus" aria-hidden="true"></i></span>
<span>Add Additional <%= (contract.isPreneed ? "Recipient" : "Deceased") %></span>
</button>
</div>
</div>
</div>
</div>
<div class="panel-block is-block">
</div>
</div>
<% } %>
</div>
</div>
</form>
<% if (!isCreate) { %>
<div class="columns is-desktop mt-4">
<div class="column is-7-desktop">
<div class="panel">
<div class="panel-heading">
<div class="level is-mobile">
<div class="level-left">
<div class="level-item">
<h2 class="has-text-weight-bold is-size-5">Fees</h2>
</div>
</div>
<div class="level-right">
<div class="level-item">
<button class="button is-small is-success is-hidden-print" id="button--addFee" type="button">
<span class="icon is-small"><i class="fas fa-plus" aria-hidden="true"></i></span>
<span>Add Fee</span>
</button>
</div>
</div>
</div>
</div>
<div class="panel-block is-block" id="container--contractFees"></div>
</div>
</div>
<div class="column">
<div class="panel">
<div class="panel-heading">
<div class="level is-mobile">
<div class="level-left">
<div class="level-item">
<h2 class="has-text-weight-bold is-size-5">Transactions</h2>
</div>
</div>
<div class="level-right">
<div class="level-item">
<button class="button is-small is-success is-hidden-print" id="button--addTransaction" type="button">
<span class="icon is-small"><i class="fas fa-plus" aria-hidden="true"></i></span>
<span>Add Transaction</span>
</button>
</div>
</div>
</div>
</div>
<div class="panel-block is-block" id="container--contractTransactions"></div>
</div>
</div>
</div> </div>
<% <%
@ -495,51 +712,25 @@
</div> </div>
</div> </div>
<div class="columns is-desktop">
<div class="column is-7-desktop">
<div class="panel"> <div class="panel">
<div class="panel-heading"> <div class="panel-heading">
<div class="level is-mobile"> <div class="level is-mobile">
<div class="level-left"> <div class="level-left">
<div class="level-item"> <div class="level-item">
<h2 class="has-text-weight-bold is-size-5">Fees</h2> <h2 class="has-text-weight-bold is-size-5">Comments</h2>
</div> </div>
</div> </div>
<div class="level-right"> <div class="level-right">
<div class="level-item"> <div class="level-item">
<button class="button is-small is-success is-hidden-print" id="button--addFee" type="button"> <button class="button is-small is-success is-hidden-print" id="button--addComment" type="button">
<span class="icon is-small"><i class="fas fa-plus" aria-hidden="true"></i></span> <span class="icon is-small"><i class="fas fa-plus" aria-hidden="true"></i></span>
<span>Add Fee</span> <span>Add Comment</span>
</button> </button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="panel-block is-block" id="container--contractFees"></div> <div class="panel-block is-block" id="container--contractComments"></div>
</div>
</div>
<div class="column">
<div class="panel">
<div class="panel-heading">
<div class="level is-mobile">
<div class="level-left">
<div class="level-item">
<h2 class="has-text-weight-bold is-size-5">Transactions</h2>
</div>
</div>
<div class="level-right">
<div class="level-item">
<button class="button is-small is-success is-hidden-print" id="button--addTransaction" type="button">
<span class="icon is-small"><i class="fas fa-plus" aria-hidden="true"></i></span>
<span>Add Transaction</span>
</button>
</div>
</div>
</div>
</div>
<div class="panel-block is-block" id="container--contractTransactions"></div>
</div>
</div>
</div> </div>
<% } %> <% } %>
@ -557,10 +748,6 @@
exports.workOrderTypes = <%- JSON.stringify(workOrderTypes) %>; exports.workOrderTypes = <%- JSON.stringify(workOrderTypes) %>;
<% } %> <% } %>
exports.burialSiteTypes = <%- JSON.stringify(burialSiteTypes) %>;
exports.burialSiteStatuses = <%- JSON.stringify(burialSiteStatuses) %>;
exports.cemeteries = <%- JSON.stringify(cemeteries) %>;
</script> </script>
<script src="<%= urlPrefix %>/javascripts/contract.edit.js"></script> <script src="<%= urlPrefix %>/javascripts/contract.edit.js"></script>