fix funeral field update
parent
b16f96c74b
commit
27097dc1ca
|
|
@ -1,4 +1,4 @@
|
|||
import { dateIntegerToString, timeIntegerToString } from '@cityssm/utils-datetime';
|
||||
import { dateIntegerToString, timeIntegerToPeriodString, timeIntegerToString } from '@cityssm/utils-datetime';
|
||||
import getContractComments from './getContractComments.js';
|
||||
import getContractFees from './getContractFees.js';
|
||||
import getContractFields from './getContractFields.js';
|
||||
|
|
@ -10,6 +10,7 @@ export default async function getContract(contractId, connectedDatabase) {
|
|||
const database = connectedDatabase ?? (await acquireConnection());
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
||||
database.function('userFn_timeIntegerToString', timeIntegerToString);
|
||||
database.function('userFn_timeIntegerToPeriodString', timeIntegerToPeriodString);
|
||||
const contract = database
|
||||
.prepare(`select o.contractId,
|
||||
o.contractTypeId, t.contractType, t.isPreneed,
|
||||
|
|
@ -24,7 +25,9 @@ export default async function getContract(contractId, connectedDatabase) {
|
|||
f.funeralHomeName, f.funeralHomeAddress1, f.funeralHomeAddress2,
|
||||
f.funeralHomeCity, f.funeralHomeProvince, f.funeralHomePostalCode,
|
||||
o.funeralDate, userFn_dateIntegerToString(o.funeralDate) as funeralDateString,
|
||||
o.funeralTime, userFn_timeIntegerToString(o.funeralTime) as funeralTimeString,
|
||||
o.funeralTime,
|
||||
userFn_timeIntegerToString(o.funeralTime) as funeralTimeString,
|
||||
userFn_timeIntegerToPeriodString(o.funeralTime) as funeralTimePeriodString,
|
||||
o.committalTypeId, c.committalType,
|
||||
o.recordUpdate_timeMillis
|
||||
from Contracts o
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { dateIntegerToString, timeIntegerToString } from '@cityssm/utils-datetime'
|
||||
import { dateIntegerToString, timeIntegerToPeriodString, timeIntegerToString } from '@cityssm/utils-datetime'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import type { Contract } from '../types/recordTypes.js'
|
||||
|
|
@ -19,6 +19,7 @@ export default async function getContract(
|
|||
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
database.function('userFn_timeIntegerToString', timeIntegerToString)
|
||||
database.function('userFn_timeIntegerToPeriodString', timeIntegerToPeriodString)
|
||||
|
||||
const contract = database
|
||||
.prepare(
|
||||
|
|
@ -35,7 +36,9 @@ export default async function getContract(
|
|||
f.funeralHomeName, f.funeralHomeAddress1, f.funeralHomeAddress2,
|
||||
f.funeralHomeCity, f.funeralHomeProvince, f.funeralHomePostalCode,
|
||||
o.funeralDate, userFn_dateIntegerToString(o.funeralDate) as funeralDateString,
|
||||
o.funeralTime, userFn_timeIntegerToString(o.funeralTime) as funeralTimeString,
|
||||
o.funeralTime,
|
||||
userFn_timeIntegerToString(o.funeralTime) as funeralTimeString,
|
||||
userFn_timeIntegerToPeriodString(o.funeralTime) as funeralTimePeriodString,
|
||||
o.committalTypeId, c.committalType,
|
||||
o.recordUpdate_timeMillis
|
||||
from Contracts o
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { type DateString } from '@cityssm/utils-datetime';
|
||||
import { type DateString, type TimeString } from '@cityssm/utils-datetime';
|
||||
export interface UpdateContractForm {
|
||||
contractId: string | number;
|
||||
contractTypeId: string | number;
|
||||
|
|
@ -6,7 +6,10 @@ export interface UpdateContractForm {
|
|||
contractStartDateString: DateString;
|
||||
contractEndDateString: DateString | '';
|
||||
funeralHomeId?: string | number;
|
||||
funeralDirectorName?: string;
|
||||
funeralDirectorName: string;
|
||||
funeralDateString: DateString | '';
|
||||
funeralTimeString: TimeString | '';
|
||||
committalTypeId?: string | number;
|
||||
purchaserName?: string;
|
||||
purchaserAddress1?: string;
|
||||
purchaserAddress2?: string;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { dateStringToInteger } from '@cityssm/utils-datetime';
|
||||
import { dateStringToInteger, timeStringToInteger } from '@cityssm/utils-datetime';
|
||||
import addOrUpdateContractField from './addOrUpdateContractField.js';
|
||||
import deleteContractField from './deleteContractField.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
// eslint-disable-next-line complexity
|
||||
export default async function updateContract(updateForm, user) {
|
||||
const database = await acquireConnection();
|
||||
const result = database
|
||||
|
|
@ -12,6 +13,9 @@ export default async function updateContract(updateForm, user) {
|
|||
contractEndDate = ?,
|
||||
funeralHomeId = ?,
|
||||
funeralDirectorName = ?,
|
||||
funeralDate = ?,
|
||||
funeralTime = ?,
|
||||
committalTypeId = ?,
|
||||
purchaserName = ?,
|
||||
purchaserAddress1 = ?,
|
||||
purchaserAddress2 = ?,
|
||||
|
|
@ -27,7 +31,13 @@ export default async function updateContract(updateForm, user) {
|
|||
and recordDelete_timeMillis is null`)
|
||||
.run(updateForm.contractTypeId, updateForm.burialSiteId === '' ? undefined : updateForm.burialSiteId, dateStringToInteger(updateForm.contractStartDateString), 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);
|
||||
: dateStringToInteger(updateForm.contractEndDateString), updateForm.funeralHomeId === '' ? undefined : updateForm.funeralHomeId, updateForm.funeralDirectorName, updateForm.funeralDateString === ''
|
||||
? undefined
|
||||
: dateStringToInteger(updateForm.funeralDateString), updateForm.funeralTimeString === ''
|
||||
? undefined
|
||||
: timeStringToInteger(updateForm.funeralTimeString), updateForm.committalTypeId === ''
|
||||
? undefined
|
||||
: updateForm.committalTypeId, 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) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
import { type DateString, dateStringToInteger } from '@cityssm/utils-datetime'
|
||||
import {
|
||||
type DateString,
|
||||
type TimeString,
|
||||
dateStringToInteger,
|
||||
timeStringToInteger
|
||||
} from '@cityssm/utils-datetime'
|
||||
|
||||
import addOrUpdateContractField from './addOrUpdateContractField.js'
|
||||
import deleteContractField from './deleteContractField.js'
|
||||
|
|
@ -13,7 +18,10 @@ export interface UpdateContractForm {
|
|||
contractEndDateString: DateString | ''
|
||||
|
||||
funeralHomeId?: string | number
|
||||
funeralDirectorName?: string
|
||||
funeralDirectorName: string
|
||||
funeralDateString: DateString | ''
|
||||
funeralTimeString: TimeString | ''
|
||||
committalTypeId?: string | number
|
||||
|
||||
purchaserName?: string
|
||||
purchaserAddress1?: string
|
||||
|
|
@ -29,6 +37,7 @@ export interface UpdateContractForm {
|
|||
[fieldValue_contractTypeFieldId: `fieldValue_${string}`]: unknown
|
||||
}
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
export default async function updateContract(
|
||||
updateForm: UpdateContractForm,
|
||||
user: User
|
||||
|
|
@ -44,6 +53,9 @@ export default async function updateContract(
|
|||
contractEndDate = ?,
|
||||
funeralHomeId = ?,
|
||||
funeralDirectorName = ?,
|
||||
funeralDate = ?,
|
||||
funeralTime = ?,
|
||||
committalTypeId = ?,
|
||||
purchaserName = ?,
|
||||
purchaserAddress1 = ?,
|
||||
purchaserAddress2 = ?,
|
||||
|
|
@ -66,7 +78,16 @@ export default async function updateContract(
|
|||
? undefined
|
||||
: dateStringToInteger(updateForm.contractEndDateString),
|
||||
updateForm.funeralHomeId === '' ? undefined : updateForm.funeralHomeId,
|
||||
updateForm.funeralDirectorName ?? '',
|
||||
updateForm.funeralDirectorName,
|
||||
updateForm.funeralDateString === ''
|
||||
? undefined
|
||||
: dateStringToInteger(updateForm.funeralDateString),
|
||||
updateForm.funeralTimeString === ''
|
||||
? undefined
|
||||
: timeStringToInteger(updateForm.funeralTimeString),
|
||||
updateForm.committalTypeId === ''
|
||||
? undefined
|
||||
: updateForm.committalTypeId,
|
||||
updateForm.purchaserName ?? '',
|
||||
updateForm.purchaserAddress1 ?? '',
|
||||
updateForm.purchaserAddress2 ?? '',
|
||||
|
|
@ -82,9 +103,9 @@ export default async function updateContract(
|
|||
)
|
||||
|
||||
if (result.changes > 0) {
|
||||
const contractTypeFieldIds = (
|
||||
updateForm.contractTypeFieldIds ?? ''
|
||||
).split(',')
|
||||
const contractTypeFieldIds = (updateForm.contractTypeFieldIds ?? '').split(
|
||||
','
|
||||
)
|
||||
|
||||
for (const contractTypeFieldId of contractTypeFieldIds) {
|
||||
const fieldValue = updateForm[
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
<strong>Age:</strong>
|
||||
</div>
|
||||
<div class="column">
|
||||
${cityssm.escapeHTML(interment.deathAge === undefined ? '(No Age)' : interment.deathAge.toString())}
|
||||
${cityssm.escapeHTML((interment.deathAge ?? '') === '' ? '(No Age)' : interment.deathAge?.toString() ?? '')}<br />
|
||||
${cityssm.escapeHTML(interment.deathAgePeriod ?? '')}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ declare const exports: Record<string, unknown>
|
|||
<strong>Age:</strong>
|
||||
</div>
|
||||
<div class="column">
|
||||
${cityssm.escapeHTML(interment.deathAge === undefined ? '(No Age)' : interment.deathAge.toString())}
|
||||
${cityssm.escapeHTML((interment.deathAge ?? '') === '' ? '(No Age)' : interment.deathAge?.toString() ?? '')}<br />
|
||||
${cityssm.escapeHTML(interment.deathAgePeriod ?? '')}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -143,6 +143,71 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<h2 class="panel-heading">Funeral</h2>
|
||||
<div class="panel-block is-block">
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<p>
|
||||
<strong>Funeral Home</strong><br />
|
||||
<%= contract.funeralHomeName %><br />
|
||||
<span class="is-size-7">
|
||||
<% if (contract.funeralHomeAddress1) { %>
|
||||
<%= contract.funeralHomeAddress1 %><br />
|
||||
<% } %>
|
||||
<% if (contract.funeralHomeAddress2) { %>
|
||||
<%= contract.funeralHomeAddress2 %><br />
|
||||
<% } %>
|
||||
<% if (contract.funeralHomeCity) { %>
|
||||
<%= contract.funeralHomeCity %>,
|
||||
<% } %>
|
||||
<%= contract.funeralHomeProvince %><br />
|
||||
<%= contract.funeralHomePostalCode %>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="column">
|
||||
<% if ((contract.funeralHomePhoneNumber ?? '') !== '') { %>
|
||||
<p class="mb-2">
|
||||
<strong>Phone</strong><br />
|
||||
<%= contract.funeralHomePhoneNumber %>
|
||||
</p>
|
||||
<% } %>
|
||||
<% if ((contract.funeralHomeEmail ?? '') !== '') { %>
|
||||
<p class="mb-2">
|
||||
<strong>Email</strong><br />
|
||||
<%= contract.funeralHomeEmail %>
|
||||
</p>
|
||||
<% } %>
|
||||
<p>
|
||||
<strong>Director</strong><br />
|
||||
<%= contract.funeralDirectorName %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<p>
|
||||
<strong>Service Date</strong><br />
|
||||
<%= contract.funeralDateString %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="column">
|
||||
<p>
|
||||
<strong>Service Time</strong><br />
|
||||
<%= contract.funeralTimePeriodString %>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
<strong>Committal Type</strong><br />
|
||||
<%= contract.committalType %>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<div class="panel">
|
||||
|
|
|
|||
Loading…
Reference in New Issue