From 7c0e7b03c2e404d65035fa63dd3cae41240a2a2e Mon Sep 17 00:00:00 2001 From: matbusby Date: Wed, 27 Mar 2024 10:32:41 -0600 Subject: [PATCH] Update long descriptions and prevent submitting certain reports as CRR --- ...e_compliance_article_long_descriptions.sql | 78 +++++++++++++++++++ .../components/reports/ReportGetStarted.tsx | 24 +++++- .../src/components/reports/ReportSteps.tsx | 6 +- .../reports/mineReportDefinition.interface.ts | 1 + .../reports/models/mine_report_definition.py | 3 +- .../core-api/app/api/mines/response_models.py | 1 + 6 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 migrations/sql/V2024.03.22.14.25__update_compliance_article_long_descriptions.sql diff --git a/migrations/sql/V2024.03.22.14.25__update_compliance_article_long_descriptions.sql b/migrations/sql/V2024.03.22.14.25__update_compliance_article_long_descriptions.sql new file mode 100644 index 0000000000..069a1e4c78 --- /dev/null +++ b/migrations/sql/V2024.03.22.14.25__update_compliance_article_long_descriptions.sql @@ -0,0 +1,78 @@ +ALTER TABLE mine_report_definition +ADD COLUMN is_prr_only BOOLEAN DEFAULT FALSE; + +UPDATE mine_report_definition +SET is_prr_only = FALSE +WHERE is_prr_only IS NULL; + +ALTER TABLE mine_report_definition +ALTER COLUMN is_prr_only SET NOT NULL; + +DO $$ + DECLARE + annual_placer_report_id INTEGER; + annual_work_and_reclamation_report_id INTEGER; + multi_year_report_id INTEGER; + + BEGIN + + SELECT mine_report_definition_id INTO annual_placer_report_id + FROM mine_report_definition + WHERE report_name = 'Annual Summary of Placer Activities'; + + SELECT mine_report_definition_id INTO annual_work_and_reclamation_report_id + FROM mine_report_definition + WHERE report_name = 'Annual Summary of Work and Reclamation Report'; + + SELECT mine_report_definition_id INTO multi_year_report_id + FROM mine_report_definition + WHERE report_name = 'Multi-Year Area Based Permit Updates'; + + UPDATE mine_report_definition + SET is_prr_only = TRUE, is_common = FALSE + WHERE mine_report_definition_id = annual_placer_report_id + OR mine_report_definition_id = annual_work_and_reclamation_report_id + OR mine_report_definition_id = multi_year_report_id; + + END +$$; + +UPDATE compliance_article +SET + sub_paragraph = '(g)', + long_description = 'This report is an annually completed PDF fillable form called "Annual Summary of Work and Reclamation" and required maps for Sand and Gravel/Quarry Operations where required by permit condition.' +WHERE + section = '10' + AND sub_section = '4' + AND paragraph = '4' + AND sub_paragraph = 'g'; + +DO +$$ + DECLARE + report_id INTEGER; + correct_compliance_article_id INTEGER; + incorrect_compliance_article_id INTEGER; + BEGIN + + SELECT mine_report_definition_id INTO report_id + FROM mine_report_definition + WHERE report_name = 'Annual Summary of Work and Reclamation Report'; + + SELECT compliance_article_id INTO incorrect_compliance_article_id + FROM mine_report_definition_compliance_article_xref + WHERE mine_report_definition_id = report_id; + + SELECT compliance_article_id INTO correct_compliance_article_id + FROM compliance_article + WHERE section = '10' + AND sub_section = '4' + AND paragraph = '4' + AND sub_paragraph = '(g)'; + + UPDATE mine_report_definition_compliance_article_xref + SET compliance_article_id = correct_compliance_article_id + WHERE mine_report_definition_id = report_id + AND compliance_article_id = incorrect_compliance_article_id; + END +$$; \ No newline at end of file diff --git a/services/common/src/components/reports/ReportGetStarted.tsx b/services/common/src/components/reports/ReportGetStarted.tsx index 1a523fb9d5..befc173b6b 100644 --- a/services/common/src/components/reports/ReportGetStarted.tsx +++ b/services/common/src/components/reports/ReportGetStarted.tsx @@ -35,6 +35,7 @@ interface ReportGetStartedProps { mine: IMine; handleSubmit: (values: Partial) => void; formButtons: ReactNode; + setDisableNextButton?: (value: boolean) => void; } export const ReportInfoBox: FC<{ mineReportDefinition: IMineReportDefinition; verb: string }> = ({ @@ -45,6 +46,14 @@ export const ReportInfoBox: FC<{ mineReportDefinition: IMineReportDefinition; ve
{mineReportDefinition && (
+ {mineReportDefinition.is_prr_only && ( + + )} You are {verb} @@ -152,7 +161,12 @@ export const RenderPRRFields: FC<{ mineGuid: string; fullWidth?: boolean }> = ({ ); }; -const ReportGetStarted: FC = ({ mine, handleSubmit, formButtons }) => { +const ReportGetStarted: FC = ({ + mine, + handleSubmit, + formButtons, + setDisableNextButton, +}) => { const dispatch = useDispatch(); const { reportType } = useParams<{ reportType?: string }>(); const system = useSelector(getSystemFlag); @@ -163,6 +177,14 @@ const ReportGetStarted: FC = ({ mine, handleSubmit, formB getMineReportDefinitionByGuid(formValues?.mine_report_definition_guid) ); + useEffect(() => { + if (selectedReportDefinition && selectedReportDefinition.is_prr_only) { + setDisableNextButton(true); + } else { + setDisableNextButton(false); + } + }, [selectedReportDefinition, setDisableNextButton]); + useEffect(() => { // Filter out common reports and sort alphabetically const commonReportDefinitions = mineReportDefinitionOptions diff --git a/services/common/src/components/reports/ReportSteps.tsx b/services/common/src/components/reports/ReportSteps.tsx index 609503cdc6..51425a4da9 100644 --- a/services/common/src/components/reports/ReportSteps.tsx +++ b/services/common/src/components/reports/ReportSteps.tsx @@ -22,6 +22,7 @@ const ReportSteps = () => { const { mineGuid, reportType } = useParams<{ mineGuid: string; reportType: string }>(); const [currentStep, setCurrentStep] = useState(0); const [initialValues, setInitialValues] = useState>({}); + const [disableNextButton, setDisableNextButton] = useState(false); const mine: IMine = useSelector((state) => getMineById(state, mineGuid)); @@ -49,11 +50,11 @@ const ReportSteps = () => { )} {nextButtonFunction ? ( - ) : ( - )} @@ -73,6 +74,7 @@ const ReportSteps = () => { setInitialValues(values); setCurrentStep(currentStep + 1); }} + setDisableNextButton={setDisableNextButton} formButtons={renderStepButtons({ nextButtonTitle: "Add Report Details", previousButtonTitle: "Cancel", diff --git a/services/common/src/interfaces/reports/mineReportDefinition.interface.ts b/services/common/src/interfaces/reports/mineReportDefinition.interface.ts index 5d3596522e..40adc70c05 100644 --- a/services/common/src/interfaces/reports/mineReportDefinition.interface.ts +++ b/services/common/src/interfaces/reports/mineReportDefinition.interface.ts @@ -14,6 +14,7 @@ export interface IMineReportDefinition { description: string; due_date_period_months?: number; is_common: boolean; + is_prr_only: boolean; mine_report_definition_guid: string; mine_report_due_date_type: string; report_name: string; diff --git a/services/core-api/app/api/mines/reports/models/mine_report_definition.py b/services/core-api/app/api/mines/reports/models/mine_report_definition.py index 6bc4612ff5..97587de48d 100644 --- a/services/core-api/app/api/mines/reports/models/mine_report_definition.py +++ b/services/core-api/app/api/mines/reports/models/mine_report_definition.py @@ -3,7 +3,6 @@ from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.schema import FetchedValue -from sqlalchemy.ext.associationproxy import association_proxy from sqlalchemy.ext.hybrid import hybrid_property from app.api.utils.models_mixins import Base, AuditMixin @@ -24,6 +23,8 @@ class MineReportDefinition(Base, AuditMixin): nullable=False) active_ind = db.Column(db.Boolean, server_default=FetchedValue(), nullable=False) is_common = db.Column(db.Boolean, server_default=FetchedValue(), nullable=False) + is_prr_only = db.Column(db.Boolean, server_default=FetchedValue(), nullable=False) + required = db.Column(db.Boolean) categories = db.relationship( diff --git a/services/core-api/app/api/mines/response_models.py b/services/core-api/app/api/mines/response_models.py index 306eba1cdf..036ab74bf5 100644 --- a/services/core-api/app/api/mines/response_models.py +++ b/services/core-api/app/api/mines/response_models.py @@ -756,6 +756,7 @@ def format(self, value): 'categories': fields.List(fields.Nested(MINE_REPORT_DEFINITION_CATEGORIES)), 'compliance_articles': fields.List(fields.Nested(COMPLIANCE_ARTICLE_MODEL)), 'is_common': fields.Boolean, + 'is_prr_only': fields.Boolean, }) PAGINATED_LIST = api.model(