From 27433ff4b053b6aed3859bed8ddd1f8c7ce30e31 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Tue, 25 Feb 2025 11:28:24 -0500 Subject: [PATCH] major refactoring --- cypress/e2e/02-update/lotOccupancies.cy.js | 4 +- cypress/e2e/02-update/lotOccupancies.cy.ts | 4 +- data/config.base.js | 1 + data/config.base.ts | 1 + data/config.baseSsm.js | 33 + data/config.baseSsm.ts | 34 ++ data/config.defaultValues.d.ts | 3 +- data/config.defaultValues.js | 12 + data/config.defaultValues.ts | 15 + database/addBurialSite.js | 7 +- database/addBurialSite.ts | 8 +- database/addBurialSiteContract.d.ts | 2 +- database/addBurialSiteContract.js | 12 +- database/addBurialSiteContract.ts | 14 +- database/addBurialSiteContractComment.d.ts | 2 +- database/addBurialSiteContractComment.js | 2 +- database/addBurialSiteContractComment.ts | 2 +- database/addBurialSiteContractFee.js | 4 +- database/addBurialSiteContractFee.ts | 4 +- .../addBurialSiteContractFeeCategory.d.ts | 2 +- database/addBurialSiteContractFeeCategory.js | 2 +- database/addBurialSiteContractFeeCategory.ts | 2 +- ... => addBurialSiteContractTransaction.d.ts} | 4 +- ...js => addBurialSiteContractTransaction.js} | 18 +- ...ts => addBurialSiteContractTransaction.ts} | 28 +- database/copyBurialSiteContract.js | 6 +- database/copyBurialSiteContract.ts | 6 +- database/getBurialSite.d.ts | 5 +- database/getBurialSite.js | 24 +- database/getBurialSite.ts | 30 +- database/getBurialSiteContract.d.ts | 2 +- database/getBurialSiteContract.js | 12 +- database/getBurialSiteContract.ts | 12 +- database/getBurialSiteContractTransactions.js | 6 +- database/getBurialSiteContractTransactions.ts | 6 +- database/getBurialSiteContracts.d.ts | 9 +- database/getBurialSiteContracts.js | 18 +- database/getBurialSiteContracts.ts | 29 +- database/getBurialSites.d.ts | 7 +- database/getBurialSites.js | 14 +- database/getBurialSites.ts | 20 +- database/getPastLotOccupancyOccupants.js | 4 +- database/getPastLotOccupancyOccupants.ts | 4 +- database/getWorkOrders.js | 4 +- database/getWorkOrders.ts | 4 +- database/initializeDatabase.js | 20 +- database/initializeDatabase.ts | 20 +- database/updateLotOccupancyOccupant.d.ts | 2 +- database/updateLotOccupancyOccupant.js | 4 +- database/updateLotOccupancyOccupant.ts | 28 +- ....d.ts => doUpdateBurialSiteTypeField.d.ts} | 0 ...ield.js => doUpdateBurialSiteTypeField.js} | 4 +- ...ield.ts => doUpdateBurialSiteTypeField.ts} | 4 +- ...ncyType.d.ts => doUpdateContractType.d.ts} | 2 +- ...cupancyType.js => doUpdateContractType.js} | 6 +- ...cupancyType.ts => doUpdateContractType.ts} | 10 +- .../admin-post/doUpdateContractTypeField.d.ts | 3 + ...eField.js => doUpdateContractTypeField.js} | 8 +- ...eField.ts => doUpdateContractTypeField.ts} | 16 +- handlers/api-get/milestoneICS.js | 12 +- handlers/api-get/milestoneICS.ts | 12 +- handlers/burialSites-get/edit.js | 30 +- handlers/burialSites-get/edit.ts | 33 +- handlers/burialSites-get/new.js | 39 +- handlers/burialSites-get/new.ts | 46 +- handlers/burialSites-get/next.js | 12 +- handlers/burialSites-get/next.ts | 12 +- handlers/burialSites-get/previous.js | 12 +- handlers/burialSites-get/previous.ts | 12 +- handlers/burialSites-get/search.js | 21 +- handlers/burialSites-get/search.ts | 24 +- handlers/burialSites-get/view.js | 20 +- handlers/burialSites-get/view.ts | 23 +- .../doAddBurialSiteComment.d.ts | 3 + .../doAddBurialSiteComment.js | 10 + .../doAddBurialSiteComment.ts | 22 + handlers/burialSites-post/doAddLotComment.js | 10 - handlers/burialSites-post/doAddLotComment.ts | 23 - .../burialSites-post/doCreateBurialSite.d.ts | 3 + .../burialSites-post/doCreateBurialSite.js | 12 + .../burialSites-post/doCreateBurialSite.ts | 25 + handlers/burialSites-post/doCreateLot.js | 12 - handlers/burialSites-post/doCreateLot.ts | 24 - .../burialSites-post/doDeleteBurialSite.d.ts | 4 + .../burialSites-post/doDeleteBurialSite.js | 12 + .../burialSites-post/doDeleteBurialSite.ts | 25 + .../doDeleteBurialSiteComment.d.ts | 5 + .../doDeleteBurialSiteComment.js | 10 + .../doDeleteBurialSiteComment.ts | 28 + handlers/burialSites-post/doDeleteLot.js | 12 - handlers/burialSites-post/doDeleteLot.ts | 22 - .../burialSites-post/doDeleteLotComment.js | 10 - .../burialSites-post/doDeleteLotComment.ts | 22 - .../doGetBurialSiteTypeFields.d.ts | 4 + .../doGetBurialSiteTypeFields.js | 7 + .../doGetBurialSiteTypeFields.ts | 16 + .../burialSites-post/doGetLotTypeFields.d.ts | 2 - .../burialSites-post/doGetLotTypeFields.js | 7 - .../burialSites-post/doGetLotTypeFields.ts | 17 - .../burialSites-post/doSearchBurialSites.d.ts | 3 + .../burialSites-post/doSearchBurialSites.js | 15 + .../burialSites-post/doSearchBurialSites.ts | 30 + handlers/burialSites-post/doSearchLots.d.ts | 2 - handlers/burialSites-post/doSearchLots.js | 13 - handlers/burialSites-post/doSearchLots.ts | 18 - .../burialSites-post/doUpdateBurialSite.d.ts | 3 + .../burialSites-post/doUpdateBurialSite.js | 15 + .../burialSites-post/doUpdateBurialSite.ts | 30 + .../doUpdateBurialSiteComment.d.ts | 5 + .../doUpdateBurialSiteComment.js | 10 + .../doUpdateBurialSiteComment.ts | 29 + handlers/burialSites-post/doUpdateLot.d.ts | 2 - handlers/burialSites-post/doUpdateLot.js | 13 - handlers/burialSites-post/doUpdateLot.ts | 25 - .../burialSites-post/doUpdateLotComment.d.ts | 2 - .../burialSites-post/doUpdateLotComment.js | 10 - .../burialSites-post/doUpdateLotComment.ts | 23 - handlers/contracts-get/edit.js | 40 +- handlers/contracts-get/edit.ts | 47 +- handlers/contracts-get/new.js | 47 +- handlers/contracts-get/new.ts | 50 +- handlers/contracts-get/search.js | 19 +- handlers/contracts-get/search.ts | 19 +- handlers/contracts-get/view.js | 20 +- handlers/contracts-get/view.ts | 24 +- .../doAddBurialSiteContractComment.d.ts | 3 + .../doAddBurialSiteContractComment.js | 10 + .../doAddBurialSiteContractComment.ts | 22 + .../doAddBurialSiteContractFee.d.ts | 3 + .../doAddBurialSiteContractFee.js | 10 + .../doAddBurialSiteContractFee.ts | 22 + .../doAddBurialSiteContractFeeCategory.d.ts | 3 + .../doAddBurialSiteContractFeeCategory.js | 10 + .../doAddBurialSiteContractFeeCategory.ts | 25 + .../doAddBurialSiteContractTransaction.d.ts | 3 + .../doAddBurialSiteContractTransaction.js | 12 + .../doAddBurialSiteContractTransaction.ts | 26 + .../doAddLotOccupancyComment.d.ts | 2 - .../doAddLotOccupancyComment.js | 10 - .../doAddLotOccupancyComment.ts | 25 - .../contracts-post/doAddLotOccupancyFee.d.ts | 2 - .../contracts-post/doAddLotOccupancyFee.js | 10 - .../contracts-post/doAddLotOccupancyFee.ts | 25 - .../doAddLotOccupancyFeeCategory.d.ts | 2 - .../doAddLotOccupancyFeeCategory.js | 10 - .../doAddLotOccupancyFeeCategory.ts | 25 - .../doAddLotOccupancyOccupant.d.ts | 2 - .../doAddLotOccupancyOccupant.js | 10 - .../doAddLotOccupancyOccupant.ts | 25 - .../doAddLotOccupancyTransaction.d.ts | 2 - .../doAddLotOccupancyTransaction.js | 10 - .../doAddLotOccupancyTransaction.ts | 26 - .../doCopyBurialSiteContract.d.ts | 4 + .../doCopyBurialSiteContract.js | 8 + .../doCopyBurialSiteContract.ts | 18 + .../contracts-post/doCopyLotOccupancy.d.ts | 2 - handlers/contracts-post/doCopyLotOccupancy.js | 8 - handlers/contracts-post/doCopyLotOccupancy.ts | 19 - .../doCreateBurialSiteContract.d.ts | 3 + .../doCreateBurialSiteContract.js | 8 + .../doCreateBurialSiteContract.ts | 21 + .../contracts-post/doCreateLotOccupancy.d.ts | 2 - .../contracts-post/doCreateLotOccupancy.js | 8 - .../contracts-post/doCreateLotOccupancy.ts | 21 - .../doDeleteBurialSiteContract.d.ts | 4 + ...pancy.js => doDeleteBurialSiteContract.js} | 2 +- ...pancy.ts => doDeleteBurialSiteContract.ts} | 7 +- .../doDeleteBurialSiteContractComment.d.ts | 5 + .../doDeleteBurialSiteContractComment.js | 10 + .../doDeleteBurialSiteContractComment.ts | 28 + .../doDeleteBurialSiteContractFee.d.ts | 5 + .../doDeleteBurialSiteContractFee.js | 10 + .../doDeleteBurialSiteContractFee.ts | 28 + ...doDeleteBurialSiteContractTransaction.d.ts | 5 + .../doDeleteBurialSiteContractTransaction.js | 12 + .../doDeleteBurialSiteContractTransaction.ts | 29 + .../contracts-post/doDeleteLotOccupancy.d.ts | 2 - .../doDeleteLotOccupancyComment.d.ts | 2 - .../doDeleteLotOccupancyComment.js | 10 - .../doDeleteLotOccupancyComment.ts | 24 - .../doDeleteLotOccupancyFee.d.ts | 2 - .../contracts-post/doDeleteLotOccupancyFee.js | 10 - .../contracts-post/doDeleteLotOccupancyFee.ts | 24 - .../doDeleteLotOccupancyOccupant.d.ts | 2 - .../doDeleteLotOccupancyOccupant.js | 10 - .../doDeleteLotOccupancyOccupant.ts | 24 - .../doDeleteLotOccupancyTransaction.d.ts | 2 - .../doDeleteLotOccupancyTransaction.js | 10 - .../doDeleteLotOccupancyTransaction.ts | 25 - .../doGetContractTypeFields.d.ts | 4 + ...peFields.js => doGetContractTypeFields.js} | 8 +- ...peFields.ts => doGetContractTypeFields.ts} | 16 +- handlers/contracts-post/doGetFees.d.ts | 4 +- handlers/contracts-post/doGetFees.js | 8 +- handlers/contracts-post/doGetFees.ts | 13 +- .../doGetOccupancyTypeFields.d.ts | 2 - .../doSearchBurialSiteContracts.d.ts} | 0 ...cies.js => doSearchBurialSiteContracts.js} | 2 +- ...cies.ts => doSearchBurialSiteContracts.ts} | 2 +- .../doSearchLotOccupancies.d.ts | 2 - .../contracts-post/doSearchPastOccupants.d.ts | 2 - .../contracts-post/doSearchPastOccupants.js | 9 - .../contracts-post/doSearchPastOccupants.ts | 21 - .../doUpdateBurialSiteContract.d.ts} | 0 ...pancy.js => doUpdateBurialSiteContract.js} | 0 ...pancy.ts => doUpdateBurialSiteContract.ts} | 0 .../doUpdateBurialSiteContractComment.d.ts} | 0 ...s => doUpdateBurialSiteContractComment.js} | 6 +- ...s => doUpdateBurialSiteContractComment.ts} | 6 +- ...oUpdateBurialSiteContractFeeQuantity.d.ts} | 0 ... doUpdateBurialSiteContractFeeQuantity.js} | 6 +- ... doUpdateBurialSiteContractFeeQuantity.ts} | 6 +- ...oUpdateBurialSiteContractTransaction.d.ts} | 0 .../doUpdateBurialSiteContractTransaction.js | 10 + ... doUpdateBurialSiteContractTransaction.ts} | 6 +- .../contracts-post/doUpdateLotOccupancy.d.ts | 2 - .../doUpdateLotOccupancyComment.d.ts | 2 - .../doUpdateLotOccupancyFeeQuantity.d.ts | 2 - .../doUpdateLotOccupancyOccupant.d.ts | 2 - .../doUpdateLotOccupancyOccupant.js | 10 - .../doUpdateLotOccupancyOccupant.ts | 25 - .../doUpdateLotOccupancyTransaction.d.ts | 2 - .../doUpdateLotOccupancyTransaction.js | 10 - handlers/dashboard-get/dashboard.js | 4 +- handlers/dashboard-get/dashboard.ts | 4 +- handlers/lots-post/doAddLotComment.d.ts | 2 - handlers/lots-post/doAddLotComment.js | 10 - handlers/lots-post/doCreateLot.d.ts | 2 - handlers/lots-post/doCreateLot.js | 12 - handlers/lots-post/doDeleteLot.d.ts | 2 - handlers/lots-post/doDeleteLot.js | 12 - handlers/lots-post/doDeleteLotComment.d.ts | 2 - handlers/lots-post/doDeleteLotComment.js | 10 - handlers/lots-post/doUpdateLot.d.ts | 2 - handlers/print-get/pdf.js | 2 +- handlers/print-get/pdf.ts | 2 +- handlers/print-get/screen.js | 2 +- handlers/print-get/screen.ts | 2 +- handlers/reports-get/search.js | 8 +- handlers/reports-get/search.ts | 8 +- handlers/workOrders-get/edit.js | 4 +- handlers/workOrders-get/edit.ts | 4 +- .../doAddWorkOrderLotOccupancy.js | 2 +- .../doAddWorkOrderLotOccupancy.ts | 2 +- .../doDeleteWorkOrderLotOccupancy.js | 2 +- .../doDeleteWorkOrderLotOccupancy.ts | 2 +- helpers/burialSites.helpers.d.ts | 7 + helpers/burialSites.helpers.js | 22 +- helpers/burialSites.helpers.ts | 41 +- helpers/functions.authentication.js | 2 +- helpers/functions.authentication.ts | 2 +- helpers/functions.fee.d.ts | 2 +- helpers/functions.fee.js | 2 +- helpers/functions.fee.ts | 2 +- helpers/functions.lotOccupancy.d.ts | 8 +- helpers/functions.lotOccupancy.js | 18 +- helpers/functions.lotOccupancy.ts | 18 +- helpers/functions.print.d.ts | 8 +- helpers/functions.print.js | 22 +- helpers/functions.print.ts | 32 +- helpers/functions.sqlFilters.d.ts | 4 +- helpers/functions.sqlFilters.js | 26 +- helpers/functions.sqlFilters.ts | 34 +- public/javascripts/lotOccupancyEdit.ts | 572 +++++++++--------- public/javascripts/lotOccupancySearch.ts | 50 +- public/javascripts/lotSearch.ts | 2 +- public/javascripts/main.ts | 4 +- .../javascripts/types.ts | 2 +- public/javascripts/workOrderEdit.ts | 92 +-- .../javascripts/workOrderMilestoneCalendar.ts | 14 +- public/javascripts/workOrderSearch.ts | 2 +- routes/admin.js | 12 +- routes/admin.ts | 12 +- routes/contracts.js | 16 +- routes/contracts.ts | 16 +- temp/legacy.importFromCSV.js | 152 ++--- temp/legacy.importFromCSV.ts | 152 ++--- test/functions.js | 12 +- test/functions.ts | 12 +- types/configTypes.d.ts | 15 + types/configTypes.ts | 26 +- types/globalTypes.d.ts | 30 - types/recordTypes.d.ts | 20 +- types/recordTypes.ts | 22 +- 284 files changed, 2160 insertions(+), 2102 deletions(-) rename database/{addLotOccupancyTransaction.d.ts => addBurialSiteContractTransaction.d.ts} (56%) rename database/{addLotOccupancyTransaction.js => addBurialSiteContractTransaction.js} (51%) rename database/{addLotOccupancyTransaction.ts => addBurialSiteContractTransaction.ts} (62%) rename handlers/admin-post/{doUpdateLotTypeField.d.ts => doUpdateBurialSiteTypeField.d.ts} (100%) rename handlers/admin-post/{doUpdateLotTypeField.js => doUpdateBurialSiteTypeField.js} (81%) rename handlers/admin-post/{doUpdateLotTypeField.ts => doUpdateBurialSiteTypeField.ts} (87%) rename handlers/admin-post/{doUpdateOccupancyType.d.ts => doUpdateContractType.d.ts} (87%) rename handlers/admin-post/{doUpdateOccupancyType.js => doUpdateContractType.js} (62%) rename handlers/admin-post/{doUpdateOccupancyType.ts => doUpdateContractType.ts} (76%) create mode 100644 handlers/admin-post/doUpdateContractTypeField.d.ts rename handlers/admin-post/{doUpdateOccupancyTypeField.js => doUpdateContractTypeField.js} (54%) rename handlers/admin-post/{doUpdateOccupancyTypeField.ts => doUpdateContractTypeField.ts} (55%) create mode 100644 handlers/burialSites-post/doAddBurialSiteComment.d.ts create mode 100644 handlers/burialSites-post/doAddBurialSiteComment.js create mode 100644 handlers/burialSites-post/doAddBurialSiteComment.ts delete mode 100644 handlers/burialSites-post/doAddLotComment.js delete mode 100644 handlers/burialSites-post/doAddLotComment.ts create mode 100644 handlers/burialSites-post/doCreateBurialSite.d.ts create mode 100644 handlers/burialSites-post/doCreateBurialSite.js create mode 100644 handlers/burialSites-post/doCreateBurialSite.ts delete mode 100644 handlers/burialSites-post/doCreateLot.js delete mode 100644 handlers/burialSites-post/doCreateLot.ts create mode 100644 handlers/burialSites-post/doDeleteBurialSite.d.ts create mode 100644 handlers/burialSites-post/doDeleteBurialSite.js create mode 100644 handlers/burialSites-post/doDeleteBurialSite.ts create mode 100644 handlers/burialSites-post/doDeleteBurialSiteComment.d.ts create mode 100644 handlers/burialSites-post/doDeleteBurialSiteComment.js create mode 100644 handlers/burialSites-post/doDeleteBurialSiteComment.ts delete mode 100644 handlers/burialSites-post/doDeleteLot.js delete mode 100644 handlers/burialSites-post/doDeleteLot.ts delete mode 100644 handlers/burialSites-post/doDeleteLotComment.js delete mode 100644 handlers/burialSites-post/doDeleteLotComment.ts create mode 100644 handlers/burialSites-post/doGetBurialSiteTypeFields.d.ts create mode 100644 handlers/burialSites-post/doGetBurialSiteTypeFields.js create mode 100644 handlers/burialSites-post/doGetBurialSiteTypeFields.ts delete mode 100644 handlers/burialSites-post/doGetLotTypeFields.d.ts delete mode 100644 handlers/burialSites-post/doGetLotTypeFields.js delete mode 100644 handlers/burialSites-post/doGetLotTypeFields.ts create mode 100644 handlers/burialSites-post/doSearchBurialSites.d.ts create mode 100644 handlers/burialSites-post/doSearchBurialSites.js create mode 100644 handlers/burialSites-post/doSearchBurialSites.ts delete mode 100644 handlers/burialSites-post/doSearchLots.d.ts delete mode 100644 handlers/burialSites-post/doSearchLots.js delete mode 100644 handlers/burialSites-post/doSearchLots.ts create mode 100644 handlers/burialSites-post/doUpdateBurialSite.d.ts create mode 100644 handlers/burialSites-post/doUpdateBurialSite.js create mode 100644 handlers/burialSites-post/doUpdateBurialSite.ts create mode 100644 handlers/burialSites-post/doUpdateBurialSiteComment.d.ts create mode 100644 handlers/burialSites-post/doUpdateBurialSiteComment.js create mode 100644 handlers/burialSites-post/doUpdateBurialSiteComment.ts delete mode 100644 handlers/burialSites-post/doUpdateLot.d.ts delete mode 100644 handlers/burialSites-post/doUpdateLot.js delete mode 100644 handlers/burialSites-post/doUpdateLot.ts delete mode 100644 handlers/burialSites-post/doUpdateLotComment.d.ts delete mode 100644 handlers/burialSites-post/doUpdateLotComment.js delete mode 100644 handlers/burialSites-post/doUpdateLotComment.ts create mode 100644 handlers/contracts-post/doAddBurialSiteContractComment.d.ts create mode 100644 handlers/contracts-post/doAddBurialSiteContractComment.js create mode 100644 handlers/contracts-post/doAddBurialSiteContractComment.ts create mode 100644 handlers/contracts-post/doAddBurialSiteContractFee.d.ts create mode 100644 handlers/contracts-post/doAddBurialSiteContractFee.js create mode 100644 handlers/contracts-post/doAddBurialSiteContractFee.ts create mode 100644 handlers/contracts-post/doAddBurialSiteContractFeeCategory.d.ts create mode 100644 handlers/contracts-post/doAddBurialSiteContractFeeCategory.js create mode 100644 handlers/contracts-post/doAddBurialSiteContractFeeCategory.ts create mode 100644 handlers/contracts-post/doAddBurialSiteContractTransaction.d.ts create mode 100644 handlers/contracts-post/doAddBurialSiteContractTransaction.js create mode 100644 handlers/contracts-post/doAddBurialSiteContractTransaction.ts delete mode 100644 handlers/contracts-post/doAddLotOccupancyComment.d.ts delete mode 100644 handlers/contracts-post/doAddLotOccupancyComment.js delete mode 100644 handlers/contracts-post/doAddLotOccupancyComment.ts delete mode 100644 handlers/contracts-post/doAddLotOccupancyFee.d.ts delete mode 100644 handlers/contracts-post/doAddLotOccupancyFee.js delete mode 100644 handlers/contracts-post/doAddLotOccupancyFee.ts delete mode 100644 handlers/contracts-post/doAddLotOccupancyFeeCategory.d.ts delete mode 100644 handlers/contracts-post/doAddLotOccupancyFeeCategory.js delete mode 100644 handlers/contracts-post/doAddLotOccupancyFeeCategory.ts delete mode 100644 handlers/contracts-post/doAddLotOccupancyOccupant.d.ts delete mode 100644 handlers/contracts-post/doAddLotOccupancyOccupant.js delete mode 100644 handlers/contracts-post/doAddLotOccupancyOccupant.ts delete mode 100644 handlers/contracts-post/doAddLotOccupancyTransaction.d.ts delete mode 100644 handlers/contracts-post/doAddLotOccupancyTransaction.js delete mode 100644 handlers/contracts-post/doAddLotOccupancyTransaction.ts create mode 100644 handlers/contracts-post/doCopyBurialSiteContract.d.ts create mode 100644 handlers/contracts-post/doCopyBurialSiteContract.js create mode 100644 handlers/contracts-post/doCopyBurialSiteContract.ts delete mode 100644 handlers/contracts-post/doCopyLotOccupancy.d.ts delete mode 100644 handlers/contracts-post/doCopyLotOccupancy.js delete mode 100644 handlers/contracts-post/doCopyLotOccupancy.ts create mode 100644 handlers/contracts-post/doCreateBurialSiteContract.d.ts create mode 100644 handlers/contracts-post/doCreateBurialSiteContract.js create mode 100644 handlers/contracts-post/doCreateBurialSiteContract.ts delete mode 100644 handlers/contracts-post/doCreateLotOccupancy.d.ts delete mode 100644 handlers/contracts-post/doCreateLotOccupancy.js delete mode 100644 handlers/contracts-post/doCreateLotOccupancy.ts create mode 100644 handlers/contracts-post/doDeleteBurialSiteContract.d.ts rename handlers/contracts-post/{doDeleteLotOccupancy.js => doDeleteBurialSiteContract.js} (58%) rename handlers/contracts-post/{doDeleteLotOccupancy.ts => doDeleteBurialSiteContract.ts} (68%) create mode 100644 handlers/contracts-post/doDeleteBurialSiteContractComment.d.ts create mode 100644 handlers/contracts-post/doDeleteBurialSiteContractComment.js create mode 100644 handlers/contracts-post/doDeleteBurialSiteContractComment.ts create mode 100644 handlers/contracts-post/doDeleteBurialSiteContractFee.d.ts create mode 100644 handlers/contracts-post/doDeleteBurialSiteContractFee.js create mode 100644 handlers/contracts-post/doDeleteBurialSiteContractFee.ts create mode 100644 handlers/contracts-post/doDeleteBurialSiteContractTransaction.d.ts create mode 100644 handlers/contracts-post/doDeleteBurialSiteContractTransaction.js create mode 100644 handlers/contracts-post/doDeleteBurialSiteContractTransaction.ts delete mode 100644 handlers/contracts-post/doDeleteLotOccupancy.d.ts delete mode 100644 handlers/contracts-post/doDeleteLotOccupancyComment.d.ts delete mode 100644 handlers/contracts-post/doDeleteLotOccupancyComment.js delete mode 100644 handlers/contracts-post/doDeleteLotOccupancyComment.ts delete mode 100644 handlers/contracts-post/doDeleteLotOccupancyFee.d.ts delete mode 100644 handlers/contracts-post/doDeleteLotOccupancyFee.js delete mode 100644 handlers/contracts-post/doDeleteLotOccupancyFee.ts delete mode 100644 handlers/contracts-post/doDeleteLotOccupancyOccupant.d.ts delete mode 100644 handlers/contracts-post/doDeleteLotOccupancyOccupant.js delete mode 100644 handlers/contracts-post/doDeleteLotOccupancyOccupant.ts delete mode 100644 handlers/contracts-post/doDeleteLotOccupancyTransaction.d.ts delete mode 100644 handlers/contracts-post/doDeleteLotOccupancyTransaction.js delete mode 100644 handlers/contracts-post/doDeleteLotOccupancyTransaction.ts create mode 100644 handlers/contracts-post/doGetContractTypeFields.d.ts rename handlers/contracts-post/{doGetOccupancyTypeFields.js => doGetContractTypeFields.js} (57%) rename handlers/contracts-post/{doGetOccupancyTypeFields.ts => doGetContractTypeFields.ts} (52%) delete mode 100644 handlers/contracts-post/doGetOccupancyTypeFields.d.ts rename handlers/{admin-post/doUpdateOccupancyTypeField.d.ts => contracts-post/doSearchBurialSiteContracts.d.ts} (100%) rename handlers/contracts-post/{doSearchLotOccupancies.js => doSearchBurialSiteContracts.js} (85%) rename handlers/contracts-post/{doSearchLotOccupancies.ts => doSearchBurialSiteContracts.ts} (86%) delete mode 100644 handlers/contracts-post/doSearchLotOccupancies.d.ts delete mode 100644 handlers/contracts-post/doSearchPastOccupants.d.ts delete mode 100644 handlers/contracts-post/doSearchPastOccupants.js delete mode 100644 handlers/contracts-post/doSearchPastOccupants.ts rename handlers/{burialSites-post/doAddLotComment.d.ts => contracts-post/doUpdateBurialSiteContract.d.ts} (100%) rename handlers/contracts-post/{doUpdateLotOccupancy.js => doUpdateBurialSiteContract.js} (100%) rename handlers/contracts-post/{doUpdateLotOccupancy.ts => doUpdateBurialSiteContract.ts} (100%) rename handlers/{burialSites-post/doCreateLot.d.ts => contracts-post/doUpdateBurialSiteContractComment.d.ts} (100%) rename handlers/contracts-post/{doUpdateLotOccupancyComment.js => doUpdateBurialSiteContractComment.js} (53%) rename handlers/contracts-post/{doUpdateLotOccupancyComment.ts => doUpdateBurialSiteContractComment.ts} (72%) rename handlers/{burialSites-post/doDeleteLot.d.ts => contracts-post/doUpdateBurialSiteContractFeeQuantity.d.ts} (100%) rename handlers/contracts-post/{doUpdateLotOccupancyFeeQuantity.js => doUpdateBurialSiteContractFeeQuantity.js} (57%) rename handlers/contracts-post/{doUpdateLotOccupancyFeeQuantity.ts => doUpdateBurialSiteContractFeeQuantity.ts} (74%) rename handlers/{burialSites-post/doDeleteLotComment.d.ts => contracts-post/doUpdateBurialSiteContractTransaction.d.ts} (100%) create mode 100644 handlers/contracts-post/doUpdateBurialSiteContractTransaction.js rename handlers/contracts-post/{doUpdateLotOccupancyTransaction.ts => doUpdateBurialSiteContractTransaction.ts} (71%) delete mode 100644 handlers/contracts-post/doUpdateLotOccupancy.d.ts delete mode 100644 handlers/contracts-post/doUpdateLotOccupancyComment.d.ts delete mode 100644 handlers/contracts-post/doUpdateLotOccupancyFeeQuantity.d.ts delete mode 100644 handlers/contracts-post/doUpdateLotOccupancyOccupant.d.ts delete mode 100644 handlers/contracts-post/doUpdateLotOccupancyOccupant.js delete mode 100644 handlers/contracts-post/doUpdateLotOccupancyOccupant.ts delete mode 100644 handlers/contracts-post/doUpdateLotOccupancyTransaction.d.ts delete mode 100644 handlers/contracts-post/doUpdateLotOccupancyTransaction.js delete mode 100644 handlers/lots-post/doAddLotComment.d.ts delete mode 100644 handlers/lots-post/doAddLotComment.js delete mode 100644 handlers/lots-post/doCreateLot.d.ts delete mode 100644 handlers/lots-post/doCreateLot.js delete mode 100644 handlers/lots-post/doDeleteLot.d.ts delete mode 100644 handlers/lots-post/doDeleteLot.js delete mode 100644 handlers/lots-post/doDeleteLotComment.d.ts delete mode 100644 handlers/lots-post/doDeleteLotComment.js delete mode 100644 handlers/lots-post/doUpdateLot.d.ts rename types/globalTypes.ts => public/javascripts/types.ts (98%) delete mode 100644 types/globalTypes.d.ts diff --git a/cypress/e2e/02-update/lotOccupancies.cy.js b/cypress/e2e/02-update/lotOccupancies.cy.js index 652aed03..069ffb32 100644 --- a/cypress/e2e/02-update/lotOccupancies.cy.js +++ b/cypress/e2e/02-update/lotOccupancies.cy.js @@ -9,11 +9,11 @@ describe('Update - Lot Occupancies', () => { it('Has a "Create" link on the Lot Occupancy Search', () => { cy.visit('/lotOccupancies'); cy.location('pathname').should('equal', '/lotOccupancies'); - cy.get("a[href$='/lotOccupancies/new']").should('exist'); + cy.get("a[href$='/contracts/new']").should('exist'); }); describe('Update a New Lot Occupancy', () => { it('Has no detectable accessibility issues', () => { - cy.visit('/lotOccupancies/new'); + cy.visit('/contracts/new'); cy.injectAxe(); cy.checkA11y(); }); diff --git a/cypress/e2e/02-update/lotOccupancies.cy.ts b/cypress/e2e/02-update/lotOccupancies.cy.ts index d11dc670..14501c2d 100644 --- a/cypress/e2e/02-update/lotOccupancies.cy.ts +++ b/cypress/e2e/02-update/lotOccupancies.cy.ts @@ -12,12 +12,12 @@ describe('Update - Lot Occupancies', () => { it('Has a "Create" link on the Lot Occupancy Search', () => { cy.visit('/lotOccupancies') cy.location('pathname').should('equal', '/lotOccupancies') - cy.get("a[href$='/lotOccupancies/new']").should('exist') + cy.get("a[href$='/contracts/new']").should('exist') }) describe('Update a New Lot Occupancy', () => { it('Has no detectable accessibility issues', () => { - cy.visit('/lotOccupancies/new') + cy.visit('/contracts/new') cy.injectAxe() cy.checkA11y() }) diff --git a/data/config.base.js b/data/config.base.js index ca7dc17c..4f24c6e7 100644 --- a/data/config.base.js +++ b/data/config.base.js @@ -7,6 +7,7 @@ export const config = { settings: { fees: {}, cemeteries: {}, + burialSites: {}, contracts: {}, workOrders: {}, adminCleanup: {}, diff --git a/data/config.base.ts b/data/config.base.ts index cc0a2f13..05960e83 100644 --- a/data/config.base.ts +++ b/data/config.base.ts @@ -9,6 +9,7 @@ export const config: Config = { settings: { fees: {}, cemeteries: {}, + burialSites: {}, contracts: {}, workOrders: {}, adminCleanup: {}, diff --git a/data/config.baseSsm.js b/data/config.baseSsm.js index f3350dd6..d536054c 100644 --- a/data/config.baseSsm.js +++ b/data/config.baseSsm.js @@ -1,6 +1,39 @@ import { config as cemeteryConfig } from './config.baseOntario.js'; export const config = { ...cemeteryConfig }; config.aliases.externalReceiptNumber = 'GP Receipt Number'; +config.settings.burialSites.burialSiteNameSegments = { + separator: '-', + segments: { + 1: { + isRequired: true, + isAvailable: true, + label: 'Block', + minLength: 1, + maxLength: 3 + }, + 2: { + isRequired: true, + isAvailable: true, + label: 'Range', + minLength: 1, + maxLength: 3 + }, + 3: { + isRequired: true, + isAvailable: true, + label: 'Lot', + minLength: 1, + maxLength: 3 + }, + 4: { + isRequired: true, + isAvailable: true, + label: 'Grave', + minLength: 1, + maxLength: 2 + } + } +}; config.settings.contracts.cityDefault = 'Sault Ste. Marie'; config.settings.contracts.prints = [ 'pdf/ssm.cemetery.burialPermit', diff --git a/data/config.baseSsm.ts b/data/config.baseSsm.ts index 4f269582..815d9d30 100644 --- a/data/config.baseSsm.ts +++ b/data/config.baseSsm.ts @@ -6,6 +6,40 @@ export const config: Config = { ...cemeteryConfig } config.aliases.externalReceiptNumber = 'GP Receipt Number' +config.settings.burialSites.burialSiteNameSegments = { + separator: '-', + segments: { + 1: { + isRequired: true, + isAvailable: true, + label: 'Block', + minLength: 1, + maxLength: 3 + }, + 2: { + isRequired: true, + isAvailable: true, + label: 'Range', + minLength: 1, + maxLength: 3 + }, + 3: { + isRequired: true, + isAvailable: true, + label: 'Lot', + minLength: 1, + maxLength: 3 + }, + 4: { + isRequired: true, + isAvailable: true, + label: 'Grave', + minLength: 1, + maxLength: 2 + } + } +} + config.settings.contracts.cityDefault = 'Sault Ste. Marie' config.settings.contracts.prints = [ 'pdf/ssm.cemetery.burialPermit', diff --git a/data/config.defaultValues.d.ts b/data/config.defaultValues.d.ts index 57144314..dc0cc417 100644 --- a/data/config.defaultValues.d.ts +++ b/data/config.defaultValues.d.ts @@ -1,5 +1,5 @@ import type { config as MSSQLConfig } from 'mssql'; -import type { ConfigActiveDirectory, ConfigNtfyStartup, DynamicsGPLookup } from '../types/configTypes.js'; +import type { ConfigActiveDirectory, ConfigBurialSiteNameSegments, ConfigNtfyStartup, DynamicsGPLookup } from '../types/configTypes.js'; export declare const configDefaultValues: { activeDirectory: ConfigActiveDirectory; 'application.applicationName': string; @@ -26,6 +26,7 @@ export declare const configDefaultValues: { 'aliases.workOrderCloseDate': string; 'settings.cemeteries.cityDefault': string; 'settings.cemeteries.provinceDefault': string; + 'settings.burialSites.burialSiteNameSegments': ConfigBurialSiteNameSegments; 'settings.contracts.burialSiteIdIsRequired': boolean; 'settings.contracts.cityDefault': string; 'settings.contracts.provinceDefault': string; diff --git a/data/config.defaultValues.js b/data/config.defaultValues.js index a629f823..1cf77d7b 100644 --- a/data/config.defaultValues.js +++ b/data/config.defaultValues.js @@ -25,6 +25,18 @@ export const configDefaultValues = { 'aliases.workOrderCloseDate': 'Completion Date', 'settings.cemeteries.cityDefault': '', 'settings.cemeteries.provinceDefault': '', + 'settings.burialSites.burialSiteNameSegments': { + separator: '-', + segments: { + 1: { + isRequired: true, + isAvailable: true, + label: 'Plot Number', + minLength: 1, + maxLength: 20 + } + } + }, 'settings.contracts.burialSiteIdIsRequired': true, 'settings.contracts.cityDefault': '', 'settings.contracts.provinceDefault': '', diff --git a/data/config.defaultValues.ts b/data/config.defaultValues.ts index 2912809f..b990b70e 100644 --- a/data/config.defaultValues.ts +++ b/data/config.defaultValues.ts @@ -3,6 +3,7 @@ import type { config as MSSQLConfig } from 'mssql' import type { ConfigActiveDirectory, + ConfigBurialSiteNameSegments, ConfigNtfyStartup, DynamicsGPLookup } from '../types/configTypes.js' @@ -41,6 +42,20 @@ export const configDefaultValues = { 'settings.cemeteries.cityDefault': '', 'settings.cemeteries.provinceDefault': '', + 'settings.burialSites.burialSiteNameSegments': { + separator: '-', + segments: { + 1: { + isRequired: true, + isAvailable: true, + label: 'Plot Number', + minLength: 1, + maxLength: 20 + } + } + } as unknown as ConfigBurialSiteNameSegments, + + 'settings.contracts.burialSiteIdIsRequired': true, 'settings.contracts.cityDefault': '', 'settings.contracts.provinceDefault': '', diff --git a/database/addBurialSite.js b/database/addBurialSite.js index db2724a4..28f3eb62 100644 --- a/database/addBurialSite.js +++ b/database/addBurialSite.js @@ -1,8 +1,10 @@ +import { buildBurialSiteName } from '../helpers/burialSites.helpers.js'; import addOrUpdateBurialSiteField from './addOrUpdateBurialSiteField.js'; import { acquireConnection } from './pool.js'; export default async function addLot(burialSiteForm, user) { const database = await acquireConnection(); const rightNowMillis = Date.now(); + const burialSiteName = buildBurialSiteName(burialSiteForm); const result = database .prepare(`insert into BurialSites ( burialSiteNameSegment1, @@ -10,16 +12,17 @@ export default async function addLot(burialSiteForm, user) { burialSiteNameSegment3, burialSiteNameSegment4, burialSiteNameSegment5, + burialSiteName, burialSiteTypeId, burialSiteStatusId, cemeteryId, cemeterySvgId, burialSiteLatitude, burialSiteLongitude, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) - values (?, + values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`) - .run(burialSiteForm.burialSiteNameSegment1, burialSiteForm.burialSiteNameSegment2 ?? '', burialSiteForm.burialSiteNameSegment3 ?? '', burialSiteForm.burialSiteNameSegment4 ?? '', burialSiteForm.burialSiteNameSegment5 ?? '', burialSiteForm.burialSiteTypeId, burialSiteForm.burialSiteStatusId === '' ? undefined : burialSiteForm.burialSiteStatusId, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteLatitude === '' ? undefined : burialSiteForm.burialSiteLatitude, burialSiteForm.burialSiteLongitude === '' ? undefined : burialSiteForm.burialSiteLongitude, user.userName, rightNowMillis, user.userName, rightNowMillis); + .run(burialSiteForm.burialSiteNameSegment1, burialSiteForm.burialSiteNameSegment2 ?? '', burialSiteForm.burialSiteNameSegment3 ?? '', burialSiteForm.burialSiteNameSegment4 ?? '', burialSiteForm.burialSiteNameSegment5 ?? '', burialSiteName, burialSiteForm.burialSiteTypeId, burialSiteForm.burialSiteStatusId === '' ? undefined : burialSiteForm.burialSiteStatusId, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteLatitude === '' ? undefined : burialSiteForm.burialSiteLatitude, burialSiteForm.burialSiteLongitude === '' ? undefined : burialSiteForm.burialSiteLongitude, user.userName, rightNowMillis, user.userName, rightNowMillis); const burialSiteId = result.lastInsertRowid; const burialSiteTypeFieldIds = (burialSiteForm.burialSiteTypeFieldIds ?? '').split(','); for (const burialSiteTypeFieldId of burialSiteTypeFieldIds) { diff --git a/database/addBurialSite.ts b/database/addBurialSite.ts index eb5305ef..ed85c4c4 100644 --- a/database/addBurialSite.ts +++ b/database/addBurialSite.ts @@ -1,3 +1,5 @@ +import { buildBurialSiteName } from '../helpers/burialSites.helpers.js' + import addOrUpdateBurialSiteField from './addOrUpdateBurialSiteField.js' import { acquireConnection } from './pool.js' @@ -29,6 +31,8 @@ export default async function addLot( const rightNowMillis = Date.now() + const burialSiteName = buildBurialSiteName(burialSiteForm) + const result = database .prepare( `insert into BurialSites ( @@ -37,13 +41,14 @@ export default async function addLot( burialSiteNameSegment3, burialSiteNameSegment4, burialSiteNameSegment5, + burialSiteName, burialSiteTypeId, burialSiteStatusId, cemeteryId, cemeterySvgId, burialSiteLatitude, burialSiteLongitude, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) - values (?, + values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` ) @@ -53,6 +58,7 @@ export default async function addLot( burialSiteForm.burialSiteNameSegment3 ?? '', burialSiteForm.burialSiteNameSegment4 ?? '', burialSiteForm.burialSiteNameSegment5 ?? '', + burialSiteName, burialSiteForm.burialSiteTypeId, burialSiteForm.burialSiteStatusId === '' ? undefined : burialSiteForm.burialSiteStatusId, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, diff --git a/database/addBurialSiteContract.d.ts b/database/addBurialSiteContract.d.ts index eb88ac67..393303ae 100644 --- a/database/addBurialSiteContract.d.ts +++ b/database/addBurialSiteContract.d.ts @@ -18,4 +18,4 @@ export interface AddBurialSiteContractForm { occupantEmailAddress?: string; occupantComment?: string; } -export default function addLotOccupancy(addForm: AddBurialSiteContractForm, user: User, connectedDatabase?: PoolConnection): Promise; +export default function addBurialSiteContract(addForm: AddBurialSiteContractForm, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/addBurialSiteContract.js b/database/addBurialSiteContract.js index c215e262..1ff5f145 100644 --- a/database/addBurialSiteContract.js +++ b/database/addBurialSiteContract.js @@ -1,8 +1,8 @@ import { dateStringToInteger } from '@cityssm/utils-datetime'; -import addLotOccupancyOccupant from './addLotOccupancyOccupant.js'; +import addBurialSiteContractOccupant from './addBurialSiteContractOccupant.js'; import addOrUpdateBurialSiteContractField from './addOrUpdateBurialSiteContractField.js'; import { acquireConnection } from './pool.js'; -export default async function addLotOccupancy(addForm, user, connectedDatabase) { +export default async function addBurialSiteContract(addForm, user, connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); const rightNowMillis = Date.now(); const contractStartDate = dateStringToInteger(addForm.contractStartDateString); @@ -22,17 +22,17 @@ export default async function addLotOccupancy(addForm, user, connectedDatabase) const burialSiteContractId = result.lastInsertRowid; const contractTypeFieldIds = (addForm.contractTypeFieldIds ?? '').split(','); for (const contractTypeFieldId of contractTypeFieldIds) { - const lotOccupancyFieldValue = addForm[`lotOccupancyFieldValue_${contractTypeFieldId}`]; - if ((lotOccupancyFieldValue ?? '') !== '') { + const burialSiteContractFieldValue = addForm[`burialSiteContractFieldValue_${contractTypeFieldId}`]; + if ((burialSiteContractFieldValue ?? '') !== '') { await addOrUpdateBurialSiteContractField({ burialSiteContractId, contractTypeFieldId, - lotOccupancyFieldValue: lotOccupancyFieldValue ?? '' + burialSiteContractFieldValue: burialSiteContractFieldValue ?? '' }, user, database); } } if ((addForm.lotOccupantTypeId ?? '') !== '') { - await addLotOccupancyOccupant({ + await addBurialSiteContractOccupant({ burialSiteContractId, lotOccupantTypeId: addForm.lotOccupantTypeId ?? '', occupantName: addForm.occupantName ?? '', diff --git a/database/addBurialSiteContract.ts b/database/addBurialSiteContract.ts index 0d12dd38..1c85e497 100644 --- a/database/addBurialSiteContract.ts +++ b/database/addBurialSiteContract.ts @@ -1,7 +1,7 @@ import { type DateString, dateStringToInteger } from '@cityssm/utils-datetime' import type { PoolConnection } from 'better-sqlite-pool' -import addLotOccupancyOccupant from './addLotOccupancyOccupant.js' +import addBurialSiteContractOccupant from './addBurialSiteContractOccupant.js' import addOrUpdateBurialSiteContractField from './addOrUpdateBurialSiteContractField.js' import { acquireConnection } from './pool.js' @@ -28,7 +28,7 @@ export interface AddBurialSiteContractForm { occupantComment?: string } -export default async function addLotOccupancy( +export default async function addBurialSiteContract( addForm: AddBurialSiteContractForm, user: User, connectedDatabase?: PoolConnection @@ -76,16 +76,16 @@ export default async function addLotOccupancy( ).split(',') for (const contractTypeFieldId of contractTypeFieldIds) { - const lotOccupancyFieldValue = addForm[ - `lotOccupancyFieldValue_${contractTypeFieldId}` + const burialSiteContractFieldValue = addForm[ + `burialSiteContractFieldValue_${contractTypeFieldId}` ] as string | undefined - if ((lotOccupancyFieldValue ?? '') !== '') { + if ((burialSiteContractFieldValue ?? '') !== '') { await addOrUpdateBurialSiteContractField( { burialSiteContractId, contractTypeFieldId, - lotOccupancyFieldValue: lotOccupancyFieldValue ?? '' + burialSiteContractFieldValue: burialSiteContractFieldValue ?? '' }, user, database @@ -94,7 +94,7 @@ export default async function addLotOccupancy( } if ((addForm.lotOccupantTypeId ?? '') !== '') { - await addLotOccupancyOccupant( + await addBurialSiteContractOccupant( { burialSiteContractId, lotOccupantTypeId: addForm.lotOccupantTypeId ?? '', diff --git a/database/addBurialSiteContractComment.d.ts b/database/addBurialSiteContractComment.d.ts index b48ab570..26bd1d48 100644 --- a/database/addBurialSiteContractComment.d.ts +++ b/database/addBurialSiteContractComment.d.ts @@ -5,4 +5,4 @@ export interface AddBurialSiteContractCommentForm { commentTimeString?: TimeString; comment: string; } -export default function addLotOccupancyComment(commentForm: AddBurialSiteContractCommentForm, user: User): Promise; +export default function addBurialSiteContractComment(commentForm: AddBurialSiteContractCommentForm, user: User): Promise; diff --git a/database/addBurialSiteContractComment.js b/database/addBurialSiteContractComment.js index 2a0a133a..ddd2075e 100644 --- a/database/addBurialSiteContractComment.js +++ b/database/addBurialSiteContractComment.js @@ -1,6 +1,6 @@ import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/utils-datetime'; import { acquireConnection } from './pool.js'; -export default async function addLotOccupancyComment(commentForm, user) { +export default async function addBurialSiteContractComment(commentForm, user) { const rightNow = new Date(); let commentDate = 0; let commentTime = 0; diff --git a/database/addBurialSiteContractComment.ts b/database/addBurialSiteContractComment.ts index 19ede41c..58f582fc 100644 --- a/database/addBurialSiteContractComment.ts +++ b/database/addBurialSiteContractComment.ts @@ -16,7 +16,7 @@ export interface AddBurialSiteContractCommentForm { comment: string } -export default async function addLotOccupancyComment( +export default async function addBurialSiteContractComment( commentForm: AddBurialSiteContractCommentForm, user: User ): Promise { diff --git a/database/addBurialSiteContractFee.js b/database/addBurialSiteContractFee.js index 9d438a53..bccf2f06 100644 --- a/database/addBurialSiteContractFee.js +++ b/database/addBurialSiteContractFee.js @@ -9,9 +9,9 @@ export default async function addBurialSiteContractFee(addFeeForm, user, connect let feeAmount; let taxAmount; if ((addFeeForm.feeAmount ?? '') === '') { - const lotOccupancy = (await getBurialSiteContract(addFeeForm.burialSiteContractId)); + const burialSiteContract = (await getBurialSiteContract(addFeeForm.burialSiteContractId)); const fee = (await getFee(addFeeForm.feeId)); - feeAmount = calculateFeeAmount(fee, lotOccupancy); + feeAmount = calculateFeeAmount(fee, burialSiteContract); taxAmount = calculateTaxAmount(fee, feeAmount); } else { diff --git a/database/addBurialSiteContractFee.ts b/database/addBurialSiteContractFee.ts index 582a7081..79d969f7 100644 --- a/database/addBurialSiteContractFee.ts +++ b/database/addBurialSiteContractFee.ts @@ -32,13 +32,13 @@ export default async function addBurialSiteContractFee( let taxAmount: number if ((addFeeForm.feeAmount ?? '') === '') { - const lotOccupancy = (await getBurialSiteContract( + const burialSiteContract = (await getBurialSiteContract( addFeeForm.burialSiteContractId )) as BurialSiteContract const fee = (await getFee(addFeeForm.feeId)) as Fee - feeAmount = calculateFeeAmount(fee, lotOccupancy) + feeAmount = calculateFeeAmount(fee, burialSiteContract) taxAmount = calculateTaxAmount(fee, feeAmount) } else { feeAmount = diff --git a/database/addBurialSiteContractFeeCategory.d.ts b/database/addBurialSiteContractFeeCategory.d.ts index 007e8fe0..c1e5ec9e 100644 --- a/database/addBurialSiteContractFeeCategory.d.ts +++ b/database/addBurialSiteContractFeeCategory.d.ts @@ -2,4 +2,4 @@ export interface AddBurialSiteContractCategoryForm { burialSiteContractId: number | string; feeCategoryId: number | string; } -export default function addLotOccupancyFeeCategory(addFeeCategoryForm: AddBurialSiteContractCategoryForm, user: User): Promise; +export default function addBurialSiteContractFeeCategory(addFeeCategoryForm: AddBurialSiteContractCategoryForm, user: User): Promise; diff --git a/database/addBurialSiteContractFeeCategory.js b/database/addBurialSiteContractFeeCategory.js index 9f6b50ab..807c3746 100644 --- a/database/addBurialSiteContractFeeCategory.js +++ b/database/addBurialSiteContractFeeCategory.js @@ -1,7 +1,7 @@ import addBurialSiteContractFee from './addBurialSiteContractFee.js'; import { getFeeCategory } from './getFeeCategories.js'; import { acquireConnection } from './pool.js'; -export default async function addLotOccupancyFeeCategory(addFeeCategoryForm, user) { +export default async function addBurialSiteContractFeeCategory(addFeeCategoryForm, user) { const database = await acquireConnection(); const feeCategory = await getFeeCategory(addFeeCategoryForm.feeCategoryId, database); let addedFeeCount = 0; diff --git a/database/addBurialSiteContractFeeCategory.ts b/database/addBurialSiteContractFeeCategory.ts index c795e020..cacac923 100644 --- a/database/addBurialSiteContractFeeCategory.ts +++ b/database/addBurialSiteContractFeeCategory.ts @@ -7,7 +7,7 @@ export interface AddBurialSiteContractCategoryForm { feeCategoryId: number | string } -export default async function addLotOccupancyFeeCategory( +export default async function addBurialSiteContractFeeCategory( addFeeCategoryForm: AddBurialSiteContractCategoryForm, user: User ): Promise { diff --git a/database/addLotOccupancyTransaction.d.ts b/database/addBurialSiteContractTransaction.d.ts similarity index 56% rename from database/addLotOccupancyTransaction.d.ts rename to database/addBurialSiteContractTransaction.d.ts index efbc616e..214bbcd4 100644 --- a/database/addLotOccupancyTransaction.d.ts +++ b/database/addBurialSiteContractTransaction.d.ts @@ -1,4 +1,4 @@ -export interface AddLotOccupancyTransactionForm { +export interface AddTransactionForm { burialSiteContractId: string | number; transactionDateString?: string; transactionTimeString?: string; @@ -6,4 +6,4 @@ export interface AddLotOccupancyTransactionForm { externalReceiptNumber: string; transactionNote: string; } -export default function addLotOccupancyTransaction(lotOccupancyTransactionForm: AddLotOccupancyTransactionForm, user: User): Promise; +export default function addBurialSiteContractTransaction(burialSiteContractTransactionForm: AddTransactionForm, user: User): Promise; diff --git a/database/addLotOccupancyTransaction.js b/database/addBurialSiteContractTransaction.js similarity index 51% rename from database/addLotOccupancyTransaction.js rename to database/addBurialSiteContractTransaction.js index 559a4754..9bc6e86b 100644 --- a/database/addLotOccupancyTransaction.js +++ b/database/addBurialSiteContractTransaction.js @@ -1,34 +1,34 @@ import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/utils-datetime'; import { acquireConnection } from './pool.js'; -export default async function addLotOccupancyTransaction(lotOccupancyTransactionForm, user) { +export default async function addBurialSiteContractTransaction(burialSiteContractTransactionForm, user) { const database = await acquireConnection(); let transactionIndex = 0; const maxIndexResult = database .prepare(`select transactionIndex - from LotOccupancyTransactions + from BurialSiteContractTransactions where burialSiteContractId = ? order by transactionIndex desc limit 1`) - .get(lotOccupancyTransactionForm.burialSiteContractId); + .get(burialSiteContractTransactionForm.burialSiteContractId); if (maxIndexResult !== undefined) { transactionIndex = maxIndexResult.transactionIndex + 1; } const rightNow = new Date(); - const transactionDate = lotOccupancyTransactionForm.transactionDateString - ? dateStringToInteger(lotOccupancyTransactionForm.transactionDateString) + const transactionDate = burialSiteContractTransactionForm.transactionDateString + ? dateStringToInteger(burialSiteContractTransactionForm.transactionDateString) : dateToInteger(rightNow); - const transactionTime = lotOccupancyTransactionForm.transactionTimeString - ? timeStringToInteger(lotOccupancyTransactionForm.transactionTimeString) + const transactionTime = burialSiteContractTransactionForm.transactionTimeString + ? timeStringToInteger(burialSiteContractTransactionForm.transactionTimeString) : dateToTimeInteger(rightNow); database - .prepare(`insert into LotOccupancyTransactions ( + .prepare(`insert into BurialSiteContractTransactions ( burialSiteContractId, transactionIndex, transactionDate, transactionTime, transactionAmount, externalReceiptNumber, transactionNote, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`) - .run(lotOccupancyTransactionForm.burialSiteContractId, transactionIndex, transactionDate, transactionTime, lotOccupancyTransactionForm.transactionAmount, lotOccupancyTransactionForm.externalReceiptNumber, lotOccupancyTransactionForm.transactionNote, user.userName, rightNow.getTime(), user.userName, rightNow.getTime()); + .run(burialSiteContractTransactionForm.burialSiteContractId, transactionIndex, transactionDate, transactionTime, burialSiteContractTransactionForm.transactionAmount, burialSiteContractTransactionForm.externalReceiptNumber, burialSiteContractTransactionForm.transactionNote, user.userName, rightNow.getTime(), user.userName, rightNow.getTime()); database.release(); return transactionIndex; } diff --git a/database/addLotOccupancyTransaction.ts b/database/addBurialSiteContractTransaction.ts similarity index 62% rename from database/addLotOccupancyTransaction.ts rename to database/addBurialSiteContractTransaction.ts index c3b689fb..1152bbc1 100644 --- a/database/addLotOccupancyTransaction.ts +++ b/database/addBurialSiteContractTransaction.ts @@ -7,7 +7,7 @@ import { import { acquireConnection } from './pool.js' -export interface AddLotOccupancyTransactionForm { +export interface AddTransactionForm { burialSiteContractId: string | number transactionDateString?: string transactionTimeString?: string @@ -16,8 +16,8 @@ export interface AddLotOccupancyTransactionForm { transactionNote: string } -export default async function addLotOccupancyTransaction( - lotOccupancyTransactionForm: AddLotOccupancyTransactionForm, +export default async function addBurialSiteContractTransaction( + burialSiteContractTransactionForm: AddTransactionForm, user: User ): Promise { const database = await acquireConnection() @@ -27,12 +27,12 @@ export default async function addLotOccupancyTransaction( const maxIndexResult = database .prepare( `select transactionIndex - from LotOccupancyTransactions + from BurialSiteContractTransactions where burialSiteContractId = ? order by transactionIndex desc limit 1` ) - .get(lotOccupancyTransactionForm.burialSiteContractId) as + .get(burialSiteContractTransactionForm.burialSiteContractId) as | { transactionIndex: number } | undefined @@ -42,17 +42,17 @@ export default async function addLotOccupancyTransaction( const rightNow = new Date() - const transactionDate = lotOccupancyTransactionForm.transactionDateString - ? dateStringToInteger(lotOccupancyTransactionForm.transactionDateString) + const transactionDate = burialSiteContractTransactionForm.transactionDateString + ? dateStringToInteger(burialSiteContractTransactionForm.transactionDateString) : dateToInteger(rightNow) - const transactionTime = lotOccupancyTransactionForm.transactionTimeString - ? timeStringToInteger(lotOccupancyTransactionForm.transactionTimeString) + const transactionTime = burialSiteContractTransactionForm.transactionTimeString + ? timeStringToInteger(burialSiteContractTransactionForm.transactionTimeString) : dateToTimeInteger(rightNow) database .prepare( - `insert into LotOccupancyTransactions ( + `insert into BurialSiteContractTransactions ( burialSiteContractId, transactionIndex, transactionDate, transactionTime, transactionAmount, externalReceiptNumber, transactionNote, @@ -61,13 +61,13 @@ export default async function addLotOccupancyTransaction( values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` ) .run( - lotOccupancyTransactionForm.burialSiteContractId, + burialSiteContractTransactionForm.burialSiteContractId, transactionIndex, transactionDate, transactionTime, - lotOccupancyTransactionForm.transactionAmount, - lotOccupancyTransactionForm.externalReceiptNumber, - lotOccupancyTransactionForm.transactionNote, + burialSiteContractTransactionForm.transactionAmount, + burialSiteContractTransactionForm.externalReceiptNumber, + burialSiteContractTransactionForm.transactionNote, user.userName, rightNow.getTime(), user.userName, diff --git a/database/copyBurialSiteContract.js b/database/copyBurialSiteContract.js index 8f5fa336..8692a3e7 100644 --- a/database/copyBurialSiteContract.js +++ b/database/copyBurialSiteContract.js @@ -1,7 +1,7 @@ import { dateToString } from '@cityssm/utils-datetime'; import addBurialSiteContract from './addBurialSiteContract.js'; import addBurialSiteContractComment from './addBurialSiteContractComment.js'; -// import addLotOccupancyOccupant from './addLotOccupancyOccupant.js' +// import addBurialSiteContractOccupant from './addBurialSiteContractOccupant.js' import getBurialSiteContract from './getBurialSiteContract.js'; import { acquireConnection } from './pool.js'; export default async function copyBurialSiteContract(oldBurialSiteContractId, user) { @@ -30,8 +30,8 @@ export default async function copyBurialSiteContract(oldBurialSiteContractId, us * Copy Occupants */ /* - for (const occupant of oldBurialSiteContract.lotOccupancyOccupants ?? []) { - await addLotOccupancyOccupant( + for (const occupant of oldBurialSiteContract.burialSiteContractOccupants ?? []) { + await addBurialSiteContractOccupant( { burialSiteContractId: newBurialSiteContractId, lotOccupantTypeId: occupant.lotOccupantTypeId!, diff --git a/database/copyBurialSiteContract.ts b/database/copyBurialSiteContract.ts index 7f0cb579..afca0bc7 100644 --- a/database/copyBurialSiteContract.ts +++ b/database/copyBurialSiteContract.ts @@ -4,7 +4,7 @@ import type { BurialSiteContract } from '../types/recordTypes.js' import addBurialSiteContract from './addBurialSiteContract.js' import addBurialSiteContractComment from './addBurialSiteContractComment.js' -// import addLotOccupancyOccupant from './addLotOccupancyOccupant.js' +// import addBurialSiteContractOccupant from './addBurialSiteContractOccupant.js' import getBurialSiteContract from './getBurialSiteContract.js' import { acquireConnection } from './pool.js' @@ -58,8 +58,8 @@ export default async function copyBurialSiteContract( */ /* - for (const occupant of oldBurialSiteContract.lotOccupancyOccupants ?? []) { - await addLotOccupancyOccupant( + for (const occupant of oldBurialSiteContract.burialSiteContractOccupants ?? []) { + await addBurialSiteContractOccupant( { burialSiteContractId: newBurialSiteContractId, lotOccupantTypeId: occupant.lotOccupantTypeId!, diff --git a/database/getBurialSite.d.ts b/database/getBurialSite.d.ts index af9a1aa9..01b95d74 100644 --- a/database/getBurialSite.d.ts +++ b/database/getBurialSite.d.ts @@ -1,2 +1,3 @@ -export declare function getLotByLotName(lotName: string): Promise; -export default function getLot(burialSiteId: number | string): Promise; +import type { BurialSite } from '../types/recordTypes.js'; +export declare function getBurialSiteByBurialSiteName(burialSiteName: string): Promise; +export default function getBurialSite(burialSiteId: number | string): Promise; diff --git a/database/getBurialSite.js b/database/getBurialSite.js index 1f7d8ee6..47ceeaa8 100644 --- a/database/getBurialSite.js +++ b/database/getBurialSite.js @@ -9,40 +9,40 @@ const baseSQL = `select l.burialSiteId, l.burialSiteNameSegment3, l.burialSiteNameSegment4, l.burialSiteNameSegment5, + l.burialSiteName, l.burialSiteStatusId, s.burialSiteStatus, l.cemeteryId, m.cemeteryName, m.cemeterySvg, l.cemeterySvgId, l.burialSiteLatitude, l.burialSiteLongitude, - from BurialSites l - left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId - left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId - left join Cemeteries m on l.cemeteryId = m.cemeteryId - where l.recordDelete_timeMillis is null`; + from BurialSites l + left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId + left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId + left join Cemeteries m on l.cemeteryId = m.cemeteryId + where l.recordDelete_timeMillis is null`; async function _getBurialSite(sql, burialSiteIdOrLotName) { const database = await acquireConnection(); const burialSite = database.prepare(sql).get(burialSiteIdOrLotName); if (burialSite !== undefined) { - const BurialSiteContracts = await getBurialSiteInterments({ + const burialSiteContracts = await getBurialSiteInterments({ burialSiteId: burialSite.burialSiteId }, { - includeOccupants: true, + includeInterments: true, includeFees: false, includeTransactions: false, limit: -1, offset: 0 }, database); - burialSite.burialSiteContracts = BurialSiteContracts.BurialSiteContracts; + burialSite.burialSiteContracts = burialSiteContracts.burialSiteContracts; burialSite.burialSiteFields = await getBurialSiteFields(burialSite.burialSiteId, database); burialSite.burialSiteComments = await getBurialSiteComments(burialSite.burialSiteId, database); } database.release(); return burialSite; } -// TODO -export async function getLotByLotName(lotName) { - return await _getBurialSite(`${baseSQL} and l.lotName = ?`, lotName); +export async function getBurialSiteByBurialSiteName(burialSiteName) { + return await _getBurialSite(`${baseSQL} and l.burialSiteName = ?`, burialSiteName); } -export default async function getLot(burialSiteId) { +export default async function getBurialSite(burialSiteId) { return await _getBurialSite(`${baseSQL} and l.burialSiteId = ?`, burialSiteId); } diff --git a/database/getBurialSite.ts b/database/getBurialSite.ts index d8c76915..dbf934d3 100644 --- a/database/getBurialSite.ts +++ b/database/getBurialSite.ts @@ -12,16 +12,17 @@ const baseSQL = `select l.burialSiteId, l.burialSiteNameSegment3, l.burialSiteNameSegment4, l.burialSiteNameSegment5, + l.burialSiteName, l.burialSiteStatusId, s.burialSiteStatus, l.cemeteryId, m.cemeteryName, m.cemeterySvg, l.cemeterySvgId, l.burialSiteLatitude, l.burialSiteLongitude, - from BurialSites l - left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId - left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId - left join Cemeteries m on l.cemeteryId = m.cemeteryId - where l.recordDelete_timeMillis is null` + from BurialSites l + left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId + left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId + left join Cemeteries m on l.cemeteryId = m.cemeteryId + where l.recordDelete_timeMillis is null` async function _getBurialSite( sql: string, @@ -32,12 +33,12 @@ async function _getBurialSite( const burialSite = database.prepare(sql).get(burialSiteIdOrLotName) as BurialSite | undefined if (burialSite !== undefined) { - const BurialSiteContracts = await getBurialSiteInterments( + const burialSiteContracts = await getBurialSiteInterments( { burialSiteId: burialSite.burialSiteId }, { - includeOccupants: true, + includeInterments: true, includeFees: false, includeTransactions: false, limit: -1, @@ -46,7 +47,7 @@ async function _getBurialSite( database ) - burialSite.burialSiteContracts = BurialSiteContracts.BurialSiteContracts + burialSite.burialSiteContracts = burialSiteContracts.burialSiteContracts burialSite.burialSiteFields = await getBurialSiteFields(burialSite.burialSiteId, database) @@ -58,15 +59,14 @@ async function _getBurialSite( return burialSite } -// TODO -export async function getLotByLotName( - lotName: string -): Promise { - return await _getBurialSite(`${baseSQL} and l.lotName = ?`, lotName) +export async function getBurialSiteByBurialSiteName( + burialSiteName: string +): Promise { + return await _getBurialSite(`${baseSQL} and l.burialSiteName = ?`, burialSiteName) } -export default async function getLot( +export default async function getBurialSite( burialSiteId: number | string -): Promise { +): Promise { return await _getBurialSite(`${baseSQL} and l.burialSiteId = ?`, burialSiteId) } diff --git a/database/getBurialSiteContract.d.ts b/database/getBurialSiteContract.d.ts index c6e91bd4..01f8eee4 100644 --- a/database/getBurialSiteContract.d.ts +++ b/database/getBurialSiteContract.d.ts @@ -1,3 +1,3 @@ import type { PoolConnection } from 'better-sqlite-pool'; import type { BurialSiteContract } from '../types/recordTypes.js'; -export default function getLotOccupancy(burialSiteContractId: number | string, connectedDatabase?: PoolConnection): Promise; +export default function getBurialSiteContract(burialSiteContractId: number | string, connectedDatabase?: PoolConnection): Promise; diff --git a/database/getBurialSiteContract.js b/database/getBurialSiteContract.js index 65d6d822..ea0c92aa 100644 --- a/database/getBurialSiteContract.js +++ b/database/getBurialSiteContract.js @@ -2,22 +2,18 @@ import { dateIntegerToString } from '@cityssm/utils-datetime'; import getBurialSiteContractComments from './getBurialSiteContractComments.js'; import getBurialSiteContractFees from './getBurialSiteContractFees.js'; import getBurialSiteContractFields from './getBurialSiteContractFields.js'; -// import getLotOccupancyOccupants from './getLotOccupancyOccupants.js' +// import getBurialSiteContractOccupants from './getBurialSiteContractOccupants.js' import getBurialSiteContractTransactions from './getBurialSiteContractTransactions.js'; import { getWorkOrders } from './getWorkOrders.js'; import { acquireConnection } from './pool.js'; -export default async function getLotOccupancy(burialSiteContractId, connectedDatabase) { +export default async function getBurialSiteContract(burialSiteContractId, connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); database.function('userFn_dateIntegerToString', dateIntegerToString); const contract = database .prepare(`select o.burialSiteContractId, o.contractTypeId, t.contractType, o.burialSiteId, - l.burialSiteNameSegment1, - l.burialSiteNameSegment2, - l.burialSiteNameSegment3, - l.burialSiteNameSegment4, - l.burialSiteNameSegment5, + l.burialSiteName, l.burialSiteTypeId, l.cemeteryId, m.cemeteryName, o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString, @@ -33,7 +29,7 @@ export default async function getLotOccupancy(burialSiteContractId, connectedDat if (contract !== undefined) { contract.burialSiteContractFields = await getBurialSiteContractFields(burialSiteContractId, database); /* - contract.burialSiteContractInterments = await getLotOccupancyOccupants( + contract.burialSiteContractInterments = await getBurialSiteContractOccupants( burialSiteContractId, database ) diff --git a/database/getBurialSiteContract.ts b/database/getBurialSiteContract.ts index a1b6ed94..210883bd 100644 --- a/database/getBurialSiteContract.ts +++ b/database/getBurialSiteContract.ts @@ -6,12 +6,12 @@ import type { BurialSiteContract } from '../types/recordTypes.js' import getBurialSiteContractComments from './getBurialSiteContractComments.js' import getBurialSiteContractFees from './getBurialSiteContractFees.js' import getBurialSiteContractFields from './getBurialSiteContractFields.js' -// import getLotOccupancyOccupants from './getLotOccupancyOccupants.js' +// import getBurialSiteContractOccupants from './getBurialSiteContractOccupants.js' import getBurialSiteContractTransactions from './getBurialSiteContractTransactions.js' import { getWorkOrders } from './getWorkOrders.js' import { acquireConnection } from './pool.js' -export default async function getLotOccupancy( +export default async function getBurialSiteContract( burialSiteContractId: number | string, connectedDatabase?: PoolConnection ): Promise { @@ -24,11 +24,7 @@ export default async function getLotOccupancy( `select o.burialSiteContractId, o.contractTypeId, t.contractType, o.burialSiteId, - l.burialSiteNameSegment1, - l.burialSiteNameSegment2, - l.burialSiteNameSegment3, - l.burialSiteNameSegment4, - l.burialSiteNameSegment5, + l.burialSiteName, l.burialSiteTypeId, l.cemeteryId, m.cemeteryName, o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString, @@ -49,7 +45,7 @@ export default async function getLotOccupancy( database ) /* - contract.burialSiteContractInterments = await getLotOccupancyOccupants( + contract.burialSiteContractInterments = await getBurialSiteContractOccupants( burialSiteContractId, database ) diff --git a/database/getBurialSiteContractTransactions.js b/database/getBurialSiteContractTransactions.js index 4c36858c..bfc1e718 100644 --- a/database/getBurialSiteContractTransactions.js +++ b/database/getBurialSiteContractTransactions.js @@ -6,7 +6,7 @@ export default async function GetBurialSiteContractTransactions(burialSiteContra const database = connectedDatabase ?? (await acquireConnection()); database.function('userFn_dateIntegerToString', dateIntegerToString); database.function('userFn_timeIntegerToString', timeIntegerToString); - const lotOccupancyTransactions = database + const burialSiteContractTransactions = database .prepare(`select burialSiteContractId, transactionIndex, transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString, transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString, @@ -21,7 +21,7 @@ export default async function GetBurialSiteContractTransactions(burialSiteContra } if (options.includeIntegrations && getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) { - for (const transaction of lotOccupancyTransactions) { + for (const transaction of burialSiteContractTransactions) { if ((transaction.externalReceiptNumber ?? '') !== '') { const gpDocument = await getDynamicsGPDocument(transaction.externalReceiptNumber ?? ''); if (gpDocument !== undefined) { @@ -30,5 +30,5 @@ export default async function GetBurialSiteContractTransactions(burialSiteContra } } } - return lotOccupancyTransactions; + return burialSiteContractTransactions; } diff --git a/database/getBurialSiteContractTransactions.ts b/database/getBurialSiteContractTransactions.ts index d49eab0c..aa945088 100644 --- a/database/getBurialSiteContractTransactions.ts +++ b/database/getBurialSiteContractTransactions.ts @@ -22,7 +22,7 @@ export default async function GetBurialSiteContractTransactions( database.function('userFn_dateIntegerToString', dateIntegerToString) database.function('userFn_timeIntegerToString', timeIntegerToString) - const lotOccupancyTransactions = database + const burialSiteContractTransactions = database .prepare( `select burialSiteContractId, transactionIndex, transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString, @@ -43,7 +43,7 @@ export default async function GetBurialSiteContractTransactions( options.includeIntegrations && getConfigProperty('settings.dynamicsGP.integrationIsEnabled') ) { - for (const transaction of lotOccupancyTransactions) { + for (const transaction of burialSiteContractTransactions) { if ((transaction.externalReceiptNumber ?? '') !== '') { const gpDocument = await getDynamicsGPDocument( transaction.externalReceiptNumber ?? '' @@ -56,5 +56,5 @@ export default async function GetBurialSiteContractTransactions( } } - return lotOccupancyTransactions + return burialSiteContractTransactions } diff --git a/database/getBurialSiteContracts.d.ts b/database/getBurialSiteContracts.d.ts index 067a45b3..3e9cbb13 100644 --- a/database/getBurialSiteContracts.d.ts +++ b/database/getBurialSiteContracts.d.ts @@ -1,7 +1,7 @@ import { type DateString } from '@cityssm/utils-datetime'; import type { PoolConnection } from 'better-sqlite-pool'; import type { BurialSiteContract } from '../types/recordTypes.js'; -interface GetBurialSiteContractsFilters { +export interface GetBurialSiteContractsFilters { burialSiteId?: number | string; occupancyTime?: '' | 'past' | 'current' | 'future'; contractStartDateString?: DateString; @@ -15,10 +15,10 @@ interface GetBurialSiteContractsFilters { workOrderId?: number | string; notWorkOrderId?: number | string; } -interface GetBurialSiteContractsOptions { +export interface GetBurialSiteContractsOptions { /** -1 for no limit */ - limit: number; - offset: number; + limit: number | string; + offset: number | string; includeInterments: boolean; includeFees: boolean; includeTransactions: boolean; @@ -27,4 +27,3 @@ export default function getBurialSiteContracts(filters: GetBurialSiteContractsFi count: number; burialSiteContracts: BurialSiteContract[]; }>; -export {}; diff --git a/database/getBurialSiteContracts.js b/database/getBurialSiteContracts.js index eecb2b73..d4972774 100644 --- a/database/getBurialSiteContracts.js +++ b/database/getBurialSiteContracts.js @@ -1,9 +1,9 @@ import { dateIntegerToString, dateStringToInteger } from '@cityssm/utils-datetime'; import { getConfigProperty } from '../helpers/config.helpers.js'; import { getContractTypeById } from '../helpers/functions.cache.js'; -import { getLotNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js'; +import { getBurialSiteNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js'; import getBurialSiteContractFees from './getBurialSiteContractFees.js'; -// import getLotOccupancyOccupants from './getLotOccupancyOccupants.js' +// import getBurialSiteContractOccupants from './getBurialSiteContractOccupants.js' import getBurialSiteContractTransactions from './getBurialSiteContractTransactions.js'; import { acquireConnection } from './pool.js'; function buildWhereClause(filters) { @@ -13,7 +13,7 @@ function buildWhereClause(filters) { sqlWhereClause += ' and o.lotId = ?'; sqlParameters.push(filters.burialSiteId); } - const lotNameFilters = getLotNameWhereClause(filters.burialSiteName, filters.burialSiteNameSearchType ?? '', 'l'); + const lotNameFilters = getBurialSiteNameWhereClause(filters.burialSiteName, filters.burialSiteNameSearchType ?? '', 'l'); sqlWhereClause += lotNameFilters.sqlWhereClause; sqlParameters.push(...lotNameFilters.sqlParameters); const occupantNameFilters = getOccupantNameWhereClause(filters.occupantName, 'o'); @@ -76,7 +76,7 @@ async function addInclusions(burialSiteContract, options, database) { /* if (options.includeInterments) { burialSiteContract.burialSiteContractInterments = - await getLotOccupancyOccupants( + await getBurialSiteContractOccupants( burialSiteContract.burialSiteContractId, database ) @@ -88,7 +88,9 @@ export default async function getBurialSiteContracts(filters, options, connected const database = connectedDatabase ?? (await acquireConnection()); database.function('userFn_dateIntegerToString', dateIntegerToString); const { sqlWhereClause, sqlParameters } = buildWhereClause(filters); - let count = options.limit; + let count = typeof options.limit === 'string' + ? Number.parseInt(options.limit, 10) + : options.limit; const isLimited = options.limit !== -1; if (isLimited) { count = database @@ -104,11 +106,7 @@ export default async function getBurialSiteContracts(filters, options, connected .prepare(`select o.burialSiteContractId, o.contractTypeId, t.contractType, o.burialSiteId, lt.burialSiteType, - l.burialSiteNameSegment1, - l.burialSiteNameSegment2, - l.burialSiteNameSegment3, - l.burialSiteNameSegment4, - l.burialSiteNameSegment5, + l.burialSiteName, l.cemeteryId, m.cemeteryName, o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString, o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString diff --git a/database/getBurialSiteContracts.ts b/database/getBurialSiteContracts.ts index 310bed1b..00d086aa 100644 --- a/database/getBurialSiteContracts.ts +++ b/database/getBurialSiteContracts.ts @@ -8,18 +8,18 @@ import type { PoolConnection } from 'better-sqlite-pool' import { getConfigProperty } from '../helpers/config.helpers.js' import { getContractTypeById } from '../helpers/functions.cache.js' import { - getLotNameWhereClause, + getBurialSiteNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js' import type { BurialSiteContract } from '../types/recordTypes.js' import getBurialSiteContractFees from './getBurialSiteContractFees.js' -// import getLotOccupancyOccupants from './getLotOccupancyOccupants.js' +// import getBurialSiteContractOccupants from './getBurialSiteContractOccupants.js' import getBurialSiteContractTransactions from './getBurialSiteContractTransactions.js' import { acquireConnection } from './pool.js' -interface GetBurialSiteContractsFilters { +export interface GetBurialSiteContractsFilters { burialSiteId?: number | string occupancyTime?: '' | 'past' | 'current' | 'future' contractStartDateString?: DateString @@ -34,10 +34,10 @@ interface GetBurialSiteContractsFilters { notWorkOrderId?: number | string } -interface GetBurialSiteContractsOptions { +export interface GetBurialSiteContractsOptions { /** -1 for no limit */ - limit: number - offset: number + limit: number | string + offset: number | string includeInterments: boolean includeFees: boolean includeTransactions: boolean @@ -55,7 +55,7 @@ function buildWhereClause(filters: GetBurialSiteContractsFilters): { sqlParameters.push(filters.burialSiteId) } - const lotNameFilters = getLotNameWhereClause( + const lotNameFilters = getBurialSiteNameWhereClause( filters.burialSiteName, filters.burialSiteNameSearchType ?? '', 'l' @@ -157,7 +157,7 @@ async function addInclusions( /* if (options.includeInterments) { burialSiteContract.burialSiteContractInterments = - await getLotOccupancyOccupants( + await getBurialSiteContractOccupants( burialSiteContract.burialSiteContractId, database ) @@ -178,7 +178,10 @@ export default async function getBurialSiteContracts( const { sqlWhereClause, sqlParameters } = buildWhereClause(filters) - let count = options.limit + let count = + typeof options.limit === 'string' + ? Number.parseInt(options.limit, 10) + : options.limit const isLimited = options.limit !== -1 @@ -203,11 +206,7 @@ export default async function getBurialSiteContracts( `select o.burialSiteContractId, o.contractTypeId, t.contractType, o.burialSiteId, lt.burialSiteType, - l.burialSiteNameSegment1, - l.burialSiteNameSegment2, - l.burialSiteNameSegment3, - l.burialSiteNameSegment4, - l.burialSiteNameSegment5, + l.burialSiteName, l.cemeteryId, m.cemeteryName, o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString, o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString @@ -236,7 +235,7 @@ export default async function getBurialSiteContracts( for (const burialSiteContract of burialSiteContracts) { const contractType = await getContractTypeById( - burialSiteContract.contractTypeId! + burialSiteContract.contractTypeId ) if (contractType !== undefined) { diff --git a/database/getBurialSites.d.ts b/database/getBurialSites.d.ts index 8edc358a..104f4d47 100644 --- a/database/getBurialSites.d.ts +++ b/database/getBurialSites.d.ts @@ -1,6 +1,6 @@ import type { PoolConnection } from 'better-sqlite-pool'; import type { BurialSite } from '../types/recordTypes.js'; -interface GetBurialSitesFilters { +export interface GetBurialSitesFilters { burialSiteNameSearchType?: '' | 'startsWith' | 'endsWith'; burialSiteName?: string; cemeteryId?: number | string; @@ -9,14 +9,13 @@ interface GetBurialSitesFilters { contractStatus?: '' | 'occupied' | 'unoccupied'; workOrderId?: number | string; } -interface GetBurialSitesOptions { +export interface GetBurialSitesOptions { /** -1 for no limit */ limit: number; - offset: number; + offset: string | number; includeBurialSiteContractCount?: boolean; } export default function getBurialSites(filters: GetBurialSitesFilters, options: GetBurialSitesOptions, connectedDatabase?: PoolConnection): Promise<{ count: number; burialSites: BurialSite[]; }>; -export {}; diff --git a/database/getBurialSites.js b/database/getBurialSites.js index a9f66877..737cd93e 100644 --- a/database/getBurialSites.js +++ b/database/getBurialSites.js @@ -1,12 +1,12 @@ import { dateToInteger } from '@cityssm/utils-datetime'; -import { getLotNameWhereClause } from '../helpers/functions.sqlFilters.js'; +import { getBurialSiteNameWhereClause } from '../helpers/functions.sqlFilters.js'; import { acquireConnection } from './pool.js'; function buildWhereClause(filters) { let sqlWhereClause = ' where l.recordDelete_timeMillis is null'; const sqlParameters = []; - const lotNameFilters = getLotNameWhereClause(filters.burialSiteName, filters.burialSiteNameSearchType ?? '', 'l'); - sqlWhereClause += lotNameFilters.sqlWhereClause; - sqlParameters.push(...lotNameFilters.sqlParameters); + const burialSiteNameFilters = getBurialSiteNameWhereClause(filters.burialSiteName, filters.burialSiteNameSearchType ?? '', 'l'); + sqlWhereClause += burialSiteNameFilters.sqlWhereClause; + sqlParameters.push(...burialSiteNameFilters.sqlParameters); if ((filters.cemeteryId ?? '') !== '') { sqlWhereClause += ' and l.cemeteryId = ?'; sqlParameters.push(filters.cemeteryId); @@ -21,16 +21,16 @@ function buildWhereClause(filters) { } if ((filters.contractStatus ?? '') !== '') { if (filters.contractStatus === 'occupied') { - sqlWhereClause += ' and lotOccupancyCount > 0'; + sqlWhereClause += ' and burialSiteContractCount > 0'; } else if (filters.contractStatus === 'unoccupied') { sqlWhereClause += - ' and (lotOccupancyCount is null or lotOccupancyCount = 0)'; + ' and (burialSiteContractCount is null or burialSiteContractCount = 0)'; } } if ((filters.workOrderId ?? '') !== '') { sqlWhereClause += - ' and l.lotId in (select lotId from WorkOrderLots where recordDelete_timeMillis is null and workOrderId = ?)'; + ' and l.burialSiteId in (select burialSiteId from WorkOrderBurialSites where recordDelete_timeMillis is null and workOrderId = ?)'; sqlParameters.push(filters.workOrderId); } return { diff --git a/database/getBurialSites.ts b/database/getBurialSites.ts index 17ffdf35..54fe8a47 100644 --- a/database/getBurialSites.ts +++ b/database/getBurialSites.ts @@ -1,12 +1,12 @@ import { dateToInteger } from '@cityssm/utils-datetime' import type { PoolConnection } from 'better-sqlite-pool' -import { getLotNameWhereClause } from '../helpers/functions.sqlFilters.js' +import { getBurialSiteNameWhereClause } from '../helpers/functions.sqlFilters.js' import type { BurialSite } from '../types/recordTypes.js' import { acquireConnection } from './pool.js' -interface GetBurialSitesFilters { +export interface GetBurialSitesFilters { burialSiteNameSearchType?: '' | 'startsWith' | 'endsWith' burialSiteName?: string cemeteryId?: number | string @@ -16,10 +16,10 @@ interface GetBurialSitesFilters { workOrderId?: number | string } -interface GetBurialSitesOptions { +export interface GetBurialSitesOptions { /** -1 for no limit */ limit: number - offset: number + offset: string | number includeBurialSiteContractCount?: boolean } @@ -30,13 +30,13 @@ function buildWhereClause(filters: GetBurialSitesFilters): { let sqlWhereClause = ' where l.recordDelete_timeMillis is null' const sqlParameters: unknown[] = [] - const lotNameFilters = getLotNameWhereClause( + const burialSiteNameFilters = getBurialSiteNameWhereClause( filters.burialSiteName, filters.burialSiteNameSearchType ?? '', 'l' ) - sqlWhereClause += lotNameFilters.sqlWhereClause - sqlParameters.push(...lotNameFilters.sqlParameters) + sqlWhereClause += burialSiteNameFilters.sqlWhereClause + sqlParameters.push(...burialSiteNameFilters.sqlParameters) if ((filters.cemeteryId ?? '') !== '') { sqlWhereClause += ' and l.cemeteryId = ?' @@ -55,16 +55,16 @@ function buildWhereClause(filters: GetBurialSitesFilters): { if ((filters.contractStatus ?? '') !== '') { if (filters.contractStatus === 'occupied') { - sqlWhereClause += ' and lotOccupancyCount > 0' + sqlWhereClause += ' and burialSiteContractCount > 0' } else if (filters.contractStatus === 'unoccupied') { sqlWhereClause += - ' and (lotOccupancyCount is null or lotOccupancyCount = 0)' + ' and (burialSiteContractCount is null or burialSiteContractCount = 0)' } } if ((filters.workOrderId ?? '') !== '') { sqlWhereClause += - ' and l.lotId in (select lotId from WorkOrderLots where recordDelete_timeMillis is null and workOrderId = ?)' + ' and l.burialSiteId in (select burialSiteId from WorkOrderBurialSites where recordDelete_timeMillis is null and workOrderId = ?)' sqlParameters.push(filters.workOrderId) } diff --git a/database/getPastLotOccupancyOccupants.js b/database/getPastLotOccupancyOccupants.js index 7beab54f..5268ecfe 100644 --- a/database/getPastLotOccupancyOccupants.js +++ b/database/getPastLotOccupancyOccupants.js @@ -31,9 +31,9 @@ export default async function getPastLotOccupancyOccupants(filters, options) { occupantPhoneNumber, occupantEmailAddress order by burialSiteContractIdCount desc, recordUpdate_timeMillisMax desc limit ${options.limit}`; - const lotOccupancyOccupants = database + const burialSiteContractOccupants = database .prepare(sql) .all(sqlParameters); database.release(); - return lotOccupancyOccupants; + return burialSiteContractOccupants; } diff --git a/database/getPastLotOccupancyOccupants.ts b/database/getPastLotOccupancyOccupants.ts index c1c14b1e..df75eb90 100644 --- a/database/getPastLotOccupancyOccupants.ts +++ b/database/getPastLotOccupancyOccupants.ts @@ -60,11 +60,11 @@ export default async function getPastLotOccupancyOccupants( order by burialSiteContractIdCount desc, recordUpdate_timeMillisMax desc limit ${options.limit}` - const lotOccupancyOccupants = database + const burialSiteContractOccupants = database .prepare(sql) .all(sqlParameters) as LotOccupancyOccupant[] database.release() - return lotOccupancyOccupants + return burialSiteContractOccupants } diff --git a/database/getWorkOrders.js b/database/getWorkOrders.js index 0d907be2..c94d3f45 100644 --- a/database/getWorkOrders.js +++ b/database/getWorkOrders.js @@ -1,5 +1,5 @@ import { dateIntegerToString, dateStringToInteger } from '@cityssm/utils-datetime'; -import { getLotNameWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js'; +import { getBurialSiteNameWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js'; import getBurialSiteContracts from './getBurialSiteContracts.js'; import getLots from './getLots.js'; import getWorkOrderComments from './getWorkOrderComments.js'; @@ -36,7 +36,7 @@ function buildWhereClause(filters) { ))`; sqlParameters.push(...occupantNameFilters.sqlParameters); } - const lotNameFilters = getLotNameWhereClause(filters.lotName, '', 'l'); + const lotNameFilters = getBurialSiteNameWhereClause(filters.lotName, '', 'l'); if (lotNameFilters.sqlParameters.length > 0) { sqlWhereClause += ` and w.workOrderId in ( diff --git a/database/getWorkOrders.ts b/database/getWorkOrders.ts index f32ec856..7acf09b3 100644 --- a/database/getWorkOrders.ts +++ b/database/getWorkOrders.ts @@ -6,7 +6,7 @@ import { import type { PoolConnection } from 'better-sqlite-pool' import { - getLotNameWhereClause, + getBurialSiteNameWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js' import type { WorkOrder } from '../types/recordTypes.js' @@ -77,7 +77,7 @@ function buildWhereClause(filters: GetWorkOrdersFilters): { sqlParameters.push(...occupantNameFilters.sqlParameters) } - const lotNameFilters = getLotNameWhereClause(filters.lotName, '', 'l') + const lotNameFilters = getBurialSiteNameWhereClause(filters.lotName, '', 'l') if (lotNameFilters.sqlParameters.length > 0) { sqlWhereClause += ` and w.workOrderId in ( diff --git a/database/initializeDatabase.js b/database/initializeDatabase.js index 06358054..a9e4afd2 100644 --- a/database/initializeDatabase.js +++ b/database/initializeDatabase.js @@ -32,8 +32,8 @@ const createStatements = [ fieldValues text, isRequired bit not null default 0, pattern varchar(100), - minimumLength smallint not null default 1 check (minimumLength >= 0), - maximumLength smallint not null default 100 check (maximumLength >= 0), + minLength smallint not null default 1 check (minLength >= 0), + maxLength smallint not null default 100 check (maxLength >= 0), orderNumber smallint not null default 0, ${recordColumns}, foreign key (burialSiteTypeId) references BurialSiteTypes (burialSiteTypeId))`, @@ -55,6 +55,7 @@ const createStatements = [ `create table if not exists Cemeteries ( cemeteryId integer not null primary key autoincrement, cemeteryName varchar(200) not null, + cemeteryKey varchar(20) not null, cemeteryDescription text, cemeteryLatitude decimal(10, 8) check (cemeteryLatitude between -90 and 90), @@ -75,11 +76,12 @@ const createStatements = [ burialSiteId integer not null primary key autoincrement, burialSiteTypeId integer not null, - burialSiteNameSegment1 varchar(20), - burialSiteNameSegment2 varchar(20), - burialSiteNameSegment3 varchar(20), - burialSiteNameSegment4 varchar(20), - burialSiteNameSegment5 varchar(20), + burialSiteNameSegment1 varchar(20) not null, + burialSiteNameSegment2 varchar(20) not null, + burialSiteNameSegment3 varchar(20) not null, + burialSiteNameSegment4 varchar(20) not null, + burialSiteNameSegment5 varchar(20) not null, + burialSiteName varchar(200) not null, cemeteryId integer, cemeterySvgId varchar(100), @@ -142,8 +144,8 @@ const createStatements = [ fieldValues text, isRequired bit not null default 0, pattern varchar(100), - minimumLength smallint not null default 1 check (minimumLength >= 0), - maximumLength smallint not null default 100 check (maximumLength >= 0), + minLength smallint not null default 1 check (minLength >= 0), + maxLength smallint not null default 100 check (maxLength >= 0), orderNumber smallint not null default 0, ${recordColumns}, foreign key (contractTypeId) references ContractTypes (contractTypeId))`, diff --git a/database/initializeDatabase.ts b/database/initializeDatabase.ts index e285d8e2..3c0a6fa7 100644 --- a/database/initializeDatabase.ts +++ b/database/initializeDatabase.ts @@ -41,8 +41,8 @@ const createStatements = [ fieldValues text, isRequired bit not null default 0, pattern varchar(100), - minimumLength smallint not null default 1 check (minimumLength >= 0), - maximumLength smallint not null default 100 check (maximumLength >= 0), + minLength smallint not null default 1 check (minLength >= 0), + maxLength smallint not null default 100 check (maxLength >= 0), orderNumber smallint not null default 0, ${recordColumns}, foreign key (burialSiteTypeId) references BurialSiteTypes (burialSiteTypeId))`, @@ -70,6 +70,7 @@ const createStatements = [ `create table if not exists Cemeteries ( cemeteryId integer not null primary key autoincrement, cemeteryName varchar(200) not null, + cemeteryKey varchar(20) not null, cemeteryDescription text, cemeteryLatitude decimal(10, 8) check (cemeteryLatitude between -90 and 90), @@ -92,11 +93,12 @@ const createStatements = [ burialSiteId integer not null primary key autoincrement, burialSiteTypeId integer not null, - burialSiteNameSegment1 varchar(20), - burialSiteNameSegment2 varchar(20), - burialSiteNameSegment3 varchar(20), - burialSiteNameSegment4 varchar(20), - burialSiteNameSegment5 varchar(20), + burialSiteNameSegment1 varchar(20) not null, + burialSiteNameSegment2 varchar(20) not null, + burialSiteNameSegment3 varchar(20) not null, + burialSiteNameSegment4 varchar(20) not null, + burialSiteNameSegment5 varchar(20) not null, + burialSiteName varchar(200) not null, cemeteryId integer, cemeterySvgId varchar(100), @@ -168,8 +170,8 @@ const createStatements = [ fieldValues text, isRequired bit not null default 0, pattern varchar(100), - minimumLength smallint not null default 1 check (minimumLength >= 0), - maximumLength smallint not null default 100 check (maximumLength >= 0), + minLength smallint not null default 1 check (minLength >= 0), + maxLength smallint not null default 100 check (maxLength >= 0), orderNumber smallint not null default 0, ${recordColumns}, foreign key (contractTypeId) references ContractTypes (contractTypeId))`, diff --git a/database/updateLotOccupancyOccupant.d.ts b/database/updateLotOccupancyOccupant.d.ts index ce9c06ca..d864bd33 100644 --- a/database/updateLotOccupancyOccupant.d.ts +++ b/database/updateLotOccupancyOccupant.d.ts @@ -13,4 +13,4 @@ export interface UpdateLotOccupancyOccupantForm { occupantEmailAddress: string; occupantComment: string; } -export default function updateLotOccupancyOccupant(lotOccupancyOccupantForm: UpdateLotOccupancyOccupantForm, user: User): Promise; +export default function updateLotOccupancyOccupant(burialSiteContractOccupantForm: UpdateLotOccupancyOccupantForm, user: User): Promise; diff --git a/database/updateLotOccupancyOccupant.js b/database/updateLotOccupancyOccupant.js index 81f01128..fab7d407 100644 --- a/database/updateLotOccupancyOccupant.js +++ b/database/updateLotOccupancyOccupant.js @@ -1,5 +1,5 @@ import { acquireConnection } from './pool.js'; -export default async function updateLotOccupancyOccupant(lotOccupancyOccupantForm, user) { +export default async function updateLotOccupancyOccupant(burialSiteContractOccupantForm, user) { const database = await acquireConnection(); const results = database .prepare(`update LotOccupancyOccupants @@ -19,7 +19,7 @@ export default async function updateLotOccupancyOccupant(lotOccupancyOccupantFor where recordDelete_timeMillis is null and burialSiteContractId = ? and lotOccupantIndex = ?`) - .run(lotOccupancyOccupantForm.occupantName, lotOccupancyOccupantForm.occupantFamilyName, lotOccupancyOccupantForm.occupantAddress1, lotOccupancyOccupantForm.occupantAddress2, lotOccupancyOccupantForm.occupantCity, lotOccupancyOccupantForm.occupantProvince, lotOccupancyOccupantForm.occupantPostalCode, lotOccupancyOccupantForm.occupantPhoneNumber, lotOccupancyOccupantForm.occupantEmailAddress, lotOccupancyOccupantForm.occupantComment, lotOccupancyOccupantForm.lotOccupantTypeId, user.userName, Date.now(), lotOccupancyOccupantForm.burialSiteContractId, lotOccupancyOccupantForm.lotOccupantIndex); + .run(burialSiteContractOccupantForm.occupantName, burialSiteContractOccupantForm.occupantFamilyName, burialSiteContractOccupantForm.occupantAddress1, burialSiteContractOccupantForm.occupantAddress2, burialSiteContractOccupantForm.occupantCity, burialSiteContractOccupantForm.occupantProvince, burialSiteContractOccupantForm.occupantPostalCode, burialSiteContractOccupantForm.occupantPhoneNumber, burialSiteContractOccupantForm.occupantEmailAddress, burialSiteContractOccupantForm.occupantComment, burialSiteContractOccupantForm.lotOccupantTypeId, user.userName, Date.now(), burialSiteContractOccupantForm.burialSiteContractId, burialSiteContractOccupantForm.lotOccupantIndex); database.release(); return results.changes > 0; } diff --git a/database/updateLotOccupancyOccupant.ts b/database/updateLotOccupancyOccupant.ts index 290a70af..9c07722e 100644 --- a/database/updateLotOccupancyOccupant.ts +++ b/database/updateLotOccupancyOccupant.ts @@ -17,7 +17,7 @@ export interface UpdateLotOccupancyOccupantForm { } export default async function updateLotOccupancyOccupant( - lotOccupancyOccupantForm: UpdateLotOccupancyOccupantForm, + burialSiteContractOccupantForm: UpdateLotOccupancyOccupantForm, user: User ): Promise { const database = await acquireConnection() @@ -43,21 +43,21 @@ export default async function updateLotOccupancyOccupant( and lotOccupantIndex = ?` ) .run( - lotOccupancyOccupantForm.occupantName, - lotOccupancyOccupantForm.occupantFamilyName, - lotOccupancyOccupantForm.occupantAddress1, - lotOccupancyOccupantForm.occupantAddress2, - lotOccupancyOccupantForm.occupantCity, - lotOccupancyOccupantForm.occupantProvince, - lotOccupancyOccupantForm.occupantPostalCode, - lotOccupancyOccupantForm.occupantPhoneNumber, - lotOccupancyOccupantForm.occupantEmailAddress, - lotOccupancyOccupantForm.occupantComment, - lotOccupancyOccupantForm.lotOccupantTypeId, + burialSiteContractOccupantForm.occupantName, + burialSiteContractOccupantForm.occupantFamilyName, + burialSiteContractOccupantForm.occupantAddress1, + burialSiteContractOccupantForm.occupantAddress2, + burialSiteContractOccupantForm.occupantCity, + burialSiteContractOccupantForm.occupantProvince, + burialSiteContractOccupantForm.occupantPostalCode, + burialSiteContractOccupantForm.occupantPhoneNumber, + burialSiteContractOccupantForm.occupantEmailAddress, + burialSiteContractOccupantForm.occupantComment, + burialSiteContractOccupantForm.lotOccupantTypeId, user.userName, Date.now(), - lotOccupancyOccupantForm.burialSiteContractId, - lotOccupancyOccupantForm.lotOccupantIndex + burialSiteContractOccupantForm.burialSiteContractId, + burialSiteContractOccupantForm.lotOccupantIndex ) database.release() diff --git a/handlers/admin-post/doUpdateLotTypeField.d.ts b/handlers/admin-post/doUpdateBurialSiteTypeField.d.ts similarity index 100% rename from handlers/admin-post/doUpdateLotTypeField.d.ts rename to handlers/admin-post/doUpdateBurialSiteTypeField.d.ts diff --git a/handlers/admin-post/doUpdateLotTypeField.js b/handlers/admin-post/doUpdateBurialSiteTypeField.js similarity index 81% rename from handlers/admin-post/doUpdateLotTypeField.js rename to handlers/admin-post/doUpdateBurialSiteTypeField.js index d9af6ae4..88032cc3 100644 --- a/handlers/admin-post/doUpdateLotTypeField.js +++ b/handlers/admin-post/doUpdateBurialSiteTypeField.js @@ -2,9 +2,9 @@ import updateBurialSiteTypeField from '../../database/updateBurialSiteTypeField. import { getBurialSiteTypes } from '../../helpers/functions.cache.js'; export default async function handler(request, response) { const success = await updateBurialSiteTypeField(request.body, request.session.user); - const lotTypes = await getBurialSiteTypes(); + const burialSiteTypes = await getBurialSiteTypes(); response.json({ success, - lotTypes + burialSiteTypes }); } diff --git a/handlers/admin-post/doUpdateLotTypeField.ts b/handlers/admin-post/doUpdateBurialSiteTypeField.ts similarity index 87% rename from handlers/admin-post/doUpdateLotTypeField.ts rename to handlers/admin-post/doUpdateBurialSiteTypeField.ts index 8a591ea2..f950be5b 100644 --- a/handlers/admin-post/doUpdateLotTypeField.ts +++ b/handlers/admin-post/doUpdateBurialSiteTypeField.ts @@ -14,10 +14,10 @@ export default async function handler( request.session.user as User ) - const lotTypes = await getBurialSiteTypes() + const burialSiteTypes = await getBurialSiteTypes() response.json({ success, - lotTypes + burialSiteTypes }) } diff --git a/handlers/admin-post/doUpdateOccupancyType.d.ts b/handlers/admin-post/doUpdateContractType.d.ts similarity index 87% rename from handlers/admin-post/doUpdateOccupancyType.d.ts rename to handlers/admin-post/doUpdateContractType.d.ts index 6be65985..8bd56034 100644 --- a/handlers/admin-post/doUpdateOccupancyType.d.ts +++ b/handlers/admin-post/doUpdateContractType.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/admin-post/doUpdateOccupancyType.js b/handlers/admin-post/doUpdateContractType.js similarity index 62% rename from handlers/admin-post/doUpdateOccupancyType.js rename to handlers/admin-post/doUpdateContractType.js index 6b23682a..ba73d2b7 100644 --- a/handlers/admin-post/doUpdateOccupancyType.js +++ b/handlers/admin-post/doUpdateContractType.js @@ -1,12 +1,12 @@ import { updateRecord } from '../../database/updateRecord.js'; import { getAllContractTypeFields, getContractTypes } from '../../helpers/functions.cache.js'; export default async function handler(request, response) { - const success = await updateRecord('OccupancyTypes', request.body.contractTypeId, request.body.occupancyType, request.session.user); - const occupancyTypes = await getContractTypes(); + const success = await updateRecord('ContractTypes', request.body.contractTypeId, request.body.contractType, request.session.user); + const contractTypes = await getContractTypes(); const allContractTypeFields = await getAllContractTypeFields(); response.json({ success, - occupancyTypes, + contractTypes, allContractTypeFields }); } diff --git a/handlers/admin-post/doUpdateOccupancyType.ts b/handlers/admin-post/doUpdateContractType.ts similarity index 76% rename from handlers/admin-post/doUpdateOccupancyType.ts rename to handlers/admin-post/doUpdateContractType.ts index ac3dc323..76079502 100644 --- a/handlers/admin-post/doUpdateOccupancyType.ts +++ b/handlers/admin-post/doUpdateContractType.ts @@ -10,23 +10,23 @@ export default async function handler( request: Request< unknown, unknown, - { contractTypeId: string; occupancyType: string } + { contractTypeId: string; contractType: string } >, response: Response ): Promise { const success = await updateRecord( - 'OccupancyTypes', + 'ContractTypes', request.body.contractTypeId, - request.body.occupancyType, + request.body.contractType, request.session.user as User ) - const occupancyTypes = await getContractTypes() + const contractTypes = await getContractTypes() const allContractTypeFields = await getAllContractTypeFields() response.json({ success, - occupancyTypes, + contractTypes, allContractTypeFields }) } diff --git a/handlers/admin-post/doUpdateContractTypeField.d.ts b/handlers/admin-post/doUpdateContractTypeField.d.ts new file mode 100644 index 00000000..725e2d46 --- /dev/null +++ b/handlers/admin-post/doUpdateContractTypeField.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type UpdateContractTypeFieldForm } from '../../database/updateContractTypeField.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/admin-post/doUpdateOccupancyTypeField.js b/handlers/admin-post/doUpdateContractTypeField.js similarity index 54% rename from handlers/admin-post/doUpdateOccupancyTypeField.js rename to handlers/admin-post/doUpdateContractTypeField.js index 600e6215..9ff8e5b0 100644 --- a/handlers/admin-post/doUpdateOccupancyTypeField.js +++ b/handlers/admin-post/doUpdateContractTypeField.js @@ -1,12 +1,12 @@ -import updateOccupancyTypeField from '../../database/updateOccupancyTypeField.js'; +import updateContractTypeField from '../../database/updateContractTypeField.js'; import { getAllContractTypeFields, getContractTypes } from '../../helpers/functions.cache.js'; export default async function handler(request, response) { - const success = await updateOccupancyTypeField(request.body, request.session.user); - const occupancyTypes = await getContractTypes(); + const success = await updateContractTypeField(request.body, request.session.user); + const contractTypes = await getContractTypes(); const allContractTypeFields = await getAllContractTypeFields(); response.json({ success, - occupancyTypes, + contractTypes, allContractTypeFields }); } diff --git a/handlers/admin-post/doUpdateOccupancyTypeField.ts b/handlers/admin-post/doUpdateContractTypeField.ts similarity index 55% rename from handlers/admin-post/doUpdateOccupancyTypeField.ts rename to handlers/admin-post/doUpdateContractTypeField.ts index 02076654..4bc1111c 100644 --- a/handlers/admin-post/doUpdateOccupancyTypeField.ts +++ b/handlers/admin-post/doUpdateContractTypeField.ts @@ -1,28 +1,28 @@ import type { Request, Response } from 'express' -import updateOccupancyTypeField, { - type UpdateOccupancyTypeFieldForm -} from '../../database/updateOccupancyTypeField.js' +import updateContractTypeField, { + type UpdateContractTypeFieldForm +} from '../../database/updateContractTypeField.js' import { getAllContractTypeFields, getContractTypes } from '../../helpers/functions.cache.js' export default async function handler( - request: Request, + request: Request, response: Response ): Promise { - const success = await updateOccupancyTypeField( - request.body as UpdateOccupancyTypeFieldForm, + const success = await updateContractTypeField( + request.body, request.session.user as User ) - const occupancyTypes = await getContractTypes() + const contractTypes = await getContractTypes() const allContractTypeFields = await getAllContractTypeFields() response.json({ success, - occupancyTypes, + contractTypes, allContractTypeFields }) } diff --git a/handlers/api-get/milestoneICS.js b/handlers/api-get/milestoneICS.js index f7c90714..e54f1ff3 100644 --- a/handlers/api-get/milestoneICS.js +++ b/handlers/api-get/milestoneICS.js @@ -23,8 +23,8 @@ function buildEventSummary(milestone) { ? milestone.workOrderMilestoneDescription ?? '' : milestone.workOrderMilestoneType ?? '').trim(); let occupantCount = 0; - for (const lotOccupancy of milestone.workOrderLotOccupancies ?? []) { - for (const occupant of lotOccupancy.lotOccupancyOccupants ?? []) { + for (const burialSiteContract of milestone.workOrderLotOccupancies ?? []) { + for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) { occupantCount += 1; if (occupantCount === 1) { if (summary !== '') { @@ -59,7 +59,7 @@ function buildEventDescriptionHTML_occupancies(request, milestone) { for (const occupancy of milestone.workOrderLotOccupancies ?? []) { descriptionHTML += ` - + ${escapeHTML(occupancy.occupancyType ?? '')} @@ -75,7 +75,7 @@ function buildEventDescriptionHTML_occupancies(request, milestone) { : '(No End Date)'} `; - for (const occupant of occupancy.lotOccupancyOccupants ?? []) { + for (const occupant of occupancy.burialSiteContractOccupants ?? []) { descriptionHTML += `${escapeHTML(occupant.lotOccupantType ?? '')}: ${escapeHTML(occupant.occupantName ?? '')} ${escapeHTML(occupant.occupantFamilyName ?? '')}
`; } descriptionHTML += ''; @@ -255,8 +255,8 @@ export default async function handler(request, response) { // Set organizer / attendees if (milestone.workOrderLotOccupancies.length > 0) { let organizerSet = false; - for (const lotOccupancy of milestone.workOrderLotOccupancies ?? []) { - for (const occupant of lotOccupancy.lotOccupancyOccupants ?? []) { + for (const burialSiteContract of milestone.workOrderLotOccupancies ?? []) { + for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) { if (organizerSet) { calendarEvent.createAttendee({ name: `${occupant.occupantName ?? ''} ${occupant.occupantFamilyName ?? ''}`, diff --git a/handlers/api-get/milestoneICS.ts b/handlers/api-get/milestoneICS.ts index 5a368243..36f56153 100644 --- a/handlers/api-get/milestoneICS.ts +++ b/handlers/api-get/milestoneICS.ts @@ -47,8 +47,8 @@ function buildEventSummary(milestone: WorkOrderMilestone): string { let occupantCount = 0 - for (const lotOccupancy of milestone.workOrderLotOccupancies ?? []) { - for (const occupant of lotOccupancy.lotOccupancyOccupants ?? []) { + for (const burialSiteContract of milestone.workOrderLotOccupancies ?? []) { + for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) { occupantCount += 1 if (occupantCount === 1) { @@ -94,7 +94,7 @@ function buildEventDescriptionHTML_occupancies( for (const occupancy of milestone.workOrderLotOccupancies ?? []) { descriptionHTML += ` - + ${escapeHTML(occupancy.occupancyType ?? '')} @@ -113,7 +113,7 @@ function buildEventDescriptionHTML_occupancies( ` - for (const occupant of occupancy.lotOccupancyOccupants ?? []) { + for (const occupant of occupancy.burialSiteContractOccupants ?? []) { descriptionHTML += `${escapeHTML( occupant.lotOccupantType ?? '' )}: ${escapeHTML(occupant.occupantName ?? '')} ${escapeHTML( @@ -377,8 +377,8 @@ export default async function handler( // Set organizer / attendees if (milestone.workOrderLotOccupancies!.length > 0) { let organizerSet = false - for (const lotOccupancy of milestone.workOrderLotOccupancies ?? []) { - for (const occupant of lotOccupancy.lotOccupancyOccupants ?? []) { + for (const burialSiteContract of milestone.workOrderLotOccupancies ?? []) { + for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) { if (organizerSet) { calendarEvent.createAttendee({ name: `${occupant.occupantName ?? ''} ${ diff --git a/handlers/burialSites-get/edit.js b/handlers/burialSites-get/edit.js index 48331939..8d637508 100644 --- a/handlers/burialSites-get/edit.js +++ b/handlers/burialSites-get/edit.js @@ -1,22 +1,22 @@ -import getLot from '../../database/getLot.js'; -import getMaps from '../../database/getMaps.js'; -import { getLotStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js'; +import getBurialSite from '../../database/getBurialSite.js'; +import getCemeteries from '../../database/getCemeteries.js'; import { getConfigProperty } from '../../helpers/config.helpers.js'; +import { getBurialSiteStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js'; export default async function handler(request, response) { - const lot = await getLot(request.params.lotId); - if (lot === undefined) { - response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=lotIdNotFound`); + const burialSite = await getBurialSite(request.params.burialSiteId); + if (burialSite === undefined) { + response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/?error=burialSiteIdNotFound`); return; } - const maps = await getMaps(); - const lotTypes = await getBurialSiteTypes(); - const lotStatuses = await getLotStatuses(); - response.render('lot-edit', { - headTitle: lot.lotName, - lot, + const cemeteries = await getCemeteries(); + const burialSiteTypes = await getBurialSiteTypes(); + const burialSiteStatuses = await getBurialSiteStatuses(); + response.render('burialSite-edit', { + headTitle: burialSite.burialSiteName, + burialSite, isCreate: false, - maps, - lotTypes, - lotStatuses + cemeteries, + burialSiteTypes, + burialSiteStatuses }); } diff --git a/handlers/burialSites-get/edit.ts b/handlers/burialSites-get/edit.ts index 5aba7591..e8f4d1b3 100644 --- a/handlers/burialSites-get/edit.ts +++ b/handlers/burialSites-get/edit.ts @@ -1,33 +1,36 @@ import type { Request, Response } from 'express' -import getLot from '../../database/getLot.js' -import getMaps from '../../database/getMaps.js' -import { getLotStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js' +import getBurialSite from '../../database/getBurialSite.js' +import getCemeteries from '../../database/getCemeteries.js' import { getConfigProperty } from '../../helpers/config.helpers.js' +import { + getBurialSiteStatuses, + getBurialSiteTypes +} from '../../helpers/functions.cache.js' export default async function handler( request: Request, response: Response ): Promise { - const lot = await getLot(request.params.lotId) + const burialSite = await getBurialSite(request.params.burialSiteId) - if (lot === undefined) { + if (burialSite === undefined) { response.redirect( - `${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=lotIdNotFound` + `${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/?error=burialSiteIdNotFound` ) return } - const maps = await getMaps() - const lotTypes = await getBurialSiteTypes() - const lotStatuses = await getLotStatuses() + const cemeteries = await getCemeteries() + const burialSiteTypes = await getBurialSiteTypes() + const burialSiteStatuses = await getBurialSiteStatuses() - response.render('lot-edit', { - headTitle: lot.lotName, - lot, + response.render('burialSite-edit', { + headTitle: burialSite.burialSiteName, + burialSite, isCreate: false, - maps, - lotTypes, - lotStatuses + cemeteries, + burialSiteTypes, + burialSiteStatuses }) } diff --git a/handlers/burialSites-get/new.js b/handlers/burialSites-get/new.js index 42f21c90..45c6f13c 100644 --- a/handlers/burialSites-get/new.js +++ b/handlers/burialSites-get/new.js @@ -1,30 +1,27 @@ -import getMaps from '../../database/getMaps.js'; -import { getLotStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js'; -import { getConfigProperty } from '../../helpers/config.helpers.js'; +import getCemeteries from '../../database/getCemeteries.js'; +import { getBurialSiteStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js'; export default async function handler(request, response) { - const lot = { - lotId: -1, - lotOccupancies: [] + const burialSite = { + burialSiteId: -1, + burialSiteContracts: [] }; - const maps = await getMaps(); + const cemeteries = await getCemeteries(); if (request.query.cemeteryId !== undefined) { const cemeteryId = Number.parseInt(request.query.cemeteryId, 10); - const map = maps.find((possibleMap) => { - return cemeteryId === possibleMap.cemeteryId; - }); - if (map !== undefined) { - lot.cemeteryId = map.cemeteryId; - lot.cemeteryName = map.cemeteryName; + const cemetery = cemeteries.find((possibleMatch) => cemeteryId === possibleMatch.cemeteryId); + if (cemetery !== undefined) { + burialSite.cemeteryId = cemetery.cemeteryId; + burialSite.cemeteryName = cemetery.cemeteryName; } } - const lotTypes = await getBurialSiteTypes(); - const lotStatuses = await getLotStatuses(); - response.render('lot-edit', { - headTitle: `Create a New ${getConfigProperty('aliases.lot')}`, - lot, + const burialSiteTypes = await getBurialSiteTypes(); + const burialSiteStatuses = await getBurialSiteStatuses(); + response.render('burialSite-edit', { + headTitle: 'Create a New Burial Site', + burialSite, isCreate: true, - maps, - lotTypes, - lotStatuses + cemeteries, + burialSiteTypes, + burialSiteStatuses }); } diff --git a/handlers/burialSites-get/new.ts b/handlers/burialSites-get/new.ts index 16b8ebd9..f495c48c 100644 --- a/handlers/burialSites-get/new.ts +++ b/handlers/burialSites-get/new.ts @@ -1,43 +1,45 @@ import type { Request, Response } from 'express' -import getMaps from '../../database/getMaps.js' -import { getLotStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js' -import { getConfigProperty } from '../../helpers/config.helpers.js' -import type { Lot } from '../../types/recordTypes.js' +import getCemeteries from '../../database/getCemeteries.js' +import { + getBurialSiteStatuses, + getBurialSiteTypes +} from '../../helpers/functions.cache.js' +import type { BurialSite } from '../../types/recordTypes.js' export default async function handler( request: Request, response: Response ): Promise { - const lot: Lot = { - lotId: -1, - lotOccupancies: [] + const burialSite: BurialSite = { + burialSiteId: -1, + burialSiteContracts: [] } - const maps = await getMaps() + const cemeteries = await getCemeteries() if (request.query.cemeteryId !== undefined) { const cemeteryId = Number.parseInt(request.query.cemeteryId as string, 10) - const map = maps.find((possibleMap) => { - return cemeteryId === possibleMap.cemeteryId - }) + const cemetery = cemeteries.find( + (possibleMatch) => cemeteryId === possibleMatch.cemeteryId + ) - if (map !== undefined) { - lot.cemeteryId = map.cemeteryId - lot.cemeteryName = map.cemeteryName + if (cemetery !== undefined) { + burialSite.cemeteryId = cemetery.cemeteryId + burialSite.cemeteryName = cemetery.cemeteryName } } - const lotTypes = await getBurialSiteTypes() - const lotStatuses = await getLotStatuses() + const burialSiteTypes = await getBurialSiteTypes() + const burialSiteStatuses = await getBurialSiteStatuses() - response.render('lot-edit', { - headTitle: `Create a New ${getConfigProperty('aliases.lot')}`, - lot, + response.render('burialSite-edit', { + headTitle: 'Create a New Burial Site', + burialSite, isCreate: true, - maps, - lotTypes, - lotStatuses + cemeteries, + burialSiteTypes, + burialSiteStatuses }) } diff --git a/handlers/burialSites-get/next.js b/handlers/burialSites-get/next.js index 805d3774..28603a85 100644 --- a/handlers/burialSites-get/next.js +++ b/handlers/burialSites-get/next.js @@ -1,11 +1,11 @@ +import { getNextBurialSiteId } from '../../helpers/burialSites.helpers.js'; import { getConfigProperty } from '../../helpers/config.helpers.js'; -import { getNextLotId } from '../../helpers/functions.lots.js'; export default async function handler(request, response) { - const lotId = Number.parseInt(request.params.lotId, 10); - const nextLotId = await getNextLotId(lotId); - if (nextLotId === undefined) { - response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=noNextLotIdFound`); + const burialSiteId = Number.parseInt(request.params.burialSiteId, 10); + const nextBurialSiteId = await getNextBurialSiteId(burialSiteId); + if (nextBurialSiteId === undefined) { + response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/?error=noNextBurialSiteIdFound`); return; } - response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/${nextLotId.toString()}`); + response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/${nextBurialSiteId.toString()}`); } diff --git a/handlers/burialSites-get/next.ts b/handlers/burialSites-get/next.ts index 56ec09c7..5194f2c7 100644 --- a/handlers/burialSites-get/next.ts +++ b/handlers/burialSites-get/next.ts @@ -1,21 +1,21 @@ import type { Request, Response } from 'express' +import { getNextBurialSiteId } from '../../helpers/burialSites.helpers.js' import { getConfigProperty } from '../../helpers/config.helpers.js' -import { getNextLotId } from '../../helpers/functions.lots.js' export default async function handler( request: Request, response: Response ): Promise { - const lotId = Number.parseInt(request.params.lotId, 10) + const burialSiteId = Number.parseInt(request.params.burialSiteId, 10) - const nextLotId = await getNextLotId(lotId) + const nextBurialSiteId = await getNextBurialSiteId(burialSiteId) - if (nextLotId === undefined) { + if (nextBurialSiteId === undefined) { response.redirect( `${getConfigProperty( 'reverseProxy.urlPrefix' - )}/lots/?error=noNextLotIdFound` + )}/burialSites/?error=noNextBurialSiteIdFound` ) return } @@ -23,6 +23,6 @@ export default async function handler( response.redirect( `${getConfigProperty( 'reverseProxy.urlPrefix' - )}/lots/${nextLotId.toString()}` + )}/burialSites/${nextBurialSiteId.toString()}` ) } diff --git a/handlers/burialSites-get/previous.js b/handlers/burialSites-get/previous.js index fa956542..8b15fb6d 100644 --- a/handlers/burialSites-get/previous.js +++ b/handlers/burialSites-get/previous.js @@ -1,11 +1,11 @@ +import { getPreviousBurialSiteId } from '../../helpers/burialSites.helpers.js'; import { getConfigProperty } from '../../helpers/config.helpers.js'; -import { getPreviousLotId } from '../../helpers/functions.lots.js'; export default async function handler(request, response) { - const lotId = Number.parseInt(request.params.lotId, 10); - const previousLotId = await getPreviousLotId(lotId); - if (previousLotId === undefined) { - response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=noPreviousLotIdFound`); + const burialSiteId = Number.parseInt(request.params.burialSiteId, 10); + const previousBurialSiteId = await getPreviousBurialSiteId(burialSiteId); + if (previousBurialSiteId === undefined) { + response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/?error=noPreviousBurialSiteIdFound`); return; } - response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/${previousLotId.toString()}`); + response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/${previousBurialSiteId.toString()}`); } diff --git a/handlers/burialSites-get/previous.ts b/handlers/burialSites-get/previous.ts index 572e2aa1..a7baa971 100644 --- a/handlers/burialSites-get/previous.ts +++ b/handlers/burialSites-get/previous.ts @@ -1,21 +1,21 @@ import type { Request, Response } from 'express' +import { getPreviousBurialSiteId } from '../../helpers/burialSites.helpers.js' import { getConfigProperty } from '../../helpers/config.helpers.js' -import { getPreviousLotId } from '../../helpers/functions.lots.js' export default async function handler( request: Request, response: Response ): Promise { - const lotId = Number.parseInt(request.params.lotId, 10) + const burialSiteId = Number.parseInt(request.params.burialSiteId, 10) - const previousLotId = await getPreviousLotId(lotId) + const previousBurialSiteId = await getPreviousBurialSiteId(burialSiteId) - if (previousLotId === undefined) { + if (previousBurialSiteId === undefined) { response.redirect( `${getConfigProperty( 'reverseProxy.urlPrefix' - )}/lots/?error=noPreviousLotIdFound` + )}/burialSites/?error=noPreviousBurialSiteIdFound` ) return } @@ -23,6 +23,6 @@ export default async function handler( response.redirect( `${getConfigProperty( 'reverseProxy.urlPrefix' - )}/lots/${previousLotId.toString()}` + )}/burialSites/${previousBurialSiteId.toString()}` ) } diff --git a/handlers/burialSites-get/search.js b/handlers/burialSites-get/search.js index af372a7e..337bcd4b 100644 --- a/handlers/burialSites-get/search.js +++ b/handlers/burialSites-get/search.js @@ -1,15 +1,14 @@ -import getMaps from '../../database/getMaps.js'; -import { getLotStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js'; -import { getConfigProperty } from '../../helpers/config.helpers.js'; +import getCemeteries from '../../database/getCemeteries.js'; +import { getBurialSiteStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js'; export default async function handler(request, response) { - const maps = await getMaps(); - const lotTypes = await getBurialSiteTypes(); - const lotStatuses = await getLotStatuses(); - response.render('lot-search', { - headTitle: `${getConfigProperty('aliases.lot')} Search`, - maps, - lotTypes, - lotStatuses, + const cemeteries = await getCemeteries(); + const burialSiteTypes = await getBurialSiteTypes(); + const burialSiteStatuses = await getBurialSiteStatuses(); + response.render('burialSite-search', { + headTitle: `Burial Site Search`, + cemeteries, + burialSiteTypes, + burialSiteStatuses, cemeteryId: request.query.cemeteryId, burialSiteTypeId: request.query.burialSiteTypeId, burialSiteStatusId: request.query.burialSiteStatusId diff --git a/handlers/burialSites-get/search.ts b/handlers/burialSites-get/search.ts index 010d3d0b..1807bb4a 100644 --- a/handlers/burialSites-get/search.ts +++ b/handlers/burialSites-get/search.ts @@ -1,22 +1,24 @@ import type { Request, Response } from 'express' -import getMaps from '../../database/getMaps.js' -import { getLotStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js' -import { getConfigProperty } from '../../helpers/config.helpers.js' +import getCemeteries from '../../database/getCemeteries.js' +import { + getBurialSiteStatuses, + getBurialSiteTypes +} from '../../helpers/functions.cache.js' export default async function handler( request: Request, response: Response ): Promise { - const maps = await getMaps() - const lotTypes = await getBurialSiteTypes() - const lotStatuses = await getLotStatuses() + const cemeteries = await getCemeteries() + const burialSiteTypes = await getBurialSiteTypes() + const burialSiteStatuses = await getBurialSiteStatuses() - response.render('lot-search', { - headTitle: `${getConfigProperty('aliases.lot')} Search`, - maps, - lotTypes, - lotStatuses, + response.render('burialSite-search', { + headTitle: `Burial Site Search`, + cemeteries, + burialSiteTypes, + burialSiteStatuses, cemeteryId: request.query.cemeteryId, burialSiteTypeId: request.query.burialSiteTypeId, burialSiteStatusId: request.query.burialSiteStatusId diff --git a/handlers/burialSites-get/view.js b/handlers/burialSites-get/view.js index f11ecd5f..4b05ad5f 100644 --- a/handlers/burialSites-get/view.js +++ b/handlers/burialSites-get/view.js @@ -1,18 +1,18 @@ -import getLot from '../../database/getLot.js'; +import getBurialSite from '../../database/getBurialSite.js'; +import { getNextBurialSiteId, getPreviousBurialSiteId } from '../../helpers/burialSites.helpers.js'; import { getConfigProperty } from '../../helpers/config.helpers.js'; -import { getNextLotId, getPreviousLotId } from '../../helpers/functions.lots.js'; export default async function handler(request, response) { - const lot = await getLot(request.params.lotId); - if (lot === undefined) { - response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=lotIdNotFound`); + const burialSite = await getBurialSite(request.params.burialSiteId); + if (burialSite === undefined) { + response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/?error=burialSiteIdNotFound`); return; } - response.render('lot-view', { - headTitle: lot.lotName, - lot + response.render('burialSite-view', { + headTitle: burialSite.burialSiteName, + lot: burialSite }); response.on('finish', () => { - void getNextLotId(lot.lotId); - void getPreviousLotId(lot.lotId); + void getNextBurialSiteId(burialSite.burialSiteId); + void getPreviousBurialSiteId(burialSite.burialSiteId); }); } diff --git a/handlers/burialSites-get/view.ts b/handlers/burialSites-get/view.ts index b89517ca..6b7afb6f 100644 --- a/handlers/burialSites-get/view.ts +++ b/handlers/burialSites-get/view.ts @@ -1,29 +1,32 @@ import type { Request, Response } from 'express' -import getLot from '../../database/getLot.js' +import getBurialSite from '../../database/getBurialSite.js' +import { + getNextBurialSiteId, + getPreviousBurialSiteId +} from '../../helpers/burialSites.helpers.js' import { getConfigProperty } from '../../helpers/config.helpers.js' -import { getNextLotId, getPreviousLotId } from '../../helpers/functions.lots.js' export default async function handler( request: Request, response: Response ): Promise { - const lot = await getLot(request.params.lotId) + const burialSite = await getBurialSite(request.params.burialSiteId) - if (lot === undefined) { + if (burialSite === undefined) { response.redirect( - `${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=lotIdNotFound` + `${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/?error=burialSiteIdNotFound` ) return } - response.render('lot-view', { - headTitle: lot.lotName, - lot + response.render('burialSite-view', { + headTitle: burialSite.burialSiteName, + lot: burialSite }) response.on('finish', () => { - void getNextLotId(lot.lotId) - void getPreviousLotId(lot.lotId) + void getNextBurialSiteId(burialSite.burialSiteId) + void getPreviousBurialSiteId(burialSite.burialSiteId) }) } diff --git a/handlers/burialSites-post/doAddBurialSiteComment.d.ts b/handlers/burialSites-post/doAddBurialSiteComment.d.ts new file mode 100644 index 00000000..b0018359 --- /dev/null +++ b/handlers/burialSites-post/doAddBurialSiteComment.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type AddBurialSiteCommentForm } from '../../database/addBurialSiteComment.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/burialSites-post/doAddBurialSiteComment.js b/handlers/burialSites-post/doAddBurialSiteComment.js new file mode 100644 index 00000000..b00b8c11 --- /dev/null +++ b/handlers/burialSites-post/doAddBurialSiteComment.js @@ -0,0 +1,10 @@ +import addBurialSiteComment from '../../database/addBurialSiteComment.js'; +import getBurialSiteComments from '../../database/getBurialSiteComments.js'; +export default async function handler(request, response) { + await addBurialSiteComment(request.body, request.session.user); + const burialSiteComments = await getBurialSiteComments(request.body.burialSiteId); + response.json({ + success: true, + burialSiteComments + }); +} diff --git a/handlers/burialSites-post/doAddBurialSiteComment.ts b/handlers/burialSites-post/doAddBurialSiteComment.ts new file mode 100644 index 00000000..7cd2d925 --- /dev/null +++ b/handlers/burialSites-post/doAddBurialSiteComment.ts @@ -0,0 +1,22 @@ +import type { Request, Response } from 'express' + +import addBurialSiteComment, { + type AddBurialSiteCommentForm +} from '../../database/addBurialSiteComment.js' +import getBurialSiteComments from '../../database/getBurialSiteComments.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + await addBurialSiteComment(request.body, request.session.user as User) + + const burialSiteComments = await getBurialSiteComments( + request.body.burialSiteId + ) + + response.json({ + success: true, + burialSiteComments + }) +} diff --git a/handlers/burialSites-post/doAddLotComment.js b/handlers/burialSites-post/doAddLotComment.js deleted file mode 100644 index 4bcec715..00000000 --- a/handlers/burialSites-post/doAddLotComment.js +++ /dev/null @@ -1,10 +0,0 @@ -import addLotComment from '../../database/addLotComment.js'; -import getLotComments from '../../database/getLotComments.js'; -export default async function handler(request, response) { - await addLotComment(request.body, request.session.user); - const lotComments = await getLotComments(request.body.lotId); - response.json({ - success: true, - lotComments - }); -} diff --git a/handlers/burialSites-post/doAddLotComment.ts b/handlers/burialSites-post/doAddLotComment.ts deleted file mode 100644 index 17fba252..00000000 --- a/handlers/burialSites-post/doAddLotComment.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type { Request, Response } from 'express' - -import addLotComment, { - type AddLotCommentForm -} from '../../database/addLotComment.js' -import getLotComments from '../../database/getLotComments.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - await addLotComment( - request.body as AddLotCommentForm, - request.session.user as User - ) - - const lotComments = await getLotComments(request.body.lotId as string) - - response.json({ - success: true, - lotComments - }) -} diff --git a/handlers/burialSites-post/doCreateBurialSite.d.ts b/handlers/burialSites-post/doCreateBurialSite.d.ts new file mode 100644 index 00000000..553f79f8 --- /dev/null +++ b/handlers/burialSites-post/doCreateBurialSite.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type AddBurialSiteForm } from '../../database/addBurialSite.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/burialSites-post/doCreateBurialSite.js b/handlers/burialSites-post/doCreateBurialSite.js new file mode 100644 index 00000000..e996c56e --- /dev/null +++ b/handlers/burialSites-post/doCreateBurialSite.js @@ -0,0 +1,12 @@ +import addBurialSite from '../../database/addBurialSite.js'; +import { clearNextPreviousBurialSiteIdCache } from '../../helpers/burialSites.helpers.js'; +export default async function handler(request, response) { + const burialSiteId = await addBurialSite(request.body, request.session.user); + response.json({ + success: true, + burialSiteId + }); + response.on('finish', () => { + clearNextPreviousBurialSiteIdCache(-1); + }); +} diff --git a/handlers/burialSites-post/doCreateBurialSite.ts b/handlers/burialSites-post/doCreateBurialSite.ts new file mode 100644 index 00000000..5b820609 --- /dev/null +++ b/handlers/burialSites-post/doCreateBurialSite.ts @@ -0,0 +1,25 @@ +import type { Request, Response } from 'express' + +import addBurialSite, { + type AddBurialSiteForm +} from '../../database/addBurialSite.js' +import { clearNextPreviousBurialSiteIdCache } from '../../helpers/burialSites.helpers.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + const burialSiteId = await addBurialSite( + request.body, + request.session.user as User + ) + + response.json({ + success: true, + burialSiteId + }) + + response.on('finish', () => { + clearNextPreviousBurialSiteIdCache(-1) + }) +} diff --git a/handlers/burialSites-post/doCreateLot.js b/handlers/burialSites-post/doCreateLot.js deleted file mode 100644 index 2737f657..00000000 --- a/handlers/burialSites-post/doCreateLot.js +++ /dev/null @@ -1,12 +0,0 @@ -import addLot from '../../database/addLot.js'; -import { clearNextPreviousLotIdCache } from '../../helpers/functions.lots.js'; -export default async function handler(request, response) { - const lotId = await addLot(request.body, request.session.user); - response.json({ - success: true, - lotId - }); - response.on('finish', () => { - clearNextPreviousLotIdCache(-1); - }); -} diff --git a/handlers/burialSites-post/doCreateLot.ts b/handlers/burialSites-post/doCreateLot.ts deleted file mode 100644 index 0d5ca3a9..00000000 --- a/handlers/burialSites-post/doCreateLot.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { Request, Response } from 'express' - -import addLot, { type AddLotForm } from '../../database/addLot.js' -import { clearNextPreviousLotIdCache } from '../../helpers/functions.lots.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - const lotId = await addLot( - request.body as AddLotForm, - request.session.user as User - ) - - response.json({ - success: true, - lotId - }) - - response.on('finish', () => { - clearNextPreviousLotIdCache(-1) - }) -} - diff --git a/handlers/burialSites-post/doDeleteBurialSite.d.ts b/handlers/burialSites-post/doDeleteBurialSite.d.ts new file mode 100644 index 00000000..87af9038 --- /dev/null +++ b/handlers/burialSites-post/doDeleteBurialSite.d.ts @@ -0,0 +1,4 @@ +import type { Request, Response } from 'express'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/burialSites-post/doDeleteBurialSite.js b/handlers/burialSites-post/doDeleteBurialSite.js new file mode 100644 index 00000000..642e6057 --- /dev/null +++ b/handlers/burialSites-post/doDeleteBurialSite.js @@ -0,0 +1,12 @@ +import { deleteRecord } from '../../database/deleteRecord.js'; +import { clearNextPreviousBurialSiteIdCache } from '../../helpers/burialSites.helpers.js'; +export default async function handler(request, response) { + const burialSiteId = Number.parseInt(request.body.burialSiteId, 10); + const success = await deleteRecord('BurialSites', burialSiteId, request.session.user); + response.json({ + success + }); + response.on('finish', () => { + clearNextPreviousBurialSiteIdCache(burialSiteId); + }); +} diff --git a/handlers/burialSites-post/doDeleteBurialSite.ts b/handlers/burialSites-post/doDeleteBurialSite.ts new file mode 100644 index 00000000..705ff343 --- /dev/null +++ b/handlers/burialSites-post/doDeleteBurialSite.ts @@ -0,0 +1,25 @@ +import type { Request, Response } from 'express' + +import { deleteRecord } from '../../database/deleteRecord.js' +import { clearNextPreviousBurialSiteIdCache } from '../../helpers/burialSites.helpers.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + const burialSiteId = Number.parseInt(request.body.burialSiteId, 10) + + const success = await deleteRecord( + 'BurialSites', + burialSiteId, + request.session.user as User + ) + + response.json({ + success + }) + + response.on('finish', () => { + clearNextPreviousBurialSiteIdCache(burialSiteId) + }) +} diff --git a/handlers/burialSites-post/doDeleteBurialSiteComment.d.ts b/handlers/burialSites-post/doDeleteBurialSiteComment.d.ts new file mode 100644 index 00000000..997f4e53 --- /dev/null +++ b/handlers/burialSites-post/doDeleteBurialSiteComment.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/burialSites-post/doDeleteBurialSiteComment.js b/handlers/burialSites-post/doDeleteBurialSiteComment.js new file mode 100644 index 00000000..de49a434 --- /dev/null +++ b/handlers/burialSites-post/doDeleteBurialSiteComment.js @@ -0,0 +1,10 @@ +import { deleteRecord } from '../../database/deleteRecord.js'; +import getBurialSiteComments from '../../database/getBurialSiteComments.js'; +export default async function handler(request, response) { + const success = await deleteRecord('BurialSiteComments', request.body.burialSiteCommentId, request.session.user); + const burialSiteComments = await getBurialSiteComments(request.body.burialSiteId); + response.json({ + success, + burialSiteComments + }); +} diff --git a/handlers/burialSites-post/doDeleteBurialSiteComment.ts b/handlers/burialSites-post/doDeleteBurialSiteComment.ts new file mode 100644 index 00000000..96d3ff5f --- /dev/null +++ b/handlers/burialSites-post/doDeleteBurialSiteComment.ts @@ -0,0 +1,28 @@ +import type { Request, Response } from 'express' + +import { deleteRecord } from '../../database/deleteRecord.js' +import getBurialSiteComments from '../../database/getBurialSiteComments.js' + +export default async function handler( + request: Request< + unknown, + unknown, + { burialSiteId: string; burialSiteCommentId: string } + >, + response: Response +): Promise { + const success = await deleteRecord( + 'BurialSiteComments', + request.body.burialSiteCommentId, + request.session.user as User + ) + + const burialSiteComments = await getBurialSiteComments( + request.body.burialSiteId as string + ) + + response.json({ + success, + burialSiteComments + }) +} diff --git a/handlers/burialSites-post/doDeleteLot.js b/handlers/burialSites-post/doDeleteLot.js deleted file mode 100644 index f0d87eee..00000000 --- a/handlers/burialSites-post/doDeleteLot.js +++ /dev/null @@ -1,12 +0,0 @@ -import { clearNextPreviousLotIdCache } from '../../helpers/functions.lots.js'; -import { deleteRecord } from '../../database/deleteRecord.js'; -export default async function handler(request, response) { - const lotId = Number.parseInt(request.body.lotId, 10); - const success = await deleteRecord('Lots', lotId, request.session.user); - response.json({ - success - }); - response.on('finish', () => { - clearNextPreviousLotIdCache(lotId); - }); -} diff --git a/handlers/burialSites-post/doDeleteLot.ts b/handlers/burialSites-post/doDeleteLot.ts deleted file mode 100644 index 87e81e6e..00000000 --- a/handlers/burialSites-post/doDeleteLot.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { Request, Response } from 'express' - -import { clearNextPreviousLotIdCache } from '../../helpers/functions.lots.js' -import { deleteRecord } from '../../database/deleteRecord.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - const lotId = Number.parseInt(request.body.lotId, 10) - - const success = await deleteRecord('Lots', lotId, request.session.user as User) - - response.json({ - success - }) - - response.on('finish', () => { - clearNextPreviousLotIdCache(lotId) - }) -} - diff --git a/handlers/burialSites-post/doDeleteLotComment.js b/handlers/burialSites-post/doDeleteLotComment.js deleted file mode 100644 index 69b8e818..00000000 --- a/handlers/burialSites-post/doDeleteLotComment.js +++ /dev/null @@ -1,10 +0,0 @@ -import { deleteRecord } from '../../database/deleteRecord.js'; -import getLotComments from '../../database/getLotComments.js'; -export default async function handler(request, response) { - const success = await deleteRecord('LotComments', request.body.lotCommentId, request.session.user); - const lotComments = await getLotComments(request.body.lotId); - response.json({ - success, - lotComments - }); -} diff --git a/handlers/burialSites-post/doDeleteLotComment.ts b/handlers/burialSites-post/doDeleteLotComment.ts deleted file mode 100644 index 2d8ad796..00000000 --- a/handlers/burialSites-post/doDeleteLotComment.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { Request, Response } from 'express' - -import { deleteRecord } from '../../database/deleteRecord.js' -import getLotComments from '../../database/getLotComments.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - const success = await deleteRecord( - 'LotComments', - request.body.lotCommentId as string, - request.session.user as User - ) - - const lotComments = await getLotComments(request.body.lotId as string) - - response.json({ - success, - lotComments - }) -} diff --git a/handlers/burialSites-post/doGetBurialSiteTypeFields.d.ts b/handlers/burialSites-post/doGetBurialSiteTypeFields.d.ts new file mode 100644 index 00000000..af966b40 --- /dev/null +++ b/handlers/burialSites-post/doGetBurialSiteTypeFields.d.ts @@ -0,0 +1,4 @@ +import type { Request, Response } from 'express'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/burialSites-post/doGetBurialSiteTypeFields.js b/handlers/burialSites-post/doGetBurialSiteTypeFields.js new file mode 100644 index 00000000..a48b4faa --- /dev/null +++ b/handlers/burialSites-post/doGetBurialSiteTypeFields.js @@ -0,0 +1,7 @@ +import { getBurialSiteTypeById } from '../../helpers/functions.cache.js'; +export default async function handler(request, response) { + const burialSiteType = await getBurialSiteTypeById(Number.parseInt(request.body.burialSiteTypeId, 10)); + response.json({ + burialSiteTypeFields: burialSiteType?.burialSiteTypeFields ?? [] + }); +} diff --git a/handlers/burialSites-post/doGetBurialSiteTypeFields.ts b/handlers/burialSites-post/doGetBurialSiteTypeFields.ts new file mode 100644 index 00000000..3b09a8d3 --- /dev/null +++ b/handlers/burialSites-post/doGetBurialSiteTypeFields.ts @@ -0,0 +1,16 @@ +import type { Request, Response } from 'express' + +import { getBurialSiteTypeById } from '../../helpers/functions.cache.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + const burialSiteType = await getBurialSiteTypeById( + Number.parseInt(request.body.burialSiteTypeId, 10) + ) + + response.json({ + burialSiteTypeFields: burialSiteType?.burialSiteTypeFields ?? [] + }) +} diff --git a/handlers/burialSites-post/doGetLotTypeFields.d.ts b/handlers/burialSites-post/doGetLotTypeFields.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/burialSites-post/doGetLotTypeFields.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/burialSites-post/doGetLotTypeFields.js b/handlers/burialSites-post/doGetLotTypeFields.js deleted file mode 100644 index a308bf9b..00000000 --- a/handlers/burialSites-post/doGetLotTypeFields.js +++ /dev/null @@ -1,7 +0,0 @@ -import { getLotTypeById } from '../../helpers/functions.cache.js'; -export default async function handler(request, response) { - const lotType = (await getLotTypeById(Number.parseInt(request.body.burialSiteTypeId, 10))); - response.json({ - BurialSiteTypeFields: lotType.BurialSiteTypeFields - }); -} diff --git a/handlers/burialSites-post/doGetLotTypeFields.ts b/handlers/burialSites-post/doGetLotTypeFields.ts deleted file mode 100644 index 44245ef9..00000000 --- a/handlers/burialSites-post/doGetLotTypeFields.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { Request, Response } from 'express' - -import { getLotTypeById } from '../../helpers/functions.cache.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - const lotType = (await getLotTypeById( - Number.parseInt(request.body.burialSiteTypeId, 10) - ))! - - response.json({ - BurialSiteTypeFields: lotType.BurialSiteTypeFields - }) -} - diff --git a/handlers/burialSites-post/doSearchBurialSites.d.ts b/handlers/burialSites-post/doSearchBurialSites.d.ts new file mode 100644 index 00000000..cd2d8778 --- /dev/null +++ b/handlers/burialSites-post/doSearchBurialSites.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type GetBurialSitesFilters, type GetBurialSitesOptions } from '../../database/getBurialSites.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/burialSites-post/doSearchBurialSites.js b/handlers/burialSites-post/doSearchBurialSites.js new file mode 100644 index 00000000..99776c3a --- /dev/null +++ b/handlers/burialSites-post/doSearchBurialSites.js @@ -0,0 +1,15 @@ +import getBurialSites from '../../database/getBurialSites.js'; +export default async function handler(request, response) { + const result = await getBurialSites(request.body, { + limit: request.body.limit, + offset: request.body.offset, + includeBurialSiteContractCount: true + }); + response.json({ + count: result.count, + offset: typeof request.body.offset === 'string' + ? Number.parseInt(request.body.offset, 10) + : request.body.offset, + burialSites: result.burialSites + }); +} diff --git a/handlers/burialSites-post/doSearchBurialSites.ts b/handlers/burialSites-post/doSearchBurialSites.ts new file mode 100644 index 00000000..7d75a362 --- /dev/null +++ b/handlers/burialSites-post/doSearchBurialSites.ts @@ -0,0 +1,30 @@ +import type { Request, Response } from 'express' + +import getBurialSites, { + type GetBurialSitesFilters, + type GetBurialSitesOptions +} from '../../database/getBurialSites.js' + +export default async function handler( + request: Request< + unknown, + unknown, + GetBurialSitesFilters & GetBurialSitesOptions + >, + response: Response +): Promise { + const result = await getBurialSites(request.body, { + limit: request.body.limit, + offset: request.body.offset, + includeBurialSiteContractCount: true + }) + + response.json({ + count: result.count, + offset: + typeof request.body.offset === 'string' + ? Number.parseInt(request.body.offset, 10) + : request.body.offset, + burialSites: result.burialSites + }) +} diff --git a/handlers/burialSites-post/doSearchLots.d.ts b/handlers/burialSites-post/doSearchLots.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/burialSites-post/doSearchLots.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/burialSites-post/doSearchLots.js b/handlers/burialSites-post/doSearchLots.js deleted file mode 100644 index 1b2716e3..00000000 --- a/handlers/burialSites-post/doSearchLots.js +++ /dev/null @@ -1,13 +0,0 @@ -import getLots from '../../database/getLots.js'; -export default async function handler(request, response) { - const result = await getLots(request.body, { - limit: request.body.limit, - offset: request.body.offset, - includeLotOccupancyCount: true - }); - response.json({ - count: result.count, - offset: Number.parseInt(request.body.offset, 10), - lots: result.lots - }); -} diff --git a/handlers/burialSites-post/doSearchLots.ts b/handlers/burialSites-post/doSearchLots.ts deleted file mode 100644 index 59ab0590..00000000 --- a/handlers/burialSites-post/doSearchLots.ts +++ /dev/null @@ -1,18 +0,0 @@ -import type { Request, Response } from 'express' - -import getLots from '../../database/getLots.js' - -export default async function handler(request: Request, response: Response): Promise { - const result = await getLots(request.body, { - limit: request.body.limit, - offset: request.body.offset, - includeLotOccupancyCount: true - }) - - response.json({ - count: result.count, - offset: Number.parseInt(request.body.offset, 10), - lots: result.lots - }) -} - diff --git a/handlers/burialSites-post/doUpdateBurialSite.d.ts b/handlers/burialSites-post/doUpdateBurialSite.d.ts new file mode 100644 index 00000000..afec09b5 --- /dev/null +++ b/handlers/burialSites-post/doUpdateBurialSite.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type UpdateBurialSiteForm } from '../../database/updateBurialSite.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/burialSites-post/doUpdateBurialSite.js b/handlers/burialSites-post/doUpdateBurialSite.js new file mode 100644 index 00000000..62f55b0c --- /dev/null +++ b/handlers/burialSites-post/doUpdateBurialSite.js @@ -0,0 +1,15 @@ +import updateBurialSite from '../../database/updateBurialSite.js'; +import { clearNextPreviousBurialSiteIdCache } from '../../helpers/burialSites.helpers.js'; +export default async function handler(request, response) { + const success = await updateBurialSite(request.body, request.session.user); + const burialSiteId = typeof request.body.burialSiteId === 'string' + ? Number.parseInt(request.body.burialSiteId, 10) + : request.body.burialSiteId; + response.json({ + success, + burialSiteId + }); + response.on('finish', () => { + clearNextPreviousBurialSiteIdCache(burialSiteId); + }); +} diff --git a/handlers/burialSites-post/doUpdateBurialSite.ts b/handlers/burialSites-post/doUpdateBurialSite.ts new file mode 100644 index 00000000..44567bea --- /dev/null +++ b/handlers/burialSites-post/doUpdateBurialSite.ts @@ -0,0 +1,30 @@ +import type { Request, Response } from 'express' + +import updateBurialSite, { + type UpdateBurialSiteForm +} from '../../database/updateBurialSite.js' +import { clearNextPreviousBurialSiteIdCache } from '../../helpers/burialSites.helpers.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + const success = await updateBurialSite( + request.body, + request.session.user as User + ) + + const burialSiteId = + typeof request.body.burialSiteId === 'string' + ? Number.parseInt(request.body.burialSiteId, 10) + : request.body.burialSiteId + + response.json({ + success, + burialSiteId + }) + + response.on('finish', () => { + clearNextPreviousBurialSiteIdCache(burialSiteId) + }) +} diff --git a/handlers/burialSites-post/doUpdateBurialSiteComment.d.ts b/handlers/burialSites-post/doUpdateBurialSiteComment.d.ts new file mode 100644 index 00000000..e451de2f --- /dev/null +++ b/handlers/burialSites-post/doUpdateBurialSiteComment.d.ts @@ -0,0 +1,5 @@ +import type { Request, Response } from 'express'; +import { type UpdateBurialSiteCommentForm } from '../../database/updateBurialSiteComment.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/burialSites-post/doUpdateBurialSiteComment.js b/handlers/burialSites-post/doUpdateBurialSiteComment.js new file mode 100644 index 00000000..cf684380 --- /dev/null +++ b/handlers/burialSites-post/doUpdateBurialSiteComment.js @@ -0,0 +1,10 @@ +import getBurialSiteComments from '../../database/getBurialSiteComments.js'; +import updateBurialSiteComment from '../../database/updateBurialSiteComment.js'; +export default async function handler(request, response) { + const success = await updateBurialSiteComment(request.body, request.session.user); + const burialSiteComments = await getBurialSiteComments(request.body.burialSiteId); + response.json({ + success, + burialSiteComments + }); +} diff --git a/handlers/burialSites-post/doUpdateBurialSiteComment.ts b/handlers/burialSites-post/doUpdateBurialSiteComment.ts new file mode 100644 index 00000000..4a4466bd --- /dev/null +++ b/handlers/burialSites-post/doUpdateBurialSiteComment.ts @@ -0,0 +1,29 @@ +import type { Request, Response } from 'express' + +import getBurialSiteComments from '../../database/getBurialSiteComments.js' +import updateBurialSiteComment, { + type UpdateBurialSiteCommentForm +} from '../../database/updateBurialSiteComment.js' + +export default async function handler( + request: Request< + unknown, + unknown, + UpdateBurialSiteCommentForm & { burialSiteId: string } + >, + response: Response +): Promise { + const success = await updateBurialSiteComment( + request.body, + request.session.user as User + ) + + const burialSiteComments = await getBurialSiteComments( + request.body.burialSiteId + ) + + response.json({ + success, + burialSiteComments + }) +} diff --git a/handlers/burialSites-post/doUpdateLot.d.ts b/handlers/burialSites-post/doUpdateLot.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/burialSites-post/doUpdateLot.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/burialSites-post/doUpdateLot.js b/handlers/burialSites-post/doUpdateLot.js deleted file mode 100644 index db15965f..00000000 --- a/handlers/burialSites-post/doUpdateLot.js +++ /dev/null @@ -1,13 +0,0 @@ -import updateLot from '../../database/updateLot.js'; -import { clearNextPreviousLotIdCache } from '../../helpers/functions.lots.js'; -export default async function handler(request, response) { - const lotId = Number.parseInt(request.body.lotId, 10); - const success = await updateLot(request.body, request.session.user); - response.json({ - success, - lotId: request.body.lotId - }); - response.on('finish', () => { - clearNextPreviousLotIdCache(lotId); - }); -} diff --git a/handlers/burialSites-post/doUpdateLot.ts b/handlers/burialSites-post/doUpdateLot.ts deleted file mode 100644 index 882fec0a..00000000 --- a/handlers/burialSites-post/doUpdateLot.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { Request, Response } from 'express' - -import updateLot, { type UpdateLotForm } from '../../database/updateLot.js' -import { clearNextPreviousLotIdCache } from '../../helpers/functions.lots.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - const lotId = Number.parseInt(request.body.lotId as string, 10) - - const success = await updateLot( - request.body as UpdateLotForm, - request.session.user as User - ) - - response.json({ - success, - lotId: request.body.lotId as string - }) - - response.on('finish', () => { - clearNextPreviousLotIdCache(lotId) - }) -} diff --git a/handlers/burialSites-post/doUpdateLotComment.d.ts b/handlers/burialSites-post/doUpdateLotComment.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/burialSites-post/doUpdateLotComment.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/burialSites-post/doUpdateLotComment.js b/handlers/burialSites-post/doUpdateLotComment.js deleted file mode 100644 index 0596e86f..00000000 --- a/handlers/burialSites-post/doUpdateLotComment.js +++ /dev/null @@ -1,10 +0,0 @@ -import getLotComments from '../../database/getLotComments.js'; -import updateLotComment from '../../database/updateLotComment.js'; -export default async function handler(request, response) { - const success = await updateLotComment(request.body, request.session.user); - const lotComments = await getLotComments(request.body.lotId); - response.json({ - success, - lotComments - }); -} diff --git a/handlers/burialSites-post/doUpdateLotComment.ts b/handlers/burialSites-post/doUpdateLotComment.ts deleted file mode 100644 index cd799c7a..00000000 --- a/handlers/burialSites-post/doUpdateLotComment.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type { Request, Response } from 'express' - -import getLotComments from '../../database/getLotComments.js' -import updateLotComment, { - type UpdateLotCommentForm -} from '../../database/updateLotComment.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - const success = await updateLotComment( - request.body as UpdateLotCommentForm, - request.session.user as User - ) - - const lotComments = await getLotComments(request.body.lotId as string) - - response.json({ - success, - lotComments - }) -} diff --git a/handlers/contracts-get/edit.js b/handlers/contracts-get/edit.js index b34524b8..4eb68e86 100644 --- a/handlers/contracts-get/edit.js +++ b/handlers/contracts-get/edit.js @@ -1,29 +1,27 @@ -import getLotOccupancy from '../../database/getLotOccupancy.js'; -import getMaps from '../../database/getMaps.js'; -import { getLotOccupantTypes, getLotStatuses, getBurialSiteTypes, getContractTypePrintsById, getContractTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js'; +import getBurialSiteContract from '../../database/getBurialSiteContract.js'; +import getCemeteries from '../../database/getCemeteries.js'; import { getConfigProperty } from '../../helpers/config.helpers.js'; +import { getBurialSiteStatuses, getBurialSiteTypes, getContractTypePrintsById, getContractTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js'; export default async function handler(request, response) { - const lotOccupancy = await getLotOccupancy(request.params.burialSiteContractId); - if (lotOccupancy === undefined) { - response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lotOccupancies/?error=burialSiteContractIdNotFound`); + const burialSiteContract = await getBurialSiteContract(request.params.burialSiteContractId); + if (burialSiteContract === undefined) { + response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/contracts/?error=burialSiteContractIdNotFound`); return; } - const ContractTypePrints = await getContractTypePrintsById(lotOccupancy.contractTypeId); - const occupancyTypes = await getContractTypes(); - const lotOccupantTypes = await getLotOccupantTypes(); - const lotTypes = await getBurialSiteTypes(); - const lotStatuses = await getLotStatuses(); - const maps = await getMaps(); + const contractTypePrints = await getContractTypePrintsById(burialSiteContract.contractTypeId); + const contractTypes = await getContractTypes(); + const burialSiteTypes = await getBurialSiteTypes(); + const burialSiteStatuses = await getBurialSiteStatuses(); + const cemeteries = await getCemeteries(); const workOrderTypes = await getWorkOrderTypes(); - response.render('lotOccupancy-edit', { - headTitle: `${getConfigProperty('aliases.occupancy')} Update`, - lotOccupancy, - ContractTypePrints, - occupancyTypes, - lotOccupantTypes, - lotTypes, - lotStatuses, - maps, + response.render('burialSiteContract-edit', { + headTitle: 'Contract Update', + burialSiteContract, + contractTypePrints, + contractTypes, + burialSiteTypes, + burialSiteStatuses, + cemeteries, workOrderTypes, isCreate: false }); diff --git a/handlers/contracts-get/edit.ts b/handlers/contracts-get/edit.ts index eb371292..ced456f4 100644 --- a/handlers/contracts-get/edit.ts +++ b/handlers/contracts-get/edit.ts @@ -1,53 +1,52 @@ import type { Request, Response } from 'express' -import getLotOccupancy from '../../database/getLotOccupancy.js' -import getMaps from '../../database/getMaps.js' +import getBurialSiteContract from '../../database/getBurialSiteContract.js' +import getCemeteries from '../../database/getCemeteries.js' +import { getConfigProperty } from '../../helpers/config.helpers.js' import { - getLotOccupantTypes, - getLotStatuses, + getBurialSiteStatuses, getBurialSiteTypes, getContractTypePrintsById, getContractTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js' -import { getConfigProperty } from '../../helpers/config.helpers.js' export default async function handler( request: Request, response: Response ): Promise { - const lotOccupancy = await getLotOccupancy(request.params.burialSiteContractId) + const burialSiteContract = await getBurialSiteContract( + request.params.burialSiteContractId + ) - if (lotOccupancy === undefined) { + if (burialSiteContract === undefined) { response.redirect( `${getConfigProperty( 'reverseProxy.urlPrefix' - )}/lotOccupancies/?error=burialSiteContractIdNotFound` + )}/contracts/?error=burialSiteContractIdNotFound` ) return } - const ContractTypePrints = await getContractTypePrintsById( - lotOccupancy.contractTypeId + const contractTypePrints = await getContractTypePrintsById( + burialSiteContract.contractTypeId ) - const occupancyTypes = await getContractTypes() - const lotOccupantTypes = await getLotOccupantTypes() - const lotTypes = await getBurialSiteTypes() - const lotStatuses = await getLotStatuses() - const maps = await getMaps() + const contractTypes = await getContractTypes() + const burialSiteTypes = await getBurialSiteTypes() + const burialSiteStatuses = await getBurialSiteStatuses() + const cemeteries = await getCemeteries() const workOrderTypes = await getWorkOrderTypes() - response.render('lotOccupancy-edit', { - headTitle: `${getConfigProperty('aliases.occupancy')} Update`, - lotOccupancy, - ContractTypePrints, + response.render('burialSiteContract-edit', { + headTitle: 'Contract Update', + burialSiteContract, + contractTypePrints, - occupancyTypes, - lotOccupantTypes, - lotTypes, - lotStatuses, - maps, + contractTypes, + burialSiteTypes, + burialSiteStatuses, + cemeteries, workOrderTypes, isCreate: false diff --git a/handlers/contracts-get/new.js b/handlers/contracts-get/new.js index 6c58603c..0cb66141 100644 --- a/handlers/contracts-get/new.js +++ b/handlers/contracts-get/new.js @@ -1,36 +1,33 @@ import { dateToInteger, dateToString } from '@cityssm/utils-datetime'; -import getLot from '../../database/getLot.js'; -import getMaps from '../../database/getMaps.js'; -import { getLotOccupantTypes, getLotStatuses, getBurialSiteTypes, getContractTypes } from '../../helpers/functions.cache.js'; -import { getConfigProperty } from '../../helpers/config.helpers.js'; +import getBurialSite from '../../database/getBurialSite.js'; +import getCemeteries from '../../database/getCemeteries.js'; +import { getBurialSiteStatuses, getBurialSiteTypes, getContractTypes } from '../../helpers/functions.cache.js'; export default async function handler(request, response) { const startDate = new Date(); - const lotOccupancy = { + const burialSiteContract = { contractStartDate: dateToInteger(startDate), contractStartDateString: dateToString(startDate) }; - if (request.query.lotId !== undefined) { - const lot = await getLot(request.query.lotId); - if (lot !== undefined) { - lotOccupancy.lotId = lot.lotId; - lotOccupancy.lotName = lot.lotName; - lotOccupancy.cemeteryId = lot.cemeteryId; - lotOccupancy.cemeteryName = lot.cemeteryName; + if (request.query.burialSiteId !== undefined) { + const burialSite = await getBurialSite(request.query.burialSiteId); + if (burialSite !== undefined) { + burialSiteContract.burialSiteId = burialSite.burialSiteId; + burialSiteContract.burialSiteName = burialSite.burialSiteName; + burialSiteContract.cemeteryId = burialSite.cemeteryId; + burialSiteContract.cemeteryName = burialSite.cemeteryName; } } - const occupancyTypes = await getContractTypes(); - const lotOccupantTypes = await getLotOccupantTypes(); - const lotTypes = await getBurialSiteTypes(); - const lotStatuses = await getLotStatuses(); - const maps = await getMaps(); - response.render('lotOccupancy-edit', { - headTitle: `Create a New ${getConfigProperty('aliases.occupancy')} Record`, - lotOccupancy, - occupancyTypes, - lotOccupantTypes, - lotTypes, - lotStatuses, - maps, + const contractTypes = await getContractTypes(); + const burialSiteTypes = await getBurialSiteTypes(); + const burialSiteStatuses = await getBurialSiteStatuses(); + const cemeteries = await getCemeteries(); + response.render('burialSiteContract-edit', { + headTitle: 'Create a New Contract', + burialSiteContract, + contractTypes, + burialSiteTypes, + burialSiteStatuses, + cemeteries, isCreate: true }); } diff --git a/handlers/contracts-get/new.ts b/handlers/contracts-get/new.ts index ced7e3ac..6a1100dd 100644 --- a/handlers/contracts-get/new.ts +++ b/handlers/contracts-get/new.ts @@ -1,16 +1,14 @@ import { dateToInteger, dateToString } from '@cityssm/utils-datetime' import type { Request, Response } from 'express' -import getLot from '../../database/getLot.js' -import getMaps from '../../database/getMaps.js' +import getBurialSite from '../../database/getBurialSite.js' +import getCemeteries from '../../database/getCemeteries.js' import { - getLotOccupantTypes, - getLotStatuses, + getBurialSiteStatuses, getBurialSiteTypes, getContractTypes } from '../../helpers/functions.cache.js' -import { getConfigProperty } from '../../helpers/config.helpers.js' -import type { LotOccupancy } from '../../types/recordTypes.js' +import type { BurialSiteContract } from '../../types/recordTypes.js' export default async function handler( request: Request, @@ -18,37 +16,35 @@ export default async function handler( ): Promise { const startDate = new Date() - const lotOccupancy: Partial = { + const burialSiteContract: Partial = { contractStartDate: dateToInteger(startDate), contractStartDateString: dateToString(startDate) } - if (request.query.lotId !== undefined) { - const lot = await getLot(request.query.lotId as string) + if (request.query.burialSiteId !== undefined) { + const burialSite = await getBurialSite(request.query.burialSiteId as string) - if (lot !== undefined) { - lotOccupancy.lotId = lot.lotId - lotOccupancy.lotName = lot.lotName - lotOccupancy.cemeteryId = lot.cemeteryId - lotOccupancy.cemeteryName = lot.cemeteryName + if (burialSite !== undefined) { + burialSiteContract.burialSiteId = burialSite.burialSiteId + burialSiteContract.burialSiteName = burialSite.burialSiteName + burialSiteContract.cemeteryId = burialSite.cemeteryId + burialSiteContract.cemeteryName = burialSite.cemeteryName } } - const occupancyTypes = await getContractTypes() - const lotOccupantTypes = await getLotOccupantTypes() - const lotTypes = await getBurialSiteTypes() - const lotStatuses = await getLotStatuses() - const maps = await getMaps() + const contractTypes = await getContractTypes() + const burialSiteTypes = await getBurialSiteTypes() + const burialSiteStatuses = await getBurialSiteStatuses() + const cemeteries = await getCemeteries() - response.render('lotOccupancy-edit', { - headTitle: `Create a New ${getConfigProperty('aliases.occupancy')} Record`, - lotOccupancy, + response.render('burialSiteContract-edit', { + headTitle: 'Create a New Contract', + burialSiteContract, - occupancyTypes, - lotOccupantTypes, - lotTypes, - lotStatuses, - maps, + contractTypes, + burialSiteTypes, + burialSiteStatuses, + cemeteries, isCreate: true }) diff --git a/handlers/contracts-get/search.js b/handlers/contracts-get/search.js index c057d8a0..fffe5b7f 100644 --- a/handlers/contracts-get/search.js +++ b/handlers/contracts-get/search.js @@ -1,15 +1,14 @@ -import getMaps from '../../database/getMaps.js'; +import getCemeteries from '../../database/getCemeteries.js'; import { getBurialSiteTypes, getContractTypes } from '../../helpers/functions.cache.js'; -import { getConfigProperty } from '../../helpers/config.helpers.js'; export default async function handler(request, response) { - const maps = await getMaps(); - const lotTypes = await getBurialSiteTypes(); - const occupancyTypes = await getContractTypes(); - response.render('lotOccupancy-search', { - headTitle: `${getConfigProperty('aliases.occupancy')} Search`, - maps, - lotTypes, - occupancyTypes, + const cemeteries = await getCemeteries(); + const burialSiteTypes = await getBurialSiteTypes(); + const contractTypes = await getContractTypes(); + response.render('burialSiteContract-search', { + headTitle: `Contract Search`, + cemeteries, + burialSiteTypes, + contractTypes, cemeteryId: request.query.cemeteryId }); } diff --git a/handlers/contracts-get/search.ts b/handlers/contracts-get/search.ts index 31947652..3a2c38a3 100644 --- a/handlers/contracts-get/search.ts +++ b/handlers/contracts-get/search.ts @@ -1,25 +1,24 @@ import type { Request, Response } from 'express' -import getMaps from '../../database/getMaps.js' +import getCemeteries from '../../database/getCemeteries.js' import { getBurialSiteTypes, getContractTypes } from '../../helpers/functions.cache.js' -import { getConfigProperty } from '../../helpers/config.helpers.js' export default async function handler( request: Request, response: Response ): Promise { - const maps = await getMaps() - const lotTypes = await getBurialSiteTypes() - const occupancyTypes = await getContractTypes() + const cemeteries = await getCemeteries() + const burialSiteTypes = await getBurialSiteTypes() + const contractTypes = await getContractTypes() - response.render('lotOccupancy-search', { - headTitle: `${getConfigProperty('aliases.occupancy')} Search`, - maps, - lotTypes, - occupancyTypes, + response.render('burialSiteContract-search', { + headTitle: `Contract Search`, + cemeteries, + burialSiteTypes, + contractTypes, cemeteryId: request.query.cemeteryId }) } diff --git a/handlers/contracts-get/view.js b/handlers/contracts-get/view.js index 5aebc90c..47b43243 100644 --- a/handlers/contracts-get/view.js +++ b/handlers/contracts-get/view.js @@ -1,16 +1,16 @@ -import getLotOccupancy from '../../database/getLotOccupancy.js'; -import { getContractTypePrintsById } from '../../helpers/functions.cache.js'; +import getBurialSiteContract from '../../database/getBurialSiteContract.js'; import { getConfigProperty } from '../../helpers/config.helpers.js'; +import { getContractTypePrintsById } from '../../helpers/functions.cache.js'; export default async function handler(request, response) { - const lotOccupancy = await getLotOccupancy(request.params.burialSiteContractId); - if (lotOccupancy === undefined) { - response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lotOccupancies/?error=burialSiteContractIdNotFound`); + const burialSiteContract = await getBurialSiteContract(request.params.burialSiteContractId); + if (burialSiteContract === undefined) { + response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/contracts/?error=burialSiteContractIdNotFound`); return; } - const ContractTypePrints = await getContractTypePrintsById(lotOccupancy.contractTypeId); - response.render('lotOccupancy-view', { - headTitle: `${getConfigProperty('aliases.occupancy')} View`, - lotOccupancy, - ContractTypePrints + const contractTypePrints = await getContractTypePrintsById(burialSiteContract.contractTypeId); + response.render('burialSiteContract-view', { + headTitle: 'Contract View', + burialSiteContract, + contractTypePrints }); } diff --git a/handlers/contracts-get/view.ts b/handlers/contracts-get/view.ts index bb429d8b..8c4507ba 100644 --- a/handlers/contracts-get/view.ts +++ b/handlers/contracts-get/view.ts @@ -1,31 +1,33 @@ import type { Request, Response } from 'express' -import getLotOccupancy from '../../database/getLotOccupancy.js' -import { getContractTypePrintsById } from '../../helpers/functions.cache.js' +import getBurialSiteContract from '../../database/getBurialSiteContract.js' import { getConfigProperty } from '../../helpers/config.helpers.js' +import { getContractTypePrintsById } from '../../helpers/functions.cache.js' export default async function handler( request: Request, response: Response ): Promise { - const lotOccupancy = await getLotOccupancy(request.params.burialSiteContractId) + const burialSiteContract = await getBurialSiteContract( + request.params.burialSiteContractId + ) - if (lotOccupancy === undefined) { + if (burialSiteContract === undefined) { response.redirect( `${getConfigProperty( 'reverseProxy.urlPrefix' - )}/lotOccupancies/?error=burialSiteContractIdNotFound` + )}/contracts/?error=burialSiteContractIdNotFound` ) return } - const ContractTypePrints = await getContractTypePrintsById( - lotOccupancy.contractTypeId + const contractTypePrints = await getContractTypePrintsById( + burialSiteContract.contractTypeId ) - response.render('lotOccupancy-view', { - headTitle: `${getConfigProperty('aliases.occupancy')} View`, - lotOccupancy, - ContractTypePrints + response.render('burialSiteContract-view', { + headTitle: 'Contract View', + burialSiteContract, + contractTypePrints }) } diff --git a/handlers/contracts-post/doAddBurialSiteContractComment.d.ts b/handlers/contracts-post/doAddBurialSiteContractComment.d.ts new file mode 100644 index 00000000..ad747d54 --- /dev/null +++ b/handlers/contracts-post/doAddBurialSiteContractComment.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type AddBurialSiteContractCommentForm } from '../../database/addBurialSiteContractComment.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doAddBurialSiteContractComment.js b/handlers/contracts-post/doAddBurialSiteContractComment.js new file mode 100644 index 00000000..0fa3f4be --- /dev/null +++ b/handlers/contracts-post/doAddBurialSiteContractComment.js @@ -0,0 +1,10 @@ +import addBurialSiteContractComment from '../../database/addBurialSiteContractComment.js'; +import getBurialSiteContractComments from '../../database/getBurialSiteContractComments.js'; +export default async function handler(request, response) { + await addBurialSiteContractComment(request.body, request.session.user); + const burialSiteContractComments = await getBurialSiteContractComments(request.body.burialSiteContractId); + response.json({ + success: true, + burialSiteContractComments + }); +} diff --git a/handlers/contracts-post/doAddBurialSiteContractComment.ts b/handlers/contracts-post/doAddBurialSiteContractComment.ts new file mode 100644 index 00000000..31e9ff1c --- /dev/null +++ b/handlers/contracts-post/doAddBurialSiteContractComment.ts @@ -0,0 +1,22 @@ +import type { Request, Response } from 'express' + +import addBurialSiteContractComment, { + type AddBurialSiteContractCommentForm +} from '../../database/addBurialSiteContractComment.js' +import getBurialSiteContractComments from '../../database/getBurialSiteContractComments.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + await addBurialSiteContractComment(request.body, request.session.user as User) + + const burialSiteContractComments = await getBurialSiteContractComments( + request.body.burialSiteContractId as string + ) + + response.json({ + success: true, + burialSiteContractComments + }) +} diff --git a/handlers/contracts-post/doAddBurialSiteContractFee.d.ts b/handlers/contracts-post/doAddBurialSiteContractFee.d.ts new file mode 100644 index 00000000..0dcb9c1a --- /dev/null +++ b/handlers/contracts-post/doAddBurialSiteContractFee.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type AddBurialSiteContractFeeForm } from '../../database/addBurialSiteContractFee.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doAddBurialSiteContractFee.js b/handlers/contracts-post/doAddBurialSiteContractFee.js new file mode 100644 index 00000000..ff95e0da --- /dev/null +++ b/handlers/contracts-post/doAddBurialSiteContractFee.js @@ -0,0 +1,10 @@ +import addBurialSiteContractFee from '../../database/addBurialSiteContractFee.js'; +import getBurialSiteContractFees from '../../database/getBurialSiteContractFees.js'; +export default async function handler(request, response) { + await addBurialSiteContractFee(request.body, request.session.user); + const burialSiteContractFees = await getBurialSiteContractFees(request.body.burialSiteContractId); + response.json({ + success: true, + burialSiteContractFees + }); +} diff --git a/handlers/contracts-post/doAddBurialSiteContractFee.ts b/handlers/contracts-post/doAddBurialSiteContractFee.ts new file mode 100644 index 00000000..8a2e7db3 --- /dev/null +++ b/handlers/contracts-post/doAddBurialSiteContractFee.ts @@ -0,0 +1,22 @@ +import type { Request, Response } from 'express' + +import addBurialSiteContractFee, { + type AddBurialSiteContractFeeForm +} from '../../database/addBurialSiteContractFee.js' +import getBurialSiteContractFees from '../../database/getBurialSiteContractFees.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + await addBurialSiteContractFee(request.body, request.session.user as User) + + const burialSiteContractFees = await getBurialSiteContractFees( + request.body.burialSiteContractId as string + ) + + response.json({ + success: true, + burialSiteContractFees + }) +} diff --git a/handlers/contracts-post/doAddBurialSiteContractFeeCategory.d.ts b/handlers/contracts-post/doAddBurialSiteContractFeeCategory.d.ts new file mode 100644 index 00000000..8dd0bc32 --- /dev/null +++ b/handlers/contracts-post/doAddBurialSiteContractFeeCategory.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type AddBurialSiteContractCategoryForm } from '../../database/addBurialSiteContractFeeCategory.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doAddBurialSiteContractFeeCategory.js b/handlers/contracts-post/doAddBurialSiteContractFeeCategory.js new file mode 100644 index 00000000..411ad5d0 --- /dev/null +++ b/handlers/contracts-post/doAddBurialSiteContractFeeCategory.js @@ -0,0 +1,10 @@ +import addBurialSiteContractFeeCategory from '../../database/addBurialSiteContractFeeCategory.js'; +import getBurialSiteContractFees from '../../database/getBurialSiteContractFees.js'; +export default async function handler(request, response) { + await addBurialSiteContractFeeCategory(request.body, request.session.user); + const burialSiteContractFees = await getBurialSiteContractFees(request.body.burialSiteContractId); + response.json({ + success: true, + burialSiteContractFees + }); +} diff --git a/handlers/contracts-post/doAddBurialSiteContractFeeCategory.ts b/handlers/contracts-post/doAddBurialSiteContractFeeCategory.ts new file mode 100644 index 00000000..7731f06c --- /dev/null +++ b/handlers/contracts-post/doAddBurialSiteContractFeeCategory.ts @@ -0,0 +1,25 @@ +import type { Request, Response } from 'express' + +import addBurialSiteContractFeeCategory, { + type AddBurialSiteContractCategoryForm +} from '../../database/addBurialSiteContractFeeCategory.js' +import getBurialSiteContractFees from '../../database/getBurialSiteContractFees.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + await addBurialSiteContractFeeCategory( + request.body, + request.session.user as User + ) + + const burialSiteContractFees = await getBurialSiteContractFees( + request.body.burialSiteContractId as string + ) + + response.json({ + success: true, + burialSiteContractFees + }) +} diff --git a/handlers/contracts-post/doAddBurialSiteContractTransaction.d.ts b/handlers/contracts-post/doAddBurialSiteContractTransaction.d.ts new file mode 100644 index 00000000..b5587461 --- /dev/null +++ b/handlers/contracts-post/doAddBurialSiteContractTransaction.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type AddTransactionForm } from '../../database/addBurialSiteContractTransaction.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doAddBurialSiteContractTransaction.js b/handlers/contracts-post/doAddBurialSiteContractTransaction.js new file mode 100644 index 00000000..b4ab613a --- /dev/null +++ b/handlers/contracts-post/doAddBurialSiteContractTransaction.js @@ -0,0 +1,12 @@ +import addBurialSiteContractTransaction from '../../database/addBurialSiteContractTransaction.js'; +import getBurialSiteContractTransactions from '../../database/getBurialSiteContractTransactions.js'; +export default async function handler(request, response) { + await addBurialSiteContractTransaction(request.body, request.session.user); + const burialSiteContractTransactions = await getBurialSiteContractTransactions(request.body.burialSiteContractId, { + includeIntegrations: true + }); + response.json({ + success: true, + burialSiteContractTransactions + }); +} diff --git a/handlers/contracts-post/doAddBurialSiteContractTransaction.ts b/handlers/contracts-post/doAddBurialSiteContractTransaction.ts new file mode 100644 index 00000000..69701e8b --- /dev/null +++ b/handlers/contracts-post/doAddBurialSiteContractTransaction.ts @@ -0,0 +1,26 @@ +import type { Request, Response } from 'express' + +import addBurialSiteContractTransaction, { + type AddTransactionForm +} from '../../database/addBurialSiteContractTransaction.js' +import getBurialSiteContractTransactions from '../../database/getBurialSiteContractTransactions.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + await addBurialSiteContractTransaction( + request.body, + request.session.user as User + ) + + const burialSiteContractTransactions = + await getBurialSiteContractTransactions(request.body.burialSiteContractId, { + includeIntegrations: true + }) + + response.json({ + success: true, + burialSiteContractTransactions + }) +} diff --git a/handlers/contracts-post/doAddLotOccupancyComment.d.ts b/handlers/contracts-post/doAddLotOccupancyComment.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doAddLotOccupancyComment.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doAddLotOccupancyComment.js b/handlers/contracts-post/doAddLotOccupancyComment.js deleted file mode 100644 index 555a169d..00000000 --- a/handlers/contracts-post/doAddLotOccupancyComment.js +++ /dev/null @@ -1,10 +0,0 @@ -import addLotOccupancyComment from '../../database/addLotOccupancyComment.js'; -import getLotOccupancyComments from '../../database/getLotOccupancyComments.js'; -export default async function handler(request, response) { - await addLotOccupancyComment(request.body, request.session.user); - const lotOccupancyComments = await getLotOccupancyComments(request.body.burialSiteContractId); - response.json({ - success: true, - lotOccupancyComments - }); -} diff --git a/handlers/contracts-post/doAddLotOccupancyComment.ts b/handlers/contracts-post/doAddLotOccupancyComment.ts deleted file mode 100644 index 5250bc7f..00000000 --- a/handlers/contracts-post/doAddLotOccupancyComment.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { Request, Response } from 'express' - -import addLotOccupancyComment, { - type AddLotOccupancyCommentForm -} from '../../database/addLotOccupancyComment.js' -import getLotOccupancyComments from '../../database/getLotOccupancyComments.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - await addLotOccupancyComment( - request.body as AddLotOccupancyCommentForm, - request.session.user as User - ) - - const lotOccupancyComments = await getLotOccupancyComments( - request.body.burialSiteContractId as string - ) - - response.json({ - success: true, - lotOccupancyComments - }) -} diff --git a/handlers/contracts-post/doAddLotOccupancyFee.d.ts b/handlers/contracts-post/doAddLotOccupancyFee.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doAddLotOccupancyFee.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doAddLotOccupancyFee.js b/handlers/contracts-post/doAddLotOccupancyFee.js deleted file mode 100644 index d9460bfd..00000000 --- a/handlers/contracts-post/doAddLotOccupancyFee.js +++ /dev/null @@ -1,10 +0,0 @@ -import addLotOccupancyFee from '../../database/addLotOccupancyFee.js'; -import getLotOccupancyFees from '../../database/getLotOccupancyFees.js'; -export default async function handler(request, response) { - await addLotOccupancyFee(request.body, request.session.user); - const lotOccupancyFees = await getLotOccupancyFees(request.body.burialSiteContractId); - response.json({ - success: true, - lotOccupancyFees - }); -} diff --git a/handlers/contracts-post/doAddLotOccupancyFee.ts b/handlers/contracts-post/doAddLotOccupancyFee.ts deleted file mode 100644 index 8c7bfecc..00000000 --- a/handlers/contracts-post/doAddLotOccupancyFee.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { Request, Response } from 'express' - -import addLotOccupancyFee, { - type AddLotOccupancyFeeForm -} from '../../database/addLotOccupancyFee.js' -import getLotOccupancyFees from '../../database/getLotOccupancyFees.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - await addLotOccupancyFee( - request.body as AddLotOccupancyFeeForm, - request.session.user as User - ) - - const lotOccupancyFees = await getLotOccupancyFees( - request.body.burialSiteContractId as string - ) - - response.json({ - success: true, - lotOccupancyFees - }) -} diff --git a/handlers/contracts-post/doAddLotOccupancyFeeCategory.d.ts b/handlers/contracts-post/doAddLotOccupancyFeeCategory.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doAddLotOccupancyFeeCategory.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doAddLotOccupancyFeeCategory.js b/handlers/contracts-post/doAddLotOccupancyFeeCategory.js deleted file mode 100644 index f153090f..00000000 --- a/handlers/contracts-post/doAddLotOccupancyFeeCategory.js +++ /dev/null @@ -1,10 +0,0 @@ -import addLotOccupancyFeeCategory from '../../database/addLotOccupancyFeeCategory.js'; -import getLotOccupancyFees from '../../database/getLotOccupancyFees.js'; -export default async function handler(request, response) { - await addLotOccupancyFeeCategory(request.body, request.session.user); - const lotOccupancyFees = await getLotOccupancyFees(request.body.burialSiteContractId); - response.json({ - success: true, - lotOccupancyFees - }); -} diff --git a/handlers/contracts-post/doAddLotOccupancyFeeCategory.ts b/handlers/contracts-post/doAddLotOccupancyFeeCategory.ts deleted file mode 100644 index ebf8a3af..00000000 --- a/handlers/contracts-post/doAddLotOccupancyFeeCategory.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { Request, Response } from 'express' - -import addLotOccupancyFeeCategory, { - type AddLotOccupancyFeeCategoryForm -} from '../../database/addLotOccupancyFeeCategory.js' -import getLotOccupancyFees from '../../database/getLotOccupancyFees.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - await addLotOccupancyFeeCategory( - request.body as AddLotOccupancyFeeCategoryForm, - request.session.user as User - ) - - const lotOccupancyFees = await getLotOccupancyFees( - request.body.burialSiteContractId as string - ) - - response.json({ - success: true, - lotOccupancyFees - }) -} diff --git a/handlers/contracts-post/doAddLotOccupancyOccupant.d.ts b/handlers/contracts-post/doAddLotOccupancyOccupant.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doAddLotOccupancyOccupant.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doAddLotOccupancyOccupant.js b/handlers/contracts-post/doAddLotOccupancyOccupant.js deleted file mode 100644 index 8c65347c..00000000 --- a/handlers/contracts-post/doAddLotOccupancyOccupant.js +++ /dev/null @@ -1,10 +0,0 @@ -import addLotOccupancyOccupant from '../../database/addLotOccupancyOccupant.js'; -import getLotOccupancyOccupants from '../../database/getLotOccupancyOccupants.js'; -export default async function handler(request, response) { - await addLotOccupancyOccupant(request.body, request.session.user); - const lotOccupancyOccupants = await getLotOccupancyOccupants(request.body.burialSiteContractId); - response.json({ - success: true, - lotOccupancyOccupants - }); -} diff --git a/handlers/contracts-post/doAddLotOccupancyOccupant.ts b/handlers/contracts-post/doAddLotOccupancyOccupant.ts deleted file mode 100644 index 2e69a9b2..00000000 --- a/handlers/contracts-post/doAddLotOccupancyOccupant.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { Request, Response } from 'express' - -import addLotOccupancyOccupant, { - type AddLotOccupancyOccupantForm -} from '../../database/addLotOccupancyOccupant.js' -import getLotOccupancyOccupants from '../../database/getLotOccupancyOccupants.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - await addLotOccupancyOccupant( - request.body as AddLotOccupancyOccupantForm, - request.session.user as User - ) - - const lotOccupancyOccupants = await getLotOccupancyOccupants( - request.body.burialSiteContractId - ) - - response.json({ - success: true, - lotOccupancyOccupants - }) -} diff --git a/handlers/contracts-post/doAddLotOccupancyTransaction.d.ts b/handlers/contracts-post/doAddLotOccupancyTransaction.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doAddLotOccupancyTransaction.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doAddLotOccupancyTransaction.js b/handlers/contracts-post/doAddLotOccupancyTransaction.js deleted file mode 100644 index 3cd2dd23..00000000 --- a/handlers/contracts-post/doAddLotOccupancyTransaction.js +++ /dev/null @@ -1,10 +0,0 @@ -import addLotOccupancyTransaction from '../../database/addLotOccupancyTransaction.js'; -import getLotOccupancyTransactions from '../../database/getLotOccupancyTransactions.js'; -export default async function handler(request, response) { - await addLotOccupancyTransaction(request.body, request.session.user); - const lotOccupancyTransactions = await getLotOccupancyTransactions(request.body.burialSiteContractId, { includeIntegrations: true }); - response.json({ - success: true, - lotOccupancyTransactions - }); -} diff --git a/handlers/contracts-post/doAddLotOccupancyTransaction.ts b/handlers/contracts-post/doAddLotOccupancyTransaction.ts deleted file mode 100644 index 07f22669..00000000 --- a/handlers/contracts-post/doAddLotOccupancyTransaction.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { Request, Response } from 'express' - -import addLotOccupancyTransaction, { - type AddLotOccupancyTransactionForm -} from '../../database/addLotOccupancyTransaction.js' -import getLotOccupancyTransactions from '../../database/getLotOccupancyTransactions.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - await addLotOccupancyTransaction( - request.body as AddLotOccupancyTransactionForm, - request.session.user as User - ) - - const lotOccupancyTransactions = await getLotOccupancyTransactions( - request.body.burialSiteContractId, - { includeIntegrations: true } - ) - - response.json({ - success: true, - lotOccupancyTransactions - }) -} diff --git a/handlers/contracts-post/doCopyBurialSiteContract.d.ts b/handlers/contracts-post/doCopyBurialSiteContract.d.ts new file mode 100644 index 00000000..6eb4657f --- /dev/null +++ b/handlers/contracts-post/doCopyBurialSiteContract.d.ts @@ -0,0 +1,4 @@ +import type { Request, Response } from 'express'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doCopyBurialSiteContract.js b/handlers/contracts-post/doCopyBurialSiteContract.js new file mode 100644 index 00000000..28c2577d --- /dev/null +++ b/handlers/contracts-post/doCopyBurialSiteContract.js @@ -0,0 +1,8 @@ +import copyBurialSiteContract from '../../database/copyBurialSiteContract.js'; +export default async function handler(request, response) { + const burialSiteContractId = await copyBurialSiteContract(request.body.burialSiteContractId, request.session.user); + response.json({ + success: true, + burialSiteContractId + }); +} diff --git a/handlers/contracts-post/doCopyBurialSiteContract.ts b/handlers/contracts-post/doCopyBurialSiteContract.ts new file mode 100644 index 00000000..bac1b38b --- /dev/null +++ b/handlers/contracts-post/doCopyBurialSiteContract.ts @@ -0,0 +1,18 @@ +import type { Request, Response } from 'express' + +import copyBurialSiteContract from '../../database/copyBurialSiteContract.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + const burialSiteContractId = await copyBurialSiteContract( + request.body.burialSiteContractId, + request.session.user as User + ) + + response.json({ + success: true, + burialSiteContractId + }) +} diff --git a/handlers/contracts-post/doCopyLotOccupancy.d.ts b/handlers/contracts-post/doCopyLotOccupancy.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doCopyLotOccupancy.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doCopyLotOccupancy.js b/handlers/contracts-post/doCopyLotOccupancy.js deleted file mode 100644 index e23b98e1..00000000 --- a/handlers/contracts-post/doCopyLotOccupancy.js +++ /dev/null @@ -1,8 +0,0 @@ -import copyLotOccupancy from '../../database/copyLotOccupancy.js'; -export default async function handler(request, response) { - const burialSiteContractId = await copyLotOccupancy(request.body.burialSiteContractId, request.session.user); - response.json({ - success: true, - burialSiteContractId - }); -} diff --git a/handlers/contracts-post/doCopyLotOccupancy.ts b/handlers/contracts-post/doCopyLotOccupancy.ts deleted file mode 100644 index ac1b246d..00000000 --- a/handlers/contracts-post/doCopyLotOccupancy.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { Request, Response } from 'express' - -import copyLotOccupancy from '../../database/copyLotOccupancy.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - const burialSiteContractId = await copyLotOccupancy( - request.body.burialSiteContractId as string, - request.session.user as User - ) - - response.json({ - success: true, - burialSiteContractId - }) -} - diff --git a/handlers/contracts-post/doCreateBurialSiteContract.d.ts b/handlers/contracts-post/doCreateBurialSiteContract.d.ts new file mode 100644 index 00000000..88577439 --- /dev/null +++ b/handlers/contracts-post/doCreateBurialSiteContract.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type AddBurialSiteContractForm } from '../../database/addBurialSiteContract.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doCreateBurialSiteContract.js b/handlers/contracts-post/doCreateBurialSiteContract.js new file mode 100644 index 00000000..03576d30 --- /dev/null +++ b/handlers/contracts-post/doCreateBurialSiteContract.js @@ -0,0 +1,8 @@ +import addBurialSiteContract from '../../database/addBurialSiteContract.js'; +export default async function handler(request, response) { + const burialSiteContractId = await addBurialSiteContract(request.body, request.session.user); + response.json({ + success: true, + burialSiteContractId + }); +} diff --git a/handlers/contracts-post/doCreateBurialSiteContract.ts b/handlers/contracts-post/doCreateBurialSiteContract.ts new file mode 100644 index 00000000..c58c6b7b --- /dev/null +++ b/handlers/contracts-post/doCreateBurialSiteContract.ts @@ -0,0 +1,21 @@ +import type { Request, Response } from 'express' + +import addBurialSiteContract, { + type AddBurialSiteContractForm +} from '../../database/addBurialSiteContract.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + const burialSiteContractId = await addBurialSiteContract( + request.body, + request.session.user as User + ) + + response.json({ + success: true, + burialSiteContractId + }) +} + diff --git a/handlers/contracts-post/doCreateLotOccupancy.d.ts b/handlers/contracts-post/doCreateLotOccupancy.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doCreateLotOccupancy.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doCreateLotOccupancy.js b/handlers/contracts-post/doCreateLotOccupancy.js deleted file mode 100644 index b5317be3..00000000 --- a/handlers/contracts-post/doCreateLotOccupancy.js +++ /dev/null @@ -1,8 +0,0 @@ -import addLotOccupancy from '../../database/addLotOccupancy.js'; -export default async function handler(request, response) { - const burialSiteContractId = await addLotOccupancy(request.body, request.session.user); - response.json({ - success: true, - burialSiteContractId - }); -} diff --git a/handlers/contracts-post/doCreateLotOccupancy.ts b/handlers/contracts-post/doCreateLotOccupancy.ts deleted file mode 100644 index bd67e998..00000000 --- a/handlers/contracts-post/doCreateLotOccupancy.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { Request, Response } from 'express' - -import addLotOccupancy, { - type AddLotOccupancyForm -} from '../../database/addLotOccupancy.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - const burialSiteContractId = await addLotOccupancy( - request.body as AddLotOccupancyForm, - request.session.user as User - ) - - response.json({ - success: true, - burialSiteContractId - }) -} - diff --git a/handlers/contracts-post/doDeleteBurialSiteContract.d.ts b/handlers/contracts-post/doDeleteBurialSiteContract.d.ts new file mode 100644 index 00000000..6eb4657f --- /dev/null +++ b/handlers/contracts-post/doDeleteBurialSiteContract.d.ts @@ -0,0 +1,4 @@ +import type { Request, Response } from 'express'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doDeleteLotOccupancy.js b/handlers/contracts-post/doDeleteBurialSiteContract.js similarity index 58% rename from handlers/contracts-post/doDeleteLotOccupancy.js rename to handlers/contracts-post/doDeleteBurialSiteContract.js index 043eb177..eb58759e 100644 --- a/handlers/contracts-post/doDeleteLotOccupancy.js +++ b/handlers/contracts-post/doDeleteBurialSiteContract.js @@ -1,6 +1,6 @@ import { deleteRecord } from '../../database/deleteRecord.js'; export default async function handler(request, response) { - const success = await deleteRecord('LotOccupancies', request.body.burialSiteContractId, request.session.user); + const success = await deleteRecord('BurialSiteContracts', request.body.burialSiteContractId, request.session.user); response.json({ success }); diff --git a/handlers/contracts-post/doDeleteLotOccupancy.ts b/handlers/contracts-post/doDeleteBurialSiteContract.ts similarity index 68% rename from handlers/contracts-post/doDeleteLotOccupancy.ts rename to handlers/contracts-post/doDeleteBurialSiteContract.ts index f9cc559b..a8d2f01a 100644 --- a/handlers/contracts-post/doDeleteLotOccupancy.ts +++ b/handlers/contracts-post/doDeleteBurialSiteContract.ts @@ -3,12 +3,12 @@ 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( - 'LotOccupancies', - request.body.burialSiteContractId as string, + 'BurialSiteContracts', + request.body.burialSiteContractId, request.session.user as User ) @@ -16,4 +16,3 @@ export default async function handler( success }) } - diff --git a/handlers/contracts-post/doDeleteBurialSiteContractComment.d.ts b/handlers/contracts-post/doDeleteBurialSiteContractComment.d.ts new file mode 100644 index 00000000..01645bd9 --- /dev/null +++ b/handlers/contracts-post/doDeleteBurialSiteContractComment.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/doDeleteBurialSiteContractComment.js b/handlers/contracts-post/doDeleteBurialSiteContractComment.js new file mode 100644 index 00000000..b4c9213d --- /dev/null +++ b/handlers/contracts-post/doDeleteBurialSiteContractComment.js @@ -0,0 +1,10 @@ +import { deleteRecord } from '../../database/deleteRecord.js'; +import getBurialSiteContractComments from '../../database/getBurialSiteContractComments.js'; +export default async function handler(request, response) { + const success = await deleteRecord('BurialSiteContractComments', request.body.burialSiteContractCommentId, request.session.user); + const burialSiteContractComments = await getBurialSiteContractComments(request.body.burialSiteContractId); + response.json({ + success, + burialSiteContractComments + }); +} diff --git a/handlers/contracts-post/doDeleteBurialSiteContractComment.ts b/handlers/contracts-post/doDeleteBurialSiteContractComment.ts new file mode 100644 index 00000000..d2e17bd9 --- /dev/null +++ b/handlers/contracts-post/doDeleteBurialSiteContractComment.ts @@ -0,0 +1,28 @@ +import type { Request, Response } from 'express' + +import { deleteRecord } from '../../database/deleteRecord.js' +import getBurialSiteContractComments from '../../database/getBurialSiteContractComments.js' + +export default async function handler( + request: Request< + unknown, + unknown, + { burialSiteContractCommentId: string; burialSiteContractId: string } + >, + response: Response +): Promise { + const success = await deleteRecord( + 'BurialSiteContractComments', + request.body.burialSiteContractCommentId, + request.session.user as User + ) + + const burialSiteContractComments = await getBurialSiteContractComments( + request.body.burialSiteContractId + ) + + response.json({ + success, + burialSiteContractComments + }) +} diff --git a/handlers/contracts-post/doDeleteBurialSiteContractFee.d.ts b/handlers/contracts-post/doDeleteBurialSiteContractFee.d.ts new file mode 100644 index 00000000..6b887bcf --- /dev/null +++ b/handlers/contracts-post/doDeleteBurialSiteContractFee.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/doDeleteBurialSiteContractFee.js b/handlers/contracts-post/doDeleteBurialSiteContractFee.js new file mode 100644 index 00000000..2a2a7ed1 --- /dev/null +++ b/handlers/contracts-post/doDeleteBurialSiteContractFee.js @@ -0,0 +1,10 @@ +import deleteBurialSiteContractFee from '../../database/deleteBurialSiteContractFee.js'; +import getBurialSiteContractFees from '../../database/getBurialSiteContractFees.js'; +export default async function handler(request, response) { + const success = await deleteBurialSiteContractFee(request.body.burialSiteContractId, request.body.feeId, request.session.user); + const burialSiteContractFees = await getBurialSiteContractFees(request.body.burialSiteContractId); + response.json({ + success, + burialSiteContractFees + }); +} diff --git a/handlers/contracts-post/doDeleteBurialSiteContractFee.ts b/handlers/contracts-post/doDeleteBurialSiteContractFee.ts new file mode 100644 index 00000000..d2a610c9 --- /dev/null +++ b/handlers/contracts-post/doDeleteBurialSiteContractFee.ts @@ -0,0 +1,28 @@ +import type { Request, Response } from 'express' + +import deleteBurialSiteContractFee from '../../database/deleteBurialSiteContractFee.js' +import getBurialSiteContractFees from '../../database/getBurialSiteContractFees.js' + +export default async function handler( + request: Request< + unknown, + unknown, + { burialSiteContractId: string; feeId: string } + >, + response: Response +): Promise { + const success = await deleteBurialSiteContractFee( + request.body.burialSiteContractId, + request.body.feeId, + request.session.user as User + ) + + const burialSiteContractFees = await getBurialSiteContractFees( + request.body.burialSiteContractId + ) + + response.json({ + success, + burialSiteContractFees + }) +} diff --git a/handlers/contracts-post/doDeleteBurialSiteContractTransaction.d.ts b/handlers/contracts-post/doDeleteBurialSiteContractTransaction.d.ts new file mode 100644 index 00000000..94d2c842 --- /dev/null +++ b/handlers/contracts-post/doDeleteBurialSiteContractTransaction.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/doDeleteBurialSiteContractTransaction.js b/handlers/contracts-post/doDeleteBurialSiteContractTransaction.js new file mode 100644 index 00000000..6f258038 --- /dev/null +++ b/handlers/contracts-post/doDeleteBurialSiteContractTransaction.js @@ -0,0 +1,12 @@ +import deleteBurialSiteContractTransaction from '../../database/deleteBurialSiteContractTransaction.js'; +import getBurialSiteContractTransactions from '../../database/getBurialSiteContractTransactions.js'; +export default async function handler(request, response) { + const success = await deleteBurialSiteContractTransaction(request.body.burialSiteContractId, request.body.transactionIndex, request.session.user); + const burialSiteContractTransactions = await getBurialSiteContractTransactions(request.body.burialSiteContractId, { + includeIntegrations: true + }); + response.json({ + success, + burialSiteContractTransactions + }); +} diff --git a/handlers/contracts-post/doDeleteBurialSiteContractTransaction.ts b/handlers/contracts-post/doDeleteBurialSiteContractTransaction.ts new file mode 100644 index 00000000..65deb1c3 --- /dev/null +++ b/handlers/contracts-post/doDeleteBurialSiteContractTransaction.ts @@ -0,0 +1,29 @@ +import type { Request, Response } from 'express' + +import deleteBurialSiteContractTransaction from '../../database/deleteBurialSiteContractTransaction.js' +import getBurialSiteContractTransactions from '../../database/getBurialSiteContractTransactions.js' + +export default async function handler( + request: Request< + unknown, + unknown, + { burialSiteContractId: string; transactionIndex: number } + >, + response: Response +): Promise { + const success = await deleteBurialSiteContractTransaction( + request.body.burialSiteContractId, + request.body.transactionIndex, + request.session.user as User + ) + + const burialSiteContractTransactions = + await getBurialSiteContractTransactions(request.body.burialSiteContractId, { + includeIntegrations: true + }) + + response.json({ + success, + burialSiteContractTransactions + }) +} diff --git a/handlers/contracts-post/doDeleteLotOccupancy.d.ts b/handlers/contracts-post/doDeleteLotOccupancy.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doDeleteLotOccupancy.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doDeleteLotOccupancyComment.d.ts b/handlers/contracts-post/doDeleteLotOccupancyComment.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doDeleteLotOccupancyComment.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doDeleteLotOccupancyComment.js b/handlers/contracts-post/doDeleteLotOccupancyComment.js deleted file mode 100644 index fca2b3aa..00000000 --- a/handlers/contracts-post/doDeleteLotOccupancyComment.js +++ /dev/null @@ -1,10 +0,0 @@ -import { deleteRecord } from '../../database/deleteRecord.js'; -import getLotOccupancyComments from '../../database/getLotOccupancyComments.js'; -export default async function handler(request, response) { - const success = await deleteRecord('LotOccupancyComments', request.body.burialSiteContractCommentId, request.session.user); - const lotOccupancyComments = await getLotOccupancyComments(request.body.burialSiteContractId); - response.json({ - success, - lotOccupancyComments - }); -} diff --git a/handlers/contracts-post/doDeleteLotOccupancyComment.ts b/handlers/contracts-post/doDeleteLotOccupancyComment.ts deleted file mode 100644 index eae11d96..00000000 --- a/handlers/contracts-post/doDeleteLotOccupancyComment.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { Request, Response } from 'express' - -import { deleteRecord } from '../../database/deleteRecord.js' -import getLotOccupancyComments from '../../database/getLotOccupancyComments.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - const success = await deleteRecord( - 'LotOccupancyComments', - request.body.burialSiteContractCommentId as string, - request.session.user as User - ) - - const lotOccupancyComments = await getLotOccupancyComments( - request.body.burialSiteContractId as string - ) - - response.json({ - success, - lotOccupancyComments - }) -} diff --git a/handlers/contracts-post/doDeleteLotOccupancyFee.d.ts b/handlers/contracts-post/doDeleteLotOccupancyFee.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doDeleteLotOccupancyFee.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doDeleteLotOccupancyFee.js b/handlers/contracts-post/doDeleteLotOccupancyFee.js deleted file mode 100644 index e2668451..00000000 --- a/handlers/contracts-post/doDeleteLotOccupancyFee.js +++ /dev/null @@ -1,10 +0,0 @@ -import deleteLotOccupancyFee from '../../database/deleteLotOccupancyFee.js'; -import getLotOccupancyFees from '../../database/getLotOccupancyFees.js'; -export default async function handler(request, response) { - const success = await deleteLotOccupancyFee(request.body.burialSiteContractId, request.body.feeId, request.session.user); - const lotOccupancyFees = await getLotOccupancyFees(request.body.burialSiteContractId); - response.json({ - success, - lotOccupancyFees - }); -} diff --git a/handlers/contracts-post/doDeleteLotOccupancyFee.ts b/handlers/contracts-post/doDeleteLotOccupancyFee.ts deleted file mode 100644 index fac2b07b..00000000 --- a/handlers/contracts-post/doDeleteLotOccupancyFee.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { Request, Response } from 'express' - -import deleteLotOccupancyFee from '../../database/deleteLotOccupancyFee.js' -import getLotOccupancyFees from '../../database/getLotOccupancyFees.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - const success = await deleteLotOccupancyFee( - request.body.burialSiteContractId, - request.body.feeId, - request.session.user as User - ) - - const lotOccupancyFees = await getLotOccupancyFees( - request.body.burialSiteContractId - ) - - response.json({ - success, - lotOccupancyFees - }) -} diff --git a/handlers/contracts-post/doDeleteLotOccupancyOccupant.d.ts b/handlers/contracts-post/doDeleteLotOccupancyOccupant.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doDeleteLotOccupancyOccupant.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doDeleteLotOccupancyOccupant.js b/handlers/contracts-post/doDeleteLotOccupancyOccupant.js deleted file mode 100644 index 9e0cecd4..00000000 --- a/handlers/contracts-post/doDeleteLotOccupancyOccupant.js +++ /dev/null @@ -1,10 +0,0 @@ -import deleteLotOccupancyOccupant from '../../database/deleteLotOccupancyOccupant.js'; -import getLotOccupancyOccupants from '../../database/getLotOccupancyOccupants.js'; -export default async function handler(request, response) { - const success = await deleteLotOccupancyOccupant(request.body.burialSiteContractId, request.body.lotOccupantIndex, request.session.user); - const lotOccupancyOccupants = await getLotOccupancyOccupants(request.body.burialSiteContractId); - response.json({ - success, - lotOccupancyOccupants - }); -} diff --git a/handlers/contracts-post/doDeleteLotOccupancyOccupant.ts b/handlers/contracts-post/doDeleteLotOccupancyOccupant.ts deleted file mode 100644 index 67321c7b..00000000 --- a/handlers/contracts-post/doDeleteLotOccupancyOccupant.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { Request, Response } from 'express' - -import deleteLotOccupancyOccupant from '../../database/deleteLotOccupancyOccupant.js' -import getLotOccupancyOccupants from '../../database/getLotOccupancyOccupants.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - const success = await deleteLotOccupancyOccupant( - request.body.burialSiteContractId, - request.body.lotOccupantIndex, - request.session.user as User - ) - - const lotOccupancyOccupants = await getLotOccupancyOccupants( - request.body.burialSiteContractId - ) - - response.json({ - success, - lotOccupancyOccupants - }) -} diff --git a/handlers/contracts-post/doDeleteLotOccupancyTransaction.d.ts b/handlers/contracts-post/doDeleteLotOccupancyTransaction.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doDeleteLotOccupancyTransaction.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doDeleteLotOccupancyTransaction.js b/handlers/contracts-post/doDeleteLotOccupancyTransaction.js deleted file mode 100644 index 7f8d2165..00000000 --- a/handlers/contracts-post/doDeleteLotOccupancyTransaction.js +++ /dev/null @@ -1,10 +0,0 @@ -import deleteLotOccupancyTransaction from '../../database/deleteLotOccupancyTransaction.js'; -import getLotOccupancyTransactions from '../../database/getLotOccupancyTransactions.js'; -export default async function handler(request, response) { - const success = await deleteLotOccupancyTransaction(request.body.burialSiteContractId, request.body.transactionIndex, request.session.user); - const lotOccupancyTransactions = await getLotOccupancyTransactions(request.body.burialSiteContractId, { includeIntegrations: true }); - response.json({ - success, - lotOccupancyTransactions - }); -} diff --git a/handlers/contracts-post/doDeleteLotOccupancyTransaction.ts b/handlers/contracts-post/doDeleteLotOccupancyTransaction.ts deleted file mode 100644 index 80870961..00000000 --- a/handlers/contracts-post/doDeleteLotOccupancyTransaction.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { Request, Response } from 'express' - -import deleteLotOccupancyTransaction from '../../database/deleteLotOccupancyTransaction.js' -import getLotOccupancyTransactions from '../../database/getLotOccupancyTransactions.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - const success = await deleteLotOccupancyTransaction( - request.body.burialSiteContractId, - request.body.transactionIndex, - request.session.user as User - ) - - const lotOccupancyTransactions = await getLotOccupancyTransactions( - request.body.burialSiteContractId, - { includeIntegrations: true } - ) - - response.json({ - success, - lotOccupancyTransactions - }) -} diff --git a/handlers/contracts-post/doGetContractTypeFields.d.ts b/handlers/contracts-post/doGetContractTypeFields.d.ts new file mode 100644 index 00000000..dc1620a5 --- /dev/null +++ b/handlers/contracts-post/doGetContractTypeFields.d.ts @@ -0,0 +1,4 @@ +import type { Request, Response } from 'express'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doGetOccupancyTypeFields.js b/handlers/contracts-post/doGetContractTypeFields.js similarity index 57% rename from handlers/contracts-post/doGetOccupancyTypeFields.js rename to handlers/contracts-post/doGetContractTypeFields.js index 987f42eb..115efc95 100644 --- a/handlers/contracts-post/doGetOccupancyTypeFields.js +++ b/handlers/contracts-post/doGetContractTypeFields.js @@ -1,10 +1,10 @@ -import { getContractTypeById, getAllContractTypeFields } from '../../helpers/functions.cache.js'; +import { getAllContractTypeFields, getContractTypeById } from '../../helpers/functions.cache.js'; export default async function handler(request, response) { const allContractTypeFields = await getAllContractTypeFields(); const result = (await getContractTypeById(Number.parseInt(request.body.contractTypeId, 10))); - const ContractTypeFields = [...allContractTypeFields]; - ContractTypeFields.push(...(result.ContractTypeFields ?? [])); + const contractTypeFields = [...allContractTypeFields]; + contractTypeFields.push(...(result.contractTypeFields ?? [])); response.json({ - ContractTypeFields + contractTypeFields }); } diff --git a/handlers/contracts-post/doGetOccupancyTypeFields.ts b/handlers/contracts-post/doGetContractTypeFields.ts similarity index 52% rename from handlers/contracts-post/doGetOccupancyTypeFields.ts rename to handlers/contracts-post/doGetContractTypeFields.ts index 928477fb..2391f91c 100644 --- a/handlers/contracts-post/doGetOccupancyTypeFields.ts +++ b/handlers/contracts-post/doGetContractTypeFields.ts @@ -1,26 +1,26 @@ import type { Request, Response } from 'express' import { - getContractTypeById, - getAllContractTypeFields + getAllContractTypeFields, + getContractTypeById } from '../../helpers/functions.cache.js' +import type { ContractType } from '../../types/recordTypes.js' export default async function handler( - request: Request, + request: Request, response: Response ): Promise { const allContractTypeFields = await getAllContractTypeFields() const result = (await getContractTypeById( Number.parseInt(request.body.contractTypeId, 10) - ))! + )) as ContractType - const ContractTypeFields = [...allContractTypeFields] + const contractTypeFields = [...allContractTypeFields] - ContractTypeFields.push(...(result.ContractTypeFields ?? [])) + contractTypeFields.push(...(result.contractTypeFields ?? [])) response.json({ - ContractTypeFields + contractTypeFields }) } - diff --git a/handlers/contracts-post/doGetFees.d.ts b/handlers/contracts-post/doGetFees.d.ts index 19d32e4d..6eb4657f 100644 --- a/handlers/contracts-post/doGetFees.d.ts +++ b/handlers/contracts-post/doGetFees.d.ts @@ -1,2 +1,4 @@ import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doGetFees.js b/handlers/contracts-post/doGetFees.js index ddf2ca72..e7e77659 100644 --- a/handlers/contracts-post/doGetFees.js +++ b/handlers/contracts-post/doGetFees.js @@ -1,11 +1,11 @@ +import getBurialSiteContract from '../../database/getBurialSiteContract.js'; import getFeeCategories from '../../database/getFeeCategories.js'; -import getLotOccupancy from '../../database/getLotOccupancy.js'; export default async function handler(request, response) { const burialSiteContractId = request.body.burialSiteContractId; - const lotOccupancy = (await getLotOccupancy(burialSiteContractId)); + const burialSiteContract = (await getBurialSiteContract(burialSiteContractId)); const feeCategories = await getFeeCategories({ - contractTypeId: lotOccupancy.contractTypeId, - burialSiteTypeId: lotOccupancy.burialSiteTypeId + contractTypeId: burialSiteContract.contractTypeId, + burialSiteTypeId: burialSiteContract.burialSiteTypeId }, { includeFees: true }); diff --git a/handlers/contracts-post/doGetFees.ts b/handlers/contracts-post/doGetFees.ts index 0260b31d..27d4c82f 100644 --- a/handlers/contracts-post/doGetFees.ts +++ b/handlers/contracts-post/doGetFees.ts @@ -1,20 +1,23 @@ import type { Request, Response } from 'express' +import getBurialSiteContract from '../../database/getBurialSiteContract.js' import getFeeCategories from '../../database/getFeeCategories.js' -import getLotOccupancy from '../../database/getLotOccupancy.js' +import type { BurialSiteContract } from '../../types/recordTypes.js' export default async function handler( - request: Request, + request: Request, response: Response ): Promise { const burialSiteContractId = request.body.burialSiteContractId - const lotOccupancy = (await getLotOccupancy(burialSiteContractId))! + const burialSiteContract = (await getBurialSiteContract( + burialSiteContractId + )) as BurialSiteContract const feeCategories = await getFeeCategories( { - contractTypeId: lotOccupancy.contractTypeId, - burialSiteTypeId: lotOccupancy.burialSiteTypeId + contractTypeId: burialSiteContract.contractTypeId, + burialSiteTypeId: burialSiteContract.burialSiteTypeId }, { includeFees: true diff --git a/handlers/contracts-post/doGetOccupancyTypeFields.d.ts b/handlers/contracts-post/doGetOccupancyTypeFields.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doGetOccupancyTypeFields.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/admin-post/doUpdateOccupancyTypeField.d.ts b/handlers/contracts-post/doSearchBurialSiteContracts.d.ts similarity index 100% rename from handlers/admin-post/doUpdateOccupancyTypeField.d.ts rename to handlers/contracts-post/doSearchBurialSiteContracts.d.ts diff --git a/handlers/contracts-post/doSearchLotOccupancies.js b/handlers/contracts-post/doSearchBurialSiteContracts.js similarity index 85% rename from handlers/contracts-post/doSearchLotOccupancies.js rename to handlers/contracts-post/doSearchBurialSiteContracts.js index 97c2cad3..6e9e6bb3 100644 --- a/handlers/contracts-post/doSearchLotOccupancies.js +++ b/handlers/contracts-post/doSearchBurialSiteContracts.js @@ -1,4 +1,4 @@ -import getBurialSiteContracts from '../../database/getLotOccupancies.js'; +import getBurialSiteContracts from '../../database/getBurialSiteContracts.js'; export default async function handler(request, response) { const result = await getBurialSiteContracts(request.body, { limit: request.body.limit, diff --git a/handlers/contracts-post/doSearchLotOccupancies.ts b/handlers/contracts-post/doSearchBurialSiteContracts.ts similarity index 86% rename from handlers/contracts-post/doSearchLotOccupancies.ts rename to handlers/contracts-post/doSearchBurialSiteContracts.ts index fcc9d503..c36b94f9 100644 --- a/handlers/contracts-post/doSearchLotOccupancies.ts +++ b/handlers/contracts-post/doSearchBurialSiteContracts.ts @@ -1,6 +1,6 @@ import type { Request, Response } from 'express' -import getBurialSiteContracts from '../../database/getLotOccupancies.js' +import getBurialSiteContracts from '../../database/getBurialSiteContracts.js' export default async function handler( request: Request, diff --git a/handlers/contracts-post/doSearchLotOccupancies.d.ts b/handlers/contracts-post/doSearchLotOccupancies.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doSearchLotOccupancies.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doSearchPastOccupants.d.ts b/handlers/contracts-post/doSearchPastOccupants.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doSearchPastOccupants.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doSearchPastOccupants.js b/handlers/contracts-post/doSearchPastOccupants.js deleted file mode 100644 index 518985f6..00000000 --- a/handlers/contracts-post/doSearchPastOccupants.js +++ /dev/null @@ -1,9 +0,0 @@ -import getPastLotOccupancyOccupants from '../../database/getPastLotOccupancyOccupants.js'; -export default async function handler(request, response) { - const occupants = await getPastLotOccupancyOccupants(request.body, { - limit: Number.parseInt(request.body.limit, 10) - }); - response.json({ - occupants - }); -} diff --git a/handlers/contracts-post/doSearchPastOccupants.ts b/handlers/contracts-post/doSearchPastOccupants.ts deleted file mode 100644 index 2dedd03d..00000000 --- a/handlers/contracts-post/doSearchPastOccupants.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { Request, Response } from 'express' - -import getPastLotOccupancyOccupants, { - type GetPastLotOccupancyOccupantsFilters -} from '../../database/getPastLotOccupancyOccupants.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - const occupants = await getPastLotOccupancyOccupants( - request.body as GetPastLotOccupancyOccupantsFilters, - { - limit: Number.parseInt(request.body.limit as string, 10) - } - ) - - response.json({ - occupants - }) -} diff --git a/handlers/burialSites-post/doAddLotComment.d.ts b/handlers/contracts-post/doUpdateBurialSiteContract.d.ts similarity index 100% rename from handlers/burialSites-post/doAddLotComment.d.ts rename to handlers/contracts-post/doUpdateBurialSiteContract.d.ts diff --git a/handlers/contracts-post/doUpdateLotOccupancy.js b/handlers/contracts-post/doUpdateBurialSiteContract.js similarity index 100% rename from handlers/contracts-post/doUpdateLotOccupancy.js rename to handlers/contracts-post/doUpdateBurialSiteContract.js diff --git a/handlers/contracts-post/doUpdateLotOccupancy.ts b/handlers/contracts-post/doUpdateBurialSiteContract.ts similarity index 100% rename from handlers/contracts-post/doUpdateLotOccupancy.ts rename to handlers/contracts-post/doUpdateBurialSiteContract.ts diff --git a/handlers/burialSites-post/doCreateLot.d.ts b/handlers/contracts-post/doUpdateBurialSiteContractComment.d.ts similarity index 100% rename from handlers/burialSites-post/doCreateLot.d.ts rename to handlers/contracts-post/doUpdateBurialSiteContractComment.d.ts diff --git a/handlers/contracts-post/doUpdateLotOccupancyComment.js b/handlers/contracts-post/doUpdateBurialSiteContractComment.js similarity index 53% rename from handlers/contracts-post/doUpdateLotOccupancyComment.js rename to handlers/contracts-post/doUpdateBurialSiteContractComment.js index 500b6404..675beec6 100644 --- a/handlers/contracts-post/doUpdateLotOccupancyComment.js +++ b/handlers/contracts-post/doUpdateBurialSiteContractComment.js @@ -1,10 +1,10 @@ -import getLotOccupancyComments from '../../database/getLotOccupancyComments.js'; +import getBurialSiteContractComments from '../../database/getBurialSiteContractComments.js'; import updateLotOccupancyComment from '../../database/updateLotOccupancyComment.js'; export default async function handler(request, response) { const success = await updateLotOccupancyComment(request.body, request.session.user); - const lotOccupancyComments = await getLotOccupancyComments(request.body.burialSiteContractId); + const burialSiteContractComments = await getBurialSiteContractComments(request.body.burialSiteContractId); response.json({ success, - lotOccupancyComments + burialSiteContractComments }); } diff --git a/handlers/contracts-post/doUpdateLotOccupancyComment.ts b/handlers/contracts-post/doUpdateBurialSiteContractComment.ts similarity index 72% rename from handlers/contracts-post/doUpdateLotOccupancyComment.ts rename to handlers/contracts-post/doUpdateBurialSiteContractComment.ts index 93661ae5..b7db956e 100644 --- a/handlers/contracts-post/doUpdateLotOccupancyComment.ts +++ b/handlers/contracts-post/doUpdateBurialSiteContractComment.ts @@ -1,6 +1,6 @@ import type { Request, Response } from 'express' -import getLotOccupancyComments from '../../database/getLotOccupancyComments.js' +import getBurialSiteContractComments from '../../database/getBurialSiteContractComments.js' import updateLotOccupancyComment, { type UpdateLotOccupancyCommentForm } from '../../database/updateLotOccupancyComment.js' @@ -14,12 +14,12 @@ export default async function handler( request.session.user as User ) - const lotOccupancyComments = await getLotOccupancyComments( + const burialSiteContractComments = await getBurialSiteContractComments( request.body.burialSiteContractId as string ) response.json({ success, - lotOccupancyComments + burialSiteContractComments }) } diff --git a/handlers/burialSites-post/doDeleteLot.d.ts b/handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.d.ts similarity index 100% rename from handlers/burialSites-post/doDeleteLot.d.ts rename to handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.d.ts diff --git a/handlers/contracts-post/doUpdateLotOccupancyFeeQuantity.js b/handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.js similarity index 57% rename from handlers/contracts-post/doUpdateLotOccupancyFeeQuantity.js rename to handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.js index f3f34832..af1c2dd5 100644 --- a/handlers/contracts-post/doUpdateLotOccupancyFeeQuantity.js +++ b/handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.js @@ -1,10 +1,10 @@ -import getLotOccupancyFees from '../../database/getLotOccupancyFees.js'; +import getBurialSiteContractFees from '../../database/getBurialSiteContractFees.js'; import updateLotOccupancyFeeQuantity from '../../database/updateLotOccupancyFeeQuantity.js'; export default async function handler(request, response) { const success = await updateLotOccupancyFeeQuantity(request.body, request.session.user); - const lotOccupancyFees = await getLotOccupancyFees(request.body.burialSiteContractId); + const burialSiteContractFees = await getBurialSiteContractFees(request.body.burialSiteContractId); response.json({ success, - lotOccupancyFees + burialSiteContractFees }); } diff --git a/handlers/contracts-post/doUpdateLotOccupancyFeeQuantity.ts b/handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.ts similarity index 74% rename from handlers/contracts-post/doUpdateLotOccupancyFeeQuantity.ts rename to handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.ts index 63295481..33bb575a 100644 --- a/handlers/contracts-post/doUpdateLotOccupancyFeeQuantity.ts +++ b/handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.ts @@ -1,6 +1,6 @@ import type { Request, Response } from 'express' -import getLotOccupancyFees from '../../database/getLotOccupancyFees.js' +import getBurialSiteContractFees from '../../database/getBurialSiteContractFees.js' import updateLotOccupancyFeeQuantity, { type UpdateLotOccupancyFeeQuantityForm } from '../../database/updateLotOccupancyFeeQuantity.js' @@ -14,12 +14,12 @@ export default async function handler( request.session.user as User ) - const lotOccupancyFees = await getLotOccupancyFees( + const burialSiteContractFees = await getBurialSiteContractFees( request.body.burialSiteContractId as string ) response.json({ success, - lotOccupancyFees + burialSiteContractFees }) } diff --git a/handlers/burialSites-post/doDeleteLotComment.d.ts b/handlers/contracts-post/doUpdateBurialSiteContractTransaction.d.ts similarity index 100% rename from handlers/burialSites-post/doDeleteLotComment.d.ts rename to handlers/contracts-post/doUpdateBurialSiteContractTransaction.d.ts diff --git a/handlers/contracts-post/doUpdateBurialSiteContractTransaction.js b/handlers/contracts-post/doUpdateBurialSiteContractTransaction.js new file mode 100644 index 00000000..bba8f8fa --- /dev/null +++ b/handlers/contracts-post/doUpdateBurialSiteContractTransaction.js @@ -0,0 +1,10 @@ +import getBurialSiteContractTransactions from '../../database/getBurialSiteContractTransactions.js'; +import updateLotOccupancyTransaction from '../../database/updateLotOccupancyTransaction.js'; +export default async function handler(request, response) { + await updateLotOccupancyTransaction(request.body, request.session.user); + const burialSiteContractTransactions = await getBurialSiteContractTransactions(request.body.burialSiteContractId, { includeIntegrations: true }); + response.json({ + success: true, + burialSiteContractTransactions + }); +} diff --git a/handlers/contracts-post/doUpdateLotOccupancyTransaction.ts b/handlers/contracts-post/doUpdateBurialSiteContractTransaction.ts similarity index 71% rename from handlers/contracts-post/doUpdateLotOccupancyTransaction.ts rename to handlers/contracts-post/doUpdateBurialSiteContractTransaction.ts index b99ab78a..49686e5e 100644 --- a/handlers/contracts-post/doUpdateLotOccupancyTransaction.ts +++ b/handlers/contracts-post/doUpdateBurialSiteContractTransaction.ts @@ -1,6 +1,6 @@ import type { Request, Response } from 'express' -import getLotOccupancyTransactions from '../../database/getLotOccupancyTransactions.js' +import getBurialSiteContractTransactions from '../../database/getBurialSiteContractTransactions.js' import updateLotOccupancyTransaction, { type UpdateLotOccupancyTransactionForm } from '../../database/updateLotOccupancyTransaction.js' @@ -14,13 +14,13 @@ export default async function handler( request.session.user as User ) - const lotOccupancyTransactions = await getLotOccupancyTransactions( + const burialSiteContractTransactions = await getBurialSiteContractTransactions( request.body.burialSiteContractId as string, { includeIntegrations: true } ) response.json({ success: true, - lotOccupancyTransactions + burialSiteContractTransactions }) } diff --git a/handlers/contracts-post/doUpdateLotOccupancy.d.ts b/handlers/contracts-post/doUpdateLotOccupancy.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doUpdateLotOccupancy.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doUpdateLotOccupancyComment.d.ts b/handlers/contracts-post/doUpdateLotOccupancyComment.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doUpdateLotOccupancyComment.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doUpdateLotOccupancyFeeQuantity.d.ts b/handlers/contracts-post/doUpdateLotOccupancyFeeQuantity.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doUpdateLotOccupancyFeeQuantity.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doUpdateLotOccupancyOccupant.d.ts b/handlers/contracts-post/doUpdateLotOccupancyOccupant.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doUpdateLotOccupancyOccupant.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doUpdateLotOccupancyOccupant.js b/handlers/contracts-post/doUpdateLotOccupancyOccupant.js deleted file mode 100644 index 9e4f0e52..00000000 --- a/handlers/contracts-post/doUpdateLotOccupancyOccupant.js +++ /dev/null @@ -1,10 +0,0 @@ -import getLotOccupancyOccupants from '../../database/getLotOccupancyOccupants.js'; -import updateLotOccupancyOccupant from '../../database/updateLotOccupancyOccupant.js'; -export default async function handler(request, response) { - const success = await updateLotOccupancyOccupant(request.body, request.session.user); - const lotOccupancyOccupants = await getLotOccupancyOccupants(request.body.burialSiteContractId); - response.json({ - success, - lotOccupancyOccupants - }); -} diff --git a/handlers/contracts-post/doUpdateLotOccupancyOccupant.ts b/handlers/contracts-post/doUpdateLotOccupancyOccupant.ts deleted file mode 100644 index 864d7b00..00000000 --- a/handlers/contracts-post/doUpdateLotOccupancyOccupant.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { Request, Response } from 'express' - -import getLotOccupancyOccupants from '../../database/getLotOccupancyOccupants.js' -import updateLotOccupancyOccupant, { - type UpdateLotOccupancyOccupantForm -} from '../../database/updateLotOccupancyOccupant.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - const success = await updateLotOccupancyOccupant( - request.body as UpdateLotOccupancyOccupantForm, - request.session.user as User - ) - - const lotOccupancyOccupants = await getLotOccupancyOccupants( - request.body.burialSiteContractId as string - ) - - response.json({ - success, - lotOccupancyOccupants - }) -} diff --git a/handlers/contracts-post/doUpdateLotOccupancyTransaction.d.ts b/handlers/contracts-post/doUpdateLotOccupancyTransaction.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/contracts-post/doUpdateLotOccupancyTransaction.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doUpdateLotOccupancyTransaction.js b/handlers/contracts-post/doUpdateLotOccupancyTransaction.js deleted file mode 100644 index 2e52ee38..00000000 --- a/handlers/contracts-post/doUpdateLotOccupancyTransaction.js +++ /dev/null @@ -1,10 +0,0 @@ -import getLotOccupancyTransactions from '../../database/getLotOccupancyTransactions.js'; -import updateLotOccupancyTransaction from '../../database/updateLotOccupancyTransaction.js'; -export default async function handler(request, response) { - await updateLotOccupancyTransaction(request.body, request.session.user); - const lotOccupancyTransactions = await getLotOccupancyTransactions(request.body.burialSiteContractId, { includeIntegrations: true }); - response.json({ - success: true, - lotOccupancyTransactions - }); -} diff --git a/handlers/dashboard-get/dashboard.js b/handlers/dashboard-get/dashboard.js index 620cd1aa..c848dff3 100644 --- a/handlers/dashboard-get/dashboard.js +++ b/handlers/dashboard-get/dashboard.js @@ -17,7 +17,7 @@ export default async function handler(_request, response) { limit: 1, // only using the count offset: 0 }); - const lotOccupancyResults = await getBurialSiteContracts({ + const burialSiteContractResults = await getBurialSiteContracts({ contractStartDateString: currentDateString }, { limit: 1, // only using the count @@ -30,6 +30,6 @@ export default async function handler(_request, response) { headTitle: 'Dashboard', workOrderMilestones, workOrderCount: workOrderResults.count, - lotOccupancyCount: lotOccupancyResults.count + burialSiteContractCount: burialSiteContractResults.count }); } diff --git a/handlers/dashboard-get/dashboard.ts b/handlers/dashboard-get/dashboard.ts index 0edfd447..64f56c87 100644 --- a/handlers/dashboard-get/dashboard.ts +++ b/handlers/dashboard-get/dashboard.ts @@ -32,7 +32,7 @@ export default async function handler( } ) - const lotOccupancyResults = await getBurialSiteContracts( + const burialSiteContractResults = await getBurialSiteContracts( { contractStartDateString: currentDateString }, @@ -49,6 +49,6 @@ export default async function handler( headTitle: 'Dashboard', workOrderMilestones, workOrderCount: workOrderResults.count, - lotOccupancyCount: lotOccupancyResults.count + burialSiteContractCount: burialSiteContractResults.count }) } diff --git a/handlers/lots-post/doAddLotComment.d.ts b/handlers/lots-post/doAddLotComment.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/lots-post/doAddLotComment.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/lots-post/doAddLotComment.js b/handlers/lots-post/doAddLotComment.js deleted file mode 100644 index 4bcec715..00000000 --- a/handlers/lots-post/doAddLotComment.js +++ /dev/null @@ -1,10 +0,0 @@ -import addLotComment from '../../database/addLotComment.js'; -import getLotComments from '../../database/getLotComments.js'; -export default async function handler(request, response) { - await addLotComment(request.body, request.session.user); - const lotComments = await getLotComments(request.body.lotId); - response.json({ - success: true, - lotComments - }); -} diff --git a/handlers/lots-post/doCreateLot.d.ts b/handlers/lots-post/doCreateLot.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/lots-post/doCreateLot.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/lots-post/doCreateLot.js b/handlers/lots-post/doCreateLot.js deleted file mode 100644 index 2737f657..00000000 --- a/handlers/lots-post/doCreateLot.js +++ /dev/null @@ -1,12 +0,0 @@ -import addLot from '../../database/addLot.js'; -import { clearNextPreviousLotIdCache } from '../../helpers/functions.lots.js'; -export default async function handler(request, response) { - const lotId = await addLot(request.body, request.session.user); - response.json({ - success: true, - lotId - }); - response.on('finish', () => { - clearNextPreviousLotIdCache(-1); - }); -} diff --git a/handlers/lots-post/doDeleteLot.d.ts b/handlers/lots-post/doDeleteLot.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/lots-post/doDeleteLot.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/lots-post/doDeleteLot.js b/handlers/lots-post/doDeleteLot.js deleted file mode 100644 index f0d87eee..00000000 --- a/handlers/lots-post/doDeleteLot.js +++ /dev/null @@ -1,12 +0,0 @@ -import { clearNextPreviousLotIdCache } from '../../helpers/functions.lots.js'; -import { deleteRecord } from '../../database/deleteRecord.js'; -export default async function handler(request, response) { - const lotId = Number.parseInt(request.body.lotId, 10); - const success = await deleteRecord('Lots', lotId, request.session.user); - response.json({ - success - }); - response.on('finish', () => { - clearNextPreviousLotIdCache(lotId); - }); -} diff --git a/handlers/lots-post/doDeleteLotComment.d.ts b/handlers/lots-post/doDeleteLotComment.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/lots-post/doDeleteLotComment.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/lots-post/doDeleteLotComment.js b/handlers/lots-post/doDeleteLotComment.js deleted file mode 100644 index 69b8e818..00000000 --- a/handlers/lots-post/doDeleteLotComment.js +++ /dev/null @@ -1,10 +0,0 @@ -import { deleteRecord } from '../../database/deleteRecord.js'; -import getLotComments from '../../database/getLotComments.js'; -export default async function handler(request, response) { - const success = await deleteRecord('LotComments', request.body.lotCommentId, request.session.user); - const lotComments = await getLotComments(request.body.lotId); - response.json({ - success, - lotComments - }); -} diff --git a/handlers/lots-post/doUpdateLot.d.ts b/handlers/lots-post/doUpdateLot.d.ts deleted file mode 100644 index 19d32e4d..00000000 --- a/handlers/lots-post/doUpdateLot.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Request, Response } from 'express'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/print-get/pdf.js b/handlers/print-get/pdf.js index 1fde905a..072f31b3 100644 --- a/handlers/print-get/pdf.js +++ b/handlers/print-get/pdf.js @@ -7,7 +7,7 @@ import { getPdfPrintConfig, getReportData } from '../../helpers/functions.print. const attachmentOrInline = getConfigProperty('settings.printPdf.contentDisposition'); export async function handler(request, response, next) { const printName = request.params.printName; - if (!getConfigProperty('settings.lotOccupancy.prints').includes(`pdf/${printName}`) && + if (!getConfigProperty('settings.burialSiteContract.prints').includes(`pdf/${printName}`) && !getConfigProperty('settings.workOrders.prints').includes(`pdf/${printName}`)) { response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/dashboard/?error=printConfigNotAllowed`); return; diff --git a/handlers/print-get/pdf.ts b/handlers/print-get/pdf.ts index 038195dc..fd9d7c87 100644 --- a/handlers/print-get/pdf.ts +++ b/handlers/print-get/pdf.ts @@ -23,7 +23,7 @@ export async function handler( const printName = request.params.printName if ( - !getConfigProperty('settings.lotOccupancy.prints').includes( + !getConfigProperty('settings.burialSiteContract.prints').includes( `pdf/${printName}` ) && !getConfigProperty('settings.workOrders.prints').includes( diff --git a/handlers/print-get/screen.js b/handlers/print-get/screen.js index 10f0f75f..9d4efa91 100644 --- a/handlers/print-get/screen.js +++ b/handlers/print-get/screen.js @@ -2,7 +2,7 @@ import { getConfigProperty } from '../../helpers/config.helpers.js'; import { getReportData, getScreenPrintConfig } from '../../helpers/functions.print.js'; export default async function handler(request, response) { const printName = request.params.printName; - if (!getConfigProperty('settings.lotOccupancy.prints').includes(`screen/${printName}`) && + if (!getConfigProperty('settings.burialSiteContract.prints').includes(`screen/${printName}`) && !getConfigProperty('settings.workOrders.prints').includes(`screen/${printName}`)) { response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/dashboard/?error=printConfigNotAllowed`); return; diff --git a/handlers/print-get/screen.ts b/handlers/print-get/screen.ts index 93c55107..d00acbd5 100644 --- a/handlers/print-get/screen.ts +++ b/handlers/print-get/screen.ts @@ -13,7 +13,7 @@ export default async function handler( const printName = request.params.printName if ( - !getConfigProperty('settings.lotOccupancy.prints').includes( + !getConfigProperty('settings.burialSiteContract.prints').includes( `screen/${printName}` ) && !getConfigProperty('settings.workOrders.prints').includes( diff --git a/handlers/reports-get/search.js b/handlers/reports-get/search.js index 75302174..87a83d87 100644 --- a/handlers/reports-get/search.js +++ b/handlers/reports-get/search.js @@ -1,11 +1,11 @@ import { dateToString } from '@cityssm/utils-datetime'; -import getMaps from '../../database/getMaps.js'; -import { getLotStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js'; +import getCemeteries from '../../database/getCemeteries.js'; +import { getBurialSiteStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js'; export default async function handler(_request, response) { const rightNow = new Date(); - const maps = await getMaps(); + const maps = await getCemeteries(); const lotTypes = await getBurialSiteTypes(); - const lotStatuses = await getLotStatuses(); + const lotStatuses = await getBurialSiteStatuses(); response.render('report-search', { headTitle: 'Reports', todayDateString: dateToString(rightNow), diff --git a/handlers/reports-get/search.ts b/handlers/reports-get/search.ts index 45c903ec..802ca15a 100644 --- a/handlers/reports-get/search.ts +++ b/handlers/reports-get/search.ts @@ -1,8 +1,8 @@ import { dateToString } from '@cityssm/utils-datetime' import type { Request, Response } from 'express' -import getMaps from '../../database/getMaps.js' -import { getLotStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js' +import getCemeteries from '../../database/getCemeteries.js' +import { getBurialSiteStatuses, getBurialSiteTypes } from '../../helpers/functions.cache.js' export default async function handler( _request: Request, @@ -10,9 +10,9 @@ export default async function handler( ): Promise { const rightNow = new Date() - const maps = await getMaps() + const maps = await getCemeteries() const lotTypes = await getBurialSiteTypes() - const lotStatuses = await getLotStatuses() + const lotStatuses = await getBurialSiteStatuses() response.render('report-search', { headTitle: 'Reports', diff --git a/handlers/workOrders-get/edit.js b/handlers/workOrders-get/edit.js index 9199d2a0..6d09c5dd 100644 --- a/handlers/workOrders-get/edit.js +++ b/handlers/workOrders-get/edit.js @@ -1,5 +1,5 @@ import getWorkOrder from '../../database/getWorkOrder.js'; -import { getLotStatuses, getWorkOrderMilestoneTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js'; +import { getBurialSiteStatuses, getWorkOrderMilestoneTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js'; import { getConfigProperty } from '../../helpers/config.helpers.js'; export default async function handler(request, response) { const workOrder = await getWorkOrder(request.params.workOrderId, { @@ -17,7 +17,7 @@ export default async function handler(request, response) { } const workOrderTypes = await getWorkOrderTypes(); const workOrderMilestoneTypes = await getWorkOrderMilestoneTypes(); - const lotStatuses = await getLotStatuses(); + const lotStatuses = await getBurialSiteStatuses(); response.render('workOrder-edit', { headTitle: `Work Order #${workOrder.workOrderNumber}`, workOrder, diff --git a/handlers/workOrders-get/edit.ts b/handlers/workOrders-get/edit.ts index 13eb2e2b..f06c2360 100644 --- a/handlers/workOrders-get/edit.ts +++ b/handlers/workOrders-get/edit.ts @@ -2,7 +2,7 @@ import type { Request, Response } from 'express' import getWorkOrder from '../../database/getWorkOrder.js' import { - getLotStatuses, + getBurialSiteStatuses, getWorkOrderMilestoneTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js' @@ -40,7 +40,7 @@ export default async function handler( const workOrderMilestoneTypes = await getWorkOrderMilestoneTypes() - const lotStatuses = await getLotStatuses() + const lotStatuses = await getBurialSiteStatuses() response.render('workOrder-edit', { headTitle: `Work Order #${workOrder.workOrderNumber}`, diff --git a/handlers/workOrders-post/doAddWorkOrderLotOccupancy.js b/handlers/workOrders-post/doAddWorkOrderLotOccupancy.js index 478e0190..46903eac 100644 --- a/handlers/workOrders-post/doAddWorkOrderLotOccupancy.js +++ b/handlers/workOrders-post/doAddWorkOrderLotOccupancy.js @@ -1,5 +1,5 @@ import addWorkOrderLotOccupancy from '../../database/addWorkOrderLotOccupancy.js'; -import getBurialSiteContracts from '../../database/getLotOccupancies.js'; +import getBurialSiteContracts from '../../database/getBurialSiteContracts.js'; export default async function handler(request, response) { const success = await addWorkOrderLotOccupancy({ workOrderId: request.body.workOrderId, diff --git a/handlers/workOrders-post/doAddWorkOrderLotOccupancy.ts b/handlers/workOrders-post/doAddWorkOrderLotOccupancy.ts index aa211c7d..d043b426 100644 --- a/handlers/workOrders-post/doAddWorkOrderLotOccupancy.ts +++ b/handlers/workOrders-post/doAddWorkOrderLotOccupancy.ts @@ -1,7 +1,7 @@ import type { Request, Response } from 'express' import addWorkOrderLotOccupancy from '../../database/addWorkOrderLotOccupancy.js' -import getBurialSiteContracts from '../../database/getLotOccupancies.js' +import getBurialSiteContracts from '../../database/getBurialSiteContracts.js' export default async function handler( request: Request, diff --git a/handlers/workOrders-post/doDeleteWorkOrderLotOccupancy.js b/handlers/workOrders-post/doDeleteWorkOrderLotOccupancy.js index 902048e2..3e164ef6 100644 --- a/handlers/workOrders-post/doDeleteWorkOrderLotOccupancy.js +++ b/handlers/workOrders-post/doDeleteWorkOrderLotOccupancy.js @@ -1,5 +1,5 @@ import deleteWorkOrderLotOccupancy from '../../database/deleteWorkOrderLotOccupancy.js'; -import getBurialSiteContracts from '../../database/getLotOccupancies.js'; +import getBurialSiteContracts from '../../database/getBurialSiteContracts.js'; export default async function handler(request, response) { const success = await deleteWorkOrderLotOccupancy(request.body.workOrderId, request.body.burialSiteContractId, request.session.user); const workOrderLotOccupancies = await getBurialSiteContracts({ diff --git a/handlers/workOrders-post/doDeleteWorkOrderLotOccupancy.ts b/handlers/workOrders-post/doDeleteWorkOrderLotOccupancy.ts index 193a49fb..cfaabd54 100644 --- a/handlers/workOrders-post/doDeleteWorkOrderLotOccupancy.ts +++ b/handlers/workOrders-post/doDeleteWorkOrderLotOccupancy.ts @@ -1,7 +1,7 @@ import type { Request, Response } from 'express' import deleteWorkOrderLotOccupancy from '../../database/deleteWorkOrderLotOccupancy.js' -import getBurialSiteContracts from '../../database/getLotOccupancies.js' +import getBurialSiteContracts from '../../database/getBurialSiteContracts.js' export default async function handler( request: Request, diff --git a/helpers/burialSites.helpers.d.ts b/helpers/burialSites.helpers.d.ts index a686d2f1..8416c4e4 100644 --- a/helpers/burialSites.helpers.d.ts +++ b/helpers/burialSites.helpers.d.ts @@ -1,3 +1,10 @@ export declare function getNextBurialSiteId(burialSiteId: number): Promise; export declare function getPreviousBurialSiteId(burialSiteId: number): Promise; export declare function clearNextPreviousBurialSiteIdCache(burialSiteId?: number, relayMessage?: boolean): void; +export declare function buildBurialSiteName(segments: { + burialSiteNameSegment1?: string; + burialSiteNameSegment2?: string; + burialSiteNameSegment3?: string; + burialSiteNameSegment4?: string; + burialSiteNameSegment5?: string; +}): string; diff --git a/helpers/burialSites.helpers.js b/helpers/burialSites.helpers.js index e6460acd..e0cd50a8 100644 --- a/helpers/burialSites.helpers.js +++ b/helpers/burialSites.helpers.js @@ -1,12 +1,16 @@ +// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair +/* eslint-disable @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/strict-boolean-expressions, security/detect-object-injection */ import cluster from 'node:cluster'; +import { minutesToSeconds } from '@cityssm/to-millis'; import Debug from 'debug'; import NodeCache from 'node-cache'; import getNextBurialSiteIdFromDatabase from '../database/getNextBurialSiteId.js'; import getPreviousLotIdFromDatabase from '../database/getPreviousLotId.js'; import { DEBUG_NAMESPACE } from '../debug.config.js'; +import { getConfigProperty } from './config.helpers.js'; const debug = Debug(`${DEBUG_NAMESPACE}:burialSites.helpers:${process.pid}`); const cacheOptions = { - stdTTL: 2 * 60, // two minutes + stdTTL: minutesToSeconds(2), useClones: false }; const previousBurialSiteIdCache = new NodeCache(cacheOptions); @@ -80,6 +84,22 @@ export function clearNextPreviousBurialSiteIdCache(burialSiteId = -1, relayMessa } catch { } } +const segmentConfig = getConfigProperty('settings.burialSites.burialSiteNameSegments'); +export function buildBurialSiteName(segments) { + const segmentPieces = []; + // eslint-disable-next-line @typescript-eslint/no-magic-numbers + for (let segmentIndex = 1; segmentIndex <= 5; segmentIndex++) { + const segmentIndexString = segmentIndex.toString(); + if ((segmentConfig.segments[segmentIndexString]?.isAvailable ?? false) && + ((segmentConfig.segments[segmentIndexString]?.isRequired ?? false) || + (segments[`burialSiteNameSegment${segmentIndexString}`] ?? '') !== '')) { + segmentPieces.push((segmentConfig.segments[segmentIndexString]?.prefix ?? '') + + (segments[`burialSiteNameSegment${segmentIndexString}`] ?? '') + + (segmentConfig.segments[segmentIndexString]?.suffix ?? '')); + } + } + return segmentPieces.join(segmentConfig.separator ?? '-'); +} process.on('message', (message) => { if (message.pid !== process.pid) { switch (message.messageType) { diff --git a/helpers/burialSites.helpers.ts b/helpers/burialSites.helpers.ts index c3964491..7bedf1a5 100644 --- a/helpers/burialSites.helpers.ts +++ b/helpers/burialSites.helpers.ts @@ -1,5 +1,9 @@ +// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair +/* eslint-disable @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/strict-boolean-expressions, security/detect-object-injection */ + import cluster from 'node:cluster' +import { minutesToSeconds } from '@cityssm/to-millis' import Debug from 'debug' import NodeCache from 'node-cache' @@ -11,10 +15,12 @@ import type { ClearNextPreviousBurialSiteIdsCacheWorkerMessage } from '../types/applicationTypes.js' +import { getConfigProperty } from './config.helpers.js' + const debug = Debug(`${DEBUG_NAMESPACE}:burialSites.helpers:${process.pid}`) const cacheOptions: NodeCache.Options = { - stdTTL: 2 * 60, // two minutes + stdTTL: minutesToSeconds(2), useClones: false } @@ -128,6 +134,39 @@ export function clearNextPreviousBurialSiteIdCache( } catch {} } +const segmentConfig = getConfigProperty( + 'settings.burialSites.burialSiteNameSegments' +) + +export function buildBurialSiteName(segments: { + burialSiteNameSegment1?: string + burialSiteNameSegment2?: string + burialSiteNameSegment3?: string + burialSiteNameSegment4?: string + burialSiteNameSegment5?: string +}): string { + const segmentPieces: string[] = [] + + // eslint-disable-next-line @typescript-eslint/no-magic-numbers + for (let segmentIndex = 1; segmentIndex <= 5; segmentIndex++) { + const segmentIndexString = segmentIndex.toString() + + if ( + (segmentConfig.segments[segmentIndexString]?.isAvailable ?? false) && + ((segmentConfig.segments[segmentIndexString]?.isRequired ?? false) || + (segments[`burialSiteNameSegment${segmentIndexString}`] ?? '') !== '') + ) { + segmentPieces.push( + (segmentConfig.segments[segmentIndexString]?.prefix ?? '') + + (segments[`burialSiteNameSegment${segmentIndexString}`] ?? '') + + (segmentConfig.segments[segmentIndexString]?.suffix ?? '') + ) + } + } + + return segmentPieces.join(segmentConfig.separator ?? '-') +} + process.on( 'message', ( diff --git a/helpers/functions.authentication.js b/helpers/functions.authentication.js index 88a140f0..f3d6ae14 100644 --- a/helpers/functions.authentication.js +++ b/helpers/functions.authentication.js @@ -33,7 +33,7 @@ const safeRedirects = new Set([ '/admin/occupancytypes', '/admin/tables', '/lotoccupancies', - '/lotoccupancies/new', + '/contracts/new', '/lots', '/lots/new', '/maps', diff --git a/helpers/functions.authentication.ts b/helpers/functions.authentication.ts index d4e44bc2..24ceb9c7 100644 --- a/helpers/functions.authentication.ts +++ b/helpers/functions.authentication.ts @@ -49,7 +49,7 @@ const safeRedirects = new Set([ '/admin/occupancytypes', '/admin/tables', '/lotoccupancies', - '/lotoccupancies/new', + '/contracts/new', '/lots', '/lots/new', '/maps', diff --git a/helpers/functions.fee.d.ts b/helpers/functions.fee.d.ts index 5ad9b18f..d01241a0 100644 --- a/helpers/functions.fee.d.ts +++ b/helpers/functions.fee.d.ts @@ -1,3 +1,3 @@ import type { Fee, LotOccupancy } from '../types/recordTypes.js'; -export declare function calculateFeeAmount(fee: Fee, lotOccupancy: LotOccupancy): number; +export declare function calculateFeeAmount(fee: Fee, burialSiteContract: LotOccupancy): number; export declare function calculateTaxAmount(fee: Fee, feeAmount: number): number; diff --git a/helpers/functions.fee.js b/helpers/functions.fee.js index d805c43e..0b307f9d 100644 --- a/helpers/functions.fee.js +++ b/helpers/functions.fee.js @@ -1,4 +1,4 @@ -export function calculateFeeAmount(fee, lotOccupancy) { +export function calculateFeeAmount(fee, burialSiteContract) { return fee.feeFunction ? 0 : fee.feeAmount ?? 0; } export function calculateTaxAmount(fee, feeAmount) { diff --git a/helpers/functions.fee.ts b/helpers/functions.fee.ts index 66778634..e3319b80 100644 --- a/helpers/functions.fee.ts +++ b/helpers/functions.fee.ts @@ -2,7 +2,7 @@ import type { Fee, LotOccupancy } from '../types/recordTypes.js' export function calculateFeeAmount( fee: Fee, - lotOccupancy: LotOccupancy + burialSiteContract: LotOccupancy ): number { return fee.feeFunction ? 0 : fee.feeAmount ?? 0 } diff --git a/helpers/functions.lotOccupancy.d.ts b/helpers/functions.lotOccupancy.d.ts index d3813651..04458ecd 100644 --- a/helpers/functions.lotOccupancy.d.ts +++ b/helpers/functions.lotOccupancy.d.ts @@ -1,5 +1,5 @@ import type { LotOccupancy, LotOccupancyFee, LotOccupancyOccupant } from '../types/recordTypes.js'; -export declare function filterOccupantsByLotOccupantType(lotOccupancy: LotOccupancy, lotOccupantType: string): LotOccupancyOccupant[]; -export declare function getFieldValueByOccupancyTypeField(lotOccupancy: LotOccupancy, occupancyTypeField: string): string | undefined; -export declare function getFeesByFeeCategory(lotOccupancy: LotOccupancy, feeCategory: string, feeCategoryContains?: boolean): LotOccupancyFee[]; -export declare function getTransactionTotal(lotOccupancy: LotOccupancy): number; +export declare function filterOccupantsByLotOccupantType(burialSiteContract: LotOccupancy, lotOccupantType: string): LotOccupancyOccupant[]; +export declare function getFieldValueByOccupancyTypeField(burialSiteContract: LotOccupancy, occupancyTypeField: string): string | undefined; +export declare function getFeesByFeeCategory(burialSiteContract: LotOccupancy, feeCategory: string, feeCategoryContains?: boolean): LotOccupancyFee[]; +export declare function getTransactionTotal(burialSiteContract: LotOccupancy): number; diff --git a/helpers/functions.lotOccupancy.js b/helpers/functions.lotOccupancy.js index cd955917..d11f1117 100644 --- a/helpers/functions.lotOccupancy.js +++ b/helpers/functions.lotOccupancy.js @@ -1,29 +1,29 @@ -export function filterOccupantsByLotOccupantType(lotOccupancy, lotOccupantType) { +export function filterOccupantsByLotOccupantType(burialSiteContract, lotOccupantType) { const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase(); - return (lotOccupancy.lotOccupancyOccupants ?? []).filter((possibleOccupant) => possibleOccupant.lotOccupantType.toLowerCase() === + return (burialSiteContract.burialSiteContractOccupants ?? []).filter((possibleOccupant) => possibleOccupant.lotOccupantType.toLowerCase() === lotOccupantTypeLowerCase); } -export function getFieldValueByOccupancyTypeField(lotOccupancy, occupancyTypeField) { +export function getFieldValueByOccupancyTypeField(burialSiteContract, occupancyTypeField) { const occupancyTypeFieldLowerCase = occupancyTypeField.toLowerCase(); - const field = (lotOccupancy.lotOccupancyFields ?? []).find((possibleField) => possibleField.occupancyTypeField.toLowerCase() === + const field = (burialSiteContract.burialSiteContractFields ?? []).find((possibleField) => possibleField.occupancyTypeField.toLowerCase() === occupancyTypeFieldLowerCase); if (field === undefined) { return undefined; } - return field.lotOccupancyFieldValue; + return field.burialSiteContractFieldValue; } -export function getFeesByFeeCategory(lotOccupancy, feeCategory, feeCategoryContains = false) { +export function getFeesByFeeCategory(burialSiteContract, feeCategory, feeCategoryContains = false) { const feeCategoryLowerCase = feeCategory.toLowerCase(); - return (lotOccupancy.lotOccupancyFees ?? []).filter((possibleFee) => feeCategoryContains + return (burialSiteContract.burialSiteContractFees ?? []).filter((possibleFee) => feeCategoryContains ? possibleFee.feeCategory .toLowerCase() .includes(feeCategoryLowerCase) : possibleFee.feeCategory.toLowerCase() === feeCategoryLowerCase); } -export function getTransactionTotal(lotOccupancy) { +export function getTransactionTotal(burialSiteContract) { let transactionTotal = 0; - for (const transaction of lotOccupancy.lotOccupancyTransactions ?? []) { + for (const transaction of burialSiteContract.burialSiteContractTransactions ?? []) { transactionTotal += transaction.transactionAmount; } return transactionTotal; diff --git a/helpers/functions.lotOccupancy.ts b/helpers/functions.lotOccupancy.ts index d55a41c9..e75d0fcc 100644 --- a/helpers/functions.lotOccupancy.ts +++ b/helpers/functions.lotOccupancy.ts @@ -5,12 +5,12 @@ import type { } from '../types/recordTypes.js' export function filterOccupantsByLotOccupantType( - lotOccupancy: LotOccupancy, + burialSiteContract: LotOccupancy, lotOccupantType: string ): LotOccupancyOccupant[] { const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase() - return (lotOccupancy.lotOccupancyOccupants ?? []).filter( + return (burialSiteContract.burialSiteContractOccupants ?? []).filter( (possibleOccupant) => (possibleOccupant.lotOccupantType as string).toLowerCase() === lotOccupantTypeLowerCase @@ -18,12 +18,12 @@ export function filterOccupantsByLotOccupantType( } export function getFieldValueByOccupancyTypeField( - lotOccupancy: LotOccupancy, + burialSiteContract: LotOccupancy, occupancyTypeField: string ): string | undefined { const occupancyTypeFieldLowerCase = occupancyTypeField.toLowerCase() - const field = (lotOccupancy.lotOccupancyFields ?? []).find( + const field = (burialSiteContract.burialSiteContractFields ?? []).find( (possibleField) => (possibleField.occupancyTypeField as string).toLowerCase() === occupancyTypeFieldLowerCase @@ -33,17 +33,17 @@ export function getFieldValueByOccupancyTypeField( return undefined } - return field.lotOccupancyFieldValue + return field.burialSiteContractFieldValue } export function getFeesByFeeCategory( - lotOccupancy: LotOccupancy, + burialSiteContract: LotOccupancy, feeCategory: string, feeCategoryContains = false ): LotOccupancyFee[] { const feeCategoryLowerCase = feeCategory.toLowerCase() - return (lotOccupancy.lotOccupancyFees ?? []).filter((possibleFee) => + return (burialSiteContract.burialSiteContractFees ?? []).filter((possibleFee) => feeCategoryContains ? (possibleFee.feeCategory as string) .toLowerCase() @@ -53,10 +53,10 @@ export function getFeesByFeeCategory( ) } -export function getTransactionTotal(lotOccupancy: LotOccupancy): number { +export function getTransactionTotal(burialSiteContract: LotOccupancy): number { let transactionTotal = 0 - for (const transaction of lotOccupancy.lotOccupancyTransactions ?? []) { + for (const transaction of burialSiteContract.burialSiteContractTransactions ?? []) { transactionTotal += transaction.transactionAmount } diff --git a/helpers/functions.print.d.ts b/helpers/functions.print.d.ts index 131fabf3..fd9063b8 100644 --- a/helpers/functions.print.d.ts +++ b/helpers/functions.print.d.ts @@ -1,16 +1,16 @@ -import type { Lot, LotOccupancy, WorkOrder } from '../types/recordTypes.js'; +import type { BurialSite, BurialSiteContract, WorkOrder } from '../types/recordTypes.js'; interface PrintConfig { title: string; params: string[]; } interface ReportData { headTitle: string; - lot?: Lot; - lotOccupancy?: LotOccupancy; + burialSite?: BurialSite; + burialSiteContract?: BurialSiteContract; workOrder?: WorkOrder; configFunctions: unknown; dateTimeFunctions: unknown; - lotOccupancyFunctions: unknown; + burialSiteContractFunctions: unknown; } export declare function getScreenPrintConfig(printName: string): PrintConfig | undefined; export declare function getPdfPrintConfig(printName: string): PrintConfig | undefined; diff --git a/helpers/functions.print.js b/helpers/functions.print.js index c6a38192..adf13620 100644 --- a/helpers/functions.print.js +++ b/helpers/functions.print.js @@ -1,12 +1,12 @@ import * as dateTimeFunctions from '@cityssm/utils-datetime'; -import getLot from '../database/getLot.js'; -import getLotOccupancy from '../database/getLotOccupancy.js'; +import getBurialSite from '../database/getBurialSite.js'; +import getBurialSiteContract from '../database/getBurialSiteContract.js'; import getWorkOrder from '../database/getWorkOrder.js'; import * as configFunctions from './config.helpers.js'; -import * as lotOccupancyFunctions from './functions.lotOccupancy.js'; +import * as burialSiteContractFunctions from './functions.burialSiteContract.js'; const screenPrintConfigs = { - lotOccupancy: { - title: `${configFunctions.getConfigProperty('aliases.lot')} ${configFunctions.getConfigProperty('aliases.occupancy')} Print`, + burialSiteContract: { + title: `Burial Site Contract Print`, params: ['burialSiteContractId'] } }; @@ -52,20 +52,20 @@ export async function getReportData(printConfig, requestQuery) { headTitle: printConfig.title, configFunctions, dateTimeFunctions, - lotOccupancyFunctions + burialSiteContractFunctions }; if (printConfig.params.includes('burialSiteContractId') && typeof requestQuery.burialSiteContractId === 'string') { - const lotOccupancy = await getLotOccupancy(requestQuery.burialSiteContractId); - if (lotOccupancy !== undefined && (lotOccupancy.lotId ?? -1) !== -1) { - reportData.lot = await getLot(lotOccupancy.lotId ?? -1); + const burialSiteContract = await getBurialSiteContract(requestQuery.burialSiteContractId); + if (burialSiteContract !== undefined && (burialSiteContract.burialSiteId ?? -1) !== -1) { + reportData.burialSite = await getBurialSite(burialSiteContract.burialSiteId ?? -1); } - reportData.lotOccupancy = lotOccupancy; + reportData.burialSiteContract = burialSiteContract; } if (printConfig.params.includes('workOrderId') && typeof requestQuery.workOrderId === 'string') { reportData.workOrder = await getWorkOrder(requestQuery.workOrderId, { - includeLotsAndLotOccupancies: true, + includeBurialSites: true, includeComments: true, includeMilestones: true }); diff --git a/helpers/functions.print.ts b/helpers/functions.print.ts index 7d3eed81..40818a83 100644 --- a/helpers/functions.print.ts +++ b/helpers/functions.print.ts @@ -1,12 +1,12 @@ import * as dateTimeFunctions from '@cityssm/utils-datetime' -import getLot from '../database/getLot.js' -import getLotOccupancy from '../database/getLotOccupancy.js' +import getBurialSite from '../database/getBurialSite.js' +import getBurialSiteContract from '../database/getBurialSiteContract.js' import getWorkOrder from '../database/getWorkOrder.js' -import type { Lot, LotOccupancy, WorkOrder } from '../types/recordTypes.js' +import type { BurialSite, BurialSiteContract, WorkOrder } from '../types/recordTypes.js' import * as configFunctions from './config.helpers.js' -import * as lotOccupancyFunctions from './functions.lotOccupancy.js' +import * as burialSiteContractFunctions from './functions.burialSiteContract.js' interface PrintConfig { title: string @@ -16,20 +16,18 @@ interface PrintConfig { interface ReportData { headTitle: string - lot?: Lot - lotOccupancy?: LotOccupancy + burialSite?: BurialSite + burialSiteContract?: BurialSiteContract workOrder?: WorkOrder configFunctions: unknown dateTimeFunctions: unknown - lotOccupancyFunctions: unknown + burialSiteContractFunctions: unknown } const screenPrintConfigs: Record = { - lotOccupancy: { - title: `${configFunctions.getConfigProperty( - 'aliases.lot' - )} ${configFunctions.getConfigProperty('aliases.occupancy')} Print`, + burialSiteContract: { + title: `Burial Site Contract Print`, params: ['burialSiteContractId'] } } @@ -90,20 +88,20 @@ export async function getReportData( headTitle: printConfig.title, configFunctions, dateTimeFunctions, - lotOccupancyFunctions + burialSiteContractFunctions } if ( printConfig.params.includes('burialSiteContractId') && typeof requestQuery.burialSiteContractId === 'string' ) { - const lotOccupancy = await getLotOccupancy(requestQuery.burialSiteContractId) + const burialSiteContract = await getBurialSiteContract(requestQuery.burialSiteContractId) - if (lotOccupancy !== undefined && (lotOccupancy.lotId ?? -1) !== -1) { - reportData.lot = await getLot(lotOccupancy.lotId ?? -1) + if (burialSiteContract !== undefined && (burialSiteContract.burialSiteId ?? -1) !== -1) { + reportData.burialSite = await getBurialSite(burialSiteContract.burialSiteId ?? -1) } - reportData.lotOccupancy = lotOccupancy + reportData.burialSiteContract = burialSiteContract } if ( @@ -111,7 +109,7 @@ export async function getReportData( typeof requestQuery.workOrderId === 'string' ) { reportData.workOrder = await getWorkOrder(requestQuery.workOrderId, { - includeLotsAndLotOccupancies: true, + includeBurialSites: true, includeComments: true, includeMilestones: true }) diff --git a/helpers/functions.sqlFilters.d.ts b/helpers/functions.sqlFilters.d.ts index 3d2a569f..6df91203 100644 --- a/helpers/functions.sqlFilters.d.ts +++ b/helpers/functions.sqlFilters.d.ts @@ -1,9 +1,9 @@ -type LotNameSearchType = 'startsWith' | 'endsWith' | ''; +type BurialSiteNameSearchType = 'startsWith' | 'endsWith' | ''; interface WhereClauseReturn { sqlWhereClause: string; sqlParameters: unknown[]; } -export declare function getLotNameWhereClause(lotName?: string, lotNameSearchType?: LotNameSearchType, lotsTableAlias?: string): WhereClauseReturn; +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; diff --git a/helpers/functions.sqlFilters.js b/helpers/functions.sqlFilters.js index a453c20c..c41e1f2d 100644 --- a/helpers/functions.sqlFilters.js +++ b/helpers/functions.sqlFilters.js @@ -1,29 +1,29 @@ import { dateToInteger } from '@cityssm/utils-datetime'; -export function getLotNameWhereClause(lotName = '', lotNameSearchType = '', lotsTableAlias = 'l') { +export function getBurialSiteNameWhereClause(burialSiteName = '', burialSiteNameSearchType = '', burialSitesTableAlias = 'l') { let sqlWhereClause = ''; const sqlParameters = []; - if (lotName !== '') { - switch (lotNameSearchType ?? '') { + if (burialSiteName !== '') { + switch (burialSiteNameSearchType) { case 'startsWith': { - sqlWhereClause += ` and ${lotsTableAlias}.lotName like ? || '%'`; - sqlParameters.push(lotName); + sqlWhereClause += ` and ${burialSitesTableAlias}.burialSiteName like ? || '%'`; + sqlParameters.push(burialSiteName); break; } case 'endsWith': { - sqlWhereClause += ` and ${lotsTableAlias}.lotName like '%' || ?`; - sqlParameters.push(lotName); + sqlWhereClause += ` and ${burialSitesTableAlias}.burialSiteName like '%' || ?`; + sqlParameters.push(burialSiteName); break; } default: { const usedPieces = new Set(); - const lotNamePieces = lotName.toLowerCase().split(' '); - for (const lotNamePiece of lotNamePieces) { - if (lotNamePiece === '' || usedPieces.has(lotNamePiece)) { + const burialSiteNamePieces = burialSiteName.toLowerCase().split(' '); + for (const burialSiteNamePiece of burialSiteNamePieces) { + if (burialSiteNamePiece === '' || usedPieces.has(burialSiteNamePiece)) { continue; } - usedPieces.add(lotNamePiece); - sqlWhereClause += ` and instr(lower(${lotsTableAlias}.lotName), ?)`; - sqlParameters.push(lotNamePiece); + usedPieces.add(burialSiteNamePiece); + sqlWhereClause += ` and instr(lower(${burialSitesTableAlias}.burialSiteName), ?)`; + sqlParameters.push(burialSiteNamePiece); } } } diff --git a/helpers/functions.sqlFilters.ts b/helpers/functions.sqlFilters.ts index 164424b5..56ebe1cb 100644 --- a/helpers/functions.sqlFilters.ts +++ b/helpers/functions.sqlFilters.ts @@ -1,46 +1,46 @@ import { dateToInteger } from '@cityssm/utils-datetime' -type LotNameSearchType = 'startsWith' | 'endsWith' | '' +type BurialSiteNameSearchType = 'startsWith' | 'endsWith' | '' interface WhereClauseReturn { sqlWhereClause: string sqlParameters: unknown[] } -export function getLotNameWhereClause( - lotName = '', - lotNameSearchType: LotNameSearchType = '', - lotsTableAlias = 'l' +export function getBurialSiteNameWhereClause( + burialSiteName = '', + burialSiteNameSearchType: BurialSiteNameSearchType = '', + burialSitesTableAlias = 'l' ): WhereClauseReturn { let sqlWhereClause = '' const sqlParameters: unknown[] = [] - if (lotName !== '') { - switch (lotNameSearchType ?? '') { + if (burialSiteName !== '') { + switch (burialSiteNameSearchType) { case 'startsWith': { - sqlWhereClause += ` and ${lotsTableAlias}.lotName like ? || '%'` - sqlParameters.push(lotName) + sqlWhereClause += ` and ${burialSitesTableAlias}.burialSiteName like ? || '%'` + sqlParameters.push(burialSiteName) break } case 'endsWith': { - sqlWhereClause += ` and ${lotsTableAlias}.lotName like '%' || ?` - sqlParameters.push(lotName) + sqlWhereClause += ` and ${burialSitesTableAlias}.burialSiteName like '%' || ?` + sqlParameters.push(burialSiteName) break } default: { const usedPieces = new Set() - const lotNamePieces = lotName.toLowerCase().split(' ') + const burialSiteNamePieces = burialSiteName.toLowerCase().split(' ') - for (const lotNamePiece of lotNamePieces) { - if (lotNamePiece === '' || usedPieces.has(lotNamePiece)) { + for (const burialSiteNamePiece of burialSiteNamePieces) { + if (burialSiteNamePiece === '' || usedPieces.has(burialSiteNamePiece)) { continue } - usedPieces.add(lotNamePiece) + usedPieces.add(burialSiteNamePiece) - sqlWhereClause += ` and instr(lower(${lotsTableAlias}.lotName), ?)` - sqlParameters.push(lotNamePiece) + sqlWhereClause += ` and instr(lower(${burialSitesTableAlias}.burialSiteName), ?)` + sqlParameters.push(burialSiteNamePiece) } } } diff --git a/public/javascripts/lotOccupancyEdit.ts b/public/javascripts/lotOccupancyEdit.ts index f8a13ebd..4386d694 100644 --- a/public/javascripts/lotOccupancyEdit.ts +++ b/public/javascripts/lotOccupancyEdit.ts @@ -26,7 +26,7 @@ declare const exports: Record const los = exports.los as LOS const burialSiteContractId = ( - document.querySelector('#lotOccupancy--burialSiteContractId') as HTMLInputElement + document.querySelector('#burialSiteContract--burialSiteContractId') as HTMLInputElement ).value const isCreate = burialSiteContractId === '' @@ -39,26 +39,26 @@ declare const exports: Record function setUnsavedChanges(): void { los.setUnsavedChanges() document - .querySelector("button[type='submit'][form='form--lotOccupancy']") + .querySelector("button[type='submit'][form='form--burialSiteContract']") ?.classList.remove('is-light') } function clearUnsavedChanges(): void { los.clearUnsavedChanges() document - .querySelector("button[type='submit'][form='form--lotOccupancy']") + .querySelector("button[type='submit'][form='form--burialSiteContract']") ?.classList.add('is-light') } const formElement = document.querySelector( - '#form--lotOccupancy' + '#form--burialSiteContract' ) as HTMLFormElement formElement.addEventListener('submit', (formEvent) => { formEvent.preventDefault() cityssm.postJSON( - `${los.urlPrefix}/lotOccupancies/${isCreate ? 'doCreateLotOccupancy' : 'doUpdateLotOccupancy'}`, + `${los.urlPrefix}/contracts/${isCreate ? 'doCreateLotOccupancy' : 'doUpdateLotOccupancy'}`, formElement, (rawResponseJSON) => { const responseJSON = rawResponseJSON as { @@ -71,7 +71,7 @@ declare const exports: Record clearUnsavedChanges() if (isCreate || refreshAfterSave) { - globalThis.location.href = los.getLotOccupancyURL( + globalThis.location.href = los.getBurialSiteContractURL( responseJSON.burialSiteContractId, true, true @@ -101,7 +101,7 @@ declare const exports: Record function doCopy(): void { cityssm.postJSON( - `${los.urlPrefix}/lotOccupancies/doCopyLotOccupancy`, + `${los.urlPrefix}/contracts/doCopyLotOccupancy`, { burialSiteContractId }, @@ -115,7 +115,7 @@ declare const exports: Record if (responseJSON.success) { clearUnsavedChanges() - globalThis.location.href = los.getLotOccupancyURL( + globalThis.location.href = los.getBurialSiteContractURL( responseJSON.burialSiteContractId, true ) @@ -131,7 +131,7 @@ declare const exports: Record } document - .querySelector('#button--copyLotOccupancy') + .querySelector('#button--copyBurialSiteContract') ?.addEventListener('click', (clickEvent) => { clickEvent.preventDefault() @@ -161,7 +161,7 @@ declare const exports: Record function doDelete(): void { cityssm.postJSON( - `${los.urlPrefix}/lotOccupancies/doDeleteLotOccupancy`, + `${los.urlPrefix}/contracts/doDeleteLotOccupancy`, { burialSiteContractId }, @@ -173,7 +173,7 @@ declare const exports: Record if (responseJSON.success) { clearUnsavedChanges() - globalThis.location.href = los.getLotOccupancyURL() + globalThis.location.href = los.getBurialSiteContractURL() } else { bulmaJS.alert({ title: 'Error Deleting Record', @@ -244,7 +244,7 @@ declare const exports: Record ) } - cityssm.openHtmlModal('lotOccupancy-createWorkOrder', { + cityssm.openHtmlModal('burialSiteContract-createWorkOrder', { onshow(modalElement) { ;( modalElement.querySelector( @@ -302,18 +302,18 @@ declare const exports: Record // Occupancy Type const contractTypeIdElement = document.querySelector( - '#lotOccupancy--contractTypeId' + '#burialSiteContract--contractTypeId' ) as HTMLSelectElement if (isCreate) { - const lotOccupancyFieldsContainerElement = document.querySelector( - '#container--lotOccupancyFields' + const burialSiteContractFieldsContainerElement = document.querySelector( + '#container--burialSiteContractFields' ) as HTMLElement contractTypeIdElement.addEventListener('change', () => { if (contractTypeIdElement.value === '') { // eslint-disable-next-line no-unsanitized/property - lotOccupancyFieldsContainerElement.innerHTML = `
+ burialSiteContractFieldsContainerElement.innerHTML = `

Select the ${los.escapedAliases.occupancy} type to load the available fields.

` @@ -321,7 +321,7 @@ declare const exports: Record } cityssm.postJSON( - `${los.urlPrefix}/lotOccupancies/doGetContractTypeFields`, + `${los.urlPrefix}/contracts/doGetContractTypeFields`, { contractTypeId: contractTypeIdElement.value }, @@ -332,23 +332,23 @@ declare const exports: Record if (responseJSON.ContractTypeFields.length === 0) { // eslint-disable-next-line no-unsanitized/property - lotOccupancyFieldsContainerElement.innerHTML = `
+ burialSiteContractFieldsContainerElement.innerHTML = `

There are no additional fields for this ${los.escapedAliases.occupancy} type.

` return } - lotOccupancyFieldsContainerElement.innerHTML = '' + burialSiteContractFieldsContainerElement.innerHTML = '' let contractTypeFieldIds = '' for (const occupancyTypeField of responseJSON.ContractTypeFields) { contractTypeFieldIds += `,${occupancyTypeField.contractTypeFieldId.toString()}` - const fieldName = `lotOccupancyFieldValue_${occupancyTypeField.contractTypeFieldId.toString()}` + const fieldName = `burialSiteContractFieldValue_${occupancyTypeField.contractTypeFieldId.toString()}` - const fieldId = `lotOccupancy--${fieldName}` + const fieldId = `burialSiteContract--${fieldName}` const fieldElement = document.createElement('div') fieldElement.className = 'field' @@ -415,10 +415,10 @@ declare const exports: Record console.log(fieldElement) - lotOccupancyFieldsContainerElement.append(fieldElement) + burialSiteContractFieldsContainerElement.append(fieldElement) } - lotOccupancyFieldsContainerElement.insertAdjacentHTML( + burialSiteContractFieldsContainerElement.insertAdjacentHTML( 'beforeend', // eslint-disable-next-line no-secrets/no-secrets ` // Lot Selector const lotNameElement = document.querySelector( - '#lotOccupancy--lotName' + '#burialSiteContract--lotName' ) as HTMLInputElement lotNameElement.addEventListener('click', (clickEvent) => { @@ -474,10 +474,10 @@ declare const exports: Record lotName: string ): void { ;( - document.querySelector('#lotOccupancy--lotId') as HTMLInputElement + document.querySelector('#burialSiteContract--lotId') as HTMLInputElement ).value = lotId.toString() ;( - document.querySelector('#lotOccupancy--lotName') as HTMLInputElement + document.querySelector('#burialSiteContract--lotName') as HTMLInputElement ).value = lotName setUnsavedChanges() @@ -537,7 +537,7 @@ declare const exports: Record
${cityssm.escapeHTML(lot.lotStatus as string)}
- ${lot.lotOccupancyCount! > 0 ? 'Currently Occupied' : ''} + ${lot.burialSiteContractCount! > 0 ? 'Currently Occupied' : ''}
` @@ -585,7 +585,7 @@ declare const exports: Record ) } - cityssm.openHtmlModal('lotOccupancy-selectLot', { + cityssm.openHtmlModal('burialSiteContract-selectLot', { onshow(modalElement) { los.populateAliases(modalElement) }, @@ -604,7 +604,7 @@ declare const exports: Record ) as HTMLInputElement if ( - (document.querySelector('#lotOccupancy--lotId') as HTMLInputElement) + (document.querySelector('#burialSiteContract--lotId') as HTMLInputElement) .value !== '' ) { lotNameFilterElement.value = currentLotName @@ -695,7 +695,7 @@ declare const exports: Record .querySelector('.is-lot-view-button') ?.addEventListener('click', () => { const lotId = ( - document.querySelector('#lotOccupancy--lotId') as HTMLInputElement + document.querySelector('#burialSiteContract--lotId') as HTMLInputElement ).value if (lotId === '') { @@ -719,7 +719,7 @@ declare const exports: Record } else { lotNameElement.value = `(No ${los.escapedAliases.Lot})` ;( - document.querySelector('#lotOccupancy--lotId') as HTMLInputElement + document.querySelector('#burialSiteContract--lotId') as HTMLInputElement ).value = '' setUnsavedChanges() @@ -731,17 +731,17 @@ declare const exports: Record los.initializeDatePickers(formElement) document - .querySelector('#lotOccupancy--contractStartDateString') + .querySelector('#burialSiteContract--contractStartDateString') ?.addEventListener('change', () => { const endDatePicker = ( document.querySelector( - '#lotOccupancy--contractEndDateString' + '#burialSiteContract--contractEndDateString' ) as HTMLInputElement ).bulmaCalendar.datePicker endDatePicker.min = ( document.querySelector( - '#lotOccupancy--contractStartDateString' + '#burialSiteContract--contractStartDateString' ) as HTMLInputElement ).value @@ -754,10 +754,10 @@ declare const exports: Record * Occupants */ ;(() => { - let lotOccupancyOccupants = - exports.lotOccupancyOccupants as LotOccupancyOccupant[] + let burialSiteContractOccupants = + exports.burialSiteContractOccupants as LotOccupancyOccupant[] - delete exports.lotOccupancyOccupants + delete exports.burialSiteContractOccupants function openEditLotOccupancyOccupant(clickEvent: Event): void { const lotOccupantIndex = Number.parseInt( @@ -766,7 +766,7 @@ declare const exports: Record 10 ) - const lotOccupancyOccupant = lotOccupancyOccupants.find( + const burialSiteContractOccupant = burialSiteContractOccupants.find( (currentLotOccupancyOccupant) => { return ( currentLotOccupancyOccupant.lotOccupantIndex === lotOccupantIndex @@ -781,17 +781,17 @@ declare const exports: Record submitEvent.preventDefault() cityssm.postJSON( - `${los.urlPrefix}/lotOccupancies/doUpdateLotOccupancyOccupant`, + `${los.urlPrefix}/contracts/doUpdateLotOccupancyOccupant`, editFormElement, (rawResponseJSON) => { const responseJSON = rawResponseJSON as { success: boolean errorMessage?: string - lotOccupancyOccupants: LotOccupancyOccupant[] + burialSiteContractOccupants: LotOccupancyOccupant[] } if (responseJSON.success) { - lotOccupancyOccupants = responseJSON.lotOccupancyOccupants + burialSiteContractOccupants = responseJSON.burialSiteContractOccupants editCloseModalFunction() renderLotOccupancyOccupants() } else { @@ -805,22 +805,22 @@ declare const exports: Record ) } - cityssm.openHtmlModal('lotOccupancy-editOccupant', { + cityssm.openHtmlModal('burialSiteContract-editOccupant', { onshow(modalElement) { los.populateAliases(modalElement) ;( modalElement.querySelector( - '#lotOccupancyOccupantEdit--burialSiteContractId' + '#burialSiteContractOccupantEdit--burialSiteContractId' ) as HTMLInputElement ).value = burialSiteContractId ;( modalElement.querySelector( - '#lotOccupancyOccupantEdit--lotOccupantIndex' + '#burialSiteContractOccupantEdit--lotOccupantIndex' ) as HTMLInputElement ).value = lotOccupantIndex.toString() const lotOccupantTypeSelectElement = modalElement.querySelector( - '#lotOccupancyOccupantEdit--lotOccupantTypeId' + '#burialSiteContractOccupantEdit--lotOccupantTypeId' ) as HTMLSelectElement let lotOccupantTypeSelected = false @@ -838,7 +838,7 @@ declare const exports: Record if ( lotOccupantType.lotOccupantTypeId === - lotOccupancyOccupant.lotOccupantTypeId + burialSiteContractOccupant.lotOccupantTypeId ) { optionElement.selected = true lotOccupantTypeSelected = true @@ -851,15 +851,15 @@ declare const exports: Record const optionElement = document.createElement('option') optionElement.value = - lotOccupancyOccupant.lotOccupantTypeId?.toString() ?? '' + burialSiteContractOccupant.lotOccupantTypeId?.toString() ?? '' optionElement.textContent = - lotOccupancyOccupant.lotOccupantType ?? '' + burialSiteContractOccupant.lotOccupantType ?? '' optionElement.dataset.occupantCommentTitle = - lotOccupancyOccupant.occupantCommentTitle + burialSiteContractOccupant.occupantCommentTitle optionElement.dataset.fontAwesomeIconClass = - lotOccupancyOccupant.fontAwesomeIconClass + burialSiteContractOccupant.fontAwesomeIconClass optionElement.selected = true @@ -868,74 +868,74 @@ declare const exports: Record ;( modalElement.querySelector( - '#lotOccupancyOccupantEdit--fontAwesomeIconClass' + '#burialSiteContractOccupantEdit--fontAwesomeIconClass' ) as HTMLElement ).innerHTML = - `` + `` ;( modalElement.querySelector( - '#lotOccupancyOccupantEdit--occupantName' + '#burialSiteContractOccupantEdit--occupantName' ) as HTMLInputElement - ).value = lotOccupancyOccupant.occupantName ?? '' + ).value = burialSiteContractOccupant.occupantName ?? '' ;( modalElement.querySelector( - '#lotOccupancyOccupantEdit--occupantFamilyName' + '#burialSiteContractOccupantEdit--occupantFamilyName' ) as HTMLInputElement - ).value = lotOccupancyOccupant.occupantFamilyName ?? '' + ).value = burialSiteContractOccupant.occupantFamilyName ?? '' ;( modalElement.querySelector( - '#lotOccupancyOccupantEdit--occupantAddress1' + '#burialSiteContractOccupantEdit--occupantAddress1' ) as HTMLInputElement - ).value = lotOccupancyOccupant.occupantAddress1 ?? '' + ).value = burialSiteContractOccupant.occupantAddress1 ?? '' ;( modalElement.querySelector( - '#lotOccupancyOccupantEdit--occupantAddress2' + '#burialSiteContractOccupantEdit--occupantAddress2' ) as HTMLInputElement - ).value = lotOccupancyOccupant.occupantAddress2 ?? '' + ).value = burialSiteContractOccupant.occupantAddress2 ?? '' ;( modalElement.querySelector( - '#lotOccupancyOccupantEdit--occupantCity' + '#burialSiteContractOccupantEdit--occupantCity' ) as HTMLInputElement - ).value = lotOccupancyOccupant.occupantCity ?? '' + ).value = burialSiteContractOccupant.occupantCity ?? '' ;( modalElement.querySelector( - '#lotOccupancyOccupantEdit--occupantProvince' + '#burialSiteContractOccupantEdit--occupantProvince' ) as HTMLInputElement - ).value = lotOccupancyOccupant.occupantProvince ?? '' + ).value = burialSiteContractOccupant.occupantProvince ?? '' ;( modalElement.querySelector( - '#lotOccupancyOccupantEdit--occupantPostalCode' + '#burialSiteContractOccupantEdit--occupantPostalCode' ) as HTMLInputElement - ).value = lotOccupancyOccupant.occupantPostalCode ?? '' + ).value = burialSiteContractOccupant.occupantPostalCode ?? '' ;( modalElement.querySelector( - '#lotOccupancyOccupantEdit--occupantPhoneNumber' + '#burialSiteContractOccupantEdit--occupantPhoneNumber' ) as HTMLInputElement - ).value = lotOccupancyOccupant.occupantPhoneNumber ?? '' + ).value = burialSiteContractOccupant.occupantPhoneNumber ?? '' ;( modalElement.querySelector( - '#lotOccupancyOccupantEdit--occupantEmailAddress' + '#burialSiteContractOccupantEdit--occupantEmailAddress' ) as HTMLInputElement - ).value = lotOccupancyOccupant.occupantEmailAddress ?? '' + ).value = burialSiteContractOccupant.occupantEmailAddress ?? '' ;( modalElement.querySelector( - '#lotOccupancyOccupantEdit--occupantCommentTitle' + '#burialSiteContractOccupantEdit--occupantCommentTitle' ) as HTMLLabelElement ).textContent = - (lotOccupancyOccupant.occupantCommentTitle ?? '') === '' + (burialSiteContractOccupant.occupantCommentTitle ?? '') === '' ? 'Comment' - : lotOccupancyOccupant.occupantCommentTitle ?? '' + : burialSiteContractOccupant.occupantCommentTitle ?? '' ;( modalElement.querySelector( - '#lotOccupancyOccupantEdit--occupantComment' + '#burialSiteContractOccupantEdit--occupantComment' ) as HTMLTextAreaElement - ).value = lotOccupancyOccupant.occupantComment ?? '' + ).value = burialSiteContractOccupant.occupantComment ?? '' }, onshown(modalElement, closeModalFunction) { bulmaJS.toggleHtmlClipped() const lotOccupantTypeIdElement = modalElement.querySelector( - '#lotOccupancyOccupantEdit--lotOccupantTypeId' + '#burialSiteContractOccupantEdit--lotOccupantTypeId' ) as HTMLSelectElement lotOccupantTypeIdElement.focus() @@ -947,7 +947,7 @@ declare const exports: Record ;( modalElement.querySelector( - '#lotOccupancyOccupantEdit--fontAwesomeIconClass' + '#burialSiteContractOccupantEdit--fontAwesomeIconClass' ) as HTMLElement ).innerHTML = `` @@ -961,7 +961,7 @@ declare const exports: Record ;( modalElement.querySelector( - '#lotOccupancyOccupantEdit--occupantCommentTitle' + '#burialSiteContractOccupantEdit--occupantCommentTitle' ) as HTMLLabelElement ).textContent = occupantCommentTitle }) @@ -986,7 +986,7 @@ declare const exports: Record function doDelete(): void { cityssm.postJSON( - `${los.urlPrefix}/lotOccupancies/doDeleteLotOccupancyOccupant`, + `${los.urlPrefix}/contracts/doDeleteLotOccupancyOccupant`, { burialSiteContractId, lotOccupantIndex @@ -995,11 +995,11 @@ declare const exports: Record const responseJSON = rawResponseJSON as { success: boolean errorMessage?: string - lotOccupancyOccupants: LotOccupancyOccupant[] + burialSiteContractOccupants: LotOccupancyOccupant[] } if (responseJSON.success) { - lotOccupancyOccupants = responseJSON.lotOccupancyOccupants + burialSiteContractOccupants = responseJSON.burialSiteContractOccupants renderLotOccupancyOccupants() } else { bulmaJS.alert({ @@ -1025,12 +1025,12 @@ declare const exports: Record function renderLotOccupancyOccupants(): void { const occupantsContainer = document.querySelector( - '#container--lotOccupancyOccupants' + '#container--burialSiteContractOccupants' ) as HTMLElement cityssm.clearElement(occupantsContainer) - if (lotOccupancyOccupants.length === 0) { + if (burialSiteContractOccupants.length === 0) { // eslint-disable-next-line no-unsanitized/property occupantsContainer.innerHTML = `

There are no ${los.escapedAliases.occupants} associated with this record.

@@ -1052,63 +1052,63 @@ declare const exports: Record ` - for (const lotOccupancyOccupant of lotOccupancyOccupants) { + for (const burialSiteContractOccupant of burialSiteContractOccupants) { const tableRowElement = document.createElement('tr') tableRowElement.dataset.lotOccupantIndex = - lotOccupancyOccupant.lotOccupantIndex?.toString() + burialSiteContractOccupant.lotOccupantIndex?.toString() // eslint-disable-next-line no-unsanitized/property tableRowElement.innerHTML = ` ${cityssm.escapeHTML( - (lotOccupancyOccupant.occupantName ?? '') === '' && - (lotOccupancyOccupant.occupantFamilyName ?? '') === '' + (burialSiteContractOccupant.occupantName ?? '') === '' && + (burialSiteContractOccupant.occupantFamilyName ?? '') === '' ? '(No Name)' - : `${lotOccupancyOccupant.occupantName} ${lotOccupancyOccupant.occupantFamilyName}` + : `${burialSiteContractOccupant.occupantName} ${burialSiteContractOccupant.occupantFamilyName}` )}
- - ${cityssm.escapeHTML(lotOccupancyOccupant.lotOccupantType ?? '')} + + ${cityssm.escapeHTML(burialSiteContractOccupant.lotOccupantType ?? '')} ${ - (lotOccupancyOccupant.occupantAddress1 ?? '') === '' + (burialSiteContractOccupant.occupantAddress1 ?? '') === '' ? '' - : `${cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress1 ?? '')}
` + : `${cityssm.escapeHTML(burialSiteContractOccupant.occupantAddress1 ?? '')}
` } ${ - (lotOccupancyOccupant.occupantAddress2 ?? '') === '' + (burialSiteContractOccupant.occupantAddress2 ?? '') === '' ? '' - : `${cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress2 ?? '')}
` + : `${cityssm.escapeHTML(burialSiteContractOccupant.occupantAddress2 ?? '')}
` } ${ - (lotOccupancyOccupant.occupantCity ?? '') === '' + (burialSiteContractOccupant.occupantCity ?? '') === '' ? '' - : `${cityssm.escapeHTML(lotOccupancyOccupant.occupantCity ?? '')}, ` + : `${cityssm.escapeHTML(burialSiteContractOccupant.occupantCity ?? '')}, ` } - ${cityssm.escapeHTML(lotOccupancyOccupant.occupantProvince ?? '')}
- ${cityssm.escapeHTML(lotOccupancyOccupant.occupantPostalCode ?? '')} + ${cityssm.escapeHTML(burialSiteContractOccupant.occupantProvince ?? '')}
+ ${cityssm.escapeHTML(burialSiteContractOccupant.occupantPostalCode ?? '')} ${ - (lotOccupancyOccupant.occupantPhoneNumber ?? '') === '' + (burialSiteContractOccupant.occupantPhoneNumber ?? '') === '' ? '' : `${cityssm.escapeHTML( - lotOccupancyOccupant.occupantPhoneNumber ?? '' + burialSiteContractOccupant.occupantPhoneNumber ?? '' )}
` } ${ - (lotOccupancyOccupant.occupantEmailAddress ?? '') === '' + (burialSiteContractOccupant.occupantEmailAddress ?? '') === '' ? '' : cityssm.escapeHTML( - lotOccupancyOccupant.occupantEmailAddress ?? '' + burialSiteContractOccupant.occupantEmailAddress ?? '' ) } - ${cityssm.escapeHTML(lotOccupancyOccupant.occupantComment ?? '')} + ${cityssm.escapeHTML(burialSiteContractOccupant.occupantComment ?? '')}
@@ -1138,7 +1138,7 @@ declare const exports: Record if (isCreate) { const lotOccupantTypeIdElement = document.querySelector( - '#lotOccupancy--lotOccupantTypeId' + '#burialSiteContract--lotOccupantTypeId' ) as HTMLSelectElement lotOccupantTypeIdElement.addEventListener('change', () => { @@ -1159,7 +1159,7 @@ declare const exports: Record ;( formElement.querySelector( - '#lotOccupancy--occupantCommentTitle' + '#burialSiteContract--occupantCommentTitle' ) as HTMLElement ).textContent = occupantCommentTitle }) @@ -1181,17 +1181,17 @@ declare const exports: Record formOrObject: HTMLFormElement | LotOccupancyOccupant ): void { cityssm.postJSON( - `${los.urlPrefix}/lotOccupancies/doAddLotOccupancyOccupant`, + `${los.urlPrefix}/contracts/doAddLotOccupancyOccupant`, formOrObject, (rawResponseJSON) => { const responseJSON = rawResponseJSON as { success: boolean errorMessage?: string - lotOccupancyOccupants: LotOccupancyOccupant[] + burialSiteContractOccupants: LotOccupancyOccupant[] } if (responseJSON.success) { - lotOccupancyOccupants = responseJSON.lotOccupancyOccupants + burialSiteContractOccupants = responseJSON.burialSiteContractOccupants addCloseModalFunction() renderLotOccupancyOccupants() } else { @@ -1226,7 +1226,7 @@ declare const exports: Record panelBlockElement .closest('.modal') ?.querySelector( - '#lotOccupancyOccupantCopy--lotOccupantTypeId' + '#burialSiteContractOccupantCopy--lotOccupantTypeId' ) as HTMLSelectElement ).value @@ -1249,7 +1249,7 @@ declare const exports: Record if ( ( searchFormElement.querySelector( - '#lotOccupancyOccupantCopy--searchFilter' + '#burialSiteContractOccupantCopy--searchFilter' ) as HTMLInputElement ).value === '' ) { @@ -1265,7 +1265,7 @@ declare const exports: Record los.getLoadingParagraphHTML('Searching...') cityssm.postJSON( - `${los.urlPrefix}/lotOccupancies/doSearchPastOccupants`, + `${los.urlPrefix}/contracts/doSearchPastOccupants`, searchFormElement, (rawResponseJSON) => { const responseJSON = rawResponseJSON as { @@ -1321,21 +1321,21 @@ declare const exports: Record ) } - cityssm.openHtmlModal('lotOccupancy-addOccupant', { + cityssm.openHtmlModal('burialSiteContract-addOccupant', { onshow(modalElement) { los.populateAliases(modalElement) ;( modalElement.querySelector( - '#lotOccupancyOccupantAdd--burialSiteContractId' + '#burialSiteContractOccupantAdd--burialSiteContractId' ) as HTMLInputElement ).value = burialSiteContractId const lotOccupantTypeSelectElement = modalElement.querySelector( - '#lotOccupancyOccupantAdd--lotOccupantTypeId' + '#burialSiteContractOccupantAdd--lotOccupantTypeId' ) as HTMLSelectElement const lotOccupantTypeCopySelectElement = modalElement.querySelector( - '#lotOccupancyOccupantCopy--lotOccupantTypeId' + '#burialSiteContractOccupantCopy--lotOccupantTypeId' ) as HTMLSelectElement for (const lotOccupantType of exports.lotOccupantTypes as LotOccupantType[]) { @@ -1358,12 +1358,12 @@ declare const exports: Record ;( modalElement.querySelector( - '#lotOccupancyOccupantAdd--occupantCity' + '#burialSiteContractOccupantAdd--occupantCity' ) as HTMLInputElement ).value = exports.occupantCityDefault as string ;( modalElement.querySelector( - '#lotOccupancyOccupantAdd--occupantProvince' + '#burialSiteContractOccupantAdd--occupantProvince' ) as HTMLInputElement ).value = exports.occupantProvinceDefault as string }, @@ -1372,7 +1372,7 @@ declare const exports: Record bulmaJS.init(modalElement) const lotOccupantTypeIdElement = modalElement.querySelector( - '#lotOccupancyOccupantAdd--lotOccupantTypeId' + '#burialSiteContractOccupantAdd--lotOccupantTypeId' ) as HTMLSelectElement lotOccupantTypeIdElement.focus() @@ -1384,7 +1384,7 @@ declare const exports: Record ;( modalElement.querySelector( - '#lotOccupancyOccupantAdd--fontAwesomeIconClass' + '#burialSiteContractOccupantAdd--fontAwesomeIconClass' ) as HTMLElement ).innerHTML = `` @@ -1399,29 +1399,29 @@ declare const exports: Record ;( modalElement.querySelector( - '#lotOccupancyOccupantAdd--occupantCommentTitle' + '#burialSiteContractOccupantAdd--occupantCommentTitle' ) as HTMLElement ).textContent = occupantCommentTitle }) addFormElement = modalElement.querySelector( - '#form--lotOccupancyOccupantAdd' + '#form--burialSiteContractOccupantAdd' ) as HTMLFormElement addFormElement.addEventListener('submit', addOccupantFromForm) searchResultsElement = modalElement.querySelector( - '#lotOccupancyOccupantCopy--searchResults' + '#burialSiteContractOccupantCopy--searchResults' ) as HTMLElement searchFormElement = modalElement.querySelector( - '#form--lotOccupancyOccupantCopy' + '#form--burialSiteContractOccupantCopy' ) as HTMLFormElement searchFormElement.addEventListener('submit', (formEvent) => { formEvent.preventDefault() }) ;( modalElement.querySelector( - '#lotOccupancyOccupantCopy--searchFilter' + '#burialSiteContractOccupantCopy--searchFilter' ) as HTMLInputElement ).addEventListener('change', searchOccupants) @@ -1444,9 +1444,9 @@ declare const exports: Record * Comments */ ;(() => { - let lotOccupancyComments = - exports.lotOccupancyComments as LotOccupancyComment[] - delete exports.lotOccupancyComments + let burialSiteContractComments = + exports.burialSiteContractComments as LotOccupancyComment[] + delete exports.burialSiteContractComments function openEditLotOccupancyComment(clickEvent: Event): void { const burialSiteContractCommentId = Number.parseInt( @@ -1455,7 +1455,7 @@ declare const exports: Record 10 ) - const lotOccupancyComment = lotOccupancyComments.find( + const burialSiteContractComment = burialSiteContractComments.find( (currentLotOccupancyComment) => { return ( currentLotOccupancyComment.burialSiteContractCommentId === @@ -1471,17 +1471,17 @@ declare const exports: Record submitEvent.preventDefault() cityssm.postJSON( - `${los.urlPrefix}/lotOccupancies/doUpdateLotOccupancyComment`, + `${los.urlPrefix}/contracts/doUpdateLotOccupancyComment`, editFormElement, (rawResponseJSON) => { const responseJSON = rawResponseJSON as { success: boolean errorMessage?: string - lotOccupancyComments?: LotOccupancyComment[] + burialSiteContractComments?: LotOccupancyComment[] } if (responseJSON.success) { - lotOccupancyComments = responseJSON.lotOccupancyComments ?? [] + burialSiteContractComments = responseJSON.burialSiteContractComments ?? [] editCloseModalFunction() renderLotOccupancyComments() } else { @@ -1495,45 +1495,45 @@ declare const exports: Record ) } - cityssm.openHtmlModal('lotOccupancy-editComment', { + cityssm.openHtmlModal('burialSiteContract-editComment', { onshow(modalElement) { los.populateAliases(modalElement) ;( modalElement.querySelector( - '#lotOccupancyCommentEdit--burialSiteContractId' + '#burialSiteContractCommentEdit--burialSiteContractId' ) as HTMLInputElement ).value = burialSiteContractId ;( modalElement.querySelector( - '#lotOccupancyCommentEdit--burialSiteContractCommentId' + '#burialSiteContractCommentEdit--burialSiteContractCommentId' ) as HTMLInputElement ).value = burialSiteContractCommentId.toString() ;( modalElement.querySelector( - '#lotOccupancyCommentEdit--lotOccupancyComment' + '#burialSiteContractCommentEdit--burialSiteContractComment' ) as HTMLInputElement - ).value = lotOccupancyComment.lotOccupancyComment ?? '' + ).value = burialSiteContractComment.burialSiteContractComment ?? '' - const lotOccupancyCommentDateStringElement = + const burialSiteContractCommentDateStringElement = modalElement.querySelector( - '#lotOccupancyCommentEdit--lotOccupancyCommentDateString' + '#burialSiteContractCommentEdit--burialSiteContractCommentDateString' ) as HTMLInputElement - lotOccupancyCommentDateStringElement.value = - lotOccupancyComment.lotOccupancyCommentDateString ?? '' + burialSiteContractCommentDateStringElement.value = + burialSiteContractComment.burialSiteContractCommentDateString ?? '' const currentDateString = cityssm.dateToString(new Date()) - lotOccupancyCommentDateStringElement.max = - lotOccupancyComment.lotOccupancyCommentDateString! <= + burialSiteContractCommentDateStringElement.max = + burialSiteContractComment.burialSiteContractCommentDateString! <= currentDateString ? currentDateString - : lotOccupancyComment.lotOccupancyCommentDateString ?? '' + : burialSiteContractComment.burialSiteContractCommentDateString ?? '' ;( modalElement.querySelector( - '#lotOccupancyCommentEdit--lotOccupancyCommentTimeString' + '#burialSiteContractCommentEdit--burialSiteContractCommentTimeString' ) as HTMLInputElement - ).value = lotOccupancyComment.lotOccupancyCommentTimeString ?? '' + ).value = burialSiteContractComment.burialSiteContractCommentTimeString ?? '' }, onshown(modalElement, closeModalFunction) { bulmaJS.toggleHtmlClipped() @@ -1541,7 +1541,7 @@ declare const exports: Record los.initializeDatePickers(modalElement) ;( modalElement.querySelector( - '#lotOccupancyCommentEdit--lotOccupancyComment' + '#burialSiteContractCommentEdit--burialSiteContractComment' ) as HTMLTextAreaElement ).focus() @@ -1568,7 +1568,7 @@ declare const exports: Record function doDelete(): void { cityssm.postJSON( - `${los.urlPrefix}/lotOccupancies/doDeleteLotOccupancyComment`, + `${los.urlPrefix}/contracts/doDeleteLotOccupancyComment`, { burialSiteContractId, burialSiteContractCommentId @@ -1577,11 +1577,11 @@ declare const exports: Record const responseJSON = rawResponseJSON as { success: boolean errorMessage?: string - lotOccupancyComments: LotOccupancyComment[] + burialSiteContractComments: LotOccupancyComment[] } if (responseJSON.success) { - lotOccupancyComments = responseJSON.lotOccupancyComments + burialSiteContractComments = responseJSON.burialSiteContractComments renderLotOccupancyComments() } else { bulmaJS.alert({ @@ -1607,10 +1607,10 @@ declare const exports: Record function renderLotOccupancyComments(): void { const containerElement = document.querySelector( - '#container--lotOccupancyComments' + '#container--burialSiteContractComments' ) as HTMLElement - if (lotOccupancyComments.length === 0) { + if (burialSiteContractComments.length === 0) { containerElement.innerHTML = `

There are no comments associated with this record.

` @@ -1627,23 +1627,23 @@ declare const exports: Record ` - for (const lotOccupancyComment of lotOccupancyComments) { + for (const burialSiteContractComment of burialSiteContractComments) { const tableRowElement = document.createElement('tr') tableRowElement.dataset.burialSiteContractCommentId = - lotOccupancyComment.burialSiteContractCommentId?.toString() + burialSiteContractComment.burialSiteContractCommentId?.toString() - tableRowElement.innerHTML = `${cityssm.escapeHTML(lotOccupancyComment.recordCreate_userName ?? '')} + tableRowElement.innerHTML = `${cityssm.escapeHTML(burialSiteContractComment.recordCreate_userName ?? '')} ${cityssm.escapeHTML( - lotOccupancyComment.lotOccupancyCommentDateString ?? '' + burialSiteContractComment.burialSiteContractCommentDateString ?? '' )} ${cityssm.escapeHTML( - lotOccupancyComment.lotOccupancyCommentTime === 0 + burialSiteContractComment.burialSiteContractCommentTime === 0 ? '' - : lotOccupancyComment.lotOccupancyCommentTimePeriodString ?? '' + : burialSiteContractComment.burialSiteContractCommentTimePeriodString ?? '' )} - ${cityssm.escapeHTML(lotOccupancyComment.lotOccupancyComment ?? '')} + ${cityssm.escapeHTML(burialSiteContractComment.burialSiteContractComment ?? '')}
- ${cityssm.escapeHTML(lotOccupancy.occupancyType ?? '')} + ${cityssm.escapeHTML(burialSiteContract.occupancyType ?? '')} ` - if (lotOccupancy.lotId) { + if (burialSiteContract.lotId) { rowElement.insertAdjacentHTML( 'beforeend', - `${cityssm.escapeHTML(lotOccupancy.lotName ?? '')}` + `${cityssm.escapeHTML(burialSiteContract.lotName ?? '')}` ) } else { // eslint-disable-next-line no-unsanitized/method @@ -817,39 +817,39 @@ declare const exports: Record rowElement.insertAdjacentHTML( 'beforeend', ` - ${lotOccupancy.contractStartDateString} + ${burialSiteContract.contractStartDateString} ${ - lotOccupancy.contractEndDate - ? lotOccupancy.contractEndDateString + burialSiteContract.contractEndDate + ? burialSiteContract.contractEndDateString : '(No End Date)' } ${ - lotOccupancy.lotOccupancyOccupants!.length === 0 + burialSiteContract.burialSiteContractOccupants!.length === 0 ? ` (No ${cityssm.escapeHTML( los.escapedAliases.Occupants )}) ` : cityssm.escapeHTML( - `${lotOccupancy.lotOccupancyOccupants![0].occupantName} + `${burialSiteContract.burialSiteContractOccupants![0].occupantName} ${ - lotOccupancy.lotOccupancyOccupants![0] + burialSiteContract.burialSiteContractOccupants![0] .occupantFamilyName }` ) + - (lotOccupancy.lotOccupancyOccupants!.length > 1 + (burialSiteContract.burialSiteContractOccupants!.length > 1 ? ` plus ${( - lotOccupancy.lotOccupancyOccupants!.length - 1 + burialSiteContract.burialSiteContractOccupants!.length - 1 ).toString()}` : '') }` ) rowElement - .querySelector('.button--addLotOccupancy') + .querySelector('.button--addBurialSiteContract') ?.addEventListener('click', doAddLotOccupancy) searchResultsContainerElement @@ -860,7 +860,7 @@ declare const exports: Record ) } - cityssm.openHtmlModal('workOrder-addLotOccupancy', { + cityssm.openHtmlModal('workOrder-addBurialSiteContract', { onshow(modalElement) { los.populateAliases(modalElement) @@ -869,16 +869,16 @@ declare const exports: Record ) as HTMLFormElement searchResultsContainerElement = modalElement.querySelector( - '#resultsContainer--lotOccupancyAdd' + '#resultsContainer--burialSiteContractAdd' ) as HTMLElement ;( modalElement.querySelector( - '#lotOccupancySearch--notWorkOrderId' + '#burialSiteContractSearch--notWorkOrderId' ) as HTMLInputElement ).value = workOrderId ;( modalElement.querySelector( - '#lotOccupancySearch--occupancyEffectiveDateString' + '#burialSiteContractSearch--occupancyEffectiveDateString' ) as HTMLInputElement ).value = ( document.querySelector( @@ -892,14 +892,14 @@ declare const exports: Record bulmaJS.toggleHtmlClipped() const occupantNameElement = modalElement.querySelector( - '#lotOccupancySearch--occupantName' + '#burialSiteContractSearch--occupantName' ) as HTMLInputElement occupantNameElement.addEventListener('change', doSearch) occupantNameElement.focus() ;( modalElement.querySelector( - '#lotOccupancySearch--lotName' + '#burialSiteContractSearch--lotName' ) as HTMLInputElement ).addEventListener('change', doSearch) @@ -909,7 +909,7 @@ declare const exports: Record bulmaJS.toggleHtmlClipped() ;( document.querySelector( - '#button--addLotOccupancy' + '#button--addBurialSiteContract' ) as HTMLButtonElement ).focus() } diff --git a/public/javascripts/workOrderMilestoneCalendar.ts b/public/javascripts/workOrderMilestoneCalendar.ts index 2221df9e..32ea76cf 100644 --- a/public/javascripts/workOrderMilestoneCalendar.ts +++ b/public/javascripts/workOrderMilestoneCalendar.ts @@ -77,10 +77,10 @@ declare const exports: Record panelBlockElement.classList.add('has-background-warning-light') } - let lotOccupancyHTML = '' + let burialSiteContractHTML = '' for (const lot of milestone.workOrderLots ?? []) { - lotOccupancyHTML += `
  • ` } - for (const lotOccupancy of milestone.workOrderLotOccupancies ?? []) { - for (const occupant of lotOccupancy.lotOccupancyOccupants ?? []) { - lotOccupancyHTML += `
  • @@ -138,9 +138,9 @@ declare const exports: Record ${cityssm.escapeHTML(milestone.workOrderDescription ?? '')}
  • ${ - lotOccupancyHTML === '' + burialSiteContractHTML === '' ? '' - : `
      ${lotOccupancyHTML}
    ` + : `
      ${burialSiteContractHTML}
    ` }
    ` ;(currentPanelElement as HTMLElement).append(panelBlockElement) } diff --git a/public/javascripts/workOrderSearch.ts b/public/javascripts/workOrderSearch.ts index 7b8b3bdd..bb4efa2d 100644 --- a/public/javascripts/workOrderSearch.ts +++ b/public/javascripts/workOrderSearch.ts @@ -66,7 +66,7 @@ declare const exports: Record } for (const occupancy of workOrder.workOrderLotOccupancies ?? []) { - for (const occupant of occupancy.lotOccupancyOccupants ?? []) { + for (const occupant of occupancy.burialSiteContractOccupants ?? []) { relatedHTML += `
  • (occupancyTypeField.occupancyTypeField === 'Funeral Date')).contractTypeFieldId, - lotOccupancyFieldValue + burialSiteContractFieldValue }, user); } if (occupancyType.occupancyType !== 'Cremation') { @@ -363,7 +363,7 @@ async function importFromMasterCSV() { await addOrUpdateLotOccupancyField({ burialSiteContractId: deceasedburialSiteContractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => (occupancyTypeField.occupancyTypeField === 'Container Type')).contractTypeFieldId, - lotOccupancyFieldValue: masterRow.CM_CONTAINER_TYPE + burialSiteContractFieldValue: masterRow.CM_CONTAINER_TYPE }, user); } if (masterRow.CM_COMMITTAL_TYPE !== '') { @@ -374,37 +374,37 @@ async function importFromMasterCSV() { await addOrUpdateLotOccupancyField({ burialSiteContractId: deceasedburialSiteContractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => (occupancyTypeField.occupancyTypeField === 'Committal Type')).contractTypeFieldId, - lotOccupancyFieldValue: commitalType + burialSiteContractFieldValue: commitalType }, user); } } if (masterRow.CM_REMARK1 !== '') { - await addLotOccupancyComment({ + await addBurialSiteContractComment({ burialSiteContractId: deceasedburialSiteContractId, - lotOccupancyCommentDateString: deceasedcontractStartDateString, - lotOccupancyCommentTimeString: '00:00', - lotOccupancyComment: masterRow.CM_REMARK1 + burialSiteContractCommentDateString: deceasedcontractStartDateString, + burialSiteContractCommentTimeString: '00:00', + burialSiteContractComment: masterRow.CM_REMARK1 }, user); } if (masterRow.CM_REMARK2 !== '') { - await addLotOccupancyComment({ + await addBurialSiteContractComment({ burialSiteContractId: deceasedburialSiteContractId, - lotOccupancyCommentDateString: deceasedcontractStartDateString, - lotOccupancyCommentTimeString: '00:00', - lotOccupancyComment: masterRow.CM_REMARK2 + burialSiteContractCommentDateString: deceasedcontractStartDateString, + burialSiteContractCommentTimeString: '00:00', + burialSiteContractComment: masterRow.CM_REMARK2 }, user); } if (masterRow.CM_WORK_ORDER.trim() !== '') { - await addLotOccupancyComment({ + await addBurialSiteContractComment({ burialSiteContractId: deceasedburialSiteContractId, - lotOccupancyCommentDateString: deceasedcontractStartDateString, - lotOccupancyCommentTimeString: '00:00', - lotOccupancyComment: `Imported Contract #${masterRow.CM_WORK_ORDER}` + burialSiteContractCommentDateString: deceasedcontractStartDateString, + burialSiteContractCommentTimeString: '00:00', + burialSiteContractComment: `Imported Contract #${masterRow.CM_WORK_ORDER}` }, user); } await updateLotStatus(lotId ?? '', importIds.takenburialSiteStatusId, user); if (masterRow.CM_PRENEED_OWNER !== '') { - await addLotOccupancyOccupant({ + await addBurialSiteContractOccupant({ burialSiteContractId: deceasedburialSiteContractId, lotOccupantTypeId: importIds.preneedOwnerLotOccupantTypeId, occupantName: masterRow.CM_PRENEED_OWNER, @@ -504,13 +504,13 @@ async function importFromPrepaidCSV() { possibleLotOccupancies.lotOccupancies[0].burialSiteContractId; } } - burialSiteContractId ||= await addLotOccupancy({ + burialSiteContractId ||= await addBurialSiteContract({ lotId: lot ? lot.lotId : '', contractTypeId: importIds.preneedOccupancyType.contractTypeId, contractStartDateString, contractEndDateString: '' }, user); - await addLotOccupancyOccupant({ + await addBurialSiteContractOccupant({ burialSiteContractId, lotOccupantTypeId: importIds.preneedOwnerLotOccupantTypeId, occupantName: prepaidRow.CMPP_PREPAID_FOR_NAME, @@ -524,7 +524,7 @@ async function importFromPrepaidCSV() { occupantEmailAddress: '' }, user); if (prepaidRow.CMPP_ARRANGED_BY_NAME) { - await addLotOccupancyOccupant({ + await addBurialSiteContractOccupant({ burialSiteContractId, lotOccupantTypeId: importIds.purchaserLotOccupantTypeId, occupantName: prepaidRow.CMPP_ARRANGED_BY_NAME, @@ -539,7 +539,7 @@ async function importFromPrepaidCSV() { }, user); } if (prepaidRow.CMPP_FEE_GRAV_SD !== '0.0') { - await addLotOccupancyFee({ + await addBurialSiteContractFee({ burialSiteContractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_GRAV_SD'), quantity: 1, @@ -548,7 +548,7 @@ async function importFromPrepaidCSV() { }, user); } if (prepaidRow.CMPP_FEE_GRAV_DD !== '0.0') { - await addLotOccupancyFee({ + await addBurialSiteContractFee({ burialSiteContractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_GRAV_DD'), quantity: 1, @@ -557,7 +557,7 @@ async function importFromPrepaidCSV() { }, user); } if (prepaidRow.CMPP_FEE_CHAP_SD !== '0.0') { - await addLotOccupancyFee({ + await addBurialSiteContractFee({ burialSiteContractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_CHAP_SD'), quantity: 1, @@ -566,7 +566,7 @@ async function importFromPrepaidCSV() { }, user); } if (prepaidRow.CMPP_FEE_CHAP_DD !== '0.0') { - await addLotOccupancyFee({ + await addBurialSiteContractFee({ burialSiteContractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_CHAP_DD'), quantity: 1, @@ -575,7 +575,7 @@ async function importFromPrepaidCSV() { }, user); } if (prepaidRow.CMPP_FEE_ENTOMBMENT !== '0.0') { - await addLotOccupancyFee({ + await addBurialSiteContractFee({ burialSiteContractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_ENTOMBMENT'), quantity: 1, @@ -584,7 +584,7 @@ async function importFromPrepaidCSV() { }, user); } if (prepaidRow.CMPP_FEE_CREM !== '0.0') { - await addLotOccupancyFee({ + await addBurialSiteContractFee({ burialSiteContractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_CREM'), quantity: 1, @@ -593,7 +593,7 @@ async function importFromPrepaidCSV() { }, user); } if (prepaidRow.CMPP_FEE_NICHE !== '0.0') { - await addLotOccupancyFee({ + await addBurialSiteContractFee({ burialSiteContractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_NICHE'), quantity: 1, @@ -603,7 +603,7 @@ async function importFromPrepaidCSV() { } if (prepaidRow.CMPP_FEE_DISINTERMENT !== '0.0' && prepaidRow.CMPP_FEE_DISINTERMENT !== '20202.02') { - await addLotOccupancyFee({ + await addBurialSiteContractFee({ burialSiteContractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_DISINTERMENT'), quantity: 1, @@ -631,7 +631,7 @@ async function importFromPrepaidCSV() { Number.parseFloat(prepaidRow.CMPP_GST_DISINTERMENT === '20202.02' ? '0' : prepaidRow.CMPP_GST_DISINTERMENT); - await addLotOccupancyTransaction({ + await addBurialSiteContractTransaction({ burialSiteContractId, externalReceiptNumber: '', transactionAmount, @@ -639,17 +639,17 @@ async function importFromPrepaidCSV() { transactionNote: `Order Number: ${prepaidRow.CMPP_ORDER_NO}` }, user); if (prepaidRow.CMPP_REMARK1) { - await addLotOccupancyComment({ + await addBurialSiteContractComment({ burialSiteContractId, - lotOccupancyCommentDateString: contractStartDateString, - lotOccupancyComment: prepaidRow.CMPP_REMARK1 + burialSiteContractCommentDateString: contractStartDateString, + burialSiteContractComment: prepaidRow.CMPP_REMARK1 }, user); } if (prepaidRow.CMPP_REMARK2) { - await addLotOccupancyComment({ + await addBurialSiteContractComment({ burialSiteContractId, - lotOccupancyCommentDateString: contractStartDateString, - lotOccupancyComment: prepaidRow.CMPP_REMARK2 + burialSiteContractCommentDateString: contractStartDateString, + burialSiteContractComment: prepaidRow.CMPP_REMARK2 }, user); } } @@ -747,13 +747,13 @@ async function importFromWorkOrderCSV() { const occupancyType = lot ? importIds.deceasedOccupancyType : importIds.cremationOccupancyType; - const burialSiteContractId = await addLotOccupancy({ + const burialSiteContractId = await addBurialSiteContract({ lotId: lot ? lot.lotId : '', contractTypeId: occupancyType.contractTypeId, contractStartDateString, contractEndDateString: '' }, user); - await addLotOccupancyOccupant({ + await addBurialSiteContractOccupant({ burialSiteContractId, lotOccupantTypeId: importIds.deceasedLotOccupantTypeId, occupantName: workOrderRow.WO_DECEASED_NAME, @@ -767,25 +767,25 @@ async function importFromWorkOrderCSV() { occupantEmailAddress: '' }, user); if (workOrderRow.WO_DEATH_YR !== '') { - const lotOccupancyFieldValue = formatDateString(workOrderRow.WO_DEATH_YR, workOrderRow.WO_DEATH_MON, workOrderRow.WO_DEATH_DAY); + const burialSiteContractFieldValue = formatDateString(workOrderRow.WO_DEATH_YR, workOrderRow.WO_DEATH_MON, workOrderRow.WO_DEATH_DAY); await addOrUpdateLotOccupancyField({ burialSiteContractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Date').contractTypeFieldId, - lotOccupancyFieldValue + burialSiteContractFieldValue }, user); } if (workOrderRow.WO_DEATH_PLACE !== '') { await addOrUpdateLotOccupancyField({ burialSiteContractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Place').contractTypeFieldId, - lotOccupancyFieldValue: workOrderRow.WO_DEATH_PLACE + burialSiteContractFieldValue: workOrderRow.WO_DEATH_PLACE }, user); } if (workOrderRow.WO_AGE !== '') { await addOrUpdateLotOccupancyField({ burialSiteContractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Age').contractTypeFieldId, - lotOccupancyFieldValue: workOrderRow.WO_AGE + burialSiteContractFieldValue: workOrderRow.WO_AGE }, user); } if (workOrderRow.WO_PERIOD !== '') { @@ -793,12 +793,12 @@ async function importFromWorkOrderCSV() { await addOrUpdateLotOccupancyField({ burialSiteContractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => (occupancyTypeField.occupancyTypeField === 'Death Age Period')).contractTypeFieldId, - lotOccupancyFieldValue: period + burialSiteContractFieldValue: period }, user); } if (workOrderRow.WO_FUNERAL_HOME !== '') { const funeralHomeOccupant = importData.getFuneralHomeLotOccupancyOccupantData(workOrderRow.WO_FUNERAL_HOME); - await addLotOccupancyOccupant({ + await addBurialSiteContractOccupant({ burialSiteContractId, lotOccupantTypeId: funeralHomeOccupant.lotOccupantTypeId, occupantName: funeralHomeOccupant.occupantName, @@ -818,18 +818,18 @@ async function importFromWorkOrderCSV() { contractTypeFieldId: allContractTypeFields.find((occupancyTypeField) => { return occupancyTypeField.occupancyTypeField === "Funeral Home"; }).contractTypeFieldId, - lotOccupancyFieldValue: workOrderRow.WO_FUNERAL_HOME + burialSiteContractFieldValue: workOrderRow.WO_FUNERAL_HOME }, user ); */ } if (workOrderRow.WO_FUNERAL_YR !== '') { - const lotOccupancyFieldValue = formatDateString(workOrderRow.WO_FUNERAL_YR, workOrderRow.WO_FUNERAL_MON, workOrderRow.WO_FUNERAL_DAY); + const burialSiteContractFieldValue = formatDateString(workOrderRow.WO_FUNERAL_YR, workOrderRow.WO_FUNERAL_MON, workOrderRow.WO_FUNERAL_DAY); await addOrUpdateLotOccupancyField({ burialSiteContractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Funeral Date').contractTypeFieldId, - lotOccupancyFieldValue + burialSiteContractFieldValue }, user); } if (occupancyType.occupancyType !== 'Cremation') { @@ -837,7 +837,7 @@ async function importFromWorkOrderCSV() { await addOrUpdateLotOccupancyField({ burialSiteContractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => (occupancyTypeField.occupancyTypeField === 'Container Type')).contractTypeFieldId, - lotOccupancyFieldValue: workOrderRow.WO_CONTAINER_TYPE + burialSiteContractFieldValue: workOrderRow.WO_CONTAINER_TYPE }, user); } if (workOrderRow.WO_COMMITTAL_TYPE !== '') { @@ -848,7 +848,7 @@ async function importFromWorkOrderCSV() { await addOrUpdateLotOccupancyField({ burialSiteContractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => (occupancyTypeField.occupancyTypeField === 'Committal Type')).contractTypeFieldId, - lotOccupancyFieldValue: commitalType + burialSiteContractFieldValue: commitalType }, user); } } diff --git a/temp/legacy.importFromCSV.ts b/temp/legacy.importFromCSV.ts index b3df6f00..6df3b143 100644 --- a/temp/legacy.importFromCSV.ts +++ b/temp/legacy.importFromCSV.ts @@ -11,11 +11,11 @@ import papa from 'papaparse' import { sunriseDB as databasePath } from '../data/databasePaths.js' import addLot from '../database/addLot.js' -import addLotOccupancy from '../database/addLotOccupancy.js' -import addLotOccupancyComment from '../database/addLotOccupancyComment.js' -import addLotOccupancyFee from '../database/addLotOccupancyFee.js' -import addLotOccupancyOccupant from '../database/addLotOccupancyOccupant.js' -import addLotOccupancyTransaction from '../database/addLotOccupancyTransaction.js' +import addBurialSiteContract from '../database/addBurialSiteContract.js' +import addBurialSiteContractComment from '../database/addBurialSiteContractComment.js' +import addBurialSiteContractFee from '../database/addBurialSiteContractFee.js' +import addBurialSiteContractOccupant from '../database/addBurialSiteContractOccupant.js' +import addBurialSiteContractTransaction from '../database/addBurialSiteContractTransaction.js' import addMap from '../database/addMap.js' import addOrUpdateLotOccupancyField from '../database/addOrUpdateLotOccupancyField.js' import addWorkOrder from '../database/addWorkOrder.js' @@ -24,7 +24,7 @@ import addWorkOrderLotOccupancy from '../database/addWorkOrderLotOccupancy.js' import addWorkOrderMilestone from '../database/addWorkOrderMilestone.js' import closeWorkOrder from '../database/closeWorkOrder.js' import getLot, { getLotByLotName } from '../database/getLot.js' -import getBurialSiteContracts from '../database/getLotOccupancies.js' +import getBurialSiteContracts from '../database/getBurialSiteContracts.js' import getMapFromDatabase from '../database/getMap.js' import getWorkOrder, { getWorkOrderByWorkOrderNumber @@ -443,7 +443,7 @@ async function importFromMasterCSV(): Promise { preneedcontractStartDateString = '0001-01-01' } - preneedburialSiteContractId = await addLotOccupancy( + preneedburialSiteContractId = await addBurialSiteContract( { contractTypeId: importIds.preneedOccupancyType.contractTypeId, lotId: lotId ?? '', @@ -457,7 +457,7 @@ async function importFromMasterCSV(): Promise { const occupantPostalCode = `${masterRow.CM_POST1} ${masterRow.CM_POST2}`.trim() - await addLotOccupancyOccupant( + await addBurialSiteContractOccupant( { burialSiteContractId: preneedburialSiteContractId, lotOccupantTypeId: importIds.preneedOwnerLotOccupantTypeId, @@ -475,36 +475,36 @@ async function importFromMasterCSV(): Promise { ) if (masterRow.CM_REMARK1 !== '') { - await addLotOccupancyComment( + await addBurialSiteContractComment( { burialSiteContractId: preneedburialSiteContractId, - lotOccupancyCommentDateString: preneedcontractStartDateString, - lotOccupancyCommentTimeString: '00:00', - lotOccupancyComment: masterRow.CM_REMARK1 + burialSiteContractCommentDateString: preneedcontractStartDateString, + burialSiteContractCommentTimeString: '00:00', + burialSiteContractComment: masterRow.CM_REMARK1 }, user ) } if (masterRow.CM_REMARK2 !== '') { - await addLotOccupancyComment( + await addBurialSiteContractComment( { burialSiteContractId: preneedburialSiteContractId, - lotOccupancyCommentDateString: preneedcontractStartDateString, - lotOccupancyCommentTimeString: '00:00', - lotOccupancyComment: masterRow.CM_REMARK2 + burialSiteContractCommentDateString: preneedcontractStartDateString, + burialSiteContractCommentTimeString: '00:00', + burialSiteContractComment: masterRow.CM_REMARK2 }, user ) } if (masterRow.CM_WORK_ORDER.trim() !== '') { - await addLotOccupancyComment( + await addBurialSiteContractComment( { burialSiteContractId: preneedburialSiteContractId, - lotOccupancyCommentDateString: preneedcontractStartDateString, - lotOccupancyCommentTimeString: '00:00', - lotOccupancyComment: `Imported Contract #${masterRow.CM_WORK_ORDER}` + burialSiteContractCommentDateString: preneedcontractStartDateString, + burialSiteContractCommentTimeString: '00:00', + burialSiteContractComment: `Imported Contract #${masterRow.CM_WORK_ORDER}` }, user ) @@ -557,7 +557,7 @@ async function importFromMasterCSV(): Promise { ? importIds.deceasedOccupancyType : importIds.cremationOccupancyType - deceasedburialSiteContractId = await addLotOccupancy( + deceasedburialSiteContractId = await addBurialSiteContract( { contractTypeId: occupancyType.contractTypeId, lotId: lotId ?? '', @@ -571,7 +571,7 @@ async function importFromMasterCSV(): Promise { const deceasedPostalCode = `${masterRow.CM_POST1} ${masterRow.CM_POST2}`.trim() - await addLotOccupancyOccupant( + await addBurialSiteContractOccupant( { burialSiteContractId: deceasedburialSiteContractId, lotOccupantTypeId: importIds.deceasedLotOccupantTypeId, @@ -589,7 +589,7 @@ async function importFromMasterCSV(): Promise { ) if (masterRow.CM_DEATH_YR !== '') { - const lotOccupancyFieldValue = formatDateString( + const burialSiteContractFieldValue = formatDateString( masterRow.CM_DEATH_YR, masterRow.CM_DEATH_MON, masterRow.CM_DEATH_DAY @@ -601,7 +601,7 @@ async function importFromMasterCSV(): Promise { contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Date' )!.contractTypeFieldId!, - lotOccupancyFieldValue + burialSiteContractFieldValue }, user ) @@ -614,7 +614,7 @@ async function importFromMasterCSV(): Promise { contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Age' )!.contractTypeFieldId!, - lotOccupancyFieldValue: masterRow.CM_AGE + burialSiteContractFieldValue: masterRow.CM_AGE }, user ) @@ -631,7 +631,7 @@ async function importFromMasterCSV(): Promise { occupancyTypeField.occupancyTypeField === 'Death Age Period' ) )!.contractTypeFieldId!, - lotOccupancyFieldValue: period + burialSiteContractFieldValue: period }, user ) @@ -643,7 +643,7 @@ async function importFromMasterCSV(): Promise { masterRow.CM_FUNERAL_HOME ) - await addLotOccupancyOccupant( + await addBurialSiteContractOccupant( { burialSiteContractId: deceasedburialSiteContractId, lotOccupantTypeId: funeralHomeOccupant.lotOccupantTypeId ?? '', @@ -669,7 +669,7 @@ async function importFromMasterCSV(): Promise { return occupancyTypeField.occupancyTypeField === "Funeral Home"; } ).contractTypeFieldId, - lotOccupancyFieldValue: masterRow.CM_FUNERAL_HOME + burialSiteContractFieldValue: masterRow.CM_FUNERAL_HOME }, user ); @@ -677,7 +677,7 @@ async function importFromMasterCSV(): Promise { } if (masterRow.CM_FUNERAL_YR !== '') { - const lotOccupancyFieldValue = formatDateString( + const burialSiteContractFieldValue = formatDateString( masterRow.CM_FUNERAL_YR, masterRow.CM_FUNERAL_MON, masterRow.CM_FUNERAL_DAY @@ -691,7 +691,7 @@ async function importFromMasterCSV(): Promise { occupancyTypeField.occupancyTypeField === 'Funeral Date' ) )!.contractTypeFieldId!, - lotOccupancyFieldValue + burialSiteContractFieldValue }, user ) @@ -707,7 +707,7 @@ async function importFromMasterCSV(): Promise { occupancyTypeField.occupancyTypeField === 'Container Type' ) )!.contractTypeFieldId!, - lotOccupancyFieldValue: masterRow.CM_CONTAINER_TYPE + burialSiteContractFieldValue: masterRow.CM_CONTAINER_TYPE }, user ) @@ -728,7 +728,7 @@ async function importFromMasterCSV(): Promise { occupancyTypeField.occupancyTypeField === 'Committal Type' ) )!.contractTypeFieldId!, - lotOccupancyFieldValue: commitalType + burialSiteContractFieldValue: commitalType }, user ) @@ -736,36 +736,36 @@ async function importFromMasterCSV(): Promise { } if (masterRow.CM_REMARK1 !== '') { - await addLotOccupancyComment( + await addBurialSiteContractComment( { burialSiteContractId: deceasedburialSiteContractId, - lotOccupancyCommentDateString: deceasedcontractStartDateString, - lotOccupancyCommentTimeString: '00:00', - lotOccupancyComment: masterRow.CM_REMARK1 + burialSiteContractCommentDateString: deceasedcontractStartDateString, + burialSiteContractCommentTimeString: '00:00', + burialSiteContractComment: masterRow.CM_REMARK1 }, user ) } if (masterRow.CM_REMARK2 !== '') { - await addLotOccupancyComment( + await addBurialSiteContractComment( { burialSiteContractId: deceasedburialSiteContractId, - lotOccupancyCommentDateString: deceasedcontractStartDateString, - lotOccupancyCommentTimeString: '00:00', - lotOccupancyComment: masterRow.CM_REMARK2 + burialSiteContractCommentDateString: deceasedcontractStartDateString, + burialSiteContractCommentTimeString: '00:00', + burialSiteContractComment: masterRow.CM_REMARK2 }, user ) } if (masterRow.CM_WORK_ORDER.trim() !== '') { - await addLotOccupancyComment( + await addBurialSiteContractComment( { burialSiteContractId: deceasedburialSiteContractId, - lotOccupancyCommentDateString: deceasedcontractStartDateString, - lotOccupancyCommentTimeString: '00:00', - lotOccupancyComment: `Imported Contract #${masterRow.CM_WORK_ORDER}` + burialSiteContractCommentDateString: deceasedcontractStartDateString, + burialSiteContractCommentTimeString: '00:00', + burialSiteContractComment: `Imported Contract #${masterRow.CM_WORK_ORDER}` }, user ) @@ -774,7 +774,7 @@ async function importFromMasterCSV(): Promise { await updateLotStatus(lotId ?? '', importIds.takenburialSiteStatusId, user) if (masterRow.CM_PRENEED_OWNER !== '') { - await addLotOccupancyOccupant( + await addBurialSiteContractOccupant( { burialSiteContractId: deceasedburialSiteContractId, lotOccupantTypeId: importIds.preneedOwnerLotOccupantTypeId, @@ -908,7 +908,7 @@ async function importFromPrepaidCSV(): Promise { } } - burialSiteContractId ||= await addLotOccupancy( + burialSiteContractId ||= await addBurialSiteContract( { lotId: lot ? lot.lotId : '', contractTypeId: importIds.preneedOccupancyType.contractTypeId, @@ -918,7 +918,7 @@ async function importFromPrepaidCSV(): Promise { user ); - await addLotOccupancyOccupant( + await addBurialSiteContractOccupant( { burialSiteContractId, lotOccupantTypeId: importIds.preneedOwnerLotOccupantTypeId, @@ -936,7 +936,7 @@ async function importFromPrepaidCSV(): Promise { ) if (prepaidRow.CMPP_ARRANGED_BY_NAME) { - await addLotOccupancyOccupant( + await addBurialSiteContractOccupant( { burialSiteContractId, lotOccupantTypeId: importIds.purchaserLotOccupantTypeId, @@ -955,7 +955,7 @@ async function importFromPrepaidCSV(): Promise { } if (prepaidRow.CMPP_FEE_GRAV_SD !== '0.0') { - await addLotOccupancyFee( + await addBurialSiteContractFee( { burialSiteContractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_GRAV_SD'), @@ -968,7 +968,7 @@ async function importFromPrepaidCSV(): Promise { } if (prepaidRow.CMPP_FEE_GRAV_DD !== '0.0') { - await addLotOccupancyFee( + await addBurialSiteContractFee( { burialSiteContractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_GRAV_DD'), @@ -981,7 +981,7 @@ async function importFromPrepaidCSV(): Promise { } if (prepaidRow.CMPP_FEE_CHAP_SD !== '0.0') { - await addLotOccupancyFee( + await addBurialSiteContractFee( { burialSiteContractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_CHAP_SD'), @@ -994,7 +994,7 @@ async function importFromPrepaidCSV(): Promise { } if (prepaidRow.CMPP_FEE_CHAP_DD !== '0.0') { - await addLotOccupancyFee( + await addBurialSiteContractFee( { burialSiteContractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_CHAP_DD'), @@ -1007,7 +1007,7 @@ async function importFromPrepaidCSV(): Promise { } if (prepaidRow.CMPP_FEE_ENTOMBMENT !== '0.0') { - await addLotOccupancyFee( + await addBurialSiteContractFee( { burialSiteContractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_ENTOMBMENT'), @@ -1020,7 +1020,7 @@ async function importFromPrepaidCSV(): Promise { } if (prepaidRow.CMPP_FEE_CREM !== '0.0') { - await addLotOccupancyFee( + await addBurialSiteContractFee( { burialSiteContractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_CREM'), @@ -1033,7 +1033,7 @@ async function importFromPrepaidCSV(): Promise { } if (prepaidRow.CMPP_FEE_NICHE !== '0.0') { - await addLotOccupancyFee( + await addBurialSiteContractFee( { burialSiteContractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_NICHE'), @@ -1049,7 +1049,7 @@ async function importFromPrepaidCSV(): Promise { prepaidRow.CMPP_FEE_DISINTERMENT !== '0.0' && prepaidRow.CMPP_FEE_DISINTERMENT !== '20202.02' ) { - await addLotOccupancyFee( + await addBurialSiteContractFee( { burialSiteContractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_DISINTERMENT'), @@ -1087,7 +1087,7 @@ async function importFromPrepaidCSV(): Promise { : prepaidRow.CMPP_GST_DISINTERMENT ) - await addLotOccupancyTransaction( + await addBurialSiteContractTransaction( { burialSiteContractId, externalReceiptNumber: '', @@ -1099,22 +1099,22 @@ async function importFromPrepaidCSV(): Promise { ) if (prepaidRow.CMPP_REMARK1) { - await addLotOccupancyComment( + await addBurialSiteContractComment( { burialSiteContractId, - lotOccupancyCommentDateString: contractStartDateString, - lotOccupancyComment: prepaidRow.CMPP_REMARK1 + burialSiteContractCommentDateString: contractStartDateString, + burialSiteContractComment: prepaidRow.CMPP_REMARK1 }, user ) } if (prepaidRow.CMPP_REMARK2) { - await addLotOccupancyComment( + await addBurialSiteContractComment( { burialSiteContractId, - lotOccupancyCommentDateString: contractStartDateString, - lotOccupancyComment: prepaidRow.CMPP_REMARK2 + burialSiteContractCommentDateString: contractStartDateString, + burialSiteContractComment: prepaidRow.CMPP_REMARK2 }, user ) @@ -1255,7 +1255,7 @@ async function importFromWorkOrderCSV(): Promise { ? importIds.deceasedOccupancyType : importIds.cremationOccupancyType - const burialSiteContractId = await addLotOccupancy( + const burialSiteContractId = await addBurialSiteContract( { lotId: lot ? lot.lotId : '', contractTypeId: occupancyType.contractTypeId, @@ -1265,7 +1265,7 @@ async function importFromWorkOrderCSV(): Promise { user ) - await addLotOccupancyOccupant( + await addBurialSiteContractOccupant( { burialSiteContractId, lotOccupantTypeId: importIds.deceasedLotOccupantTypeId, @@ -1283,7 +1283,7 @@ async function importFromWorkOrderCSV(): Promise { ) if (workOrderRow.WO_DEATH_YR !== '') { - const lotOccupancyFieldValue = formatDateString( + const burialSiteContractFieldValue = formatDateString( workOrderRow.WO_DEATH_YR, workOrderRow.WO_DEATH_MON, workOrderRow.WO_DEATH_DAY @@ -1295,7 +1295,7 @@ async function importFromWorkOrderCSV(): Promise { contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Date' )!.contractTypeFieldId!, - lotOccupancyFieldValue + burialSiteContractFieldValue }, user ) @@ -1308,7 +1308,7 @@ async function importFromWorkOrderCSV(): Promise { contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Place' )!.contractTypeFieldId!, - lotOccupancyFieldValue: workOrderRow.WO_DEATH_PLACE + burialSiteContractFieldValue: workOrderRow.WO_DEATH_PLACE }, user ) @@ -1321,7 +1321,7 @@ async function importFromWorkOrderCSV(): Promise { contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Age' )!.contractTypeFieldId!, - lotOccupancyFieldValue: workOrderRow.WO_AGE + burialSiteContractFieldValue: workOrderRow.WO_AGE }, user ) @@ -1338,7 +1338,7 @@ async function importFromWorkOrderCSV(): Promise { occupancyTypeField.occupancyTypeField === 'Death Age Period' ) )!.contractTypeFieldId!, - lotOccupancyFieldValue: period + burialSiteContractFieldValue: period }, user ) @@ -1350,7 +1350,7 @@ async function importFromWorkOrderCSV(): Promise { workOrderRow.WO_FUNERAL_HOME ) - await addLotOccupancyOccupant( + await addBurialSiteContractOccupant( { burialSiteContractId, lotOccupantTypeId: funeralHomeOccupant.lotOccupantTypeId!, @@ -1374,7 +1374,7 @@ async function importFromWorkOrderCSV(): Promise { contractTypeFieldId: allContractTypeFields.find((occupancyTypeField) => { return occupancyTypeField.occupancyTypeField === "Funeral Home"; }).contractTypeFieldId, - lotOccupancyFieldValue: workOrderRow.WO_FUNERAL_HOME + burialSiteContractFieldValue: workOrderRow.WO_FUNERAL_HOME }, user ); @@ -1382,7 +1382,7 @@ async function importFromWorkOrderCSV(): Promise { } if (workOrderRow.WO_FUNERAL_YR !== '') { - const lotOccupancyFieldValue = formatDateString( + const burialSiteContractFieldValue = formatDateString( workOrderRow.WO_FUNERAL_YR, workOrderRow.WO_FUNERAL_MON, workOrderRow.WO_FUNERAL_DAY @@ -1394,7 +1394,7 @@ async function importFromWorkOrderCSV(): Promise { contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Funeral Date' )!.contractTypeFieldId!, - lotOccupancyFieldValue + burialSiteContractFieldValue }, user ) @@ -1410,7 +1410,7 @@ async function importFromWorkOrderCSV(): Promise { occupancyTypeField.occupancyTypeField === 'Container Type' ) )!.contractTypeFieldId!, - lotOccupancyFieldValue: workOrderRow.WO_CONTAINER_TYPE + burialSiteContractFieldValue: workOrderRow.WO_CONTAINER_TYPE }, user ) @@ -1431,7 +1431,7 @@ async function importFromWorkOrderCSV(): Promise { occupancyTypeField.occupancyTypeField === 'Committal Type' ) )!.contractTypeFieldId!, - lotOccupancyFieldValue: commitalType + burialSiteContractFieldValue: commitalType }, user ) diff --git a/test/functions.js b/test/functions.js index 25d1d6e0..07543edf 100644 --- a/test/functions.js +++ b/test/functions.js @@ -16,7 +16,7 @@ describe('functions.cache', () => { describe('Lot Statuses', () => { it('returns Lot Statuses', async () => { cacheFunctions.clearCacheByTableName('LotStatuses'); - const lotStatuses = await cacheFunctions.getLotStatuses(); + const lotStatuses = await cacheFunctions.getBurialSiteStatuses(); assert.ok(lotStatuses.length > 0); for (const lotStatus of lotStatuses) { const byId = await cacheFunctions.getLotStatusById(lotStatus.burialSiteStatusId); @@ -116,30 +116,30 @@ describe('functions.cache', () => { describe('functions.sqlFilters', () => { describe('LotName filter', () => { it('returns startsWith filter', () => { - const filter = sqlFilterFunctions.getLotNameWhereClause('TEST1 TEST2', 'startsWith', 'l'); + const filter = sqlFilterFunctions.getBurialSiteNameWhereClause('TEST1 TEST2', 'startsWith', 'l'); assert.strictEqual(filter.sqlWhereClause, " and l.lotName like ? || '%'"); assert.strictEqual(filter.sqlParameters.length, 1); assert.ok(filter.sqlParameters.includes('TEST1 TEST2')); }); it('returns endsWith filter', () => { - const filter = sqlFilterFunctions.getLotNameWhereClause('TEST1 TEST2', 'endsWith', 'l'); + const filter = sqlFilterFunctions.getBurialSiteNameWhereClause('TEST1 TEST2', 'endsWith', 'l'); assert.strictEqual(filter.sqlWhereClause, " and l.lotName like '%' || ?"); assert.strictEqual(filter.sqlParameters.length, 1); assert.strictEqual(filter.sqlParameters[0], 'TEST1 TEST2'); }); it('returns contains filter', () => { - const filter = sqlFilterFunctions.getLotNameWhereClause('TEST1 TEST2', '', 'l'); + const filter = sqlFilterFunctions.getBurialSiteNameWhereClause('TEST1 TEST2', '', 'l'); assert.strictEqual(filter.sqlWhereClause, ' and instr(lower(l.lotName), ?) and instr(lower(l.lotName), ?)'); assert.ok(filter.sqlParameters.includes('test1')); assert.ok(filter.sqlParameters.includes('test2')); }); it('handles empty filter', () => { - const filter = sqlFilterFunctions.getLotNameWhereClause('', ''); + const filter = sqlFilterFunctions.getBurialSiteNameWhereClause('', ''); assert.strictEqual(filter.sqlWhereClause, ''); assert.strictEqual(filter.sqlParameters.length, 0); }); it('handles undefined filter', () => { - const filter = sqlFilterFunctions.getLotNameWhereClause(undefined, undefined, 'l'); + const filter = sqlFilterFunctions.getBurialSiteNameWhereClause(undefined, undefined, 'l'); assert.strictEqual(filter.sqlWhereClause, ''); assert.strictEqual(filter.sqlParameters.length, 0); }); diff --git a/test/functions.ts b/test/functions.ts index 37180e92..56fe4c71 100644 --- a/test/functions.ts +++ b/test/functions.ts @@ -21,7 +21,7 @@ describe('functions.cache', () => { it('returns Lot Statuses', async () => { cacheFunctions.clearCacheByTableName('LotStatuses') - const lotStatuses = await cacheFunctions.getLotStatuses() + const lotStatuses = await cacheFunctions.getBurialSiteStatuses() assert.ok(lotStatuses.length > 0) @@ -182,7 +182,7 @@ describe('functions.cache', () => { describe('functions.sqlFilters', () => { describe('LotName filter', () => { it('returns startsWith filter', () => { - const filter = sqlFilterFunctions.getLotNameWhereClause( + const filter = sqlFilterFunctions.getBurialSiteNameWhereClause( 'TEST1 TEST2', 'startsWith', 'l' @@ -194,7 +194,7 @@ describe('functions.sqlFilters', () => { }) it('returns endsWith filter', () => { - const filter = sqlFilterFunctions.getLotNameWhereClause( + const filter = sqlFilterFunctions.getBurialSiteNameWhereClause( 'TEST1 TEST2', 'endsWith', 'l' @@ -206,7 +206,7 @@ describe('functions.sqlFilters', () => { }) it('returns contains filter', () => { - const filter = sqlFilterFunctions.getLotNameWhereClause( + const filter = sqlFilterFunctions.getBurialSiteNameWhereClause( 'TEST1 TEST2', '', 'l' @@ -221,14 +221,14 @@ describe('functions.sqlFilters', () => { }) it('handles empty filter', () => { - const filter = sqlFilterFunctions.getLotNameWhereClause('', '') + const filter = sqlFilterFunctions.getBurialSiteNameWhereClause('', '') assert.strictEqual(filter.sqlWhereClause, '') assert.strictEqual(filter.sqlParameters.length, 0) }) it('handles undefined filter', () => { - const filter = sqlFilterFunctions.getLotNameWhereClause( + const filter = sqlFilterFunctions.getBurialSiteNameWhereClause( undefined, undefined, 'l' diff --git a/types/configTypes.d.ts b/types/configTypes.d.ts index 1575bb68..75196e21 100644 --- a/types/configTypes.d.ts +++ b/types/configTypes.d.ts @@ -27,6 +27,9 @@ export interface Config { cityDefault?: string; provinceDefault?: string; }; + burialSites: { + burialSiteNameSegments?: ConfigBurialSiteNameSegments; + }; contracts: { burialSiteIdIsRequired?: boolean; cityDefault?: string; @@ -83,4 +86,16 @@ export interface ConfigActiveDirectory { username: string; password: string; } +export interface ConfigBurialSiteNameSegments { + separator?: string; + segments: Partial>; +} export {}; diff --git a/types/configTypes.ts b/types/configTypes.ts index af05ddd7..388dfab1 100644 --- a/types/configTypes.ts +++ b/types/configTypes.ts @@ -28,6 +28,9 @@ export interface Config { cityDefault?: string provinceDefault?: string } + burialSites: { + burialSiteNameSegments?: ConfigBurialSiteNameSegments + } contracts: { burialSiteIdIsRequired?: boolean cityDefault?: string @@ -58,7 +61,10 @@ export interface Config { } } -export type DynamicsGPLookup = 'diamond/cashReceipt' | 'diamond/extendedInvoice' | 'invoice' +export type DynamicsGPLookup = + | 'diamond/cashReceipt' + | 'diamond/extendedInvoice' + | 'invoice' interface ConfigApplication { applicationName?: string @@ -89,3 +95,21 @@ export interface ConfigActiveDirectory { username: string password: string } + +export interface ConfigBurialSiteNameSegments { + separator?: string + segments: Partial< + Record< + '1' | '2' | '3' | '4' | '5', + { + isAvailable?: boolean + isRequired?: boolean + label?: string + prefix?: string + suffix?: string + minLength?: number + maxLength?: number + } + > + > +} diff --git a/types/globalTypes.d.ts b/types/globalTypes.d.ts deleted file mode 100644 index 44d783a6..00000000 --- a/types/globalTypes.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -export interface LOS { - urlPrefix: string; - apiKey: string; - highlightMap: (mapContainerElement: HTMLElement, mapKey: string, contextualClass: 'success' | 'danger') => void; - initializeDatePickers: (containerElement: HTMLElement) => void; - initializeUnlockFieldButtons: (containerElement: HTMLElement) => void; - populateAliases: (containerElement: HTMLElement) => void; - escapedAliases: { - ExternalReceiptNumber: string; - externalReceiptNumber: string; - contractStartDate: string; - contractStartDate: string; - WorkOrderOpenDate: string; - workOrderOpenDate: string; - WorkOrderCloseDate: string; - workOrderCloseDate: string; - }; - dynamicsGPIntegrationIsEnabled: boolean; - getRandomColor: (seedString: string) => string; - setUnsavedChanges: () => void; - clearUnsavedChanges: () => void; - hasUnsavedChanges: () => boolean; - getMoveUpDownButtonFieldHTML: (upButtonClassNames: string, downButtonClassNames: string, isSmall?: boolean) => string; - getLoadingParagraphHTML: (captionText?: string) => string; - getSearchResultsPagerHTML: (limit: number, offset: number, count: number) => string; - getMapURL: (cemeteryId?: number | string, edit?: boolean, time?: boolean) => string; - getLotURL: (lotId?: number | string, edit?: boolean, time?: boolean) => string; - getLotOccupancyURL: (burialSiteContractId?: number | string, edit?: boolean, time?: boolean) => string; - getWorkOrderURL: (workOrderId?: number | string, edit?: boolean, time?: boolean) => string; -} diff --git a/types/recordTypes.d.ts b/types/recordTypes.d.ts index f908d9e6..98b53395 100644 --- a/types/recordTypes.d.ts +++ b/types/recordTypes.d.ts @@ -13,6 +13,7 @@ export interface Record { export interface Cemetery extends Record { cemeteryId?: number; cemeteryName?: string; + cemeteryKey?: string; cemeteryDescription?: string; cemeteryLatitude?: number; cemeteryLongitude?: number; @@ -40,8 +41,8 @@ export interface BurialSiteTypeField extends Record { fieldValues?: string; isRequired?: boolean; pattern?: string; - minimumLength?: number; - maximumLength?: number; + minLength?: number; + maxLength?: number; orderNumber?: number; } export interface BurialSiteStatus extends Record { @@ -51,6 +52,11 @@ export interface BurialSiteStatus extends Record { } export interface BurialSite extends Record { burialSiteId: number; + burialSiteNameSegment1?: string; + burialSiteNameSegment2?: string; + burialSiteNameSegment3?: string; + burialSiteNameSegment4?: string; + burialSiteNameSegment5?: string; burialSiteName?: string; burialSiteTypeId?: number; burialSiteType?: string; @@ -97,8 +103,8 @@ export interface ContractTypeField { fieldValues?: string; isRequired?: boolean; pattern?: string; - minimumLength?: number; - maximumLength?: number; + minLength?: number; + maxLength?: number; orderNumber?: number; } export interface FeeCategory extends Record { @@ -197,11 +203,7 @@ export interface BurialSiteContract extends Record { burialSiteId?: number; burialSiteTypeId?: number; burialSiteType?: string; - burialSiteNameSegment1?: string; - burialSiteNameSegment2?: string; - burialSiteNameSegment3?: string; - burialSiteNameSegment4?: string; - burialSiteNameSegment5?: string; + burialSiteName?: string; cemeteryId?: number; cemeteryName?: string; contractStartDate?: number; diff --git a/types/recordTypes.ts b/types/recordTypes.ts index 2023ed45..5fb73836 100644 --- a/types/recordTypes.ts +++ b/types/recordTypes.ts @@ -20,6 +20,7 @@ export interface Record { export interface Cemetery extends Record { cemeteryId?: number cemeteryName?: string + cemeteryKey?: string cemeteryDescription?: string cemeteryLatitude?: number @@ -54,8 +55,8 @@ export interface BurialSiteTypeField extends Record { fieldValues?: string isRequired?: boolean pattern?: string - minimumLength?: number - maximumLength?: number + minLength?: number + maxLength?: number orderNumber?: number } @@ -68,6 +69,12 @@ export interface BurialSiteStatus extends Record { export interface BurialSite extends Record { burialSiteId: number + + burialSiteNameSegment1?: string + burialSiteNameSegment2?: string + burialSiteNameSegment3?: string + burialSiteNameSegment4?: string + burialSiteNameSegment5?: string burialSiteName?: string burialSiteTypeId?: number @@ -129,8 +136,8 @@ export interface ContractTypeField { fieldValues?: string isRequired?: boolean pattern?: string - minimumLength?: number - maximumLength?: number + minLength?: number + maxLength?: number orderNumber?: number } @@ -261,13 +268,8 @@ export interface BurialSiteContract extends Record { burialSiteId?: number burialSiteTypeId?: number burialSiteType?: string + burialSiteName?: string - burialSiteNameSegment1?: string - burialSiteNameSegment2?: string - burialSiteNameSegment3?: string - burialSiteNameSegment4?: string - burialSiteNameSegment5?: string - cemeteryId?: number cemeteryName?: string