Description:
Implement functionality for creating a supplemental report. When the "Create supplemental report" button is clicked, it will generate a new version of the assessed report, renamed from "Compliance report" to "Supplemental report" with a status of "Draft." The original compliance report needs to remain a permanent record.
A supplemental report in Draft status will include the bulleted list of schedule links, and the edit icon will be available on the schedules.
The new supplemental report will build on the original schedule data and only create data for new and amended information. Deleted data will also be tagged for tracking the changes. A new summary will be created resulting in a new summary snapshot when submitted and assessed. This will allow for comparison of historical summary data.
Changes to schedule data and while new schedules added will be reflected in a changelog; tracking all edits, deletions, and additions. The system will allow switching between 'track changes' and 'accepted changes' modes.
Purpose and benefit to user:
This feature allows users to create an amended report based on the original compliance report, providing a clear view of all changes while retaining the original data. It simplifies tracking of report revisions and provides transparency through a "track changes" style functionality.
Acceptance Criteria:
[ ] Clicking the "Create supplemental report" button generates a new version of the report with a new title: "Supplemental report."
[ ] The status of the new report is set to "Draft."
[ ] The original summary snapshot, assessment, and history data are retained.
[ ] The edit icon is available on schedules.
[ ] Links to all schedules are displayed in a bulleted list format.
[ ] The changelog tracks any deleted, edited, or added rows and data in the schedules.
[ ] Changelog and display modes behave like "track changes" and "accepted changes."
[ ] New summary information is generated based on the original schedule data and the newly amended data.
Developer Requirements:
Backend Implementation:
Supplemental Report Creation Logic:
Implement the "Create Supplemental Report" functionality.
On button click:
Create a new supplemental_report record.
Set status to 'DRAFT' and report_type to 'SUPPLEMENTAL'.
Set original_report_id and previous_report_id:
First Supplemental Report:
Both original_report_id and previous_report_id are set to the initial compliance report's ID.
Subsequent Supplemental Reports:
original_report_id remains the initial report's ID.
previous_report_id is set to the most recent supplemental report's ID.
Set the version number appropriately (initial report is version 1).
Ensure the original compliance report remains unaltered.
ComplianceReportSummary Model Adjustments:
class ComplianceReportSummary(BaseModel, Auditable):
__tablename__ = "compliance_report_summary"
__table_args__ = (
CheckConstraint(
"(compliance_report_id IS NULL) != (supplemental_report_id IS NULL)",
name="check_one_report_id_not_null",
),
{"comment": "Summary of compliance calculations"},
)
ComplianceReportHistory Model Adjustments:
class ComplianceReportHistory(BaseModel, Auditable):
__tablename__ = "compliance_report_history"
__table_args__ = (
CheckConstraint(
"(compliance_report_id IS NULL) != (supplemental_report_id IS NULL)",
name="check_one_report_id_not_null",
),
{"comment": "Tracks status changes of compliance reports"},
)
compliance_report_history_id = Column(
Integer,
primary_key=True,
autoincrement=True,
comment="Unique identifier for the compliance report history",
)
compliance_report_id = Column(
Integer,
ForeignKey("compliance_report.compliance_report_id"),
nullable=True,
comment="Foreign key to the compliance report",
)
supplemental_report_id = Column(
Integer,
ForeignKey("supplemental_report.supplemental_report_id"),
nullable=True,
comment="Foreign key to the supplemental report",
)
- Update relationships and ensure that either `compliance_report_id` or `supplemental_report_id` is set, not both.
Creating ComplianceReportSummary Record:
On creation of the supplemental report:
Create a new compliance_report_summary record.
Set supplemental_report_id to the new supplemental report's ID.
Leave compliance_report_id as NULL.
Set the version number to match the supplemental report's version.
ComplianceReportHistory Record Creation:
Create a new compliance_report_history record referencing the new supplemental report.
Set status_id to 'DRAFT'.
Associate it with the user who created the supplemental report.
Ensure compliance_report_id is NULL and supplemental_report_id is set.
Frontend Implementation:
UI Updates:
Add the "Create Supplemental Report" button on the compliance report view page.
Upon creating a supplemental report:
Redirect the user to the new supplemental report in Draft status.
Update the report title to "Supplemental Report".
Display the version number prominently.
Schedule Editing:
Enable the edit icon on schedules within the supplemental report.
Ensure users can add, edit, or delete data in the schedules.
Display schedule links in a bulleted list format.
Data Integrity and Versioning:
Report Chain Management:
Ensure original_report_id and previous_report_id correctly represent the report chain.
Validate that version numbers are correctly incremented.
Implement checks to prevent skipping versions or incorrect associations.
Database Constraints:
Utilize database constraints (e.g., foreign keys, check constraints) to enforce data integrity.
Ensure that the Check Constraint in ComplianceReportSummary and ComplianceReportHistory enforces that only one of compliance_report_id or supplemental_report_id is non-null.
Testing:
Unit Tests:
Write tests for creating supplemental reports and ensuring correct field values.
Test the creation of ComplianceReportSummary and ComplianceReportHistory records.
Data Integrity Tests:
Test scenarios where data integrity might be compromised (e.g., missing IDs, incorrect versioning).
Ensure that constraints and validations are effective.
Additional Context:
Changelog Out of Scope:
Building the complete changelog mode to track all schedule changes (deleted, edited, added data) is out of scope for this ticket.
Focus on Database and Versioning Logic:
The primary focus is on implementing the backend logic for supplemental report creation, versioning, and history tracking.
Assumptions:
Users have the necessary permissions to create and edit supplemental reports.
The system supports multiple supplemental reports linked to a single original compliance report.
Notes:
Data Integrity:
Ensure that creating a supplemental report does not alter or invalidate the original compliance report.
The system must prevent the creation of supplemental reports if there are pending assessments on previous reports.
Description: Implement functionality for creating a supplemental report. When the "Create supplemental report" button is clicked, it will generate a new version of the assessed report, renamed from "Compliance report" to "Supplemental report" with a status of "Draft." The original compliance report needs to remain a permanent record.
A supplemental report in Draft status will include the bulleted list of schedule links, and the edit icon will be available on the schedules.
The new supplemental report will build on the original schedule data and only create data for new and amended information. Deleted data will also be tagged for tracking the changes. A new summary will be created resulting in a new summary snapshot when submitted and assessed. This will allow for comparison of historical summary data.
Changes to schedule data and while new schedules added will be reflected in a changelog; tracking all edits, deletions, and additions. The system will allow switching between 'track changes' and 'accepted changes' modes.
Wireframe: This wireframe contains some additional updates to the card layout that will likely be covered in a different ticket. https://preview.uxpin.com/da68049c0af15edd7ce4e47e4bee431fed40c30d#/pages/188097236
Purpose and benefit to user: This feature allows users to create an amended report based on the original compliance report, providing a clear view of all changes while retaining the original data. It simplifies tracking of report revisions and provides transparency through a "track changes" style functionality.
Acceptance Criteria:
Developer Requirements:
Backend Implementation:
Supplemental Report Creation Logic:
Implement the "Create Supplemental Report" functionality.
On button click:
Create a new
supplemental_report
record.Set
status
to 'DRAFT' andreport_type
to 'SUPPLEMENTAL'.Set
original_report_id
andprevious_report_id
:original_report_id
andprevious_report_id
are set to the initial compliance report's ID.original_report_id
remains the initial report's ID.previous_report_id
is set to the most recent supplemental report's ID.Set the
version
number appropriately (initial report is version 1).Ensure the original compliance report remains unaltered.
ComplianceReportSummary Model Adjustments:
ComplianceReportHistory Model Adjustments:
Creating ComplianceReportSummary Record:
compliance_report_summary
record.supplemental_report_id
to the new supplemental report's ID.compliance_report_id
asNULL
.version
number to match the supplemental report's version.ComplianceReportHistory Record Creation:
compliance_report_history
record referencing the new supplemental report.status_id
to 'DRAFT'.compliance_report_id
isNULL
andsupplemental_report_id
is set.Frontend Implementation:
UI Updates:
version
number prominently.Schedule Editing:
Data Integrity and Versioning:
Report Chain Management:
original_report_id
andprevious_report_id
correctly represent the report chain.version
numbers are correctly incremented.Database Constraints:
ComplianceReportSummary
andComplianceReportHistory
enforces that only one ofcompliance_report_id
orsupplemental_report_id
is non-null.Testing:
Unit Tests:
ComplianceReportSummary
andComplianceReportHistory
records.Data Integrity Tests:
Additional Context:
Changelog Out of Scope:
Focus on Database and Versioning Logic:
Assumptions:
Notes: