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';
export interface AddContractForm {
contractTypeId: string | number;
burialSiteId: string | number;
contractStartDateString: string;
contractEndDateString: string;
contractStartDateString: DateString | '';
contractEndDateString: DateString | '';
contractTypeFieldIds?: string;
[fieldValue_contractTypeFieldId: string]: unknown;
lotOccupantTypeId?: string;
occupantName?: string;
occupantFamilyName?: string;
occupantAddress1?: string;
occupantAddress2?: string;
occupantCity?: string;
occupantProvince?: string;
occupantPostalCode?: string;
occupantPhoneNumber?: string;
occupantEmailAddress?: string;
occupantComment?: string;
[fieldValue_contractTypeFieldId: `fieldValue_${string}`]: unknown;
purchaserName?: string;
purchaserAddress1?: string;
purchaserAddress2?: string;
purchaserCity?: string;
purchaserProvince?: string;
purchaserPostalCode?: string;
purchaserPhoneNumber?: string;
purchaserEmail?: string;
purchaserRelationship?: 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;
}
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 addOrUpdateContractField from './addOrUpdateContractField.js';
import { acquireConnection } from './pool.js';
// eslint-disable-next-line complexity
export default async function addContract(addForm, user, connectedDatabase) {
const database = connectedDatabase ?? (await acquireConnection());
const rightNowMillis = Date.now();
const contractStartDate = dateStringToInteger(addForm.contractStartDateString);
const result = database
.prepare(`insert into Contracts (
contractTypeId, lotId,
contractTypeId, burialSiteId,
contractStartDate, contractEndDate,
purchaserName, purchaserAddress1, purchaserAddress2,
purchaserCity, purchaserProvince, purchaserPostalCode,
purchaserPhoneNumber, purchaserEmail, purchaserRelationship,
funeralHomeId, funeralDirectorName,
recordCreate_userName, recordCreate_timeMillis,
recordUpdate_userName, recordUpdate_timeMillis)
values (?, ?, ?, ?, ?, ?, ?, ?)`)
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
.run(addForm.contractTypeId, addForm.burialSiteId === '' ? undefined : addForm.burialSiteId, contractStartDate, addForm.contractEndDateString === ''
? 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;
/*
* Add contract fields
*/
const contractTypeFieldIds = (addForm.contractTypeFieldIds ?? '').split(',');
for (const contractTypeFieldId of contractTypeFieldIds) {
const fieldValue = addForm[`fieldValue_${contractTypeFieldId}`];
@ -27,6 +35,34 @@ export default async function addContract(addForm, user, connectedDatabase) {
}, 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) {
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 addOrUpdateContractField from './addOrUpdateContractField.js'
@ -8,25 +11,42 @@ export interface AddContractForm {
contractTypeId: string | number
burialSiteId: string | number
contractStartDateString: string
contractEndDateString: string
contractStartDateString: DateString | ''
contractEndDateString: DateString | ''
contractTypeFieldIds?: string
[fieldValue_contractTypeFieldId: string]: unknown
[fieldValue_contractTypeFieldId: `fieldValue_${string}`]: unknown
lotOccupantTypeId?: string
occupantName?: string
occupantFamilyName?: string
occupantAddress1?: string
occupantAddress2?: string
occupantCity?: string
occupantProvince?: string
occupantPostalCode?: string
occupantPhoneNumber?: string
occupantEmailAddress?: string
occupantComment?: string
purchaserName?: string
purchaserAddress1?: string
purchaserAddress2?: string
purchaserCity?: string
purchaserProvince?: string
purchaserPostalCode?: string
purchaserPhoneNumber?: string
purchaserEmail?: string
purchaserRelationship?: 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(
addForm: AddContractForm,
user: User,
@ -43,11 +63,15 @@ export default async function addContract(
const result = database
.prepare(
`insert into Contracts (
contractTypeId, lotId,
contractTypeId, burialSiteId,
contractStartDate, contractEndDate,
purchaserName, purchaserAddress1, purchaserAddress2,
purchaserCity, purchaserProvince, purchaserPostalCode,
purchaserPhoneNumber, purchaserEmail, purchaserRelationship,
funeralHomeId, funeralDirectorName,
recordCreate_userName, recordCreate_timeMillis,
recordUpdate_userName, recordUpdate_timeMillis)
values (?, ?, ?, ?, ?, ?, ?, ?)`
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
)
.run(
addForm.contractTypeId,
@ -56,6 +80,17 @@ export default async function addContract(
addForm.contractEndDateString === ''
? undefined
: 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,
rightNowMillis,
user.userName,
@ -64,6 +99,10 @@ export default async function addContract(
const contractId = result.lastInsertRowid as number
/*
* Add contract fields
*/
const contractTypeFieldIds = (addForm.contractTypeFieldIds ?? '').split(',')
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) {
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 {};

View File

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

View File

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

View File

@ -2,7 +2,7 @@ import { dateIntegerToString } from '@cityssm/utils-datetime';
import getContractComments from './getContractComments.js';
import getContractFees from './getContractFees.js';
import getContractFields from './getContractFields.js';
// import getContractOccupants from './getContractOccupants.js'
import getContractInterments from './getContractInterments.js';
import getContractTransactions from './getContractTransactions.js';
import { getWorkOrders } from './getWorkOrders.js';
import { acquireConnection } from './pool.js';
@ -11,29 +11,26 @@ export default async function getContract(contractId, connectedDatabase) {
database.function('userFn_dateIntegerToString', dateIntegerToString);
const contract = database
.prepare(`select o.contractId,
o.contractTypeId, t.contractType,
o.burialSiteId,
l.burialSiteName,
l.burialSiteTypeId,
o.contractTypeId, t.contractType, t.isPreneed,
o.burialSiteId, l.burialSiteName, l.burialSiteTypeId,
l.cemeteryId, m.cemeteryName,
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
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
from Contracts o
left join ContractTypes t on o.contractTypeId = t.contractTypeId
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
and o.contractId = ?`)
.get(contractId);
if (contract !== undefined) {
contract.contractFields = await getContractFields(contractId, database);
/*
contract.contractInterments = await getContractOccupants(
contractId,
database
)
*/
contract.contractInterments = await getContractInterments(contractId, database);
contract.contractComments = await getContractComments(contractId, database);
contract.contractFees = await getContractFees(contractId, 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 getContractFees from './getContractFees.js'
import getContractFields from './getContractFields.js'
// import getContractOccupants from './getContractOccupants.js'
import getContractInterments from './getContractInterments.js'
import getContractTransactions from './getContractTransactions.js'
import { getWorkOrders } from './getWorkOrders.js'
import { acquireConnection } from './pool.js'
@ -22,42 +22,35 @@ export default async function getContract(
const contract = database
.prepare(
`select o.contractId,
o.contractTypeId, t.contractType,
o.burialSiteId,
l.burialSiteName,
l.burialSiteTypeId,
o.contractTypeId, t.contractType, t.isPreneed,
o.burialSiteId, l.burialSiteName, l.burialSiteTypeId,
l.cemeteryId, m.cemeteryName,
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
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
from Contracts o
left join ContractTypes t on o.contractTypeId = t.contractTypeId
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
and o.contractId = ?`
)
.get(contractId) as Contract | undefined
if (contract !== undefined) {
contract.contractFields = await getContractFields(
contractId,
database
)
/*
contract.contractInterments = await getContractOccupants(
contractId,
database
)
*/
contract.contractComments = await getContractComments(
contractId,
database
)
contract.contractFees = await getContractFees(
contract.contractFields = await getContractFields(contractId, database)
contract.contractInterments = await getContractInterments(
contractId,
database
)
contract.contractComments = await getContractComments(contractId, database)
contract.contractFees = await getContractFees(contractId, database)
contract.contractTransactions = await getContractTransactions(
contractId,
{ 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';
export default async function getContractInterments(contractId, connectedDatabase) {
const database = connectedDatabase ?? (await acquireConnection());
database.function('userFn_dateIntegerToString', dateIntegerToString);
database.function('userFn_timeIntegerToString', timeIntegerToString);
const interments = database
.prepare(`select o.contractId, o.intermentNumber,
o.isCremated,
o.deceasedName,
birthDate, userFn_dateIntegerToString(birthDate) as birthDateString,
birthPlace,
deathDate, userFn_dateIntegerToString(deathDate) as deathDateString,
deathPlace,
o.birthDate, userFn_dateIntegerToString(o.birthDate) as birthDateString,
o.birthPlace,
o.deathDate, userFn_dateIntegerToString(o.deathDate) as deathDateString,
o.deathPlace,
intermentDate, userFn_dateIntegerToString(intermentDate) as intermentDateString,
intermentTime, userFn_timeIntegerToString(intermentTime) as intermentTimeString,
o.intermentDate, userFn_dateIntegerToString(o.intermentDate) as intermentDateString,
intermentContainerTypeId, t.intermentContainerType,
intermentCommittalTypeId, c.intermentCommittalType
o.intermentContainerTypeId, t.intermentContainerType,
o.intermentCommittalTypeId, c.intermentCommittalType
from ContractInterments o
left join IntermentContainerTypes t on o.intermentContainerTypeId = t.intermentContainerTypeId

View File

@ -1,6 +1,5 @@
import {
dateIntegerToString,
timeIntegerToString
dateIntegerToString
} from '@cityssm/utils-datetime'
import type { PoolConnection } from 'better-sqlite-pool'
@ -15,23 +14,21 @@ export default async function getContractInterments(
const database = connectedDatabase ?? (await acquireConnection())
database.function('userFn_dateIntegerToString', dateIntegerToString)
database.function('userFn_timeIntegerToString', timeIntegerToString)
const interments = database
.prepare(
`select o.contractId, o.intermentNumber,
o.isCremated,
o.deceasedName,
birthDate, userFn_dateIntegerToString(birthDate) as birthDateString,
birthPlace,
deathDate, userFn_dateIntegerToString(deathDate) as deathDateString,
deathPlace,
o.birthDate, userFn_dateIntegerToString(o.birthDate) as birthDateString,
o.birthPlace,
o.deathDate, userFn_dateIntegerToString(o.deathDate) as deathDateString,
o.deathPlace,
intermentDate, userFn_dateIntegerToString(intermentDate) as intermentDateString,
intermentTime, userFn_timeIntegerToString(intermentTime) as intermentTimeString,
o.intermentDate, userFn_dateIntegerToString(o.intermentDate) as intermentDateString,
intermentContainerTypeId, t.intermentContainerType,
intermentCommittalTypeId, c.intermentCommittalType
o.intermentContainerTypeId, t.intermentContainerType,
o.intermentCommittalTypeId, c.intermentCommittalType
from ContractInterments o
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() {
const database = await acquireConnection();
const contractTypes = database
.prepare(`select contractTypeId, contractType, orderNumber
.prepare(`select contractTypeId, contractType, isPreneed, orderNumber
from ContractTypes
where recordDelete_timeMillis is null
order by orderNumber, contractType`)

View File

@ -10,7 +10,7 @@ export default async function getContractTypes(): Promise<ContractType[]> {
const contractTypes = database
.prepare(
`select contractTypeId, contractType, orderNumber
`select contractTypeId, contractType, isPreneed, orderNumber
from ContractTypes
where recordDelete_timeMillis is null
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 { getBurialSiteNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js';
import getContractFees from './getContractFees.js';
// import getContractOccupants from './getContractOccupants.js'
import getContractInterments from './getContractInterments.js';
import getContractTransactions from './getContractTransactions.js';
import { acquireConnection } from './pool.js';
function buildWhereClause(filters) {
@ -70,18 +70,11 @@ async function addInclusions(contract, options, database) {
contract.contractFees = await getContractFees(contract.contractId, database);
}
if (options.includeTransactions) {
contract.contractTransactions =
await getContractTransactions(contract.contractId, { includeIntegrations: false }, database);
contract.contractTransactions = await getContractTransactions(contract.contractId, { includeIntegrations: false }, database);
}
/*
if (options.includeInterments) {
contract.contractInterments =
await getContractOccupants(
contract.contractId,
database
)
contract.contractInterments = await getContractInterments(contract.contractId, database);
}
*/
return contract;
}
export default async function getContracts(filters, options, connectedDatabase) {
@ -104,12 +97,15 @@ export default async function getContracts(filters, options, connectedDatabase)
if (count !== 0) {
contracts = database
.prepare(`select o.contractId,
o.contractTypeId, t.contractType,
o.burialSiteId, lt.burialSiteType,
l.burialSiteName,
o.contractTypeId, t.contractType, t.isPreneed,
o.burialSiteId, lt.burialSiteType, l.burialSiteName,
l.cemeteryId, m.cemeteryName,
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
left join ContractTypes t on o.contractTypeId = t.contractTypeId
left join BurialSites l on o.burialSiteId = l.burialSiteId

View File

@ -15,7 +15,7 @@ import {
import type { Contract } from '../types/recordTypes.js'
import getContractFees from './getContractFees.js'
// import getContractOccupants from './getContractOccupants.js'
import getContractInterments from './getContractInterments.js'
import getContractTransactions from './getContractTransactions.js'
import { acquireConnection } from './pool.js'
@ -139,30 +139,23 @@ async function addInclusions(
database: PoolConnection
): Promise<Contract> {
if (options.includeFees) {
contract.contractFees = await getContractFees(
contract.contractId,
database
)
contract.contractFees = await getContractFees(contract.contractId, database)
}
if (options.includeTransactions) {
contract.contractTransactions =
await getContractTransactions(
contract.contractTransactions = await getContractTransactions(
contract.contractId,
{ includeIntegrations: false },
database
)
}
/*
if (options.includeInterments) {
contract.contractInterments =
await getContractOccupants(
contract.contractInterments = await getContractInterments(
contract.contractId,
database
)
}
*/
return contract
}
@ -204,12 +197,15 @@ export default async function getContracts(
contracts = database
.prepare(
`select o.contractId,
o.contractTypeId, t.contractType,
o.burialSiteId, lt.burialSiteType,
l.burialSiteName,
o.contractTypeId, t.contractType, t.isPreneed,
o.burialSiteId, lt.burialSiteType, l.burialSiteName,
l.cemeteryId, m.cemeteryName,
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
left join ContractTypes t on o.contractTypeId = t.contractTypeId
left join BurialSites l on o.burialSiteId = l.burialSiteId
@ -234,14 +230,12 @@ export default async function getContracts(
}
for (const contract of contracts) {
const contractType = await getContractTypeById(
contract.contractTypeId
)
const contractType = await getContractTypeById(contract.contractTypeId)
if (contractType !== undefined) {
contract.printEJS = (
contractType.contractTypePrints ?? []
).includes('*')
contract.printEJS = (contractType.contractTypePrints ?? []).includes(
'*'
)
? getConfigProperty('settings.contracts.prints')[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_NAMESPACE } from '../debug.config.js';
import { sunriseDB as databasePath } from '../helpers/database.helpers.js';
import addContractType from './addContractType.js';
import addFeeCategory from './addFeeCategory.js';
import addRecord from './addRecord.js';
const debug = Debug(`${DEBUG_NAMESPACE}:database/initializeDatabase`);
@ -132,6 +133,7 @@ const createStatements = [
`create table if not exists ContractTypes (
contractTypeId integer not null primary key autoincrement,
contractType varchar(100) not null,
isPreneed bit not null default 0,
orderNumber smallint not null default 0,
${recordColumns})`,
`create index if not exists idx_ContractTypes_orderNumber
@ -175,6 +177,7 @@ const createStatements = [
purchaserPostalCode varchar(7),
purchaserPhoneNumber varchar(30),
purchaserEmail varchar(100),
purchaserRelationship varchar(50),
funeralHomeId integer,
funeralDirectorName varchar(100),
@ -225,6 +228,12 @@ const createStatements = [
deceasedName varchar(50) not null,
isCremated bit not null default 0,
deceasedAddress1 varchar(50),
deceasedAddress2 varchar(50),
deceasedCity varchar(20),
deceasedProvince varchar(2),
deceasedPostalCode varchar(7),
birthDate integer,
birthPlace varchar(100),
@ -393,9 +402,30 @@ async function initializeData() {
await addRecord('BurialSiteStatuses', 'Available', 1, initializingUser);
await addRecord('BurialSiteStatuses', 'Reserved', 2, initializingUser);
await addRecord('BurialSiteStatuses', 'Taken', 3, initializingUser);
await addRecord('ContractTypes', 'Preneed', 1, initializingUser);
await addRecord('ContractTypes', 'Interment', 2, initializingUser);
await addRecord('ContractTypes', 'Cremation', 3, initializingUser);
await addContractType({
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
*/

View File

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

View File

@ -5,7 +5,18 @@ export interface UpdateContractForm {
burialSiteId: string | number;
contractStartDateString: 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;
[fieldValue_contractTypeFieldId: string]: unknown;
[fieldValue_contractTypeFieldId: `fieldValue_${string}`]: unknown;
}
export default function updateContract(updateForm: UpdateContractForm, user: User): Promise<boolean>;

View File

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

View File

@ -12,8 +12,21 @@ export interface UpdateContractForm {
contractStartDateString: 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
[fieldValue_contractTypeFieldId: string]: unknown
[fieldValue_contractTypeFieldId: `fieldValue_${string}`]: unknown
}
export default async function updateContract(
@ -29,6 +42,17 @@ export default async function updateContract(
burialSiteId = ?,
contractStartDate = ?,
contractEndDate = ?,
funeralHomeId = ?,
funeralDirectorName = ?,
purchaserName = ?,
purchaserAddress1 = ?,
purchaserAddress2 = ?,
purchaserCity = ?,
purchaserProvince = ?,
purchaserPostalCode = ?,
purchaserPhoneNumber = ?,
purchaserEmail = ?,
purchaserRelationship = ?,
recordUpdate_userName = ?,
recordUpdate_timeMillis = ?
where contractId = ?
@ -41,6 +65,17 @@ export default async function updateContract(
updateForm.contractEndDateString === ''
? undefined
: 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

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 {};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,6 +6,8 @@ import getBurialSiteStatusesFromDatabase from '../database/getBurialSiteStatuses
import getBurialSiteTypesFromDatabase from '../database/getBurialSiteTypes.js';
import getContractTypeFieldsFromDatabase from '../database/getContractTypeFields.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 getWorkOrderTypesFromDatabase from '../database/getWorkOrderTypes.js';
import { DEBUG_NAMESPACE } from '../debug.config.js';
@ -96,6 +98,40 @@ function clearContractTypesCache() {
contractTypes = 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
*/
@ -169,6 +205,14 @@ export function clearCacheByTableName(tableName, relayMessage = true) {
clearContractTypesCache();
break;
}
case 'IntermentContainerTypes': {
clearIntermentContainerTypesCache();
break;
}
case 'IntermentCommittalTypes': {
clearIntermentCommittalTypesCache();
break;
}
case 'WorkOrderMilestoneTypes': {
clearWorkOrderMilestoneTypesCache();
break;

View File

@ -9,6 +9,8 @@ import getBurialSiteStatusesFromDatabase from '../database/getBurialSiteStatuses
import getBurialSiteTypesFromDatabase from '../database/getBurialSiteTypes.js'
import getContractTypeFieldsFromDatabase from '../database/getContractTypeFields.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 getWorkOrderTypesFromDatabase from '../database/getWorkOrderTypes.js'
import { DEBUG_NAMESPACE } from '../debug.config.js'
@ -21,6 +23,8 @@ import type {
BurialSiteType,
ContractType,
ContractTypeField,
IntermentCommittalType,
IntermentContainerType,
WorkOrderMilestoneType,
WorkOrderType
} from '../types/recordTypes.js'
@ -178,6 +182,68 @@ function clearContractTypesCache(): void {
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
*/
@ -278,6 +344,8 @@ type CacheTableNames =
| 'ContractTypes'
| 'ContractTypeFields'
| 'ContractTypePrints'
| 'IntermentContainerTypes'
| 'IntermentCommittalTypes'
| 'WorkOrderMilestoneTypes'
| 'WorkOrderTypes'
| 'FeeCategories'
@ -306,6 +374,16 @@ export function clearCacheByTableName(
break
}
case 'IntermentContainerTypes': {
clearIntermentContainerTypesCache()
break
}
case 'IntermentCommittalTypes': {
clearIntermentCommittalTypesCache()
break
}
case 'WorkOrderMilestoneTypes': {
clearWorkOrderMilestoneTypesCache()
break

View File

@ -13,6 +13,8 @@
</header>
<section class="modal-card-body">
<form id="form--contractTypeAdd">
<div class="columns">
<div class="column">
<div class="field">
<label class="label" for="contractTypeAdd--contractType"
>Contract Type</label
@ -28,6 +30,22 @@
/>
</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>
</section>
<footer class="modal-card-foot justify-right">

View File

@ -2,9 +2,7 @@
<div class="modal-background"></div>
<div class="modal-card has-width-900">
<header class="modal-card-head">
<h3 class="modal-card-title">
Update Contract Type
</h3>
<h3 class="modal-card-title">Update Contract Type</h3>
<button
class="delete is-close-modal-button"
aria-label="close"
@ -19,6 +17,8 @@
name="contractTypeId"
type="hidden"
/>
<div class="columns">
<div class="column">
<div class="field">
<label class="label" for="contractTypeEdit--contractType"
>Contract Type</label
@ -34,6 +34,22 @@
/>
</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>
</section>
<footer class="modal-card-foot justify-right">
@ -43,9 +59,7 @@
form="form--contractTypeEdit"
>
<span class="icon"><i class="fas fa-save" aria-hidden="true"></i></span>
<span
>Update Contract Type</span
>
<span>Update Contract Type</span>
</button>
<button class="button is-close-modal-button" type="button">Cancel</button>
</footer>

View File

@ -3,7 +3,7 @@
<div class="modal-card">
<header class="modal-card-head">
<h3 class="modal-card-title">
Select a <span class="alias" data-alias="Lot"></span>
Select a Burial Site
</h3>
<button
class="delete is-close-modal-button"
@ -12,28 +12,16 @@
></button>
</header>
<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">
<form id="form--lotSelect">
<form id="form--burialSiteSelect">
<input name="limit" type="hidden" value="100" />
<input name="offset" type="hidden" value="0" />
<div class="field">
<div class="control has-icons-left">
<input
class="input"
id="lotSelect--lotName"
name="lotName"
id="burialSiteSelect--burialSiteName"
name="burialSiteName"
type="text"
/>
<span class="icon is-small is-left">
@ -45,7 +33,7 @@
<div class="control has-icons-left">
<div class="select is-fullwidth">
<select
id="lotSelect--occupancyStatus"
id="burialSiteSelect--occupancyStatus"
name="occupancyStatus"
>
<option value="">(All Statuses)</option>
@ -62,93 +50,7 @@
</div>
</form>
</div>
<div id="resultsContainer--lotSelect"></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>
<div id="resultsContainer--burialSiteSelect"></div>
</section>
<footer class="modal-card-foot justify-right">
<button class="button is-close-modal-button" type="button">Cancel</button>

View File

@ -1,4 +1,6 @@
"use strict";
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable max-lines */
Object.defineProperty(exports, "__esModule", { value: true });
(() => {
const sunrise = exports.sunrise;
@ -192,6 +194,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
if (isCreate) {
const contractFieldsContainerElement = document.querySelector('#container--contractFields');
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 === '') {
contractFieldsContainerElement.innerHTML = `<div class="message is-info">
<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
.value;
let burialSiteSelectCloseModalFunction;
let burialSiteSelectModalElement;
let burialSiteSelectFormElement;
let burialSiteSelectResultsElement;
function renderSelectedBurialSiteAndClose(burialSiteId, burialSiteName) {
@ -303,8 +311,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
}
function selectExistingBurialSite(clickEvent) {
clickEvent.preventDefault();
const selectedLotElement = clickEvent.currentTarget;
renderSelectedBurialSiteAndClose(selectedLotElement.dataset.burialSiteId ?? '', selectedLotElement.dataset.burialSiteName ?? '');
const selectedBurialSiteElement = clickEvent.currentTarget;
renderSelectedBurialSiteAndClose(selectedBurialSiteElement.dataset.burialSiteId ?? '', selectedBurialSiteElement.dataset.burialSiteName ?? '');
}
function searchBurialSites() {
// eslint-disable-next-line no-unsanitized/property
@ -326,7 +334,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
panelBlockElement.href = '#';
panelBlockElement.dataset.burialSiteId =
burialSite.burialSiteId.toString();
panelBlockElement.dataset.lotName = burialSite.burialSiteName;
panelBlockElement.dataset.burialSiteName = burialSite.burialSiteName;
// eslint-disable-next-line no-unsanitized/property
panelBlockElement.innerHTML = `<div class="columns">
<div class="column">
@ -347,33 +355,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
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', {
onshow(modalElement) {
sunrise.populateAliases(modalElement);
},
onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped();
burialSiteSelectModalElement = modalElement;
burialSiteSelectCloseModalFunction = closeModalFunction;
bulmaJS.init(modalElement);
// search Tab
// Search Tab
const burialSiteNameFilterElement = modalElement.querySelector('#burialSiteSelect--burialSiteName');
if (document.querySelector('#contract--burialSiteId').value !== '') {
burialSiteNameFilterElement.value = currentBurialSiteName;
@ -391,32 +381,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
submitEvent.preventDefault();
});
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() {
bulmaJS.toggleHtmlClipped();
@ -462,30 +426,56 @@ Object.defineProperty(exports, "__esModule", { value: true });
endDatePicker.refresh();
});
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
*/
;
(() => {
let contractComments = exports.contractComments;
delete exports.contractComments;
function openEditLotOccupancyComment(clickEvent) {
function openEditContractComment(clickEvent) {
const contractCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset
.contractCommentId ?? '', 10);
const contractComment = contractComments.find((currentLotOccupancyComment) => {
return (currentLotOccupancyComment.contractCommentId === contractCommentId);
});
const contractComment = contractComments.find((currentComment) => currentComment.contractCommentId === contractCommentId);
let editFormElement;
let editCloseModalFunction;
function editComment(submitEvent) {
function editContractComment(submitEvent) {
submitEvent.preventDefault();
cityssm.postJSON(`${sunrise.urlPrefix}/contracts/doUpdateContractComment`, editFormElement, (rawResponseJSON) => {
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
contractComments = responseJSON.contractComments ?? [];
editCloseModalFunction();
renderLotOccupancyComments();
renderContractComments();
}
else {
bulmaJS.alert({
@ -517,7 +507,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
sunrise.initializeDatePickers(modalElement);
modalElement.querySelector('#contractCommentEdit--contractComment').focus();
editFormElement = modalElement.querySelector('form');
editFormElement.addEventListener('submit', editComment);
editFormElement.addEventListener('submit', editContractComment);
editCloseModalFunction = closeModalFunction;
},
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
.contractCommentId ?? '', 10);
function doDelete() {
@ -536,7 +526,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
contractComments = responseJSON.contractComments;
renderLotOccupancyComments();
renderContractComments();
}
else {
bulmaJS.alert({
@ -557,7 +547,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
contextualColorName: 'warning'
});
}
function renderLotOccupancyComments() {
function renderContractComments() {
const containerElement = document.querySelector('#container--contractComments');
if (contractComments.length === 0) {
containerElement.innerHTML = `<div class="message is-info">
@ -568,7 +558,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const tableElement = document.createElement('table');
tableElement.className = 'table is-fullwidth is-striped is-hoverable';
tableElement.innerHTML = `<thead><tr>
<th>Commentor</th>
<th>Author</th>
<th>Comment Date</th>
<th>Comment</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>`;
tableRowElement
.querySelector('.button--edit')
?.addEventListener('click', openEditLotOccupancyComment);
?.addEventListener('click', openEditContractComment);
tableRowElement
.querySelector('.button--delete')
?.addEventListener('click', deleteLotOccupancyComment);
?.addEventListener('click', deleteContractComment);
tableElement.querySelector('tbody')?.append(tableRowElement);
}
containerElement.innerHTML = '';
@ -620,7 +610,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
if (responseJSON.success) {
contractComments = responseJSON.contractComments;
addCloseModalFunction();
renderLotOccupancyComments();
renderContractComments();
}
else {
bulmaJS.alert({
@ -638,20 +628,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
},
onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped();
modalElement.querySelector('#contractCommentAdd--contractComment').focus();
modalElement.querySelector('#contractCommentAdd--comment').focus();
addFormElement = modalElement.querySelector('form');
addFormElement.addEventListener('submit', addComment);
addCloseModalFunction = closeModalFunction;
},
onremoved: () => {
onremoved() {
bulmaJS.toggleHtmlClipped();
document.querySelector('#button--addComment').focus();
}
});
});
renderLotOccupancyComments();
})();
(() => {
renderContractComments();
/**
* Fees
*/
let contractFees = exports.contractFees;
delete exports.contractFees;
const contractFeesContainerElement = document.querySelector('#container--contractFees');
@ -664,12 +655,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
}
return feeGrandTotal;
}
function editLotOccupancyFeeQuantity(clickEvent) {
function editContractFeeQuantity(clickEvent) {
const feeId = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset
.feeId ?? '', 10);
const fee = contractFees.find((possibleFee) => {
return possibleFee.feeId === feeId;
});
const fee = contractFees.find((possibleFee) => possibleFee.feeId === feeId);
let updateCloseModalFunction;
function doUpdateQuantity(formEvent) {
formEvent.preventDefault();
@ -677,7 +666,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
contractFees = responseJSON.contractFees;
renderLotOccupancyFees();
renderContractFees();
updateCloseModalFunction();
}
else {
@ -720,7 +709,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
contractFees = responseJSON.contractFees;
renderLotOccupancyFees();
renderContractFees();
}
else {
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) {
contractFeesContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no fees associated with this record.</p>
</div>`;
renderLotOccupancyTransactions();
renderContractTransactions();
return;
}
// eslint-disable-next-line no-secrets/no-secrets
contractFeesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr>
<th>Fee</th>
@ -813,7 +802,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
</td>`;
tableRowElement
.querySelector('.button--editQuantity')
?.addEventListener('click', editLotOccupancyFeeQuantity);
?.addEventListener('click', editContractFeeQuantity);
tableRowElement
.querySelector('.button--delete')
?.addEventListener('click', deleteContractFee);
@ -829,7 +818,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
contractFeesContainerElement.querySelector('#contractFees--feeAmountTotal').textContent = `$${feeAmountTotal.toFixed(2)}`;
contractFeesContainerElement.querySelector('#contractFees--taxAmountTotal').textContent = `$${taxAmountTotal.toFixed(2)}`;
contractFeesContainerElement.querySelector('#contractFees--grandTotal').textContent = `$${(feeAmountTotal + taxAmountTotal).toFixed(2)}`;
renderLotOccupancyTransactions();
renderContractTransactions();
}
const addFeeButtonElement = document.querySelector('#button--addFee');
addFeeButtonElement.addEventListener('click', () => {
@ -845,8 +834,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
let feeFilterResultsElement;
function doAddFeeCategory(clickEvent) {
clickEvent.preventDefault();
const feeCategoryId = Number.parseInt(clickEvent.currentTarget.dataset.feeCategoryId ??
'', 10);
const feeCategoryId = Number.parseInt(clickEvent.currentTarget.dataset.feeCategoryId ?? '', 10);
cityssm.postJSON(`${sunrise.urlPrefix}/contracts/doAddContractFeeCategory`, {
contractId,
feeCategoryId
@ -854,7 +842,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
contractFees = responseJSON.contractFees;
renderLotOccupancyFees();
renderContractFees();
bulmaJS.alert({
message: 'Fee Group Added Successfully',
contextualColorName: 'success'
@ -870,7 +858,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
});
}
function doAddFee(feeId, quantity = 1) {
cityssm.postJSON(`${sunrise.urlPrefix}/contracts/doAddLotOccupancyFee`, {
cityssm.postJSON(`${sunrise.urlPrefix}/contracts/doAddContractFee`, {
contractId,
feeId,
quantity
@ -878,7 +866,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
contractFees = responseJSON.contractFees;
renderLotOccupancyFees();
renderContractFees();
filterFees();
}
else {
@ -915,14 +903,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
function tryAddFee(clickEvent) {
clickEvent.preventDefault();
const feeId = Number.parseInt(clickEvent.currentTarget.dataset.feeId ?? '', 10);
const feeCategoryId = Number.parseInt(clickEvent.currentTarget.dataset.feeCategoryId ??
'', 10);
const feeCategory = feeCategories.find((currentFeeCategory) => {
return currentFeeCategory.feeCategoryId === feeCategoryId;
});
const fee = feeCategory.fees.find((currentFee) => {
return currentFee.feeId === feeId;
});
const feeCategoryId = Number.parseInt(clickEvent.currentTarget.dataset.feeCategoryId ?? '', 10);
const feeCategory = feeCategories.find((currentFeeCategory) => currentFeeCategory.feeCategoryId === feeCategoryId);
const fee = feeCategory.fees.find((currentFee) => currentFee.feeId === feeId);
if (fee.includeQuantity ?? false) {
doSetQuantityAndAddFee(fee);
}
@ -982,17 +965,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
}
hasFees = true;
const panelBlockElement = document.createElement(feeCategory.isGroupedFee ? 'div' : 'a');
panelBlockElement.className =
'panel-block is-block container--fee';
panelBlockElement.className = 'panel-block is-block container--fee';
panelBlockElement.dataset.feeId = fee.feeId.toString();
panelBlockElement.dataset.feeCategoryId =
feeCategory.feeCategoryId.toString();
// eslint-disable-next-line no-unsanitized/property
panelBlockElement.innerHTML = `<strong>${cityssm.escapeHTML(fee.feeName ?? '')}</strong><br />
<small>
${
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
cityssm
${cityssm
.escapeHTML(fee.feeDescription ?? '')
.replaceAll('\n', '<br />')}
</small>`;
@ -1028,7 +1008,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
bulmaJS.toggleHtmlClipped();
},
onhidden() {
renderLotOccupancyFees();
renderContractFees();
},
onremoved() {
bulmaJS.toggleHtmlClipped();
@ -1046,12 +1026,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
}
return transactionGrandTotal;
}
function editLotOccupancyTransaction(clickEvent) {
function editContractTransaction(clickEvent) {
const transactionIndex = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset
.transactionIndex ?? '', 10);
const transaction = contractTransactions.find((possibleTransaction) => {
return possibleTransaction.transactionIndex === transactionIndex;
});
const transaction = contractTransactions.find((possibleTransaction) => possibleTransaction.transactionIndex === transactionIndex);
let editCloseModalFunction;
function doEdit(formEvent) {
formEvent.preventDefault();
@ -1059,7 +1037,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
contractTransactions = responseJSON.contractTransactions;
renderLotOccupancyTransactions();
renderContractTransactions();
editCloseModalFunction();
}
else {
@ -1086,9 +1064,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
bulmaJS.toggleHtmlClipped();
sunrise.initializeDatePickers(modalElement);
modalElement.querySelector('#contractTransactionEdit--transactionAmount').focus();
modalElement
.querySelector('form')
?.addEventListener('submit', doEdit);
modalElement.querySelector('form')?.addEventListener('submit', doEdit);
editCloseModalFunction = closeModalFunction;
},
onremoved() {
@ -1106,7 +1082,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
contractTransactions = responseJSON.contractTransactions;
renderLotOccupancyTransactions();
renderContractTransactions();
}
else {
bulmaJS.alert({
@ -1127,7 +1103,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
}
});
}
function renderLotOccupancyTransactions() {
function renderContractTransactions() {
if (contractTransactions.length === 0) {
// eslint-disable-next-line no-unsanitized/property
contractTransactionsContainerElement.innerHTML = `<div class="message ${contractFees.length === 0 ? 'is-info' : 'is-warning'}">
@ -1203,7 +1179,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
</td>`;
tableRowElement
.querySelector('.button--edit')
?.addEventListener('click', editLotOccupancyTransaction);
?.addEventListener('click', editContractTransaction);
tableRowElement
.querySelector('.button--delete')
?.addEventListener('click', deleteContractTransaction);
@ -1237,12 +1213,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
let addCloseModalFunction;
function doAddTransaction(submitEvent) {
submitEvent.preventDefault();
cityssm.postJSON(`${sunrise.urlPrefix}/contracts/doAddLotOccupancyTransaction`, submitEvent.currentTarget, (rawResponseJSON) => {
cityssm.postJSON(`${sunrise.urlPrefix}/contracts/doAddContractTransaction`, submitEvent.currentTarget, (rawResponseJSON) => {
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
contractTransactions = responseJSON.contractTransactions;
addCloseModalFunction();
renderLotOccupancyTransactions();
renderContractTransactions();
}
else {
bulmaJS.confirm({
@ -1302,9 +1278,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
transactionAmountElement.max = Math.max(feeGrandTotal - transactionGrandTotal, 0).toFixed(2);
transactionAmountElement.value = Math.max(feeGrandTotal - transactionGrandTotal, 0).toFixed(2);
if (sunrise.dynamicsGPIntegrationIsEnabled) {
externalReceiptNumberElement = modalElement.querySelector(
// eslint-disable-next-line no-secrets/no-secrets
'#contractTransactionAdd--externalReceiptNumber');
externalReceiptNumberElement = modalElement.querySelector('#contractTransactionAdd--externalReceiptNumber');
const externalReceiptNumberControlElement = externalReceiptNumberElement.closest('.control');
externalReceiptNumberControlElement.classList.add('has-icons-right');
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 */
import type { BulmaJS } from '@cityssm/bulma-js/types.js'
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js'
import type {
BurialSite,
BurialSiteStatus,
BurialSiteType,
Cemetery,
ContractComment,
ContractFee,
ContractInterment,
ContractTransaction,
ContractTypeField,
DynamicsGPDocument,
Fee,
@ -309,6 +311,19 @@ declare const exports: Record<string, unknown>
) as HTMLElement
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 === '') {
contractFieldsContainerElement.innerHTML = `<div class="message is-info">
<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
let burialSiteSelectCloseModalFunction: () => void
let burialSiteSelectModalElement: HTMLElement
let burialSiteSelectFormElement: HTMLFormElement
let burialSiteSelectResultsElement: HTMLElement
@ -480,11 +494,11 @@ declare const exports: Record<string, unknown>
function selectExistingBurialSite(clickEvent: Event): void {
clickEvent.preventDefault()
const selectedLotElement = clickEvent.currentTarget as HTMLElement
const selectedBurialSiteElement = clickEvent.currentTarget as HTMLElement
renderSelectedBurialSiteAndClose(
selectedLotElement.dataset.burialSiteId ?? '',
selectedLotElement.dataset.burialSiteName ?? ''
selectedBurialSiteElement.dataset.burialSiteId ?? '',
selectedBurialSiteElement.dataset.burialSiteName ?? ''
)
}
@ -520,7 +534,7 @@ declare const exports: Record<string, unknown>
panelBlockElement.dataset.burialSiteId =
burialSite.burialSiteId.toString()
panelBlockElement.dataset.lotName = burialSite.burialSiteName
panelBlockElement.dataset.burialSiteName = burialSite.burialSiteName
// eslint-disable-next-line no-unsanitized/property
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', {
onshow(modalElement) {
sunrise.populateAliases(modalElement)
@ -592,12 +571,11 @@ declare const exports: Record<string, unknown>
onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped()
burialSiteSelectModalElement = modalElement
burialSiteSelectCloseModalFunction = closeModalFunction
bulmaJS.init(modalElement)
// search Tab
// Search Tab
const burialSiteNameFilterElement = modalElement.querySelector(
'#burialSiteSelect--burialSiteName'
@ -646,48 +624,6 @@ declare const exports: Record<string, unknown>
)
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() {
bulmaJS.toggleHtmlClipped()
@ -754,15 +690,57 @@ declare const exports: Record<string, unknown>
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
*/
;(() => {
let contractComments = exports.contractComments as LotOccupancyComment[]
let contractComments = exports.contractComments as ContractComment[]
delete exports.contractComments
function openEditLotOccupancyComment(clickEvent: Event): void {
function openEditContractComment(clickEvent: Event): void {
const contractCommentId = Number.parseInt(
(clickEvent.currentTarget as HTMLElement).closest('tr')?.dataset
.contractCommentId ?? '',
@ -770,17 +748,14 @@ declare const exports: Record<string, unknown>
)
const contractComment = contractComments.find(
(currentLotOccupancyComment) => {
return (
currentLotOccupancyComment.contractCommentId === contractCommentId
)
}
) as LotOccupancyComment
(currentComment) =>
currentComment.contractCommentId === contractCommentId
) as ContractComment
let editFormElement: HTMLFormElement
let editCloseModalFunction: () => void
function editComment(submitEvent: SubmitEvent): void {
function editContractComment(submitEvent: SubmitEvent): void {
submitEvent.preventDefault()
cityssm.postJSON(
@ -790,13 +765,13 @@ declare const exports: Record<string, unknown>
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
contractComments?: LotOccupancyComment[]
contractComments?: ContractComment[]
}
if (responseJSON.success) {
contractComments = responseJSON.contractComments ?? []
editCloseModalFunction()
renderLotOccupancyComments()
renderContractComments()
} else {
bulmaJS.alert({
title: 'Error Updating Comment',
@ -860,7 +835,7 @@ declare const exports: Record<string, unknown>
'form'
) as HTMLFormElement
editFormElement.addEventListener('submit', editComment)
editFormElement.addEventListener('submit', editContractComment)
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(
(clickEvent.currentTarget as HTMLElement).closest('tr')?.dataset
.contractCommentId ?? '',
@ -888,12 +863,12 @@ declare const exports: Record<string, unknown>
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
contractComments: LotOccupancyComment[]
contractComments: ContractComment[]
}
if (responseJSON.success) {
contractComments = responseJSON.contractComments
renderLotOccupancyComments()
renderContractComments()
} else {
bulmaJS.alert({
title: 'Error Removing Comment',
@ -916,7 +891,7 @@ declare const exports: Record<string, unknown>
})
}
function renderLotOccupancyComments(): void {
function renderContractComments(): void {
const containerElement = document.querySelector(
'#container--contractComments'
) as HTMLElement
@ -931,7 +906,7 @@ declare const exports: Record<string, unknown>
const tableElement = document.createElement('table')
tableElement.className = 'table is-fullwidth is-striped is-hoverable'
tableElement.innerHTML = `<thead><tr>
<th>Commentor</th>
<th>Author</th>
<th>Comment Date</th>
<th>Comment</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
.querySelector('.button--edit')
?.addEventListener('click', openEditLotOccupancyComment)
?.addEventListener('click', openEditContractComment)
tableRowElement
.querySelector('.button--delete')
?.addEventListener('click', deleteLotOccupancyComment)
?.addEventListener('click', deleteContractComment)
tableElement.querySelector('tbody')?.append(tableRowElement)
}
@ -996,13 +971,13 @@ declare const exports: Record<string, unknown>
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
contractComments: LotOccupancyComment[]
contractComments: ContractComment[]
}
if (responseJSON.success) {
contractComments = responseJSON.contractComments
addCloseModalFunction()
renderLotOccupancyComments()
renderContractComments()
} else {
bulmaJS.alert({
title: 'Error Adding Comment',
@ -1027,7 +1002,7 @@ declare const exports: Record<string, unknown>
bulmaJS.toggleHtmlClipped()
;(
modalElement.querySelector(
'#contractCommentAdd--contractComment'
'#contractCommentAdd--comment'
) as HTMLTextAreaElement
).focus()
@ -1039,25 +1014,22 @@ declare const exports: Record<string, unknown>
addCloseModalFunction = closeModalFunction
},
onremoved: () => {
onremoved() {
bulmaJS.toggleHtmlClipped()
;(
document.querySelector(
'#button--addComment'
) as HTMLButtonElement
document.querySelector('#button--addComment') as HTMLButtonElement
).focus()
}
})
})
renderLotOccupancyComments()
})()
renderContractComments()
/**
* Fees
*/
;(() => {
let contractFees = exports.contractFees as LotOccupancyFee[]
let contractFees = exports.contractFees as ContractFee[]
delete exports.contractFees
const contractFeesContainerElement = document.querySelector(
@ -1076,16 +1048,16 @@ declare const exports: Record<string, unknown>
return feeGrandTotal
}
function editLotOccupancyFeeQuantity(clickEvent: Event): void {
function editContractFeeQuantity(clickEvent: Event): void {
const feeId = Number.parseInt(
(clickEvent.currentTarget as HTMLButtonElement).closest('tr')?.dataset
.feeId ?? '',
10
)
const fee = contractFees.find((possibleFee) => {
return possibleFee.feeId === feeId
}) as LotOccupancyFee
const fee = contractFees.find(
(possibleFee) => possibleFee.feeId === feeId
) as ContractFee
let updateCloseModalFunction: () => void
@ -1098,12 +1070,12 @@ declare const exports: Record<string, unknown>
(rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
success: boolean
contractFees: LotOccupancyFee[]
contractFees: ContractFee[]
}
if (responseJSON.success) {
contractFees = responseJSON.contractFees
renderLotOccupancyFees()
renderContractFees()
updateCloseModalFunction()
} else {
bulmaJS.alert({
@ -1177,12 +1149,12 @@ declare const exports: Record<string, unknown>
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
contractFees: LotOccupancyFee[]
contractFees: ContractFee[]
}
if (responseJSON.success) {
contractFees = responseJSON.contractFees
renderLotOccupancyFees()
renderContractFees()
} else {
bulmaJS.alert({
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) {
contractFeesContainerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no fees associated with this record.</p>
</div>`
renderLotOccupancyTransactions()
renderContractTransactions()
return
}
// eslint-disable-next-line no-secrets/no-secrets
contractFeesContainerElement.innerHTML = `<table class="table is-fullwidth is-striped is-hoverable">
<thead><tr>
<th>Fee</th>
@ -1288,7 +1260,7 @@ declare const exports: Record<string, unknown>
tableRowElement
.querySelector('.button--editQuantity')
?.addEventListener('click', editLotOccupancyFeeQuantity)
?.addEventListener('click', editContractFeeQuantity)
tableRowElement
.querySelector('.button--delete')
@ -1321,7 +1293,7 @@ declare const exports: Record<string, unknown>
) as HTMLElement
).textContent = `$${(feeAmountTotal + taxAmountTotal).toFixed(2)}`
renderLotOccupancyTransactions()
renderContractTransactions()
}
const addFeeButtonElement = document.querySelector(
@ -1346,8 +1318,7 @@ declare const exports: Record<string, unknown>
clickEvent.preventDefault()
const feeCategoryId = Number.parseInt(
(clickEvent.currentTarget as HTMLElement).dataset.feeCategoryId ??
'',
(clickEvent.currentTarget as HTMLElement).dataset.feeCategoryId ?? '',
10
)
@ -1361,12 +1332,12 @@ declare const exports: Record<string, unknown>
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
contractFees: LotOccupancyFee[]
contractFees: ContractFee[]
}
if (responseJSON.success) {
contractFees = responseJSON.contractFees
renderLotOccupancyFees()
renderContractFees()
bulmaJS.alert({
message: 'Fee Group Added Successfully',
@ -1385,7 +1356,7 @@ declare const exports: Record<string, unknown>
function doAddFee(feeId: number, quantity: number | string = 1): void {
cityssm.postJSON(
`${sunrise.urlPrefix}/contracts/doAddLotOccupancyFee`,
`${sunrise.urlPrefix}/contracts/doAddContractFee`,
{
contractId,
feeId,
@ -1395,12 +1366,12 @@ declare const exports: Record<string, unknown>
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
contractFees: LotOccupancyFee[]
contractFees: ContractFee[]
}
if (responseJSON.success) {
contractFees = responseJSON.contractFees
renderLotOccupancyFees()
renderContractFees()
filterFees()
} else {
bulmaJS.alert({
@ -1453,18 +1424,18 @@ declare const exports: Record<string, unknown>
10
)
const feeCategoryId = Number.parseInt(
(clickEvent.currentTarget as HTMLElement).dataset.feeCategoryId ??
'',
(clickEvent.currentTarget as HTMLElement).dataset.feeCategoryId ?? '',
10
)
const feeCategory = feeCategories.find((currentFeeCategory) => {
return currentFeeCategory.feeCategoryId === feeCategoryId
}) as FeeCategory
const feeCategory = feeCategories.find(
(currentFeeCategory) =>
currentFeeCategory.feeCategoryId === feeCategoryId
) as FeeCategory
const fee = feeCategory.fees.find((currentFee) => {
return currentFee.feeId === feeId
}) as Fee
const fee = feeCategory.fees.find(
(currentFee) => currentFee.feeId === feeId
) as Fee
if (fee.includeQuantity ?? false) {
doSetQuantityAndAddFee(fee)
@ -1550,8 +1521,7 @@ declare const exports: Record<string, unknown>
const panelBlockElement = document.createElement(
feeCategory.isGroupedFee ? 'div' : 'a'
)
panelBlockElement.className =
'panel-block is-block container--fee'
panelBlockElement.className = 'panel-block is-block container--fee'
panelBlockElement.dataset.feeId = fee.feeId.toString()
panelBlockElement.dataset.feeCategoryId =
feeCategory.feeCategoryId.toString()
@ -1560,7 +1530,6 @@ declare const exports: Record<string, unknown>
panelBlockElement.innerHTML = `<strong>${cityssm.escapeHTML(fee.feeName ?? '')}</strong><br />
<small>
${
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
cityssm
.escapeHTML(fee.feeDescription ?? '')
.replaceAll('\n', '<br />')
@ -1616,7 +1585,7 @@ declare const exports: Record<string, unknown>
bulmaJS.toggleHtmlClipped()
},
onhidden() {
renderLotOccupancyFees()
renderContractFees()
},
onremoved() {
bulmaJS.toggleHtmlClipped()
@ -1626,7 +1595,7 @@ declare const exports: Record<string, unknown>
})
let contractTransactions =
exports.contractTransactions as LotOccupancyTransaction[]
exports.contractTransactions as ContractTransaction[]
delete exports.contractTransactions
const contractTransactionsContainerElement = document.querySelector(
@ -1643,16 +1612,14 @@ declare const exports: Record<string, unknown>
return transactionGrandTotal
}
function editLotOccupancyTransaction(clickEvent: Event): void {
function editContractTransaction(clickEvent: Event): void {
const transactionIndex = Number.parseInt(
(clickEvent.currentTarget as HTMLButtonElement).closest('tr')?.dataset
.transactionIndex ?? '',
10
)
const transaction = contractTransactions.find((possibleTransaction) => {
return possibleTransaction.transactionIndex === transactionIndex
}) as LotOccupancyTransaction
const transaction = contractTransactions.find((possibleTransaction) => possibleTransaction.transactionIndex === transactionIndex) as ContractTransaction
let editCloseModalFunction: () => void
@ -1665,12 +1632,12 @@ declare const exports: Record<string, unknown>
(rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
success: boolean
contractTransactions: LotOccupancyTransaction[]
contractTransactions: ContractTransaction[]
}
if (responseJSON.success) {
contractTransactions = responseJSON.contractTransactions
renderLotOccupancyTransactions()
renderContractTransactions()
editCloseModalFunction()
} else {
bulmaJS.alert({
@ -1732,9 +1699,7 @@ declare const exports: Record<string, unknown>
) as HTMLInputElement
).focus()
modalElement
.querySelector('form')
?.addEventListener('submit', doEdit)
modalElement.querySelector('form')?.addEventListener('submit', doEdit)
editCloseModalFunction = closeModalFunction
},
@ -1762,12 +1727,12 @@ declare const exports: Record<string, unknown>
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
contractTransactions: LotOccupancyTransaction[]
contractTransactions: ContractTransaction[]
}
if (responseJSON.success) {
contractTransactions = responseJSON.contractTransactions
renderLotOccupancyTransactions()
renderContractTransactions()
} else {
bulmaJS.alert({
title: 'Error Deleting Transaction',
@ -1790,7 +1755,7 @@ declare const exports: Record<string, unknown>
})
}
function renderLotOccupancyTransactions(): void {
function renderContractTransactions(): void {
if (contractTransactions.length === 0) {
// eslint-disable-next-line no-unsanitized/property
contractTransactionsContainerElement.innerHTML = `<div class="message ${contractFees.length === 0 ? 'is-info' : 'is-warning'}">
@ -1885,7 +1850,7 @@ declare const exports: Record<string, unknown>
tableRowElement
.querySelector('.button--edit')
?.addEventListener('click', editLotOccupancyTransaction)
?.addEventListener('click', editContractTransaction)
tableRowElement
.querySelector('.button--delete')
@ -1938,19 +1903,19 @@ declare const exports: Record<string, unknown>
submitEvent.preventDefault()
cityssm.postJSON(
`${sunrise.urlPrefix}/contracts/doAddLotOccupancyTransaction`,
`${sunrise.urlPrefix}/contracts/doAddContractTransaction`,
submitEvent.currentTarget,
(rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
contractTransactions: LotOccupancyTransaction[]
contractTransactions: ContractTransaction[]
}
if (responseJSON.success) {
contractTransactions = responseJSON.contractTransactions
addCloseModalFunction()
renderLotOccupancyTransactions()
renderContractTransactions()
} else {
bulmaJS.confirm({
title: 'Error Adding Transaction',
@ -2031,9 +1996,7 @@ declare const exports: Record<string, unknown>
'#contractTransactionAdd--transactionAmount'
) as HTMLInputElement
transactionAmountElement.min = (-1 * transactionGrandTotal).toFixed(
2
)
transactionAmountElement.min = (-1 * transactionGrandTotal).toFixed(2)
transactionAmountElement.max = Math.max(
feeGrandTotal - transactionGrandTotal,
@ -2047,16 +2010,13 @@ declare const exports: Record<string, unknown>
if (sunrise.dynamicsGPIntegrationIsEnabled) {
externalReceiptNumberElement = modalElement.querySelector(
// eslint-disable-next-line no-secrets/no-secrets
'#contractTransactionAdd--externalReceiptNumber'
) as HTMLInputElement
const externalReceiptNumberControlElement =
externalReceiptNumberElement.closest('.control') as HTMLElement
externalReceiptNumberControlElement.classList.add(
'has-icons-right'
)
externalReceiptNumberControlElement.classList.add('has-icons-right')
externalReceiptNumberControlElement.insertAdjacentHTML(
'beforeend',
@ -2099,7 +2059,6 @@ declare const exports: Record<string, unknown>
})
})
renderLotOccupancyFees()
})()
renderContractFees()
}
})()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -129,7 +129,7 @@
<span>
<%= (isCreate ? "Create" : "Update") %>
<span class="is-hidden-touch">
Contract Record
Contract
</span>
</span>
</button>
@ -158,7 +158,7 @@
required accesskey="f"
<%= (isCreate ? " autofocus" : "") %>>
<% if (isCreate) { %>
<option value="">(No Type)</option>
<option value="" data-is-preneed="false">(No Type)</option>
<% } %>
<% let typeIsFound = false; %>
<% for (const contractType of contractTypes) { %>
@ -168,13 +168,16 @@
}
%>
<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" : "") %>>
<%= contractType.contractType %>
</option>
<% } %>
<% 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 %>
</option>
<% } %>
@ -201,7 +204,7 @@
<%= (isCreate ? "" : " disabled readonly") %> />
</div>
<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>
</button>
</div>
@ -211,7 +214,7 @@
</button>
</div>
<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>
</button>
</div>
@ -304,7 +307,8 @@
<% } %>
minlength="<%= contractField.minLength %>"
maxlength="<%= contractField.maxLength %>"
<%= contractField.isRequired ? " required" : "" %> />
<%= contractField.isRequired ? " required" : "" %>
/>
<% } %>
</div>
</div>
@ -317,6 +321,44 @@
</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="column">
<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 %>" />
</div>
</div>
<div class="field">
<label class="label" for="contract--purchaserAddress1">Address</label>
<div class="control">
@ -373,56 +414,232 @@
<div class="field">
<label class="label" for="contract--purchaserPhoneNumber">Phone Number</label>
<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 class="column">
<div class="field">
<label class="label" for="contract--purchaserEmailAddress">Email Address</label>
<label class="label" for="contract--purchaserEmail">Email Address</label>
<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 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 class="column">
<div class="panel">
<h2 class="panel-heading">Deceased</h2>
</div>
<div class="panel">
<h2 class="panel-heading">Funeral Home</h2>
</div>
</div>
</div>
</form>
<% if (!isCreate) { %>
<% if (isCreate) { %>
<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">Comments</h2>
<h2 class="has-text-weight-bold is-size-5 is-recipient-or-deceased">
<%= (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--addComment" type="button">
<span class="icon is-small"><i class="fas fa-plus" aria-hidden="true"></i></span>
<span>Add Comment</span>
<button class="button is-small is-hidden-print" id="button--copyFromPurchaser" type="button">
<span class="icon is-small"><i class="far fa-copy" aria-hidden="true"></i></span>
<span>Copy from Purchaser</span>
</button>
</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>
<%
@ -495,51 +712,25 @@
</div>
</div>
<div class="columns is-desktop">
<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>
<h2 class="has-text-weight-bold is-size-5">Comments</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">
<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>Add Fee</span>
<span>Add Comment</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 class="panel-block is-block" id="container--contractComments"></div>
</div>
<% } %>
@ -557,10 +748,6 @@
exports.workOrderTypes = <%- JSON.stringify(workOrderTypes) %>;
<% } %>
exports.burialSiteTypes = <%- JSON.stringify(burialSiteTypes) %>;
exports.burialSiteStatuses = <%- JSON.stringify(burialSiteStatuses) %>;
exports.cemeteries = <%- JSON.stringify(cemeteries) %>;
</script>
<script src="<%= urlPrefix %>/javascripts/contract.edit.js"></script>