From 7dc95ef90f353535be7866bfce1b599454351e6b Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Fri, 7 Mar 2025 15:42:38 -0500 Subject: [PATCH] major refactoring mostly finished, see #1 --- app.js | 1 - app.ts | 5 - ....d.ts => burialSiteTypeManagement.cy.d.ts} | 0 ...t.cy.js => burialSiteTypeManagement.cy.js} | 6 +- ...t.cy.ts => burialSiteTypeManagement.cy.ts} | 6 +- ...ccupancies.cy.d.ts => burialSites.cy.d.ts} | 0 .../{lots.cy.js => burialSites.cy.js} | 10 +- .../{lots.cy.ts => burialSites.cy.ts} | 10 +- .../{lots.cy.d.ts => contracts.cy.d.ts} | 0 .../{lotOccupancies.cy.js => contracts.cy.js} | 10 +- .../{lotOccupancies.cy.ts => contracts.cy.ts} | 10 +- cypress/e2e/02-update/workOrders.cy.js | 2 +- cypress/e2e/02-update/workOrders.cy.ts | 2 +- database/addContractComment.js | 2 +- database/addContractComment.ts | 4 +- database/addContractInterment.d.ts | 16 + database/addContractInterment.js | 30 + database/addContractInterment.ts | 77 + database/addWorkOrderBurialSite.d.ts | 4 +- database/addWorkOrderBurialSite.ts | 4 +- database/addWorkOrderComment.d.ts | 2 +- database/addWorkOrderComment.js | 6 +- database/addWorkOrderComment.ts | 8 +- database/addWorkOrderContract.d.ts | 4 +- database/addWorkOrderContract.ts | 4 +- database/deleteContractFee.js | 2 +- database/deleteContractFee.ts | 2 +- database/getContract.js | 3 + database/getContract.ts | 3 + database/getContracts.d.ts | 6 +- database/getContracts.js | 22 +- database/getContracts.ts | 36 +- database/getWorkOrderComments.js | 12 +- database/getWorkOrderComments.ts | 12 +- database/getWorkOrders.d.ts | 2 +- database/getWorkOrders.js | 20 +- database/getWorkOrders.ts | 24 +- database/initializeDatabase.js | 2 +- database/initializeDatabase.ts | 2 +- database/updateContractInterment.d.ts | 17 + database/updateContractInterment.js | 32 + database/updateContractInterment.ts | 74 + database/updateLotOccupancyOccupant.d.ts | 16 - database/updateLotOccupancyOccupant.js | 25 - database/updateLotOccupancyOccupant.ts | 66 - database/updateWorkOrderComment.d.ts | 6 +- database/updateWorkOrderComment.js | 8 +- database/updateWorkOrderComment.ts | 18 +- .../doAddContractInterment.d.ts | 3 + .../contracts-post/doAddContractInterment.js | 10 + .../contracts-post/doAddContractInterment.ts | 22 + .../doDeleteContractInterment.d.ts | 5 + .../doDeleteContractInterment.js | 10 + .../doDeleteContractInterment.ts | 28 + .../doUpdateContractInterment.d.ts | 3 + .../doUpdateContractInterment.js | 10 + .../doUpdateContractInterment.ts | 24 + handlers/workOrders-get/edit.js | 4 +- handlers/workOrders-get/edit.ts | 4 +- .../doAddWorkOrderBurialSite.js | 4 +- .../doAddWorkOrderBurialSite.ts | 4 +- helpers/functions.dynamicsGP.js | 6 +- helpers/functions.dynamicsGP.ts | 6 +- helpers/functions.sqlFilters.d.ts | 6 +- helpers/functions.sqlFilters.js | 26 +- helpers/functions.sqlFilters.ts | 34 +- package-lock.json | 27 +- package.json | 1 - public/html/adminFees-addFee.html | 20 +- public/html/adminFees-editFee.html | 7 +- ...l => burialSite-editBurialSiteStatus.html} | 20 +- ...dComment.html => contract-addComment.html} | 6 +- ...pancy-addFee.html => contract-addFee.html} | 0 public/html/contract-addInterment.html | 203 +++ ...tion.html => contract-addTransaction.html} | 0 ...der.html => contract-createWorkOrder.html} | 0 ...Comment.html => contract-editComment.html} | 18 +- ...ity.html => contract-editFeeQuantity.html} | 0 public/html/contract-editInterment.html | 172 +- ...ion.html => contract-editTransaction.html} | 0 ...tity.html => contract-setFeeQuantity.html} | 0 public/html/lotOccupancy-addOccupant.html | 318 ---- ...dLot.html => workOrder-addBurialSite.html} | 19 +- public/html/workOrder-addComment.html | 6 +- ...upancy.html => workOrder-addContract.html} | 19 +- public/html/workOrder-editComment.html | 18 +- public/javascripts/burialSite.edit.js | 35 +- public/javascripts/burialSite.edit.ts | 35 +- public/javascripts/burialSite.search.js | 12 +- public/javascripts/burialSite.search.ts | 12 +- public/javascripts/burialSiteTypes.admin.js | 30 +- public/javascripts/burialSiteTypes.admin.ts | 30 +- public/javascripts/contract.edit.js | 989 +---------- public/javascripts/contract.edit.ts | 1546 +---------------- public/javascripts/contract.editComments.d.ts | 1 + public/javascripts/contract.editComments.js | 185 ++ public/javascripts/contract.editComments.ts | 299 ++++ public/javascripts/contract.editFees.d.ts | 1 + public/javascripts/contract.editFees.js | 668 +++++++ public/javascripts/contract.editFees.ts | 1057 +++++++++++ .../javascripts/contract.editInterments.d.ts | 1 + public/javascripts/contract.editInterments.js | 257 +++ public/javascripts/contract.editInterments.ts | 375 ++++ .../javascripts/contract.editWorkOrders.d.ts | 1 + public/javascripts/contract.editWorkOrders.js | 70 + public/javascripts/contract.editWorkOrders.ts | 120 ++ public/javascripts/contract.search.js | 14 +- public/javascripts/contract.search.ts | 14 +- public/javascripts/database.admin.js | 6 +- public/javascripts/database.admin.ts | 8 +- public/javascripts/fees.admin.js | 79 +- public/javascripts/fees.admin.ts | 80 +- public/javascripts/main.js | 70 - public/javascripts/main.ts | 103 -- public/javascripts/types.d.ts | 1 - public/javascripts/types.ts | 3 - public/javascripts/workOrder.edit.js | 786 +-------- public/javascripts/workOrder.edit.ts | 1196 +------------ .../javascripts/workOrder.editComments.d.ts | 1 + public/javascripts/workOrder.editComments.js | 181 ++ public/javascripts/workOrder.editComments.ts | 294 ++++ public/javascripts/workOrder.editRelated.d.ts | 1 + public/javascripts/workOrder.editRelated.js | 547 ++++++ public/javascripts/workOrder.editRelated.ts | 856 +++++++++ .../workOrder.milestoneCalendar.js | 15 +- .../workOrder.milestoneCalendar.ts | 19 +- public/javascripts/workOrder.outlook.js | 4 +- public/javascripts/workOrder.outlook.ts | 12 +- public/javascripts/workOrder.search.js | 51 +- public/javascripts/workOrder.search.ts | 59 +- public/javascripts/workOrder.view.js | 60 +- public/javascripts/workOrder.view.ts | 21 +- routes/contracts.js | 7 + routes/contracts.ts | 58 +- temp/legacy.importFromCSV.js | 2 +- temp/legacy.importFromCSV.ts | 2 +- test/functions.js | 16 +- test/functions.ts | 16 +- types/recordTypes.d.ts | 5 + types/recordTypes.ts | 5 + views/_footerA.ejs | 1 - views/admin-fees.ejs | 4 +- views/contract-edit.ejs | 7 + views/contract-view.ejs | 40 +- views/print/pdf/ssm.cemetery.burialPermit.ejs | 62 +- views/print/pdf/ssm.cemetery.contract.ejs | 83 +- views/print/pdf/workOrder.ejs | 36 +- views/workOrder-edit.ejs | 358 ++-- views/workOrder-search.ejs | 215 ++- views/workOrder-view.ejs | 207 ++- 150 files changed, 6706 insertions(+), 6319 deletions(-) rename cypress/e2e/01-admin/{lotTypeManagement.cy.d.ts => burialSiteTypeManagement.cy.d.ts} (100%) rename cypress/e2e/01-admin/{lotTypeManagement.cy.js => burialSiteTypeManagement.cy.js} (66%) rename cypress/e2e/01-admin/{lotTypeManagement.cy.ts => burialSiteTypeManagement.cy.ts} (65%) rename cypress/e2e/02-update/{lotOccupancies.cy.d.ts => burialSites.cy.d.ts} (100%) rename cypress/e2e/02-update/{lots.cy.js => burialSites.cy.js} (65%) rename cypress/e2e/02-update/{lots.cy.ts => burialSites.cy.ts} (63%) rename cypress/e2e/02-update/{lots.cy.d.ts => contracts.cy.d.ts} (100%) rename cypress/e2e/02-update/{lotOccupancies.cy.js => contracts.cy.js} (63%) rename cypress/e2e/02-update/{lotOccupancies.cy.ts => contracts.cy.ts} (61%) create mode 100644 database/addContractInterment.d.ts create mode 100644 database/addContractInterment.js create mode 100644 database/addContractInterment.ts create mode 100644 database/updateContractInterment.d.ts create mode 100644 database/updateContractInterment.js create mode 100644 database/updateContractInterment.ts delete mode 100644 database/updateLotOccupancyOccupant.d.ts delete mode 100644 database/updateLotOccupancyOccupant.js delete mode 100644 database/updateLotOccupancyOccupant.ts create mode 100644 handlers/contracts-post/doAddContractInterment.d.ts create mode 100644 handlers/contracts-post/doAddContractInterment.js create mode 100644 handlers/contracts-post/doAddContractInterment.ts create mode 100644 handlers/contracts-post/doDeleteContractInterment.d.ts create mode 100644 handlers/contracts-post/doDeleteContractInterment.js create mode 100644 handlers/contracts-post/doDeleteContractInterment.ts create mode 100644 handlers/contracts-post/doUpdateContractInterment.d.ts create mode 100644 handlers/contracts-post/doUpdateContractInterment.js create mode 100644 handlers/contracts-post/doUpdateContractInterment.ts rename public/html/{burialSite-editLotStatus.html => burialSite-editBurialSiteStatus.html} (66%) rename public/html/{lotOccupancy-addComment.html => contract-addComment.html} (88%) rename public/html/{lotOccupancy-addFee.html => contract-addFee.html} (100%) create mode 100644 public/html/contract-addInterment.html rename public/html/{lotOccupancy-addTransaction.html => contract-addTransaction.html} (100%) rename public/html/{lotOccupancy-createWorkOrder.html => contract-createWorkOrder.html} (100%) rename public/html/{lotOccupancy-editComment.html => contract-editComment.html} (82%) rename public/html/{lotOccupancy-editFeeQuantity.html => contract-editFeeQuantity.html} (100%) rename public/html/{lotOccupancy-editTransaction.html => contract-editTransaction.html} (100%) rename public/html/{lotOccupancy-setFeeQuantity.html => contract-setFeeQuantity.html} (100%) delete mode 100644 public/html/lotOccupancy-addOccupant.html rename public/html/{workOrder-addLot.html => workOrder-addBurialSite.html} (76%) rename public/html/{workOrder-addLotOccupancy.html => workOrder-addContract.html} (80%) create mode 100644 public/javascripts/contract.editComments.d.ts create mode 100644 public/javascripts/contract.editComments.js create mode 100644 public/javascripts/contract.editComments.ts create mode 100644 public/javascripts/contract.editFees.d.ts create mode 100644 public/javascripts/contract.editFees.js create mode 100644 public/javascripts/contract.editFees.ts create mode 100644 public/javascripts/contract.editInterments.d.ts create mode 100644 public/javascripts/contract.editInterments.js create mode 100644 public/javascripts/contract.editInterments.ts create mode 100644 public/javascripts/contract.editWorkOrders.d.ts create mode 100644 public/javascripts/contract.editWorkOrders.js create mode 100644 public/javascripts/contract.editWorkOrders.ts create mode 100644 public/javascripts/workOrder.editComments.d.ts create mode 100644 public/javascripts/workOrder.editComments.js create mode 100644 public/javascripts/workOrder.editComments.ts create mode 100644 public/javascripts/workOrder.editRelated.d.ts create mode 100644 public/javascripts/workOrder.editRelated.js create mode 100644 public/javascripts/workOrder.editRelated.ts diff --git a/app.js b/app.js index 9c740bb0..cf2905da 100644 --- a/app.js +++ b/app.js @@ -75,7 +75,6 @@ if (urlPrefix !== '') { debug(`urlPrefix = ${urlPrefix}`); } app.use(urlPrefix, express.static(path.join('public'))); -app.use(`${urlPrefix}/lib/bulma-calendar`, express.static(path.join('node_modules', 'bulma-calendar', 'dist'))); app.use(`${urlPrefix}/lib/cityssm-bulma-js/bulma-js.js`, express.static(path.join('node_modules', '@cityssm', 'bulma-js', 'dist', 'bulma-js.js'))); app.use(`${urlPrefix}/lib/cityssm-bulma-webapp-js`, express.static(path.join('node_modules', '@cityssm', 'bulma-webapp-js', 'dist'))); app.use(`${urlPrefix}/lib/fa`, express.static(path.join('node_modules', '@fortawesome', 'fontawesome-free'))); diff --git a/app.ts b/app.ts index 753dc21f..bed9a32d 100644 --- a/app.ts +++ b/app.ts @@ -104,11 +104,6 @@ if (urlPrefix !== '') { app.use(urlPrefix, express.static(path.join('public'))) -app.use( - `${urlPrefix}/lib/bulma-calendar`, - express.static(path.join('node_modules', 'bulma-calendar', 'dist')) -) - app.use( `${urlPrefix}/lib/cityssm-bulma-js/bulma-js.js`, express.static( diff --git a/cypress/e2e/01-admin/lotTypeManagement.cy.d.ts b/cypress/e2e/01-admin/burialSiteTypeManagement.cy.d.ts similarity index 100% rename from cypress/e2e/01-admin/lotTypeManagement.cy.d.ts rename to cypress/e2e/01-admin/burialSiteTypeManagement.cy.d.ts diff --git a/cypress/e2e/01-admin/lotTypeManagement.cy.js b/cypress/e2e/01-admin/burialSiteTypeManagement.cy.js similarity index 66% rename from cypress/e2e/01-admin/lotTypeManagement.cy.js rename to cypress/e2e/01-admin/burialSiteTypeManagement.cy.js index 36c6b284..d87360e1 100644 --- a/cypress/e2e/01-admin/lotTypeManagement.cy.js +++ b/cypress/e2e/01-admin/burialSiteTypeManagement.cy.js @@ -1,11 +1,11 @@ import { testAdmin } from '../../../test/_globals.js'; import { login, logout } from '../../support/index.js'; -describe('Admin - Lot Type Management', () => { +describe('Admin - Burial Site Type Management', () => { beforeEach('Loads page', () => { logout(); login(testAdmin); - cy.visit('/admin/lotTypes'); - cy.location('pathname').should('equal', '/admin/lotTypes'); + cy.visit('/admin/burialSiteTypes'); + cy.location('pathname').should('equal', '/admin/burialSiteTypes'); }); afterEach(logout); it('Has no detectable accessibility issues', () => { diff --git a/cypress/e2e/01-admin/lotTypeManagement.cy.ts b/cypress/e2e/01-admin/burialSiteTypeManagement.cy.ts similarity index 65% rename from cypress/e2e/01-admin/lotTypeManagement.cy.ts rename to cypress/e2e/01-admin/burialSiteTypeManagement.cy.ts index 585ff19d..fc19595d 100644 --- a/cypress/e2e/01-admin/lotTypeManagement.cy.ts +++ b/cypress/e2e/01-admin/burialSiteTypeManagement.cy.ts @@ -1,12 +1,12 @@ import { testAdmin } from '../../../test/_globals.js' import { login, logout } from '../../support/index.js' -describe('Admin - Lot Type Management', () => { +describe('Admin - Burial Site Type Management', () => { beforeEach('Loads page', () => { logout() login(testAdmin) - cy.visit('/admin/lotTypes') - cy.location('pathname').should('equal', '/admin/lotTypes') + cy.visit('/admin/burialSiteTypes') + cy.location('pathname').should('equal', '/admin/burialSiteTypes') }) afterEach(logout) diff --git a/cypress/e2e/02-update/lotOccupancies.cy.d.ts b/cypress/e2e/02-update/burialSites.cy.d.ts similarity index 100% rename from cypress/e2e/02-update/lotOccupancies.cy.d.ts rename to cypress/e2e/02-update/burialSites.cy.d.ts diff --git a/cypress/e2e/02-update/lots.cy.js b/cypress/e2e/02-update/burialSites.cy.js similarity index 65% rename from cypress/e2e/02-update/lots.cy.js rename to cypress/e2e/02-update/burialSites.cy.js index 8ae70571..c91154b3 100644 --- a/cypress/e2e/02-update/lots.cy.js +++ b/cypress/e2e/02-update/burialSites.cy.js @@ -1,17 +1,17 @@ import { testUpdate } from '../../../test/_globals.js'; import { login, logout } from '../../support/index.js'; -describe('Update - Lots', () => { +describe('Update - Burial Sites', () => { beforeEach('Loads page', () => { logout(); login(testUpdate); }); afterEach(logout); - it('Has a "Create" link on the Lot Search', () => { - cy.visit('/lots'); - cy.location('pathname').should('equal', '/lots'); + it('Has a "Create" link on the Burial Site Search', () => { + cy.visit('/burialSites'); + cy.location('pathname').should('equal', '/burialSites'); cy.get("a[href$='/burialSites/new']").should('exist'); }); - describe('Update a New Lot', () => { + describe('Creates a New Burial Site', () => { it('Has no detectable accessibility issues', () => { cy.visit('/burialSites/new'); cy.injectAxe(); diff --git a/cypress/e2e/02-update/lots.cy.ts b/cypress/e2e/02-update/burialSites.cy.ts similarity index 63% rename from cypress/e2e/02-update/lots.cy.ts rename to cypress/e2e/02-update/burialSites.cy.ts index dee30068..67c1833e 100644 --- a/cypress/e2e/02-update/lots.cy.ts +++ b/cypress/e2e/02-update/burialSites.cy.ts @@ -1,7 +1,7 @@ import { testUpdate } from '../../../test/_globals.js' import { login, logout } from '../../support/index.js' -describe('Update - Lots', () => { +describe('Update - Burial Sites', () => { beforeEach('Loads page', () => { logout() login(testUpdate) @@ -9,13 +9,13 @@ describe('Update - Lots', () => { afterEach(logout) - it('Has a "Create" link on the Lot Search', () => { - cy.visit('/lots') - cy.location('pathname').should('equal', '/lots') + it('Has a "Create" link on the Burial Site Search', () => { + cy.visit('/burialSites') + cy.location('pathname').should('equal', '/burialSites') cy.get("a[href$='/burialSites/new']").should('exist') }) - describe('Update a New Lot', () => { + describe('Creates a New Burial Site', () => { it('Has no detectable accessibility issues', () => { cy.visit('/burialSites/new') cy.injectAxe() diff --git a/cypress/e2e/02-update/lots.cy.d.ts b/cypress/e2e/02-update/contracts.cy.d.ts similarity index 100% rename from cypress/e2e/02-update/lots.cy.d.ts rename to cypress/e2e/02-update/contracts.cy.d.ts diff --git a/cypress/e2e/02-update/lotOccupancies.cy.js b/cypress/e2e/02-update/contracts.cy.js similarity index 63% rename from cypress/e2e/02-update/lotOccupancies.cy.js rename to cypress/e2e/02-update/contracts.cy.js index 069ffb32..974a824a 100644 --- a/cypress/e2e/02-update/lotOccupancies.cy.js +++ b/cypress/e2e/02-update/contracts.cy.js @@ -1,17 +1,17 @@ import { testUpdate } from '../../../test/_globals.js'; import { login, logout } from '../../support/index.js'; -describe('Update - Lot Occupancies', () => { +describe('Update - Contracts', () => { beforeEach(() => { logout(); login(testUpdate); }); afterEach(logout); - it('Has a "Create" link on the Lot Occupancy Search', () => { - cy.visit('/lotOccupancies'); - cy.location('pathname').should('equal', '/lotOccupancies'); + it('Has a "Create" link on the Contract Search', () => { + cy.visit('/contracts'); + cy.location('pathname').should('equal', '/contracts'); cy.get("a[href$='/contracts/new']").should('exist'); }); - describe('Update a New Lot Occupancy', () => { + describe('Creates a New Contract', () => { it('Has no detectable accessibility issues', () => { cy.visit('/contracts/new'); cy.injectAxe(); diff --git a/cypress/e2e/02-update/lotOccupancies.cy.ts b/cypress/e2e/02-update/contracts.cy.ts similarity index 61% rename from cypress/e2e/02-update/lotOccupancies.cy.ts rename to cypress/e2e/02-update/contracts.cy.ts index 14501c2d..4ae0e462 100644 --- a/cypress/e2e/02-update/lotOccupancies.cy.ts +++ b/cypress/e2e/02-update/contracts.cy.ts @@ -1,7 +1,7 @@ import { testUpdate } from '../../../test/_globals.js' import { login, logout } from '../../support/index.js' -describe('Update - Lot Occupancies', () => { +describe('Update - Contracts', () => { beforeEach(() => { logout() login(testUpdate) @@ -9,13 +9,13 @@ describe('Update - Lot Occupancies', () => { afterEach(logout) - it('Has a "Create" link on the Lot Occupancy Search', () => { - cy.visit('/lotOccupancies') - cy.location('pathname').should('equal', '/lotOccupancies') + it('Has a "Create" link on the Contract Search', () => { + cy.visit('/contracts') + cy.location('pathname').should('equal', '/contracts') cy.get("a[href$='/contracts/new']").should('exist') }) - describe('Update a New Lot Occupancy', () => { + describe('Creates a New Contract', () => { it('Has no detectable accessibility issues', () => { cy.visit('/contracts/new') cy.injectAxe() diff --git a/cypress/e2e/02-update/workOrders.cy.js b/cypress/e2e/02-update/workOrders.cy.js index a7aab9ab..831058ac 100644 --- a/cypress/e2e/02-update/workOrders.cy.js +++ b/cypress/e2e/02-update/workOrders.cy.js @@ -11,7 +11,7 @@ describe('Update - Work Orders', () => { cy.location('pathname').should('equal', '/workOrders'); cy.get("a[href$='/workOrders/new']").should('exist'); }); - describe('Update a New Work Order', () => { + describe('Creates a New Work Order', () => { it('Has no detectable accessibility issues', () => { cy.visit('/workOrders/new'); cy.location('pathname').should('equal', '/workOrders/new'); diff --git a/cypress/e2e/02-update/workOrders.cy.ts b/cypress/e2e/02-update/workOrders.cy.ts index 9d1e2436..2674498e 100644 --- a/cypress/e2e/02-update/workOrders.cy.ts +++ b/cypress/e2e/02-update/workOrders.cy.ts @@ -15,7 +15,7 @@ describe('Update - Work Orders', () => { cy.get("a[href$='/workOrders/new']").should('exist') }) - describe('Update a New Work Order', () => { + describe('Creates a New Work Order', () => { it('Has no detectable accessibility issues', () => { cy.visit('/workOrders/new') cy.location('pathname').should('equal', '/workOrders/new') diff --git a/database/addContractComment.js b/database/addContractComment.js index c9122197..9e224735 100644 --- a/database/addContractComment.js +++ b/database/addContractComment.js @@ -14,7 +14,7 @@ export default async function addContractComment(commentForm, user) { } const database = await acquireConnection(); const result = database - .prepare(`insert into BurialSiteContactComments ( + .prepare(`insert into ContractComments ( contractId, commentDate, commentTime, comment, diff --git a/database/addContractComment.ts b/database/addContractComment.ts index 7a5f5c97..1075ec2e 100644 --- a/database/addContractComment.ts +++ b/database/addContractComment.ts @@ -11,7 +11,7 @@ import { acquireConnection } from './pool.js' export interface AddContractCommentForm { contractId: string | number - commentDateString?: DateString + commentDateString?: DateString commentTimeString?: TimeString comment: string } @@ -41,7 +41,7 @@ export default async function addContractComment( const result = database .prepare( - `insert into BurialSiteContactComments ( + `insert into ContractComments ( contractId, commentDate, commentTime, comment, diff --git a/database/addContractInterment.d.ts b/database/addContractInterment.d.ts new file mode 100644 index 00000000..d0a2355e --- /dev/null +++ b/database/addContractInterment.d.ts @@ -0,0 +1,16 @@ +import { type DateString } from '@cityssm/utils-datetime'; +export interface AddForm { + contractId: string | number; + deceasedName: string; + deceasedAddress1: string; + deceasedAddress2: string; + deceasedCity: string; + deceasedProvince: string; + deceasedPostalCode: string; + birthDateString: DateString | ''; + birthPlace: string; + deathDateString: DateString | ''; + deathPlace: string; + intermentContainerTypeId: string | number; +} +export default function addContractInterment(contractForm: AddForm, user: User): Promise; diff --git a/database/addContractInterment.js b/database/addContractInterment.js new file mode 100644 index 00000000..20002000 --- /dev/null +++ b/database/addContractInterment.js @@ -0,0 +1,30 @@ +import { dateStringToInteger } from '@cityssm/utils-datetime'; +import { acquireConnection } from './pool.js'; +export default async function addContractInterment(contractForm, user) { + const database = await acquireConnection(); + const maxIntermentNumber = (database + .prepare(`select max(intermentNumber) as maxIntermentNumber + from ContractInterments + where contractId = ?`) + .pluck() + .get(contractForm.contractId) ?? 0); + const newIntermentNumber = maxIntermentNumber + 1; + const rightNowMillis = Date.now(); + database + .prepare(`insert into ContractInterments + (contractId, intermentNumber, + deceasedName, deceasedAddress1, deceasedAddress2, deceasedCity, deceasedProvince, deceasedPostalCode, + birthDate, birthPlace, deathDate, deathPlace, intermentContainerTypeId, + recordCreate_userName, recordCreate_timeMillis, + recordUpdate_userName, recordUpdate_timeMillis) + values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`) + .run(contractForm.contractId, newIntermentNumber, contractForm.deceasedName, contractForm.deceasedAddress1, contractForm.deceasedAddress2, contractForm.deceasedCity, contractForm.deceasedProvince, contractForm.deceasedPostalCode, contractForm.birthDateString === '' + ? undefined + : dateStringToInteger(contractForm.birthDateString), contractForm.birthPlace, contractForm.deathDateString === '' + ? undefined + : dateStringToInteger(contractForm.deathDateString), contractForm.deathPlace, contractForm.intermentContainerTypeId === '' + ? undefined + : contractForm.intermentContainerTypeId, user.userName, rightNowMillis, user.userName, rightNowMillis); + database.release(); + return newIntermentNumber; +} diff --git a/database/addContractInterment.ts b/database/addContractInterment.ts new file mode 100644 index 00000000..5e4b6d1b --- /dev/null +++ b/database/addContractInterment.ts @@ -0,0 +1,77 @@ +import { type DateString, dateStringToInteger } from '@cityssm/utils-datetime' + +import { acquireConnection } from './pool.js' + +export interface AddForm { + contractId: string | number + deceasedName: string + deceasedAddress1: string + deceasedAddress2: string + deceasedCity: string + deceasedProvince: string + deceasedPostalCode: string + birthDateString: DateString | '' + birthPlace: string + deathDateString: DateString | '' + deathPlace: string + intermentContainerTypeId: string | number +} + +export default async function addContractInterment( + contractForm: AddForm, + user: User +): Promise { + const database = await acquireConnection() + + const maxIntermentNumber = (database + .prepare( + `select max(intermentNumber) as maxIntermentNumber + from ContractInterments + where contractId = ?` + ) + .pluck() + .get(contractForm.contractId) ?? 0) as number + + const newIntermentNumber = maxIntermentNumber + 1 + const rightNowMillis = Date.now() + + database + .prepare( + `insert into ContractInterments + (contractId, intermentNumber, + deceasedName, deceasedAddress1, deceasedAddress2, deceasedCity, deceasedProvince, deceasedPostalCode, + birthDate, birthPlace, deathDate, deathPlace, intermentContainerTypeId, + recordCreate_userName, recordCreate_timeMillis, + recordUpdate_userName, recordUpdate_timeMillis) + values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` + ) + .run( + contractForm.contractId, + newIntermentNumber, + contractForm.deceasedName, + contractForm.deceasedAddress1, + contractForm.deceasedAddress2, + contractForm.deceasedCity, + contractForm.deceasedProvince, + contractForm.deceasedPostalCode, + contractForm.birthDateString === '' + ? undefined + : dateStringToInteger(contractForm.birthDateString), + contractForm.birthPlace, + contractForm.deathDateString === '' + ? undefined + : dateStringToInteger(contractForm.deathDateString), + contractForm.deathPlace, + contractForm.intermentContainerTypeId === '' + ? undefined + : contractForm.intermentContainerTypeId, + user.userName, + rightNowMillis, + user.userName, + rightNowMillis + ) + + database.release() + + return newIntermentNumber +} diff --git a/database/addWorkOrderBurialSite.d.ts b/database/addWorkOrderBurialSite.d.ts index 2f84e34b..0d57c515 100644 --- a/database/addWorkOrderBurialSite.d.ts +++ b/database/addWorkOrderBurialSite.d.ts @@ -1,5 +1,5 @@ -export interface AddWorkOrderLotForm { +export interface AddForm { workOrderId: number | string; burialSiteId: number | string; } -export default function addWorkOrderBurialSite(workOrderLotForm: AddWorkOrderLotForm, user: User): Promise; +export default function addWorkOrderBurialSite(workOrderLotForm: AddForm, user: User): Promise; diff --git a/database/addWorkOrderBurialSite.ts b/database/addWorkOrderBurialSite.ts index 72682563..44f44c04 100644 --- a/database/addWorkOrderBurialSite.ts +++ b/database/addWorkOrderBurialSite.ts @@ -1,12 +1,12 @@ import { acquireConnection } from './pool.js' -export interface AddWorkOrderLotForm { +export interface AddForm { workOrderId: number | string burialSiteId: number | string } export default async function addWorkOrderBurialSite( - workOrderLotForm: AddWorkOrderLotForm, + workOrderLotForm: AddForm, user: User ): Promise { const database = await acquireConnection() diff --git a/database/addWorkOrderComment.d.ts b/database/addWorkOrderComment.d.ts index f9b4c357..a37c0583 100644 --- a/database/addWorkOrderComment.d.ts +++ b/database/addWorkOrderComment.d.ts @@ -1,5 +1,5 @@ export interface AddWorkOrderCommentForm { workOrderId: string; - workOrderComment: string; + comment: string; } export default function addWorkOrderComment(workOrderCommentForm: AddWorkOrderCommentForm, user: User): Promise; diff --git a/database/addWorkOrderComment.js b/database/addWorkOrderComment.js index cf90b964..7dda5538 100644 --- a/database/addWorkOrderComment.js +++ b/database/addWorkOrderComment.js @@ -6,12 +6,12 @@ export default async function addWorkOrderComment(workOrderCommentForm, user) { const result = database .prepare(`insert into WorkOrderComments ( workOrderId, - workOrderCommentDate, workOrderCommentTime, - workOrderComment, + commentDate, commentTime, + comment, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?, ?)`) - .run(workOrderCommentForm.workOrderId, dateToInteger(rightNow), dateToTimeInteger(rightNow), workOrderCommentForm.workOrderComment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime()); + .run(workOrderCommentForm.workOrderId, dateToInteger(rightNow), dateToTimeInteger(rightNow), workOrderCommentForm.comment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime()); database.release(); return result.lastInsertRowid; } diff --git a/database/addWorkOrderComment.ts b/database/addWorkOrderComment.ts index 1d5ca2c5..5b7d81db 100644 --- a/database/addWorkOrderComment.ts +++ b/database/addWorkOrderComment.ts @@ -4,7 +4,7 @@ import { acquireConnection } from './pool.js' export interface AddWorkOrderCommentForm { workOrderId: string - workOrderComment: string + comment: string } export default async function addWorkOrderComment( @@ -19,8 +19,8 @@ export default async function addWorkOrderComment( .prepare( `insert into WorkOrderComments ( workOrderId, - workOrderCommentDate, workOrderCommentTime, - workOrderComment, + commentDate, commentTime, + comment, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?, ?)` @@ -29,7 +29,7 @@ export default async function addWorkOrderComment( workOrderCommentForm.workOrderId, dateToInteger(rightNow), dateToTimeInteger(rightNow), - workOrderCommentForm.workOrderComment, + workOrderCommentForm.comment, user.userName, rightNow.getTime(), user.userName, diff --git a/database/addWorkOrderContract.d.ts b/database/addWorkOrderContract.d.ts index acf7a95a..c1b66cb9 100644 --- a/database/addWorkOrderContract.d.ts +++ b/database/addWorkOrderContract.d.ts @@ -1,6 +1,6 @@ import type { PoolConnection } from 'better-sqlite-pool'; -export interface AddWorkOrderContractOccupancyForm { +export interface AddForm { workOrderId: number | string; contractId: number | string; } -export default function addWorkOrderContract(addForm: AddWorkOrderContractOccupancyForm, user: User, connectedDatabase?: PoolConnection): Promise; +export default function addWorkOrderContract(addForm: AddForm, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/addWorkOrderContract.ts b/database/addWorkOrderContract.ts index 5d3c3c6b..58710071 100644 --- a/database/addWorkOrderContract.ts +++ b/database/addWorkOrderContract.ts @@ -2,13 +2,13 @@ import type { PoolConnection } from 'better-sqlite-pool' import { acquireConnection } from './pool.js' -export interface AddWorkOrderContractOccupancyForm { +export interface AddForm { workOrderId: number | string contractId: number | string } export default async function addWorkOrderContract( - addForm: AddWorkOrderContractOccupancyForm, + addForm: AddForm, user: User, connectedDatabase?: PoolConnection ): Promise { diff --git a/database/deleteContractFee.js b/database/deleteContractFee.js index 8ad368f5..39c306d7 100644 --- a/database/deleteContractFee.js +++ b/database/deleteContractFee.js @@ -2,7 +2,7 @@ import { acquireConnection } from './pool.js'; export default async function deleteContractFee(contractId, feeId, user) { const database = await acquireConnection(); const result = database - .prepare(`update BurialSteContractFees + .prepare(`update ContractFees set recordDelete_userName = ?, recordDelete_timeMillis = ? where contractId = ? diff --git a/database/deleteContractFee.ts b/database/deleteContractFee.ts index ebf26015..737b8458 100644 --- a/database/deleteContractFee.ts +++ b/database/deleteContractFee.ts @@ -9,7 +9,7 @@ export default async function deleteContractFee( const result = database .prepare( - `update BurialSteContractFees + `update ContractFees set recordDelete_userName = ?, recordDelete_timeMillis = ? where contractId = ? diff --git a/database/getContract.js b/database/getContract.js index f6b02241..ffcfa9d2 100644 --- a/database/getContract.js +++ b/database/getContract.js @@ -21,12 +21,15 @@ export default async function getContract(contractId, connectedDatabase) { o.purchaserCity, o.purchaserProvince, o.purchaserPostalCode, o.purchaserPhoneNumber, o.purchaserEmail, o.purchaserRelationship, o.funeralHomeId, o.funeralDirectorName, + 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.committalTypeId, c.committalType, o.recordUpdate_timeMillis from Contracts o left join ContractTypes t on o.contractTypeId = t.contractTypeId + left join FuneralHomes f on o.funeralHomeId = f.funeralHomeId left join CommittalTypes c on o.committalTypeId = c.committalTypeId left join BurialSites l on o.burialSiteId = l.burialSiteId left join Cemeteries m on l.cemeteryId = m.cemeteryId diff --git a/database/getContract.ts b/database/getContract.ts index 00e28b5a..f274c2cc 100644 --- a/database/getContract.ts +++ b/database/getContract.ts @@ -32,12 +32,15 @@ export default async function getContract( o.purchaserCity, o.purchaserProvince, o.purchaserPostalCode, o.purchaserPhoneNumber, o.purchaserEmail, o.purchaserRelationship, o.funeralHomeId, o.funeralDirectorName, + 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.committalTypeId, c.committalType, o.recordUpdate_timeMillis from Contracts o left join ContractTypes t on o.contractTypeId = t.contractTypeId + left join FuneralHomes f on o.funeralHomeId = f.funeralHomeId left join CommittalTypes c on o.committalTypeId = c.committalTypeId left join BurialSites l on o.burialSiteId = l.burialSiteId left join Cemeteries m on l.cemeteryId = m.cemeteryId diff --git a/database/getContracts.d.ts b/database/getContracts.d.ts index b6dd8b37..71fa231b 100644 --- a/database/getContracts.d.ts +++ b/database/getContracts.d.ts @@ -3,10 +3,10 @@ import type { PoolConnection } from 'better-sqlite-pool'; import type { Contract } from '../types/recordTypes.js'; export interface GetContractsFilters { burialSiteId?: number | string; - occupancyTime?: '' | 'past' | 'current' | 'future'; + contractTime?: '' | 'past' | 'current' | 'future'; contractStartDateString?: DateString; - occupancyEffectiveDateString?: string; - occupantName?: string; + contractEffectiveDateString?: string; + deceasedName?: string; contractTypeId?: number | string; cemeteryId?: number | string; burialSiteNameSearchType?: '' | 'startsWith' | 'endsWith'; diff --git a/database/getContracts.js b/database/getContracts.js index 71245b84..c31816e1 100644 --- a/database/getContracts.js +++ b/database/getContracts.js @@ -1,7 +1,7 @@ import { dateIntegerToString, dateStringToInteger, timeIntegerToString } from '@cityssm/utils-datetime'; import { getConfigProperty } from '../helpers/config.helpers.js'; import { getContractTypeById } from '../helpers/functions.cache.js'; -import { getBurialSiteNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js'; +import { getBurialSiteNameWhereClause, getContractTimeWhereClause, getDeceasedNameWhereClause, } from '../helpers/functions.sqlFilters.js'; import getContractFees from './getContractFees.js'; import getContractInterments from './getContractInterments.js'; import getContractTransactions from './getContractTransactions.js'; @@ -16,31 +16,31 @@ function buildWhereClause(filters) { const burialSiteNameFilters = getBurialSiteNameWhereClause(filters.burialSiteName, filters.burialSiteNameSearchType ?? '', 'l'); sqlWhereClause += burialSiteNameFilters.sqlWhereClause; sqlParameters.push(...burialSiteNameFilters.sqlParameters); - const occupantNameFilters = getOccupantNameWhereClause(filters.occupantName, 'o'); - if (occupantNameFilters.sqlParameters.length > 0) { + const deceasedNameFilters = getDeceasedNameWhereClause(filters.deceasedName, 'o'); + if (deceasedNameFilters.sqlParameters.length > 0) { sqlWhereClause += ` and o.contractId in ( - select contractId from LotOccupancyOccupants o + select contractId from ContractInterments o where recordDelete_timeMillis is null - ${occupantNameFilters.sqlWhereClause})`; - sqlParameters.push(...occupantNameFilters.sqlParameters); + ${deceasedNameFilters.sqlWhereClause})`; + sqlParameters.push(...deceasedNameFilters.sqlParameters); } if ((filters.contractTypeId ?? '') !== '') { sqlWhereClause += ' and o.contractTypeId = ?'; sqlParameters.push(filters.contractTypeId); } - const occupancyTimeFilters = getOccupancyTimeWhereClause(filters.occupancyTime ?? '', 'o'); - sqlWhereClause += occupancyTimeFilters.sqlWhereClause; - sqlParameters.push(...occupancyTimeFilters.sqlParameters); + const contractTimeFilters = getContractTimeWhereClause(filters.contractTime ?? '', 'o'); + sqlWhereClause += contractTimeFilters.sqlWhereClause; + sqlParameters.push(...contractTimeFilters.sqlParameters); if ((filters.contractStartDateString ?? '') !== '') { sqlWhereClause += ' and o.contractStartDate = ?'; sqlParameters.push(dateStringToInteger(filters.contractStartDateString)); } - if ((filters.occupancyEffectiveDateString ?? '') !== '') { + if ((filters.contractEffectiveDateString ?? '') !== '') { sqlWhereClause += ` and ( o.contractEndDate is null or (o.contractStartDate <= ? and o.contractEndDate >= ?) )`; - sqlParameters.push(dateStringToInteger(filters.occupancyEffectiveDateString), dateStringToInteger(filters.occupancyEffectiveDateString)); + sqlParameters.push(dateStringToInteger(filters.contractEffectiveDateString), dateStringToInteger(filters.contractEffectiveDateString)); } if ((filters.cemeteryId ?? '') !== '') { sqlWhereClause += ' and l.cemeteryId = ?'; diff --git a/database/getContracts.ts b/database/getContracts.ts index 5976085e..a48948bd 100644 --- a/database/getContracts.ts +++ b/database/getContracts.ts @@ -10,8 +10,8 @@ import { getConfigProperty } from '../helpers/config.helpers.js' import { getContractTypeById } from '../helpers/functions.cache.js' import { getBurialSiteNameWhereClause, - getOccupancyTimeWhereClause, - getOccupantNameWhereClause + getContractTimeWhereClause, + getDeceasedNameWhereClause, } from '../helpers/functions.sqlFilters.js' import type { Contract } from '../types/recordTypes.js' @@ -22,10 +22,10 @@ import { acquireConnection } from './pool.js' export interface GetContractsFilters { burialSiteId?: number | string - occupancyTime?: '' | 'past' | 'current' | 'future' + contractTime?: '' | 'past' | 'current' | 'future' contractStartDateString?: DateString - occupancyEffectiveDateString?: string - occupantName?: string + contractEffectiveDateString?: string + deceasedName?: string contractTypeId?: number | string cemeteryId?: number | string burialSiteNameSearchType?: '' | 'startsWith' | 'endsWith' @@ -64,16 +64,16 @@ function buildWhereClause(filters: GetContractsFilters): { sqlWhereClause += burialSiteNameFilters.sqlWhereClause sqlParameters.push(...burialSiteNameFilters.sqlParameters) - const occupantNameFilters = getOccupantNameWhereClause( - filters.occupantName, + const deceasedNameFilters = getDeceasedNameWhereClause( + filters.deceasedName, 'o' ) - if (occupantNameFilters.sqlParameters.length > 0) { + if (deceasedNameFilters.sqlParameters.length > 0) { sqlWhereClause += ` and o.contractId in ( - select contractId from LotOccupancyOccupants o + select contractId from ContractInterments o where recordDelete_timeMillis is null - ${occupantNameFilters.sqlWhereClause})` - sqlParameters.push(...occupantNameFilters.sqlParameters) + ${deceasedNameFilters.sqlWhereClause})` + sqlParameters.push(...deceasedNameFilters.sqlParameters) } if ((filters.contractTypeId ?? '') !== '') { @@ -81,12 +81,12 @@ function buildWhereClause(filters: GetContractsFilters): { sqlParameters.push(filters.contractTypeId) } - const occupancyTimeFilters = getOccupancyTimeWhereClause( - filters.occupancyTime ?? '', + const contractTimeFilters = getContractTimeWhereClause( + filters.contractTime ?? '', 'o' ) - sqlWhereClause += occupancyTimeFilters.sqlWhereClause - sqlParameters.push(...occupancyTimeFilters.sqlParameters) + sqlWhereClause += contractTimeFilters.sqlWhereClause + sqlParameters.push(...contractTimeFilters.sqlParameters) if ((filters.contractStartDateString ?? '') !== '') { sqlWhereClause += ' and o.contractStartDate = ?' @@ -95,14 +95,14 @@ function buildWhereClause(filters: GetContractsFilters): { ) } - if ((filters.occupancyEffectiveDateString ?? '') !== '') { + if ((filters.contractEffectiveDateString ?? '') !== '') { sqlWhereClause += ` and ( o.contractEndDate is null or (o.contractStartDate <= ? and o.contractEndDate >= ?) )` sqlParameters.push( - dateStringToInteger(filters.occupancyEffectiveDateString as DateString), - dateStringToInteger(filters.occupancyEffectiveDateString as DateString) + dateStringToInteger(filters.contractEffectiveDateString as DateString), + dateStringToInteger(filters.contractEffectiveDateString as DateString) ) } diff --git a/database/getWorkOrderComments.js b/database/getWorkOrderComments.js index 87dbcaa5..36ca3cf8 100644 --- a/database/getWorkOrderComments.js +++ b/database/getWorkOrderComments.js @@ -7,16 +7,16 @@ export default async function getWorkOrderComments(workOrderId, connectedDatabas database.function('userFn_timeIntegerToPeriodString', timeIntegerToPeriodString); const workOrderComments = database .prepare(`select workOrderCommentId, - workOrderCommentDate, userFn_dateIntegerToString(workOrderCommentDate) as workOrderCommentDateString, - workOrderCommentTime, - userFn_timeIntegerToString(workOrderCommentTime) as workOrderCommentTimeString, - userFn_timeIntegerToPeriodString(workOrderCommentTime) as workOrderCommentTimePeriodString, - workOrderComment, + commentDate, userFn_dateIntegerToString(commentDate) as commentDateString, + commentTime, + userFn_timeIntegerToString(commentTime) as commentTimeString, + userFn_timeIntegerToPeriodString(commentTime) as commentTimePeriodString, + comment, recordCreate_userName, recordUpdate_userName from WorkOrderComments where recordDelete_timeMillis is null and workOrderId = ? - order by workOrderCommentDate desc, workOrderCommentTime desc, workOrderCommentId desc`) + order by commentDate desc, commentTime desc, workOrderCommentId desc`) .all(workOrderId); if (connectedDatabase === undefined) { database.release(); diff --git a/database/getWorkOrderComments.ts b/database/getWorkOrderComments.ts index 4acb3afe..eae61b9d 100644 --- a/database/getWorkOrderComments.ts +++ b/database/getWorkOrderComments.ts @@ -25,16 +25,16 @@ export default async function getWorkOrderComments( const workOrderComments = database .prepare( `select workOrderCommentId, - workOrderCommentDate, userFn_dateIntegerToString(workOrderCommentDate) as workOrderCommentDateString, - workOrderCommentTime, - userFn_timeIntegerToString(workOrderCommentTime) as workOrderCommentTimeString, - userFn_timeIntegerToPeriodString(workOrderCommentTime) as workOrderCommentTimePeriodString, - workOrderComment, + commentDate, userFn_dateIntegerToString(commentDate) as commentDateString, + commentTime, + userFn_timeIntegerToString(commentTime) as commentTimeString, + userFn_timeIntegerToPeriodString(commentTime) as commentTimePeriodString, + comment, recordCreate_userName, recordUpdate_userName from WorkOrderComments where recordDelete_timeMillis is null and workOrderId = ? - order by workOrderCommentDate desc, workOrderCommentTime desc, workOrderCommentId desc` + order by commentDate desc, commentTime desc, workOrderCommentId desc` ) .all(workOrderId) as WorkOrderComment[] diff --git a/database/getWorkOrders.d.ts b/database/getWorkOrders.d.ts index dce60c27..f7e832bb 100644 --- a/database/getWorkOrders.d.ts +++ b/database/getWorkOrders.d.ts @@ -4,7 +4,7 @@ export interface GetWorkOrdersFilters { workOrderTypeId?: number | string; workOrderOpenStatus?: '' | 'open' | 'closed'; workOrderOpenDateString?: string; - occupantName?: string; + deceasedName?: string; burialSiteName?: string; contractId?: number | string; } diff --git a/database/getWorkOrders.js b/database/getWorkOrders.js index 7f8de6c9..df3f780b 100644 --- a/database/getWorkOrders.js +++ b/database/getWorkOrders.js @@ -1,7 +1,7 @@ import { dateIntegerToString, dateStringToInteger } from '@cityssm/utils-datetime'; -import { getBurialSiteNameWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js'; -import getContracts from './getContracts.js'; +import { getBurialSiteNameWhereClause, getDeceasedNameWhereClause } from '../helpers/functions.sqlFilters.js'; import getBurialSites from './getBurialSites.js'; +import getContracts from './getContracts.js'; import getWorkOrderComments from './getWorkOrderComments.js'; import getWorkOrderMilestones from './getWorkOrderMilestones.js'; import { acquireConnection } from './pool.js'; @@ -24,17 +24,17 @@ function buildWhereClause(filters) { sqlWhereClause += ' and w.workOrderOpenDate = ?'; sqlParameters.push(dateStringToInteger(filters.workOrderOpenDateString)); } - const occupantNameFilters = getOccupantNameWhereClause(filters.occupantName, 'o'); - if (occupantNameFilters.sqlParameters.length > 0) { + const deceasedNameFilters = getDeceasedNameWhereClause(filters.deceasedName, 'o'); + if (deceasedNameFilters.sqlParameters.length > 0) { sqlWhereClause += ` and w.workOrderId in ( select workOrderId from WorkOrderContracts o where recordDelete_timeMillis is null and o.contractId in ( - select contractId from LotOccupancyOccupants o where recordDelete_timeMillis is null - ${occupantNameFilters.sqlWhereClause} + select contractId from ContractInterments o where recordDelete_timeMillis is null + ${deceasedNameFilters.sqlWhereClause} ))`; - sqlParameters.push(...occupantNameFilters.sqlParameters); + sqlParameters.push(...deceasedNameFilters.sqlParameters); } const burialSiteNameFilters = getBurialSiteNameWhereClause(filters.burialSiteName, '', 'l'); if (burialSiteNameFilters.sqlParameters.length > 0) { @@ -119,7 +119,7 @@ export async function getWorkOrders(filters, options, connectedDatabase) { w.workOrderCloseDate, userFn_dateIntegerToString(w.workOrderCloseDate) as workOrderCloseDateString, ifnull(m.workOrderMilestoneCount, 0) as workOrderMilestoneCount, ifnull(m.workOrderMilestoneCompletionCount, 0) as workOrderMilestoneCompletionCount, - ifnull(l.workOrderLotCount, 0) as workOrderLotCount + ifnull(l.workOrderBurialSiteCount, 0) as workOrderBurialSiteCount from WorkOrders w left join WorkOrderTypes t on w.workOrderTypeId = t.workOrderTypeId left join ( @@ -130,8 +130,8 @@ export async function getWorkOrders(filters, options, connectedDatabase) { where recordDelete_timeMillis is null group by workOrderId) m on w.workOrderId = m.workOrderId left join ( - select workOrderId, count(burialSiteId) as workOrderLotCount - from WorkOrderLots + select workOrderId, count(burialSiteId) as workOrderBurialSiteCount + from WorkOrderBurialSites where recordDelete_timeMillis is null group by workOrderId) l on w.workOrderId = l.workOrderId ${sqlWhereClause} diff --git a/database/getWorkOrders.ts b/database/getWorkOrders.ts index fcafa68d..b21255d2 100644 --- a/database/getWorkOrders.ts +++ b/database/getWorkOrders.ts @@ -7,12 +7,12 @@ import type { PoolConnection } from 'better-sqlite-pool' import { getBurialSiteNameWhereClause, - getOccupantNameWhereClause + getDeceasedNameWhereClause } from '../helpers/functions.sqlFilters.js' import type { WorkOrder } from '../types/recordTypes.js' -import getContracts from './getContracts.js' import getBurialSites from './getBurialSites.js' +import getContracts from './getContracts.js' import getWorkOrderComments from './getWorkOrderComments.js' import getWorkOrderMilestones from './getWorkOrderMilestones.js' import { acquireConnection } from './pool.js' @@ -21,7 +21,7 @@ export interface GetWorkOrdersFilters { workOrderTypeId?: number | string workOrderOpenStatus?: '' | 'open' | 'closed' workOrderOpenDateString?: string - occupantName?: string + deceasedName?: string burialSiteName?: string contractId?: number | string } @@ -61,20 +61,20 @@ function buildWhereClause(filters: GetWorkOrdersFilters): { ) } - const occupantNameFilters = getOccupantNameWhereClause( - filters.occupantName, + const deceasedNameFilters = getDeceasedNameWhereClause( + filters.deceasedName, 'o' ) - if (occupantNameFilters.sqlParameters.length > 0) { + if (deceasedNameFilters.sqlParameters.length > 0) { sqlWhereClause += ` and w.workOrderId in ( select workOrderId from WorkOrderContracts o where recordDelete_timeMillis is null and o.contractId in ( - select contractId from LotOccupancyOccupants o where recordDelete_timeMillis is null - ${occupantNameFilters.sqlWhereClause} + select contractId from ContractInterments o where recordDelete_timeMillis is null + ${deceasedNameFilters.sqlWhereClause} ))` - sqlParameters.push(...occupantNameFilters.sqlParameters) + sqlParameters.push(...deceasedNameFilters.sqlParameters) } const burialSiteNameFilters = getBurialSiteNameWhereClause(filters.burialSiteName, '', 'l') @@ -202,7 +202,7 @@ export async function getWorkOrders( w.workOrderCloseDate, userFn_dateIntegerToString(w.workOrderCloseDate) as workOrderCloseDateString, ifnull(m.workOrderMilestoneCount, 0) as workOrderMilestoneCount, ifnull(m.workOrderMilestoneCompletionCount, 0) as workOrderMilestoneCompletionCount, - ifnull(l.workOrderLotCount, 0) as workOrderLotCount + ifnull(l.workOrderBurialSiteCount, 0) as workOrderBurialSiteCount from WorkOrders w left join WorkOrderTypes t on w.workOrderTypeId = t.workOrderTypeId left join ( @@ -213,8 +213,8 @@ export async function getWorkOrders( where recordDelete_timeMillis is null group by workOrderId) m on w.workOrderId = m.workOrderId left join ( - select workOrderId, count(burialSiteId) as workOrderLotCount - from WorkOrderLots + select workOrderId, count(burialSiteId) as workOrderBurialSiteCount + from WorkOrderBurialSites where recordDelete_timeMillis is null group by workOrderId) l on w.workOrderId = l.workOrderId ${sqlWhereClause} diff --git a/database/initializeDatabase.js b/database/initializeDatabase.js index a0eeb8c1..53bdff0c 100644 --- a/database/initializeDatabase.js +++ b/database/initializeDatabase.js @@ -231,7 +231,7 @@ const createStatements = [ contractId integer not null, intermentNumber integer not null, - deceasedName varchar(50) not null, + deceasedName varchar(200) not null, isCremated bit not null default 0, deceasedAddress1 varchar(50), diff --git a/database/initializeDatabase.ts b/database/initializeDatabase.ts index afa23ee8..9d1bb88a 100644 --- a/database/initializeDatabase.ts +++ b/database/initializeDatabase.ts @@ -270,7 +270,7 @@ const createStatements = [ contractId integer not null, intermentNumber integer not null, - deceasedName varchar(50) not null, + deceasedName varchar(200) not null, isCremated bit not null default 0, deceasedAddress1 varchar(50), diff --git a/database/updateContractInterment.d.ts b/database/updateContractInterment.d.ts new file mode 100644 index 00000000..ef9b3de6 --- /dev/null +++ b/database/updateContractInterment.d.ts @@ -0,0 +1,17 @@ +import { type DateString } from '@cityssm/utils-datetime'; +export interface UpdateForm { + contractId: string | number; + intermentNumber: string | number; + deceasedName: string; + deceasedAddress1: string; + deceasedAddress2: string; + deceasedCity: string; + deceasedProvince: string; + deceasedPostalCode: string; + birthDateString: DateString | ''; + birthPlace: string; + deathDateString: DateString | ''; + deathPlace: string; + intermentContainerTypeId: string | number; +} +export default function updateContractInterment(contractForm: UpdateForm, user: User): Promise; diff --git a/database/updateContractInterment.js b/database/updateContractInterment.js new file mode 100644 index 00000000..497180ef --- /dev/null +++ b/database/updateContractInterment.js @@ -0,0 +1,32 @@ +import { dateStringToInteger } from '@cityssm/utils-datetime'; +import { acquireConnection } from './pool.js'; +export default async function updateContractInterment(contractForm, user) { + const database = await acquireConnection(); + const results = database + .prepare(`update ContractInterments + set deceasedName = ?, + deceasedAddress1 = ?, + deceasedAddress2 = ?, + deceasedCity = ?, + deceasedProvince = ?, + deceasedPostalCode = ?, + birthDate = ?, + birthPlace = ?, + deathDate = ?, + deathPlace = ?, + intermentContainerTypeId = ?, + recordUpdate_userName = ?, + recordUpdate_timeMillis = ? + where recordDelete_timeMillis is null + and contractId = ? + and intermentNumber = ?`) + .run(contractForm.deceasedName, contractForm.deceasedAddress1, contractForm.deceasedAddress2, contractForm.deceasedCity, contractForm.deceasedProvince, contractForm.deceasedPostalCode, contractForm.birthDateString === '' + ? undefined + : dateStringToInteger(contractForm.birthDateString), contractForm.birthPlace, contractForm.deathDateString === '' + ? undefined + : dateStringToInteger(contractForm.deathDateString), contractForm.deathPlace, contractForm.intermentContainerTypeId === '' + ? undefined + : contractForm.intermentContainerTypeId, user.userName, Date.now(), contractForm.contractId, contractForm.intermentNumber); + database.release(); + return results.changes > 0; +} diff --git a/database/updateContractInterment.ts b/database/updateContractInterment.ts new file mode 100644 index 00000000..38bce77b --- /dev/null +++ b/database/updateContractInterment.ts @@ -0,0 +1,74 @@ +import { type DateString, dateStringToInteger } from '@cityssm/utils-datetime' + +import { acquireConnection } from './pool.js' + +export interface UpdateForm { + contractId: string | number + intermentNumber: string | number + deceasedName: string + deceasedAddress1: string + deceasedAddress2: string + deceasedCity: string + deceasedProvince: string + deceasedPostalCode: string + birthDateString: DateString | '' + birthPlace: string + deathDateString: DateString | '' + deathPlace: string + intermentContainerTypeId: string | number +} + +export default async function updateContractInterment( + contractForm: UpdateForm, + user: User +): Promise { + const database = await acquireConnection() + + const results = database + .prepare( + `update ContractInterments + set deceasedName = ?, + deceasedAddress1 = ?, + deceasedAddress2 = ?, + deceasedCity = ?, + deceasedProvince = ?, + deceasedPostalCode = ?, + birthDate = ?, + birthPlace = ?, + deathDate = ?, + deathPlace = ?, + intermentContainerTypeId = ?, + recordUpdate_userName = ?, + recordUpdate_timeMillis = ? + where recordDelete_timeMillis is null + and contractId = ? + and intermentNumber = ?` + ) + .run( + contractForm.deceasedName, + contractForm.deceasedAddress1, + contractForm.deceasedAddress2, + contractForm.deceasedCity, + contractForm.deceasedProvince, + contractForm.deceasedPostalCode, + contractForm.birthDateString === '' + ? undefined + : dateStringToInteger(contractForm.birthDateString), + contractForm.birthPlace, + contractForm.deathDateString === '' + ? undefined + : dateStringToInteger(contractForm.deathDateString), + contractForm.deathPlace, + contractForm.intermentContainerTypeId === '' + ? undefined + : contractForm.intermentContainerTypeId, + user.userName, + Date.now(), + contractForm.contractId, + contractForm.intermentNumber + ) + + database.release() + + return results.changes > 0 +} diff --git a/database/updateLotOccupancyOccupant.d.ts b/database/updateLotOccupancyOccupant.d.ts deleted file mode 100644 index 2ba973a0..00000000 --- a/database/updateLotOccupancyOccupant.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -export interface UpdateLotOccupancyOccupantForm { - contractId: string | number; - lotOccupantIndex: string | number; - lotOccupantTypeId: string | number; - occupantName: string; - occupantFamilyName: string; - occupantAddress1: string; - occupantAddress2: string; - occupantCity: string; - occupantProvince: string; - occupantPostalCode: string; - occupantPhoneNumber: string; - occupantEmailAddress: string; - occupantComment: string; -} -export default function updateContractOccupant(contractOccupantForm: UpdateLotOccupancyOccupantForm, user: User): Promise; diff --git a/database/updateLotOccupancyOccupant.js b/database/updateLotOccupancyOccupant.js deleted file mode 100644 index e74fc32d..00000000 --- a/database/updateLotOccupancyOccupant.js +++ /dev/null @@ -1,25 +0,0 @@ -import { acquireConnection } from './pool.js'; -export default async function updateContractOccupant(contractOccupantForm, user) { - const database = await acquireConnection(); - const results = database - .prepare(`update LotOccupancyOccupants - set occupantName = ?, - occupantFamilyName = ?, - occupantAddress1 = ?, - occupantAddress2 = ?, - occupantCity = ?, - occupantProvince = ?, - occupantPostalCode = ?, - occupantPhoneNumber = ?, - occupantEmailAddress = ?, - occupantComment = ?, - lotOccupantTypeId = ?, - recordUpdate_userName = ?, - recordUpdate_timeMillis = ? - where recordDelete_timeMillis is null - and contractId = ? - and lotOccupantIndex = ?`) - .run(contractOccupantForm.occupantName, contractOccupantForm.occupantFamilyName, contractOccupantForm.occupantAddress1, contractOccupantForm.occupantAddress2, contractOccupantForm.occupantCity, contractOccupantForm.occupantProvince, contractOccupantForm.occupantPostalCode, contractOccupantForm.occupantPhoneNumber, contractOccupantForm.occupantEmailAddress, contractOccupantForm.occupantComment, contractOccupantForm.lotOccupantTypeId, user.userName, Date.now(), contractOccupantForm.contractId, contractOccupantForm.lotOccupantIndex); - database.release(); - return results.changes > 0; -} diff --git a/database/updateLotOccupancyOccupant.ts b/database/updateLotOccupancyOccupant.ts deleted file mode 100644 index be2d0e07..00000000 --- a/database/updateLotOccupancyOccupant.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { acquireConnection } from './pool.js' - -export interface UpdateLotOccupancyOccupantForm { - contractId: string | number - lotOccupantIndex: string | number - lotOccupantTypeId: string | number - occupantName: string - occupantFamilyName: string - occupantAddress1: string - occupantAddress2: string - occupantCity: string - occupantProvince: string - occupantPostalCode: string - occupantPhoneNumber: string - occupantEmailAddress: string - occupantComment: string -} - -export default async function updateContractOccupant( - contractOccupantForm: UpdateLotOccupancyOccupantForm, - user: User -): Promise { - const database = await acquireConnection() - - const results = database - .prepare( - `update LotOccupancyOccupants - set occupantName = ?, - occupantFamilyName = ?, - occupantAddress1 = ?, - occupantAddress2 = ?, - occupantCity = ?, - occupantProvince = ?, - occupantPostalCode = ?, - occupantPhoneNumber = ?, - occupantEmailAddress = ?, - occupantComment = ?, - lotOccupantTypeId = ?, - recordUpdate_userName = ?, - recordUpdate_timeMillis = ? - where recordDelete_timeMillis is null - and contractId = ? - and lotOccupantIndex = ?` - ) - .run( - contractOccupantForm.occupantName, - contractOccupantForm.occupantFamilyName, - contractOccupantForm.occupantAddress1, - contractOccupantForm.occupantAddress2, - contractOccupantForm.occupantCity, - contractOccupantForm.occupantProvince, - contractOccupantForm.occupantPostalCode, - contractOccupantForm.occupantPhoneNumber, - contractOccupantForm.occupantEmailAddress, - contractOccupantForm.occupantComment, - contractOccupantForm.lotOccupantTypeId, - user.userName, - Date.now(), - contractOccupantForm.contractId, - contractOccupantForm.lotOccupantIndex - ) - - database.release() - - return results.changes > 0 -} diff --git a/database/updateWorkOrderComment.d.ts b/database/updateWorkOrderComment.d.ts index 3ea6a547..efeac9f5 100644 --- a/database/updateWorkOrderComment.d.ts +++ b/database/updateWorkOrderComment.d.ts @@ -1,8 +1,8 @@ import { type DateString, type TimeString } from '@cityssm/utils-datetime'; export interface UpdateWorkOrderCommentForm { workOrderCommentId: string | number; - workOrderCommentDateString: DateString; - workOrderCommentTimeString: TimeString; - workOrderComment: string; + commentDateString: DateString; + commentTimeString: TimeString; + comment: string; } export default function updateWorkOrderComment(commentForm: UpdateWorkOrderCommentForm, user: User): Promise; diff --git a/database/updateWorkOrderComment.js b/database/updateWorkOrderComment.js index 46b9082d..17de433e 100644 --- a/database/updateWorkOrderComment.js +++ b/database/updateWorkOrderComment.js @@ -4,14 +4,14 @@ export default async function updateWorkOrderComment(commentForm, user) { const database = await acquireConnection(); const result = database .prepare(`update WorkOrderComments - set workOrderCommentDate = ?, - workOrderCommentTime = ?, - workOrderComment = ?, + set commentDate = ?, + commentTime = ?, + comment = ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ? where recordDelete_timeMillis is null and workOrderCommentId = ?`) - .run(dateStringToInteger(commentForm.workOrderCommentDateString), timeStringToInteger(commentForm.workOrderCommentTimeString), commentForm.workOrderComment, user.userName, Date.now(), commentForm.workOrderCommentId); + .run(dateStringToInteger(commentForm.commentDateString), timeStringToInteger(commentForm.commentTimeString), commentForm.comment, user.userName, Date.now(), commentForm.workOrderCommentId); database.release(); return result.changes > 0; } diff --git a/database/updateWorkOrderComment.ts b/database/updateWorkOrderComment.ts index b0c18371..ad865c17 100644 --- a/database/updateWorkOrderComment.ts +++ b/database/updateWorkOrderComment.ts @@ -9,9 +9,9 @@ import { acquireConnection } from './pool.js' export interface UpdateWorkOrderCommentForm { workOrderCommentId: string | number - workOrderCommentDateString: DateString - workOrderCommentTimeString: TimeString - workOrderComment: string + commentDateString: DateString + commentTimeString: TimeString + comment: string } export default async function updateWorkOrderComment( @@ -23,18 +23,18 @@ export default async function updateWorkOrderComment( const result = database .prepare( `update WorkOrderComments - set workOrderCommentDate = ?, - workOrderCommentTime = ?, - workOrderComment = ?, + set commentDate = ?, + commentTime = ?, + comment = ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ? where recordDelete_timeMillis is null and workOrderCommentId = ?` ) .run( - dateStringToInteger(commentForm.workOrderCommentDateString), - timeStringToInteger(commentForm.workOrderCommentTimeString), - commentForm.workOrderComment, + dateStringToInteger(commentForm.commentDateString), + timeStringToInteger(commentForm.commentTimeString), + commentForm.comment, user.userName, Date.now(), commentForm.workOrderCommentId diff --git a/handlers/contracts-post/doAddContractInterment.d.ts b/handlers/contracts-post/doAddContractInterment.d.ts new file mode 100644 index 00000000..3c0ca003 --- /dev/null +++ b/handlers/contracts-post/doAddContractInterment.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type AddForm } from '../../database/addContractInterment.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doAddContractInterment.js b/handlers/contracts-post/doAddContractInterment.js new file mode 100644 index 00000000..7b1835d0 --- /dev/null +++ b/handlers/contracts-post/doAddContractInterment.js @@ -0,0 +1,10 @@ +import addContractInterment from '../../database/addContractInterment.js'; +import getContractInterments from '../../database/getContractInterments.js'; +export default async function handler(request, response) { + await addContractInterment(request.body, request.session.user); + const contractInterments = await getContractInterments(request.body.contractId); + response.json({ + success: true, + contractInterments + }); +} diff --git a/handlers/contracts-post/doAddContractInterment.ts b/handlers/contracts-post/doAddContractInterment.ts new file mode 100644 index 00000000..6c35b227 --- /dev/null +++ b/handlers/contracts-post/doAddContractInterment.ts @@ -0,0 +1,22 @@ +import type { Request, Response } from 'express' + +import addContractInterment, { + type AddForm +} from '../../database/addContractInterment.js' +import getContractInterments from '../../database/getContractInterments.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + await addContractInterment(request.body, request.session.user as User) + + const contractInterments = await getContractInterments( + request.body.contractId + ) + + response.json({ + success: true, + contractInterments + }) +} diff --git a/handlers/contracts-post/doDeleteContractInterment.d.ts b/handlers/contracts-post/doDeleteContractInterment.d.ts new file mode 100644 index 00000000..2c0a449a --- /dev/null +++ b/handlers/contracts-post/doDeleteContractInterment.d.ts @@ -0,0 +1,5 @@ +import type { Request, Response } from 'express'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doDeleteContractInterment.js b/handlers/contracts-post/doDeleteContractInterment.js new file mode 100644 index 00000000..de50e30c --- /dev/null +++ b/handlers/contracts-post/doDeleteContractInterment.js @@ -0,0 +1,10 @@ +import deleteContractInterment from '../../database/deleteContractInterment.js'; +import getContractInterments from '../../database/getContractInterments.js'; +export default async function handler(request, response) { + const success = await deleteContractInterment(request.body.contractId, request.body.intermentNumber, request.session.user); + const contractInterments = await getContractInterments(request.body.contractId); + response.json({ + success, + contractInterments + }); +} diff --git a/handlers/contracts-post/doDeleteContractInterment.ts b/handlers/contracts-post/doDeleteContractInterment.ts new file mode 100644 index 00000000..9242dd49 --- /dev/null +++ b/handlers/contracts-post/doDeleteContractInterment.ts @@ -0,0 +1,28 @@ +import type { Request, Response } from 'express' + +import deleteContractInterment from '../../database/deleteContractInterment.js' +import getContractInterments from '../../database/getContractInterments.js' + +export default async function handler( + request: Request< + unknown, + unknown, + { contractId: string; intermentNumber: string } + >, + response: Response +): Promise { + const success = await deleteContractInterment( + request.body.contractId, + request.body.intermentNumber, + request.session.user as User + ) + + const contractInterments = await getContractInterments( + request.body.contractId + ) + + response.json({ + success, + contractInterments + }) +} diff --git a/handlers/contracts-post/doUpdateContractInterment.d.ts b/handlers/contracts-post/doUpdateContractInterment.d.ts new file mode 100644 index 00000000..f40b8fa2 --- /dev/null +++ b/handlers/contracts-post/doUpdateContractInterment.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type UpdateForm } from '../../database/updateContractInterment.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doUpdateContractInterment.js b/handlers/contracts-post/doUpdateContractInterment.js new file mode 100644 index 00000000..72482211 --- /dev/null +++ b/handlers/contracts-post/doUpdateContractInterment.js @@ -0,0 +1,10 @@ +import getContractInterments from '../../database/getContractInterments.js'; +import updateContractInterment from '../../database/updateContractInterment.js'; +export default async function handler(request, response) { + await updateContractInterment(request.body, request.session.user); + const contractInterments = await getContractInterments(request.body.contractId); + response.json({ + success: true, + contractInterments + }); +} diff --git a/handlers/contracts-post/doUpdateContractInterment.ts b/handlers/contracts-post/doUpdateContractInterment.ts new file mode 100644 index 00000000..ca689fd9 --- /dev/null +++ b/handlers/contracts-post/doUpdateContractInterment.ts @@ -0,0 +1,24 @@ +import type { Request, Response } from 'express' + +import getContractInterments from '../../database/getContractInterments.js' +import updateContractInterment, { + type UpdateForm +} from '../../database/updateContractInterment.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + await updateContractInterment( + request.body, + request.session.user as User + ) + + const contractInterments = + await getContractInterments(request.body.contractId) + + response.json({ + success: true, + contractInterments + }) +} diff --git a/handlers/workOrders-get/edit.js b/handlers/workOrders-get/edit.js index bb35f305..bca16425 100644 --- a/handlers/workOrders-get/edit.js +++ b/handlers/workOrders-get/edit.js @@ -17,13 +17,13 @@ export default async function handler(request, response) { } const workOrderTypes = await getWorkOrderTypes(); const workOrderMilestoneTypes = await getWorkOrderMilestoneTypes(); - const lotStatuses = await getBurialSiteStatuses(); + const burialSiteStatuses = await getBurialSiteStatuses(); response.render('workOrder-edit', { headTitle: `Work Order #${workOrder.workOrderNumber}`, workOrder, isCreate: false, workOrderTypes, workOrderMilestoneTypes, - lotStatuses + burialSiteStatuses }); } diff --git a/handlers/workOrders-get/edit.ts b/handlers/workOrders-get/edit.ts index 69aa90c9..a5142fc0 100644 --- a/handlers/workOrders-get/edit.ts +++ b/handlers/workOrders-get/edit.ts @@ -40,7 +40,7 @@ export default async function handler( const workOrderMilestoneTypes = await getWorkOrderMilestoneTypes() - const lotStatuses = await getBurialSiteStatuses() + const burialSiteStatuses = await getBurialSiteStatuses() response.render('workOrder-edit', { headTitle: `Work Order #${workOrder.workOrderNumber}`, @@ -48,6 +48,6 @@ export default async function handler( isCreate: false, workOrderTypes, workOrderMilestoneTypes, - lotStatuses + burialSiteStatuses }) } diff --git a/handlers/workOrders-post/doAddWorkOrderBurialSite.js b/handlers/workOrders-post/doAddWorkOrderBurialSite.js index 24f9a2d2..1c5b6e12 100644 --- a/handlers/workOrders-post/doAddWorkOrderBurialSite.js +++ b/handlers/workOrders-post/doAddWorkOrderBurialSite.js @@ -5,7 +5,7 @@ export default async function handler(request, response) { workOrderId: request.body.workOrderId, burialSiteId: request.body.burialSiteId }, request.session.user); - const workOrderLotsResults = await getBurialSites({ + const results = await getBurialSites({ workOrderId: request.body.workOrderId }, { limit: -1, @@ -14,6 +14,6 @@ export default async function handler(request, response) { }); response.json({ success, - workOrderBurialSites: workOrderLotsResults.burialSites + workOrderBurialSites: results.burialSites }); } diff --git a/handlers/workOrders-post/doAddWorkOrderBurialSite.ts b/handlers/workOrders-post/doAddWorkOrderBurialSite.ts index 80dff2fd..1660bcc3 100644 --- a/handlers/workOrders-post/doAddWorkOrderBurialSite.ts +++ b/handlers/workOrders-post/doAddWorkOrderBurialSite.ts @@ -19,7 +19,7 @@ export default async function handler( request.session.user as User ) - const workOrderLotsResults = await getBurialSites( + const results = await getBurialSites( { workOrderId: request.body.workOrderId }, @@ -32,6 +32,6 @@ export default async function handler( response.json({ success, - workOrderBurialSites: workOrderLotsResults.burialSites + workOrderBurialSites: results.burialSites }) } diff --git a/helpers/functions.dynamicsGP.js b/helpers/functions.dynamicsGP.js index a815d63d..c8470a27 100644 --- a/helpers/functions.dynamicsGP.js +++ b/helpers/functions.dynamicsGP.js @@ -8,12 +8,14 @@ if (getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) { function filterCashReceipt(cashReceipt) { const accountCodes = getConfigProperty('settings.dynamicsGP.accountCodes'); if (accountCodes.length > 0) { - for (const detail of cashReceipt.details) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + for (const detail of cashReceipt?.details ?? []) { if (accountCodes.includes(detail.accountCode)) { return cashReceipt; } } - for (const distribution of cashReceipt.distributions) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + for (const distribution of cashReceipt?.distributions ?? []) { if (accountCodes.includes(distribution.accountCode)) { return cashReceipt; } diff --git a/helpers/functions.dynamicsGP.ts b/helpers/functions.dynamicsGP.ts index 2564c705..0b38284a 100644 --- a/helpers/functions.dynamicsGP.ts +++ b/helpers/functions.dynamicsGP.ts @@ -23,13 +23,15 @@ function filterCashReceipt( const accountCodes = getConfigProperty('settings.dynamicsGP.accountCodes') if (accountCodes.length > 0) { - for (const detail of cashReceipt.details) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + for (const detail of cashReceipt?.details ?? []) { if (accountCodes.includes(detail.accountCode)) { return cashReceipt } } - for (const distribution of cashReceipt.distributions) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + for (const distribution of cashReceipt?.distributions ?? []) { if (accountCodes.includes(distribution.accountCode)) { return cashReceipt } diff --git a/helpers/functions.sqlFilters.d.ts b/helpers/functions.sqlFilters.d.ts index 6df91203..679f35bf 100644 --- a/helpers/functions.sqlFilters.d.ts +++ b/helpers/functions.sqlFilters.d.ts @@ -4,7 +4,7 @@ interface WhereClauseReturn { sqlParameters: unknown[]; } export declare function getBurialSiteNameWhereClause(burialSiteName?: string, burialSiteNameSearchType?: BurialSiteNameSearchType, burialSitesTableAlias?: string): WhereClauseReturn; -type OccupancyTime = '' | 'current' | 'past' | 'future'; -export declare function getOccupancyTimeWhereClause(occupancyTime: OccupancyTime | undefined, lotOccupanciesTableAlias?: string): WhereClauseReturn; -export declare function getOccupantNameWhereClause(occupantName?: string, tableAlias?: string): WhereClauseReturn; +type ContractTime = '' | 'current' | 'past' | 'future'; +export declare function getContractTimeWhereClause(contractTime: ContractTime | undefined, contractsTableAlias?: string): WhereClauseReturn; +export declare function getDeceasedNameWhereClause(deceasedName?: string, tableAlias?: string): WhereClauseReturn; export {}; diff --git a/helpers/functions.sqlFilters.js b/helpers/functions.sqlFilters.js index dc01d2e1..a99a3671 100644 --- a/helpers/functions.sqlFilters.js +++ b/helpers/functions.sqlFilters.js @@ -33,27 +33,27 @@ export function getBurialSiteNameWhereClause(burialSiteName = '', burialSiteName sqlParameters }; } -export function getOccupancyTimeWhereClause(occupancyTime, lotOccupanciesTableAlias = 'o') { +export function getContractTimeWhereClause(contractTime, contractsTableAlias = 'o') { let sqlWhereClause = ''; const sqlParameters = []; const currentDateString = dateToInteger(new Date()); // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check - switch (occupancyTime ?? '') { + switch (contractTime ?? '') { case 'current': { - sqlWhereClause += ` and ${lotOccupanciesTableAlias}.contractStartDate <= ? - and (${lotOccupanciesTableAlias}.contractEndDate is null or ${lotOccupanciesTableAlias}.contractEndDate >= ?)`; + sqlWhereClause += ` and ${contractsTableAlias}.contractStartDate <= ? + and (${contractsTableAlias}.contractEndDate is null or ${contractsTableAlias}.contractEndDate >= ?)`; sqlParameters.push(currentDateString, currentDateString); break; } case 'past': { sqlWhereClause += - ` and ${lotOccupanciesTableAlias}.contractEndDate < ?`; + ` and ${contractsTableAlias}.contractEndDate < ?`; sqlParameters.push(currentDateString); break; } case 'future': { sqlWhereClause += - ` and ${lotOccupanciesTableAlias}.contractStartDate > ?`; + ` and ${contractsTableAlias}.contractStartDate > ?`; sqlParameters.push(currentDateString); break; } @@ -63,18 +63,18 @@ export function getOccupancyTimeWhereClause(occupancyTime, lotOccupanciesTableAl sqlParameters }; } -export function getOccupantNameWhereClause(occupantName = '', tableAlias = 'o') { +export function getDeceasedNameWhereClause(deceasedName = '', tableAlias = 'o') { let sqlWhereClause = ''; const sqlParameters = []; const usedPieces = new Set(); - const occupantNamePieces = occupantName.toLowerCase().split(' '); - for (const occupantNamePiece of occupantNamePieces) { - if (occupantNamePiece === '' || usedPieces.has(occupantNamePiece)) { + const deceasedNamePieces = deceasedName.toLowerCase().split(' '); + for (const namePiece of deceasedNamePieces) { + if (namePiece === '' || usedPieces.has(namePiece)) { continue; } - usedPieces.add(occupantNamePiece); - sqlWhereClause += ` and (instr(lower(${tableAlias}.occupantName), ?) or instr(lower(${tableAlias}.occupantFamilyName), ?))`; - sqlParameters.push(occupantNamePiece, occupantNamePiece); + usedPieces.add(namePiece); + sqlWhereClause += ` and instr(lower(${tableAlias}.deceasedName), ?)`; + sqlParameters.push(namePiece); } return { sqlWhereClause, diff --git a/helpers/functions.sqlFilters.ts b/helpers/functions.sqlFilters.ts index a9ebf1dc..25c20cb5 100644 --- a/helpers/functions.sqlFilters.ts +++ b/helpers/functions.sqlFilters.ts @@ -52,11 +52,11 @@ export function getBurialSiteNameWhereClause( } } -type OccupancyTime = '' | 'current' | 'past' | 'future' +type ContractTime = '' | 'current' | 'past' | 'future' -export function getOccupancyTimeWhereClause( - occupancyTime: OccupancyTime | undefined, - lotOccupanciesTableAlias = 'o' +export function getContractTimeWhereClause( + contractTime: ContractTime | undefined, + contractsTableAlias = 'o' ): WhereClauseReturn { let sqlWhereClause = '' const sqlParameters: unknown[] = [] @@ -64,24 +64,24 @@ export function getOccupancyTimeWhereClause( const currentDateString = dateToInteger(new Date()) // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check - switch (occupancyTime ?? '') { + switch (contractTime ?? '') { case 'current': { - sqlWhereClause += ` and ${lotOccupanciesTableAlias}.contractStartDate <= ? - and (${lotOccupanciesTableAlias}.contractEndDate is null or ${lotOccupanciesTableAlias}.contractEndDate >= ?)` + sqlWhereClause += ` and ${contractsTableAlias}.contractStartDate <= ? + and (${contractsTableAlias}.contractEndDate is null or ${contractsTableAlias}.contractEndDate >= ?)` sqlParameters.push(currentDateString, currentDateString) break } case 'past': { sqlWhereClause += - ` and ${lotOccupanciesTableAlias}.contractEndDate < ?` + ` and ${contractsTableAlias}.contractEndDate < ?` sqlParameters.push(currentDateString) break } case 'future': { sqlWhereClause += - ` and ${lotOccupanciesTableAlias}.contractStartDate > ?` + ` and ${contractsTableAlias}.contractStartDate > ?` sqlParameters.push(currentDateString) break } @@ -93,8 +93,8 @@ export function getOccupancyTimeWhereClause( } } -export function getOccupantNameWhereClause( - occupantName = '', +export function getDeceasedNameWhereClause( + deceasedName = '', tableAlias = 'o' ): WhereClauseReturn { let sqlWhereClause = '' @@ -102,16 +102,16 @@ export function getOccupantNameWhereClause( const usedPieces = new Set() - const occupantNamePieces = occupantName.toLowerCase().split(' ') - for (const occupantNamePiece of occupantNamePieces) { - if (occupantNamePiece === '' || usedPieces.has(occupantNamePiece)) { + const deceasedNamePieces = deceasedName.toLowerCase().split(' ') + for (const namePiece of deceasedNamePieces) { + if (namePiece === '' || usedPieces.has(namePiece)) { continue } - usedPieces.add(occupantNamePiece) + usedPieces.add(namePiece) - sqlWhereClause += ` and (instr(lower(${tableAlias}.occupantName), ?) or instr(lower(${tableAlias}.occupantFamilyName), ?))` - sqlParameters.push(occupantNamePiece, occupantNamePiece) + sqlWhereClause += ` and instr(lower(${tableAlias}.deceasedName), ?)` + sqlParameters.push(namePiece) } return { diff --git a/package-lock.json b/package-lock.json index 9c0d1f41..c283b3f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,6 @@ "activedirectory2": "^2.2.0", "better-sqlite-pool": "^0.3.2", "better-sqlite3": "^11.8.1", - "bulma-calendar": "^6.1.19", "camelcase": "^8.0.0", "compression": "^1.8.0", "cookie-parser": "^1.4.7", @@ -3735,18 +3734,8 @@ "node_modules/bulma": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/bulma/-/bulma-0.9.4.tgz", - "integrity": "sha512-86FlT5+1GrsgKbPLRRY7cGDg8fsJiP/jzTqXXVqiUZZ2aZT8uemEOHlU1CDU+TxklPEZ11HZNNWclRBBecP4CQ==" - }, - "node_modules/bulma-calendar": { - "version": "6.1.19", - "resolved": "https://registry.npmjs.org/bulma-calendar/-/bulma-calendar-6.1.19.tgz", - "integrity": "sha512-roosrqoXWGTP7MR5PW151XO4mnarov2qvfzvHfGKzT8rV+SGRZmhzbr4/xmUxRyD+vdn6mSG+ensda4mvvKDow==", - "dependencies": { - "date-fns": "^2.21.3" - }, - "peerDependencies": { - "bulma": "^0.9.4" - } + "integrity": "sha512-86FlT5+1GrsgKbPLRRY7cGDg8fsJiP/jzTqXXVqiUZZ2aZT8uemEOHlU1CDU+TxklPEZ11HZNNWclRBBecP4CQ==", + "dev": true }, "node_modules/bulma-divider": { "version": "0.2.0", @@ -4876,18 +4865,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/date-fns": { - "version": "2.29.3", - "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.3.tgz", - "integrity": "sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==", - "engines": { - "node": ">=0.11" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/date-fns" - } - }, "node_modules/dayjs": { "version": "1.11.7", "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.7.tgz", diff --git a/package.json b/package.json index 635a6e34..1a2c8e90 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,6 @@ "activedirectory2": "^2.2.0", "better-sqlite-pool": "^0.3.2", "better-sqlite3": "^11.8.1", - "bulma-calendar": "^6.1.19", "camelcase": "^8.0.0", "compression": "^1.8.0", "cookie-parser": "^1.4.7", diff --git a/public/html/adminFees-addFee.html b/public/html/adminFees-addFee.html index 3dcee820..23980a0f 100644 --- a/public/html/adminFees-addFee.html +++ b/public/html/adminFees-addFee.html @@ -68,20 +68,16 @@

Filters can be used to show or hide available fees depending on the - type and - type selected when - creating the - - record. + contract type and burial site type selected when + creating the contract record.

- +
diff --git a/public/html/adminFees-editFee.html b/public/html/adminFees-editFee.html index 045edc99..82b69c31 100644 --- a/public/html/adminFees-editFee.html +++ b/public/html/adminFees-editFee.html @@ -69,11 +69,8 @@

Filters can be used to show or hide available fees depending on the - type and - type selected when - creating the - - record. + contract type and burial site type selected when + creating the contract record.

diff --git a/public/html/burialSite-editLotStatus.html b/public/html/burialSite-editBurialSiteStatus.html similarity index 66% rename from public/html/burialSite-editLotStatus.html rename to public/html/burialSite-editBurialSiteStatus.html index 8692a16f..d2cf51c8 100644 --- a/public/html/burialSite-editLotStatus.html +++ b/public/html/burialSite-editBurialSiteStatus.html @@ -3,7 +3,7 @@