From 414a45041c5378f5d5cf988ec4129419503c75e8 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Fri, 28 Feb 2025 13:15:49 -0500 Subject: [PATCH] major refactoring simplify by remove "burial site" from "burial site contracts" --- database/addBurialSiteContractComment.d.ts | 8 - database/addBurialSiteContractFee.d.ts | 9 - .../addBurialSiteContractFeeCategory.d.ts | 5 - database/addBurialSiteContractTransaction.js | 34 - ...rialSiteContract.d.ts => addContract.d.ts} | 4 +- ...ddBurialSiteContract.js => addContract.js} | 14 +- ...ddBurialSiteContract.ts => addContract.ts} | 18 +- database/addContractComment.d.ts | 8 + ...ntractComment.js => addContractComment.js} | 6 +- ...ntractComment.ts => addContractComment.ts} | 12 +- database/addContractFee.d.ts | 9 + ...alSiteContractFee.js => addContractFee.js} | 38 +- ...alSiteContractFee.ts => addContractFee.ts} | 50 +- database/addContractFeeCategory.d.ts | 5 + ...eCategory.js => addContractFeeCategory.js} | 8 +- ...eCategory.ts => addContractFeeCategory.ts} | 14 +- ...ction.d.ts => addContractTransaction.d.ts} | 4 +- database/addContractTransaction.js | 34 + ...ansaction.ts => addContractTransaction.ts} | 32 +- .../addOrUpdateBurialSiteContractField.d.ts | 7 - database/addOrUpdateContractField.d.ts | 7 + ...ctField.js => addOrUpdateContractField.js} | 14 +- ...ctField.ts => addOrUpdateContractField.ts} | 20 +- database/addWorkOrder.d.ts | 2 +- database/addWorkOrder.js | 8 +- database/addWorkOrder.ts | 10 +- database/addWorkOrderBurialSiteContract.d.ts | 6 - database/addWorkOrderContract.d.ts | 6 + ...iteContract.js => addWorkOrderContract.js} | 20 +- ...iteContract.ts => addWorkOrderContract.ts} | 26 +- database/cleanupDatabase.js | 46 +- database/cleanupDatabase.ts | 46 +- database/copyBurialSiteContract.d.ts | 1 - database/copyBurialSiteContract.js | 62 -- database/copyContract.d.ts | 1 + database/copyContract.js | 62 ++ ...yBurialSiteContract.ts => copyContract.ts} | 52 +- database/deleteBurialSiteContractFee.d.ts | 1 - database/deleteBurialSiteContractField.d.ts | 2 - .../deleteBurialSiteContractInterment.d.ts | 1 - .../deleteBurialSiteContractTransaction.d.ts | 1 - database/deleteContractFee.d.ts | 1 + ...iteContractFee.js => deleteContractFee.js} | 6 +- ...iteContractFee.ts => deleteContractFee.ts} | 8 +- database/deleteContractField.d.ts | 2 + ...ontractField.js => deleteContractField.js} | 8 +- ...ontractField.ts => deleteContractField.ts} | 10 +- database/deleteContractInterment.d.ts | 1 + ...nterment.js => deleteContractInterment.js} | 8 +- ...nterment.ts => deleteContractInterment.ts} | 10 +- database/deleteContractTransaction.d.ts | 1 + ...action.js => deleteContractTransaction.js} | 8 +- ...action.ts => deleteContractTransaction.ts} | 10 +- database/deleteRecord.d.ts | 2 +- database/deleteRecord.js | 12 +- database/deleteRecord.ts | 16 +- .../deleteWorkOrderBurialSiteContract.d.ts | 1 - database/deleteWorkOrderContract.d.ts | 1 + ...Contract.js => deleteWorkOrderContract.js} | 8 +- ...Contract.ts => deleteWorkOrderContract.ts} | 10 +- database/getBurialSite.js | 6 +- database/getBurialSite.ts | 6 +- database/getBurialSiteContract.d.ts | 3 - database/getBurialSiteContractComments.d.ts | 3 - database/getBurialSiteContractFees.d.ts | 3 - database/getBurialSiteContractFields.d.ts | 3 - database/getBurialSiteContractInterments.d.ts | 3 - .../getBurialSiteContractTransactions.d.ts | 5 - database/getBurialSites.d.ts | 2 +- database/getBurialSites.js | 20 +- database/getBurialSites.ts | 22 +- database/getContract.d.ts | 3 + ...etBurialSiteContract.js => getContract.js} | 34 +- ...etBurialSiteContract.ts => getContract.ts} | 48 +- database/getContractComments.d.ts | 3 + ...ractComments.js => getContractComments.js} | 12 +- ...ractComments.ts => getContractComments.ts} | 18 +- database/getContractFees.d.ts | 3 + ...SiteContractFees.js => getContractFees.js} | 10 +- ...SiteContractFees.ts => getContractFees.ts} | 16 +- database/getContractFields.d.ts | 3 + ...ContractFields.js => getContractFields.js} | 16 +- ...ContractFields.ts => getContractFields.ts} | 30 +- database/getContractInterments.d.ts | 3 + ...Interments.js => getContractInterments.js} | 10 +- ...Interments.ts => getContractInterments.ts} | 16 +- database/getContractTransactions.d.ts | 5 + ...sactions.js => getContractTransactions.js} | 16 +- ...sactions.ts => getContractTransactions.ts} | 22 +- ...alSiteContracts.d.ts => getContracts.d.ts} | 10 +- ...BurialSiteContracts.js => getContracts.js} | 56 +- ...BurialSiteContracts.ts => getContracts.ts} | 80 +-- database/getFees.js | 6 +- database/getFees.ts | 6 +- database/getReportData.js | 32 +- database/getReportData.ts | 32 +- database/getWorkOrder.js | 10 +- database/getWorkOrder.ts | 10 +- database/getWorkOrderMilestones.js | 10 +- database/getWorkOrderMilestones.ts | 10 +- database/getWorkOrders.d.ts | 2 +- database/getWorkOrders.js | 20 +- database/getWorkOrders.ts | 22 +- database/initializeDatabase.js | 60 +- database/initializeDatabase.ts | 60 +- .../updateBurialSiteContractFeeQuantity.d.ts | 6 - ...lSiteContract.d.ts => updateContract.d.ts} | 6 +- ...urialSiteContract.js => updateContract.js} | 18 +- ...urialSiteContract.ts => updateContract.ts} | 26 +- ...omment.d.ts => updateContractComment.d.ts} | 4 +- ...actComment.js => updateContractComment.js} | 8 +- ...actComment.ts => updateContractComment.ts} | 10 +- database/updateContractFeeQuantity.d.ts | 6 + ...antity.js => updateContractFeeQuantity.js} | 8 +- ...antity.ts => updateContractFeeQuantity.ts} | 10 +- ...on.d.ts => updateContractTransaction.d.ts} | 6 +- ...action.js => updateContractTransaction.js} | 8 +- ...action.ts => updateContractTransaction.ts} | 14 +- database/updateLotOccupancyOccupant.d.ts | 4 +- database/updateLotOccupancyOccupant.js | 6 +- database/updateLotOccupancyOccupant.ts | 34 +- handlers/api-get/milestoneICS.js | 18 +- handlers/api-get/milestoneICS.ts | 18 +- handlers/burialSites-get/new.js | 2 +- handlers/burialSites-get/new.ts | 2 +- .../burialSites-post/doSearchBurialSites.js | 2 +- .../burialSites-post/doSearchBurialSites.ts | 2 +- handlers/contracts-get/edit.js | 14 +- handlers/contracts-get/edit.ts | 16 +- handlers/contracts-get/new.js | 14 +- handlers/contracts-get/new.ts | 16 +- handlers/contracts-get/search.js | 2 +- handlers/contracts-get/search.ts | 2 +- handlers/contracts-get/view.js | 14 +- handlers/contracts-get/view.ts | 16 +- .../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.js | 12 - .../doAddBurialSiteContractTransaction.ts | 26 - .../contracts-post/doAddContractComment.d.ts | 3 + .../contracts-post/doAddContractComment.js | 10 + .../contracts-post/doAddContractComment.ts | 22 + handlers/contracts-post/doAddContractFee.d.ts | 3 + handlers/contracts-post/doAddContractFee.js | 10 + handlers/contracts-post/doAddContractFee.ts | 22 + .../doAddContractFeeCategory.d.ts | 3 + .../doAddContractFeeCategory.js | 10 + .../doAddContractFeeCategory.ts | 25 + ...ion.d.ts => doAddContractTransaction.d.ts} | 2 +- .../doAddContractTransaction.js | 12 + .../doAddContractTransaction.ts | 26 + .../doCopyBurialSiteContract.js | 8 - .../doCopyBurialSiteContract.ts | 18 - ...lSiteContract.d.ts => doCopyContract.d.ts} | 2 +- handlers/contracts-post/doCopyContract.js | 8 + handlers/contracts-post/doCopyContract.ts | 18 + .../doCreateBurialSiteContract.d.ts | 3 - .../doCreateBurialSiteContract.js | 8 - .../doCreateBurialSiteContract.ts | 21 - handlers/contracts-post/doCreateContract.d.ts | 3 + handlers/contracts-post/doCreateContract.js | 8 + handlers/contracts-post/doCreateContract.ts | 21 + .../doDeleteBurialSiteContractComment.d.ts | 5 - .../doDeleteBurialSiteContractComment.js | 10 - .../doDeleteBurialSiteContractComment.ts | 28 - .../doDeleteBurialSiteContractFee.js | 10 - .../doDeleteBurialSiteContractFee.ts | 28 - .../doDeleteBurialSiteContractTransaction.js | 12 - .../doDeleteBurialSiteContractTransaction.ts | 29 - ...iteContract.d.ts => doDeleteContract.d.ts} | 2 +- ...ialSiteContract.js => doDeleteContract.js} | 2 +- ...ialSiteContract.ts => doDeleteContract.ts} | 6 +- .../doDeleteContractComment.d.ts | 5 + .../contracts-post/doDeleteContractComment.js | 10 + .../contracts-post/doDeleteContractComment.ts | 28 + ...tractFee.d.ts => doDeleteContractFee.d.ts} | 2 +- .../contracts-post/doDeleteContractFee.js | 10 + .../contracts-post/doDeleteContractFee.ts | 28 + ....d.ts => doDeleteContractTransaction.d.ts} | 2 +- .../doDeleteContractTransaction.js | 12 + .../doDeleteContractTransaction.ts | 29 + handlers/contracts-post/doGetFees.d.ts | 2 +- handlers/contracts-post/doGetFees.js | 10 +- handlers/contracts-post/doGetFees.ts | 18 +- .../doSearchBurialSiteContracts.d.ts | 3 - .../contracts-post/doSearchContracts.d.ts | 3 + ...lSiteContracts.js => doSearchContracts.js} | 6 +- ...lSiteContracts.ts => doSearchContracts.ts} | 14 +- .../doUpdateBurialSiteContract.d.ts | 3 - .../doUpdateBurialSiteContract.js | 8 - .../doUpdateBurialSiteContract.ts | 20 - .../doUpdateBurialSiteContractComment.js | 10 - .../doUpdateBurialSiteContractComment.ts | 29 - .../doUpdateBurialSiteContractFeeQuantity.js | 10 - .../doUpdateBurialSiteContractFeeQuantity.ts | 25 - ...doUpdateBurialSiteContractTransaction.d.ts | 3 - .../doUpdateBurialSiteContractTransaction.js | 12 - .../doUpdateBurialSiteContractTransaction.ts | 26 - handlers/contracts-post/doUpdateContract.d.ts | 3 + handlers/contracts-post/doUpdateContract.js | 8 + handlers/contracts-post/doUpdateContract.ts | 20 + ...ment.d.ts => doUpdateContractComment.d.ts} | 4 +- .../contracts-post/doUpdateContractComment.js | 10 + .../contracts-post/doUpdateContractComment.ts | 29 + ....d.ts => doUpdateContractFeeQuantity.d.ts} | 2 +- .../doUpdateContractFeeQuantity.js | 10 + .../doUpdateContractFeeQuantity.ts | 25 + .../doUpdateContractTransaction.d.ts | 3 + .../doUpdateContractTransaction.js | 12 + .../doUpdateContractTransaction.ts | 26 + handlers/dashboard-get/dashboard.js | 6 +- handlers/dashboard-get/dashboard.ts | 6 +- .../doAddWorkOrderBurialSite.js | 2 +- .../doAddWorkOrderBurialSite.ts | 2 +- .../doAddWorkOrderBurialSiteContract.js | 21 - ...tract.d.ts => doAddWorkOrderContract.d.ts} | 2 +- .../workOrders-post/doAddWorkOrderContract.js | 21 + ...eContract.ts => doAddWorkOrderContract.ts} | 14 +- .../doDeleteWorkOrderBurialSite.js | 2 +- .../doDeleteWorkOrderBurialSite.ts | 2 +- .../doDeleteWorkOrderBurialSiteContract.js | 18 - .../doDeleteWorkOrderBurialSiteContract.ts | 38 -- ...ct.d.ts => doDeleteWorkOrderContract.d.ts} | 2 +- .../doDeleteWorkOrderContract.js | 18 + .../doDeleteWorkOrderContract.ts | 38 ++ .../doUpdateBurialSiteStatus.js | 2 +- .../doUpdateBurialSiteStatus.ts | 2 +- helpers/burialSiteContracts.helpers.d.ts | 4 - helpers/contracts.helpers.d.ts | 4 + ...tracts.helpers.js => contracts.helpers.js} | 12 +- ...tracts.helpers.ts => contracts.helpers.ts} | 18 +- helpers/functions.fee.d.ts | 4 +- helpers/functions.fee.js | 2 +- helpers/functions.fee.ts | 4 +- helpers/functions.print.d.ts | 6 +- helpers/functions.print.js | 26 +- helpers/functions.print.ts | 32 +- public/javascripts/burialSite.search.js | 2 +- public/javascripts/burialSite.search.ts | 2 +- ...eContract.edit.d.ts => contract.edit.d.ts} | 0 ...lSiteContract.edit.js => contract.edit.js} | 522 +++++++-------- ...lSiteContract.edit.ts => contract.edit.ts} | 626 +++++++++--------- ...tract.search.d.ts => contract.search.d.ts} | 0 ...eContract.search.js => contract.search.js} | 56 +- ...eContract.search.ts => contract.search.ts} | 60 +- public/javascripts/main.js | 6 +- public/javascripts/main.ts | 8 +- public/javascripts/types.d.ts | 2 +- public/javascripts/types.ts | 4 +- public/javascripts/workOrder.edit.js | 116 ++-- public/javascripts/workOrder.edit.ts | 128 ++-- .../workOrder.milestoneCalendar.js | 14 +- .../workOrder.milestoneCalendar.ts | 14 +- public/javascripts/workOrder.search.js | 4 +- public/javascripts/workOrder.search.ts | 4 +- routes/contracts.js | 64 +- routes/contracts.ts | 94 +-- routes/workOrders.js | 8 +- routes/workOrders.ts | 12 +- temp/legacy.importFromCSV.js | 296 ++++----- temp/legacy.importFromCSV.ts | 296 ++++----- types/recordTypes.d.ts | 46 +- types/recordTypes.ts | 46 +- views/burialSite-edit.ejs | 24 +- views/burialSite-view.ejs | 24 +- ...iteContract-edit.ejs => contract-edit.ejs} | 0 ...ontract-search.ejs => contract-search.ejs} | 2 +- ...iteContract-view.ejs => contract-view.ejs} | 0 views/dashboard.ejs | 10 +- 276 files changed, 2873 insertions(+), 2867 deletions(-) delete mode 100644 database/addBurialSiteContractComment.d.ts delete mode 100644 database/addBurialSiteContractFee.d.ts delete mode 100644 database/addBurialSiteContractFeeCategory.d.ts delete mode 100644 database/addBurialSiteContractTransaction.js rename database/{addBurialSiteContract.d.ts => addContract.d.ts} (76%) rename database/{addBurialSiteContract.js => addContract.js} (76%) rename database/{addBurialSiteContract.ts => addContract.ts} (82%) create mode 100644 database/addContractComment.d.ts rename database/{addBurialSiteContractComment.js => addContractComment.js} (77%) rename database/{addBurialSiteContractComment.ts => addContractComment.ts} (83%) create mode 100644 database/addContractFee.d.ts rename database/{addBurialSiteContractFee.js => addContractFee.js} (67%) rename database/{addBurialSiteContractFee.ts => addContractFee.ts} (73%) create mode 100644 database/addContractFeeCategory.d.ts rename database/{addBurialSiteContractFeeCategory.js => addContractFeeCategory.js} (64%) rename database/{addBurialSiteContractFeeCategory.ts => addContractFeeCategory.ts} (59%) rename database/{addBurialSiteContractTransaction.d.ts => addContractTransaction.d.ts} (53%) create mode 100644 database/addContractTransaction.js rename database/{addBurialSiteContractTransaction.ts => addContractTransaction.ts} (58%) delete mode 100644 database/addOrUpdateBurialSiteContractField.d.ts create mode 100644 database/addOrUpdateContractField.d.ts rename database/{addOrUpdateBurialSiteContractField.js => addOrUpdateContractField.js} (59%) rename database/{addOrUpdateBurialSiteContractField.ts => addOrUpdateContractField.ts} (72%) delete mode 100644 database/addWorkOrderBurialSiteContract.d.ts create mode 100644 database/addWorkOrderContract.d.ts rename database/{addWorkOrderBurialSiteContract.js => addWorkOrderContract.js} (61%) rename database/{addWorkOrderBurialSiteContract.ts => addWorkOrderContract.ts} (72%) delete mode 100644 database/copyBurialSiteContract.d.ts delete mode 100644 database/copyBurialSiteContract.js create mode 100644 database/copyContract.d.ts create mode 100644 database/copyContract.js rename database/{copyBurialSiteContract.ts => copyContract.ts} (51%) delete mode 100644 database/deleteBurialSiteContractFee.d.ts delete mode 100644 database/deleteBurialSiteContractField.d.ts delete mode 100644 database/deleteBurialSiteContractInterment.d.ts delete mode 100644 database/deleteBurialSiteContractTransaction.d.ts create mode 100644 database/deleteContractFee.d.ts rename database/{deleteBurialSiteContractFee.js => deleteContractFee.js} (61%) rename database/{deleteBurialSiteContractFee.ts => deleteContractFee.ts} (65%) create mode 100644 database/deleteContractField.d.ts rename database/{deleteBurialSiteContractField.js => deleteContractField.js} (54%) rename database/{deleteBurialSiteContractField.ts => deleteContractField.ts} (67%) create mode 100644 database/deleteContractInterment.d.ts rename database/{deleteBurialSiteContractInterment.js => deleteContractInterment.js} (50%) rename database/{deleteBurialSiteContractInterment.ts => deleteContractInterment.ts} (58%) create mode 100644 database/deleteContractTransaction.d.ts rename database/{deleteBurialSiteContractTransaction.js => deleteContractTransaction.js} (50%) rename database/{deleteBurialSiteContractTransaction.ts => deleteContractTransaction.ts} (58%) delete mode 100644 database/deleteWorkOrderBurialSiteContract.d.ts create mode 100644 database/deleteWorkOrderContract.d.ts rename database/{deleteWorkOrderBurialSiteContract.js => deleteWorkOrderContract.js} (50%) rename database/{deleteWorkOrderBurialSiteContract.ts => deleteWorkOrderContract.ts} (58%) delete mode 100644 database/getBurialSiteContract.d.ts delete mode 100644 database/getBurialSiteContractComments.d.ts delete mode 100644 database/getBurialSiteContractFees.d.ts delete mode 100644 database/getBurialSiteContractFields.d.ts delete mode 100644 database/getBurialSiteContractInterments.d.ts delete mode 100644 database/getBurialSiteContractTransactions.d.ts create mode 100644 database/getContract.d.ts rename database/{getBurialSiteContract.js => getContract.js} (51%) rename database/{getBurialSiteContract.ts => getContract.ts} (53%) create mode 100644 database/getContractComments.d.ts rename database/{getBurialSiteContractComments.js => getContractComments.js} (72%) rename database/{getBurialSiteContractComments.ts => getContractComments.ts} (68%) create mode 100644 database/getContractFees.d.ts rename database/{getBurialSiteContractFees.js => getContractFees.js} (67%) rename database/{getBurialSiteContractFees.ts => getContractFees.ts} (63%) create mode 100644 database/getContractFields.d.ts rename database/{getBurialSiteContractFields.js => getContractFields.js} (65%) rename database/{getBurialSiteContractFields.ts => getContractFields.ts} (63%) create mode 100644 database/getContractInterments.d.ts rename database/{getBurialSiteContractInterments.js => getContractInterments.js} (82%) rename database/{getBurialSiteContractInterments.ts => getContractInterments.ts} (77%) create mode 100644 database/getContractTransactions.d.ts rename database/{getBurialSiteContractTransactions.js => getContractTransactions.js} (75%) rename database/{getBurialSiteContractTransactions.ts => getContractTransactions.ts} (72%) rename database/{getBurialSiteContracts.d.ts => getContracts.d.ts} (67%) rename database/{getBurialSiteContracts.js => getContracts.js} (71%) rename database/{getBurialSiteContracts.ts => getContracts.ts} (72%) delete mode 100644 database/updateBurialSiteContractFeeQuantity.d.ts rename database/{updateBurialSiteContract.d.ts => updateContract.d.ts} (59%) rename database/{updateBurialSiteContract.js => updateContract.js} (66%) rename database/{updateBurialSiteContract.ts => updateContract.ts} (72%) rename database/{updateBurialSiteContractComment.d.ts => updateContractComment.d.ts} (55%) rename database/{updateBurialSiteContractComment.js => updateContractComment.js} (69%) rename database/{updateBurialSiteContractComment.ts => updateContractComment.ts} (78%) create mode 100644 database/updateContractFeeQuantity.d.ts rename database/{updateBurialSiteContractFeeQuantity.js => updateContractFeeQuantity.js} (63%) rename database/{updateBurialSiteContractFeeQuantity.ts => updateContractFeeQuantity.ts} (74%) rename database/{updateBurialSiteContractTransaction.d.ts => updateContractTransaction.d.ts} (54%) rename database/{updateBurialSiteContractTransaction.js => updateContractTransaction.js} (72%) rename database/{updateBurialSiteContractTransaction.ts => updateContractTransaction.ts} (77%) delete mode 100644 handlers/contracts-post/doAddBurialSiteContractComment.d.ts delete mode 100644 handlers/contracts-post/doAddBurialSiteContractComment.js delete mode 100644 handlers/contracts-post/doAddBurialSiteContractComment.ts delete mode 100644 handlers/contracts-post/doAddBurialSiteContractFee.d.ts delete mode 100644 handlers/contracts-post/doAddBurialSiteContractFee.js delete mode 100644 handlers/contracts-post/doAddBurialSiteContractFee.ts delete mode 100644 handlers/contracts-post/doAddBurialSiteContractFeeCategory.d.ts delete mode 100644 handlers/contracts-post/doAddBurialSiteContractFeeCategory.js delete mode 100644 handlers/contracts-post/doAddBurialSiteContractFeeCategory.ts delete mode 100644 handlers/contracts-post/doAddBurialSiteContractTransaction.js delete mode 100644 handlers/contracts-post/doAddBurialSiteContractTransaction.ts create mode 100644 handlers/contracts-post/doAddContractComment.d.ts create mode 100644 handlers/contracts-post/doAddContractComment.js create mode 100644 handlers/contracts-post/doAddContractComment.ts create mode 100644 handlers/contracts-post/doAddContractFee.d.ts create mode 100644 handlers/contracts-post/doAddContractFee.js create mode 100644 handlers/contracts-post/doAddContractFee.ts create mode 100644 handlers/contracts-post/doAddContractFeeCategory.d.ts create mode 100644 handlers/contracts-post/doAddContractFeeCategory.js create mode 100644 handlers/contracts-post/doAddContractFeeCategory.ts rename handlers/contracts-post/{doAddBurialSiteContractTransaction.d.ts => doAddContractTransaction.d.ts} (64%) create mode 100644 handlers/contracts-post/doAddContractTransaction.js create mode 100644 handlers/contracts-post/doAddContractTransaction.ts delete mode 100644 handlers/contracts-post/doCopyBurialSiteContract.js delete mode 100644 handlers/contracts-post/doCopyBurialSiteContract.ts rename handlers/contracts-post/{doDeleteBurialSiteContract.d.ts => doCopyContract.d.ts} (82%) create mode 100644 handlers/contracts-post/doCopyContract.js create mode 100644 handlers/contracts-post/doCopyContract.ts delete mode 100644 handlers/contracts-post/doCreateBurialSiteContract.d.ts delete mode 100644 handlers/contracts-post/doCreateBurialSiteContract.js delete mode 100644 handlers/contracts-post/doCreateBurialSiteContract.ts create mode 100644 handlers/contracts-post/doCreateContract.d.ts create mode 100644 handlers/contracts-post/doCreateContract.js create mode 100644 handlers/contracts-post/doCreateContract.ts delete mode 100644 handlers/contracts-post/doDeleteBurialSiteContractComment.d.ts delete mode 100644 handlers/contracts-post/doDeleteBurialSiteContractComment.js delete mode 100644 handlers/contracts-post/doDeleteBurialSiteContractComment.ts delete mode 100644 handlers/contracts-post/doDeleteBurialSiteContractFee.js delete mode 100644 handlers/contracts-post/doDeleteBurialSiteContractFee.ts delete mode 100644 handlers/contracts-post/doDeleteBurialSiteContractTransaction.js delete mode 100644 handlers/contracts-post/doDeleteBurialSiteContractTransaction.ts rename handlers/contracts-post/{doCopyBurialSiteContract.d.ts => doDeleteContract.d.ts} (82%) rename handlers/contracts-post/{doDeleteBurialSiteContract.js => doDeleteContract.js} (58%) rename handlers/contracts-post/{doDeleteBurialSiteContract.ts => doDeleteContract.ts} (68%) create mode 100644 handlers/contracts-post/doDeleteContractComment.d.ts create mode 100644 handlers/contracts-post/doDeleteContractComment.js create mode 100644 handlers/contracts-post/doDeleteContractComment.ts rename handlers/contracts-post/{doDeleteBurialSiteContractFee.d.ts => doDeleteContractFee.d.ts} (83%) create mode 100644 handlers/contracts-post/doDeleteContractFee.js create mode 100644 handlers/contracts-post/doDeleteContractFee.ts rename handlers/contracts-post/{doDeleteBurialSiteContractTransaction.d.ts => doDeleteContractTransaction.d.ts} (84%) create mode 100644 handlers/contracts-post/doDeleteContractTransaction.js create mode 100644 handlers/contracts-post/doDeleteContractTransaction.ts delete mode 100644 handlers/contracts-post/doSearchBurialSiteContracts.d.ts create mode 100644 handlers/contracts-post/doSearchContracts.d.ts rename handlers/contracts-post/{doSearchBurialSiteContracts.js => doSearchContracts.js} (68%) rename handlers/contracts-post/{doSearchBurialSiteContracts.ts => doSearchContracts.ts} (60%) delete mode 100644 handlers/contracts-post/doUpdateBurialSiteContract.d.ts delete mode 100644 handlers/contracts-post/doUpdateBurialSiteContract.js delete mode 100644 handlers/contracts-post/doUpdateBurialSiteContract.ts delete mode 100644 handlers/contracts-post/doUpdateBurialSiteContractComment.js delete mode 100644 handlers/contracts-post/doUpdateBurialSiteContractComment.ts delete mode 100644 handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.js delete mode 100644 handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.ts delete mode 100644 handlers/contracts-post/doUpdateBurialSiteContractTransaction.d.ts delete mode 100644 handlers/contracts-post/doUpdateBurialSiteContractTransaction.js delete mode 100644 handlers/contracts-post/doUpdateBurialSiteContractTransaction.ts create mode 100644 handlers/contracts-post/doUpdateContract.d.ts create mode 100644 handlers/contracts-post/doUpdateContract.js create mode 100644 handlers/contracts-post/doUpdateContract.ts rename handlers/contracts-post/{doUpdateBurialSiteContractComment.d.ts => doUpdateContractComment.d.ts} (59%) create mode 100644 handlers/contracts-post/doUpdateContractComment.js create mode 100644 handlers/contracts-post/doUpdateContractComment.ts rename handlers/contracts-post/{doUpdateBurialSiteContractFeeQuantity.d.ts => doUpdateContractFeeQuantity.d.ts} (86%) create mode 100644 handlers/contracts-post/doUpdateContractFeeQuantity.js create mode 100644 handlers/contracts-post/doUpdateContractFeeQuantity.ts create mode 100644 handlers/contracts-post/doUpdateContractTransaction.d.ts create mode 100644 handlers/contracts-post/doUpdateContractTransaction.js create mode 100644 handlers/contracts-post/doUpdateContractTransaction.ts delete mode 100644 handlers/workOrders-post/doAddWorkOrderBurialSiteContract.js rename handlers/workOrders-post/{doAddWorkOrderBurialSiteContract.d.ts => doAddWorkOrderContract.d.ts} (84%) create mode 100644 handlers/workOrders-post/doAddWorkOrderContract.js rename handlers/workOrders-post/{doAddWorkOrderBurialSiteContract.ts => doAddWorkOrderContract.ts} (52%) delete mode 100644 handlers/workOrders-post/doDeleteWorkOrderBurialSiteContract.js delete mode 100644 handlers/workOrders-post/doDeleteWorkOrderBurialSiteContract.ts rename handlers/workOrders-post/{doDeleteWorkOrderBurialSiteContract.d.ts => doDeleteWorkOrderContract.d.ts} (84%) create mode 100644 handlers/workOrders-post/doDeleteWorkOrderContract.js create mode 100644 handlers/workOrders-post/doDeleteWorkOrderContract.ts delete mode 100644 helpers/burialSiteContracts.helpers.d.ts create mode 100644 helpers/contracts.helpers.d.ts rename helpers/{burialSiteContracts.helpers.js => contracts.helpers.js} (50%) rename helpers/{burialSiteContracts.helpers.ts => contracts.helpers.ts} (70%) rename public/javascripts/{burialSiteContract.edit.d.ts => contract.edit.d.ts} (100%) rename public/javascripts/{burialSiteContract.edit.js => contract.edit.js} (74%) rename public/javascripts/{burialSiteContract.edit.ts => contract.edit.ts} (78%) rename public/javascripts/{burialSiteContract.search.d.ts => contract.search.d.ts} (100%) rename public/javascripts/{burialSiteContract.search.js => contract.search.js} (71%) rename public/javascripts/{burialSiteContract.search.ts => contract.search.ts} (75%) rename views/{burialSiteContract-edit.ejs => contract-edit.ejs} (100%) rename views/{burialSiteContract-search.ejs => contract-search.ejs} (98%) rename views/{burialSiteContract-view.ejs => contract-view.ejs} (100%) diff --git a/database/addBurialSiteContractComment.d.ts b/database/addBurialSiteContractComment.d.ts deleted file mode 100644 index 26bd1d48..00000000 --- a/database/addBurialSiteContractComment.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { type DateString, type TimeString } from '@cityssm/utils-datetime'; -export interface AddBurialSiteContractCommentForm { - burialSiteContractId: string | number; - commentDateString?: DateString; - commentTimeString?: TimeString; - comment: string; -} -export default function addBurialSiteContractComment(commentForm: AddBurialSiteContractCommentForm, user: User): Promise; diff --git a/database/addBurialSiteContractFee.d.ts b/database/addBurialSiteContractFee.d.ts deleted file mode 100644 index 6a265d65..00000000 --- a/database/addBurialSiteContractFee.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { PoolConnection } from 'better-sqlite-pool'; -export interface AddBurialSiteContractFeeForm { - burialSiteContractId: number | string; - feeId: number | string; - quantity: number | string; - feeAmount?: number | string; - taxAmount?: number | string; -} -export default function addBurialSiteContractFee(addFeeForm: AddBurialSiteContractFeeForm, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/addBurialSiteContractFeeCategory.d.ts b/database/addBurialSiteContractFeeCategory.d.ts deleted file mode 100644 index c1e5ec9e..00000000 --- a/database/addBurialSiteContractFeeCategory.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface AddBurialSiteContractCategoryForm { - burialSiteContractId: number | string; - feeCategoryId: number | string; -} -export default function addBurialSiteContractFeeCategory(addFeeCategoryForm: AddBurialSiteContractCategoryForm, user: User): Promise; diff --git a/database/addBurialSiteContractTransaction.js b/database/addBurialSiteContractTransaction.js deleted file mode 100644 index 9bc6e86b..00000000 --- a/database/addBurialSiteContractTransaction.js +++ /dev/null @@ -1,34 +0,0 @@ -import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/utils-datetime'; -import { acquireConnection } from './pool.js'; -export default async function addBurialSiteContractTransaction(burialSiteContractTransactionForm, user) { - const database = await acquireConnection(); - let transactionIndex = 0; - const maxIndexResult = database - .prepare(`select transactionIndex - from BurialSiteContractTransactions - where burialSiteContractId = ? - order by transactionIndex desc - limit 1`) - .get(burialSiteContractTransactionForm.burialSiteContractId); - if (maxIndexResult !== undefined) { - transactionIndex = maxIndexResult.transactionIndex + 1; - } - const rightNow = new Date(); - const transactionDate = burialSiteContractTransactionForm.transactionDateString - ? dateStringToInteger(burialSiteContractTransactionForm.transactionDateString) - : dateToInteger(rightNow); - const transactionTime = burialSiteContractTransactionForm.transactionTimeString - ? timeStringToInteger(burialSiteContractTransactionForm.transactionTimeString) - : dateToTimeInteger(rightNow); - database - .prepare(`insert into BurialSiteContractTransactions ( - burialSiteContractId, transactionIndex, - transactionDate, transactionTime, - transactionAmount, externalReceiptNumber, transactionNote, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`) - .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/addBurialSiteContract.d.ts b/database/addContract.d.ts similarity index 76% rename from database/addBurialSiteContract.d.ts rename to database/addContract.d.ts index 393303ae..a277e070 100644 --- a/database/addBurialSiteContract.d.ts +++ b/database/addContract.d.ts @@ -1,5 +1,5 @@ import type { PoolConnection } from 'better-sqlite-pool'; -export interface AddBurialSiteContractForm { +export interface AddContractForm { contractTypeId: string | number; burialSiteId: string | number; contractStartDateString: string; @@ -18,4 +18,4 @@ export interface AddBurialSiteContractForm { occupantEmailAddress?: string; occupantComment?: string; } -export default function addBurialSiteContract(addForm: AddBurialSiteContractForm, user: User, connectedDatabase?: PoolConnection): Promise; +export default function addContract(addForm: AddContractForm, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/addBurialSiteContract.js b/database/addContract.js similarity index 76% rename from database/addBurialSiteContract.js rename to database/addContract.js index 079c8219..8b256964 100644 --- a/database/addBurialSiteContract.js +++ b/database/addContract.js @@ -1,12 +1,12 @@ import { dateStringToInteger } from '@cityssm/utils-datetime'; -import addOrUpdateBurialSiteContractField from './addOrUpdateBurialSiteContractField.js'; +import addOrUpdateContractField from './addOrUpdateContractField.js'; import { acquireConnection } from './pool.js'; -export default async function addBurialSiteContract(addForm, user, connectedDatabase) { +export default async function addContract(addForm, user, connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); const rightNowMillis = Date.now(); const contractStartDate = dateStringToInteger(addForm.contractStartDateString); const result = database - .prepare(`insert into BurialSiteContracts ( + .prepare(`insert into Contracts ( contractTypeId, lotId, contractStartDate, contractEndDate, recordCreate_userName, recordCreate_timeMillis, @@ -15,13 +15,13 @@ export default async function addBurialSiteContract(addForm, user, connectedData .run(addForm.contractTypeId, addForm.burialSiteId === '' ? undefined : addForm.burialSiteId, contractStartDate, addForm.contractEndDateString === '' ? undefined : dateStringToInteger(addForm.contractEndDateString), user.userName, rightNowMillis, user.userName, rightNowMillis); - const burialSiteContractId = result.lastInsertRowid; + const contractId = result.lastInsertRowid; const contractTypeFieldIds = (addForm.contractTypeFieldIds ?? '').split(','); for (const contractTypeFieldId of contractTypeFieldIds) { const fieldValue = addForm[`fieldValue_${contractTypeFieldId}`]; if ((fieldValue ?? '') !== '') { - await addOrUpdateBurialSiteContractField({ - burialSiteContractId, + await addOrUpdateContractField({ + contractId, contractTypeFieldId, fieldValue: fieldValue ?? '' }, user, database); @@ -30,5 +30,5 @@ export default async function addBurialSiteContract(addForm, user, connectedData if (connectedDatabase === undefined) { database.release(); } - return burialSiteContractId; + return contractId; } diff --git a/database/addBurialSiteContract.ts b/database/addContract.ts similarity index 82% rename from database/addBurialSiteContract.ts rename to database/addContract.ts index 73d0c5c5..fb759e81 100644 --- a/database/addBurialSiteContract.ts +++ b/database/addContract.ts @@ -1,10 +1,10 @@ import { type DateString, dateStringToInteger } from '@cityssm/utils-datetime' import type { PoolConnection } from 'better-sqlite-pool' -import addOrUpdateBurialSiteContractField from './addOrUpdateBurialSiteContractField.js' +import addOrUpdateContractField from './addOrUpdateContractField.js' import { acquireConnection } from './pool.js' -export interface AddBurialSiteContractForm { +export interface AddContractForm { contractTypeId: string | number burialSiteId: string | number @@ -27,8 +27,8 @@ export interface AddBurialSiteContractForm { occupantComment?: string } -export default async function addBurialSiteContract( - addForm: AddBurialSiteContractForm, +export default async function addContract( + addForm: AddContractForm, user: User, connectedDatabase?: PoolConnection ): Promise { @@ -42,7 +42,7 @@ export default async function addBurialSiteContract( const result = database .prepare( - `insert into BurialSiteContracts ( + `insert into Contracts ( contractTypeId, lotId, contractStartDate, contractEndDate, recordCreate_userName, recordCreate_timeMillis, @@ -62,7 +62,7 @@ export default async function addBurialSiteContract( rightNowMillis ) - const burialSiteContractId = result.lastInsertRowid as number + const contractId = result.lastInsertRowid as number const contractTypeFieldIds = (addForm.contractTypeFieldIds ?? '').split(',') @@ -72,9 +72,9 @@ export default async function addBurialSiteContract( | undefined if ((fieldValue ?? '') !== '') { - await addOrUpdateBurialSiteContractField( + await addOrUpdateContractField( { - burialSiteContractId, + contractId, contractTypeFieldId, fieldValue: fieldValue ?? '' }, @@ -88,5 +88,5 @@ export default async function addBurialSiteContract( database.release() } - return burialSiteContractId + return contractId } diff --git a/database/addContractComment.d.ts b/database/addContractComment.d.ts new file mode 100644 index 00000000..434442a2 --- /dev/null +++ b/database/addContractComment.d.ts @@ -0,0 +1,8 @@ +import { type DateString, type TimeString } from '@cityssm/utils-datetime'; +export interface AddContractCommentForm { + contractId: string | number; + commentDateString?: DateString; + commentTimeString?: TimeString; + comment: string; +} +export default function addContractComment(commentForm: AddContractCommentForm, user: User): Promise; diff --git a/database/addBurialSiteContractComment.js b/database/addContractComment.js similarity index 77% rename from database/addBurialSiteContractComment.js rename to database/addContractComment.js index ddd2075e..c9122197 100644 --- a/database/addBurialSiteContractComment.js +++ b/database/addContractComment.js @@ -1,6 +1,6 @@ import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/utils-datetime'; import { acquireConnection } from './pool.js'; -export default async function addBurialSiteContractComment(commentForm, user) { +export default async function addContractComment(commentForm, user) { const rightNow = new Date(); let commentDate = 0; let commentTime = 0; @@ -15,13 +15,13 @@ export default async function addBurialSiteContractComment(commentForm, user) { const database = await acquireConnection(); const result = database .prepare(`insert into BurialSiteContactComments ( - burialSiteContractId, + contractId, commentDate, commentTime, comment, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?, ?)`) - .run(commentForm.burialSiteContractId, commentDate, commentTime ?? 0, commentForm.comment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime()); + .run(commentForm.contractId, commentDate, commentTime ?? 0, commentForm.comment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime()); database.release(); return result.lastInsertRowid; } diff --git a/database/addBurialSiteContractComment.ts b/database/addContractComment.ts similarity index 83% rename from database/addBurialSiteContractComment.ts rename to database/addContractComment.ts index 58f582fc..7a5f5c97 100644 --- a/database/addBurialSiteContractComment.ts +++ b/database/addContractComment.ts @@ -9,15 +9,15 @@ import { import { acquireConnection } from './pool.js' -export interface AddBurialSiteContractCommentForm { - burialSiteContractId: string | number +export interface AddContractCommentForm { + contractId: string | number commentDateString?: DateString commentTimeString?: TimeString comment: string } -export default async function addBurialSiteContractComment( - commentForm: AddBurialSiteContractCommentForm, +export default async function addContractComment( + commentForm: AddContractCommentForm, user: User ): Promise { const rightNow = new Date() @@ -42,7 +42,7 @@ export default async function addBurialSiteContractComment( const result = database .prepare( `insert into BurialSiteContactComments ( - burialSiteContractId, + contractId, commentDate, commentTime, comment, recordCreate_userName, recordCreate_timeMillis, @@ -50,7 +50,7 @@ export default async function addBurialSiteContractComment( values (?, ?, ?, ?, ?, ?, ?, ?)` ) .run( - commentForm.burialSiteContractId, + commentForm.contractId, commentDate, commentTime ?? 0, commentForm.comment, diff --git a/database/addContractFee.d.ts b/database/addContractFee.d.ts new file mode 100644 index 00000000..a434c205 --- /dev/null +++ b/database/addContractFee.d.ts @@ -0,0 +1,9 @@ +import type { PoolConnection } from 'better-sqlite-pool'; +export interface AddContractFeeForm { + contractId: number | string; + feeId: number | string; + quantity: number | string; + feeAmount?: number | string; + taxAmount?: number | string; +} +export default function addContractFee(addFeeForm: AddContractFeeForm, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/addBurialSiteContractFee.js b/database/addContractFee.js similarity index 67% rename from database/addBurialSiteContractFee.js rename to database/addContractFee.js index bccf2f06..2ceca371 100644 --- a/database/addBurialSiteContractFee.js +++ b/database/addContractFee.js @@ -1,17 +1,17 @@ import { calculateFeeAmount, calculateTaxAmount } from '../helpers/functions.fee.js'; -import getBurialSiteContract from './getBurialSiteContract.js'; +import getContract from './getContract.js'; import getFee from './getFee.js'; import { acquireConnection } from './pool.js'; -export default async function addBurialSiteContractFee(addFeeForm, user, connectedDatabase) { +export default async function addContractFee(addFeeForm, user, connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); const rightNowMillis = Date.now(); // Calculate fee and tax (if not set) let feeAmount; let taxAmount; if ((addFeeForm.feeAmount ?? '') === '') { - const burialSiteContract = (await getBurialSiteContract(addFeeForm.burialSiteContractId)); + const contract = (await getContract(addFeeForm.contractId)); const fee = (await getFee(addFeeForm.feeId)); - feeAmount = calculateFeeAmount(fee, burialSiteContract); + feeAmount = calculateFeeAmount(fee, contract); taxAmount = calculateTaxAmount(fee, feeAmount); } else { @@ -28,29 +28,29 @@ export default async function addBurialSiteContractFee(addFeeForm, user, connect // Check if record already exists const record = database .prepare(`select feeAmount, taxAmount, recordDelete_timeMillis - from BurialSiteContractFees - where burialSiteContractId = ? + from ContractFees + where contractId = ? and feeId = ?`) - .get(addFeeForm.burialSiteContractId, addFeeForm.feeId); + .get(addFeeForm.contractId, addFeeForm.feeId); if (record !== undefined) { if (record.recordDelete_timeMillis !== null) { database - .prepare(`delete from BurialSiteContractFees + .prepare(`delete from ContractFees where recordDelete_timeMillis is not null - and burialSiteContractId = ? + and contractId = ? and feeId = ?`) - .run(addFeeForm.burialSiteContractId, addFeeForm.feeId); + .run(addFeeForm.contractId, addFeeForm.feeId); } else if (record.feeAmount === feeAmount && record.taxAmount === taxAmount) { database - .prepare(`update BurialSiteContractFees + .prepare(`update ContractFees set quantity = quantity + ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ? - where burialSiteContractId = ? + where contractId = ? and feeId = ?`) - .run(addFeeForm.quantity, user.userName, rightNowMillis, addFeeForm.burialSiteContractId, addFeeForm.feeId); + .run(addFeeForm.quantity, user.userName, rightNowMillis, addFeeForm.contractId, addFeeForm.feeId); return true; } else { @@ -58,27 +58,27 @@ export default async function addBurialSiteContractFee(addFeeForm, user, connect ? Number.parseFloat(addFeeForm.quantity) : addFeeForm.quantity; database - .prepare(`update BurialSiteContractFees + .prepare(`update ContractFees set feeAmount = (feeAmount * quantity) + ?, taxAmount = (taxAmount * quantity) + ?, quantity = 1, recordUpdate_userName = ?, recordUpdate_timeMillis = ? - where burialSiteContractId = ? + where contractId = ? and feeId = ?`) - .run(feeAmount * quantity, taxAmount * quantity, user.userName, rightNowMillis, addFeeForm.burialSiteContractId, addFeeForm.feeId); + .run(feeAmount * quantity, taxAmount * quantity, user.userName, rightNowMillis, addFeeForm.contractId, addFeeForm.feeId); return true; } } // Create new record const result = database - .prepare(`insert into BurialSiteContractFees ( - burialSiteContractId, feeId, + .prepare(`insert into ContractFees ( + contractId, feeId, quantity, feeAmount, taxAmount, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?, ?, ?)`) - .run(addFeeForm.burialSiteContractId, addFeeForm.feeId, addFeeForm.quantity, feeAmount, taxAmount, user.userName, rightNowMillis, user.userName, rightNowMillis); + .run(addFeeForm.contractId, addFeeForm.feeId, addFeeForm.quantity, feeAmount, taxAmount, user.userName, rightNowMillis, user.userName, rightNowMillis); return result.changes > 0; } finally { diff --git a/database/addBurialSiteContractFee.ts b/database/addContractFee.ts similarity index 73% rename from database/addBurialSiteContractFee.ts rename to database/addContractFee.ts index 79d969f7..5699304d 100644 --- a/database/addBurialSiteContractFee.ts +++ b/database/addContractFee.ts @@ -4,22 +4,22 @@ import { calculateFeeAmount, calculateTaxAmount } from '../helpers/functions.fee.js' -import type { BurialSiteContract, Fee } from '../types/recordTypes.js' +import type { Contract, Fee } from '../types/recordTypes.js' -import getBurialSiteContract from './getBurialSiteContract.js' +import getContract from './getContract.js' import getFee from './getFee.js' import { acquireConnection } from './pool.js' -export interface AddBurialSiteContractFeeForm { - burialSiteContractId: number | string +export interface AddContractFeeForm { + contractId: number | string feeId: number | string quantity: number | string feeAmount?: number | string taxAmount?: number | string } -export default async function addBurialSiteContractFee( - addFeeForm: AddBurialSiteContractFeeForm, +export default async function addContractFee( + addFeeForm: AddContractFeeForm, user: User, connectedDatabase?: PoolConnection ): Promise { @@ -32,13 +32,13 @@ export default async function addBurialSiteContractFee( let taxAmount: number if ((addFeeForm.feeAmount ?? '') === '') { - const burialSiteContract = (await getBurialSiteContract( - addFeeForm.burialSiteContractId - )) as BurialSiteContract + const contract = (await getContract( + addFeeForm.contractId + )) as Contract const fee = (await getFee(addFeeForm.feeId)) as Fee - feeAmount = calculateFeeAmount(fee, burialSiteContract) + feeAmount = calculateFeeAmount(fee, contract) taxAmount = calculateTaxAmount(fee, feeAmount) } else { feeAmount = @@ -56,11 +56,11 @@ export default async function addBurialSiteContractFee( const record = database .prepare( `select feeAmount, taxAmount, recordDelete_timeMillis - from BurialSiteContractFees - where burialSiteContractId = ? + from ContractFees + where contractId = ? and feeId = ?` ) - .get(addFeeForm.burialSiteContractId, addFeeForm.feeId) as + .get(addFeeForm.contractId, addFeeForm.feeId) as | { feeAmount: number | null taxAmount: number | null @@ -72,30 +72,30 @@ export default async function addBurialSiteContractFee( if (record.recordDelete_timeMillis !== null) { database .prepare( - `delete from BurialSiteContractFees + `delete from ContractFees where recordDelete_timeMillis is not null - and burialSiteContractId = ? + and contractId = ? and feeId = ?` ) - .run(addFeeForm.burialSiteContractId, addFeeForm.feeId) + .run(addFeeForm.contractId, addFeeForm.feeId) } else if ( record.feeAmount === feeAmount && record.taxAmount === taxAmount ) { database .prepare( - `update BurialSiteContractFees + `update ContractFees set quantity = quantity + ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ? - where burialSiteContractId = ? + where contractId = ? and feeId = ?` ) .run( addFeeForm.quantity, user.userName, rightNowMillis, - addFeeForm.burialSiteContractId, + addFeeForm.contractId, addFeeForm.feeId ) @@ -108,13 +108,13 @@ export default async function addBurialSiteContractFee( database .prepare( - `update BurialSiteContractFees + `update ContractFees set feeAmount = (feeAmount * quantity) + ?, taxAmount = (taxAmount * quantity) + ?, quantity = 1, recordUpdate_userName = ?, recordUpdate_timeMillis = ? - where burialSiteContractId = ? + where contractId = ? and feeId = ?` ) .run( @@ -122,7 +122,7 @@ export default async function addBurialSiteContractFee( taxAmount * quantity, user.userName, rightNowMillis, - addFeeForm.burialSiteContractId, + addFeeForm.contractId, addFeeForm.feeId ) @@ -133,15 +133,15 @@ export default async function addBurialSiteContractFee( // Create new record const result = database .prepare( - `insert into BurialSiteContractFees ( - burialSiteContractId, feeId, + `insert into ContractFees ( + contractId, feeId, quantity, feeAmount, taxAmount, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?, ?, ?)` ) .run( - addFeeForm.burialSiteContractId, + addFeeForm.contractId, addFeeForm.feeId, addFeeForm.quantity, feeAmount, diff --git a/database/addContractFeeCategory.d.ts b/database/addContractFeeCategory.d.ts new file mode 100644 index 00000000..8e9294ed --- /dev/null +++ b/database/addContractFeeCategory.d.ts @@ -0,0 +1,5 @@ +export interface AddContractCategoryForm { + contractId: number | string; + feeCategoryId: number | string; +} +export default function addContractFeeCategory(addFeeCategoryForm: AddContractCategoryForm, user: User): Promise; diff --git a/database/addBurialSiteContractFeeCategory.js b/database/addContractFeeCategory.js similarity index 64% rename from database/addBurialSiteContractFeeCategory.js rename to database/addContractFeeCategory.js index 807c3746..aee4a7e1 100644 --- a/database/addBurialSiteContractFeeCategory.js +++ b/database/addContractFeeCategory.js @@ -1,13 +1,13 @@ -import addBurialSiteContractFee from './addBurialSiteContractFee.js'; +import addContractFee from './addContractFee.js'; import { getFeeCategory } from './getFeeCategories.js'; import { acquireConnection } from './pool.js'; -export default async function addBurialSiteContractFeeCategory(addFeeCategoryForm, user) { +export default async function addContractFeeCategory(addFeeCategoryForm, user) { const database = await acquireConnection(); const feeCategory = await getFeeCategory(addFeeCategoryForm.feeCategoryId, database); let addedFeeCount = 0; for (const fee of feeCategory?.fees ?? []) { - const success = await addBurialSiteContractFee({ - burialSiteContractId: addFeeCategoryForm.burialSiteContractId, + const success = await addContractFee({ + contractId: addFeeCategoryForm.contractId, feeId: fee.feeId, quantity: 1 }, user, database); diff --git a/database/addBurialSiteContractFeeCategory.ts b/database/addContractFeeCategory.ts similarity index 59% rename from database/addBurialSiteContractFeeCategory.ts rename to database/addContractFeeCategory.ts index cacac923..24530e04 100644 --- a/database/addBurialSiteContractFeeCategory.ts +++ b/database/addContractFeeCategory.ts @@ -1,14 +1,14 @@ -import addBurialSiteContractFee from './addBurialSiteContractFee.js' +import addContractFee from './addContractFee.js' import { getFeeCategory } from './getFeeCategories.js' import { acquireConnection } from './pool.js' -export interface AddBurialSiteContractCategoryForm { - burialSiteContractId: number | string +export interface AddContractCategoryForm { + contractId: number | string feeCategoryId: number | string } -export default async function addBurialSiteContractFeeCategory( - addFeeCategoryForm: AddBurialSiteContractCategoryForm, +export default async function addContractFeeCategory( + addFeeCategoryForm: AddContractCategoryForm, user: User ): Promise { const database = await acquireConnection() @@ -21,9 +21,9 @@ export default async function addBurialSiteContractFeeCategory( let addedFeeCount = 0 for (const fee of feeCategory?.fees ?? []) { - const success = await addBurialSiteContractFee( + const success = await addContractFee( { - burialSiteContractId: addFeeCategoryForm.burialSiteContractId, + contractId: addFeeCategoryForm.contractId, feeId: fee.feeId, quantity: 1 }, diff --git a/database/addBurialSiteContractTransaction.d.ts b/database/addContractTransaction.d.ts similarity index 53% rename from database/addBurialSiteContractTransaction.d.ts rename to database/addContractTransaction.d.ts index 214bbcd4..fa255b88 100644 --- a/database/addBurialSiteContractTransaction.d.ts +++ b/database/addContractTransaction.d.ts @@ -1,9 +1,9 @@ export interface AddTransactionForm { - burialSiteContractId: string | number; + contractId: string | number; transactionDateString?: string; transactionTimeString?: string; transactionAmount: string | number; externalReceiptNumber: string; transactionNote: string; } -export default function addBurialSiteContractTransaction(burialSiteContractTransactionForm: AddTransactionForm, user: User): Promise; +export default function addContractTransaction(contractTransactionForm: AddTransactionForm, user: User): Promise; diff --git a/database/addContractTransaction.js b/database/addContractTransaction.js new file mode 100644 index 00000000..e5cdf207 --- /dev/null +++ b/database/addContractTransaction.js @@ -0,0 +1,34 @@ +import { dateStringToInteger, dateToInteger, dateToTimeInteger, timeStringToInteger } from '@cityssm/utils-datetime'; +import { acquireConnection } from './pool.js'; +export default async function addContractTransaction(contractTransactionForm, user) { + const database = await acquireConnection(); + let transactionIndex = 0; + const maxIndexResult = database + .prepare(`select transactionIndex + from ContractTransactions + where contractId = ? + order by transactionIndex desc + limit 1`) + .get(contractTransactionForm.contractId); + if (maxIndexResult !== undefined) { + transactionIndex = maxIndexResult.transactionIndex + 1; + } + const rightNow = new Date(); + const transactionDate = contractTransactionForm.transactionDateString + ? dateStringToInteger(contractTransactionForm.transactionDateString) + : dateToInteger(rightNow); + const transactionTime = contractTransactionForm.transactionTimeString + ? timeStringToInteger(contractTransactionForm.transactionTimeString) + : dateToTimeInteger(rightNow); + database + .prepare(`insert into ContractTransactions ( + contractId, transactionIndex, + transactionDate, transactionTime, + transactionAmount, externalReceiptNumber, transactionNote, + recordCreate_userName, recordCreate_timeMillis, + recordUpdate_userName, recordUpdate_timeMillis) + values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`) + .run(contractTransactionForm.contractId, transactionIndex, transactionDate, transactionTime, contractTransactionForm.transactionAmount, contractTransactionForm.externalReceiptNumber, contractTransactionForm.transactionNote, user.userName, rightNow.getTime(), user.userName, rightNow.getTime()); + database.release(); + return transactionIndex; +} diff --git a/database/addBurialSiteContractTransaction.ts b/database/addContractTransaction.ts similarity index 58% rename from database/addBurialSiteContractTransaction.ts rename to database/addContractTransaction.ts index 1152bbc1..4ec27e45 100644 --- a/database/addBurialSiteContractTransaction.ts +++ b/database/addContractTransaction.ts @@ -8,7 +8,7 @@ import { import { acquireConnection } from './pool.js' export interface AddTransactionForm { - burialSiteContractId: string | number + contractId: string | number transactionDateString?: string transactionTimeString?: string transactionAmount: string | number @@ -16,8 +16,8 @@ export interface AddTransactionForm { transactionNote: string } -export default async function addBurialSiteContractTransaction( - burialSiteContractTransactionForm: AddTransactionForm, +export default async function addContractTransaction( + contractTransactionForm: AddTransactionForm, user: User ): Promise { const database = await acquireConnection() @@ -27,12 +27,12 @@ export default async function addBurialSiteContractTransaction( const maxIndexResult = database .prepare( `select transactionIndex - from BurialSiteContractTransactions - where burialSiteContractId = ? + from ContractTransactions + where contractId = ? order by transactionIndex desc limit 1` ) - .get(burialSiteContractTransactionForm.burialSiteContractId) as + .get(contractTransactionForm.contractId) as | { transactionIndex: number } | undefined @@ -42,18 +42,18 @@ export default async function addBurialSiteContractTransaction( const rightNow = new Date() - const transactionDate = burialSiteContractTransactionForm.transactionDateString - ? dateStringToInteger(burialSiteContractTransactionForm.transactionDateString) + const transactionDate = contractTransactionForm.transactionDateString + ? dateStringToInteger(contractTransactionForm.transactionDateString) : dateToInteger(rightNow) - const transactionTime = burialSiteContractTransactionForm.transactionTimeString - ? timeStringToInteger(burialSiteContractTransactionForm.transactionTimeString) + const transactionTime = contractTransactionForm.transactionTimeString + ? timeStringToInteger(contractTransactionForm.transactionTimeString) : dateToTimeInteger(rightNow) database .prepare( - `insert into BurialSiteContractTransactions ( - burialSiteContractId, transactionIndex, + `insert into ContractTransactions ( + contractId, transactionIndex, transactionDate, transactionTime, transactionAmount, externalReceiptNumber, transactionNote, recordCreate_userName, recordCreate_timeMillis, @@ -61,13 +61,13 @@ export default async function addBurialSiteContractTransaction( values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` ) .run( - burialSiteContractTransactionForm.burialSiteContractId, + contractTransactionForm.contractId, transactionIndex, transactionDate, transactionTime, - burialSiteContractTransactionForm.transactionAmount, - burialSiteContractTransactionForm.externalReceiptNumber, - burialSiteContractTransactionForm.transactionNote, + contractTransactionForm.transactionAmount, + contractTransactionForm.externalReceiptNumber, + contractTransactionForm.transactionNote, user.userName, rightNow.getTime(), user.userName, diff --git a/database/addOrUpdateBurialSiteContractField.d.ts b/database/addOrUpdateBurialSiteContractField.d.ts deleted file mode 100644 index f47a7d00..00000000 --- a/database/addOrUpdateBurialSiteContractField.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { PoolConnection } from 'better-sqlite-pool'; -export interface BurialSiteContractFieldForm { - burialSiteContractId: string | number; - contractTypeFieldId: string | number; - fieldValue: string; -} -export default function addOrUpdateBurialSiteContractField(fieldForm: BurialSiteContractFieldForm, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/addOrUpdateContractField.d.ts b/database/addOrUpdateContractField.d.ts new file mode 100644 index 00000000..71dac326 --- /dev/null +++ b/database/addOrUpdateContractField.d.ts @@ -0,0 +1,7 @@ +import type { PoolConnection } from 'better-sqlite-pool'; +export interface ContractFieldForm { + contractId: string | number; + contractTypeFieldId: string | number; + fieldValue: string; +} +export default function addOrUpdateContractField(fieldForm: ContractFieldForm, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/addOrUpdateBurialSiteContractField.js b/database/addOrUpdateContractField.js similarity index 59% rename from database/addOrUpdateBurialSiteContractField.js rename to database/addOrUpdateContractField.js index 67f38213..32f6275e 100644 --- a/database/addOrUpdateBurialSiteContractField.js +++ b/database/addOrUpdateContractField.js @@ -1,25 +1,25 @@ import { acquireConnection } from './pool.js'; -export default async function addOrUpdateBurialSiteContractField(fieldForm, user, connectedDatabase) { +export default async function addOrUpdateContractField(fieldForm, user, connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); const rightNowMillis = Date.now(); let result = database - .prepare(`update BurialSiteContractFields + .prepare(`update ContractFields set fieldValue = ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ?, recordDelete_userName = null, recordDelete_timeMillis = null - where burialSiteContractId = ? + where contractId = ? and contractTypeFieldId = ?`) - .run(fieldForm.fieldValue, user.userName, rightNowMillis, fieldForm.burialSiteContractId, fieldForm.contractTypeFieldId); + .run(fieldForm.fieldValue, user.userName, rightNowMillis, fieldForm.contractId, fieldForm.contractTypeFieldId); if (result.changes === 0) { result = database - .prepare(`insert into BurialSiteContractFields ( - burialSiteContractId, contractTypeFieldId, fieldValue, + .prepare(`insert into ContractFields ( + contractId, contractTypeFieldId, fieldValue, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?)`) - .run(fieldForm.burialSiteContractId, fieldForm.contractTypeFieldId, fieldForm.fieldValue, user.userName, rightNowMillis, user.userName, rightNowMillis); + .run(fieldForm.contractId, fieldForm.contractTypeFieldId, fieldForm.fieldValue, user.userName, rightNowMillis, user.userName, rightNowMillis); } if (connectedDatabase === undefined) { database.release(); diff --git a/database/addOrUpdateBurialSiteContractField.ts b/database/addOrUpdateContractField.ts similarity index 72% rename from database/addOrUpdateBurialSiteContractField.ts rename to database/addOrUpdateContractField.ts index 2fbb6567..6329cbe6 100644 --- a/database/addOrUpdateBurialSiteContractField.ts +++ b/database/addOrUpdateContractField.ts @@ -2,14 +2,14 @@ import type { PoolConnection } from 'better-sqlite-pool' import { acquireConnection } from './pool.js' -export interface BurialSiteContractFieldForm { - burialSiteContractId: string | number +export interface ContractFieldForm { + contractId: string | number contractTypeFieldId: string | number fieldValue: string } -export default async function addOrUpdateBurialSiteContractField( - fieldForm: BurialSiteContractFieldForm, +export default async function addOrUpdateContractField( + fieldForm: ContractFieldForm, user: User, connectedDatabase?: PoolConnection ): Promise { @@ -19,34 +19,34 @@ export default async function addOrUpdateBurialSiteContractField( let result = database .prepare( - `update BurialSiteContractFields + `update ContractFields set fieldValue = ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ?, recordDelete_userName = null, recordDelete_timeMillis = null - where burialSiteContractId = ? + where contractId = ? and contractTypeFieldId = ?` ) .run( fieldForm.fieldValue, user.userName, rightNowMillis, - fieldForm.burialSiteContractId, + fieldForm.contractId, fieldForm.contractTypeFieldId ) if (result.changes === 0) { result = database .prepare( - `insert into BurialSiteContractFields ( - burialSiteContractId, contractTypeFieldId, fieldValue, + `insert into ContractFields ( + contractId, contractTypeFieldId, fieldValue, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?)` ) .run( - fieldForm.burialSiteContractId, + fieldForm.contractId, fieldForm.contractTypeFieldId, fieldForm.fieldValue, user.userName, diff --git a/database/addWorkOrder.d.ts b/database/addWorkOrder.d.ts index 4c96d69b..4131e3a2 100644 --- a/database/addWorkOrder.d.ts +++ b/database/addWorkOrder.d.ts @@ -4,6 +4,6 @@ export interface AddWorkOrderForm { workOrderDescription: string; workOrderOpenDateString?: string; workOrderCloseDateString?: string; - burialSiteContractId?: string; + contractId?: string; } export default function addWorkOrder(workOrderForm: AddWorkOrderForm, user: User): Promise; diff --git a/database/addWorkOrder.js b/database/addWorkOrder.js index 9a91b40e..6c68ddc8 100644 --- a/database/addWorkOrder.js +++ b/database/addWorkOrder.js @@ -1,5 +1,5 @@ import { dateStringToInteger, dateToInteger } from '@cityssm/utils-datetime'; -import addWorkOrderBurialSiteContract from './addWorkOrderBurialSiteContract.js'; +import addWorkOrderContract from './addWorkOrderContract.js'; import getNextWorkOrderNumber from './getNextWorkOrderNumber.js'; import { acquireConnection } from './pool.js'; export default async function addWorkOrder(workOrderForm, user) { @@ -22,10 +22,10 @@ export default async function addWorkOrder(workOrderForm, user) { ? undefined : dateStringToInteger(workOrderForm.workOrderCloseDateString), user.userName, rightNow.getTime(), user.userName, rightNow.getTime()); const workOrderId = result.lastInsertRowid; - if ((workOrderForm.burialSiteContractId ?? '') !== '') { - await addWorkOrderBurialSiteContract({ + if ((workOrderForm.contractId ?? '') !== '') { + await addWorkOrderContract({ workOrderId, - burialSiteContractId: workOrderForm.burialSiteContractId + contractId: workOrderForm.contractId }, user, database); } database.release(); diff --git a/database/addWorkOrder.ts b/database/addWorkOrder.ts index 5255045a..ad4a1d50 100644 --- a/database/addWorkOrder.ts +++ b/database/addWorkOrder.ts @@ -4,7 +4,7 @@ import { dateToInteger } from '@cityssm/utils-datetime' -import addWorkOrderBurialSiteContract from './addWorkOrderBurialSiteContract.js' +import addWorkOrderContract from './addWorkOrderContract.js' import getNextWorkOrderNumber from './getNextWorkOrderNumber.js' import { acquireConnection } from './pool.js' @@ -14,7 +14,7 @@ export interface AddWorkOrderForm { workOrderDescription: string workOrderOpenDateString?: string workOrderCloseDateString?: string - burialSiteContractId?: string + contractId?: string } export default async function addWorkOrder( @@ -62,11 +62,11 @@ export default async function addWorkOrder( const workOrderId = result.lastInsertRowid as number - if ((workOrderForm.burialSiteContractId ?? '') !== '') { - await addWorkOrderBurialSiteContract( + if ((workOrderForm.contractId ?? '') !== '') { + await addWorkOrderContract( { workOrderId, - burialSiteContractId: workOrderForm.burialSiteContractId as string + contractId: workOrderForm.contractId as string }, user, database diff --git a/database/addWorkOrderBurialSiteContract.d.ts b/database/addWorkOrderBurialSiteContract.d.ts deleted file mode 100644 index eef8b3e7..00000000 --- a/database/addWorkOrderBurialSiteContract.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { PoolConnection } from 'better-sqlite-pool'; -export interface AddWorkOrderBurialSiteContractOccupancyForm { - workOrderId: number | string; - burialSiteContractId: number | string; -} -export default function addWorkOrderBurialSiteContract(addForm: AddWorkOrderBurialSiteContractOccupancyForm, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/addWorkOrderContract.d.ts b/database/addWorkOrderContract.d.ts new file mode 100644 index 00000000..acf7a95a --- /dev/null +++ b/database/addWorkOrderContract.d.ts @@ -0,0 +1,6 @@ +import type { PoolConnection } from 'better-sqlite-pool'; +export interface AddWorkOrderContractOccupancyForm { + workOrderId: number | string; + contractId: number | string; +} +export default function addWorkOrderContract(addForm: AddWorkOrderContractOccupancyForm, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/addWorkOrderBurialSiteContract.js b/database/addWorkOrderContract.js similarity index 61% rename from database/addWorkOrderBurialSiteContract.js rename to database/addWorkOrderContract.js index 8b0a07c0..1d94fb7d 100644 --- a/database/addWorkOrderBurialSiteContract.js +++ b/database/addWorkOrderContract.js @@ -1,27 +1,27 @@ import { acquireConnection } from './pool.js'; -export default async function addWorkOrderBurialSiteContract(addForm, user, connectedDatabase) { +export default async function addWorkOrderContract(addForm, user, connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); const rightNowMillis = Date.now(); const recordDeleteTimeMillis = database .prepare(`select recordDelete_timeMillis - from WorkOrderBurialSiteContracts + from WorkOrderContracts where workOrderId = ? - and burialSiteContractId = ?`) + and contractId = ?`) .pluck() - .get(addForm.workOrderId, addForm.burialSiteContractId); + .get(addForm.workOrderId, addForm.contractId); if (recordDeleteTimeMillis === undefined) { database - .prepare(`insert into WorkOrderBurialSiteContracts ( - workOrderId, burialSiteContractId, + .prepare(`insert into WorkOrderContracts ( + workOrderId, contractId, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?)`) - .run(addForm.workOrderId, addForm.burialSiteContractId, user.userName, rightNowMillis, user.userName, rightNowMillis); + .run(addForm.workOrderId, addForm.contractId, user.userName, rightNowMillis, user.userName, rightNowMillis); } else { if (recordDeleteTimeMillis !== null) { database - .prepare(`update WorkOrderBurialSiteContracts + .prepare(`update WorkOrderContracts set recordCreate_userName = ?, recordCreate_timeMillis = ?, recordUpdate_userName = ?, @@ -29,8 +29,8 @@ export default async function addWorkOrderBurialSiteContract(addForm, user, conn recordDelete_userName = null, recordDelete_timeMillis = null where workOrderId = ? - and burialSiteContractId = ?`) - .run(user.userName, rightNowMillis, user.userName, rightNowMillis, addForm.workOrderId, addForm.burialSiteContractId); + and contractId = ?`) + .run(user.userName, rightNowMillis, user.userName, rightNowMillis, addForm.workOrderId, addForm.contractId); } } if (connectedDatabase === undefined) { diff --git a/database/addWorkOrderBurialSiteContract.ts b/database/addWorkOrderContract.ts similarity index 72% rename from database/addWorkOrderBurialSiteContract.ts rename to database/addWorkOrderContract.ts index ce6fdff4..5d3c3c6b 100644 --- a/database/addWorkOrderBurialSiteContract.ts +++ b/database/addWorkOrderContract.ts @@ -2,13 +2,13 @@ import type { PoolConnection } from 'better-sqlite-pool' import { acquireConnection } from './pool.js' -export interface AddWorkOrderBurialSiteContractOccupancyForm { +export interface AddWorkOrderContractOccupancyForm { workOrderId: number | string - burialSiteContractId: number | string + contractId: number | string } -export default async function addWorkOrderBurialSiteContract( - addForm: AddWorkOrderBurialSiteContractOccupancyForm, +export default async function addWorkOrderContract( + addForm: AddWorkOrderContractOccupancyForm, user: User, connectedDatabase?: PoolConnection ): Promise { @@ -19,28 +19,28 @@ export default async function addWorkOrderBurialSiteContract( const recordDeleteTimeMillis: number | null | undefined = database .prepare( `select recordDelete_timeMillis - from WorkOrderBurialSiteContracts + from WorkOrderContracts where workOrderId = ? - and burialSiteContractId = ?` + and contractId = ?` ) .pluck() .get( addForm.workOrderId, - addForm.burialSiteContractId + addForm.contractId ) as number | null | undefined if (recordDeleteTimeMillis === undefined) { database .prepare( - `insert into WorkOrderBurialSiteContracts ( - workOrderId, burialSiteContractId, + `insert into WorkOrderContracts ( + workOrderId, contractId, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?)` ) .run( addForm.workOrderId, - addForm.burialSiteContractId, + addForm.contractId, user.userName, rightNowMillis, user.userName, @@ -50,7 +50,7 @@ export default async function addWorkOrderBurialSiteContract( if (recordDeleteTimeMillis !== null) { database .prepare( - `update WorkOrderBurialSiteContracts + `update WorkOrderContracts set recordCreate_userName = ?, recordCreate_timeMillis = ?, recordUpdate_userName = ?, @@ -58,7 +58,7 @@ export default async function addWorkOrderBurialSiteContract( recordDelete_userName = null, recordDelete_timeMillis = null where workOrderId = ? - and burialSiteContractId = ?` + and contractId = ?` ) .run( user.userName, @@ -66,7 +66,7 @@ export default async function addWorkOrderBurialSiteContract( user.userName, rightNowMillis, addForm.workOrderId, - addForm.burialSiteContractId + addForm.contractId ) } } diff --git a/database/cleanupDatabase.js b/database/cleanupDatabase.js index 9e813098..87919327 100644 --- a/database/cleanupDatabase.js +++ b/database/cleanupDatabase.js @@ -26,7 +26,7 @@ export default async function cleanupDatabase(user) { * Work Order Burial Site Contracts */ inactivatedRecordCount += database - .prepare(`update WorkOrderBurialSiteContracts + .prepare(`update WorkOrderContracts set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null @@ -34,7 +34,7 @@ export default async function cleanupDatabase(user) { select workOrderId from WorkOrders where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database - .prepare('delete from WorkOrderBurialSiteContracts where recordDelete_timeMillis <= ?') + .prepare('delete from WorkOrderContracts where recordDelete_timeMillis <= ?') .run(recordDeleteTimeMillisMin).changes; /* * Work Order Burial Sites @@ -71,7 +71,7 @@ export default async function cleanupDatabase(user) { .prepare(`delete from WorkOrders where recordDelete_timeMillis <= ? and workOrderId not in (select workOrderId from WorkOrderComments) - and workOrderId not in (select workOrderId from WorkOrderBurialSiteContracts) + and workOrderId not in (select workOrderId from WorkOrderContracts) and workOrderId not in (select workOrderId from WorkOrderBurialSites) and workOrderId not in (select workOrderId from WorkOrderMilestones)`) .run(recordDeleteTimeMillisMin).changes; @@ -96,51 +96,51 @@ export default async function cleanupDatabase(user) { * Burial Site Contract Comments */ inactivatedRecordCount += database - .prepare(`update BurialSiteContractComments + .prepare(`update ContractComments set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteContractId in ( - select burialSiteContractId from BurialSiteContracts where recordDelete_timeMillis is not null)`) + and contractId in ( + select contractId from Contracts where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database - .prepare('delete from BurialSiteContractComments where recordDelete_timeMillis <= ?') + .prepare('delete from ContractComments where recordDelete_timeMillis <= ?') .run(recordDeleteTimeMillisMin).changes; /* * Burial Site Contract Fields */ inactivatedRecordCount += database - .prepare(`update BurialSiteContractFields + .prepare(`update ContractFields set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteContractId in (select burialSiteContractId from BurialSiteContracts where recordDelete_timeMillis is not null)`) + and contractId in (select contractId from Contracts where recordDelete_timeMillis is not null)`) .run(user.userName, rightNowMillis).changes; purgedRecordCount += database - .prepare('delete from BurialSiteContractFields where recordDelete_timeMillis <= ?') + .prepare('delete from ContractFields where recordDelete_timeMillis <= ?') .run(recordDeleteTimeMillisMin).changes; /* * Burial Site Contract Fees/Transactions * - Maintain financials, do not delete related. */ purgedRecordCount += database - .prepare('delete from BurialSiteContractFees where recordDelete_timeMillis <= ?') + .prepare('delete from ContractFees where recordDelete_timeMillis <= ?') .run(recordDeleteTimeMillisMin).changes; purgedRecordCount += database - .prepare('delete from BurialSiteContractTransactions where recordDelete_timeMillis <= ?') + .prepare('delete from ContractTransactions where recordDelete_timeMillis <= ?') .run(recordDeleteTimeMillisMin).changes; /* * Burial Site Contracts */ purgedRecordCount += database - .prepare(`delete from BurialSiteContracts + .prepare(`delete from Contracts where recordDelete_timeMillis <= ? - and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractComments) - and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractFees) - and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractFields) - and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractInterments) - and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractTransactions) - and burialSiteContractId not in (select burialSiteContractId from WorkOrderBurialSiteContracts)`) + and contractId not in (select contractId from ContractComments) + and contractId not in (select contractId from ContractFees) + and contractId not in (select contractId from ContractFields) + and contractId not in (select contractId from ContractInterments) + and contractId not in (select contractId from ContractTransactions) + and contractId not in (select contractId from WorkOrderContracts)`) .run(recordDeleteTimeMillisMin).changes; /* * Fees @@ -155,7 +155,7 @@ export default async function cleanupDatabase(user) { purgedRecordCount += database .prepare(`delete from Fees where recordDelete_timeMillis <= ? - and feeId not in (select feeId from BurialSiteContractFees)`) + and feeId not in (select feeId from ContractFees)`) .run(recordDeleteTimeMillisMin).changes; /* * Fee Categories @@ -178,7 +178,7 @@ export default async function cleanupDatabase(user) { purgedRecordCount += database .prepare(`delete from ContractTypeFields where recordDelete_timeMillis <= ? - and contractTypeFieldId not in (select contractTypeFieldId from BurialSiteContractFields)`) + and contractTypeFieldId not in (select contractTypeFieldId from ContractFields)`) .run(recordDeleteTimeMillisMin).changes; /* * Occupancy Type Prints @@ -201,7 +201,7 @@ export default async function cleanupDatabase(user) { where recordDelete_timeMillis <= ? and contractTypeId not in (select contractTypeId from ContractTypeFields) and contractTypeId not in (select contractTypeId from ContractTypePrints) - and contractTypeId not in (select contractTypeId from BurialSiteContracts) + and contractTypeId not in (select contractTypeId from Contracts) and contractTypeId not in (select contractTypeId from Fees)`) .run(recordDeleteTimeMillisMin).changes; /* @@ -245,7 +245,7 @@ export default async function cleanupDatabase(user) { where recordDelete_timeMillis <= ? and burialSiteId not in (select burialSiteId from BurialSiteComments) and burialSiteId not in (select burialSiteId from BurialSiteFields) - and burialSiteId not in (select burialSiteId from BurialSiteContracts) + and burialSiteId not in (select burialSiteId from Contracts) and burialSiteId not in (select burialSiteId from WorkOrderLots)`) .run(recordDeleteTimeMillisMin).changes; /* diff --git a/database/cleanupDatabase.ts b/database/cleanupDatabase.ts index f16fbc25..cf6dca1f 100644 --- a/database/cleanupDatabase.ts +++ b/database/cleanupDatabase.ts @@ -42,7 +42,7 @@ export default async function cleanupDatabase( inactivatedRecordCount += database .prepare( - `update WorkOrderBurialSiteContracts + `update WorkOrderContracts set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null @@ -53,7 +53,7 @@ export default async function cleanupDatabase( purgedRecordCount += database .prepare( - 'delete from WorkOrderBurialSiteContracts where recordDelete_timeMillis <= ?' + 'delete from WorkOrderContracts where recordDelete_timeMillis <= ?' ) .run(recordDeleteTimeMillisMin).changes @@ -108,7 +108,7 @@ export default async function cleanupDatabase( `delete from WorkOrders where recordDelete_timeMillis <= ? and workOrderId not in (select workOrderId from WorkOrderComments) - and workOrderId not in (select workOrderId from WorkOrderBurialSiteContracts) + and workOrderId not in (select workOrderId from WorkOrderContracts) and workOrderId not in (select workOrderId from WorkOrderBurialSites) and workOrderId not in (select workOrderId from WorkOrderMilestones)` ) @@ -145,18 +145,18 @@ export default async function cleanupDatabase( inactivatedRecordCount += database .prepare( - `update BurialSiteContractComments + `update ContractComments set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteContractId in ( - select burialSiteContractId from BurialSiteContracts where recordDelete_timeMillis is not null)` + and contractId in ( + select contractId from Contracts where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes purgedRecordCount += database .prepare( - 'delete from BurialSiteContractComments where recordDelete_timeMillis <= ?' + 'delete from ContractComments where recordDelete_timeMillis <= ?' ) .run(recordDeleteTimeMillisMin).changes @@ -166,17 +166,17 @@ export default async function cleanupDatabase( inactivatedRecordCount += database .prepare( - `update BurialSiteContractFields + `update ContractFields set recordDelete_userName = ?, recordDelete_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteContractId in (select burialSiteContractId from BurialSiteContracts where recordDelete_timeMillis is not null)` + and contractId in (select contractId from Contracts where recordDelete_timeMillis is not null)` ) .run(user.userName, rightNowMillis).changes purgedRecordCount += database .prepare( - 'delete from BurialSiteContractFields where recordDelete_timeMillis <= ?' + 'delete from ContractFields where recordDelete_timeMillis <= ?' ) .run(recordDeleteTimeMillisMin).changes @@ -187,13 +187,13 @@ export default async function cleanupDatabase( purgedRecordCount += database .prepare( - 'delete from BurialSiteContractFees where recordDelete_timeMillis <= ?' + 'delete from ContractFees where recordDelete_timeMillis <= ?' ) .run(recordDeleteTimeMillisMin).changes purgedRecordCount += database .prepare( - 'delete from BurialSiteContractTransactions where recordDelete_timeMillis <= ?' + 'delete from ContractTransactions where recordDelete_timeMillis <= ?' ) .run(recordDeleteTimeMillisMin).changes @@ -203,14 +203,14 @@ export default async function cleanupDatabase( purgedRecordCount += database .prepare( - `delete from BurialSiteContracts + `delete from Contracts where recordDelete_timeMillis <= ? - and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractComments) - and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractFees) - and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractFields) - and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractInterments) - and burialSiteContractId not in (select burialSiteContractId from BurialSiteContractTransactions) - and burialSiteContractId not in (select burialSiteContractId from WorkOrderBurialSiteContracts)` + and contractId not in (select contractId from ContractComments) + and contractId not in (select contractId from ContractFees) + and contractId not in (select contractId from ContractFields) + and contractId not in (select contractId from ContractInterments) + and contractId not in (select contractId from ContractTransactions) + and contractId not in (select contractId from WorkOrderContracts)` ) .run(recordDeleteTimeMillisMin).changes @@ -232,7 +232,7 @@ export default async function cleanupDatabase( .prepare( `delete from Fees where recordDelete_timeMillis <= ? - and feeId not in (select feeId from BurialSiteContractFees)` + and feeId not in (select feeId from ContractFees)` ) .run(recordDeleteTimeMillisMin).changes @@ -266,7 +266,7 @@ export default async function cleanupDatabase( .prepare( `delete from ContractTypeFields where recordDelete_timeMillis <= ? - and contractTypeFieldId not in (select contractTypeFieldId from BurialSiteContractFields)` + and contractTypeFieldId not in (select contractTypeFieldId from ContractFields)` ) .run(recordDeleteTimeMillisMin).changes @@ -300,7 +300,7 @@ export default async function cleanupDatabase( where recordDelete_timeMillis <= ? and contractTypeId not in (select contractTypeId from ContractTypeFields) and contractTypeId not in (select contractTypeId from ContractTypePrints) - and contractTypeId not in (select contractTypeId from BurialSiteContracts) + and contractTypeId not in (select contractTypeId from Contracts) and contractTypeId not in (select contractTypeId from Fees)` ) .run(recordDeleteTimeMillisMin).changes @@ -363,7 +363,7 @@ export default async function cleanupDatabase( where recordDelete_timeMillis <= ? and burialSiteId not in (select burialSiteId from BurialSiteComments) and burialSiteId not in (select burialSiteId from BurialSiteFields) - and burialSiteId not in (select burialSiteId from BurialSiteContracts) + and burialSiteId not in (select burialSiteId from Contracts) and burialSiteId not in (select burialSiteId from WorkOrderLots)` ) .run(recordDeleteTimeMillisMin).changes diff --git a/database/copyBurialSiteContract.d.ts b/database/copyBurialSiteContract.d.ts deleted file mode 100644 index 63d08900..00000000 --- a/database/copyBurialSiteContract.d.ts +++ /dev/null @@ -1 +0,0 @@ -export default function copyBurialSiteContract(oldBurialSiteContractId: number | string, user: User): Promise; diff --git a/database/copyBurialSiteContract.js b/database/copyBurialSiteContract.js deleted file mode 100644 index 8692a3e7..00000000 --- a/database/copyBurialSiteContract.js +++ /dev/null @@ -1,62 +0,0 @@ -import { dateToString } from '@cityssm/utils-datetime'; -import addBurialSiteContract from './addBurialSiteContract.js'; -import addBurialSiteContractComment from './addBurialSiteContractComment.js'; -// import addBurialSiteContractOccupant from './addBurialSiteContractOccupant.js' -import getBurialSiteContract from './getBurialSiteContract.js'; -import { acquireConnection } from './pool.js'; -export default async function copyBurialSiteContract(oldBurialSiteContractId, user) { - const database = await acquireConnection(); - const oldBurialSiteContract = await getBurialSiteContract(oldBurialSiteContractId, database); - const newBurialSiteContractId = await addBurialSiteContract({ - burialSiteId: oldBurialSiteContract.burialSiteId ?? '', - contractTypeId: oldBurialSiteContract.contractTypeId, - contractStartDateString: dateToString(new Date()), - contractEndDateString: '' - }, user, database); - /* - * Copy Fields - */ - const rightNowMillis = Date.now(); - for (const field of oldBurialSiteContract.burialSiteContractFields ?? []) { - database - .prepare(`insert into BurialSiteContractFields ( - burialSiteContractId, contractTypeFieldId, fieldValue, - recordCreate_userName, recordCreate_timeMillis, - recordUpdate_userName, recordUpdate_timeMillis) - values (?, ?, ?, ?, ?, ?, ?)`) - .run(newBurialSiteContractId, field.contractTypeFieldId, field.fieldValue, user.userName, rightNowMillis, user.userName, rightNowMillis); - } - /* - * Copy Occupants - */ - /* - for (const occupant of oldBurialSiteContract.burialSiteContractOccupants ?? []) { - await addBurialSiteContractOccupant( - { - burialSiteContractId: newBurialSiteContractId, - lotOccupantTypeId: occupant.lotOccupantTypeId!, - occupantName: occupant.occupantName!, - occupantFamilyName: occupant.occupantFamilyName!, - occupantAddress1: occupant.occupantAddress1!, - occupantAddress2: occupant.occupantAddress2!, - occupantCity: occupant.occupantCity!, - occupantProvince: occupant.occupantProvince!, - occupantPostalCode: occupant.occupantPostalCode!, - occupantPhoneNumber: occupant.occupantPhoneNumber!, - occupantEmailAddress: occupant.occupantEmailAddress! - }, - user, - database - ) - } - */ - /* - * Add Comment - */ - await addBurialSiteContractComment({ - burialSiteContractId: newBurialSiteContractId, - comment: `New record copied from #${oldBurialSiteContractId}.` - }, user); - database.release(); - return newBurialSiteContractId; -} diff --git a/database/copyContract.d.ts b/database/copyContract.d.ts new file mode 100644 index 00000000..afe409ba --- /dev/null +++ b/database/copyContract.d.ts @@ -0,0 +1 @@ +export default function copyContract(oldContractId: number | string, user: User): Promise; diff --git a/database/copyContract.js b/database/copyContract.js new file mode 100644 index 00000000..42e97e5f --- /dev/null +++ b/database/copyContract.js @@ -0,0 +1,62 @@ +import { dateToString } from '@cityssm/utils-datetime'; +import addContract from './addContract.js'; +import addContractComment from './addContractComment.js'; +// import addContractOccupant from './addContractOccupant.js' +import getContract from './getContract.js'; +import { acquireConnection } from './pool.js'; +export default async function copyContract(oldContractId, user) { + const database = await acquireConnection(); + const oldContract = (await getContract(oldContractId, database)); + const newContractId = await addContract({ + burialSiteId: oldContract.burialSiteId ?? '', + contractTypeId: oldContract.contractTypeId, + contractStartDateString: dateToString(new Date()), + contractEndDateString: '' + }, user, database); + /* + * Copy Fields + */ + const rightNowMillis = Date.now(); + for (const field of oldContract.contractFields ?? []) { + database + .prepare(`insert into ContractFields ( + contractId, contractTypeFieldId, fieldValue, + recordCreate_userName, recordCreate_timeMillis, + recordUpdate_userName, recordUpdate_timeMillis) + values (?, ?, ?, ?, ?, ?, ?)`) + .run(newContractId, field.contractTypeFieldId, field.fieldValue, user.userName, rightNowMillis, user.userName, rightNowMillis); + } + /* + * Copy Occupants + */ + /* + for (const occupant of oldContract.contractOccupants ?? []) { + await addContractOccupant( + { + contractId: newContractId, + lotOccupantTypeId: occupant.lotOccupantTypeId!, + occupantName: occupant.occupantName!, + occupantFamilyName: occupant.occupantFamilyName!, + occupantAddress1: occupant.occupantAddress1!, + occupantAddress2: occupant.occupantAddress2!, + occupantCity: occupant.occupantCity!, + occupantProvince: occupant.occupantProvince!, + occupantPostalCode: occupant.occupantPostalCode!, + occupantPhoneNumber: occupant.occupantPhoneNumber!, + occupantEmailAddress: occupant.occupantEmailAddress! + }, + user, + database + ) + } + */ + /* + * Add Comment + */ + await addContractComment({ + contractId: newContractId, + comment: `New record copied from #${oldContractId}.` + }, user); + database.release(); + return newContractId; +} diff --git a/database/copyBurialSiteContract.ts b/database/copyContract.ts similarity index 51% rename from database/copyBurialSiteContract.ts rename to database/copyContract.ts index afca0bc7..a038c650 100644 --- a/database/copyBurialSiteContract.ts +++ b/database/copyContract.ts @@ -1,25 +1,28 @@ import { dateToString } from '@cityssm/utils-datetime' -import type { BurialSiteContract } from '../types/recordTypes.js' +import type { Contract } from '../types/recordTypes.js' -import addBurialSiteContract from './addBurialSiteContract.js' -import addBurialSiteContractComment from './addBurialSiteContractComment.js' -// import addBurialSiteContractOccupant from './addBurialSiteContractOccupant.js' -import getBurialSiteContract from './getBurialSiteContract.js' +import addContract from './addContract.js' +import addContractComment from './addContractComment.js' +// import addContractOccupant from './addContractOccupant.js' +import getContract from './getContract.js' import { acquireConnection } from './pool.js' -export default async function copyBurialSiteContract( - oldBurialSiteContractId: number | string, +export default async function copyContract( + oldContractId: number | string, user: User ): Promise { const database = await acquireConnection() - const oldBurialSiteContract = await getBurialSiteContract(oldBurialSiteContractId, database) as BurialSiteContract + const oldContract = (await getContract( + oldContractId, + database + )) as Contract - const newBurialSiteContractId = await addBurialSiteContract( + const newContractId = await addContract( { - burialSiteId: oldBurialSiteContract.burialSiteId ?? '', - contractTypeId: oldBurialSiteContract.contractTypeId, + burialSiteId: oldContract.burialSiteId ?? '', + contractTypeId: oldContract.contractTypeId, contractStartDateString: dateToString(new Date()), contractEndDateString: '' }, @@ -33,17 +36,17 @@ export default async function copyBurialSiteContract( const rightNowMillis = Date.now() - for (const field of oldBurialSiteContract.burialSiteContractFields ?? []) { + for (const field of oldContract.contractFields ?? []) { database .prepare( - `insert into BurialSiteContractFields ( - burialSiteContractId, contractTypeFieldId, fieldValue, + `insert into ContractFields ( + contractId, contractTypeFieldId, fieldValue, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?)` ) .run( - newBurialSiteContractId, + newContractId, field.contractTypeFieldId, field.fieldValue, user.userName, @@ -58,10 +61,10 @@ export default async function copyBurialSiteContract( */ /* - for (const occupant of oldBurialSiteContract.burialSiteContractOccupants ?? []) { - await addBurialSiteContractOccupant( + for (const occupant of oldContract.contractOccupants ?? []) { + await addContractOccupant( { - burialSiteContractId: newBurialSiteContractId, + contractId: newContractId, lotOccupantTypeId: occupant.lotOccupantTypeId!, occupantName: occupant.occupantName!, occupantFamilyName: occupant.occupantFamilyName!, @@ -83,12 +86,15 @@ export default async function copyBurialSiteContract( * Add Comment */ - await addBurialSiteContractComment({ - burialSiteContractId: newBurialSiteContractId, - comment: `New record copied from #${oldBurialSiteContractId}.` - }, user) + await addContractComment( + { + contractId: newContractId, + comment: `New record copied from #${oldContractId}.` + }, + user + ) database.release() - return newBurialSiteContractId + return newContractId } diff --git a/database/deleteBurialSiteContractFee.d.ts b/database/deleteBurialSiteContractFee.d.ts deleted file mode 100644 index 9ad5a7fc..00000000 --- a/database/deleteBurialSiteContractFee.d.ts +++ /dev/null @@ -1 +0,0 @@ -export default function deleteBurialSiteContractFee(burialSiteContractId: number | string, feeId: number | string, user: User): Promise; diff --git a/database/deleteBurialSiteContractField.d.ts b/database/deleteBurialSiteContractField.d.ts deleted file mode 100644 index 6a71c485..00000000 --- a/database/deleteBurialSiteContractField.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { PoolConnection } from 'better-sqlite-pool'; -export default function deleteBurialSiteContractField(burialSiteContractId: number | string, contractTypeFieldId: number | string, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/deleteBurialSiteContractInterment.d.ts b/database/deleteBurialSiteContractInterment.d.ts deleted file mode 100644 index 7961bfa4..00000000 --- a/database/deleteBurialSiteContractInterment.d.ts +++ /dev/null @@ -1 +0,0 @@ -export default function deleteBurialSiteContractInterment(burialSiteContractId: number | string, intermentNumber: number | string, user: User): Promise; diff --git a/database/deleteBurialSiteContractTransaction.d.ts b/database/deleteBurialSiteContractTransaction.d.ts deleted file mode 100644 index 12a0577c..00000000 --- a/database/deleteBurialSiteContractTransaction.d.ts +++ /dev/null @@ -1 +0,0 @@ -export default function deleteBurialSiteContractTransaction(burialSiteContractId: number | string, transactionIndex: number | string, user: User): Promise; diff --git a/database/deleteContractFee.d.ts b/database/deleteContractFee.d.ts new file mode 100644 index 00000000..842b3075 --- /dev/null +++ b/database/deleteContractFee.d.ts @@ -0,0 +1 @@ +export default function deleteContractFee(contractId: number | string, feeId: number | string, user: User): Promise; diff --git a/database/deleteBurialSiteContractFee.js b/database/deleteContractFee.js similarity index 61% rename from database/deleteBurialSiteContractFee.js rename to database/deleteContractFee.js index 85c3a41d..8ad368f5 100644 --- a/database/deleteBurialSiteContractFee.js +++ b/database/deleteContractFee.js @@ -1,13 +1,13 @@ import { acquireConnection } from './pool.js'; -export default async function deleteBurialSiteContractFee(burialSiteContractId, feeId, user) { +export default async function deleteContractFee(contractId, feeId, user) { const database = await acquireConnection(); const result = database .prepare(`update BurialSteContractFees set recordDelete_userName = ?, recordDelete_timeMillis = ? - where burialSiteContractId = ? + where contractId = ? and feeId = ?`) - .run(user.userName, Date.now(), burialSiteContractId, feeId); + .run(user.userName, Date.now(), contractId, feeId); database.release(); return result.changes > 0; } diff --git a/database/deleteBurialSiteContractFee.ts b/database/deleteContractFee.ts similarity index 65% rename from database/deleteBurialSiteContractFee.ts rename to database/deleteContractFee.ts index c3c52a9a..ebf26015 100644 --- a/database/deleteBurialSiteContractFee.ts +++ b/database/deleteContractFee.ts @@ -1,7 +1,7 @@ import { acquireConnection } from './pool.js' -export default async function deleteBurialSiteContractFee( - burialSiteContractId: number | string, +export default async function deleteContractFee( + contractId: number | string, feeId: number | string, user: User ): Promise { @@ -12,10 +12,10 @@ export default async function deleteBurialSiteContractFee( `update BurialSteContractFees set recordDelete_userName = ?, recordDelete_timeMillis = ? - where burialSiteContractId = ? + where contractId = ? and feeId = ?` ) - .run(user.userName, Date.now(), burialSiteContractId, feeId) + .run(user.userName, Date.now(), contractId, feeId) database.release() diff --git a/database/deleteContractField.d.ts b/database/deleteContractField.d.ts new file mode 100644 index 00000000..679dfa75 --- /dev/null +++ b/database/deleteContractField.d.ts @@ -0,0 +1,2 @@ +import type { PoolConnection } from 'better-sqlite-pool'; +export default function deleteContractField(contractId: number | string, contractTypeFieldId: number | string, user: User, connectedDatabase?: PoolConnection): Promise; diff --git a/database/deleteBurialSiteContractField.js b/database/deleteContractField.js similarity index 54% rename from database/deleteBurialSiteContractField.js rename to database/deleteContractField.js index 388e9e94..9c0aaa4b 100644 --- a/database/deleteBurialSiteContractField.js +++ b/database/deleteContractField.js @@ -1,13 +1,13 @@ import { acquireConnection } from './pool.js'; -export default async function deleteBurialSiteContractField(burialSiteContractId, contractTypeFieldId, user, connectedDatabase) { +export default async function deleteContractField(contractId, contractTypeFieldId, user, connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); const result = database - .prepare(`update BurialSiteContractFields + .prepare(`update ContractFields set recordDelete_userName = ?, recordDelete_timeMillis = ? - where burialSiteContractId = ? + where contractId = ? and contractTypeFieldId = ?`) - .run(user.userName, Date.now(), burialSiteContractId, contractTypeFieldId); + .run(user.userName, Date.now(), contractId, contractTypeFieldId); if (connectedDatabase === undefined) { database.release(); } diff --git a/database/deleteBurialSiteContractField.ts b/database/deleteContractField.ts similarity index 67% rename from database/deleteBurialSiteContractField.ts rename to database/deleteContractField.ts index d9067bc8..2484b31d 100644 --- a/database/deleteBurialSiteContractField.ts +++ b/database/deleteContractField.ts @@ -2,8 +2,8 @@ import type { PoolConnection } from 'better-sqlite-pool' import { acquireConnection } from './pool.js' -export default async function deleteBurialSiteContractField( - burialSiteContractId: number | string, +export default async function deleteContractField( + contractId: number | string, contractTypeFieldId: number | string, user: User, connectedDatabase?: PoolConnection @@ -12,13 +12,13 @@ export default async function deleteBurialSiteContractField( const result = database .prepare( - `update BurialSiteContractFields + `update ContractFields set recordDelete_userName = ?, recordDelete_timeMillis = ? - where burialSiteContractId = ? + where contractId = ? and contractTypeFieldId = ?` ) - .run(user.userName, Date.now(), burialSiteContractId, contractTypeFieldId) + .run(user.userName, Date.now(), contractId, contractTypeFieldId) if (connectedDatabase === undefined) { database.release() diff --git a/database/deleteContractInterment.d.ts b/database/deleteContractInterment.d.ts new file mode 100644 index 00000000..d87fb060 --- /dev/null +++ b/database/deleteContractInterment.d.ts @@ -0,0 +1 @@ +export default function deleteContractInterment(contractId: number | string, intermentNumber: number | string, user: User): Promise; diff --git a/database/deleteBurialSiteContractInterment.js b/database/deleteContractInterment.js similarity index 50% rename from database/deleteBurialSiteContractInterment.js rename to database/deleteContractInterment.js index 31e5afb4..8c436c92 100644 --- a/database/deleteBurialSiteContractInterment.js +++ b/database/deleteContractInterment.js @@ -1,13 +1,13 @@ import { acquireConnection } from './pool.js'; -export default async function deleteBurialSiteContractInterment(burialSiteContractId, intermentNumber, user) { +export default async function deleteContractInterment(contractId, intermentNumber, user) { const database = await acquireConnection(); const result = database - .prepare(`update BurialSiteContractInterments + .prepare(`update ContractInterments set recordDelete_userName = ?, recordDelete_timeMillis = ? - where burialSiteContractId = ? + where contractId = ? and intermentNumber = ?`) - .run(user.userName, Date.now(), burialSiteContractId, intermentNumber); + .run(user.userName, Date.now(), contractId, intermentNumber); database.release(); return result.changes > 0; } diff --git a/database/deleteBurialSiteContractInterment.ts b/database/deleteContractInterment.ts similarity index 58% rename from database/deleteBurialSiteContractInterment.ts rename to database/deleteContractInterment.ts index d59e92a0..90426d28 100644 --- a/database/deleteBurialSiteContractInterment.ts +++ b/database/deleteContractInterment.ts @@ -1,7 +1,7 @@ import { acquireConnection } from './pool.js' -export default async function deleteBurialSiteContractInterment( - burialSiteContractId: number | string, +export default async function deleteContractInterment( + contractId: number | string, intermentNumber: number | string, user: User ): Promise { @@ -9,13 +9,13 @@ export default async function deleteBurialSiteContractInterment( const result = database .prepare( - `update BurialSiteContractInterments + `update ContractInterments set recordDelete_userName = ?, recordDelete_timeMillis = ? - where burialSiteContractId = ? + where contractId = ? and intermentNumber = ?` ) - .run(user.userName, Date.now(), burialSiteContractId, intermentNumber) + .run(user.userName, Date.now(), contractId, intermentNumber) database.release() diff --git a/database/deleteContractTransaction.d.ts b/database/deleteContractTransaction.d.ts new file mode 100644 index 00000000..422ed7a4 --- /dev/null +++ b/database/deleteContractTransaction.d.ts @@ -0,0 +1 @@ +export default function deleteContractTransaction(contractId: number | string, transactionIndex: number | string, user: User): Promise; diff --git a/database/deleteBurialSiteContractTransaction.js b/database/deleteContractTransaction.js similarity index 50% rename from database/deleteBurialSiteContractTransaction.js rename to database/deleteContractTransaction.js index c7f72852..ccbbde7f 100644 --- a/database/deleteBurialSiteContractTransaction.js +++ b/database/deleteContractTransaction.js @@ -1,13 +1,13 @@ import { acquireConnection } from './pool.js'; -export default async function deleteBurialSiteContractTransaction(burialSiteContractId, transactionIndex, user) { +export default async function deleteContractTransaction(contractId, transactionIndex, user) { const database = await acquireConnection(); const result = database - .prepare(`update BurialSiteContractTransactions + .prepare(`update ContractTransactions set recordDelete_userName = ?, recordDelete_timeMillis = ? - where burialSiteContractId = ? + where contractId = ? and transactionIndex = ?`) - .run(user.userName, Date.now(), burialSiteContractId, transactionIndex); + .run(user.userName, Date.now(), contractId, transactionIndex); database.release(); return result.changes > 0; } diff --git a/database/deleteBurialSiteContractTransaction.ts b/database/deleteContractTransaction.ts similarity index 58% rename from database/deleteBurialSiteContractTransaction.ts rename to database/deleteContractTransaction.ts index b4c991cf..3b36c19f 100644 --- a/database/deleteBurialSiteContractTransaction.ts +++ b/database/deleteContractTransaction.ts @@ -1,7 +1,7 @@ import { acquireConnection } from './pool.js' -export default async function deleteBurialSiteContractTransaction( - burialSiteContractId: number | string, +export default async function deleteContractTransaction( + contractId: number | string, transactionIndex: number | string, user: User ): Promise { @@ -9,13 +9,13 @@ export default async function deleteBurialSiteContractTransaction( const result = database .prepare( - `update BurialSiteContractTransactions + `update ContractTransactions set recordDelete_userName = ?, recordDelete_timeMillis = ? - where burialSiteContractId = ? + where contractId = ? and transactionIndex = ?` ) - .run(user.userName, Date.now(), burialSiteContractId, transactionIndex) + .run(user.userName, Date.now(), contractId, transactionIndex) database.release() diff --git a/database/deleteRecord.d.ts b/database/deleteRecord.d.ts index 5bb92ae1..8ecf9f25 100644 --- a/database/deleteRecord.d.ts +++ b/database/deleteRecord.d.ts @@ -1,3 +1,3 @@ -type RecordTable = 'FeeCategories' | 'Fees' | 'BurialSites' | 'BurialSiteComments' | 'BurialSiteContracts' | 'BurialSiteContractComments' | 'BurialSiteStatuses' | 'BurialSiteTypes' | 'BurialSiteTypeFields' | 'Cemeteries' | 'ContractTypes' | 'ContractTypeFields' | 'WorkOrders' | 'WorkOrderComments' | 'WorkOrderMilestones' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes'; +type RecordTable = 'FeeCategories' | 'Fees' | 'BurialSites' | 'BurialSiteComments' | 'Contracts' | 'ContractComments' | 'BurialSiteStatuses' | 'BurialSiteTypes' | 'BurialSiteTypeFields' | 'Cemeteries' | 'ContractTypes' | 'ContractTypeFields' | 'WorkOrders' | 'WorkOrderComments' | 'WorkOrderMilestones' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes'; export declare function deleteRecord(recordTable: RecordTable, recordId: number | string, user: User): Promise; export {}; diff --git a/database/deleteRecord.js b/database/deleteRecord.js index b747a46b..6113d7b3 100644 --- a/database/deleteRecord.js +++ b/database/deleteRecord.js @@ -5,8 +5,8 @@ recordIdColumns.set('FeeCategories', 'feeCategoryId'); recordIdColumns.set('Fees', 'feeId'); recordIdColumns.set('BurialSites', 'burialSiteId'); recordIdColumns.set('BurialSiteComments', 'burialSiteCommentId'); -recordIdColumns.set('BurialSiteContracts', 'burialSiteContractId'); -recordIdColumns.set('BurialSiteContractComments', 'burialSiteContractCommentId'); +recordIdColumns.set('Contracts', 'contractId'); +recordIdColumns.set('ContractComments', 'contractCommentId'); recordIdColumns.set('BurialSiteStatuses', 'burialSiteStatusId'); recordIdColumns.set('BurialSiteTypes', 'burialSiteTypeId'); recordIdColumns.set('BurialSiteTypeFields', 'burialSiteFieldTypeId'); @@ -21,9 +21,9 @@ recordIdColumns.set('WorkOrderTypes', 'workOrderTypeId'); const relatedTables = new Map(); relatedTables.set('FeeCategories', ['Fees']); relatedTables.set('BurialSites', ['BurialSiteFields', 'BurialSiteComments']); -relatedTables.set('BurialSiteContracts', [ - 'BurialSiteContractFields', - 'BurialSiteContractComments' +relatedTables.set('Contracts', [ + 'ContractFields', + 'ContractComments' ]); relatedTables.set('BurialSiteTypes', ['BurialSiteTypeFields']); relatedTables.set('Cemeteries', ['BurialSites']); @@ -31,7 +31,7 @@ relatedTables.set('ContractTypes', ['ContractTypePrints', 'ContractTypeFields']) relatedTables.set('WorkOrders', [ 'WorkOrderMilestones', 'WorkOrderLots', - 'WorkOrderBurialSiteContracts', + 'WorkOrderContracts', 'WorkOrderComments' ]); export async function deleteRecord(recordTable, recordId, user) { diff --git a/database/deleteRecord.ts b/database/deleteRecord.ts index 8a42a353..1913dc5a 100644 --- a/database/deleteRecord.ts +++ b/database/deleteRecord.ts @@ -7,8 +7,8 @@ type RecordTable = | 'Fees' | 'BurialSites' | 'BurialSiteComments' - | 'BurialSiteContracts' - | 'BurialSiteContractComments' + | 'Contracts' + | 'ContractComments' | 'BurialSiteStatuses' | 'BurialSiteTypes' | 'BurialSiteTypeFields' @@ -26,8 +26,8 @@ recordIdColumns.set('FeeCategories', 'feeCategoryId') recordIdColumns.set('Fees', 'feeId') recordIdColumns.set('BurialSites', 'burialSiteId') recordIdColumns.set('BurialSiteComments', 'burialSiteCommentId') -recordIdColumns.set('BurialSiteContracts', 'burialSiteContractId') -recordIdColumns.set('BurialSiteContractComments', 'burialSiteContractCommentId') +recordIdColumns.set('Contracts', 'contractId') +recordIdColumns.set('ContractComments', 'contractCommentId') recordIdColumns.set('BurialSiteStatuses', 'burialSiteStatusId') recordIdColumns.set('BurialSiteTypes', 'burialSiteTypeId') recordIdColumns.set('BurialSiteTypeFields', 'burialSiteFieldTypeId') @@ -43,9 +43,9 @@ recordIdColumns.set('WorkOrderTypes', 'workOrderTypeId') const relatedTables = new Map() relatedTables.set('FeeCategories', ['Fees']) relatedTables.set('BurialSites', ['BurialSiteFields', 'BurialSiteComments']) -relatedTables.set('BurialSiteContracts', [ - 'BurialSiteContractFields', - 'BurialSiteContractComments' +relatedTables.set('Contracts', [ + 'ContractFields', + 'ContractComments' ]) relatedTables.set('BurialSiteTypes', ['BurialSiteTypeFields']) relatedTables.set('Cemeteries', ['BurialSites']) @@ -53,7 +53,7 @@ relatedTables.set('ContractTypes', ['ContractTypePrints', 'ContractTypeFields']) relatedTables.set('WorkOrders', [ 'WorkOrderMilestones', 'WorkOrderLots', - 'WorkOrderBurialSiteContracts', + 'WorkOrderContracts', 'WorkOrderComments' ]) diff --git a/database/deleteWorkOrderBurialSiteContract.d.ts b/database/deleteWorkOrderBurialSiteContract.d.ts deleted file mode 100644 index 8a834a14..00000000 --- a/database/deleteWorkOrderBurialSiteContract.d.ts +++ /dev/null @@ -1 +0,0 @@ -export default function deleteWorkOrderBurialSiteContract(workOrderId: number | string, burialSiteContractId: number | string, user: User): Promise; diff --git a/database/deleteWorkOrderContract.d.ts b/database/deleteWorkOrderContract.d.ts new file mode 100644 index 00000000..163fe71a --- /dev/null +++ b/database/deleteWorkOrderContract.d.ts @@ -0,0 +1 @@ +export default function deleteWorkOrderContract(workOrderId: number | string, contractId: number | string, user: User): Promise; diff --git a/database/deleteWorkOrderBurialSiteContract.js b/database/deleteWorkOrderContract.js similarity index 50% rename from database/deleteWorkOrderBurialSiteContract.js rename to database/deleteWorkOrderContract.js index b403f460..6ad8972d 100644 --- a/database/deleteWorkOrderBurialSiteContract.js +++ b/database/deleteWorkOrderContract.js @@ -1,13 +1,13 @@ import { acquireConnection } from './pool.js'; -export default async function deleteWorkOrderBurialSiteContract(workOrderId, burialSiteContractId, user) { +export default async function deleteWorkOrderContract(workOrderId, contractId, user) { const database = await acquireConnection(); const result = database - .prepare(`update WorkOrderBurialSiteContracts + .prepare(`update WorkOrderContracts set recordDelete_userName = ?, recordDelete_timeMillis = ? where workOrderId = ? - and burialSiteContractId = ?`) - .run(user.userName, Date.now(), workOrderId, burialSiteContractId); + and contractId = ?`) + .run(user.userName, Date.now(), workOrderId, contractId); database.release(); return result.changes > 0; } diff --git a/database/deleteWorkOrderBurialSiteContract.ts b/database/deleteWorkOrderContract.ts similarity index 58% rename from database/deleteWorkOrderBurialSiteContract.ts rename to database/deleteWorkOrderContract.ts index 3ec5fa82..11108668 100644 --- a/database/deleteWorkOrderBurialSiteContract.ts +++ b/database/deleteWorkOrderContract.ts @@ -1,21 +1,21 @@ import { acquireConnection } from './pool.js' -export default async function deleteWorkOrderBurialSiteContract( +export default async function deleteWorkOrderContract( workOrderId: number | string, - burialSiteContractId: number | string, + contractId: number | string, user: User ): Promise { const database = await acquireConnection() const result = database .prepare( - `update WorkOrderBurialSiteContracts + `update WorkOrderContracts set recordDelete_userName = ?, recordDelete_timeMillis = ? where workOrderId = ? - and burialSiteContractId = ?` + and contractId = ?` ) - .run(user.userName, Date.now(), workOrderId, burialSiteContractId) + .run(user.userName, Date.now(), workOrderId, contractId) database.release() diff --git a/database/getBurialSite.js b/database/getBurialSite.js index f16aa1be..cd9ae014 100644 --- a/database/getBurialSite.js +++ b/database/getBurialSite.js @@ -1,5 +1,5 @@ import getBurialSiteComments from './getBurialSiteComments.js'; -import getBurialSiteInterments from './getBurialSiteContracts.js'; +import getBurialSiteInterments from './getContracts.js'; import getBurialSiteFields from './getBurialSiteFields.js'; import { acquireConnection } from './pool.js'; const baseSQL = `select l.burialSiteId, @@ -24,7 +24,7 @@ async function _getBurialSite(sql, burialSiteIdOrLotName) { const database = await acquireConnection(); const burialSite = database.prepare(sql).get(burialSiteIdOrLotName); if (burialSite !== undefined) { - const burialSiteContracts = await getBurialSiteInterments({ + const contracts = await getBurialSiteInterments({ burialSiteId: burialSite.burialSiteId }, { includeInterments: true, @@ -33,7 +33,7 @@ async function _getBurialSite(sql, burialSiteIdOrLotName) { limit: -1, offset: 0 }, database); - burialSite.burialSiteContracts = burialSiteContracts.burialSiteContracts; + burialSite.contracts = contracts.contracts; burialSite.burialSiteFields = await getBurialSiteFields(burialSite.burialSiteId, database); burialSite.burialSiteComments = await getBurialSiteComments(burialSite.burialSiteId, database); } diff --git a/database/getBurialSite.ts b/database/getBurialSite.ts index 40d4f86a..7a00df95 100644 --- a/database/getBurialSite.ts +++ b/database/getBurialSite.ts @@ -1,7 +1,7 @@ import type { BurialSite } from '../types/recordTypes.js' import getBurialSiteComments from './getBurialSiteComments.js' -import getBurialSiteInterments from './getBurialSiteContracts.js' +import getBurialSiteInterments from './getContracts.js' import getBurialSiteFields from './getBurialSiteFields.js' import { acquireConnection } from './pool.js' @@ -33,7 +33,7 @@ async function _getBurialSite( const burialSite = database.prepare(sql).get(burialSiteIdOrLotName) as BurialSite | undefined if (burialSite !== undefined) { - const burialSiteContracts = await getBurialSiteInterments( + const contracts = await getBurialSiteInterments( { burialSiteId: burialSite.burialSiteId }, @@ -47,7 +47,7 @@ async function _getBurialSite( database ) - burialSite.burialSiteContracts = burialSiteContracts.burialSiteContracts + burialSite.contracts = contracts.contracts burialSite.burialSiteFields = await getBurialSiteFields(burialSite.burialSiteId, database) diff --git a/database/getBurialSiteContract.d.ts b/database/getBurialSiteContract.d.ts deleted file mode 100644 index 01f8eee4..00000000 --- a/database/getBurialSiteContract.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { PoolConnection } from 'better-sqlite-pool'; -import type { BurialSiteContract } from '../types/recordTypes.js'; -export default function getBurialSiteContract(burialSiteContractId: number | string, connectedDatabase?: PoolConnection): Promise; diff --git a/database/getBurialSiteContractComments.d.ts b/database/getBurialSiteContractComments.d.ts deleted file mode 100644 index 54837098..00000000 --- a/database/getBurialSiteContractComments.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { PoolConnection } from 'better-sqlite-pool'; -import type { BurialSiteContractComment } from '../types/recordTypes.js'; -export default function getBurialSiteContractComments(burialSiteContractId: number | string, connectedDatabase?: PoolConnection): Promise; diff --git a/database/getBurialSiteContractFees.d.ts b/database/getBurialSiteContractFees.d.ts deleted file mode 100644 index d1635bae..00000000 --- a/database/getBurialSiteContractFees.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { PoolConnection } from 'better-sqlite-pool'; -import type { BurialSiteContractFee } from '../types/recordTypes.js'; -export default function getBurialSiteContractFees(burialSiteContractId: number | string, connectedDatabase?: PoolConnection): Promise; diff --git a/database/getBurialSiteContractFields.d.ts b/database/getBurialSiteContractFields.d.ts deleted file mode 100644 index 51e39733..00000000 --- a/database/getBurialSiteContractFields.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { PoolConnection } from 'better-sqlite-pool'; -import type { BurialSiteContractField } from '../types/recordTypes.js'; -export default function getBurialSiteContractField(burialSiteContractId: number | string, connectedDatabase?: PoolConnection): Promise; diff --git a/database/getBurialSiteContractInterments.d.ts b/database/getBurialSiteContractInterments.d.ts deleted file mode 100644 index 0a65ceca..00000000 --- a/database/getBurialSiteContractInterments.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { PoolConnection } from 'better-sqlite-pool'; -import type { BurialSiteContractInterment } from '../types/recordTypes.js'; -export default function getBurialSiteContractInterments(burialSiteContractId: number | string, connectedDatabase?: PoolConnection): Promise; diff --git a/database/getBurialSiteContractTransactions.d.ts b/database/getBurialSiteContractTransactions.d.ts deleted file mode 100644 index 3204286e..00000000 --- a/database/getBurialSiteContractTransactions.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { PoolConnection } from 'better-sqlite-pool'; -import type { BurialSiteContractTransaction } from '../types/recordTypes.js'; -export default function GetBurialSiteContractTransactions(burialSiteContractId: number | string, options: { - includeIntegrations: boolean; -}, connectedDatabase?: PoolConnection): Promise; diff --git a/database/getBurialSites.d.ts b/database/getBurialSites.d.ts index 104f4d47..2366fccf 100644 --- a/database/getBurialSites.d.ts +++ b/database/getBurialSites.d.ts @@ -13,7 +13,7 @@ export interface GetBurialSitesOptions { /** -1 for no limit */ limit: number; offset: string | number; - includeBurialSiteContractCount?: boolean; + includeContractCount?: boolean; } export default function getBurialSites(filters: GetBurialSitesFilters, options: GetBurialSitesOptions, connectedDatabase?: PoolConnection): Promise<{ count: number; diff --git a/database/getBurialSites.js b/database/getBurialSites.js index 130ebf8c..e614f1f3 100644 --- a/database/getBurialSites.js +++ b/database/getBurialSites.js @@ -21,11 +21,11 @@ function buildWhereClause(filters) { } if ((filters.contractStatus ?? '') !== '') { if (filters.contractStatus === 'occupied') { - sqlWhereClause += ' and burialSiteContractCount > 0'; + sqlWhereClause += ' and contractCount > 0'; } else if (filters.contractStatus === 'unoccupied') { sqlWhereClause += - ' and (burialSiteContractCount is null or burialSiteContractCount = 0)'; + ' and (contractCount is null or contractCount = 0)'; } } if ((filters.workOrderId ?? '') !== '') { @@ -48,7 +48,7 @@ export default async function getBurialSites(filters, options, connectedDatabase .prepare(`select count(*) as recordCount from BurialSites l left join ( - select burialSiteId, count(burialSiteContractId) as burialSiteContractCount from BurialSiteContracts + select burialSiteId, count(contractId) as contractCount from Contracts where recordDelete_timeMillis is null and contractStartDate <= ${currentDate.toString()} and (contractEndDate is null or contractEndDate >= ${currentDate.toString()}) @@ -59,8 +59,8 @@ export default async function getBurialSites(filters, options, connectedDatabase } let burialSites = []; if (options.limit === -1 || count > 0) { - const includeBurialSiteContractCount = options.includeBurialSiteContractCount ?? true; - if (includeBurialSiteContractCount) { + const includeContractCount = options.includeContractCount ?? true; + if (includeContractCount) { sqlParameters.unshift(currentDate, currentDate); } burialSites = database @@ -74,17 +74,17 @@ export default async function getBurialSites(filters, options, connectedDatabase t.burialSiteType, l.cemeteryId, m.cemeteryName, l.cemeterySvgId, l.burialSiteStatusId, s.burialSiteStatus - ${includeBurialSiteContractCount - ? ', ifnull(o.burialSiteContractCount, 0) as burialSiteContractCount' + ${includeContractCount + ? ', ifnull(o.contractCount, 0) as contractCount' : ''} 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 - ${includeBurialSiteContractCount + ${includeContractCount ? `left join ( - select burialSiteId, count(burialSiteContractId) as burialSiteContractCount - from BurialSiteContracts + select burialSiteId, count(contractId) as contractCount + from Contracts where recordDelete_timeMillis is null and contractStartDate <= ? and (contractEndDate is null or contractEndDate >= ?) diff --git a/database/getBurialSites.ts b/database/getBurialSites.ts index 3c181c13..fe448d86 100644 --- a/database/getBurialSites.ts +++ b/database/getBurialSites.ts @@ -20,7 +20,7 @@ export interface GetBurialSitesOptions { /** -1 for no limit */ limit: number offset: string | number - includeBurialSiteContractCount?: boolean + includeContractCount?: boolean } function buildWhereClause(filters: GetBurialSitesFilters): { @@ -55,10 +55,10 @@ function buildWhereClause(filters: GetBurialSitesFilters): { if ((filters.contractStatus ?? '') !== '') { if (filters.contractStatus === 'occupied') { - sqlWhereClause += ' and burialSiteContractCount > 0' + sqlWhereClause += ' and contractCount > 0' } else if (filters.contractStatus === 'unoccupied') { sqlWhereClause += - ' and (burialSiteContractCount is null or burialSiteContractCount = 0)' + ' and (contractCount is null or contractCount = 0)' } } @@ -94,7 +94,7 @@ export default async function getBurialSites( `select count(*) as recordCount from BurialSites l left join ( - select burialSiteId, count(burialSiteContractId) as burialSiteContractCount from BurialSiteContracts + select burialSiteId, count(contractId) as contractCount from Contracts where recordDelete_timeMillis is null and contractStartDate <= ${currentDate.toString()} and (contractEndDate is null or contractEndDate >= ${currentDate.toString()}) @@ -109,9 +109,9 @@ export default async function getBurialSites( let burialSites: BurialSite[] = [] if (options.limit === -1 || count > 0) { - const includeBurialSiteContractCount = options.includeBurialSiteContractCount ?? true + const includeContractCount = options.includeContractCount ?? true - if (includeBurialSiteContractCount) { + if (includeContractCount) { sqlParameters.unshift(currentDate, currentDate) } @@ -128,8 +128,8 @@ export default async function getBurialSites( l.cemeteryId, m.cemeteryName, l.cemeterySvgId, l.burialSiteStatusId, s.burialSiteStatus ${ - includeBurialSiteContractCount - ? ', ifnull(o.burialSiteContractCount, 0) as burialSiteContractCount' + includeContractCount + ? ', ifnull(o.contractCount, 0) as contractCount' : '' } from BurialSites l @@ -137,10 +137,10 @@ export default async function getBurialSites( left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId left join Cemeteries m on l.cemeteryId = m.cemeteryId ${ - includeBurialSiteContractCount + includeContractCount ? `left join ( - select burialSiteId, count(burialSiteContractId) as burialSiteContractCount - from BurialSiteContracts + select burialSiteId, count(contractId) as contractCount + from Contracts where recordDelete_timeMillis is null and contractStartDate <= ? and (contractEndDate is null or contractEndDate >= ?) diff --git a/database/getContract.d.ts b/database/getContract.d.ts new file mode 100644 index 00000000..9d759f55 --- /dev/null +++ b/database/getContract.d.ts @@ -0,0 +1,3 @@ +import type { PoolConnection } from 'better-sqlite-pool'; +import type { Contract } from '../types/recordTypes.js'; +export default function getContract(contractId: number | string, connectedDatabase?: PoolConnection): Promise; diff --git a/database/getBurialSiteContract.js b/database/getContract.js similarity index 51% rename from database/getBurialSiteContract.js rename to database/getContract.js index ea0c92aa..db182f8c 100644 --- a/database/getBurialSiteContract.js +++ b/database/getContract.js @@ -1,16 +1,16 @@ import { dateIntegerToString } from '@cityssm/utils-datetime'; -import getBurialSiteContractComments from './getBurialSiteContractComments.js'; -import getBurialSiteContractFees from './getBurialSiteContractFees.js'; -import getBurialSiteContractFields from './getBurialSiteContractFields.js'; -// import getBurialSiteContractOccupants from './getBurialSiteContractOccupants.js' -import getBurialSiteContractTransactions from './getBurialSiteContractTransactions.js'; +import getContractComments from './getContractComments.js'; +import getContractFees from './getContractFees.js'; +import getContractFields from './getContractFields.js'; +// import getContractOccupants from './getContractOccupants.js' +import getContractTransactions from './getContractTransactions.js'; import { getWorkOrders } from './getWorkOrders.js'; import { acquireConnection } from './pool.js'; -export default async function getBurialSiteContract(burialSiteContractId, connectedDatabase) { +export default async function getContract(contractId, connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); database.function('userFn_dateIntegerToString', dateIntegerToString); const contract = database - .prepare(`select o.burialSiteContractId, + .prepare(`select o.contractId, o.contractTypeId, t.contractType, o.burialSiteId, l.burialSiteName, @@ -19,26 +19,26 @@ export default async function getBurialSiteContract(burialSiteContractId, connec o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString, o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString, o.recordUpdate_timeMillis - from BurialSiteContracts o + from Contracts o left join ContractTypes t on o.contractTypeId = t.contractTypeId left join BurialSites l on o.burialSiteId = l.burialSiteId left join Maps m on l.cemeteryId = m.cemeteryId where o.recordDelete_timeMillis is null - and o.burialSiteContractId = ?`) - .get(burialSiteContractId); + and o.contractId = ?`) + .get(contractId); if (contract !== undefined) { - contract.burialSiteContractFields = await getBurialSiteContractFields(burialSiteContractId, database); + contract.contractFields = await getContractFields(contractId, database); /* - contract.burialSiteContractInterments = await getBurialSiteContractOccupants( - burialSiteContractId, + contract.contractInterments = await getContractOccupants( + contractId, database ) */ - contract.burialSiteContractComments = await getBurialSiteContractComments(burialSiteContractId, database); - contract.burialSiteContractFees = await getBurialSiteContractFees(burialSiteContractId, database); - contract.burialSiteContractTransactions = await getBurialSiteContractTransactions(burialSiteContractId, { includeIntegrations: true }, database); + contract.contractComments = await getContractComments(contractId, database); + contract.contractFees = await getContractFees(contractId, database); + contract.contractTransactions = await getContractTransactions(contractId, { includeIntegrations: true }, database); const workOrdersResults = await getWorkOrders({ - burialSiteContractId + contractId }, { limit: -1, offset: 0 diff --git a/database/getBurialSiteContract.ts b/database/getContract.ts similarity index 53% rename from database/getBurialSiteContract.ts rename to database/getContract.ts index 210883bd..0fbd1172 100644 --- a/database/getBurialSiteContract.ts +++ b/database/getContract.ts @@ -1,27 +1,27 @@ import { dateIntegerToString } from '@cityssm/utils-datetime' import type { PoolConnection } from 'better-sqlite-pool' -import type { BurialSiteContract } from '../types/recordTypes.js' +import type { Contract } from '../types/recordTypes.js' -import getBurialSiteContractComments from './getBurialSiteContractComments.js' -import getBurialSiteContractFees from './getBurialSiteContractFees.js' -import getBurialSiteContractFields from './getBurialSiteContractFields.js' -// import getBurialSiteContractOccupants from './getBurialSiteContractOccupants.js' -import getBurialSiteContractTransactions from './getBurialSiteContractTransactions.js' +import getContractComments from './getContractComments.js' +import getContractFees from './getContractFees.js' +import getContractFields from './getContractFields.js' +// import getContractOccupants from './getContractOccupants.js' +import getContractTransactions from './getContractTransactions.js' import { getWorkOrders } from './getWorkOrders.js' import { acquireConnection } from './pool.js' -export default async function getBurialSiteContract( - burialSiteContractId: number | string, +export default async function getContract( + contractId: number | string, connectedDatabase?: PoolConnection -): Promise { +): Promise { const database = connectedDatabase ?? (await acquireConnection()) database.function('userFn_dateIntegerToString', dateIntegerToString) const contract = database .prepare( - `select o.burialSiteContractId, + `select o.contractId, o.contractTypeId, t.contractType, o.burialSiteId, l.burialSiteName, @@ -30,43 +30,43 @@ export default async function getBurialSiteContract( o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString, o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString, o.recordUpdate_timeMillis - from BurialSiteContracts o + from Contracts o left join ContractTypes t on o.contractTypeId = t.contractTypeId left join BurialSites l on o.burialSiteId = l.burialSiteId left join Maps m on l.cemeteryId = m.cemeteryId where o.recordDelete_timeMillis is null - and o.burialSiteContractId = ?` + and o.contractId = ?` ) - .get(burialSiteContractId) as BurialSiteContract | undefined + .get(contractId) as Contract | undefined if (contract !== undefined) { - contract.burialSiteContractFields = await getBurialSiteContractFields( - burialSiteContractId, + contract.contractFields = await getContractFields( + contractId, database ) /* - contract.burialSiteContractInterments = await getBurialSiteContractOccupants( - burialSiteContractId, + contract.contractInterments = await getContractOccupants( + contractId, database ) */ - contract.burialSiteContractComments = await getBurialSiteContractComments( - burialSiteContractId, + contract.contractComments = await getContractComments( + contractId, database ) - contract.burialSiteContractFees = await getBurialSiteContractFees( - burialSiteContractId, + contract.contractFees = await getContractFees( + contractId, database ) - contract.burialSiteContractTransactions = await getBurialSiteContractTransactions( - burialSiteContractId, + contract.contractTransactions = await getContractTransactions( + contractId, { includeIntegrations: true }, database ) const workOrdersResults = await getWorkOrders( { - burialSiteContractId + contractId }, { limit: -1, diff --git a/database/getContractComments.d.ts b/database/getContractComments.d.ts new file mode 100644 index 00000000..c2fc196f --- /dev/null +++ b/database/getContractComments.d.ts @@ -0,0 +1,3 @@ +import type { PoolConnection } from 'better-sqlite-pool'; +import type { ContractComment } from '../types/recordTypes.js'; +export default function getContractComments(contractId: number | string, connectedDatabase?: PoolConnection): Promise; diff --git a/database/getBurialSiteContractComments.js b/database/getContractComments.js similarity index 72% rename from database/getBurialSiteContractComments.js rename to database/getContractComments.js index d545c9fd..9f62d190 100644 --- a/database/getBurialSiteContractComments.js +++ b/database/getContractComments.js @@ -1,23 +1,23 @@ import { dateIntegerToString, timeIntegerToPeriodString, timeIntegerToString } from '@cityssm/utils-datetime'; import { acquireConnection } from './pool.js'; -export default async function getBurialSiteContractComments(burialSiteContractId, connectedDatabase) { +export default async function getContractComments(contractId, connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); database.function('userFn_dateIntegerToString', dateIntegerToString); database.function('userFn_timeIntegerToString', timeIntegerToString); database.function('userFn_timeIntegerToPeriodString', timeIntegerToPeriodString); const comments = database - .prepare(`select burialSiteContractCommentId, + .prepare(`select contractCommentId, commentDate, userFn_dateIntegerToString(commentDate) as commentDateString, commentTime, userFn_timeIntegerToString(commentTime) as commentTimeString, userFn_timeIntegerToPeriodString(commentTime) as commentTimePeriodString, comment, recordCreate_userName, recordUpdate_userName - from BurialSiteContractComments + from ContractComments where recordDelete_timeMillis is null - and burialSiteContractId = ? - order by commentDate desc, commentTime desc, burialSiteContractCommentId desc`) - .all(burialSiteContractId); + and contractId = ? + order by commentDate desc, commentTime desc, contractCommentId desc`) + .all(contractId); if (connectedDatabase === undefined) { database.release(); } diff --git a/database/getBurialSiteContractComments.ts b/database/getContractComments.ts similarity index 68% rename from database/getBurialSiteContractComments.ts rename to database/getContractComments.ts index 8cdec0a0..b4213d3a 100644 --- a/database/getBurialSiteContractComments.ts +++ b/database/getContractComments.ts @@ -5,14 +5,14 @@ import { } from '@cityssm/utils-datetime' import type { PoolConnection } from 'better-sqlite-pool' -import type { BurialSiteContractComment } from '../types/recordTypes.js' +import type { ContractComment } from '../types/recordTypes.js' import { acquireConnection } from './pool.js' -export default async function getBurialSiteContractComments( - burialSiteContractId: number | string, +export default async function getContractComments( + contractId: number | string, connectedDatabase?: PoolConnection -): Promise { +): Promise { const database = connectedDatabase ?? (await acquireConnection()) database.function('userFn_dateIntegerToString', dateIntegerToString) @@ -24,19 +24,19 @@ export default async function getBurialSiteContractComments( const comments = database .prepare( - `select burialSiteContractCommentId, + `select contractCommentId, commentDate, userFn_dateIntegerToString(commentDate) as commentDateString, commentTime, userFn_timeIntegerToString(commentTime) as commentTimeString, userFn_timeIntegerToPeriodString(commentTime) as commentTimePeriodString, comment, recordCreate_userName, recordUpdate_userName - from BurialSiteContractComments + from ContractComments where recordDelete_timeMillis is null - and burialSiteContractId = ? - order by commentDate desc, commentTime desc, burialSiteContractCommentId desc` + and contractId = ? + order by commentDate desc, commentTime desc, contractCommentId desc` ) - .all(burialSiteContractId) as BurialSiteContractComment[] + .all(contractId) as ContractComment[] if (connectedDatabase === undefined) { database.release() diff --git a/database/getContractFees.d.ts b/database/getContractFees.d.ts new file mode 100644 index 00000000..157dc9e0 --- /dev/null +++ b/database/getContractFees.d.ts @@ -0,0 +1,3 @@ +import type { PoolConnection } from 'better-sqlite-pool'; +import type { ContractFee } from '../types/recordTypes.js'; +export default function getContractFees(contractId: number | string, connectedDatabase?: PoolConnection): Promise; diff --git a/database/getBurialSiteContractFees.js b/database/getContractFees.js similarity index 67% rename from database/getBurialSiteContractFees.js rename to database/getContractFees.js index 886dd761..2a5dc94d 100644 --- a/database/getBurialSiteContractFees.js +++ b/database/getContractFees.js @@ -1,17 +1,17 @@ import { acquireConnection } from './pool.js'; -export default async function getBurialSiteContractFees(burialSiteContractId, connectedDatabase) { +export default async function getContractFees(contractId, connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); const fees = database - .prepare(`select o.burialSiteContractId, o.feeId, + .prepare(`select o.contractId, o.feeId, c.feeCategory, f.feeName, f.includeQuantity, o.feeAmount, o.taxAmount, o.quantity, f.quantityUnit - from BurialSiteContractFees o + from ContractFees o left join Fees f on o.feeId = f.feeId left join FeeCategories c on f.feeCategoryId = c.feeCategoryId where o.recordDelete_timeMillis is null - and o.burialSiteContractId = ? + and o.contractId = ? order by o.recordCreate_timeMillis`) - .all(burialSiteContractId); + .all(contractId); if (connectedDatabase === undefined) { database.release(); } diff --git a/database/getBurialSiteContractFees.ts b/database/getContractFees.ts similarity index 63% rename from database/getBurialSiteContractFees.ts rename to database/getContractFees.ts index 733142fa..577685c4 100644 --- a/database/getBurialSiteContractFees.ts +++ b/database/getContractFees.ts @@ -1,28 +1,28 @@ import type { PoolConnection } from 'better-sqlite-pool' -import type { BurialSiteContractFee } from '../types/recordTypes.js' +import type { ContractFee } from '../types/recordTypes.js' import { acquireConnection } from './pool.js' -export default async function getBurialSiteContractFees( - burialSiteContractId: number | string, +export default async function getContractFees( + contractId: number | string, connectedDatabase?: PoolConnection -): Promise { +): Promise { const database = connectedDatabase ?? (await acquireConnection()) const fees = database .prepare( - `select o.burialSiteContractId, o.feeId, + `select o.contractId, o.feeId, c.feeCategory, f.feeName, f.includeQuantity, o.feeAmount, o.taxAmount, o.quantity, f.quantityUnit - from BurialSiteContractFees o + from ContractFees o left join Fees f on o.feeId = f.feeId left join FeeCategories c on f.feeCategoryId = c.feeCategoryId where o.recordDelete_timeMillis is null - and o.burialSiteContractId = ? + and o.contractId = ? order by o.recordCreate_timeMillis` ) - .all(burialSiteContractId) as BurialSiteContractFee[] + .all(contractId) as ContractFee[] if (connectedDatabase === undefined) { database.release() diff --git a/database/getContractFields.d.ts b/database/getContractFields.d.ts new file mode 100644 index 00000000..a2e3cbc3 --- /dev/null +++ b/database/getContractFields.d.ts @@ -0,0 +1,3 @@ +import type { PoolConnection } from 'better-sqlite-pool'; +import type { ContractField } from '../types/recordTypes.js'; +export default function getContractField(contractId: number | string, connectedDatabase?: PoolConnection): Promise; diff --git a/database/getBurialSiteContractFields.js b/database/getContractFields.js similarity index 65% rename from database/getBurialSiteContractFields.js rename to database/getContractFields.js index 5c239835..b3f806b2 100644 --- a/database/getBurialSiteContractFields.js +++ b/database/getContractFields.js @@ -1,20 +1,20 @@ import { acquireConnection } from './pool.js'; -export default async function getBurialSiteContractField(burialSiteContractId, connectedDatabase) { +export default async function getContractField(contractId, connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); const fields = database - .prepare(`select o.burialSiteContractId, o.contractTypeFieldId, + .prepare(`select o.contractId, o.contractTypeFieldId, o.fieldValue, f.contractTypeField, f.fieldType, f.fieldValues, f.isRequired, f.pattern, f.minLength, f.maxLength, f.orderNumber, t.orderNumber as contractTypeOrderNumber - from BurialSiteContractFields o + from ContractFields o left join ContractTypeFields f on o.contractTypeFieldId = f.contractTypeFieldId left join ContractTypes t on f.contractTypeId = t.contractTypeId where o.recordDelete_timeMillis is null - and o.burialSiteContractId = ? + and o.contractId = ? union - select ? as burialSiteContractId, f.contractTypeFieldId, + select ? as contractId, f.contractTypeFieldId, '' as fieldValue, f.contractTypeField, f.fieldType, f.fieldValues, f.isRequired, f.pattern, f.minLength, f.maxLength, f.orderNumber, t.orderNumber as contractTypeOrderNumber @@ -22,10 +22,10 @@ export default async function getBurialSiteContractField(burialSiteContractId, c left join ContractTypes t on f.contractTypeId = t.contractTypeId where f.recordDelete_timeMillis is null and ( f.contractTypeId is null - or f.contractTypeId in (select contractTypeId from BurialSiteContracts where burialSiteContractId = ?)) - and f.contractTypeFieldId not in (select contractTypeFieldId from BurialSiteContractFields where burialSiteContractId = ? and recordDelete_timeMillis is null) + or f.contractTypeId in (select contractTypeId from Contracts where contractId = ?)) + and f.contractTypeFieldId not in (select contractTypeFieldId from ContractFields where contractId = ? and recordDelete_timeMillis is null) order by contractTypeOrderNumber, f.orderNumber, f.contractTypeField`) - .all(burialSiteContractId, burialSiteContractId, burialSiteContractId, burialSiteContractId); + .all(contractId, contractId, contractId, contractId); if (connectedDatabase === undefined) { database.release(); } diff --git a/database/getBurialSiteContractFields.ts b/database/getContractFields.ts similarity index 63% rename from database/getBurialSiteContractFields.ts rename to database/getContractFields.ts index cc900bc1..2df018a7 100644 --- a/database/getBurialSiteContractFields.ts +++ b/database/getContractFields.ts @@ -1,30 +1,30 @@ import type { PoolConnection } from 'better-sqlite-pool' -import type { BurialSiteContractField } from '../types/recordTypes.js' +import type { ContractField } from '../types/recordTypes.js' import { acquireConnection } from './pool.js' -export default async function getBurialSiteContractField( - burialSiteContractId: number | string, +export default async function getContractField( + contractId: number | string, connectedDatabase?: PoolConnection -): Promise { +): Promise { const database = connectedDatabase ?? (await acquireConnection()) const fields = database .prepare( - `select o.burialSiteContractId, o.contractTypeFieldId, + `select o.contractId, o.contractTypeFieldId, o.fieldValue, f.contractTypeField, f.fieldType, f.fieldValues, f.isRequired, f.pattern, f.minLength, f.maxLength, f.orderNumber, t.orderNumber as contractTypeOrderNumber - from BurialSiteContractFields o + from ContractFields o left join ContractTypeFields f on o.contractTypeFieldId = f.contractTypeFieldId left join ContractTypes t on f.contractTypeId = t.contractTypeId where o.recordDelete_timeMillis is null - and o.burialSiteContractId = ? + and o.contractId = ? union - select ? as burialSiteContractId, f.contractTypeFieldId, + select ? as contractId, f.contractTypeFieldId, '' as fieldValue, f.contractTypeField, f.fieldType, f.fieldValues, f.isRequired, f.pattern, f.minLength, f.maxLength, f.orderNumber, t.orderNumber as contractTypeOrderNumber @@ -32,16 +32,16 @@ export default async function getBurialSiteContractField( left join ContractTypes t on f.contractTypeId = t.contractTypeId where f.recordDelete_timeMillis is null and ( f.contractTypeId is null - or f.contractTypeId in (select contractTypeId from BurialSiteContracts where burialSiteContractId = ?)) - and f.contractTypeFieldId not in (select contractTypeFieldId from BurialSiteContractFields where burialSiteContractId = ? and recordDelete_timeMillis is null) + or f.contractTypeId in (select contractTypeId from Contracts where contractId = ?)) + and f.contractTypeFieldId not in (select contractTypeFieldId from ContractFields where contractId = ? and recordDelete_timeMillis is null) order by contractTypeOrderNumber, f.orderNumber, f.contractTypeField` ) .all( - burialSiteContractId, - burialSiteContractId, - burialSiteContractId, - burialSiteContractId - ) as BurialSiteContractField[] + contractId, + contractId, + contractId, + contractId + ) as ContractField[] if (connectedDatabase === undefined) { database.release() diff --git a/database/getContractInterments.d.ts b/database/getContractInterments.d.ts new file mode 100644 index 00000000..fa51d170 --- /dev/null +++ b/database/getContractInterments.d.ts @@ -0,0 +1,3 @@ +import type { PoolConnection } from 'better-sqlite-pool'; +import type { ContractInterment } from '../types/recordTypes.js'; +export default function getContractInterments(contractId: number | string, connectedDatabase?: PoolConnection): Promise; diff --git a/database/getBurialSiteContractInterments.js b/database/getContractInterments.js similarity index 82% rename from database/getBurialSiteContractInterments.js rename to database/getContractInterments.js index efc4e755..3de3d89e 100644 --- a/database/getBurialSiteContractInterments.js +++ b/database/getContractInterments.js @@ -1,11 +1,11 @@ import { dateIntegerToString, timeIntegerToString } from '@cityssm/utils-datetime'; import { acquireConnection } from './pool.js'; -export default async function getBurialSiteContractInterments(burialSiteContractId, connectedDatabase) { +export default async function getContractInterments(contractId, connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); database.function('userFn_dateIntegerToString', dateIntegerToString); database.function('userFn_timeIntegerToString', timeIntegerToString); const interments = database - .prepare(`select o.burialSiteContractId, o.intermentNumber, + .prepare(`select o.contractId, o.intermentNumber, o.isCremated, o.deceasedName, birthDate, userFn_dateIntegerToString(birthDate) as birthDateString, @@ -19,14 +19,14 @@ export default async function getBurialSiteContractInterments(burialSiteContract intermentContainerTypeId, t.intermentContainerType, intermentCommittalTypeId, c.intermentCommittalType - from BurialSiteContractInterments o + from ContractInterments o left join IntermentContainerTypes t on o.intermentContainerTypeId = t.intermentContainerTypeId left join IntermentCommittalTypes c on o.intermentCommittalTypeId = c.intermentCommittalTypeId where o.recordDelete_timeMillis is null - and o.burialSiteContractId = ? + and o.contractId = ? order by t.orderNumber, o.deceasedName, o.intermentNumber`) - .all(burialSiteContractId); + .all(contractId); if (connectedDatabase === undefined) { database.release(); } diff --git a/database/getBurialSiteContractInterments.ts b/database/getContractInterments.ts similarity index 77% rename from database/getBurialSiteContractInterments.ts rename to database/getContractInterments.ts index 6534db8f..233e8ca4 100644 --- a/database/getBurialSiteContractInterments.ts +++ b/database/getContractInterments.ts @@ -4,14 +4,14 @@ import { } from '@cityssm/utils-datetime' import type { PoolConnection } from 'better-sqlite-pool' -import type { BurialSiteContractInterment } from '../types/recordTypes.js' +import type { ContractInterment } from '../types/recordTypes.js' import { acquireConnection } from './pool.js' -export default async function getBurialSiteContractInterments( - burialSiteContractId: number | string, +export default async function getContractInterments( + contractId: number | string, connectedDatabase?: PoolConnection -): Promise { +): Promise { const database = connectedDatabase ?? (await acquireConnection()) database.function('userFn_dateIntegerToString', dateIntegerToString) @@ -19,7 +19,7 @@ export default async function getBurialSiteContractInterments( const interments = database .prepare( - `select o.burialSiteContractId, o.intermentNumber, + `select o.contractId, o.intermentNumber, o.isCremated, o.deceasedName, birthDate, userFn_dateIntegerToString(birthDate) as birthDateString, @@ -33,15 +33,15 @@ export default async function getBurialSiteContractInterments( intermentContainerTypeId, t.intermentContainerType, intermentCommittalTypeId, c.intermentCommittalType - from BurialSiteContractInterments o + from ContractInterments o left join IntermentContainerTypes t on o.intermentContainerTypeId = t.intermentContainerTypeId left join IntermentCommittalTypes c on o.intermentCommittalTypeId = c.intermentCommittalTypeId where o.recordDelete_timeMillis is null - and o.burialSiteContractId = ? + and o.contractId = ? order by t.orderNumber, o.deceasedName, o.intermentNumber` ) - .all(burialSiteContractId) as BurialSiteContractInterment[] + .all(contractId) as ContractInterment[] if (connectedDatabase === undefined) { database.release() diff --git a/database/getContractTransactions.d.ts b/database/getContractTransactions.d.ts new file mode 100644 index 00000000..948438ed --- /dev/null +++ b/database/getContractTransactions.d.ts @@ -0,0 +1,5 @@ +import type { PoolConnection } from 'better-sqlite-pool'; +import type { ContractTransaction } from '../types/recordTypes.js'; +export default function GetContractTransactions(contractId: number | string, options: { + includeIntegrations: boolean; +}, connectedDatabase?: PoolConnection): Promise; diff --git a/database/getBurialSiteContractTransactions.js b/database/getContractTransactions.js similarity index 75% rename from database/getBurialSiteContractTransactions.js rename to database/getContractTransactions.js index bfc1e718..4101945a 100644 --- a/database/getBurialSiteContractTransactions.js +++ b/database/getContractTransactions.js @@ -2,26 +2,26 @@ import { dateIntegerToString, timeIntegerToString } from '@cityssm/utils-datetim import { getConfigProperty } from '../helpers/config.helpers.js'; import { getDynamicsGPDocument } from '../helpers/functions.dynamicsGP.js'; import { acquireConnection } from './pool.js'; -export default async function GetBurialSiteContractTransactions(burialSiteContractId, options, connectedDatabase) { +export default async function GetContractTransactions(contractId, options, connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); database.function('userFn_dateIntegerToString', dateIntegerToString); database.function('userFn_timeIntegerToString', timeIntegerToString); - const burialSiteContractTransactions = database - .prepare(`select burialSiteContractId, transactionIndex, + const contractTransactions = database + .prepare(`select contractId, transactionIndex, transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString, transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString, transactionAmount, externalReceiptNumber, transactionNote - from BurialSiteContractTransactions + from ContractTransactions where recordDelete_timeMillis is null - and burialSiteContractId = ? + and contractId = ? order by transactionDate, transactionTime, transactionIndex`) - .all(burialSiteContractId); + .all(contractId); if (connectedDatabase === undefined) { database.release(); } if (options.includeIntegrations && getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) { - for (const transaction of burialSiteContractTransactions) { + for (const transaction of contractTransactions) { if ((transaction.externalReceiptNumber ?? '') !== '') { const gpDocument = await getDynamicsGPDocument(transaction.externalReceiptNumber ?? ''); if (gpDocument !== undefined) { @@ -30,5 +30,5 @@ export default async function GetBurialSiteContractTransactions(burialSiteContra } } } - return burialSiteContractTransactions; + return contractTransactions; } diff --git a/database/getBurialSiteContractTransactions.ts b/database/getContractTransactions.ts similarity index 72% rename from database/getBurialSiteContractTransactions.ts rename to database/getContractTransactions.ts index aa945088..41589848 100644 --- a/database/getBurialSiteContractTransactions.ts +++ b/database/getContractTransactions.ts @@ -6,34 +6,34 @@ import type { PoolConnection } from 'better-sqlite-pool' import { getConfigProperty } from '../helpers/config.helpers.js' import { getDynamicsGPDocument } from '../helpers/functions.dynamicsGP.js' -import type { BurialSiteContractTransaction } from '../types/recordTypes.js' +import type { ContractTransaction } from '../types/recordTypes.js' import { acquireConnection } from './pool.js' -export default async function GetBurialSiteContractTransactions( - burialSiteContractId: number | string, +export default async function GetContractTransactions( + contractId: number | string, options: { includeIntegrations: boolean }, connectedDatabase?: PoolConnection -): Promise { +): Promise { const database = connectedDatabase ?? (await acquireConnection()) database.function('userFn_dateIntegerToString', dateIntegerToString) database.function('userFn_timeIntegerToString', timeIntegerToString) - const burialSiteContractTransactions = database + const contractTransactions = database .prepare( - `select burialSiteContractId, transactionIndex, + `select contractId, transactionIndex, transactionDate, userFn_dateIntegerToString(transactionDate) as transactionDateString, transactionTime, userFn_timeIntegerToString(transactionTime) as transactionTimeString, transactionAmount, externalReceiptNumber, transactionNote - from BurialSiteContractTransactions + from ContractTransactions where recordDelete_timeMillis is null - and burialSiteContractId = ? + and contractId = ? order by transactionDate, transactionTime, transactionIndex` ) - .all(burialSiteContractId) as BurialSiteContractTransaction[] + .all(contractId) as ContractTransaction[] if (connectedDatabase === undefined) { database.release() @@ -43,7 +43,7 @@ export default async function GetBurialSiteContractTransactions( options.includeIntegrations && getConfigProperty('settings.dynamicsGP.integrationIsEnabled') ) { - for (const transaction of burialSiteContractTransactions) { + for (const transaction of contractTransactions) { if ((transaction.externalReceiptNumber ?? '') !== '') { const gpDocument = await getDynamicsGPDocument( transaction.externalReceiptNumber ?? '' @@ -56,5 +56,5 @@ export default async function GetBurialSiteContractTransactions( } } - return burialSiteContractTransactions + return contractTransactions } diff --git a/database/getBurialSiteContracts.d.ts b/database/getContracts.d.ts similarity index 67% rename from database/getBurialSiteContracts.d.ts rename to database/getContracts.d.ts index 3e9cbb13..b6dd8b37 100644 --- a/database/getBurialSiteContracts.d.ts +++ b/database/getContracts.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'; -export interface GetBurialSiteContractsFilters { +import type { Contract } from '../types/recordTypes.js'; +export interface GetContractsFilters { burialSiteId?: number | string; occupancyTime?: '' | 'past' | 'current' | 'future'; contractStartDateString?: DateString; @@ -15,7 +15,7 @@ export interface GetBurialSiteContractsFilters { workOrderId?: number | string; notWorkOrderId?: number | string; } -export interface GetBurialSiteContractsOptions { +export interface GetContractsOptions { /** -1 for no limit */ limit: number | string; offset: number | string; @@ -23,7 +23,7 @@ export interface GetBurialSiteContractsOptions { includeFees: boolean; includeTransactions: boolean; } -export default function getBurialSiteContracts(filters: GetBurialSiteContractsFilters, options: GetBurialSiteContractsOptions, connectedDatabase?: PoolConnection): Promise<{ +export default function getContracts(filters: GetContractsFilters, options: GetContractsOptions, connectedDatabase?: PoolConnection): Promise<{ count: number; - burialSiteContracts: BurialSiteContract[]; + contracts: Contract[]; }>; diff --git a/database/getBurialSiteContracts.js b/database/getContracts.js similarity index 71% rename from database/getBurialSiteContracts.js rename to database/getContracts.js index 80be4291..def913dd 100644 --- a/database/getBurialSiteContracts.js +++ b/database/getContracts.js @@ -2,9 +2,9 @@ import { dateIntegerToString, dateStringToInteger } from '@cityssm/utils-datetim import { getConfigProperty } from '../helpers/config.helpers.js'; import { getContractTypeById } from '../helpers/functions.cache.js'; import { getBurialSiteNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js'; -import getBurialSiteContractFees from './getBurialSiteContractFees.js'; -// import getBurialSiteContractOccupants from './getBurialSiteContractOccupants.js' -import getBurialSiteContractTransactions from './getBurialSiteContractTransactions.js'; +import getContractFees from './getContractFees.js'; +// import getContractOccupants from './getContractOccupants.js' +import getContractTransactions from './getContractTransactions.js'; import { acquireConnection } from './pool.js'; function buildWhereClause(filters) { let sqlWhereClause = ' where o.recordDelete_timeMillis is null'; @@ -18,8 +18,8 @@ function buildWhereClause(filters) { sqlParameters.push(...lotNameFilters.sqlParameters); const occupantNameFilters = getOccupantNameWhereClause(filters.occupantName, 'o'); if (occupantNameFilters.sqlParameters.length > 0) { - sqlWhereClause += ` and o.burialSiteContractId in ( - select burialSiteContractId from LotOccupancyOccupants o + sqlWhereClause += ` and o.contractId in ( + select contractId from LotOccupancyOccupants o where recordDelete_timeMillis is null ${occupantNameFilters.sqlWhereClause})`; sqlParameters.push(...occupantNameFilters.sqlParameters); @@ -52,12 +52,12 @@ function buildWhereClause(filters) { } if ((filters.workOrderId ?? '') !== '') { sqlWhereClause += - ' and o.burialSiteContractId in (select burialSiteContractId from WorkOrderBurialSiteContracts where recordDelete_timeMillis is null and workOrderId = ?)'; + ' and o.contractId in (select contractId from WorkOrderContracts where recordDelete_timeMillis is null and workOrderId = ?)'; sqlParameters.push(filters.workOrderId); } if ((filters.notWorkOrderId ?? '') !== '') { sqlWhereClause += - ' and o.burialSiteContractId not in (select burialSiteContractId from WorkOrderBurialSiteContracts where recordDelete_timeMillis is null and workOrderId = ?)'; + ' and o.contractId not in (select contractId from WorkOrderContracts where recordDelete_timeMillis is null and workOrderId = ?)'; sqlParameters.push(filters.notWorkOrderId); } return { @@ -65,26 +65,26 @@ function buildWhereClause(filters) { sqlParameters }; } -async function addInclusions(burialSiteContract, options, database) { +async function addInclusions(contract, options, database) { if (options.includeFees) { - burialSiteContract.burialSiteContractFees = await getBurialSiteContractFees(burialSiteContract.burialSiteContractId, database); + contract.contractFees = await getContractFees(contract.contractId, database); } if (options.includeTransactions) { - burialSiteContract.burialSiteContractTransactions = - await getBurialSiteContractTransactions(burialSiteContract.burialSiteContractId, { includeIntegrations: false }, database); + contract.contractTransactions = + await getContractTransactions(contract.contractId, { includeIntegrations: false }, database); } /* if (options.includeInterments) { - burialSiteContract.burialSiteContractInterments = - await getBurialSiteContractOccupants( - burialSiteContract.burialSiteContractId, + contract.contractInterments = + await getContractOccupants( + contract.contractId, database ) } */ - return burialSiteContract; + return contract; } -export default async function getBurialSiteContracts(filters, options, connectedDatabase) { +export default async function getContracts(filters, options, connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); database.function('userFn_dateIntegerToString', dateIntegerToString); const { sqlWhereClause, sqlParameters } = buildWhereClause(filters); @@ -95,22 +95,22 @@ export default async function getBurialSiteContracts(filters, options, connected if (isLimited) { count = database .prepare(`select count(*) as recordCount - from BurialSiteContracts o + from Contracts o left join BurialSites l on o.burialSiteId = l.burialSiteId ${sqlWhereClause}`) .get(sqlParameters).recordCount; } - let burialSiteContracts = []; + let contracts = []; if (count !== 0) { - burialSiteContracts = database - .prepare(`select o.burialSiteContractId, + contracts = database + .prepare(`select o.contractId, o.contractTypeId, t.contractType, o.burialSiteId, lt.burialSiteType, l.burialSiteName, l.cemeteryId, m.cemeteryName, o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString, o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString - from BurialSiteContracts o + from Contracts o left join ContractTypes t on o.contractTypeId = t.contractTypeId left join BurialSites l on o.burialSiteId = l.burialSiteId left join BurialSiteTypes lt on l.burialSiteTypeId = lt.burialSiteTypeId @@ -122,20 +122,20 @@ export default async function getBurialSiteContracts(filters, options, connected l.burialSiteNameSegment3, l.burialSiteNameSegment4, l.burialSiteNameSegment5, - o.burialSiteId, o.burialSiteContractId desc + o.burialSiteId, o.contractId desc ${isLimited ? ` limit ${options.limit} offset ${options.offset}` : ''}`) .all(sqlParameters); if (!isLimited) { - count = burialSiteContracts.length; + count = contracts.length; } - for (const burialSiteContract of burialSiteContracts) { - const contractType = await getContractTypeById(burialSiteContract.contractTypeId); + for (const contract of contracts) { + const contractType = await getContractTypeById(contract.contractTypeId); if (contractType !== undefined) { - burialSiteContract.printEJS = (contractType.contractTypePrints ?? []).includes('*') + contract.printEJS = (contractType.contractTypePrints ?? []).includes('*') ? getConfigProperty('settings.contracts.prints')[0] : (contractType.contractTypePrints ?? [])[0]; } - await addInclusions(burialSiteContract, options, database); + await addInclusions(contract, options, database); } } if (connectedDatabase === undefined) { @@ -143,6 +143,6 @@ export default async function getBurialSiteContracts(filters, options, connected } return { count, - burialSiteContracts + contracts }; } diff --git a/database/getBurialSiteContracts.ts b/database/getContracts.ts similarity index 72% rename from database/getBurialSiteContracts.ts rename to database/getContracts.ts index 8dab26b6..5e8b3a23 100644 --- a/database/getBurialSiteContracts.ts +++ b/database/getContracts.ts @@ -12,14 +12,14 @@ import { getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js' -import type { BurialSiteContract } from '../types/recordTypes.js' +import type { Contract } from '../types/recordTypes.js' -import getBurialSiteContractFees from './getBurialSiteContractFees.js' -// import getBurialSiteContractOccupants from './getBurialSiteContractOccupants.js' -import getBurialSiteContractTransactions from './getBurialSiteContractTransactions.js' +import getContractFees from './getContractFees.js' +// import getContractOccupants from './getContractOccupants.js' +import getContractTransactions from './getContractTransactions.js' import { acquireConnection } from './pool.js' -export interface GetBurialSiteContractsFilters { +export interface GetContractsFilters { burialSiteId?: number | string occupancyTime?: '' | 'past' | 'current' | 'future' contractStartDateString?: DateString @@ -34,7 +34,7 @@ export interface GetBurialSiteContractsFilters { notWorkOrderId?: number | string } -export interface GetBurialSiteContractsOptions { +export interface GetContractsOptions { /** -1 for no limit */ limit: number | string offset: number | string @@ -43,7 +43,7 @@ export interface GetBurialSiteContractsOptions { includeTransactions: boolean } -function buildWhereClause(filters: GetBurialSiteContractsFilters): { +function buildWhereClause(filters: GetContractsFilters): { sqlWhereClause: string sqlParameters: unknown[] } { @@ -68,8 +68,8 @@ function buildWhereClause(filters: GetBurialSiteContractsFilters): { 'o' ) if (occupantNameFilters.sqlParameters.length > 0) { - sqlWhereClause += ` and o.burialSiteContractId in ( - select burialSiteContractId from LotOccupancyOccupants o + sqlWhereClause += ` and o.contractId in ( + select contractId from LotOccupancyOccupants o where recordDelete_timeMillis is null ${occupantNameFilters.sqlWhereClause})` sqlParameters.push(...occupantNameFilters.sqlParameters) @@ -117,13 +117,13 @@ function buildWhereClause(filters: GetBurialSiteContractsFilters): { if ((filters.workOrderId ?? '') !== '') { sqlWhereClause += - ' and o.burialSiteContractId in (select burialSiteContractId from WorkOrderBurialSiteContracts where recordDelete_timeMillis is null and workOrderId = ?)' + ' and o.contractId in (select contractId from WorkOrderContracts where recordDelete_timeMillis is null and workOrderId = ?)' sqlParameters.push(filters.workOrderId) } if ((filters.notWorkOrderId ?? '') !== '') { sqlWhereClause += - ' and o.burialSiteContractId not in (select burialSiteContractId from WorkOrderBurialSiteContracts where recordDelete_timeMillis is null and workOrderId = ?)' + ' and o.contractId not in (select contractId from WorkOrderContracts where recordDelete_timeMillis is null and workOrderId = ?)' sqlParameters.push(filters.notWorkOrderId) } @@ -134,21 +134,21 @@ function buildWhereClause(filters: GetBurialSiteContractsFilters): { } async function addInclusions( - burialSiteContract: BurialSiteContract, - options: GetBurialSiteContractsOptions, + contract: Contract, + options: GetContractsOptions, database: PoolConnection -): Promise { +): Promise { if (options.includeFees) { - burialSiteContract.burialSiteContractFees = await getBurialSiteContractFees( - burialSiteContract.burialSiteContractId, + contract.contractFees = await getContractFees( + contract.contractId, database ) } if (options.includeTransactions) { - burialSiteContract.burialSiteContractTransactions = - await getBurialSiteContractTransactions( - burialSiteContract.burialSiteContractId, + contract.contractTransactions = + await getContractTransactions( + contract.contractId, { includeIntegrations: false }, database ) @@ -156,22 +156,22 @@ async function addInclusions( /* if (options.includeInterments) { - burialSiteContract.burialSiteContractInterments = - await getBurialSiteContractOccupants( - burialSiteContract.burialSiteContractId, + contract.contractInterments = + await getContractOccupants( + contract.contractId, database ) } */ - return burialSiteContract + return contract } -export default async function getBurialSiteContracts( - filters: GetBurialSiteContractsFilters, - options: GetBurialSiteContractsOptions, +export default async function getContracts( + filters: GetContractsFilters, + options: GetContractsOptions, connectedDatabase?: PoolConnection -): Promise<{ count: number; burialSiteContracts: BurialSiteContract[] }> { +): Promise<{ count: number; contracts: Contract[] }> { const database = connectedDatabase ?? (await acquireConnection()) database.function('userFn_dateIntegerToString', dateIntegerToString) @@ -190,7 +190,7 @@ export default async function getBurialSiteContracts( database .prepare( `select count(*) as recordCount - from BurialSiteContracts o + from Contracts o left join BurialSites l on o.burialSiteId = l.burialSiteId ${sqlWhereClause}` ) @@ -198,19 +198,19 @@ export default async function getBurialSiteContracts( ).recordCount } - let burialSiteContracts: BurialSiteContract[] = [] + let contracts: Contract[] = [] if (count !== 0) { - burialSiteContracts = database + contracts = database .prepare( - `select o.burialSiteContractId, + `select o.contractId, o.contractTypeId, t.contractType, o.burialSiteId, lt.burialSiteType, l.burialSiteName, l.cemeteryId, m.cemeteryName, o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString, o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString - from BurialSiteContracts o + from Contracts o left join ContractTypes t on o.contractTypeId = t.contractTypeId left join BurialSites l on o.burialSiteId = l.burialSiteId left join BurialSiteTypes lt on l.burialSiteTypeId = lt.burialSiteTypeId @@ -222,31 +222,31 @@ export default async function getBurialSiteContracts( l.burialSiteNameSegment3, l.burialSiteNameSegment4, l.burialSiteNameSegment5, - o.burialSiteId, o.burialSiteContractId desc + o.burialSiteId, o.contractId desc ${ isLimited ? ` limit ${options.limit} offset ${options.offset}` : '' }` ) - .all(sqlParameters) as BurialSiteContract[] + .all(sqlParameters) as Contract[] if (!isLimited) { - count = burialSiteContracts.length + count = contracts.length } - for (const burialSiteContract of burialSiteContracts) { + for (const contract of contracts) { const contractType = await getContractTypeById( - burialSiteContract.contractTypeId + contract.contractTypeId ) if (contractType !== undefined) { - burialSiteContract.printEJS = ( + contract.printEJS = ( contractType.contractTypePrints ?? [] ).includes('*') ? getConfigProperty('settings.contracts.prints')[0] : (contractType.contractTypePrints ?? [])[0] } - await addInclusions(burialSiteContract, options, database) + await addInclusions(contract, options, database) } } @@ -256,6 +256,6 @@ export default async function getBurialSiteContracts( return { count, - burialSiteContracts + contracts } } diff --git a/database/getFees.js b/database/getFees.js index 270dd077..91c1fb16 100644 --- a/database/getFees.js +++ b/database/getFees.js @@ -24,11 +24,11 @@ export default async function getFees(feeCategoryId, additionalFilters, connecte f.taxAmount, f.taxPercentage, f.includeQuantity, f.quantityUnit, f.isRequired, f.orderNumber, - ifnull(lo.burialSiteContractFeeCount, 0) as burialSiteContractFeeCount + ifnull(lo.contractFeeCount, 0) as contractFeeCount from Fees f left join ( - select feeId, count(burialSiteContractId) as burialSiteContractFeeCount - from BurialSiteContractFees + select feeId, count(contractId) as contractFeeCount + from ContractFees where recordDelete_timeMillis is null group by feeId ) lo on f.feeId = lo.feeId diff --git a/database/getFees.ts b/database/getFees.ts index 311faf20..b5d10d47 100644 --- a/database/getFees.ts +++ b/database/getFees.ts @@ -50,11 +50,11 @@ export default async function getFees( f.taxAmount, f.taxPercentage, f.includeQuantity, f.quantityUnit, f.isRequired, f.orderNumber, - ifnull(lo.burialSiteContractFeeCount, 0) as burialSiteContractFeeCount + ifnull(lo.contractFeeCount, 0) as contractFeeCount from Fees f left join ( - select feeId, count(burialSiteContractId) as burialSiteContractFeeCount - from BurialSiteContractFees + select feeId, count(contractId) as contractFeeCount + from ContractFees where recordDelete_timeMillis is null group by feeId ) lo on f.feeId = lo.feeId diff --git a/database/getReportData.js b/database/getReportData.js index 9e88ffe9..3fd7f1ad 100644 --- a/database/getReportData.js +++ b/database/getReportData.js @@ -90,12 +90,12 @@ export default async function getReportData(reportName, reportParameters = {}) { sql = 'select * from BurialSiteFields'; break; } - case 'burialSiteContracts-all': { - sql = 'select * from BurialSiteContracts'; + case 'contracts-all': { + sql = 'select * from Contracts'; break; } - case 'burialSiteContracts-current-byCemeteryId': { - sql = `select o.burialSiteContractId, + case 'contracts-current-byCemeteryId': { + sql = `select o.contractId, l.burialSiteNameSegment1, l.burialSiteNameSegment2, l.burialSiteNameSegment3, @@ -105,7 +105,7 @@ export default async function getReportData(reportName, reportParameters = {}) { ot.contractType, o.contractStartDate, o.contractEndDate - from BurialSiteContracts o + from Contracts o left join ContractTypes ot on o.contractTypeId = ot.contractTypeId left join BurialSites l on o.burialSiteId = l.burialSiteId left join Cemeteries m on l.cemeteryId = m.cemeteryId @@ -115,28 +115,28 @@ export default async function getReportData(reportName, reportParameters = {}) { sqlParameters.push(dateToInteger(new Date()), reportParameters.cemeteryId); break; } - case 'burialSiteContractComments-all': { - sql = 'select * from BurialSiteContractComments'; + case 'contractComments-all': { + sql = 'select * from ContractComments'; break; } - case 'burialSiteContractFees-all': { - sql = 'select * from BurialSiteContractFees'; + case 'contractFees-all': { + sql = 'select * from ContractFees'; break; } - case 'burialSiteContractFields-all': { - sql = 'select * from BurialSiteContractFields'; + case 'contractFields-all': { + sql = 'select * from ContractFields'; break; } - case 'burialSiteContractTransactions-all': { - sql = 'select * from BurialSiteContractTransactions'; + case 'contractTransactions-all': { + sql = 'select * from ContractTransactions'; break; } - case 'burialSiteContractTransactions-byTransactionDateString': { - sql = `select t.burialSiteContractId, t.transactionIndex, + case 'contractTransactions-byTransactionDateString': { + sql = `select t.contractId, t.transactionIndex, t.transactionDate, t.transactionTime, t.transactionAmount, t.externalReceiptNumber, t.transactionNote - from BurialSiteContractTransactions t + from ContractTransactions t where t.recordDelete_timeMillis is null and t.transactionDate = ?`; sqlParameters.push(dateStringToInteger(reportParameters.transactionDateString)); diff --git a/database/getReportData.ts b/database/getReportData.ts index f175b69c..c6f336d4 100644 --- a/database/getReportData.ts +++ b/database/getReportData.ts @@ -119,13 +119,13 @@ export default async function getReportData( break } - case 'burialSiteContracts-all': { - sql = 'select * from BurialSiteContracts' + case 'contracts-all': { + sql = 'select * from Contracts' break } - case 'burialSiteContracts-current-byCemeteryId': { - sql = `select o.burialSiteContractId, + case 'contracts-current-byCemeteryId': { + sql = `select o.contractId, l.burialSiteNameSegment1, l.burialSiteNameSegment2, l.burialSiteNameSegment3, @@ -135,7 +135,7 @@ export default async function getReportData( ot.contractType, o.contractStartDate, o.contractEndDate - from BurialSiteContracts o + from Contracts o left join ContractTypes ot on o.contractTypeId = ot.contractTypeId left join BurialSites l on o.burialSiteId = l.burialSiteId left join Cemeteries m on l.cemeteryId = m.cemeteryId @@ -148,32 +148,32 @@ export default async function getReportData( break } - case 'burialSiteContractComments-all': { - sql = 'select * from BurialSiteContractComments' + case 'contractComments-all': { + sql = 'select * from ContractComments' break } - case 'burialSiteContractFees-all': { - sql = 'select * from BurialSiteContractFees' + case 'contractFees-all': { + sql = 'select * from ContractFees' break } - case 'burialSiteContractFields-all': { - sql = 'select * from BurialSiteContractFields' + case 'contractFields-all': { + sql = 'select * from ContractFields' break } - case 'burialSiteContractTransactions-all': { - sql = 'select * from BurialSiteContractTransactions' + case 'contractTransactions-all': { + sql = 'select * from ContractTransactions' break } - case 'burialSiteContractTransactions-byTransactionDateString': { - sql = `select t.burialSiteContractId, t.transactionIndex, + case 'contractTransactions-byTransactionDateString': { + sql = `select t.contractId, t.transactionIndex, t.transactionDate, t.transactionTime, t.transactionAmount, t.externalReceiptNumber, t.transactionNote - from BurialSiteContractTransactions t + from ContractTransactions t where t.recordDelete_timeMillis is null and t.transactionDate = ?` diff --git a/database/getWorkOrder.js b/database/getWorkOrder.js index 7b26a0f2..6690b38e 100644 --- a/database/getWorkOrder.js +++ b/database/getWorkOrder.js @@ -1,6 +1,6 @@ import { dateIntegerToString } from '@cityssm/utils-datetime'; -import getBurialSiteContracts from './getBurialSiteContracts.js'; import getBurialSites from './getBurialSites.js'; +import getContracts from './getContracts.js'; import getWorkOrderComments from './getWorkOrderComments.js'; import getWorkOrderMilestones from './getWorkOrderMilestones.js'; import { acquireConnection } from './pool.js'; @@ -24,10 +24,10 @@ async function _getWorkOrder(sql, workOrderIdOrWorkOrderNumber, options, connect }, { limit: -1, offset: 0, - includeBurialSiteContractCount: false + includeContractCount: false }, database); workOrder.workOrderBurialSites = burialSiteResults.burialSites; - const workOrderBurialSiteContractsResults = await getBurialSiteContracts({ + const workOrderContractsResults = await getContracts({ workOrderId: workOrder.workOrderId }, { limit: -1, @@ -36,8 +36,8 @@ async function _getWorkOrder(sql, workOrderIdOrWorkOrderNumber, options, connect includeFees: false, includeTransactions: false }, database); - workOrder.workOrderBurialSiteContracts = - workOrderBurialSiteContractsResults.burialSiteContracts; + workOrder.workOrderContracts = + workOrderContractsResults.contracts; } if (options.includeComments) { workOrder.workOrderComments = await getWorkOrderComments(workOrder.workOrderId, database); diff --git a/database/getWorkOrder.ts b/database/getWorkOrder.ts index 7de4cec9..32599afb 100644 --- a/database/getWorkOrder.ts +++ b/database/getWorkOrder.ts @@ -3,8 +3,8 @@ import type { PoolConnection } from 'better-sqlite-pool' import type { WorkOrder } from '../types/recordTypes.js' -import getBurialSiteContracts from './getBurialSiteContracts.js' import getBurialSites from './getBurialSites.js' +import getContracts from './getContracts.js' import getWorkOrderComments from './getWorkOrderComments.js' import getWorkOrderMilestones from './getWorkOrderMilestones.js' import { acquireConnection } from './pool.js' @@ -48,14 +48,14 @@ async function _getWorkOrder( { limit: -1, offset: 0, - includeBurialSiteContractCount: false + includeContractCount: false }, database ) workOrder.workOrderBurialSites = burialSiteResults.burialSites - const workOrderBurialSiteContractsResults = await getBurialSiteContracts( + const workOrderContractsResults = await getContracts( { workOrderId: workOrder.workOrderId }, @@ -69,8 +69,8 @@ async function _getWorkOrder( database ) - workOrder.workOrderBurialSiteContracts = - workOrderBurialSiteContractsResults.burialSiteContracts + workOrder.workOrderContracts = + workOrderContractsResults.contracts } if (options.includeComments) { diff --git a/database/getWorkOrderMilestones.js b/database/getWorkOrderMilestones.js index d31b1972..f130059b 100644 --- a/database/getWorkOrderMilestones.js +++ b/database/getWorkOrderMilestones.js @@ -1,6 +1,6 @@ import { dateIntegerToString, dateStringToInteger, dateToInteger, timeIntegerToPeriodString, timeIntegerToString } from '@cityssm/utils-datetime'; import { getConfigProperty } from '../helpers/config.helpers.js'; -import getBurialSiteContracts from './getBurialSiteContracts.js'; +import getContracts from './getContracts.js'; import getBurialSites from './getBurialSites.js'; import { acquireConnection } from './pool.js'; // eslint-disable-next-line security/detect-unsafe-regex @@ -127,10 +127,10 @@ export default async function getWorkOrderMilestones(filters, options, connected }, { limit: -1, offset: 0, - includeBurialSiteContractCount: false + includeContractCount: false }, database); workOrderMilestone.workOrderBurialSites = burialSites.burialSites; - const burialSiteContracts = await getBurialSiteContracts({ + const contracts = await getContracts({ workOrderId: workOrderMilestone.workOrderId }, { limit: -1, @@ -139,8 +139,8 @@ export default async function getWorkOrderMilestones(filters, options, connected includeFees: false, includeTransactions: false }, database); - workOrderMilestone.workOrderBurialSiteContracts = - burialSiteContracts.burialSiteContracts; + workOrderMilestone.workOrderContracts = + contracts.contracts; } } if (connectedDatabase === undefined) { diff --git a/database/getWorkOrderMilestones.ts b/database/getWorkOrderMilestones.ts index 25095ca5..448df80b 100644 --- a/database/getWorkOrderMilestones.ts +++ b/database/getWorkOrderMilestones.ts @@ -11,7 +11,7 @@ import type { PoolConnection } from 'better-sqlite-pool' import { getConfigProperty } from '../helpers/config.helpers.js' import type { WorkOrderMilestone } from '../types/recordTypes.js' -import getBurialSiteContracts from './getBurialSiteContracts.js' +import getContracts from './getContracts.js' import getBurialSites from './getBurialSites.js' import { acquireConnection } from './pool.js' @@ -214,14 +214,14 @@ export default async function getWorkOrderMilestones( { limit: -1, offset: 0, - includeBurialSiteContractCount: false + includeContractCount: false }, database ) workOrderMilestone.workOrderBurialSites = burialSites.burialSites - const burialSiteContracts = await getBurialSiteContracts( + const contracts = await getContracts( { workOrderId: workOrderMilestone.workOrderId }, @@ -235,8 +235,8 @@ export default async function getWorkOrderMilestones( database ) - workOrderMilestone.workOrderBurialSiteContracts = - burialSiteContracts.burialSiteContracts + workOrderMilestone.workOrderContracts = + contracts.contracts } } diff --git a/database/getWorkOrders.d.ts b/database/getWorkOrders.d.ts index ce2ceac6..17ead16b 100644 --- a/database/getWorkOrders.d.ts +++ b/database/getWorkOrders.d.ts @@ -6,7 +6,7 @@ export interface GetWorkOrdersFilters { workOrderOpenDateString?: string; occupantName?: string; lotName?: string; - burialSiteContractId?: number | string; + contractId?: number | string; } interface GetWorkOrdersOptions { limit: number; diff --git a/database/getWorkOrders.js b/database/getWorkOrders.js index 7c2e8215..0908fadd 100644 --- a/database/getWorkOrders.js +++ b/database/getWorkOrders.js @@ -1,6 +1,6 @@ import { dateIntegerToString, dateStringToInteger } from '@cityssm/utils-datetime'; import { getBurialSiteNameWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js'; -import getBurialSiteContracts from './getBurialSiteContracts.js'; +import getContracts from './getContracts.js'; import getBurialSites from './getBurialSites.js'; import getWorkOrderComments from './getWorkOrderComments.js'; import getWorkOrderMilestones from './getWorkOrderMilestones.js'; @@ -28,10 +28,10 @@ function buildWhereClause(filters) { if (occupantNameFilters.sqlParameters.length > 0) { sqlWhereClause += ` and w.workOrderId in ( - select workOrderId from WorkOrderBurialSiteContracts o + select workOrderId from WorkOrderContracts o where recordDelete_timeMillis is null - and o.burialSiteContractId in ( - select burialSiteContractId from LotOccupancyOccupants o where recordDelete_timeMillis is null + and o.contractId in ( + select contractId from LotOccupancyOccupants o where recordDelete_timeMillis is null ${occupantNameFilters.sqlWhereClause} ))`; sqlParameters.push(...occupantNameFilters.sqlParameters); @@ -49,10 +49,10 @@ function buildWhereClause(filters) { ))`; sqlParameters.push(...burialSiteNameFilters.sqlParameters); } - if ((filters.burialSiteContractId ?? '') !== '') { + if ((filters.contractId ?? '') !== '') { sqlWhereClause += - ' and w.workOrderId in (select workOrderId from WorkOrderBurialSiteContracts where recordDelete_timeMillis is null and burialSiteContractId = ?)'; - sqlParameters.push(filters.burialSiteContractId); + ' and w.workOrderId in (select workOrderId from WorkOrderContracts where recordDelete_timeMillis is null and contractId = ?)'; + sqlParameters.push(filters.contractId); } return { sqlWhereClause, @@ -73,11 +73,11 @@ async function addInclusions(workOrder, options, database) { }, { limit: -1, offset: 0, - includeBurialSiteContractCount: false + includeContractCount: false }, database); workOrder.workOrderBurialSites = workOrderBurialSitesResults.burialSites; } - const burialSiteContracts = await getBurialSiteContracts({ + const contracts = await getContracts({ workOrderId: workOrder.workOrderId }, { limit: -1, @@ -86,7 +86,7 @@ async function addInclusions(workOrder, options, database) { includeFees: false, includeTransactions: false }, database); - workOrder.workOrderBurialSiteContracts = burialSiteContracts.burialSiteContracts; + workOrder.workOrderContracts = contracts.contracts; } if (options.includeMilestones ?? false) { workOrder.workOrderMilestones = diff --git a/database/getWorkOrders.ts b/database/getWorkOrders.ts index 8553e26a..e2b4a3b4 100644 --- a/database/getWorkOrders.ts +++ b/database/getWorkOrders.ts @@ -11,7 +11,7 @@ import { } from '../helpers/functions.sqlFilters.js' import type { WorkOrder } from '../types/recordTypes.js' -import getBurialSiteContracts from './getBurialSiteContracts.js' +import getContracts from './getContracts.js' import getBurialSites from './getBurialSites.js' import getWorkOrderComments from './getWorkOrderComments.js' import getWorkOrderMilestones from './getWorkOrderMilestones.js' @@ -23,7 +23,7 @@ export interface GetWorkOrdersFilters { workOrderOpenDateString?: string occupantName?: string lotName?: string - burialSiteContractId?: number | string + contractId?: number | string } interface GetWorkOrdersOptions { @@ -68,10 +68,10 @@ function buildWhereClause(filters: GetWorkOrdersFilters): { if (occupantNameFilters.sqlParameters.length > 0) { sqlWhereClause += ` and w.workOrderId in ( - select workOrderId from WorkOrderBurialSiteContracts o + select workOrderId from WorkOrderContracts o where recordDelete_timeMillis is null - and o.burialSiteContractId in ( - select burialSiteContractId from LotOccupancyOccupants o where recordDelete_timeMillis is null + and o.contractId in ( + select contractId from LotOccupancyOccupants o where recordDelete_timeMillis is null ${occupantNameFilters.sqlWhereClause} ))` sqlParameters.push(...occupantNameFilters.sqlParameters) @@ -91,10 +91,10 @@ function buildWhereClause(filters: GetWorkOrdersFilters): { sqlParameters.push(...burialSiteNameFilters.sqlParameters) } - if ((filters.burialSiteContractId ?? '') !== '') { + if ((filters.contractId ?? '') !== '') { sqlWhereClause += - ' and w.workOrderId in (select workOrderId from WorkOrderBurialSiteContracts where recordDelete_timeMillis is null and burialSiteContractId = ?)' - sqlParameters.push(filters.burialSiteContractId) + ' and w.workOrderId in (select workOrderId from WorkOrderContracts where recordDelete_timeMillis is null and contractId = ?)' + sqlParameters.push(filters.contractId) } return { @@ -126,7 +126,7 @@ async function addInclusions( { limit: -1, offset: 0, - includeBurialSiteContractCount: false + includeContractCount: false }, database ) @@ -134,7 +134,7 @@ async function addInclusions( workOrder.workOrderBurialSites = workOrderBurialSitesResults.burialSites } - const burialSiteContracts = await getBurialSiteContracts( + const contracts = await getContracts( { workOrderId: workOrder.workOrderId }, @@ -148,7 +148,7 @@ async function addInclusions( database ) - workOrder.workOrderBurialSiteContracts = burialSiteContracts.burialSiteContracts + workOrder.workOrderContracts = contracts.contracts } if (options.includeMilestones ?? false) { diff --git a/database/initializeDatabase.js b/database/initializeDatabase.js index 28a9c152..b17c78bf 100644 --- a/database/initializeDatabase.js +++ b/database/initializeDatabase.js @@ -160,8 +160,8 @@ const createStatements = [ foreign key (contractTypeId) references ContractTypes (contractTypeId))`, `create index if not exists idx_ContractTypePrints_orderNumber on ContractTypePrints (contractTypeId, orderNumber, printEJS)`, - `create table if not exists BurialSiteContracts ( - burialSiteContractId integer not null primary key autoincrement, + `create table if not exists Contracts ( + contractId integer not null primary key autoincrement, contractTypeId integer not null, burialSiteId integer, contractStartDate integer not null check (contractStartDate > 0), @@ -183,24 +183,24 @@ const createStatements = [ foreign key (burialSiteId) references BurialSites (burialSiteId), foreign key (contractTypeId) references ContractTypes (contractTypeId), foreign key (funeralHomeId) references FuneralHomes (funeralHomeId))`, - `create table if not exists BurialSiteContractFields ( - burialSiteContractId integer not null, + `create table if not exists ContractFields ( + contractId integer not null, contractTypeFieldId integer not null, fieldValue text not null, ${recordColumns}, - primary key (burialSiteContractId, contractTypeFieldId), - foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId), + primary key (contractId, contractTypeFieldId), + foreign key (contractId) references Contracts (contractId), foreign key (contractTypeFieldId) references ContractTypeFields (contractTypeFieldId)) without rowid`, - `create table if not exists BurialSiteContractComments ( - burialSiteContractCommentId integer not null primary key autoincrement, - burialSiteContractId integer not null, + `create table if not exists ContractComments ( + contractCommentId integer not null primary key autoincrement, + contractId integer not null, commentDate integer not null check (commentDate > 0), commentTime integer not null check (commentTime >= 0), comment text not null, ${recordColumns}, - foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId))`, - `create index if not exists idx_BurialSiteContractComments_datetime - on BurialSiteContractComments (burialSiteContractId, commentDate, commentTime)`, + foreign key (contractId) references Contracts (contractId))`, + `create index if not exists idx_ContractComments_datetime + on ContractComments (contractId, commentDate, commentTime)`, /* * Interments */ @@ -218,8 +218,8 @@ const createStatements = [ ${recordColumns})`, `create index if not exists idx_IntermentCommittalType_orderNumber on IntermentCommittalTypes (orderNumber, intermentCommittalType)`, - `create table if not exists BurialSiteContractInterments ( - burialSiteContractId integer not null, + `create table if not exists ContractInterments ( + contractId integer not null, intermentNumber integer not null, deceasedName varchar(50) not null, @@ -238,8 +238,8 @@ const createStatements = [ intermentCommittalTypeId integer, ${recordColumns}, - primary key (burialSiteContractId, intermentNumber), - foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId), + primary key (contractId, intermentNumber), + foreign key (contractId) references Contracts (contractId), foreign key (intermentContainerTypeId) references IntermentContainerTypes (intermentContainerTypeId), foreign key (intermentCommittalTypeId) references IntermentCommittalTypes (intermentCommittalTypeId)) without rowid`, /* @@ -274,18 +274,18 @@ const createStatements = [ foreign key (contractTypeId) references ContractTypes (contractTypeId), foreign key (burialSiteTypeId) references BurialSiteTypes (burialSiteTypeId))`, 'create index if not exists idx_Fees_orderNumber on Fees (orderNumber, feeName)', - `create table if not exists BurialSiteContractFees ( - burialSiteContractId integer not null, + `create table if not exists ContractFees ( + contractId integer not null, feeId integer not null, quantity decimal(4, 1) not null default 1, feeAmount decimal(8, 2) not null, taxAmount decimal(8, 2) not null, ${recordColumns}, - primary key (burialSiteContractId, feeId), - foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId), + primary key (contractId, feeId), + foreign key (contractId) references Contracts (contractId), foreign key (feeId) references Fees (feeId)) without rowid`, - `create table if not exists BurialSiteContractTransactions ( - burialSiteContractId integer not null, + `create table if not exists ContractTransactions ( + contractId integer not null, transactionIndex integer not null, transactionDate integer not null check (transactionDate > 0), transactionTime integer not null check (transactionTime >= 0), @@ -293,10 +293,10 @@ const createStatements = [ externalReceiptNumber varchar(100), transactionNote text, ${recordColumns}, - primary key (burialSiteContractId, transactionIndex), - foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId)) without rowid`, - `create index if not exists idx_BurialSiteContractTransactions_orderNumber - on BurialSiteContractTransactions (burialSiteContractId, transactionDate, transactionTime)`, + primary key (contractId, transactionIndex), + foreign key (contractId) references Contracts (contractId)) without rowid`, + `create index if not exists idx_ContractTransactions_orderNumber + on ContractTransactions (contractId, transactionDate, transactionTime)`, /* * Work Orders */ @@ -323,13 +323,13 @@ const createStatements = [ primary key (workOrderId, burialSiteId), foreign key (workOrderId) references WorkOrders (workOrderId), foreign key (burialSiteId) references BurialSites (burialSiteId)) without rowid`, - `create table if not exists WorkOrderBurialSiteContracts ( + `create table if not exists WorkOrderContracts ( workOrderId integer not null, - burialSiteContractId integer not null, + contractId integer not null, ${recordColumns}, - primary key (workOrderId, burialSiteContractId), + primary key (workOrderId, contractId), foreign key (workOrderId) references WorkOrders (workOrderId), - foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId)) without rowid`, + foreign key (contractId) references Contracts (contractId)) without rowid`, `create table if not exists WorkOrderComments ( workOrderCommentId integer not null primary key autoincrement, workOrderId integer not null, diff --git a/database/initializeDatabase.ts b/database/initializeDatabase.ts index 741fdb5b..eb655cd9 100644 --- a/database/initializeDatabase.ts +++ b/database/initializeDatabase.ts @@ -190,8 +190,8 @@ const createStatements = [ `create index if not exists idx_ContractTypePrints_orderNumber on ContractTypePrints (contractTypeId, orderNumber, printEJS)`, - `create table if not exists BurialSiteContracts ( - burialSiteContractId integer not null primary key autoincrement, + `create table if not exists Contracts ( + contractId integer not null primary key autoincrement, contractTypeId integer not null, burialSiteId integer, contractStartDate integer not null check (contractStartDate > 0), @@ -214,26 +214,26 @@ const createStatements = [ foreign key (contractTypeId) references ContractTypes (contractTypeId), foreign key (funeralHomeId) references FuneralHomes (funeralHomeId))`, - `create table if not exists BurialSiteContractFields ( - burialSiteContractId integer not null, + `create table if not exists ContractFields ( + contractId integer not null, contractTypeFieldId integer not null, fieldValue text not null, ${recordColumns}, - primary key (burialSiteContractId, contractTypeFieldId), - foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId), + primary key (contractId, contractTypeFieldId), + foreign key (contractId) references Contracts (contractId), foreign key (contractTypeFieldId) references ContractTypeFields (contractTypeFieldId)) without rowid`, - `create table if not exists BurialSiteContractComments ( - burialSiteContractCommentId integer not null primary key autoincrement, - burialSiteContractId integer not null, + `create table if not exists ContractComments ( + contractCommentId integer not null primary key autoincrement, + contractId integer not null, commentDate integer not null check (commentDate > 0), commentTime integer not null check (commentTime >= 0), comment text not null, ${recordColumns}, - foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId))`, + foreign key (contractId) references Contracts (contractId))`, - `create index if not exists idx_BurialSiteContractComments_datetime - on BurialSiteContractComments (burialSiteContractId, commentDate, commentTime)`, + `create index if not exists idx_ContractComments_datetime + on ContractComments (contractId, commentDate, commentTime)`, /* * Interments @@ -257,8 +257,8 @@ const createStatements = [ `create index if not exists idx_IntermentCommittalType_orderNumber on IntermentCommittalTypes (orderNumber, intermentCommittalType)`, - `create table if not exists BurialSiteContractInterments ( - burialSiteContractId integer not null, + `create table if not exists ContractInterments ( + contractId integer not null, intermentNumber integer not null, deceasedName varchar(50) not null, @@ -277,8 +277,8 @@ const createStatements = [ intermentCommittalTypeId integer, ${recordColumns}, - primary key (burialSiteContractId, intermentNumber), - foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId), + primary key (contractId, intermentNumber), + foreign key (contractId) references Contracts (contractId), foreign key (intermentContainerTypeId) references IntermentContainerTypes (intermentContainerTypeId), foreign key (intermentCommittalTypeId) references IntermentCommittalTypes (intermentCommittalTypeId)) without rowid`, @@ -318,19 +318,19 @@ const createStatements = [ 'create index if not exists idx_Fees_orderNumber on Fees (orderNumber, feeName)', - `create table if not exists BurialSiteContractFees ( - burialSiteContractId integer not null, + `create table if not exists ContractFees ( + contractId integer not null, feeId integer not null, quantity decimal(4, 1) not null default 1, feeAmount decimal(8, 2) not null, taxAmount decimal(8, 2) not null, ${recordColumns}, - primary key (burialSiteContractId, feeId), - foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId), + primary key (contractId, feeId), + foreign key (contractId) references Contracts (contractId), foreign key (feeId) references Fees (feeId)) without rowid`, - `create table if not exists BurialSiteContractTransactions ( - burialSiteContractId integer not null, + `create table if not exists ContractTransactions ( + contractId integer not null, transactionIndex integer not null, transactionDate integer not null check (transactionDate > 0), transactionTime integer not null check (transactionTime >= 0), @@ -338,11 +338,11 @@ const createStatements = [ externalReceiptNumber varchar(100), transactionNote text, ${recordColumns}, - primary key (burialSiteContractId, transactionIndex), - foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId)) without rowid`, + primary key (contractId, transactionIndex), + foreign key (contractId) references Contracts (contractId)) without rowid`, - `create index if not exists idx_BurialSiteContractTransactions_orderNumber - on BurialSiteContractTransactions (burialSiteContractId, transactionDate, transactionTime)`, + `create index if not exists idx_ContractTransactions_orderNumber + on ContractTransactions (contractId, transactionDate, transactionTime)`, /* * Work Orders @@ -375,13 +375,13 @@ const createStatements = [ foreign key (workOrderId) references WorkOrders (workOrderId), foreign key (burialSiteId) references BurialSites (burialSiteId)) without rowid`, - `create table if not exists WorkOrderBurialSiteContracts ( + `create table if not exists WorkOrderContracts ( workOrderId integer not null, - burialSiteContractId integer not null, + contractId integer not null, ${recordColumns}, - primary key (workOrderId, burialSiteContractId), + primary key (workOrderId, contractId), foreign key (workOrderId) references WorkOrders (workOrderId), - foreign key (burialSiteContractId) references BurialSiteContracts (burialSiteContractId)) without rowid`, + foreign key (contractId) references Contracts (contractId)) without rowid`, `create table if not exists WorkOrderComments ( workOrderCommentId integer not null primary key autoincrement, diff --git a/database/updateBurialSiteContractFeeQuantity.d.ts b/database/updateBurialSiteContractFeeQuantity.d.ts deleted file mode 100644 index 3ea59793..00000000 --- a/database/updateBurialSiteContractFeeQuantity.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface UpdateBurialSiteFeeForm { - burialSiteContractId: string | number; - feeId: string | number; - quantity: string | number; -} -export default function updateBurialSiteContractFeeQuantity(feeQuantityForm: UpdateBurialSiteFeeForm, user: User): Promise; diff --git a/database/updateBurialSiteContract.d.ts b/database/updateContract.d.ts similarity index 59% rename from database/updateBurialSiteContract.d.ts rename to database/updateContract.d.ts index dfe10e15..518c188f 100644 --- a/database/updateBurialSiteContract.d.ts +++ b/database/updateContract.d.ts @@ -1,6 +1,6 @@ import { type DateString } from '@cityssm/utils-datetime'; -export interface UpdateBurialSiteContractForm { - burialSiteContractId: string | number; +export interface UpdateContractForm { + contractId: string | number; contractTypeId: string | number; burialSiteId: string | number; contractStartDateString: DateString; @@ -8,4 +8,4 @@ export interface UpdateBurialSiteContractForm { contractTypeFieldIds?: string; [fieldValue_contractTypeFieldId: string]: unknown; } -export default function updateBurialSiteContract(updateForm: UpdateBurialSiteContractForm, user: User): Promise; +export default function updateContract(updateForm: UpdateContractForm, user: User): Promise; diff --git a/database/updateBurialSiteContract.js b/database/updateContract.js similarity index 66% rename from database/updateBurialSiteContract.js rename to database/updateContract.js index 901c4d8c..3ef5e1c6 100644 --- a/database/updateBurialSiteContract.js +++ b/database/updateContract.js @@ -1,31 +1,31 @@ import { dateStringToInteger } from '@cityssm/utils-datetime'; -import addOrUpdateBurialSiteContractField from './addOrUpdateBurialSiteContractField.js'; -import deleteBurialSiteContractField from './deleteBurialSiteContractField.js'; +import addOrUpdateContractField from './addOrUpdateContractField.js'; +import deleteContractField from './deleteContractField.js'; import { acquireConnection } from './pool.js'; -export default async function updateBurialSiteContract(updateForm, user) { +export default async function updateContract(updateForm, user) { const database = await acquireConnection(); const result = database - .prepare(`update BurialSiteContracts + .prepare(`update Contracts set contractTypeId = ?, burialSiteId = ?, contractStartDate = ?, contractEndDate = ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ? - where burialSiteContractId = ? + where contractId = ? and recordDelete_timeMillis is null`) .run(updateForm.contractTypeId, updateForm.burialSiteId === '' ? undefined : updateForm.burialSiteId, dateStringToInteger(updateForm.contractStartDateString), updateForm.contractEndDateString === '' ? undefined - : dateStringToInteger(updateForm.contractEndDateString), user.userName, Date.now(), updateForm.burialSiteContractId); + : dateStringToInteger(updateForm.contractEndDateString), user.userName, Date.now(), updateForm.contractId); if (result.changes > 0) { const contractTypeFieldIds = (updateForm.contractTypeFieldIds ?? '').split(','); for (const contractTypeFieldId of contractTypeFieldIds) { const fieldValue = updateForm[`fieldValue_${contractTypeFieldId}`]; // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition await ((fieldValue ?? '') === '' - ? deleteBurialSiteContractField(updateForm.burialSiteContractId, contractTypeFieldId, user, database) - : addOrUpdateBurialSiteContractField({ - burialSiteContractId: updateForm.burialSiteContractId, + ? deleteContractField(updateForm.contractId, contractTypeFieldId, user, database) + : addOrUpdateContractField({ + contractId: updateForm.contractId, contractTypeFieldId, fieldValue }, user, database)); diff --git a/database/updateBurialSiteContract.ts b/database/updateContract.ts similarity index 72% rename from database/updateBurialSiteContract.ts rename to database/updateContract.ts index 103462f6..bca99df5 100644 --- a/database/updateBurialSiteContract.ts +++ b/database/updateContract.ts @@ -1,11 +1,11 @@ import { type DateString, dateStringToInteger } from '@cityssm/utils-datetime' -import addOrUpdateBurialSiteContractField from './addOrUpdateBurialSiteContractField.js' -import deleteBurialSiteContractField from './deleteBurialSiteContractField.js' +import addOrUpdateContractField from './addOrUpdateContractField.js' +import deleteContractField from './deleteContractField.js' import { acquireConnection } from './pool.js' -export interface UpdateBurialSiteContractForm { - burialSiteContractId: string | number +export interface UpdateContractForm { + contractId: string | number contractTypeId: string | number burialSiteId: string | number @@ -16,22 +16,22 @@ export interface UpdateBurialSiteContractForm { [fieldValue_contractTypeFieldId: string]: unknown } -export default async function updateBurialSiteContract( - updateForm: UpdateBurialSiteContractForm, +export default async function updateContract( + updateForm: UpdateContractForm, user: User ): Promise { const database = await acquireConnection() const result = database .prepare( - `update BurialSiteContracts + `update Contracts set contractTypeId = ?, burialSiteId = ?, contractStartDate = ?, contractEndDate = ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ? - where burialSiteContractId = ? + where contractId = ? and recordDelete_timeMillis is null` ) .run( @@ -43,7 +43,7 @@ export default async function updateBurialSiteContract( : dateStringToInteger(updateForm.contractEndDateString), user.userName, Date.now(), - updateForm.burialSiteContractId + updateForm.contractId ) if (result.changes > 0) { @@ -58,15 +58,15 @@ export default async function updateBurialSiteContract( // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition await ((fieldValue ?? '') === '' - ? deleteBurialSiteContractField( - updateForm.burialSiteContractId, + ? deleteContractField( + updateForm.contractId, contractTypeFieldId, user, database ) - : addOrUpdateBurialSiteContractField( + : addOrUpdateContractField( { - burialSiteContractId: updateForm.burialSiteContractId, + contractId: updateForm.contractId, contractTypeFieldId, fieldValue }, diff --git a/database/updateBurialSiteContractComment.d.ts b/database/updateContractComment.d.ts similarity index 55% rename from database/updateBurialSiteContractComment.d.ts rename to database/updateContractComment.d.ts index af05dcfe..afadb590 100644 --- a/database/updateBurialSiteContractComment.d.ts +++ b/database/updateContractComment.d.ts @@ -1,8 +1,8 @@ import { type DateString, type TimeString } from '@cityssm/utils-datetime'; export interface UpdateForm { - burialSiteContractCommentId: string | number; + contractCommentId: string | number; commentDateString: DateString; commentTimeString: TimeString; comment: string; } -export default function updateBurialSiteContractComment(commentForm: UpdateForm, user: User): Promise; +export default function updateContractComment(commentForm: UpdateForm, user: User): Promise; diff --git a/database/updateBurialSiteContractComment.js b/database/updateContractComment.js similarity index 69% rename from database/updateBurialSiteContractComment.js rename to database/updateContractComment.js index b0b3859c..e7ed4501 100644 --- a/database/updateBurialSiteContractComment.js +++ b/database/updateContractComment.js @@ -1,17 +1,17 @@ import { dateStringToInteger, timeStringToInteger } from '@cityssm/utils-datetime'; import { acquireConnection } from './pool.js'; -export default async function updateBurialSiteContractComment(commentForm, user) { +export default async function updateContractComment(commentForm, user) { const database = await acquireConnection(); const result = database - .prepare(`update BurialSiteContractComments + .prepare(`update ContractComments set commentDate = ?, commentTime = ?, comment = ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteContractCommentId = ?`) - .run(dateStringToInteger(commentForm.commentDateString), timeStringToInteger(commentForm.commentTimeString), commentForm.comment, user.userName, Date.now(), commentForm.burialSiteContractCommentId); + and contractCommentId = ?`) + .run(dateStringToInteger(commentForm.commentDateString), timeStringToInteger(commentForm.commentTimeString), commentForm.comment, user.userName, Date.now(), commentForm.contractCommentId); database.release(); return result.changes > 0; } diff --git a/database/updateBurialSiteContractComment.ts b/database/updateContractComment.ts similarity index 78% rename from database/updateBurialSiteContractComment.ts rename to database/updateContractComment.ts index 3d05bc5e..f36d0f36 100644 --- a/database/updateBurialSiteContractComment.ts +++ b/database/updateContractComment.ts @@ -8,13 +8,13 @@ import { import { acquireConnection } from './pool.js' export interface UpdateForm { - burialSiteContractCommentId: string | number + contractCommentId: string | number commentDateString: DateString commentTimeString: TimeString comment: string } -export default async function updateBurialSiteContractComment( +export default async function updateContractComment( commentForm: UpdateForm, user: User ): Promise { @@ -22,14 +22,14 @@ export default async function updateBurialSiteContractComment( const result = database .prepare( - `update BurialSiteContractComments + `update ContractComments set commentDate = ?, commentTime = ?, comment = ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteContractCommentId = ?` + and contractCommentId = ?` ) .run( dateStringToInteger(commentForm.commentDateString), @@ -37,7 +37,7 @@ export default async function updateBurialSiteContractComment( commentForm.comment, user.userName, Date.now(), - commentForm.burialSiteContractCommentId + commentForm.contractCommentId ) database.release() diff --git a/database/updateContractFeeQuantity.d.ts b/database/updateContractFeeQuantity.d.ts new file mode 100644 index 00000000..f3e79a91 --- /dev/null +++ b/database/updateContractFeeQuantity.d.ts @@ -0,0 +1,6 @@ +export interface UpdateBurialSiteFeeForm { + contractId: string | number; + feeId: string | number; + quantity: string | number; +} +export default function updateContractFeeQuantity(feeQuantityForm: UpdateBurialSiteFeeForm, user: User): Promise; diff --git a/database/updateBurialSiteContractFeeQuantity.js b/database/updateContractFeeQuantity.js similarity index 63% rename from database/updateBurialSiteContractFeeQuantity.js rename to database/updateContractFeeQuantity.js index 1d510591..8a99be74 100644 --- a/database/updateBurialSiteContractFeeQuantity.js +++ b/database/updateContractFeeQuantity.js @@ -1,15 +1,15 @@ import { acquireConnection } from './pool.js'; -export default async function updateBurialSiteContractFeeQuantity(feeQuantityForm, user) { +export default async function updateContractFeeQuantity(feeQuantityForm, user) { const database = await acquireConnection(); const result = database - .prepare(`update BurialSiteContractFees + .prepare(`update ContractFees set quantity = ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteContractId = ? + and contractId = ? and feeId = ?`) - .run(feeQuantityForm.quantity, user.userName, Date.now(), feeQuantityForm.burialSiteContractId, feeQuantityForm.feeId); + .run(feeQuantityForm.quantity, user.userName, Date.now(), feeQuantityForm.contractId, feeQuantityForm.feeId); database.release(); return result.changes > 0; } diff --git a/database/updateBurialSiteContractFeeQuantity.ts b/database/updateContractFeeQuantity.ts similarity index 74% rename from database/updateBurialSiteContractFeeQuantity.ts rename to database/updateContractFeeQuantity.ts index 2557a4a6..38e059a2 100644 --- a/database/updateBurialSiteContractFeeQuantity.ts +++ b/database/updateContractFeeQuantity.ts @@ -1,12 +1,12 @@ import { acquireConnection } from './pool.js' export interface UpdateBurialSiteFeeForm { - burialSiteContractId: string | number + contractId: string | number feeId: string | number quantity: string | number } -export default async function updateBurialSiteContractFeeQuantity( +export default async function updateContractFeeQuantity( feeQuantityForm: UpdateBurialSiteFeeForm, user: User ): Promise { @@ -14,19 +14,19 @@ export default async function updateBurialSiteContractFeeQuantity( const result = database .prepare( - `update BurialSiteContractFees + `update ContractFees set quantity = ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteContractId = ? + and contractId = ? and feeId = ?` ) .run( feeQuantityForm.quantity, user.userName, Date.now(), - feeQuantityForm.burialSiteContractId, + feeQuantityForm.contractId, feeQuantityForm.feeId ) diff --git a/database/updateBurialSiteContractTransaction.d.ts b/database/updateContractTransaction.d.ts similarity index 54% rename from database/updateBurialSiteContractTransaction.d.ts rename to database/updateContractTransaction.d.ts index 452b4709..30bdf1db 100644 --- a/database/updateBurialSiteContractTransaction.d.ts +++ b/database/updateContractTransaction.d.ts @@ -1,6 +1,6 @@ import { type DateString, type TimeString } from '@cityssm/utils-datetime'; -export interface BurialSiteContractTransactionUpdateForm { - burialSiteContractId: string | number; +export interface ContractTransactionUpdateForm { + contractId: string | number; transactionIndex: string | number; transactionDateString: DateString; transactionTimeString: TimeString; @@ -8,4 +8,4 @@ export interface BurialSiteContractTransactionUpdateForm { externalReceiptNumber: string; transactionNote: string; } -export default function updateBurialSiteContractTransaction(updateForm: BurialSiteContractTransactionUpdateForm, user: User): Promise; +export default function updateContractTransaction(updateForm: ContractTransactionUpdateForm, user: User): Promise; diff --git a/database/updateBurialSiteContractTransaction.js b/database/updateContractTransaction.js similarity index 72% rename from database/updateBurialSiteContractTransaction.js rename to database/updateContractTransaction.js index 20be3501..7cf08175 100644 --- a/database/updateBurialSiteContractTransaction.js +++ b/database/updateContractTransaction.js @@ -1,9 +1,9 @@ import { dateStringToInteger, timeStringToInteger } from '@cityssm/utils-datetime'; import { acquireConnection } from './pool.js'; -export default async function updateBurialSiteContractTransaction(updateForm, user) { +export default async function updateContractTransaction(updateForm, user) { const database = await acquireConnection(); const result = database - .prepare(`update BurialSiteContractTransactions + .prepare(`update ContractTransactions set transactionAmount = ?, externalReceiptNumber = ?, transactionNote = ?, @@ -12,9 +12,9 @@ export default async function updateBurialSiteContractTransaction(updateForm, us recordUpdate_userName = ?, recordUpdate_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteContractId = ? + and contractId = ? and transactionIndex = ?`) - .run(updateForm.transactionAmount, updateForm.externalReceiptNumber, updateForm.transactionNote, dateStringToInteger(updateForm.transactionDateString), timeStringToInteger(updateForm.transactionTimeString), user.userName, Date.now(), updateForm.burialSiteContractId, updateForm.transactionIndex); + .run(updateForm.transactionAmount, updateForm.externalReceiptNumber, updateForm.transactionNote, dateStringToInteger(updateForm.transactionDateString), timeStringToInteger(updateForm.transactionTimeString), user.userName, Date.now(), updateForm.contractId, updateForm.transactionIndex); database.release(); return result.changes > 0; } diff --git a/database/updateBurialSiteContractTransaction.ts b/database/updateContractTransaction.ts similarity index 77% rename from database/updateBurialSiteContractTransaction.ts rename to database/updateContractTransaction.ts index 71ec332f..7d382974 100644 --- a/database/updateBurialSiteContractTransaction.ts +++ b/database/updateContractTransaction.ts @@ -7,8 +7,8 @@ import { import { acquireConnection } from './pool.js' -export interface BurialSiteContractTransactionUpdateForm { - burialSiteContractId: string | number +export interface ContractTransactionUpdateForm { + contractId: string | number transactionIndex: string | number transactionDateString: DateString transactionTimeString: TimeString @@ -17,15 +17,15 @@ export interface BurialSiteContractTransactionUpdateForm { transactionNote: string } -export default async function updateBurialSiteContractTransaction( - updateForm: BurialSiteContractTransactionUpdateForm, +export default async function updateContractTransaction( + updateForm: ContractTransactionUpdateForm, user: User ): Promise { const database = await acquireConnection() const result = database .prepare( - `update BurialSiteContractTransactions + `update ContractTransactions set transactionAmount = ?, externalReceiptNumber = ?, transactionNote = ?, @@ -34,7 +34,7 @@ export default async function updateBurialSiteContractTransaction( recordUpdate_userName = ?, recordUpdate_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteContractId = ? + and contractId = ? and transactionIndex = ?` ) .run( @@ -45,7 +45,7 @@ export default async function updateBurialSiteContractTransaction( timeStringToInteger(updateForm.transactionTimeString), user.userName, Date.now(), - updateForm.burialSiteContractId, + updateForm.contractId, updateForm.transactionIndex ) diff --git a/database/updateLotOccupancyOccupant.d.ts b/database/updateLotOccupancyOccupant.d.ts index a5bcc9c2..2ba973a0 100644 --- a/database/updateLotOccupancyOccupant.d.ts +++ b/database/updateLotOccupancyOccupant.d.ts @@ -1,5 +1,5 @@ export interface UpdateLotOccupancyOccupantForm { - burialSiteContractId: string | number; + contractId: string | number; lotOccupantIndex: string | number; lotOccupantTypeId: string | number; occupantName: string; @@ -13,4 +13,4 @@ export interface UpdateLotOccupancyOccupantForm { occupantEmailAddress: string; occupantComment: string; } -export default function updateBurialSiteContractOccupant(burialSiteContractOccupantForm: UpdateLotOccupancyOccupantForm, user: User): Promise; +export default function updateContractOccupant(contractOccupantForm: UpdateLotOccupancyOccupantForm, user: User): Promise; diff --git a/database/updateLotOccupancyOccupant.js b/database/updateLotOccupancyOccupant.js index aed18e1e..e74fc32d 100644 --- a/database/updateLotOccupancyOccupant.js +++ b/database/updateLotOccupancyOccupant.js @@ -1,5 +1,5 @@ import { acquireConnection } from './pool.js'; -export default async function updateBurialSiteContractOccupant(burialSiteContractOccupantForm, user) { +export default async function updateContractOccupant(contractOccupantForm, user) { const database = await acquireConnection(); const results = database .prepare(`update LotOccupancyOccupants @@ -17,9 +17,9 @@ export default async function updateBurialSiteContractOccupant(burialSiteContrac recordUpdate_userName = ?, recordUpdate_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteContractId = ? + and contractId = ? and 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); + .run(contractOccupantForm.occupantName, contractOccupantForm.occupantFamilyName, contractOccupantForm.occupantAddress1, contractOccupantForm.occupantAddress2, contractOccupantForm.occupantCity, contractOccupantForm.occupantProvince, contractOccupantForm.occupantPostalCode, contractOccupantForm.occupantPhoneNumber, contractOccupantForm.occupantEmailAddress, contractOccupantForm.occupantComment, contractOccupantForm.lotOccupantTypeId, user.userName, Date.now(), contractOccupantForm.contractId, contractOccupantForm.lotOccupantIndex); database.release(); return results.changes > 0; } diff --git a/database/updateLotOccupancyOccupant.ts b/database/updateLotOccupancyOccupant.ts index bbeafdd1..be2d0e07 100644 --- a/database/updateLotOccupancyOccupant.ts +++ b/database/updateLotOccupancyOccupant.ts @@ -1,7 +1,7 @@ import { acquireConnection } from './pool.js' export interface UpdateLotOccupancyOccupantForm { - burialSiteContractId: string | number + contractId: string | number lotOccupantIndex: string | number lotOccupantTypeId: string | number occupantName: string @@ -16,8 +16,8 @@ export interface UpdateLotOccupancyOccupantForm { occupantComment: string } -export default async function updateBurialSiteContractOccupant( - burialSiteContractOccupantForm: UpdateLotOccupancyOccupantForm, +export default async function updateContractOccupant( + contractOccupantForm: UpdateLotOccupancyOccupantForm, user: User ): Promise { const database = await acquireConnection() @@ -39,25 +39,25 @@ export default async function updateBurialSiteContractOccupant( recordUpdate_userName = ?, recordUpdate_timeMillis = ? where recordDelete_timeMillis is null - and burialSiteContractId = ? + and contractId = ? and lotOccupantIndex = ?` ) .run( - burialSiteContractOccupantForm.occupantName, - burialSiteContractOccupantForm.occupantFamilyName, - burialSiteContractOccupantForm.occupantAddress1, - burialSiteContractOccupantForm.occupantAddress2, - burialSiteContractOccupantForm.occupantCity, - burialSiteContractOccupantForm.occupantProvince, - burialSiteContractOccupantForm.occupantPostalCode, - burialSiteContractOccupantForm.occupantPhoneNumber, - burialSiteContractOccupantForm.occupantEmailAddress, - burialSiteContractOccupantForm.occupantComment, - burialSiteContractOccupantForm.lotOccupantTypeId, + contractOccupantForm.occupantName, + contractOccupantForm.occupantFamilyName, + contractOccupantForm.occupantAddress1, + contractOccupantForm.occupantAddress2, + contractOccupantForm.occupantCity, + contractOccupantForm.occupantProvince, + contractOccupantForm.occupantPostalCode, + contractOccupantForm.occupantPhoneNumber, + contractOccupantForm.occupantEmailAddress, + contractOccupantForm.occupantComment, + contractOccupantForm.lotOccupantTypeId, user.userName, Date.now(), - burialSiteContractOccupantForm.burialSiteContractId, - burialSiteContractOccupantForm.lotOccupantIndex + contractOccupantForm.contractId, + contractOccupantForm.lotOccupantIndex ) database.release() diff --git a/handlers/api-get/milestoneICS.js b/handlers/api-get/milestoneICS.js index fd2c9376..4984ad2d 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 burialSiteContract of milestone.workOrderBurialSiteContracts ?? []) { - for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) { + for (const contract of milestone.workOrderContracts ?? []) { + for (const occupant of contract.contractOccupants ?? []) { occupantCount += 1; if (occupantCount === 1) { if (summary !== '') { @@ -42,7 +42,7 @@ function buildEventSummary(milestone) { // eslint-disable-next-line @typescript-eslint/naming-convention function buildEventDescriptionHTML_occupancies(request, milestone) { let descriptionHTML = ''; - if (milestone.workOrderBurialSiteContracts.length > 0) { + if (milestone.workOrderContracts.length > 0) { const urlRoot = getUrlRoot(request); descriptionHTML = `

Related Contracts @@ -56,10 +56,10 @@ function buildEventDescriptionHTML_occupancies(request, milestone) { ${escapeHTML(getConfigProperty('aliases.occupants'))} `; - for (const occupancy of milestone.workOrderBurialSiteContracts ?? []) { + for (const occupancy of milestone.workOrderContracts ?? []) { descriptionHTML += ` - + ${escapeHTML(occupancy.occupancyType ?? '')} @@ -75,7 +75,7 @@ function buildEventDescriptionHTML_occupancies(request, milestone) { : '(No End Date)'} `; - for (const occupant of occupancy.burialSiteContractOccupants ?? []) { + for (const occupant of occupancy.contractOccupants ?? []) { descriptionHTML += `${escapeHTML(occupant.lotOccupantType ?? '')}: ${escapeHTML(occupant.occupantName ?? '')} ${escapeHTML(occupant.occupantFamilyName ?? '')}
`; } descriptionHTML += ''; @@ -247,10 +247,10 @@ export default async function handler(request, response) { const location = buildEventLocation(milestone); calendarEvent.location(location); // Set organizer / attendees - if (milestone.workOrderBurialSiteContracts.length > 0) { + if (milestone.workOrderContracts.length > 0) { let organizerSet = false; - for (const burialSiteContract of milestone.workOrderBurialSiteContracts ?? []) { - for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) { + for (const contract of milestone.workOrderContracts ?? []) { + for (const occupant of contract.contractOccupants ?? []) { if (organizerSet) { calendarEvent.createAttendee({ name: `${occupant.occupantName ?? ''} ${occupant.occupantFamilyName ?? ''}`, diff --git a/handlers/api-get/milestoneICS.ts b/handlers/api-get/milestoneICS.ts index 65686f16..a9f3020a 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 burialSiteContract of milestone.workOrderBurialSiteContracts ?? []) { - for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) { + for (const contract of milestone.workOrderContracts ?? []) { + for (const occupant of contract.contractOccupants ?? []) { occupantCount += 1 if (occupantCount === 1) { @@ -75,7 +75,7 @@ function buildEventDescriptionHTML_occupancies( ): string { let descriptionHTML = '' - if (milestone.workOrderBurialSiteContracts!.length > 0) { + if (milestone.workOrderContracts!.length > 0) { const urlRoot = getUrlRoot(request) descriptionHTML = `

@@ -91,10 +91,10 @@ function buildEventDescriptionHTML_occupancies( ` - for (const occupancy of milestone.workOrderBurialSiteContracts ?? []) { + for (const occupancy of milestone.workOrderContracts ?? []) { descriptionHTML += ` - + ${escapeHTML(occupancy.occupancyType ?? '')} @@ -113,7 +113,7 @@ function buildEventDescriptionHTML_occupancies( ` - for (const occupant of occupancy.burialSiteContractOccupants ?? []) { + for (const occupant of occupancy.contractOccupants ?? []) { descriptionHTML += `${escapeHTML( occupant.lotOccupantType ?? '' )}: ${escapeHTML(occupant.occupantName ?? '')} ${escapeHTML( @@ -369,10 +369,10 @@ export default async function handler( calendarEvent.location(location) // Set organizer / attendees - if (milestone.workOrderBurialSiteContracts!.length > 0) { + if (milestone.workOrderContracts!.length > 0) { let organizerSet = false - for (const burialSiteContract of milestone.workOrderBurialSiteContracts ?? []) { - for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) { + for (const contract of milestone.workOrderContracts ?? []) { + for (const occupant of contract.contractOccupants ?? []) { if (organizerSet) { calendarEvent.createAttendee({ name: `${occupant.occupantName ?? ''} ${ diff --git a/handlers/burialSites-get/new.js b/handlers/burialSites-get/new.js index 45c6f13c..6ccd26d5 100644 --- a/handlers/burialSites-get/new.js +++ b/handlers/burialSites-get/new.js @@ -3,7 +3,7 @@ import { getBurialSiteStatuses, getBurialSiteTypes } from '../../helpers/functio export default async function handler(request, response) { const burialSite = { burialSiteId: -1, - burialSiteContracts: [] + contracts: [] }; const cemeteries = await getCemeteries(); if (request.query.cemeteryId !== undefined) { diff --git a/handlers/burialSites-get/new.ts b/handlers/burialSites-get/new.ts index f495c48c..cf92fa7e 100644 --- a/handlers/burialSites-get/new.ts +++ b/handlers/burialSites-get/new.ts @@ -13,7 +13,7 @@ export default async function handler( ): Promise { const burialSite: BurialSite = { burialSiteId: -1, - burialSiteContracts: [] + contracts: [] } const cemeteries = await getCemeteries() diff --git a/handlers/burialSites-post/doSearchBurialSites.js b/handlers/burialSites-post/doSearchBurialSites.js index 99776c3a..c0b0f156 100644 --- a/handlers/burialSites-post/doSearchBurialSites.js +++ b/handlers/burialSites-post/doSearchBurialSites.js @@ -3,7 +3,7 @@ export default async function handler(request, response) { const result = await getBurialSites(request.body, { limit: request.body.limit, offset: request.body.offset, - includeBurialSiteContractCount: true + includeContractCount: true }); response.json({ count: result.count, diff --git a/handlers/burialSites-post/doSearchBurialSites.ts b/handlers/burialSites-post/doSearchBurialSites.ts index 7d75a362..712ac457 100644 --- a/handlers/burialSites-post/doSearchBurialSites.ts +++ b/handlers/burialSites-post/doSearchBurialSites.ts @@ -16,7 +16,7 @@ export default async function handler( const result = await getBurialSites(request.body, { limit: request.body.limit, offset: request.body.offset, - includeBurialSiteContractCount: true + includeContractCount: true }) response.json({ diff --git a/handlers/contracts-get/edit.js b/handlers/contracts-get/edit.js index 4eb68e86..8304b6b3 100644 --- a/handlers/contracts-get/edit.js +++ b/handlers/contracts-get/edit.js @@ -1,22 +1,22 @@ -import getBurialSiteContract from '../../database/getBurialSiteContract.js'; import getCemeteries from '../../database/getCemeteries.js'; +import getContract from '../../database/getContract.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 burialSiteContract = await getBurialSiteContract(request.params.burialSiteContractId); - if (burialSiteContract === undefined) { - response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/contracts/?error=burialSiteContractIdNotFound`); + const contract = await getContract(request.params.contractId); + if (contract === undefined) { + response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/contracts/?error=contractIdNotFound`); return; } - const contractTypePrints = await getContractTypePrintsById(burialSiteContract.contractTypeId); + const contractTypePrints = await getContractTypePrintsById(contract.contractTypeId); const contractTypes = await getContractTypes(); const burialSiteTypes = await getBurialSiteTypes(); const burialSiteStatuses = await getBurialSiteStatuses(); const cemeteries = await getCemeteries(); const workOrderTypes = await getWorkOrderTypes(); - response.render('burialSiteContract-edit', { + response.render('contract-edit', { headTitle: 'Contract Update', - burialSiteContract, + contract, contractTypePrints, contractTypes, burialSiteTypes, diff --git a/handlers/contracts-get/edit.ts b/handlers/contracts-get/edit.ts index ced456f4..aaf1bca9 100644 --- a/handlers/contracts-get/edit.ts +++ b/handlers/contracts-get/edit.ts @@ -1,7 +1,7 @@ import type { Request, Response } from 'express' -import getBurialSiteContract from '../../database/getBurialSiteContract.js' import getCemeteries from '../../database/getCemeteries.js' +import getContract from '../../database/getContract.js' import { getConfigProperty } from '../../helpers/config.helpers.js' import { getBurialSiteStatuses, @@ -15,21 +15,21 @@ export default async function handler( request: Request, response: Response ): Promise { - const burialSiteContract = await getBurialSiteContract( - request.params.burialSiteContractId + const contract = await getContract( + request.params.contractId ) - if (burialSiteContract === undefined) { + if (contract === undefined) { response.redirect( `${getConfigProperty( 'reverseProxy.urlPrefix' - )}/contracts/?error=burialSiteContractIdNotFound` + )}/contracts/?error=contractIdNotFound` ) return } const contractTypePrints = await getContractTypePrintsById( - burialSiteContract.contractTypeId + contract.contractTypeId ) const contractTypes = await getContractTypes() @@ -38,9 +38,9 @@ export default async function handler( const cemeteries = await getCemeteries() const workOrderTypes = await getWorkOrderTypes() - response.render('burialSiteContract-edit', { + response.render('contract-edit', { headTitle: 'Contract Update', - burialSiteContract, + contract, contractTypePrints, contractTypes, diff --git a/handlers/contracts-get/new.js b/handlers/contracts-get/new.js index 0cb66141..b3ee6299 100644 --- a/handlers/contracts-get/new.js +++ b/handlers/contracts-get/new.js @@ -4,26 +4,26 @@ 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 burialSiteContract = { + const contract = { contractStartDate: dateToInteger(startDate), contractStartDateString: dateToString(startDate) }; 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; + contract.burialSiteId = burialSite.burialSiteId; + contract.burialSiteName = burialSite.burialSiteName; + contract.cemeteryId = burialSite.cemeteryId; + contract.cemeteryName = burialSite.cemeteryName; } } const contractTypes = await getContractTypes(); const burialSiteTypes = await getBurialSiteTypes(); const burialSiteStatuses = await getBurialSiteStatuses(); const cemeteries = await getCemeteries(); - response.render('burialSiteContract-edit', { + response.render('contract-edit', { headTitle: 'Create a New Contract', - burialSiteContract, + contract, contractTypes, burialSiteTypes, burialSiteStatuses, diff --git a/handlers/contracts-get/new.ts b/handlers/contracts-get/new.ts index 6a1100dd..c6646704 100644 --- a/handlers/contracts-get/new.ts +++ b/handlers/contracts-get/new.ts @@ -8,7 +8,7 @@ import { getBurialSiteTypes, getContractTypes } from '../../helpers/functions.cache.js' -import type { BurialSiteContract } from '../../types/recordTypes.js' +import type { Contract } from '../../types/recordTypes.js' export default async function handler( request: Request, @@ -16,7 +16,7 @@ export default async function handler( ): Promise { const startDate = new Date() - const burialSiteContract: Partial = { + const contract: Partial = { contractStartDate: dateToInteger(startDate), contractStartDateString: dateToString(startDate) } @@ -25,10 +25,10 @@ export default async function handler( const burialSite = await getBurialSite(request.query.burialSiteId as string) if (burialSite !== undefined) { - burialSiteContract.burialSiteId = burialSite.burialSiteId - burialSiteContract.burialSiteName = burialSite.burialSiteName - burialSiteContract.cemeteryId = burialSite.cemeteryId - burialSiteContract.cemeteryName = burialSite.cemeteryName + contract.burialSiteId = burialSite.burialSiteId + contract.burialSiteName = burialSite.burialSiteName + contract.cemeteryId = burialSite.cemeteryId + contract.cemeteryName = burialSite.cemeteryName } } @@ -37,9 +37,9 @@ export default async function handler( const burialSiteStatuses = await getBurialSiteStatuses() const cemeteries = await getCemeteries() - response.render('burialSiteContract-edit', { + response.render('contract-edit', { headTitle: 'Create a New Contract', - burialSiteContract, + contract, contractTypes, burialSiteTypes, diff --git a/handlers/contracts-get/search.js b/handlers/contracts-get/search.js index fffe5b7f..a7275902 100644 --- a/handlers/contracts-get/search.js +++ b/handlers/contracts-get/search.js @@ -4,7 +4,7 @@ export default async function handler(request, response) { const cemeteries = await getCemeteries(); const burialSiteTypes = await getBurialSiteTypes(); const contractTypes = await getContractTypes(); - response.render('burialSiteContract-search', { + response.render('contract-search', { headTitle: `Contract Search`, cemeteries, burialSiteTypes, diff --git a/handlers/contracts-get/search.ts b/handlers/contracts-get/search.ts index 3a2c38a3..44474285 100644 --- a/handlers/contracts-get/search.ts +++ b/handlers/contracts-get/search.ts @@ -14,7 +14,7 @@ export default async function handler( const burialSiteTypes = await getBurialSiteTypes() const contractTypes = await getContractTypes() - response.render('burialSiteContract-search', { + response.render('contract-search', { headTitle: `Contract Search`, cemeteries, burialSiteTypes, diff --git a/handlers/contracts-get/view.js b/handlers/contracts-get/view.js index 47b43243..0758415c 100644 --- a/handlers/contracts-get/view.js +++ b/handlers/contracts-get/view.js @@ -1,16 +1,16 @@ -import getBurialSiteContract from '../../database/getBurialSiteContract.js'; +import getContract from '../../database/getContract.js'; import { getConfigProperty } from '../../helpers/config.helpers.js'; import { getContractTypePrintsById } from '../../helpers/functions.cache.js'; export default async function handler(request, response) { - const burialSiteContract = await getBurialSiteContract(request.params.burialSiteContractId); - if (burialSiteContract === undefined) { - response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/contracts/?error=burialSiteContractIdNotFound`); + const contract = await getContract(request.params.contractId); + if (contract === undefined) { + response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/contracts/?error=contractIdNotFound`); return; } - const contractTypePrints = await getContractTypePrintsById(burialSiteContract.contractTypeId); - response.render('burialSiteContract-view', { + const contractTypePrints = await getContractTypePrintsById(contract.contractTypeId); + response.render('contract-view', { headTitle: 'Contract View', - burialSiteContract, + contract, contractTypePrints }); } diff --git a/handlers/contracts-get/view.ts b/handlers/contracts-get/view.ts index 8c4507ba..af1a703f 100644 --- a/handlers/contracts-get/view.ts +++ b/handlers/contracts-get/view.ts @@ -1,6 +1,6 @@ import type { Request, Response } from 'express' -import getBurialSiteContract from '../../database/getBurialSiteContract.js' +import getContract from '../../database/getContract.js' import { getConfigProperty } from '../../helpers/config.helpers.js' import { getContractTypePrintsById } from '../../helpers/functions.cache.js' @@ -8,26 +8,26 @@ export default async function handler( request: Request, response: Response ): Promise { - const burialSiteContract = await getBurialSiteContract( - request.params.burialSiteContractId + const contract = await getContract( + request.params.contractId ) - if (burialSiteContract === undefined) { + if (contract === undefined) { response.redirect( `${getConfigProperty( 'reverseProxy.urlPrefix' - )}/contracts/?error=burialSiteContractIdNotFound` + )}/contracts/?error=contractIdNotFound` ) return } const contractTypePrints = await getContractTypePrintsById( - burialSiteContract.contractTypeId + contract.contractTypeId ) - response.render('burialSiteContract-view', { + response.render('contract-view', { headTitle: 'Contract View', - burialSiteContract, + contract, contractTypePrints }) } diff --git a/handlers/contracts-post/doAddBurialSiteContractComment.d.ts b/handlers/contracts-post/doAddBurialSiteContractComment.d.ts deleted file mode 100644 index ad747d54..00000000 --- a/handlers/contracts-post/doAddBurialSiteContractComment.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 0fa3f4be..00000000 --- a/handlers/contracts-post/doAddBurialSiteContractComment.js +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 31e9ff1c..00000000 --- a/handlers/contracts-post/doAddBurialSiteContractComment.ts +++ /dev/null @@ -1,22 +0,0 @@ -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 deleted file mode 100644 index 0dcb9c1a..00000000 --- a/handlers/contracts-post/doAddBurialSiteContractFee.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index ff95e0da..00000000 --- a/handlers/contracts-post/doAddBurialSiteContractFee.js +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 8a2e7db3..00000000 --- a/handlers/contracts-post/doAddBurialSiteContractFee.ts +++ /dev/null @@ -1,22 +0,0 @@ -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 deleted file mode 100644 index 8dd0bc32..00000000 --- a/handlers/contracts-post/doAddBurialSiteContractFeeCategory.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 411ad5d0..00000000 --- a/handlers/contracts-post/doAddBurialSiteContractFeeCategory.js +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 7731f06c..00000000 --- a/handlers/contracts-post/doAddBurialSiteContractFeeCategory.ts +++ /dev/null @@ -1,25 +0,0 @@ -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.js b/handlers/contracts-post/doAddBurialSiteContractTransaction.js deleted file mode 100644 index b4ab613a..00000000 --- a/handlers/contracts-post/doAddBurialSiteContractTransaction.js +++ /dev/null @@ -1,12 +0,0 @@ -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 deleted file mode 100644 index 69701e8b..00000000 --- a/handlers/contracts-post/doAddBurialSiteContractTransaction.ts +++ /dev/null @@ -1,26 +0,0 @@ -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/doAddContractComment.d.ts b/handlers/contracts-post/doAddContractComment.d.ts new file mode 100644 index 00000000..8b914dcd --- /dev/null +++ b/handlers/contracts-post/doAddContractComment.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type AddContractCommentForm } from '../../database/addContractComment.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doAddContractComment.js b/handlers/contracts-post/doAddContractComment.js new file mode 100644 index 00000000..760fd828 --- /dev/null +++ b/handlers/contracts-post/doAddContractComment.js @@ -0,0 +1,10 @@ +import addContractComment from '../../database/addContractComment.js'; +import getContractComments from '../../database/getContractComments.js'; +export default async function handler(request, response) { + await addContractComment(request.body, request.session.user); + const contractComments = await getContractComments(request.body.contractId); + response.json({ + success: true, + contractComments + }); +} diff --git a/handlers/contracts-post/doAddContractComment.ts b/handlers/contracts-post/doAddContractComment.ts new file mode 100644 index 00000000..063d3ce2 --- /dev/null +++ b/handlers/contracts-post/doAddContractComment.ts @@ -0,0 +1,22 @@ +import type { Request, Response } from 'express' + +import addContractComment, { + type AddContractCommentForm +} from '../../database/addContractComment.js' +import getContractComments from '../../database/getContractComments.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + await addContractComment(request.body, request.session.user as User) + + const contractComments = await getContractComments( + request.body.contractId as string + ) + + response.json({ + success: true, + contractComments + }) +} diff --git a/handlers/contracts-post/doAddContractFee.d.ts b/handlers/contracts-post/doAddContractFee.d.ts new file mode 100644 index 00000000..e96d9589 --- /dev/null +++ b/handlers/contracts-post/doAddContractFee.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type AddContractFeeForm } from '../../database/addContractFee.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doAddContractFee.js b/handlers/contracts-post/doAddContractFee.js new file mode 100644 index 00000000..87b1b183 --- /dev/null +++ b/handlers/contracts-post/doAddContractFee.js @@ -0,0 +1,10 @@ +import addContractFee from '../../database/addContractFee.js'; +import getContractFees from '../../database/getContractFees.js'; +export default async function handler(request, response) { + await addContractFee(request.body, request.session.user); + const contractFees = await getContractFees(request.body.contractId); + response.json({ + success: true, + contractFees + }); +} diff --git a/handlers/contracts-post/doAddContractFee.ts b/handlers/contracts-post/doAddContractFee.ts new file mode 100644 index 00000000..45527b59 --- /dev/null +++ b/handlers/contracts-post/doAddContractFee.ts @@ -0,0 +1,22 @@ +import type { Request, Response } from 'express' + +import addContractFee, { + type AddContractFeeForm +} from '../../database/addContractFee.js' +import getContractFees from '../../database/getContractFees.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + await addContractFee(request.body, request.session.user as User) + + const contractFees = await getContractFees( + request.body.contractId as string + ) + + response.json({ + success: true, + contractFees + }) +} diff --git a/handlers/contracts-post/doAddContractFeeCategory.d.ts b/handlers/contracts-post/doAddContractFeeCategory.d.ts new file mode 100644 index 00000000..dd61a8d6 --- /dev/null +++ b/handlers/contracts-post/doAddContractFeeCategory.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type AddContractCategoryForm } from '../../database/addContractFeeCategory.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doAddContractFeeCategory.js b/handlers/contracts-post/doAddContractFeeCategory.js new file mode 100644 index 00000000..4094b8c9 --- /dev/null +++ b/handlers/contracts-post/doAddContractFeeCategory.js @@ -0,0 +1,10 @@ +import addContractFeeCategory from '../../database/addContractFeeCategory.js'; +import getContractFees from '../../database/getContractFees.js'; +export default async function handler(request, response) { + await addContractFeeCategory(request.body, request.session.user); + const contractFees = await getContractFees(request.body.contractId); + response.json({ + success: true, + contractFees + }); +} diff --git a/handlers/contracts-post/doAddContractFeeCategory.ts b/handlers/contracts-post/doAddContractFeeCategory.ts new file mode 100644 index 00000000..54e02c0b --- /dev/null +++ b/handlers/contracts-post/doAddContractFeeCategory.ts @@ -0,0 +1,25 @@ +import type { Request, Response } from 'express' + +import addContractFeeCategory, { + type AddContractCategoryForm +} from '../../database/addContractFeeCategory.js' +import getContractFees from '../../database/getContractFees.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + await addContractFeeCategory( + request.body, + request.session.user as User + ) + + const contractFees = await getContractFees( + request.body.contractId as string + ) + + response.json({ + success: true, + contractFees + }) +} diff --git a/handlers/contracts-post/doAddBurialSiteContractTransaction.d.ts b/handlers/contracts-post/doAddContractTransaction.d.ts similarity index 64% rename from handlers/contracts-post/doAddBurialSiteContractTransaction.d.ts rename to handlers/contracts-post/doAddContractTransaction.d.ts index b5587461..9302fe77 100644 --- a/handlers/contracts-post/doAddBurialSiteContractTransaction.d.ts +++ b/handlers/contracts-post/doAddContractTransaction.d.ts @@ -1,3 +1,3 @@ import type { Request, Response } from 'express'; -import { type AddTransactionForm } from '../../database/addBurialSiteContractTransaction.js'; +import { type AddTransactionForm } from '../../database/addContractTransaction.js'; export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doAddContractTransaction.js b/handlers/contracts-post/doAddContractTransaction.js new file mode 100644 index 00000000..20ff00c9 --- /dev/null +++ b/handlers/contracts-post/doAddContractTransaction.js @@ -0,0 +1,12 @@ +import addContractTransaction from '../../database/addContractTransaction.js'; +import getContractTransactions from '../../database/getContractTransactions.js'; +export default async function handler(request, response) { + await addContractTransaction(request.body, request.session.user); + const contractTransactions = await getContractTransactions(request.body.contractId, { + includeIntegrations: true + }); + response.json({ + success: true, + contractTransactions + }); +} diff --git a/handlers/contracts-post/doAddContractTransaction.ts b/handlers/contracts-post/doAddContractTransaction.ts new file mode 100644 index 00000000..88ba02b6 --- /dev/null +++ b/handlers/contracts-post/doAddContractTransaction.ts @@ -0,0 +1,26 @@ +import type { Request, Response } from 'express' + +import addContractTransaction, { + type AddTransactionForm +} from '../../database/addContractTransaction.js' +import getContractTransactions from '../../database/getContractTransactions.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + await addContractTransaction( + request.body, + request.session.user as User + ) + + const contractTransactions = + await getContractTransactions(request.body.contractId, { + includeIntegrations: true + }) + + response.json({ + success: true, + contractTransactions + }) +} diff --git a/handlers/contracts-post/doCopyBurialSiteContract.js b/handlers/contracts-post/doCopyBurialSiteContract.js deleted file mode 100644 index 28c2577d..00000000 --- a/handlers/contracts-post/doCopyBurialSiteContract.js +++ /dev/null @@ -1,8 +0,0 @@ -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 deleted file mode 100644 index bac1b38b..00000000 --- a/handlers/contracts-post/doCopyBurialSiteContract.ts +++ /dev/null @@ -1,18 +0,0 @@ -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/doDeleteBurialSiteContract.d.ts b/handlers/contracts-post/doCopyContract.d.ts similarity index 82% rename from handlers/contracts-post/doDeleteBurialSiteContract.d.ts rename to handlers/contracts-post/doCopyContract.d.ts index 6eb4657f..1b8f821d 100644 --- a/handlers/contracts-post/doDeleteBurialSiteContract.d.ts +++ b/handlers/contracts-post/doCopyContract.d.ts @@ -1,4 +1,4 @@ import type { Request, Response } from 'express'; export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doCopyContract.js b/handlers/contracts-post/doCopyContract.js new file mode 100644 index 00000000..457ab36c --- /dev/null +++ b/handlers/contracts-post/doCopyContract.js @@ -0,0 +1,8 @@ +import copyContract from '../../database/copyContract.js'; +export default async function handler(request, response) { + const contractId = await copyContract(request.body.contractId, request.session.user); + response.json({ + success: true, + contractId + }); +} diff --git a/handlers/contracts-post/doCopyContract.ts b/handlers/contracts-post/doCopyContract.ts new file mode 100644 index 00000000..84d82589 --- /dev/null +++ b/handlers/contracts-post/doCopyContract.ts @@ -0,0 +1,18 @@ +import type { Request, Response } from 'express' + +import copyContract from '../../database/copyContract.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + const contractId = await copyContract( + request.body.contractId, + request.session.user as User + ) + + response.json({ + success: true, + contractId + }) +} diff --git a/handlers/contracts-post/doCreateBurialSiteContract.d.ts b/handlers/contracts-post/doCreateBurialSiteContract.d.ts deleted file mode 100644 index 88577439..00000000 --- a/handlers/contracts-post/doCreateBurialSiteContract.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 03576d30..00000000 --- a/handlers/contracts-post/doCreateBurialSiteContract.js +++ /dev/null @@ -1,8 +0,0 @@ -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 deleted file mode 100644 index c58c6b7b..00000000 --- a/handlers/contracts-post/doCreateBurialSiteContract.ts +++ /dev/null @@ -1,21 +0,0 @@ -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/doCreateContract.d.ts b/handlers/contracts-post/doCreateContract.d.ts new file mode 100644 index 00000000..43cf7302 --- /dev/null +++ b/handlers/contracts-post/doCreateContract.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type AddContractForm } from '../../database/addContract.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doCreateContract.js b/handlers/contracts-post/doCreateContract.js new file mode 100644 index 00000000..b1a3fac1 --- /dev/null +++ b/handlers/contracts-post/doCreateContract.js @@ -0,0 +1,8 @@ +import addContract from '../../database/addContract.js'; +export default async function handler(request, response) { + const contractId = await addContract(request.body, request.session.user); + response.json({ + success: true, + contractId + }); +} diff --git a/handlers/contracts-post/doCreateContract.ts b/handlers/contracts-post/doCreateContract.ts new file mode 100644 index 00000000..f2f22b94 --- /dev/null +++ b/handlers/contracts-post/doCreateContract.ts @@ -0,0 +1,21 @@ +import type { Request, Response } from 'express' + +import addContract, { + type AddContractForm +} from '../../database/addContract.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + const contractId = await addContract( + request.body, + request.session.user as User + ) + + response.json({ + success: true, + contractId + }) +} + diff --git a/handlers/contracts-post/doDeleteBurialSiteContractComment.d.ts b/handlers/contracts-post/doDeleteBurialSiteContractComment.d.ts deleted file mode 100644 index 01645bd9..00000000 --- a/handlers/contracts-post/doDeleteBurialSiteContractComment.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index b4c9213d..00000000 --- a/handlers/contracts-post/doDeleteBurialSiteContractComment.js +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index d2e17bd9..00000000 --- a/handlers/contracts-post/doDeleteBurialSiteContractComment.ts +++ /dev/null @@ -1,28 +0,0 @@ -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.js b/handlers/contracts-post/doDeleteBurialSiteContractFee.js deleted file mode 100644 index 2a2a7ed1..00000000 --- a/handlers/contracts-post/doDeleteBurialSiteContractFee.js +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index d2a610c9..00000000 --- a/handlers/contracts-post/doDeleteBurialSiteContractFee.ts +++ /dev/null @@ -1,28 +0,0 @@ -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.js b/handlers/contracts-post/doDeleteBurialSiteContractTransaction.js deleted file mode 100644 index 6f258038..00000000 --- a/handlers/contracts-post/doDeleteBurialSiteContractTransaction.js +++ /dev/null @@ -1,12 +0,0 @@ -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 deleted file mode 100644 index 65deb1c3..00000000 --- a/handlers/contracts-post/doDeleteBurialSiteContractTransaction.ts +++ /dev/null @@ -1,29 +0,0 @@ -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/doCopyBurialSiteContract.d.ts b/handlers/contracts-post/doDeleteContract.d.ts similarity index 82% rename from handlers/contracts-post/doCopyBurialSiteContract.d.ts rename to handlers/contracts-post/doDeleteContract.d.ts index 6eb4657f..1b8f821d 100644 --- a/handlers/contracts-post/doCopyBurialSiteContract.d.ts +++ b/handlers/contracts-post/doDeleteContract.d.ts @@ -1,4 +1,4 @@ import type { Request, Response } from 'express'; export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doDeleteBurialSiteContract.js b/handlers/contracts-post/doDeleteContract.js similarity index 58% rename from handlers/contracts-post/doDeleteBurialSiteContract.js rename to handlers/contracts-post/doDeleteContract.js index eb58759e..c507d6c0 100644 --- a/handlers/contracts-post/doDeleteBurialSiteContract.js +++ b/handlers/contracts-post/doDeleteContract.js @@ -1,6 +1,6 @@ import { deleteRecord } from '../../database/deleteRecord.js'; export default async function handler(request, response) { - const success = await deleteRecord('BurialSiteContracts', request.body.burialSiteContractId, request.session.user); + const success = await deleteRecord('Contracts', request.body.contractId, request.session.user); response.json({ success }); diff --git a/handlers/contracts-post/doDeleteBurialSiteContract.ts b/handlers/contracts-post/doDeleteContract.ts similarity index 68% rename from handlers/contracts-post/doDeleteBurialSiteContract.ts rename to handlers/contracts-post/doDeleteContract.ts index a8d2f01a..54e92eee 100644 --- a/handlers/contracts-post/doDeleteBurialSiteContract.ts +++ b/handlers/contracts-post/doDeleteContract.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( - 'BurialSiteContracts', - request.body.burialSiteContractId, + 'Contracts', + request.body.contractId, request.session.user as User ) diff --git a/handlers/contracts-post/doDeleteContractComment.d.ts b/handlers/contracts-post/doDeleteContractComment.d.ts new file mode 100644 index 00000000..2f18d678 --- /dev/null +++ b/handlers/contracts-post/doDeleteContractComment.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/doDeleteContractComment.js b/handlers/contracts-post/doDeleteContractComment.js new file mode 100644 index 00000000..1124789a --- /dev/null +++ b/handlers/contracts-post/doDeleteContractComment.js @@ -0,0 +1,10 @@ +import { deleteRecord } from '../../database/deleteRecord.js'; +import getContractComments from '../../database/getContractComments.js'; +export default async function handler(request, response) { + const success = await deleteRecord('ContractComments', request.body.contractCommentId, request.session.user); + const contractComments = await getContractComments(request.body.contractId); + response.json({ + success, + contractComments + }); +} diff --git a/handlers/contracts-post/doDeleteContractComment.ts b/handlers/contracts-post/doDeleteContractComment.ts new file mode 100644 index 00000000..ff2f535a --- /dev/null +++ b/handlers/contracts-post/doDeleteContractComment.ts @@ -0,0 +1,28 @@ +import type { Request, Response } from 'express' + +import { deleteRecord } from '../../database/deleteRecord.js' +import getContractComments from '../../database/getContractComments.js' + +export default async function handler( + request: Request< + unknown, + unknown, + { contractCommentId: string; contractId: string } + >, + response: Response +): Promise { + const success = await deleteRecord( + 'ContractComments', + request.body.contractCommentId, + request.session.user as User + ) + + const contractComments = await getContractComments( + request.body.contractId + ) + + response.json({ + success, + contractComments + }) +} diff --git a/handlers/contracts-post/doDeleteBurialSiteContractFee.d.ts b/handlers/contracts-post/doDeleteContractFee.d.ts similarity index 83% rename from handlers/contracts-post/doDeleteBurialSiteContractFee.d.ts rename to handlers/contracts-post/doDeleteContractFee.d.ts index 6b887bcf..a866eba0 100644 --- a/handlers/contracts-post/doDeleteBurialSiteContractFee.d.ts +++ b/handlers/contracts-post/doDeleteContractFee.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/contracts-post/doDeleteContractFee.js b/handlers/contracts-post/doDeleteContractFee.js new file mode 100644 index 00000000..fffd8fee --- /dev/null +++ b/handlers/contracts-post/doDeleteContractFee.js @@ -0,0 +1,10 @@ +import deleteContractFee from '../../database/deleteContractFee.js'; +import getContractFees from '../../database/getContractFees.js'; +export default async function handler(request, response) { + const success = await deleteContractFee(request.body.contractId, request.body.feeId, request.session.user); + const contractFees = await getContractFees(request.body.contractId); + response.json({ + success, + contractFees + }); +} diff --git a/handlers/contracts-post/doDeleteContractFee.ts b/handlers/contracts-post/doDeleteContractFee.ts new file mode 100644 index 00000000..5b8c0deb --- /dev/null +++ b/handlers/contracts-post/doDeleteContractFee.ts @@ -0,0 +1,28 @@ +import type { Request, Response } from 'express' + +import deleteContractFee from '../../database/deleteContractFee.js' +import getContractFees from '../../database/getContractFees.js' + +export default async function handler( + request: Request< + unknown, + unknown, + { contractId: string; feeId: string } + >, + response: Response +): Promise { + const success = await deleteContractFee( + request.body.contractId, + request.body.feeId, + request.session.user as User + ) + + const contractFees = await getContractFees( + request.body.contractId + ) + + response.json({ + success, + contractFees + }) +} diff --git a/handlers/contracts-post/doDeleteBurialSiteContractTransaction.d.ts b/handlers/contracts-post/doDeleteContractTransaction.d.ts similarity index 84% rename from handlers/contracts-post/doDeleteBurialSiteContractTransaction.d.ts rename to handlers/contracts-post/doDeleteContractTransaction.d.ts index 94d2c842..9a8aaa97 100644 --- a/handlers/contracts-post/doDeleteBurialSiteContractTransaction.d.ts +++ b/handlers/contracts-post/doDeleteContractTransaction.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/contracts-post/doDeleteContractTransaction.js b/handlers/contracts-post/doDeleteContractTransaction.js new file mode 100644 index 00000000..8627ef43 --- /dev/null +++ b/handlers/contracts-post/doDeleteContractTransaction.js @@ -0,0 +1,12 @@ +import deleteContractTransaction from '../../database/deleteContractTransaction.js'; +import getContractTransactions from '../../database/getContractTransactions.js'; +export default async function handler(request, response) { + const success = await deleteContractTransaction(request.body.contractId, request.body.transactionIndex, request.session.user); + const contractTransactions = await getContractTransactions(request.body.contractId, { + includeIntegrations: true + }); + response.json({ + success, + contractTransactions + }); +} diff --git a/handlers/contracts-post/doDeleteContractTransaction.ts b/handlers/contracts-post/doDeleteContractTransaction.ts new file mode 100644 index 00000000..f8d9f6d3 --- /dev/null +++ b/handlers/contracts-post/doDeleteContractTransaction.ts @@ -0,0 +1,29 @@ +import type { Request, Response } from 'express' + +import deleteContractTransaction from '../../database/deleteContractTransaction.js' +import getContractTransactions from '../../database/getContractTransactions.js' + +export default async function handler( + request: Request< + unknown, + unknown, + { contractId: string; transactionIndex: number } + >, + response: Response +): Promise { + const success = await deleteContractTransaction( + request.body.contractId, + request.body.transactionIndex, + request.session.user as User + ) + + const contractTransactions = + await getContractTransactions(request.body.contractId, { + includeIntegrations: true + }) + + response.json({ + success, + contractTransactions + }) +} diff --git a/handlers/contracts-post/doGetFees.d.ts b/handlers/contracts-post/doGetFees.d.ts index 6eb4657f..1b8f821d 100644 --- a/handlers/contracts-post/doGetFees.d.ts +++ b/handlers/contracts-post/doGetFees.d.ts @@ -1,4 +1,4 @@ import type { Request, Response } from 'express'; export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doGetFees.js b/handlers/contracts-post/doGetFees.js index e7e77659..87cd8bb0 100644 --- a/handlers/contracts-post/doGetFees.js +++ b/handlers/contracts-post/doGetFees.js @@ -1,11 +1,11 @@ -import getBurialSiteContract from '../../database/getBurialSiteContract.js'; +import getContract from '../../database/getContract.js'; import getFeeCategories from '../../database/getFeeCategories.js'; export default async function handler(request, response) { - const burialSiteContractId = request.body.burialSiteContractId; - const burialSiteContract = (await getBurialSiteContract(burialSiteContractId)); + const contractId = request.body.contractId; + const contract = (await getContract(contractId)); const feeCategories = await getFeeCategories({ - contractTypeId: burialSiteContract.contractTypeId, - burialSiteTypeId: burialSiteContract.burialSiteTypeId + contractTypeId: contract.contractTypeId, + burialSiteTypeId: contract.burialSiteTypeId }, { includeFees: true }); diff --git a/handlers/contracts-post/doGetFees.ts b/handlers/contracts-post/doGetFees.ts index 27d4c82f..882c551c 100644 --- a/handlers/contracts-post/doGetFees.ts +++ b/handlers/contracts-post/doGetFees.ts @@ -1,23 +1,23 @@ import type { Request, Response } from 'express' -import getBurialSiteContract from '../../database/getBurialSiteContract.js' +import getContract from '../../database/getContract.js' import getFeeCategories from '../../database/getFeeCategories.js' -import type { BurialSiteContract } from '../../types/recordTypes.js' +import type { Contract } from '../../types/recordTypes.js' export default async function handler( - request: Request, + request: Request, response: Response ): Promise { - const burialSiteContractId = request.body.burialSiteContractId + const contractId = request.body.contractId - const burialSiteContract = (await getBurialSiteContract( - burialSiteContractId - )) as BurialSiteContract + const contract = (await getContract( + contractId + )) as Contract const feeCategories = await getFeeCategories( { - contractTypeId: burialSiteContract.contractTypeId, - burialSiteTypeId: burialSiteContract.burialSiteTypeId + contractTypeId: contract.contractTypeId, + burialSiteTypeId: contract.burialSiteTypeId }, { includeFees: true diff --git a/handlers/contracts-post/doSearchBurialSiteContracts.d.ts b/handlers/contracts-post/doSearchBurialSiteContracts.d.ts deleted file mode 100644 index e7b4b06f..00000000 --- a/handlers/contracts-post/doSearchBurialSiteContracts.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { Request, Response } from 'express'; -import { type GetBurialSiteContractsFilters, type GetBurialSiteContractsOptions } from '../../database/getBurialSiteContracts.js'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doSearchContracts.d.ts b/handlers/contracts-post/doSearchContracts.d.ts new file mode 100644 index 00000000..1acb4561 --- /dev/null +++ b/handlers/contracts-post/doSearchContracts.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type GetContractsFilters, type GetContractsOptions } from '../../database/getContracts.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doSearchBurialSiteContracts.js b/handlers/contracts-post/doSearchContracts.js similarity index 68% rename from handlers/contracts-post/doSearchBurialSiteContracts.js rename to handlers/contracts-post/doSearchContracts.js index edd61514..ffce2c12 100644 --- a/handlers/contracts-post/doSearchBurialSiteContracts.js +++ b/handlers/contracts-post/doSearchContracts.js @@ -1,6 +1,6 @@ -import getBurialSiteContracts from '../../database/getBurialSiteContracts.js'; +import getContracts from '../../database/getContracts.js'; export default async function handler(request, response) { - const result = await getBurialSiteContracts(request.body, { + const result = await getContracts(request.body, { limit: request.body.limit, offset: request.body.offset, includeInterments: true, @@ -12,6 +12,6 @@ export default async function handler(request, response) { offset: typeof request.body.offset === 'string' ? Number.parseInt(request.body.offset, 10) : request.body.offset, - burialSiteContracts: result.burialSiteContracts + contracts: result.contracts }); } diff --git a/handlers/contracts-post/doSearchBurialSiteContracts.ts b/handlers/contracts-post/doSearchContracts.ts similarity index 60% rename from handlers/contracts-post/doSearchBurialSiteContracts.ts rename to handlers/contracts-post/doSearchContracts.ts index f2065cdc..2dba2025 100644 --- a/handlers/contracts-post/doSearchBurialSiteContracts.ts +++ b/handlers/contracts-post/doSearchContracts.ts @@ -1,19 +1,19 @@ import type { Request, Response } from 'express' -import getBurialSiteContracts, { - type GetBurialSiteContractsFilters, - type GetBurialSiteContractsOptions -} from '../../database/getBurialSiteContracts.js' +import getContracts, { + type GetContractsFilters, + type GetContractsOptions +} from '../../database/getContracts.js' export default async function handler( request: Request< unknown, unknown, - GetBurialSiteContractsFilters & GetBurialSiteContractsOptions + GetContractsFilters & GetContractsOptions >, response: Response ): Promise { - const result = await getBurialSiteContracts(request.body, { + const result = await getContracts(request.body, { limit: request.body.limit, offset: request.body.offset, includeInterments: true, @@ -27,6 +27,6 @@ export default async function handler( typeof request.body.offset === 'string' ? Number.parseInt(request.body.offset, 10) : request.body.offset, - burialSiteContracts: result.burialSiteContracts + contracts: result.contracts }) } diff --git a/handlers/contracts-post/doUpdateBurialSiteContract.d.ts b/handlers/contracts-post/doUpdateBurialSiteContract.d.ts deleted file mode 100644 index 2898c95b..00000000 --- a/handlers/contracts-post/doUpdateBurialSiteContract.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { Request, Response } from 'express'; -import { type UpdateBurialSiteContractForm } from '../../database/updateBurialSiteContract.js'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doUpdateBurialSiteContract.js b/handlers/contracts-post/doUpdateBurialSiteContract.js deleted file mode 100644 index cb09ee7c..00000000 --- a/handlers/contracts-post/doUpdateBurialSiteContract.js +++ /dev/null @@ -1,8 +0,0 @@ -import updateBurialSiteContract from '../../database/updateBurialSiteContract.js'; -export default async function handler(request, response) { - const success = await updateBurialSiteContract(request.body, request.session.user); - response.json({ - success, - burialSiteContractId: request.body.burialSiteContractId - }); -} diff --git a/handlers/contracts-post/doUpdateBurialSiteContract.ts b/handlers/contracts-post/doUpdateBurialSiteContract.ts deleted file mode 100644 index 4a19e7c4..00000000 --- a/handlers/contracts-post/doUpdateBurialSiteContract.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { Request, Response } from 'express' - -import updateBurialSiteContract, { - type UpdateBurialSiteContractForm -} from '../../database/updateBurialSiteContract.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - const success = await updateBurialSiteContract( - request.body, - request.session.user as User - ) - - response.json({ - success, - burialSiteContractId: request.body.burialSiteContractId - }) -} diff --git a/handlers/contracts-post/doUpdateBurialSiteContractComment.js b/handlers/contracts-post/doUpdateBurialSiteContractComment.js deleted file mode 100644 index fdbf1682..00000000 --- a/handlers/contracts-post/doUpdateBurialSiteContractComment.js +++ /dev/null @@ -1,10 +0,0 @@ -import getBurialSiteContractComments from '../../database/getBurialSiteContractComments.js'; -import updateBurialSiteContractComment from '../../database/updateBurialSiteContractComment.js'; -export default async function handler(request, response) { - const success = await updateBurialSiteContractComment(request.body, request.session.user); - const burialSiteContractComments = await getBurialSiteContractComments(request.body.burialSiteContractId); - response.json({ - success, - burialSiteContractComments - }); -} diff --git a/handlers/contracts-post/doUpdateBurialSiteContractComment.ts b/handlers/contracts-post/doUpdateBurialSiteContractComment.ts deleted file mode 100644 index aa52dc7e..00000000 --- a/handlers/contracts-post/doUpdateBurialSiteContractComment.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { Request, Response } from 'express' - -import getBurialSiteContractComments from '../../database/getBurialSiteContractComments.js' -import updateBurialSiteContractComment, { - type UpdateForm -} from '../../database/updateBurialSiteContractComment.js' - -export default async function handler( - request: Request< - unknown, - unknown, - UpdateForm & { burialSiteContractId: string } - >, - response: Response -): Promise { - const success = await updateBurialSiteContractComment( - request.body, - request.session.user as User - ) - - const burialSiteContractComments = await getBurialSiteContractComments( - request.body.burialSiteContractId - ) - - response.json({ - success, - burialSiteContractComments - }) -} diff --git a/handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.js b/handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.js deleted file mode 100644 index 8df0ed17..00000000 --- a/handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.js +++ /dev/null @@ -1,10 +0,0 @@ -import getBurialSiteContractFees from '../../database/getBurialSiteContractFees.js'; -import updateBurialSiteContractFeeQuantity from '../../database/updateBurialSiteContractFeeQuantity.js'; -export default async function handler(request, response) { - const success = await updateBurialSiteContractFeeQuantity(request.body, request.session.user); - const burialSiteContractFees = await getBurialSiteContractFees(request.body.burialSiteContractId); - response.json({ - success, - burialSiteContractFees - }); -} diff --git a/handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.ts b/handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.ts deleted file mode 100644 index d718ea50..00000000 --- a/handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { Request, Response } from 'express' - -import getBurialSiteContractFees from '../../database/getBurialSiteContractFees.js' -import updateBurialSiteContractFeeQuantity, { - type UpdateBurialSiteFeeForm -} from '../../database/updateBurialSiteContractFeeQuantity.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - const success = await updateBurialSiteContractFeeQuantity( - request.body, - request.session.user as User - ) - - const burialSiteContractFees = await getBurialSiteContractFees( - request.body.burialSiteContractId - ) - - response.json({ - success, - burialSiteContractFees - }) -} diff --git a/handlers/contracts-post/doUpdateBurialSiteContractTransaction.d.ts b/handlers/contracts-post/doUpdateBurialSiteContractTransaction.d.ts deleted file mode 100644 index 0bfad4d6..00000000 --- a/handlers/contracts-post/doUpdateBurialSiteContractTransaction.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { Request, Response } from 'express'; -import { type BurialSiteContractTransactionUpdateForm } from '../../database/updateBurialSiteContractTransaction.js'; -export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doUpdateBurialSiteContractTransaction.js b/handlers/contracts-post/doUpdateBurialSiteContractTransaction.js deleted file mode 100644 index e44ff6a2..00000000 --- a/handlers/contracts-post/doUpdateBurialSiteContractTransaction.js +++ /dev/null @@ -1,12 +0,0 @@ -import getBurialSiteContractTransactions from '../../database/getBurialSiteContractTransactions.js'; -import updateBurialSiteContractTransaction from '../../database/updateBurialSiteContractTransaction.js'; -export default async function handler(request, response) { - await updateBurialSiteContractTransaction(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/doUpdateBurialSiteContractTransaction.ts b/handlers/contracts-post/doUpdateBurialSiteContractTransaction.ts deleted file mode 100644 index 66e0b8f8..00000000 --- a/handlers/contracts-post/doUpdateBurialSiteContractTransaction.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { Request, Response } from 'express' - -import getBurialSiteContractTransactions from '../../database/getBurialSiteContractTransactions.js' -import updateBurialSiteContractTransaction, { - type BurialSiteContractTransactionUpdateForm -} from '../../database/updateBurialSiteContractTransaction.js' - -export default async function handler( - request: Request, - response: Response -): Promise { - await updateBurialSiteContractTransaction( - 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/doUpdateContract.d.ts b/handlers/contracts-post/doUpdateContract.d.ts new file mode 100644 index 00000000..2f1de434 --- /dev/null +++ b/handlers/contracts-post/doUpdateContract.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type UpdateContractForm } from '../../database/updateContract.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doUpdateContract.js b/handlers/contracts-post/doUpdateContract.js new file mode 100644 index 00000000..e21d89bd --- /dev/null +++ b/handlers/contracts-post/doUpdateContract.js @@ -0,0 +1,8 @@ +import updateContract from '../../database/updateContract.js'; +export default async function handler(request, response) { + const success = await updateContract(request.body, request.session.user); + response.json({ + success, + contractId: request.body.contractId + }); +} diff --git a/handlers/contracts-post/doUpdateContract.ts b/handlers/contracts-post/doUpdateContract.ts new file mode 100644 index 00000000..8b99cdda --- /dev/null +++ b/handlers/contracts-post/doUpdateContract.ts @@ -0,0 +1,20 @@ +import type { Request, Response } from 'express' + +import updateContract, { + type UpdateContractForm +} from '../../database/updateContract.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + const success = await updateContract( + request.body, + request.session.user as User + ) + + response.json({ + success, + contractId: request.body.contractId + }) +} diff --git a/handlers/contracts-post/doUpdateBurialSiteContractComment.d.ts b/handlers/contracts-post/doUpdateContractComment.d.ts similarity index 59% rename from handlers/contracts-post/doUpdateBurialSiteContractComment.d.ts rename to handlers/contracts-post/doUpdateContractComment.d.ts index 0bf71c74..af52aba5 100644 --- a/handlers/contracts-post/doUpdateBurialSiteContractComment.d.ts +++ b/handlers/contracts-post/doUpdateContractComment.d.ts @@ -1,5 +1,5 @@ import type { Request, Response } from 'express'; -import { type UpdateForm } from '../../database/updateBurialSiteContractComment.js'; +import { type UpdateForm } from '../../database/updateContractComment.js'; export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doUpdateContractComment.js b/handlers/contracts-post/doUpdateContractComment.js new file mode 100644 index 00000000..8127ba00 --- /dev/null +++ b/handlers/contracts-post/doUpdateContractComment.js @@ -0,0 +1,10 @@ +import getContractComments from '../../database/getContractComments.js'; +import updateContractComment from '../../database/updateContractComment.js'; +export default async function handler(request, response) { + const success = await updateContractComment(request.body, request.session.user); + const contractComments = await getContractComments(request.body.contractId); + response.json({ + success, + contractComments + }); +} diff --git a/handlers/contracts-post/doUpdateContractComment.ts b/handlers/contracts-post/doUpdateContractComment.ts new file mode 100644 index 00000000..0f884146 --- /dev/null +++ b/handlers/contracts-post/doUpdateContractComment.ts @@ -0,0 +1,29 @@ +import type { Request, Response } from 'express' + +import getContractComments from '../../database/getContractComments.js' +import updateContractComment, { + type UpdateForm +} from '../../database/updateContractComment.js' + +export default async function handler( + request: Request< + unknown, + unknown, + UpdateForm & { contractId: string } + >, + response: Response +): Promise { + const success = await updateContractComment( + request.body, + request.session.user as User + ) + + const contractComments = await getContractComments( + request.body.contractId + ) + + response.json({ + success, + contractComments + }) +} diff --git a/handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.d.ts b/handlers/contracts-post/doUpdateContractFeeQuantity.d.ts similarity index 86% rename from handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.d.ts rename to handlers/contracts-post/doUpdateContractFeeQuantity.d.ts index 8f9659de..051c760d 100644 --- a/handlers/contracts-post/doUpdateBurialSiteContractFeeQuantity.d.ts +++ b/handlers/contracts-post/doUpdateContractFeeQuantity.d.ts @@ -1,3 +1,3 @@ import type { Request, Response } from 'express'; -import { type UpdateBurialSiteFeeForm } from '../../database/updateBurialSiteContractFeeQuantity.js'; +import { type UpdateBurialSiteFeeForm } from '../../database/updateContractFeeQuantity.js'; export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doUpdateContractFeeQuantity.js b/handlers/contracts-post/doUpdateContractFeeQuantity.js new file mode 100644 index 00000000..35ea75ba --- /dev/null +++ b/handlers/contracts-post/doUpdateContractFeeQuantity.js @@ -0,0 +1,10 @@ +import getContractFees from '../../database/getContractFees.js'; +import updateContractFeeQuantity from '../../database/updateContractFeeQuantity.js'; +export default async function handler(request, response) { + const success = await updateContractFeeQuantity(request.body, request.session.user); + const contractFees = await getContractFees(request.body.contractId); + response.json({ + success, + contractFees + }); +} diff --git a/handlers/contracts-post/doUpdateContractFeeQuantity.ts b/handlers/contracts-post/doUpdateContractFeeQuantity.ts new file mode 100644 index 00000000..9b68e14f --- /dev/null +++ b/handlers/contracts-post/doUpdateContractFeeQuantity.ts @@ -0,0 +1,25 @@ +import type { Request, Response } from 'express' + +import getContractFees from '../../database/getContractFees.js' +import updateContractFeeQuantity, { + type UpdateBurialSiteFeeForm +} from '../../database/updateContractFeeQuantity.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + const success = await updateContractFeeQuantity( + request.body, + request.session.user as User + ) + + const contractFees = await getContractFees( + request.body.contractId + ) + + response.json({ + success, + contractFees + }) +} diff --git a/handlers/contracts-post/doUpdateContractTransaction.d.ts b/handlers/contracts-post/doUpdateContractTransaction.d.ts new file mode 100644 index 00000000..d9cad38a --- /dev/null +++ b/handlers/contracts-post/doUpdateContractTransaction.d.ts @@ -0,0 +1,3 @@ +import type { Request, Response } from 'express'; +import { type ContractTransactionUpdateForm } from '../../database/updateContractTransaction.js'; +export default function handler(request: Request, response: Response): Promise; diff --git a/handlers/contracts-post/doUpdateContractTransaction.js b/handlers/contracts-post/doUpdateContractTransaction.js new file mode 100644 index 00000000..05b2439d --- /dev/null +++ b/handlers/contracts-post/doUpdateContractTransaction.js @@ -0,0 +1,12 @@ +import getContractTransactions from '../../database/getContractTransactions.js'; +import updateContractTransaction from '../../database/updateContractTransaction.js'; +export default async function handler(request, response) { + await updateContractTransaction(request.body, request.session.user); + const contractTransactions = await getContractTransactions(request.body.contractId, { + includeIntegrations: true + }); + response.json({ + success: true, + contractTransactions + }); +} diff --git a/handlers/contracts-post/doUpdateContractTransaction.ts b/handlers/contracts-post/doUpdateContractTransaction.ts new file mode 100644 index 00000000..46bbca48 --- /dev/null +++ b/handlers/contracts-post/doUpdateContractTransaction.ts @@ -0,0 +1,26 @@ +import type { Request, Response } from 'express' + +import getContractTransactions from '../../database/getContractTransactions.js' +import updateContractTransaction, { + type ContractTransactionUpdateForm +} from '../../database/updateContractTransaction.js' + +export default async function handler( + request: Request, + response: Response +): Promise { + await updateContractTransaction( + request.body, + request.session.user as User + ) + + const contractTransactions = + await getContractTransactions(request.body.contractId, { + includeIntegrations: true + }) + + response.json({ + success: true, + contractTransactions + }) +} diff --git a/handlers/dashboard-get/dashboard.js b/handlers/dashboard-get/dashboard.js index c848dff3..39b6bff6 100644 --- a/handlers/dashboard-get/dashboard.js +++ b/handlers/dashboard-get/dashboard.js @@ -1,5 +1,5 @@ import { dateToString } from '@cityssm/utils-datetime'; -import getBurialSiteContracts from '../../database/getBurialSiteContracts.js'; +import getContracts from '../../database/getContracts.js'; import getWorkOrderMilestones from '../../database/getWorkOrderMilestones.js'; import { getWorkOrders } from '../../database/getWorkOrders.js'; export default async function handler(_request, response) { @@ -17,7 +17,7 @@ export default async function handler(_request, response) { limit: 1, // only using the count offset: 0 }); - const burialSiteContractResults = await getBurialSiteContracts({ + const contractResults = await getContracts({ 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, - burialSiteContractCount: burialSiteContractResults.count + contractCount: contractResults.count }); } diff --git a/handlers/dashboard-get/dashboard.ts b/handlers/dashboard-get/dashboard.ts index 64f56c87..c28a2493 100644 --- a/handlers/dashboard-get/dashboard.ts +++ b/handlers/dashboard-get/dashboard.ts @@ -1,7 +1,7 @@ import { dateToString } from '@cityssm/utils-datetime' import type { Request, Response } from 'express' -import getBurialSiteContracts from '../../database/getBurialSiteContracts.js' +import getContracts from '../../database/getContracts.js' import getWorkOrderMilestones from '../../database/getWorkOrderMilestones.js' import { getWorkOrders } from '../../database/getWorkOrders.js' @@ -32,7 +32,7 @@ export default async function handler( } ) - const burialSiteContractResults = await getBurialSiteContracts( + const contractResults = await getContracts( { contractStartDateString: currentDateString }, @@ -49,6 +49,6 @@ export default async function handler( headTitle: 'Dashboard', workOrderMilestones, workOrderCount: workOrderResults.count, - burialSiteContractCount: burialSiteContractResults.count + contractCount: contractResults.count }) } diff --git a/handlers/workOrders-post/doAddWorkOrderBurialSite.js b/handlers/workOrders-post/doAddWorkOrderBurialSite.js index 1bd7908f..24f9a2d2 100644 --- a/handlers/workOrders-post/doAddWorkOrderBurialSite.js +++ b/handlers/workOrders-post/doAddWorkOrderBurialSite.js @@ -10,7 +10,7 @@ export default async function handler(request, response) { }, { limit: -1, offset: 0, - includeBurialSiteContractCount: false + includeContractCount: false }); response.json({ success, diff --git a/handlers/workOrders-post/doAddWorkOrderBurialSite.ts b/handlers/workOrders-post/doAddWorkOrderBurialSite.ts index 7375ca2a..80dff2fd 100644 --- a/handlers/workOrders-post/doAddWorkOrderBurialSite.ts +++ b/handlers/workOrders-post/doAddWorkOrderBurialSite.ts @@ -26,7 +26,7 @@ export default async function handler( { limit: -1, offset: 0, - includeBurialSiteContractCount: false + includeContractCount: false } ) diff --git a/handlers/workOrders-post/doAddWorkOrderBurialSiteContract.js b/handlers/workOrders-post/doAddWorkOrderBurialSiteContract.js deleted file mode 100644 index d7e31600..00000000 --- a/handlers/workOrders-post/doAddWorkOrderBurialSiteContract.js +++ /dev/null @@ -1,21 +0,0 @@ -import addWorkOrderBurialSiteContract from '../../database/addWorkOrderBurialSiteContract.js'; -import getBurialSiteContracts from '../../database/getBurialSiteContracts.js'; -export default async function handler(request, response) { - const success = await addWorkOrderBurialSiteContract({ - workOrderId: request.body.workOrderId, - burialSiteContractId: request.body.burialSiteContractId - }, request.session.user); - const results = await getBurialSiteContracts({ - workOrderId: request.body.workOrderId - }, { - limit: -1, - offset: 0, - includeInterments: true, - includeFees: false, - includeTransactions: false - }); - response.json({ - success, - workOrderBurialSiteContracts: results.burialSiteContracts - }); -} diff --git a/handlers/workOrders-post/doAddWorkOrderBurialSiteContract.d.ts b/handlers/workOrders-post/doAddWorkOrderContract.d.ts similarity index 84% rename from handlers/workOrders-post/doAddWorkOrderBurialSiteContract.d.ts rename to handlers/workOrders-post/doAddWorkOrderContract.d.ts index d5e2e662..d4427103 100644 --- a/handlers/workOrders-post/doAddWorkOrderBurialSiteContract.d.ts +++ b/handlers/workOrders-post/doAddWorkOrderContract.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/workOrders-post/doAddWorkOrderContract.js b/handlers/workOrders-post/doAddWorkOrderContract.js new file mode 100644 index 00000000..bf502836 --- /dev/null +++ b/handlers/workOrders-post/doAddWorkOrderContract.js @@ -0,0 +1,21 @@ +import addWorkOrderContract from '../../database/addWorkOrderContract.js'; +import getContracts from '../../database/getContracts.js'; +export default async function handler(request, response) { + const success = await addWorkOrderContract({ + workOrderId: request.body.workOrderId, + contractId: request.body.contractId + }, request.session.user); + const results = await getContracts({ + workOrderId: request.body.workOrderId + }, { + limit: -1, + offset: 0, + includeInterments: true, + includeFees: false, + includeTransactions: false + }); + response.json({ + success, + workOrderContracts: results.contracts + }); +} diff --git a/handlers/workOrders-post/doAddWorkOrderBurialSiteContract.ts b/handlers/workOrders-post/doAddWorkOrderContract.ts similarity index 52% rename from handlers/workOrders-post/doAddWorkOrderBurialSiteContract.ts rename to handlers/workOrders-post/doAddWorkOrderContract.ts index 0b42f6ca..2a0dd000 100644 --- a/handlers/workOrders-post/doAddWorkOrderBurialSiteContract.ts +++ b/handlers/workOrders-post/doAddWorkOrderContract.ts @@ -1,25 +1,25 @@ import type { Request, Response } from 'express' -import addWorkOrderBurialSiteContract from '../../database/addWorkOrderBurialSiteContract.js' -import getBurialSiteContracts from '../../database/getBurialSiteContracts.js' +import addWorkOrderContract from '../../database/addWorkOrderContract.js' +import getContracts from '../../database/getContracts.js' export default async function handler( request: Request< unknown, unknown, - { workOrderId: string; burialSiteContractId: string } + { workOrderId: string; contractId: string } >, response: Response ): Promise { - const success = await addWorkOrderBurialSiteContract( + const success = await addWorkOrderContract( { workOrderId: request.body.workOrderId, - burialSiteContractId: request.body.burialSiteContractId + contractId: request.body.contractId }, request.session.user as User ) - const results = await getBurialSiteContracts( + const results = await getContracts( { workOrderId: request.body.workOrderId }, @@ -34,6 +34,6 @@ export default async function handler( response.json({ success, - workOrderBurialSiteContracts: results.burialSiteContracts + workOrderContracts: results.contracts }) } diff --git a/handlers/workOrders-post/doDeleteWorkOrderBurialSite.js b/handlers/workOrders-post/doDeleteWorkOrderBurialSite.js index 1a9acf2f..6b640eea 100644 --- a/handlers/workOrders-post/doDeleteWorkOrderBurialSite.js +++ b/handlers/workOrders-post/doDeleteWorkOrderBurialSite.js @@ -7,7 +7,7 @@ export default async function handler(request, response) { }, { limit: -1, offset: 0, - includeBurialSiteContractCount: false + includeContractCount: false }); response.json({ success, diff --git a/handlers/workOrders-post/doDeleteWorkOrderBurialSite.ts b/handlers/workOrders-post/doDeleteWorkOrderBurialSite.ts index 23b36a55..f83ff520 100644 --- a/handlers/workOrders-post/doDeleteWorkOrderBurialSite.ts +++ b/handlers/workOrders-post/doDeleteWorkOrderBurialSite.ts @@ -20,7 +20,7 @@ export default async function handler( { limit: -1, offset: 0, - includeBurialSiteContractCount: false + includeContractCount: false } ) diff --git a/handlers/workOrders-post/doDeleteWorkOrderBurialSiteContract.js b/handlers/workOrders-post/doDeleteWorkOrderBurialSiteContract.js deleted file mode 100644 index a1f8db72..00000000 --- a/handlers/workOrders-post/doDeleteWorkOrderBurialSiteContract.js +++ /dev/null @@ -1,18 +0,0 @@ -import deleteWorkOrderBurialSiteContract from '../../database/deleteWorkOrderBurialSiteContract.js'; -import getBurialSiteContracts from '../../database/getBurialSiteContracts.js'; -export default async function handler(request, response) { - const success = await deleteWorkOrderBurialSiteContract(request.body.workOrderId, request.body.burialSiteContractId, request.session.user); - const workOrderBurialSiteContracts = await getBurialSiteContracts({ - workOrderId: request.body.workOrderId - }, { - limit: -1, - offset: 0, - includeInterments: true, - includeFees: false, - includeTransactions: false - }); - response.json({ - success, - workOrderBurialSiteContracts: workOrderBurialSiteContracts.burialSiteContracts - }); -} diff --git a/handlers/workOrders-post/doDeleteWorkOrderBurialSiteContract.ts b/handlers/workOrders-post/doDeleteWorkOrderBurialSiteContract.ts deleted file mode 100644 index c021c269..00000000 --- a/handlers/workOrders-post/doDeleteWorkOrderBurialSiteContract.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type { Request, Response } from 'express' - -import deleteWorkOrderBurialSiteContract from '../../database/deleteWorkOrderBurialSiteContract.js' -import getBurialSiteContracts from '../../database/getBurialSiteContracts.js' - -export default async function handler( - request: Request< - unknown, - unknown, - { workOrderId: string; burialSiteContractId: string } - >, - response: Response -): Promise { - const success = await deleteWorkOrderBurialSiteContract( - request.body.workOrderId, - request.body.burialSiteContractId, - request.session.user as User - ) - - const workOrderBurialSiteContracts = await getBurialSiteContracts( - { - workOrderId: request.body.workOrderId - }, - { - limit: -1, - offset: 0, - includeInterments: true, - includeFees: false, - includeTransactions: false - } - ) - - response.json({ - success, - workOrderBurialSiteContracts: - workOrderBurialSiteContracts.burialSiteContracts - }) -} diff --git a/handlers/workOrders-post/doDeleteWorkOrderBurialSiteContract.d.ts b/handlers/workOrders-post/doDeleteWorkOrderContract.d.ts similarity index 84% rename from handlers/workOrders-post/doDeleteWorkOrderBurialSiteContract.d.ts rename to handlers/workOrders-post/doDeleteWorkOrderContract.d.ts index d5e2e662..d4427103 100644 --- a/handlers/workOrders-post/doDeleteWorkOrderBurialSiteContract.d.ts +++ b/handlers/workOrders-post/doDeleteWorkOrderContract.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/workOrders-post/doDeleteWorkOrderContract.js b/handlers/workOrders-post/doDeleteWorkOrderContract.js new file mode 100644 index 00000000..cd4dd354 --- /dev/null +++ b/handlers/workOrders-post/doDeleteWorkOrderContract.js @@ -0,0 +1,18 @@ +import deleteWorkOrderContract from '../../database/deleteWorkOrderContract.js'; +import getContracts from '../../database/getContracts.js'; +export default async function handler(request, response) { + const success = await deleteWorkOrderContract(request.body.workOrderId, request.body.contractId, request.session.user); + const workOrderContracts = await getContracts({ + workOrderId: request.body.workOrderId + }, { + limit: -1, + offset: 0, + includeInterments: true, + includeFees: false, + includeTransactions: false + }); + response.json({ + success, + workOrderContracts: workOrderContracts.contracts + }); +} diff --git a/handlers/workOrders-post/doDeleteWorkOrderContract.ts b/handlers/workOrders-post/doDeleteWorkOrderContract.ts new file mode 100644 index 00000000..3ed9d8a9 --- /dev/null +++ b/handlers/workOrders-post/doDeleteWorkOrderContract.ts @@ -0,0 +1,38 @@ +import type { Request, Response } from 'express' + +import deleteWorkOrderContract from '../../database/deleteWorkOrderContract.js' +import getContracts from '../../database/getContracts.js' + +export default async function handler( + request: Request< + unknown, + unknown, + { workOrderId: string; contractId: string } + >, + response: Response +): Promise { + const success = await deleteWorkOrderContract( + request.body.workOrderId, + request.body.contractId, + request.session.user as User + ) + + const workOrderContracts = await getContracts( + { + workOrderId: request.body.workOrderId + }, + { + limit: -1, + offset: 0, + includeInterments: true, + includeFees: false, + includeTransactions: false + } + ) + + response.json({ + success, + workOrderContracts: + workOrderContracts.contracts + }) +} diff --git a/handlers/workOrders-post/doUpdateBurialSiteStatus.js b/handlers/workOrders-post/doUpdateBurialSiteStatus.js index 63faac7a..d2ddc193 100644 --- a/handlers/workOrders-post/doUpdateBurialSiteStatus.js +++ b/handlers/workOrders-post/doUpdateBurialSiteStatus.js @@ -7,7 +7,7 @@ export default async function handler(request, response) { }, { limit: -1, offset: 0, - includeBurialSiteContractCount: true + includeContractCount: true }); response.json({ success, diff --git a/handlers/workOrders-post/doUpdateBurialSiteStatus.ts b/handlers/workOrders-post/doUpdateBurialSiteStatus.ts index d2f0452e..5e265272 100644 --- a/handlers/workOrders-post/doUpdateBurialSiteStatus.ts +++ b/handlers/workOrders-post/doUpdateBurialSiteStatus.ts @@ -24,7 +24,7 @@ export default async function handler( { limit: -1, offset: 0, - includeBurialSiteContractCount: true + includeContractCount: true } ) diff --git a/helpers/burialSiteContracts.helpers.d.ts b/helpers/burialSiteContracts.helpers.d.ts deleted file mode 100644 index 1ef415d2..00000000 --- a/helpers/burialSiteContracts.helpers.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { BurialSiteContract, BurialSiteContractFee } from '../types/recordTypes.js'; -export declare function getFieldValueByContractTypeField(burialSiteContract: BurialSiteContract, contractTypeField: string): string | undefined; -export declare function getFeesByFeeCategory(burialSiteContract: BurialSiteContract, feeCategory: string, feeCategoryContains?: boolean): BurialSiteContractFee[]; -export declare function getTransactionTotal(burialSiteContract: BurialSiteContract): number; diff --git a/helpers/contracts.helpers.d.ts b/helpers/contracts.helpers.d.ts new file mode 100644 index 00000000..a81164aa --- /dev/null +++ b/helpers/contracts.helpers.d.ts @@ -0,0 +1,4 @@ +import type { Contract, ContractFee } from '../types/recordTypes.js'; +export declare function getFieldValueByContractTypeField(contract: Contract, contractTypeField: string): string | undefined; +export declare function getFeesByFeeCategory(contract: Contract, feeCategory: string, feeCategoryContains?: boolean): ContractFee[]; +export declare function getTransactionTotal(contract: Contract): number; diff --git a/helpers/burialSiteContracts.helpers.js b/helpers/contracts.helpers.js similarity index 50% rename from helpers/burialSiteContracts.helpers.js rename to helpers/contracts.helpers.js index 180e2952..0e85e817 100644 --- a/helpers/burialSiteContracts.helpers.js +++ b/helpers/contracts.helpers.js @@ -1,24 +1,24 @@ -export function getFieldValueByContractTypeField(burialSiteContract, contractTypeField) { +export function getFieldValueByContractTypeField(contract, contractTypeField) { const contractTypeFieldLowerCase = contractTypeField.toLowerCase(); - const field = (burialSiteContract.burialSiteContractFields ?? []).find((possibleField) => possibleField.contractTypeField.toLowerCase() === + const field = (contract.contractFields ?? []).find((possibleField) => possibleField.contractTypeField.toLowerCase() === contractTypeFieldLowerCase); if (field === undefined) { return undefined; } return field.fieldValue; } -export function getFeesByFeeCategory(burialSiteContract, feeCategory, feeCategoryContains = false) { +export function getFeesByFeeCategory(contract, feeCategory, feeCategoryContains = false) { const feeCategoryLowerCase = feeCategory.toLowerCase(); - return (burialSiteContract.burialSiteContractFees ?? []).filter((possibleFee) => feeCategoryContains + return (contract.contractFees ?? []).filter((possibleFee) => feeCategoryContains ? possibleFee.feeCategory .toLowerCase() .includes(feeCategoryLowerCase) : possibleFee.feeCategory.toLowerCase() === feeCategoryLowerCase); } -export function getTransactionTotal(burialSiteContract) { +export function getTransactionTotal(contract) { let transactionTotal = 0; - for (const transaction of burialSiteContract.burialSiteContractTransactions ?? + for (const transaction of contract.contractTransactions ?? []) { transactionTotal += transaction.transactionAmount; } diff --git a/helpers/burialSiteContracts.helpers.ts b/helpers/contracts.helpers.ts similarity index 70% rename from helpers/burialSiteContracts.helpers.ts rename to helpers/contracts.helpers.ts index c83c885d..3d051699 100644 --- a/helpers/burialSiteContracts.helpers.ts +++ b/helpers/contracts.helpers.ts @@ -1,15 +1,15 @@ import type { - BurialSiteContract, - BurialSiteContractFee + Contract, + ContractFee } from '../types/recordTypes.js' export function getFieldValueByContractTypeField( - burialSiteContract: BurialSiteContract, + contract: Contract, contractTypeField: string ): string | undefined { const contractTypeFieldLowerCase = contractTypeField.toLowerCase() - const field = (burialSiteContract.burialSiteContractFields ?? []).find( + const field = (contract.contractFields ?? []).find( (possibleField) => (possibleField.contractTypeField as string).toLowerCase() === contractTypeFieldLowerCase @@ -23,13 +23,13 @@ export function getFieldValueByContractTypeField( } export function getFeesByFeeCategory( - burialSiteContract: BurialSiteContract, + contract: Contract, feeCategory: string, feeCategoryContains = false -): BurialSiteContractFee[] { +): ContractFee[] { const feeCategoryLowerCase = feeCategory.toLowerCase() - return (burialSiteContract.burialSiteContractFees ?? []).filter( + return (contract.contractFees ?? []).filter( (possibleFee) => feeCategoryContains ? (possibleFee.feeCategory as string) @@ -41,11 +41,11 @@ export function getFeesByFeeCategory( } export function getTransactionTotal( - burialSiteContract: BurialSiteContract + contract: Contract ): number { let transactionTotal = 0 - for (const transaction of burialSiteContract.burialSiteContractTransactions ?? + for (const transaction of contract.contractTransactions ?? []) { transactionTotal += transaction.transactionAmount } diff --git a/helpers/functions.fee.d.ts b/helpers/functions.fee.d.ts index 129ced63..469ff4da 100644 --- a/helpers/functions.fee.d.ts +++ b/helpers/functions.fee.d.ts @@ -1,3 +1,3 @@ -import type { BurialSiteContract, Fee } from '../types/recordTypes.js'; -export declare function calculateFeeAmount(fee: Fee, burialSiteContract: BurialSiteContract): number; +import type { Contract, Fee } from '../types/recordTypes.js'; +export declare function calculateFeeAmount(fee: Fee, contract: Contract): number; export declare function calculateTaxAmount(fee: Fee, feeAmount: number): number; diff --git a/helpers/functions.fee.js b/helpers/functions.fee.js index 0b307f9d..4590b590 100644 --- a/helpers/functions.fee.js +++ b/helpers/functions.fee.js @@ -1,4 +1,4 @@ -export function calculateFeeAmount(fee, burialSiteContract) { +export function calculateFeeAmount(fee, contract) { 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 78a1a240..815a468b 100644 --- a/helpers/functions.fee.ts +++ b/helpers/functions.fee.ts @@ -1,8 +1,8 @@ -import type { BurialSiteContract, Fee } from '../types/recordTypes.js' +import type { Contract, Fee } from '../types/recordTypes.js' export function calculateFeeAmount( fee: Fee, - burialSiteContract: BurialSiteContract + contract: Contract ): number { return fee.feeFunction ? 0 : fee.feeAmount ?? 0 } diff --git a/helpers/functions.print.d.ts b/helpers/functions.print.d.ts index fd9063b8..48ac6e1a 100644 --- a/helpers/functions.print.d.ts +++ b/helpers/functions.print.d.ts @@ -1,4 +1,4 @@ -import type { BurialSite, BurialSiteContract, WorkOrder } from '../types/recordTypes.js'; +import type { BurialSite, Contract, WorkOrder } from '../types/recordTypes.js'; interface PrintConfig { title: string; params: string[]; @@ -6,11 +6,11 @@ interface PrintConfig { interface ReportData { headTitle: string; burialSite?: BurialSite; - burialSiteContract?: BurialSiteContract; + contract?: Contract; workOrder?: WorkOrder; configFunctions: unknown; dateTimeFunctions: unknown; - burialSiteContractFunctions: unknown; + contractFunctions: 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 d7300f07..fdf805b2 100644 --- a/helpers/functions.print.js +++ b/helpers/functions.print.js @@ -2,14 +2,14 @@ /* eslint-disable security/detect-object-injection */ import * as dateTimeFunctions from '@cityssm/utils-datetime'; import getBurialSite from '../database/getBurialSite.js'; -import getBurialSiteContract from '../database/getBurialSiteContract.js'; +import getContract from '../database/getContract.js'; import getWorkOrder from '../database/getWorkOrder.js'; -import * as burialSiteContractFunctions from './burialSiteContracts.helpers.js'; +import * as contractFunctions from './contracts.helpers.js'; import * as configFunctions from './config.helpers.js'; const screenPrintConfigs = { - burialSiteContract: { + contract: { title: `Burial Site Contract Print`, - params: ['burialSiteContractId'] + params: ['contractId'] } }; export function getScreenPrintConfig(printName) { @@ -27,11 +27,11 @@ const pdfPrintConfigs = { // Occupancy 'ssm.cemetery.burialPermit': { title: 'Burial Permit', - params: ['burialSiteContractId'] + params: ['contractId'] }, 'ssm.cemetery.contract': { title: 'Contract for Purchase of Interment Rights', - params: ['burialSiteContractId'] + params: ['contractId'] } }; export function getPdfPrintConfig(printName) { @@ -54,15 +54,15 @@ export async function getReportData(printConfig, requestQuery) { headTitle: printConfig.title, configFunctions, dateTimeFunctions, - burialSiteContractFunctions + contractFunctions }; - if (printConfig.params.includes('burialSiteContractId') && - typeof requestQuery.burialSiteContractId === 'string') { - const burialSiteContract = await getBurialSiteContract(requestQuery.burialSiteContractId); - if (burialSiteContract !== undefined && (burialSiteContract.burialSiteId ?? -1) !== -1) { - reportData.burialSite = await getBurialSite(burialSiteContract.burialSiteId ?? -1); + if (printConfig.params.includes('contractId') && + typeof requestQuery.contractId === 'string') { + const contract = await getContract(requestQuery.contractId); + if (contract !== undefined && (contract.burialSiteId ?? -1) !== -1) { + reportData.burialSite = await getBurialSite(contract.burialSiteId ?? -1); } - reportData.burialSiteContract = burialSiteContract; + reportData.contract = contract; } if (printConfig.params.includes('workOrderId') && typeof requestQuery.workOrderId === 'string') { diff --git a/helpers/functions.print.ts b/helpers/functions.print.ts index d2baf2d7..6dc4c198 100644 --- a/helpers/functions.print.ts +++ b/helpers/functions.print.ts @@ -4,11 +4,11 @@ import * as dateTimeFunctions from '@cityssm/utils-datetime' import getBurialSite from '../database/getBurialSite.js' -import getBurialSiteContract from '../database/getBurialSiteContract.js' +import getContract from '../database/getContract.js' import getWorkOrder from '../database/getWorkOrder.js' -import type { BurialSite, BurialSiteContract, WorkOrder } from '../types/recordTypes.js' +import type { BurialSite, Contract, WorkOrder } from '../types/recordTypes.js' -import * as burialSiteContractFunctions from './burialSiteContracts.helpers.js' +import * as contractFunctions from './contracts.helpers.js' import * as configFunctions from './config.helpers.js' interface PrintConfig { @@ -20,18 +20,18 @@ interface ReportData { headTitle: string burialSite?: BurialSite - burialSiteContract?: BurialSiteContract + contract?: Contract workOrder?: WorkOrder configFunctions: unknown dateTimeFunctions: unknown - burialSiteContractFunctions: unknown + contractFunctions: unknown } const screenPrintConfigs: Record = { - burialSiteContract: { + contract: { title: `Burial Site Contract Print`, - params: ['burialSiteContractId'] + params: ['contractId'] } } @@ -54,11 +54,11 @@ const pdfPrintConfigs: Record = { // Occupancy 'ssm.cemetery.burialPermit': { title: 'Burial Permit', - params: ['burialSiteContractId'] + params: ['contractId'] }, 'ssm.cemetery.contract': { title: 'Contract for Purchase of Interment Rights', - params: ['burialSiteContractId'] + params: ['contractId'] } } @@ -91,20 +91,20 @@ export async function getReportData( headTitle: printConfig.title, configFunctions, dateTimeFunctions, - burialSiteContractFunctions + contractFunctions } if ( - printConfig.params.includes('burialSiteContractId') && - typeof requestQuery.burialSiteContractId === 'string' + printConfig.params.includes('contractId') && + typeof requestQuery.contractId === 'string' ) { - const burialSiteContract = await getBurialSiteContract(requestQuery.burialSiteContractId) + const contract = await getContract(requestQuery.contractId) - if (burialSiteContract !== undefined && (burialSiteContract.burialSiteId ?? -1) !== -1) { - reportData.burialSite = await getBurialSite(burialSiteContract.burialSiteId ?? -1) + if (contract !== undefined && (contract.burialSiteId ?? -1) !== -1) { + reportData.burialSite = await getBurialSite(contract.burialSiteId ?? -1) } - reportData.burialSiteContract = burialSiteContract + reportData.contract = contract } if ( diff --git a/public/javascripts/burialSite.search.js b/public/javascripts/burialSite.search.js index 01ff04dc..8a7ca25e 100644 --- a/public/javascripts/burialSite.search.js +++ b/public/javascripts/burialSite.search.js @@ -34,7 +34,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); ${burialSite.burialSiteStatusId ? cityssm.escapeHTML(burialSite.burialSiteStatus ?? '') : '(No Status)'}
- ${(burialSite.burialSiteContractCount ?? 0) > 0 + ${(burialSite.contractCount ?? 0) > 0 ? 'Currently Occupied' : ''} diff --git a/public/javascripts/burialSite.search.ts b/public/javascripts/burialSite.search.ts index b13b2c8e..1e98c7cc 100644 --- a/public/javascripts/burialSite.search.ts +++ b/public/javascripts/burialSite.search.ts @@ -69,7 +69,7 @@ declare const exports: Record : '(No Status)' }
${ - (burialSite.burialSiteContractCount ?? 0) > 0 + (burialSite.contractCount ?? 0) > 0 ? 'Currently Occupied' : '' } diff --git a/public/javascripts/burialSiteContract.edit.d.ts b/public/javascripts/contract.edit.d.ts similarity index 100% rename from public/javascripts/burialSiteContract.edit.d.ts rename to public/javascripts/contract.edit.d.ts diff --git a/public/javascripts/burialSiteContract.edit.js b/public/javascripts/contract.edit.js similarity index 74% rename from public/javascripts/burialSiteContract.edit.js rename to public/javascripts/contract.edit.js index 07a5f4d7..607b4cae 100644 --- a/public/javascripts/burialSiteContract.edit.js +++ b/public/javascripts/contract.edit.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); (() => { const los = exports.los; - const burialSiteContractId = document.querySelector('#burialSiteContract--burialSiteContractId').value; - const isCreate = burialSiteContractId === ''; + const contractId = document.querySelector('#contract--contractId').value; + const isCreate = contractId === ''; /* * Main form */ @@ -11,24 +11,24 @@ Object.defineProperty(exports, "__esModule", { value: true }); function setUnsavedChanges() { los.setUnsavedChanges(); document - .querySelector("button[type='submit'][form='form--burialSiteContract']") + .querySelector("button[type='submit'][form='form--contract']") ?.classList.remove('is-light'); } function clearUnsavedChanges() { los.clearUnsavedChanges(); document - .querySelector("button[type='submit'][form='form--burialSiteContract']") + .querySelector("button[type='submit'][form='form--contract']") ?.classList.add('is-light'); } - const formElement = document.querySelector('#form--burialSiteContract'); + const formElement = document.querySelector('#form--contract'); formElement.addEventListener('submit', (formEvent) => { formEvent.preventDefault(); - cityssm.postJSON(`${los.urlPrefix}/contracts/${isCreate ? 'doCreateBurialSiteOccupancy' : 'doUpdateBurialSiteContract'}`, formElement, (rawResponseJSON) => { + cityssm.postJSON(`${los.urlPrefix}/contracts/${isCreate ? 'doCreateBurialSiteOccupancy' : 'doUpdateContract'}`, formElement, (rawResponseJSON) => { const responseJSON = rawResponseJSON; if (responseJSON.success) { clearUnsavedChanges(); if (isCreate || refreshAfterSave) { - globalThis.location.href = los.getBurialSiteContractURL(responseJSON.burialSiteContractId, true, true); + globalThis.location.href = los.getContractURL(responseJSON.contractId, true, true); } else { bulmaJS.alert({ @@ -51,13 +51,13 @@ Object.defineProperty(exports, "__esModule", { value: true }); formInputElement.addEventListener('change', setUnsavedChanges); } function doCopy() { - cityssm.postJSON(`${los.urlPrefix}/contracts/doCopyBurialSiteContract`, { - burialSiteContractId + cityssm.postJSON(`${los.urlPrefix}/contracts/doCopyContract`, { + contractId }, (rawResponseJSON) => { const responseJSON = rawResponseJSON; if (responseJSON.success) { clearUnsavedChanges(); - globalThis.location.href = los.getBurialSiteContractURL(responseJSON.burialSiteContractId, true); + globalThis.location.href = los.getContractURL(responseJSON.contractId, true); } else { bulmaJS.alert({ @@ -69,7 +69,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); }); } document - .querySelector('#button--copyBurialSiteContract') + .querySelector('#button--copyContract') ?.addEventListener('click', (clickEvent) => { clickEvent.preventDefault(); if (los.hasUnsavedChanges()) { @@ -96,13 +96,13 @@ Object.defineProperty(exports, "__esModule", { value: true }); ?.addEventListener('click', (clickEvent) => { clickEvent.preventDefault(); function doDelete() { - cityssm.postJSON(`${los.urlPrefix}/contracts/doDeleteBurialSiteContract`, { - burialSiteContractId + cityssm.postJSON(`${los.urlPrefix}/contracts/doDeleteContract`, { + contractId }, (rawResponseJSON) => { const responseJSON = rawResponseJSON; if (responseJSON.success) { clearUnsavedChanges(); - globalThis.location.href = los.getBurialSiteContractURL(); + globalThis.location.href = los.getContractURL(); } else { bulmaJS.alert({ @@ -155,10 +155,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); } }); } - cityssm.openHtmlModal('burialSiteContract-createWorkOrder', { + cityssm.openHtmlModal('contract-createWorkOrder', { onshow(modalElement) { ; - modalElement.querySelector('#workOrderCreate--burialSiteContractId').value = burialSiteContractId; + modalElement.querySelector('#workOrderCreate--contractId').value = contractId; modalElement.querySelector('#workOrderCreate--workOrderOpenDateString').value = cityssm.dateToString(new Date()); const workOrderTypeSelectElement = modalElement.querySelector('#workOrderCreate--workOrderTypeId'); const workOrderTypes = exports @@ -188,13 +188,13 @@ Object.defineProperty(exports, "__esModule", { value: true }); }); }); // Occupancy Type - const contractTypeIdElement = document.querySelector('#burialSiteContract--contractTypeId'); + const contractTypeIdElement = document.querySelector('#contract--contractTypeId'); if (isCreate) { - const burialSiteContractFieldsContainerElement = document.querySelector('#container--burialSiteContractFields'); + const contractFieldsContainerElement = document.querySelector('#container--contractFields'); contractTypeIdElement.addEventListener('change', () => { if (contractTypeIdElement.value === '') { // eslint-disable-next-line no-unsanitized/property - burialSiteContractFieldsContainerElement.innerHTML = `
+ contractFieldsContainerElement.innerHTML = `

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

`; return; @@ -205,17 +205,17 @@ Object.defineProperty(exports, "__esModule", { value: true }); const responseJSON = rawResponseJSON; if (responseJSON.ContractTypeFields.length === 0) { // eslint-disable-next-line no-unsanitized/property - burialSiteContractFieldsContainerElement.innerHTML = `
+ contractFieldsContainerElement.innerHTML = `

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

`; return; } - burialSiteContractFieldsContainerElement.innerHTML = ''; + contractFieldsContainerElement.innerHTML = ''; let contractTypeFieldIds = ''; for (const occupancyTypeField of responseJSON.ContractTypeFields) { contractTypeFieldIds += `,${occupancyTypeField.contractTypeFieldId.toString()}`; - const fieldName = `burialSiteContractFieldValue_${occupancyTypeField.contractTypeFieldId.toString()}`; - const fieldId = `burialSiteContract--${fieldName}`; + const fieldName = `contractFieldValue_${occupancyTypeField.contractTypeFieldId.toString()}`; + const fieldId = `contract--${fieldName}`; const fieldElement = document.createElement('div'); fieldElement.className = 'field'; fieldElement.innerHTML = `
`; @@ -256,9 +256,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); fieldElement.querySelector('.control').append(inputElement); } console.log(fieldElement); - burialSiteContractFieldsContainerElement.append(fieldElement); + contractFieldsContainerElement.append(fieldElement); } - burialSiteContractFieldsContainerElement.insertAdjacentHTML('beforeend', + contractFieldsContainerElement.insertAdjacentHTML('beforeend', // eslint-disable-next-line no-secrets/no-secrets ``); @@ -291,7 +291,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); }); } // Lot Selector - const lotNameElement = document.querySelector('#burialSiteContract--lotName'); + const lotNameElement = document.querySelector('#contract--lotName'); lotNameElement.addEventListener('click', (clickEvent) => { const currentLotName = clickEvent.currentTarget.value; let lotSelectCloseModalFunction; @@ -300,8 +300,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); let lotSelectResultsElement; function renderSelectedLotAndClose(lotId, lotName) { ; - document.querySelector('#burialSiteContract--lotId').value = lotId.toString(); - document.querySelector('#burialSiteContract--lotName').value = lotName; + document.querySelector('#contract--lotId').value = lotId.toString(); + document.querySelector('#contract--lotName').value = lotName; setUnsavedChanges(); lotSelectCloseModalFunction(); } @@ -339,7 +339,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
${cityssm.escapeHTML(lot.lotStatus)}
- ${lot.burialSiteContractCount > 0 ? 'Currently Occupied' : ''} + ${lot.contractCount > 0 ? 'Currently Occupied' : ''}
`; @@ -367,7 +367,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); } }); } - cityssm.openHtmlModal('burialSiteContract-selectLot', { + cityssm.openHtmlModal('contract-selectLot', { onshow(modalElement) { los.populateAliases(modalElement); }, @@ -378,7 +378,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); bulmaJS.init(modalElement); // search Tab const lotNameFilterElement = modalElement.querySelector('#lotSelect--lotName'); - if (document.querySelector('#burialSiteContract--lotId') + if (document.querySelector('#contract--lotId') .value !== '') { lotNameFilterElement.value = currentLotName; } @@ -433,7 +433,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); document .querySelector('.is-lot-view-button') ?.addEventListener('click', () => { - const lotId = document.querySelector('#burialSiteContract--lotId').value; + const lotId = document.querySelector('#contract--lotId').value; if (lotId === '') { bulmaJS.alert({ message: `No ${los.escapedAliases.lot} selected.`, @@ -455,37 +455,37 @@ Object.defineProperty(exports, "__esModule", { value: true }); } else { lotNameElement.value = `(No ${los.escapedAliases.Lot})`; - document.querySelector('#burialSiteContract--lotId').value = ''; + document.querySelector('#contract--lotId').value = ''; setUnsavedChanges(); } }); // Start Date los.initializeDatePickers(formElement); document - .querySelector('#burialSiteContract--contractStartDateString') + .querySelector('#contract--contractStartDateString') ?.addEventListener('change', () => { - const endDatePicker = document.querySelector('#burialSiteContract--contractEndDateString').bulmaCalendar.datePicker; - endDatePicker.min = document.querySelector('#burialSiteContract--contractStartDateString').value; + const endDatePicker = document.querySelector('#contract--contractEndDateString').bulmaCalendar.datePicker; + endDatePicker.min = document.querySelector('#contract--contractStartDateString').value; endDatePicker.refresh(); }); los.initializeUnlockFieldButtons(formElement); (() => { - let burialSiteContractOccupants = exports.burialSiteContractOccupants; - delete exports.burialSiteContractOccupants; + let contractOccupants = exports.contractOccupants; + delete exports.contractOccupants; function openEditLotOccupancyOccupant(clickEvent) { const lotOccupantIndex = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset .lotOccupantIndex ?? '', 10); - const burialSiteContractOccupant = burialSiteContractOccupants.find((currentLotOccupancyOccupant) => { + const contractOccupant = contractOccupants.find((currentLotOccupancyOccupant) => { return (currentLotOccupancyOccupant.lotOccupantIndex === lotOccupantIndex); }); let editFormElement; let editCloseModalFunction; function editOccupant(submitEvent) { submitEvent.preventDefault(); - cityssm.postJSON(`${los.urlPrefix}/contracts/doUpdateBurialSiteContractOccupant`, editFormElement, (rawResponseJSON) => { + cityssm.postJSON(`${los.urlPrefix}/contracts/doUpdateContractOccupant`, editFormElement, (rawResponseJSON) => { const responseJSON = rawResponseJSON; if (responseJSON.success) { - burialSiteContractOccupants = responseJSON.burialSiteContractOccupants; + contractOccupants = responseJSON.contractOccupants; editCloseModalFunction(); renderLotOccupancyOccupants(); } @@ -498,12 +498,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); } }); } - cityssm.openHtmlModal('burialSiteContract-editOccupant', { + cityssm.openHtmlModal('contract-editOccupant', { onshow(modalElement) { los.populateAliases(modalElement); - modalElement.querySelector('#burialSiteContractOccupantEdit--burialSiteContractId').value = burialSiteContractId; - modalElement.querySelector('#burialSiteContractOccupantEdit--lotOccupantIndex').value = lotOccupantIndex.toString(); - const lotOccupantTypeSelectElement = modalElement.querySelector('#burialSiteContractOccupantEdit--lotOccupantTypeId'); + modalElement.querySelector('#contractOccupantEdit--contractId').value = contractId; + modalElement.querySelector('#contractOccupantEdit--lotOccupantIndex').value = lotOccupantIndex.toString(); + const lotOccupantTypeSelectElement = modalElement.querySelector('#contractOccupantEdit--lotOccupantTypeId'); let lotOccupantTypeSelected = false; for (const lotOccupantType of exports.lotOccupantTypes) { const optionElement = document.createElement('option'); @@ -514,7 +514,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); optionElement.dataset.fontAwesomeIconClass = lotOccupantType.fontAwesomeIconClass; if (lotOccupantType.lotOccupantTypeId === - burialSiteContractOccupant.lotOccupantTypeId) { + contractOccupant.lotOccupantTypeId) { optionElement.selected = true; lotOccupantTypeSelected = true; } @@ -523,42 +523,42 @@ Object.defineProperty(exports, "__esModule", { value: true }); if (!lotOccupantTypeSelected) { const optionElement = document.createElement('option'); optionElement.value = - burialSiteContractOccupant.lotOccupantTypeId?.toString() ?? ''; + contractOccupant.lotOccupantTypeId?.toString() ?? ''; optionElement.textContent = - burialSiteContractOccupant.lotOccupantType ?? ''; + contractOccupant.lotOccupantType ?? ''; optionElement.dataset.occupantCommentTitle = - burialSiteContractOccupant.occupantCommentTitle; + contractOccupant.occupantCommentTitle; optionElement.dataset.fontAwesomeIconClass = - burialSiteContractOccupant.fontAwesomeIconClass; + contractOccupant.fontAwesomeIconClass; optionElement.selected = true; lotOccupantTypeSelectElement.append(optionElement); } ; - modalElement.querySelector('#burialSiteContractOccupantEdit--fontAwesomeIconClass').innerHTML = - ``; - modalElement.querySelector('#burialSiteContractOccupantEdit--occupantName').value = burialSiteContractOccupant.occupantName ?? ''; - modalElement.querySelector('#burialSiteContractOccupantEdit--occupantFamilyName').value = burialSiteContractOccupant.occupantFamilyName ?? ''; - modalElement.querySelector('#burialSiteContractOccupantEdit--occupantAddress1').value = burialSiteContractOccupant.occupantAddress1 ?? ''; - modalElement.querySelector('#burialSiteContractOccupantEdit--occupantAddress2').value = burialSiteContractOccupant.occupantAddress2 ?? ''; - modalElement.querySelector('#burialSiteContractOccupantEdit--occupantCity').value = burialSiteContractOccupant.occupantCity ?? ''; - modalElement.querySelector('#burialSiteContractOccupantEdit--occupantProvince').value = burialSiteContractOccupant.occupantProvince ?? ''; - modalElement.querySelector('#burialSiteContractOccupantEdit--occupantPostalCode').value = burialSiteContractOccupant.occupantPostalCode ?? ''; - modalElement.querySelector('#burialSiteContractOccupantEdit--occupantPhoneNumber').value = burialSiteContractOccupant.occupantPhoneNumber ?? ''; - modalElement.querySelector('#burialSiteContractOccupantEdit--occupantEmailAddress').value = burialSiteContractOccupant.occupantEmailAddress ?? ''; - modalElement.querySelector('#burialSiteContractOccupantEdit--occupantCommentTitle').textContent = - (burialSiteContractOccupant.occupantCommentTitle ?? '') === '' + modalElement.querySelector('#contractOccupantEdit--fontAwesomeIconClass').innerHTML = + ``; + modalElement.querySelector('#contractOccupantEdit--occupantName').value = contractOccupant.occupantName ?? ''; + modalElement.querySelector('#contractOccupantEdit--occupantFamilyName').value = contractOccupant.occupantFamilyName ?? ''; + modalElement.querySelector('#contractOccupantEdit--occupantAddress1').value = contractOccupant.occupantAddress1 ?? ''; + modalElement.querySelector('#contractOccupantEdit--occupantAddress2').value = contractOccupant.occupantAddress2 ?? ''; + modalElement.querySelector('#contractOccupantEdit--occupantCity').value = contractOccupant.occupantCity ?? ''; + modalElement.querySelector('#contractOccupantEdit--occupantProvince').value = contractOccupant.occupantProvince ?? ''; + modalElement.querySelector('#contractOccupantEdit--occupantPostalCode').value = contractOccupant.occupantPostalCode ?? ''; + modalElement.querySelector('#contractOccupantEdit--occupantPhoneNumber').value = contractOccupant.occupantPhoneNumber ?? ''; + modalElement.querySelector('#contractOccupantEdit--occupantEmailAddress').value = contractOccupant.occupantEmailAddress ?? ''; + modalElement.querySelector('#contractOccupantEdit--occupantCommentTitle').textContent = + (contractOccupant.occupantCommentTitle ?? '') === '' ? 'Comment' - : burialSiteContractOccupant.occupantCommentTitle ?? ''; - modalElement.querySelector('#burialSiteContractOccupantEdit--occupantComment').value = burialSiteContractOccupant.occupantComment ?? ''; + : contractOccupant.occupantCommentTitle ?? ''; + modalElement.querySelector('#contractOccupantEdit--occupantComment').value = contractOccupant.occupantComment ?? ''; }, onshown(modalElement, closeModalFunction) { bulmaJS.toggleHtmlClipped(); - const lotOccupantTypeIdElement = modalElement.querySelector('#burialSiteContractOccupantEdit--lotOccupantTypeId'); + const lotOccupantTypeIdElement = modalElement.querySelector('#contractOccupantEdit--lotOccupantTypeId'); lotOccupantTypeIdElement.focus(); lotOccupantTypeIdElement.addEventListener('change', () => { const fontAwesomeIconClass = lotOccupantTypeIdElement.selectedOptions[0].dataset .fontAwesomeIconClass ?? 'user'; - modalElement.querySelector('#burialSiteContractOccupantEdit--fontAwesomeIconClass').innerHTML = + modalElement.querySelector('#contractOccupantEdit--fontAwesomeIconClass').innerHTML = ``; let occupantCommentTitle = lotOccupantTypeIdElement.selectedOptions[0].dataset .occupantCommentTitle ?? ''; @@ -566,7 +566,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); occupantCommentTitle = 'Comment'; } ; - modalElement.querySelector('#burialSiteContractOccupantEdit--occupantCommentTitle').textContent = occupantCommentTitle; + modalElement.querySelector('#contractOccupantEdit--occupantCommentTitle').textContent = occupantCommentTitle; }); editFormElement = modalElement.querySelector('form'); editFormElement.addEventListener('submit', editOccupant); @@ -580,13 +580,13 @@ Object.defineProperty(exports, "__esModule", { value: true }); function deleteLotOccupancyOccupant(clickEvent) { const lotOccupantIndex = clickEvent.currentTarget.closest('tr')?.dataset.lotOccupantIndex; function doDelete() { - cityssm.postJSON(`${los.urlPrefix}/contracts/doDeleteBurialSiteContractOccupant`, { - burialSiteContractId, + cityssm.postJSON(`${los.urlPrefix}/contracts/doDeleteContractOccupant`, { + contractId, lotOccupantIndex }, (rawResponseJSON) => { const responseJSON = rawResponseJSON; if (responseJSON.success) { - burialSiteContractOccupants = responseJSON.burialSiteContractOccupants; + contractOccupants = responseJSON.contractOccupants; renderLotOccupancyOccupants(); } else { @@ -609,9 +609,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); }); } function renderLotOccupancyOccupants() { - const occupantsContainer = document.querySelector('#container--burialSiteContractOccupants'); + const occupantsContainer = document.querySelector('#container--contractOccupants'); cityssm.clearElement(occupantsContainer); - if (burialSiteContractOccupants.length === 0) { + if (contractOccupants.length === 0) { // eslint-disable-next-line no-unsanitized/property occupantsContainer.innerHTML = `

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

@@ -629,44 +629,44 @@ Object.defineProperty(exports, "__esModule", { value: true }); Options `; - for (const burialSiteContractOccupant of burialSiteContractOccupants) { + for (const contractOccupant of contractOccupants) { const tableRowElement = document.createElement('tr'); tableRowElement.dataset.lotOccupantIndex = - burialSiteContractOccupant.lotOccupantIndex?.toString(); + contractOccupant.lotOccupantIndex?.toString(); // eslint-disable-next-line no-unsanitized/property tableRowElement.innerHTML = ` - ${cityssm.escapeHTML((burialSiteContractOccupant.occupantName ?? '') === '' && - (burialSiteContractOccupant.occupantFamilyName ?? '') === '' + ${cityssm.escapeHTML((contractOccupant.occupantName ?? '') === '' && + (contractOccupant.occupantFamilyName ?? '') === '' ? '(No Name)' - : `${burialSiteContractOccupant.occupantName} ${burialSiteContractOccupant.occupantFamilyName}`)}
+ : `${contractOccupant.occupantName} ${contractOccupant.occupantFamilyName}`)}
- - ${cityssm.escapeHTML(burialSiteContractOccupant.lotOccupantType ?? '')} + + ${cityssm.escapeHTML(contractOccupant.lotOccupantType ?? '')} - ${(burialSiteContractOccupant.occupantAddress1 ?? '') === '' + ${(contractOccupant.occupantAddress1 ?? '') === '' ? '' - : `${cityssm.escapeHTML(burialSiteContractOccupant.occupantAddress1 ?? '')}
`} - ${(burialSiteContractOccupant.occupantAddress2 ?? '') === '' + : `${cityssm.escapeHTML(contractOccupant.occupantAddress1 ?? '')}
`} + ${(contractOccupant.occupantAddress2 ?? '') === '' ? '' - : `${cityssm.escapeHTML(burialSiteContractOccupant.occupantAddress2 ?? '')}
`} - ${(burialSiteContractOccupant.occupantCity ?? '') === '' + : `${cityssm.escapeHTML(contractOccupant.occupantAddress2 ?? '')}
`} + ${(contractOccupant.occupantCity ?? '') === '' ? '' - : `${cityssm.escapeHTML(burialSiteContractOccupant.occupantCity ?? '')}, `} - ${cityssm.escapeHTML(burialSiteContractOccupant.occupantProvince ?? '')}
- ${cityssm.escapeHTML(burialSiteContractOccupant.occupantPostalCode ?? '')} + : `${cityssm.escapeHTML(contractOccupant.occupantCity ?? '')}, `} + ${cityssm.escapeHTML(contractOccupant.occupantProvince ?? '')}
+ ${cityssm.escapeHTML(contractOccupant.occupantPostalCode ?? '')} - ${(burialSiteContractOccupant.occupantPhoneNumber ?? '') === '' + ${(contractOccupant.occupantPhoneNumber ?? '') === '' ? '' - : `${cityssm.escapeHTML(burialSiteContractOccupant.occupantPhoneNumber ?? '')}
`} - ${(burialSiteContractOccupant.occupantEmailAddress ?? '') === '' + : `${cityssm.escapeHTML(contractOccupant.occupantPhoneNumber ?? '')}
`} + ${(contractOccupant.occupantEmailAddress ?? '') === '' ? '' - : cityssm.escapeHTML(burialSiteContractOccupant.occupantEmailAddress ?? '')} + : cityssm.escapeHTML(contractOccupant.occupantEmailAddress ?? '')} - - ${cityssm.escapeHTML(burialSiteContractOccupant.occupantComment ?? '')} + : contractOccupant.occupantCommentTitle ?? '')}"> + ${cityssm.escapeHTML(contractOccupant.occupantComment ?? '')}
@@ -690,7 +690,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); occupantsContainer.append(tableElement); } if (isCreate) { - const lotOccupantTypeIdElement = document.querySelector('#burialSiteContract--lotOccupantTypeId'); + const lotOccupantTypeIdElement = document.querySelector('#contract--lotOccupantTypeId'); lotOccupantTypeIdElement.addEventListener('change', () => { const occupantFields = formElement.querySelectorAll("[data-table='LotOccupancyOccupant']"); for (const occupantField of occupantFields) { @@ -702,7 +702,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); occupantCommentTitle = 'Comment'; } ; - formElement.querySelector('#burialSiteContract--occupantCommentTitle').textContent = occupantCommentTitle; + formElement.querySelector('#contract--occupantCommentTitle').textContent = occupantCommentTitle; }); } else { @@ -719,7 +719,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); cityssm.postJSON(`${los.urlPrefix}/contracts/doAddLotOccupancyOccupant`, formOrObject, (rawResponseJSON) => { const responseJSON = rawResponseJSON; if (responseJSON.success) { - burialSiteContractOccupants = responseJSON.burialSiteContractOccupants; + contractOccupants = responseJSON.contractOccupants; addCloseModalFunction(); renderLotOccupancyOccupants(); } @@ -743,7 +743,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const occupant = pastOccupantSearchResults[Number.parseInt(panelBlockElement.dataset.index ?? '', 10)]; const lotOccupantTypeId = (panelBlockElement .closest('.modal') - ?.querySelector('#burialSiteContractOccupantCopy--lotOccupantTypeId')).value; + ?.querySelector('#contractOccupantCopy--lotOccupantTypeId')).value; if (lotOccupantTypeId === '') { bulmaJS.alert({ title: `No ${los.escapedAliases.Occupant} Type Selected`, @@ -753,13 +753,13 @@ Object.defineProperty(exports, "__esModule", { value: true }); } else { occupant.lotOccupantTypeId = Number.parseInt(lotOccupantTypeId, 10); - occupant.burialSiteContractId = Number.parseInt(burialSiteContractId, 10); + occupant.contractId = Number.parseInt(contractId, 10); addOccupant(occupant); } } function searchOccupants(event) { event.preventDefault(); - if (searchFormElement.querySelector('#burialSiteContractOccupantCopy--searchFilter').value === '') { + if (searchFormElement.querySelector('#contractOccupantCopy--searchFilter').value === '') { searchResultsElement.innerHTML = `

Enter a partial name or address in the search field above.

`; @@ -804,12 +804,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); searchResultsElement.append(panelElement); }); } - cityssm.openHtmlModal('burialSiteContract-addOccupant', { + cityssm.openHtmlModal('contract-addOccupant', { onshow(modalElement) { los.populateAliases(modalElement); - modalElement.querySelector('#burialSiteContractOccupantAdd--burialSiteContractId').value = burialSiteContractId; - const lotOccupantTypeSelectElement = modalElement.querySelector('#burialSiteContractOccupantAdd--lotOccupantTypeId'); - const lotOccupantTypeCopySelectElement = modalElement.querySelector('#burialSiteContractOccupantCopy--lotOccupantTypeId'); + modalElement.querySelector('#contractOccupantAdd--contractId').value = contractId; + const lotOccupantTypeSelectElement = modalElement.querySelector('#contractOccupantAdd--lotOccupantTypeId'); + const lotOccupantTypeCopySelectElement = modalElement.querySelector('#contractOccupantCopy--lotOccupantTypeId'); for (const lotOccupantType of exports.lotOccupantTypes) { const optionElement = document.createElement('option'); optionElement.value = lotOccupantType.lotOccupantTypeId.toString(); @@ -822,18 +822,18 @@ Object.defineProperty(exports, "__esModule", { value: true }); lotOccupantTypeCopySelectElement.append(optionElement.cloneNode(true)); } ; - modalElement.querySelector('#burialSiteContractOccupantAdd--occupantCity').value = exports.occupantCityDefault; - modalElement.querySelector('#burialSiteContractOccupantAdd--occupantProvince').value = exports.occupantProvinceDefault; + modalElement.querySelector('#contractOccupantAdd--occupantCity').value = exports.occupantCityDefault; + modalElement.querySelector('#contractOccupantAdd--occupantProvince').value = exports.occupantProvinceDefault; }, onshown(modalElement, closeModalFunction) { bulmaJS.toggleHtmlClipped(); bulmaJS.init(modalElement); - const lotOccupantTypeIdElement = modalElement.querySelector('#burialSiteContractOccupantAdd--lotOccupantTypeId'); + const lotOccupantTypeIdElement = modalElement.querySelector('#contractOccupantAdd--lotOccupantTypeId'); lotOccupantTypeIdElement.focus(); lotOccupantTypeIdElement.addEventListener('change', () => { const fontAwesomeIconClass = lotOccupantTypeIdElement.selectedOptions[0].dataset .fontAwesomeIconClass ?? 'user'; - modalElement.querySelector('#burialSiteContractOccupantAdd--fontAwesomeIconClass').innerHTML = + modalElement.querySelector('#contractOccupantAdd--fontAwesomeIconClass').innerHTML = ``; let occupantCommentTitle = lotOccupantTypeIdElement.selectedOptions[0].dataset .occupantCommentTitle ?? ''; @@ -841,16 +841,16 @@ Object.defineProperty(exports, "__esModule", { value: true }); occupantCommentTitle = 'Comment'; } ; - modalElement.querySelector('#burialSiteContractOccupantAdd--occupantCommentTitle').textContent = occupantCommentTitle; + modalElement.querySelector('#contractOccupantAdd--occupantCommentTitle').textContent = occupantCommentTitle; }); - addFormElement = modalElement.querySelector('#form--burialSiteContractOccupantAdd'); + addFormElement = modalElement.querySelector('#form--contractOccupantAdd'); addFormElement.addEventListener('submit', addOccupantFromForm); - searchResultsElement = modalElement.querySelector('#burialSiteContractOccupantCopy--searchResults'); - searchFormElement = modalElement.querySelector('#form--burialSiteContractOccupantCopy'); + searchResultsElement = modalElement.querySelector('#contractOccupantCopy--searchResults'); + searchFormElement = modalElement.querySelector('#form--contractOccupantCopy'); searchFormElement.addEventListener('submit', (formEvent) => { formEvent.preventDefault(); }); - modalElement.querySelector('#burialSiteContractOccupantCopy--searchFilter').addEventListener('change', searchOccupants); + modalElement.querySelector('#contractOccupantCopy--searchFilter').addEventListener('change', searchOccupants); addCloseModalFunction = closeModalFunction; }, onremoved() { @@ -866,23 +866,23 @@ Object.defineProperty(exports, "__esModule", { value: true }); */ ; (() => { - let burialSiteContractComments = exports.burialSiteContractComments; - delete exports.burialSiteContractComments; + let contractComments = exports.contractComments; + delete exports.contractComments; function openEditLotOccupancyComment(clickEvent) { - const burialSiteContractCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset - .burialSiteContractCommentId ?? '', 10); - const burialSiteContractComment = burialSiteContractComments.find((currentLotOccupancyComment) => { - return (currentLotOccupancyComment.burialSiteContractCommentId === - burialSiteContractCommentId); + const contractCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset + .contractCommentId ?? '', 10); + const contractComment = contractComments.find((currentLotOccupancyComment) => { + return (currentLotOccupancyComment.contractCommentId === + contractCommentId); }); let editFormElement; let editCloseModalFunction; function editComment(submitEvent) { submitEvent.preventDefault(); - cityssm.postJSON(`${los.urlPrefix}/contracts/doUpdateBurialSiteContractComment`, editFormElement, (rawResponseJSON) => { + cityssm.postJSON(`${los.urlPrefix}/contracts/doUpdateContractComment`, editFormElement, (rawResponseJSON) => { const responseJSON = rawResponseJSON; if (responseJSON.success) { - burialSiteContractComments = responseJSON.burialSiteContractComments ?? []; + contractComments = responseJSON.contractComments ?? []; editCloseModalFunction(); renderLotOccupancyComments(); } @@ -895,27 +895,27 @@ Object.defineProperty(exports, "__esModule", { value: true }); } }); } - cityssm.openHtmlModal('burialSiteContract-editComment', { + cityssm.openHtmlModal('contract-editComment', { onshow(modalElement) { los.populateAliases(modalElement); - modalElement.querySelector('#burialSiteContractCommentEdit--burialSiteContractId').value = burialSiteContractId; - modalElement.querySelector('#burialSiteContractCommentEdit--burialSiteContractCommentId').value = burialSiteContractCommentId.toString(); - modalElement.querySelector('#burialSiteContractCommentEdit--burialSiteContractComment').value = burialSiteContractComment.burialSiteContractComment ?? ''; - const burialSiteContractCommentDateStringElement = modalElement.querySelector('#burialSiteContractCommentEdit--burialSiteContractCommentDateString'); - burialSiteContractCommentDateStringElement.value = - burialSiteContractComment.burialSiteContractCommentDateString ?? ''; + modalElement.querySelector('#contractCommentEdit--contractId').value = contractId; + modalElement.querySelector('#contractCommentEdit--contractCommentId').value = contractCommentId.toString(); + modalElement.querySelector('#contractCommentEdit--contractComment').value = contractComment.contractComment ?? ''; + const contractCommentDateStringElement = modalElement.querySelector('#contractCommentEdit--contractCommentDateString'); + contractCommentDateStringElement.value = + contractComment.contractCommentDateString ?? ''; const currentDateString = cityssm.dateToString(new Date()); - burialSiteContractCommentDateStringElement.max = - burialSiteContractComment.burialSiteContractCommentDateString <= + contractCommentDateStringElement.max = + contractComment.contractCommentDateString <= currentDateString ? currentDateString - : burialSiteContractComment.burialSiteContractCommentDateString ?? ''; - modalElement.querySelector('#burialSiteContractCommentEdit--burialSiteContractCommentTimeString').value = burialSiteContractComment.burialSiteContractCommentTimeString ?? ''; + : contractComment.contractCommentDateString ?? ''; + modalElement.querySelector('#contractCommentEdit--contractCommentTimeString').value = contractComment.contractCommentTimeString ?? ''; }, onshown(modalElement, closeModalFunction) { bulmaJS.toggleHtmlClipped(); los.initializeDatePickers(modalElement); - modalElement.querySelector('#burialSiteContractCommentEdit--burialSiteContractComment').focus(); + modalElement.querySelector('#contractCommentEdit--contractComment').focus(); editFormElement = modalElement.querySelector('form'); editFormElement.addEventListener('submit', editComment); editCloseModalFunction = closeModalFunction; @@ -926,16 +926,16 @@ Object.defineProperty(exports, "__esModule", { value: true }); }); } function deleteLotOccupancyComment(clickEvent) { - const burialSiteContractCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset - .burialSiteContractCommentId ?? '', 10); + const contractCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr')?.dataset + .contractCommentId ?? '', 10); function doDelete() { - cityssm.postJSON(`${los.urlPrefix}/contracts/doDeleteBurialSiteContractComment`, { - burialSiteContractId, - burialSiteContractCommentId + cityssm.postJSON(`${los.urlPrefix}/contracts/doDeleteContractComment`, { + contractId, + contractCommentId }, (rawResponseJSON) => { const responseJSON = rawResponseJSON; if (responseJSON.success) { - burialSiteContractComments = responseJSON.burialSiteContractComments; + contractComments = responseJSON.contractComments; renderLotOccupancyComments(); } else { @@ -958,8 +958,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); }); } function renderLotOccupancyComments() { - const containerElement = document.querySelector('#container--burialSiteContractComments'); - if (burialSiteContractComments.length === 0) { + const containerElement = document.querySelector('#container--contractComments'); + if (contractComments.length === 0) { containerElement.innerHTML = `

There are no comments associated with this record.

`; @@ -974,18 +974,18 @@ Object.defineProperty(exports, "__esModule", { value: true }); Options `; - for (const burialSiteContractComment of burialSiteContractComments) { + for (const contractComment of contractComments) { const tableRowElement = document.createElement('tr'); - tableRowElement.dataset.burialSiteContractCommentId = - burialSiteContractComment.burialSiteContractCommentId?.toString(); - tableRowElement.innerHTML = `${cityssm.escapeHTML(burialSiteContractComment.recordCreate_userName ?? '')} + tableRowElement.dataset.contractCommentId = + contractComment.contractCommentId?.toString(); + tableRowElement.innerHTML = `${cityssm.escapeHTML(contractComment.recordCreate_userName ?? '')} - ${cityssm.escapeHTML(burialSiteContractComment.burialSiteContractCommentDateString ?? '')} - ${cityssm.escapeHTML(burialSiteContractComment.burialSiteContractCommentTime === 0 + ${cityssm.escapeHTML(contractComment.contractCommentDateString ?? '')} + ${cityssm.escapeHTML(contractComment.contractCommentTime === 0 ? '' - : burialSiteContractComment.burialSiteContractCommentTimePeriodString ?? '')} + : contractComment.contractCommentTimePeriodString ?? '')} - ${cityssm.escapeHTML(burialSiteContractComment.burialSiteContractComment ?? '')} + ${cityssm.escapeHTML(contractComment.contractComment ?? '')}
- ${cityssm.escapeHTML(burialSiteContract.occupancyType ?? '')} + ${cityssm.escapeHTML(contract.occupancyType ?? '')} `; - if (burialSiteContract.lotId) { - rowElement.insertAdjacentHTML('beforeend', `${cityssm.escapeHTML(burialSiteContract.lotName ?? '')}`); + if (contract.lotId) { + rowElement.insertAdjacentHTML('beforeend', `${cityssm.escapeHTML(contract.lotName ?? '')}`); } else { // eslint-disable-next-line no-unsanitized/method @@ -550,25 +550,25 @@ Object.defineProperty(exports, "__esModule", { value: true }); } // eslint-disable-next-line no-unsanitized/method rowElement.insertAdjacentHTML('beforeend', ` - ${burialSiteContract.contractStartDateString} + ${contract.contractStartDateString} - ${burialSiteContract.contractEndDate - ? burialSiteContract.contractEndDateString + ${contract.contractEndDate + ? contract.contractEndDateString : '(No End Date)'} - ${burialSiteContract.burialSiteContractOccupants.length === 0 + ${contract.contractOccupants.length === 0 ? ` (No ${cityssm.escapeHTML(los.escapedAliases.Occupants)}) ` - : cityssm.escapeHTML(`${burialSiteContract.burialSiteContractOccupants[0].occupantName} - ${burialSiteContract.burialSiteContractOccupants[0] + : cityssm.escapeHTML(`${contract.contractOccupants[0].occupantName} + ${contract.contractOccupants[0] .occupantFamilyName}`) + - (burialSiteContract.burialSiteContractOccupants.length > 1 + (contract.contractOccupants.length > 1 ? ` plus - ${(burialSiteContract.burialSiteContractOccupants.length - 1).toString()}` + ${(contract.contractOccupants.length - 1).toString()}` : '')}`); rowElement - .querySelector('.button--addBurialSiteContract') + .querySelector('.button--addContract') ?.addEventListener('click', doAddLotOccupancy); searchResultsContainerElement .querySelector('tbody') @@ -576,26 +576,26 @@ Object.defineProperty(exports, "__esModule", { value: true }); } }); } - cityssm.openHtmlModal('workOrder-addBurialSiteContract', { + cityssm.openHtmlModal('workOrder-addContract', { onshow(modalElement) { los.populateAliases(modalElement); searchFormElement = modalElement.querySelector('form'); - searchResultsContainerElement = modalElement.querySelector('#resultsContainer--burialSiteContractAdd'); - modalElement.querySelector('#burialSiteContractSearch--notWorkOrderId').value = workOrderId; - modalElement.querySelector('#burialSiteContractSearch--occupancyEffectiveDateString').value = document.querySelector('#workOrderEdit--workOrderOpenDateString').value; + searchResultsContainerElement = modalElement.querySelector('#resultsContainer--contractAdd'); + modalElement.querySelector('#contractSearch--notWorkOrderId').value = workOrderId; + modalElement.querySelector('#contractSearch--occupancyEffectiveDateString').value = document.querySelector('#workOrderEdit--workOrderOpenDateString').value; doSearch(); }, onshown(modalElement) { bulmaJS.toggleHtmlClipped(); - const occupantNameElement = modalElement.querySelector('#burialSiteContractSearch--occupantName'); + const occupantNameElement = modalElement.querySelector('#contractSearch--occupantName'); occupantNameElement.addEventListener('change', doSearch); occupantNameElement.focus(); - modalElement.querySelector('#burialSiteContractSearch--lotName').addEventListener('change', doSearch); + modalElement.querySelector('#contractSearch--lotName').addEventListener('change', doSearch); searchFormElement.addEventListener('submit', doSearch); }, onremoved() { bulmaJS.toggleHtmlClipped(); - document.querySelector('#button--addBurialSiteContract').focus(); + document.querySelector('#button--addContract').focus(); } }); }); diff --git a/public/javascripts/workOrder.edit.ts b/public/javascripts/workOrder.edit.ts index d9911c82..9c8f6d84 100644 --- a/public/javascripts/workOrder.edit.ts +++ b/public/javascripts/workOrder.edit.ts @@ -220,33 +220,33 @@ declare const exports: Record let workOrderLots = exports.workOrderLots as Lot[] delete exports.workOrderLots - let workOrderBurialSiteContracts = - exports.workOrderBurialSiteContracts as LotOccupancy[] - delete exports.workOrderBurialSiteContracts + let workOrderContracts = + exports.workOrderContracts as LotOccupancy[] + delete exports.workOrderContracts function deleteLotOccupancy(clickEvent: Event): void { - const burialSiteContractId = ( + const contractId = ( (clickEvent.currentTarget as HTMLElement).closest( - '.container--burialSiteContract' + '.container--contract' ) as HTMLElement - ).dataset.burialSiteContractId + ).dataset.contractId function doDelete(): void { cityssm.postJSON( - `${los.urlPrefix}/workOrders/doDeleteWorkOrderBurialSiteContract`, + `${los.urlPrefix}/workOrders/doDeleteWorkOrderContract`, { workOrderId, - burialSiteContractId + contractId }, (rawResponseJSON) => { const responseJSON = rawResponseJSON as { success: boolean errorMessage?: string - workOrderBurialSiteContracts: LotOccupancy[] + workOrderContracts: LotOccupancy[] } if (responseJSON.success) { - workOrderBurialSiteContracts = responseJSON.workOrderBurialSiteContracts + workOrderContracts = responseJSON.workOrderContracts renderRelatedLotsAndOccupancies() } else { bulmaJS.alert({ @@ -305,25 +305,25 @@ declare const exports: Record ) } - function addBurialSiteContract( - burialSiteContractId: number | string, + function addContract( + contractId: number | string, callbackFunction?: (success?: boolean) => void ): void { cityssm.postJSON( - `${los.urlPrefix}/workOrders/doAddWorkOrderBurialSiteContract`, + `${los.urlPrefix}/workOrders/doAddWorkOrderContract`, { workOrderId, - burialSiteContractId + contractId }, (rawResponseJSON) => { const responseJSON = rawResponseJSON as { success: boolean errorMessage?: string - workOrderBurialSiteContracts: LotOccupancy[] + workOrderContracts: LotOccupancy[] } if (responseJSON.success) { - workOrderBurialSiteContracts = responseJSON.workOrderBurialSiteContracts + workOrderContracts = responseJSON.workOrderContracts renderRelatedLotsAndOccupancies() } else { bulmaJS.alert({ @@ -355,9 +355,9 @@ declare const exports: Record document.querySelector( ".tabs a[href='#relatedTab--lotOccupancies'] .tag" ) as HTMLElement - ).textContent = workOrderBurialSiteContracts.length.toString() + ).textContent = workOrderContracts.length.toString() - if (workOrderBurialSiteContracts.length === 0) { + if (workOrderContracts.length === 0) { // eslint-disable-next-line no-unsanitized/property occupanciesContainerElement.innerHTML = `

There are no ${los.escapedAliases.occupancies} associated with this work order.

@@ -382,20 +382,20 @@ declare const exports: Record const currentDateString = cityssm.dateToString(new Date()) - for (const burialSiteContract of workOrderBurialSiteContracts) { + for (const contract of workOrderContracts) { const rowElement = document.createElement('tr') - rowElement.className = 'container--burialSiteContract' - rowElement.dataset.burialSiteContractId = - burialSiteContract.burialSiteContractId.toString() + rowElement.className = 'container--contract' + rowElement.dataset.contractId = + contract.contractId.toString() const isActive = !( - burialSiteContract.contractEndDate && - burialSiteContract.contractEndDateString! < currentDateString + contract.contractEndDate && + contract.contractEndDateString! < currentDateString ) const hasLotRecord = - burialSiteContract.lotId && - workOrderLots.some((lot) => burialSiteContract.lotId === lot.lotId) + contract.lotId && + workOrderLots.some((lot) => contract.lotId === lot.lotId) // eslint-disable-next-line no-unsanitized/property rowElement.innerHTML = ` @@ -405,23 +405,23 @@ declare const exports: Record : `` } - - ${cityssm.escapeHTML(burialSiteContract.occupancyType ?? '')} + + ${cityssm.escapeHTML(contract.occupancyType ?? '')}
- #${burialSiteContract.burialSiteContractId} + #${contract.contractId} ` - if (burialSiteContract.lotId) { + if (contract.lotId) { // eslint-disable-next-line no-unsanitized/method rowElement.insertAdjacentHTML( 'beforeend', ` - ${cityssm.escapeHTML(burialSiteContract.lotName ?? '')} + ${cityssm.escapeHTML(contract.lotName ?? '')} ${ hasLotRecord ? '' : ` - ${cityssm.escapeHTML(burialSiteContract.occupancyType ?? '')} + ${cityssm.escapeHTML(contract.occupancyType ?? '')} ` - if (burialSiteContract.lotId) { + if (contract.lotId) { rowElement.insertAdjacentHTML( 'beforeend', - `${cityssm.escapeHTML(burialSiteContract.lotName ?? '')}` + `${cityssm.escapeHTML(contract.lotName ?? '')}` ) } else { // eslint-disable-next-line no-unsanitized/method @@ -817,39 +817,39 @@ declare const exports: Record rowElement.insertAdjacentHTML( 'beforeend', ` - ${burialSiteContract.contractStartDateString} + ${contract.contractStartDateString} ${ - burialSiteContract.contractEndDate - ? burialSiteContract.contractEndDateString + contract.contractEndDate + ? contract.contractEndDateString : '(No End Date)' } ${ - burialSiteContract.burialSiteContractOccupants!.length === 0 + contract.contractOccupants!.length === 0 ? ` (No ${cityssm.escapeHTML( los.escapedAliases.Occupants )}) ` : cityssm.escapeHTML( - `${burialSiteContract.burialSiteContractOccupants![0].occupantName} + `${contract.contractOccupants![0].occupantName} ${ - burialSiteContract.burialSiteContractOccupants![0] + contract.contractOccupants![0] .occupantFamilyName }` ) + - (burialSiteContract.burialSiteContractOccupants!.length > 1 + (contract.contractOccupants!.length > 1 ? ` plus ${( - burialSiteContract.burialSiteContractOccupants!.length - 1 + contract.contractOccupants!.length - 1 ).toString()}` : '') }` ) rowElement - .querySelector('.button--addBurialSiteContract') + .querySelector('.button--addContract') ?.addEventListener('click', doAddLotOccupancy) searchResultsContainerElement @@ -860,7 +860,7 @@ declare const exports: Record ) } - cityssm.openHtmlModal('workOrder-addBurialSiteContract', { + cityssm.openHtmlModal('workOrder-addContract', { onshow(modalElement) { los.populateAliases(modalElement) @@ -869,16 +869,16 @@ declare const exports: Record ) as HTMLFormElement searchResultsContainerElement = modalElement.querySelector( - '#resultsContainer--burialSiteContractAdd' + '#resultsContainer--contractAdd' ) as HTMLElement ;( modalElement.querySelector( - '#burialSiteContractSearch--notWorkOrderId' + '#contractSearch--notWorkOrderId' ) as HTMLInputElement ).value = workOrderId ;( modalElement.querySelector( - '#burialSiteContractSearch--occupancyEffectiveDateString' + '#contractSearch--occupancyEffectiveDateString' ) as HTMLInputElement ).value = ( document.querySelector( @@ -892,14 +892,14 @@ declare const exports: Record bulmaJS.toggleHtmlClipped() const occupantNameElement = modalElement.querySelector( - '#burialSiteContractSearch--occupantName' + '#contractSearch--occupantName' ) as HTMLInputElement occupantNameElement.addEventListener('change', doSearch) occupantNameElement.focus() ;( modalElement.querySelector( - '#burialSiteContractSearch--lotName' + '#contractSearch--lotName' ) as HTMLInputElement ).addEventListener('change', doSearch) @@ -909,7 +909,7 @@ declare const exports: Record bulmaJS.toggleHtmlClipped() ;( document.querySelector( - '#button--addBurialSiteContract' + '#button--addContract' ) as HTMLButtonElement ).focus() } diff --git a/public/javascripts/workOrder.milestoneCalendar.js b/public/javascripts/workOrder.milestoneCalendar.js index 6180f0b4..2eb21286 100644 --- a/public/javascripts/workOrder.milestoneCalendar.js +++ b/public/javascripts/workOrder.milestoneCalendar.js @@ -40,9 +40,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); milestone.workOrderMilestoneDateString < currentDate) { panelBlockElement.classList.add('has-background-warning-light'); } - let burialSiteContractHTML = ''; + let contractHTML = ''; for (const lot of milestone.workOrderLots ?? []) { - burialSiteContractHTML += `
  • `; } - for (const burialSiteContract of milestone.workOrderBurialSiteContracts ?? []) { - for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) { - burialSiteContractHTML += `

  • ${cityssm.escapeHTML(milestone.workOrderDescription ?? '')}
  • - ${burialSiteContractHTML === '' + ${contractHTML === '' ? '' - : `
      ${burialSiteContractHTML}
    `}
    `; + : `
      ${contractHTML}
    `}
    `; currentPanelElement.append(panelBlockElement); } milestoneCalendarContainerElement.append(currentPanelElement); diff --git a/public/javascripts/workOrder.milestoneCalendar.ts b/public/javascripts/workOrder.milestoneCalendar.ts index 16ea02b2..99c93e32 100644 --- a/public/javascripts/workOrder.milestoneCalendar.ts +++ b/public/javascripts/workOrder.milestoneCalendar.ts @@ -77,10 +77,10 @@ declare const exports: Record panelBlockElement.classList.add('has-background-warning-light') } - let burialSiteContractHTML = '' + let contractHTML = '' for (const lot of milestone.workOrderLots ?? []) { - burialSiteContractHTML += `
  • ` } - for (const burialSiteContract of milestone.workOrderBurialSiteContracts ?? []) { - for (const occupant of burialSiteContract.burialSiteContractOccupants ?? []) { - burialSiteContractHTML += `
  • @@ -138,9 +138,9 @@ declare const exports: Record ${cityssm.escapeHTML(milestone.workOrderDescription ?? '')}
  • ${ - burialSiteContractHTML === '' + contractHTML === '' ? '' - : `
      ${burialSiteContractHTML}
    ` + : `
      ${contractHTML}
    ` }
    ` ;(currentPanelElement as HTMLElement).append(panelBlockElement) } diff --git a/public/javascripts/workOrder.search.js b/public/javascripts/workOrder.search.js index 91d921ec..8307f492 100644 --- a/public/javascripts/workOrder.search.js +++ b/public/javascripts/workOrder.search.js @@ -31,8 +31,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); : lot.lotName ?? '')} `; } - for (const occupancy of workOrder.workOrderBurialSiteContracts ?? []) { - for (const occupant of occupancy.burialSiteContractOccupants ?? []) { + for (const occupancy of workOrder.workOrderContracts ?? []) { + for (const occupant of occupancy.contractOccupants ?? []) { relatedHTML += `
  • diff --git a/public/javascripts/workOrder.search.ts b/public/javascripts/workOrder.search.ts index fb5291b7..6cd87b87 100644 --- a/public/javascripts/workOrder.search.ts +++ b/public/javascripts/workOrder.search.ts @@ -65,8 +65,8 @@ declare const exports: Record
  • ` } - for (const occupancy of workOrder.workOrderBurialSiteContracts ?? []) { - for (const occupant of occupancy.burialSiteContractOccupants ?? []) { + for (const occupancy of workOrder.workOrderContracts ?? []) { + for (const occupant of occupancy.contractOccupants ?? []) { relatedHTML += `
  • occupancyTypeField.occupancyTypeField === 'Funeral Date').contractTypeFieldId, - burialSiteContractFieldValue + contractFieldValue }, user); } if (occupancyType.occupancyType !== 'Cremation') { if (masterRow.CM_CONTAINER_TYPE !== '') { - await addOrUpdateBurialSiteContractField({ - burialSiteContractId: deceasedburialSiteContractId, + await addOrUpdateContractField({ + contractId: deceasedcontractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Container Type').contractTypeFieldId, - burialSiteContractFieldValue: masterRow.CM_CONTAINER_TYPE + contractFieldValue: masterRow.CM_CONTAINER_TYPE }, user); } if (masterRow.CM_COMMITTAL_TYPE !== '') { @@ -361,41 +361,41 @@ async function importFromMasterCSV() { if (commitalType === 'GS') { commitalType = 'Graveside'; } - await addOrUpdateBurialSiteContractField({ - burialSiteContractId: deceasedburialSiteContractId, + await addOrUpdateContractField({ + contractId: deceasedcontractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Committal Type').contractTypeFieldId, - burialSiteContractFieldValue: commitalType + contractFieldValue: commitalType }, user); } } if (masterRow.CM_REMARK1 !== '') { - await addBurialSiteContractComment({ - burialSiteContractId: deceasedburialSiteContractId, - burialSiteContractCommentDateString: deceasedcontractStartDateString, - burialSiteContractCommentTimeString: '00:00', - burialSiteContractComment: masterRow.CM_REMARK1 + await addContractComment({ + contractId: deceasedcontractId, + contractCommentDateString: deceasedcontractStartDateString, + contractCommentTimeString: '00:00', + contractComment: masterRow.CM_REMARK1 }, user); } if (masterRow.CM_REMARK2 !== '') { - await addBurialSiteContractComment({ - burialSiteContractId: deceasedburialSiteContractId, - burialSiteContractCommentDateString: deceasedcontractStartDateString, - burialSiteContractCommentTimeString: '00:00', - burialSiteContractComment: masterRow.CM_REMARK2 + await addContractComment({ + contractId: deceasedcontractId, + contractCommentDateString: deceasedcontractStartDateString, + contractCommentTimeString: '00:00', + contractComment: masterRow.CM_REMARK2 }, user); } if (masterRow.CM_WORK_ORDER.trim() !== '') { - await addBurialSiteContractComment({ - burialSiteContractId: deceasedburialSiteContractId, - burialSiteContractCommentDateString: deceasedcontractStartDateString, - burialSiteContractCommentTimeString: '00:00', - burialSiteContractComment: `Imported Contract #${masterRow.CM_WORK_ORDER}` + await addContractComment({ + contractId: deceasedcontractId, + contractCommentDateString: deceasedcontractStartDateString, + contractCommentTimeString: '00:00', + contractComment: `Imported Contract #${masterRow.CM_WORK_ORDER}` }, user); } await updateBurialSiteStatus(burialSiteId ?? '', importIds.takenburialSiteStatusId, user); if (masterRow.CM_PRENEED_OWNER !== '') { - await addBurialSiteContractOccupant({ - burialSiteContractId: deceasedburialSiteContractId, + await addContractOccupant({ + contractId: deceasedcontractId, lotOccupantTypeId: importIds.preneedOwnerLotOccupantTypeId, occupantName: masterRow.CM_PRENEED_OWNER, occupantFamilyName: '', @@ -476,9 +476,9 @@ async function importFromPrepaidCSV() { await updateBurialSiteStatus(lot.lotId, importIds.reservedburialSiteStatusId, user); } const contractStartDateString = formatDateString(prepaidRow.CMPP_PURCH_YR, prepaidRow.CMPP_PURCH_MON, prepaidRow.CMPP_PURCH_DAY); - let burialSiteContractId; + let contractId; if (lot) { - const possibleLotOccupancies = await getBurialSiteContracts({ + const possibleLotOccupancies = await getContracts({ lotId: lot.lotId, contractTypeId: importIds.preneedOccupancyType.contractTypeId, occupantName: prepaidRow.CMPP_PREPAID_FOR_NAME, @@ -491,18 +491,18 @@ async function importFromPrepaidCSV() { offset: 0 }); if (possibleLotOccupancies.lotOccupancies.length > 0) { - burialSiteContractId = - possibleLotOccupancies.lotOccupancies[0].burialSiteContractId; + contractId = + possibleLotOccupancies.lotOccupancies[0].contractId; } } - burialSiteContractId ||= await addBurialSiteContract({ + contractId ||= await addContract({ lotId: lot ? lot.lotId : '', contractTypeId: importIds.preneedOccupancyType.contractTypeId, contractStartDateString, contractEndDateString: '' }, user); - await addBurialSiteContractOccupant({ - burialSiteContractId, + await addContractOccupant({ + contractId, lotOccupantTypeId: importIds.preneedOwnerLotOccupantTypeId, occupantName: prepaidRow.CMPP_PREPAID_FOR_NAME, occupantFamilyName: '', @@ -515,8 +515,8 @@ async function importFromPrepaidCSV() { occupantEmailAddress: '' }, user); if (prepaidRow.CMPP_ARRANGED_BY_NAME) { - await addBurialSiteContractOccupant({ - burialSiteContractId, + await addContractOccupant({ + contractId, lotOccupantTypeId: importIds.purchaserLotOccupantTypeId, occupantName: prepaidRow.CMPP_ARRANGED_BY_NAME, occupantFamilyName: '', @@ -530,8 +530,8 @@ async function importFromPrepaidCSV() { }, user); } if (prepaidRow.CMPP_FEE_GRAV_SD !== '0.0') { - await addBurialSiteContractFee({ - burialSiteContractId, + await addContractFee({ + contractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_GRAV_SD'), quantity: 1, feeAmount: prepaidRow.CMPP_FEE_GRAV_SD, @@ -539,8 +539,8 @@ async function importFromPrepaidCSV() { }, user); } if (prepaidRow.CMPP_FEE_GRAV_DD !== '0.0') { - await addBurialSiteContractFee({ - burialSiteContractId, + await addContractFee({ + contractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_GRAV_DD'), quantity: 1, feeAmount: prepaidRow.CMPP_FEE_GRAV_DD, @@ -548,8 +548,8 @@ async function importFromPrepaidCSV() { }, user); } if (prepaidRow.CMPP_FEE_CHAP_SD !== '0.0') { - await addBurialSiteContractFee({ - burialSiteContractId, + await addContractFee({ + contractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_CHAP_SD'), quantity: 1, feeAmount: prepaidRow.CMPP_FEE_CHAP_SD, @@ -557,8 +557,8 @@ async function importFromPrepaidCSV() { }, user); } if (prepaidRow.CMPP_FEE_CHAP_DD !== '0.0') { - await addBurialSiteContractFee({ - burialSiteContractId, + await addContractFee({ + contractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_CHAP_DD'), quantity: 1, feeAmount: prepaidRow.CMPP_FEE_CHAP_DD, @@ -566,8 +566,8 @@ async function importFromPrepaidCSV() { }, user); } if (prepaidRow.CMPP_FEE_ENTOMBMENT !== '0.0') { - await addBurialSiteContractFee({ - burialSiteContractId, + await addContractFee({ + contractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_ENTOMBMENT'), quantity: 1, feeAmount: prepaidRow.CMPP_FEE_ENTOMBMENT, @@ -575,8 +575,8 @@ async function importFromPrepaidCSV() { }, user); } if (prepaidRow.CMPP_FEE_CREM !== '0.0') { - await addBurialSiteContractFee({ - burialSiteContractId, + await addContractFee({ + contractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_CREM'), quantity: 1, feeAmount: prepaidRow.CMPP_FEE_CREM, @@ -584,8 +584,8 @@ async function importFromPrepaidCSV() { }, user); } if (prepaidRow.CMPP_FEE_NICHE !== '0.0') { - await addBurialSiteContractFee({ - burialSiteContractId, + await addContractFee({ + contractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_NICHE'), quantity: 1, feeAmount: prepaidRow.CMPP_FEE_NICHE, @@ -594,8 +594,8 @@ async function importFromPrepaidCSV() { } if (prepaidRow.CMPP_FEE_DISINTERMENT !== '0.0' && prepaidRow.CMPP_FEE_DISINTERMENT !== '20202.02') { - await addBurialSiteContractFee({ - burialSiteContractId, + await addContractFee({ + contractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_DISINTERMENT'), quantity: 1, feeAmount: prepaidRow.CMPP_FEE_DISINTERMENT, @@ -622,25 +622,25 @@ async function importFromPrepaidCSV() { Number.parseFloat(prepaidRow.CMPP_GST_DISINTERMENT === '20202.02' ? '0' : prepaidRow.CMPP_GST_DISINTERMENT); - await addBurialSiteContractTransaction({ - burialSiteContractId, + await addContractTransaction({ + contractId, externalReceiptNumber: '', transactionAmount, transactionDateString: contractStartDateString, transactionNote: `Order Number: ${prepaidRow.CMPP_ORDER_NO}` }, user); if (prepaidRow.CMPP_REMARK1) { - await addBurialSiteContractComment({ - burialSiteContractId, - burialSiteContractCommentDateString: contractStartDateString, - burialSiteContractComment: prepaidRow.CMPP_REMARK1 + await addContractComment({ + contractId, + contractCommentDateString: contractStartDateString, + contractComment: prepaidRow.CMPP_REMARK1 }, user); } if (prepaidRow.CMPP_REMARK2) { - await addBurialSiteContractComment({ - burialSiteContractId, - burialSiteContractCommentDateString: contractStartDateString, - burialSiteContractComment: prepaidRow.CMPP_REMARK2 + await addContractComment({ + contractId, + contractCommentDateString: contractStartDateString, + contractComment: prepaidRow.CMPP_REMARK2 }, user); } } @@ -738,14 +738,14 @@ async function importFromWorkOrderCSV() { const occupancyType = lot ? importIds.deceasedOccupancyType : importIds.cremationOccupancyType; - const burialSiteContractId = await addBurialSiteContract({ + const contractId = await addContract({ lotId: lot ? lot.lotId : '', contractTypeId: occupancyType.contractTypeId, contractStartDateString, contractEndDateString: '' }, user); - await addBurialSiteContractOccupant({ - burialSiteContractId, + await addContractOccupant({ + contractId, lotOccupantTypeId: importIds.deceasedLotOccupantTypeId, occupantName: workOrderRow.WO_DECEASED_NAME, occupantFamilyName: '', @@ -758,39 +758,39 @@ async function importFromWorkOrderCSV() { occupantEmailAddress: '' }, user); if (workOrderRow.WO_DEATH_YR !== '') { - const burialSiteContractFieldValue = formatDateString(workOrderRow.WO_DEATH_YR, workOrderRow.WO_DEATH_MON, workOrderRow.WO_DEATH_DAY); - await addOrUpdateBurialSiteContractField({ - burialSiteContractId, + const contractFieldValue = formatDateString(workOrderRow.WO_DEATH_YR, workOrderRow.WO_DEATH_MON, workOrderRow.WO_DEATH_DAY); + await addOrUpdateContractField({ + contractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Date').contractTypeFieldId, - burialSiteContractFieldValue + contractFieldValue }, user); } if (workOrderRow.WO_DEATH_PLACE !== '') { - await addOrUpdateBurialSiteContractField({ - burialSiteContractId, + await addOrUpdateContractField({ + contractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Place').contractTypeFieldId, - burialSiteContractFieldValue: workOrderRow.WO_DEATH_PLACE + contractFieldValue: workOrderRow.WO_DEATH_PLACE }, user); } if (workOrderRow.WO_AGE !== '') { - await addOrUpdateBurialSiteContractField({ - burialSiteContractId, + await addOrUpdateContractField({ + contractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Age').contractTypeFieldId, - burialSiteContractFieldValue: workOrderRow.WO_AGE + contractFieldValue: workOrderRow.WO_AGE }, user); } if (workOrderRow.WO_PERIOD !== '') { const period = importData.getDeathAgePeriod(workOrderRow.WO_PERIOD); - await addOrUpdateBurialSiteContractField({ - burialSiteContractId, + await addOrUpdateContractField({ + contractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Age Period').contractTypeFieldId, - burialSiteContractFieldValue: period + contractFieldValue: period }, user); } if (workOrderRow.WO_FUNERAL_HOME !== '') { const funeralHomeOccupant = importData.getFuneralHomeLotOccupancyOccupantData(workOrderRow.WO_FUNERAL_HOME); - await addBurialSiteContractOccupant({ - burialSiteContractId, + await addContractOccupant({ + contractId, lotOccupantTypeId: funeralHomeOccupant.lotOccupantTypeId, occupantName: funeralHomeOccupant.occupantName, occupantFamilyName: '', @@ -803,32 +803,32 @@ async function importFromWorkOrderCSV() { occupantEmailAddress: funeralHomeOccupant.occupantEmailAddress }, user); /* - addOrUpdateBurialSiteContractField( + addOrUpdateContractField( { - burialSiteContractId: burialSiteContractId, + contractId: contractId, contractTypeFieldId: allContractTypeFields.find((occupancyTypeField) => { return occupancyTypeField.occupancyTypeField === "Funeral Home"; }).contractTypeFieldId, - burialSiteContractFieldValue: workOrderRow.WO_FUNERAL_HOME + contractFieldValue: workOrderRow.WO_FUNERAL_HOME }, user ); */ } if (workOrderRow.WO_FUNERAL_YR !== '') { - const burialSiteContractFieldValue = formatDateString(workOrderRow.WO_FUNERAL_YR, workOrderRow.WO_FUNERAL_MON, workOrderRow.WO_FUNERAL_DAY); - await addOrUpdateBurialSiteContractField({ - burialSiteContractId, + const contractFieldValue = formatDateString(workOrderRow.WO_FUNERAL_YR, workOrderRow.WO_FUNERAL_MON, workOrderRow.WO_FUNERAL_DAY); + await addOrUpdateContractField({ + contractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Funeral Date').contractTypeFieldId, - burialSiteContractFieldValue + contractFieldValue }, user); } if (occupancyType.occupancyType !== 'Cremation') { if (workOrderRow.WO_CONTAINER_TYPE !== '') { - await addOrUpdateBurialSiteContractField({ - burialSiteContractId, + await addOrUpdateContractField({ + contractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Container Type').contractTypeFieldId, - burialSiteContractFieldValue: workOrderRow.WO_CONTAINER_TYPE + contractFieldValue: workOrderRow.WO_CONTAINER_TYPE }, user); } if (workOrderRow.WO_COMMITTAL_TYPE !== '') { @@ -836,16 +836,16 @@ async function importFromWorkOrderCSV() { if (commitalType === 'GS') { commitalType = 'Graveside'; } - await addOrUpdateBurialSiteContractField({ - burialSiteContractId, + await addOrUpdateContractField({ + contractId, contractTypeFieldId: occupancyType.ContractTypeFields.find((occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Committal Type').contractTypeFieldId, - burialSiteContractFieldValue: commitalType + contractFieldValue: commitalType }, user); } } - await addWorkOrderBurialSiteContract({ + await addWorkOrderContract({ workOrderId: workOrder.workOrderId, - burialSiteContractId + contractId }, user); // Milestones let hasIncompleteMilestones = !workOrderRow.WO_CONFIRMATION_IN; diff --git a/temp/legacy.importFromCSV.ts b/temp/legacy.importFromCSV.ts index 542bf241..a6894b8c 100644 --- a/temp/legacy.importFromCSV.ts +++ b/temp/legacy.importFromCSV.ts @@ -13,22 +13,22 @@ import papa from 'papaparse' import { sunriseDB as databasePath } from '../helpers/database.helpers.js' import addBurialSite from '../database/addBurialSite.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 addContract from '../database/addContract.js' +import addContractComment from '../database/addContractComment.js' +import addContractFee from '../database/addContractFee.js' +import addContractOccupant from '../database/addContractOccupant.js' +import addContractTransaction from '../database/addContractTransaction.js' import addCemetery from '../database/addCemetery.js' -import addOrUpdateBurialSiteContractField from '../database/addOrUpdateBurialSiteContractField.js' +import addOrUpdateContractField from '../database/addOrUpdateContractField.js' import addWorkOrder from '../database/addWorkOrder.js' import addWorkOrderBurialSite from '../database/addWorkOrderBurialSite.js' -import addWorkOrderBurialSiteContract from '../database/addWorkOrderBurialSiteContract.js' +import addWorkOrderContract from '../database/addWorkOrderContract.js' import addWorkOrderMilestone from '../database/addWorkOrderMilestone.js' import closeWorkOrder from '../database/closeWorkOrder.js' import getBurialSite, { getBurialSiteByBurialSiteName } from '../database/getBurialSite.js' -import getBurialSiteContracts from '../database/getBurialSiteContracts.js' +import getContracts from '../database/getContracts.js' import getCemeteryFromDatabase from '../database/getCemetery.js' import getWorkOrder, { getWorkOrderByWorkOrderNumber @@ -199,14 +199,14 @@ function purgeTables(): void { 'WorkOrderMilestones', 'WorkOrderComments', 'WorkOrderBurialSites', - 'WorkOrderBurialSiteContracts', + 'WorkOrderContracts', 'WorkOrders', - 'BurialSiteContractTransactions', - 'BurialSiteContractFees', - 'BurialSiteContractFields', - 'BurialSiteContractComments', - 'BurialSiteContractInterments', - 'BurialSiteContracts', + 'ContractTransactions', + 'ContractFees', + 'ContractFields', + 'ContractComments', + 'ContractInterments', + 'Contracts', 'BurialSiteFields', 'BurialSiteComments', 'BurialSites' @@ -380,7 +380,7 @@ async function importFromMasterCSV(): Promise { } let preneedcontractStartDateString: string - let preneedburialSiteContractId: number + let preneedcontractId: number if (masterRow.CM_PRENEED_OWNER !== '' || masterRow.CM_STATUS === 'P') { preneedcontractStartDateString = formatDateString( @@ -438,7 +438,7 @@ async function importFromMasterCSV(): Promise { preneedcontractStartDateString = '0001-01-01' } - preneedburialSiteContractId = await addBurialSiteContract( + preneedcontractId = await addContract( { contractTypeId: importIds.preneedOccupancyType.contractTypeId, lotId: burialSiteId ?? '', @@ -452,9 +452,9 @@ async function importFromMasterCSV(): Promise { const occupantPostalCode = `${masterRow.CM_POST1} ${masterRow.CM_POST2}`.trim() - await addBurialSiteContractOccupant( + await addContractOccupant( { - burialSiteContractId: preneedburialSiteContractId, + contractId: preneedcontractId, lotOccupantTypeId: importIds.preneedOwnerLotOccupantTypeId, occupantName: masterRow.CM_PRENEED_OWNER, occupantFamilyName: '', @@ -470,39 +470,39 @@ async function importFromMasterCSV(): Promise { ) if (masterRow.CM_REMARK1 !== '') { - await addBurialSiteContractComment( + await addContractComment( { - burialSiteContractId: preneedburialSiteContractId, - burialSiteContractCommentDateString: + contractId: preneedcontractId, + contractCommentDateString: preneedcontractStartDateString, - burialSiteContractCommentTimeString: '00:00', - burialSiteContractComment: masterRow.CM_REMARK1 + contractCommentTimeString: '00:00', + contractComment: masterRow.CM_REMARK1 }, user ) } if (masterRow.CM_REMARK2 !== '') { - await addBurialSiteContractComment( + await addContractComment( { - burialSiteContractId: preneedburialSiteContractId, - burialSiteContractCommentDateString: + contractId: preneedcontractId, + contractCommentDateString: preneedcontractStartDateString, - burialSiteContractCommentTimeString: '00:00', - burialSiteContractComment: masterRow.CM_REMARK2 + contractCommentTimeString: '00:00', + contractComment: masterRow.CM_REMARK2 }, user ) } if (masterRow.CM_WORK_ORDER.trim() !== '') { - await addBurialSiteContractComment( + await addContractComment( { - burialSiteContractId: preneedburialSiteContractId, - burialSiteContractCommentDateString: + contractId: preneedcontractId, + contractCommentDateString: preneedcontractStartDateString, - burialSiteContractCommentTimeString: '00:00', - burialSiteContractComment: `Imported Contract #${masterRow.CM_WORK_ORDER}` + contractCommentTimeString: '00:00', + contractComment: `Imported Contract #${masterRow.CM_WORK_ORDER}` }, user ) @@ -518,7 +518,7 @@ async function importFromMasterCSV(): Promise { } let deceasedcontractStartDateString: string - let deceasedburialSiteContractId: number + let deceasedcontractId: number if (masterRow.CM_DECEASED_NAME !== '') { deceasedcontractStartDateString = formatDateString( @@ -555,7 +555,7 @@ async function importFromMasterCSV(): Promise { ? importIds.deceasedOccupancyType : importIds.cremationOccupancyType - deceasedburialSiteContractId = await addBurialSiteContract( + deceasedcontractId = await addContract( { contractTypeId: occupancyType.contractTypeId, lotId: burialSiteId ?? '', @@ -569,9 +569,9 @@ async function importFromMasterCSV(): Promise { const deceasedPostalCode = `${masterRow.CM_POST1} ${masterRow.CM_POST2}`.trim() - await addBurialSiteContractOccupant( + await addContractOccupant( { - burialSiteContractId: deceasedburialSiteContractId, + contractId: deceasedcontractId, lotOccupantTypeId: importIds.deceasedLotOccupantTypeId, occupantName: masterRow.CM_DECEASED_NAME, occupantFamilyName: '', @@ -587,34 +587,34 @@ async function importFromMasterCSV(): Promise { ) if (masterRow.CM_DEATH_YR !== '') { - const burialSiteContractFieldValue = formatDateString( + const contractFieldValue = formatDateString( masterRow.CM_DEATH_YR, masterRow.CM_DEATH_MON, masterRow.CM_DEATH_DAY ) - await addOrUpdateBurialSiteContractField( + await addOrUpdateContractField( { - burialSiteContractId: deceasedburialSiteContractId, + contractId: deceasedcontractId, contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Date' )!.contractTypeFieldId!, - burialSiteContractFieldValue + contractFieldValue }, user ) } if (masterRow.CM_AGE !== '') { - await addOrUpdateBurialSiteContractField( + await addOrUpdateContractField( { - burialSiteContractId: deceasedburialSiteContractId, + contractId: deceasedcontractId, contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Age' )!.contractTypeFieldId!, - burialSiteContractFieldValue: masterRow.CM_AGE + contractFieldValue: masterRow.CM_AGE }, user ) @@ -623,14 +623,14 @@ async function importFromMasterCSV(): Promise { if (masterRow.CM_PERIOD !== '') { const period = importData.getDeathAgePeriod(masterRow.CM_PERIOD) - await addOrUpdateBurialSiteContractField( + await addOrUpdateContractField( { - burialSiteContractId: deceasedburialSiteContractId, + contractId: deceasedcontractId, contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Age Period' )!.contractTypeFieldId!, - burialSiteContractFieldValue: period + contractFieldValue: period }, user ) @@ -642,9 +642,9 @@ async function importFromMasterCSV(): Promise { masterRow.CM_FUNERAL_HOME ) - await addBurialSiteContractOccupant( + await addContractOccupant( { - burialSiteContractId: deceasedburialSiteContractId, + contractId: deceasedcontractId, lotOccupantTypeId: funeralHomeOccupant.lotOccupantTypeId ?? '', occupantName: funeralHomeOccupant.occupantName ?? '', occupantFamilyName: '', @@ -662,15 +662,15 @@ async function importFromMasterCSV(): Promise { ) /* - addOrUpdateBurialSiteContractField( + addOrUpdateContractField( { - burialSiteContractId: deceasedburialSiteContractId, + contractId: deceasedcontractId, contractTypeFieldId: allContractTypeFields.find( (occupancyTypeField) => { return occupancyTypeField.occupancyTypeField === "Funeral Home"; } ).contractTypeFieldId, - burialSiteContractFieldValue: masterRow.CM_FUNERAL_HOME + contractFieldValue: masterRow.CM_FUNERAL_HOME }, user ); @@ -678,20 +678,20 @@ async function importFromMasterCSV(): Promise { } if (masterRow.CM_FUNERAL_YR !== '') { - const burialSiteContractFieldValue = formatDateString( + const contractFieldValue = formatDateString( masterRow.CM_FUNERAL_YR, masterRow.CM_FUNERAL_MON, masterRow.CM_FUNERAL_DAY ) - await addOrUpdateBurialSiteContractField( + await addOrUpdateContractField( { - burialSiteContractId: deceasedburialSiteContractId, + contractId: deceasedcontractId, contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Funeral Date' )!.contractTypeFieldId!, - burialSiteContractFieldValue + contractFieldValue }, user ) @@ -699,14 +699,14 @@ async function importFromMasterCSV(): Promise { if (occupancyType.occupancyType !== 'Cremation') { if (masterRow.CM_CONTAINER_TYPE !== '') { - await addOrUpdateBurialSiteContractField( + await addOrUpdateContractField( { - burialSiteContractId: deceasedburialSiteContractId, + contractId: deceasedcontractId, contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Container Type' )!.contractTypeFieldId!, - burialSiteContractFieldValue: masterRow.CM_CONTAINER_TYPE + contractFieldValue: masterRow.CM_CONTAINER_TYPE }, user ) @@ -719,14 +719,14 @@ async function importFromMasterCSV(): Promise { commitalType = 'Graveside' } - await addOrUpdateBurialSiteContractField( + await addOrUpdateContractField( { - burialSiteContractId: deceasedburialSiteContractId, + contractId: deceasedcontractId, contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Committal Type' )!.contractTypeFieldId!, - burialSiteContractFieldValue: commitalType + contractFieldValue: commitalType }, user ) @@ -734,39 +734,39 @@ async function importFromMasterCSV(): Promise { } if (masterRow.CM_REMARK1 !== '') { - await addBurialSiteContractComment( + await addContractComment( { - burialSiteContractId: deceasedburialSiteContractId, - burialSiteContractCommentDateString: + contractId: deceasedcontractId, + contractCommentDateString: deceasedcontractStartDateString, - burialSiteContractCommentTimeString: '00:00', - burialSiteContractComment: masterRow.CM_REMARK1 + contractCommentTimeString: '00:00', + contractComment: masterRow.CM_REMARK1 }, user ) } if (masterRow.CM_REMARK2 !== '') { - await addBurialSiteContractComment( + await addContractComment( { - burialSiteContractId: deceasedburialSiteContractId, - burialSiteContractCommentDateString: + contractId: deceasedcontractId, + contractCommentDateString: deceasedcontractStartDateString, - burialSiteContractCommentTimeString: '00:00', - burialSiteContractComment: masterRow.CM_REMARK2 + contractCommentTimeString: '00:00', + contractComment: masterRow.CM_REMARK2 }, user ) } if (masterRow.CM_WORK_ORDER.trim() !== '') { - await addBurialSiteContractComment( + await addContractComment( { - burialSiteContractId: deceasedburialSiteContractId, - burialSiteContractCommentDateString: + contractId: deceasedcontractId, + contractCommentDateString: deceasedcontractStartDateString, - burialSiteContractCommentTimeString: '00:00', - burialSiteContractComment: `Imported Contract #${masterRow.CM_WORK_ORDER}` + contractCommentTimeString: '00:00', + contractComment: `Imported Contract #${masterRow.CM_WORK_ORDER}` }, user ) @@ -779,9 +779,9 @@ async function importFromMasterCSV(): Promise { ) if (masterRow.CM_PRENEED_OWNER !== '') { - await addBurialSiteContractOccupant( + await addContractOccupant( { - burialSiteContractId: deceasedburialSiteContractId, + contractId: deceasedcontractId, lotOccupantTypeId: importIds.preneedOwnerLotOccupantTypeId, occupantName: masterRow.CM_PRENEED_OWNER, occupantFamilyName: '', @@ -895,10 +895,10 @@ async function importFromPrepaidCSV(): Promise { prepaidRow.CMPP_PURCH_DAY ) - let burialSiteContractId: number + let contractId: number if (lot) { - const possibleLotOccupancies = await getBurialSiteContracts( + const possibleLotOccupancies = await getContracts( { lotId: lot.lotId, contractTypeId: importIds.preneedOccupancyType.contractTypeId, @@ -915,12 +915,12 @@ async function importFromPrepaidCSV(): Promise { ) if (possibleLotOccupancies.lotOccupancies.length > 0) { - burialSiteContractId = - possibleLotOccupancies.lotOccupancies[0].burialSiteContractId! + contractId = + possibleLotOccupancies.lotOccupancies[0].contractId! } } - burialSiteContractId ||= await addBurialSiteContract( + contractId ||= await addContract( { lotId: lot ? lot.lotId : '', contractTypeId: importIds.preneedOccupancyType.contractTypeId, @@ -930,9 +930,9 @@ async function importFromPrepaidCSV(): Promise { user ) - await addBurialSiteContractOccupant( + await addContractOccupant( { - burialSiteContractId, + contractId, lotOccupantTypeId: importIds.preneedOwnerLotOccupantTypeId, occupantName: prepaidRow.CMPP_PREPAID_FOR_NAME, occupantFamilyName: '', @@ -948,9 +948,9 @@ async function importFromPrepaidCSV(): Promise { ) if (prepaidRow.CMPP_ARRANGED_BY_NAME) { - await addBurialSiteContractOccupant( + await addContractOccupant( { - burialSiteContractId, + contractId, lotOccupantTypeId: importIds.purchaserLotOccupantTypeId, occupantName: prepaidRow.CMPP_ARRANGED_BY_NAME, occupantFamilyName: '', @@ -967,9 +967,9 @@ async function importFromPrepaidCSV(): Promise { } if (prepaidRow.CMPP_FEE_GRAV_SD !== '0.0') { - await addBurialSiteContractFee( + await addContractFee( { - burialSiteContractId, + contractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_GRAV_SD'), quantity: 1, feeAmount: prepaidRow.CMPP_FEE_GRAV_SD, @@ -980,9 +980,9 @@ async function importFromPrepaidCSV(): Promise { } if (prepaidRow.CMPP_FEE_GRAV_DD !== '0.0') { - await addBurialSiteContractFee( + await addContractFee( { - burialSiteContractId, + contractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_GRAV_DD'), quantity: 1, feeAmount: prepaidRow.CMPP_FEE_GRAV_DD, @@ -993,9 +993,9 @@ async function importFromPrepaidCSV(): Promise { } if (prepaidRow.CMPP_FEE_CHAP_SD !== '0.0') { - await addBurialSiteContractFee( + await addContractFee( { - burialSiteContractId, + contractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_CHAP_SD'), quantity: 1, feeAmount: prepaidRow.CMPP_FEE_CHAP_SD, @@ -1006,9 +1006,9 @@ async function importFromPrepaidCSV(): Promise { } if (prepaidRow.CMPP_FEE_CHAP_DD !== '0.0') { - await addBurialSiteContractFee( + await addContractFee( { - burialSiteContractId, + contractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_CHAP_DD'), quantity: 1, feeAmount: prepaidRow.CMPP_FEE_CHAP_DD, @@ -1019,9 +1019,9 @@ async function importFromPrepaidCSV(): Promise { } if (prepaidRow.CMPP_FEE_ENTOMBMENT !== '0.0') { - await addBurialSiteContractFee( + await addContractFee( { - burialSiteContractId, + contractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_ENTOMBMENT'), quantity: 1, feeAmount: prepaidRow.CMPP_FEE_ENTOMBMENT, @@ -1032,9 +1032,9 @@ async function importFromPrepaidCSV(): Promise { } if (prepaidRow.CMPP_FEE_CREM !== '0.0') { - await addBurialSiteContractFee( + await addContractFee( { - burialSiteContractId, + contractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_CREM'), quantity: 1, feeAmount: prepaidRow.CMPP_FEE_CREM, @@ -1045,9 +1045,9 @@ async function importFromPrepaidCSV(): Promise { } if (prepaidRow.CMPP_FEE_NICHE !== '0.0') { - await addBurialSiteContractFee( + await addContractFee( { - burialSiteContractId, + contractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_NICHE'), quantity: 1, feeAmount: prepaidRow.CMPP_FEE_NICHE, @@ -1061,9 +1061,9 @@ async function importFromPrepaidCSV(): Promise { prepaidRow.CMPP_FEE_DISINTERMENT !== '0.0' && prepaidRow.CMPP_FEE_DISINTERMENT !== '20202.02' ) { - await addBurialSiteContractFee( + await addContractFee( { - burialSiteContractId, + contractId, feeId: importIds.getFeeIdByFeeDescription('CMPP_FEE_DISINTERMENT'), quantity: 1, feeAmount: prepaidRow.CMPP_FEE_DISINTERMENT, @@ -1099,9 +1099,9 @@ async function importFromPrepaidCSV(): Promise { : prepaidRow.CMPP_GST_DISINTERMENT ) - await addBurialSiteContractTransaction( + await addContractTransaction( { - burialSiteContractId, + contractId, externalReceiptNumber: '', transactionAmount, transactionDateString: contractStartDateString, @@ -1111,22 +1111,22 @@ async function importFromPrepaidCSV(): Promise { ) if (prepaidRow.CMPP_REMARK1) { - await addBurialSiteContractComment( + await addContractComment( { - burialSiteContractId, - burialSiteContractCommentDateString: contractStartDateString, - burialSiteContractComment: prepaidRow.CMPP_REMARK1 + contractId, + contractCommentDateString: contractStartDateString, + contractComment: prepaidRow.CMPP_REMARK1 }, user ) } if (prepaidRow.CMPP_REMARK2) { - await addBurialSiteContractComment( + await addContractComment( { - burialSiteContractId, - burialSiteContractCommentDateString: contractStartDateString, - burialSiteContractComment: prepaidRow.CMPP_REMARK2 + contractId, + contractCommentDateString: contractStartDateString, + contractComment: prepaidRow.CMPP_REMARK2 }, user ) @@ -1271,7 +1271,7 @@ async function importFromWorkOrderCSV(): Promise { ? importIds.deceasedOccupancyType : importIds.cremationOccupancyType - const burialSiteContractId = await addBurialSiteContract( + const contractId = await addContract( { lotId: lot ? lot.lotId : '', contractTypeId: occupancyType.contractTypeId, @@ -1281,9 +1281,9 @@ async function importFromWorkOrderCSV(): Promise { user ) - await addBurialSiteContractOccupant( + await addContractOccupant( { - burialSiteContractId, + contractId, lotOccupantTypeId: importIds.deceasedLotOccupantTypeId, occupantName: workOrderRow.WO_DECEASED_NAME, occupantFamilyName: '', @@ -1299,48 +1299,48 @@ async function importFromWorkOrderCSV(): Promise { ) if (workOrderRow.WO_DEATH_YR !== '') { - const burialSiteContractFieldValue = formatDateString( + const contractFieldValue = formatDateString( workOrderRow.WO_DEATH_YR, workOrderRow.WO_DEATH_MON, workOrderRow.WO_DEATH_DAY ) - await addOrUpdateBurialSiteContractField( + await addOrUpdateContractField( { - burialSiteContractId, + contractId, contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Date' )!.contractTypeFieldId!, - burialSiteContractFieldValue + contractFieldValue }, user ) } if (workOrderRow.WO_DEATH_PLACE !== '') { - await addOrUpdateBurialSiteContractField( + await addOrUpdateContractField( { - burialSiteContractId, + contractId, contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Place' )!.contractTypeFieldId!, - burialSiteContractFieldValue: workOrderRow.WO_DEATH_PLACE + contractFieldValue: workOrderRow.WO_DEATH_PLACE }, user ) } if (workOrderRow.WO_AGE !== '') { - await addOrUpdateBurialSiteContractField( + await addOrUpdateContractField( { - burialSiteContractId, + contractId, contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Age' )!.contractTypeFieldId!, - burialSiteContractFieldValue: workOrderRow.WO_AGE + contractFieldValue: workOrderRow.WO_AGE }, user ) @@ -1349,14 +1349,14 @@ async function importFromWorkOrderCSV(): Promise { if (workOrderRow.WO_PERIOD !== '') { const period = importData.getDeathAgePeriod(workOrderRow.WO_PERIOD) - await addOrUpdateBurialSiteContractField( + await addOrUpdateContractField( { - burialSiteContractId, + contractId, contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Death Age Period' )!.contractTypeFieldId!, - burialSiteContractFieldValue: period + contractFieldValue: period }, user ) @@ -1368,9 +1368,9 @@ async function importFromWorkOrderCSV(): Promise { workOrderRow.WO_FUNERAL_HOME ) - await addBurialSiteContractOccupant( + await addContractOccupant( { - burialSiteContractId, + contractId, lotOccupantTypeId: funeralHomeOccupant.lotOccupantTypeId!, occupantName: funeralHomeOccupant.occupantName!, occupantFamilyName: '', @@ -1386,13 +1386,13 @@ async function importFromWorkOrderCSV(): Promise { ) /* - addOrUpdateBurialSiteContractField( + addOrUpdateContractField( { - burialSiteContractId: burialSiteContractId, + contractId: contractId, contractTypeFieldId: allContractTypeFields.find((occupancyTypeField) => { return occupancyTypeField.occupancyTypeField === "Funeral Home"; }).contractTypeFieldId, - burialSiteContractFieldValue: workOrderRow.WO_FUNERAL_HOME + contractFieldValue: workOrderRow.WO_FUNERAL_HOME }, user ); @@ -1400,20 +1400,20 @@ async function importFromWorkOrderCSV(): Promise { } if (workOrderRow.WO_FUNERAL_YR !== '') { - const burialSiteContractFieldValue = formatDateString( + const contractFieldValue = formatDateString( workOrderRow.WO_FUNERAL_YR, workOrderRow.WO_FUNERAL_MON, workOrderRow.WO_FUNERAL_DAY ) - await addOrUpdateBurialSiteContractField( + await addOrUpdateContractField( { - burialSiteContractId, + contractId, contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Funeral Date' )!.contractTypeFieldId!, - burialSiteContractFieldValue + contractFieldValue }, user ) @@ -1421,14 +1421,14 @@ async function importFromWorkOrderCSV(): Promise { if (occupancyType.occupancyType !== 'Cremation') { if (workOrderRow.WO_CONTAINER_TYPE !== '') { - await addOrUpdateBurialSiteContractField( + await addOrUpdateContractField( { - burialSiteContractId, + contractId, contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Container Type' )!.contractTypeFieldId!, - burialSiteContractFieldValue: workOrderRow.WO_CONTAINER_TYPE + contractFieldValue: workOrderRow.WO_CONTAINER_TYPE }, user ) @@ -1441,24 +1441,24 @@ async function importFromWorkOrderCSV(): Promise { commitalType = 'Graveside' } - await addOrUpdateBurialSiteContractField( + await addOrUpdateContractField( { - burialSiteContractId, + contractId, contractTypeFieldId: occupancyType.ContractTypeFields!.find( (occupancyTypeField) => occupancyTypeField.occupancyTypeField === 'Committal Type' )!.contractTypeFieldId!, - burialSiteContractFieldValue: commitalType + contractFieldValue: commitalType }, user ) } } - await addWorkOrderBurialSiteContract( + await addWorkOrderContract( { workOrderId: workOrder.workOrderId!, - burialSiteContractId + contractId }, user ) diff --git a/types/recordTypes.d.ts b/types/recordTypes.d.ts index 000fb56b..21d9e661 100644 --- a/types/recordTypes.d.ts +++ b/types/recordTypes.d.ts @@ -70,8 +70,8 @@ export interface BurialSite extends Record { burialSiteStatusId?: number; burialSiteStatus?: string; burialSiteFields?: BurialSiteField[]; - burialSiteContractCount?: number; - burialSiteContracts?: BurialSiteContract[]; + contractCount?: number; + contracts?: Contract[]; burialSiteComments?: BurialSiteComment[]; } export interface BurialSiteComment extends Record { @@ -133,14 +133,14 @@ export interface Fee extends Record { taxPercentage?: number; isRequired?: boolean; orderNumber: number; - burialSiteContractFeeCount?: number; + contractFeeCount?: number; } -export interface BurialSiteContractFee extends Fee, Record { - burialSiteContractId?: number; +export interface ContractFee extends Fee, Record { + contractId?: number; quantity?: number; } -export interface BurialSiteContractTransaction extends Record { - burialSiteContractId?: number; +export interface ContractTransaction extends Record { + contractId?: number; transactionIndex?: number; transactionDate?: number; transactionDateString?: string; @@ -158,8 +158,8 @@ export interface DynamicsGPDocument { documentDescription: string[]; documentTotal: number; } -export interface BurialSiteContractInterment extends Record { - burialSiteContractId?: number; +export interface ContractInterment extends Record { + contractId?: number; intermentNumber?: number; isCremated?: boolean; deceasedName?: string; @@ -177,12 +177,12 @@ export interface BurialSiteContractInterment extends Record { intermentContainerType?: string; intermentCommittalTypeId?: number; intermentCommittalType?: string; - burialSiteContractIdCount?: number; + contractIdCount?: number; recordUpdate_timeMillisMax?: number; } -export interface BurialSiteContractComment extends Record { - burialSiteContractCommentId?: number; - burialSiteContractId?: number; +export interface ContractComment extends Record { + contractCommentId?: number; + contractId?: number; commentDate?: number; commentDateString?: string; commentTime?: number; @@ -190,13 +190,13 @@ export interface BurialSiteContractComment extends Record { commentTimePeriodString?: string; comment?: string; } -export interface BurialSiteContractField extends ContractTypeField, Record { - burialSiteContractId: number; +export interface ContractField extends ContractTypeField, Record { + contractId: number; contractTypeFieldId: number; fieldValue?: string; } -export interface BurialSiteContract extends Record { - burialSiteContractId: number; +export interface Contract extends Record { + contractId: number; contractTypeId: number; contractType?: string; printEJS?: string; @@ -221,11 +221,11 @@ export interface BurialSiteContract extends Record { funeralHomeId?: number; funeralHomeDirectorName?: string; funeralHomeName?: string; - burialSiteContractFields?: BurialSiteContractField[]; - burialSiteContractComments?: BurialSiteContractComment[]; - burialSiteContractInterments?: BurialSiteContractInterment[]; - burialSiteContractFees?: BurialSiteContractFee[]; - burialSiteContractTransactions?: BurialSiteContractTransaction[]; + contractFields?: ContractField[]; + contractComments?: ContractComment[]; + contractInterments?: ContractInterment[]; + contractFees?: ContractFee[]; + contractTransactions?: ContractTransaction[]; workOrders?: WorkOrder[]; } export interface WorkOrderType extends Record { @@ -281,7 +281,7 @@ export interface WorkOrder extends Record { workOrderComments?: WorkOrderComment[]; workOrderBurialSites?: BurialSite[]; workOrderBurialSiteCount?: number; - workOrderBurialSiteContracts?: BurialSiteContract[]; + workOrderContracts?: Contract[]; } declare global { export interface User { diff --git a/types/recordTypes.ts b/types/recordTypes.ts index 5e951ba4..3cef8a2b 100644 --- a/types/recordTypes.ts +++ b/types/recordTypes.ts @@ -94,8 +94,8 @@ export interface BurialSite extends Record { burialSiteFields?: BurialSiteField[] - burialSiteContractCount?: number - burialSiteContracts?: BurialSiteContract[] + contractCount?: number + contracts?: Contract[] burialSiteComments?: BurialSiteComment[] } @@ -178,16 +178,16 @@ export interface Fee extends Record { orderNumber: number - burialSiteContractFeeCount?: number + contractFeeCount?: number } -export interface BurialSiteContractFee extends Fee, Record { - burialSiteContractId?: number +export interface ContractFee extends Fee, Record { + contractId?: number quantity?: number } -export interface BurialSiteContractTransaction extends Record { - burialSiteContractId?: number +export interface ContractTransaction extends Record { + contractId?: number transactionIndex?: number transactionDate?: number transactionDateString?: string @@ -207,8 +207,8 @@ export interface DynamicsGPDocument { documentTotal: number } -export interface BurialSiteContractInterment extends Record { - burialSiteContractId?: number +export interface ContractInterment extends Record { + contractId?: number intermentNumber?: number isCremated?: boolean @@ -234,13 +234,13 @@ export interface BurialSiteContractInterment extends Record { intermentCommittalTypeId?: number intermentCommittalType?: string - burialSiteContractIdCount?: number + contractIdCount?: number recordUpdate_timeMillisMax?: number } -export interface BurialSiteContractComment extends Record { - burialSiteContractCommentId?: number - burialSiteContractId?: number +export interface ContractComment extends Record { + contractCommentId?: number + contractId?: number commentDate?: number commentDateString?: string @@ -252,14 +252,14 @@ export interface BurialSiteContractComment extends Record { comment?: string } -export interface BurialSiteContractField extends ContractTypeField, Record { - burialSiteContractId: number +export interface ContractField extends ContractTypeField, Record { + contractId: number contractTypeFieldId: number fieldValue?: string } -export interface BurialSiteContract extends Record { - burialSiteContractId: number +export interface Contract extends Record { + contractId: number contractTypeId: number contractType?: string @@ -292,11 +292,11 @@ export interface BurialSiteContract extends Record { funeralHomeDirectorName?: string funeralHomeName?: string - burialSiteContractFields?: BurialSiteContractField[] - burialSiteContractComments?: BurialSiteContractComment[] - burialSiteContractInterments?: BurialSiteContractInterment[] - burialSiteContractFees?: BurialSiteContractFee[] - burialSiteContractTransactions?: BurialSiteContractTransaction[] + contractFields?: ContractField[] + contractComments?: ContractComment[] + contractInterments?: ContractInterment[] + contractFees?: ContractFee[] + contractTransactions?: ContractTransaction[] workOrders?: WorkOrder[] } @@ -379,7 +379,7 @@ export interface WorkOrder extends Record { workOrderBurialSites?: BurialSite[] workOrderBurialSiteCount?: number - workOrderBurialSiteContracts?: BurialSiteContract[] + workOrderContracts?: Contract[] } /* diff --git a/views/burialSite-edit.ejs b/views/burialSite-edit.ejs index 1126e5f1..ed4f91cf 100644 --- a/views/burialSite-edit.ejs +++ b/views/burialSite-edit.ejs @@ -410,7 +410,7 @@

    Contracts - <%= burialSite.burialSiteContracts.length %> + <%= burialSite.contracts.length %>

    @@ -425,7 +425,7 @@
    - <% if (burialSite.burialSiteContracts.length === 0) { %> + <% if (burialSite.contracts.length === 0) { %>

    There are no contracts associated with this burial site. @@ -444,8 +444,8 @@ <% const currentDate = dateTimeFunctions.dateToInteger(new Date()); %> - <% for (const burialSiteContract of burialSite.burialSiteContracts) { %> - <% const isActive = !(burialSiteContract.contractEndDate && burialSiteContract.contractEndDate < currentDate); %> + <% for (const contract of burialSite.contracts) { %> + <% const isActive = !(contract.contractEndDate && contract.contractEndDate < currentDate); %> <% if (isActive) { %> @@ -455,26 +455,26 @@ <% } %> - - <%= burialSiteContract.contractType %> + + <%= contract.contractType %>
    - #<%= burialSiteContract.burialSiteContractId %> + #<%= contract.contractId %> - <%= burialSiteContract.contractStartDateString %> + <%= contract.contractStartDateString %> - <% if (burialSiteContract.contractEndDate) { %> - <%= burialSiteContract.contractEndDateString %> + <% if (contract.contractEndDate) { %> + <%= contract.contractEndDateString %> <% } else { %> (No End Date) <% } %> - <% if (burialSiteContract.burialSiteContractInterments.length === 0) { %> + <% if (contract.contractInterments.length === 0) { %> (No Interments) <% } else { %> - <% for (const interment of burialSiteContract.burialSiteContractInterments) { %> + <% for (const interment of contract.contractInterments) { %> <%= interment.deceasedName %> <% } %> <% } %> diff --git a/views/burialSite-view.ejs b/views/burialSite-view.ejs index cd0918f3..f8e8cae7 100644 --- a/views/burialSite-view.ejs +++ b/views/burialSite-view.ejs @@ -146,10 +146,10 @@

    Contracts - <%= burialSite.burialSiteContracts.length %> + <%= burialSite.contracts.length %>

    - <% if (burialSite.burialSiteContracts.length === 0) { %> + <% if (burialSite.contracts.length === 0) { %>

    There are no contracts asscociated with this burial site. @@ -168,8 +168,8 @@ <% const currentDate = dateTimeFunctions.dateToInteger(new Date()); %> - <% for (const burialSiteContract of burialSite.burialSiteContracts) { %> - <% const isActive = !(burialSiteContract.contractEndDate && burialSiteContract.contractEndDate < currentDate); %> + <% for (const contract of burialSite.contracts) { %> + <% const isActive = !(contract.contractEndDate && contract.contractEndDate < currentDate); %> <% if (isActive) { %> @@ -180,24 +180,24 @@ - <%= burialSiteContract.contractType %> + href="<%= urlPrefix %>/contracts/<%= contract.contractId %>"> + <%= contract.contractType %>
    - #<%= burialSiteContract.burialSiteContractId %> + #<%= contract.contractId %> - <%= burialSiteContract.contractStartDateString %> + <%= contract.contractStartDateString %> - <% if (burialSiteContract.contractEndDate) { %> - <%= burialSiteContract.contractEndDateString %> + <% if (contract.contractEndDate) { %> + <%= contract.contractEndDateString %> <% } else { %> (No End Date) <% } %> - <% if (burialSiteContract.burialSiteContractInterments.length === 0) { %> + <% if (contract.contractInterments.length === 0) { %> (No Interments) <% } else { %> - <% for (const interment of burialSiteContract.burialSiteContractInterments) { %> + <% for (const interment of contract.contractInterments) { %> <%= interment.deceasedName %> <% } %> <% } %> diff --git a/views/burialSiteContract-edit.ejs b/views/contract-edit.ejs similarity index 100% rename from views/burialSiteContract-edit.ejs rename to views/contract-edit.ejs diff --git a/views/burialSiteContract-search.ejs b/views/contract-search.ejs similarity index 98% rename from views/burialSiteContract-search.ejs rename to views/contract-search.ejs index f5f66d64..9c6fbbbf 100644 --- a/views/burialSiteContract-search.ejs +++ b/views/contract-search.ejs @@ -151,6 +151,6 @@ <%- include('_footerA'); -%> - + <%- include('_footerB'); -%> diff --git a/views/burialSiteContract-view.ejs b/views/contract-view.ejs similarity index 100% rename from views/burialSiteContract-view.ejs rename to views/contract-view.ejs diff --git a/views/dashboard.ejs b/views/dashboard.ejs index b349198d..5a6be172 100644 --- a/views/dashboard.ejs +++ b/views/dashboard.ejs @@ -70,9 +70,9 @@ } } - if (milestone.workOrderBurialSiteContracts.length > 0) { - for (const burialSiteContract of milestone.workOrderBurialSiteContracts) { - for (const interment of burialSiteContract.lotOccupancyInterments) { + if (milestone.workOrderContracts.length > 0) { + for (const contract of milestone.workOrderContracts) { + for (const interment of contract.lotOccupancyInterments) { %> @@ -144,8 +144,8 @@