diff --git a/database/moveFee.js b/database/moveFee.js index 1ffa157b..f45fb10a 100644 --- a/database/moveFee.js +++ b/database/moveFee.js @@ -8,8 +8,8 @@ export async function moveFeeDown(feeId) { .prepare(`update Fees set orderNumber = orderNumber - 1 where recordDelete_timeMillis is null - and feeCategoryId = ? - and orderNumber = ? + 1`) + and feeCategoryId = ? + and orderNumber = ? + 1`) .run(currentFee.feeCategoryId, currentFee.orderNumber); const success = updateRecordOrderNumber('Fees', feeId, currentFee.orderNumber + 1, database); database.release(); @@ -20,9 +20,9 @@ export async function moveFeeDownToBottom(feeId) { const currentFee = (await getFee(feeId, database)); const maxOrderNumber = database .prepare(`select max(orderNumber) as maxOrderNumber - from Fees - where recordDelete_timeMillis is null - and feeCategoryId = ?`) + from Fees + where recordDelete_timeMillis is null + and feeCategoryId = ?`) .get(currentFee.feeCategoryId).maxOrderNumber; if (currentFee.orderNumber !== maxOrderNumber) { updateRecordOrderNumber('Fees', feeId, maxOrderNumber + 1, database); @@ -30,7 +30,7 @@ export async function moveFeeDownToBottom(feeId) { .prepare(`update Fees set orderNumber = orderNumber - 1 where recordDelete_timeMillis is null - and feeCategoryId = ? and orderNumber > ?`) + and feeCategoryId = ? and orderNumber > ?`) .run(currentFee.feeCategoryId, currentFee.orderNumber); } database.release(); @@ -47,8 +47,8 @@ export async function moveFeeUp(feeId) { .prepare(`update Fees set orderNumber = orderNumber + 1 where recordDelete_timeMillis is null - and feeCategoryId = ? - and orderNumber = ? - 1`) + and feeCategoryId = ? + and orderNumber = ? - 1`) .run(currentFee.feeCategoryId, currentFee.orderNumber); const success = updateRecordOrderNumber('Fees', feeId, currentFee.orderNumber - 1, database); database.release(); @@ -63,8 +63,8 @@ export async function moveFeeUpToTop(feeId) { .prepare(`update Fees set orderNumber = orderNumber + 1 where recordDelete_timeMillis is null - and feeCategoryId = ? - and orderNumber < ?`) + and feeCategoryId = ? + and orderNumber < ?`) .run(currentFee.feeCategoryId, currentFee.orderNumber); } database.release(); diff --git a/database/moveFee.ts b/database/moveFee.ts index c417c4cf..d3c0bb1c 100644 --- a/database/moveFee.ts +++ b/database/moveFee.ts @@ -14,8 +14,8 @@ export async function moveFeeDown(feeId: number | string): Promise { `update Fees set orderNumber = orderNumber - 1 where recordDelete_timeMillis is null - and feeCategoryId = ? - and orderNumber = ? + 1` + and feeCategoryId = ? + and orderNumber = ? + 1` ) .run(currentFee.feeCategoryId, currentFee.orderNumber) @@ -42,9 +42,9 @@ export async function moveFeeDownToBottom( database .prepare( `select max(orderNumber) as maxOrderNumber - from Fees - where recordDelete_timeMillis is null - and feeCategoryId = ?` + from Fees + where recordDelete_timeMillis is null + and feeCategoryId = ?` ) .get(currentFee.feeCategoryId) as { maxOrderNumber: number } ).maxOrderNumber @@ -57,7 +57,7 @@ export async function moveFeeDownToBottom( `update Fees set orderNumber = orderNumber - 1 where recordDelete_timeMillis is null - and feeCategoryId = ? and orderNumber > ?` + and feeCategoryId = ? and orderNumber > ?` ) .run(currentFee.feeCategoryId, currentFee.orderNumber) } @@ -82,8 +82,8 @@ export async function moveFeeUp(feeId: number | string): Promise { `update Fees set orderNumber = orderNumber + 1 where recordDelete_timeMillis is null - and feeCategoryId = ? - and orderNumber = ? - 1` + and feeCategoryId = ? + and orderNumber = ? - 1` ) .run(currentFee.feeCategoryId, currentFee.orderNumber) @@ -112,8 +112,8 @@ export async function moveFeeUpToTop(feeId: number | string): Promise { `update Fees set orderNumber = orderNumber + 1 where recordDelete_timeMillis is null - and feeCategoryId = ? - and orderNumber < ?` + and feeCategoryId = ? + and orderNumber < ?` ) .run(currentFee.feeCategoryId, currentFee.orderNumber) } diff --git a/docs/installation.md b/docs/installation.md index 20e6b9c1..28c627f4 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -18,6 +18,7 @@ the application peaked at the following: - 512 MB of RAM - 1 GB of storage for application, dependencies, and data. +- Active Directory for authentication. ## Step 1: Install Node.js 18 or better and npm diff --git a/eslint.config.js b/eslint.config.js index b0e667fc..51474816 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -11,7 +11,7 @@ export const config = tseslint.config(...configWebApp, { 'warn', { cspell: { - words: [...cspellWords, 'autoincrement', 'ical', 'preneed', 'ntfy'] + words: [...cspellWords, 'autoincrement', 'fontawesome', 'ical', 'preneed', 'ntfy'] } } ], diff --git a/eslint.config.ts b/eslint.config.ts index 03645d8e..16b3ad6c 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -12,7 +12,7 @@ export const config = tseslint.config(...configWebApp, { 'warn', { cspell: { - words: [...cspellWords, 'autoincrement', 'ical', 'preneed', 'ntfy'] + words: [...cspellWords, 'autoincrement', 'fontawesome', 'ical', 'preneed', 'ntfy'] } } ], diff --git a/handlers/burialSites-post/doCreateBurialSite.ts b/handlers/burialSites-post/doCreateBurialSite.ts index d41daf37..c777a427 100644 --- a/handlers/burialSites-post/doCreateBurialSite.ts +++ b/handlers/burialSites-post/doCreateBurialSite.ts @@ -17,6 +17,7 @@ export default async function handler( response.json({ success: true, + burialSiteId }) @@ -26,6 +27,7 @@ export default async function handler( } catch (error) { response.json({ success: false, + errorMessage: (error as Error).message }) } diff --git a/handlers/burialSites-post/doDeleteBurialSite.js b/handlers/burialSites-post/doDeleteBurialSite.js index e84b2f7c..ff55fc25 100644 --- a/handlers/burialSites-post/doDeleteBurialSite.js +++ b/handlers/burialSites-post/doDeleteBurialSite.js @@ -4,10 +4,10 @@ export default async function handler(request, response) { const burialSiteId = Number.parseInt(request.body.burialSiteId, 10); const success = await deleteBurialSite(burialSiteId, request.session.user); response.json({ + success, errorMessage: success ? '' - : 'Note that burial sites with active contracts cannot be deleted.', - success + : 'Note that burial sites with active contracts cannot be deleted.' }); if (success) { response.on('finish', () => { diff --git a/handlers/burialSites-post/doDeleteBurialSite.ts b/handlers/burialSites-post/doDeleteBurialSite.ts index 9fe37d41..a9265f2a 100644 --- a/handlers/burialSites-post/doDeleteBurialSite.ts +++ b/handlers/burialSites-post/doDeleteBurialSite.ts @@ -15,10 +15,11 @@ export default async function handler( ) response.json({ + success, + errorMessage: success ? '' - : 'Note that burial sites with active contracts cannot be deleted.', - success + : 'Note that burial sites with active contracts cannot be deleted.' }) if (success) { diff --git a/handlers/burialSites-post/doDeleteBurialSiteComment.d.ts b/handlers/burialSites-post/doDeleteBurialSiteComment.d.ts index 997f4e53..52039e36 100644 --- a/handlers/burialSites-post/doDeleteBurialSiteComment.d.ts +++ b/handlers/burialSites-post/doDeleteBurialSiteComment.d.ts @@ -1,5 +1,5 @@ import type { Request, Response } from 'express'; export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/burialSites-post/doDeleteBurialSiteComment.ts b/handlers/burialSites-post/doDeleteBurialSiteComment.ts index 96d3ff5f..353c74c8 100644 --- a/handlers/burialSites-post/doDeleteBurialSiteComment.ts +++ b/handlers/burialSites-post/doDeleteBurialSiteComment.ts @@ -7,7 +7,7 @@ export default async function handler( request: Request< unknown, unknown, - { burialSiteId: string; burialSiteCommentId: string } + { burialSiteCommentId: string; burialSiteId: string; } >, response: Response ): Promise { @@ -23,6 +23,7 @@ export default async function handler( response.json({ success, + burialSiteComments }) } diff --git a/handlers/burialSites-post/doSearchBurialSites.ts b/handlers/burialSites-post/doSearchBurialSites.ts index 712ac457..f295364a 100644 --- a/handlers/burialSites-post/doSearchBurialSites.ts +++ b/handlers/burialSites-post/doSearchBurialSites.ts @@ -16,6 +16,7 @@ export default async function handler( const result = await getBurialSites(request.body, { limit: request.body.limit, offset: request.body.offset, + includeContractCount: true }) @@ -25,6 +26,7 @@ export default async function handler( typeof request.body.offset === 'string' ? Number.parseInt(request.body.offset, 10) : request.body.offset, + burialSites: result.burialSites }) } diff --git a/handlers/burialSites-post/doUpdateBurialSite.ts b/handlers/burialSites-post/doUpdateBurialSite.ts index e8406b5e..195e0cde 100644 --- a/handlers/burialSites-post/doUpdateBurialSite.ts +++ b/handlers/burialSites-post/doUpdateBurialSite.ts @@ -22,6 +22,7 @@ export default async function handler( response.json({ success, + burialSiteId }) @@ -31,6 +32,7 @@ export default async function handler( } catch (error) { response.json({ success: false, + errorMessage: (error as Error).message }) } diff --git a/handlers/burialSites-post/doUpdateBurialSiteComment.ts b/handlers/burialSites-post/doUpdateBurialSiteComment.ts index 4a4466bd..90007ac8 100644 --- a/handlers/burialSites-post/doUpdateBurialSiteComment.ts +++ b/handlers/burialSites-post/doUpdateBurialSiteComment.ts @@ -24,6 +24,7 @@ export default async function handler( response.json({ success, + burialSiteComments }) } diff --git a/handlers/cemeteries-get/search.ts b/handlers/cemeteries-get/search.ts index a450cfe9..f8f714bf 100644 --- a/handlers/cemeteries-get/search.ts +++ b/handlers/cemeteries-get/search.ts @@ -10,6 +10,7 @@ export default async function handler( response.render('cemetery-search', { headTitle: "Cemetery Search", + cemeteries }) } diff --git a/handlers/cemeteries-get/view.js b/handlers/cemeteries-get/view.js index a76909d7..2f4a691a 100644 --- a/handlers/cemeteries-get/view.js +++ b/handlers/cemeteries-get/view.js @@ -17,7 +17,7 @@ export default async function handler(request, response) { response.render('cemetery-view', { headTitle: cemetery.cemeteryName, cemetery, - burialSiteTypeSummary, - burialSiteStatusSummary + burialSiteStatusSummary, + burialSiteTypeSummary }); } diff --git a/handlers/cemeteries-get/view.ts b/handlers/cemeteries-get/view.ts index a671499d..2a9b7e11 100644 --- a/handlers/cemeteries-get/view.ts +++ b/handlers/cemeteries-get/view.ts @@ -28,8 +28,10 @@ export default async function handler( response.render('cemetery-view', { headTitle: cemetery.cemeteryName, + cemetery, - burialSiteTypeSummary, - burialSiteStatusSummary + + burialSiteStatusSummary, + burialSiteTypeSummary }) } diff --git a/handlers/cemeteries-post/doCreateCemetery.ts b/handlers/cemeteries-post/doCreateCemetery.ts index 9fae9fca..a64cf531 100644 --- a/handlers/cemeteries-post/doCreateCemetery.ts +++ b/handlers/cemeteries-post/doCreateCemetery.ts @@ -15,6 +15,7 @@ export default async function handler( response.json({ success: true, + cemeteryId }) } diff --git a/handlers/dashboard-get/dashboard.js b/handlers/dashboard-get/dashboard.js index d404db4b..525938f6 100644 --- a/handlers/dashboard-get/dashboard.js +++ b/handlers/dashboard-get/dashboard.js @@ -6,8 +6,8 @@ export default async function handler(_request, response) { workOrderMilestoneDateFilter: 'date', workOrderMilestoneDateString: currentDateString }, { - orderBy: 'completion', - includeWorkOrders: true + includeWorkOrders: true, + orderBy: 'completion' }); response.render('dashboard', { headTitle: 'Dashboard', diff --git a/handlers/dashboard-get/dashboard.ts b/handlers/dashboard-get/dashboard.ts index 59c7d9b1..2168f9e3 100644 --- a/handlers/dashboard-get/dashboard.ts +++ b/handlers/dashboard-get/dashboard.ts @@ -16,8 +16,8 @@ export default async function handler( workOrderMilestoneDateString: currentDateString }, { - orderBy: 'completion', - includeWorkOrders: true + includeWorkOrders: true, + orderBy: 'completion' } ) diff --git a/handlers/funeralHomes-post/doCreateFuneralHome.ts b/handlers/funeralHomes-post/doCreateFuneralHome.ts index 88cc71f9..be64a7aa 100644 --- a/handlers/funeralHomes-post/doCreateFuneralHome.ts +++ b/handlers/funeralHomes-post/doCreateFuneralHome.ts @@ -13,6 +13,7 @@ export default async function handler( response.json({ success: true, + funeralHomeId }) } diff --git a/handlers/funeralHomes-post/doDeleteFuneralHome.d.ts b/handlers/funeralHomes-post/doDeleteFuneralHome.d.ts index 33acaa76..43bf7cbf 100644 --- a/handlers/funeralHomes-post/doDeleteFuneralHome.d.ts +++ b/handlers/funeralHomes-post/doDeleteFuneralHome.d.ts @@ -1,4 +1,4 @@ import type { Request, Response } from 'express'; export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/funeralHomes-post/doDeleteFuneralHome.ts b/handlers/funeralHomes-post/doDeleteFuneralHome.ts index 8a7fe099..6445c34b 100644 --- a/handlers/funeralHomes-post/doDeleteFuneralHome.ts +++ b/handlers/funeralHomes-post/doDeleteFuneralHome.ts @@ -3,7 +3,7 @@ import type { Request, Response } from 'express' import { deleteRecord } from '../../database/deleteRecord.js' export default async function handler( - request: Request, + request: Request, response: Response ): Promise { const success = await deleteRecord( diff --git a/handlers/funeralHomes-post/doUpdateFuneralHome.ts b/handlers/funeralHomes-post/doUpdateFuneralHome.ts index 94086a5f..d9e2e0dc 100644 --- a/handlers/funeralHomes-post/doUpdateFuneralHome.ts +++ b/handlers/funeralHomes-post/doUpdateFuneralHome.ts @@ -15,6 +15,7 @@ export default async function handler( response.json({ success, + funeralHomeId: request.body.funeralHomeId }) } diff --git a/handlers/print-get/pdf.ts b/handlers/print-get/pdf.ts index 3ef8d6f1..f8580691 100644 --- a/handlers/print-get/pdf.ts +++ b/handlers/print-get/pdf.ts @@ -1,9 +1,10 @@ +import type { NextFunction, Request, Response } from 'express' + import path from 'node:path' import { convertHTMLToPDF } from '@cityssm/pdf-puppeteer' import camelcase from 'camelcase' import { renderFile as renderEjsFile } from 'ejs' -import type { NextFunction, Request, Response } from 'express' import { getConfigProperty } from '../../helpers/config.helpers.js' import { diff --git a/temp/legacyImportFromCsv/data.cemeteries.js b/temp/legacyImportFromCsv/data.cemeteries.js index 33dcf3ed..6648673f 100644 --- a/temp/legacyImportFromCsv/data.cemeteries.js +++ b/temp/legacyImportFromCsv/data.cemeteries.js @@ -79,7 +79,7 @@ const cemeteryKeyToCemetery = { parentCemeteryId: '' }, MN: { - cemeteryName: 'Mausoleum Niche', + cemeteryName: 'Holy Sepulchre - Mausoleum Niche', cemeteryDescription: 'At Holy Sepulchre Cemetery', cemeteryKey: 'MN', cemeterySvg: '', @@ -109,7 +109,7 @@ const cemeteryKeyToCemetery = { parentCemeteryId: '' }, NW: { - cemeteryName: 'Niche Wall', + cemeteryName: 'New Greenwood - Niche Wall', cemeteryDescription: 'At New Greenwood Cemetery', cemeteryKey: 'NW', cemeterySvg: '', diff --git a/temp/legacyImportFromCsv/data.cemeteries.ts b/temp/legacyImportFromCsv/data.cemeteries.ts index 10db282b..5fe9d302 100644 --- a/temp/legacyImportFromCsv/data.cemeteries.ts +++ b/temp/legacyImportFromCsv/data.cemeteries.ts @@ -105,7 +105,7 @@ const cemeteryKeyToCemetery: Record = { parentCemeteryId: '' }, MN: { - cemeteryName: 'Mausoleum Niche', + cemeteryName: 'Holy Sepulchre - Mausoleum Niche', cemeteryDescription: 'At Holy Sepulchre Cemetery', cemeteryKey: 'MN', @@ -144,7 +144,7 @@ const cemeteryKeyToCemetery: Record = { parentCemeteryId: '' }, NW: { - cemeteryName: 'Niche Wall', + cemeteryName: 'New Greenwood - Niche Wall', cemeteryDescription: 'At New Greenwood Cemetery', cemeteryKey: 'NW', diff --git a/temp/legacyImportFromCsv/data.funeralHomes.d.ts b/temp/legacyImportFromCsv/data.funeralHomes.d.ts index 795e5910..9e20141b 100644 --- a/temp/legacyImportFromCsv/data.funeralHomes.d.ts +++ b/temp/legacyImportFromCsv/data.funeralHomes.d.ts @@ -1,2 +1,2 @@ -export declare function initializeFuneralHomes(user: User): Promise; export declare function getFuneralHomeIdByKey(funeralHomeKey: string, user: User): Promise; +export declare function initializeFuneralHomes(user: User): Promise; diff --git a/temp/legacyImportFromCsv/data.funeralHomes.js b/temp/legacyImportFromCsv/data.funeralHomes.js index b52cd587..f8ebe64d 100644 --- a/temp/legacyImportFromCsv/data.funeralHomes.js +++ b/temp/legacyImportFromCsv/data.funeralHomes.js @@ -1,4 +1,4 @@ -import addFuneralHome from "../../database/addFuneralHome.js"; +import addFuneralHome from '../../database/addFuneralHome.js'; const funeralHomes = [ { funeralHomeKey: 'AR', @@ -72,7 +72,7 @@ const funeralHomes = [ }, { funeralHomeKey: 'ME', - funeralHomeName: "Menard Funeral Home", + funeralHomeName: 'Menard Funeral Home', funeralHomeAddress1: '72 Lakeside Avenue', funeralHomeAddress2: '', funeralHomeCity: 'Blind River', @@ -82,28 +82,13 @@ const funeralHomes = [ } ]; const funeralHomeKeyToId = new Map(); -export async function initializeFuneralHomes(user) { - for (const funeralHome of funeralHomes) { - const funeralHomeId = await addFuneralHome({ - funeralHomeName: funeralHome.funeralHomeName ?? '', - funeralHomeKey: funeralHome.funeralHomeKey ?? '', - funeralHomeAddress1: funeralHome.funeralHomeAddress1 ?? '', - funeralHomeAddress2: funeralHome.funeralHomeAddress2 ?? '', - funeralHomeCity: funeralHome.funeralHomeCity ?? '', - funeralHomeProvince: funeralHome.funeralHomeProvince ?? '', - funeralHomePostalCode: funeralHome.funeralHomePostalCode ?? '', - funeralHomePhoneNumber: funeralHome.funeralHomePhoneNumber ?? '' - }, user); - funeralHomeKeyToId.set(funeralHome.funeralHomeKey ?? '', funeralHomeId); - } -} export async function getFuneralHomeIdByKey(funeralHomeKey, user) { if (funeralHomeKeyToId.has(funeralHomeKey)) { return funeralHomeKeyToId.get(funeralHomeKey); } const funeralHomeId = await addFuneralHome({ - funeralHomeName: funeralHomeKey, funeralHomeKey, + funeralHomeName: funeralHomeKey, funeralHomeAddress1: '', funeralHomeAddress2: '', funeralHomeCity: '', @@ -114,3 +99,18 @@ export async function getFuneralHomeIdByKey(funeralHomeKey, user) { funeralHomeKeyToId.set(funeralHomeKey, funeralHomeId); return funeralHomeId; } +export async function initializeFuneralHomes(user) { + for (const funeralHome of funeralHomes) { + const funeralHomeId = await addFuneralHome({ + funeralHomeKey: funeralHome.funeralHomeKey ?? '', + funeralHomeName: funeralHome.funeralHomeName ?? '', + funeralHomeAddress1: funeralHome.funeralHomeAddress1 ?? '', + funeralHomeAddress2: funeralHome.funeralHomeAddress2 ?? '', + funeralHomeCity: funeralHome.funeralHomeCity ?? '', + funeralHomeProvince: funeralHome.funeralHomeProvince ?? '', + funeralHomePostalCode: funeralHome.funeralHomePostalCode ?? '', + funeralHomePhoneNumber: funeralHome.funeralHomePhoneNumber ?? '' + }, user); + funeralHomeKeyToId.set(funeralHome.funeralHomeKey ?? '', funeralHomeId); + } +} diff --git a/temp/legacyImportFromCsv/data.funeralHomes.ts b/temp/legacyImportFromCsv/data.funeralHomes.ts index 5d2f8d69..66627da4 100644 --- a/temp/legacyImportFromCsv/data.funeralHomes.ts +++ b/temp/legacyImportFromCsv/data.funeralHomes.ts @@ -1,111 +1,107 @@ -import addFuneralHome from "../../database/addFuneralHome.js" -import type { FuneralHome } from "../../types/recordTypes.js" +import addFuneralHome from '../../database/addFuneralHome.js' +import type { FuneralHome } from '../../types/recordTypes.js' const funeralHomes: FuneralHome[] = [ { funeralHomeKey: 'AR', funeralHomeName: 'Arthur Funeral Home', + funeralHomeAddress1: '492 Wellington Street East', funeralHomeAddress2: '', funeralHomeCity: 'Sault Ste. Marie', funeralHomeProvince: 'ON', funeralHomePostalCode: 'P6A 2L9', + funeralHomePhoneNumber: '705-759-2522' }, { funeralHomeKey: 'BG', funeralHomeName: 'Beggs Funeral Home', + funeralHomeAddress1: '175 Main Street', funeralHomeAddress2: 'P.O. Box 280', funeralHomeCity: 'Thessalon', funeralHomeProvince: 'ON', funeralHomePostalCode: 'P0R 1L0', + funeralHomePhoneNumber: '705-842-2520' }, { funeralHomeKey: 'BK', funeralHomeName: 'Barton and Kiteley', + funeralHomeAddress1: '', funeralHomeAddress2: '', funeralHomeCity: 'Sault Ste. Marie', funeralHomeProvince: 'ON', funeralHomePostalCode: '', + funeralHomePhoneNumber: '' }, { funeralHomeKey: 'DA', funeralHomeName: 'Damignani Burial, Cremation and Transfer Service', + funeralHomeAddress1: '215 St. James Street', funeralHomeAddress2: '', funeralHomeCity: 'Sault Ste. Marie', funeralHomeProvince: 'ON', funeralHomePostalCode: 'P6A 1P7', + funeralHomePhoneNumber: '705-759-8456' }, { funeralHomeKey: 'GL', funeralHomeName: 'Gilmartin P.M. Funeral Home', + funeralHomeAddress1: '140 Churchill Avenue', funeralHomeAddress2: '', funeralHomeCity: 'Wawa', funeralHomeProvince: 'ON', funeralHomePostalCode: 'P0S 1K0', + funeralHomePhoneNumber: '705-856-7340' }, { funeralHomeKey: 'NO', funeralHomeName: 'Northwood Funeral Home', + funeralHomeAddress1: '942 Great Northern Road', funeralHomeAddress2: '', funeralHomeCity: 'Sault Ste. Marie', funeralHomeProvince: 'ON', funeralHomePostalCode: 'P6B 0B6', + funeralHomePhoneNumber: '705-945-7758' }, { funeralHomeKey: 'OS', funeralHomeName: "O'Sullivan Funeral Home", + funeralHomeAddress1: '215 St. James Street', funeralHomeAddress2: '', funeralHomeCity: 'Sault Ste. Marie', funeralHomeProvince: 'ON', funeralHomePostalCode: 'P6A 1P7', + funeralHomePhoneNumber: '705-759-8456' }, { funeralHomeKey: 'ME', - funeralHomeName: "Menard Funeral Home", + funeralHomeName: 'Menard Funeral Home', + funeralHomeAddress1: '72 Lakeside Avenue', funeralHomeAddress2: '', funeralHomeCity: 'Blind River', funeralHomeProvince: 'ON', funeralHomePostalCode: 'P0R 1B0', + funeralHomePhoneNumber: '705-356-7151' } ] const funeralHomeKeyToId = new Map() -export async function initializeFuneralHomes(user: User): Promise { - for (const funeralHome of funeralHomes) { - const funeralHomeId = await addFuneralHome( - { - funeralHomeName: funeralHome.funeralHomeName ?? '', - funeralHomeKey: funeralHome.funeralHomeKey ?? '', - funeralHomeAddress1: funeralHome.funeralHomeAddress1 ?? '', - funeralHomeAddress2: funeralHome.funeralHomeAddress2 ?? '', - funeralHomeCity: funeralHome.funeralHomeCity ?? '', - funeralHomeProvince: funeralHome.funeralHomeProvince ?? '', - funeralHomePostalCode: funeralHome.funeralHomePostalCode ?? '', - funeralHomePhoneNumber: funeralHome.funeralHomePhoneNumber ?? '' - }, - user - ) - - funeralHomeKeyToId.set(funeralHome.funeralHomeKey ?? '', funeralHomeId) - } -} - export async function getFuneralHomeIdByKey( funeralHomeKey: string, user: User @@ -116,8 +112,9 @@ export async function getFuneralHomeIdByKey( const funeralHomeId = await addFuneralHome( { - funeralHomeName: funeralHomeKey, funeralHomeKey, + funeralHomeName: funeralHomeKey, + funeralHomeAddress1: '', funeralHomeAddress2: '', funeralHomeCity: '', @@ -131,4 +128,26 @@ export async function getFuneralHomeIdByKey( funeralHomeKeyToId.set(funeralHomeKey, funeralHomeId) return funeralHomeId -} \ No newline at end of file +} + +export async function initializeFuneralHomes(user: User): Promise { + for (const funeralHome of funeralHomes) { + const funeralHomeId = await addFuneralHome( + { + funeralHomeKey: funeralHome.funeralHomeKey ?? '', + funeralHomeName: funeralHome.funeralHomeName ?? '', + + funeralHomeAddress1: funeralHome.funeralHomeAddress1 ?? '', + funeralHomeAddress2: funeralHome.funeralHomeAddress2 ?? '', + funeralHomeCity: funeralHome.funeralHomeCity ?? '', + funeralHomeProvince: funeralHome.funeralHomeProvince ?? '', + funeralHomePostalCode: funeralHome.funeralHomePostalCode ?? '', + + funeralHomePhoneNumber: funeralHome.funeralHomePhoneNumber ?? '' + }, + user + ) + + funeralHomeKeyToId.set(funeralHome.funeralHomeKey ?? '', funeralHomeId) + } +} diff --git a/temp/legacyImportFromCsv/index.js b/temp/legacyImportFromCsv/index.js index 1e687b6b..542df54e 100644 --- a/temp/legacyImportFromCsv/index.js +++ b/temp/legacyImportFromCsv/index.js @@ -204,17 +204,17 @@ async function importFromMasterCSV() { if (masterRow.CM_REMARK2 !== '') { await addContractComment({ contractId: preneedContractId, + comment: masterRow.CM_REMARK2, commentDateString: preneedContractStartDateString, - commentTimeString: '00:00', - comment: masterRow.CM_REMARK2 + commentTimeString: '00:00' }, user); } if (masterRow.CM_WORK_ORDER.trim() !== '') { await addContractComment({ contractId: preneedContractId, + comment: `Imported Contract #${masterRow.CM_WORK_ORDER}`, commentDateString: preneedContractStartDateString, - commentTimeString: '00:00', - comment: `Imported Contract #${masterRow.CM_WORK_ORDER}` + commentTimeString: '00:00' }, user); } if (contractEndDateString === '') { @@ -628,7 +628,7 @@ async function importFromWorkOrderCSV() { }, user); burialSite = await getBurialSite(burialSiteId); } - const workOrderContainsLot = workOrder?.workOrderBurialSites?.find((possibleLot) => (possibleLot.burialSiteId === burialSite?.burialSiteId)); + const workOrderContainsLot = workOrder?.workOrderBurialSites?.find((possibleLot) => possibleLot.burialSiteId === burialSite?.burialSiteId); if (!workOrderContainsLot) { await addWorkOrderBurialSite({ workOrderId: workOrder.workOrderId, diff --git a/temp/legacyImportFromCsv/index.ts b/temp/legacyImportFromCsv/index.ts index 19a36d49..47de92f8 100644 --- a/temp/legacyImportFromCsv/index.ts +++ b/temp/legacyImportFromCsv/index.ts @@ -452,9 +452,10 @@ async function importFromMasterCSV(): Promise { await addContractComment( { contractId: preneedContractId, + + comment: masterRow.CM_REMARK2, commentDateString: preneedContractStartDateString, - commentTimeString: '00:00', - comment: masterRow.CM_REMARK2 + commentTimeString: '00:00' }, user ) @@ -464,9 +465,10 @@ async function importFromMasterCSV(): Promise { await addContractComment( { contractId: preneedContractId, + + comment: `Imported Contract #${masterRow.CM_WORK_ORDER}`, commentDateString: preneedContractStartDateString, - commentTimeString: '00:00', - comment: `Imported Contract #${masterRow.CM_WORK_ORDER}` + commentTimeString: '00:00' }, user ) @@ -1089,7 +1091,7 @@ async function importFromWorkOrderCSV(): Promise { burialSiteNameSegment2, burialSiteNameSegment3, burialSiteNameSegment4, - + cemeteryId, cemeterySvgId: burialSiteName.includes(',') ? burialSiteName.split(',')[0] @@ -1109,7 +1111,7 @@ async function importFromWorkOrderCSV(): Promise { } const workOrderContainsLot = workOrder?.workOrderBurialSites?.find( - (possibleLot) => (possibleLot.burialSiteId === burialSite?.burialSiteId) + (possibleLot) => possibleLot.burialSiteId === burialSite?.burialSiteId ) if (!workOrderContainsLot) { diff --git a/views/workOrder-edit.ejs b/views/workOrder-edit.ejs index 51d4df57..93ac174f 100644 --- a/views/workOrder-edit.ejs +++ b/views/workOrder-edit.ejs @@ -193,14 +193,16 @@
-
- -
+ <% if (!isCreate) { %> +
+ +
+ <% } %>