From a38b7a05d648a562bd2c534e77d62a519dca5205 Mon Sep 17 00:00:00 2001 From: mgtennant <100305096+mgtennant@users.noreply.github.com> Date: Tue, 12 Mar 2024 19:53:54 -0700 Subject: [PATCH 1/7] backend decent state --- backend/db/Dockerfile | 11 + backend/db/flyway.conf | 6 + .../migrations/V2.0.0__Database_Migration.sql | 167 + backend/db2/V1.1.0__Database_Objects.sql | 278 + backend/db2/V1.1.1__TICDI_Data_Nov-10-23.sql | 339 + backend/src/admin/admin.controller.ts | 14 +- backend/src/admin/admin.service.ts | 25 +- backend/src/app.controller.ts | 9 +- backend/src/app.module.ts | 20 +- backend/src/app.service.ts | 14 +- .../document_data/document_data.controller.ts | 73 + .../src/document_data/document_data.module.ts | 28 + .../document_data/document_data.service.ts | 381 + .../dto/create-document_data.dto.ts | 10 + .../dto/document_data.dto.ts} | 4 +- .../dto/update-document_data.dto.ts | 11 + .../entities/document_data.entity.ts | 61 + .../document_data_provision.entity.ts | 23 + .../entities/document_data_variable.entity.ts | 23 + .../entities/document_data_vw.ts | 223 + .../document_data_log.module.ts | 11 + .../document_data_log.service.ts | 51 + .../dto/create-document_data_log.dto.ts | 12 + .../dto/document_data_log.dto.ts} | 7 +- .../dto/update-document_data_log.dto.ts | 12 + .../entities/document_data_log.entity.ts} | 22 +- .../document_template.controller.ts | 34 +- .../document_template.module.ts | 11 +- .../document_template.service.ts | 147 +- .../dto/create-document_template.dto.ts | 2 +- .../dto/document_template.dto.ts | 2 +- .../dto/update-document_template.dto.ts | 2 +- .../entities/document_template.entity.ts | 13 +- .../document_type/document_type.controller.ts | 23 + .../src/document_type/document_type.module.ts | 13 + .../document_type/document_type.service.ts | 19 + .../entities/document_type.entity.ts | 44 + backend/src/main.ts | 2 +- .../src/nfr_data/dto/create-nfr_data.dto.ts | 10 - .../src/nfr_data/dto/update-nfr_data.dto.ts | 11 - .../src/nfr_data/entities/nfr_data.entity.ts | 61 - .../entities/nfr_data_provision.entity.ts | 21 - .../entities/nfr_data_variable.entity.ts | 21 - backend/src/nfr_data/entities/nfr_data_vw.ts | 221 - backend/src/nfr_data/nfr_data.controller.ts | 70 - backend/src/nfr_data/nfr_data.module.ts | 29 - backend/src/nfr_data/nfr_data.service.ts | 375 - .../dto/create-nfr_data_log.dto.ts | 11 - .../dto/update-nfr_data_log.dto.ts | 11 - .../entities/nfr_data_log.entity.ts | 43 - .../nfr_data_log/nfr_data_log.controller.ts | 32 - .../src/nfr_data_log/nfr_data_log.module.ts | 12 - .../src/nfr_data_log/nfr_data_log.service.ts | 51 - .../entities/nfr_provision_variant.entity.ts | 21 - .../nfr_provision/nfr_provision.controller.ts | 128 - .../src/nfr_provision/nfr_provision.module.ts | 21 - .../nfr_provision/nfr_provision.service.ts | 364 - backend/src/ormconfig.ts | 38 +- .../dto/create-print_request_detail.dto.ts | 41 - .../dto/print_request_detail.dto.ts | 39 - .../dto/update-print_request_detail.dto.ts | 41 - .../entities/print_request_detail.entity.ts | 163 - .../entities/print_request_detail_vw.ts | 77 - .../print_request_detail.controller.ts | 39 - .../print_request_detail.module.ts | 12 - .../print_request_detail.service.ts | 127 - .../dto/create-print_request_log.dto.ts | 12 - .../dto/print_request_log.dto.ts | 10 - .../dto/update-print_request_log.dto.ts | 12 - .../print_request_log.controller.ts | 33 - .../print_request_log.module.ts | 13 - .../print_request_log.service.ts | 65 - .../dto/create-provision.dto.ts} | 5 +- .../dto/provision.dto.ts} | 3 +- .../dto/update-provision.dto.ts} | 5 +- .../entities/provision.entity.ts} | 45 +- .../entities/provision_group.entity.ts} | 8 +- .../entities/provision_variable.entity.ts} | 14 +- backend/src/provision/provision.controller.ts | 102 + backend/src/provision/provision.module.ts | 21 + backend/src/provision/provision.service.ts | 308 + backend/src/report/report.controller.ts | 106 +- backend/src/report/report.module.ts | 17 +- backend/src/report/report.service.ts | 232 +- backend/src/ttls/ttls.service.ts | 2 +- backend/utils/db/init-db.sql | 469 +- backend/utils/types.ts | 4 +- docker-compose.yml | 36 +- frontend/package-lock.json | 48 +- frontend/public/js/manage-templates.js | 1129 +- frontend/public/js/nfr.js | 8 +- frontend/src/app/App.tsx | 67 +- frontend/src/app/common/manage-templates.ts | 2 +- frontend/src/app/common/report.ts | 36 +- frontend/src/app/common/search.ts | 2 +- .../manage-templates/AddProvisionModal.tsx | 2 + .../forms/EditProvisionModalForm.tsx | 2 + .../table/reports/ProvisionsTable.tsx | 18 +- .../table/reports/SelectedProvisionsTable.tsx | 13 +- .../table/search/SearchDataTable.tsx | 2 + frontend/src/app/content/Content.tsx | 35 - frontend/src/app/content/ContentWrapper.tsx | 23 + .../src/app/content/display/Provisions.tsx | 24 +- .../src/app/content/display/Variables.tsx | 11 +- .../app/content/pages/ManageTemplatesPage.tsx | 3 + frontend/src/app/content/pages/ReportPage.tsx | 44 +- frontend/src/app/content/pages/SearchPage.tsx | 2 + frontend/src/app/types/types.ts | 15 +- frontend/src/app/util/constants.ts | 56 +- frontend_old/.env.example | 16 - frontend_old/Dockerfile | 37 - frontend_old/nest-cli.json | 20 - frontend_old/nodemon.json | 6 - frontend_old/package-lock.json | 18373 ---------------- frontend_old/package.json | 143 - frontend_old/src/app.module.ts | 36 - frontend_old/src/app.service.ts | 8 - frontend_old/src/main.ts | 41 - frontend_old/test-report.xml | 6 - frontend_old/tsconfig.build.json | 4 - frontend_old/tsconfig.json | 17 - frontend_old/views/layout/template.hbs | 26 - frontend_old/views/pages/404.hbs | 13 - frontend_old/views/pages/grazing-lease.hbs | 137 - frontend_old/views/pages/index.hbs | 154 - frontend_old/views/pages/index.html | 154 - frontend_old/views/pages/manage-templates.hbs | 513 - frontend_old/views/pages/nfr.hbs | 190 - frontend_old/views/pages/search.hbs | 181 - frontend_old/views/pages/system-admin.hbs | 422 - frontend_old/views/partials/footer.hbs | 45 - frontend_old/views/partials/navbar.hbs | 55 - frontend_old/views/partials/scripts.hbs | 13 - frontend_old/views/partials/style.hbs | 77 - 134 files changed, 3779 insertions(+), 24209 deletions(-) create mode 100644 backend/db/Dockerfile create mode 100644 backend/db/flyway.conf create mode 100644 backend/db/migrations/V2.0.0__Database_Migration.sql create mode 100644 backend/db2/V1.1.0__Database_Objects.sql create mode 100644 backend/db2/V1.1.1__TICDI_Data_Nov-10-23.sql create mode 100644 backend/src/document_data/document_data.controller.ts create mode 100644 backend/src/document_data/document_data.module.ts create mode 100644 backend/src/document_data/document_data.service.ts create mode 100644 backend/src/document_data/dto/create-document_data.dto.ts rename backend/src/{nfr_data/dto/nfr_data.dto.ts => document_data/dto/document_data.dto.ts} (71%) create mode 100644 backend/src/document_data/dto/update-document_data.dto.ts create mode 100644 backend/src/document_data/entities/document_data.entity.ts create mode 100644 backend/src/document_data/entities/document_data_provision.entity.ts create mode 100644 backend/src/document_data/entities/document_data_variable.entity.ts create mode 100644 backend/src/document_data/entities/document_data_vw.ts create mode 100644 backend/src/document_data_log/document_data_log.module.ts create mode 100644 backend/src/document_data_log/document_data_log.service.ts create mode 100644 backend/src/document_data_log/dto/create-document_data_log.dto.ts rename backend/src/{nfr_data_log/dto/nfr_data_log.dto.ts => document_data_log/dto/document_data_log.dto.ts} (62%) create mode 100644 backend/src/document_data_log/dto/update-document_data_log.dto.ts rename backend/src/{print_request_log/entities/print_request_log.entity.ts => document_data_log/entities/document_data_log.entity.ts} (80%) create mode 100644 backend/src/document_type/document_type.controller.ts create mode 100644 backend/src/document_type/document_type.module.ts create mode 100644 backend/src/document_type/document_type.service.ts create mode 100644 backend/src/document_type/entities/document_type.entity.ts delete mode 100644 backend/src/nfr_data/dto/create-nfr_data.dto.ts delete mode 100644 backend/src/nfr_data/dto/update-nfr_data.dto.ts delete mode 100644 backend/src/nfr_data/entities/nfr_data.entity.ts delete mode 100644 backend/src/nfr_data/entities/nfr_data_provision.entity.ts delete mode 100644 backend/src/nfr_data/entities/nfr_data_variable.entity.ts delete mode 100644 backend/src/nfr_data/entities/nfr_data_vw.ts delete mode 100644 backend/src/nfr_data/nfr_data.controller.ts delete mode 100644 backend/src/nfr_data/nfr_data.module.ts delete mode 100644 backend/src/nfr_data/nfr_data.service.ts delete mode 100644 backend/src/nfr_data_log/dto/create-nfr_data_log.dto.ts delete mode 100644 backend/src/nfr_data_log/dto/update-nfr_data_log.dto.ts delete mode 100644 backend/src/nfr_data_log/entities/nfr_data_log.entity.ts delete mode 100644 backend/src/nfr_data_log/nfr_data_log.controller.ts delete mode 100644 backend/src/nfr_data_log/nfr_data_log.module.ts delete mode 100644 backend/src/nfr_data_log/nfr_data_log.service.ts delete mode 100644 backend/src/nfr_provision/entities/nfr_provision_variant.entity.ts delete mode 100644 backend/src/nfr_provision/nfr_provision.controller.ts delete mode 100644 backend/src/nfr_provision/nfr_provision.module.ts delete mode 100644 backend/src/nfr_provision/nfr_provision.service.ts delete mode 100644 backend/src/print_request_detail/dto/create-print_request_detail.dto.ts delete mode 100644 backend/src/print_request_detail/dto/print_request_detail.dto.ts delete mode 100644 backend/src/print_request_detail/dto/update-print_request_detail.dto.ts delete mode 100644 backend/src/print_request_detail/entities/print_request_detail.entity.ts delete mode 100644 backend/src/print_request_detail/entities/print_request_detail_vw.ts delete mode 100644 backend/src/print_request_detail/print_request_detail.controller.ts delete mode 100644 backend/src/print_request_detail/print_request_detail.module.ts delete mode 100644 backend/src/print_request_detail/print_request_detail.service.ts delete mode 100644 backend/src/print_request_log/dto/create-print_request_log.dto.ts delete mode 100644 backend/src/print_request_log/dto/print_request_log.dto.ts delete mode 100644 backend/src/print_request_log/dto/update-print_request_log.dto.ts delete mode 100644 backend/src/print_request_log/print_request_log.controller.ts delete mode 100644 backend/src/print_request_log/print_request_log.module.ts delete mode 100644 backend/src/print_request_log/print_request_log.service.ts rename backend/src/{nfr_provision/dto/create-nfr_provision.dto.ts => provision/dto/create-provision.dto.ts} (61%) rename backend/src/{nfr_provision/dto/nfr_provision.dto.ts => provision/dto/provision.dto.ts} (82%) rename backend/src/{nfr_provision/dto/update-nfr_provision.dto.ts => provision/dto/update-provision.dto.ts} (61%) rename backend/src/{nfr_provision/entities/nfr_provision.entity.ts => provision/entities/provision.entity.ts} (54%) rename backend/src/{nfr_provision/entities/nfr_provision_group.entity.ts => provision/entities/provision_group.entity.ts} (71%) rename backend/src/{nfr_provision/entities/nfr_provision_variable.entity.ts => provision/entities/provision_variable.entity.ts} (64%) create mode 100644 backend/src/provision/provision.controller.ts create mode 100644 backend/src/provision/provision.module.ts create mode 100644 backend/src/provision/provision.service.ts delete mode 100644 frontend/src/app/content/Content.tsx create mode 100644 frontend/src/app/content/ContentWrapper.tsx delete mode 100644 frontend_old/.env.example delete mode 100644 frontend_old/Dockerfile delete mode 100644 frontend_old/nest-cli.json delete mode 100644 frontend_old/nodemon.json delete mode 100644 frontend_old/package-lock.json delete mode 100644 frontend_old/package.json delete mode 100644 frontend_old/src/app.module.ts delete mode 100644 frontend_old/src/app.service.ts delete mode 100644 frontend_old/src/main.ts delete mode 100644 frontend_old/test-report.xml delete mode 100644 frontend_old/tsconfig.build.json delete mode 100644 frontend_old/tsconfig.json delete mode 100644 frontend_old/views/layout/template.hbs delete mode 100644 frontend_old/views/pages/404.hbs delete mode 100644 frontend_old/views/pages/grazing-lease.hbs delete mode 100644 frontend_old/views/pages/index.hbs delete mode 100644 frontend_old/views/pages/index.html delete mode 100644 frontend_old/views/pages/manage-templates.hbs delete mode 100644 frontend_old/views/pages/nfr.hbs delete mode 100644 frontend_old/views/pages/search.hbs delete mode 100644 frontend_old/views/pages/system-admin.hbs delete mode 100644 frontend_old/views/partials/footer.hbs delete mode 100644 frontend_old/views/partials/navbar.hbs delete mode 100644 frontend_old/views/partials/scripts.hbs delete mode 100644 frontend_old/views/partials/style.hbs diff --git a/backend/db/Dockerfile b/backend/db/Dockerfile new file mode 100644 index 00000000..efc98550 --- /dev/null +++ b/backend/db/Dockerfile @@ -0,0 +1,11 @@ +FROM flyway/flyway:9.10-alpine + +# Non-root user +RUN adduser -D app +USER app + +# Copy migrations +COPY ./migrations /flyway/sql + +# Startup +CMD ["info","migrate","info"] \ No newline at end of file diff --git a/backend/db/flyway.conf b/backend/db/flyway.conf new file mode 100644 index 00000000..49999248 --- /dev/null +++ b/backend/db/flyway.conf @@ -0,0 +1,6 @@ +flyway.url=jdbc:postgresql://localhost:5432/ticdi_db +flyway.user=ticdi_db_user +flyway.password=dfs2113 +flyway.schemas=public +flyway.locations=filesystem:./db/migrations +flyway.baselineOnMigrate=true diff --git a/backend/db/migrations/V2.0.0__Database_Migration.sql b/backend/db/migrations/V2.0.0__Database_Migration.sql new file mode 100644 index 00000000..188d7c05 --- /dev/null +++ b/backend/db/migrations/V2.0.0__Database_Migration.sql @@ -0,0 +1,167 @@ +BEGIN; +---------------------------------- +-- Changes to NFR & related tables +---------------------------------- +-- Rename tables +ALTER TABLE public.nfr_data RENAME TO document_data; + +ALTER TABLE public.nfr_provision RENAME TO provision; +ALTER TABLE public.nfr_provision_variable RENAME TO provision_variable; +ALTER TABLE public.nfr_provision_group RENAME TO provision_group; + +ALTER TABLE public.nfr_data_provision RENAME TO document_data_provision; +ALTER TABLE public.nfr_data_variable RENAME TO document_data_variable; + +-- Rename columns +ALTER TABLE public.document_data_provision + RENAME COLUMN "nfrProvisionId" TO document_provision_id; +ALTER TABLE public.document_data_provision + RENAME COLUMN "nfrDataId" TO document_data_id; +ALTER TABLE public.provision + RENAME COLUMN "provisionGroupId" TO provision_group_id; + +ALTER TABLE public.document_data_variable + RENAME COLUMN "nfrVariableId" TO document_variable_id; +ALTER TABLE public.document_data_variable + RENAME COLUMN "nfrDataId" TO document_data_id; + + +-- Modify constraints +ALTER TABLE public.provision +DROP CONSTRAINT "FK_a43df8873b446878b2ee5cebb24", +ADD CONSTRAINT "FK_provision_group_id" FOREIGN KEY (provision_group_id) REFERENCES public.provision(id); + +ALTER TABLE public.document_data_provision +DROP CONSTRAINT "FK_31783ee54c5bc5e6b76a2803123", +ADD CONSTRAINT "FK_document_provision_id" FOREIGN KEY (document_provision_id) REFERENCES public.provision(id) ON DELETE CASCADE; + +ALTER TABLE public.document_data_provision +DROP CONSTRAINT "FK_de4669e0ff571ddf23c9490059c", +ADD CONSTRAINT "FK_document_data_id" FOREIGN KEY (document_data_id) REFERENCES public.document_data(id) ON DELETE CASCADE; + +ALTER TABLE public.document_data_variable +DROP CONSTRAINT "FK_2f9dc95b75fb29c01a332823044", +ADD CONSTRAINT "FK_2f9dc95b75fb29c01a332823044" FOREIGN KEY (document_variable_id) REFERENCES public.provision_variable(id) ON DELETE CASCADE; + +ALTER TABLE public.document_data_variable +DROP CONSTRAINT "FK_76bc71b9b4fbbcdd622bab0ff19", +ADD CONSTRAINT "FK_76bc71b9b4fbbcdd622bab0ff19" FOREIGN KEY (document_data_id) REFERENCES public.document_data(id) ON DELETE CASCADE; + +---------------------------------- +-- Changes to template tables +---------------------------------- +-- Create new document_type table +CREATE TABLE public.document_type ( + id serial PRIMARY KEY, + name varchar NOT NULL, + create_userid varchar NOT NULL, + update_userid varchar NOT NULL, + create_timestamp timestamp NOT NULL DEFAULT now(), + update_timestamp timestamp NOT NULL DEFAULT now() +); +INSERT INTO public.document_type (name, create_userid, update_userid) +VALUES ('Land Use Report', 'system', 'system'); +VALUES ('Notice of Final Review', 'system', 'system'); +VALUES ('Notice of Final Review (Delayed)', 'system', 'system'); +VALUES ('Notice of Final Review (No Fees)', 'system', 'system'); +VALUES ('Notice of Final Review (Survey Required)', 'system', 'system'); +VALUES ('Notice of Final Review (To Obtain Survey)', 'system', 'system'); +VALUES ('Grazing Lease', 'system', 'system'); + +ALTER TABLE public.document_template ADD COLUMN document_type_id int4; +ALTER TABLE public.document_template DROP COLUMN document_type; + +UPDATE public.document_template +SET document_type_id = (SELECT id FROM public.document_type WHERE name = 'Land Use Report'); + +ALTER TABLE public.document_template +ADD CONSTRAINT fk_document_template_document_type_id +FOREIGN KEY (document_type_id) REFERENCES public.document_type(id); + +ALTER TABLE public.document_template +ALTER COLUMN document_type_id SET NOT NULL; + +---------------------------------- +-- Changes to logs tables +---------------------------------- +-- Create new unified log table +CREATE TABLE public.document_data_log ( + id serial4 NOT NULL, + dtid int4 NULL, + document_type_id int4 NULL, -- New column + document_data_id int4 NULL, -- Previously nfr_data_id, no direct table join + document_template_id int4 NULL, + request_app_user varchar NULL, + request_json varchar NULL, + create_userid varchar NULL, + update_userid varchar NULL, + create_timestamp timestamp NULL DEFAULT now(), + update_timestamp timestamp NULL DEFAULT now(), + PRIMARY KEY (id) +); + +-- Copy over nfr_data_log data +INSERT INTO public.document_data_log ( + dtid, + document_type_id, + document_data_id, + document_template_id, + request_app_user, + request_json, + create_userid, + update_userid, + create_timestamp, + update_timestamp +) +SELECT + dtid, + NULL, + nfr_data_id AS document_data_id, + document_template_id, + request_app_user, + request_json, + create_userid, + update_userid, + create_timestamp, + update_timestamp +FROM + public.nfr_data_log; + +-- Copy over print_request_log data +INSERT INTO public.document_data_log ( + dtid, + document_type_id, + document_data_id, + document_template_id, + request_app_user, + request_json, + create_userid, + update_userid, + create_timestamp, + update_timestamp +) +SELECT + dtid, + NULL, + NULL, + document_template_id, + request_app_user, + request_json, + create_userid, + update_userid, + create_timestamp, + update_timestamp +FROM + public.print_request_log; + +---------------------------------- +-- Delete tables which are no longer being used +---------------------------------- +DROP TABLE public.nfr_data_log; +DROP TABLE public.print_request_log; +DROP VIEW public.print_request_detail_view; +DROP TABLE public.print_request_detail; +DROP TABLE public.nfr_provision_provision_variant_nfr_provision_variant; +DROP TABLE public.nfr_provision_variant; + +COMMIT; \ No newline at end of file diff --git a/backend/db2/V1.1.0__Database_Objects.sql b/backend/db2/V1.1.0__Database_Objects.sql new file mode 100644 index 00000000..d980e8ec --- /dev/null +++ b/backend/db2/V1.1.0__Database_Objects.sql @@ -0,0 +1,278 @@ +-- -- public.document_template definition + +-- -- Drop table + +-- -- DROP TABLE public.document_template; + +-- CREATE TABLE public.document_template ( +-- id serial4 NOT NULL, +-- document_type varchar NOT NULL, +-- template_version int4 NOT NULL, +-- template_author varchar NOT NULL, +-- active_flag bool NOT NULL, +-- is_deleted bool NOT NULL, +-- mime_type varchar NOT NULL, +-- file_name varchar NOT NULL, +-- the_file varchar NOT NULL, +-- "comments" varchar NOT NULL, +-- create_userid varchar NOT NULL, +-- update_userid varchar NOT NULL, +-- create_timestamp timestamp NOT NULL DEFAULT now(), +-- update_timestamp timestamp NOT NULL DEFAULT now(), +-- CONSTRAINT "PK_0e9c5bda0dd75f3bde7ae176c62" PRIMARY KEY (id) +-- ); + + +-- -- public.nfr_data definition + +-- -- Drop table + +-- -- DROP TABLE public.nfr_data; + +-- CREATE TABLE public.nfr_data ( +-- id serial4 NOT NULL, +-- dtid int4 NULL, +-- variant_name varchar NULL, +-- template_id int4 NULL, +-- status varchar NULL, +-- active bool NULL, +-- create_userid varchar NULL, +-- update_userid varchar NULL, +-- create_timestamp timestamp NOT NULL DEFAULT now(), +-- update_timestamp timestamp NOT NULL DEFAULT now(), +-- CONSTRAINT "PK_d799fd74be596cab9c066ed23ac" PRIMARY KEY (id) +-- ); + + +-- -- public.nfr_data_log definition + +-- -- Drop table + +-- -- DROP TABLE public.nfr_data_log; + +-- CREATE TABLE public.nfr_data_log ( +-- id serial4 NOT NULL, +-- document_template_id int4 NULL, +-- nfr_data_id int4 NULL, +-- dtid int4 NULL, +-- request_app_user varchar NULL, +-- request_json varchar NULL, +-- create_userid varchar NULL, +-- update_userid varchar NULL, +-- create_timestamp timestamp NULL DEFAULT now(), +-- update_timestamp timestamp NULL DEFAULT now(), +-- CONSTRAINT "PK_4482adc99fe410378694fd5cab5" PRIMARY KEY (id) +-- ); + + +-- -- public.nfr_provision_group definition + +-- -- Drop table + +-- -- DROP TABLE public.nfr_provision_group; + +-- CREATE TABLE public.nfr_provision_group ( +-- id serial4 NOT NULL, +-- provision_group int4 NULL, +-- provision_group_text varchar NULL, +-- max int4 NULL, +-- CONSTRAINT "PK_db4bcde496c52c47aedb885287e" PRIMARY KEY (id) +-- ); + + +-- -- public.nfr_provision_variant definition + +-- -- Drop table + +-- -- DROP TABLE public.nfr_provision_variant; + +-- CREATE TABLE public.nfr_provision_variant ( +-- id serial4 NOT NULL, +-- variant_name varchar NULL, +-- CONSTRAINT "PK_52d5e2ef42a148cf8c8076ab08e" PRIMARY KEY (id) +-- ); + + +-- -- public.print_request_detail definition + +-- -- Drop table + +-- -- DROP TABLE public.print_request_detail; + +-- CREATE TABLE public.print_request_detail ( +-- id serial4 NOT NULL, +-- dtid int4 NULL, +-- tenure_file_number varchar NULL, +-- incorporation_number varchar NULL, +-- organization_unit varchar NULL, +-- purpose_name varchar NULL, +-- sub_purpose_name varchar NULL, +-- type_name varchar NULL, +-- sub_type_name varchar NULL, +-- licence_holder_name varchar NULL, +-- contact_agent varchar NULL, +-- contact_company_name varchar NULL, +-- contact_first_name varchar NULL, +-- contact_middle_name varchar NULL, +-- contact_last_name varchar NULL, +-- contact_phone_number varchar NULL, +-- contact_email_address varchar NULL, +-- first_name varchar NULL, +-- middle_name varchar NULL, +-- last_name varchar NULL, +-- legal_name varchar NULL, +-- email_address varchar NULL, +-- phone_number varchar NULL, +-- inspected_date varchar NULL, +-- mailing_address varchar NULL, +-- mailing_address_line_1 varchar NULL, +-- mailing_address_line_2 varchar NULL, +-- mailing_address_line_3 varchar NULL, +-- mailing_city varchar NULL, +-- mailing_province_state_code varchar NULL, +-- mailing_postal_code varchar NULL, +-- mailing_zip varchar NULL, +-- mailing_country_code varchar NULL, +-- mailing_country varchar NULL, +-- location_description varchar NULL, +-- tenure varchar NULL, +-- create_userid varchar NULL, +-- update_userid varchar NULL, +-- create_timestamp timestamp NOT NULL DEFAULT now(), +-- update_timestamp timestamp NOT NULL DEFAULT now(), +-- CONSTRAINT "PK_2de96ab00388f75e42763d1f10d" PRIMARY KEY (id) +-- ); + + +-- -- public.print_request_log definition + +-- -- Drop table + +-- -- DROP TABLE public.print_request_log; + +-- CREATE TABLE public.print_request_log ( +-- id serial4 NOT NULL, +-- document_template_id int4 NULL, +-- print_request_detail_id int4 NULL, +-- dtid int4 NULL, +-- request_app_user varchar NULL, +-- request_json varchar NULL, +-- create_userid varchar NULL, +-- update_userid varchar NULL, +-- create_timestamp timestamp NULL DEFAULT now(), +-- update_timestamp timestamp NULL DEFAULT now(), +-- document_type varchar NULL, +-- CONSTRAINT "PK_e0a0d1732be69648cb82307c5ef" PRIMARY KEY (id) +-- ); + + +-- -- public.typeorm_metadata definition + +-- -- Drop table + +-- -- DROP TABLE public.typeorm_metadata; + +-- CREATE TABLE public.typeorm_metadata ( +-- "type" varchar NOT NULL, +-- "database" varchar NULL, +-- "schema" varchar NULL, +-- "table" varchar NULL, +-- "name" varchar NULL, +-- value text NULL +-- ); + + +-- -- public.nfr_provision definition + +-- -- Drop table + +-- -- DROP TABLE public.nfr_provision; + +-- CREATE TABLE public.nfr_provision ( +-- id serial4 NOT NULL, +-- "type" varchar NULL, +-- provision_name varchar NULL, +-- free_text varchar NULL, +-- help_text varchar NULL, +-- category varchar NULL, +-- active_flag bool NULL, +-- create_userid varchar NULL, +-- update_userid varchar NULL, +-- create_timestamp timestamp NOT NULL DEFAULT now(), +-- update_timestamp timestamp NOT NULL DEFAULT now(), +-- "provisionGroupId" int4 NULL, +-- CONSTRAINT "PK_c4a6f10af0456d58c04d4d145f3" PRIMARY KEY (id), +-- CONSTRAINT "FK_a43df8873b446878b2ee5cebb24" FOREIGN KEY ("provisionGroupId") REFERENCES public.nfr_provision_group(id) +-- ); + + +-- -- public.nfr_provision_provision_variant_nfr_provision_variant definition + +-- -- Drop table + +-- -- DROP TABLE public.nfr_provision_provision_variant_nfr_provision_variant; + +-- CREATE TABLE public.nfr_provision_provision_variant_nfr_provision_variant ( +-- "nfrProvisionId" int4 NOT NULL, +-- "nfrProvisionVariantId" int4 NOT NULL, +-- CONSTRAINT "PK_5b9a48b11c13574b2a9304958af" PRIMARY KEY ("nfrProvisionId", "nfrProvisionVariantId"), +-- CONSTRAINT "FK_29eff651c342499678c06aad32b" FOREIGN KEY ("nfrProvisionVariantId") REFERENCES public.nfr_provision_variant(id) ON DELETE CASCADE ON UPDATE CASCADE, +-- CONSTRAINT "FK_636125267180d5eaf59688a2a43" FOREIGN KEY ("nfrProvisionId") REFERENCES public.nfr_provision(id) ON DELETE CASCADE ON UPDATE CASCADE +-- ); +-- CREATE INDEX "IDX_29eff651c342499678c06aad32" ON public.nfr_provision_provision_variant_nfr_provision_variant USING btree ("nfrProvisionVariantId"); +-- CREATE INDEX "IDX_636125267180d5eaf59688a2a4" ON public.nfr_provision_provision_variant_nfr_provision_variant USING btree ("nfrProvisionId"); + + +-- -- public.nfr_provision_variable definition + +-- -- Drop table + +-- -- DROP TABLE public.nfr_provision_variable; + +-- CREATE TABLE public.nfr_provision_variable ( +-- id serial4 NOT NULL, +-- variable_name varchar NULL, +-- variable_value varchar NULL, +-- help_text varchar NULL, +-- create_userid varchar NULL, +-- update_userid varchar NULL, +-- create_timestamp timestamp NOT NULL DEFAULT now(), +-- update_timestamp timestamp NOT NULL DEFAULT now(), +-- "provisionId" int4 NULL, +-- CONSTRAINT "PK_e7bc9c66c16a184bea624bd8d97" PRIMARY KEY (id), +-- CONSTRAINT "FK_b24f739d9a39f30051eb9500650" FOREIGN KEY ("provisionId") REFERENCES public.nfr_provision(id) +-- ); + + +-- -- public.nfr_data_provision definition + +-- -- Drop table + +-- -- DROP TABLE public.nfr_data_provision; + +-- CREATE TABLE public.nfr_data_provision ( +-- id serial4 NOT NULL, +-- provision_free_text varchar NULL, +-- "nfrProvisionId" int4 NULL, +-- "nfrDataId" int4 NULL, +-- CONSTRAINT "PK_73a4f1b680a4ab0819beb7a83ba" PRIMARY KEY (id), +-- CONSTRAINT "FK_31783ee54c5bc5e6b76a2803123" FOREIGN KEY ("nfrProvisionId") REFERENCES public.nfr_provision(id) ON DELETE CASCADE, +-- CONSTRAINT "FK_de4669e0ff571ddf23c9490059c" FOREIGN KEY ("nfrDataId") REFERENCES public.nfr_data(id) ON DELETE CASCADE +-- ); + + +-- -- public.nfr_data_variable definition + +-- -- Drop table + +-- -- DROP TABLE public.nfr_data_variable; + +-- CREATE TABLE public.nfr_data_variable ( +-- id serial4 NOT NULL, +-- data_variable_value varchar NULL, +-- "nfrVariableId" int4 NULL, +-- "nfrDataId" int4 NULL, +-- CONSTRAINT "PK_78b5abaae0c841c70d3dbe79dd4" PRIMARY KEY (id), +-- CONSTRAINT "FK_2f9dc95b75fb29c01a332823044" FOREIGN KEY ("nfrVariableId") REFERENCES public.nfr_provision_variable(id) ON DELETE CASCADE, +-- CONSTRAINT "FK_76bc71b9b4fbbcdd622bab0ff19" FOREIGN KEY ("nfrDataId") REFERENCES public.nfr_data(id) ON DELETE CASCADE +-- ); \ No newline at end of file diff --git a/backend/db2/V1.1.1__TICDI_Data_Nov-10-23.sql b/backend/db2/V1.1.1__TICDI_Data_Nov-10-23.sql new file mode 100644 index 00000000..63b9cfd8 --- /dev/null +++ b/backend/db2/V1.1.1__TICDI_Data_Nov-10-23.sql @@ -0,0 +1,339 @@ +BEGIN; +SET CLIENT_ENCODING TO 'utf8'; +ALTER TABLE public.nfr_provision_group DISABLE TRIGGER ALL; +ALTER TABLE public.nfr_provision DISABLE TRIGGER ALL; +ALTER TABLE public.nfr_provision_variable DISABLE TRIGGER ALL; +ALTER TABLE public.nfr_provision_variant DISABLE TRIGGER ALL; +ALTER TABLE public.nfr_provision_provision_variant_nfr_provision_variant DISABLE TRIGGER ALL; + +-- nfr_provision_group +INSERT INTO public.nfr_provision_group (provision_group,provision_group_text,max) VALUES + (1,'DOCUMENT TYPE',999), + (2,'FEES',999), + (5,'PREAMBLE',3), + (15,'OCCUPATIONAL RENT',1), + (20,'SECURITY',2), + (25,'INSURANCE',2), + (28,'',3), + (27,'ADDITIONAL REQUIREMENTS',999), + (34,'ADDITIONAL REQUIREMENTS',999), + (10,'SURVEY REQUIREMENTS',999); +INSERT INTO public.nfr_provision_group (provision_group,provision_group_text,max) VALUES + (14,'OBTAIN SURVEY',999), + (12,'SURVEY FEES',1); + +--nfr_provision +INSERT INTO public.nfr_provision ("type",provision_name,free_text,help_text,category,active_flag,create_userid,update_userid,create_timestamp,update_timestamp,"provisionGroupId") VALUES + ('O','INSURANCE REQUIRED - NFR OBTAIN SURVEY- OTHER','You must at your expense, effect and keep in force insurance as described in the enclosed «INTERIM_TENURE_TYPE».','Use when insurance is required on the interim tenure and may be covered under homeowners insurance etc.','OFFER - INSURANCE',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-22 16:38:55.979829',9), + ('O','ADDITIONAL REQUIREMENTS - FISHERIES AND OCEANS APPROVAL','You must deliver to us a copy of a permit issued by the Federal Department of Fisheries and Oceans in respect of your proposed use of the Land for aquaculture purposes.','Use to require delivery of a copy of a permit from Fisheries and Oceans for aquaculture purposes.','ADDITIONAL REQUIREMENTS',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-15 14:46:47.992471',10), + ('O','FREE FIELD - PREAMBLE INFORMATION','«PREAMBLE_FREE_FIELD»','Use when you want to enter additional information for the preamble','OFFER PREAMBLE',true,NULL,'LOMILLER','2023-06-02 15:57:07.279427','2023-06-26 17:42:07.859382',3), + ('M','TEMPLATE VARIABLES - NFR - NO FEES','','Nominal rent tenures e.g. for community purposes being issued. Do not use for Crown Grants.  No additional fees are being requested.','DOCUMENT TYPE',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-15 17:46:18.385388',1), + ('O','FREE FIELD FOR INSURANCE','«INSURANCE_FREE_FIELD»','Use when you want to enter additional information for insurance.','OFFER - INSURANCE',true,NULL,'LOMILLER','2023-06-02 15:57:07.279427','2023-06-26 18:38:59.492308',9), + ('M','FEES','','Use this to create a table listing all the fees to be paid. Table is unprotected, will be able to modify text ','FEES',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-22 16:23:44.53137',2), + ('O','DELIVER SECURITY DEPOSIT','You must deliver to us a security deposit in the amount of $«SECURITY_AMOUNT» to guarantee the performance of your obligations under the «DB_TENURE_TYPE». Please see attached information regarding acceptable types of security.','Use this to require delivery of security deposit','OFFER - SECURITY',true,NULL,'LOMILLER','2023-06-02 15:57:07.279427','2023-06-21 21:41:03.491356',8), + ('M','TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW','','majority of the new tenures and replacement tenures when survey is not required. Do not use for Crown Grants or when no additional fees are requested such as Nominal Rent tenures.','DOCUMENT TYPE',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-13 21:16:55.658566',1), + ('O','FREE FIELD FOR SECURITY SECTION','«SECURITY_FREE_FIELD»','Use where you need to add information regarding security','OFFER - SECURITY',true,NULL,'LOMILLER','2023-06-02 15:57:07.279427','2023-06-26 17:44:08.717371',8), + ('O','BOUNDARY SURVEY PLAN - CLIENT PAYS','In preparing the boundary survey the surveyor is also to indicate on the plan the location, type and dimensions of all existing improvements on the Land.','Use when "as built" survey of existing improvements is required.','OFFER SURVEY',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-27 14:57:22.134285',4); +INSERT INTO public.nfr_provision ("type",provision_name,free_text,help_text,category,active_flag,create_userid,update_userid,create_timestamp,update_timestamp,"provisionGroupId") VALUES + ('V','MONIES PAYABLE - NFR DELAYED','You must deliver to us the following amounts:','Use when you are providing a firm amount payable.','OFFER SURVEY',true,NULL,'LOMILLER','2023-06-02 15:57:07.279427','2023-06-28 18:33:54.808381',5), + ('O','LETTER AFFIRMING BOUNDARY SURVEY','This letter must confirm that in preparing the boundary survey the surveyor will also indicate on the plan the location, type and dimensions of all existing improvements on the Land.','Use to remind client that Surveyor’s letter must confirm that location of improvements will be on boundary plan','OFFER - OBTAIN SURVEY',true,NULL,'LOMILLER','2023-06-02 15:57:07.279427','2023-06-22 23:32:25.268378',6), + ('O','DELIVER SECURITY DEPOSIT - OBTAIN SURVEY','You must deliver to us a security deposit in the amount of $«SECURITY_AMOUNT» to guarantee the performance of your obligations under the «INTERIM_TENURE_TYPE». Please see attached information regarding acceptable types of security.','Use this when security is required for the interim tenure','OFFER - SECURITY',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-22 16:44:32.291826',8), + ('O','LETTER AFFIRMING BC LAND SURVEYOR WAS HIRED','«DEADLINE_CONFIRM_SURVEY» you must submit to us a letter from a British Columbia Land Surveyor confirming that you have hired the surveyor to prepare a boundary survey of the Land at your expense.','When client must provide us with a letter confirming Surveyor has been hired','OFFER - OBTAIN SURVEY',true,NULL,'LOMILLER','2023-06-02 15:57:07.279427','2023-06-22 23:32:10.132454',6), + ('O','ADDITIONAL REQUIREMENTS - AFFILIATE STATUS CERTIFICATE','You must deliver to us a certificate of affiliate status, in the form attached, for each affiliate of your company which will be using the communication site.','Use when a certificate of affiliate status is required for each affiliate of your company using the communication site.','ADDITIONAL REQUIREMENTS',true,NULL,'BSALL','2023-06-02 15:57:07.364365','2023-06-22 16:45:03.795999',10), + ('O','FREE FIELD - ADDITIONAL REQUIREMENTS','«ADDITIONAL_REQUIREMENTS_FREE_FIELD»','Use where you want to state additional conditions of the offer','ADDITIONAL REQUIREMENTS',true,NULL,'LOMILLER','2023-06-02 15:57:07.364365','2023-06-26 17:48:12.021686',10), + ('O','INSURANCE REQUIRED - NFR - OTHER','You must at your expense, effect and keep in force insurance as described in the enclosed ','Use when insurance is required and may be covered under homeowners insurance etc.','OFFER - INSURANCE',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-22 16:38:10.794413',9), + ('O','REPLACEMENT STATEMENT','This is to replace «REPLACEMENT_TENURE_TYPE».',' Use this when the tenure is being replaced ','OFFER PREAMBLE',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-20 18:16:12.396934',3), + ('O','OCCUPATIONAL RENT STATEMENT','Please note that Occupational Rental under section 96 of the Land Act is payable for your occupation of the Land for the period from <>.','Use this when occupational rent is payable','OFFER - MONIES - PAYABLE',true,NULL,'LOMILLER','2023-06-02 15:57:07.364365','2023-06-21 23:52:11.226929',7), + ('O','ADDITIONAL REQUIREMENTS - MANAGEMENT PLAN','You must submit to us a management plan that is acceptable to us for your proposed development of the Land.','Use to require delivery of a management plan.','ADDITIONAL REQUIREMENTS',true,NULL,'LOMILLER','2023-06-02 15:57:07.364365','2023-06-12 21:33:54.879335',10); +INSERT INTO public.nfr_provision ("type",provision_name,free_text,help_text,category,active_flag,create_userid,update_userid,create_timestamp,update_timestamp,"provisionGroupId") VALUES + ('M','FEES','','Use this to create a table listing all the fees to be paid. Table is unprotected, will be able to modify text ','FEES',true,NULL,'BSALL','2023-06-02 15:57:07.364365','2023-06-29 21:41:36.444092',2), + ('O','LAND DIFFERS FROM STATEMENT','The Land differs from what you applied for because «WHY_LAND_DIFFERS».','Use when land being offered differs from the applied area','OFFER PREAMBLE',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-20 18:16:44.295381',3), + ('M','TEMPLATE VARIABLES - NFR - DELAYED','','Use when applicant requires assurance tenure will be issued once additional requirements are fulfilled. (eg zoning, reports)','DOCUMENT TYPE',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-15 17:46:42.133675',1), + ('V','SURVEY DEPOSIT','You must, by «DEADLINE_SURVEY_DEPOSIT», pay to us a deposit of $«DEPOSIT_AMOUNT_SURVEY» (which, if a tenure is issued to you following completion of survey, will be credited against the amounts owing for that tenure). If you choose not to proceed with the survey after it has been started, the deposit will be forfeited to the Province as liquidated damages. Please make your cheque or money order payable to the Minister of Finance and deliver it to «DB_ADDRESS_LINE_REGIONAL_OFFICE».','Use when we require a deposit from the client because the Province is paying for the survey','OFFER SURVEY',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-27 20:36:16.969351',5), + ('V','ESTIMATED MONIES PAYABLE - NFR - DELAYED','You must deliver to us the following amounts as set out below (estimated amounts are set out below). The final amounts owing will be calculated when the survey is complete and the area of the Land has been established. It will include the following items, some of which are subject to adjustment if the survey plan and area of the Land do not, in our opinion, conform to the attached sketch.','Use when you are providing an estimated amount payable.','OFFER SURVEY',true,NULL,'LOMILLER','2023-06-02 15:57:07.279427','2023-06-28 18:34:04.60236',5), + ('O','ADDITIONAL REQUIREMENTS - TAX CLEARANCE CERTIFICATE','You must deliver to us a Tax Clearance Certificate, obtained from the Provincial Tax Collector’s office at «TAX_COLLECTOR_OFFICE», verifying that there are no arrears of taxes in connection with the Land.','Use when a tax clearance certificate is required verifying that there are no arrears of taxes.','ADDITIONAL REQUIREMENTS',true,NULL,'LOMILLER','2023-06-02 15:57:07.364365','2023-06-12 21:36:03.361001',10), + ('O','ADDITIONAL REQUIREMENTS - ZONING APPROVAL','You must deliver to us written confirmation from «LOCAL_GOVERNMENT» stating that it has adopted a zoning bylaw permitting the Land to be used for «PURPOSE_GENERIC_ZONING» purposes.','Use to require confirmation that a zoning bylaw permitting use of the Land for the intended purposes has been adopted.','ADDITIONAL REQUIREMENTS',true,NULL,'LOMILLER','2023-06-02 15:57:07.364365','2023-06-13 18:13:04.140914',10), + ('O','ADDITIONAL REQUIREMENTS - OBTAIN AND DELIVER','You must obtain the «DOCUMENT_TO_OBTAIN» and «DEADLINE_TO_DELIVER», deliver a copy of it to us.','Use when you require immediate delivery of documentation.','ADDITIONAL REQUIREMENTS',true,NULL,'BSALL','2023-06-02 15:57:07.364365','2023-06-13 21:01:39.704815',10), + ('O','ADDITIONAL REQUIREMENTS - COAST GUARD APPROVAL','You must deliver to us a copy of a letter of approval from the Canadian Coast Guard under the Navigable Waters Protection Act for your proposed construction on the Land. In this regard, please contact: Canadian Coast Guard, «COAST_GUARD_ADDRESS».','Use to require delivery of a letter of approval from the Canadian Coast Guard for the proposed construction.','ADDITIONAL REQUIREMENTS',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-15 14:46:33.558354',10), + ('O','BOUNDARY SURVEY PLAN - MINISTRY PAYS','A boundary survey of the Land will be undertaken by a British Columbia Land Surveyor hired by us.','Use when we will pay a Surveyor to prepare a boundary survey','OFFER PREAMBLE',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-27 14:57:45.158502',4); +INSERT INTO public.nfr_provision ("type",provision_name,free_text,help_text,category,active_flag,create_userid,update_userid,create_timestamp,update_timestamp,"provisionGroupId") VALUES + ('M','TEMPLATE VARIABLES - NFR - SURVEY REQUIRED','','Survey of the Land/improvements is required prior to issuance of tenure. E.g. when its a decision to convert an existing Licence for a Lease or SRW. Not to be used for Crown Grants.','DOCUMENT TYPE',true,NULL,'BSALL','2023-06-02 15:57:07.364365','2023-06-15 17:47:18.794212',1), + ('M','TEMPLATE VARIABLES - NFR- TO OBTAIN SURVEY','','Interim tenure is being issued for survey purposes and/or initial activity. A subsequent tenure will be issued upon completion of the requirements set out in interim tenure. Not to be used for Crown Grants.','DOCUMENT TYPE',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-22 16:19:52.911188',1), + ('O','BLANKET SECURITY STATEMENT','According to our records, you are currently covered by a blanket security agreement between the Province and «BLANKET_BOND_NAME». As long as this agreement is in good standing and you continue to be covered by it, you are not required to post security for this «DB_TENURE_TYPE» unless and until you receive further notice from us.','Use this when client is covered by blanket security agreement','OFFER - SECURITY',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-22 17:15:25.058373',8), + ('O','ADDITIONAL REQUIREMENTS - IMPROVEMENTS STAT DEC','You must deliver to us a statutory declaration, in the form attached, stating that all improvements on the Land are either owned by you or have been constructed, erected or place on the Land by you. Please sign this declaration in front of a solicitor or notary public.','Use this when a statutory declaration is required regarding ownership of improvements.','ADDITIONAL REQUIREMENTS',true,NULL,'BSALL','2023-06-02 15:57:07.364365','2023-06-20 20:34:35.62335',10), + ('O','SURVEY - CLIENT - PAYS','«DEADLINE_CONFIRM_SURVEY», you must retain a British Columbia Land Surveyor to prepare a boundary survey of the Land at your expense. + +The survey must be completed and the plan submitted to the Surveyor General on or before «DEADLINE_COMPLETE_SURVEY». If the survey is not completed on or before that date, and that date is not otherwise extended in writing by us we are under no further obligation to issue a «DB_TENURE_TYPE» of the Land to you.','Use when client pays for survey','OFFER SURVEY',true,NULL,'LOMILLER','2023-06-02 15:57:07.364365','2023-06-21 21:39:34.632611',4), + ('O','INSURANCE REQUIRED - NFR - CERTIFICATE REQUIRED','You must deliver to us the attached Province of British Columbia Certificate of Insurance, signed by your insurance agent, for the insurance required to be maintained under the «DB_TENURE_TYPE». A sample certificate is enclosed.','Use when a Certificate of Insurance is required.','OFFER - INSURANCE',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-22 16:41:47.327374',9), + ('O','INSURANCE REQUIRED - NFR OBTAIN SURVEY - CERTIFICATE','You must deliver to us the attached Province of British Columbia Certificate of Insurance, signed by your insurance agent, for the insurance required to be maintained under the «INTERIM_TENURE_TYPE». A sample certificate is enclosed.','Use when a Certificate of Insurance is required.','OFFER - INSURANCE',true,NULL,'BSALL','2023-06-02 15:57:07.364365','2023-06-22 16:41:32.284043',9), + ('O','SURVEY - MINISTRY PAYS (DEPOSIT REQUIRED) -NFR DELAYED','A boundary survey of the Land will be undertaken by a British Columbia Land Surveyor hired by us. + +You must, by «DEADLINE_SURVEY_DEPOSIT», pay to us a deposit of $«DEPOSIT_AMOUNT_SURVEY» (which, if the «DB_TENURE_TYPE» is issued, will be credited against the amounts set out below that you are required to pay). If you choose not to proceed with the «DB_TENURE_TYPE» after the survey has been started, the deposit will be forfeited to the Province as liquidated damages. Please make your cheque or money order payable to the Minister of Finance and deliver it to «DB_ADDRESS_LINE_REGIONAL_OFFICE». + +If the survey is completed in accordance with the requirements set out above, we will complete the «DB_TENURE_TYPE» documents by inserting the correct legal description for the Land and by inserting the required monies payable. The monies payable are calculated on the basis of the area of the Land at a rate of $«RATE_PER_METRE_SURVEY_DEPOSIT_DELAYED». If the area of the Land exceeds «MAXIMUM_AREA_SURVEY_DEPOSIT_DELAYED», this offer terminates unless we agree with you in writing to proceed with the issuance of the «DB_TENURE_TYPE».','Use to require payment of a deposit where Province is to pay for a survey.','OFFER SURVEY',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-27 15:09:33.645396',4), + ('O','BLANKET SECURITY - OBTAIN SURVEY','According to our records, you are currently covered by a blanket security agreement between the Province and «BLANKET_BOND_NAME». As long as this agreement is in good standing and you continue to be covered by it, you are not required to post security for this «INTERIM_TENURE_TYPE» until you receive further notice from us.','Client has a blanket security - we are issuing interim tenure','OFFER - SECURITY',true,NULL,'BSALL','2023-06-02 15:57:07.279427','2023-06-22 16:58:36.242497',8), + ('O','SURVEY - CLIENT PAYS - NFR DELAYED','«DEADLINE_CONFIRM_SURVEY», you must retain a British Columbia Land Surveyor to prepare a boundary survey of the Land at your expense. + +The survey must be completed, and the plan submitted to the Surveyor General on or before «DEADLINE_COMPLETE_SURVEY». If the survey is not completed on or before that date, and that date is not otherwise extended in writing by us we are under no further obligation to issue a «DB_TENURE_TYPE» of the Land to you. + +If the survey is completed in accordance with the requirements set out above, we will complete the «DB_TENURE_TYPE» documents by inserting the correct legal description for the Land and by inserting the required monies payable. The monies payable are calculated on the basis of the area of the Land at a rate of $«RATE_PER_METRE». If the area of the Land exceeds «MAXIMUM_AREA», this offer terminates unless we agree with you in writing to proceed with the issuance of the «DB_TENURE_TYPE».','Use when the client pays for survey.','OFFER SURVEY',true,NULL,'LOMILLER','2023-06-02 15:57:07.279427','2023-07-20 19:12:59.172236',4); +INSERT INTO public.nfr_provision ("type",provision_name,free_text,help_text,category,active_flag,create_userid,update_userid,create_timestamp,update_timestamp,"provisionGroupId") VALUES + ('O','SURVEY DEPOSIT REQUIRED','You must, by «DEADLINE_SURVEY_DEPOSIT», pay to us a deposit of $«DEPOSIT_AMOUNT_SURVEY» (which, if the «DB_TENURE_TYPE» is issued, will be credited against the amounts set out below that you are required to pay). + +If you choose not to proceed with the «DB_TENURE_TYPE» after the survey has been started, the deposit will be forfeited to the Province as liquidated damages. Please make your cheque or money order payable to the Minister of Finance and deliver it to «DB_ADDRESS_LINE_REGIONAL_OFFICE».','Use to require payment of a deposit where Province is to pay for a survey.','OFFER SURVEY',true,NULL,'BSALL','2023-06-02 15:57:07.364365','2023-06-27 20:35:35.371359',4), + ('O','DELIVER SECURITY DEPOSIT & SURVEY DEPOSIT','In addition to the deposit referred to in the “Survey” portion of this letter, you must deliver to us a security deposit in the amount of $«SECURITY_AMOUNT» to guarantee the performance of your obligations under the «DB_TENURE_TYPE». Please see attached information regarding acceptable types of security.','Use this where 2 deposits are to be delivered: one for the survey and another for clean-up under the terms of the tenure to be issued','OFFER - SECURITY',true,NULL,'BSALL','2023-06-02 15:57:07.364365','2023-06-30 15:22:22.442357',8); + +-- nfr_provision_variable +INSERT INTO public.nfr_provision_variable (variable_name,variable_value,help_text,create_userid,update_userid,create_timestamp,update_timestamp,"provisionId") VALUES + ('DATE_OF_NOTICE','','Date of letter: Month Day ,Year',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',1), + ('DEADLINE_COMPLETION_REQUIREMENTS','','Enter the date (month day, year) for completion of requirements',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',1), + ('FACSIMILE_NUMBER','','Type in your facsimile number - "250 ___-____"',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',1), + ('PURPOSE_GENERIC','','used for "_________" purposes.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',1), + ('SALUTATION','','Dear "______": Type in the person’’s name or Sir or Madam.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',1), + ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',1), + ('SECURITY_AMOUNT','','#.## to post as security - indicate an amount even if blanket bond applies. Put in Decimal.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',7), + ('COAST_GUARD_ADDRESS','','Type in the address of the Canadian Coast Guard office.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',22), + ('DATE_OF_NOTICE','','Date of letter: Month Day ,Year',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',23), + ('DEADLINE_COMPLETION_REQUIREMENTS','','Enter the date (month day, year) for completion of requirements',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',23); +INSERT INTO public.nfr_provision_variable (variable_name,variable_value,help_text,create_userid,update_userid,create_timestamp,update_timestamp,"provisionId") VALUES + ('FACSIMILE_NUMBER','','Type in your facsimile number - "250 ___-____"',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',23), + ('PURPOSE_GENERIC','','used for "_________" purposes.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',23), + ('SALUTATION','','Dear "______": Type in the person’’s name or Sir or Madam.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',23), + ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',23), + ('DATE_OF_NOTICE','','Date of letter: Month Day ,Year',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',41), + ('DEADLINE_COMPLETION_REQUIREMENTS','','Enter the date (month day, year) for completion of requirements',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',41), + ('FACSIMILE_NUMBER','','Type in your facsimile number - "250 ___-____"',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',41), + ('PURPOSE_GENERIC','','used for "_________" purposes.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',41), + ('CLIENT_FILE_NO','','Your file: "______"',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-13 21:20:25.383347',1), + ('NUMBER_OF_COPIES','','type the number (two) of how many copies of the tenure documents are being forwarded to client to sign. ',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-13 21:26:39.628364',23); +INSERT INTO public.nfr_provision_variable (variable_name,variable_value,help_text,create_userid,update_userid,create_timestamp,update_timestamp,"provisionId") VALUES + ('NUMBER_OF_COPIES','','type the number (two) of how many copies of the tenure documents are being forwarded to client to sign. ',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-13 21:25:44.257358',1), + ('ATTENTION_LINE','','Attention: "______"',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-13 21:26:50.872419',23), + ('CLIENT_FILE_NO','','Your file: "______"',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-13 21:27:04.425352',23), + ('ATTENTION_LINE','','Attention: "______"',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-13 21:28:04.897347',41), + ('CLIENT_FILE_NO','','Your file: "______" ',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-13 21:28:12.654356',41), + ('NUMBER_OF_COPIES','','type the number (two) of how many copies of the tenure documents are being forwarded to client to sign. ',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-13 21:28:32.644364',41), + ('FEE_DOCUMENTATION_AMOUNT','','EG: "1000.00" (no comma, and use decimals)',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-20 19:47:18.08737',2), + ('FEE_OCCUPATIONAL_RENTAL_AMOUNT','','EG: "1000.00" (no comma, and use decimals)',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-20 19:47:36.347441',2), + ('BLANKET_BOND_NAME','','enter details of blanket security',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-22 17:16:22.131377',8), + ('FEE_APPLICATION_AMOUNT','','EG: "1000.00" (no comma, and use decimals)',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-20 19:47:25.315439',2); +INSERT INTO public.nfr_provision_variable (variable_name,variable_value,help_text,create_userid,update_userid,create_timestamp,update_timestamp,"provisionId") VALUES + ('WHY_LAND_DIFFERS','','The Land differs from what you applied for because "____". Explain why area is different.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-13 21:36:29.985325',4), + ('REPLACEMENT_TENURE_TYPE','','Specify type and tenure number which is being replaced e.g. Lease No. 999999.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-16 20:36:04.20696',3), + ('FEE_OTHER_CREDIT_AMOUNT','','EG: "1000.00" (no comma, and use decimals)',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-20 19:47:45.891637',2), + ('SALUTATION','','Dear "______": Type in the person’’s name or Sir or Madam.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',41), + ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',41), + ('RATE_PER_METRE','','$"#.## per square metre/per hectare" Put in the decimal.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',46), + ('DEPOSIT_AMOUNT_SURVEY','','$"#.##" Enter amount of survey deposit. Put in the decimal.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',47), + ('DATE_OF_NOTICE','','Date of letter: Month Day ,Year',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',66), + ('DEADLINE_COMPLETION_REQUIREMENTS','','Enter the date (month day, year) for completion of requirements',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',66), + ('FACSIMILE_NUMBER','','Type in your facsimile number - "250 ___-____"',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',66); +INSERT INTO public.nfr_provision_variable (variable_name,variable_value,help_text,create_userid,update_userid,create_timestamp,update_timestamp,"provisionId") VALUES + ('INTERIM_TENURE_TYPE','','Insert the type of tenure now being used. e.g. Licence.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',66), + ('PURPOSE_GENERIC','','used for "_________" purposes.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',66), + ('SALUTATION','','Dear "______": Type in the person’’s name or Sir or Madam.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',66), + ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',66), + ('DEADLINE_SURVEY_DEPOSIT','','Deadline to pay survey deposit. Enter Month, Day, Year',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',72), + ('DEPOSIT_AMOUNT_SURVEY','','$"#.##" Enter amount of survey deposit. Put in the decimal.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',72), + ('DEADLINE_CONFIRM_SURVEY','','Enter "On or before [date]" OR "Within [45] days from the date of this letter". Capitalize first character as this is the start of a sentence.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',73), + ('SECURITY_AMOUNT','','#.## to post as security - indicate an amount even if blanket bond applies. Put in Decimal.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-02 15:57:07.279427',76), + ('ATTENTION_LINE','','Attention: "______" ',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-13 21:28:50.005304',66), + ('CLIENT_FILE_NO','','Your file: "______" ',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-13 21:28:57.756376',66); +INSERT INTO public.nfr_provision_variable (variable_name,variable_value,help_text,create_userid,update_userid,create_timestamp,update_timestamp,"provisionId") VALUES + ('NUMBER_OF_COPIES','','type the number (two) of how many copies of the tenure documents are being forwarded to client to sign. ',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-13 21:29:17.789098',66), + ('MAXIMUM_AREA_SURVEY_DEPOSIT_DELAYED','','Enter the number of hectares. EG. "0.5 hectares"',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-23 20:26:40.639362',47), + ('MAXIMUM_AREA','','Enter the number of hectares. EG. "0.5 hectares"',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-23 18:33:30.847392',46), + ('DEADLINE_CONFIRM_SURVEY','','Enter: "On or before [date]" this date is when the survey plan must be submitted to the SGs office',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-20 18:00:21.374354',46), + ('DEADLINE_SURVEY_DEPOSIT','','Deadline to pay survey deposit. Enter [date]',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-23 20:11:04.128362',47), + ('DEADLINE_COMPLETE_SURVEY','','Enter: [date] the survey must be completed by',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-21 15:43:07.536357',46), + ('RATE_PER_METRE_SURVEY_DEPOSIT_DELAYED','','$"#.## per square metre/per hectare" Put in the decimal.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-15 17:41:36.463885',47), + ('INTERIM_TENURE_TYPE','','(Blanket Security) Insert the type of tenure now being used. e.g. Licence.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-22 17:24:43.417375',77), + ('INTERIM_TENURE_TYPE','','(Security) Insert the type of tenure now being used. e.g. Licence.',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-22 17:25:02.184734',76), + ('BLANKET_BOND_NAME','','enter details of blanket security',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-22 17:16:03.192347',77); +INSERT INTO public.nfr_provision_variable (variable_name,variable_value,help_text,create_userid,update_userid,create_timestamp,update_timestamp,"provisionId") VALUES + ('FACSIMILE_NUMBER','','Type in your facsimile number - "250 ___-____"',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-02 15:57:07.364365',90), + ('PURPOSE_GENERIC','','used for "_________" purposes.',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-02 15:57:07.364365',90), + ('RATE_PER_METRE','','$"#.## per square metre/per hectare" Put in the decimal.',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-02 15:57:07.364365',90), + ('SALUTATION','','Dear "______": Type in the person’’s name or Sir or Madam.',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-02 15:57:07.364365',90), + ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-02 15:57:07.364365',90), + ('FEE_APPLICATION_AMOUNT','','$"#.##" payable. Fill in either amount, or "0" if nothing payable for this category of fee. Put in decimals.',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-02 15:57:07.364365',91), + ('FEE_OCCUPATIONAL_RENTAL_AMOUNT','','$"#.##" payable. Fill in either amount, or "0" if nothing payable for this category of fee. Put in decimals.',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-02 15:57:07.364365',91), + ('FEE_OTHER_CREDIT_AMOUNT','','$"#.##" payable. Fill in either amount, or "0" if nothing payable for this category of fee. Put in decimals.',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-02 15:57:07.364365',91), + ('DEADLINE_SURVEY_DEPOSIT','','Deadline to pay survey deposit. Enter Month, Day, Year',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-02 15:57:07.364365',96), + ('DEPOSIT_AMOUNT_SURVEY','','$"#.##" Enter amount of survey deposit. Put in the decimal.',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-02 15:57:07.364365',96); +INSERT INTO public.nfr_provision_variable (variable_name,variable_value,help_text,create_userid,update_userid,create_timestamp,update_timestamp,"provisionId") VALUES + ('SECURITY_AMOUNT','','#.## to post as security - indicate an amount even if blanket bond applies. Put in Decimal.',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-02 15:57:07.364365',101), + ('LOCAL_GOVERNMENT','','Type in the name of the local government.',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-02 15:57:07.364365',110), + ('TAX_COLLECTOR_OFFICE','','Type in the address of the local Provincial Tax Collector’’s office.',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-02 15:57:07.364365',112), + ('DOCUMENT_TO_OBTAIN','','You must obtain the [specify the name of the document(s)] and ....',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-02 15:57:07.364365',114), + ('PURPOSE_GENERIC_ZONING','','used for "_________" purposes.',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-13 18:06:54.115699',110), + ('ATTENTION_LINE','','Attention: "______" ',NULL,NULL,'2023-06-02 15:57:07.279427','2023-06-13 21:16:49.648451',1), + ('DAYS_TO_RETURN_DOCUMENTS','','Enter [# days] "You must sign and return them to us within (# days) of our letter to you .....’’',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-21 15:56:28.489881',90), + ('CLIENT_FILE_NO','','Your file: "______"',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-13 21:29:43.260364',90), + ('DATE_OF_NOTICE','','Date of letter: Month Day ,Year',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-13 21:30:06.91673',90), + ('NUMBER_OF_COPIES','','type the number (two) of how many copies of the tenure documents are being forwarded to client to sign. ',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-13 21:30:30.231347',90); +INSERT INTO public.nfr_provision_variable (variable_name,variable_value,help_text,create_userid,update_userid,create_timestamp,update_timestamp,"provisionId") VALUES + ('DEADLINE_CONFIRM_SURVEY','','Enter "On or before [date]" .. this is the date the surveyor must be hired by',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-14 22:18:37.124318',97), + ('PREAMBLE_FREE_FIELD','','Use when you want to enter additional information for the preamble','LOMILLER',NULL,'2023-06-26 17:30:55.159152','2023-06-26 17:31:31.493375',5), + ('ATTENTION_LINE','','Attention: "______"',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-16 21:02:12.755383',90), + ('INSURANCE_FREE_FIELD','','Use when you want to enter additional information for insurance.','LOMILLER',NULL,'2023-06-26 17:45:00.98355','2023-06-26 18:38:56.168009',12), + ('DEADLINE_COMPLETION_REQUIREMENTS','','Enter the date (month day, year) for completion of requirements for the NFR',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-20 17:48:10.48195',90), + ('MAXIMUM_AREA','','Enter: "# hectares"',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-20 18:01:49.180358',90), + ('OCC_RENT_DETAILS','','Occupational Rental is payable for your occupation of the Land for the period from "___". ',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-20 23:08:37.630361',99), + ('ADDITIONAL_REQUIREMENTS_FREE_FIELD','','Use where you want to state additional conditions of the offer.','LOMILLER',NULL,'2023-06-26 17:48:35.340383','2023-06-26 18:39:33.478342',107), + ('DEADLINE_COMPLETE_SURVEY','','Enter the date (month day, year) the plan must be submitted to the SG''s office',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-21 15:50:26.530352',97), + ('DAYS_TO_DELIVER_DOCUMENTS','','Enter [# days] .. "We will forward the documents to you within # days of the survey being completed.....’’',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-21 15:55:14.497797',90); +INSERT INTO public.nfr_provision_variable (variable_name,variable_value,help_text,create_userid,update_userid,create_timestamp,update_timestamp,"provisionId") VALUES + ('INTERIM_TENURE_TYPE','','(Insurance Other) Insert the type of tenure now being used. e.g. Licence.','BSALL',NULL,'2023-06-15 18:18:50.859363','2023-06-22 17:23:27.119879',30), + ('INTERIM_TENURE_TYPE','','(Insurance Certificate) Insert the type of tenure now being used. e.g. Licence.','BSALL',NULL,'2023-06-15 18:15:43.795116','2023-06-22 17:24:10.979754',79), + ('SECURITY_FREE_FIELD','','Use where you need to add information regarding security.','LOMILLER',NULL,'2023-06-23 21:00:33.78888','2023-06-23 21:00:33.78888',9), + ('DEADLINE_TO_DELIVER','','(Obtain and Deliver) Enter "on or before [date]" OR "within [45] days from the date of this letter.',NULL,NULL,'2023-06-02 15:57:07.364365','2023-06-27 22:08:08.797474',114); + +-- nfr_provision_variant +INSERT INTO public.nfr_provision_variant (variant_name) VALUES + ('NOTICE OF FINAL REVIEW'), + ('NOTICE OF FINAL REVIEW (DELAYED)'), + ('NOTICE OF FINAL REVIEW (NO FEES)'), + ('NOTICE OF FINAL REVIEW (SURVEY REQUIRED)'), + ('NOTICE OF FINAL REVIEW (TO OBTAIN SURVEY)'); + +-- nfr_provision_provision_variant_nfr_provision_variant +INSERT INTO public.nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId","nfrProvisionVariantId") VALUES + (1,1), + (2,1), + (3,1), + (4,1), + (5,1), + (114,1), + (7,1), + (8,1), + (9,1), + (10,1); +INSERT INTO public.nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId","nfrProvisionVariantId") VALUES + (11,1), + (12,1), + (114,2), + (114,3), + (114,5), + (110,2), + (22,2), + (22,3), + (22,4), + (21,1); +INSERT INTO public.nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId","nfrProvisionVariantId") VALUES + (22,1), + (23,3), + (22,5), + (21,2), + (21,3), + (21,4), + (21,5), + (48,4), + (71,4), + (101,2); +INSERT INTO public.nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId","nfrProvisionVariantId") VALUES + (77,5), + (79,5), + (30,5), + (91,4), + (96,5), + (101,5), + (41,2), + (46,2), + (47,2), + (48,2); +INSERT INTO public.nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId","nfrProvisionVariantId") VALUES + (49,2), + (50,2), + (66,5), + (71,5), + (73,5), + (74,5), + (76,5), + (90,4), + (96,4), + (97,4); +INSERT INTO public.nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId","nfrProvisionVariantId") VALUES + (99,4), + (101,4), + (107,4), + (109,4), + (110,4), + (111,4), + (112,4), + (113,4), + (114,4), + (4,2); +INSERT INTO public.nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId","nfrProvisionVariantId") VALUES + (4,3), + (4,4), + (4,5), + (3,2), + (3,3), + (3,4), + (3,5), + (2,2), + (2,5), + (10,2); +INSERT INTO public.nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId","nfrProvisionVariantId") VALUES + (10,3), + (10,4), + (11,2), + (11,3), + (11,4), + (12,2), + (12,3), + (12,4), + (12,5), + (5,2); +INSERT INTO public.nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId","nfrProvisionVariantId") VALUES + (5,3), + (5,4), + (5,5), + (99,1), + (99,2), + (99,5), + (7,3), + (7,2), + (7,4), + (8,3); +INSERT INTO public.nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId","nfrProvisionVariantId") VALUES + (8,2), + (8,4), + (9,3), + (9,2), + (9,5), + (9,4), + (107,1), + (107,2), + (107,3), + (107,5); +INSERT INTO public.nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId","nfrProvisionVariantId") VALUES + (109,1), + (109,2), + (109,3), + (109,5), + (110,1), + (110,3), + (110,5), + (111,1), + (111,2), + (111,3); +INSERT INTO public.nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId","nfrProvisionVariantId") VALUES + (111,5), + (112,1), + (112,2), + (112,3), + (112,5), + (113,1), + (113,2), + (113,3), + (113,5); + +ALTER TABLE public.nfr_provision_group ENABLE TRIGGER ALL; +ALTER TABLE public.nfr_provision ENABLE TRIGGER ALL; +ALTER TABLE public.nfr_provision_variable ENABLE TRIGGER ALL; +ALTER TABLE public.nfr_provision_variant ENABLE TRIGGER ALL; +ALTER TABLE public.nfr_provision_provision_variant_nfr_provision_variant ENABLE TRIGGER ALL; + +COMMIT; \ No newline at end of file diff --git a/backend/src/admin/admin.controller.ts b/backend/src/admin/admin.controller.ts index 44343642..09e9f4b9 100644 --- a/backend/src/admin/admin.controller.ts +++ b/backend/src/admin/admin.controller.ts @@ -97,7 +97,7 @@ export class AdminController { file: Express.Multer.File, @Body() params: { - document_type: string; + document_type_id: number; template_name: string; } ) { @@ -112,7 +112,7 @@ export class AdminController { : '' : ''; const uploadData = { - document_type: params.document_type, + document_type_id: params.document_type_id, active_flag: false, mime_type: file.mimetype, file_name: params.template_name, @@ -183,9 +183,9 @@ export class AdminController { return this.adminService.getTemplates(reportId); } - @Get('open-document/:nfr_id') - setSessionDocument(@Session() session: { data?: SessionData }, @Param('nfr_id') nfrId: number): void { - session.data.selected_document = { nfr_id: nfrId }; + @Get('open-document/:document_id') + setSessionDocument(@Session() session: { data?: SessionData }, @Param('document_id') documentId: number): void { + session.data.selected_document = { document_id: documentId }; } @Get('get-templates/:document_type') @@ -193,12 +193,12 @@ export class AdminController { return this.adminService.getDocumentTemplates(documentType); } - @Get('nfr-provisions') + @Get('provisions') getNFRProvisions(): any { return this.adminService.getNFRProvisions(); } - @Get('nfr-variables') + @Get('document-variables') getNFRVariables(): any { return this.adminService.getNFRVariables(); } diff --git a/backend/src/admin/admin.service.ts b/backend/src/admin/admin.service.ts index 8bd11508..b2afe4c2 100644 --- a/backend/src/admin/admin.service.ts +++ b/backend/src/admin/admin.service.ts @@ -4,6 +4,7 @@ import { HttpService } from '@nestjs/axios'; import { ExportDataObject, SearchResultsItem, UserObject } from 'utils/types'; import { REPORT_TYPES } from 'utils/constants'; import { DocumentTemplateService } from 'src/document_template/document_template.service'; +import { DocumentType } from 'src/document_type/entities/document_type.entity'; const axios = require('axios'); const FormData = require('form-data'); @@ -51,7 +52,7 @@ export class AdminService { async uploadTemplate( data: { - document_type: string; + document_type_id: number; active_flag: boolean; mime_type: string; file_name: string; @@ -62,7 +63,7 @@ export class AdminService { ): Promise { return this.documentTemplateService.create( { - document_type: data.document_type, + document_type_id: data.document_type_id, template_author: data.template_author, mime_type: data.mime_type, file_name: data.file_name, @@ -340,7 +341,7 @@ export class AdminService { 'active_flag', 'variants', ]; - const url = `${hostname}:${port}/nfr-provision`; + const url = `${hostname}:${port}/provision`; const nfrProvisions = await axios .get(url) .then((res) => { @@ -362,7 +363,7 @@ export class AdminService { async getNFRVariables(): Promise { const returnItems = ['variable_name', 'variable_value', 'help_text', 'id', 'provision_id']; - const url = `${hostname}:${port}/nfr-provision/variables`; + const url = `${hostname}:${port}/provision/variables`; const nfrVariables = await axios .get(url) .then((res) => { @@ -383,21 +384,21 @@ export class AdminService { } async enableProvision(id: number): Promise { - const url = `${hostname}:${port}/nfr-provision/enable/${id}`; + const url = `${hostname}:${port}/provision/enable/${id}`; return await axios.get(url).then((res) => { return res.data; }); } async disableProvision(id: number): Promise { - const url = `${hostname}:${port}/nfr-provision/disable/${id}`; + const url = `${hostname}:${port}/provision/disable/${id}`; return await axios.get(url).then((res) => { return res.data; }); } async getGroupMax(): Promise { - const url = `${hostname}:${port}/nfr-provision/get-group-max/1`; + const url = `${hostname}:${port}/provision/get-group-max/1`; return await axios.get(url).then((res) => { return res.data; }); @@ -417,7 +418,7 @@ export class AdminService { }, create_userid: string ) { - const url = `${hostname}:${port}/nfr-provision`; + const url = `${hostname}:${port}/provision`; return await axios.post(url, { ...provisionParams, create_userid }).then((res) => { return res.data; }); @@ -438,7 +439,7 @@ export class AdminService { }, update_userid: string ) { - const url = `${hostname}:${port}/nfr-provision/update`; + const url = `${hostname}:${port}/provision/update`; return await axios.post(url, { ...provisionParams, update_userid }).then((res) => { return res.data; }); @@ -453,7 +454,7 @@ export class AdminService { }, create_userid: string ) { - const url = `${hostname}:${port}/nfr-provision/add-variable`; + const url = `${hostname}:${port}/provision/add-variable`; return await axios.post(url, { ...variableParams, create_userid }).then((res) => { return res.data; }); @@ -468,14 +469,14 @@ export class AdminService { }, update_userid: string ) { - const url = `${hostname}:${port}/nfr-provision/update-variable`; + const url = `${hostname}:${port}/provision/update-variable`; return await axios.post(url, { ...variableParams, update_userid }).then((res) => { return res.data; }); } async removeVariable(id: number) { - const url = `${hostname}:${port}/nfr-provision/remove-variable/${id}`; + const url = `${hostname}:${port}/provision/remove-variable/${id}`; return await axios.get(url).then((res) => { return res.data; }); diff --git a/backend/src/app.controller.ts b/backend/src/app.controller.ts index 7af9efd2..ca672907 100644 --- a/backend/src/app.controller.ts +++ b/backend/src/app.controller.ts @@ -222,7 +222,8 @@ export class AppController { : PAGE_TITLES.MANAGE_TEMPLATES; let variantJsonArray = []; if (reportIndex == 2) { - variantJsonArray = await this.reportService.getVariantsWithIds(); + // variantJsonArray = await this.reportService.getVariantsWithIds(); + variantJsonArray = []; } return { title: title, @@ -364,12 +365,14 @@ export class AppController { const title = process.env.ticdi_environment == 'DEVELOPMENT' ? 'DEVELOPMENT - ' + PAGE_TITLES.NOFR : PAGE_TITLES.NOFR; const displayAdmin = isAdmin ? 'Administration' : '-'; - const groupMaxJsonArray = await this.reportService.getGroupMaxByVariant('NOTICE OF FINAL REVIEW'); + // const groupMaxJsonArray = await this.reportService.getGroupMaxByVariant('NOTICE OF FINAL REVIEW'); + const groupMaxJsonArray = []; try { const nfrDataObject = await this.reportService.getActiveNfrDataByDtid(dtid); nfrData = nfrDataObject.nfrData; const provisionIds = nfrDataObject.provisionIds ? nfrDataObject.provisionIds : []; - const mandatoryProvisionIds = await this.reportService.getMandatoryProvisionsByVariant(variantName); + // const mandatoryProvisionIds = await this.reportService.getMandatoryProvisionsByVariant(variantName); + const mandatoryProvisionIds = []; await this.ttlsService.setWebadeToken(); const response: any = await firstValueFrom(this.ttlsService.callHttp(dtid)) .then((res) => { diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index 94477755..741c398e 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -2,15 +2,11 @@ import 'dotenv/config'; import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; import { ConfigModule } from '@nestjs/config'; -import { AppController } from './app.controller'; import { AppService } from './app.service'; import { DocumentTemplateModule } from './document_template/document_template.module'; -import { PrintRequestDetailModule } from './print_request_detail/print_request_detail.module'; -import { PrintRequestLogModule } from './print_request_log/print_request_log.module'; -import { NFRDataModule } from './nfr_data/nfr_data.module'; -import { NFRDataLogModule } from './nfr_data_log/nfr_data_log.module'; -import { NFRProvisionModule } from './nfr_provision/nfr_provision.module'; - +import { DocumentDataLogModule } from './document_data_log/document_data_log.module'; +import { ProvisionModule } from './provision/provision.module'; +import { DocumentDataModule } from './document_data/document_data.module'; import { HttpModule } from '@nestjs/axios'; import { TTLSService } from './ttls/ttls.service'; import { AuthenticationModule } from './authentication/authentication.module'; @@ -18,6 +14,7 @@ import { SessionModule } from 'nestjs-session'; import { AdminController } from './admin/admin.controller'; import { AdminModule } from './admin/admin.module'; import { ReportModule } from './report/report.module'; +import { DocumentTypeModule } from './document_type/document_type.module'; import { HttpExceptionFilter } from './authentication/http-exception.filter'; import { APP_FILTER } from '@nestjs/core'; @@ -37,11 +34,10 @@ if (process.env.POSTGRESQL_PASSWORD != null) { ConfigModule.forRoot(), TypeOrmModule.forRoot(config), DocumentTemplateModule, - PrintRequestDetailModule, - NFRDataModule, - NFRDataLogModule, - NFRProvisionModule, - PrintRequestLogModule, + DocumentTypeModule, + DocumentDataModule, + DocumentDataLogModule, + ProvisionModule, HttpModule, AuthenticationModule, AdminModule, diff --git a/backend/src/app.service.ts b/backend/src/app.service.ts index 96fc5469..386c6d0f 100644 --- a/backend/src/app.service.ts +++ b/backend/src/app.service.ts @@ -9,14 +9,14 @@ export class AppService { async initializeDb() { const queryRunner = this.dataSource.createQueryRunner(); // Check if there are already provisions/groups/variants in the db - const [provisionCount] = await queryRunner.query('SELECT COUNT(*) FROM nfr_provision'); - const [groupCount] = await queryRunner.query('SELECT COUNT(*) FROM nfr_provision_group'); - const [variantCount] = await queryRunner.query('SELECT COUNT(*) FROM nfr_provision_variant'); + const [provisionCount] = await queryRunner.query('SELECT COUNT(*) FROM provision'); + const [groupCount] = await queryRunner.query('SELECT COUNT(*) FROM provision_group'); + const [documentType] = await queryRunner.query('SELECT COUNT(*) FROM document_type'); // If there is no data in any of the tables, run the SQL script - if (provisionCount.count == 0 && groupCount.count == 0 && variantCount.count == 0) { - //const sql = fs.readFileSync("./utils/db/init-db.sql", "utf8"); - //await queryRunner.query(sql); - //await queryRunner.release(); + if (provisionCount.count == 0 && groupCount.count == 0 && documentType.count == 0) { + const sql = fs.readFileSync('./utils/db/init-db.sql', 'utf8'); + await queryRunner.query(sql); + await queryRunner.release(); } } diff --git a/backend/src/document_data/document_data.controller.ts b/backend/src/document_data/document_data.controller.ts new file mode 100644 index 00000000..76d0b1bf --- /dev/null +++ b/backend/src/document_data/document_data.controller.ts @@ -0,0 +1,73 @@ +import { Body, Controller, Delete, Get, Param, Post } from '@nestjs/common'; +import { ProvisionJSON, VariableJSON } from 'utils/types'; +import { CreateDocumentDataDto } from './dto/create-document_data.dto'; +import { DocumentDataService } from './document_data.service'; + +@Controller('document-data') +export class DocumentDataController { + constructor(private readonly documentDataService: DocumentDataService) {} + + @Post() + async create( + @Body() + data: { + body: CreateDocumentDataDto & { + provisionJsonArray: ProvisionJSON[]; + variableJsonArray: VariableJSON[]; + }; + } + ) { + const provArr = data.body.provisionJsonArray; + const varArr = data.body.variableJsonArray; + delete data.body['provisionJsonArray']; + delete data.body['variableJsonArray']; + return this.documentDataService.createOrUpdate(data.body, provArr, varArr); + } + + @Get() + findAll() { + return this.documentDataService.findAll(); + } + + @Get(':documentDataId') + findById(@Param('documentDataId') documentDataId: number) { + if (documentDataId && documentDataId != 0) { + return this.documentDataService.findByDocumentDataId(documentDataId); + } else { + return null; + } + } + + @Get('dtid/:dtid') + findActiveByDtid(@Param('dtid') dtid: number) { + return this.documentDataService.findActiveByDtid(dtid); + } + + @Get('view/:documentDataId') + findViewByPRDID(@Param('documentDataId') documentDataId: string) { + return this.documentDataService.findViewByDocumentDataId(+documentDataId); + } + + @Get('variables/:dtid/:document_type_id') + getVariablesByDtidAndDocType(@Param('document_type_id') document_type_id: number, @Param('dtid') dtid: number) { + return this.documentDataService.getVariablesByDtidAndDocType(dtid, document_type_id); + } + + @Get('provisions/:document_type_id/:dtid') + getProvisionsByDocTypeIdAndDtid(@Param('document_type_id') document_type_id: number, @Param('dtid') dtid: number) { + return this.documentDataService.getProvisionsByDocTypeIdAndDtid(document_type_id, dtid); + } + + @Get('get-enabled-provisions/:document_type_id/:dtid') + getEnabledProvisionsByDocTypeIdAndDtid( + @Param('document_type_id') document_type_id: number, + @Param('dtid') dtid: number + ) { + return this.documentDataService.getEnabledProvisionsByDocTypeIdAndDtid(document_type_id, dtid); + } + + @Delete(':dtid') + remove(@Param('dtid') dtid: string) { + return this.documentDataService.remove(+dtid); + } +} diff --git a/backend/src/document_data/document_data.module.ts b/backend/src/document_data/document_data.module.ts new file mode 100644 index 00000000..d1d080ac --- /dev/null +++ b/backend/src/document_data/document_data.module.ts @@ -0,0 +1,28 @@ +import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { DocumentTemplateModule } from 'src/document_template/document_template.module'; +import { ProvisionVariable } from 'src/provision/entities/provision_variable.entity'; +import { ProvisionModule } from 'src/provision/provision.module'; +import { Provision } from '../provision/entities/provision.entity'; +import { DocumentData } from './entities/document_data.entity'; +import { DocumentDataProvision } from './entities/document_data_provision.entity'; +import { DocumentDataVariable } from './entities/document_data_variable.entity'; +import { DocumentDataController } from './document_data.controller'; +import { DocumentDataService } from './document_data.service'; +import { DocumentDataLog } from 'src/document_data_log/entities/document_data_log.entity'; + +@Module({ + imports: [ + TypeOrmModule.forFeature([DocumentData]), + TypeOrmModule.forFeature([DocumentDataProvision]), + TypeOrmModule.forFeature([ProvisionVariable]), + TypeOrmModule.forFeature([DocumentDataVariable]), + TypeOrmModule.forFeature([Provision]), + ProvisionModule, + DocumentTemplateModule, + ], + controllers: [DocumentDataController], + providers: [DocumentDataService], + exports: [DocumentDataService], +}) +export class DocumentDataModule {} diff --git a/backend/src/document_data/document_data.service.ts b/backend/src/document_data/document_data.service.ts new file mode 100644 index 00000000..63d7cb65 --- /dev/null +++ b/backend/src/document_data/document_data.service.ts @@ -0,0 +1,381 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Provision } from 'src/provision/entities/provision.entity'; +import { ProvisionVariable } from 'src/provision/entities/provision_variable.entity'; +import { DataSource, In, Repository } from 'typeorm'; +import { CreateDocumentDataDto } from './dto/create-document_data.dto'; +import { DocumentData } from './entities/document_data.entity'; +import { DocumentDataProvision } from './entities/document_data_provision.entity'; +import { DocumentDataVariable } from './entities/document_data_variable.entity'; +import { DocumentDataView } from './entities/document_data_vw'; +import { ProvisionService } from 'src/provision/provision.service'; +import { DocumentTemplateService } from 'src/document_template/document_template.service'; +import { DocumentType } from 'src/document_type/entities/document_type.entity'; + +@Injectable() +export class DocumentDataService { + constructor( + @InjectRepository(DocumentData) + private documentDataRepository: Repository, + @InjectRepository(Provision) + private documentProvisionRepository: Repository, + @InjectRepository(DocumentDataProvision) + private documentDataProvisionRepository: Repository, + @InjectRepository(ProvisionVariable) + private documentProvisionVariableRepository: Repository, + @InjectRepository(DocumentDataVariable) + private documentDataVariableRepository: Repository, + private provisionService: ProvisionService, + private documentTemplateService: DocumentTemplateService, + private dataSource: DataSource + ) {} + + async createOrUpdate( + documentDataDto: CreateDocumentDataDto, + provisionArray: { provision_id: number; free_text: string }[], + variableArray: { variable_id: number; variable_value: string }[] + ): Promise { + const { dtid, document_type_id } = documentDataDto; + // const documentType: DocumentType = await this.documentTemplateService.getDocumentType(document_type_id); + const documentData: DocumentData = await this.documentDataRepository.findOne({ + where: { dtid: dtid, document_type: { id: document_type_id } }, + relations: [ + 'document_data_variables', + 'document_data_provisions', + 'document_data_variables.document_variable', + 'document_data_provisions.provision', + 'document_type', + ], + }); + + const documentProvisionIds = provisionArray.map(({ provision_id }) => provision_id); + const documentProvisions = await this.documentProvisionRepository.findBy({ + id: In(documentProvisionIds), + }); + const documentVariableIds = variableArray.map(({ variable_id }) => variable_id); + const documentVariables = await this.documentProvisionVariableRepository.findBy({ + id: In(documentVariableIds), + }); + + // if documentData for this dtid+template exists, update it + if (documentData) { + return await this.updateDocumentData( + documentDataDto, + documentData, + provisionArray, + variableArray, + documentProvisions, + documentVariables + ); + } + // else create new documentData + const documentTemplate = await this.documentTemplateService.findActiveByDocumentType( + documentDataDto.document_type_id + ); + documentDataDto['template_id'] = documentTemplate ? documentTemplate.id : null; + const newNfrData: DocumentData = this.documentDataRepository.create(documentDataDto); + const updatedNfrData = await this.documentDataRepository.save(newNfrData); + + const documentDataProvisions = provisionArray.map(({ provision_id, free_text }) => { + const documentProvision = documentProvisions.find((provision) => provision.id === provision_id); + const documentDataProvision = new DocumentDataProvision(); + documentDataProvision.document_data = updatedNfrData; + documentDataProvision.document_provision = documentProvision; + documentDataProvision.provision_free_text = documentProvision.free_text; // quick fix to not use the free_text from the document page + return documentDataProvision; + }); + const documentDataVariables = variableArray.map(({ variable_id, variable_value }) => { + const documentVariable = documentVariables.find((variable) => variable.id === variable_id); + const documentDataVariable = new DocumentDataVariable(); + documentDataVariable.document_data = updatedNfrData; + documentDataVariable.document_variable = documentVariable; + documentDataVariable.data_variable_value = variable_value; + return documentDataVariable; + }); + if (documentData) { + await this.deleteDataVarsAndProvs(documentData, provisionArray, variableArray); + } + + await this.documentDataProvisionRepository.save(documentDataProvisions); + await this.documentDataVariableRepository.save(documentDataVariables); + + return updatedNfrData; + } + + async updateDocumentData( + documentDataDto: CreateDocumentDataDto, + documentData: DocumentData, + provisionArray: { provision_id: number; free_text: string }[], + variableArray: { variable_id: number; variable_value: string }[], + documentProvisions: Provision[], + documentVariables: ProvisionVariable[] + ): Promise { + // Update NFRData entity + documentData.template_id = documentDataDto.template_id; + documentData.status = documentDataDto.status; + documentData.update_userid = documentDataDto.create_userid; + + const updatedNfrData = await this.documentDataRepository.save(documentData); + + // Update NFRDataProvision entities + for (const provision of provisionArray) { + const documentDataProvision = documentData.document_data_provisions.find( + (p) => p.document_provision.id === provision.provision_id + ); + const documentProvision = documentProvisions.find((p) => p.id === provision.provision_id); + + if (documentDataProvision && documentDataProvision.provision_free_text != documentProvision.free_text) { + // Update an existing NFRDataProvision entry + documentDataProvision.provision_free_text = documentProvision.free_text; + await this.documentDataProvisionRepository.save(documentDataProvision); + } else if (!documentDataProvision) { + // No data found for this specific provision so create a new entry in NFRDataProvision + const documentProvisionToAdd = await this.documentProvisionRepository.findOneBy({ + id: provision.provision_id, + }); + const newNfrDataProvision: DocumentDataProvision = this.documentDataProvisionRepository.create({ + document_provision: documentProvisionToAdd, + document_data: updatedNfrData, + provision_free_text: documentProvisionToAdd.free_text, // quick fix + }); + await this.documentDataProvisionRepository.save(newNfrDataProvision); + } + } + + // Update NFRDataVariable entities + for (const variable of variableArray) { + const documentDataVariable = documentData.document_data_variables.find( + (v) => v.document_variable.id === variable.variable_id + ); + + if (documentDataVariable && documentDataVariable.data_variable_value != variable.variable_value) { + // Update an existing NFRDataVariable entry + documentDataVariable.data_variable_value = variable.variable_value; + await this.documentDataVariableRepository.save(documentDataVariable); + } else if (!documentDataVariable) { + // No data found for this specific variable so create a new entry in NFRDataVariable + const documentVariable = await this.documentProvisionVariableRepository.findOneBy({ + id: variable.variable_id, + }); + const newNfrDataVariable: DocumentDataVariable = this.documentDataVariableRepository.create({ + document_variable: documentVariable, + document_data: updatedNfrData, + data_variable_value: variable.variable_value, + }); + await this.documentDataVariableRepository.save(newNfrDataVariable); + } + } + await this.deleteDataVarsAndProvs(documentData, provisionArray, variableArray); + + return updatedNfrData; + } + + async deleteDataVarsAndProvs( + documentData: DocumentData, + provisionArray: { provision_id: number; free_text: string }[], + variableArray: { variable_id: number; variable_value: string }[] + ) { + // Delete data provisions that have been removed by the user + const oldProvisionIds = documentData + ? documentData.document_data_provisions.map((dataProvision) => dataProvision.document_provision.id) + : []; + const newProvisionIds = provisionArray.map(({ provision_id }) => provision_id); + const provisionsToDelete = oldProvisionIds.filter((item) => !newProvisionIds.includes(item)); + const documentDataProvisionsToDelete = documentData.document_data_provisions + .filter((dataProvision) => provisionsToDelete.includes(dataProvision.document_provision.id)) + .map((dataProvision) => dataProvision.id); + if (documentDataProvisionsToDelete.length > 0) { + await this.documentDataProvisionRepository.delete(documentDataProvisionsToDelete); + } + + // Delete data variables that have been removed by the user + const oldVariableIds = documentData + ? documentData.document_data_variables.map((dataVariable) => dataVariable.document_variable.id) + : []; + const newVariableIds = variableArray.map(({ variable_id }) => variable_id); + const variablesToDelete = oldVariableIds.filter((item) => !newVariableIds.includes(item)); + const documentDataVariablesToDelete = documentData.document_data_variables + .filter((dataVariable) => variablesToDelete.includes(dataVariable.document_variable.id)) + .map((dataVariable) => dataVariable.id); + if (documentDataVariablesToDelete.length > 0) { + await this.documentDataVariableRepository.delete(documentDataVariablesToDelete); + } + return null; + } + + // Used by the search page. + // Variant data is persisted so only return the active variant foreach dtid. + async findAll(): Promise { + return await this.documentDataRepository.find({ + where: { + active: true, + }, + }); + } + + async findByDocumentDataId(documentDataId: number): Promise<{ + documentData: DocumentData; + provisionIds: number[]; + variableIds: number[]; + }> { + try { + const documentData = await this.documentDataRepository.findOne({ + where: { id: documentDataId }, + join: { + alias: 'document_data', + leftJoinAndSelect: { + document_data_provisions: 'document_data.document_data_provisions', + provision: 'document_data_provisions.provision', + document_data_variables: 'document_data.document_data_variables', + document_variable: 'document_data_variables.document_variable', + }, + }, + }); + const existingDataProvisions = documentData.document_data_provisions; + const provisionIds = existingDataProvisions.map((dataProvision) => dataProvision.document_provision.id); + const existingDataVariables = documentData.document_data_variables; + const variableIds = existingDataVariables.map((dataVariable) => dataVariable.document_variable.id); + return { documentData, provisionIds, variableIds }; + } catch (err) { + console.log(err); + return null; + } + } + + async findActiveByDtid(dtid: number): Promise<{ + documentData: DocumentData; + provisionIds: number[]; + variableIds: number[]; + }> { + try { + const documentData = await this.documentDataRepository.findOne({ + where: { dtid: dtid, active: true }, + join: { + alias: 'document_data', + leftJoinAndSelect: { + document_data_provisions: 'document_data.document_data_provisions', + provision: 'document_data_provisions.provision', + document_data_variables: 'document_data.document_data_variables', + document_variable: 'document_data_variables.document_variable', + }, + }, + }); + const provisionIds = + documentData && documentData.document_data_provisions + ? documentData.document_data_provisions.map((dataProvision) => dataProvision.document_provision.id) + : []; + const variableIds = + documentData && documentData.document_data_variables + ? documentData.document_data_variables.map((dataVariable) => dataVariable.document_variable.id) + : []; + return { documentData, provisionIds, variableIds }; + } catch (err) { + console.log(err); + return null; + } + } + + async findViewByDocumentDataId(documentDataId: number): Promise { + return this.dataSource.manager.findOneBy(DocumentDataView, { + DocumentDataId: documentDataId, + }); + } + + async getVariablesByDtidAndDocType(dtid: number, document_type_id: number) { + // const documentType: DocumentType = await this.documentTemplateService.getDocumentType(document_type_id); + const documentData: DocumentData = await this.documentDataRepository.findOne({ + where: { dtid: dtid, document_type: { id: document_type_id } }, + join: { + alias: 'document_data', + leftJoinAndSelect: { + document_data_variables: 'document_data.document_data_variables', + document_variable: 'document_data_variables.document_variable', + }, + }, + }); + // if the documentData doesn't exist yet, return null. This null value is caught elsewhere. + if (!documentData) { + return null; + } + // saved variables attached to the documentData entry + const existingDataVariables: DocumentDataVariable[] = documentData.document_data_variables; + // all variables associated with the variant + const variables: ProvisionVariable[] = await this.provisionService.getVariablesByDocumentTypeId(document_type_id); + // inserting the existing variable_values to the set of all variables + for (const variable of variables) { + const existingDataVariable = existingDataVariables.find( + (dataVariable) => dataVariable.document_variable.id === variable.id + ); + if (existingDataVariable) { + variable.variable_value = existingDataVariable.data_variable_value; + } + } + const variableIds = existingDataVariables.map((dataVariable) => dataVariable.document_variable.id); + return { variables, variableIds }; + } + + async getProvisionsByDocTypeIdAndDtid(document_type_id: number, dtid: number) { + const documentData: DocumentData = await this.documentDataRepository.findOne({ + where: { dtid: dtid, document_type: { id: document_type_id } }, + join: { + alias: 'document_data', + leftJoinAndSelect: { + document_data_provisions: 'document_data.document_data_provisions', + provision: 'document_data_provisions.provision', + }, + }, + }); + // if the documentData doesn't exist yet, return null. This null value is caught elsewhere. + if (!documentData) { + return null; + } + // documentData for all variants of this dtid + const fullDocumentData: DocumentData[] = await this.documentDataRepository.find({ + where: { dtid: documentData.dtid }, + join: { + alias: 'document_data', + leftJoinAndSelect: { + document_data_provisions: 'document_data.document_data_provisions', + provision: 'document_data_provisions.provision', + }, + }, + }); + + // saved provisions attached to the dtid + const existingDataProvisions: DocumentDataProvision[] = []; + fullDocumentData.forEach((documentData) => { + existingDataProvisions.push(...documentData.document_data_provisions); + }); + // all provisions + const provisions: Provision[] = await this.provisionService.getAllProvisions(); + const provisionIds = existingDataProvisions.map((dataProvision) => dataProvision.document_provision.id); + return { provisions, provisionIds }; + } + + async getEnabledProvisionsByDocTypeIdAndDtid(document_type_id: number, dtid: number) { + const documentData: DocumentData = await this.documentDataRepository.findOne({ + where: { dtid: dtid, document_type: { id: document_type_id } }, + join: { + alias: 'document_data', + leftJoinAndSelect: { + document_data_provisions: 'document_data.document_data_provisions', + provision: 'document_data_provisions.provision', + }, + }, + }); + const provisionIds = + documentData && documentData.document_data_provisions + ? documentData.document_data_provisions.map((dataProvision) => dataProvision.document_provision.id) + : []; + return provisionIds; + } + + async remove(dtid: number): Promise<{ deleted: boolean; message?: string }> { + try { + await this.documentDataRepository.delete({ dtid: dtid }); + return { deleted: true }; + } catch (err) { + return { deleted: false, message: err.message }; + } + } +} diff --git a/backend/src/document_data/dto/create-document_data.dto.ts b/backend/src/document_data/dto/create-document_data.dto.ts new file mode 100644 index 00000000..e2473dee --- /dev/null +++ b/backend/src/document_data/dto/create-document_data.dto.ts @@ -0,0 +1,10 @@ +import { PickType } from '@nestjs/swagger'; +import { DocumentDataDto } from './document_data.dto'; + +export class CreateDocumentDataDto extends PickType(DocumentDataDto, [ + 'dtid', + 'document_type_id', + 'template_id', + 'status', + 'create_userid', +] as const) {} diff --git a/backend/src/nfr_data/dto/nfr_data.dto.ts b/backend/src/document_data/dto/document_data.dto.ts similarity index 71% rename from backend/src/nfr_data/dto/nfr_data.dto.ts rename to backend/src/document_data/dto/document_data.dto.ts index 242093aa..ad586bd1 100644 --- a/backend/src/nfr_data/dto/nfr_data.dto.ts +++ b/backend/src/document_data/dto/document_data.dto.ts @@ -1,6 +1,6 @@ -export class NFRDataDto { +export class DocumentDataDto { dtid?: number; - variant_name?: string; + document_type_id?: number; template_id?: number; status?: string; enabled_provisions?: number[]; diff --git a/backend/src/document_data/dto/update-document_data.dto.ts b/backend/src/document_data/dto/update-document_data.dto.ts new file mode 100644 index 00000000..90744506 --- /dev/null +++ b/backend/src/document_data/dto/update-document_data.dto.ts @@ -0,0 +1,11 @@ +import { PickType } from '@nestjs/swagger'; +import { DocumentDataDto } from './document_data.dto'; + +export class UpdateDocumentDataDto extends PickType(DocumentDataDto, [ + 'dtid', + 'document_type_id', + 'template_id', + 'status', + 'enabled_provisions', + 'update_userid', +] as const) {} diff --git a/backend/src/document_data/entities/document_data.entity.ts b/backend/src/document_data/entities/document_data.entity.ts new file mode 100644 index 00000000..abfdad47 --- /dev/null +++ b/backend/src/document_data/entities/document_data.entity.ts @@ -0,0 +1,61 @@ +import { + Column, + CreateDateColumn, + Entity, + ManyToOne, + OneToMany, + PrimaryGeneratedColumn, + UpdateDateColumn, +} from 'typeorm'; +import { DocumentDataProvision } from './document_data_provision.entity'; +import { DocumentDataVariable } from './document_data_variable.entity'; +import { DocumentType } from 'src/document_type/entities/document_type.entity'; + +@Entity() +export class DocumentData { + @PrimaryGeneratedColumn() + id: number; + @Column({ nullable: true }) + dtid: number; + @Column({ nullable: true }) + template_id: number; + @Column({ nullable: true }) + status: string; + @Column({ nullable: true }) + active: boolean; + @Column({ nullable: true }) + create_userid: string; + @Column({ nullable: true }) + update_userid: string; + @CreateDateColumn() + create_timestamp: Date; + @UpdateDateColumn() + update_timestamp: Date; + @OneToMany(() => DocumentDataProvision, (documentDataProvision) => documentDataProvision.document_data, { + nullable: true, + cascade: true, + }) + document_data_provisions: DocumentDataProvision[]; + @OneToMany(() => DocumentDataVariable, (documentDataVariable) => documentDataVariable.document_data, { + nullable: true, + cascade: true, + }) + document_data_variables: DocumentDataVariable[]; + @ManyToOne(() => DocumentType, (document_type) => document_type.document_data, {}) + document_type: DocumentType; + + public get getDocumentDataProvisions(): DocumentDataProvision[] { + return this.document_data_provisions; + } + public get getDocumentDataVariables(): DocumentDataVariable[] { + return this.document_data_variables; + } + + constructor(dtid?: number, template_id?: number, status?: string, create_userid?: string, update_userid?: string) { + this.dtid = dtid || null; + this.template_id = template_id || null; + this.status = status || ''; + this.create_userid = create_userid || ''; + this.update_userid = update_userid || ''; + } +} diff --git a/backend/src/document_data/entities/document_data_provision.entity.ts b/backend/src/document_data/entities/document_data_provision.entity.ts new file mode 100644 index 00000000..0a6ae7d8 --- /dev/null +++ b/backend/src/document_data/entities/document_data_provision.entity.ts @@ -0,0 +1,23 @@ +import { Provision } from 'src/provision/entities/provision.entity'; +import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; +import { DocumentData } from './document_data.entity'; + +@Entity() +export class DocumentDataProvision { + @PrimaryGeneratedColumn() + id: number; + @ManyToOne(() => Provision, (provision) => provision.document_data_provisions, { + onDelete: 'CASCADE', + }) + document_provision: Provision; + @ManyToOne(() => DocumentData, (document_data) => document_data.document_data_provisions, { + onDelete: 'CASCADE', + }) + document_data: DocumentData; + @Column({ nullable: true }) + provision_free_text: string; + + constructor(provision_free_text?: string) { + this.provision_free_text = provision_free_text || ''; + } +} diff --git a/backend/src/document_data/entities/document_data_variable.entity.ts b/backend/src/document_data/entities/document_data_variable.entity.ts new file mode 100644 index 00000000..a0d13b42 --- /dev/null +++ b/backend/src/document_data/entities/document_data_variable.entity.ts @@ -0,0 +1,23 @@ +import { ProvisionVariable } from 'src/provision/entities/provision_variable.entity'; +import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; +import { DocumentData } from './document_data.entity'; + +@Entity() +export class DocumentDataVariable { + @PrimaryGeneratedColumn() + id: number; + @ManyToOne(() => ProvisionVariable, (document_variable) => document_variable.document_data_variables, { + onDelete: 'CASCADE', + }) + document_variable: ProvisionVariable; + @ManyToOne(() => DocumentData, (document_data) => document_data.document_data_variables, { + onDelete: 'CASCADE', + }) + document_data: DocumentData; + @Column({ nullable: true }) + data_variable_value: string; + + constructor(data_variable_value?: string) { + this.data_variable_value = data_variable_value || ''; + } +} diff --git a/backend/src/document_data/entities/document_data_vw.ts b/backend/src/document_data/entities/document_data_vw.ts new file mode 100644 index 00000000..5041b4b6 --- /dev/null +++ b/backend/src/document_data/entities/document_data_vw.ts @@ -0,0 +1,223 @@ +import { DataSource, ViewColumn, ViewEntity } from 'typeorm'; +import { DocumentData } from './document_data.entity'; + +// very specific to old NFR... +// need to review how report generation relies on this +@ViewEntity({ + expression: (dataSource: DataSource) => + dataSource + .createQueryBuilder() + .select('document_data.id', 'DocumentDataId') + .addSelect('document_data.dtid', 'DTID') + .addSelect('document_data.db_address_regional_office', 'DB_Address_Regional_Office') + .addSelect('document_data.var_telephone_number', 'VAR_Telephone_Number') + .addSelect('document_data.var_facsimile_number', 'VAR_Facsimile_Number') + .addSelect('document_data.db_name_bcal_contact', 'DB_Name_BCAL_Contact') + .addSelect('document_data.db_file_number', 'DB_File_Number') + .addSelect('document_data.var_client_file_no', 'VAR_Client_File_No') + .addSelect('document_data.var_date_of_notice', 'VAR_Date_Of_Notice') + .addSelect('document_data.db_address_mailing_tenant', 'DB_Address_Mailing_Tenant') + .addSelect('document_data.var_attention_line', 'VAR_Attention_Line') + .addSelect('document_data.var_salutation', 'VAR_Salutation') + .addSelect('document_data.db_tenure_type', 'DB_Tenure_Type') + .addSelect('document_data.var_purpose_generic', 'VAR_Purpose_Generic') + .addSelect('document_data.db_legal_description', 'DB_Legal_Description') + .addSelect('document_data.show_section_five_1', 'showSectionFive_1') + .addSelect('document_data.section_five_1_text', 'SectionFive_1_Text') + .addSelect('document_data.insert_space', 'Insert_Space') + .addSelect('document_data.var_replacement_tenure_type', 'VAR_Replacement_Tenure_Type') + .addSelect('document_data.show_section_five_2', 'showSectionFive_2') + .addSelect('document_data.section_five_2_text', 'SectionFive_2_Text') + .addSelect('document_data.var_why_land_differs', 'VAR_Why_Land_Differs') + .addSelect('document_data.show_section_five_3', 'showSectionFive_3') + .addSelect('document_data.var_sect5_free_field', 'VAR_Sect5_Free_Field') + .addSelect('document_data.var_deadline_completion_requirements', 'VAR_Deadline_Completion_Requirements') + .addSelect('document_data.var_number_of_copies', 'VAR_Number_Of_Copies') + .addSelect('document_data.db_fee_payable_type', 'DB_Fee_Payable_Type') + .addSelect('document_data.db_fee_payable_amount_gst', 'DB_Fee_Payable_Amount_GST') + .addSelect('document_data.db_fee_payable_amount', 'DB_Fee_Payable_Amount') + .addSelect('document_data.db_fp_asterisk', 'DB_FP_Asterisk') + .addSelect('document_data.var_fee_occupational_rental_amount', 'VAR_Fee_Occupational_Rental_Amount') + .addSelect('document_data.var_fee_application_amount', 'VAR_Fee_Application_Amount') + .addSelect('document_data.var_fee_other_credit_amount', 'VAR_Fee_Other_Credit_Amount') + .addSelect('document_data.db_total_gst_amount', 'DB_Total_GST_Amount') + .addSelect('document_data.db_total_monies_payable', 'DB_Total_Monies_Payable') + .addSelect('document_data.db_address_line_regional_office', 'DB_Address_Line_Regional_Office') + .addSelect('document_data.var_interim_tenure_type', 'VAR_Interim_Tenure_Type') + .addSelect('document_data.show_section_fifteen_1', 'showSectionFifteen_1') + .addSelect('document_data.section_fifteen_1_text', 'SectionFifteen_1_Text') + .addSelect('document_data.var_occ_rent_details', 'VAR_Occ_Rent_Details') + .addSelect('document_data.show_section_twenty_1', 'showSectionTwenty_1') + .addSelect('document_data.section_twenty_1_text', 'SectionTwenty_1_Text') + .addSelect('document_data.show_section_twenty_2', 'showSectionTwenty_2') + .addSelect('document_data.section_twenty_2_text', 'SectionTwenty_2_Text') + .addSelect('document_data.show_section_twenty_3', 'showSectionTwenty_3') + .addSelect('document_data.section_twenty_3_text', 'SectionTwenty_3_Text') + .addSelect('document_data.show_section_twenty_4', 'showSectionTwenty_4') + .addSelect('document_data.section_twenty_4_text', 'SectionTwenty_4_Text') + .addSelect('document_data.show_section_twenty_5', 'showSectionTwenty_5') + .addSelect('document_data.section_twenty_5_text', 'SectionTwenty_5_Text') + .addSelect('document_data.show_section_twentyfive_1', 'showSectionTwentyFive_1') + .addSelect('document_data.section_twentyfive_1_text', 'SectionTwentyFive_1_Text') + .addSelect('document_data.show_section_twentyfive_2', 'showSectionTwentyFive_2') + .addSelect('document_data.section_twentyfive_2_text', 'SectionTwentyFive_2_Text') + .addSelect('document_data.show_section_twentyfive_3', 'showSectionTwentyFive_3') + .addSelect('document_data.section_twentyfive_3_text', 'SectionTwentyFive_3_Text') + .addSelect('document_data.show_section_twentyfive_4', 'showSectionTwentyFive_4') + .addSelect('document_data.section_twentyfive_4_text', 'SectionTwentyFive_4_Text') + .addSelect('document_data.show_section_twentyseven_1', 'showSectionTwentySeven_1') + .addSelect('document_data.section_twentyseven_1_text', 'SectionTwentySeven_1_Text') + .addSelect('document_data.show_section_twentyseven_2', 'showSectionTwentySeven_2') + .addSelect('document_data.section_twentyseven_2_text', 'SectionTwentySeven_2_Text') + .addSelect('document_data.show_section_twentyseven_3', 'showSectionTwentySeven_3') + .addSelect('document_data.section_twentyseven_3_text', 'SectionTwentySeven_3_Text') + .addSelect('document_data.show_section_twentyseven_4', 'showSectionTwentySeven_4') + .addSelect('document_data.section_twentyseven_4_text', 'SectionTwentySeven_4_Text') + .addSelect('document_data.show_section_twentyseven_5', 'showSectionTwentySeven_5') + .addSelect('document_data.section_twentyseven_5_text', 'SectionTwentySeven_5_Text') + .addSelect('document_data.show_section_twentyseven_6', 'showSectionTwentySeven_6') + .addSelect('document_data.section_twentyseven_6_text', 'SectionTwentySeven_6_Text') + .from(DocumentData, 'document_data'), +}) +export class DocumentDataView { + @ViewColumn() + DocumentDataId: number; + @ViewColumn() + DTID: number; + @ViewColumn() + DB_Address_Regional_Office: string; + @ViewColumn() + VAR_Telephone_Number: string; + @ViewColumn() + VAR_Facsimile_Number: string; + @ViewColumn() + DB_Name_BCAL_Contact: string; + @ViewColumn() + DB_File_Number: string; + @ViewColumn() + VAR_Client_File_No: string; + @ViewColumn() + VAR_Date_Of_Notice: string; + @ViewColumn() + DB_Address_Mailing_Tenant: string; + @ViewColumn() + VAR_Attention_Line: string; + @ViewColumn() + VAR_Salutation: string; + @ViewColumn() + DB_Tenure_Type: string; + @ViewColumn() + VAR_Purpose_Generic: string; + @ViewColumn() + DB_Legal_Description: string; + @ViewColumn() + showSectionFive_1: number; + @ViewColumn() + SectionFive_1_Text: string; + @ViewColumn() + Insert_Space: string; + @ViewColumn() + VAR_Replacement_Tenure_Type: string; + @ViewColumn() + showSectionFive_2: number; + @ViewColumn() + SectionFive_2_Text: string; + @ViewColumn() + VAR_Why_Land_Differs: string; + @ViewColumn() + showSectionFive_3: string; + @ViewColumn() + VAR_Sect5_Free_Field: string; + @ViewColumn() + VAR_Deadline_Completion_Requirements: string; + @ViewColumn() + VAR_Number_Of_Copies: string; + @ViewColumn() + DB_Fee_Payable_Type: string; + @ViewColumn() + DB_Fee_Payable_Amount_GST: string; + @ViewColumn() + DB_Fee_Payable_Amount: string; + @ViewColumn() + DB_FP_Asterisk: string; + @ViewColumn() + VAR_Fee_Occupational_Rental_Amount: string; + @ViewColumn() + VAR_Fee_Application_Amount: string; + @ViewColumn() + VAR_Fee_Other_Credit_Amount: string; + @ViewColumn() + DB_Total_GST_Amount: string; + @ViewColumn() + DB_Total_Monies_Payable: string; + @ViewColumn() + DB_Address_Line_Regional_Office: string; + @ViewColumn() + VAR_Interim_Tenure_Type: string; + @ViewColumn() + showSectionFifteen_1: number; + @ViewColumn() + SectionFifteen_1_Text: string; + @ViewColumn() + VAR_Occ_Rent_Details: string; + @ViewColumn() + showSectionTwenty_1: number; + @ViewColumn() + SectionTwenty_1_Text: string; + @ViewColumn() + showSectionTwenty_2: number; + @ViewColumn() + SectionTwenty_2_Text: string; + @ViewColumn() + showSectionTwenty_3: number; + @ViewColumn() + SectionTwenty_3_Text: string; + @ViewColumn() + showSectionTwenty_4: number; + @ViewColumn() + SectionTwenty_4_Text: string; + @ViewColumn() + showSectionTwenty_5: number; + @ViewColumn() + SectionTwenty_5_Text: string; + @ViewColumn() + showSectionTwentyFive_1: number; + @ViewColumn() + SectionTwentyFive_1_Text: string; + @ViewColumn() + showSectionTwentyFive_2: number; + @ViewColumn() + SectionTwentyFive_2_Text: string; + @ViewColumn() + showSectionTwentyFive_3: number; + @ViewColumn() + SectionTwentyFive_3_Text: string; + @ViewColumn() + showSectionTwentyFive_4: number; + @ViewColumn() + SectionTwentyFive_4_Text: string; + @ViewColumn() + showSectionTwentySeven_1: number; + @ViewColumn() + SectionTwentySeven_1_Text: string; + @ViewColumn() + showSectionTwentySeven_2: number; + @ViewColumn() + SectionTwentySeven_2_Text: string; + @ViewColumn() + showSectionTwentySeven_3: number; + @ViewColumn() + SectionTwentySeven_3_Text: string; + @ViewColumn() + showSectionTwentySeven_4: number; + @ViewColumn() + SectionTwentySeven_4_Text: string; + @ViewColumn() + showSectionTwentySeven_5: number; + @ViewColumn() + SectionTwentySeven_5_Text: string; + @ViewColumn() + showSectionTwentySeven_6: number; + @ViewColumn() + SectionTwentySeven_6_Text: string; +} diff --git a/backend/src/document_data_log/document_data_log.module.ts b/backend/src/document_data_log/document_data_log.module.ts new file mode 100644 index 00000000..8a75a250 --- /dev/null +++ b/backend/src/document_data_log/document_data_log.module.ts @@ -0,0 +1,11 @@ +import { Module } from '@nestjs/common'; +import { DocumentDataLogService } from './document_data_log.service'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { DocumentDataLog } from './entities/document_data_log.entity'; + +@Module({ + imports: [TypeOrmModule.forFeature([DocumentDataLog])], + providers: [DocumentDataLogService], + exports: [DocumentDataLogService, TypeOrmModule.forFeature([DocumentDataLog])], +}) +export class DocumentDataLogModule {} diff --git a/backend/src/document_data_log/document_data_log.service.ts b/backend/src/document_data_log/document_data_log.service.ts new file mode 100644 index 00000000..f73bb7d1 --- /dev/null +++ b/backend/src/document_data_log/document_data_log.service.ts @@ -0,0 +1,51 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { DocumentDataLog } from './entities/document_data_log.entity'; +import { CreateDocumentDataLogDto } from './dto/create-document_data_log.dto'; +import { Repository } from 'typeorm'; + +@Injectable() +export class DocumentDataLogService { + constructor( + @InjectRepository(DocumentDataLog) + private documentDataLogRepository: Repository + ) {} + + async create(documentDataLog: CreateDocumentDataLogDto): Promise { + const newItem = new DocumentDataLog(); + newItem.document_template_id = documentDataLog.document_template_id; + newItem.document_data_id = documentDataLog.document_data_id; + newItem.dtid = documentDataLog.dtid; + newItem.request_app_user = documentDataLog.request_app_user; + newItem.request_json = documentDataLog.request_json; + newItem.create_userid = documentDataLog.request_app_user; // same as request_app_user + const newPRL = this.documentDataLogRepository.create(newItem); + return this.documentDataLogRepository.save(newPRL); + } + + async findAll(): Promise { + return this.documentDataLogRepository.find(); + } + + async findByDtid(dtid: number): Promise { + return this.documentDataLogRepository.find({ + where: { + document_template_id: dtid, + }, + }); + } + + async findNextVersion(dtid: number): Promise { + const requestLogs = await this.documentDataLogRepository.findAndCount({ + where: { + dtid: dtid, + }, + }); + let version = (requestLogs[1] + 1).toString(); + // prepend zeroes to the version before returning + while (version.length < 4) { + version = '0' + version; + } + return version; + } +} diff --git a/backend/src/document_data_log/dto/create-document_data_log.dto.ts b/backend/src/document_data_log/dto/create-document_data_log.dto.ts new file mode 100644 index 00000000..786f4940 --- /dev/null +++ b/backend/src/document_data_log/dto/create-document_data_log.dto.ts @@ -0,0 +1,12 @@ +import { PickType } from '@nestjs/swagger'; +import { DocumentDataLogDto } from './document_data_log.dto'; + +export class CreateDocumentDataLogDto extends PickType(DocumentDataLogDto, [ + 'dtid', + 'document_data_id', + 'document_type_id', + 'document_template_id', + 'request_app_user', + 'request_json', + 'create_userid', +] as const) {} diff --git a/backend/src/nfr_data_log/dto/nfr_data_log.dto.ts b/backend/src/document_data_log/dto/document_data_log.dto.ts similarity index 62% rename from backend/src/nfr_data_log/dto/nfr_data_log.dto.ts rename to backend/src/document_data_log/dto/document_data_log.dto.ts index 44e62622..760cc659 100644 --- a/backend/src/nfr_data_log/dto/nfr_data_log.dto.ts +++ b/backend/src/document_data_log/dto/document_data_log.dto.ts @@ -1,7 +1,8 @@ -export class NFRDataLogDto { - document_template_id: number; - nfr_data_id: number; +export class DocumentDataLogDto { dtid: number; + document_data_id: number; + document_type_id: number; + document_template_id: number; request_app_user: string; request_json: string; create_userid: string; diff --git a/backend/src/document_data_log/dto/update-document_data_log.dto.ts b/backend/src/document_data_log/dto/update-document_data_log.dto.ts new file mode 100644 index 00000000..c9cdd8bc --- /dev/null +++ b/backend/src/document_data_log/dto/update-document_data_log.dto.ts @@ -0,0 +1,12 @@ +import { PickType } from '@nestjs/swagger'; +import { DocumentDataLogDto } from './document_data_log.dto'; + +export class UpdateDocumentDataLogDto extends PickType(DocumentDataLogDto, [ + 'dtid', + 'document_data_id', + 'document_type_id', + 'document_template_id', + 'request_app_user', + 'request_json', + 'update_userid', +] as const) {} diff --git a/backend/src/print_request_log/entities/print_request_log.entity.ts b/backend/src/document_data_log/entities/document_data_log.entity.ts similarity index 80% rename from backend/src/print_request_log/entities/print_request_log.entity.ts rename to backend/src/document_data_log/entities/document_data_log.entity.ts index 2bf8ff37..f3ce25e1 100644 --- a/backend/src/print_request_log/entities/print_request_log.entity.ts +++ b/backend/src/document_data_log/entities/document_data_log.entity.ts @@ -1,17 +1,17 @@ import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'; @Entity() -export class PrintRequestLog { +export class DocumentDataLog { @PrimaryGeneratedColumn() id: number; @Column({ nullable: true }) - document_template_id: number; + dtid: number; @Column({ nullable: true }) - print_request_detail_id: number; + document_data_id: number; @Column({ nullable: true }) - dtid: number; + document_type_id: number; @Column({ nullable: true }) - document_type: string; + document_template_id: number; @Column({ nullable: true }) request_app_user: string; @Column({ nullable: true }) @@ -26,19 +26,19 @@ export class PrintRequestLog { update_timestamp: Date; constructor( - document_template_id?: number, - print_request_detail_id?: number, dtid?: number, - document_type?: string, + document_data_id?: number, + document_type_id?: number, + document_template_id?: number, request_app_user?: string, request_json?: string, create_userid?: string, update_userid?: string ) { - this.document_template_id = document_template_id || null; - this.print_request_detail_id = print_request_detail_id || null; this.dtid = dtid || null; - this.document_type = document_type || ''; + this.document_data_id = document_data_id || null; + this.document_type_id = document_type_id || null; + this.document_template_id = document_template_id || null; this.request_app_user = request_app_user || ''; this.request_json = request_json || ''; this.create_userid = create_userid || ''; diff --git a/backend/src/document_template/document_template.controller.ts b/backend/src/document_template/document_template.controller.ts index 2f4701da..6e4ecde8 100644 --- a/backend/src/document_template/document_template.controller.ts +++ b/backend/src/document_template/document_template.controller.ts @@ -19,48 +19,46 @@ export class DocumentTemplateController { file: Express.Multer.File, @Body() params: CreateDocumentTemplateDto ): Promise { - console.log('Uploading new template!!!'); - // - const params2 = { - document_type: params.document_type, + const newDocumentParams: CreateDocumentTemplateDto = { + document_type_id: params.document_type_id, template_author: params.template_author, mime_type: params.mime_type, file_name: params.file_name, comments: params.comments, create_userid: params.create_userid, }; - const newTemplate = await this.templateService.create(params2, file); + const newTemplate: DocumentTemplate = await this.templateService.create(newDocumentParams, file); return await this.templateService.checkForActiveTemplates({ id: newTemplate.id, update_userid: newTemplate.update_userid, - document_type: newTemplate.document_type, + document_type_id: params.document_type_id, }); } @Post('activate-template') - activateTemplate(@Body() data: { id: number; update_userid: string; document_type: string }): Promise { + activateTemplate(@Body() data: { id: number; update_userid: string; document_type_id: number }): Promise { return this.templateService.activateTemplate(data); } - @Post('update') - update(@Body() data: UpdateDocumentTemplateDto): Promise { - return this.templateService.update(data); - } + // @Post('update') + // update(@Body() data: UpdateDocumentTemplateDto): Promise { + // return this.templateService.update(data); + // } @Get('remove/:document_type/:id') - remove(@Param('document_type') document_type: string, @Param('id') id: number): Promise<{ id: number }> { - return this.templateService.remove(document_type, id); + remove(@Param('document_type') document_type_id: number, @Param('id') id: number): Promise<{ id: number }> { + return this.templateService.remove(document_type_id, id); } - @Get(':document_type') - async findAll(@Param('document_type') document_type: string): Promise { - let documents: DocumentTemplate[] = await this.templateService.findAll(document_type); + @Get(':document_type_id') + async findAll(@Param('document_type_id') document_type_id: number): Promise { + let documents: DocumentTemplate[] = await this.templateService.findAll(document_type_id); return documents.map(({ the_file, ...rest }) => rest); } @Get('get-active-report/:document_type') - findActiveByDocumentType(@Param('document_type') document_type: string): Promise { - return this.templateService.findActiveByDocumentType(document_type); + findActiveByDocumentType(@Param('document_type') document_type_id: number): Promise { + return this.templateService.findActiveByDocumentType(document_type_id); } @Get('find-one/:id') diff --git a/backend/src/document_template/document_template.module.ts b/backend/src/document_template/document_template.module.ts index 7a08a7d8..0db22eba 100644 --- a/backend/src/document_template/document_template.module.ts +++ b/backend/src/document_template/document_template.module.ts @@ -3,10 +3,17 @@ import { TypeOrmModule } from '@nestjs/typeorm'; import { DocumentTemplateController } from './document_template.controller'; import { DocumentTemplateService } from './document_template.service'; import { DocumentTemplate } from './entities/document_template.entity'; -import { NFRData } from 'src/nfr_data/entities/nfr_data.entity'; +import { DocumentData } from 'src/document_data/entities/document_data.entity'; +import { DocumentTypeModule } from 'src/document_type/document_type.module'; +import { DocumentType } from 'src/document_type/entities/document_type.entity'; @Module({ - imports: [TypeOrmModule.forFeature([DocumentTemplate]), TypeOrmModule.forFeature([NFRData])], + imports: [ + TypeOrmModule.forFeature([DocumentTemplate]), + TypeOrmModule.forFeature([DocumentData]), + TypeOrmModule.forFeature([DocumentType]), + DocumentTypeModule, + ], controllers: [DocumentTemplateController], providers: [DocumentTemplateService], exports: [DocumentTemplateService], diff --git a/backend/src/document_template/document_template.service.ts b/backend/src/document_template/document_template.service.ts index b0425cca..b922b99f 100644 --- a/backend/src/document_template/document_template.service.ts +++ b/backend/src/document_template/document_template.service.ts @@ -4,21 +4,26 @@ import { In, Repository } from 'typeorm'; import { CreateDocumentTemplateDto } from './dto/create-document_template.dto'; import { UpdateDocumentTemplateDto } from './dto/update-document_template.dto'; import { DocumentTemplate } from './entities/document_template.entity'; -import { NFRData } from 'src/nfr_data/entities/nfr_data.entity'; +import { DocumentType } from '../document_type/entities/document_type.entity'; +import { DocumentData } from 'src/document_data/entities/document_data.entity'; +import { DocumentTypeService } from 'src/document_type/document_type.service'; @Injectable() export class DocumentTemplateService { constructor( @InjectRepository(DocumentTemplate) private documentTemplateRepository: Repository, - @InjectRepository(NFRData) - private nfrDataRepository: Repository + @InjectRepository(DocumentType) + private documentTypeService: DocumentTypeService, + @InjectRepository(DocumentData) + private documentDataRepository: Repository ) {} async create(documentTemplate: CreateDocumentTemplateDto, file: any): Promise { const base64File = Buffer.from(file.buffer).toString('base64'); const newItem = new DocumentTemplate(); - newItem.document_type = documentTemplate.document_type; + const docType: DocumentType = await this.documentTypeService.findById(documentTemplate.document_type_id); + newItem.document_type = docType; newItem.template_author = documentTemplate.template_author; newItem.mime_type = documentTemplate.mime_type; newItem.file_name = documentTemplate.file_name; @@ -31,40 +36,42 @@ export class DocumentTemplateService { } async getTemplateVersion(documentTemplate: CreateDocumentTemplateDto): Promise { - const existingReports = await this.documentTemplateRepository.findBy({ - document_type: documentTemplate.document_type, - }); - if (!existingReports) { + const existingTemplates = await this.documentTemplateRepository + .createQueryBuilder('documentTemplate') + .leftJoin('documentTemplate.document_type', 'documentType') + .where('documentType.id = :documentTypeId', { documentTypeId: documentTemplate.document_type_id }) + .getMany(); + + if (!existingTemplates || existingTemplates.length === 0) { return 0; } else { - let currentVersion = 0; - for (let item of existingReports) { - if (item.template_version > currentVersion) { - currentVersion = item.template_version; - } - } + let currentVersion = existingTemplates.reduce((max, item) => Math.max(max, item.template_version), 0); return currentVersion + 1; } } - async activateTemplate(data: { id: number; update_userid: string; document_type: string }): Promise { - let allTemplates = await this.documentTemplateRepository.findBy({ - document_type: data.document_type.toUpperCase(), - }); + async activateTemplate(data: { id: number; update_userid: string; document_type_id: number }): Promise { + const allTemplates = await this.documentTemplateRepository + .createQueryBuilder('documentTemplate') + .leftJoin('documentTemplate.document_type', 'documentType') + .where('documentType.id = :documentTypeId', { documentTypeId: data.document_type_id }) + .getMany(); for (let entry of allTemplates) { if (entry.active_flag == true) { await this.documentTemplateRepository.update({ id: entry.id }, { active_flag: false }); } } const activatedTemplate = await this.documentTemplateRepository.update({ id: data.id }, { active_flag: true }); - await this.updateNfrTemplates(data.document_type.toUpperCase()); + await this.updateTemplates(data.document_type_id); return activatedTemplate; } - async checkForActiveTemplates(data: { id: number; update_userid: string; document_type: string }): Promise { - let allTemplates = await this.documentTemplateRepository.findBy({ - document_type: data.document_type, - }); + async checkForActiveTemplates(data: { id: number; update_userid: string; document_type_id: number }): Promise { + const allTemplates = await this.documentTemplateRepository + .createQueryBuilder('documentTemplate') + .leftJoin('documentTemplate.document_type', 'documentType') + .where('documentType.id = :documentTypeId', { documentTypeId: data.document_type_id }) + .getMany(); for (let entry of allTemplates) { if (entry.active_flag == true) { return true; @@ -95,13 +102,12 @@ export class DocumentTemplateService { return result; } - async remove(document_type: string, id: number): Promise<{ id: number }> { + async remove(document_type_id: number, id: number): Promise<{ id: number }> { // if the removed template was active, activate the highest version template const templateToRemove = await this.findOne(id); - const variantName = templateToRemove.document_type; await this.documentTemplateRepository.update({ id: id }, { is_deleted: true, active_flag: false }); if (templateToRemove.active_flag == true) { - const allTemplates = await this.findAll(templateToRemove.document_type); + const allTemplates: DocumentTemplate[] = await this.findAll(document_type_id); if (allTemplates.length != 0) { let newestVersionTemplate: DocumentTemplate; let currentVersion = 0; @@ -111,51 +117,59 @@ export class DocumentTemplateService { newestVersionTemplate = entry; } } - await this.activateTemplate(newestVersionTemplate); - await this.updateNfrTemplates(variantName); + await this.activateTemplate({ + id: newestVersionTemplate.id, + update_userid: newestVersionTemplate.update_userid, + document_type_id: document_type_id, + }); + await this.updateTemplates(document_type_id); return { id: newestVersionTemplate.id }; } } - await this.updateNfrTemplates(variantName); + await this.updateTemplates(document_type_id); return { id: 0 }; } // updates the updated_by and document_version columns // unused - needs to be updated - async update(templateData: UpdateDocumentTemplateDto): Promise { - let allTemplates = await this.documentTemplateRepository.findBy({ - document_type: templateData.document_type, - }); - let mostRecentTemplate = allTemplates[0]; - for (let template of allTemplates) { - if (template.template_version > mostRecentTemplate.template_version) { - mostRecentTemplate = template; - } - } - let templateToUpdate = await this.documentTemplateRepository.findOneByOrFail({ - document_type: templateData.document_type, - template_version: templateData.template_version, - }); - templateToUpdate.document_type = templateData.document_type; - templateToUpdate.template_version = mostRecentTemplate.template_version + 1; - templateToUpdate.template_author = templateData.template_author; - templateToUpdate.active_flag = templateData.active_flag; - templateToUpdate.mime_type = templateData.mime_type; - templateToUpdate.file_name = templateData.file_name; - templateToUpdate.the_file = templateData.the_file; - templateToUpdate.comments = templateData.comments; - return this.documentTemplateRepository.save(templateToUpdate); - } - - findAll(document_type: string): Promise { + // async update(templateData: UpdateDocumentTemplateDto): Promise { + // const docType: DocumentType = await this.documentTypeService.findById(templateData.document_type_id); + // const allTemplates = await this.documentTemplateRepository + // .createQueryBuilder('documentTemplate') + // .leftJoin('documentTemplate.document_type', 'documentType') + // .where('documentType.id = :documentTypeId', { documentTypeId: templateData.document_type_id }) + // .getMany(); + // let mostRecentTemplate = allTemplates[0]; + // for (let template of allTemplates) { + // if (template.template_version > mostRecentTemplate.template_version) { + // mostRecentTemplate = template; + // } + // } + // let templateToUpdate = await this.documentTemplateRepository.findOneByOrFail({ + // document_type: { id: templateData.document_type_id }, + // template_version: templateData.template_version, + // }); + // templateToUpdate.document_type = docType; + // templateToUpdate.template_version = mostRecentTemplate.template_version + 1; + // templateToUpdate.template_author = templateData.template_author; + // templateToUpdate.active_flag = templateData.active_flag; + // templateToUpdate.mime_type = templateData.mime_type; + // templateToUpdate.file_name = templateData.file_name; + // templateToUpdate.the_file = templateData.the_file; + // templateToUpdate.comments = templateData.comments; + // return this.documentTemplateRepository.save(templateToUpdate); + // } + + async findAll(document_type_id: number): Promise { + const docType: DocumentType = await this.documentTypeService.findById(document_type_id); return this.documentTemplateRepository.find({ - where: { is_deleted: false, document_type: document_type }, + where: { is_deleted: false, document_type: { id: document_type_id } }, }); } - findActiveByDocumentType(documentType: string): Promise { + async findActiveByDocumentType(document_type_id: number): Promise { return this.documentTemplateRepository.findOneBy({ - document_type: documentType, + document_type: { id: document_type_id }, active_flag: true, }); } @@ -173,21 +187,18 @@ export class DocumentTemplateService { }); } - // after removing a template, this updates nfrData that is now tied to inactive templates - async updateNfrTemplates(variantName: string) { - const nfrData: NFRData[] = await this.nfrDataRepository.find({ - where: { - variant_name: variantName, - }, + // after removing a template, this updates documentData that is now tied to inactive templates + async updateTemplates(document_type_id: number) { + const documentData: DocumentData[] = await this.documentDataRepository.findBy({ + document_type: { id: document_type_id }, }); - const activeTemplate = await this.documentTemplateRepository.findOne({ - where: { document_type: variantName, active_flag: true }, + where: { document_type: { id: document_type_id }, active_flag: true }, }); - for (let item of nfrData) { + for (let item of documentData) { if (item.template_id != activeTemplate.id) { - await this.nfrDataRepository.update(item.id, { + await this.documentDataRepository.update(item.id, { template_id: activeTemplate.id, }); } diff --git a/backend/src/document_template/dto/create-document_template.dto.ts b/backend/src/document_template/dto/create-document_template.dto.ts index 11760d90..2f299ed4 100644 --- a/backend/src/document_template/dto/create-document_template.dto.ts +++ b/backend/src/document_template/dto/create-document_template.dto.ts @@ -2,7 +2,7 @@ import { PickType } from '@nestjs/swagger'; import { DocumentTemplateDto } from './document_template.dto'; export class CreateDocumentTemplateDto extends PickType(DocumentTemplateDto, [ - 'document_type', + 'document_type_id', 'template_author', 'mime_type', 'file_name', diff --git a/backend/src/document_template/dto/document_template.dto.ts b/backend/src/document_template/dto/document_template.dto.ts index 1b1f8889..40130c30 100644 --- a/backend/src/document_template/dto/document_template.dto.ts +++ b/backend/src/document_template/dto/document_template.dto.ts @@ -1,5 +1,5 @@ export class DocumentTemplateDto { - document_type: string; + document_type_id: number; template_version: number; template_author: string; template_creation_date: string; diff --git a/backend/src/document_template/dto/update-document_template.dto.ts b/backend/src/document_template/dto/update-document_template.dto.ts index df00c273..d830bb4c 100644 --- a/backend/src/document_template/dto/update-document_template.dto.ts +++ b/backend/src/document_template/dto/update-document_template.dto.ts @@ -2,7 +2,7 @@ import { PickType } from '@nestjs/swagger'; import { DocumentTemplateDto } from './document_template.dto'; export class UpdateDocumentTemplateDto extends PickType(DocumentTemplateDto, [ - 'document_type', + 'document_type_id', 'template_version', 'template_author', 'template_creation_date', diff --git a/backend/src/document_template/entities/document_template.entity.ts b/backend/src/document_template/entities/document_template.entity.ts index ab057920..cad13408 100644 --- a/backend/src/document_template/entities/document_template.entity.ts +++ b/backend/src/document_template/entities/document_template.entity.ts @@ -1,11 +1,14 @@ -import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'; +import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'; +import { DocumentType } from '../../document_type/entities/document_type.entity'; @Entity() export class DocumentTemplate { @PrimaryGeneratedColumn() id: number; - @Column() - document_type: string; // the template type (Land Use Report / Notice of Final Review) + @ManyToOne(() => DocumentType, (documentType) => documentType.document_templates, { + nullable: true, + }) + document_type: DocumentType; @Column() template_version: number; @Column() @@ -32,7 +35,7 @@ export class DocumentTemplate { update_timestamp: Date; constructor( - document_type?: string, + document_type?: DocumentType, template_version?: number, template_author?: string, active_flag?: boolean, @@ -44,7 +47,7 @@ export class DocumentTemplate { create_userid?: string, update_userid?: string ) { - this.document_type = document_type || ''; + this.document_type = document_type || null; this.template_version = template_version || null; this.template_author = template_author || ''; this.active_flag = active_flag || false; diff --git a/backend/src/document_type/document_type.controller.ts b/backend/src/document_type/document_type.controller.ts new file mode 100644 index 00000000..43bc8414 --- /dev/null +++ b/backend/src/document_type/document_type.controller.ts @@ -0,0 +1,23 @@ +import { Controller, Get, Param, UseFilters, UseGuards } from '@nestjs/common'; +import { AuthenticationFilter } from 'src/authentication/authentication.filter'; +import { AuthenticationGuard } from 'src/authentication/authentication.guard'; +import { GenerateReportGuard } from 'src/authentication/generate-report.guard'; +import { DocumentTypeService } from './document_type.service'; + +// @UseFilters(AuthenticationFilter) +// @UseGuards(AuthenticationGuard) +// @UseGuards(GenerateReportGuard) +@Controller('document-type') +export class DocumentTypeController { + constructor(private documentTypeService: DocumentTypeService) {} + + @Get(':id') + findById(@Param('id') id: number) { + return this.documentTypeService.findById(id); + } + + @Get() + findAll() { + return this.documentTypeService.findAll(); + } +} diff --git a/backend/src/document_type/document_type.module.ts b/backend/src/document_type/document_type.module.ts new file mode 100644 index 00000000..ae2a3378 --- /dev/null +++ b/backend/src/document_type/document_type.module.ts @@ -0,0 +1,13 @@ +import { Module } from '@nestjs/common'; +import { DocumentTypeService } from './document_type.service'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { DocumentTypeController } from './document_type.controller'; +import { DocumentType } from './entities/document_type.entity'; + +@Module({ + imports: [TypeOrmModule.forFeature([DocumentType])], + providers: [DocumentTypeService], + controllers: [DocumentTypeController], + exports: [DocumentTypeService], +}) +export class DocumentTypeModule {} diff --git a/backend/src/document_type/document_type.service.ts b/backend/src/document_type/document_type.service.ts new file mode 100644 index 00000000..ad98be07 --- /dev/null +++ b/backend/src/document_type/document_type.service.ts @@ -0,0 +1,19 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { DocumentType } from './entities/document_type.entity'; + +@Injectable() +export class DocumentTypeService { + constructor( + @InjectRepository(DocumentType) + private documentTypeRepository: Repository + ) {} + findById(id: number): Promise { + return this.documentTypeRepository.findOneByOrFail({ id: id }); + } + + findAll(): Promise { + return this.documentTypeRepository.find(); + } +} diff --git a/backend/src/document_type/entities/document_type.entity.ts b/backend/src/document_type/entities/document_type.entity.ts new file mode 100644 index 00000000..20e31cd5 --- /dev/null +++ b/backend/src/document_type/entities/document_type.entity.ts @@ -0,0 +1,44 @@ +import { + Column, + CreateDateColumn, + Entity, + ManyToMany, + OneToMany, + PrimaryGeneratedColumn, + UpdateDateColumn, +} from 'typeorm'; +import { DocumentTemplate } from '../../document_template/entities/document_template.entity'; +import { DocumentData } from 'src/document_data/entities/document_data.entity'; +import { Provision } from 'src/provision/entities/provision.entity'; + +@Entity() +export class DocumentType { + @PrimaryGeneratedColumn() + id: number; + @Column() + name: string; + @Column() + create_userid: string; + @Column() + update_userid: string; + @CreateDateColumn() + create_timestamp: Date; + @UpdateDateColumn() + update_timestamp: Date; + @OneToMany(() => DocumentTemplate, (document_template) => document_template.document_type, { + nullable: true, + }) + document_templates: DocumentTemplate[]; + @OneToMany(() => DocumentData, (document_data) => document_data.document_type, { + nullable: true, + }) + document_data: DocumentData[]; + @ManyToMany(() => Provision, (provision) => provision.document_types) + provisions: Provision[]; + + constructor(name?: string, create_userid?: string, update_userid?: string) { + this.name = name || ''; + this.create_userid = create_userid || ''; + this.update_userid = update_userid || ''; + } +} diff --git a/backend/src/main.ts b/backend/src/main.ts index c0dcef8a..8dddd1e6 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -20,7 +20,7 @@ async function bootstrap() { const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api', app, document); const appService = app.get(AppService); - // await appService.initializeDb(); + await appService.initializeDb(); await app.listen(3001); } diff --git a/backend/src/nfr_data/dto/create-nfr_data.dto.ts b/backend/src/nfr_data/dto/create-nfr_data.dto.ts deleted file mode 100644 index 998f3dd6..00000000 --- a/backend/src/nfr_data/dto/create-nfr_data.dto.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { PickType } from '@nestjs/swagger'; -import { NFRDataDto } from './nfr_data.dto'; - -export class CreateNFRDataDto extends PickType(NFRDataDto, [ - 'dtid', - 'variant_name', - 'template_id', - 'status', - 'create_userid', -] as const) {} diff --git a/backend/src/nfr_data/dto/update-nfr_data.dto.ts b/backend/src/nfr_data/dto/update-nfr_data.dto.ts deleted file mode 100644 index 697d20f6..00000000 --- a/backend/src/nfr_data/dto/update-nfr_data.dto.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { PickType } from '@nestjs/swagger'; -import { NFRDataDto } from './nfr_data.dto'; - -export class UpdateNFRDataDto extends PickType(NFRDataDto, [ - 'dtid', - 'variant_name', - 'template_id', - 'status', - 'enabled_provisions', - 'update_userid', -] as const) {} diff --git a/backend/src/nfr_data/entities/nfr_data.entity.ts b/backend/src/nfr_data/entities/nfr_data.entity.ts deleted file mode 100644 index 4dc28a5a..00000000 --- a/backend/src/nfr_data/entities/nfr_data.entity.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Column, CreateDateColumn, Entity, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'; -import { NFRDataProvision } from './nfr_data_provision.entity'; -import { NFRDataVariable } from './nfr_data_variable.entity'; - -@Entity() -export class NFRData { - @PrimaryGeneratedColumn() - id: number; - @Column({ nullable: true }) - dtid: number; - @Column({ nullable: true }) - variant_name: string; - - @Column({ nullable: true }) - template_id: number; - @Column({ nullable: true }) - status: string; - @OneToMany(() => NFRDataProvision, (nfrDataProvision) => nfrDataProvision.nfr_data, { - nullable: true, - cascade: true, - }) - nfr_data_provisions: NFRDataProvision[]; - @OneToMany(() => NFRDataVariable, (nfrDataVariable) => nfrDataVariable.nfr_data, { - nullable: true, - cascade: true, - }) - nfr_data_variables: NFRDataVariable[]; - @Column({ nullable: true }) - active: boolean; - @Column({ nullable: true }) - create_userid: string; - @Column({ nullable: true }) - update_userid: string; - @CreateDateColumn() - create_timestamp: Date; - @UpdateDateColumn() - update_timestamp: Date; - - public get getNfrDataProvisions(): NFRDataProvision[] { - return this.nfr_data_provisions; - } - public get getNfrDataVariables(): NFRDataVariable[] { - return this.nfr_data_variables; - } - - constructor( - dtid?: number, - variant_name?: string, - template_id?: number, - status?: string, - create_userid?: string, - update_userid?: string - ) { - this.dtid = dtid || null; - this.variant_name = variant_name || ''; - this.template_id = template_id || null; - this.status = status || ''; - this.create_userid = create_userid || ''; - this.update_userid = update_userid || ''; - } -} diff --git a/backend/src/nfr_data/entities/nfr_data_provision.entity.ts b/backend/src/nfr_data/entities/nfr_data_provision.entity.ts deleted file mode 100644 index 0c2f1ec5..00000000 --- a/backend/src/nfr_data/entities/nfr_data_provision.entity.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { NFRProvision } from 'src/nfr_provision/entities/nfr_provision.entity'; -import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; -import { NFRData } from './nfr_data.entity'; - -@Entity() -export class NFRDataProvision { - @PrimaryGeneratedColumn() - id: number; - @ManyToOne(() => NFRProvision, (nfr_provision) => nfr_provision.nfr_data_provisions, { onDelete: 'CASCADE' }) - nfr_provision: NFRProvision; - @ManyToOne(() => NFRData, (nfr_data) => nfr_data.nfr_data_provisions, { - onDelete: 'CASCADE', - }) - nfr_data: NFRData; - @Column({ nullable: true }) - provision_free_text: string; - - constructor(provision_free_text?: string) { - this.provision_free_text = provision_free_text || ''; - } -} diff --git a/backend/src/nfr_data/entities/nfr_data_variable.entity.ts b/backend/src/nfr_data/entities/nfr_data_variable.entity.ts deleted file mode 100644 index ed2ee031..00000000 --- a/backend/src/nfr_data/entities/nfr_data_variable.entity.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { NFRProvisionVariable } from 'src/nfr_provision/entities/nfr_provision_variable.entity'; -import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; -import { NFRData } from './nfr_data.entity'; - -@Entity() -export class NFRDataVariable { - @PrimaryGeneratedColumn() - id: number; - @ManyToOne(() => NFRProvisionVariable, (nfr_variable) => nfr_variable.nfr_data_variables, { onDelete: 'CASCADE' }) - nfr_variable: NFRProvisionVariable; - @ManyToOne(() => NFRData, (nfr_data) => nfr_data.nfr_data_variables, { - onDelete: 'CASCADE', - }) - nfr_data: NFRData; - @Column({ nullable: true }) - data_variable_value: string; - - constructor(data_variable_value?: string) { - this.data_variable_value = data_variable_value || ''; - } -} diff --git a/backend/src/nfr_data/entities/nfr_data_vw.ts b/backend/src/nfr_data/entities/nfr_data_vw.ts deleted file mode 100644 index 3ea05416..00000000 --- a/backend/src/nfr_data/entities/nfr_data_vw.ts +++ /dev/null @@ -1,221 +0,0 @@ -import { DataSource, ViewColumn, ViewEntity } from 'typeorm'; -import { NFRData } from './nfr_data.entity'; - -@ViewEntity({ - expression: (dataSource: DataSource) => - dataSource - .createQueryBuilder() - .select('nfr_data.id', 'NFRDataId') - .addSelect('nfr_data.dtid', 'DTID') - .addSelect('nfr_data.db_address_regional_office', 'DB_Address_Regional_Office') - .addSelect('nfr_data.var_telephone_number', 'VAR_Telephone_Number') - .addSelect('nfr_data.var_facsimile_number', 'VAR_Facsimile_Number') - .addSelect('nfr_data.db_name_bcal_contact', 'DB_Name_BCAL_Contact') - .addSelect('nfr_data.db_file_number', 'DB_File_Number') - .addSelect('nfr_data.var_client_file_no', 'VAR_Client_File_No') - .addSelect('nfr_data.var_date_of_notice', 'VAR_Date_Of_Notice') - .addSelect('nfr_data.db_address_mailing_tenant', 'DB_Address_Mailing_Tenant') - .addSelect('nfr_data.var_attention_line', 'VAR_Attention_Line') - .addSelect('nfr_data.var_salutation', 'VAR_Salutation') - .addSelect('nfr_data.db_tenure_type', 'DB_Tenure_Type') - .addSelect('nfr_data.var_purpose_generic', 'VAR_Purpose_Generic') - .addSelect('nfr_data.db_legal_description', 'DB_Legal_Description') - .addSelect('nfr_data.show_section_five_1', 'showSectionFive_1') - .addSelect('nfr_data.section_five_1_text', 'SectionFive_1_Text') - .addSelect('nfr_data.insert_space', 'Insert_Space') - .addSelect('nfr_data.var_replacement_tenure_type', 'VAR_Replacement_Tenure_Type') - .addSelect('nfr_data.show_section_five_2', 'showSectionFive_2') - .addSelect('nfr_data.section_five_2_text', 'SectionFive_2_Text') - .addSelect('nfr_data.var_why_land_differs', 'VAR_Why_Land_Differs') - .addSelect('nfr_data.show_section_five_3', 'showSectionFive_3') - .addSelect('nfr_data.var_sect5_free_field', 'VAR_Sect5_Free_Field') - .addSelect('nfr_data.var_deadline_completion_requirements', 'VAR_Deadline_Completion_Requirements') - .addSelect('nfr_data.var_number_of_copies', 'VAR_Number_Of_Copies') - .addSelect('nfr_data.db_fee_payable_type', 'DB_Fee_Payable_Type') - .addSelect('nfr_data.db_fee_payable_amount_gst', 'DB_Fee_Payable_Amount_GST') - .addSelect('nfr_data.db_fee_payable_amount', 'DB_Fee_Payable_Amount') - .addSelect('nfr_data.db_fp_asterisk', 'DB_FP_Asterisk') - .addSelect('nfr_data.var_fee_occupational_rental_amount', 'VAR_Fee_Occupational_Rental_Amount') - .addSelect('nfr_data.var_fee_application_amount', 'VAR_Fee_Application_Amount') - .addSelect('nfr_data.var_fee_other_credit_amount', 'VAR_Fee_Other_Credit_Amount') - .addSelect('nfr_data.db_total_gst_amount', 'DB_Total_GST_Amount') - .addSelect('nfr_data.db_total_monies_payable', 'DB_Total_Monies_Payable') - .addSelect('nfr_data.db_address_line_regional_office', 'DB_Address_Line_Regional_Office') - .addSelect('nfr_data.var_interim_tenure_type', 'VAR_Interim_Tenure_Type') - .addSelect('nfr_data.show_section_fifteen_1', 'showSectionFifteen_1') - .addSelect('nfr_data.section_fifteen_1_text', 'SectionFifteen_1_Text') - .addSelect('nfr_data.var_occ_rent_details', 'VAR_Occ_Rent_Details') - .addSelect('nfr_data.show_section_twenty_1', 'showSectionTwenty_1') - .addSelect('nfr_data.section_twenty_1_text', 'SectionTwenty_1_Text') - .addSelect('nfr_data.show_section_twenty_2', 'showSectionTwenty_2') - .addSelect('nfr_data.section_twenty_2_text', 'SectionTwenty_2_Text') - .addSelect('nfr_data.show_section_twenty_3', 'showSectionTwenty_3') - .addSelect('nfr_data.section_twenty_3_text', 'SectionTwenty_3_Text') - .addSelect('nfr_data.show_section_twenty_4', 'showSectionTwenty_4') - .addSelect('nfr_data.section_twenty_4_text', 'SectionTwenty_4_Text') - .addSelect('nfr_data.show_section_twenty_5', 'showSectionTwenty_5') - .addSelect('nfr_data.section_twenty_5_text', 'SectionTwenty_5_Text') - .addSelect('nfr_data.show_section_twentyfive_1', 'showSectionTwentyFive_1') - .addSelect('nfr_data.section_twentyfive_1_text', 'SectionTwentyFive_1_Text') - .addSelect('nfr_data.show_section_twentyfive_2', 'showSectionTwentyFive_2') - .addSelect('nfr_data.section_twentyfive_2_text', 'SectionTwentyFive_2_Text') - .addSelect('nfr_data.show_section_twentyfive_3', 'showSectionTwentyFive_3') - .addSelect('nfr_data.section_twentyfive_3_text', 'SectionTwentyFive_3_Text') - .addSelect('nfr_data.show_section_twentyfive_4', 'showSectionTwentyFive_4') - .addSelect('nfr_data.section_twentyfive_4_text', 'SectionTwentyFive_4_Text') - .addSelect('nfr_data.show_section_twentyseven_1', 'showSectionTwentySeven_1') - .addSelect('nfr_data.section_twentyseven_1_text', 'SectionTwentySeven_1_Text') - .addSelect('nfr_data.show_section_twentyseven_2', 'showSectionTwentySeven_2') - .addSelect('nfr_data.section_twentyseven_2_text', 'SectionTwentySeven_2_Text') - .addSelect('nfr_data.show_section_twentyseven_3', 'showSectionTwentySeven_3') - .addSelect('nfr_data.section_twentyseven_3_text', 'SectionTwentySeven_3_Text') - .addSelect('nfr_data.show_section_twentyseven_4', 'showSectionTwentySeven_4') - .addSelect('nfr_data.section_twentyseven_4_text', 'SectionTwentySeven_4_Text') - .addSelect('nfr_data.show_section_twentyseven_5', 'showSectionTwentySeven_5') - .addSelect('nfr_data.section_twentyseven_5_text', 'SectionTwentySeven_5_Text') - .addSelect('nfr_data.show_section_twentyseven_6', 'showSectionTwentySeven_6') - .addSelect('nfr_data.section_twentyseven_6_text', 'SectionTwentySeven_6_Text') - .from(NFRData, 'nfr_data'), -}) -export class NFRDataView { - @ViewColumn() - NFRDataId: number; - @ViewColumn() - DTID: number; - @ViewColumn() - DB_Address_Regional_Office: string; - @ViewColumn() - VAR_Telephone_Number: string; - @ViewColumn() - VAR_Facsimile_Number: string; - @ViewColumn() - DB_Name_BCAL_Contact: string; - @ViewColumn() - DB_File_Number: string; - @ViewColumn() - VAR_Client_File_No: string; - @ViewColumn() - VAR_Date_Of_Notice: string; - @ViewColumn() - DB_Address_Mailing_Tenant: string; - @ViewColumn() - VAR_Attention_Line: string; - @ViewColumn() - VAR_Salutation: string; - @ViewColumn() - DB_Tenure_Type: string; - @ViewColumn() - VAR_Purpose_Generic: string; - @ViewColumn() - DB_Legal_Description: string; - @ViewColumn() - showSectionFive_1: number; - @ViewColumn() - SectionFive_1_Text: string; - @ViewColumn() - Insert_Space: string; - @ViewColumn() - VAR_Replacement_Tenure_Type: string; - @ViewColumn() - showSectionFive_2: number; - @ViewColumn() - SectionFive_2_Text: string; - @ViewColumn() - VAR_Why_Land_Differs: string; - @ViewColumn() - showSectionFive_3: string; - @ViewColumn() - VAR_Sect5_Free_Field: string; - @ViewColumn() - VAR_Deadline_Completion_Requirements: string; - @ViewColumn() - VAR_Number_Of_Copies: string; - @ViewColumn() - DB_Fee_Payable_Type: string; - @ViewColumn() - DB_Fee_Payable_Amount_GST: string; - @ViewColumn() - DB_Fee_Payable_Amount: string; - @ViewColumn() - DB_FP_Asterisk: string; - @ViewColumn() - VAR_Fee_Occupational_Rental_Amount: string; - @ViewColumn() - VAR_Fee_Application_Amount: string; - @ViewColumn() - VAR_Fee_Other_Credit_Amount: string; - @ViewColumn() - DB_Total_GST_Amount: string; - @ViewColumn() - DB_Total_Monies_Payable: string; - @ViewColumn() - DB_Address_Line_Regional_Office: string; - @ViewColumn() - VAR_Interim_Tenure_Type: string; - @ViewColumn() - showSectionFifteen_1: number; - @ViewColumn() - SectionFifteen_1_Text: string; - @ViewColumn() - VAR_Occ_Rent_Details: string; - @ViewColumn() - showSectionTwenty_1: number; - @ViewColumn() - SectionTwenty_1_Text: string; - @ViewColumn() - showSectionTwenty_2: number; - @ViewColumn() - SectionTwenty_2_Text: string; - @ViewColumn() - showSectionTwenty_3: number; - @ViewColumn() - SectionTwenty_3_Text: string; - @ViewColumn() - showSectionTwenty_4: number; - @ViewColumn() - SectionTwenty_4_Text: string; - @ViewColumn() - showSectionTwenty_5: number; - @ViewColumn() - SectionTwenty_5_Text: string; - @ViewColumn() - showSectionTwentyFive_1: number; - @ViewColumn() - SectionTwentyFive_1_Text: string; - @ViewColumn() - showSectionTwentyFive_2: number; - @ViewColumn() - SectionTwentyFive_2_Text: string; - @ViewColumn() - showSectionTwentyFive_3: number; - @ViewColumn() - SectionTwentyFive_3_Text: string; - @ViewColumn() - showSectionTwentyFive_4: number; - @ViewColumn() - SectionTwentyFive_4_Text: string; - @ViewColumn() - showSectionTwentySeven_1: number; - @ViewColumn() - SectionTwentySeven_1_Text: string; - @ViewColumn() - showSectionTwentySeven_2: number; - @ViewColumn() - SectionTwentySeven_2_Text: string; - @ViewColumn() - showSectionTwentySeven_3: number; - @ViewColumn() - SectionTwentySeven_3_Text: string; - @ViewColumn() - showSectionTwentySeven_4: number; - @ViewColumn() - SectionTwentySeven_4_Text: string; - @ViewColumn() - showSectionTwentySeven_5: number; - @ViewColumn() - SectionTwentySeven_5_Text: string; - @ViewColumn() - showSectionTwentySeven_6: number; - @ViewColumn() - SectionTwentySeven_6_Text: string; -} diff --git a/backend/src/nfr_data/nfr_data.controller.ts b/backend/src/nfr_data/nfr_data.controller.ts deleted file mode 100644 index 43f09494..00000000 --- a/backend/src/nfr_data/nfr_data.controller.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { Body, Controller, Delete, Get, Param, Post } from '@nestjs/common'; -import { ProvisionJSON, VariableJSON } from 'utils/types'; -import { CreateNFRDataDto } from './dto/create-nfr_data.dto'; -import { NFRDataService } from './nfr_data.service'; - -@Controller('nfr-data') -export class NFRDataController { - constructor(private readonly nfrDataService: NFRDataService) {} - - @Post() - async create( - @Body() - data: { - body: CreateNFRDataDto & { - provisionJsonArray: ProvisionJSON[]; - variableJsonArray: VariableJSON[]; - }; - } - ) { - const provArr = data.body.provisionJsonArray; - const varArr = data.body.variableJsonArray; - delete data.body['provisionJsonArray']; - delete data.body['variableJsonArray']; - return this.nfrDataService.createOrUpdate(data.body, provArr, varArr); - } - - @Get() - findAll() { - return this.nfrDataService.findAll(); - } - - @Get(':nfrDataId') - findById(@Param('nfrDataId') nfrDataId: number) { - if (nfrDataId && nfrDataId != 0) { - return this.nfrDataService.findByNfrDataId(nfrDataId); - } else { - return null; - } - } - - @Get('dtid/:dtid') - findActiveByDtid(@Param('dtid') dtid: number) { - return this.nfrDataService.findActiveByDtid(dtid); - } - - @Get('view/:nfrDataId') - findViewByPRDID(@Param('nfrDataId') nfrDataId: string) { - return this.nfrDataService.findViewByNFRDataId(+nfrDataId); - } - - @Get('variables/:variantName/:dtid') - getVariablesByVariantAndDtid(@Param('variantName') variantName: string, @Param('dtid') dtid: number) { - return this.nfrDataService.getVariablesByVariantAndDtid(variantName, dtid); - } - - @Get('provisions/:variantName/:dtid') - getProvisionsByVariantAndDtid(@Param('variantName') variantName: string, @Param('dtid') dtid: number) { - return this.nfrDataService.getProvisionsByVariantAndDtid(variantName, dtid); - } - - @Get('get-enabled-provisions/:variantName/:dtid') - getEnabledProvisionsByVariantAndDtid(@Param('variantName') variantName: string, @Param('dtid') dtid: number) { - return this.nfrDataService.getEnabledProvisionsByVariantAndDtid(variantName, dtid); - } - - @Delete(':dtid') - remove(@Param('dtid') dtid: string) { - return this.nfrDataService.remove(+dtid); - } -} diff --git a/backend/src/nfr_data/nfr_data.module.ts b/backend/src/nfr_data/nfr_data.module.ts deleted file mode 100644 index 61fa0ca6..00000000 --- a/backend/src/nfr_data/nfr_data.module.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Module } from '@nestjs/common'; -import { TypeOrmModule } from '@nestjs/typeorm'; -import { DocumentTemplateModule } from 'src/document_template/document_template.module'; -import { NFRProvisionVariable } from 'src/nfr_provision/entities/nfr_provision_variable.entity'; -import { NFRProvisionModule } from 'src/nfr_provision/nfr_provision.module'; -import { NFRProvisionService } from 'src/nfr_provision/nfr_provision.service'; -import { NFRProvision } from '../nfr_provision/entities/nfr_provision.entity'; -import { NFRProvisionVariant } from '../nfr_provision/entities/nfr_provision_variant.entity'; -import { NFRData } from './entities/nfr_data.entity'; -import { NFRDataProvision } from './entities/nfr_data_provision.entity'; -import { NFRDataVariable } from './entities/nfr_data_variable.entity'; -import { NFRDataController } from './nfr_data.controller'; -import { NFRDataService } from './nfr_data.service'; - -@Module({ - imports: [ - TypeOrmModule.forFeature([NFRData]), - TypeOrmModule.forFeature([NFRDataProvision]), - TypeOrmModule.forFeature([NFRProvisionVariable]), - TypeOrmModule.forFeature([NFRDataVariable]), - TypeOrmModule.forFeature([NFRProvision]), - TypeOrmModule.forFeature([NFRProvisionVariant]), - NFRProvisionModule, - DocumentTemplateModule, - ], - controllers: [NFRDataController], - providers: [NFRDataService], -}) -export class NFRDataModule {} diff --git a/backend/src/nfr_data/nfr_data.service.ts b/backend/src/nfr_data/nfr_data.service.ts deleted file mode 100644 index e51a25a4..00000000 --- a/backend/src/nfr_data/nfr_data.service.ts +++ /dev/null @@ -1,375 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { InjectRepository } from '@nestjs/typeorm'; -import { NFRProvision } from 'src/nfr_provision/entities/nfr_provision.entity'; -import { NFRProvisionVariable } from 'src/nfr_provision/entities/nfr_provision_variable.entity'; -import { DataSource, In, Repository } from 'typeorm'; -import { CreateNFRDataDto } from './dto/create-nfr_data.dto'; -import { NFRData } from './entities/nfr_data.entity'; -import { NFRDataProvision } from './entities/nfr_data_provision.entity'; -import { NFRDataVariable } from './entities/nfr_data_variable.entity'; -import { NFRDataView } from './entities/nfr_data_vw'; -import { NFRProvisionService } from 'src/nfr_provision/nfr_provision.service'; -import { DocumentTemplateService } from 'src/document_template/document_template.service'; - -@Injectable() -export class NFRDataService { - constructor( - @InjectRepository(NFRData) - private nfrDataRepository: Repository, - @InjectRepository(NFRProvision) - private nfrProvisionRepository: Repository, - @InjectRepository(NFRDataProvision) - private nfrDataProvisionRepository: Repository, - @InjectRepository(NFRProvisionVariable) - private nfrProvisionVariableRepository: Repository, - @InjectRepository(NFRDataVariable) - private nfrDataVariableRepository: Repository, - private nfrProvisionService: NFRProvisionService, - private documentTemplateService: DocumentTemplateService, - private dataSource: DataSource - ) {} - - async createOrUpdate( - nfrDataDto: CreateNFRDataDto, - provisionArray: { provision_id: number; free_text: string }[], - variableArray: { variable_id: number; variable_value: string }[] - ): Promise { - const { dtid, variant_name } = nfrDataDto; - const nfrData: NFRData = await this.nfrDataRepository.findOne({ - where: { dtid: dtid, variant_name: variant_name }, - relations: [ - 'nfr_data_variables', - 'nfr_data_provisions', - 'nfr_data_variables.nfr_variable', - 'nfr_data_provisions.nfr_provision', - ], - }); - - const nfrProvisionIds = provisionArray.map(({ provision_id }) => provision_id); - const nfrProvisions = await this.nfrProvisionRepository.findBy({ - id: In(nfrProvisionIds), - }); - const nfrVariableIds = variableArray.map(({ variable_id }) => variable_id); - const nfrVariables = await this.nfrProvisionVariableRepository.findBy({ - id: In(nfrVariableIds), - }); - - // if nfrData for this dtid+template exists, update it - if (nfrData) { - return await this.updateNfrData(nfrDataDto, nfrData, provisionArray, variableArray, nfrProvisions, nfrVariables); - } - // else create new nfrData - const documentTemplate = await this.documentTemplateService.findActiveByDocumentType(nfrDataDto.variant_name); - nfrDataDto['template_id'] = documentTemplate ? documentTemplate.id : null; - const newNfrData: NFRData = this.nfrDataRepository.create(nfrDataDto); - const updatedNfrData = await this.nfrDataRepository.save(newNfrData); - - const nfrDataProvisions = provisionArray.map(({ provision_id, free_text }) => { - const nfrProvision = nfrProvisions.find((provision) => provision.id === provision_id); - const nfrDataProvision = new NFRDataProvision(); - nfrDataProvision.nfr_data = updatedNfrData; - nfrDataProvision.nfr_provision = nfrProvision; - nfrDataProvision.provision_free_text = nfrProvision.free_text; // quick fix to not use the free_text from the nfr page - return nfrDataProvision; - }); - const nfrDataVariables = variableArray.map(({ variable_id, variable_value }) => { - const nfrVariable = nfrVariables.find((variable) => variable.id === variable_id); - const nfrDataVariable = new NFRDataVariable(); - nfrDataVariable.nfr_data = updatedNfrData; - nfrDataVariable.nfr_variable = nfrVariable; - nfrDataVariable.data_variable_value = variable_value; - return nfrDataVariable; - }); - if (nfrData) { - await this.deleteDataVarsAndProvs(nfrData, provisionArray, variableArray); - } - - await this.nfrDataProvisionRepository.save(nfrDataProvisions); - await this.nfrDataVariableRepository.save(nfrDataVariables); - - await this.makeActive(newNfrData.dtid, newNfrData.variant_name); - - return updatedNfrData; - } - - async updateNfrData( - nfrDataDto: CreateNFRDataDto, - nfrData: NFRData, - provisionArray: { provision_id: number; free_text: string }[], - variableArray: { variable_id: number; variable_value: string }[], - nfrProvisions: NFRProvision[], - nfrVariables: NFRProvisionVariable[] - ): Promise { - // Update NFRData entity - nfrData.variant_name = nfrDataDto.variant_name; - nfrData.template_id = nfrDataDto.template_id; - nfrData.status = nfrDataDto.status; - nfrData.update_userid = nfrDataDto.create_userid; - - const updatedNfrData = await this.nfrDataRepository.save(nfrData); - await this.makeActive(nfrData.dtid, nfrData.variant_name); - - // Update NFRDataProvision entities - for (const provision of provisionArray) { - const nfrDataProvision = nfrData.nfr_data_provisions.find((p) => p.nfr_provision.id === provision.provision_id); - const nfrProvision = nfrProvisions.find((p) => p.id === provision.provision_id); - - if (nfrDataProvision && nfrDataProvision.provision_free_text != nfrProvision.free_text) { - // Update an existing NFRDataProvision entry - nfrDataProvision.provision_free_text = nfrProvision.free_text; - await this.nfrDataProvisionRepository.save(nfrDataProvision); - } else if (!nfrDataProvision) { - // No data found for this specific provision so create a new entry in NFRDataProvision - const nfrProvisionToAdd = await this.nfrProvisionRepository.findOneBy({ - id: provision.provision_id, - }); - const newNfrDataProvision: NFRDataProvision = this.nfrDataProvisionRepository.create({ - nfr_provision: nfrProvisionToAdd, - nfr_data: updatedNfrData, - provision_free_text: nfrProvisionToAdd.free_text, // quick fix - }); - await this.nfrDataProvisionRepository.save(newNfrDataProvision); - } - } - - // Update NFRDataVariable entities - for (const variable of variableArray) { - const nfrDataVariable = nfrData.nfr_data_variables.find((v) => v.nfr_variable.id === variable.variable_id); - - if (nfrDataVariable && nfrDataVariable.data_variable_value != variable.variable_value) { - // Update an existing NFRDataVariable entry - nfrDataVariable.data_variable_value = variable.variable_value; - await this.nfrDataVariableRepository.save(nfrDataVariable); - } else if (!nfrDataVariable) { - // No data found for this specific variable so create a new entry in NFRDataVariable - const nfrVariable = await this.nfrProvisionVariableRepository.findOneBy({ - id: variable.variable_id, - }); - const newNfrDataVariable: NFRDataVariable = this.nfrDataVariableRepository.create({ - nfr_variable: nfrVariable, - nfr_data: updatedNfrData, - data_variable_value: variable.variable_value, - }); - await this.nfrDataVariableRepository.save(newNfrDataVariable); - } - } - await this.deleteDataVarsAndProvs(nfrData, provisionArray, variableArray); - - return updatedNfrData; - } - - async deleteDataVarsAndProvs( - nfrData: NFRData, - provisionArray: { provision_id: number; free_text: string }[], - variableArray: { variable_id: number; variable_value: string }[] - ) { - // Delete data provisions that have been removed by the user - const oldProvisionIds = nfrData - ? nfrData.nfr_data_provisions.map((dataProvision) => dataProvision.nfr_provision.id) - : []; - const newProvisionIds = provisionArray.map(({ provision_id }) => provision_id); - const provisionsToDelete = oldProvisionIds.filter((item) => !newProvisionIds.includes(item)); - const nfrDataProvisionsToDelete = nfrData.nfr_data_provisions - .filter((dataProvision) => provisionsToDelete.includes(dataProvision.nfr_provision.id)) - .map((dataProvision) => dataProvision.id); - if (nfrDataProvisionsToDelete.length > 0) { - await this.nfrDataProvisionRepository.delete(nfrDataProvisionsToDelete); - } - - // Delete data variables that have been removed by the user - const oldVariableIds = nfrData - ? nfrData.nfr_data_variables.map((dataVariable) => dataVariable.nfr_variable.id) - : []; - const newVariableIds = variableArray.map(({ variable_id }) => variable_id); - const variablesToDelete = oldVariableIds.filter((item) => !newVariableIds.includes(item)); - const nfrDataVariablesToDelete = nfrData.nfr_data_variables - .filter((dataVariable) => variablesToDelete.includes(dataVariable.nfr_variable.id)) - .map((dataVariable) => dataVariable.id); - if (nfrDataVariablesToDelete.length > 0) { - await this.nfrDataVariableRepository.delete(nfrDataVariablesToDelete); - } - return null; - } - - // Used by the search page. - // Variant data is persisted so only return the active variant foreach dtid. - async findAll(): Promise { - return await this.nfrDataRepository.find({ - where: { - active: true, - }, - }); - } - - async findByNfrDataId(nfrDataId: number): Promise<{ - nfrData: NFRData; - provisionIds: number[]; - variableIds: number[]; - }> { - try { - const nfrData = await this.nfrDataRepository.findOne({ - where: { id: nfrDataId }, - join: { - alias: 'nfr_data', - leftJoinAndSelect: { - nfr_data_provisions: 'nfr_data.nfr_data_provisions', - nfr_provision: 'nfr_data_provisions.nfr_provision', - nfr_data_variables: 'nfr_data.nfr_data_variables', - nfr_variable: 'nfr_data_variables.nfr_variable', - }, - }, - }); - const existingDataProvisions = nfrData.nfr_data_provisions; - const provisionIds = existingDataProvisions.map((dataProvision) => dataProvision.nfr_provision.id); - const existingDataVariables = nfrData.nfr_data_variables; - const variableIds = existingDataVariables.map((dataVariable) => dataVariable.nfr_variable.id); - return { nfrData, provisionIds, variableIds }; - } catch (err) { - console.log(err); - return null; - } - } - - async findActiveByDtid(dtid: number): Promise<{ - nfrData: NFRData; - provisionIds: number[]; - variableIds: number[]; - }> { - try { - const nfrData = await this.nfrDataRepository.findOne({ - where: { dtid: dtid, active: true }, - join: { - alias: 'nfr_data', - leftJoinAndSelect: { - nfr_data_provisions: 'nfr_data.nfr_data_provisions', - nfr_provision: 'nfr_data_provisions.nfr_provision', - nfr_data_variables: 'nfr_data.nfr_data_variables', - nfr_variable: 'nfr_data_variables.nfr_variable', - }, - }, - }); - const provisionIds = - nfrData && nfrData.nfr_data_provisions - ? nfrData.nfr_data_provisions.map((dataProvision) => dataProvision.nfr_provision.id) - : []; - const variableIds = - nfrData && nfrData.nfr_data_variables - ? nfrData.nfr_data_variables.map((dataVariable) => dataVariable.nfr_variable.id) - : []; - return { nfrData, provisionIds, variableIds }; - } catch (err) { - console.log(err); - return null; - } - } - - async findViewByNFRDataId(nfrDataId: number): Promise { - return this.dataSource.manager.findOneBy(NFRDataView, { - NFRDataId: nfrDataId, - }); - } - - async getVariablesByVariantAndDtid(variantName: string, dtid: number) { - const nfrData: NFRData = await this.nfrDataRepository.findOne({ - where: { dtid: dtid, variant_name: variantName }, - join: { - alias: 'nfr_data', - leftJoinAndSelect: { - nfr_data_variables: 'nfr_data.nfr_data_variables', - nfr_variable: 'nfr_data_variables.nfr_variable', - }, - }, - }); - // if the nfrData doesn't exist yet, return null. This null value is caught elsewhere. - if (!nfrData) { - return null; - } - // saved variables attached to the nfrData entry - const existingDataVariables: NFRDataVariable[] = nfrData.nfr_data_variables; - // all variables associated with the variant - const variables: NFRProvisionVariable[] = await this.nfrProvisionService.getVariablesByVariant( - nfrData.variant_name - ); - // inserting the existing variable_values to the set of all variables - for (const variable of variables) { - const existingDataVariable = existingDataVariables.find( - (dataVariable) => dataVariable.nfr_variable.id === variable.id - ); - if (existingDataVariable) { - variable.variable_value = existingDataVariable.data_variable_value; - } - } - const variableIds = existingDataVariables.map((dataVariable) => dataVariable.nfr_variable.id); - return { variables, variableIds }; - } - - async getProvisionsByVariantAndDtid(variantName: string, dtid: number) { - const nfrData: NFRData = await this.nfrDataRepository.findOne({ - where: { dtid: dtid, variant_name: variantName }, - join: { - alias: 'nfr_data', - leftJoinAndSelect: { - nfr_data_provisions: 'nfr_data.nfr_data_provisions', - nfr_provision: 'nfr_data_provisions.nfr_provision', - }, - }, - }); - // if the nfrData doesn't exist yet, return null. This null value is caught elsewhere. - if (!nfrData) { - return null; - } - // nfrData for all variants of this dtid - const fullNfrData: NFRData[] = await this.nfrDataRepository.find({ - where: { dtid: nfrData.dtid }, - join: { - alias: 'nfr_data', - leftJoinAndSelect: { - nfr_data_provisions: 'nfr_data.nfr_data_provisions', - nfr_provision: 'nfr_data_provisions.nfr_provision', - }, - }, - }); - - // saved provisions attached to the dtid - const existingDataProvisions: NFRDataProvision[] = []; - fullNfrData.forEach((nfrData) => { - existingDataProvisions.push(...nfrData.nfr_data_provisions); - }); - // all provisions - const provisions: NFRProvision[] = await this.nfrProvisionService.getAllProvisions(); - const provisionIds = existingDataProvisions.map((dataProvision) => dataProvision.nfr_provision.id); - return { provisions, provisionIds }; - } - - async getEnabledProvisionsByVariantAndDtid(variantName: string, dtid: number) { - const nfrData: NFRData = await this.nfrDataRepository.findOne({ - where: { variant_name: variantName, dtid: dtid }, - join: { - alias: 'nfr_data', - leftJoinAndSelect: { - nfr_data_provisions: 'nfr_data.nfr_data_provisions', - nfr_provision: 'nfr_data_provisions.nfr_provision', - }, - }, - }); - const provisionIds = - nfrData && nfrData.nfr_data_provisions - ? nfrData.nfr_data_provisions.map((dataProvision) => dataProvision.nfr_provision.id) - : []; - return provisionIds; - } - - async remove(dtid: number): Promise<{ deleted: boolean; message?: string }> { - try { - await this.nfrDataRepository.delete({ dtid: dtid }); - return { deleted: true }; - } catch (err) { - return { deleted: false, message: err.message }; - } - } - - async makeActive(dtid: number, variant_name: string): Promise { - await this.nfrDataRepository.update({ dtid: dtid }, { active: false }); - await this.nfrDataRepository.update({ dtid: dtid, variant_name: variant_name }, { active: true }); - } -} diff --git a/backend/src/nfr_data_log/dto/create-nfr_data_log.dto.ts b/backend/src/nfr_data_log/dto/create-nfr_data_log.dto.ts deleted file mode 100644 index 95de3a5e..00000000 --- a/backend/src/nfr_data_log/dto/create-nfr_data_log.dto.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { PickType } from '@nestjs/swagger'; -import { NFRDataLogDto } from './nfr_data_log.dto'; - -export class CreateNFRDataLogDto extends PickType(NFRDataLogDto, [ - 'document_template_id', - 'nfr_data_id', - 'dtid', - 'request_app_user', - 'request_json', - 'create_userid', -] as const) {} diff --git a/backend/src/nfr_data_log/dto/update-nfr_data_log.dto.ts b/backend/src/nfr_data_log/dto/update-nfr_data_log.dto.ts deleted file mode 100644 index 4d7fc5be..00000000 --- a/backend/src/nfr_data_log/dto/update-nfr_data_log.dto.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { PickType } from '@nestjs/swagger'; -import { NFRDataLogDto } from './nfr_data_log.dto'; - -export class UpdateNFRDataLogDto extends PickType(NFRDataLogDto, [ - 'document_template_id', - 'nfr_data_id', - 'dtid', - 'request_app_user', - 'request_json', - 'update_userid', -] as const) {} diff --git a/backend/src/nfr_data_log/entities/nfr_data_log.entity.ts b/backend/src/nfr_data_log/entities/nfr_data_log.entity.ts deleted file mode 100644 index 3c1d24bd..00000000 --- a/backend/src/nfr_data_log/entities/nfr_data_log.entity.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'; - -@Entity() -export class NFRDataLog { - @PrimaryGeneratedColumn() - id: number; - @Column({ nullable: true }) - document_template_id: number; - @Column({ nullable: true }) - nfr_data_id: number; - @Column({ nullable: true }) - dtid: number; - @Column({ nullable: true }) - request_app_user: string; - @Column({ nullable: true }) - request_json: string; - @Column({ nullable: true }) - create_userid: string; - @Column({ nullable: true }) - update_userid: string; - @CreateDateColumn({ nullable: true }) - create_timestamp: Date; - @UpdateDateColumn({ nullable: true }) - update_timestamp: Date; - - constructor( - document_template_id?: number, - nfr_data_id?: number, - dtid?: number, - request_app_user?: string, - request_json?: string, - create_userid?: string, - update_userid?: string - ) { - this.document_template_id = document_template_id || null; - this.nfr_data_id = nfr_data_id || null; - this.dtid = dtid || null; - this.request_app_user = request_app_user || ''; - this.request_json = request_json || ''; - this.create_userid = create_userid || ''; - this.update_userid = update_userid || ''; - } -} diff --git a/backend/src/nfr_data_log/nfr_data_log.controller.ts b/backend/src/nfr_data_log/nfr_data_log.controller.ts deleted file mode 100644 index 06d02b4b..00000000 --- a/backend/src/nfr_data_log/nfr_data_log.controller.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Body, Controller, Get, Param, Post } from '@nestjs/common'; -import { CreateNFRDataLogDto } from './dto/create-nfr_data_log.dto'; -import { NFRDataLog } from './entities/nfr_data_log.entity'; -import { NFRDataLogService } from './nfr_data_log.service'; - -@Controller('nfr-data-log') -export class NFRDataLogController { - constructor(private readonly nfrDataLogService: NFRDataLogService) {} - - @Post() - async create( - @Body() - nfrDataLog: CreateNFRDataLogDto - ): Promise { - return this.nfrDataLogService.create(nfrDataLog); - } - - @Get() - findAll(): Promise { - return this.nfrDataLogService.findAll(); - } - - @Get(':dtid') - findByDtid(@Param('dtid') dtid: string): Promise { - return this.nfrDataLogService.findByDtid(+dtid); - } - - @Get('version/:dtid') - findNextVersion(@Param('dtid') dtid: string): Promise { - return this.nfrDataLogService.findNextVersion(+dtid); - } -} diff --git a/backend/src/nfr_data_log/nfr_data_log.module.ts b/backend/src/nfr_data_log/nfr_data_log.module.ts deleted file mode 100644 index 9594d5de..00000000 --- a/backend/src/nfr_data_log/nfr_data_log.module.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Module } from '@nestjs/common'; -import { TypeOrmModule } from '@nestjs/typeorm'; -import { NFRDataLog } from './entities/nfr_data_log.entity'; -import { NFRDataLogController } from './nfr_data_log.controller'; -import { NFRDataLogService } from './nfr_data_log.service'; - -@Module({ - imports: [TypeOrmModule.forFeature([NFRDataLog])], - controllers: [NFRDataLogController], - providers: [NFRDataLogService], -}) -export class NFRDataLogModule {} diff --git a/backend/src/nfr_data_log/nfr_data_log.service.ts b/backend/src/nfr_data_log/nfr_data_log.service.ts deleted file mode 100644 index bee32fc7..00000000 --- a/backend/src/nfr_data_log/nfr_data_log.service.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { InjectRepository } from '@nestjs/typeorm'; -import { Repository } from 'typeorm'; -import { CreateNFRDataLogDto } from './dto/create-nfr_data_log.dto'; -import { NFRDataLog } from './entities/nfr_data_log.entity'; - -@Injectable() -export class NFRDataLogService { - constructor( - @InjectRepository(NFRDataLog) - private nfrDataLogRepository: Repository - ) {} - - async create(nfrDataLog: CreateNFRDataLogDto): Promise { - const newItem = new NFRDataLog(); - newItem.document_template_id = nfrDataLog.document_template_id; - newItem.nfr_data_id = nfrDataLog.nfr_data_id; - newItem.dtid = nfrDataLog.dtid; - newItem.request_app_user = nfrDataLog.request_app_user; - newItem.request_json = nfrDataLog.request_json; - newItem.create_userid = nfrDataLog.request_app_user; // same as request_app_user - const newPRL = this.nfrDataLogRepository.create(newItem); - return this.nfrDataLogRepository.save(newPRL); - } - - async findAll(): Promise { - return this.nfrDataLogRepository.find(); - } - - async findByDtid(dtid: number): Promise { - return this.nfrDataLogRepository.find({ - where: { - document_template_id: dtid, - }, - }); - } - - async findNextVersion(dtid: number): Promise { - const requestLogs = await this.nfrDataLogRepository.findAndCount({ - where: { - dtid: dtid, - }, - }); - let version = (requestLogs[1] + 1).toString(); - // prepend zeroes to the version before returning - while (version.length < 4) { - version = '0' + version; - } - return version; - } -} diff --git a/backend/src/nfr_provision/entities/nfr_provision_variant.entity.ts b/backend/src/nfr_provision/entities/nfr_provision_variant.entity.ts deleted file mode 100644 index 72fe58e5..00000000 --- a/backend/src/nfr_provision/entities/nfr_provision_variant.entity.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Entity, Column, PrimaryGeneratedColumn, ManyToMany } from 'typeorm'; -import { NFRProvision } from './nfr_provision.entity'; - -/** - * This entity allows us to associate certain provisions with certain - * variants and to alter those associations easily. This is used - * when loading the NFR report page with relevant provisions. - */ -@Entity() -export class NFRProvisionVariant { - @PrimaryGeneratedColumn() - id: number; - - @Column({ nullable: true }) - variant_name: string; - - @ManyToMany(() => NFRProvision, (provision) => provision.provision_variant, { - nullable: true, - }) - provisions: NFRProvision[]; -} diff --git a/backend/src/nfr_provision/nfr_provision.controller.ts b/backend/src/nfr_provision/nfr_provision.controller.ts deleted file mode 100644 index 8296d6f2..00000000 --- a/backend/src/nfr_provision/nfr_provision.controller.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { Body, Controller, Delete, Get, Param, Post } from '@nestjs/common'; -import { CreateNFRProvisionDto } from './dto/create-nfr_provision.dto'; -import { NFRProvisionService } from './nfr_provision.service'; - -@Controller('nfr-provision') -export class NFRProvisionController { - constructor(private readonly nfrProvisionService: NFRProvisionService) {} - - @Post() - async create( - @Body() - nfrProvision: CreateNFRProvisionDto - ) { - return this.nfrProvisionService.create(nfrProvision); - } - - @Post('update') - async update(@Body() nfrProvision: CreateNFRProvisionDto & { id: number }) { - const id = nfrProvision.id; - delete nfrProvision['id']; - return this.nfrProvisionService.update(id, nfrProvision); - } - - @Post('add-variable') - async addVariable( - @Body() - nfrVariable: { - variable_name: string; - variable_value: string; - help_text: string; - provision_id: number; - } - ) { - return this.nfrProvisionService.addVariable(nfrVariable); - } - - @Post('update-variable') - async updateVariable( - @Body() - nfrVariable: { - variable_name: string; - variable_value: string; - help_text: string; - provision_id: number; - id: number; - } - ) { - const id = nfrVariable.id; - delete nfrVariable['id']; - return this.nfrProvisionService.updateVariable(id, nfrVariable); - } - - @Get('remove-variable/:id') - async removeVariable(@Param('id') id: number) { - return this.nfrProvisionService.removeVariable(id); - } - - @Get() - findAll() { - return this.nfrProvisionService.findAll(); - } - - @Get('variables') - findAllVariables() { - return this.nfrProvisionService.findAllVariables(); - } - - @Get(':nfrProvisionId') - findById(@Param('nfrProvisionId') nfrProvisionId: number) { - if (nfrProvisionId && nfrProvisionId != 0) { - return this.nfrProvisionService.findById(nfrProvisionId); - } else { - return null; - } - } - - @Get('variant/:variant') - getProvisionsByVariant(@Param('variant') variantName: string) { - return this.nfrProvisionService.getProvisionsByVariant(variantName); - } - - @Get('enable/:id') - enableProvision(@Param('id') id: number) { - return this.nfrProvisionService.enable(id); - } - - @Get('disable/:id') - disableProvision(@Param('id') id: number) { - return this.nfrProvisionService.disable(id); - } - - // nestjs gets upset when there is no parameter, id is unused - @Get('get-group-max/:id') - getGroupMax(@Param('id') id: number) { - return this.nfrProvisionService.getGroupMax(); - } - - @Get('get-group-max/variant/:variant') - getGroupMaxByDTID(@Param('variant') variantName: string) { - return this.nfrProvisionService.getGroupMaxByVariant(variantName); - } - - @Get('get-provision-variables/variant/:variant') - getVariablesByVariant(@Param('variant') variantName: string) { - console.log('get-provision-variables'); - return this.nfrProvisionService.getVariablesByVariant(variantName); - } - - @Get('get-all-mandatory-provisions/:id') - getMandatoryProvisions() { - return this.nfrProvisionService.getMandatoryProvisions(); - } - - @Get('get-mandatory-provisions/variant/:variant') - getMandatoryProvisionsByVariant(@Param('variant') variantName: string) { - return this.nfrProvisionService.getMandatoryProvisionsByVariant(variantName); - } - - @Get('get-variants-with-ids/:id') - getVariantsWithIds() { - return this.nfrProvisionService.getVariantsWithIds(); - } - - @Delete(':id') - remove(@Param('id') id: number) { - return this.nfrProvisionService.remove(id); - } -} diff --git a/backend/src/nfr_provision/nfr_provision.module.ts b/backend/src/nfr_provision/nfr_provision.module.ts deleted file mode 100644 index 4d0b6da7..00000000 --- a/backend/src/nfr_provision/nfr_provision.module.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Module } from '@nestjs/common'; -import { TypeOrmModule } from '@nestjs/typeorm'; -import { NFRProvision } from './entities/nfr_provision.entity'; -import { NFRProvisionGroup } from './entities/nfr_provision_group.entity'; -import { NFRProvisionVariant } from './entities/nfr_provision_variant.entity'; -import { NFRProvisionController } from './nfr_provision.controller'; -import { NFRProvisionService } from './nfr_provision.service'; -import { NFRProvisionVariable } from './entities/nfr_provision_variable.entity'; - -@Module({ - imports: [ - TypeOrmModule.forFeature([NFRProvision]), - TypeOrmModule.forFeature([NFRProvisionGroup]), - TypeOrmModule.forFeature([NFRProvisionVariable]), - TypeOrmModule.forFeature([NFRProvisionVariant]), - ], - controllers: [NFRProvisionController], - providers: [NFRProvisionService], - exports: [NFRProvisionService], -}) -export class NFRProvisionModule {} diff --git a/backend/src/nfr_provision/nfr_provision.service.ts b/backend/src/nfr_provision/nfr_provision.service.ts deleted file mode 100644 index 0af752a5..00000000 --- a/backend/src/nfr_provision/nfr_provision.service.ts +++ /dev/null @@ -1,364 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { InjectRepository } from '@nestjs/typeorm'; -import { In, Repository } from 'typeorm'; -import { CreateNFRProvisionDto } from './dto/create-nfr_provision.dto'; -import { NFRProvision } from './entities/nfr_provision.entity'; -import { UpdateNFRProvisionDto } from './dto/update-nfr_provision.dto'; -import { NFRProvisionGroup } from './entities/nfr_provision_group.entity'; -import { NFRProvisionVariant } from './entities/nfr_provision_variant.entity'; -import { NFRProvisionVariable } from './entities/nfr_provision_variable.entity'; - -@Injectable() -export class NFRProvisionService { - constructor( - @InjectRepository(NFRProvision) - private nfrProvisionRepository: Repository, - @InjectRepository(NFRProvisionGroup) - private nfrProvisionGroupRepository: Repository, - @InjectRepository(NFRProvisionVariant) - private nfrProvisionVariantRepository: Repository, - @InjectRepository(NFRProvisionVariable) - private nfrProvisionVariableRepository: Repository - ) {} - - async create(nfrProvision: CreateNFRProvisionDto): Promise { - const variantIds = nfrProvision.variants; - const provision_group = Math.floor(nfrProvision.provision_group); - const provision_group_text = nfrProvision.provision_group_text; - delete nfrProvision['variants']; - delete nfrProvision['provision_group']; - delete nfrProvision['provision_group_text']; - nfrProvision.max = Math.floor(nfrProvision.max); - await this.updateGroupMaximums(provision_group, nfrProvision.max, provision_group_text); - if ((await this.nfrProvisionGroupRepository.countBy({ provision_group })) == 0) { - const newProvisionGroup = this.nfrProvisionGroupRepository.create({ - provision_group, - provision_group_text, - }); - await this.nfrProvisionGroupRepository.save(newProvisionGroup); - } - const nfrProvisionGroup = await this.nfrProvisionGroupRepository.findOneBy({ - provision_group, - }); - const nfrProvisionVariants = await this.nfrProvisionVariantRepository.find({ - where: { id: In(variantIds) }, - }); - const newProvision: NFRProvision = this.nfrProvisionRepository.create({ - ...nfrProvision, - provision_group: nfrProvisionGroup, - provision_variant: nfrProvisionVariants, - }); - return this.nfrProvisionRepository.save(newProvision); - } - - async update(id: number, nfrProvision: UpdateNFRProvisionDto): Promise { - const variantIds = nfrProvision.variants; - const provision_group = Math.floor(nfrProvision.provision_group); - const provision_group_text = nfrProvision.provision_group_text; - delete nfrProvision['variants']; - delete nfrProvision['provision_group']; - delete nfrProvision['provision_group_text']; - nfrProvision.max = Math.floor(nfrProvision.max); - await this.updateGroupMaximums(provision_group, nfrProvision.max, provision_group_text); - const nfrProvisionGroup = await this.nfrProvisionGroupRepository.findOneBy({ - provision_group, - }); - const nfrProvisionVariants = await this.nfrProvisionVariantRepository.find({ - where: { id: In(variantIds) }, - }); - const existingProvision: NFRProvision = await this.nfrProvisionRepository.findOneBy({ id }); - existingProvision.type = nfrProvision.type; - existingProvision.provision_name = nfrProvision.provision_name; - existingProvision.free_text = nfrProvision.free_text; - existingProvision.help_text = nfrProvision.help_text; - existingProvision.category = nfrProvision.category; - existingProvision.update_userid = nfrProvision.update_userid; - const updatedProvision = this.nfrProvisionRepository.create({ - ...existingProvision, - provision_group: nfrProvisionGroup, - provision_variant: nfrProvisionVariants, - }); - return this.nfrProvisionRepository.save(updatedProvision); - } - - async addVariable(nfrVariable: { - variable_name: string; - variable_value: string; - help_text: string; - provision_id: number; - }) { - const nfrProvision = await this.findById(nfrVariable.provision_id); - delete nfrVariable['provision_id']; - const newVariable = this.nfrProvisionVariableRepository.create({ - ...nfrVariable, - provision: nfrProvision, - }); - return this.nfrProvisionVariableRepository.save(newVariable); - } - - async updateVariable( - id: number, - nfrVariable: { - variable_name: string; - variable_value: string; - help_text: string; - provision_id: number; - } - ) { - const nfrProvision = await this.findById(nfrVariable.provision_id); - delete nfrVariable['provision_id']; - const variableToUpdate = await this.nfrProvisionVariableRepository.findOne({ - where: { id: id }, - }); - - if (!variableToUpdate) { - throw new Error('Variable not found'); - } - variableToUpdate.variable_name = nfrVariable.variable_name; - variableToUpdate.variable_value = nfrVariable.variable_value; - variableToUpdate.help_text = nfrVariable.help_text; - variableToUpdate.provision = nfrProvision; - - return this.nfrProvisionVariableRepository.save(variableToUpdate); - } - - async removeVariable(id: number): Promise { - return this.nfrProvisionVariableRepository.delete(id); - } - - async findAll(): Promise { - const nfrProvisions = await this.nfrProvisionRepository.find({ - relations: ['provision_group', 'provision_variant'], - }); - return nfrProvisions.map((nfrProvision) => { - const provisionVariantIds = nfrProvision.provision_variant.map((provisionVariant) => provisionVariant.id); - - delete nfrProvision.provision_group['id']; - delete nfrProvision['provision_variant']; - - return { - ...nfrProvision, - ...nfrProvision.provision_group, - variants: provisionVariantIds, - }; - }); - } - - async findAllVariables(): Promise { - const nfrVariables = await this.nfrProvisionVariableRepository.find({ - relations: ['provision'], - }); - return nfrVariables.map((variable) => { - return { - ...variable, - provision_id: variable.provision.id, - }; - }); - } - - async findById(provisionId: number): Promise { - try { - return this.nfrProvisionRepository.findOne({ - where: { id: provisionId }, - relations: ['provision_group'], - }); - } catch (err) { - console.log(err); - return null; - } - } - - async getAllProvisions(): Promise { - try { - const provisions: NFRProvision[] = await this.nfrProvisionRepository.find({ - relations: ['provision_group'], - }); - return provisions; - } catch (err) { - console.log(err); - return null; - } - } - - async getProvisionsByVariant(variantName: string): Promise { - try { - const variant = await this.nfrProvisionVariantRepository.findOne({ - where: { - variant_name: variantName, - }, - }); - if (!variant) { - return []; - } - const provisions: NFRProvision[] = await this.nfrProvisionRepository.find({ - where: { provision_variant: variant }, - relations: ['provision_group'], - }); - return provisions; - } catch (err) { - console.log(err); - return null; - } - } - - async enable(id: number): Promise { - await this.nfrProvisionRepository.update(id, { - active_flag: true, - }); - return { message: 'Provision Enabled' }; - } - - async disable(id: number): Promise { - await this.nfrProvisionRepository.update(id, { - active_flag: false, - }); - return { message: 'Provision Disabled' }; - } - - async getGroupMax(): Promise { - const nfrProvisions = await this.nfrProvisionRepository.find({ - relations: ['provision_group'], - }); - let nfrProvisionGroups: NFRProvisionGroup[] = []; - nfrProvisions.forEach((nfrProvision) => { - nfrProvisionGroups.push(nfrProvision.provision_group); - }); - nfrProvisionGroups = this.removeDuplicates(nfrProvisionGroups, 'provision_group'); - return Array.from(nfrProvisionGroups).sort((a, b) => a.provision_group - b.provision_group); - } - - async getGroupMaxByVariant(variantName: string): Promise { - try { - const variant = await this.nfrProvisionVariantRepository.findOne({ - where: { - variant_name: variantName.toUpperCase(), - }, - }); - if (!variant) { - return []; - } - const provisions = await this.nfrProvisionRepository.find({ - where: { provision_variant: variant }, - relations: ['provision_group'], - }); - let nfrProvisionGroups: NFRProvisionGroup[] = []; - provisions.forEach((nfrProvision) => { - nfrProvisionGroups.push(nfrProvision.provision_group); - }); - nfrProvisionGroups = this.removeDuplicates(nfrProvisionGroups, 'provision_group'); - return Array.from(nfrProvisionGroups).sort((a, b) => a.provision_group - b.provision_group); - } catch (err) { - console.log(err); - return null; - } - } - - async getVariablesByVariant(variantName: string): Promise { - const variant = await this.nfrProvisionVariantRepository.findOne({ - where: { - variant_name: variantName, - }, - }); - if (!variant) { - return []; - } - const provisions = await this.nfrProvisionRepository.find({ - where: { provision_variant: variant }, - relations: ['provision_variables'], - }); - - const provisionVariables: NFRProvisionVariable[] = []; - provisions.forEach((provision) => { - provision.provision_variables.forEach((variable) => { - variable['provisionId'] = provision.id; - provisionVariables.push(variable); - }); - }); - return provisionVariables; - } - - async getVariablesByDtid(dtid: number): Promise { - // gets ALL provisions - const provisions = await this.nfrProvisionRepository.find({ - relations: ['provision_variables'], - }); - - const provisionVariables: NFRProvisionVariable[] = []; - provisions.forEach((provision) => { - provision.provision_variables.forEach((variable) => { - variable['provisionId'] = provision.id; - provisionVariables.push(variable); - }); - }); - return provisionVariables; - } - - async getMandatoryProvisions(): Promise { - const provisions = await this.nfrProvisionRepository.find({ - where: { type: 'M' }, - }); - return provisions.map((provision) => provision.id); - } - - async getMandatoryProvisionsByVariant(variantName: string): Promise { - const variant = await this.nfrProvisionVariantRepository.findOne({ - where: { - variant_name: variantName, - }, - }); - if (!variant) { - return []; - } - const provisions = await this.nfrProvisionRepository.find({ - where: { provision_variant: variant, type: 'M' }, - }); - return provisions.map((provision) => provision.id); - } - - async getVariantsWithIds(): Promise<{ id: number; variant_name: string }[]> { - const variants = await this.nfrProvisionVariantRepository.find(); - const variantMap = variants.map((variant) => { - return { id: variant.id, variant_name: variant.variant_name }; - }); - return variantMap; - } - - async remove(id: number): Promise<{ deleted: boolean; message?: string }> { - try { - await this.nfrProvisionRepository.delete(id); - return { deleted: true }; - } catch (err) { - return { deleted: false, message: err.message }; - } - } - - async updateGroupMaximums(provision_group: number, max: number, provision_group_text: string) { - let nfrProvisionGroup: NFRProvisionGroup = await this.nfrProvisionGroupRepository.findOneBy({ - provision_group: provision_group, - }); - if (!nfrProvisionGroup) { - const newGroup = this.nfrProvisionGroupRepository.create({ - provision_group: provision_group, - max: max, - provision_group_text: provision_group_text, - }); - nfrProvisionGroup = await this.nfrProvisionGroupRepository.save(newGroup); - } - if (nfrProvisionGroup.max != max || nfrProvisionGroup.provision_group_text != provision_group_text) { - await this.nfrProvisionGroupRepository.update(nfrProvisionGroup.id, { - max: max, - provision_group_text: provision_group_text, - }); - } - } - - removeDuplicates(array: T[], property: keyof T): T[] { - return array.reduce((accumulator, currentObject) => { - const existingObject = accumulator.find((obj) => obj[property] === currentObject[property]); - if (!existingObject) { - accumulator.push(currentObject); - } - return accumulator; - }, []); - } -} diff --git a/backend/src/ormconfig.ts b/backend/src/ormconfig.ts index 21f72c22..39046219 100644 --- a/backend/src/ormconfig.ts +++ b/backend/src/ormconfig.ts @@ -1,16 +1,13 @@ import { TypeOrmModuleOptions } from '@nestjs/typeorm'; -import { PrintRequestDetail } from './print_request_detail/entities/print_request_detail.entity'; -import { PrintRequestLog } from './print_request_log/entities/print_request_log.entity'; +import { DocumentData } from './document_data/entities/document_data.entity'; +import { DocumentDataProvision } from './document_data/entities/document_data_provision.entity'; +import { DocumentDataVariable } from './document_data/entities/document_data_variable.entity'; +import { DocumentDataLog } from './document_data_log/entities/document_data_log.entity'; import { DocumentTemplate } from './document_template/entities/document_template.entity'; -import { PrintRequestDetailView } from './print_request_detail/entities/print_request_detail_vw'; -import { NFRData } from './nfr_data/entities/nfr_data.entity'; -import { NFRDataLog } from './nfr_data_log/entities/nfr_data_log.entity'; -import { NFRProvision } from './nfr_provision/entities/nfr_provision.entity'; -import { NFRProvisionGroup } from './nfr_provision/entities/nfr_provision_group.entity'; -import { NFRProvisionVariable } from './nfr_provision/entities/nfr_provision_variable.entity'; -import { NFRProvisionVariant } from './nfr_provision/entities/nfr_provision_variant.entity'; -import { NFRDataProvision } from './nfr_data/entities/nfr_data_provision.entity'; -import { NFRDataVariable } from './nfr_data/entities/nfr_data_variable.entity'; +import { DocumentType } from './document_type/entities/document_type.entity'; +import { Provision } from './provision/entities/provision.entity'; +import { ProvisionGroup } from './provision/entities/provision_group.entity'; +import { ProvisionVariable } from './provision/entities/provision_variable.entity'; const config: TypeOrmModuleOptions = { type: 'postgres', @@ -20,18 +17,15 @@ const config: TypeOrmModuleOptions = { username: process.env.POSTGRESQL_USER || 'postgres', password: process.env.POSTGRESQL_PASSWORD, entities: [ - PrintRequestDetail, - PrintRequestLog, - NFRData, - NFRDataProvision, - NFRDataVariable, - NFRDataLog, - NFRProvision, - NFRProvisionGroup, - NFRProvisionVariable, - NFRProvisionVariant, + DocumentData, + DocumentDataProvision, + DocumentDataVariable, + DocumentDataLog, + Provision, + ProvisionGroup, + ProvisionVariable, DocumentTemplate, - PrintRequestDetailView, + DocumentType, ], synchronize: true, }; diff --git a/backend/src/print_request_detail/dto/create-print_request_detail.dto.ts b/backend/src/print_request_detail/dto/create-print_request_detail.dto.ts deleted file mode 100644 index f17ded2d..00000000 --- a/backend/src/print_request_detail/dto/create-print_request_detail.dto.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { PickType } from '@nestjs/swagger'; -import { PrintRequestDetailDto } from './print_request_detail.dto'; - -export class CreatePrintRequestDetailDto extends PickType(PrintRequestDetailDto, [ - 'dtid', - 'tenure_file_number', - 'incorporation_number', - 'organization_unit', - 'purpose_name', - 'sub_purpose_name', - 'type_name', - 'sub_type_name', - 'first_name', - 'middle_name', - 'last_name', - 'legal_name', - 'licence_holder_name', - 'inspected_date', - 'email_address', - 'phone_number', - 'contact_agent', - 'contact_company_name', - 'contact_first_name', - 'contact_middle_name', - 'contact_last_name', - 'contact_phone_number', - 'contact_email_address', - 'mailing_address', - 'mailing_address_line_1', - 'mailing_address_line_2', - 'mailing_address_line_3', - 'mailing_city', - 'mailing_province_state_code', - 'mailing_postal_code', - 'mailing_zip', - 'mailing_country_code', - 'mailing_country', - 'location_description', - 'create_userid', - 'tenure', -] as const) {} diff --git a/backend/src/print_request_detail/dto/print_request_detail.dto.ts b/backend/src/print_request_detail/dto/print_request_detail.dto.ts deleted file mode 100644 index c16cb911..00000000 --- a/backend/src/print_request_detail/dto/print_request_detail.dto.ts +++ /dev/null @@ -1,39 +0,0 @@ -export class PrintRequestDetailDto { - dtid: number; - tenure_file_number: string; - incorporation_number: string; - organization_unit: string; - purpose_name: string; - sub_purpose_name: string; - type_name: string; - sub_type_name: string; - first_name: string; - middle_name: string; - last_name: string; - legal_name: string; - licence_holder_name: string; - email_address: string; - phone_number: string; - contact_agent: string; - contact_company_name: string; - contact_first_name: string; - contact_middle_name: string; - contact_last_name: string; - contact_phone_number: string; - contact_email_address: string; - inspected_date: string; - mailing_address: string; - mailing_address_line_1: string; - mailing_address_line_2: string; - mailing_address_line_3: string; - mailing_city: string; - mailing_province_state_code: string; - mailing_postal_code: string; - mailing_zip: string; - mailing_country_code: string; - mailing_country: string; - location_description: string; - create_userid: string; - update_userid: string; - tenure: string; -} diff --git a/backend/src/print_request_detail/dto/update-print_request_detail.dto.ts b/backend/src/print_request_detail/dto/update-print_request_detail.dto.ts deleted file mode 100644 index ce8b34b6..00000000 --- a/backend/src/print_request_detail/dto/update-print_request_detail.dto.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { PickType } from '@nestjs/swagger'; -import { PrintRequestDetailDto } from './print_request_detail.dto'; - -export class UpdatePrintRequestDetailDto extends PickType(PrintRequestDetailDto, [ - 'dtid', - 'tenure_file_number', - 'incorporation_number', - 'organization_unit', - 'purpose_name', - 'sub_purpose_name', - 'type_name', - 'sub_type_name', - 'first_name', - 'middle_name', - 'last_name', - 'legal_name', - 'licence_holder_name', - 'email_address', - 'phone_number', - 'contact_agent', - 'contact_company_name', - 'contact_first_name', - 'contact_middle_name', - 'contact_last_name', - 'contact_phone_number', - 'contact_email_address', - 'inspected_date', - 'mailing_address', - 'mailing_address_line_1', - 'mailing_address_line_2', - 'mailing_address_line_3', - 'mailing_city', - 'mailing_province_state_code', - 'mailing_postal_code', - 'mailing_zip', - 'mailing_country_code', - 'mailing_country', - 'location_description', - 'tenure', - 'update_userid', -] as const) {} diff --git a/backend/src/print_request_detail/entities/print_request_detail.entity.ts b/backend/src/print_request_detail/entities/print_request_detail.entity.ts deleted file mode 100644 index f9632d5e..00000000 --- a/backend/src/print_request_detail/entities/print_request_detail.entity.ts +++ /dev/null @@ -1,163 +0,0 @@ -import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'; - -@Entity() -export class PrintRequestDetail { - @PrimaryGeneratedColumn() - id: number; - @Column({ nullable: true }) - dtid: number; - @Column({ nullable: true }) - tenure_file_number: string; - @Column({ nullable: true }) - incorporation_number: string; - @Column({ nullable: true }) - organization_unit: string; - @Column({ nullable: true }) - purpose_name: string; - @Column({ nullable: true }) - sub_purpose_name: string; - @Column({ nullable: true }) - type_name: string; - @Column({ nullable: true }) - sub_type_name: string; - @Column({ nullable: true }) - licence_holder_name: string; - @Column({ nullable: true }) - contact_agent: string; - @Column({ nullable: true }) - contact_company_name?: string; - @Column({ nullable: true }) - contact_first_name?: string; - @Column({ nullable: true }) - contact_middle_name?: string; - @Column({ nullable: true }) - contact_last_name?: string; - @Column({ nullable: true }) - contact_phone_number?: string; - @Column({ nullable: true }) - contact_email_address?: string; - @Column({ nullable: true }) - first_name: string; - @Column({ nullable: true }) - middle_name: string; - @Column({ nullable: true }) - last_name: string; - @Column({ nullable: true }) - legal_name: string; - @Column({ nullable: true }) - email_address: string; - @Column({ nullable: true }) - phone_number: string; - @Column({ nullable: true }) - inspected_date: string; - @Column({ nullable: true }) - mailing_address: string; - @Column({ nullable: true }) - mailing_address_line_1: string; - @Column({ nullable: true }) - mailing_address_line_2: string; - @Column({ nullable: true }) - mailing_address_line_3: string; - @Column({ nullable: true }) - mailing_city: string; - @Column({ nullable: true }) - mailing_province_state_code: string; - @Column({ nullable: true }) - mailing_postal_code: string; - @Column({ nullable: true }) - mailing_zip: string; - @Column({ nullable: true }) - mailing_country_code: string; - @Column({ nullable: true }) - mailing_country: string; - @Column({ nullable: true }) - location_description: string; - @Column({ nullable: true }) - tenure: string; - @Column({ nullable: true }) - create_userid: string; - @Column({ nullable: true }) - update_userid: string; - @CreateDateColumn() - create_timestamp: Date; - @UpdateDateColumn() - update_timestamp: Date; - - constructor( - dtid?: number, - tenure_file_number?: string, - incorporation_number?: string, - organization_unit?: string, - purpose_name?: string, - sub_purpose_name?: string, - type_name?: string, - sub_type_name?: string, - licence_holder_name?: string, - contact_agent?: string, - contact_company_name?: string, - contact_first_name?: string, - contact_middle_name?: string, - contact_last_name?: string, - contact_phone_number?: string, - contact_email_address?: string, - first_name?: string, - middle_name?: string, - last_name?: string, - legal_name?: string, - email_address?: string, - phone_number?: string, - inspected_date?: string, - mailing_address?: string, - mailing_address_line_1?: string, - mailing_address_line_2?: string, - mailing_address_line_3?: string, - mailing_city?: string, - mailing_province_state_code?: string, - mailing_postal_code?: string, - mailing_zip?: string, - mailing_country_code?: string, - mailing_country?: string, - location_description?: string, - tenure?: string, - create_userid?: string, - update_userid?: string - ) { - this.dtid = dtid || null; - this.tenure_file_number = tenure_file_number || ''; - this.incorporation_number = incorporation_number || ''; - this.organization_unit = organization_unit || ''; - this.purpose_name = purpose_name || ''; - this.sub_purpose_name = sub_purpose_name || ''; - this.type_name = type_name || ''; - this.sub_type_name = sub_type_name || ''; - this.licence_holder_name = licence_holder_name || ''; - this.contact_agent = contact_agent || ''; - this.contact_company_name = contact_company_name || ''; - this.contact_first_name = contact_first_name || ''; - this.contact_middle_name = contact_middle_name || ''; - this.contact_last_name = contact_last_name || ''; - this.contact_phone_number = contact_phone_number || ''; - this.contact_email_address = contact_email_address || ''; - this.first_name = first_name || ''; - this.middle_name = middle_name || ''; - this.last_name = last_name || ''; - this.legal_name = legal_name || ''; - this.email_address = email_address || ''; - this.phone_number = phone_number || ''; - this.inspected_date = inspected_date || ''; - this.mailing_address = mailing_address || ''; - this.mailing_address_line_1 = mailing_address_line_1 || ''; - this.mailing_address_line_2 = mailing_address_line_2 || ''; - this.mailing_address_line_3 = mailing_address_line_3 || ''; - this.mailing_city = mailing_city || ''; - this.mailing_province_state_code = mailing_province_state_code || ''; - this.mailing_postal_code = mailing_postal_code || ''; - this.mailing_zip = mailing_zip || ''; - this.mailing_country_code = mailing_country_code || ''; - this.mailing_country = mailing_country || ''; - this.location_description = location_description || ''; - this.tenure = tenure || ''; - this.create_userid = create_userid || ''; - this.update_userid = update_userid || ''; - } -} diff --git a/backend/src/print_request_detail/entities/print_request_detail_vw.ts b/backend/src/print_request_detail/entities/print_request_detail_vw.ts deleted file mode 100644 index 92811f08..00000000 --- a/backend/src/print_request_detail/entities/print_request_detail_vw.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { DataSource, ViewColumn, ViewEntity } from 'typeorm'; -import { PrintRequestDetail } from './print_request_detail.entity'; - -@ViewEntity({ - expression: (dataSource: DataSource) => - dataSource - .createQueryBuilder() - .select('print_request_detail.id', 'PRDID') - .addSelect('print_request_detail.dtid', 'DTID') - .addSelect('print_request_detail.tenure_file_number', 'FileNum') - .addSelect('print_request_detail.organization_unit', 'OrganizationUnit') - .addSelect('print_request_detail.purpose_name', 'Purpose') - .addSelect('print_request_detail.sub_purpose_name', 'SubPurpose') - .addSelect('print_request_detail.type_name', 'TenureType') - .addSelect('print_request_detail.sub_type_name', 'TenureSubType') - .addSelect('print_request_detail.licence_holder_name', 'LicenceHolderName') - .addSelect('print_request_detail.mailing_address', 'MailingAddress') - .addSelect('print_request_detail.mailing_city', 'MailingCity') - .addSelect('print_request_detail.mailing_province_state_code', 'MailingProv') - .addSelect('print_request_detail.mailing_postal_code', 'PostCode') - .addSelect('print_request_detail.email_address', 'PrimaryContactEmail') - .addSelect('print_request_detail.phone_number', 'PrimaryContactPhone') - .addSelect('print_request_detail.location_description', 'Location') - .addSelect('print_request_detail.tenure', 'Tenure') - .addSelect('print_request_detail.contact_agent', 'ContactAgent') - .addSelect('print_request_detail.contact_email_address', 'ContactAgentEmail') - .addSelect('print_request_detail.contact_phone_number', 'ContactAgentPhone') - .addSelect('print_request_detail.inspected_date', 'InspectionDate') - .addSelect('print_request_detail.incorporation_number', 'IncorporationNumber') - .from(PrintRequestDetail, 'print_request_detail'), -}) -export class PrintRequestDetailView { - @ViewColumn() - DTID: number; - @ViewColumn() - PRDID: number; - @ViewColumn() - FileNum: string; - @ViewColumn() - OrganizationUnit: string; - @ViewColumn() - Purpose: string; - @ViewColumn() - SubPurpose: string; - @ViewColumn() - TenureType: string; - @ViewColumn() - TenureSubType: string; - @ViewColumn() - LicenceHolderName: string; - @ViewColumn() - MailingAddress: string; - @ViewColumn() - MailingCity: string; - @ViewColumn() - MailingProv: string; - @ViewColumn() - PostCode: string; - @ViewColumn() - ContactAgent: string; - @ViewColumn() - ContactAgentEmail: string; - @ViewColumn() - ContactAgentPhone: string; - @ViewColumn() - Tenure: string; - @ViewColumn() - Location: string; - @ViewColumn() - PrimaryContactEmail: string; - @ViewColumn() - PrimaryContactPhone: string; - @ViewColumn() - InspectionDate: string; - @ViewColumn() - IncorporationNumber: string; -} diff --git a/backend/src/print_request_detail/print_request_detail.controller.ts b/backend/src/print_request_detail/print_request_detail.controller.ts deleted file mode 100644 index e2ee6a7d..00000000 --- a/backend/src/print_request_detail/print_request_detail.controller.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { Body, Controller, Delete, Get, Param, Post } from '@nestjs/common'; -import { CreatePrintRequestDetailDto } from './dto/create-print_request_detail.dto'; -import { PrintRequestDetailService } from './print_request_detail.service'; - -@Controller('print-request-detail') -export class PrintRequestDetailController { - constructor(private readonly printRequestDetailService: PrintRequestDetailService) {} - - @Post() - async create( - @Body() - data: { - printRequestDetail: CreatePrintRequestDetailDto; - } - ) { - let printRequestDetail = data.printRequestDetail; - return this.printRequestDetailService.create(printRequestDetail); - } - - @Get() - findAll() { - return this.printRequestDetailService.findAll(); - } - - @Get(':dtid') - findByDtid(@Param('dtid') dtid: string) { - return this.printRequestDetailService.findByDtid(+dtid); - } - - @Get('view/:prdid') - findViewByPRDID(@Param('prdid') prdid: string) { - return this.printRequestDetailService.findViewByPRDID(+prdid); - } - - @Delete(':dtid') - remove(@Param('dtid') dtid: string) { - return this.printRequestDetailService.remove(+dtid); - } -} diff --git a/backend/src/print_request_detail/print_request_detail.module.ts b/backend/src/print_request_detail/print_request_detail.module.ts deleted file mode 100644 index 330d5565..00000000 --- a/backend/src/print_request_detail/print_request_detail.module.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Module } from '@nestjs/common'; -import { TypeOrmModule } from '@nestjs/typeorm'; -import { PrintRequestDetail } from './entities/print_request_detail.entity'; -import { PrintRequestDetailController } from './print_request_detail.controller'; -import { PrintRequestDetailService } from './print_request_detail.service'; - -@Module({ - imports: [TypeOrmModule.forFeature([PrintRequestDetail])], - controllers: [PrintRequestDetailController], - providers: [PrintRequestDetailService], -}) -export class PrintRequestDetailModule {} diff --git a/backend/src/print_request_detail/print_request_detail.service.ts b/backend/src/print_request_detail/print_request_detail.service.ts deleted file mode 100644 index 079e8cef..00000000 --- a/backend/src/print_request_detail/print_request_detail.service.ts +++ /dev/null @@ -1,127 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { InjectRepository } from '@nestjs/typeorm'; -import { DataSource, Repository } from 'typeorm'; -import { CreatePrintRequestDetailDto } from './dto/create-print_request_detail.dto'; -import { PrintRequestDetail } from './entities/print_request_detail.entity'; -import { PrintRequestDetailView } from './entities/print_request_detail_vw'; - -@Injectable() -export class PrintRequestDetailService { - constructor( - @InjectRepository(PrintRequestDetail) - private printRequestDetailRepository: Repository, - private dataSource: DataSource - ) {} - - async create(printRequestDetail: CreatePrintRequestDetailDto): Promise { - const newItem = new PrintRequestDetail(); - newItem.dtid = printRequestDetail.dtid; - newItem.tenure_file_number = printRequestDetail.tenure_file_number; - newItem.incorporation_number = printRequestDetail.incorporation_number; - newItem.organization_unit = printRequestDetail.organization_unit; - newItem.purpose_name = printRequestDetail.purpose_name; - newItem.sub_purpose_name = printRequestDetail.sub_purpose_name; - newItem.type_name = printRequestDetail.type_name; - newItem.sub_type_name = printRequestDetail.sub_type_name; - newItem.first_name = printRequestDetail.first_name; - newItem.middle_name = printRequestDetail.middle_name; - newItem.last_name = printRequestDetail.last_name; - newItem.legal_name = printRequestDetail.legal_name; - newItem.licence_holder_name = printRequestDetail.licence_holder_name; - newItem.contact_agent = printRequestDetail.contact_agent; - newItem.contact_company_name = printRequestDetail.contact_company_name; - newItem.contact_first_name = printRequestDetail.contact_first_name; - newItem.contact_middle_name = printRequestDetail.contact_middle_name; - newItem.contact_last_name = printRequestDetail.contact_last_name; - newItem.contact_phone_number = printRequestDetail.contact_phone_number; - newItem.contact_email_address = printRequestDetail.contact_email_address; - newItem.email_address = printRequestDetail.email_address; - newItem.phone_number = printRequestDetail.phone_number; - newItem.inspected_date = printRequestDetail.inspected_date; - newItem.mailing_address = printRequestDetail.mailing_address; - newItem.mailing_address_line_1 = printRequestDetail.mailing_address_line_1; - newItem.mailing_address_line_2 = printRequestDetail.mailing_address_line_2; - newItem.mailing_address_line_3 = printRequestDetail.mailing_address_line_3; - newItem.mailing_city = printRequestDetail.mailing_city; - newItem.mailing_province_state_code = printRequestDetail.mailing_province_state_code; - newItem.mailing_postal_code = printRequestDetail.mailing_postal_code; - newItem.mailing_zip = printRequestDetail.mailing_zip; - newItem.mailing_country_code = printRequestDetail.mailing_country_code; - newItem.mailing_country = printRequestDetail.mailing_country; - newItem.location_description = printRequestDetail.location_description; - newItem.tenure = printRequestDetail.tenure; - newItem.create_userid = printRequestDetail.create_userid; - - const newPRD = this.printRequestDetailRepository.create(newItem); - return this.convertTenureToJson(await this.printRequestDetailRepository.save(newPRD)); - } - - async findAll(): Promise { - return this.convertTenureToJson(await this.printRequestDetailRepository.find()); - } - - async findByDtid(dtid: number): Promise { - try { - const prd = await this.printRequestDetailRepository.find({ - where: { - dtid: dtid, - }, - }); - return this.convertTenureToJson(prd); - } catch (err) { - console.log(err); - } - } - - async findViewByPRDID(prdid: number): Promise { - let view = await this.dataSource.manager.findOneBy(PrintRequestDetailView, { - PRDID: prdid, - }); - return this.convertTenureToJson(view); - } - - async remove(dtid: number): Promise<{ deleted: boolean; message?: string }> { - try { - await this.printRequestDetailRepository.delete({ dtid: dtid }); - return { deleted: true }; - } catch (err) { - return { deleted: false, message: err.message }; - } - } - - // converts the tenure/Tenure from a json string to a json object before returning - convertTenureToJson(prd: any) { - let p; - if (Array.isArray(prd)) { - if (prd[0].tenure) { - prd = prd.map(function (entry) { - if (entry.tenure) { - p = JSON.parse(entry.tenure); - entry['tenure'] = p; - return entry; - } - }); - return prd; - } else if (prd[0].Tenure) { - prd = prd.map(function (entry) { - if (entry.Tenure) { - p = JSON.parse(entry.Tenure); - entry['Tenure'] = p; - return entry; - } - }); - return prd; - } - } else { - if (prd.tenure) { - p = JSON.parse(prd.tenure); - prd['tenure'] = p; - return prd; - } else if (prd.Tenure) { - p = JSON.parse(prd.Tenure); - prd['Tenure'] = p; - return prd; - } - } - } -} diff --git a/backend/src/print_request_log/dto/create-print_request_log.dto.ts b/backend/src/print_request_log/dto/create-print_request_log.dto.ts deleted file mode 100644 index aafd8209..00000000 --- a/backend/src/print_request_log/dto/create-print_request_log.dto.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { PickType } from '@nestjs/swagger'; -import { PrintRequestLogDto } from './print_request_log.dto'; - -export class CreatePrintRequestLogDto extends PickType(PrintRequestLogDto, [ - 'document_template_id', - 'print_request_detail_id', - 'dtid', - 'document_type', - 'request_app_user', - 'request_json', - 'create_userid', -] as const) {} diff --git a/backend/src/print_request_log/dto/print_request_log.dto.ts b/backend/src/print_request_log/dto/print_request_log.dto.ts deleted file mode 100644 index a9f34bdc..00000000 --- a/backend/src/print_request_log/dto/print_request_log.dto.ts +++ /dev/null @@ -1,10 +0,0 @@ -export class PrintRequestLogDto { - document_template_id: number; - print_request_detail_id: number; - dtid: number; - document_type: string; - request_app_user: string; - request_json: string; - create_userid: string; - update_userid: string; -} diff --git a/backend/src/print_request_log/dto/update-print_request_log.dto.ts b/backend/src/print_request_log/dto/update-print_request_log.dto.ts deleted file mode 100644 index 7ef40925..00000000 --- a/backend/src/print_request_log/dto/update-print_request_log.dto.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { PickType } from '@nestjs/swagger'; -import { PrintRequestLogDto } from './print_request_log.dto'; - -export class UpdatePrintRequestLogDto extends PickType(PrintRequestLogDto, [ - 'document_template_id', - 'print_request_detail_id', - 'dtid', - 'document_type', - 'request_app_user', - 'request_json', - 'update_userid', -] as const) {} diff --git a/backend/src/print_request_log/print_request_log.controller.ts b/backend/src/print_request_log/print_request_log.controller.ts deleted file mode 100644 index be8e7728..00000000 --- a/backend/src/print_request_log/print_request_log.controller.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Body, Controller, Get, Param, Post } from '@nestjs/common'; -import { CreatePrintRequestLogDto } from './dto/create-print_request_log.dto'; -import { PrintRequestLog } from './entities/print_request_log.entity'; -import { PrintRequestLogService } from './print_request_log.service'; -// -@Controller('print-request-log') -export class PrintRequestLogController { - constructor(private readonly printRequestLogService: PrintRequestLogService) {} - - @Post() - async create( - @Body() - printRequestLog: CreatePrintRequestLogDto - ): Promise { - console.log('Creating log entry for requested document!!!'); - return this.printRequestLogService.create(printRequestLog); - } - - @Get() - findAll(): Promise { - return this.printRequestLogService.findAll(); - } - - @Get(':dtid') - findByDtid(@Param('dtid') dtid: string): Promise { - return this.printRequestLogService.findByDtid(+dtid); - } - - @Get('version/:dtid/:documentType') - findNextVersion(@Param('dtid') dtid: string, @Param('documentType') documentType: string): Promise { - return this.printRequestLogService.findNextVersion(+dtid, documentType); - } -} diff --git a/backend/src/print_request_log/print_request_log.module.ts b/backend/src/print_request_log/print_request_log.module.ts deleted file mode 100644 index 2a2000a9..00000000 --- a/backend/src/print_request_log/print_request_log.module.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Module } from '@nestjs/common'; -import { TypeOrmModule } from '@nestjs/typeorm'; -import { PrintRequestLog } from './entities/print_request_log.entity'; -import { PrintRequestLogController } from './print_request_log.controller'; -import { PrintRequestLogService } from './print_request_log.service'; - -@Module({ - imports: [TypeOrmModule.forFeature([PrintRequestLog])], - controllers: [PrintRequestLogController], - providers: [PrintRequestLogService], - exports: [PrintRequestLogService], -}) -export class PrintRequestLogModule {} diff --git a/backend/src/print_request_log/print_request_log.service.ts b/backend/src/print_request_log/print_request_log.service.ts deleted file mode 100644 index 4fad5350..00000000 --- a/backend/src/print_request_log/print_request_log.service.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { InjectRepository } from '@nestjs/typeorm'; -import { Repository } from 'typeorm'; -import { CreatePrintRequestLogDto } from './dto/create-print_request_log.dto'; -import { PrintRequestLog } from './entities/print_request_log.entity'; - -@Injectable() -export class PrintRequestLogService { - constructor( - @InjectRepository(PrintRequestLog) - private printRequestLogRepository: Repository - ) {} - - async create(printRequestLog: CreatePrintRequestLogDto): Promise { - const newItem = new PrintRequestLog(); - newItem.document_template_id = printRequestLog.document_template_id; - newItem.print_request_detail_id = printRequestLog.print_request_detail_id; - newItem.dtid = printRequestLog.dtid; - newItem.document_type = printRequestLog.document_type; - newItem.request_app_user = printRequestLog.request_app_user; - newItem.request_json = printRequestLog.request_json; - newItem.create_userid = printRequestLog.request_app_user; // same as request_app_user - const newPRL = this.printRequestLogRepository.create(newItem); - return this.printRequestLogRepository.save(newPRL); - } - - async findAll(): Promise { - return this.printRequestLogRepository.find(); - } - - async findByDtid(dtid: number): Promise { - return this.printRequestLogRepository.find({ - where: { - document_template_id: dtid, - }, - }); - } - - async findNextVersion(dtid: number, documentType: string): Promise { - let fullDocumentType = ''; - switch (documentType) { - case 'LUR': - fullDocumentType = 'LAND USE REPORT'; - break; - case 'GL': - fullDocumentType = 'GRAZING LEASE'; - break; - default: - fullDocumentType = 'LAND USE REPORT'; - break; - } - const requestLogs = await this.printRequestLogRepository.findAndCount({ - where: { - dtid: dtid, - document_type: fullDocumentType, - }, - }); - let version = (requestLogs[1] + 1).toString(); - // prepend zeroes to the version before returning - while (version.length < 4) { - version = '0' + version; - } - return version; - } -} diff --git a/backend/src/nfr_provision/dto/create-nfr_provision.dto.ts b/backend/src/provision/dto/create-provision.dto.ts similarity index 61% rename from backend/src/nfr_provision/dto/create-nfr_provision.dto.ts rename to backend/src/provision/dto/create-provision.dto.ts index 1b28772f..46777977 100644 --- a/backend/src/nfr_provision/dto/create-nfr_provision.dto.ts +++ b/backend/src/provision/dto/create-provision.dto.ts @@ -1,7 +1,7 @@ import { PickType } from '@nestjs/swagger'; -import { NFRProvisionDto } from './nfr_provision.dto'; +import { ProvisionDto } from './provision.dto'; -export class CreateNFRProvisionDto extends PickType(NFRProvisionDto, [ +export class CreateProvisionDto extends PickType(ProvisionDto, [ 'dtid', 'type', 'provision_group', @@ -11,6 +11,5 @@ export class CreateNFRProvisionDto extends PickType(NFRProvisionDto, [ 'free_text', 'help_text', 'category', - 'variants', 'create_userid', ] as const) {} diff --git a/backend/src/nfr_provision/dto/nfr_provision.dto.ts b/backend/src/provision/dto/provision.dto.ts similarity index 82% rename from backend/src/nfr_provision/dto/nfr_provision.dto.ts rename to backend/src/provision/dto/provision.dto.ts index dec487f7..0a92ca35 100644 --- a/backend/src/nfr_provision/dto/nfr_provision.dto.ts +++ b/backend/src/provision/dto/provision.dto.ts @@ -1,4 +1,4 @@ -export class NFRProvisionDto { +export class ProvisionDto { dtid?: number; type?: string; provision_group?: number; @@ -8,7 +8,6 @@ export class NFRProvisionDto { free_text?: string; help_text?: string; category?: string; - variants?: number[]; create_userid?: string; update_userid?: string; } diff --git a/backend/src/nfr_provision/dto/update-nfr_provision.dto.ts b/backend/src/provision/dto/update-provision.dto.ts similarity index 61% rename from backend/src/nfr_provision/dto/update-nfr_provision.dto.ts rename to backend/src/provision/dto/update-provision.dto.ts index d986c128..b10b8c99 100644 --- a/backend/src/nfr_provision/dto/update-nfr_provision.dto.ts +++ b/backend/src/provision/dto/update-provision.dto.ts @@ -1,7 +1,7 @@ import { PickType } from '@nestjs/swagger'; -import { NFRProvisionDto } from './nfr_provision.dto'; +import { ProvisionDto } from './provision.dto'; -export class UpdateNFRProvisionDto extends PickType(NFRProvisionDto, [ +export class UpdateProvisionDto extends PickType(ProvisionDto, [ 'dtid', 'type', 'provision_group', @@ -11,6 +11,5 @@ export class UpdateNFRProvisionDto extends PickType(NFRProvisionDto, [ 'free_text', 'help_text', 'category', - 'variants', 'update_userid', ] as const) {} diff --git a/backend/src/nfr_provision/entities/nfr_provision.entity.ts b/backend/src/provision/entities/provision.entity.ts similarity index 54% rename from backend/src/nfr_provision/entities/nfr_provision.entity.ts rename to backend/src/provision/entities/provision.entity.ts index 5a7d680e..847ed980 100644 --- a/backend/src/nfr_provision/entities/nfr_provision.entity.ts +++ b/backend/src/provision/entities/provision.entity.ts @@ -9,13 +9,13 @@ import { PrimaryGeneratedColumn, UpdateDateColumn, } from 'typeorm'; -import { NFRProvisionGroup } from './nfr_provision_group.entity'; -import { NFRProvisionVariant } from './nfr_provision_variant.entity'; -import { NFRProvisionVariable } from './nfr_provision_variable.entity'; -import { NFRDataProvision } from 'src/nfr_data/entities/nfr_data_provision.entity'; +import { ProvisionGroup } from './provision_group.entity'; +import { ProvisionVariable } from './provision_variable.entity'; +import { DocumentDataProvision } from 'src/document_data/entities/document_data_provision.entity'; +import { DocumentType } from 'src/document_type/entities/document_type.entity'; @Entity() -export class NFRProvision { +export class Provision { @PrimaryGeneratedColumn() id: number; @Column({ nullable: true }) @@ -38,24 +38,31 @@ export class NFRProvision { create_timestamp: Date; @UpdateDateColumn() update_timestamp: Date; - @ManyToOne(() => NFRProvisionGroup, (provisionGroup) => provisionGroup.provisions) - provision_group: NFRProvisionGroup; - @OneToMany(() => NFRProvisionVariable, (provisionVariable) => provisionVariable.provision, { + @ManyToOne(() => ProvisionGroup, (provisionGroup) => provisionGroup.provisions) + provision_group: ProvisionGroup; + @OneToMany(() => ProvisionVariable, (provisionVariable) => provisionVariable.provision, { nullable: true, cascade: true, }) - provision_variables: NFRProvisionVariable[]; - @ManyToMany(() => NFRProvisionVariant, { - nullable: true, - eager: true, - }) - @JoinTable() - provision_variant: NFRProvisionVariant[]; - @OneToMany(() => NFRDataProvision, (nfrDataProvision) => nfrDataProvision.nfr_provision, { + provision_variables: ProvisionVariable[]; + @OneToMany(() => DocumentDataProvision, (documentDataProvision) => documentDataProvision.document_provision, { nullable: true, cascade: true, }) - nfr_data_provisions: NFRDataProvision[]; + document_data_provisions: DocumentDataProvision[]; + @ManyToMany(() => DocumentType) + @JoinTable({ + name: 'provision_document_type', // Name of the join table + joinColumn: { + name: 'provision_id', + referencedColumnName: 'id', + }, + inverseJoinColumn: { + name: 'document_type_id', + referencedColumnName: 'id', + }, + }) + document_types: DocumentType[]; constructor( type?: string, @@ -65,8 +72,7 @@ export class NFRProvision { active_flag?: boolean, create_userid?: string, update_userid?: string, - provision_group?: NFRProvisionGroup, - provision_variant?: NFRProvisionVariant[] + provision_group?: ProvisionGroup ) { this.type = type || ''; this.provision_name = provision_name || ''; @@ -76,6 +82,5 @@ export class NFRProvision { this.create_userid = create_userid || ''; this.update_userid = update_userid || ''; this.provision_group = provision_group || null; - this.provision_variant = provision_variant; } } diff --git a/backend/src/nfr_provision/entities/nfr_provision_group.entity.ts b/backend/src/provision/entities/provision_group.entity.ts similarity index 71% rename from backend/src/nfr_provision/entities/nfr_provision_group.entity.ts rename to backend/src/provision/entities/provision_group.entity.ts index 4adba13d..08acff89 100644 --- a/backend/src/nfr_provision/entities/nfr_provision_group.entity.ts +++ b/backend/src/provision/entities/provision_group.entity.ts @@ -1,5 +1,5 @@ import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm'; -import { NFRProvision } from './nfr_provision.entity'; +import { Provision } from './provision.entity'; /** * This entity holds group descriptions and provision maximums @@ -7,7 +7,7 @@ import { NFRProvision } from './nfr_provision.entity'; * an NFRProvisionGroup. */ @Entity() -export class NFRProvisionGroup { +export class ProvisionGroup { @PrimaryGeneratedColumn() id: number; @@ -20,8 +20,8 @@ export class NFRProvisionGroup { @Column({ nullable: true }) max: number; - @OneToMany(() => NFRProvision, (provision) => provision.provision_group, { + @OneToMany(() => Provision, (provision) => provision.provision_group, { nullable: true, }) - provisions: NFRProvision[]; + provisions: Provision[]; } diff --git a/backend/src/nfr_provision/entities/nfr_provision_variable.entity.ts b/backend/src/provision/entities/provision_variable.entity.ts similarity index 64% rename from backend/src/nfr_provision/entities/nfr_provision_variable.entity.ts rename to backend/src/provision/entities/provision_variable.entity.ts index 850884c8..a277dafd 100644 --- a/backend/src/nfr_provision/entities/nfr_provision_variable.entity.ts +++ b/backend/src/provision/entities/provision_variable.entity.ts @@ -1,4 +1,4 @@ -import { NFRDataVariable } from 'src/nfr_data/entities/nfr_data_variable.entity'; +import { DocumentDataVariable } from 'src/document_data/entities/document_data_variable.entity'; import { Entity, Column, @@ -8,7 +8,7 @@ import { CreateDateColumn, UpdateDateColumn, } from 'typeorm'; -import { NFRProvision } from './nfr_provision.entity'; +import { Provision } from './provision.entity'; /** * This entity holds variables associated with a provision. @@ -16,7 +16,7 @@ import { NFRProvision } from './nfr_provision.entity'; * inserted into the provision text. */ @Entity() -export class NFRProvisionVariable { +export class ProvisionVariable { @PrimaryGeneratedColumn() id: number; @Column({ nullable: true }) @@ -33,13 +33,13 @@ export class NFRProvisionVariable { create_timestamp: Date; @UpdateDateColumn() update_timestamp: Date; - @ManyToOne(() => NFRProvision, (provision) => provision.provision_variables, { + @ManyToOne(() => Provision, (provision) => provision.provision_variables, { nullable: true, }) - provision: NFRProvision; - @OneToMany(() => NFRDataVariable, (nfrDataVariable) => nfrDataVariable.nfr_variable, { + provision: Provision; + @OneToMany(() => DocumentDataVariable, (documentDataVariable) => documentDataVariable.document_variable, { nullable: true, cascade: true, }) - nfr_data_variables: NFRDataVariable[]; + document_data_variables: DocumentDataVariable[]; } diff --git a/backend/src/provision/provision.controller.ts b/backend/src/provision/provision.controller.ts new file mode 100644 index 00000000..1cb1509f --- /dev/null +++ b/backend/src/provision/provision.controller.ts @@ -0,0 +1,102 @@ +import { Body, Controller, Delete, Get, Param, Post } from '@nestjs/common'; +import { CreateProvisionDto } from './dto/create-provision.dto'; +import { ProvisionService } from './provision.service'; + +@Controller('provision') +export class ProvisionController { + constructor(private readonly provisionService: ProvisionService) {} + + @Post() + async create( + @Body() + provision: CreateProvisionDto + ) { + return this.provisionService.create(provision); + } + + @Post('update') + async update(@Body() provision: CreateProvisionDto & { id: number }) { + const id = provision.id; + delete provision['id']; + return this.provisionService.update(id, provision); + } + + @Post('add-variable') + async addVariable( + @Body() + variable: { + variable_name: string; + variable_value: string; + help_text: string; + provision_id: number; + } + ) { + return this.provisionService.addVariable(variable); + } + + @Post('update-variable') + async updateVariable( + @Body() + variable: { + variable_name: string; + variable_value: string; + help_text: string; + provision_id: number; + id: number; + } + ) { + const id = variable.id; + delete variable['id']; + return this.provisionService.updateVariable(id, variable); + } + + @Get('remove-variable/:id') + async removeVariable(@Param('id') id: number) { + return this.provisionService.removeVariable(id); + } + + @Get() + findAll() { + return this.provisionService.findAll(); + } + + @Get('variables') + findAllVariables() { + return this.provisionService.findAllVariables(); + } + + @Get(':provisionId') + findById(@Param('provisionId') provisionId: number) { + if (provisionId && provisionId != 0) { + return this.provisionService.findById(provisionId); + } else { + return null; + } + } + + @Get('enable/:id') + enableProvision(@Param('id') id: number) { + return this.provisionService.enable(id); + } + + @Get('disable/:id') + disableProvision(@Param('id') id: number) { + return this.provisionService.disable(id); + } + + // nestjs gets upset when there is no parameter, id is unused + @Get('get-group-max/:id') + getGroupMax(@Param('id') id: number) { + return this.provisionService.getGroupMax(); + } + + @Get('get-all-mandatory-provisions/:id') + getMandatoryProvisions() { + return this.provisionService.getMandatoryProvisions(); + } + + @Delete(':id') + remove(@Param('id') id: number) { + return this.provisionService.remove(id); + } +} diff --git a/backend/src/provision/provision.module.ts b/backend/src/provision/provision.module.ts new file mode 100644 index 00000000..3f12a732 --- /dev/null +++ b/backend/src/provision/provision.module.ts @@ -0,0 +1,21 @@ +import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { Provision } from './entities/provision.entity'; +import { ProvisionGroup } from './entities/provision_group.entity'; +import { ProvisionController } from './provision.controller'; +import { ProvisionService } from './provision.service'; +import { ProvisionVariable } from './entities/provision_variable.entity'; +import { DocumentType } from 'src/document_type/entities/document_type.entity'; + +@Module({ + imports: [ + TypeOrmModule.forFeature([Provision]), + TypeOrmModule.forFeature([ProvisionGroup]), + TypeOrmModule.forFeature([ProvisionVariable]), + TypeOrmModule.forFeature([DocumentType]), + ], + controllers: [ProvisionController], + providers: [ProvisionService], + exports: [ProvisionService], +}) +export class ProvisionModule {} diff --git a/backend/src/provision/provision.service.ts b/backend/src/provision/provision.service.ts new file mode 100644 index 00000000..119c21d3 --- /dev/null +++ b/backend/src/provision/provision.service.ts @@ -0,0 +1,308 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { CreateProvisionDto } from './dto/create-provision.dto'; +import { Provision } from './entities/provision.entity'; +import { UpdateProvisionDto } from './dto/update-provision.dto'; +import { ProvisionGroup } from './entities/provision_group.entity'; +import { ProvisionVariable } from './entities/provision_variable.entity'; +import { DocumentType } from 'src/document_type/entities/document_type.entity'; + +@Injectable() +export class ProvisionService { + constructor( + @InjectRepository(Provision) + private provisionRepository: Repository, + @InjectRepository(ProvisionGroup) + private provisionGroupRepository: Repository, + @InjectRepository(ProvisionVariable) + private provisionVariableRepository: Repository, + @InjectRepository(DocumentType) + private documentTypeRepository: Repository + ) {} + + async create(provision: CreateProvisionDto): Promise { + const provision_group = Math.floor(provision.provision_group); + const provision_group_text = provision.provision_group_text; + delete provision['provision_group']; + delete provision['provision_group_text']; + provision.max = Math.floor(provision.max); + await this.updateGroupMaximums(provision_group, provision.max, provision_group_text); + if ((await this.provisionGroupRepository.countBy({ provision_group })) == 0) { + const newProvisionGroup = this.provisionGroupRepository.create({ + provision_group, + provision_group_text, + }); + await this.provisionGroupRepository.save(newProvisionGroup); + } + const provisionGroup = await this.provisionGroupRepository.findOneBy({ + provision_group, + }); + const newProvision: Provision = this.provisionRepository.create({ + ...provision, + provision_group: provisionGroup, + }); + return this.provisionRepository.save(newProvision); + } + + async update(id: number, provision: UpdateProvisionDto): Promise { + const provision_group = Math.floor(provision.provision_group); + const provision_group_text = provision.provision_group_text; + delete provision['provision_group']; + delete provision['provision_group_text']; + provision.max = Math.floor(provision.max); + await this.updateGroupMaximums(provision_group, provision.max, provision_group_text); + const provisionGroup = await this.provisionGroupRepository.findOneBy({ + provision_group, + }); + const existingProvision: Provision = await this.provisionRepository.findOneBy({ id }); + existingProvision.type = provision.type; + existingProvision.provision_name = provision.provision_name; + existingProvision.free_text = provision.free_text; + existingProvision.help_text = provision.help_text; + existingProvision.category = provision.category; + existingProvision.update_userid = provision.update_userid; + const updatedProvision = this.provisionRepository.create({ + ...existingProvision, + provision_group: provisionGroup, + }); + return this.provisionRepository.save(updatedProvision); + } + + async addVariable(variable: { + variable_name: string; + variable_value: string; + help_text: string; + provision_id: number; + }) { + const provision = await this.findById(variable.provision_id); + delete variable['provision_id']; + const newVariable = this.provisionVariableRepository.create({ + ...variable, + provision: provision, + }); + return this.provisionVariableRepository.save(newVariable); + } + + async updateVariable( + id: number, + variable: { + variable_name: string; + variable_value: string; + help_text: string; + provision_id: number; + } + ) { + const provision = await this.findById(variable.provision_id); + delete variable['provision_id']; + const variableToUpdate = await this.provisionVariableRepository.findOne({ + where: { id: id }, + }); + + if (!variableToUpdate) { + throw new Error('Variable not found'); + } + variableToUpdate.variable_name = variable.variable_name; + variableToUpdate.variable_value = variable.variable_value; + variableToUpdate.help_text = variable.help_text; + variableToUpdate.provision = provision; + + return this.provisionVariableRepository.save(variableToUpdate); + } + + async removeVariable(id: number): Promise { + return this.provisionVariableRepository.delete(id); + } + + async findAll(): Promise { + const provisions = await this.provisionRepository.find({ + relations: ['provision_group'], + }); + return provisions.map((provision) => { + delete provision.provision_group['id']; + + return { + ...provision, + ...provision.provision_group, + }; + }); + } + + async findAllVariables(): Promise { + const variables = await this.provisionVariableRepository.find({ + relations: ['provision'], + }); + return variables.map((variable) => { + return { + ...variable, + provision_id: variable.provision.id, + }; + }); + } + + async getProvisionsByDocumentTypeId(document_type_id: number): Promise { + const provisions: Provision[] = await this.provisionRepository + .createQueryBuilder('provision') + .innerJoinAndSelect('provision.document_types', 'documentType') + .innerJoinAndSelect('provision.provision_group', 'provisionGroup') + .where('documentType.id = :documentTypeId', { documentTypeId: document_type_id }) + .getMany(); + + return provisions; + } + + // querybuilder is more efficient here + async getVariablesByDocumentTypeId(document_type_id: number): Promise { + const provisions = await this.provisionRepository + .createQueryBuilder('provision') + .innerJoin('provision.document_types', 'documentType', 'documentType.id = :document_type_id', { + document_type_id, + }) + .getMany(); + if (!provisions.length) { + return []; + } + const provisionIds = provisions.map((provision) => provision.id); + const provisionVariables = await this.provisionVariableRepository + .createQueryBuilder('provisionVariable') + .where('provisionVariable.provisionId IN (:...provisionIds)', { provisionIds }) + .leftJoinAndSelect('provisionVariable.provision', 'provision') + .getMany(); + return provisionVariables; + } + + async findById(provisionId: number): Promise { + try { + return this.provisionRepository.findOne({ + where: { id: provisionId }, + relations: ['provision_group'], + }); + } catch (err) { + console.log(err); + return null; + } + } + + async getAllProvisions(): Promise { + try { + const provisions: Provision[] = await this.provisionRepository.find({ + relations: ['provision_group'], + }); + return provisions; + } catch (err) { + console.log(err); + return null; + } + } + + async enable(id: number): Promise { + await this.provisionRepository.update(id, { + active_flag: true, + }); + return { message: 'Provision Enabled' }; + } + + async disable(id: number): Promise { + await this.provisionRepository.update(id, { + active_flag: false, + }); + return { message: 'Provision Disabled' }; + } + + async getGroupMax(): Promise { + const provisions = await this.provisionRepository.find({ + relations: ['provision_group'], + }); + let provisionGroups: ProvisionGroup[] = []; + provisions.forEach((provision) => { + provisionGroups.push(provision.provision_group); + }); + provisionGroups = this.removeDuplicates(provisionGroups, 'provision_group'); + return Array.from(provisionGroups).sort((a, b) => a.provision_group - b.provision_group); + } + + async getGroupMaxByDocTypeId(document_type_id: number): Promise { + const provisions = await this.provisionRepository.find({ + relations: ['provision_group'], + }); + let provisionGroups: ProvisionGroup[] = []; + provisions.forEach((provision) => { + provisionGroups.push(provision.provision_group); + }); + provisionGroups = this.removeDuplicates(provisionGroups, 'provision_group'); + return Array.from(provisionGroups).sort((a, b) => a.provision_group - b.provision_group); + } + + // async getVariablesByDtid(dtid: number): Promise { + // // gets ALL provisions + // const provisions = await this.provisionRepository.find({ + // relations: ['provision_variables'], + // }); + + // const provisionVariables: ProvisionVariable[] = []; + // provisions.forEach((provision) => { + // provision.provision_variables.forEach((variable) => { + // variable['provisionId'] = provision.id; + // provisionVariables.push(variable); + // }); + // }); + // return provisionVariables; + // } + + async getMandatoryProvisions(): Promise { + const provisions = await this.provisionRepository.find({ + where: { type: 'M' }, + }); + return provisions.map((provision) => provision.id); + } + + async getMandatoryProvisionsByDocumentTypeId(document_type_id: number): Promise { + const provisions = await this.provisionRepository + .createQueryBuilder('provision') + .innerJoinAndSelect('provision.document_types', 'documentType') + .where('provision.type = :type', { type: 'M' }) + .andWhere('documentType.id = :documentTypeId', { documentTypeId: document_type_id }) + .getMany(); + + return provisions.map((provision) => provision.id); + } + + async remove(id: number): Promise<{ deleted: boolean; message?: string }> { + try { + await this.provisionRepository.delete(id); + return { deleted: true }; + } catch (err) { + return { deleted: false, message: err.message }; + } + } + + async updateGroupMaximums(provision_group: number, max: number, provision_group_text: string) { + let provisionGroup: ProvisionGroup = await this.provisionGroupRepository.findOneBy({ + provision_group: provision_group, + }); + if (!provisionGroup) { + const newGroup = this.provisionGroupRepository.create({ + provision_group: provision_group, + max: max, + provision_group_text: provision_group_text, + }); + provisionGroup = await this.provisionGroupRepository.save(newGroup); + } + if (provisionGroup.max != max || provisionGroup.provision_group_text != provision_group_text) { + await this.provisionGroupRepository.update(provisionGroup.id, { + max: max, + provision_group_text: provision_group_text, + }); + } + } + + removeDuplicates(array: T[], property: keyof T): T[] { + return array.reduce((accumulator, currentObject) => { + const existingObject = accumulator.find((obj) => obj[property] === currentObject[property]); + if (!existingObject) { + accumulator.push(currentObject); + } + return accumulator; + }, []); + } +} diff --git a/backend/src/report/report.controller.ts b/backend/src/report/report.controller.ts index f9e9c8f9..ef1496b6 100644 --- a/backend/src/report/report.controller.ts +++ b/backend/src/report/report.controller.ts @@ -56,9 +56,9 @@ export class ReportController { return response; } - @Get('get-nfr-data/:dtid') + @Get('get-document-data/:dtid') getNfrData(@Session() session: { data?: SessionData }, @Param('dtid') dtid: number) { - console.log('get-nfr-data ~ ' + dtid); + console.log('get-document-data ~ ' + dtid); return this.reportService.getActiveNfrDataByDtid(dtid); } @@ -147,15 +147,51 @@ export class ReportController { ); } - @Get('get-group-max/:variant') - getGroupMaxByVariant(@Param('variant') variantName: string) { - console.log('variantName: ' + variantName); - return this.reportService.getGroupMaxByVariant(variantName); + @Post('generate-report-new') + @Header('Content-Type', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') + @Header('Content-Disposition', 'attachment; filename=report.docx') + async generateReportNew( + @Session() session: { data: SessionData }, + @Body() + data: { + dtid: number; + document_type_id: number; + variableJson: VariableJSON[]; + provisionJson: ProvisionJSON[]; + } + ) { + let idir_username = ''; + let idir_full_name = ''; + if (session?.data?.activeAccount) { + idir_username = session?.data?.activeAccount.idir_username; + idir_full_name = session?.data?.activeAccount.full_name; + console.log('active account found'); + } else { + console.log('no active account found'); + } + // return new StreamableFile( + await this.reportService.generateReportNew( + data.dtid, + data.document_type_id, + idir_username, + idir_full_name, + data.variableJson, + data.provisionJson + ); + // ); + } + + @Get('get-group-max/:document_type_id') + getGroupMaxByVariant(@Param('document_type_id') document_type_id: number) { + return this.reportService.getGroupMaxByDocTypeId(document_type_id); } - @Get('nfr-provisions/:variantName/:dtid') - getNFRProvisionsByVariant(@Param('variantName') variantName: string, @Param('dtid') dtid: number): any { - return this.reportService.getNFRProvisionsByVariantAndDtid(variantName, dtid); + @Get('provisions/:document_type_id/:dtid') + getDocumentProvisionsByDocumentTypeId( + @Param('document_type_id') document_type_id: number, + @Param('dtid') dtid: number + ): any { + return this.reportService.getDocumentProvisionsByDocTypeIdAndDtid(document_type_id, dtid); } @Get('get-provision-variables/:variantName/:dtid') @@ -165,6 +201,35 @@ export class ReportController { return variables; } + @Post('save-document') + saveDocument( + @Session() session: { data: SessionData }, + @Body() + data: { + dtid: number; + document_type_id: number; + status: string; + provisionArray: ProvisionJSON[]; + variableArray: VariableJSON[]; + } + ) { + let idir_username = ''; + if (session?.data?.activeAccount) { + idir_username = session?.data?.activeAccount.idir_username; + console.log('active account found'); + } else { + console.log('no active account found'); + } + return this.reportService.saveDocument( + data.dtid, + data.document_type_id, + data.status, + data.provisionArray, + data.variableArray, + idir_username + ); + } + @Post('save-nfr') saveNFR( @Session() session: { data: SessionData }, @@ -194,23 +259,26 @@ export class ReportController { ); } - @Get('enabled-provisions/:variantName') - getEnabledProvisionsByVariant(@Param('variantName') variantName: string) { - return this.reportService.getEnabledProvisionsByVariant(variantName); + @Get('enabled-provisions/:document_type_id') + getEnabledProvisionsByDocTypeId(@Param('document_type_id') document_type_id: number) { + return this.reportService.getEnabledProvisionsByDocTypeId(document_type_id); } - @Get('enabled-provisions2/:variantName/:dtid') - getEnabledProvisionsByVariantAndDtid(@Param('variantName') variantName: string, @Param('dtid') dtid: number) { - return this.reportService.getEnabledProvisionsByVariantAndDtid(variantName, dtid); + @Get('enabled-provisions2/:document_type_id/:dtid') + getEnabledProvisionsByDocumentTypeIdDtid( + @Param('document_type_id') document_type_id: number, + @Param('dtid') dtid: number + ) { + return this.reportService.getEnabledProvisionsByDocTypeIdDtid(document_type_id, dtid); } - @Get('search-nfr-data') + @Get('search-document-data') getNFRData() { return this.reportService.getNFRData(); } - @Get('get-mandatory-provisions-by-variant/:variant') - getMandatoryProvisionsByVariant(@Param('variant') variant: string) { - return this.reportService.getMandatoryProvisionsByVariant(variant); + @Get('get-mandatory-provisions-by-document-type-id/:document_type_id') + getMandatoryProvisionsByDocumentTypeId(@Param('document_type_id') document_type_id: number) { + return this.reportService.getMandatoryProvisionsByDocumentTypeId(document_type_id); } } diff --git a/backend/src/report/report.module.ts b/backend/src/report/report.module.ts index 99de75dc..12f6d6e0 100644 --- a/backend/src/report/report.module.ts +++ b/backend/src/report/report.module.ts @@ -5,12 +5,21 @@ import { AuthenticationModule } from 'src/authentication/authentication.module'; import { ReportService } from './report.service'; import { HttpModule } from '@nestjs/axios'; import { DocumentTemplateModule } from 'src/document_template/document_template.module'; -import { PrintRequestLogModule } from 'src/print_request_log/print_request_log.module'; -import { NFRProvisionModule } from 'src/nfr_provision/nfr_provision.module'; +import { ProvisionModule } from 'src/provision/provision.module'; +import { DocumentDataModule } from 'src/document_data/document_data.module'; +import { DocumentDataLogModule } from 'src/document_data_log/document_data_log.module'; +import { DocumentDataLogService } from 'src/document_data_log/document_data_log.service'; @Module({ - imports: [HttpModule, AuthenticationModule, DocumentTemplateModule, PrintRequestLogModule, NFRProvisionModule], - providers: [TTLSService, ReportService], + imports: [ + HttpModule, + AuthenticationModule, + DocumentTemplateModule, + ProvisionModule, + DocumentDataModule, + DocumentDataLogModule, + ], + providers: [TTLSService, ReportService, DocumentDataLogService], exports: [ReportService], controllers: [ReportController], }) diff --git a/backend/src/report/report.service.ts b/backend/src/report/report.service.ts index a4c5b894..3c394eca 100644 --- a/backend/src/report/report.service.ts +++ b/backend/src/report/report.service.ts @@ -2,12 +2,14 @@ import { Injectable } from '@nestjs/common'; import * as dotenv from 'dotenv'; import { firstValueFrom } from 'rxjs'; import { DocumentTemplateService } from 'src/document_template/document_template.service'; -import { NFRProvisionService } from 'src/nfr_provision/nfr_provision.service'; -import { PrintRequestLogService } from 'src/print_request_log/print_request_log.service'; +import { ProvisionService } from 'src/provision/provision.service'; import { TTLSService } from 'src/ttls/ttls.service'; import { GL_REPORT_TYPE, LUR_REPORT_TYPE, numberWords, sectionTitles } from 'utils/constants'; import { ProvisionJSON, VariableJSON } from 'utils/types'; import { convertToSpecialCamelCase, formatMoney, grazingLeaseVariables, nfrAddressBuilder } from 'utils/util'; +import { DocumentDataService } from 'src/document_data/document_data.service'; +import { DocumentTemplate } from 'src/document_template/entities/document_template.entity'; +import { DocumentDataLogService } from 'src/document_data_log/document_data_log.service'; const axios = require('axios'); dotenv.config(); @@ -19,8 +21,9 @@ export class ReportService { constructor( private readonly ttlsService: TTLSService, private readonly documentTemplateService: DocumentTemplateService, - private readonly printRequestLogService: PrintRequestLogService, - private readonly nfrProvisionService: NFRProvisionService + private readonly documentDataLogService: DocumentDataLogService, + private readonly provisionService: ProvisionService, + private readonly documentDataService: DocumentDataService ) { hostname = process.env.backend_url ? process.env.backend_url : `http://localhost`; // local development backend port is 3001, docker backend port is 3000 @@ -52,6 +55,12 @@ export class ReportService { }; } + async generateReport(dtid: number, username: string, document_type_id: number) { + const documentTemplateObject: { id: number; the_file: string } = + await this.documentTemplateService.findActiveByDocumentType(document_type_id); + const data = await this.documentDataService; + } + /** * Generates the Land Use Report using CDOGS * @@ -304,7 +313,7 @@ export class ReportService { * @returns */ async generateNFRReportName(dtid: number, tenureFileNumber: string) { - const url = `${hostname}:${port}/nfr-data-log/version/` + dtid; + const url = `${hostname}:${port}/document-data-log/version/` + dtid; // grab the next version string for the dtid const version = await axios .get(url, { @@ -318,6 +327,36 @@ export class ReportService { return { reportName: 'NFR_' + tenureFileNumber + '_' + version + '.docx' }; } + async generateReportNew( + dtid: number, + document_type_id: number, + idirUsername: string, + idirName: string, + variableJson: VariableJSON[], + provisionJson: ProvisionJSON[] + ) { + console.log('TODO'); + // Get raw data from TTLS + await this.ttlsService.setWebadeToken(); + const rawData: any = await firstValueFrom(this.ttlsService.callHttp(dtid)) + .then((res) => { + return res; + }) + .catch((err) => { + console.log(err); + }); + // Get the active template file for this document type + const documentTemplateObject: DocumentTemplate = await this.documentTemplateService.findActiveByDocumentType( + document_type_id + ); + // format the provisions & variables in a dynamic way + // TODO + // create a log of the transaction + // TODO + // generate and return the document + // TODO + } + async generateNFRReport( dtid: number, variantName: string, @@ -327,7 +366,7 @@ export class ReportService { provisionJson: ProvisionJSON[] ) { const templateUrl = `${hostname}:${port}/document-template/get-active-report/${variantName}`; - const logUrl = `${hostname}:${port}/nfr-data-log/`; + const logUrl = `${hostname}:${port}/document-data-log/`; // get raw ttls data for later await this.ttlsService.setWebadeToken(); @@ -690,7 +729,7 @@ export class ReportService { return response2.data; } - async getNFRProvisionsByVariantAndDtid(variantName: string, dtid: number): Promise { + async getDocumentProvisionsByDocTypeIdAndDtid(document_type_id: number, dtid: number): Promise { const returnItems = [ 'type', 'provision_name', @@ -703,16 +742,10 @@ export class ReportService { ]; let reduced, provisions; // nfrDataId exists so return a list of provisions with pre-existing free_text data inserted, certain provisions preselected - const url = `${hostname}:${port}/nfr-data/provisions/${variantName}/${dtid}`; - const nfrProvisions = await axios - .get(url) - .then((res) => { - return res.data; - }) - .catch((err) => console.log(err.response.data)); - if (nfrProvisions) { - const provisionIds = nfrProvisions.provisionIds; - provisions = nfrProvisions.provisions; + const documentProvisions = await this.documentDataService.getProvisionsByDocTypeIdAndDtid(document_type_id, dtid); + if (documentProvisions) { + const provisionIds = documentProvisions.provisionIds; + provisions = documentProvisions.provisions; reduced = provisions.map((obj) => { if (provisionIds.includes(obj.id)) { obj.select = true; @@ -723,13 +756,7 @@ export class ReportService { }); } else { // no nfrDataId so just return generic provisions with all of them deselected by default - const url2 = `${hostname}:${port}/nfr-provision/variant/${variantName}`; - provisions = await axios - .get(url2) - .then((res) => { - return res.data; - }) - .catch((err) => console.log(err.response.data)); + provisions = await this.provisionService.getProvisionsByDocumentTypeId(document_type_id); reduced = provisions.map((obj) => Object.keys(obj) .filter((key) => returnItems.includes(key)) @@ -752,13 +779,13 @@ export class ReportService { }); } - getGroupMaxByVariant(variantName: string): Promise { - return this.nfrProvisionService.getGroupMaxByVariant(variantName); + getGroupMaxByDocTypeId(document_type_id: number): Promise { + return this.provisionService.getGroupMaxByDocTypeId(document_type_id); } async getNFRVariablesByVariantAndDtid(variantName: string, dtid: number): Promise { // if an nfrId is provided, get the variables with any existing user specified values - const url = `${hostname}:${port}/nfr-data/variables/${variantName}/${dtid}`; + const url = `${hostname}:${port}/document-data/variables/${variantName}/${dtid}`; const variables = await axios .get(url) .then((res) => { @@ -769,7 +796,7 @@ export class ReportService { return variables; } else { // grab the basic variable list corresponding to the variant - const url2 = `${hostname}:${port}/nfr-provision/get-provision-variables/variant/${variantName}`; + const url2 = `${hostname}:${port}/provision/get-provision-variables/variant/${variantName}`; return axios.get(url2).then((res) => { return res.data; }); @@ -777,74 +804,67 @@ export class ReportService { } getMandatoryProvisions() { - return this.nfrProvisionService.getMandatoryProvisions(); + return this.provisionService.getMandatoryProvisions(); } - getMandatoryProvisionsByVariant(variantName: string) { - return this.nfrProvisionService.getMandatoryProvisionsByVariant(variantName); + getMandatoryProvisionsByDocumentTypeId(document_type_id: number) { + return this.provisionService.getMandatoryProvisionsByDocumentTypeId(document_type_id); } async getNFRData() { const nfrDataUrl = `${hostname}:${port}/nfr-data`; const templateUrl = `${hostname}:${port}/document-template/nfr-template-info`; - const nfrData = await axios - .get(nfrDataUrl) - .then((res) => { - return res.data; - }) - .catch((err) => console.log(err.response.data)); - const templateIds = []; - for (let entry of nfrData) { - templateIds.push(entry.template_id); + + // get NFR data + let nfrData; + try { + const response = await axios.get(nfrDataUrl); + nfrData = response.data; + } catch (err) { + console.log(err.response.data); + return; } - const allTemplates: { - id: number; - file_name: string; - active_flag: boolean; - is_deleted: boolean; - template_version: number; - }[] = await axios - .post(templateUrl, templateIds) - .then((res) => { - return res.data; - }) - .catch((err) => console.log(err.response.data)); - // Combine the corresponding templates with the nfr data. - const combinedArray = []; - - let i = 0; - let j = 0; - - while (i < allTemplates.length && j < nfrData.length) { - const template = allTemplates[i]; - const nfr = nfrData[j]; - - if (template.id === nfr.template_id) { - if (!template.is_deleted) { - combinedArray.push({ - dtid: nfr.dtid, - version: template.template_version, - file_name: template.file_name, - updated_date: nfr.update_timestamp.split('T')[0], - status: nfr.status, - active: template.active_flag, - nfr_id: nfr.id, - variant_name: nfr.variant_name, - }); - } - j++; - } else if (template.id < nfr.template_id) { - i++; - } else { - j++; - } + // get template IDs from NFR data + const templateIds = nfrData.map((entry) => entry.template_id); + + // get templates using template IDs + let allTemplates; + try { + const response = await axios.post(templateUrl, templateIds); + allTemplates = response.data; + } catch (err) { + console.log(err.response.data); + return; } + + // filter out deleted templates and create a lookup table + const templatesLookup = allTemplates.reduce((acc, template) => { + if (!template.is_deleted) { + acc[template.id] = template; + } + return acc; + }, {}); + + // combine NFR data with their corresponding templates + const combinedArray = nfrData + .filter((nfr) => templatesLookup[nfr.template_id]) + .map((nfr) => ({ + dtid: nfr.dtid, + version: templatesLookup[nfr.template_id].template_version, + file_name: templatesLookup[nfr.template_id].file_name, + updated_date: nfr.update_timestamp.split('T')[0], + status: nfr.status, + active: templatesLookup[nfr.template_id].active_flag, + nfr_id: nfr.id, + variant_name: nfr.variant_name, + })); + return combinedArray; } async getActiveNfrDataByDtid(dtid: number): Promise { - const url = `${hostname}:${port}/nfr-data/dtid/${dtid}`; + const url = `${hostname}:${port}/document-data/dtid/${dtid}`; const response = await axios .get(url, { headers: { @@ -860,10 +880,10 @@ export class ReportService { // // console.log(groupMax); // console.log('\ngetActiveNfrDataByDtid'); // console.log(response); - // console.log('\nnfr_data_provisions'); - // // console.log(response.nfrData.nfr_data_provisions); - // console.log('\nnfr_data_variables'); - // // console.log(response.nfrData.nfr_data_variables); + // console.log('\ndocument_data_provisions'); + // // console.log(response.nfrData.document_data_provisions); + // console.log('\ndocument_data_variables'); + // // console.log(response.nfrData.document_data_variables); // console.log('\nthis.getMandatoryProvisionsByVariant(NOTICE OF FINAL REVIEW)'); // const mandatoryProvisions = await this.getMandatoryProvisionsByVariant('NOTICE OF FINAL REVIEW'); // // console.log(mandatoryProvisions); @@ -883,7 +903,7 @@ export class ReportService { const documentTemplate = await axios.get(templateUrl).then((res) => { return res.data; }); - const url = `${hostname}:${port}/nfr-data`; + const url = `${hostname}:${port}/document-data`; const data = { dtid: dtid, variant_name: variant_name, @@ -903,24 +923,32 @@ export class ReportService { }); } - async getEnabledProvisionsByVariant(variantName: string) { - const url = `${hostname}:${port}/nfr-provision/get-mandatory-provisions/variant/${variantName}`; - return axios.get(url).then((res) => { - return res.data; - }); + async saveDocument( + dtid: number, + document_type_id: number, + status: string, + provisionJsonArray: ProvisionJSON[], + variableJsonArray: VariableJSON[], + idir_username: string + ) { + const url = `${hostname}:${port}/document-data`; + const documentTemplate = await this.documentTemplateService.findActiveByDocumentType(document_type_id); + const data = { + dtid: dtid, + document_type_id: document_type_id, + template_id: documentTemplate.id, + status: status, + create_userid: idir_username, + ttls_data: [], + }; + return this.documentDataService.createOrUpdate(data, provisionJsonArray, variableJsonArray); } - async getEnabledProvisionsByVariantAndDtid(variantName: string, dtid: number) { - const url = `${hostname}:${port}/nfr-data/get-enabled-provisions/${variantName}/${dtid}`; - return axios.get(url).then((res) => { - return res.data; - }); + async getEnabledProvisionsByDocTypeId(document_type_id: number) { + return this.provisionService.getMandatoryProvisionsByDocumentTypeId(document_type_id); } - async getVariantsWithIds() { - const url = `${hostname}:${port}/nfr-provision/get-variants-with-ids/0`; - return axios.get(url).then((res) => { - return res.data; - }); + getEnabledProvisionsByDocTypeIdDtid(document_type_id: number, dtid: number) { + return this.documentDataService.getEnabledProvisionsByDocTypeIdAndDtid(document_type_id, dtid); } } diff --git a/backend/src/ttls/ttls.service.ts b/backend/src/ttls/ttls.service.ts index f2224ea2..c0b93273 100644 --- a/backend/src/ttls/ttls.service.ts +++ b/backend/src/ttls/ttls.service.ts @@ -349,7 +349,7 @@ export class TTLSService { // TODO async generateNFRReport(prdid: number, templateId: number, variables: any, username: string) { - const url = `${hostname}:${port}/nfr-data/view/${prdid}`; + const url = `${hostname}:${port}/document-data/view/${prdid}`; const templateUrl = `${hostname}:${port}/document-template/find-one/${templateId}`; const logUrl = `${hostname}:${port}/print-request-log/`; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/backend/utils/db/init-db.sql b/backend/utils/db/init-db.sql index 7e6231a3..478d34a5 100644 --- a/backend/utils/db/init-db.sql +++ b/backend/utils/db/init-db.sql @@ -1,31 +1,30 @@ -- Initialize Database Provisions -- Create groups -INSERT INTO nfr_provision_group (provision_group, max, provision_group_text) VALUES (1,999,'DOCUMENT TYPE'); -INSERT INTO nfr_provision_group (provision_group, max, provision_group_text) VALUES (2,999,'FEES'); -INSERT INTO nfr_provision_group (provision_group, max, provision_group_text) VALUES (5,3,'PREAMBLE'); -INSERT INTO nfr_provision_group (provision_group, max, provision_group_text) VALUES (10,3,'SURVEY REQUIREMENTS'); -INSERT INTO nfr_provision_group (provision_group, max, provision_group_text) VALUES (12,3,'SURVEY FEES'); -INSERT INTO nfr_provision_group (provision_group, max, provision_group_text) VALUES (14,3,'OBTAIN SURVEY'); -INSERT INTO nfr_provision_group (provision_group, max, provision_group_text) VALUES (15,1,'OCCUPATIONAL RENT'); -INSERT INTO nfr_provision_group (provision_group, max, provision_group_text) VALUES (20,2,'SECURITY'); -INSERT INTO nfr_provision_group (provision_group, max, provision_group_text) VALUES (25,2,'INSURANCE'); -INSERT INTO nfr_provision_group (provision_group, max, provision_group_text) VALUES (27,3,'ADDITIONAL REQUIREMENTS'); -INSERT INTO nfr_provision_group (provision_group, max, provision_group_text) VALUES (28,3,'ADDITIONAL REQUIREMENTS'); -INSERT INTO nfr_provision_group (provision_group, max, provision_group_text) VALUES (34,999,'ADDITIONAL REQUIREMENTS'); - --- Create variants -INSERT INTO nfr_provision_variant (variant_name) VALUES ('NOTICE OF FINAL REVIEW'); -INSERT INTO nfr_provision_variant (variant_name) VALUES ('NOTICE OF FINAL REVIEW (DELAYED)'); -INSERT INTO nfr_provision_variant (variant_name) VALUES ('NOTICE OF FINAL REVIEW (NO FEES)'); -INSERT INTO nfr_provision_variant (variant_name) VALUES ('NOTICE OF FINAL REVIEW (SURVEY REQUIRED)'); -INSERT INTO nfr_provision_variant (variant_name) VALUES ('NOTICE OF FINAL REVIEW (TO OBTAIN SURVEY)'); - --- Helper functions for grabbing variant ids, group ids, current variable id, and current provision id. +INSERT INTO provision_group (provision_group, max, provision_group_text) VALUES (1,999,'DOCUMENT TYPE'); +INSERT INTO provision_group (provision_group, max, provision_group_text) VALUES (2,999,'FEES'); +INSERT INTO provision_group (provision_group, max, provision_group_text) VALUES (5,3,'PREAMBLE'); +INSERT INTO provision_group (provision_group, max, provision_group_text) VALUES (10,3,'SURVEY REQUIREMENTS'); +INSERT INTO provision_group (provision_group, max, provision_group_text) VALUES (12,3,'SURVEY FEES'); +INSERT INTO provision_group (provision_group, max, provision_group_text) VALUES (14,3,'OBTAIN SURVEY'); +INSERT INTO provision_group (provision_group, max, provision_group_text) VALUES (15,1,'OCCUPATIONAL RENT'); +INSERT INTO provision_group (provision_group, max, provision_group_text) VALUES (20,2,'SECURITY'); +INSERT INTO provision_group (provision_group, max, provision_group_text) VALUES (25,2,'INSURANCE'); +INSERT INTO provision_group (provision_group, max, provision_group_text) VALUES (27,3,'ADDITIONAL REQUIREMENTS'); +INSERT INTO provision_group (provision_group, max, provision_group_text) VALUES (28,3,'ADDITIONAL REQUIREMENTS'); +INSERT INTO provision_group (provision_group, max, provision_group_text) VALUES (34,999,'ADDITIONAL REQUIREMENTS'); + +INSERT INTO document_type (name, create_userid, update_userid) VALUES ('Notice of Final Review', 'system', 'system'); +INSERT INTO document_type (name, create_userid, update_userid) VALUES ('Notice of Final Review (Delayed)', 'system', 'system'); +INSERT INTO document_type (name, create_userid, update_userid) VALUES ('Notice of Final Review (No Fees)', 'system', 'system'); +INSERT INTO document_type (name, create_userid, update_userid) VALUES ('Notice of Final Review (Survey Required)', 'system', 'system'); +INSERT INTO document_type (name, create_userid, update_userid) VALUES ('Notice of Final Review (To Obtain Survey)', 'system', 'system'); + +-- Helper functions for grabbing document type ids, group ids, current variable id, and current provision id. CREATE OR REPLACE FUNCTION get_current_provision_id() RETURNS INTEGER AS $$ DECLARE provision_id INTEGER; BEGIN - SELECT max(id) INTO provision_id FROM nfr_provision; + SELECT max(id) INTO provision_id FROM provision; return provision_id; END; $$ LANGUAGE PLPGSQL; @@ -34,53 +33,53 @@ CREATE OR REPLACE FUNCTION get_last_provision_variable_id() RETURNS INTEGER AS $ DECLARE provision_variable_id INTEGER; BEGIN - SELECT max(id) INTO provision_variable_id FROM nfr_provision_variable; + SELECT max(id) INTO provision_variable_id FROM provision_variable; return provision_variable_id; END; $$ LANGUAGE PLPGSQL; -CREATE OR REPLACE FUNCTION get_variant_default() RETURNS INTEGER AS $$ +CREATE OR REPLACE FUNCTION get_doc_type_default() RETURNS INTEGER AS $$ DECLARE - variant_id INTEGER; + document_type_id INTEGER; BEGIN - SELECT id INTO variant_id FROM nfr_provision_variant WHERE variant_name = 'NOTICE OF FINAL REVIEW'; - RETURN variant_id; + SELECT id INTO document_type_id FROM document_type WHERE name = 'Notice of Final Review'; + RETURN document_type_id; END; $$ LANGUAGE PLPGSQL; -CREATE OR REPLACE FUNCTION get_variant_delayed() RETURNS INTEGER AS $$ +CREATE OR REPLACE FUNCTION get_doc_type_delayed() RETURNS INTEGER AS $$ DECLARE - variant_id INTEGER; + document_type_id INTEGER; BEGIN - SELECT id INTO variant_id FROM nfr_provision_variant WHERE variant_name = 'NOTICE OF FINAL REVIEW (DELAYED)'; - RETURN variant_id; + SELECT id INTO document_type_id FROM document_type WHERE name = 'Notice of Final Review (Delayed)'; + RETURN document_type_id; END; $$ LANGUAGE PLPGSQL; -CREATE OR REPLACE FUNCTION get_variant_nofees() RETURNS INTEGER AS $$ +CREATE OR REPLACE FUNCTION get_doc_type_nofees() RETURNS INTEGER AS $$ DECLARE - variant_id INTEGER; + document_type_id INTEGER; BEGIN - SELECT id INTO variant_id FROM nfr_provision_variant WHERE variant_name = 'NOTICE OF FINAL REVIEW (NO FEES)'; - RETURN variant_id; + SELECT id INTO document_type_id FROM document_type WHERE name = 'Notice of Final Review (No Fees)'; + RETURN document_type_id; END; $$ LANGUAGE PLPGSQL; -CREATE OR REPLACE FUNCTION get_variant_surveyreq() RETURNS INTEGER AS $$ +CREATE OR REPLACE FUNCTION get_doc_type_surveyreq() RETURNS INTEGER AS $$ DECLARE - variant_id INTEGER; + document_type_id INTEGER; BEGIN - SELECT id INTO variant_id FROM nfr_provision_variant WHERE variant_name = 'NOTICE OF FINAL REVIEW (SURVEY REQUIRED)'; - RETURN variant_id; + SELECT id INTO document_type_id FROM document_type WHERE name = 'Notice of Final Review (Survey Required)'; + RETURN document_type_id; END; $$ LANGUAGE PLPGSQL; -CREATE OR REPLACE FUNCTION get_variant_toobtain() RETURNS INTEGER AS $$ +CREATE OR REPLACE FUNCTION get_doc_type_toobtain() RETURNS INTEGER AS $$ DECLARE - variant_id INTEGER; + document_type_id INTEGER; BEGIN - SELECT id INTO variant_id FROM nfr_provision_variant WHERE variant_name = 'NOTICE OF FINAL REVIEW (TO OBTAIN SURVEY)'; - RETURN variant_id; + SELECT id INTO document_type_id FROM document_type WHERE name = 'Notice of Final Review (To Obtain Survey)'; + RETURN document_type_id; END; $$ LANGUAGE PLPGSQL; @@ -89,232 +88,232 @@ RETURNS INTEGER AS $$ DECLARE pg_id INTEGER; BEGIN - SELECT id INTO pg_id FROM nfr_provision_group WHERE provision_group = p_provision_group; + SELECT id INTO pg_id FROM provision_group WHERE provision_group = p_provision_group; RETURN pg_id; END; $$ LANGUAGE plpgsql; --- Create Provisions and relations to variants +-- Create Provisions and relations to document types -- Variant 'NOTICE OF FINAL REVIEW' -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW','','Use this to enter values for each of the variables in the boilerplate of the NOTICE OF FINAL REVIEW letter.','DOCUMENT TYPE',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('ATTENTION_LINE','','Attention: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('CLIENT_FILE_NO','','Your file: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DATE_OF_NOTICE','','Date of letter: Month Day ,Year',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_COMPLETION_REQUIREMENTS','','Enter the date (month day, year) for completion of requirements',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FACSIMILE_NUMBER','','Type in your facsimile number - "250 ___-____"',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('NUMBER_OF_COPIES','','three copies of tenure documents which are being forwarded to client to sign. The number should be typed as a word, not a number.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('PURPOSE_GENERIC','','used for "_________" purposes.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SALUTATION','','Dear "______": Type in the person’s name or Sir or Madam.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',get_current_provision_id()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW','','Use this to enter values for each of the variables in the boilerplate of the NOTICE OF FINAL REVIEW letter.','DOCUMENT TYPE',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('ATTENTION_LINE','','Attention: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('CLIENT_FILE_NO','','Your file: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DATE_OF_NOTICE','','Date of letter: Month Day ,Year',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_COMPLETION_REQUIREMENTS','','Enter the date (month day, year) for completion of requirements',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FACSIMILE_NUMBER','','Type in your facsimile number - "250 ___-____"',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('NUMBER_OF_COPIES','','three copies of tenure documents which are being forwarded to client to sign. The number should be typed as a word, not a number.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('PURPOSE_GENERIC','','used for "_________" purposes.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SALUTATION','','Dear "______": Type in the person’s name or Sir or Madam.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',get_current_provision_id()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(2),'FEES','','Use this to create a table listing all the fees to be paid. Table is unprotected, so you will be able to modify text ','FEES',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_toobtain()), (get_current_provision_id(), get_variant_surveyreq()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FEE_APPLICATION_AMOUNT','','$"#.##" payable. Fill in either amount, or "0" if nothing payable for this category of fee. Put in decimals.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FEE_DOCUMENTATION_AMOUNT','','$"#.##" payable. Fill in either amount, or "0" if nothing payable for this category of fee. Put in decimals.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FEE_OCCUPATIONAL_RENTAL_AMOUNT','','$"#.##" payable. Fill in either amount, or "0" if nothing payable for this category of fee. Put in decimals.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FEE_OTHER_CREDIT_AMOUNT','','$"#.##" payable. Fill in either amount, or "0" if nothing payable for this category of fee. Put in decimals.',get_current_provision_id()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(2),'FEES','','Use this to create a table listing all the fees to be paid. Table is unprotected, so you will be able to modify text ','FEES',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FEE_APPLICATION_AMOUNT','','$"#.##" payable. Fill in either amount, or "0" if nothing payable for this category of fee. Put in decimals.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FEE_DOCUMENTATION_AMOUNT','','$"#.##" payable. Fill in either amount, or "0" if nothing payable for this category of fee. Put in decimals.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FEE_OCCUPATIONAL_RENTAL_AMOUNT','','$"#.##" payable. Fill in either amount, or "0" if nothing payable for this category of fee. Put in decimals.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FEE_OTHER_CREDIT_AMOUNT','','$"#.##" payable. Fill in either amount, or "0" if nothing payable for this category of fee. Put in decimals.',get_current_provision_id()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(5),'REPLACEMENT STATEMENT','',' Use this when tenure is being replaced','PREAMBLE',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_toobtain()), (get_current_provision_id(), get_variant_surveyreq()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('REPLACEMENT_TENURE_TYPE','','____No. #. Use to specify type and number of tenure being replaced e.g. lease No. 999.',get_current_provision_id()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(5),'REPLACEMENT STATEMENT','',' Use this when tenure is being replaced','PREAMBLE',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('REPLACEMENT_TENURE_TYPE','','____No. #. Use to specify type and number of tenure being replaced e.g. lease No. 999.',get_current_provision_id()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(5),'LAND DIFFERS FROM STATEMENT','','Use when land being offered differs from the applied area','OFFER PREAMBLE',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_toobtain()), (get_current_provision_id(), get_variant_surveyreq()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('WHY_LAND_DIFFERS','','The Land differs from what you applied for because "____". Explain why you are offering some...',get_current_provision_id()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(5),'LAND DIFFERS FROM STATEMENT','','Use when land being offered differs from the applied area','OFFER PREAMBLE',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('WHY_LAND_DIFFERS','','The Land differs from what you applied for because "____". Explain why you are offering some...',get_current_provision_id()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(5),'FREE FIELD - PREAMBLE INFORMATION','','Use when you want to enter additonal information for the preamble','OFFER PREAMBLE',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_toobtain()), (get_current_provision_id(), get_variant_surveyreq()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(5),'FREE FIELD - PREAMBLE INFORMATION','','Use when you want to enter additonal information for the preamble','OFFER PREAMBLE',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(15),'OCCUPATIONAL RENT STATEMENT','','Use this where occupational rent is payable','OFFER - MONIES - PAYABLE',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_toobtain()), (get_current_provision_id(), get_variant_surveyreq()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('OCC_RENT_DETAILS','','Occupatianal Rental is payable for your occupation of the Land for the period from "___". Set out ...',get_current_provision_id()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(15),'OCCUPATIONAL RENT STATEMENT','','Use this where occupational rent is payable','OFFER - MONIES - PAYABLE',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('OCC_RENT_DETAILS','','Occupatianal Rental is payable for your occupation of the Land for the period from "___". Set out ...',get_current_provision_id()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'DELIVER SECURITY DEPOSIT - NOTICE OF FINAL REVIEW','','Use this to require delivery of security deposit','OFFER - SECURITY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_surveyreq()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SECURITY_AMOUNT','','#.## to post as security - indicate an amount even if blanket bond applies. Put in Decimal.',get_current_provision_id()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'DELIVER SECURITY DEPOSIT - NOTICE OF FINAL REVIEW','','Use this to require delivery of security deposit','OFFER - SECURITY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_surveyreq()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SECURITY_AMOUNT','','#.## to post as security - indicate an amount even if blanket bond applies. Put in Decimal.',get_current_provision_id()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'BLANKET SECURITY STATEMENT','','Use this when client is covered by blanket security agreement','OFFER - SECURITY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_surveyreq()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('BLANKET_BOND_NAME','','You are currently covered by a blanket bond between MELP and "____". S...',get_current_provision_id()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'BLANKET SECURITY STATEMENT','','Use this when client is covered by blanket security agreement','OFFER - SECURITY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_surveyreq()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('BLANKET_BOND_NAME','','You are currently covered by a blanket bond between MELP and "____". S...',get_current_provision_id()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'FREE FIELD FOR SECURITY SECTION','','Use where you need to add information regarding security','OFFER - SECURITY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_toobtain()), (get_current_provision_id(), get_variant_surveyreq()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'FREE FIELD FOR SECURITY SECTION','','Use where you need to add information regarding security','OFFER - SECURITY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(25),'INSURANCE REQUIRED - NOTICE OF FINAL REVIEW - OTHER','','Use when insurance is required for other tenures eg. homeowners','OFFER - INSURANCE',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_surveyreq()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(25),'INSURANCE REQUIRED - NOTICE OF FINAL REVIEW - OTHER','','Use when insurance is required for other tenures eg. homeowners','OFFER - INSURANCE',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(25),'INSURANCE REQUIRED - NOTICE OF FINAL REVIEW - CERTIFICATE REQUIRED','','Use when insurance along with a Certificate of Insurance is required.','OFFER - INSURANCE',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_toobtain()), (get_current_provision_id(), get_variant_surveyreq()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(25),'INSURANCE REQUIRED - NOTICE OF FINAL REVIEW - CERTIFICATE REQUIRED','','Use when insurance along with a Certificate of Insurance is required.','OFFER - INSURANCE',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(25),'FREE FIELD FOR INSURANCE','','Use where you want to enter additonal information on insurance','OFFER - INSURANCE',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_toobtain()), (get_current_provision_id(), get_variant_surveyreq()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(25),'FREE FIELD FOR INSURANCE','','Use where you want to enter additonal information on insurance','OFFER - INSURANCE',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'FREE FIELD - ADDITIONAL REQUIREMENTS','','Use where you want to state additional conditions of the offer','ADDITIONAL REQUIREMENTS',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_toobtain()), (get_current_provision_id(), get_variant_surveyreq()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'FREE FIELD - ADDITIONAL REQUIREMENTS','','Use where you want to state additional conditions of the offer','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'FREE FIELD - ADDITIONAL REQUIREMENTS - 2','','Use where you want to state additional conditions of the offer','ADDITIONAL REQUIREMENTS',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_toobtain()), (get_current_provision_id(), get_variant_surveyreq()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'FREE FIELD - ADDITIONAL REQUIREMENTS - 2','','Use where you want to state additional conditions of the offer','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - MANAGEMENT PLAN','','Use to require delivery of a management plan.','ADDITIONAL REQUIREMENTS',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_toobtain()), (get_current_provision_id(), get_variant_surveyreq()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - MANAGEMENT PLAN','','Use to require delivery of a management plan.','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - ZONING APPROVAL','','Use to require confirmation that a zoning bylaw permitting use of the Land for the intended purposes has been adopted.','ADDITIONAL REQUIREMENTS',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_toobtain()), (get_current_provision_id(), get_variant_surveyreq()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('LOCAL_GOVERNMENT','','Type in the name of the local government.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('PURPOSE_GENERIC','','used for "_________" purposes.',get_current_provision_id()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - ZONING APPROVAL','','Use to require confirmation that a zoning bylaw permitting use of the Land for the intended purposes has been adopted.','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('LOCAL_GOVERNMENT','','Type in the name of the local government.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('PURPOSE_GENERIC','','used for "_________" purposes.',get_current_provision_id()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - IMPROVEMENTS STAT DEC','','Use this when a statutory declaration is required regarding ownership of improvements.','ADDITIONAL REQUIREMENTS',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_toobtain()), (get_current_provision_id(), get_variant_surveyreq()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - IMPROVEMENTS STAT DEC','','Use this when a statutory declaration is required regarding ownership of improvements.','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - TAX CLEARANCE CERTIFICATE','','Use when a tax clearance certificate is required verifying that there are no arrears of taxes.','ADDITIONAL REQUIREMENTS',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_toobtain()), (get_current_provision_id(), get_variant_surveyreq()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TAX_COLLECTOR_OFFICE','','Type in the address of the local Provincial Tax Collector’s office.',get_current_provision_id()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - TAX CLEARANCE CERTIFICATE','','Use when a tax clearance certificate is required verifying that there are no arrears of taxes.','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TAX_COLLECTOR_OFFICE','','Type in the address of the local Provincial Tax Collector’s office.',get_current_provision_id()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - AFFILIATE STATUS CERTIFICATE','','Use when a certificate of affiliate status is required for each affiliate of your company using the communication site.','ADDITIONAL REQUIREMENTS',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_toobtain()), (get_current_provision_id(), get_variant_surveyreq()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - AFFILIATE STATUS CERTIFICATE','','Use when a certificate of affiliate status is required for each affiliate of your company using the communication site.','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - OBTAIN AND DELIVER','','Use when you require immediate delivery of documentation.','ADDITIONAL REQUIREMENTS',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()), (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_nofees()), (get_current_provision_id(), get_variant_toobtain()), (get_current_provision_id(), get_variant_surveyreq()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_TO_DELIVER','','Enter "on or before [date]" OR "within [45] days from the date of this letter.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DOCUMENT_TO_OBTAIN','','You must obtain the [specify the name of the document(s)] and ....',get_current_provision_id()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - OBTAIN AND DELIVER','','Use when you require immediate delivery of documentation.','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_TO_DELIVER','','Enter "on or before [date]" OR "within [45] days from the date of this letter.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DOCUMENT_TO_OBTAIN','','You must obtain the [specify the name of the document(s)] and ....',get_current_provision_id()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - FISHERIES AND OCEANS APPROVAL','','Use to require delivery of a copy of a permit from Fisheries and Oceans for aquaculture purposes.','ADDITIONAL REQUIREMENTS',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - FISHERIES AND OCEANS APPROVAL','','Use to require delivery of a copy of a permit from Fisheries and Oceans for aquaculture purposes.','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()); -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - COAST GUARD APPROVAL','','Use to require delivery of a letter of approval from the Canadian Coast Guard for the proposed construction.','ADDITIONAL REQUIREMENTS',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_default()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('COAST_GUARD_ADDRESS','','Type in the address of the Canadian Coast Guard office.',get_current_provision_id()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - COAST GUARD APPROVAL','','Use to require delivery of a letter of approval from the Canadian Coast Guard for the proposed construction.','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('COAST_GUARD_ADDRESS','','Type in the address of the Canadian Coast Guard office.',get_current_provision_id()); -- Variant 'NOTICE OF FINAL REVIEW (NO FEES)' -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW - NO FEES','','require message from POLICY','DOCUMENT TYPE',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_nofees()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('ATTENTION_LINE','','Attention: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('CLIENT_FILE_NO','','Your file: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DATE_OF_NOTICE','','Date of letter: Month Day ,Year',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_COMPLETION_REQUIREMENTS','','Enter the date (month day, year) for completion of requirements',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FACSIMILE_NUMBER','','Type in your facsimile number - "250 ___-____"',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('NUMBER_OF_COPIES','','three copies of tenure documents which are being forwarded to client to sign. The number should be typed as a word, not a number.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('PURPOSE_GENERIC','','used for "_________" purposes.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('REPLACEMENT_TENURE_TYPE','','____No. #. Use to specify type and number of tenure being replaced e.g. lease No. 999.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SALUTATION','','Dear "______": Type in the person’s name or Sir or Madam.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',get_current_provision_id()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW - NO FEES','','require message from POLICY','DOCUMENT TYPE',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_nofees()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('ATTENTION_LINE','','Attention: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('CLIENT_FILE_NO','','Your file: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DATE_OF_NOTICE','','Date of letter: Month Day ,Year',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_COMPLETION_REQUIREMENTS','','Enter the date (month day, year) for completion of requirements',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FACSIMILE_NUMBER','','Type in your facsimile number - "250 ___-____"',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('NUMBER_OF_COPIES','','three copies of tenure documents which are being forwarded to client to sign. The number should be typed as a word, not a number.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('PURPOSE_GENERIC','','used for "_________" purposes.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('REPLACEMENT_TENURE_TYPE','','____No. #. Use to specify type and number of tenure being replaced e.g. lease No. 999.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SALUTATION','','Dear "______": Type in the person’s name or Sir or Madam.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',get_current_provision_id()); -- Variant 'NOTICE OF FINAL REVIEW (DELAYED)' -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW - DELAYED','','require message from POLICY','DOCUMENT TYPE',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_delayed()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('ATTENTION_LINE','','Attention: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('CLIENT_FILE_NO','','Your file: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DATE_OF_NOTICE','','Date of letter: Month Day ,Year',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_COMPLETION_REQUIREMENTS','','Enter the date (month day, year) for completion of requirements',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FACSIMILE_NUMBER','','Type in your facsimile number - "250 ___-____"',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('NUMBER_OF_COPIES','','three copies of tenure documents which are being forwarded to client to sign. The number should be typed as a word, not a number.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('PURPOSE_GENERIC','','used for "_________" purposes.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SALUTATION','','Dear "______": Type in the person’s name or Sir or Madam.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TENURE_TYPE','','Type in the tenure type. e.g. Lease',get_current_provision_id()); - -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'SURVEY CONFIRMATION - CLIENT PAYS - DELAYED','','Use when the client pays for survey.','OFFER SURVEY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_delayed()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_COMPLETE_SURVEY','','on or before "month day, year"',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_CONFIRM_SURVEY','','Enter "On or before [date]" OR "Within [45] days from the date of this letter". Capitalize first character as this is the start of a sentence.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('MAXIMUM_AREA','','# hectares',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('RATE_PER_METRE','','$"#.## per square metre/per hectare" Put in the decimal.',get_current_provision_id()); - -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'SURVEY DEPOSIT - DELAYED','','Use to require payment of a deposit where Province is to pay for a survey.','OFFER SURVEY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_delayed()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SURVEY_DEPOSIT_DELAYED','','Deadline to pay survey deposit. Enter Month, Day, Year',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEPOSIT_AMOUNT_SURVEY','','$"#.##" Enter amount of survey deposit. Put in the decimal.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('MAXIMUM_AREA','','# hectares',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('RATE_PER_METRE','','$"#.## per square metre/per hectare" Put in the decimal.',get_current_provision_id()); - -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'PREPARE BOUNDARY PLAN (CLIENT PAYS)','','require message from POLICY','OFFER SURVEY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_delayed()), (get_current_provision_id(), get_variant_surveyreq()); - -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(12),'MONIES PAYABLE - NOTICE OF FINAL REVIEW - DELAYED','','Use when you are providing a firm amount payable.','OFFER SURVEY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_delayed()); - -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(12),'ESTIMATED MONIES PAYABLE - NOTICE OF FINAL REVIEW - DELAYED','','Use when you are providing an estimated amount payable.','OFFER SURVEY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_delayed()); - -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'DELIVER SECURITY DEPOSIT (& SURVEY DEPOSIT) - NOTICE OF FINAL REVIEW','','Use this where 2 deposits are to be delivered: one for the survey and another for clean-up under the terms of the tenure to be issued','OFFER - SECURITY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_delayed()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW - DELAYED','','require message from POLICY','DOCUMENT TYPE',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_delayed()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('ATTENTION_LINE','','Attention: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('CLIENT_FILE_NO','','Your file: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DATE_OF_NOTICE','','Date of letter: Month Day ,Year',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_COMPLETION_REQUIREMENTS','','Enter the date (month day, year) for completion of requirements',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FACSIMILE_NUMBER','','Type in your facsimile number - "250 ___-____"',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('NUMBER_OF_COPIES','','three copies of tenure documents which are being forwarded to client to sign. The number should be typed as a word, not a number.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('PURPOSE_GENERIC','','used for "_________" purposes.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SALUTATION','','Dear "______": Type in the person’s name or Sir or Madam.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TENURE_TYPE','','Type in the tenure type. e.g. Lease',get_current_provision_id()); + +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'SURVEY CONFIRMATION - CLIENT PAYS - DELAYED','','Use when the client pays for survey.','OFFER SURVEY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_delayed()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_COMPLETE_SURVEY','','on or before "month day, year"',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_CONFIRM_SURVEY','','Enter "On or before [date]" OR "Within [45] days from the date of this letter". Capitalize first character as this is the start of a sentence.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('MAXIMUM_AREA','','# hectares',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('RATE_PER_METRE','','$"#.## per square metre/per hectare" Put in the decimal.',get_current_provision_id()); + +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'SURVEY DEPOSIT - DELAYED','','Use to require payment of a deposit where Province is to pay for a survey.','OFFER SURVEY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_delayed()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SURVEY_DEPOSIT_DELAYED','','Deadline to pay survey deposit. Enter Month, Day, Year',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEPOSIT_AMOUNT_SURVEY','','$"#.##" Enter amount of survey deposit. Put in the decimal.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('MAXIMUM_AREA','','# hectares',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('RATE_PER_METRE','','$"#.## per square metre/per hectare" Put in the decimal.',get_current_provision_id()); + +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'PREPARE BOUNDARY PLAN (CLIENT PAYS)','','require message from POLICY','OFFER SURVEY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_surveyreq()); + +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(12),'MONIES PAYABLE - NOTICE OF FINAL REVIEW - DELAYED','','Use when you are providing a firm amount payable.','OFFER SURVEY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_delayed()); + +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(12),'ESTIMATED MONIES PAYABLE - NOTICE OF FINAL REVIEW - DELAYED','','Use when you are providing an estimated amount payable.','OFFER SURVEY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_delayed()); + +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'DELIVER SECURITY DEPOSIT (& SURVEY DEPOSIT) - NOTICE OF FINAL REVIEW','','Use this where 2 deposits are to be delivered: one for the survey and another for clean-up under the terms of the tenure to be issued','OFFER - SECURITY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_delayed()); -- Variant 'NOTICE OF FINAL REVIEW (TO OBTAIN SURVEY)' -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW - TO OBTAIN SURVEY','','require message from POLICY','DOCUMENT TYPE',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_toobtain()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('ATTENTION_LINE','','Attention: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('CLIENT_FILE_NO','','Your file: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DATE_OF_NOTICE','','Date of letter: Month Day ,Year',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_COMPLETION_REQUIREMENTS','','Enter the date (month day, year) for completion of requirements',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FACSIMILE_NUMBER','','Type in your facsimile number - "250 ___-____"',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('INTERIM_TENURE_TYPE','','Insert the type of tenure now being used. e.g. Licence.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('NUMBER_OF_COPIES','','three copies of tenure documents which are being forwarded to client to sign. The number should be typed as a word, not a number.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('PURPOSE_GENERIC','','used for "_________" purposes.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SALUTATION','','Dear "______": Type in the person’s name or Sir or Madam.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',get_current_provision_id()); - -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'BOUNDARY SURVEY (WE PAY)','','Use where we will pay a B.C.L.S. to prepare a boundary survey','OFFER PREAMBLE',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_toobtain()); - -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(12),'SURVEY DEPOSIT','','Use to require payment of a deposit where Province is to pay for a survey','OFFER SURVEY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_toobtain()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_SURVEY_DEPOSIT','','Deadline to pay survey deposit. Enter Month, Day, Year',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEPOSIT_AMOUNT_SURVEY','','$"#.##" Enter amount of survey deposit. Put in the decimal.',get_current_provision_id()); - -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(14),'LETTER AFFIRMING BC LAND SURVEYOR WAS HIRED','','Use to require client to submit letter confirming B.C.L.S. has been hired','OFFER - OBTAIN SURVEY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_toobtain()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_CONFIRM_SURVEY','','Enter "On or before [date]" OR "Within [45] days from the date of this letter". Capitalize first character as this is the start of a sentence.',get_current_provision_id()); - -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(14),'LETTER AFFIRMING BOUNDARY SURVEY','','Use to remind client that surveyor’s letter must confirm that location of improvements will be on boundary plan','OFFER - OBTAIN SURVEY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_toobtain()); - -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'DELIVER SECURITY DEPOSIT - OS','','require message from POLICY','OFFER - SECURITY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_toobtain()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('INTERIM_TENURE_TYPE','','Insert the type of tenure now being used. e.g. Licence.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SECURITY_AMOUNT','','#.## to post as security - indicate an amount even if blanket bond applies. Put in Decimal.',get_current_provision_id()); - -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'BLANKET SECURITY STATEMENT - OS','','Use this when client is covered by blanket security agreement.','OFFER - SECURITY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_toobtain()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('BLANKET_BOND_NAME','','You are currently covered by a blanket bond between MELP and "____". S...',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('INTERIM_TENURE_TYPE','','Insert the type of tenure now being used. e.g. Licence.',get_current_provision_id()); - -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(25),'INSURANCE REQUIRED - NOTICE OF FINAL REVIEW - OTHER - OS','','Use when insurance is required for other tenures eg. homeowners','OFFER - INSURANCE',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_toobtain()); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW - TO OBTAIN SURVEY','','require message from POLICY','DOCUMENT TYPE',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_toobtain()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('ATTENTION_LINE','','Attention: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('CLIENT_FILE_NO','','Your file: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DATE_OF_NOTICE','','Date of letter: Month Day ,Year',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_COMPLETION_REQUIREMENTS','','Enter the date (month day, year) for completion of requirements',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FACSIMILE_NUMBER','','Type in your facsimile number - "250 ___-____"',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('INTERIM_TENURE_TYPE','','Insert the type of tenure now being used. e.g. Licence.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('NUMBER_OF_COPIES','','three copies of tenure documents which are being forwarded to client to sign. The number should be typed as a word, not a number.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('PURPOSE_GENERIC','','used for "_________" purposes.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SALUTATION','','Dear "______": Type in the person’s name or Sir or Madam.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',get_current_provision_id()); + +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'BOUNDARY SURVEY (WE PAY)','','Use where we will pay a B.C.L.S. to prepare a boundary survey','OFFER PREAMBLE',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_toobtain()); + +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(12),'SURVEY DEPOSIT','','Use to require payment of a deposit where Province is to pay for a survey','OFFER SURVEY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_toobtain()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_SURVEY_DEPOSIT','','Deadline to pay survey deposit. Enter Month, Day, Year',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEPOSIT_AMOUNT_SURVEY','','$"#.##" Enter amount of survey deposit. Put in the decimal.',get_current_provision_id()); + +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(14),'LETTER AFFIRMING BC LAND SURVEYOR WAS HIRED','','Use to require client to submit letter confirming B.C.L.S. has been hired','OFFER - OBTAIN SURVEY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_toobtain()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_CONFIRM_SURVEY','','Enter "On or before [date]" OR "Within [45] days from the date of this letter". Capitalize first character as this is the start of a sentence.',get_current_provision_id()); + +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(14),'LETTER AFFIRMING BOUNDARY SURVEY','','Use to remind client that surveyor’s letter must confirm that location of improvements will be on boundary plan','OFFER - OBTAIN SURVEY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_toobtain()); + +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'DELIVER SECURITY DEPOSIT - OS','','require message from POLICY','OFFER - SECURITY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_toobtain()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('INTERIM_TENURE_TYPE','','Insert the type of tenure now being used. e.g. Licence.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SECURITY_AMOUNT','','#.## to post as security - indicate an amount even if blanket bond applies. Put in Decimal.',get_current_provision_id()); + +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'BLANKET SECURITY STATEMENT - OS','','Use this when client is covered by blanket security agreement.','OFFER - SECURITY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_toobtain()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('BLANKET_BOND_NAME','','You are currently covered by a blanket bond between MELP and "____". S...',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('INTERIM_TENURE_TYPE','','Insert the type of tenure now being used. e.g. Licence.',get_current_provision_id()); + +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(25),'INSURANCE REQUIRED - NOTICE OF FINAL REVIEW - OTHER - OS','','Use when insurance is required for other tenures eg. homeowners','OFFER - INSURANCE',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_toobtain()); -- Variant 'NOTICE OF FINAL REVIEW (SURVEY REQUIRED)' -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW - SURVEY REQUIRED','','require message from POLICY','DOCUMENT TYPE',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_surveyreq()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('ATTENTION_LINE','','Attention: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('CLIENT_FILE_NO','','Your file: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DATE_OF_NOTICE','','Date of letter: Month Day ,Year',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DAYS_TO_DELIVER_DOCUMENTS','','# days in the sentence: We will forward the documents to you within ___of the survey being completed.....',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DAYS_TO_RETURN_DOCUMENTS','','__ days - You must sign and return them to us within _____ of our letter to you .......',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_COMPLETION_REQUIREMENTS','','Enter the date (month day, year) for completion of requirements',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FACSIMILE_NUMBER','','Type in your facsimile number - "250 ___-____"',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('MAXIMUM_AREA','','# hectares',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('NUMBER_OF_COPIES','','three copies of tenure documents which are being forwarded to client to sign. The number should be typed as a word, not a number.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('PURPOSE_GENERIC','','used for "_________" purposes.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('RATE_PER_METRE','','$"#.## per square metre/per hectare" Put in the decimal.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SALUTATION','','Dear "______": Type in the person’s name or Sir or Madam.',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',get_current_provision_id()); - -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'SURVEY - MINISTRY PAYS','','Use where ministry pays fro survey','OFFER SURVEY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_surveyreq()); - -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'SURVEY DEPOSIT - DEL','','Use to require payment of a deposit where Province is to pay for a survey.','OFFER SURVEY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_surveyreq()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_SURVEY_DEPOSIT','','Deadline to pay survey deposit. Enter Month, Day, Year',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEPOSIT_AMOUNT_SURVEY','','$"#.##" Enter amount of survey deposit. Put in the decimal.',get_current_provision_id()); - -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'SURVEY - CLIENT - PAYS','','Use when client pays for survey','OFFER SURVEY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_surveyreq()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_COMPLETE_SURVEY','','on or before "month day, year"',get_current_provision_id()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_CONFIRM_SURVEY','','Enter "On or before [date]" OR "Within [45] days from the date of this letter". Capitalize first character as this is the start of a sentence.',get_current_provision_id()); - -INSERT INTO nfr_provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'DELIVER SECURITY DEPOSIT (& SURVEY DEPOSIT) - NOTICE OF FINAL REVIEW','','Use this where 2 deposits are to be delivered: one for the survey and another for clean-up under the terms of the tenure to be issued','OFFER - SECURITY',true); -INSERT INTO nfr_provision_provision_variant_nfr_provision_variant ("nfrProvisionId", "nfrProvisionVariantId") VALUES (get_current_provision_id(), get_variant_surveyreq()); -INSERT INTO nfr_provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SECURITY_AMOUNT','','#.## to post as security - indicate an amount even if blanket bond applies. Put in Decimal.',get_current_provision_id()); \ No newline at end of file +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW - SURVEY REQUIRED','','require message from POLICY','DOCUMENT TYPE',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_surveyreq()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('ATTENTION_LINE','','Attention: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('CLIENT_FILE_NO','','Your file: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DATE_OF_NOTICE','','Date of letter: Month Day ,Year',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DAYS_TO_DELIVER_DOCUMENTS','','# days in the sentence: We will forward the documents to you within ___of the survey being completed.....',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DAYS_TO_RETURN_DOCUMENTS','','__ days - You must sign and return them to us within _____ of our letter to you .......',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_COMPLETION_REQUIREMENTS','','Enter the date (month day, year) for completion of requirements',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FACSIMILE_NUMBER','','Type in your facsimile number - "250 ___-____"',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('MAXIMUM_AREA','','# hectares',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('NUMBER_OF_COPIES','','three copies of tenure documents which are being forwarded to client to sign. The number should be typed as a word, not a number.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('PURPOSE_GENERIC','','used for "_________" purposes.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('RATE_PER_METRE','','$"#.## per square metre/per hectare" Put in the decimal.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SALUTATION','','Dear "______": Type in the person’s name or Sir or Madam.',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',get_current_provision_id()); + +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'SURVEY - MINISTRY PAYS','','Use where ministry pays fro survey','OFFER SURVEY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_surveyreq()); + +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'SURVEY DEPOSIT - DEL','','Use to require payment of a deposit where Province is to pay for a survey.','OFFER SURVEY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_surveyreq()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_SURVEY_DEPOSIT','','Deadline to pay survey deposit. Enter Month, Day, Year',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEPOSIT_AMOUNT_SURVEY','','$"#.##" Enter amount of survey deposit. Put in the decimal.',get_current_provision_id()); + +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'SURVEY - CLIENT - PAYS','','Use when client pays for survey','OFFER SURVEY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_surveyreq()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_COMPLETE_SURVEY','','on or before "month day, year"',get_current_provision_id()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_CONFIRM_SURVEY','','Enter "On or before [date]" OR "Within [45] days from the date of this letter". Capitalize first character as this is the start of a sentence.',get_current_provision_id()); + +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'DELIVER SECURITY DEPOSIT (& SURVEY DEPOSIT) - NOTICE OF FINAL REVIEW','','Use this where 2 deposits are to be delivered: one for the survey and another for clean-up under the terms of the tenure to be issued','OFFER - SECURITY',true); +INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_surveyreq()); +INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SECURITY_AMOUNT','','#.## to post as security - indicate an amount even if blanket bond applies. Put in Decimal.',get_current_provision_id()); \ No newline at end of file diff --git a/backend/utils/types.ts b/backend/utils/types.ts index 6e6233d8..91ca7637 100644 --- a/backend/utils/types.ts +++ b/backend/utils/types.ts @@ -2,7 +2,7 @@ * DocumentTemplate object without the base64 file. */ export type TrimmedDocumentTemplate = { - document_type?: string; + document_type_id?: number; template_version?: number; template_author?: string; active_flag?: boolean; @@ -38,7 +38,7 @@ export type SessionData = { accounts: AccountObject[]; activeAccount: AccountObject; selected_document: { - nfr_id: number; + document_id: number; }; }; diff --git a/docker-compose.yml b/docker-compose.yml index 32a4a947..9938b279 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,5 @@ --- -version: "3.8" +version: '3.8' services: database: @@ -17,9 +17,9 @@ services: backend: container_name: backend entrypoint: - - "sh" - - "-c" - - "npm i && npm run start" + - 'sh' + - '-c' + - 'npm i && npm run start' environment: NODE_ENV: development POSTGRESQL_HOST: database @@ -27,7 +27,7 @@ services: POSTGRESQL_PASSWORD: default POSTGRESQL_DATABASE: default healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:3000"] + test: ['CMD', 'curl', '-f', 'http://localhost:3000'] interval: 1m30s timeout: 10s retries: 3 @@ -37,25 +37,25 @@ services: links: - database ports: - - "3001:3000" + - '3001:3000' volumes: - ./backend:/app:z - /app/node_modules - working_dir: "/app" + working_dir: '/app' frontend: container_name: frontend entrypoint: - - "sh" - - "-c" - - "apt-get update && apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libgbm-dev && npm i && npm run start" + - 'sh' + - '-c' + - 'apt-get update && apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libgbm-dev && npm i && npm run start' environment: NODE_ENV: development backend_url: http://backend COOKIE_SECRET: asdf SESSION_SECRET: fdsa healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:3000"] + test: ['CMD', 'curl', '-f', 'http://localhost:3000'] interval: 1m30s timeout: 10s retries: 3 @@ -65,8 +65,18 @@ services: links: - backend ports: - - "3000:3000" + - '3000:3000' volumes: - ./frontend:/app:z - /app/node_modules - working_dir: "/app" + working_dir: '/app' + + flyway: + container_name: flyway + image: flyway/flyway:latest + command: + ['-url=jdbc:postgresql://database:5432/default', '-user=default', '-password=default', 'baseline', 'migrate'] + volumes: + - ./backend/db/migrations:/flyway/sql + depends_on: + - database diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 1d19ad5a..1d9b5ad2 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -28,6 +28,9 @@ "react-scripts": "5.0.1", "redux": "^5.0.1", "web-vitals": "^2.1.4" + }, + "devDependencies": { + "@babel/plugin-proposal-private-property-in-object": "^7.21.11" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -656,9 +659,17 @@ } }, "node_modules/@babel/plugin-proposal-private-property-in-object": { - "version": "7.21.0-placeholder-for-preset-env.2", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", - "integrity": "sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==", + "version": "7.21.11", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.11.tgz", + "integrity": "sha512-0QZ8qP/3RLDVBwBFoWAwCtgcDZJVwA5LUJRZU8x2YFfKNuFq161wK3cuGrALu5yiPu+vzwTAg/sMWVNeWeNyaw==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-property-in-object instead.", + "dev": true, + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-create-class-features-plugin": "^7.21.0", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5" + }, "engines": { "node": ">=6.9.0" }, @@ -1902,6 +1913,17 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/preset-env/node_modules/@babel/plugin-proposal-private-property-in-object": { + "version": "7.21.0-placeholder-for-preset-env.2", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", + "integrity": "sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==", + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/preset-env/node_modules/semver": { "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", @@ -19122,10 +19144,16 @@ } }, "@babel/plugin-proposal-private-property-in-object": { - "version": "7.21.0-placeholder-for-preset-env.2", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", - "integrity": "sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==", - "requires": {} + "version": "7.21.11", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.11.tgz", + "integrity": "sha512-0QZ8qP/3RLDVBwBFoWAwCtgcDZJVwA5LUJRZU8x2YFfKNuFq161wK3cuGrALu5yiPu+vzwTAg/sMWVNeWeNyaw==", + "dev": true, + "requires": { + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-create-class-features-plugin": "^7.21.0", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5" + } }, "@babel/plugin-syntax-async-generators": { "version": "7.8.4", @@ -19921,6 +19949,12 @@ "semver": "^6.3.1" }, "dependencies": { + "@babel/plugin-proposal-private-property-in-object": { + "version": "7.21.0-placeholder-for-preset-env.2", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", + "integrity": "sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==", + "requires": {} + }, "semver": { "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", diff --git a/frontend/public/js/manage-templates.js b/frontend/public/js/manage-templates.js index 1a181bfd..34a9a8bd 100644 --- a/frontend/public/js/manage-templates.js +++ b/frontend/public/js/manage-templates.js @@ -1,85 +1,85 @@ var documentTable; // main template upload table var groupMaxTable, provisionTable, editProvisionVariableTable; var documentTable2, documentTable3, documentTable4, documentTable5; // nfr variants -var reportType = ""; -var reportTitle = ""; -var nfrDelayed = "NOTICE OF FINAL REVIEW (DELAYED)"; -var nfrNoFees = "NOTICE OF FINAL REVIEW (NO FEES)"; -var nfrSurveyReq = "NOTICE OF FINAL REVIEW (SURVEY REQUIRED)"; -var nfrToObtain = "NOTICE OF FINAL REVIEW (TO OBTAIN SURVEY)"; +var reportType = ''; +var reportTitle = ''; +var nfrDelayed = 'NOTICE OF FINAL REVIEW (DELAYED)'; +var nfrNoFees = 'NOTICE OF FINAL REVIEW (NO FEES)'; +var nfrSurveyReq = 'NOTICE OF FINAL REVIEW (SURVEY REQUIRED)'; +var nfrToObtain = 'NOTICE OF FINAL REVIEW (TO OBTAIN SURVEY)'; $(document).ready(function () { const urlParams = new URLSearchParams(window.location.search); - const reportIndex = parseInt(urlParams.get("report")); + const reportIndex = parseInt(urlParams.get('report')); if (reportIndex != 2) { - $(".nofr-section").hide(); + $('.nofr-section').hide(); } switch (reportIndex) { case 1: - reportType = "LAND USE REPORT"; - reportTitle = "Land Use Report"; + reportType = 'LAND USE REPORT'; + reportTitle = 'Land Use Report'; break; case 2: - reportType = "NOTICE OF FINAL REVIEW"; - reportTitle = "Notice of Final Review"; + reportType = 'NOTICE OF FINAL REVIEW'; + reportTitle = 'Notice of Final Review'; break; case 3: - reportType = "GRAZING LEASE"; - reportTitle = "Grazing Lease"; + reportType = 'GRAZING LEASE'; + reportTitle = 'Grazing Lease'; break; default: break; } - $("#reportTitle").text(reportTitle); + $('#reportTitle').text(reportTitle); // used for sorting the radio buttons - $.fn.dataTable.ext.order["dom-checkbox"] = function (settings, col) { + $.fn.dataTable.ext.order['dom-checkbox'] = function (settings, col) { return this.api() - .column(col, { order: "index" }) + .column(col, { order: 'index' }) .nodes() .map(function (td, i) { - return $("input", td).prop("checked") ? "1" : "0"; + return $('input', td).prop('checked') ? '1' : '0'; }); }; - documentTable = $("#documentTable").DataTable({ + documentTable = $('#documentTable').DataTable({ ajax: { url: `admin/get-templates/${encodeURIComponent(reportType)}`, - dataSrc: "", + dataSrc: '', }, paging: true, bFilter: true, columns: [ - { data: "template_version" }, - { data: "file_name" }, - { data: "update_timestamp" }, - { data: "active_flag" }, - { data: "view" }, - { data: "remove" }, - { data: "id" }, + { data: 'template_version' }, + { data: 'file_name' }, + { data: 'update_timestamp' }, + { data: 'active_flag' }, + { data: 'view' }, + { data: 'remove' }, + { data: 'id' }, ], columnDefs: [ { targets: [0, 1, 2, 3, 4, 5, 6], render: function (data, type, row, meta) { - if (type === "display") { + if (type === 'display') { var columnTypes = [ - "template_version", - "file_name", - "update_timestamp", - "active_flag", - "view", - "remove", - "id", + 'template_version', + 'file_name', + 'update_timestamp', + 'active_flag', + 'view', + 'remove', + 'id', ]; var columnType = columnTypes[meta.col]; - var id = row["id"]; - const checked = data === true ? "checked" : ""; + var id = row['id']; + const checked = data === true ? 'checked' : ''; - if (columnType === "active_flag") { + if (columnType === 'active_flag') { return ``; - } else if (columnType === "remove") { + } else if (columnType === 'remove') { return ` - - - - - - - - {{/inline}} -{{/template}} \ No newline at end of file diff --git a/frontend_old/views/pages/index.hbs b/frontend_old/views/pages/index.hbs deleted file mode 100644 index 51bbb3e1..00000000 --- a/frontend_old/views/pages/index.hbs +++ /dev/null @@ -1,154 +0,0 @@ -{{#> template}} - {{#*inline "content"}} -
-
-
-

Preview - Land Use Report (Draft)

-
- -
DTID: {{message.dtid}}
-
Tenure File Number: {{message.tenure_file_number}}
-
Primary Contact Name: {{primaryContactName}}
- -
- Disposition Transaction ID Details - -
-
- Tenure Details - -
-
- Area - -
-
-
- -
-
-
-
- -
- - {{/inline}} -{{/template}} \ No newline at end of file diff --git a/frontend_old/views/pages/index.html b/frontend_old/views/pages/index.html deleted file mode 100644 index 29602cb3..00000000 --- a/frontend_old/views/pages/index.html +++ /dev/null @@ -1,154 +0,0 @@ - - -
-
-
-

Preview - Land Use Report (Draft)

-
- -
DTID: {message.dtid}
-
Tenure File Number: {message.tenure_file_number}
-
Primary Contact Name: {primaryContactName}
- -
- Disposition Transaction ID Details - -
-
- Tenure Details - -
-
- Area - -
-
-
- -
-
-
-
- -
- - - \ No newline at end of file diff --git a/frontend_old/views/pages/manage-templates.hbs b/frontend_old/views/pages/manage-templates.hbs deleted file mode 100644 index b01f96ed..00000000 --- a/frontend_old/views/pages/manage-templates.hbs +++ /dev/null @@ -1,513 +0,0 @@ -{{#> template}} - {{#*inline "content"}} -
-
-

Manage Templates

-
- -
- - -
-
- Notice of Final Review (Delayed) - -
-
- Notice of Final Review (No Fees) - -
-
- Notice of Final Review (Survey Required) - -
-
- Notice of Final Review (To Obtain Survey) - -
-
- Manage NFR Provisions - -
-
-
-
-
- - - - - -
-
- - {{/inline}} -{{/template}} \ No newline at end of file diff --git a/frontend_old/views/pages/nfr.hbs b/frontend_old/views/pages/nfr.hbs deleted file mode 100644 index de383ae6..00000000 --- a/frontend_old/views/pages/nfr.hbs +++ /dev/null @@ -1,190 +0,0 @@ -{{#> template}} - {{#*inline "content"}} -
-
-
-

Preview - Notice of Final Review

-
-
-
-

Select an NFR Variant

-
-
- -
-
-
- -
DTID: {{message.dtid}}
-
Tenure File Number: {{message.fileNum}}
-
Primary Contact Name: {{primaryContactName}}
- -
- Disposition Transaction ID Details - -
-
- Tenure Details - -
-
- Interested Parties - -
-
- Provisions - -
-
- Variables - -
- -
-
-
-
- -
-
- -
-
-
-
- -
-
-
-
-
-
-
- - - -
- - - {{/inline}} -{{/template}} \ No newline at end of file diff --git a/frontend_old/views/pages/search.hbs b/frontend_old/views/pages/search.hbs deleted file mode 100644 index 6fd74a08..00000000 --- a/frontend_old/views/pages/search.hbs +++ /dev/null @@ -1,181 +0,0 @@ -{{#> template}} - {{#*inline "content"}} -
-
-

{{title}}

-
-
-
- - - - - - - - {{!-- Active --}} - {{!-- NFR_ID --}} - {{!-- variant_name --}} - - - - -
DTIDDoc No.Template NameUploaded DateStatus
-
-
-
-
- -
-
-
-
- - - {{/inline}} -{{/template}} \ No newline at end of file diff --git a/frontend_old/views/pages/system-admin.hbs b/frontend_old/views/pages/system-admin.hbs deleted file mode 100644 index 9ac3347e..00000000 --- a/frontend_old/views/pages/system-admin.hbs +++ /dev/null @@ -1,422 +0,0 @@ -{{#> template}} - {{#*inline "content"}} -
-
-

System Administration

-
-
-

List of TICDI Administrators

-
- {{!--
-
- -
-
- -
-
--}} - {{!--
--}} -
-
- - - - - - - - - -
NameUser NameEmail
-
-
-
-
-
- -
-
- -
-
-
-
-

Manage Templates

-
- {{!--
--}} -
-

Select a Template:

-
-
-
- -
-
- -
-
-
- - -
- - {{/inline}} -{{/template}} \ No newline at end of file diff --git a/frontend_old/views/partials/footer.hbs b/frontend_old/views/partials/footer.hbs deleted file mode 100644 index c479fe99..00000000 --- a/frontend_old/views/partials/footer.hbs +++ /dev/null @@ -1,45 +0,0 @@ - \ No newline at end of file diff --git a/frontend_old/views/partials/navbar.hbs b/frontend_old/views/partials/navbar.hbs deleted file mode 100644 index bed2dad0..00000000 --- a/frontend_old/views/partials/navbar.hbs +++ /dev/null @@ -1,55 +0,0 @@ -
- -
\ No newline at end of file diff --git a/frontend_old/views/partials/scripts.hbs b/frontend_old/views/partials/scripts.hbs deleted file mode 100644 index fce242c5..00000000 --- a/frontend_old/views/partials/scripts.hbs +++ /dev/null @@ -1,13 +0,0 @@ - - - - \ No newline at end of file diff --git a/frontend_old/views/partials/style.hbs b/frontend_old/views/partials/style.hbs deleted file mode 100644 index 01d78033..00000000 --- a/frontend_old/views/partials/style.hbs +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - -{{! }} - - - - - - - - - - - - - - - \ No newline at end of file From cf69bc8762865cca246805dab9d9559316abb54e Mon Sep 17 00:00:00 2001 From: mgtennant <100305096+mgtennant@users.noreply.github.com> Date: Wed, 13 Mar 2024 20:35:40 -0700 Subject: [PATCH 2/7] updating routes --- backend/src/admin/admin.controller.ts | 31 ++-- backend/src/admin/admin.service.ts | 151 +++++------------- backend/src/main.ts | 2 +- backend/src/provision/provision.controller.ts | 6 +- backend/src/provision/provision.service.ts | 21 +-- frontend/src/app/common/manage-templates.ts | 8 +- frontend/src/app/common/report.ts | 2 + 7 files changed, 81 insertions(+), 140 deletions(-) diff --git a/backend/src/admin/admin.controller.ts b/backend/src/admin/admin.controller.ts index 09e9f4b9..b4b3b58e 100644 --- a/backend/src/admin/admin.controller.ts +++ b/backend/src/admin/admin.controller.ts @@ -43,11 +43,11 @@ export class AdminController { }; } - @Get('activate-template/:id/:document_type') + @Get('activate-template/:id/:document_type_id') async activateTemplate( @Session() session: { data?: SessionData }, - @Param('id') id, - @Param('document_type') document_type + @Param('id') id: number, + @Param('document_type_id') document_type_id: number ) { const update_userid = session?.data?.activeAccount ? session.data.activeAccount.idir_username @@ -57,7 +57,7 @@ export class AdminController { return this.adminService.activateTemplate({ id: id, update_userid: update_userid, - document_type: document_type, + document_type_id: document_type_id, }); } @@ -75,9 +75,9 @@ export class AdminController { streamableFile.pipe(res); } - @Get('remove-template/:reportType/:id') - async removeTemplate(@Param('reportType') reportType: string, @Param('id') id: number) { - return this.adminService.removeTemplate(reportType, id); + @Get('remove-template/:id/:document_type_id') + async removeTemplate(@Param('id') id: number, @Param('document_type_id') document_type_id: number) { + return this.adminService.removeTemplate(document_type_id, id); } @Post('upload-template') @@ -188,19 +188,19 @@ export class AdminController { session.data.selected_document = { document_id: documentId }; } - @Get('get-templates/:document_type') - getDocumentTemplates(@Param('document_type') documentType: string): any { - return this.adminService.getDocumentTemplates(documentType); + @Get('get-templates/:document_type_id') + getDocumentTemplates(@Param('document_type_id') document_type_id: number): any { + return this.adminService.getDocumentTemplates(document_type_id); } @Get('provisions') - getNFRProvisions(): any { - return this.adminService.getNFRProvisions(); + getDocumentProvisions(): any { + return this.adminService.getDocumentProvisions(); } @Get('document-variables') - getNFRVariables(): any { - return this.adminService.getNFRVariables(); + getDocumentVariables(): any { + return this.adminService.getDocumentVariables(); } @Get('enable-provision/:provisionId') @@ -278,6 +278,7 @@ export class AdminController { updateVariable( @Body() variableParams: { + id: number; variable_name: string; variable_value: string; help_text: string; @@ -286,7 +287,7 @@ export class AdminController { @Session() session: { data?: SessionData } ) { const update_userid = session?.data?.activeAccount.idir_username; - return this.adminService.updateVariable(variableParams, update_userid); + return this.adminService.updateVariable({ ...variableParams, update_userid }); } @Get('remove-variable/:id') diff --git a/backend/src/admin/admin.service.ts b/backend/src/admin/admin.service.ts index b2afe4c2..81735956 100644 --- a/backend/src/admin/admin.service.ts +++ b/backend/src/admin/admin.service.ts @@ -5,6 +5,7 @@ import { ExportDataObject, SearchResultsItem, UserObject } from 'utils/types'; import { REPORT_TYPES } from 'utils/constants'; import { DocumentTemplateService } from 'src/document_template/document_template.service'; import { DocumentType } from 'src/document_type/entities/document_type.entity'; +import { ProvisionService } from 'src/provision/provision.service'; const axios = require('axios'); const FormData = require('form-data'); @@ -16,38 +17,24 @@ let port: number; export class AdminService { constructor( private readonly httpService: HttpService, - private readonly documentTemplateService: DocumentTemplateService + private readonly documentTemplateService: DocumentTemplateService, + private readonly provisionService: ProvisionService ) { hostname = process.env.backend_url ? process.env.backend_url : `http://localhost`; // local development backend port is 3001, docker backend port is 3000 port = process.env.backend_url ? 3000 : 3001; } - async activateTemplate(data: { id: number; update_userid: string; document_type: string }): Promise { - const url = `${hostname}:${port}/document-template/activate-template`; - return axios - .post(url, { - id: data.id, - update_userid: data.update_userid, - document_type: data.document_type, - }) - .then((res) => { - return res.data; - }); + activateTemplate(data: { id: number; update_userid: string; document_type_id: number }): Promise { + return this.documentTemplateService.activateTemplate(data); } - async downloadTemplate(id: number) { - const url = `${hostname}:${port}/document-template/find-one/${id}`; - return axios.get(url).then((res) => { - return res.data; - }); + downloadTemplate(id: number) { + return this.documentTemplateService.findOne(id); } - async removeTemplate(reportType: string, id: number): Promise { - const url = `${hostname}:${port}/document-template/remove/${encodeURI(reportType)}/${id}`; - return axios.get(url).then((res) => { - return res.data; - }); + removeTemplate(document_type_id: number, id: number): Promise { + return this.documentTemplateService.remove(document_type_id, id); } async uploadTemplate( @@ -274,15 +261,8 @@ export class AdminService { return { message: 'error' }; } - async getTemplates(reportId: number) { - const documentType = reportId == 1 || reportId == 2 ? REPORT_TYPES[reportId - 1] : 'none'; - const url = `${hostname}:${port}/document-template/${encodeURI(documentType)}`; - const data = await axios - .get(url) - .then((res) => { - return res.data; - }) - .catch((err) => console.log(err.response.data)); + async getTemplates(document_type_id: number) { + const data = await this.documentTemplateService.findAll(document_type_id); let documents: { version: number; file_name: string; @@ -295,7 +275,7 @@ export class AdminService { const document = { version: entry.template_version, file_name: entry.file_name, - updated_date: entry.update_timestamp.split('T')[0], + updated_date: entry.update_timestamp.toString().split('T')[0], status: '???', active: entry.active_flag, template_id: entry.id, @@ -305,21 +285,15 @@ export class AdminService { return documents; } - async getDocumentTemplates(documentType: string): Promise { + async getDocumentTemplates(document_type_id: number): Promise { const returnItems = ['id', 'template_version', 'file_name', 'uploaded_date', 'active_flag', 'update_timestamp']; - const url = `${hostname}:${port}/document-template/${encodeURI(documentType)}`; - const documentTemplateObjects = await axios - .get(url) - .then((res) => { - return res.data; - }) - .catch((err) => console.log(err.response.data)); + const documentTemplateObjects = await this.documentTemplateService.findAll(document_type_id); return documentTemplateObjects.map((obj) => Object.keys(obj) .filter((key) => returnItems.includes(key)) .reduce( (acc, key) => { - key == 'update_timestamp' ? (acc[key] = obj[key].split('T')[0]) : (acc[key] = obj[key]); + key == 'update_timestamp' ? (acc[key] = obj[key].toString().split('T')[0]) : (acc[key] = obj[key]); return acc; }, { view: 'view', remove: 'remove' } @@ -327,7 +301,7 @@ export class AdminService { ); } - async getNFRProvisions(): Promise { + async getDocumentProvisions(): Promise { const returnItems = [ 'id', 'dtid', @@ -341,14 +315,8 @@ export class AdminService { 'active_flag', 'variants', ]; - const url = `${hostname}:${port}/provision`; - const nfrProvisions = await axios - .get(url) - .then((res) => { - return res.data; - }) - .catch((err) => console.log(err.response.data)); - return nfrProvisions.map((obj) => + const documentProvisions = await this.provisionService.findAll(); + return documentProvisions.map((obj) => Object.keys(obj) .filter((key) => returnItems.includes(key)) .reduce( @@ -361,16 +329,10 @@ export class AdminService { ); } - async getNFRVariables(): Promise { + async getDocumentVariables(): Promise { const returnItems = ['variable_name', 'variable_value', 'help_text', 'id', 'provision_id']; - const url = `${hostname}:${port}/provision/variables`; - const nfrVariables = await axios - .get(url) - .then((res) => { - return res.data; - }) - .catch((err) => console.log(err.response.data)); - return nfrVariables.map((obj) => + const documentVariables = await this.provisionService.findAllVariables(); + return documentVariables.map((obj) => Object.keys(obj) .filter((key) => returnItems.includes(key)) .reduce( @@ -383,28 +345,19 @@ export class AdminService { ); } - async enableProvision(id: number): Promise { - const url = `${hostname}:${port}/provision/enable/${id}`; - return await axios.get(url).then((res) => { - return res.data; - }); + enableProvision(id: number): Promise { + return this.provisionService.enable(id); } - async disableProvision(id: number): Promise { - const url = `${hostname}:${port}/provision/disable/${id}`; - return await axios.get(url).then((res) => { - return res.data; - }); + disableProvision(id: number): Promise { + return this.provisionService.disable(id); } - async getGroupMax(): Promise { - const url = `${hostname}:${port}/provision/get-group-max/1`; - return await axios.get(url).then((res) => { - return res.data; - }); + getGroupMax(): Promise { + return this.provisionService.getGroupMax(); } - async addProvision( + addProvision( provisionParams: { type: string; provision_group: number; @@ -418,13 +371,10 @@ export class AdminService { }, create_userid: string ) { - const url = `${hostname}:${port}/provision`; - return await axios.post(url, { ...provisionParams, create_userid }).then((res) => { - return res.data; - }); + return this.provisionService.create({ ...provisionParams, create_userid }); } - async updateProvision( + updateProvision( provisionParams: { id: number; type: string; @@ -439,13 +389,10 @@ export class AdminService { }, update_userid: string ) { - const url = `${hostname}:${port}/provision/update`; - return await axios.post(url, { ...provisionParams, update_userid }).then((res) => { - return res.data; - }); + return this.provisionService.update(provisionParams.id, { ...provisionParams, update_userid }); } - async addVariable( + addVariable( variableParams: { variable_name: string; variable_value: string; @@ -454,32 +401,22 @@ export class AdminService { }, create_userid: string ) { - const url = `${hostname}:${port}/provision/add-variable`; - return await axios.post(url, { ...variableParams, create_userid }).then((res) => { - return res.data; - }); + return this.provisionService.addVariable({ ...variableParams, create_userid }); } - async updateVariable( - variableParams: { - variable_name: string; - variable_value: string; - help_text: string; - provision_id: number; - }, - update_userid: string - ) { - const url = `${hostname}:${port}/provision/update-variable`; - return await axios.post(url, { ...variableParams, update_userid }).then((res) => { - return res.data; - }); + async updateVariable(variableParams: { + id: number; + variable_name: string; + variable_value: string; + help_text: string; + provision_id: number; + update_userid: string; + }) { + return this.provisionService.updateVariable(variableParams); } - async removeVariable(id: number) { - const url = `${hostname}:${port}/provision/remove-variable/${id}`; - return await axios.get(url).then((res) => { - return res.data; - }); + removeVariable(id: number) { + return this.provisionService.removeVariable(id); } /** diff --git a/backend/src/main.ts b/backend/src/main.ts index 8dddd1e6..c0dcef8a 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -20,7 +20,7 @@ async function bootstrap() { const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api', app, document); const appService = app.get(AppService); - await appService.initializeDb(); + // await appService.initializeDb(); await app.listen(3001); } diff --git a/backend/src/provision/provision.controller.ts b/backend/src/provision/provision.controller.ts index 1cb1509f..b213f6b5 100644 --- a/backend/src/provision/provision.controller.ts +++ b/backend/src/provision/provision.controller.ts @@ -29,6 +29,7 @@ export class ProvisionController { variable_value: string; help_text: string; provision_id: number; + create_userid: string; } ) { return this.provisionService.addVariable(variable); @@ -43,11 +44,10 @@ export class ProvisionController { help_text: string; provision_id: number; id: number; + update_userid: string; } ) { - const id = variable.id; - delete variable['id']; - return this.provisionService.updateVariable(id, variable); + return this.provisionService.updateVariable(variable); } @Get('remove-variable/:id') diff --git a/backend/src/provision/provision.service.ts b/backend/src/provision/provision.service.ts index 119c21d3..cd77525f 100644 --- a/backend/src/provision/provision.service.ts +++ b/backend/src/provision/provision.service.ts @@ -74,6 +74,7 @@ export class ProvisionService { variable_value: string; help_text: string; provision_id: number; + create_userid: string; }) { const provision = await this.findById(variable.provision_id); delete variable['provision_id']; @@ -84,19 +85,18 @@ export class ProvisionService { return this.provisionVariableRepository.save(newVariable); } - async updateVariable( - id: number, - variable: { - variable_name: string; - variable_value: string; - help_text: string; - provision_id: number; - } - ) { + async updateVariable(variable: { + id: number; + variable_name: string; + variable_value: string; + help_text: string; + provision_id: number; + update_userid: string; + }) { const provision = await this.findById(variable.provision_id); delete variable['provision_id']; const variableToUpdate = await this.provisionVariableRepository.findOne({ - where: { id: id }, + where: { id: variable.id }, }); if (!variableToUpdate) { @@ -106,6 +106,7 @@ export class ProvisionService { variableToUpdate.variable_value = variable.variable_value; variableToUpdate.help_text = variable.help_text; variableToUpdate.provision = provision; + variableToUpdate.update_userid = variable.update_userid; return this.provisionVariableRepository.save(variableToUpdate); } diff --git a/frontend/src/app/common/manage-templates.ts b/frontend/src/app/common/manage-templates.ts index ead64f87..3c6b977c 100644 --- a/frontend/src/app/common/manage-templates.ts +++ b/frontend/src/app/common/manage-templates.ts @@ -61,16 +61,16 @@ export const downloadTemplate = async (id: number, fileName: string): Promise => { - const url = `${config.API_BASE_URL}/admin/remove-template/${reportType}/${id}`; +export const removeTemplate = async (id: number, document_template_id: number): Promise => { + const url = `${config.API_BASE_URL}/admin/remove-template/${id}/${document_template_id}`; const getParameters = api.generateApiParameters(url); const response = await api.get(getParameters); console.log('removeTemplate response'); console.log(response); }; -export const activateTemplate = async (id: number, variantType: string): Promise => { - const url = `${config.API_BASE_URL}/admin/activate-template/${id}/${variantType}`; +export const activateTemplate = async (id: number, document_template_id: string): Promise => { + const url = `${config.API_BASE_URL}/admin/activate-template/${id}/${document_template_id}`; const getParameters = api.generateApiParameters(url); await api.get(getParameters); }; diff --git a/frontend/src/app/common/report.ts b/frontend/src/app/common/report.ts index 5330752b..4857b363 100644 --- a/frontend/src/app/common/report.ts +++ b/frontend/src/app/common/report.ts @@ -103,6 +103,7 @@ export const saveDocument = async ( await api.post(postParameters); }; +// TODO stop using NFR export const generateNfrReport = async ( dtid: number, fileNum: string, @@ -128,6 +129,7 @@ export const generateNfrReport = async ( export const getDocumentTypes = () => { const url = `${config.API_BASE_URL}/report/get-document-types`; + console.log(url); const getParameters = api.generateApiParameters(url); return api.get(getParameters); }; From 678e338cec4caa237f6d209eee44e628da9e3251 Mon Sep 17 00:00:00 2001 From: mgtennant <100305096+mgtennant@users.noreply.github.com> Date: Thu, 14 Mar 2024 10:25:24 -0700 Subject: [PATCH 3/7] remove old js files --- frontend/public/js/nfr.js | 655 ------------------------------------- frontend/public/js/util.js | 52 --- 2 files changed, 707 deletions(-) delete mode 100644 frontend/public/js/nfr.js delete mode 100644 frontend/public/js/util.js diff --git a/frontend/public/js/nfr.js b/frontend/public/js/nfr.js deleted file mode 100644 index 7b78c86f..00000000 --- a/frontend/public/js/nfr.js +++ /dev/null @@ -1,655 +0,0 @@ -const dtid = +$('#dtid').text(); -let preloadedProvisions = false; -let preloadedSelected = false; -let preloadedVariables = false; -let reloadingTables = false; -const groupMaxJsonInput = document.getElementById('groupMaxJson'); -let groupMaxJsonArray = JSON.parse(groupMaxJsonInput.value); -groupMaxJsonArray = JSON.parse(groupMaxJsonArray); -let defaultGroup = 0; -if (Array.isArray(groupMaxJsonArray) && groupMaxJsonArray.length > 0) { - defaultGroup = groupMaxJsonArray.reduce((acc, curr) => - acc.provision_group < curr.provision_group ? acc : curr - ).provision_group; -} -let groupMaxTable; -let provisionTable, variableTable, selectedProvisionsTable; - -const nfrDataId = $('#nfrDataId').val(); -$('.dataSection dd').each(function () { - if ($(this).text() == '' || $(this).text() == 'TBD') { - if ($(this).attr('id') == 'address2' || $(this).attr('id') == 'address3') { - $(this).hide(); - } - $(this).text(' '); - $(this).css('border', 'solid 1px orange'); - } -}); - -$('.legalDesc').each(function () { - if ($(this).text().length > 2000) { - $(this).text($(this).text().substr(0, 2000) + '...'); - } -}); -if ($('#adminLink').text() == '-') { - $('#adminLink').hide(); - $('#adminLink').text(''); -} -groupMaxTable = $('#groupMaxTable').DataTable({ - ajax: { - url: `${window.location.origin}/report/get-group-max/${variantName}`, - dataSrc: '', - }, - columns: [ - { data: 'provision_group', title: 'Group' }, - { data: 'max', title: 'Max' }, - { data: 'provision_group_text', title: 'Group Text' }, - ], - order: [0, 'asc'], -}); - -provisionTable = $('#provisionTable').DataTable({ - ajax: { - url: `${window.location.origin}/report/provisions/${encodeURI(variantName)}/-1`, - dataSrc: '', - }, - paging: false, - info: false, - bFilter: false, - columns: [ - { data: 'type' }, - { data: 'provision_name' }, - { data: 'help_text' }, - { data: 'select' }, - { data: 'provision_group' }, - { data: 'max' }, - { data: 'id' }, - { data: 'free_text' }, - ], - columnDefs: [ - { - targets: [0, 1, 2, 3, 4, 5, 6, 7], - render: function (data, type, row, meta) { - if (type === 'display') { - var columnTypes = [ - 'type', - 'provision_name', - 'help_text', - 'select', - 'provision_group', - 'max', - 'id', - 'free_text', - ]; - var columnType = columnTypes[meta.col]; - var id = row['id']; - var group = row['provision_group']; - var max = row['max']; - var mandatory = row['type'] == 'M' ? true : false; - var provisionName = row['provision_name']; - var xor = - provisionName == 'MONIES PAYABLE - NOTICE OF FINAL REVIEW - DELAYED' || - provisionName == 'ESTIMATED MONIES PAYABLE - NOTICE OF FINAL REVIEW - DELAYED' - ? 1 - : 0; - - if (columnType === 'select') { - const checked = enabledProvisions.includes(id) === true ? 'checked' : ''; - return ``; - } else if (columnType === 'max' || columnType === 'id' || columnType === 'free_text') { - return ``; - } else if (columnType === 'help_text') { - return ``; - } else if (columnType === 'provision_group') { - return ``; - } else { - return ``; - } - } else { - return data; - } - }, - }, - { - targets: 3, - className: 'text-center', - orderDataType: 'dom-checkbox', - }, - { - targets: [0, 1, 2, 3, 4, 5, 6, 7], - orderable: false, - }, - ], - rowCallback: function (row, data, index) { - $(row).attr('data-id', data.id); - if (!enabledProvisions.includes(data.id) && (!preloadedProvisions || reloadingTables)) { - $(row).hide(); - } - }, - drawCallback: function (settings) { - // add event listeners to the provision checkboxes - const checkboxes = document.querySelectorAll('input[type="checkbox"]'); - if (checkboxes.length > 0) { - checkboxes.forEach((checkbox) => { - checkbox.addEventListener('click', function () { - const group = checkbox.dataset.group; - const max = checkbox.dataset.max; - const id = checkbox.dataset.id; - const xor = checkbox.dataset.xor; - const active = document.querySelectorAll(`input[type="checkbox"][data-group="${group}"]:checked`).length; - if (active >= max) { - document - .querySelectorAll(`input[type="checkbox"][data-group="${group}"]:not(:checked)`) - .forEach((checkbox) => { - checkbox.disabled = true; - }); - } else { - document - .querySelectorAll(`input[type="checkbox"][data-group="${group}"]:not(:checked)`) - .forEach((checkbox) => { - checkbox.disabled = false; - }); - } - if (checkbox.checked) { - $(`#selected-provision-row-${id}`).show(); - $(`.variable-provision-row-${id}`).show(); - if (xor != 0) { - // disable the checkboxes that have the same xor - document - .querySelectorAll( - `input[type="checkbox"][data-group="${group}"][data-xor="${xor}"]:not(#${checkbox.id})` - ) - .forEach((checkbox) => { - checkbox.disabled = true; - }); - } - } else { - $(`#selected-provision-row-${id}`).hide(); - $(`.variable-provision-row-${id}`).hide(); - if (xor != 0) { - // enable the checkboxes that have the same xor - document - .querySelectorAll( - `input[type="checkbox"][data-group="${group}"][data-xor="${xor}"]:not(#${checkbox.id})` - ) - .forEach((checkbox) => { - checkbox.disabled = false; - }); - } - } - }); - const grp = checkbox.dataset.group; - const mx = checkbox.dataset.max; - const act = document.querySelectorAll(`input[type="checkbox"][data-group="${grp}"]:checked`).length; - if (act >= mx) { - document.querySelectorAll(`input[type="checkbox"][data-group="${grp}"]:not(:checked)`).forEach((checkbox) => { - checkbox.disabled = true; - }); - } - }); - } - if (reloadingTables) { - // reloadingTables will be false for preload and true after the user changes the dropdown select - const gmUrl = `${window.location.origin}/report/get-group-max/${variantName}`; - const spUrl = `${window.location.origin}/report/provisions/${encodeURI(variantName)}/${dtid}`; - const vUrl = `${window.location.origin}/report/get-provision-variables/${encodeURI(variantName)}/${dtid}`; - fetch(`/report/get-group-max/${variantName}`) - .then((res) => { - return res.json(); - }) - .then((resJson) => { - groupMaxJsonArray = resJson; - updateGroupSelect(groupMaxJsonArray); - groupMaxTable.ajax.url(gmUrl).load(); - groupMaxTable.draw(); - selectedProvisionsTable.ajax.url(spUrl).load(); - selectedProvisionsTable.draw(); - variableTable.ajax.url(vUrl).load(); - variableTable.draw(); - }); - } - }, - initComplete: function (settings, json) { - preloadedProvisions = true; - }, - order: [[1, 'asc']], -}); - -let selectedProvisionsUrl = `${window.location.origin}/report/provisions/${encodeURI(variantName)}/${dtid}`; -selectedProvisionsTable = $('#selectedProvisionsTable').DataTable({ - ajax: { - url: selectedProvisionsUrl, - dataSrc: '', - }, - paging: false, - info: false, - bFilter: false, - rowId: function (data) { - return `selected-provision-row-${data.id}`; - }, - columns: [ - { data: 'type' }, - { data: 'provision_group' }, - { data: 'provision_name' }, - { data: 'category' }, - { data: 'free_text' }, - { data: 'max' }, - { data: 'id' }, - ], - columnDefs: [ - { - targets: [0, 1, 2, 3, 4, 5, 6], - render: function (data, type, row, meta) { - if (type === 'display') { - var columnTypes = ['type', 'provision_group', 'provision_name', 'category', 'free_text', 'max', 'id']; - var columnType = columnTypes[meta.col]; - var id = row['id']; - - if (columnType === 'max' || columnType === 'id') { - return ``; - } else if (columnType === 'free_text') { - return ``; - } else if (columnType === 'provision_name') { - return ``; - } else { - return ``; - } - } else { - return data; - } - }, - }, - { - targets: [0, 1, 2, 3, 4, 5, 6], - orderable: false, - }, - ], - order: [[1, 'asc']], - rowCallback: function (row, data) { - $(row).attr('data-id', data.id); - if (!enabledProvisions.includes(data.id) && (!preloadedSelected || reloadingTables)) { - $(row).hide(); - } - }, - initComplete: function (settings, json) { - preloadedSelected = true; - }, -}); - -let variablesUrl = `${window.location.origin}/report/get-provision-variables/${encodeURI(variantName)}/${dtid}`; -variableTable = $('#variableTable').DataTable({ - ajax: { - url: variablesUrl, - dataSrc: '', - }, - paging: false, - info: false, - bFilter: false, - columns: [ - { data: 'variable_name' }, - { data: 'variable_value' }, - { data: 'help_text' }, - { data: 'id' }, - { data: 'provisionId' }, - ], - columnDefs: [ - { - targets: [0, 1, 2, 3, 4], - render: function (data, type, row, meta) { - if (type === 'display') { - var columnTypes = ['variable_name', 'variable_value', 'help_text', 'id', 'provisionId']; - var columnType = columnTypes[meta.col]; - var id = row['id']; - - if (columnType === 'id' || columnType === 'provisionId') { - return ``; - } else if (columnType === 'variable_value') { - return ``; - } else if (columnType === 'help_text') { - return ``; - } else { - return ``; - } - } else { - return data; - } - }, - orderable: false, - }, - ], - rowCallback: function (row, data, index) { - $(row).addClass(`variable-provision-row-${data.provisionId}`); - $(row).attr('data-id', data.provisionId); - $(row).attr('data-variable_id', data.id); - if (!enabledProvisions.includes(data.provisionId) && (!preloadedVariables || reloadingTables)) { - $(row).hide(); - } - }, - initComplete: function (settings, json) { - preloadedVariables = true; - }, - order: [[0, 'asc']], -}); - -// Don't reload the page when Save For Later button is clicked -document.querySelector('#saveNfr').addEventListener('click', function (event) { - event.preventDefault(); -}); - -// When the selected variant changes, the tables need to be reloaded and -// mandatory and enabled provisions need to be fetched -$('#documentVariantId').on('change', function () { - variantName = $(this).val(); - reloadingTables = true; - const pUrl = `${window.location.origin}/report/provisions/${encodeURI(variantName)}/-1`; - fetch(`/report/enabled-provisions/${encodeURI(variantName)}`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, - responseType: 'application/json', - }) - .then((res) => res.json()) - .then((newMandatoryProvisions) => { - mandatoryProvisions = newMandatoryProvisions; - fetch(`/report/enabled-provisions2/${encodeURI(variantName)}/${dtid}`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, - responseType: 'application/json', - }) - .then((res) => res.json()) - .then((newEnabledProvisions) => { - enabledProvisions = newEnabledProvisions; - }) - .then(() => { - provisionTable.ajax.url(pUrl).load(); - }); - }); -}); - -// event listener for the Select A Group dropdown -$('#group-select').on('change', function () { - const selectedGroup = $(this).val(); - if (selectedGroup != 0) { - const selectedOption = $(this).find('option:selected'); - selectedOption.addClass('viewed'); - provisionTable.rows().every(function () { - const provisionGroup = this.data().provision_group; - if (selectedGroup == '' || provisionGroup == selectedGroup) { - $(this.node()).show(); - } else { - $(this.node()).hide(); - } - }); - if (Array.isArray(groupMaxJsonArray) && groupMaxJsonArray.length > 0) { - const groupMax = groupMaxJsonArray.find((element) => element.provision_group == selectedGroup).max; - const groupMaxText = groupMax == 999 ? '' : 'Max for this Group is ' + groupMax; - $('#maxGroupNum').text(groupMaxText); - } - } else { - $('#maxGroupNum').text(''); - provisionTable.rows().every(function () { - $(this.node()).hide(); - }); - } -}); - -function filterRows() { - const selectedGroup = $('#group-select').val(); - if (selectedGroup != 0 && Array.isArray(groupMaxJsonArray) && groupMaxJsonArray.length > 0) { - const groupMax = groupMaxJsonArray.find((element) => element.provision_group == selectedGroup).max; - const groupMaxText = groupMax == 999 ? '' : 'Max for this Group is ' + groupMax; - $('#maxGroupNum').text(groupMaxText); - provisionTable.rows().every(function () { - const provisionGroup = this.data().provision_group; - if (selectedGroup == '' || provisionGroup == selectedGroup) { - $(this.node()).show(); - } else { - $(this.node()).hide(); - } - }); - } else { - $('#maxGroupNum').text(''); - provisionTable.rows().every(function () { - $(this.node()).hide(); - }); - } -} - -$('#provisionLegend').click(function () { - filterRows(); -}); - -// collapsible sections -$('fieldset legend').click(function () { - $(this).parent().find('.contents').toggle(); - if ($('.fa', this).hasClass('fa-plus')) { - $('.fa', this).removeClass('fa-plus').addClass('fa-minus'); - } else { - $('.fa', this).removeClass('fa-minus').addClass('fa-plus'); - } -}); - -function saveForLater() { - // get the provisions that the user has selected - const savedMsg = document.getElementById('savedMsg'); - const saveBtn = document.getElementById('saveNfr'); - saveBtn.disabled = true; - - const dtid = $('#dtid').text(); - if (dtid != '') { - let provisionArray = []; - let variableArray = []; - selectedProvisionsTable - .rows() - .nodes() - .each((row) => { - if ($(row).css('display') !== 'none') { - const provision_id = $(row).data('id'); - const free_text = $(row).find('.free_text').val(); - provisionArray.push({ - provision_id: provision_id, - free_text: free_text, - }); - } - }); - variableTable - .rows() - .nodes() - .each((row) => { - if ($(row).css('display') !== 'none') { - const provision_id = $(row).data('id'); - const variable_id = $(row).data('variable_id'); - const variable_value = $(row).find('.variable_value').val(); - variableArray.push({ - provision_id: provision_id, - variable_id: variable_id, - variable_value: variable_value, - }); - } - }); - const data = { - dtid: dtid, - variant_name: variantName, - status: 'In Progress', - provisionArray: provisionArray, - variableArray: variableArray, - }; - fetch(`${window.location.origin}/report/save-nfr`, { - method: 'POST', - body: JSON.stringify(data), - headers: { - 'Content-Type': 'application/json', - }, - }).catch((err) => { - console.log(err); - saveBtn.disabled = false; - }); - savedMsg.style.display = 'block'; - $(savedMsg).fadeIn('fast'); - setTimeout(function () { - $(savedMsg).fadeOut('slow', function () { - // enable the Save For Later button after the saved message div is faded out - saveBtn.disabled = false; - }); - }, 2000); - } -} - -async function generateNFRReport() { - const tenureFileNumber = $('#tfn').text(); - const dtid = $('#dtid').text(); - const unselectedMandatoryGroups = []; - // Check that all mandatory provisions have been selected - $('#provisionTable') - .find('tbody tr') - .each(function () { - var isMandatory = $(this).find('.provisionSelect').data('mandatory'); - var xor = $(this).find('.provisionSelect').data('xor'); - var provisionGroup = $(this).find('.provisionGroupValue').val(); - if (isMandatory === true) { - var provisionSelect = $(this).find('.provisionSelect').prop('checked'); - if (!provisionSelect && xor != 0) { - // Check if any other provision with the same XOR value is selected - var otherSelected = $(`input[data-xor="${xor}"][data-mandatory="true"]:checked`).length > 0; - if (!otherSelected) { - unselectedMandatoryGroups.push(provisionGroup); - } - } else if (!provisionSelect) { - unselectedMandatoryGroups.push(provisionGroup); - } - } - }); - if (unselectedMandatoryGroups.length == 0) { - $('#genReport').prop('disabled', true); - const reportName = await fetch(`/report/get-nfr-report-name/${dtid}/${tenureFileNumber}`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, - responseType: 'application/json', - }) - .then((res) => res.json()) - .then((resJson) => { - return resJson.reportName; - }) - .catch(() => { - location.reload(); - }); - - const provisionIds = getEnabledProvisionIds(); - const provisionJson = getProvisionJson(provisionIds); - const variableJson = getVariableJson(provisionIds); - const data = { - dtid: dtid, - variantName: variantName, - provisionJson: provisionJson, - variableJson: variableJson, - }; - fetch(`/report/generate-nfr-report`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - responseType: 'application/json', - body: JSON.stringify(data), - }) - .then((res) => res.blob()) - .then((blob) => { - const url = window.URL.createObjectURL(blob); - const a = document.createElement('a'); - a.style.display = 'none'; - a.href = url; - a.download = reportName + '.docx'; - document.body.appendChild(a); - a.click(); - window.URL.revokeObjectURL(url); - $('#genReport').prop('disabled', false); - }) - .catch(() => { - location.reload(); - $('#genReport').prop('disabled', false); - }); - } else { - const uniqueProvisionGroups = [...new Set(unselectedMandatoryGroups)].sort((a, b) => a - b); - alert('There are unselected mandatory provisions the following groups: ' + uniqueProvisionGroups.join(', ')); - } -} - -function getEnabledProvisionIds() { - let provisionIds = []; - $('#provisionTable') - .find('.provisionSelect:checked') - .each(function () { - provisionIds.push($(this).data('id')); - }); - return provisionIds; -} - -function getProvisionJson(provisionIds) { - var data = []; - $('#selectedProvisionsTable tbody tr').each(function () { - var row = $(this); - var provision_id = parseInt(row.attr('data-id')); - - // Only include rows with provisionId in the list - if (provisionIds.includes(provision_id)) { - var provision_name = row.find('.provision_name').val(); - var provision_group = row.find('.provision_group').val(); - var free_text = row.find('.free_text').val(); - - var rowData = { - provision_id: provision_id, - provision_group: provision_group, - provision_name: provision_name, - free_text: free_text, - }; - - data.push(rowData); - } - }); - return data; -} - -function getVariableJson(provisionIds) { - var data = []; - $('#variableTable tbody tr').each(function () { - var row = $(this); - var provision_id = parseInt(row.attr('data-id')); - - // Only include rows with provisionId in the list - if (provisionIds.includes(provision_id)) { - var variable_name = row.find('.variable_name').val(); - var variable_value = row.find('.variable_value').val(); - var variable_id = row.data('variable_id'); - - var rowData = { - provision_id: provision_id, - variable_id: variable_id, - variable_name: variable_name, - variable_value: variable_value, - }; - - data.push(rowData); - } - }); - return data; -} - -function updateGroupSelect(groupMaxJsonArray) { - // repopulate the group select using the new groupMaxJsonArray - const selectElement = document.getElementById('group-select'); - selectElement.innerHTML = ``; - groupMaxJsonArray.forEach((item) => { - const optionElement = document.createElement('option'); - optionElement.value = item.provision_group; - optionElement.text = `${item.provision_group} - ${item.provision_group_text}`; - selectElement.appendChild(optionElement); - }); - // color the first option green - $('#group-select').find('option:first-child').addClass('viewed'); - // this will update groupMaxNum - filterRows(); -} diff --git a/frontend/public/js/util.js b/frontend/public/js/util.js deleted file mode 100644 index 0096474f..00000000 --- a/frontend/public/js/util.js +++ /dev/null @@ -1,52 +0,0 @@ -async function generateReport(documentType) { - const tenureFileNumber = $("#tfn").text(); - const prdid = $("#prdid").text(); - const dtid = $("#dtid").text(); - $("#genReport").prop("disabled", true); - const reportName = await fetch( - `/report/get-report-name/${dtid}/${tenureFileNumber}/${documentType}`, - { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - responseType: "application/json", - } - ) - .then((res) => res.json()) - .then((resJson) => { - return resJson.reportName; - }) - .catch(() => { - location.reload(); - }); - const data = { - prdid: prdid, - dtid: dtid, - document_type: documentType, - }; - fetch(`/report/generate-report`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - responseType: "application/json", - body: JSON.stringify(data), - }) - .then((res) => res.blob()) - .then((blob) => { - const url = window.URL.createObjectURL(blob); - const a = document.createElement("a"); - a.style.display = "none"; - a.href = url; - a.download = reportName + ".docx"; - document.body.appendChild(a); - a.click(); - window.URL.revokeObjectURL(url); - $("#genReport").prop("disabled", false); - }) - .catch(() => { - location.reload(); - $("#genReport").prop("disabled", false); - }); -} From e6f190a90184231999e8772e9634ba0792c59f77 Mon Sep 17 00:00:00 2001 From: mgtennant <100305096+mgtennant@users.noreply.github.com> Date: Mon, 18 Mar 2024 09:38:14 -0700 Subject: [PATCH 4/7] wip --- backend/src/admin/admin.module.ts | 3 +- backend/src/app.controller.ts | 2 +- .../document_data/document_data.controller.ts | 6 +- .../document_data/document_data.service.ts | 179 +++++---- .../document_data_log.service.ts | 4 +- .../dto/create-document_data_log.dto.ts | 1 - .../dto/document_data_log.dto.ts | 1 - .../dto/update-document_data_log.dto.ts | 1 - .../entities/document_data_log.entity.ts | 4 - .../entities/document_type.entity.ts | 5 + backend/src/main.ts | 2 +- .../provision/entities/provision.entity.ts | 2 +- .../entities/provision_group.entity.ts | 6 +- backend/src/provision/provision.service.ts | 24 +- backend/src/report/report.controller.ts | 184 ++------- backend/src/report/report.module.ts | 2 + backend/src/report/report.service.ts | 379 ++++++++---------- frontend/src/app/App.tsx | 4 +- frontend/src/app/common/admin.ts | 1 - frontend/src/app/common/manage-templates.ts | 8 +- frontend/src/app/common/report.ts | 86 ++-- frontend/src/app/common/search.ts | 1 + .../manage-templates/AddProvisionModal.tsx | 75 ++-- .../manage-templates/EditProvisionModal.tsx | 6 +- .../manage-templates/RemoveTemplateModal.tsx | 6 +- .../manage-templates/UploadTemplateModal.tsx | 15 +- .../forms/EditProvisionModalForm.tsx | 84 ++-- .../ManageProvisionsTable.tsx | 6 +- .../table/reports/ProvisionsTable.tsx | 4 +- .../table/reports/SelectedProvisionsTable.tsx | 4 +- .../table/reports/VariablesTable.tsx | 4 +- .../table/search/SearchDataTable.tsx | 27 +- .../src/app/content/display/Provisions.tsx | 44 +- .../src/app/content/display/Variables.tsx | 23 +- frontend/src/app/content/pages/IndexPage.tsx | 6 +- .../app/content/pages/ManageTemplatesPage.tsx | 10 +- frontend/src/app/content/pages/ReportPage.tsx | 118 ++---- frontend/src/app/content/pages/SearchPage.tsx | 9 +- .../pages/documentpreview/DocumentPreview.tsx | 123 +++--- frontend/src/app/types/types.ts | 32 +- 40 files changed, 660 insertions(+), 841 deletions(-) diff --git a/backend/src/admin/admin.module.ts b/backend/src/admin/admin.module.ts index c6262b3d..91560108 100644 --- a/backend/src/admin/admin.module.ts +++ b/backend/src/admin/admin.module.ts @@ -6,9 +6,10 @@ import { AdminService } from './admin.service'; import { AdminController } from './admin.controller'; import { AuthenticationModule } from 'src/authentication/authentication.module'; import { DocumentTemplateModule } from 'src/document_template/document_template.module'; +import { ProvisionModule } from 'src/provision/provision.module'; @Module({ - imports: [HttpModule, AuthenticationModule, DocumentTemplateModule], + imports: [HttpModule, AuthenticationModule, DocumentTemplateModule, ProvisionModule], providers: [AdminGuard, AdminService], exports: [AdminService], controllers: [AdminController], diff --git a/backend/src/app.controller.ts b/backend/src/app.controller.ts index c715d0db..2aa15911 100644 --- a/backend/src/app.controller.ts +++ b/backend/src/app.controller.ts @@ -367,7 +367,7 @@ export class AppController { // const groupMaxJsonArray = await this.reportService.getGroupMaxByVariant('NOTICE OF FINAL REVIEW'); const groupMaxJsonArray = []; try { - const nfrDataObject = await this.reportService.getActiveNfrDataByDtid(dtid); + const nfrDataObject = await this.reportService.getDocumentDataByDocTypeIdAndDtid(1, dtid); nfrData = nfrDataObject.nfrData; const provisionIds = nfrDataObject.provisionIds ? nfrDataObject.provisionIds : []; // const mandatoryProvisionIds = await this.reportService.getMandatoryProvisionsByVariant(variantName); diff --git a/backend/src/document_data/document_data.controller.ts b/backend/src/document_data/document_data.controller.ts index 76d0b1bf..8789d934 100644 --- a/backend/src/document_data/document_data.controller.ts +++ b/backend/src/document_data/document_data.controller.ts @@ -38,9 +38,9 @@ export class DocumentDataController { } } - @Get('dtid/:dtid') - findActiveByDtid(@Param('dtid') dtid: number) { - return this.documentDataService.findActiveByDtid(dtid); + @Get('dtid/:document_type_id/:dtid') + findActiveByDtid(@Param('dtid') dtid: number, @Param('document_type_id') document_type_id: number) { + return this.documentDataService.findDocumentDataByDocTypeIdAndDtid(document_type_id, dtid); } @Get('view/:documentDataId') diff --git a/backend/src/document_data/document_data.service.ts b/backend/src/document_data/document_data.service.ts index 63d7cb65..26bed656 100644 --- a/backend/src/document_data/document_data.service.ts +++ b/backend/src/document_data/document_data.service.ts @@ -43,7 +43,7 @@ export class DocumentDataService { 'document_data_variables', 'document_data_provisions', 'document_data_variables.document_variable', - 'document_data_provisions.provision', + 'document_data_provisions.document_provision', 'document_type', ], }); @@ -210,6 +210,7 @@ export class DocumentDataService { where: { active: true, }, + relations: ['document_type'], }); } @@ -237,39 +238,46 @@ export class DocumentDataService { const variableIds = existingDataVariables.map((dataVariable) => dataVariable.document_variable.id); return { documentData, provisionIds, variableIds }; } catch (err) { + console.log('Error in findByDocumentDataId'); console.log(err); return null; } } - async findActiveByDtid(dtid: number): Promise<{ + async findDocumentDataByDocTypeIdAndDtid( + document_type_id: number, + dtid: number + ): Promise<{ documentData: DocumentData; provisionIds: number[]; variableIds: number[]; }> { try { - const documentData = await this.documentDataRepository.findOne({ - where: { dtid: dtid, active: true }, + const documentData = await this.documentDataRepository.find({ + where: { dtid: dtid }, join: { alias: 'document_data', leftJoinAndSelect: { document_data_provisions: 'document_data.document_data_provisions', - provision: 'document_data_provisions.provision', + document_provision: 'document_data_provisions.document_provision', document_data_variables: 'document_data.document_data_variables', document_variable: 'document_data_variables.document_variable', }, }, }); + const filteredDocumentData = documentData.find((d) => d.document_type.id === document_type_id); + console.log(filteredDocumentData); const provisionIds = - documentData && documentData.document_data_provisions - ? documentData.document_data_provisions.map((dataProvision) => dataProvision.document_provision.id) + filteredDocumentData && filteredDocumentData.document_data_provisions + ? filteredDocumentData.document_data_provisions.map((dataProvision) => dataProvision.document_provision.id) : []; const variableIds = - documentData && documentData.document_data_variables - ? documentData.document_data_variables.map((dataVariable) => dataVariable.document_variable.id) + filteredDocumentData && filteredDocumentData.document_data_variables + ? filteredDocumentData.document_data_variables.map((dataVariable) => dataVariable.document_variable.id) : []; - return { documentData, provisionIds, variableIds }; + return { documentData: filteredDocumentData, provisionIds, variableIds }; } catch (err) { + console.log('Error in findActiveByDtid'); console.log(err); return null; } @@ -282,92 +290,95 @@ export class DocumentDataService { } async getVariablesByDtidAndDocType(dtid: number, document_type_id: number) { - // const documentType: DocumentType = await this.documentTemplateService.getDocumentType(document_type_id); - const documentData: DocumentData = await this.documentDataRepository.findOne({ - where: { dtid: dtid, document_type: { id: document_type_id } }, - join: { - alias: 'document_data', - leftJoinAndSelect: { - document_data_variables: 'document_data.document_data_variables', - document_variable: 'document_data_variables.document_variable', + try { + const documentData: DocumentData = await this.documentDataRepository.findOne({ + where: { dtid: dtid, document_type: { id: document_type_id } }, + join: { + alias: 'document_data', + leftJoinAndSelect: { + document_data_variables: 'document_data.document_data_variables', + document_variable: 'document_data_variables.document_variable', + }, }, - }, - }); - // if the documentData doesn't exist yet, return null. This null value is caught elsewhere. - if (!documentData) { - return null; - } - // saved variables attached to the documentData entry - const existingDataVariables: DocumentDataVariable[] = documentData.document_data_variables; - // all variables associated with the variant - const variables: ProvisionVariable[] = await this.provisionService.getVariablesByDocumentTypeId(document_type_id); - // inserting the existing variable_values to the set of all variables - for (const variable of variables) { - const existingDataVariable = existingDataVariables.find( - (dataVariable) => dataVariable.document_variable.id === variable.id - ); - if (existingDataVariable) { - variable.variable_value = existingDataVariable.data_variable_value; + }); + // if the documentData doesn't exist yet, return null. This null value is caught elsewhere. + if (!documentData) { + return null; } + // saved variables attached to the documentData entry + const existingDataVariables: DocumentDataVariable[] = documentData.document_data_variables; + // all variables associated with the variant + const variables: ProvisionVariable[] = await this.provisionService.getVariablesByDocumentTypeId(document_type_id); + // inserting the existing variable_values to the set of all variables + for (const variable of variables) { + const existingDataVariable = existingDataVariables.find( + (dataVariable) => dataVariable.document_variable.id === variable.id + ); + if (existingDataVariable) { + variable.variable_value = existingDataVariable.data_variable_value; + } + } + const variableIds = existingDataVariables.map((dataVariable) => dataVariable.document_variable.id); + return { variables, variableIds }; + } catch (err) { + console.log('Error in getVariablesByDtidAndDocType'); + console.log(err); + return null; } - const variableIds = existingDataVariables.map((dataVariable) => dataVariable.document_variable.id); - return { variables, variableIds }; } async getProvisionsByDocTypeIdAndDtid(document_type_id: number, dtid: number) { - const documentData: DocumentData = await this.documentDataRepository.findOne({ - where: { dtid: dtid, document_type: { id: document_type_id } }, - join: { - alias: 'document_data', - leftJoinAndSelect: { - document_data_provisions: 'document_data.document_data_provisions', - provision: 'document_data_provisions.provision', - }, - }, - }); - // if the documentData doesn't exist yet, return null. This null value is caught elsewhere. - if (!documentData) { - return null; - } - // documentData for all variants of this dtid - const fullDocumentData: DocumentData[] = await this.documentDataRepository.find({ - where: { dtid: documentData.dtid }, - join: { - alias: 'document_data', - leftJoinAndSelect: { - document_data_provisions: 'document_data.document_data_provisions', - provision: 'document_data_provisions.provision', - }, - }, - }); + try { + const documentData = await this.documentDataRepository + .createQueryBuilder('document_data') + .leftJoinAndSelect('document_data.document_data_provisions', 'document_data_provisions') + .leftJoinAndSelect('document_data_provisions.document_provision', 'provision') + .where('document_data.dtid = :dtid', { dtid }) + .andWhere('document_data."documentTypeId" = :document_type_id', { document_type_id }) + .getOne(); + console.log(documentData); - // saved provisions attached to the dtid - const existingDataProvisions: DocumentDataProvision[] = []; - fullDocumentData.forEach((documentData) => { + // if the documentData doesn't exist yet, return null. This null value is caught elsewhere. + if (!documentData) { + return null; + } + + // saved provisions attached to the dtid + const existingDataProvisions: DocumentDataProvision[] = []; existingDataProvisions.push(...documentData.document_data_provisions); - }); - // all provisions - const provisions: Provision[] = await this.provisionService.getAllProvisions(); - const provisionIds = existingDataProvisions.map((dataProvision) => dataProvision.document_provision.id); - return { provisions, provisionIds }; + // all provisions + const provisions: Provision[] = await this.provisionService.getAllProvisionsByDocTypeId(document_type_id); + const provisionIds = existingDataProvisions.map((dataProvision) => dataProvision.document_provision.id); + return { provisions, provisionIds }; + } catch (err) { + console.log('Error in getProvisionsByDocTypeIdAndDtid'); + console.log(err); + return null; + } } async getEnabledProvisionsByDocTypeIdAndDtid(document_type_id: number, dtid: number) { - const documentData: DocumentData = await this.documentDataRepository.findOne({ - where: { dtid: dtid, document_type: { id: document_type_id } }, - join: { - alias: 'document_data', - leftJoinAndSelect: { - document_data_provisions: 'document_data.document_data_provisions', - provision: 'document_data_provisions.provision', + try { + const documentData: DocumentData = await this.documentDataRepository.findOne({ + where: { dtid: dtid, document_type: { id: document_type_id } }, + join: { + alias: 'document_data', + leftJoinAndSelect: { + document_data_provisions: 'document_data.document_data_provisions', + provision: 'document_data_provisions.provision', + }, }, - }, - }); - const provisionIds = - documentData && documentData.document_data_provisions - ? documentData.document_data_provisions.map((dataProvision) => dataProvision.document_provision.id) - : []; - return provisionIds; + }); + const provisionIds = + documentData && documentData.document_data_provisions + ? documentData.document_data_provisions.map((dataProvision) => dataProvision.document_provision.id) + : []; + return provisionIds; + } catch (err) { + console.log('Error in getEnabledProvisionsByDocTypeIdAndDtid'); + console.log(err); + return null; + } } async remove(dtid: number): Promise<{ deleted: boolean; message?: string }> { diff --git a/backend/src/document_data_log/document_data_log.service.ts b/backend/src/document_data_log/document_data_log.service.ts index f73bb7d1..1ee4f1df 100644 --- a/backend/src/document_data_log/document_data_log.service.ts +++ b/backend/src/document_data_log/document_data_log.service.ts @@ -14,7 +14,6 @@ export class DocumentDataLogService { async create(documentDataLog: CreateDocumentDataLogDto): Promise { const newItem = new DocumentDataLog(); newItem.document_template_id = documentDataLog.document_template_id; - newItem.document_data_id = documentDataLog.document_data_id; newItem.dtid = documentDataLog.dtid; newItem.request_app_user = documentDataLog.request_app_user; newItem.request_json = documentDataLog.request_json; @@ -35,10 +34,11 @@ export class DocumentDataLogService { }); } - async findNextVersion(dtid: number): Promise { + async findNextVersion(dtid: number, document_type_id: number): Promise { const requestLogs = await this.documentDataLogRepository.findAndCount({ where: { dtid: dtid, + document_type_id: document_type_id, }, }); let version = (requestLogs[1] + 1).toString(); diff --git a/backend/src/document_data_log/dto/create-document_data_log.dto.ts b/backend/src/document_data_log/dto/create-document_data_log.dto.ts index 786f4940..dbc58bbc 100644 --- a/backend/src/document_data_log/dto/create-document_data_log.dto.ts +++ b/backend/src/document_data_log/dto/create-document_data_log.dto.ts @@ -3,7 +3,6 @@ import { DocumentDataLogDto } from './document_data_log.dto'; export class CreateDocumentDataLogDto extends PickType(DocumentDataLogDto, [ 'dtid', - 'document_data_id', 'document_type_id', 'document_template_id', 'request_app_user', diff --git a/backend/src/document_data_log/dto/document_data_log.dto.ts b/backend/src/document_data_log/dto/document_data_log.dto.ts index 760cc659..a7dc8de7 100644 --- a/backend/src/document_data_log/dto/document_data_log.dto.ts +++ b/backend/src/document_data_log/dto/document_data_log.dto.ts @@ -1,6 +1,5 @@ export class DocumentDataLogDto { dtid: number; - document_data_id: number; document_type_id: number; document_template_id: number; request_app_user: string; diff --git a/backend/src/document_data_log/dto/update-document_data_log.dto.ts b/backend/src/document_data_log/dto/update-document_data_log.dto.ts index c9cdd8bc..9521ce57 100644 --- a/backend/src/document_data_log/dto/update-document_data_log.dto.ts +++ b/backend/src/document_data_log/dto/update-document_data_log.dto.ts @@ -3,7 +3,6 @@ import { DocumentDataLogDto } from './document_data_log.dto'; export class UpdateDocumentDataLogDto extends PickType(DocumentDataLogDto, [ 'dtid', - 'document_data_id', 'document_type_id', 'document_template_id', 'request_app_user', diff --git a/backend/src/document_data_log/entities/document_data_log.entity.ts b/backend/src/document_data_log/entities/document_data_log.entity.ts index f3ce25e1..d8f1f19b 100644 --- a/backend/src/document_data_log/entities/document_data_log.entity.ts +++ b/backend/src/document_data_log/entities/document_data_log.entity.ts @@ -7,8 +7,6 @@ export class DocumentDataLog { @Column({ nullable: true }) dtid: number; @Column({ nullable: true }) - document_data_id: number; - @Column({ nullable: true }) document_type_id: number; @Column({ nullable: true }) document_template_id: number; @@ -27,7 +25,6 @@ export class DocumentDataLog { constructor( dtid?: number, - document_data_id?: number, document_type_id?: number, document_template_id?: number, request_app_user?: string, @@ -36,7 +33,6 @@ export class DocumentDataLog { update_userid?: string ) { this.dtid = dtid || null; - this.document_data_id = document_data_id || null; this.document_type_id = document_type_id || null; this.document_template_id = document_template_id || null; this.request_app_user = request_app_user || ''; diff --git a/backend/src/document_type/entities/document_type.entity.ts b/backend/src/document_type/entities/document_type.entity.ts index 20e31cd5..ef876212 100644 --- a/backend/src/document_type/entities/document_type.entity.ts +++ b/backend/src/document_type/entities/document_type.entity.ts @@ -10,6 +10,7 @@ import { import { DocumentTemplate } from '../../document_template/entities/document_template.entity'; import { DocumentData } from 'src/document_data/entities/document_data.entity'; import { Provision } from 'src/provision/entities/provision.entity'; +import { ProvisionGroup } from 'src/provision/entities/provision_group.entity'; @Entity() export class DocumentType { @@ -35,6 +36,10 @@ export class DocumentType { document_data: DocumentData[]; @ManyToMany(() => Provision, (provision) => provision.document_types) provisions: Provision[]; + @OneToMany(() => ProvisionGroup, (provisionGroup) => provisionGroup.document_type, { + cascade: true, + }) + provision_groups: ProvisionGroup[]; constructor(name?: string, create_userid?: string, update_userid?: string) { this.name = name || ''; diff --git a/backend/src/main.ts b/backend/src/main.ts index c0dcef8a..8dddd1e6 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -20,7 +20,7 @@ async function bootstrap() { const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api', app, document); const appService = app.get(AppService); - // await appService.initializeDb(); + await appService.initializeDb(); await app.listen(3001); } diff --git a/backend/src/provision/entities/provision.entity.ts b/backend/src/provision/entities/provision.entity.ts index 847ed980..25511a81 100644 --- a/backend/src/provision/entities/provision.entity.ts +++ b/backend/src/provision/entities/provision.entity.ts @@ -52,7 +52,7 @@ export class Provision { document_data_provisions: DocumentDataProvision[]; @ManyToMany(() => DocumentType) @JoinTable({ - name: 'provision_document_type', // Name of the join table + name: 'provision_document_type', joinColumn: { name: 'provision_id', referencedColumnName: 'id', diff --git a/backend/src/provision/entities/provision_group.entity.ts b/backend/src/provision/entities/provision_group.entity.ts index 08acff89..a5c44112 100644 --- a/backend/src/provision/entities/provision_group.entity.ts +++ b/backend/src/provision/entities/provision_group.entity.ts @@ -1,5 +1,6 @@ -import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm'; +import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToMany, ManyToOne } from 'typeorm'; import { Provision } from './provision.entity'; +import { DocumentType } from 'src/document_type/entities/document_type.entity'; /** * This entity holds group descriptions and provision maximums @@ -20,6 +21,9 @@ export class ProvisionGroup { @Column({ nullable: true }) max: number; + @ManyToOne(() => DocumentType, (documentType) => documentType.provision_groups) + document_type: DocumentType; + @OneToMany(() => Provision, (provision) => provision.provision_group, { nullable: true, }) diff --git a/backend/src/provision/provision.service.ts b/backend/src/provision/provision.service.ts index cd77525f..e7c5c3da 100644 --- a/backend/src/provision/provision.service.ts +++ b/backend/src/provision/provision.service.ts @@ -153,7 +153,7 @@ export class ProvisionService { } // querybuilder is more efficient here - async getVariablesByDocumentTypeId(document_type_id: number): Promise { + async getVariablesByDocumentTypeId(document_type_id: number) { const provisions = await this.provisionRepository .createQueryBuilder('provision') .innerJoin('provision.document_types', 'documentType', 'documentType.id = :document_type_id', { @@ -184,13 +184,18 @@ export class ProvisionService { } } - async getAllProvisions(): Promise { + async getAllProvisionsByDocTypeId(document_type_id: number): Promise { try { - const provisions: Provision[] = await this.provisionRepository.find({ - relations: ['provision_group'], - }); + const provisions: Provision[] = await this.provisionRepository + .createQueryBuilder('provision') + .innerJoinAndSelect('provision.provision_group', 'provision_group') + .innerJoin('provision_group.document_type', 'document_type') + .where('document_type.id = :document_type_id', { document_type_id }) + .getMany(); + return provisions; } catch (err) { + console.log('Error in getAllProvisionsByDocTypeId'); console.log(err); return null; } @@ -223,14 +228,9 @@ export class ProvisionService { } async getGroupMaxByDocTypeId(document_type_id: number): Promise { - const provisions = await this.provisionRepository.find({ - relations: ['provision_group'], + const provisionGroups = await this.provisionGroupRepository.find({ + where: { document_type: { id: document_type_id } }, }); - let provisionGroups: ProvisionGroup[] = []; - provisions.forEach((provision) => { - provisionGroups.push(provision.provision_group); - }); - provisionGroups = this.removeDuplicates(provisionGroups, 'provision_group'); return Array.from(provisionGroups).sort((a, b) => a.provision_group - b.provision_group); } diff --git a/backend/src/report/report.controller.ts b/backend/src/report/report.controller.ts index ef1496b6..a6e22c4a 100644 --- a/backend/src/report/report.controller.ts +++ b/backend/src/report/report.controller.ts @@ -38,94 +38,57 @@ export class ReportController { }; } - @Get('get-data/:dtid') - async getData(@Session() session: { data?: SessionData }, @Param('dtid') dtid: number) { - console.log(dtid); - console.log(session); - await this.reportService.getActiveNfrDataByDtid(dtid); - await this.ttlsService.setWebadeToken(); - const response: any = await firstValueFrom(this.ttlsService.callHttp(dtid)) - .then((res) => { - return res; - }) - .catch((err) => { - console.log('callHttp failed'); - console.log(err); - console.log(err.response.data); - }); - return response; - } - - @Get('get-document-data/:dtid') - getNfrData(@Session() session: { data?: SessionData }, @Param('dtid') dtid: number) { - console.log('get-document-data ~ ' + dtid); - return this.reportService.getActiveNfrDataByDtid(dtid); - } - - @Get('get-report-name/:dtid/:tfn/:documentType') - getReportName( - @Param('dtid') dtid: number, - @Param('tfn') tenureFileNumber: string, - @Param('documentType') documentType: string - ): Promise<{ reportName: string }> { - return this.reportService.generateReportName(dtid, tenureFileNumber, documentType); + // @Get('get-data/:dtid') + // async getData(@Session() session: { data?: SessionData }, @Param('dtid') dtid: number) { + // console.log(dtid); + // console.log(session); + // await this.reportService.getTtlsDataByDtid(dtid); + // await this.ttlsService.setWebadeToken(); + // const response: any = await firstValueFrom(this.ttlsService.callHttp(dtid)) + // .then((res) => { + // return res; + // }) + // .catch((err) => { + // console.log('callHttp failed'); + // console.log(err); + // console.log(err.response.data); + // }); + // return response; + // } + + @Get('get-document-data/:document_type_id/:dtid') + getNfrData( + @Session() session: { data?: SessionData }, + @Param('document_type_id') document_type_id: number, + @Param('dtid') dtid: number + ) { + console.log('get-document-data ~ dtid:' + dtid + ', doctypeid: ' + document_type_id); + return this.reportService.getDocumentDataByDocTypeIdAndDtid(document_type_id, dtid); } - @Get('get-nfr-report-name/:dtid/:tfn') - getNFRReportName( + @Get('get-report-name/:dtid/:tfn/:document_type_id') + getReportNameNew( @Param('dtid') dtid: number, - @Param('tfn') tenureFileNumber: string + @Param('tfn') tenure_file_number: string, + @Param('document_type_id') document_type_id: number ): Promise<{ reportName: string }> { - return this.reportService.generateNFRReportName(dtid, tenureFileNumber); + return this.reportService.generateReportName(dtid, tenure_file_number, document_type_id); } + // remember to update @Post('generate-report') @Header('Content-Type', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') - @Header('Content-Disposition', 'attachment; filename=landusereport.docx') + @Header('Content-Disposition', 'attachment; filename=report.docx') async generateReport( - @Session() session: { data: SessionData }, - @Body() data: { prdid: string; document_type: string; dtid: number } - ) { - // this should eventually check permissions and prevent unauthorized users from generating documents - let idir_username = ''; - session = { - data: { - activeAccount: { - idir_username: 'mtennant', - name: '', - full_name: '', - client_roles: [''], - }, - }, - ...session, - }; - if (session.data.activeAccount) { - idir_username = session?.data?.activeAccount.idir_username; - console.log('active account found'); - } else { - console.log('no active account found'); - } - if (data.document_type == 'GL') { - return new StreamableFile(await this.reportService.generateGLReport(+data.dtid, idir_username)); - } else { - return new StreamableFile(await this.reportService.generateLURReport(+data.prdid, idir_username)); - } - } - - @Post('generate-nfr-report') - @Header('Content-Type', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') - @Header('Content-Disposition', 'attachment; filename=nfr-report.docx') - async generateNFRReport( @Session() session: { data: SessionData }, @Body() data: { dtid: number; - variantName: string; + document_type_id: number; variableJson: VariableJSON[]; provisionJson: ProvisionJSON[]; } ) { - // this should eventually check permissions and prevent unauthorized users from generating documents let idir_username = ''; let idir_full_name = ''; if (session?.data?.activeAccount) { @@ -136,9 +99,9 @@ export class ReportController { console.log('no active account found'); } return new StreamableFile( - await this.reportService.generateNFRReport( + await this.reportService.generateReport( data.dtid, - data.variantName, + data.document_type_id, idir_username, idir_full_name, data.variableJson, @@ -147,40 +110,6 @@ export class ReportController { ); } - @Post('generate-report-new') - @Header('Content-Type', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') - @Header('Content-Disposition', 'attachment; filename=report.docx') - async generateReportNew( - @Session() session: { data: SessionData }, - @Body() - data: { - dtid: number; - document_type_id: number; - variableJson: VariableJSON[]; - provisionJson: ProvisionJSON[]; - } - ) { - let idir_username = ''; - let idir_full_name = ''; - if (session?.data?.activeAccount) { - idir_username = session?.data?.activeAccount.idir_username; - idir_full_name = session?.data?.activeAccount.full_name; - console.log('active account found'); - } else { - console.log('no active account found'); - } - // return new StreamableFile( - await this.reportService.generateReportNew( - data.dtid, - data.document_type_id, - idir_username, - idir_full_name, - data.variableJson, - data.provisionJson - ); - // ); - } - @Get('get-group-max/:document_type_id') getGroupMaxByVariant(@Param('document_type_id') document_type_id: number) { return this.reportService.getGroupMaxByDocTypeId(document_type_id); @@ -194,10 +123,12 @@ export class ReportController { return this.reportService.getDocumentProvisionsByDocTypeIdAndDtid(document_type_id, dtid); } - @Get('get-provision-variables/:variantName/:dtid') - async getNFRVariablesByVariant(@Param('variantName') variantName: string, @Param('dtid') dtid: number) { - console.log('getting variables for NFR'); - const variables = await this.reportService.getNFRVariablesByVariantAndDtid(variantName, dtid); + @Get('get-provision-variables/:document_type_id/:dtid') + async getDocumentVariablesByDocumentTypeIdAndDtid( + @Param('document_type_id') document_type_id: number, + @Param('dtid') dtid: number + ) { + const variables = await this.reportService.getDocumentVariablesByDocumentTypeIdAndDtid(document_type_id, dtid); return variables; } @@ -230,35 +161,6 @@ export class ReportController { ); } - @Post('save-nfr') - saveNFR( - @Session() session: { data: SessionData }, - @Body() - data: { - dtid: number; - variant_name: string; - status: string; - provisionArray: ProvisionJSON[]; - variableArray: VariableJSON[]; - } - ) { - let idir_username = ''; - if (session?.data?.activeAccount) { - idir_username = session?.data?.activeAccount.idir_username; - console.log('active account found'); - } else { - console.log('no active account found'); - } - return this.reportService.saveNFR( - data.dtid, - data.variant_name, - data.status, - data.provisionArray, - data.variableArray, - idir_username - ); - } - @Get('enabled-provisions/:document_type_id') getEnabledProvisionsByDocTypeId(@Param('document_type_id') document_type_id: number) { return this.reportService.getEnabledProvisionsByDocTypeId(document_type_id); @@ -274,7 +176,7 @@ export class ReportController { @Get('search-document-data') getNFRData() { - return this.reportService.getNFRData(); + return this.reportService.getDocumentData(); } @Get('get-mandatory-provisions-by-document-type-id/:document_type_id') diff --git a/backend/src/report/report.module.ts b/backend/src/report/report.module.ts index 12f6d6e0..860f6fe2 100644 --- a/backend/src/report/report.module.ts +++ b/backend/src/report/report.module.ts @@ -9,6 +9,7 @@ import { ProvisionModule } from 'src/provision/provision.module'; import { DocumentDataModule } from 'src/document_data/document_data.module'; import { DocumentDataLogModule } from 'src/document_data_log/document_data_log.module'; import { DocumentDataLogService } from 'src/document_data_log/document_data_log.service'; +import { DocumentTypeModule } from 'src/document_type/document_type.module'; @Module({ imports: [ @@ -18,6 +19,7 @@ import { DocumentDataLogService } from 'src/document_data_log/document_data_log. ProvisionModule, DocumentDataModule, DocumentDataLogModule, + DocumentTypeModule, ], providers: [TTLSService, ReportService, DocumentDataLogService], exports: [ReportService], diff --git a/backend/src/report/report.service.ts b/backend/src/report/report.service.ts index ce69e19e..a3a652ce 100644 --- a/backend/src/report/report.service.ts +++ b/backend/src/report/report.service.ts @@ -10,8 +10,11 @@ import { convertToSpecialCamelCase, formatMoney, grazingLeaseVariables, nfrAddre import { DocumentDataService } from 'src/document_data/document_data.service'; import { DocumentTemplate } from 'src/document_template/entities/document_template.entity'; import { DocumentDataLogService } from 'src/document_data_log/document_data_log.service'; +import { DocumentTypeService } from 'src/document_type/document_type.service'; const axios = require('axios'); +// generate report needs to be consolidated which is impossible until we figure out how provisions & variables will be dynamically inserted into the docx files + dotenv.config(); let hostname: string; let port: number; @@ -23,42 +26,77 @@ export class ReportService { private readonly documentTemplateService: DocumentTemplateService, private readonly documentDataLogService: DocumentDataLogService, private readonly provisionService: ProvisionService, - private readonly documentDataService: DocumentDataService + private readonly documentDataService: DocumentDataService, + private readonly documentTypeService: DocumentTypeService ) { hostname = process.env.backend_url ? process.env.backend_url : `http://localhost`; // local development backend port is 3001, docker backend port is 3000 port = process.env.backend_url ? 3000 : 3001; } - /** - * Generates a LUR report name using tenure file number - * and a version number. The version number is incremented - * each time someone generates a LUR report. - * - * @param tenureFileNumber - * @returns - */ - async generateReportName(dtid: number, tenureFileNumber: string, documentType: string) { - const url = `${hostname}:${port}/print-request-log/version/${dtid}/${documentType}`; - // grab the next version string for the dtid - const version = await axios - .get(url, { - headers: { - 'Content-Type': 'application/json', - }, - }) - .then((res) => { - return res.data; - }); + // /** + // * Generates a LUR report name using tenure file number + // * and a version number. The version number is incremented + // * each time someone generates a LUR report. + // * + // * @param tenureFileNumber + // * @returns + // */ + // async generateReportName(dtid: number, tenureFileNumber: string, documentType: string) { + // const url = `${hostname}:${port}/print-request-log/version/${dtid}/${documentType}`; + // // grab the next version string for the dtid + // const version = await axios + // .get(url, { + // headers: { + // 'Content-Type': 'application/json', + // }, + // }) + // .then((res) => { + // return res.data; + // }); + // return { + // reportName: documentType + '_' + tenureFileNumber + '_' + version + '.docx', + // }; + // } + + async generateReportName(dtid: number, tenure_file_number: string, document_type_id: number) { + const version = await this.documentDataLogService.findNextVersion(dtid, document_type_id); + const documentType = await this.documentTypeService.findById(document_type_id); + // probably a better way of doing this + let prefix = 'report'; + if (documentType) { + if (documentType.name.toLowerCase().includes('notice of final review')) { + prefix = 'NFR'; + } else if (documentType.name.toLowerCase().includes('land use report')) { + prefix = 'LUR'; + } else if (documentType.name.toLowerCase().includes('grazing')) { + prefix = 'GL'; + } + } return { - reportName: documentType + '_' + tenureFileNumber + '_' + version + '.docx', + reportName: prefix + '_' + tenure_file_number + '_' + version + '.docx', }; } - async generateReport(dtid: number, username: string, document_type_id: number) { - const documentTemplateObject: { id: number; the_file: string } = - await this.documentTemplateService.findActiveByDocumentType(document_type_id); - const data = await this.documentDataService; + async generateReport( + dtid: number, + document_type_id: number, + idirUsername: string, + idirName: string, + variableJson: VariableJSON[], + provisionJson: ProvisionJSON[] + ) { + // For now, hardcode this to call the different static report routes based on document type + const documentType = await this.documentTypeService.findById(document_type_id); + if (documentType) { + if (documentType.name.toLowerCase().includes('notice of final review')) { + return this.generateNFRReport(dtid, document_type_id, idirUsername, idirName, variableJson, provisionJson); + } else if (documentType.name.toLowerCase().includes('land use report')) { + return this.generateLURReport(dtid, idirUsername); + } else if (documentType.name.toLowerCase().includes('grazing')) { + return this.generateGLReport(dtid, idirUsername); + } + } } /** @@ -68,6 +106,7 @@ export class ReportService { * @param username * @returns */ + // needs a rewrite as prdid is being removed... async generateLURReport(prdid: number, username: string) { prdid = 1; const documentType = LUR_REPORT_TYPE; @@ -304,70 +343,37 @@ export class ReportService { // return response.data; // } - /** - * Generates an NFR report name using tenure file number - * and a version number. The version number is incremented - * each time someone generates a NFR report. - * - * @param tenureFileNumber - * @returns - */ - async generateNFRReportName(dtid: number, tenureFileNumber: string) { - const url = `${hostname}:${port}/document-data-log/version/` + dtid; - // grab the next version string for the dtid - const version = await axios - .get(url, { - headers: { - 'Content-Type': 'application/json', - }, - }) - .then((res) => { - return res.data; - }); - return { reportName: 'NFR_' + tenureFileNumber + '_' + version + '.docx' }; - } - - async generateReportNew( - dtid: number, - document_type_id: number, - idirUsername: string, - idirName: string, - variableJson: VariableJSON[], - provisionJson: ProvisionJSON[] - ) { - console.log('TODO'); - // Get raw data from TTLS - await this.ttlsService.setWebadeToken(); - const rawData: any = await firstValueFrom(this.ttlsService.callHttp(dtid)) - .then((res) => { - return res; - }) - .catch((err) => { - console.log(err); - }); - // Get the active template file for this document type - const documentTemplateObject: DocumentTemplate = await this.documentTemplateService.findActiveByDocumentType( - document_type_id - ); - // format the provisions & variables in a dynamic way - // TODO - // create a log of the transaction - // TODO - // generate and return the document - // TODO - } + // /** + // * Generates an NFR report name using tenure file number + // * and a version number. The version number is incremented + // * each time someone generates a NFR report. + // * + // * @param tenureFileNumber + // * @returns + // */ + // async generateNFRReportName(dtid: number, tenureFileNumber: string) { + // const url = `${hostname}:${port}/document-data-log/version/` + dtid; + // // grab the next version string for the dtid + // const version = await axios + // .get(url, { + // headers: { + // 'Content-Type': 'application/json', + // }, + // }) + // .then((res) => { + // return res.data; + // }); + // return { reportName: 'NFR_' + tenureFileNumber + '_' + version + '.docx' }; + // } async generateNFRReport( dtid: number, - variantName: string, + document_type_id: number, idirUsername: string, idirName: string, variableJson: VariableJSON[], provisionJson: ProvisionJSON[] ) { - const templateUrl = `${hostname}:${port}/document-template/get-active-report/${variantName}`; - const logUrl = `${hostname}:${port}/document-data-log/`; - // get raw ttls data for later await this.ttlsService.setWebadeToken(); const rawData: any = await firstValueFrom(this.ttlsService.callHttp(dtid)) @@ -378,14 +384,7 @@ export class ReportService { console.log(err); }); - // get the document template - const documentTemplateObject: { - id: number; - the_file: string; - document_template: string; - } = await axios.get(templateUrl).then((res) => { - return res.data; - }); + const documentTemplateObject = await this.documentTemplateService.findActiveByDocumentType(document_type_id); // Format variables with names that the document template expects const variables: any = {}; @@ -681,16 +680,17 @@ export class ReportService { const data = Object.assign({}, ttlsData, variables, showProvisionSections); // Log the request - const document_template_id = documentTemplateObject.id; - await axios.post(logUrl, { - document_template_id: document_template_id, + await this.documentDataLogService.create({ dtid: dtid, + document_type_id: document_type_id, + document_template_id: documentTemplateObject?.id, request_app_user: idirUsername, request_json: JSON.stringify(data), + create_userid: idirUsername, }); // Save the NFR Data - await this.saveNFR(dtid, variantName, 'Complete', provisionJson, variableJson, idirUsername); + await this.saveDocument(dtid, document_type_id, 'Complete', provisionJson, variableJson, idirUsername); // Generate the report const cdogsToken = await this.ttlsService.callGetToken(); @@ -796,23 +796,15 @@ export class ReportService { return this.provisionService.getGroupMaxByDocTypeId(document_type_id); } - async getNFRVariablesByVariantAndDtid(variantName: string, dtid: number): Promise { - // if an nfrId is provided, get the variables with any existing user specified values - const url = `${hostname}:${port}/document-data/variables/${variantName}/${dtid}`; - const variables = await axios - .get(url) - .then((res) => { - return res.data.variables; - }) - .catch((err) => console.log(err.response.data)); + async getDocumentVariablesByDocumentTypeIdAndDtid(document_type_id: number, dtid: number): Promise { + // if a dtid & document_type_id are provided, get the variables with any existing user specified values + const variables = await this.documentDataService.getVariablesByDtidAndDocType(dtid, document_type_id); if (variables) { return variables; } else { - // grab the basic variable list corresponding to the variant - const url2 = `${hostname}:${port}/provision/get-provision-variables/variant/${variantName}`; - return axios.get(url2).then((res) => { - return res.data; - }); + // grab the basic variable list corresponding to the document type + const basicVariables = await this.provisionService.getVariablesByDocumentTypeId(document_type_id); + return { variables: basicVariables, variableIds: [] }; } } @@ -824,32 +816,10 @@ export class ReportService { return this.provisionService.getMandatoryProvisionsByDocumentTypeId(document_type_id); } - async getNFRData() { - const nfrDataUrl = `${hostname}:${port}/nfr-data`; - const templateUrl = `${hostname}:${port}/document-template/nfr-template-info`; - - // get NFR data - let nfrData; - try { - const response = await axios.get(nfrDataUrl); - nfrData = response.data; - } catch (err) { - console.log(err.response.data); - return; - } - - // get template IDs from NFR data - const templateIds = nfrData.map((entry) => entry.template_id); - - // get templates using template IDs - let allTemplates; - try { - const response = await axios.post(templateUrl, templateIds); - allTemplates = response.data; - } catch (err) { - console.log(err.response.data); - return; - } + async getDocumentData() { + const documentData = await this.documentDataService.findAll(); + const templateIds = documentData.map((d) => d.template_id); + const allTemplates = await this.documentTemplateService.getTemplatesInfoByIds(templateIds); // filter out deleted templates and create a lookup table const templatesLookup = allTemplates.reduce((acc, template) => { @@ -859,82 +829,84 @@ export class ReportService { return acc; }, {}); - // combine NFR data with their corresponding templates - const combinedArray = nfrData - .filter((nfr) => templatesLookup[nfr.template_id]) - .map((nfr) => ({ - dtid: nfr.dtid, - version: templatesLookup[nfr.template_id].template_version, - file_name: templatesLookup[nfr.template_id].file_name, - updated_date: nfr.update_timestamp.split('T')[0], - status: nfr.status, - active: templatesLookup[nfr.template_id].active_flag, - nfr_id: nfr.id, - variant_name: nfr.variant_name, + // combine Document data with their corresponding templates + const combinedArray = documentData + .filter((document) => templatesLookup[document.template_id]) + .map((document) => ({ + dtid: document.dtid, + version: templatesLookup[document.template_id].template_version, + file_name: templatesLookup[document.template_id].file_name, + updated_date: document.update_timestamp.toString().split('T')[0], + status: document.status, + active: templatesLookup[document.template_id].active_flag, + document_data_id: document.id, + document_type: document.document_type, })); return combinedArray; } - async getActiveNfrDataByDtid(dtid: number): Promise { - const url = `${hostname}:${port}/document-data/dtid/${dtid}`; - const response = await axios - .get(url, { - headers: { - 'Content-Type': 'application/json', - }, - }) - .then((res) => { - return res.data; - }); - // console.log('!!!~~~~~~~~'); - // console.log("this.getGroupMaxByVariant('NOTICE OF FINAL REVIEW')"); - // const groupMax = await this.getGroupMaxByVariant('NOTICE OF FINAL REVIEW'); - // // console.log(groupMax); - // console.log('\ngetActiveNfrDataByDtid'); - // console.log(response); - // console.log('\ndocument_data_provisions'); - // // console.log(response.nfrData.document_data_provisions); - // console.log('\ndocument_data_variables'); - // // console.log(response.nfrData.document_data_variables); - // console.log('\nthis.getMandatoryProvisionsByVariant(NOTICE OF FINAL REVIEW)'); - // const mandatoryProvisions = await this.getMandatoryProvisionsByVariant('NOTICE OF FINAL REVIEW'); - // // console.log(mandatoryProvisions); - // console.log('~~~~~~~~!!!'); - return response; + async getDocumentDataByDocTypeIdAndDtid(document_type_id: number, dtid: number): Promise { + return this.documentDataService.findDocumentDataByDocTypeIdAndDtid(document_type_id, dtid); + // const url = `${hostname}:${port}/document-data/dtid/${dtid}`; + // const response = await axios + // .get(url, { + // headers: { + // 'Content-Type': 'application/json', + // }, + // }) + // .then((res) => { + // return res.data; + // }); + // // const documentData = await this.documentDataService.findActiveByDtid(dtid); + // // console.log('!!!~~~~~~~~'); + // // console.log("this.getGroupMaxByVariant('NOTICE OF FINAL REVIEW')"); + // // const groupMax = await this.getGroupMaxByVariant('NOTICE OF FINAL REVIEW'); + // // // console.log(groupMax); + // // console.log('\ngetActiveNfrDataByDtid'); + // // console.log(response); + // // console.log('\ndocument_data_provisions'); + // // // console.log(response.nfrData.document_data_provisions); + // // console.log('\ndocument_data_variables'); + // // // console.log(response.nfrData.document_data_variables); + // // console.log('\nthis.getMandatoryProvisionsByVariant(NOTICE OF FINAL REVIEW)'); + // // const mandatoryProvisions = await this.getMandatoryProvisionsByVariant('NOTICE OF FINAL REVIEW'); + // // // console.log(mandatoryProvisions); + // // console.log('~~~~~~~~!!!'); + // return response; } - async saveNFR( - dtid: number, - variant_name: string, - status: string, - provisionJsonArray: ProvisionJSON[], - variableJsonArray: VariableJSON[], - idir_username: string - ) { - const templateUrl = `${hostname}:${port}/document-template/get-active-report/${variant_name}`; - const documentTemplate = await axios.get(templateUrl).then((res) => { - return res.data; - }); - const url = `${hostname}:${port}/document-data`; - const data = { - dtid: dtid, - variant_name: variant_name, - template_id: documentTemplate.id, - status: status, - create_userid: idir_username, - ttls_data: [], - provisionJsonArray, - variableJsonArray, - }; - await axios - .post(url, { - body: data, - }) - .then((res) => { - return res.data; - }); - } + // async saveNFR( + // dtid: number, + // variant_name: string, + // status: string, + // provisionJsonArray: ProvisionJSON[], + // variableJsonArray: VariableJSON[], + // idir_username: string + // ) { + // const templateUrl = `${hostname}:${port}/document-template/get-active-report/${variant_name}`; + // const documentTemplate = await axios.get(templateUrl).then((res) => { + // return res.data; + // }); + // const url = `${hostname}:${port}/document-data`; + // const data = { + // dtid: dtid, + // variant_name: variant_name, + // template_id: documentTemplate.id, + // status: status, + // create_userid: idir_username, + // ttls_data: [], + // provisionJsonArray, + // variableJsonArray, + // }; + // await axios + // .post(url, { + // body: data, + // }) + // .then((res) => { + // return res.data; + // }); + // } async saveDocument( dtid: number, @@ -944,7 +916,6 @@ export class ReportService { variableJsonArray: VariableJSON[], idir_username: string ) { - const url = `${hostname}:${port}/document-data`; const documentTemplate = await this.documentTemplateService.findActiveByDocumentType(document_type_id); const data = { dtid: dtid, diff --git a/frontend/src/app/App.tsx b/frontend/src/app/App.tsx index c749195d..28e55e72 100644 --- a/frontend/src/app/App.tsx +++ b/frontend/src/app/App.tsx @@ -3,7 +3,7 @@ import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'; import Header from './content/display/Header'; import Footer from './content/display/Footer'; import { getDocumentTypes } from './common/report'; -import { DocumentType } from './types/types'; +import { DocType } from './types/types'; import ReportPage from './content/pages/ReportPage'; import SearchPage from './content/pages/SearchPage'; import ManageTemplatesPage from './content/pages/ManageTemplatesPage'; @@ -12,7 +12,7 @@ import ContentWrapper from './content/ContentWrapper'; const App: FC = () => { // used to render report pages - const [documentTypes, setDocumentTypes] = useState([]); + const [documentTypes, setDocumentTypes] = useState([]); useEffect(() => { const getDocTypes = async () => { diff --git a/frontend/src/app/common/admin.ts b/frontend/src/app/common/admin.ts index bd82e9d4..28bef7a0 100644 --- a/frontend/src/app/common/admin.ts +++ b/frontend/src/app/common/admin.ts @@ -2,7 +2,6 @@ import config from '../../config'; import { IdirUserObject } from '../components/modal/admin/AddAdmin'; import { AdminData } from '../components/table/admin/AdminDataTable'; import * as api from './api'; -import fileDownload from 'js-file-download'; /** * Used in report name generation diff --git a/frontend/src/app/common/manage-templates.ts b/frontend/src/app/common/manage-templates.ts index 3c6b977c..fa5b21f3 100644 --- a/frontend/src/app/common/manage-templates.ts +++ b/frontend/src/app/common/manage-templates.ts @@ -61,16 +61,16 @@ export const downloadTemplate = async (id: number, fileName: string): Promise => { - const url = `${config.API_BASE_URL}/admin/remove-template/${id}/${document_template_id}`; +export const removeTemplate = async (id: number, documentTypeId: number): Promise => { + const url = `${config.API_BASE_URL}/admin/remove-template/${id}/${documentTypeId}`; const getParameters = api.generateApiParameters(url); const response = await api.get(getParameters); console.log('removeTemplate response'); console.log(response); }; -export const activateTemplate = async (id: number, document_template_id: string): Promise => { - const url = `${config.API_BASE_URL}/admin/activate-template/${id}/${document_template_id}`; +export const activateTemplate = async (id: number, documentTypeId: string): Promise => { + const url = `${config.API_BASE_URL}/admin/activate-template/${id}/${documentTypeId}`; const getParameters = api.generateApiParameters(url); await api.get(getParameters); }; diff --git a/frontend/src/app/common/report.ts b/frontend/src/app/common/report.ts index 4857b363..319f1947 100644 --- a/frontend/src/app/common/report.ts +++ b/frontend/src/app/common/report.ts @@ -3,51 +3,37 @@ import { ProvisionJson } from '../components/table/reports/SelectedProvisionsTab import { VariableJson } from '../components/table/reports/VariablesTable'; import { ProvisionData } from '../content/display/Provisions'; import { VariableData } from '../content/display/Variables'; -import { DTR, DTRDisplayObject, DocumentType, NfrDataObject, ProvisionGroup } from '../types/types'; +import { DTR, DTRDisplayObject, DocType, DocumentDataObject, ProvisionGroup } from '../types/types'; import { buildDTRDisplayData } from '../util/util'; import * as api from './api'; -/** - * Gets ttls data and parses it for displaying - * - * @param dtid - * @returns - */ -export async function getData(dtid: number): Promise { - const dataUrl = `${config.API_BASE_URL}/report/get-data/${dtid}`; - +// /** +// * Gets ttls data and parses it for displaying +// * +// * @param dtid +// * @returns +// */ +// export async function getData(dtid: number): Promise { +// const dataUrl = `${config.API_BASE_URL}/report/get-data/${dtid}`; + +// const data: DTR = await api.get({ url: dataUrl }); +// const displayData = buildDTRDisplayData(data); +// return displayData; +// } + +export async function getData(document_type_id: number, dtid: number): Promise { + const dataUrl = `${config.API_BASE_URL}/report/get-document-data/${document_type_id}/${dtid}`; const data: DTR = await api.get({ url: dataUrl }); + console.log(data); const displayData = buildDTRDisplayData(data); return displayData; } -/** - * Used to generate reports - * - * @param dtid - * @param fileNum - * @param documentDescription - */ -export async function generateReport(dtid: number, fileNum: string, documentDescription: string): Promise { - const reportNameUrl = `${config.API_BASE_URL}/report/get-report-name/${dtid}/${fileNum}/${documentDescription}`; - const reportUrl = `${config.API_BASE_URL}/report/generate-report`; - - const reportNameResponse: { reportName: string } = await api.get({ url: reportNameUrl }); - const reportName: string = reportNameResponse.reportName; - - const data = { - prdid: null, - dtid: dtid, - document_type: documentDescription, - }; - api.handleFileDownloadPost(reportUrl, data, reportName); -} - /** Section for Notice of Final Review which has lots of custom logic */ -export const getDocumentDataByDtid = async (dtid: number) => { - const url = `${config.API_BASE_URL}/report/get-document-data/${dtid}`; +export const getDocumentDataByDocTypeIdAndDtid = async (document_type_id: number, dtid: number) => { + const url = `${config.API_BASE_URL}/report/get-document-data/${document_type_id}/${dtid}`; const getParameters = api.generateApiParameters(url); - const response: NfrDataObject = await api.get(getParameters); + const response: DocumentDataObject = await api.get(getParameters); return response; }; @@ -59,7 +45,7 @@ export const getGroupMaxByDocTypeId = async (document_type_id: number) => { }; export const getMandatoryProvisionsByDocTypeId = async (document_type_id: number): Promise => { - const url = `${config.API_BASE_URL}/report/get-mandatory-provisions-by-variant/${document_type_id}`; + const url = `${config.API_BASE_URL}/report/get-mandatory-provisions-by-document-type-id/${document_type_id}`; const getParameters = api.generateApiParameters(url); const response: number[] = await api.get(getParameters); return response; @@ -78,23 +64,26 @@ export const getDocumentProvisionsByDocTypeIdDtid = async ( export const getDocumentVariablesByDocTypeIdDtid = async ( document_type_id: number, dtid: number -): Promise => { +): Promise<{ variables: VariableData[]; variableIds: number[] }> => { const url = `${config.API_BASE_URL}/report/get-provision-variables/${document_type_id}/${dtid}`; const getParameters = api.generateApiParameters(url); - const response: VariableData[] = await api.get(getParameters); + const response: { variables: VariableData[]; variableIds: number[] } = await api.get<{ + variables: VariableData[]; + variableIds: number[]; + }>(getParameters); return response; }; export const saveDocument = async ( dtid: number, - variantName: string, + document_type_id: number, provisionArray: { provision_id: number; free_text: string }[], variableArray: { provision_id: number; variable_id: number; variable_value: string }[] ): Promise => { - const url = `${config.API_BASE_URL}/report/save-nfr`; + const url = `${config.API_BASE_URL}/report/save-document`; const data = { dtid: dtid, - variant_name: variantName, + document_type_id: document_type_id, status: 'In Progress', provisionArray: provisionArray, variableArray: variableArray, @@ -103,23 +92,22 @@ export const saveDocument = async ( await api.post(postParameters); }; -// TODO stop using NFR -export const generateNfrReport = async ( +export const generateReport = async ( dtid: number, fileNum: string, - variant: string, + document_type_id: number, provisionJson: ProvisionJson[], variableJson: VariableJson[] ) => { - const url = `${config.API_BASE_URL}/report/generate-nfr-report`; - const reportNameUrl = `${config.API_BASE_URL}/report/get-nfr-report-name/${dtid}/${fileNum}`; + const url = `${config.API_BASE_URL}/report/generate-report`; + const reportNameUrl = `${config.API_BASE_URL}/report/get-report-name/${dtid}/${fileNum}/${document_type_id}`; const reportNameResponse: { reportName: string } = await api.get({ url: reportNameUrl }); const reportName: string = reportNameResponse.reportName; const data = { dtid: dtid, - variantName: variant, + document_type_id: document_type_id, provisionJson: provisionJson, variableJson: variableJson, }; @@ -128,8 +116,8 @@ export const generateNfrReport = async ( }; export const getDocumentTypes = () => { - const url = `${config.API_BASE_URL}/report/get-document-types`; + const url = `${config.API_BASE_URL}/document-type`; console.log(url); const getParameters = api.generateApiParameters(url); - return api.get(getParameters); + return api.get(getParameters); }; diff --git a/frontend/src/app/common/search.ts b/frontend/src/app/common/search.ts index 7f271dab..70ad8975 100644 --- a/frontend/src/app/common/search.ts +++ b/frontend/src/app/common/search.ts @@ -13,6 +13,7 @@ export async function getSearchData(): Promise { const parameters = api.generateApiParameters(url); const response = await api.get(parameters); + console.log(response) if (Array.isArray(response)) { return response; } else { diff --git a/frontend/src/app/components/modal/manage-templates/AddProvisionModal.tsx b/frontend/src/app/components/modal/manage-templates/AddProvisionModal.tsx index aacb1da4..51470fdd 100644 --- a/frontend/src/app/components/modal/manage-templates/AddProvisionModal.tsx +++ b/frontend/src/app/components/modal/manage-templates/AddProvisionModal.tsx @@ -1,10 +1,11 @@ import { useEffect, useState } from 'react'; -import { GroupMax, ProvisionUpload } from '../../../types/types'; +import { DocType, GroupMax, ProvisionUpload } from '../../../types/types'; import { Button, Col, Form, Modal, Row, Spinner } from 'react-bootstrap'; interface AddProvisionModalProps { groupMaxArray: GroupMax[] | undefined; show: boolean; + documentTypes: DocType[] | undefined; addProvisionHandler: (provision: ProvisionUpload) => void; onHide: () => void; refreshTables: () => void; @@ -15,6 +16,7 @@ interface AddProvisionModalProps { const AddProvisionModal: React.FC = ({ groupMaxArray, show, + documentTypes, addProvisionHandler, onHide, refreshTables, @@ -30,7 +32,7 @@ const AddProvisionModal: React.FC = ({ const [freeText, setFreeText] = useState(''); const [helpText, setHelpText] = useState(''); const [category, setCategory] = useState(''); - const [variants, setVariants] = useState([]); + const [documentTypeIds, setDocumentTypeIds] = useState([]); useEffect(() => { setIsMaxUnlimited(max ? max >= 999 : false); @@ -104,12 +106,12 @@ const AddProvisionModal: React.FC = ({ setCategory(e.target.value); }; - const handleVariantIdUpdate = (e: React.ChangeEvent) => { - const variantId: number = parseInt(e.target.value); + const handleDocumentTypeIdUpdate = (e: React.ChangeEvent) => { + const documentTypeId: number = parseInt(e.target.value); if (e.target.checked) { - setVariants((prevVariants) => [...prevVariants, variantId]); + setDocumentTypeIds((prevDocTypeIds) => [...prevDocTypeIds, documentTypeId]); } else { - setVariants(variants.filter((v) => v === variantId)); + setDocumentTypeIds(documentTypeIds.filter((v) => v === documentTypeId)); } }; @@ -127,7 +129,7 @@ const AddProvisionModal: React.FC = ({ free_text: freeText, help_text: helpText, category: category, - variants: variants, + document_type_ids: documentTypeIds, }; addProvisionHandler(provisionUpload); refreshTables(); @@ -256,48 +258,25 @@ const AddProvisionModal: React.FC = ({ - Variants + Document Types - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + {documentTypes && + documentTypes.map((docType) => { + return ( + + + + + + + + + ); + })} - + = () => { show={showUploadModal} onHide={() => setShowUploadModal(false)} onUpload={refreshTables} - reportType={currentReportType} + documentTypeId={1} + documentTypeName="placeholder" /> setShowRemoveTemplateModal(false)} onRemove={refreshTables} - reportType={currentReportType} + documentTypeId={1} templateId={currentReportId} /> setShowEditProvisionModal(false)} @@ -189,6 +192,7 @@ const ManageTemplatesPage: FC = () => { /> setShowAddProvisionModal(false)} addProvisionHandler={addProvisionHandler} diff --git a/frontend/src/app/content/pages/ReportPage.tsx b/frontend/src/app/content/pages/ReportPage.tsx index 256ce5fa..1d7bc78f 100644 --- a/frontend/src/app/content/pages/ReportPage.tsx +++ b/frontend/src/app/content/pages/ReportPage.tsx @@ -1,21 +1,20 @@ import { FC, useCallback, useEffect, useState } from 'react'; import Collapsible from '../../../app/components/common/Collapsible'; -import { DTRDisplayObject, DocumentType } from '../../../app/types/types'; +import { DTRDisplayObject, DocType, ProvisionGroup } from '../../../app/types/types'; import TenureDetails from '../display/TenureDetails'; import AreaDetails from '../display/AreaDetails'; import DtidDetails from '../display/DtidDetails'; import { - generateNfrReport, generateReport, getData, getDocumentProvisionsByDocTypeIdDtid, saveDocument, getMandatoryProvisionsByDocTypeId, + getGroupMaxByDocTypeId, } from '../../common/report'; -import VariantDropdown from '../../components/common/VariantDropdown'; -import { CURRENT_REPORT_PAGES, NFR_REPORT_PAGES, NFR_VARIANTS } from '../../util/constants'; +import { CURRENT_REPORT_PAGES } from '../../util/constants'; import InterestedParties from '../display/InterestedParties'; -import { useParams, useNavigate } from 'react-router-dom'; +import { useParams } from 'react-router-dom'; import Skeleton from 'react-loading-skeleton'; import Provisions, { ProvisionData } from '../display/Provisions'; import Variables from '../display/Variables'; @@ -24,18 +23,14 @@ import { SaveVariableData, VariableJson } from '../../components/table/reports/V import { Button } from 'react-bootstrap'; export interface ReportPageProps { - documentType: DocumentType; + documentType: DocType; } -// TODO - remove variants, possibly replace with document type dropdown -// remove any mention of nfr - const ReportPage: FC = ({ documentType }) => { const { dtid } = useParams<{ dtid: string }>(); const dtidNumber = dtid ? parseInt(dtid, 10) : null; const [loading, setLoading] = useState(false); const [data, setData] = useState(null); - const [showNfr, setShowNfr] = useState(false); const [allProvisions, setAllProvisions] = useState([]); const [variableArray, setVariableArray] = useState([]); const [provisionArray, setProvisionArray] = useState([]); @@ -43,16 +38,14 @@ const ReportPage: FC = ({ documentType }) => { const [provisionJsonArray, setProvisionJsonArray] = useState([]); const [selectedProvisionIds, setSelectedProvisionIds] = useState([]); const [mandatoryProvisionIds, setMandatoryProvisionIds] = useState([]); - - const navigate = useNavigate(); + const [provisionGroups, setProvisionGroups] = useState([]); useEffect(() => { - setShowNfr(NFR_VARIANTS.includes(documentType.name.toUpperCase())); const fetchData = async () => { if (dtidNumber) { try { setLoading(true); - const fetchedData: DTRDisplayObject = await getData(dtidNumber); + const fetchedData: DTRDisplayObject = await getData(documentType.id, dtidNumber); setData(fetchedData); const fetchProvisions: ProvisionData[] = await getDocumentProvisionsByDocTypeIdDtid( documentType.id, @@ -61,6 +54,8 @@ const ReportPage: FC = ({ documentType }) => { setAllProvisions(fetchProvisions); const mpIds: number[] = await getMandatoryProvisionsByDocTypeId(documentType.id); setMandatoryProvisionIds(mpIds); + const provisionGroupsObject: ProvisionGroup[] = await getGroupMaxByDocTypeId(documentType.id); + setProvisionGroups(provisionGroupsObject); } catch (error) { console.error('Failed to fetch data', error); setData(null); @@ -72,24 +67,12 @@ const ReportPage: FC = ({ documentType }) => { fetchData(); }, [dtidNumber, documentType]); - const generateReportHandler = () => { - if (dtidNumber) { - generateReport(dtidNumber, data!.fileNum, documentType.name); - } - }; - - const handleNfrGenerate = () => { + const handleGenerateReport = () => { if (dtidNumber) { const errorMessage = validateProvisions(); if (!errorMessage) { if (data) { - generateNfrReport( - dtidNumber, - data.fileNum, - documentType.name.toUpperCase(), - provisionJsonArray, - variableJsonArray - ); + generateReport(dtidNumber, data!.fileNum, documentType.id, provisionJsonArray, variableJsonArray); } } else { alert(errorMessage); @@ -110,11 +93,6 @@ const ReportPage: FC = ({ documentType }) => { } }; - const variantChangeHandler = (variant: string) => { - const upperCaseVariant = variant.toUpperCase(); - navigate(`/dtid/${dtid}/${upperCaseVariant}`); - }; - const updateSelectedProvisionIds = useCallback((selectedProvisionIds: number[]) => { setSelectedProvisionIds(selectedProvisionIds); }, []); @@ -145,14 +123,14 @@ const ReportPage: FC = ({ documentType }) => { setProvisionJsonArray(provisionJsonData); }, []); - const handleNfrSave = () => { + const handleDocumentSave = () => { const saveData = async () => { if (dtidNumber) { try { setLoading(true); - await saveDocument(dtidNumber, documentType.name.toUpperCase(), provisionArray, variableArray); + await saveDocument(dtidNumber, documentType.id, provisionArray, variableArray); } catch (err) { - console.log('Error saving NFR Data'); + console.log('Error saving Document Data'); console.log(err); } finally { setLoading(false); @@ -168,16 +146,6 @@ const ReportPage: FC = ({ documentType }) => { <>
Preview - {documentType.name} (Draft)

- {Object.values(NFR_REPORT_PAGES).includes(documentType.name) && ( -
- -
-
- )}
DTID:
@@ -203,42 +171,38 @@ const ReportPage: FC = ({ documentType }) => { ) : ( {data ? : } )} - {showNfr && ( - - - - )} - {showNfr && ( - - - + {provisionGroups && ( + <> + + + + + + + + )}
- {showNfr ? ( - <> - - - - ) : ( - + - )} +
); diff --git a/frontend/src/app/content/pages/SearchPage.tsx b/frontend/src/app/content/pages/SearchPage.tsx index b81d3f67..382edfd0 100644 --- a/frontend/src/app/content/pages/SearchPage.tsx +++ b/frontend/src/app/content/pages/SearchPage.tsx @@ -7,17 +7,18 @@ import { FC, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import SearchDataTable from '../../components/table/search/SearchDataTable'; +import { DocType } from '../../types/types'; // TODO - redo page to include all document types, replace variant with document type const SearchPage: FC = () => { - const [selectedDocument, setSelectedDocument] = useState<{ dtid: number; variant: string } | null>(null); + const [selectedDocument, setSelectedDocument] = useState<{ dtid: number; documentType: DocType } | null>(null); const [searchTerm, setSearchTerm] = useState(''); const navigate = useNavigate(); const handleOpenDocument = async () => { if (selectedDocument) { - navigate(`/dtid/${selectedDocument.dtid}/${selectedDocument.variant}`); + navigate(`/dtid/${selectedDocument.dtid}/${selectedDocument.documentType.name}`); } }; @@ -25,8 +26,8 @@ const SearchPage: FC = () => { setSearchTerm(e.target.value); }; - const handleSelectedDocumentChange = (dtid: number, variant: string) => { - setSelectedDocument({ dtid, variant }); + const handleSelectedDocumentChange = (dtid: number, documentType: DocType) => { + setSelectedDocument({ dtid, documentType }); }; return ( diff --git a/frontend/src/app/content/pages/documentpreview/DocumentPreview.tsx b/frontend/src/app/content/pages/documentpreview/DocumentPreview.tsx index 8788882b..26a2b0a4 100644 --- a/frontend/src/app/content/pages/documentpreview/DocumentPreview.tsx +++ b/frontend/src/app/content/pages/documentpreview/DocumentPreview.tsx @@ -1,5 +1,9 @@ import React, { useState } from 'react'; -import { getData, getNfrProvisionsByVariantDtid, getNfrVariablesByVariantDtid } from '../../../common/report'; +import { + getData, + getDocumentProvisionsByDocTypeIdDtid, + getDocumentVariablesByDocTypeIdDtid, +} from '../../../common/report'; import DocumentPreviewForm from './DocumentPreviewForm'; import ContactInfoDisplay from './ContactInfoDisplay'; import LicenseDetailDisplay from './LicenseDetailDisplay'; @@ -9,7 +13,6 @@ import ProvisionsTable from './ProvisionsTable'; import './DocumentPreview.scss'; import CustomCollapsible from './CustomCollapsible'; - interface DocumentPreviewResponse { dtid: number; fileNum: string; @@ -40,7 +43,6 @@ interface DocumentPreviewResponse { }>; } - interface Provision { type: string; provision: string; @@ -85,8 +87,8 @@ const DocumentPreview: React.FC = () => { const handleClear = () => { setTenureFileNumber(''); setDtid(''); - setIsOpen(false) - setDocumentPreviewResponse(null) + setIsOpen(false); + setDocumentPreviewResponse(null); }; const [provisions, setProvisions] = useState([ @@ -97,25 +99,22 @@ const DocumentPreview: React.FC = () => { const [documentType, setDocumentType] = useState('STANDARD_LICENSE'); - const handleCheckboxChange = (index: number) => { provisions[index].included = !provisions[index].included; }; - - const fetchData = async () => { - const nfrData = await getData(parseInt(dtid)) as DocumentPreviewResponse; + const nfrData = (await getData(1, parseInt(dtid))) as DocumentPreviewResponse; if (nfrData) { - setDocumentPreviewResponse(nfrData) - const dataProvisions = await getNfrProvisionsByVariantDtid("NOTICE OF FINAL REVIEW", 928437); - const dataVariables = await getNfrVariablesByVariantDtid("NOTICE OF FINAL REVIEW", 928437); + setDocumentPreviewResponse(nfrData); + const dataProvisions = await getDocumentProvisionsByDocTypeIdDtid(1, 928437); + const dataVariables = await getDocumentVariablesByDocTypeIdDtid(1, 928437); setIsOpen(true); } }; const handleRetrieve = () => { - if (tenureFileNumber !== "" && dtid !== "") { + if (tenureFileNumber !== '' && dtid !== '') { fetchData(); } }; @@ -123,83 +122,91 @@ const DocumentPreview: React.FC = () => { const toggleCollapsible = () => setIsOpen(!isOpen); - - - - return (
- - - {documentPreviewResponse !== null ? : ""} + isSpanRequired={false} + > + {documentPreviewResponse !== null ? ( + + ) : ( + '' + )} - - - {documentPreviewResponse !== null ? : ""} + isSpanRequired={false} + > + {documentPreviewResponse !== null ? ( + + ) : ( + '' + )} - - - {documentPreviewResponse !== null ? : ""} + isSpanRequired={false} + > + {documentPreviewResponse !== null ? ( + + ) : ( + '' + )}

Create Document


-
- - + { /> - - +
- - + +
); diff --git a/frontend/src/app/types/types.ts b/frontend/src/app/types/types.ts index 27ac130b..bb39f76b 100644 --- a/frontend/src/app/types/types.ts +++ b/frontend/src/app/types/types.ts @@ -112,13 +112,13 @@ export interface InterestedParties { address: string | null; } -export type NfrDataVariableObject = { +export type DocumentDataVariableObject = { data_variable_value: string; id: number; - nfr_variable: NfrVariableObject; + provision_variable: ProvisionVariableObject; }; -export type NfrVariableObject = { +export type ProvisionVariableObject = { id: number; variable_name: string; variable_value: string; @@ -129,13 +129,13 @@ export type NfrVariableObject = { update_timestamp: string; }; -export type NfrDataProvisionObject = { +export type DocumentDataProvisionObject = { provision_free_text: string; id: number; - provision: NfrProvisionObject; + provision: ProvisionObject; }; -export type NfrProvisionObject = { +export type ProvisionObject = { type: string; provision_name: string; free_text: string; @@ -157,10 +157,9 @@ export type ProvisionGroup = { max: number; }; -export type NfrDataObject = { - nfrData: { +export type DocumentDataObject = { + documentData: { dtid: number; - variant_name: string; template_id: number; status: string; create_userid: string; @@ -169,8 +168,9 @@ export type NfrDataObject = { active: boolean; create_timestamp: string; update_timestamp: string; - document_data_provisions: NfrDataProvisionObject; - document_data_variables: NfrDataVariableObject; + document_data_provisions: DocumentDataProvisionObject; + document_data_variables: DocumentDataVariableObject; + document_type: any; // }; provisionIds: number[]; variableIds: number[]; @@ -204,7 +204,7 @@ export type Provision = { edit: any; // remove from route help_text: string; id: number; - variants: any; // seems to be a string array which gets converted to string and saved in the cell + document_type_ids: number[]; // }; export type Variable = { @@ -226,7 +226,7 @@ export type ProvisionUpload = { free_text: string; help_text: string; category: string; - variants: any; + document_type_ids: number[]; // }; export type VariableUpload = { @@ -243,11 +243,11 @@ export type SearchData = { updated_date: string; status: string; active: boolean; - nfr_id: number; - variant_name: string; + document_data_id: number; // + document_type: DocType; // }; -export type DocumentType = { +export type DocType = { id: number; name: string; create_userid: string; From c619a0269232b1ecb801ffb95ab7486526e2eaba Mon Sep 17 00:00:00 2001 From: mgtennant <100305096+mgtennant@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:49:11 -0700 Subject: [PATCH 5/7] decent state --- backend/src/admin/admin.controller.ts | 10 +- backend/src/admin/admin.service.ts | 112 ++++----- .../document_data/document_data.service.ts | 40 ++-- .../document_template.controller.ts | 2 +- .../document_template.service.ts | 4 +- .../document_type/document_type.service.ts | 10 +- .../entities/provision_group.entity.ts | 4 +- backend/src/provision/provision.controller.ts | 12 +- backend/src/provision/provision.module.ts | 4 +- backend/src/provision/provision.service.ts | 18 +- backend/src/report/report.controller.ts | 4 +- backend/src/ttls/ttls.service.ts | 132 +++++----- frontend/src/app/App.tsx | 26 +- frontend/src/app/common/manage-templates.ts | 8 +- .../manage-templates/AddProvisionModal.tsx | 5 +- .../manage-templates/EditProvisionModal.tsx | 6 - .../manage-templates/RemoveTemplateModal.tsx | 12 +- .../forms/EditProvisionModalForm.tsx | 14 +- .../ManageProvisionsTable.tsx | 29 +-- .../manage-templates/TemplateInfoTable.tsx | 23 +- frontend/src/app/content/display/Header.tsx | 2 +- frontend/src/app/content/pages/AdminPage.tsx | 26 +- .../content/pages/ManageProvisionsPage.tsx | 96 ++++++++ .../app/content/pages/ManageTemplatesPage.tsx | 225 +++++++++--------- .../content/pages/SystemAdministration.tsx | 92 ++++--- .../app/content/pages/UploadReportsPage.tsx | 104 ++++++++ frontend/src/app/util/constants.ts | 8 +- 27 files changed, 605 insertions(+), 423 deletions(-) create mode 100644 frontend/src/app/content/pages/ManageProvisionsPage.tsx create mode 100644 frontend/src/app/content/pages/UploadReportsPage.tsx diff --git a/backend/src/admin/admin.controller.ts b/backend/src/admin/admin.controller.ts index b4b3b58e..a3ad8ac9 100644 --- a/backend/src/admin/admin.controller.ts +++ b/backend/src/admin/admin.controller.ts @@ -178,10 +178,10 @@ export class AdminController { return this.adminService.removeAdmin(input.idirUsername); } - @Get('templates/:reportId') - getTemplates(@Param('reportId') reportId: number): Promise { - return this.adminService.getTemplates(reportId); - } + // @Get('templates/:reportId') + // getTemplates(@Param('reportId') reportId: number): Promise { + // return this.adminService.getTemplates(reportId); + // } @Get('open-document/:document_id') setSessionDocument(@Session() session: { data?: SessionData }, @Param('document_id') documentId: number): void { @@ -251,7 +251,7 @@ export class AdminController { free_text: string; help_text: string; category: string; - variants: number[]; + document_type_ids: number[]; }, @Session() session: { data?: SessionData } ) { diff --git a/backend/src/admin/admin.service.ts b/backend/src/admin/admin.service.ts index 092fda38..bb1902e9 100644 --- a/backend/src/admin/admin.service.ts +++ b/backend/src/admin/admin.service.ts @@ -259,72 +259,59 @@ export class AdminService { return { message: 'error' }; } - async getTemplates(document_type_id: number) { - const data = await this.documentTemplateService.findAll(document_type_id); - let documents: { - version: number; - file_name: string; - updated_date: string; - status: string; - active: boolean; - template_id: number; - }[] = []; - for (let entry of data) { - const document = { - version: entry.template_version, - file_name: entry.file_name, - updated_date: entry.update_timestamp.toString().split('T')[0], - status: '???', - active: entry.active_flag, - template_id: entry.id, - }; - documents.push(document); - } - return documents; - } + // async getTemplates(document_type_id: number) { + // const data = await this.documentTemplateService.findAll(document_type_id); + // let documents: { + // version: number; + // file_name: string; + // updated_date: string; + // status: string; + // active: boolean; + // template_id: number; + // }[] = []; + // for (let entry of data) { + // const document = { + // version: entry.template_version, + // file_name: entry.file_name, + // updated_date: entry.update_timestamp.toString().split('T')[0], + // status: '???', + // active: entry.active_flag, + // template_id: entry.id, + // }; + // documents.push(document); + // } + // return documents; + // } async getDocumentTemplates(document_type_id: number): Promise { - const returnItems = ['id', 'template_version', 'file_name', 'uploaded_date', 'active_flag', 'update_timestamp']; const documentTemplateObjects = await this.documentTemplateService.findAll(document_type_id); - return documentTemplateObjects.map((obj) => - Object.keys(obj) - .filter((key) => returnItems.includes(key)) - .reduce( - (acc, key) => { - key == 'update_timestamp' ? (acc[key] = obj[key].toString().split('T')[0]) : (acc[key] = obj[key]); - return acc; - }, - { view: 'view', remove: 'remove' } - ) - ); + const formattedDate = (date: Date) => date.toISOString().split('T')[0]; + return documentTemplateObjects.map((template) => { + return { + id: template.id, + template_version: template.template_version, + file_name: template.file_name, + active_flag: template.active_flag, + update_timestamp: formattedDate(template.update_timestamp), + }; + }); } async getDocumentProvisions(): Promise { - const returnItems = [ - 'id', - 'dtid', - 'type', - 'provision_group', - 'max', - 'provision_name', - 'free_text', - 'help_text', - 'category', - 'active_flag', - 'variants', - ]; const documentProvisions = await this.provisionService.findAll(); - return documentProvisions.map((obj) => - Object.keys(obj) - .filter((key) => returnItems.includes(key)) - .reduce( - (acc, key) => { - acc[key] = obj[key]; - return acc; - }, - { edit: 'edit' } - ) - ); + return documentProvisions.map((provision) => ({ + id: provision.id, + type: provision.type, + provision_group: provision.provision_group, + max: provision.max, + provision_name: provision.provision_name, + free_text: provision.free_text, + help_text: provision.help_text, + category: provision.category, + active_flag: provision.active_flag, + // transform document_types to an array of ids + document_type_ids: provision.document_types.map((dt) => dt.id), + })); } async getDocumentVariables(): Promise { @@ -383,11 +370,14 @@ export class AdminService { free_text: string; help_text: string; category: string; - variants: number[]; + document_type_ids: number[]; }, update_userid: string ) { - return this.provisionService.update(provisionParams.id, { ...provisionParams, update_userid }); + return this.provisionService.update(provisionParams.id, provisionParams.document_type_ids, { + ...provisionParams, + update_userid, + }); } addVariable( diff --git a/backend/src/document_data/document_data.service.ts b/backend/src/document_data/document_data.service.ts index 26bed656..23821cd0 100644 --- a/backend/src/document_data/document_data.service.ts +++ b/backend/src/document_data/document_data.service.ts @@ -73,13 +73,13 @@ export class DocumentDataService { documentDataDto.document_type_id ); documentDataDto['template_id'] = documentTemplate ? documentTemplate.id : null; - const newNfrData: DocumentData = this.documentDataRepository.create(documentDataDto); - const updatedNfrData = await this.documentDataRepository.save(newNfrData); + const newDocumentData: DocumentData = this.documentDataRepository.create(documentDataDto); + const updatedDocumentData = await this.documentDataRepository.save(newDocumentData); const documentDataProvisions = provisionArray.map(({ provision_id, free_text }) => { const documentProvision = documentProvisions.find((provision) => provision.id === provision_id); const documentDataProvision = new DocumentDataProvision(); - documentDataProvision.document_data = updatedNfrData; + documentDataProvision.document_data = updatedDocumentData; documentDataProvision.document_provision = documentProvision; documentDataProvision.provision_free_text = documentProvision.free_text; // quick fix to not use the free_text from the document page return documentDataProvision; @@ -87,7 +87,7 @@ export class DocumentDataService { const documentDataVariables = variableArray.map(({ variable_id, variable_value }) => { const documentVariable = documentVariables.find((variable) => variable.id === variable_id); const documentDataVariable = new DocumentDataVariable(); - documentDataVariable.document_data = updatedNfrData; + documentDataVariable.document_data = updatedDocumentData; documentDataVariable.document_variable = documentVariable; documentDataVariable.data_variable_value = variable_value; return documentDataVariable; @@ -99,7 +99,7 @@ export class DocumentDataService { await this.documentDataProvisionRepository.save(documentDataProvisions); await this.documentDataVariableRepository.save(documentDataVariables); - return updatedNfrData; + return updatedDocumentData; } async updateDocumentData( @@ -110,14 +110,14 @@ export class DocumentDataService { documentProvisions: Provision[], documentVariables: ProvisionVariable[] ): Promise { - // Update NFRData entity + // Update DocumentData entity documentData.template_id = documentDataDto.template_id; documentData.status = documentDataDto.status; documentData.update_userid = documentDataDto.create_userid; - const updatedNfrData = await this.documentDataRepository.save(documentData); + const updatedDocumentData = await this.documentDataRepository.save(documentData); - // Update NFRDataProvision entities + // Update DocumentDataProvision entities for (const provision of provisionArray) { const documentDataProvision = documentData.document_data_provisions.find( (p) => p.document_provision.id === provision.provision_id @@ -125,49 +125,49 @@ export class DocumentDataService { const documentProvision = documentProvisions.find((p) => p.id === provision.provision_id); if (documentDataProvision && documentDataProvision.provision_free_text != documentProvision.free_text) { - // Update an existing NFRDataProvision entry + // Update an existing DocumentDataProvision entry documentDataProvision.provision_free_text = documentProvision.free_text; await this.documentDataProvisionRepository.save(documentDataProvision); } else if (!documentDataProvision) { - // No data found for this specific provision so create a new entry in NFRDataProvision + // No data found for this specific provision so create a new entry in DocumentDataProvision const documentProvisionToAdd = await this.documentProvisionRepository.findOneBy({ id: provision.provision_id, }); - const newNfrDataProvision: DocumentDataProvision = this.documentDataProvisionRepository.create({ + const newDocumentDataProvision: DocumentDataProvision = this.documentDataProvisionRepository.create({ document_provision: documentProvisionToAdd, - document_data: updatedNfrData, + document_data: updatedDocumentData, provision_free_text: documentProvisionToAdd.free_text, // quick fix }); - await this.documentDataProvisionRepository.save(newNfrDataProvision); + await this.documentDataProvisionRepository.save(newDocumentDataProvision); } } - // Update NFRDataVariable entities + // Update DocumentDataVariable entities for (const variable of variableArray) { const documentDataVariable = documentData.document_data_variables.find( (v) => v.document_variable.id === variable.variable_id ); if (documentDataVariable && documentDataVariable.data_variable_value != variable.variable_value) { - // Update an existing NFRDataVariable entry + // Update an existing DocumentDataVariable entry documentDataVariable.data_variable_value = variable.variable_value; await this.documentDataVariableRepository.save(documentDataVariable); } else if (!documentDataVariable) { - // No data found for this specific variable so create a new entry in NFRDataVariable + // No data found for this specific variable so create a new entry in DocumentDataVariable const documentVariable = await this.documentProvisionVariableRepository.findOneBy({ id: variable.variable_id, }); - const newNfrDataVariable: DocumentDataVariable = this.documentDataVariableRepository.create({ + const newDocumentDataVariable: DocumentDataVariable = this.documentDataVariableRepository.create({ document_variable: documentVariable, - document_data: updatedNfrData, + document_data: updatedDocumentData, data_variable_value: variable.variable_value, }); - await this.documentDataVariableRepository.save(newNfrDataVariable); + await this.documentDataVariableRepository.save(newDocumentDataVariable); } } await this.deleteDataVarsAndProvs(documentData, provisionArray, variableArray); - return updatedNfrData; + return updatedDocumentData; } async deleteDataVarsAndProvs( diff --git a/backend/src/document_template/document_template.controller.ts b/backend/src/document_template/document_template.controller.ts index 6e4ecde8..daa1ca7b 100644 --- a/backend/src/document_template/document_template.controller.ts +++ b/backend/src/document_template/document_template.controller.ts @@ -66,7 +66,7 @@ export class DocumentTemplateController { return this.templateService.findOne(id); } - @Post('nfr-template-info') + @Post('document-template-info') getTemplatesInfoByIds(@Body() ids: number[]): Promise { return this.templateService.getTemplatesInfoByIds(ids); } diff --git a/backend/src/document_template/document_template.service.ts b/backend/src/document_template/document_template.service.ts index b922b99f..15c035f3 100644 --- a/backend/src/document_template/document_template.service.ts +++ b/backend/src/document_template/document_template.service.ts @@ -11,10 +11,9 @@ import { DocumentTypeService } from 'src/document_type/document_type.service'; @Injectable() export class DocumentTemplateService { constructor( + private documentTypeService: DocumentTypeService, @InjectRepository(DocumentTemplate) private documentTemplateRepository: Repository, - @InjectRepository(DocumentType) - private documentTypeService: DocumentTypeService, @InjectRepository(DocumentData) private documentDataRepository: Repository ) {} @@ -161,7 +160,6 @@ export class DocumentTemplateService { // } async findAll(document_type_id: number): Promise { - const docType: DocumentType = await this.documentTypeService.findById(document_type_id); return this.documentTemplateRepository.find({ where: { is_deleted: false, document_type: { id: document_type_id } }, }); diff --git a/backend/src/document_type/document_type.service.ts b/backend/src/document_type/document_type.service.ts index ad98be07..9e524007 100644 --- a/backend/src/document_type/document_type.service.ts +++ b/backend/src/document_type/document_type.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; -import { Repository } from 'typeorm'; +import { In, Repository } from 'typeorm'; import { DocumentType } from './entities/document_type.entity'; @Injectable() @@ -9,8 +9,14 @@ export class DocumentTypeService { @InjectRepository(DocumentType) private documentTypeRepository: Repository ) {} + findById(id: number): Promise { - return this.documentTypeRepository.findOneByOrFail({ id: id }); + console.log('findById function'); + return this.documentTypeRepository.findOneBy({ id: id }); + } + + findByIds(ids: number[]): Promise { + return this.documentTypeRepository.findBy({ id: In(ids) }); } findAll(): Promise { diff --git a/backend/src/provision/entities/provision_group.entity.ts b/backend/src/provision/entities/provision_group.entity.ts index a5c44112..29cbee24 100644 --- a/backend/src/provision/entities/provision_group.entity.ts +++ b/backend/src/provision/entities/provision_group.entity.ts @@ -4,8 +4,8 @@ import { DocumentType } from 'src/document_type/entities/document_type.entity'; /** * This entity holds group descriptions and provision maximums - * based on group number. Every NFRProvision is associated with - * an NFRProvisionGroup. + * based on group number. Every Provision is associated with + * a ProvisionGroup. */ @Entity() export class ProvisionGroup { diff --git a/backend/src/provision/provision.controller.ts b/backend/src/provision/provision.controller.ts index b213f6b5..97521019 100644 --- a/backend/src/provision/provision.controller.ts +++ b/backend/src/provision/provision.controller.ts @@ -14,12 +14,12 @@ export class ProvisionController { return this.provisionService.create(provision); } - @Post('update') - async update(@Body() provision: CreateProvisionDto & { id: number }) { - const id = provision.id; - delete provision['id']; - return this.provisionService.update(id, provision); - } + // @Post('update') + // async update(@Body() provision: CreateProvisionDto & { id: number }) { + // const id = provision.id; + // delete provision['id']; + // return this.provisionService.update(id, provision); + // } @Post('add-variable') async addVariable( diff --git a/backend/src/provision/provision.module.ts b/backend/src/provision/provision.module.ts index 3f12a732..a3e714a4 100644 --- a/backend/src/provision/provision.module.ts +++ b/backend/src/provision/provision.module.ts @@ -5,14 +5,14 @@ import { ProvisionGroup } from './entities/provision_group.entity'; import { ProvisionController } from './provision.controller'; import { ProvisionService } from './provision.service'; import { ProvisionVariable } from './entities/provision_variable.entity'; -import { DocumentType } from 'src/document_type/entities/document_type.entity'; +import { DocumentTypeModule } from 'src/document_type/document_type.module'; @Module({ imports: [ TypeOrmModule.forFeature([Provision]), TypeOrmModule.forFeature([ProvisionGroup]), TypeOrmModule.forFeature([ProvisionVariable]), - TypeOrmModule.forFeature([DocumentType]), + DocumentTypeModule, ], controllers: [ProvisionController], providers: [ProvisionService], diff --git a/backend/src/provision/provision.service.ts b/backend/src/provision/provision.service.ts index e7c5c3da..d7906607 100644 --- a/backend/src/provision/provision.service.ts +++ b/backend/src/provision/provision.service.ts @@ -6,6 +6,7 @@ import { Provision } from './entities/provision.entity'; import { UpdateProvisionDto } from './dto/update-provision.dto'; import { ProvisionGroup } from './entities/provision_group.entity'; import { ProvisionVariable } from './entities/provision_variable.entity'; +import { DocumentTypeService } from 'src/document_type/document_type.service'; import { DocumentType } from 'src/document_type/entities/document_type.entity'; @Injectable() @@ -17,8 +18,7 @@ export class ProvisionService { private provisionGroupRepository: Repository, @InjectRepository(ProvisionVariable) private provisionVariableRepository: Repository, - @InjectRepository(DocumentType) - private documentTypeRepository: Repository + private documentTypeService: DocumentTypeService ) {} async create(provision: CreateProvisionDto): Promise { @@ -45,7 +45,7 @@ export class ProvisionService { return this.provisionRepository.save(newProvision); } - async update(id: number, provision: UpdateProvisionDto): Promise { + async update(id: number, document_type_ids: number[], provision: UpdateProvisionDto): Promise { const provision_group = Math.floor(provision.provision_group); const provision_group_text = provision.provision_group_text; delete provision['provision_group']; @@ -56,12 +56,16 @@ export class ProvisionService { provision_group, }); const existingProvision: Provision = await this.provisionRepository.findOneBy({ id }); + + const documentTypes: DocumentType[] = await this.documentTypeService.findByIds(document_type_ids); + existingProvision.type = provision.type; existingProvision.provision_name = provision.provision_name; existingProvision.free_text = provision.free_text; existingProvision.help_text = provision.help_text; existingProvision.category = provision.category; existingProvision.update_userid = provision.update_userid; + existingProvision.document_types = documentTypes; const updatedProvision = this.provisionRepository.create({ ...existingProvision, provision_group: provisionGroup, @@ -117,14 +121,16 @@ export class ProvisionService { async findAll(): Promise { const provisions = await this.provisionRepository.find({ - relations: ['provision_group'], + relations: ['provision_group', 'document_types'], }); return provisions.map((provision) => { - delete provision.provision_group['id']; + const { provision_group, document_types, ...restOfProvision } = provision; + delete provision_group['id']; return { ...provision, - ...provision.provision_group, + ...provision_group, + document_types, }; }); } diff --git a/backend/src/report/report.controller.ts b/backend/src/report/report.controller.ts index a6e22c4a..4d582a98 100644 --- a/backend/src/report/report.controller.ts +++ b/backend/src/report/report.controller.ts @@ -57,7 +57,7 @@ export class ReportController { // } @Get('get-document-data/:document_type_id/:dtid') - getNfrData( + getDocumentDataByDocTypeIdAndDtid( @Session() session: { data?: SessionData }, @Param('document_type_id') document_type_id: number, @Param('dtid') dtid: number @@ -175,7 +175,7 @@ export class ReportController { } @Get('search-document-data') - getNFRData() { + getDocumentData() { return this.reportService.getDocumentData(); } diff --git a/backend/src/ttls/ttls.service.ts b/backend/src/ttls/ttls.service.ts index c0b93273..c8ff3c48 100644 --- a/backend/src/ttls/ttls.service.ts +++ b/backend/src/ttls/ttls.service.ts @@ -347,73 +347,73 @@ export class TTLSService { }); } - // TODO - async generateNFRReport(prdid: number, templateId: number, variables: any, username: string) { - const url = `${hostname}:${port}/document-data/view/${prdid}`; - const templateUrl = `${hostname}:${port}/document-template/find-one/${templateId}`; - const logUrl = `${hostname}:${port}/print-request-log/`; - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // TODO get the view for specified prdid from the new NFR entity - const data = await axios - .get(url, { - headers: { - 'Content-Type': 'application/json', - }, - }) - .then((res) => { - return res.data; - }); - if (data.InspectionDate) { - data['InspectionDate'] = this.formatInspectedDate(data.InspectionDate); - } - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // get the document template - const documentTemplateObject: { id: number; the_file: string } = await axios.get(templateUrl).then((res) => { - return res.data; - }); + // // TODO + // async generateNFRReport(prdid: number, templateId: number, variables: any, username: string) { + // const url = `${hostname}:${port}/document-data/view/${prdid}`; + // const templateUrl = `${hostname}:${port}/document-template/find-one/${templateId}`; + // const logUrl = `${hostname}:${port}/print-request-log/`; + // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // // TODO get the view for specified prdid from the new NFR entity + // const data = await axios + // .get(url, { + // headers: { + // 'Content-Type': 'application/json', + // }, + // }) + // .then((res) => { + // return res.data; + // }); + // if (data.InspectionDate) { + // data['InspectionDate'] = this.formatInspectedDate(data.InspectionDate); + // } + // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // // get the document template + // const documentTemplateObject: { id: number; the_file: string } = await axios.get(templateUrl).then((res) => { + // return res.data; + // }); - // log the request - await axios.post(logUrl, { - document_template_id: templateId, - print_request_detail_id: prdid, - dtid: data.DTID, - request_app_user: username, - request_json: JSON.stringify(data), - }); + // // log the request + // await axios.post(logUrl, { + // document_template_id: templateId, + // print_request_detail_id: prdid, + // dtid: data.DTID, + // request_app_user: username, + // request_json: JSON.stringify(data), + // }); - const cdogsToken = await this.callGetToken(); - let bufferBase64 = documentTemplateObject.the_file; - const md = JSON.stringify({ - data, - formatters: - '{"myFormatter":"_function_myFormatter|function(data) { return data.slice(1); }","myOtherFormatter":"_function_myOtherFormatter|function(data) {return data.slice(2);}"}', - options: { - cacheReport: false, - convertTo: 'docx', - overwrite: true, - reportName: 'nfr-report', - }, - template: { - content: `${bufferBase64}`, - encodingType: 'base64', - fileType: 'docx', - }, - }); + // const cdogsToken = await this.callGetToken(); + // let bufferBase64 = documentTemplateObject.the_file; + // const md = JSON.stringify({ + // data, + // formatters: + // '{"myFormatter":"_function_myFormatter|function(data) { return data.slice(1); }","myOtherFormatter":"_function_myOtherFormatter|function(data) {return data.slice(2);}"}', + // options: { + // cacheReport: false, + // convertTo: 'docx', + // overwrite: true, + // reportName: 'nfr-report', + // }, + // template: { + // content: `${bufferBase64}`, + // encodingType: 'base64', + // fileType: 'docx', + // }, + // }); - const conf = { - method: 'post', - url: process.env.cdogs_url, - headers: { - Authorization: `Bearer ${cdogsToken}`, - 'Content-Type': 'application/json', - }, - responseType: 'arraybuffer', - data: md, - }; - const ax = require('axios'); - const response = await ax(conf).catch((error) => { - console.log(error.response); - }); - return response.data; - } + // const conf = { + // method: 'post', + // url: process.env.cdogs_url, + // headers: { + // Authorization: `Bearer ${cdogsToken}`, + // 'Content-Type': 'application/json', + // }, + // responseType: 'arraybuffer', + // data: md, + // }; + // const ax = require('axios'); + // const response = await ax(conf).catch((error) => { + // console.log(error.response); + // }); + // return response.data; + // } } diff --git a/frontend/src/app/App.tsx b/frontend/src/app/App.tsx index 28e55e72..ea6247cb 100644 --- a/frontend/src/app/App.tsx +++ b/frontend/src/app/App.tsx @@ -9,6 +9,9 @@ import SearchPage from './content/pages/SearchPage'; import ManageTemplatesPage from './content/pages/ManageTemplatesPage'; import AdminPage from './content/pages/AdminPage'; import ContentWrapper from './content/ContentWrapper'; +import SystemAdministration from './content/pages/SystemAdministration'; +import UploadReportsPage from './content/pages/UploadReportsPage'; +import ManageProvisionsPage from './content/pages/ManageProvisionsPage'; const App: FC = () => { // used to render report pages @@ -27,40 +30,47 @@ const App: FC = () => {
- + } /> ; - + } /> - ; - + } /> ; } /> + + + + } + /> ; {documentTypes.map((docType) => ( => { - const url = `${config.API_BASE_URL}/admin/get-templates/${reportType.toUpperCase()}`; +export const getTemplatesInfo = async (document_type_id: number): Promise => { + const url = `${config.API_BASE_URL}/admin/get-templates/${document_type_id}`; const getParameters = api.generateApiParameters(url); const response: TemplateInfo[] = await api.get(getParameters); console.log('getTemplatesInfo response'); @@ -30,7 +30,7 @@ export const getProvisions = async (): Promise => { }; export const getVariables = async (): Promise => { - const url = `${config.API_BASE_URL}/admin/nfr-variables`; + const url = `${config.API_BASE_URL}/admin/document-variables`; const getParameters = api.generateApiParameters(url); const response: Variable[] = await api.get(getParameters); console.log('getVariables response'); @@ -69,7 +69,7 @@ export const removeTemplate = async (id: number, documentTypeId: number): Promis console.log(response); }; -export const activateTemplate = async (id: number, documentTypeId: string): Promise => { +export const activateTemplate = async (id: number, documentTypeId: number): Promise => { const url = `${config.API_BASE_URL}/admin/activate-template/${id}/${documentTypeId}`; const getParameters = api.generateApiParameters(url); await api.get(getParameters); diff --git a/frontend/src/app/components/modal/manage-templates/AddProvisionModal.tsx b/frontend/src/app/components/modal/manage-templates/AddProvisionModal.tsx index 51470fdd..e3815e69 100644 --- a/frontend/src/app/components/modal/manage-templates/AddProvisionModal.tsx +++ b/frontend/src/app/components/modal/manage-templates/AddProvisionModal.tsx @@ -132,6 +132,7 @@ const AddProvisionModal: React.FC = ({ document_type_ids: documentTypeIds, }; addProvisionHandler(provisionUpload); + onHide(); refreshTables(); } } catch (err) { @@ -261,9 +262,9 @@ const AddProvisionModal: React.FC = ({ Document Types {documentTypes && - documentTypes.map((docType) => { + documentTypes.map((docType, index) => { return ( - + diff --git a/frontend/src/app/components/modal/manage-templates/EditProvisionModal.tsx b/frontend/src/app/components/modal/manage-templates/EditProvisionModal.tsx index 6c033967..4d804178 100644 --- a/frontend/src/app/components/modal/manage-templates/EditProvisionModal.tsx +++ b/frontend/src/app/components/modal/manage-templates/EditProvisionModal.tsx @@ -30,8 +30,6 @@ const EditProvisionModal: FC = ({ const [loading, setLoading] = useState(false); const [error, setError] = useState(''); const [showError, setShowError] = useState(false); - const [allVariables, setAllVariables] = useState(variables); - const [currentProvision, setCurrentProvision] = useState(provision); const [currentVariable, setCurrentVariable] = useState(); const [displayEditProvision, setDisplayEditProvision] = useState(true); @@ -80,10 +78,6 @@ const EditProvisionModal: FC = ({ provision_id: provision.id, }; await addVariable(variableUpload); - // if (allVariables && provision) { - // const newVariables = [...allVariables, {variable_name, variable_value, help_text, provision_id: provision.id}]; - // setAllVariables(newVariables); - // } refreshTables(); returnToEditProvision(); } diff --git a/frontend/src/app/components/modal/manage-templates/RemoveTemplateModal.tsx b/frontend/src/app/components/modal/manage-templates/RemoveTemplateModal.tsx index e08fefa2..b3fbcb2e 100644 --- a/frontend/src/app/components/modal/manage-templates/RemoveTemplateModal.tsx +++ b/frontend/src/app/components/modal/manage-templates/RemoveTemplateModal.tsx @@ -7,12 +7,20 @@ import { removeTemplate } from '../../../common/manage-templates'; type RemoveTemplateModalProps = { templateId: number; documentTypeId: number; + documentTypeName: string; show: boolean; onHide: () => void; onRemove: () => void; }; -const RemoveTemplateModal: FC = ({ templateId, documentTypeId, show, onHide, onRemove }) => { +const RemoveTemplateModal: FC = ({ + templateId, + documentTypeId, + documentTypeName, + show, + onHide, + onRemove, +}) => { const [loading, setLoading] = useState(false); const [error, setError] = useState(''); const [showError, setShowError] = useState(false); @@ -37,7 +45,7 @@ const RemoveTemplateModal: FC = ({ templateId, documen return ( - Remove Administrator + Remove Template: {documentTypeName} ), diff --git a/frontend/src/app/content/display/Header.tsx b/frontend/src/app/content/display/Header.tsx index d84fbaeb..35cd04fe 100644 --- a/frontend/src/app/content/display/Header.tsx +++ b/frontend/src/app/content/display/Header.tsx @@ -42,7 +42,7 @@ const Header: FC = ({ isAdmin, idirUsername }) => {
{isAdmin && ( diff --git a/frontend/src/app/content/pages/AdminPage.tsx b/frontend/src/app/content/pages/AdminPage.tsx index c9b9430c..d94d3a12 100644 --- a/frontend/src/app/content/pages/AdminPage.tsx +++ b/frontend/src/app/content/pages/AdminPage.tsx @@ -1,17 +1,17 @@ import { FC, useState } from 'react'; -import { REPORT_TYPES } from '../../util/constants'; +// import { REPORT_TYPES } from '../../util/constants'; import AddAdmin from '../../components/modal/admin/AddAdmin'; import RemoveAdmin from '../../components/modal/admin/RemoveAdmin'; -import { useNavigate } from 'react-router-dom'; +// import { useNavigate } from 'react-router-dom'; import { exportUsers } from '../../common/admin'; import AdminDataTable, { AdminData } from '../../components/table/admin/AdminDataTable'; const AdminPage: FC = () => { - const navigate = useNavigate(); + // const navigate = useNavigate(); const [selectedAdmin, setSelectedAdmin] = useState(null); const [showAddAdminModal, setShowAddAdminModal] = useState(false); const [showRemoveAdminModal, setShowRemoveAdminModal] = useState(false); - const [selectedReport, setSelectedReport] = useState('0'); + // const [selectedReport, setSelectedReport] = useState('0'); const [searchTerm, setSearchTerm] = useState(''); const showAddAdminModalHandler = (e: React.MouseEvent) => { @@ -29,18 +29,18 @@ const AdminPage: FC = () => { setShowRemoveAdminModal(false); }; - const selectedReportHandler = (event: React.ChangeEvent) => { - setSelectedReport(event.target.value); - }; + // const selectedReportHandler = (event: React.ChangeEvent) => { + // setSelectedReport(event.target.value); + // }; const exportUserListHandler = async (event: React.MouseEvent) => { event.preventDefault(); await exportUsers(); }; - const manageReportsHandler = () => { - navigate(`/manage-templates/${selectedReport}`); - }; + // const manageReportsHandler = () => { + // navigate(`/manage-templates/${selectedReport}`); + // }; const handleSearchChange = (e: React.ChangeEvent) => { setSearchTerm(e.target.value); @@ -48,7 +48,7 @@ const AdminPage: FC = () => { return ( <> -

System Administration

+

Manage Administrators


List of TICDI Administrators

@@ -85,7 +85,7 @@ const AdminPage: FC = () => {
-
+ {/*

Manage Templates

@@ -118,7 +118,7 @@ const AdminPage: FC = () => { Manage
-
+ */} {showAddAdminModal && } {selectedAdmin && showRemoveAdminModal && ( diff --git a/frontend/src/app/content/pages/ManageProvisionsPage.tsx b/frontend/src/app/content/pages/ManageProvisionsPage.tsx new file mode 100644 index 00000000..e5b33d5a --- /dev/null +++ b/frontend/src/app/content/pages/ManageProvisionsPage.tsx @@ -0,0 +1,96 @@ +import { FC, useEffect, useState } from 'react'; +import ManageProvisionsTable from '../../components/table/manage-templates/ManageProvisionsTable'; +import { Button } from 'react-bootstrap'; +import { DocType, GroupMax, Provision, ProvisionUpload, Variable } from '../../types/types'; +import { addProvision, getGroupMax, getProvisions, getVariables, updateProvision } from '../../common/manage-templates'; +import EditProvisionModal from '../../components/modal/manage-templates/EditProvisionModal'; +import AddProvisionModal from '../../components/modal/manage-templates/AddProvisionModal'; +import { getDocumentTypes } from '../../common/report'; + +interface ManageProvisionsPageProps {} + +const ManageProvisionsPage: FC = () => { + const [data, setData] = useState<{ + allProvisions?: Provision[]; + allVariables?: Variable[]; + groupMaxArray?: GroupMax[]; + documentTypes?: DocType[]; + }>({}); + const [currentProvision, setCurrentProvision] = useState(); + const [showEditProvisionModal, setShowEditProvisionModal] = useState(false); + const [showAddProvisionModal, setShowAddProvisionModal] = useState(false); + const [refreshTrigger, setRefreshTrigger] = useState(0); + + useEffect(() => { + const getData = async () => { + const groupMaxArray = await getGroupMax(); + const provisions = await getProvisions(); + const variables = await getVariables(); + const documentTypes = await getDocumentTypes(); + setData({ allProvisions: provisions, allVariables: variables, groupMaxArray, documentTypes }); + }; + getData(); + }, [refreshTrigger]); + + useEffect(() => { + if (currentProvision && data.allProvisions) { + const updatedProvision: Provision | undefined = data.allProvisions.find((p) => p.id === currentProvision.id); + if (updatedProvision) setCurrentProvision(updatedProvision); + } + }, [currentProvision, data.allProvisions]); + + const refreshTables = () => { + setRefreshTrigger((prev) => prev + 1); + }; + + const openEditProvisionModal = (provision: Provision, variables: Variable[]) => { + setCurrentProvision(provision); + setShowEditProvisionModal(true); + }; + + const updateProvisionHandler = async (provisionUpload: ProvisionUpload, provisionId: number) => { + await updateProvision({ ...provisionUpload, id: provisionId }); + }; + + const addProvisionHandler = async (provisionUpload: ProvisionUpload) => { + await addProvision(provisionUpload); + }; + + const currentVariables = data.allVariables?.filter((v) => v.provision_id === currentProvision?.id) || []; + + return ( + <> +

Manage Provisions

+
+ + + + setShowEditProvisionModal(false)} + updateProvisionHandler={updateProvisionHandler} + refreshTables={refreshTables} + /> + setShowAddProvisionModal(false)} + addProvisionHandler={addProvisionHandler} + refreshTables={refreshTables} + /> + + ); +}; + +export default ManageProvisionsPage; diff --git a/frontend/src/app/content/pages/ManageTemplatesPage.tsx b/frontend/src/app/content/pages/ManageTemplatesPage.tsx index c3cb8391..341ecd16 100644 --- a/frontend/src/app/content/pages/ManageTemplatesPage.tsx +++ b/frontend/src/app/content/pages/ManageTemplatesPage.tsx @@ -87,118 +87,119 @@ const ManageTemplatesPage: FC = () => { }; return ( - <> -

Manage Templates

-
- {/** TO BE MOVED TO IT'S OWN PAGE */} - {reportType === 'Notice of Final Review' ? ( - <> - - - - - - - - - - - - - - - - - - - - - - - - - - ) : ( - - - - - )} - setShowUploadModal(false)} - onUpload={refreshTables} - documentTypeId={1} - documentTypeName="placeholder" - /> - setShowRemoveTemplateModal(false)} - onRemove={refreshTables} - documentTypeId={1} - templateId={currentReportId} - /> - setShowEditProvisionModal(false)} - updateProvisionHandler={updateProvisionHandler} - refreshTables={refreshTables} - /> - setShowAddProvisionModal(false)} - addProvisionHandler={addProvisionHandler} - refreshTables={refreshTables} - /> - + <> + // <> + //

Manage Templates

+ //
+ // {/** TO BE MOVED TO IT'S OWN PAGE */} + // {reportType === 'Notice of Final Review' ? ( + // <> + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // ) : ( + // + // + // + // + // )} + // setShowUploadModal(false)} + // onUpload={refreshTables} + // documentTypeId={1} + // documentTypeName="placeholder" + // /> + // setShowRemoveTemplateModal(false)} + // onRemove={refreshTables} + // documentTypeId={1} + // templateId={currentReportId} + // /> + // setShowEditProvisionModal(false)} + // updateProvisionHandler={updateProvisionHandler} + // refreshTables={refreshTables} + // /> + // setShowAddProvisionModal(false)} + // addProvisionHandler={addProvisionHandler} + // refreshTables={refreshTables} + // /> + // ); }; diff --git a/frontend/src/app/content/pages/SystemAdministration.tsx b/frontend/src/app/content/pages/SystemAdministration.tsx index 6d0b243b..ebf27b11 100644 --- a/frontend/src/app/content/pages/SystemAdministration.tsx +++ b/frontend/src/app/content/pages/SystemAdministration.tsx @@ -1,66 +1,58 @@ import React from 'react'; +import { Button } from 'react-bootstrap'; import { useNavigate } from 'react-router-dom'; interface ManagementOption { - id: string; - label: string; + id: string; + label: string; } const managementOptions: ManagementOption[] = [ - { id: 'administrators', label: 'Manage Administrators' }, - { id: 'documentTypes', label: 'Manage Document Types' }, - { id: 'templates', label: 'Manage Templates' }, - { id: 'provisions', label: 'Manage Provisions' }, + { id: 'administrators', label: 'Manage Administrators' }, + { id: 'documentTypes', label: 'Manage Document Types' }, + { id: 'templates', label: 'Manage Templates' }, + { id: 'provisions', label: 'Manage Provisions' }, ]; const SystemAdministration: React.FC = () => { - const navigate = useNavigate(); + const navigate = useNavigate(); + const handleGoClick = (optionId: string) => { + switch (optionId) { + case 'administrators': + navigate(`/manage-admins`); + break; + case 'documentTypes': + console.log('Go to Manage Document Types'); + break; + case 'templates': + navigate(`/manage-templates`); + break; + case 'provisions': + navigate(`/manage-provisions`); + break; + default: + break; + } + }; - const handleGoClick = (optionId: string) => { - switch (optionId) { - case 'administrators': - console.log('Go to Manage Administrators'); - navigate(`/system-admin`); - break; - case 'documentTypes': - console.log('Go to Manage Document Types'); - break; - case 'templates': - console.log('Go to Manage Templates'); - navigate(`/manage-templates-select`); - break; - case 'provisions': - console.log('Go to Manage Provisions'); - break; - default: - console.log('Unknown option'); - break; - } - }; - - return ( -
-

System Administration

-
- {managementOptions.map((option) => ( -
- {option.label} - -
- ))} + return ( +
+

System Administration

+
+ {managementOptions.map((option) => ( +
+ {option.label} +
- ); + ))} +
+ ); }; export default SystemAdministration; diff --git a/frontend/src/app/content/pages/UploadReportsPage.tsx b/frontend/src/app/content/pages/UploadReportsPage.tsx new file mode 100644 index 00000000..a4ca601b --- /dev/null +++ b/frontend/src/app/content/pages/UploadReportsPage.tsx @@ -0,0 +1,104 @@ +import { FC, useEffect, useState } from 'react'; +import TemplateInfoTable from '../../components/table/manage-templates/TemplateInfoTable'; +import { Button } from 'react-bootstrap'; +import { DocType } from '../../types/types'; +import UploadTemplateModal from '../../components/modal/manage-templates/UploadTemplateModal'; +import RemoveTemplateModal from '../../components/modal/manage-templates/RemoveTemplateModal'; +import { getDocumentTypes } from '../../common/report'; + +// switch the name of this page to manage templates after manage provisions/variables page is created + +const UploadReportsPage: FC = () => { + const [showUploadModal, setShowUploadModal] = useState(false); + const [showRemoveTemplateModal, setShowRemoveTemplateModal] = useState(false); + const [currentReportId, setCurrentReportId] = useState(-1); + const [refreshTrigger, setRefreshTrigger] = useState(0); + const [selectedDocType, setSelectedDocType] = useState(); + const [allDocTypes, setAllDocTypes] = useState([]); + + useEffect(() => { + const getData = async () => { + const docTypeData = await getDocumentTypes(); + setAllDocTypes(docTypeData); + }; + getData(); + }, []); + + useEffect(() => { + refreshTables(); + }, [selectedDocType]); + + const refreshTables = () => { + setRefreshTrigger((prev) => prev + 1); + }; + + const openUploadModal = () => { + setShowUploadModal(true); + }; + + const openRemoveTemplateModal = (id: number) => { + setCurrentReportId(id); + setShowRemoveTemplateModal(true); + }; + + const selectedDocTypeHandler = (event: React.ChangeEvent) => { + const docTypeId: number = parseInt(event.target.value); + setSelectedDocType(allDocTypes.find((docType) => docType.id === docTypeId)); + }; + + return ( + <> +

Manage Templates

+
+
+

Select a Template:

+
+
+
+ +
+
+ {selectedDocType && ( + <> + + + setShowUploadModal(false)} + onUpload={refreshTables} + documentTypeId={selectedDocType.id} + documentTypeName={selectedDocType.name} + /> + setShowRemoveTemplateModal(false)} + onRemove={refreshTables} + documentTypeId={selectedDocType.id} + documentTypeName={selectedDocType.name} + templateId={currentReportId} + /> + + )} + + ); +}; + +export default UploadReportsPage; diff --git a/frontend/src/app/util/constants.ts b/frontend/src/app/util/constants.ts index 304dd969..a6460a2b 100644 --- a/frontend/src/app/util/constants.ts +++ b/frontend/src/app/util/constants.ts @@ -41,16 +41,16 @@ export const PAGE = [ }, { title: 'Document Preview', - path: '/' + path: '/', }, { title: 'Select Manage Templates', - path: 'manage-templates-select' + path: 'manage-templates-select', }, { title: 'System Administration Menu', - path: 'system-admin-menu', - } + path: 'system-admin', + }, ]; // should eventually be stored in a table in the db and obtained from there From cad1ca2f09528f39115a325d41f7f2c52e887f9b Mon Sep 17 00:00:00 2001 From: mgtennant <100305096+mgtennant@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:09:52 -0700 Subject: [PATCH 6/7] doctype page, provision changes --- backend/src/admin/admin.controller.ts | 3 + backend/src/admin/admin.service.ts | 3 + .../document_type/document_type.controller.ts | 25 +- .../document_type/document_type.service.ts | 34 +++ .../entities/document_type.entity.ts | 8 +- .../src/provision/dto/create-provision.dto.ts | 1 + backend/src/provision/dto/provision.dto.ts | 1 + .../src/provision/dto/update-provision.dto.ts | 1 + .../provision/entities/provision.entity.ts | 9 +- backend/src/provision/provision.controller.ts | 2 +- backend/src/provision/provision.service.ts | 26 +- frontend/src/app/App.css | 5 + frontend/src/app/App.tsx | 20 +- frontend/src/app/common/admin.ts | 2 +- frontend/src/app/common/manage-doc-types.ts | 38 +++ frontend/src/app/common/manage-templates.ts | 8 + .../admin/{ => manage-admins}/AddAdmin.tsx | 2 +- .../admin/{ => manage-admins}/RemoveAdmin.tsx | 5 +- .../manage-doc-types/AddDocTypeModal.tsx | 104 ++++++++ .../manage-doc-types/EditDocTypeModal.tsx | 118 ++++++++ .../manage-doc-types/RemoveDocTypeModal.tsx | 61 +++++ .../manage-templates/AddProvisionModal.tsx | 21 +- .../manage-templates/EditProvisionModal.tsx | 4 +- .../manage-templates/RemoveProvisionModal.tsx | 63 +++++ .../manage-templates/RemoveTemplateModal.tsx | 3 +- .../manage-templates/UploadTemplateModal.tsx | 2 +- .../forms/AddVariableModalForm.tsx | 0 .../forms/EditProvisionModalForm.tsx | 24 +- .../forms/EditVariableModalForm.tsx | 2 +- .../forms/RemoveVariableModalForm.tsx | 2 +- frontend/src/app/components/modal/modals.css | 4 - .../table/admin/ManageDocTypesTable.tsx | 87 ++++++ .../ManageProvisionsTable.tsx | 17 +- frontend/src/app/content/pages/AdminPage.tsx | 4 +- .../app/content/pages/ManageDocumentsPage.tsx | 133 +++++++++ .../content/pages/ManageProvisionsPage.tsx | 31 ++- .../src/app/content/pages/ManageTemplates.tsx | 59 ---- .../app/content/pages/ManageTemplatesPage.tsx | 252 +++++------------- .../content/pages/SystemAdministration.tsx | 2 +- .../app/content/pages/UploadReportsPage.tsx | 104 -------- frontend/src/app/types/types.ts | 5 + 41 files changed, 902 insertions(+), 393 deletions(-) create mode 100644 frontend/src/app/common/manage-doc-types.ts rename frontend/src/app/components/modal/admin/{ => manage-admins}/AddAdmin.tsx (98%) rename frontend/src/app/components/modal/admin/{ => manage-admins}/RemoveAdmin.tsx (95%) create mode 100644 frontend/src/app/components/modal/admin/manage-doc-types/AddDocTypeModal.tsx create mode 100644 frontend/src/app/components/modal/admin/manage-doc-types/EditDocTypeModal.tsx create mode 100644 frontend/src/app/components/modal/admin/manage-doc-types/RemoveDocTypeModal.tsx rename frontend/src/app/components/modal/{ => admin}/manage-templates/AddProvisionModal.tsx (94%) rename frontend/src/app/components/modal/{ => admin}/manage-templates/EditProvisionModal.tsx (98%) create mode 100644 frontend/src/app/components/modal/admin/manage-templates/RemoveProvisionModal.tsx rename frontend/src/app/components/modal/{ => admin}/manage-templates/RemoveTemplateModal.tsx (95%) rename frontend/src/app/components/modal/{ => admin}/manage-templates/UploadTemplateModal.tsx (97%) rename frontend/src/app/components/modal/{ => admin}/manage-templates/forms/AddVariableModalForm.tsx (100%) rename frontend/src/app/components/modal/{ => admin}/manage-templates/forms/EditProvisionModalForm.tsx (93%) rename frontend/src/app/components/modal/{ => admin}/manage-templates/forms/EditVariableModalForm.tsx (97%) rename frontend/src/app/components/modal/{ => admin}/manage-templates/forms/RemoveVariableModalForm.tsx (96%) delete mode 100644 frontend/src/app/components/modal/modals.css create mode 100644 frontend/src/app/components/table/admin/ManageDocTypesTable.tsx create mode 100644 frontend/src/app/content/pages/ManageDocumentsPage.tsx delete mode 100644 frontend/src/app/content/pages/ManageTemplates.tsx delete mode 100644 frontend/src/app/content/pages/UploadReportsPage.tsx diff --git a/backend/src/admin/admin.controller.ts b/backend/src/admin/admin.controller.ts index a3ad8ac9..86a8dcbb 100644 --- a/backend/src/admin/admin.controller.ts +++ b/backend/src/admin/admin.controller.ts @@ -230,6 +230,7 @@ export class AdminController { free_text: string; help_text: string; category: string; + order_value: number; variants: number[]; }, @Session() session: { data?: SessionData } @@ -251,11 +252,13 @@ export class AdminController { free_text: string; help_text: string; category: string; + order_value: number; document_type_ids: number[]; }, @Session() session: { data?: SessionData } ) { const update_userid = session?.data?.activeAccount.idir_username; + console.log('order_value: ' + provisionParams.order_value); return this.adminService.updateProvision(provisionParams, update_userid); } diff --git a/backend/src/admin/admin.service.ts b/backend/src/admin/admin.service.ts index bb1902e9..fcf9f3be 100644 --- a/backend/src/admin/admin.service.ts +++ b/backend/src/admin/admin.service.ts @@ -308,6 +308,7 @@ export class AdminService { free_text: provision.free_text, help_text: provision.help_text, category: provision.category, + order_value: provision.order_value, active_flag: provision.active_flag, // transform document_types to an array of ids document_type_ids: provision.document_types.map((dt) => dt.id), @@ -352,6 +353,7 @@ export class AdminService { free_text: string; help_text: string; category: string; + order_value: number; variants: number[]; }, create_userid: string @@ -370,6 +372,7 @@ export class AdminService { free_text: string; help_text: string; category: string; + order_value: number; document_type_ids: number[]; }, update_userid: string diff --git a/backend/src/document_type/document_type.controller.ts b/backend/src/document_type/document_type.controller.ts index 43bc8414..fd4c522c 100644 --- a/backend/src/document_type/document_type.controller.ts +++ b/backend/src/document_type/document_type.controller.ts @@ -1,8 +1,9 @@ -import { Controller, Get, Param, UseFilters, UseGuards } from '@nestjs/common'; +import { Body, Controller, Get, Param, Post, Session, UseFilters, UseGuards } from '@nestjs/common'; import { AuthenticationFilter } from 'src/authentication/authentication.filter'; import { AuthenticationGuard } from 'src/authentication/authentication.guard'; import { GenerateReportGuard } from 'src/authentication/generate-report.guard'; import { DocumentTypeService } from './document_type.service'; +import { SessionData } from 'utils/types'; // @UseFilters(AuthenticationFilter) // @UseGuards(AuthenticationGuard) @@ -16,6 +17,28 @@ export class DocumentTypeController { return this.documentTypeService.findById(id); } + @Post('add') + add(@Body() data: { name: string; created_by: string; created_date: string }, @Session() session: SessionData) { + const create_userid = session?.activeAccount?.idir_username; + console.log(data); + return this.documentTypeService.add(data.name, data.created_by, data.created_date, create_userid); + } + + @Post('update') + update( + @Body() data: { id: number; name: string; created_by: string; created_date: string }, + @Session() session: SessionData + ) { + const update_userid = session?.activeAccount?.idir_username; + return this.documentTypeService.update(data.id, data.name, data.created_by, data.created_date, update_userid); + } + + @Get('remove/:id') + remove(@Param('id') id: number) { + console.log('in remove'); + return this.documentTypeService.remove(id); + } + @Get() findAll() { return this.documentTypeService.findAll(); diff --git a/backend/src/document_type/document_type.service.ts b/backend/src/document_type/document_type.service.ts index 9e524007..437db796 100644 --- a/backend/src/document_type/document_type.service.ts +++ b/backend/src/document_type/document_type.service.ts @@ -22,4 +22,38 @@ export class DocumentTypeService { findAll(): Promise { return this.documentTypeRepository.find(); } + + add(name: string, created_by: string, created_date: string, userid: string): Promise { + const newDocumentType = this.documentTypeRepository.create({ + name: name, + created_by: created_by, + created_date: created_date, + create_userid: userid, + update_userid: userid, + }); + return this.documentTypeRepository.save(newDocumentType); + } + + async update( + id: number, + name: string, + created_by: string, + created_date: string, + userid: string + ): Promise { + await this.documentTypeRepository.update(id, { name, created_by, created_date, update_userid: userid }); + const updatedDocumentType = await this.documentTypeRepository.findOneBy({ id }); + if (!updatedDocumentType) { + throw new Error('DocumentType not found'); + } + return updatedDocumentType; + } + + async remove(id: number): Promise { + const result = await this.documentTypeRepository.delete(id); + + if (result.affected === 0) { + throw new Error(`DocumentType with ID ${id} not found`); + } + } } diff --git a/backend/src/document_type/entities/document_type.entity.ts b/backend/src/document_type/entities/document_type.entity.ts index ef876212..d90bb5e8 100644 --- a/backend/src/document_type/entities/document_type.entity.ts +++ b/backend/src/document_type/entities/document_type.entity.ts @@ -18,6 +18,10 @@ export class DocumentType { id: number; @Column() name: string; + @Column({ nullable: true }) + created_by: string; + @Column({ nullable: true }) + created_date: Date; @Column() create_userid: string; @Column() @@ -41,8 +45,10 @@ export class DocumentType { }) provision_groups: ProvisionGroup[]; - constructor(name?: string, create_userid?: string, update_userid?: string) { + constructor(name?: string, created_by?: string, created_date?: Date, create_userid?: string, update_userid?: string) { this.name = name || ''; + this.created_by = created_by || ''; + this.created_date = created_date || null; this.create_userid = create_userid || ''; this.update_userid = update_userid || ''; } diff --git a/backend/src/provision/dto/create-provision.dto.ts b/backend/src/provision/dto/create-provision.dto.ts index 46777977..6f6a32a0 100644 --- a/backend/src/provision/dto/create-provision.dto.ts +++ b/backend/src/provision/dto/create-provision.dto.ts @@ -11,5 +11,6 @@ export class CreateProvisionDto extends PickType(ProvisionDto, [ 'free_text', 'help_text', 'category', + 'order_value', 'create_userid', ] as const) {} diff --git a/backend/src/provision/dto/provision.dto.ts b/backend/src/provision/dto/provision.dto.ts index 0a92ca35..f96e6e59 100644 --- a/backend/src/provision/dto/provision.dto.ts +++ b/backend/src/provision/dto/provision.dto.ts @@ -8,6 +8,7 @@ export class ProvisionDto { free_text?: string; help_text?: string; category?: string; + order_value?: number; create_userid?: string; update_userid?: string; } diff --git a/backend/src/provision/dto/update-provision.dto.ts b/backend/src/provision/dto/update-provision.dto.ts index b10b8c99..bf5b4c86 100644 --- a/backend/src/provision/dto/update-provision.dto.ts +++ b/backend/src/provision/dto/update-provision.dto.ts @@ -11,5 +11,6 @@ export class UpdateProvisionDto extends PickType(ProvisionDto, [ 'free_text', 'help_text', 'category', + 'order_value', 'update_userid', ] as const) {} diff --git a/backend/src/provision/entities/provision.entity.ts b/backend/src/provision/entities/provision.entity.ts index 25511a81..1c75b21e 100644 --- a/backend/src/provision/entities/provision.entity.ts +++ b/backend/src/provision/entities/provision.entity.ts @@ -29,8 +29,12 @@ export class Provision { @Column({ nullable: true }) category: string; @Column({ nullable: true }) + order_value: number; + @Column({ nullable: true }) active_flag: boolean; @Column({ nullable: true }) + is_deleted: boolean; + @Column({ nullable: true }) create_userid: string; @Column({ nullable: true }) update_userid: string; @@ -70,6 +74,7 @@ export class Provision { free_text?: string, category?: string, active_flag?: boolean, + order_value?: number, create_userid?: string, update_userid?: string, provision_group?: ProvisionGroup @@ -78,9 +83,11 @@ export class Provision { this.provision_name = provision_name || ''; this.free_text = free_text || ''; this.category = category || ''; - this.active_flag = active_flag; + this.active_flag = active_flag || true; + this.order_value = order_value || null; this.create_userid = create_userid || ''; this.update_userid = update_userid || ''; this.provision_group = provision_group || null; + this.is_deleted = false; } } diff --git a/backend/src/provision/provision.controller.ts b/backend/src/provision/provision.controller.ts index 97521019..99d3b5ae 100644 --- a/backend/src/provision/provision.controller.ts +++ b/backend/src/provision/provision.controller.ts @@ -95,7 +95,7 @@ export class ProvisionController { return this.provisionService.getMandatoryProvisions(); } - @Delete(':id') + @Get('remove/:id') remove(@Param('id') id: number) { return this.provisionService.remove(id); } diff --git a/backend/src/provision/provision.service.ts b/backend/src/provision/provision.service.ts index d7906607..056181cc 100644 --- a/backend/src/provision/provision.service.ts +++ b/backend/src/provision/provision.service.ts @@ -64,6 +64,7 @@ export class ProvisionService { existingProvision.free_text = provision.free_text; existingProvision.help_text = provision.help_text; existingProvision.category = provision.category; + existingProvision.order_value = provision.order_value; existingProvision.update_userid = provision.update_userid; existingProvision.document_types = documentTypes; const updatedProvision = this.provisionRepository.create({ @@ -121,6 +122,7 @@ export class ProvisionService { async findAll(): Promise { const provisions = await this.provisionRepository.find({ + where: { is_deleted: false }, relations: ['provision_group', 'document_types'], }); return provisions.map((provision) => { @@ -153,6 +155,7 @@ export class ProvisionService { .innerJoinAndSelect('provision.document_types', 'documentType') .innerJoinAndSelect('provision.provision_group', 'provisionGroup') .where('documentType.id = :documentTypeId', { documentTypeId: document_type_id }) + .andWhere('is_deleted = false') .getMany(); return provisions; @@ -165,6 +168,7 @@ export class ProvisionService { .innerJoin('provision.document_types', 'documentType', 'documentType.id = :document_type_id', { document_type_id, }) + .where('is_deleted = false') .getMany(); if (!provisions.length) { return []; @@ -197,6 +201,7 @@ export class ProvisionService { .innerJoinAndSelect('provision.provision_group', 'provision_group') .innerJoin('provision_group.document_type', 'document_type') .where('document_type.id = :document_type_id', { document_type_id }) + .andWhere('is_deleted = false') .getMany(); return provisions; @@ -221,6 +226,11 @@ export class ProvisionService { return { message: 'Provision Disabled' }; } + async remove(id: number): Promise { + await this.provisionRepository.update(id, { is_deleted: true }); + return { message: 'Provision deleted' }; + } + async getGroupMax(): Promise { const provisions = await this.provisionRepository.find({ relations: ['provision_group'], @@ -274,14 +284,14 @@ export class ProvisionService { return provisions.map((provision) => provision.id); } - async remove(id: number): Promise<{ deleted: boolean; message?: string }> { - try { - await this.provisionRepository.delete(id); - return { deleted: true }; - } catch (err) { - return { deleted: false, message: err.message }; - } - } + // async remove(id: number): Promise<{ deleted: boolean; message?: string }> { + // try { + // await this.provisionRepository.delete(id); + // return { deleted: true }; + // } catch (err) { + // return { deleted: false, message: err.message }; + // } + // } async updateGroupMaximums(provision_group: number, max: number, provision_group_text: string) { let provisionGroup: ProvisionGroup = await this.provisionGroupRepository.findOneBy({ diff --git a/frontend/src/app/App.css b/frontend/src/app/App.css index 8a0f456d..f76d57db 100644 --- a/frontend/src/app/App.css +++ b/frontend/src/app/App.css @@ -26,3 +26,8 @@ .linkButton:hover { color: blue; } + +.removeAdminInput { + color: gray; + min-width: 270px; +} diff --git a/frontend/src/app/App.tsx b/frontend/src/app/App.tsx index ea6247cb..500dba19 100644 --- a/frontend/src/app/App.tsx +++ b/frontend/src/app/App.tsx @@ -10,8 +10,8 @@ import ManageTemplatesPage from './content/pages/ManageTemplatesPage'; import AdminPage from './content/pages/AdminPage'; import ContentWrapper from './content/ContentWrapper'; import SystemAdministration from './content/pages/SystemAdministration'; -import UploadReportsPage from './content/pages/UploadReportsPage'; import ManageProvisionsPage from './content/pages/ManageProvisionsPage'; +import ManageDocumentsPage from './content/pages/ManageDocumentsPage'; const App: FC = () => { // used to render report pages @@ -47,19 +47,26 @@ const App: FC = () => { } /> - + } /> - ; - + + + } + /> + + } /> @@ -71,7 +78,6 @@ const App: FC = () => { } /> - ; {documentTypes.map((docType) => ( { + const url = `${config.API_BASE_URL}/document-type`; + const getParameters = api.generateApiParameters(url); + return api.get(getParameters); +}; + +export const addDocType = (name: string, created_by: string, created_date: string) => { + const url = `${config.API_BASE_URL}/document-type/add`; + const data = { + name, + created_by, + created_date, + }; + const postParameters = api.generateApiParameters(url, data); + return api.post(postParameters); +}; + +export const updateDocType = (id: number, name: string, created_by: string, created_date: string) => { + const url = `${config.API_BASE_URL}/document-type/update`; + const data = { + id, + name, + created_by, + created_date, + }; + const postParameters = api.generateApiParameters(url, data); + return api.post(postParameters); +}; + +export const removeDocType = (id: number) => { + const url = `${config.API_BASE_URL}/document-type/remove/${id}`; + const getParameters = api.generateApiParameters(url); + return api.get(getParameters); +}; diff --git a/frontend/src/app/common/manage-templates.ts b/frontend/src/app/common/manage-templates.ts index d5a157c9..623dca49 100644 --- a/frontend/src/app/common/manage-templates.ts +++ b/frontend/src/app/common/manage-templates.ts @@ -89,6 +89,14 @@ export const addProvision = async (data: ProvisionUpload): Promise => { console.log(response); }; +export const removeProvision = async (id: number): Promise => { + const url = `${config.API_BASE_URL}/provision/remove/${id}`; + const getParameters = api.generateApiParameters(url); + const response = await api.get(getParameters); + console.log('removeProvision response'); + console.log(response); +}; + export const updateProvision = async (data: ProvisionUpload & { id: number }): Promise => { const url = `${config.API_BASE_URL}/admin/update-provision`; const postParameters = api.generateApiParameters(url, data); diff --git a/frontend/src/app/components/modal/admin/AddAdmin.tsx b/frontend/src/app/components/modal/admin/manage-admins/AddAdmin.tsx similarity index 98% rename from frontend/src/app/components/modal/admin/AddAdmin.tsx rename to frontend/src/app/components/modal/admin/manage-admins/AddAdmin.tsx index 2e52ccb1..8c78d69e 100644 --- a/frontend/src/app/components/modal/admin/AddAdmin.tsx +++ b/frontend/src/app/components/modal/admin/manage-admins/AddAdmin.tsx @@ -3,7 +3,7 @@ import Modal from 'react-bootstrap/Modal'; import Button from 'react-bootstrap/Button'; import Form from 'react-bootstrap/Form'; import { Col, Row, Spinner } from 'react-bootstrap'; -import { findIdirUser } from '../../../common/admin'; +import { findIdirUser } from '../../../../common/admin'; type AddAdminProps = { show: boolean; diff --git a/frontend/src/app/components/modal/admin/RemoveAdmin.tsx b/frontend/src/app/components/modal/admin/manage-admins/RemoveAdmin.tsx similarity index 95% rename from frontend/src/app/components/modal/admin/RemoveAdmin.tsx rename to frontend/src/app/components/modal/admin/manage-admins/RemoveAdmin.tsx index d802fa7d..1989652d 100644 --- a/frontend/src/app/components/modal/admin/RemoveAdmin.tsx +++ b/frontend/src/app/components/modal/admin/manage-admins/RemoveAdmin.tsx @@ -1,11 +1,10 @@ import { FC, useState } from 'react'; -import '../modals.css'; -import { AdminData } from '../../table/admin/AdminDataTable'; +import { AdminData } from '../../../table/admin/AdminDataTable'; import Modal from 'react-bootstrap/Modal'; import Button from 'react-bootstrap/Button'; import Form from 'react-bootstrap/Form'; import { Col, Row } from 'react-bootstrap'; -import { removeAdmin } from '../../../common/admin'; +import { removeAdmin } from '../../../../common/admin'; type RemoveAdminProps = { admin: AdminData; diff --git a/frontend/src/app/components/modal/admin/manage-doc-types/AddDocTypeModal.tsx b/frontend/src/app/components/modal/admin/manage-doc-types/AddDocTypeModal.tsx new file mode 100644 index 00000000..48c7c3fa --- /dev/null +++ b/frontend/src/app/components/modal/admin/manage-doc-types/AddDocTypeModal.tsx @@ -0,0 +1,104 @@ +import { FC, useState } from 'react'; +import { Button, Col, Form, Modal, Row, Spinner } from 'react-bootstrap'; +import { DocType } from '../../../../types/types'; + +interface AddDocTypeModalProps { + allDocTypes: DocType[]; + show: boolean; + onHide: () => void; + onAdd: (name: string, created_by: string, created_date: string) => void; +} + +const AddDocTypeModal: FC = ({ allDocTypes, show, onHide, onAdd }) => { + const [name, setName] = useState(''); + const [createdBy, setCreatedBy] = useState(''); + const [createdDate, setCreatedDate] = useState(new Date().toISOString().substring(0, 10)); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(''); + const [showError, setShowError] = useState(false); + const [defaultDisabled, setDefaultDisabled] = useState(true); + + const addDocTypeHandler = async () => { + try { + setLoading(true); + setShowError(false); + const isNameUnique = !allDocTypes.some((docType) => docType.name === name); + if (isNameUnique) { + onAdd(name, createdBy, createdDate); + onHide(); + } else { + setError('That document type name already exists'); + setShowError(true); + } + } catch (err) { + setError('Error adding new Document Type'); + setShowError(true); + console.log(err); + } finally { + setLoading(false); + } + }; + + const handleNameChange = (e: React.ChangeEvent) => { + if (defaultDisabled) setDefaultDisabled(false); + setName(e.target.value); + }; + + const handleCreatedByChange = (e: React.ChangeEvent) => { + console.log(e.target.value); + setCreatedBy(e.target.value); + }; + + const handleCreatedDateChange = (e: React.ChangeEvent) => { + console.log(e.target.value); + setCreatedDate(e.target.value); + }; + + return ( + + + Add Document Type + + +
+ + + Document Type Name: + + + + + + + + Created By: + + + + + + + + Created Date: + + + + + +
+ {showError &&
{error}
} +
+ + + + + +
+ ); +}; + +export default AddDocTypeModal; diff --git a/frontend/src/app/components/modal/admin/manage-doc-types/EditDocTypeModal.tsx b/frontend/src/app/components/modal/admin/manage-doc-types/EditDocTypeModal.tsx new file mode 100644 index 00000000..344123e4 --- /dev/null +++ b/frontend/src/app/components/modal/admin/manage-doc-types/EditDocTypeModal.tsx @@ -0,0 +1,118 @@ +import { FC, useEffect, useState } from 'react'; +import { Button, Col, Form, Modal, Row, Spinner } from 'react-bootstrap'; +import { DocType } from '../../../../types/types'; + +interface EditDocTypeModalProps { + documentType: DocType; + allDocTypes: DocType[]; + show: boolean; + onHide: () => void; + onEdit: (id: number, name: string, created_by: string, created_date: string) => void; +} + +const EditDocTypeModal: FC = ({ documentType, allDocTypes, show, onHide, onEdit }) => { + const [name, setName] = useState(''); + const [createdBy, setCreatedBy] = useState(''); + const [createdDate, setCreatedDate] = useState(''); + const [defaultDisabled, setDefaultDisabled] = useState(true); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(''); + const [showError, setShowError] = useState(false); + + useEffect(() => { + setName(documentType.name); + setCreatedBy(documentType.created_by); + setCreatedDate(documentType.created_date?.substring(0, 10)); + }, [documentType]); + + const editDocTypeHandler = async () => { + try { + setLoading(true); + setShowError(false); + const sameDocTypes = allDocTypes.filter((docType) => { + return docType.name === name; + }); + const isNameUnique = sameDocTypes.length <= 1; // there should only be up to one docType (the current one) that has the same name + const isNameNotEmpty = name.length !== 0; + console.log('name: ' + name); + console.log(sameDocTypes); + console.log(isNameUnique); + if (isNameUnique && isNameNotEmpty) { + onEdit(documentType.id, name, createdBy, createdDate); + onHide(); + } else { + setError('That document type name already exists'); + setShowError(true); + } + } catch (err) { + setError('Error updating Document Type'); + setShowError(true); + console.log(err); + } finally { + setLoading(false); + } + }; + + const handleNameChange = (e: React.ChangeEvent) => { + if (defaultDisabled) setDefaultDisabled(false); + setName(e.target.value); + }; + + const handleCreatedByChange = (e: React.ChangeEvent) => { + if (defaultDisabled) setDefaultDisabled(false); + setCreatedBy(e.target.value); + }; + + const handleCreatedDateChange = (e: React.ChangeEvent) => { + if (defaultDisabled) setDefaultDisabled(false); + setCreatedDate(e.target.value); + }; + + return ( + + + Edit Document Type + + +
+ + + Name: + + + + + + + + Created By: + + + + + + + + Created Date: + + + + + +
+ {showError &&
{error}
} +
+ + + + + +
+ ); +}; + +export default EditDocTypeModal; diff --git a/frontend/src/app/components/modal/admin/manage-doc-types/RemoveDocTypeModal.tsx b/frontend/src/app/components/modal/admin/manage-doc-types/RemoveDocTypeModal.tsx new file mode 100644 index 00000000..6f3c91ac --- /dev/null +++ b/frontend/src/app/components/modal/admin/manage-doc-types/RemoveDocTypeModal.tsx @@ -0,0 +1,61 @@ +import { FC, useState } from 'react'; +import { Button, Form, Modal, Row, Spinner } from 'react-bootstrap'; +import { DocType } from '../../../../types/types'; + +interface RemoveDocTypeModalProps { + documentType: DocType; + show: boolean; + onHide: () => void; + onRemove: (id: number) => void; +} + +const RemoveDocTypeModal: FC = ({ documentType, show, onHide, onRemove }) => { + const [loading, setLoading] = useState(false); + const [error, setError] = useState(''); + const [showError, setShowError] = useState(false); + + const removeDocTypeHandler = async () => { + try { + setLoading(true); + setShowError(false); + onRemove(documentType.id); + onHide(); + } catch (err) { + setError('Error removing Document Type'); + setShowError(true); + console.log(err); + } finally { + setLoading(false); + } + }; + + return ( + + + Remove Document Type + + +
+

Are you sure you want to remove this document type?

+ + + Document Type: {documentType.name} + + +
+ {showError &&
{error}
} +
+ + + + + +
+ ); +}; + +export default RemoveDocTypeModal; diff --git a/frontend/src/app/components/modal/manage-templates/AddProvisionModal.tsx b/frontend/src/app/components/modal/admin/manage-templates/AddProvisionModal.tsx similarity index 94% rename from frontend/src/app/components/modal/manage-templates/AddProvisionModal.tsx rename to frontend/src/app/components/modal/admin/manage-templates/AddProvisionModal.tsx index e3815e69..e8f51de8 100644 --- a/frontend/src/app/components/modal/manage-templates/AddProvisionModal.tsx +++ b/frontend/src/app/components/modal/admin/manage-templates/AddProvisionModal.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react'; -import { DocType, GroupMax, ProvisionUpload } from '../../../types/types'; +import { DocType, GroupMax, ProvisionUpload } from '../../../../types/types'; import { Button, Col, Form, Modal, Row, Spinner } from 'react-bootstrap'; interface AddProvisionModalProps { @@ -11,8 +11,6 @@ interface AddProvisionModalProps { refreshTables: () => void; } -// TODO - variants to be removed, possibly add ability to assign to multiple document types - const AddProvisionModal: React.FC = ({ groupMaxArray, show, @@ -32,6 +30,7 @@ const AddProvisionModal: React.FC = ({ const [freeText, setFreeText] = useState(''); const [helpText, setHelpText] = useState(''); const [category, setCategory] = useState(''); + const [order, setOrder] = useState(1); const [documentTypeIds, setDocumentTypeIds] = useState([]); useEffect(() => { @@ -106,6 +105,10 @@ const AddProvisionModal: React.FC = ({ setCategory(e.target.value); }; + const handleOrderChange = (e: React.ChangeEvent) => { + setOrder(parseInt(e.target.value)); + }; + const handleDocumentTypeIdUpdate = (e: React.ChangeEvent) => { const documentTypeId: number = parseInt(e.target.value); if (e.target.checked) { @@ -129,6 +132,7 @@ const AddProvisionModal: React.FC = ({ free_text: freeText, help_text: helpText, category: category, + order_value: order, document_type_ids: documentTypeIds, }; addProvisionHandler(provisionUpload); @@ -169,9 +173,8 @@ const AddProvisionModal: React.FC = ({ - - + @@ -257,6 +260,14 @@ const AddProvisionModal: React.FC = ({ + + + Order + + + + + Document Types diff --git a/frontend/src/app/components/modal/manage-templates/EditProvisionModal.tsx b/frontend/src/app/components/modal/admin/manage-templates/EditProvisionModal.tsx similarity index 98% rename from frontend/src/app/components/modal/manage-templates/EditProvisionModal.tsx rename to frontend/src/app/components/modal/admin/manage-templates/EditProvisionModal.tsx index 4d804178..1793c4f8 100644 --- a/frontend/src/app/components/modal/manage-templates/EditProvisionModal.tsx +++ b/frontend/src/app/components/modal/admin/manage-templates/EditProvisionModal.tsx @@ -1,7 +1,7 @@ import { FC, useState } from 'react'; import Modal from 'react-bootstrap/Modal'; -import { DocType, GroupMax, Provision, ProvisionUpload, Variable, VariableUpload } from '../../../types/types'; -import { addVariable, removeVariable, updateProvision, updateVariable } from '../../../common/manage-templates'; +import { DocType, GroupMax, Provision, ProvisionUpload, Variable, VariableUpload } from '../../../../types/types'; +import { addVariable, removeVariable, updateProvision, updateVariable } from '../../../../common/manage-templates'; import EditProvisionModalForm from './forms/EditProvisionModalForm'; import AddVariableModalForm from './forms/AddVariableModalForm'; import EditVariableModalForm from './forms/EditVariableModalForm'; diff --git a/frontend/src/app/components/modal/admin/manage-templates/RemoveProvisionModal.tsx b/frontend/src/app/components/modal/admin/manage-templates/RemoveProvisionModal.tsx new file mode 100644 index 00000000..e65d16e8 --- /dev/null +++ b/frontend/src/app/components/modal/admin/manage-templates/RemoveProvisionModal.tsx @@ -0,0 +1,63 @@ +import { FC, useState } from 'react'; +import { Button, Form, Modal, Row, Spinner } from 'react-bootstrap'; +import { Provision } from '../../../../types/types'; + +interface RemoveProvisionModalProps { + provision: Provision | undefined; + show: boolean; + onHide: () => void; + onRemove: (id: number) => void; +} + +const RemoveProvisionModal: FC = ({ provision, show, onHide, onRemove }) => { + const [loading, setLoading] = useState(false); + const [error, setError] = useState(''); + const [showError, setShowError] = useState(false); + + const removeProvisionHandler = async () => { + try { + if (provision) { + setLoading(true); + setShowError(false); + onRemove(provision.id); + onHide(); + } + } catch (err) { + setError('Error removing provision'); + setShowError(true); + console.log(err); + } finally { + setLoading(false); + } + }; + + return ( + + + Remove Document Type + + +
+

Are you sure you want to remove this provision?

+ + + {provision?.provision_name} + + +
+ {showError &&
{error}
} +
+ + + + + +
+ ); +}; + +export default RemoveProvisionModal; diff --git a/frontend/src/app/components/modal/manage-templates/RemoveTemplateModal.tsx b/frontend/src/app/components/modal/admin/manage-templates/RemoveTemplateModal.tsx similarity index 95% rename from frontend/src/app/components/modal/manage-templates/RemoveTemplateModal.tsx rename to frontend/src/app/components/modal/admin/manage-templates/RemoveTemplateModal.tsx index b3fbcb2e..85d18490 100644 --- a/frontend/src/app/components/modal/manage-templates/RemoveTemplateModal.tsx +++ b/frontend/src/app/components/modal/admin/manage-templates/RemoveTemplateModal.tsx @@ -1,8 +1,7 @@ import { FC, useState } from 'react'; -import '../modals.css'; import Modal from 'react-bootstrap/Modal'; import Button from 'react-bootstrap/Button'; -import { removeTemplate } from '../../../common/manage-templates'; +import { removeTemplate } from '../../../../common/manage-templates'; type RemoveTemplateModalProps = { templateId: number; diff --git a/frontend/src/app/components/modal/manage-templates/UploadTemplateModal.tsx b/frontend/src/app/components/modal/admin/manage-templates/UploadTemplateModal.tsx similarity index 97% rename from frontend/src/app/components/modal/manage-templates/UploadTemplateModal.tsx rename to frontend/src/app/components/modal/admin/manage-templates/UploadTemplateModal.tsx index c7621cd5..8b3c3404 100644 --- a/frontend/src/app/components/modal/manage-templates/UploadTemplateModal.tsx +++ b/frontend/src/app/components/modal/admin/manage-templates/UploadTemplateModal.tsx @@ -1,6 +1,6 @@ import { FC, useState } from 'react'; import Modal from 'react-bootstrap/Modal'; -import { uploadTemplate } from '../../../common/manage-templates'; +import { uploadTemplate } from '../../../../common/manage-templates'; import { Button } from 'react-bootstrap'; type UploadTemplateModalProps = { diff --git a/frontend/src/app/components/modal/manage-templates/forms/AddVariableModalForm.tsx b/frontend/src/app/components/modal/admin/manage-templates/forms/AddVariableModalForm.tsx similarity index 100% rename from frontend/src/app/components/modal/manage-templates/forms/AddVariableModalForm.tsx rename to frontend/src/app/components/modal/admin/manage-templates/forms/AddVariableModalForm.tsx diff --git a/frontend/src/app/components/modal/manage-templates/forms/EditProvisionModalForm.tsx b/frontend/src/app/components/modal/admin/manage-templates/forms/EditProvisionModalForm.tsx similarity index 93% rename from frontend/src/app/components/modal/manage-templates/forms/EditProvisionModalForm.tsx rename to frontend/src/app/components/modal/admin/manage-templates/forms/EditProvisionModalForm.tsx index 5cd12aa7..c3eb60f4 100644 --- a/frontend/src/app/components/modal/manage-templates/forms/EditProvisionModalForm.tsx +++ b/frontend/src/app/components/modal/admin/manage-templates/forms/EditProvisionModalForm.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react'; -import { DocType, GroupMax, Provision, ProvisionUpload, Variable } from '../../../../types/types'; +import { DocType, GroupMax, Provision, ProvisionUpload, Variable } from '../../../../../types/types'; import { Button, Col, Form, Modal, Row, Spinner } from 'react-bootstrap'; -import ManageVariablesTable from '../../../table/manage-templates/ManageVariablesTable'; +import ManageVariablesTable from '../../../../table/manage-templates/ManageVariablesTable'; interface EditProvisionModalFormProps { provision: Provision | undefined; @@ -38,6 +38,7 @@ const EditProvisionModalForm: React.FC = ({ const [freeText, setFreeText] = useState(''); const [helpText, setHelpText] = useState(''); const [category, setCategory] = useState(''); + const [order, setOrder] = useState(); const [documentTypeIds, setDocumentTypeIds] = useState([]); useEffect(() => { @@ -54,6 +55,8 @@ const EditProvisionModalForm: React.FC = ({ setFreeText(provision.free_text); setHelpText(provision.help_text); setCategory(provision.category); + setOrder(provision.order_value); + console.log('setOrder:' + provision.order_value); provision.document_type_ids ? setDocumentTypeIds(provision.document_type_ids) : setDocumentTypeIds([]); } }; @@ -133,6 +136,10 @@ const EditProvisionModalForm: React.FC = ({ setCategory(e.target.value); }; + const handleOrderChange = (e: React.ChangeEvent) => { + setOrder(parseInt(e.target.value)); + }; + const handleDocumentTypeIdUpdate = (e: React.ChangeEvent) => { const documentTypeId: number = parseInt(e.target.value); if (e.target.checked) { @@ -154,6 +161,7 @@ const EditProvisionModalForm: React.FC = ({ free_text: freeText, help_text: helpText, category: category, + order_value: order ? order : 1, document_type_ids: documentTypeIds, }; updateProvisionHandler(provisionUpload, provision.id); @@ -178,9 +186,8 @@ const EditProvisionModalForm: React.FC = ({ - - + @@ -282,6 +289,15 @@ const EditProvisionModalForm: React.FC = ({ + + + + Order + + + + + Document Types diff --git a/frontend/src/app/components/modal/manage-templates/forms/EditVariableModalForm.tsx b/frontend/src/app/components/modal/admin/manage-templates/forms/EditVariableModalForm.tsx similarity index 97% rename from frontend/src/app/components/modal/manage-templates/forms/EditVariableModalForm.tsx rename to frontend/src/app/components/modal/admin/manage-templates/forms/EditVariableModalForm.tsx index 74e67579..fc47df33 100644 --- a/frontend/src/app/components/modal/manage-templates/forms/EditVariableModalForm.tsx +++ b/frontend/src/app/components/modal/admin/manage-templates/forms/EditVariableModalForm.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react'; import { Button, Col, Form, Modal, Spinner } from 'react-bootstrap'; -import { Variable, VariableUpload } from '../../../../types/types'; +import { Variable, VariableUpload } from '../../../../../types/types'; interface EditVariableModalFormProps { variable: Variable | undefined; diff --git a/frontend/src/app/components/modal/manage-templates/forms/RemoveVariableModalForm.tsx b/frontend/src/app/components/modal/admin/manage-templates/forms/RemoveVariableModalForm.tsx similarity index 96% rename from frontend/src/app/components/modal/manage-templates/forms/RemoveVariableModalForm.tsx rename to frontend/src/app/components/modal/admin/manage-templates/forms/RemoveVariableModalForm.tsx index 2c542ccc..1c5e67dd 100644 --- a/frontend/src/app/components/modal/manage-templates/forms/RemoveVariableModalForm.tsx +++ b/frontend/src/app/components/modal/admin/manage-templates/forms/RemoveVariableModalForm.tsx @@ -1,5 +1,5 @@ import { Button, Modal, Spinner } from 'react-bootstrap'; -import { Variable } from '../../../../types/types'; +import { Variable } from '../../../../../types/types'; interface RemoveVariableModalFormProps { variable: Variable | undefined; diff --git a/frontend/src/app/components/modal/modals.css b/frontend/src/app/components/modal/modals.css deleted file mode 100644 index 46d51464..00000000 --- a/frontend/src/app/components/modal/modals.css +++ /dev/null @@ -1,4 +0,0 @@ -.removeAdminInput { - color: gray; - min-width: 270px; -} diff --git a/frontend/src/app/components/table/admin/ManageDocTypesTable.tsx b/frontend/src/app/components/table/admin/ManageDocTypesTable.tsx new file mode 100644 index 00000000..b0b768d7 --- /dev/null +++ b/frontend/src/app/components/table/admin/ManageDocTypesTable.tsx @@ -0,0 +1,87 @@ +import React from 'react'; +import { DataTable } from '../common/DataTable'; +import { ColumnDef, createColumnHelper } from '@tanstack/react-table'; +import { DocType } from '../../../types/types'; + +interface ManageDocTypesTableProps { + documentTypes: DocType[]; + handleEdit: (id: number) => void; + handleRemove: (id: number) => void; +} + +const ManageDocTypesTable: React.FC = ({ documentTypes, handleEdit, handleRemove }) => { + const editDocTypeButtonHandler = (id: number) => { + handleEdit(id); + }; + + const removeDocTypeButtonHandler = (id: number) => { + handleRemove(id); + }; + + const columnHelper = createColumnHelper(); + + const columns: ColumnDef[] = [ + columnHelper.accessor('name', { + id: 'name', + cell: (info) => , + header: () => 'Name', + meta: { customCss: { width: '30%' } }, + }), + columnHelper.accessor('created_date', { + id: 'created_date', + cell: (info) => , + header: () => 'Create Date', + meta: { customCss: { width: '30%' } }, + }), + columnHelper.accessor('created_by', { + id: 'created_by', + cell: (info) => , + header: () => 'Created By', + meta: { customCss: { width: '30%' } }, + }), + columnHelper.display({ + id: 'edit', + cell: (info) => ( + + ), + header: () => null, + meta: { customCss: { width: '10%' } }, + }), + columnHelper.display({ + id: 'remove', + cell: (info) => ( + + ), + header: () => null, + meta: { customCss: { width: '10%' } }, + }), + ]; + + return ; +}; + +export default ManageDocTypesTable; diff --git a/frontend/src/app/components/table/manage-templates/ManageProvisionsTable.tsx b/frontend/src/app/components/table/manage-templates/ManageProvisionsTable.tsx index 3e4a9086..147e1acd 100644 --- a/frontend/src/app/components/table/manage-templates/ManageProvisionsTable.tsx +++ b/frontend/src/app/components/table/manage-templates/ManageProvisionsTable.tsx @@ -9,12 +9,14 @@ interface ManageProvisionsTableProps { provisions: Provision[] | undefined; variables: Variable[] | undefined; editProvisionHandler: (provision: Provision, variables: Variable[]) => void; + removeProvisionHandler: (provision: Provision) => void; } const ManageProvisionsTable: React.FC = ({ provisions, variables, editProvisionHandler, + removeProvisionHandler, }) => { const [allProvisions, setProvisions] = useState([]); const [allVariables, setVariables] = useState([]); @@ -76,6 +78,11 @@ const ManageProvisionsTable: React.FC = ({ if (selectedProvision && selectedVariables) editProvisionHandler(selectedProvision, selectedVariables); }; + const openRemoveProvisionModal = async (provision: Provision) => { + const selectedProvision = allProvisions ? allProvisions.find((p) => p.id === provision.id) : undefined; + if (selectedProvision) removeProvisionHandler(selectedProvision); + }; + const columnHelper = createColumnHelper(); const columns: ColumnDef[] = [ @@ -101,7 +108,7 @@ const ManageProvisionsTable: React.FC = ({ id: 'category', cell: (info) => , header: () => 'Category', - meta: { customCss: { width: '25%' } }, + meta: { customCss: { width: '20%' } }, }), columnHelper.accessor('active_flag', { id: 'active_flag', @@ -116,12 +123,18 @@ const ManageProvisionsTable: React.FC = ({ header: () => 'Active', meta: { customCss: { width: '5%' } }, }), - columnHelper.accessor('edit', { + columnHelper.display({ id: 'edit', cell: (info) => openEditProvisionModal(info.row.original.id)} />, header: () => null, meta: { customCss: { width: '5%' } }, }), + columnHelper.display({ + id: 'remove', + cell: (info) => openRemoveProvisionModal(info.row.original)} />, + header: () => null, + meta: { customCss: { width: '5%' } }, + }), ]; return ; diff --git a/frontend/src/app/content/pages/AdminPage.tsx b/frontend/src/app/content/pages/AdminPage.tsx index d94d3a12..1c936545 100644 --- a/frontend/src/app/content/pages/AdminPage.tsx +++ b/frontend/src/app/content/pages/AdminPage.tsx @@ -1,7 +1,7 @@ import { FC, useState } from 'react'; // import { REPORT_TYPES } from '../../util/constants'; -import AddAdmin from '../../components/modal/admin/AddAdmin'; -import RemoveAdmin from '../../components/modal/admin/RemoveAdmin'; +import AddAdmin from '../../components/modal/admin/manage-admins/AddAdmin'; +import RemoveAdmin from '../../components/modal/admin/manage-admins/RemoveAdmin'; // import { useNavigate } from 'react-router-dom'; import { exportUsers } from '../../common/admin'; import AdminDataTable, { AdminData } from '../../components/table/admin/AdminDataTable'; diff --git a/frontend/src/app/content/pages/ManageDocumentsPage.tsx b/frontend/src/app/content/pages/ManageDocumentsPage.tsx new file mode 100644 index 00000000..5ddfc557 --- /dev/null +++ b/frontend/src/app/content/pages/ManageDocumentsPage.tsx @@ -0,0 +1,133 @@ +import { FC, useEffect, useState } from 'react'; +import { Button } from 'react-bootstrap'; +import { DocType } from '../../types/types'; +import { getDocumentTypes } from '../../common/report'; +import ManageDocTypesTable from '../../components/table/admin/ManageDocTypesTable'; +import AddDocTypeModal from '../../components/modal/admin/manage-doc-types/AddDocTypeModal'; +import EditDocTypeModal from '../../components/modal/admin/manage-doc-types/EditDocTypeModal'; +import RemoveDocTypeModal from '../../components/modal/admin/manage-doc-types/RemoveDocTypeModal'; +import { addDocType, removeDocType, updateDocType } from '../../common/manage-doc-types'; + +const ManageDocumentsPage: FC = () => { + const [currentDocType, setCurrentDocType] = useState({ + id: -1, + name: '', + created_by: '', + created_date: '', + create_userid: '', + create_timestamp: '', + update_timestamp: '', + update_userid: '', + }); + const [allDocTypes, setAllDocTypes] = useState([]); + + const [showAddDocTypeModal, setShowAddDocTypeModal] = useState(false); + const [showEditDocTypeModal, setShowEditDocTypeModal] = useState(false); + const [showRemoveDocTypeModal, setShowRemoveDocTypeModal] = useState(false); + + const [refreshTrigger, setRefreshTrigger] = useState(0); + + useEffect(() => { + const getData = async () => { + const docTypeData = await getDocumentTypes(); + setAllDocTypes(docTypeData); + }; + getData(); + }, [refreshTrigger]); + + const refreshTables = () => { + setRefreshTrigger((prev) => prev + 1); + }; + + const openAddDocTypeModal = () => { + setShowAddDocTypeModal(true); + }; + + const addDocTypeHandler = async (name: string, created_by: string, created_date: string) => { + try { + await addDocType(name, created_by, created_date); + refreshTables(); + } catch (err) { + console.log('Error adding doc type'); + console.log(err); + } + }; + + const openEditDocTypeModal = (id: number) => { + const selectedDocType = allDocTypes.find((docType) => docType.id === id); + if (selectedDocType) { + setCurrentDocType(selectedDocType); + setShowEditDocTypeModal(true); + } + }; + + const editDocTypeHandler = async (id: number, name: string, created_by: string, created_date: string) => { + try { + await updateDocType(id, name, created_by, created_date); + refreshTables(); + } catch (err) { + console.log('Error updating doc type'); + console.log(err); + } + }; + + const openRemoveDocTypeModal = (id: number) => { + const selectedDocType = allDocTypes.find((docType) => docType.id === id); + if (selectedDocType) { + setCurrentDocType(selectedDocType); + setShowRemoveDocTypeModal(true); + } + }; + + const removeDocTypeHandler = async (id: number) => { + try { + await removeDocType(id); + refreshTables(); + } catch (err) { + console.log('Error removing doc type'); + console.log(err); + } + }; + + return ( + <> +

Manage Document Types

+
+ + + setShowAddDocTypeModal(false)} + onAdd={addDocTypeHandler} + /> + + {currentDocType && ( + setShowEditDocTypeModal(false)} + onEdit={editDocTypeHandler} + /> + )} + + {currentDocType && ( + setShowRemoveDocTypeModal(false)} + onRemove={removeDocTypeHandler} + /> + )} + + ); +}; + +export default ManageDocumentsPage; diff --git a/frontend/src/app/content/pages/ManageProvisionsPage.tsx b/frontend/src/app/content/pages/ManageProvisionsPage.tsx index e5b33d5a..7abd5e74 100644 --- a/frontend/src/app/content/pages/ManageProvisionsPage.tsx +++ b/frontend/src/app/content/pages/ManageProvisionsPage.tsx @@ -2,10 +2,18 @@ import { FC, useEffect, useState } from 'react'; import ManageProvisionsTable from '../../components/table/manage-templates/ManageProvisionsTable'; import { Button } from 'react-bootstrap'; import { DocType, GroupMax, Provision, ProvisionUpload, Variable } from '../../types/types'; -import { addProvision, getGroupMax, getProvisions, getVariables, updateProvision } from '../../common/manage-templates'; -import EditProvisionModal from '../../components/modal/manage-templates/EditProvisionModal'; -import AddProvisionModal from '../../components/modal/manage-templates/AddProvisionModal'; +import { + addProvision, + getGroupMax, + getProvisions, + getVariables, + removeProvision, + updateProvision, +} from '../../common/manage-templates'; +import EditProvisionModal from '../../components/modal/admin/manage-templates/EditProvisionModal'; +import AddProvisionModal from '../../components/modal/admin/manage-templates/AddProvisionModal'; import { getDocumentTypes } from '../../common/report'; +import RemoveProvisionModal from '../../components/modal/admin/manage-templates/RemoveProvisionModal'; interface ManageProvisionsPageProps {} @@ -19,6 +27,7 @@ const ManageProvisionsPage: FC = () => { const [currentProvision, setCurrentProvision] = useState(); const [showEditProvisionModal, setShowEditProvisionModal] = useState(false); const [showAddProvisionModal, setShowAddProvisionModal] = useState(false); + const [showRemoveProvisionModal, setShowRemoveProvisionModal] = useState(false); const [refreshTrigger, setRefreshTrigger] = useState(0); useEffect(() => { @@ -48,6 +57,11 @@ const ManageProvisionsPage: FC = () => { setShowEditProvisionModal(true); }; + const openRemoveProvisionModal = (provision: Provision) => { + setCurrentProvision(provision); + setShowRemoveProvisionModal(true); + }; + const updateProvisionHandler = async (provisionUpload: ProvisionUpload, provisionId: number) => { await updateProvision({ ...provisionUpload, id: provisionId }); }; @@ -55,6 +69,10 @@ const ManageProvisionsPage: FC = () => { const addProvisionHandler = async (provisionUpload: ProvisionUpload) => { await addProvision(provisionUpload); }; + const removeProvisionHandler = async (id: number) => { + await removeProvision(id); + refreshTables(); + }; const currentVariables = data.allVariables?.filter((v) => v.provision_id === currentProvision?.id) || []; @@ -66,6 +84,7 @@ const ManageProvisionsPage: FC = () => { provisions={data.allProvisions} variables={data.allVariables} editProvisionHandler={openEditProvisionModal} + removeProvisionHandler={openRemoveProvisionModal} /> -
- - - ); -}; - -export default ManageTemplates; \ No newline at end of file diff --git a/frontend/src/app/content/pages/ManageTemplatesPage.tsx b/frontend/src/app/content/pages/ManageTemplatesPage.tsx index 341ecd16..603b1f30 100644 --- a/frontend/src/app/content/pages/ManageTemplatesPage.tsx +++ b/frontend/src/app/content/pages/ManageTemplatesPage.tsx @@ -1,205 +1,101 @@ import { FC, useEffect, useState } from 'react'; -import { useParams } from 'react-router'; -import { NFR_REPORT_PAGES, REPORT_TYPES } from '../../util/constants'; -import Collapsible from '../../components/common/Collapsible'; import TemplateInfoTable from '../../components/table/manage-templates/TemplateInfoTable'; -import AddProvisionModal from '../../components/modal/manage-templates/AddProvisionModal'; -import UploadTemplateModal from '../../components/modal/manage-templates/UploadTemplateModal'; -import RemoveTemplateModal from '../../components/modal/manage-templates/RemoveTemplateModal'; -import ManageProvisionsTable from '../../components/table/manage-templates/ManageProvisionsTable'; -import { GroupMax, Provision, ProvisionUpload, Variable } from '../../types/types'; -import EditProvisionModal from '../../components/modal/manage-templates/EditProvisionModal'; -import { addProvision, getGroupMax, getProvisions, getVariables, updateProvision } from '../../common/manage-templates'; import { Button } from 'react-bootstrap'; +import { DocType } from '../../types/types'; +import UploadTemplateModal from '../../components/modal/admin/manage-templates/UploadTemplateModal'; +import RemoveTemplateModal from '../../components/modal/admin/manage-templates/RemoveTemplateModal'; +import { getDocumentTypes } from '../../common/report'; -export interface ManageTemplatesPageProps {} - -// TODO - template upload and provisions to be split out into separate pages -// provision / variables routes are changing to be centered around document types instead of variants - -const ManageTemplatesPage: FC = () => { +const ManageTemplatesPage: FC = () => { const [showUploadModal, setShowUploadModal] = useState(false); const [showRemoveTemplateModal, setShowRemoveTemplateModal] = useState(false); - const [showEditProvisionModal, setShowEditProvisionModal] = useState(false); - const [showAddProvisionModal, setShowAddProvisionModal] = useState(false); - const [currentReportType, setCurrentReportType] = useState(''); const [currentReportId, setCurrentReportId] = useState(-1); - const [currentProvision, setCurrentProvision] = useState(); - const [currentVariables, setCurrentVariables] = useState(); - const [groupMaxArray, setGroupMaxArray] = useState(); - const [allProvisions, setAllProvisions] = useState(); - const [allVariables, setAllVariables] = useState(); const [refreshTrigger, setRefreshTrigger] = useState(0); - const { id } = useParams<{ id: string }>(); - let idNum: number; - idNum = id ? parseInt(id) : 0; - const reportType: string = REPORT_TYPES.filter((report) => report.reportIndex === idNum).map( - (report) => report.reportType - )[0]; + const [selectedDocType, setSelectedDocType] = useState(); + const [allDocTypes, setAllDocTypes] = useState([]); useEffect(() => { const getData = async () => { - const fetchedGroupMaxArray: GroupMax[] = await getGroupMax(); - setGroupMaxArray(fetchedGroupMaxArray); - const provisionData: Provision[] = await getProvisions(); - setAllProvisions(provisionData); - const variablesData: Variable[] = await getVariables(); - setAllVariables(variablesData); - if (currentProvision && currentVariables) { - const updatedProvision: Provision | undefined = provisionData.find((p) => p.id === currentProvision.id); - if (updatedProvision) setCurrentProvision(updatedProvision); - const updatedVariables: Variable[] | undefined = variablesData.filter( - (v) => v.provision_id === currentProvision.id - ); - setCurrentVariables(updatedVariables); - } + const docTypeData = await getDocumentTypes(); + setAllDocTypes(docTypeData); }; getData(); - }, [refreshTrigger]); - - const openUploadModal = (report: string) => { - setCurrentReportType(report); - setShowUploadModal(true); - }; + }, []); - const openRemoveTemplateModal = (id: number, report: string) => { - setCurrentReportType(report); - setCurrentReportId(id); - setShowRemoveTemplateModal(true); - }; + useEffect(() => { + refreshTables(); + }, [selectedDocType]); - const openEditProvisionModal = (provision: Provision, variables: Variable[]) => { - setCurrentProvision(provision); - setCurrentVariables(variables); - setShowEditProvisionModal(true); + const refreshTables = () => { + setRefreshTrigger((prev) => prev + 1); }; - const updateProvisionHandler = async (provisionUpload: ProvisionUpload, provisionId: number) => { - await updateProvision({ ...provisionUpload, id: provisionId }); + const openUploadModal = () => { + setShowUploadModal(true); }; - const addProvisionHandler = async (provisionUpload: ProvisionUpload) => { - await addProvision(provisionUpload); + const openRemoveTemplateModal = (id: number) => { + setCurrentReportId(id); + setShowRemoveTemplateModal(true); }; - const refreshTables = () => { - setRefreshTrigger((prev) => prev + 1); + const selectedDocTypeHandler = (event: React.ChangeEvent) => { + const docTypeId: number = parseInt(event.target.value); + setSelectedDocType(allDocTypes.find((docType) => docType.id === docTypeId)); }; return ( - <> - // <> - //

Manage Templates

- //
- // {/** TO BE MOVED TO IT'S OWN PAGE */} - // {reportType === 'Notice of Final Review' ? ( - // <> - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // ) : ( - // - // - // - // - // )} - // setShowUploadModal(false)} - // onUpload={refreshTables} - // documentTypeId={1} - // documentTypeName="placeholder" - // /> - // setShowRemoveTemplateModal(false)} - // onRemove={refreshTables} - // documentTypeId={1} - // templateId={currentReportId} - // /> - // setShowEditProvisionModal(false)} - // updateProvisionHandler={updateProvisionHandler} - // refreshTables={refreshTables} - // /> - // setShowAddProvisionModal(false)} - // addProvisionHandler={addProvisionHandler} - // refreshTables={refreshTables} - // /> - // + <> +

Manage Templates

+
+
+

Select a Template:

+
+
+
+ +
+
+ {selectedDocType && ( + <> + + + setShowUploadModal(false)} + onUpload={refreshTables} + documentTypeId={selectedDocType.id} + documentTypeName={selectedDocType.name} + /> + setShowRemoveTemplateModal(false)} + onRemove={refreshTables} + documentTypeId={selectedDocType.id} + documentTypeName={selectedDocType.name} + templateId={currentReportId} + /> + + )} + ); }; diff --git a/frontend/src/app/content/pages/SystemAdministration.tsx b/frontend/src/app/content/pages/SystemAdministration.tsx index ebf27b11..84e675a0 100644 --- a/frontend/src/app/content/pages/SystemAdministration.tsx +++ b/frontend/src/app/content/pages/SystemAdministration.tsx @@ -23,7 +23,7 @@ const SystemAdministration: React.FC = () => { navigate(`/manage-admins`); break; case 'documentTypes': - console.log('Go to Manage Document Types'); + navigate(`/manage-doc-types`); break; case 'templates': navigate(`/manage-templates`); diff --git a/frontend/src/app/content/pages/UploadReportsPage.tsx b/frontend/src/app/content/pages/UploadReportsPage.tsx deleted file mode 100644 index a4ca601b..00000000 --- a/frontend/src/app/content/pages/UploadReportsPage.tsx +++ /dev/null @@ -1,104 +0,0 @@ -import { FC, useEffect, useState } from 'react'; -import TemplateInfoTable from '../../components/table/manage-templates/TemplateInfoTable'; -import { Button } from 'react-bootstrap'; -import { DocType } from '../../types/types'; -import UploadTemplateModal from '../../components/modal/manage-templates/UploadTemplateModal'; -import RemoveTemplateModal from '../../components/modal/manage-templates/RemoveTemplateModal'; -import { getDocumentTypes } from '../../common/report'; - -// switch the name of this page to manage templates after manage provisions/variables page is created - -const UploadReportsPage: FC = () => { - const [showUploadModal, setShowUploadModal] = useState(false); - const [showRemoveTemplateModal, setShowRemoveTemplateModal] = useState(false); - const [currentReportId, setCurrentReportId] = useState(-1); - const [refreshTrigger, setRefreshTrigger] = useState(0); - const [selectedDocType, setSelectedDocType] = useState(); - const [allDocTypes, setAllDocTypes] = useState([]); - - useEffect(() => { - const getData = async () => { - const docTypeData = await getDocumentTypes(); - setAllDocTypes(docTypeData); - }; - getData(); - }, []); - - useEffect(() => { - refreshTables(); - }, [selectedDocType]); - - const refreshTables = () => { - setRefreshTrigger((prev) => prev + 1); - }; - - const openUploadModal = () => { - setShowUploadModal(true); - }; - - const openRemoveTemplateModal = (id: number) => { - setCurrentReportId(id); - setShowRemoveTemplateModal(true); - }; - - const selectedDocTypeHandler = (event: React.ChangeEvent) => { - const docTypeId: number = parseInt(event.target.value); - setSelectedDocType(allDocTypes.find((docType) => docType.id === docTypeId)); - }; - - return ( - <> -

Manage Templates

-
-
-

Select a Template:

-
-
-
- -
-
- {selectedDocType && ( - <> - - - setShowUploadModal(false)} - onUpload={refreshTables} - documentTypeId={selectedDocType.id} - documentTypeName={selectedDocType.name} - /> - setShowRemoveTemplateModal(false)} - onRemove={refreshTables} - documentTypeId={selectedDocType.id} - documentTypeName={selectedDocType.name} - templateId={currentReportId} - /> - - )} - - ); -}; - -export default UploadReportsPage; diff --git a/frontend/src/app/types/types.ts b/frontend/src/app/types/types.ts index bb39f76b..04263488 100644 --- a/frontend/src/app/types/types.ts +++ b/frontend/src/app/types/types.ts @@ -146,6 +146,7 @@ export type ProvisionObject = { provision_group: number; // will always be null id: number; help_text: string; + order_value: number; create_timestamp: string; update_timestamp: string; }; @@ -203,6 +204,7 @@ export type Provision = { active_flag: boolean; edit: any; // remove from route help_text: string; + order_value: number; id: number; document_type_ids: number[]; // }; @@ -226,6 +228,7 @@ export type ProvisionUpload = { free_text: string; help_text: string; category: string; + order_value: number; document_type_ids: number[]; // }; @@ -250,6 +253,8 @@ export type SearchData = { export type DocType = { id: number; name: string; + created_by: string; + created_date: string; create_userid: string; update_userid: string; create_timestamp: string; From aea7c06aa8a86dc4c1b17fdcc882c112269853cc Mon Sep 17 00:00:00 2001 From: mgtennant <100305096+mgtennant@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:18:52 -0700 Subject: [PATCH 7/7] update to test data init --- backend/utils/db/init-db.sql | 106 +++++++++--------- .../forms/EditProvisionModalForm.tsx | 1 - 2 files changed, 53 insertions(+), 54 deletions(-) diff --git a/backend/utils/db/init-db.sql b/backend/utils/db/init-db.sql index 478d34a5..3c6ddf8c 100644 --- a/backend/utils/db/init-db.sql +++ b/backend/utils/db/init-db.sql @@ -13,11 +13,11 @@ INSERT INTO provision_group (provision_group, max, provision_group_text) VALUES INSERT INTO provision_group (provision_group, max, provision_group_text) VALUES (28,3,'ADDITIONAL REQUIREMENTS'); INSERT INTO provision_group (provision_group, max, provision_group_text) VALUES (34,999,'ADDITIONAL REQUIREMENTS'); -INSERT INTO document_type (name, create_userid, update_userid) VALUES ('Notice of Final Review', 'system', 'system'); -INSERT INTO document_type (name, create_userid, update_userid) VALUES ('Notice of Final Review (Delayed)', 'system', 'system'); -INSERT INTO document_type (name, create_userid, update_userid) VALUES ('Notice of Final Review (No Fees)', 'system', 'system'); -INSERT INTO document_type (name, create_userid, update_userid) VALUES ('Notice of Final Review (Survey Required)', 'system', 'system'); -INSERT INTO document_type (name, create_userid, update_userid) VALUES ('Notice of Final Review (To Obtain Survey)', 'system', 'system'); +INSERT INTO document_type (name, created_by, created_date, create_userid, update_userid) VALUES ('Notice of Final Review', 'system', '2024-03-19 00:00:00', 'system', 'system'); +INSERT INTO document_type (name, created_by, created_date, create_userid, update_userid) VALUES ('Notice of Final Review (Delayed)', 'system', '2024-03-19 00:00:00', 'system', 'system'); +INSERT INTO document_type (name, created_by, created_date, create_userid, update_userid) VALUES ('Notice of Final Review (No Fees)', 'system', '2024-03-19 00:00:00', 'system', 'system'); +INSERT INTO document_type (name, created_by, created_date, create_userid, update_userid) VALUES ('Notice of Final Review (Survey Required)', 'system', '2024-03-19 00:00:00', 'system', 'system'); +INSERT INTO document_type (name, created_by, created_date, create_userid, update_userid) VALUES ('Notice of Final Review (To Obtain Survey)', 'system', '2024-03-19 00:00:00', 'system', 'system'); -- Helper functions for grabbing document type ids, group ids, current variable id, and current provision id. CREATE OR REPLACE FUNCTION get_current_provision_id() RETURNS INTEGER AS $$ @@ -94,8 +94,8 @@ END; $$ LANGUAGE plpgsql; -- Create Provisions and relations to document types --- Variant 'NOTICE OF FINAL REVIEW' -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW','','Use this to enter values for each of the variables in the boilerplate of the NOTICE OF FINAL REVIEW letter.','DOCUMENT TYPE',true); +-- Document Type 'NOTICE OF FINAL REVIEW' +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW','','Use this to enter values for each of the variables in the boilerplate of the NOTICE OF FINAL REVIEW letter.','DOCUMENT TYPE', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('ATTENTION_LINE','','Attention: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('CLIENT_FILE_NO','','Your file: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); @@ -107,86 +107,86 @@ INSERT INTO provision_variable (variable_name, variable_value, help_text, "provi INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SALUTATION','','Dear "______": Type in the person’s name or Sir or Madam.',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(2),'FEES','','Use this to create a table listing all the fees to be paid. Table is unprotected, so you will be able to modify text ','FEES',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('M',get_provision_group_id(2),'FEES','','Use this to create a table listing all the fees to be paid. Table is unprotected, so you will be able to modify text ','FEES', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FEE_APPLICATION_AMOUNT','','$"#.##" payable. Fill in either amount, or "0" if nothing payable for this category of fee. Put in decimals.',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FEE_DOCUMENTATION_AMOUNT','','$"#.##" payable. Fill in either amount, or "0" if nothing payable for this category of fee. Put in decimals.',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FEE_OCCUPATIONAL_RENTAL_AMOUNT','','$"#.##" payable. Fill in either amount, or "0" if nothing payable for this category of fee. Put in decimals.',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('FEE_OTHER_CREDIT_AMOUNT','','$"#.##" payable. Fill in either amount, or "0" if nothing payable for this category of fee. Put in decimals.',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(5),'REPLACEMENT STATEMENT','',' Use this when tenure is being replaced','PREAMBLE',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(5),'REPLACEMENT STATEMENT','',' Use this when tenure is being replaced','PREAMBLE', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('REPLACEMENT_TENURE_TYPE','','____No. #. Use to specify type and number of tenure being replaced e.g. lease No. 999.',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(5),'LAND DIFFERS FROM STATEMENT','','Use when land being offered differs from the applied area','OFFER PREAMBLE',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(5),'LAND DIFFERS FROM STATEMENT','','Use when land being offered differs from the applied area','OFFER PREAMBLE', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('WHY_LAND_DIFFERS','','The Land differs from what you applied for because "____". Explain why you are offering some...',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(5),'FREE FIELD - PREAMBLE INFORMATION','','Use when you want to enter additonal information for the preamble','OFFER PREAMBLE',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(5),'FREE FIELD - PREAMBLE INFORMATION','','Use when you want to enter additonal information for the preamble','OFFER PREAMBLE', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(15),'OCCUPATIONAL RENT STATEMENT','','Use this where occupational rent is payable','OFFER - MONIES - PAYABLE',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(15),'OCCUPATIONAL RENT STATEMENT','','Use this where occupational rent is payable','OFFER - MONIES - PAYABLE', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('OCC_RENT_DETAILS','','Occupatianal Rental is payable for your occupation of the Land for the period from "___". Set out ...',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'DELIVER SECURITY DEPOSIT - NOTICE OF FINAL REVIEW','','Use this to require delivery of security deposit','OFFER - SECURITY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(20),'DELIVER SECURITY DEPOSIT - NOTICE OF FINAL REVIEW','','Use this to require delivery of security deposit','OFFER - SECURITY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_surveyreq()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SECURITY_AMOUNT','','#.## to post as security - indicate an amount even if blanket bond applies. Put in Decimal.',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'BLANKET SECURITY STATEMENT','','Use this when client is covered by blanket security agreement','OFFER - SECURITY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(20),'BLANKET SECURITY STATEMENT','','Use this when client is covered by blanket security agreement','OFFER - SECURITY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_surveyreq()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('BLANKET_BOND_NAME','','You are currently covered by a blanket bond between MELP and "____". S...',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'FREE FIELD FOR SECURITY SECTION','','Use where you need to add information regarding security','OFFER - SECURITY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(20),'FREE FIELD FOR SECURITY SECTION','','Use where you need to add information regarding security','OFFER - SECURITY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(25),'INSURANCE REQUIRED - NOTICE OF FINAL REVIEW - OTHER','','Use when insurance is required for other tenures eg. homeowners','OFFER - INSURANCE',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(25),'INSURANCE REQUIRED - NOTICE OF FINAL REVIEW - OTHER','','Use when insurance is required for other tenures eg. homeowners','OFFER - INSURANCE', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(25),'INSURANCE REQUIRED - NOTICE OF FINAL REVIEW - CERTIFICATE REQUIRED','','Use when insurance along with a Certificate of Insurance is required.','OFFER - INSURANCE',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(25),'INSURANCE REQUIRED - NOTICE OF FINAL REVIEW - CERTIFICATE REQUIRED','','Use when insurance along with a Certificate of Insurance is required.','OFFER - INSURANCE', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(25),'FREE FIELD FOR INSURANCE','','Use where you want to enter additonal information on insurance','OFFER - INSURANCE',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(25),'FREE FIELD FOR INSURANCE','','Use where you want to enter additonal information on insurance','OFFER - INSURANCE', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'FREE FIELD - ADDITIONAL REQUIREMENTS','','Use where you want to state additional conditions of the offer','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(27),'FREE FIELD - ADDITIONAL REQUIREMENTS','','Use where you want to state additional conditions of the offer','ADDITIONAL REQUIREMENTS', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'FREE FIELD - ADDITIONAL REQUIREMENTS - 2','','Use where you want to state additional conditions of the offer','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(27),'FREE FIELD - ADDITIONAL REQUIREMENTS - 2','','Use where you want to state additional conditions of the offer','ADDITIONAL REQUIREMENTS', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - MANAGEMENT PLAN','','Use to require delivery of a management plan.','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - MANAGEMENT PLAN','','Use to require delivery of a management plan.','ADDITIONAL REQUIREMENTS', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - ZONING APPROVAL','','Use to require confirmation that a zoning bylaw permitting use of the Land for the intended purposes has been adopted.','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - ZONING APPROVAL','','Use to require confirmation that a zoning bylaw permitting use of the Land for the intended purposes has been adopted.','ADDITIONAL REQUIREMENTS', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('LOCAL_GOVERNMENT','','Type in the name of the local government.',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('PURPOSE_GENERIC','','used for "_________" purposes.',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - IMPROVEMENTS STAT DEC','','Use this when a statutory declaration is required regarding ownership of improvements.','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - IMPROVEMENTS STAT DEC','','Use this when a statutory declaration is required regarding ownership of improvements.','ADDITIONAL REQUIREMENTS', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - TAX CLEARANCE CERTIFICATE','','Use when a tax clearance certificate is required verifying that there are no arrears of taxes.','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - TAX CLEARANCE CERTIFICATE','','Use when a tax clearance certificate is required verifying that there are no arrears of taxes.','ADDITIONAL REQUIREMENTS', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TAX_COLLECTOR_OFFICE','','Type in the address of the local Provincial Tax Collector’s office.',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - AFFILIATE STATUS CERTIFICATE','','Use when a certificate of affiliate status is required for each affiliate of your company using the communication site.','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - AFFILIATE STATUS CERTIFICATE','','Use when a certificate of affiliate status is required for each affiliate of your company using the communication site.','ADDITIONAL REQUIREMENTS', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - OBTAIN AND DELIVER','','Use when you require immediate delivery of documentation.','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - OBTAIN AND DELIVER','','Use when you require immediate delivery of documentation.','ADDITIONAL REQUIREMENTS', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()), (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_nofees()), (get_current_provision_id(), get_doc_type_toobtain()), (get_current_provision_id(), get_doc_type_surveyreq()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_TO_DELIVER','','Enter "on or before [date]" OR "within [45] days from the date of this letter.',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DOCUMENT_TO_OBTAIN','','You must obtain the [specify the name of the document(s)] and ....',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - FISHERIES AND OCEANS APPROVAL','','Use to require delivery of a copy of a permit from Fisheries and Oceans for aquaculture purposes.','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - FISHERIES AND OCEANS APPROVAL','','Use to require delivery of a copy of a permit from Fisheries and Oceans for aquaculture purposes.','ADDITIONAL REQUIREMENTS', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - COAST GUARD APPROVAL','','Use to require delivery of a letter of approval from the Canadian Coast Guard for the proposed construction.','ADDITIONAL REQUIREMENTS',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(27),'ADDITIONAL REQUIREMENTS - COAST GUARD APPROVAL','','Use to require delivery of a letter of approval from the Canadian Coast Guard for the proposed construction.','ADDITIONAL REQUIREMENTS', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_default()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('COAST_GUARD_ADDRESS','','Type in the address of the Canadian Coast Guard office.',get_current_provision_id()); --- Variant 'NOTICE OF FINAL REVIEW (NO FEES)' -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW - NO FEES','','require message from POLICY','DOCUMENT TYPE',true); +-- Document Type 'NOTICE OF FINAL REVIEW (NO FEES)' +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW - NO FEES','','require message from POLICY','DOCUMENT TYPE', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_nofees()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('ATTENTION_LINE','','Attention: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('CLIENT_FILE_NO','','Your file: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); @@ -200,8 +200,8 @@ INSERT INTO provision_variable (variable_name, variable_value, help_text, "provi INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',get_current_provision_id()); --- Variant 'NOTICE OF FINAL REVIEW (DELAYED)' -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW - DELAYED','','require message from POLICY','DOCUMENT TYPE',true); +-- Document Type 'NOTICE OF FINAL REVIEW (DELAYED)' +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW - DELAYED','','require message from POLICY','DOCUMENT TYPE', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_delayed()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('ATTENTION_LINE','','Attention: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('CLIENT_FILE_NO','','Your file: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); @@ -214,35 +214,35 @@ INSERT INTO provision_variable (variable_name, variable_value, help_text, "provi INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TENURE_TYPE','','Type in the tenure type. e.g. Lease',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'SURVEY CONFIRMATION - CLIENT PAYS - DELAYED','','Use when the client pays for survey.','OFFER SURVEY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(10),'SURVEY CONFIRMATION - CLIENT PAYS - DELAYED','','Use when the client pays for survey.','OFFER SURVEY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_delayed()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_COMPLETE_SURVEY','','on or before "month day, year"',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_CONFIRM_SURVEY','','Enter "On or before [date]" OR "Within [45] days from the date of this letter". Capitalize first character as this is the start of a sentence.',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('MAXIMUM_AREA','','# hectares',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('RATE_PER_METRE','','$"#.## per square metre/per hectare" Put in the decimal.',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'SURVEY DEPOSIT - DELAYED','','Use to require payment of a deposit where Province is to pay for a survey.','OFFER SURVEY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(10),'SURVEY DEPOSIT - DELAYED','','Use to require payment of a deposit where Province is to pay for a survey.','OFFER SURVEY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_delayed()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SURVEY_DEPOSIT_DELAYED','','Deadline to pay survey deposit. Enter Month, Day, Year',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEPOSIT_AMOUNT_SURVEY','','$"#.##" Enter amount of survey deposit. Put in the decimal.',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('MAXIMUM_AREA','','# hectares',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('RATE_PER_METRE','','$"#.## per square metre/per hectare" Put in the decimal.',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'PREPARE BOUNDARY PLAN (CLIENT PAYS)','','require message from POLICY','OFFER SURVEY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(10),'PREPARE BOUNDARY PLAN (CLIENT PAYS)','','require message from POLICY','OFFER SURVEY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_delayed()), (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(12),'MONIES PAYABLE - NOTICE OF FINAL REVIEW - DELAYED','','Use when you are providing a firm amount payable.','OFFER SURVEY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('M',get_provision_group_id(12),'MONIES PAYABLE - NOTICE OF FINAL REVIEW - DELAYED','','Use when you are providing a firm amount payable.','OFFER SURVEY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_delayed()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(12),'ESTIMATED MONIES PAYABLE - NOTICE OF FINAL REVIEW - DELAYED','','Use when you are providing an estimated amount payable.','OFFER SURVEY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('M',get_provision_group_id(12),'ESTIMATED MONIES PAYABLE - NOTICE OF FINAL REVIEW - DELAYED','','Use when you are providing an estimated amount payable.','OFFER SURVEY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_delayed()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'DELIVER SECURITY DEPOSIT (& SURVEY DEPOSIT) - NOTICE OF FINAL REVIEW','','Use this where 2 deposits are to be delivered: one for the survey and another for clean-up under the terms of the tenure to be issued','OFFER - SECURITY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(20),'DELIVER SECURITY DEPOSIT (& SURVEY DEPOSIT) - NOTICE OF FINAL REVIEW','','Use this where 2 deposits are to be delivered: one for the survey and another for clean-up under the terms of the tenure to be issued','OFFER - SECURITY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_delayed()); --- Variant 'NOTICE OF FINAL REVIEW (TO OBTAIN SURVEY)' -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW - TO OBTAIN SURVEY','','require message from POLICY','DOCUMENT TYPE',true); +-- Document Type 'NOTICE OF FINAL REVIEW (TO OBTAIN SURVEY)' +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW - TO OBTAIN SURVEY','','require message from POLICY','DOCUMENT TYPE', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_toobtain()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('ATTENTION_LINE','','Attention: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('CLIENT_FILE_NO','','Your file: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); @@ -255,37 +255,37 @@ INSERT INTO provision_variable (variable_name, variable_value, help_text, "provi INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SALUTATION','','Dear "______": Type in the person’s name or Sir or Madam.',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'BOUNDARY SURVEY (WE PAY)','','Use where we will pay a B.C.L.S. to prepare a boundary survey','OFFER PREAMBLE',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(10),'BOUNDARY SURVEY (WE PAY)','','Use where we will pay a B.C.L.S. to prepare a boundary survey','OFFER PREAMBLE', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_toobtain()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(12),'SURVEY DEPOSIT','','Use to require payment of a deposit where Province is to pay for a survey','OFFER SURVEY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(12),'SURVEY DEPOSIT','','Use to require payment of a deposit where Province is to pay for a survey','OFFER SURVEY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_toobtain()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_SURVEY_DEPOSIT','','Deadline to pay survey deposit. Enter Month, Day, Year',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEPOSIT_AMOUNT_SURVEY','','$"#.##" Enter amount of survey deposit. Put in the decimal.',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(14),'LETTER AFFIRMING BC LAND SURVEYOR WAS HIRED','','Use to require client to submit letter confirming B.C.L.S. has been hired','OFFER - OBTAIN SURVEY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(14),'LETTER AFFIRMING BC LAND SURVEYOR WAS HIRED','','Use to require client to submit letter confirming B.C.L.S. has been hired','OFFER - OBTAIN SURVEY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_toobtain()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_CONFIRM_SURVEY','','Enter "On or before [date]" OR "Within [45] days from the date of this letter". Capitalize first character as this is the start of a sentence.',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(14),'LETTER AFFIRMING BOUNDARY SURVEY','','Use to remind client that surveyor’s letter must confirm that location of improvements will be on boundary plan','OFFER - OBTAIN SURVEY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(14),'LETTER AFFIRMING BOUNDARY SURVEY','','Use to remind client that surveyor’s letter must confirm that location of improvements will be on boundary plan','OFFER - OBTAIN SURVEY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_toobtain()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'DELIVER SECURITY DEPOSIT - OS','','require message from POLICY','OFFER - SECURITY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(20),'DELIVER SECURITY DEPOSIT - OS','','require message from POLICY','OFFER - SECURITY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_toobtain()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('INTERIM_TENURE_TYPE','','Insert the type of tenure now being used. e.g. Licence.',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SECURITY_AMOUNT','','#.## to post as security - indicate an amount even if blanket bond applies. Put in Decimal.',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'BLANKET SECURITY STATEMENT - OS','','Use this when client is covered by blanket security agreement.','OFFER - SECURITY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(20),'BLANKET SECURITY STATEMENT - OS','','Use this when client is covered by blanket security agreement.','OFFER - SECURITY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_toobtain()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('BLANKET_BOND_NAME','','You are currently covered by a blanket bond between MELP and "____". S...',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('INTERIM_TENURE_TYPE','','Insert the type of tenure now being used. e.g. Licence.',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(25),'INSURANCE REQUIRED - NOTICE OF FINAL REVIEW - OTHER - OS','','Use when insurance is required for other tenures eg. homeowners','OFFER - INSURANCE',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(25),'INSURANCE REQUIRED - NOTICE OF FINAL REVIEW - OTHER - OS','','Use when insurance is required for other tenures eg. homeowners','OFFER - INSURANCE', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_toobtain()); --- Variant 'NOTICE OF FINAL REVIEW (SURVEY REQUIRED)' -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW - SURVEY REQUIRED','','require message from POLICY','DOCUMENT TYPE',true); +-- Document Type 'NOTICE OF FINAL REVIEW (SURVEY REQUIRED)' +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('M',get_provision_group_id(1),'TEMPLATE VARIABLES - NOTICE OF FINAL REVIEW - SURVEY REQUIRED','','require message from POLICY','DOCUMENT TYPE', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_surveyreq()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('ATTENTION_LINE','','Attention: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('CLIENT_FILE_NO','','Your file: "______" - MUST FILL A VALUE IN - IF NOT REQUIRED, DELETE AFTER MERGING PROCESS.',get_current_provision_id()); @@ -301,19 +301,19 @@ INSERT INTO provision_variable (variable_name, variable_value, help_text, "provi INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SALUTATION','','Dear "______": Type in the person’s name or Sir or Madam.',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('TELEPHONE_NUMBER','','Type in your telephone number - "250 ___-____"',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'SURVEY - MINISTRY PAYS','','Use where ministry pays fro survey','OFFER SURVEY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(10),'SURVEY - MINISTRY PAYS','','Use where ministry pays fro survey','OFFER SURVEY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_surveyreq()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'SURVEY DEPOSIT - DEL','','Use to require payment of a deposit where Province is to pay for a survey.','OFFER SURVEY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(10),'SURVEY DEPOSIT - DEL','','Use to require payment of a deposit where Province is to pay for a survey.','OFFER SURVEY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_surveyreq()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_SURVEY_DEPOSIT','','Deadline to pay survey deposit. Enter Month, Day, Year',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEPOSIT_AMOUNT_SURVEY','','$"#.##" Enter amount of survey deposit. Put in the decimal.',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(10),'SURVEY - CLIENT - PAYS','','Use when client pays for survey','OFFER SURVEY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(10),'SURVEY - CLIENT - PAYS','','Use when client pays for survey','OFFER SURVEY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_surveyreq()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_COMPLETE_SURVEY','','on or before "month day, year"',get_current_provision_id()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('DEADLINE_CONFIRM_SURVEY','','Enter "On or before [date]" OR "Within [45] days from the date of this letter". Capitalize first character as this is the start of a sentence.',get_current_provision_id()); -INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag) VALUES ('V',get_provision_group_id(20),'DELIVER SECURITY DEPOSIT (& SURVEY DEPOSIT) - NOTICE OF FINAL REVIEW','','Use this where 2 deposits are to be delivered: one for the survey and another for clean-up under the terms of the tenure to be issued','OFFER - SECURITY',true); +INSERT INTO provision (type, "provisionGroupId", provision_name, free_text, help_text, category, active_flag, order_value, is_deleted) VALUES ('V',get_provision_group_id(20),'DELIVER SECURITY DEPOSIT (& SURVEY DEPOSIT) - NOTICE OF FINAL REVIEW','','Use this where 2 deposits are to be delivered: one for the survey and another for clean-up under the terms of the tenure to be issued','OFFER - SECURITY', true, 1, false); INSERT INTO provision_document_type (provision_id, document_type_id) VALUES (get_current_provision_id(), get_doc_type_surveyreq()); INSERT INTO provision_variable (variable_name, variable_value, help_text, "provisionId") VALUES ('SECURITY_AMOUNT','','#.## to post as security - indicate an amount even if blanket bond applies. Put in Decimal.',get_current_provision_id()); \ No newline at end of file diff --git a/frontend/src/app/components/modal/admin/manage-templates/forms/EditProvisionModalForm.tsx b/frontend/src/app/components/modal/admin/manage-templates/forms/EditProvisionModalForm.tsx index c3eb60f4..2595df14 100644 --- a/frontend/src/app/components/modal/admin/manage-templates/forms/EditProvisionModalForm.tsx +++ b/frontend/src/app/components/modal/admin/manage-templates/forms/EditProvisionModalForm.tsx @@ -56,7 +56,6 @@ const EditProvisionModalForm: React.FC = ({ setHelpText(provision.help_text); setCategory(provision.category); setOrder(provision.order_value); - console.log('setOrder:' + provision.order_value); provision.document_type_ids ? setDocumentTypeIds(provision.document_type_ids) : setDocumentTypeIds([]); } };