Skip to content

Commit

Permalink
docs:
Browse files Browse the repository at this point in the history
Initial documentation for DR SPs
  • Loading branch information
fibble committed Jun 3, 2024
1 parent d690188 commit fdf9b1e
Show file tree
Hide file tree
Showing 25 changed files with 315 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/app/data-retention/sp_populate_admin_cancelled.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### sp_populate_admin_cancelled

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `bus_reg`
- **Status Filter:** Selects records where the `bus_reg_status_id` is `'breg_s_admin'` which is "admin cancelled" status
- **Date Filter:** Selects records where the `effective_date` is older than the current date minus the retention period.


#### Summary:
- This procedure deletes records from the `bus_reg` table where the `bus_reg_status_id` is `'breg_s_admin'` and the `effective_date` is older than the current date minus the retention period defined in the data retention rules.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### sp_populate_application_not_yet_submitted

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `application`
- **Status Filter:** Selects records where the application status is `'apsts_not_submitted'`.
- **Date Filter:** Selects records based on the `last_modified_on` or `created_on` date being older than the current date minus the retention period.

#### Summary:
- This procedure targets records in the `application` table where the status is `'apsts_not_submitted'` and either the last modified date or creation date is older than the current date minus the retention period. These records are then staged for deletion.
13 changes: 13 additions & 0 deletions docs/app/data-retention/sp_populate_application_ntu_withdrawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### sp_populate_application_ntu_withdrawn

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `application`
- **Status Filter:** Selects records where the application status is either `'apsts_ntu'` (not taken up) or `'apsts_withdrawn'` (withdrawn by the applicant).
- **Event Filter:** Only considers records where the last event related to the application is of type ID `5` or `16`, which are presumably significant events for these application statuses.
- **Date Filter:** Filters applications based on the date of the last relevant event being older than the current date minus the retention period defined.

#### Summary:
- This procedure focuses on records from the `application` table with statuses of not taken up or withdrawn, considering only those where the last significant event occurred before the current date minus the retention period.
13 changes: 13 additions & 0 deletions docs/app/data-retention/sp_populate_application_refused.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### sp_populate_application_refused

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `application`
- **Status Filter:** Selects records where the application status is `'apsts_refused'`.
- **Variation Filter:** Considers only applications that are not variations (`is_variation = 0`).
- **Date Filter:** Filters applications based on the `refused_date` being older than the current date minus the retention period.

#### Summary:
- This procedure targets records in the `application` table that have been refused and are not variations, considering those whose refusal date is older than the current date minus the retention period.
12 changes: 12 additions & 0 deletions docs/app/data-retention/sp_populate_cancelled_reg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### sp_populate_cancelled_reg

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `bus_reg`
- **Status Filter:** Selects records where the bus registration status is `'breg_s_cancelled'`, ensuring that the selected registrations are cancelled.
- **Date Filter:** Filters registrations based on the `effective_date` being older than the current date minus the retention period defined for this rule.

#### Summary:
- This procedure targets records in the `bus_reg` table that have been cancelled, specifically those whose effective date is older than the current date minus the retention period.
11 changes: 11 additions & 0 deletions docs/app/data-retention/sp_populate_case_impounding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### sp_populate_case_impounding

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `cases`
- **Closure Filter:** Selects case records where the `closed_date` is older than the current date minus the retention period defined for this.

#### Summary:
- This procedure identifies cases related to impounding that have been closed and whose closed date is older than the current date minus the retention period.
13 changes: 13 additions & 0 deletions docs/app/data-retention/sp_populate_document_financial_reports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### sp_populate_document_financial_reports

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `document`
- **Sub-category Filter:** Selects records specifically in the sub-category with ID `180`, which likely corresponds to financial reports.
- **Association Filters:** Ensures the documents considered for deletion are not associated with any licences, applications, cases, transport managers, operating centres, IRFO organisations, submissions, statements, or continuation details.
- **Date Filter:** Filters documents based on the last modification or creation date being older than the current date minus the retention period from the data retention rules table.

#### Summary:
- Targets documents classified under a specific financial report sub-category, which are not linked to any major entity (eg licences or applications), and whose last modification or creation date is older than the retention period.
11 changes: 11 additions & 0 deletions docs/app/data-retention/sp_populate_irfo_gv_permit_expired.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### sp_populate_irfo_gv_permit_expired

#### Parameters:
- `p_user_id INT`: User ID executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `irfo_gv_permit`
- **Expiry Filter:** Selects records where the `expiry_date` of the permit is older than the current date minus the retention period.

#### Summary:
- This procedure targets expired IRFO goods vehicle permits, populating rows where the expiry date is older than the current date minus the retention period.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### sp_populate_irfo_gv_permit_withdrawn_pending_refused_expired

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `irfo_gv_permit`
- **Status Filter:** Selects records where the IRFO goods vehicle permit status is in one of the following states: 'irfo_auth_s_withdrawn' (withdrawn), 'irfo_perm_s_pending' (pending), or 'irfo_perm_s_refused' (refused).
- **No Expiry Date Filter:** Specifically targets permits that do not have an `expiry_date` set.
- **Creation Date Filter:** Filters permits based on the `created_on` date being older than the current date minus the retention period

#### Summary:
- This procedure identifies IRFO goods vehicle permits with specific statuses (withdrawn, pending, or refused) that lack an expiry date and whose creation date is older than the current date minus the retention period.
13 changes: 13 additions & 0 deletions docs/app/data-retention/sp_populate_irfo_operator_expired.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### sp_populate_irfo_operator_expired

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `organisation`
- **Type Filter:** Focuses on organizations of type 'org_t_ir', IRFO Operators.
- **Creation Date Filter:** Selects organizations based on the `created_on` date being older than the current date minus the retention period fron the data retention rules.
- **Association Filters:** Ensures that the organizations are not currently associated with any IRFO PSV authorizations, IRFO goods vehicle permits, or licenses.

#### Summary:
- This procedure targets IRFO operator organizations that are no longer linked to any active permits, authorizations, or licenses and whose creation date is older than the specified retention period. It stages these organization records for deletion.
11 changes: 11 additions & 0 deletions docs/app/data-retention/sp_populate_irfo_psv_auth_expired.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### sp_populate_irfo_psv_auth_expired

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `irfo_psv_auth`
- **Expiry Filter:** Selects records where the `expiry_date` of the PSV authorization is older than the current date minus the retention period parameter.

#### Summary:
- This procedure identifies expired IRFO PSV authorizations, selecting those whose expiry date is older than the current date minus the retention period.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### sp_populate_irfo_psv_auth_withdrawn_pending_refused_expired

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `irfo_psv_auth`
- **Status Filter:** Selects records where the PSV authorization status is in one of the following states: 'irfo_auth_s_withdrawn' (withdrawn), 'irfo_auth_s_pending' (pending), 'irfo_auth_s_refused' (refused), 'irfo_auth_s_granted' (granted), or 'irfo_auth_s_cns' (consented).
- **No Expiry Date Filter:** Specifically targets authorizations that do not have an `expiry_date` set.
- **Creation Date Filter:** Filters authorizations based on the `created_on` date being older than the current date minus the retention period.

#### Summary:
- This procedure identifies IRFO PSV authorizations with specific statuses, particularly those without an expiry date and whose creation date is older than the current date minus the retention period.
11 changes: 11 additions & 0 deletions docs/app/data-retention/sp_populate_irhp_cancelled_withdrawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### sp_populate_irhp_cancelled_withdrawn

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `irhp_application`
- **Status Filter:** Selects records where the IRHP (International Road Haulage Permit) application status is either 'permit_app_cancelled' (cancelled) or 'permit_app_withdrawn' (withdrawn).
- **Date Filter:** Filters applications based on the `last_modified_on` date being older than the current date minus the retention period.
#### Summary:
- This procedure identifies cancelled or withdrawn IRHP applications, selecting those whose last modification date is older than the current date minus the retention period
12 changes: 12 additions & 0 deletions docs/app/data-retention/sp_populate_irhp_cert_road_nys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### sp_populate_irhp_cert_road_nys

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `irhp_application`
- **Status Filter:** Selects records where the IRHP application status is 'permit_app_nys' (not yet started).
- **Permit Type Filter:** Specifically targets applications for permit types with IDs `6` and `7`.
- **Date Filter:** Filters applications based on either the `last_modified_on` date or the `created_on` date being older than 12 months from the current date. This accounts for cases where the last modified date might be null.
#### Summary:
- This procedure identifies IRHP applications that are not yet started (status 'permit_app_nys') for specific permit types, selecting those whose last interaction or creation is older than 12 months.
14 changes: 14 additions & 0 deletions docs/app/data-retention/sp_populate_irhp_expired.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### sp_populate_irhp_expired

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `irhp_permit` and `irhp_application`
- **Status Filter for IRHP Permit:** Selects records where the IRHP permit status is 'irhp_permit_expired'.
- **Status Filter for IRHP Application:** Selects records where the IRHP application status is 'permit_app_expired'.
- **Date Filter for IRHP Permit:** Filters permits based on the `last_modified_on` date being older than the current date minus the retention window.
- **Date Filter for IRHP Application:** Filters applications based on the `last_modified_on` date being older than 60 months from the current date.

#### Summary:
- This procedure identifies expired IRHP permits and applications, selecting those permits whose last modification date is older than the defined retention period and applications whose last modification date is older than 60 months.
11 changes: 11 additions & 0 deletions docs/app/data-retention/sp_populate_irhp_replaced_permits.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### sp_populate_irhp_replaced_permits

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `irhp_permit`
- **Status Filter:** Selects records where the IRHP permit status is 'irhp_permit_ceased'.
- **Expiry Date Filter:** Filters permits based on the `expiry_date` being earlier than the current date minus the retention period.
#### Summary:
- This procedure targets IRHP permits that have been ceased or replaced, selecting those whose expiry date is older than the defined retention period.
13 changes: 13 additions & 0 deletions docs/app/data-retention/sp_populate_irhp_terminated_permits.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### sp_populate_irhp_terminated_permits

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `irhp_permit` and `irhp_application`
- **Status Filter for IRHP Permit:** Selects records where the IRHP permit status is 'irhp_permit_terminated'.
- **Date Filter for IRHP Permit:** Filters permits based on the `last_modified_on` date being older than the current date minus the retention period defined in the data retention rules.
- **Comprehensive Application Cleanup:** Also targets IRHP applications associated solely with terminated permits, ensuring applications that no longer have any active or non-terminated permits and were last modified more than 60 months ago are selected.

#### Summary:
- This procedure identifies terminated IRHP permits and their associated applications, selecting those permits and applications whose last modification dates are older than the defined retention periods.
12 changes: 12 additions & 0 deletions docs/app/data-retention/sp_populate_irhp_unsuccessful.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### sp_populate_irhp_unsuccessful

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `irhp_application`
- **Status Filter:** Selects records where the IRHP application status is 'permit_app_unsuccessful'.
- **Date Filter:** Filters applications based on the `last_modified_on` date being older than the current date minus the retention period defined in config.

#### Summary:
- This procedure identifies IRHP applications that were unsuccessful, selecting those whose last modification date is older than the defined retention period.
14 changes: 14 additions & 0 deletions docs/app/data-retention/sp_populate_licence_no_imp_unlicenced.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### sp_populate_licence_no_imp_unlicenced

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `licence`
- **Organisation Filter:** Targets licences linked to organisations flagged as unlicensed (`is_unlicensed = TRUE`).
- **Licence Status Filter:** Selects licences with the status `'lsts_unlicenced'`.
- **Case Association Filter:** Excludes licences that are associated with any cases, specifically impounding cases.
- **Expiry Date Filter:** Filters licences based on their expiry date being earlier than the current date minus the retention period.

#### Summary:
- This procedure identifies unlicensed licences that are not involved in ongoing cases and whose expiry dates have passed beyond the designated retention period.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### sp_populate_licence_no_pi_no_imp_not_unlicenced

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `licence`
- **Exclusion of Cases:** Excludes licences that are currently involved in any public inquiry (`pi`) or impounding cases.
- **Organisation Filter:** Targets licences linked to organisations that are not marked as unlicensed (`is_unlicensed = FALSE`).
- **Licence Category Filter:** Specifically targets licences categorised under 'lcat_gv' (likely goods vehicles).
- **Expiry Date Filter:** Filters licences based on their expiry date being earlier than the current date minus the retention period defined in the data retention rules.

#### Summary:
- This procedure identifies licences not involved in public inquiries or impounding cases, which are not marked as unlicensed, specifically within the GV category, and whose expiry dates have passed beyond the retention period.
13 changes: 13 additions & 0 deletions docs/app/data-retention/sp_populate_licence_not_submitted.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### sp_populate_licence_not_submitted

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Summary:
- This procedure identifies licences that have not been submitted and are not associated with any applications. It targets those whose expiry dates have passed beyond the retention period

#### Record Selection Criteria for Deletion:
- **Entity:** `licence`
- **Status Filter:** Selects licences with the status `'lsts_not_submitted'`.
- **Expiry Date Filter:** Filters licences based on their expiry date being earlier than the current date minus the retention period.
- **Application Association Filter:** Excludes licences that are associated with any applications, ensuring only those without any submitted applications are selected.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### sp_populate_licence_with_imp_not_unlicenced

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Summary:
- This procedure identifies licences within the goods vehicles category that have been involved in impounding cases and are not associated with unlicensed organisations. It targets those whose expiry dates have passed beyond the designated retention period, staging these licence records for potential deletion if they meet the specified retention criteria. This process aids in maintaining compliance and data integrity by removing outdated or no longer needed licence records from the system.

#### Record Selection Criteria for Deletion:
- **Entity:** `licence`
- **Impounding Cases Filter:** Selects licences that are associated with impounding cases.
- **Organisation Filter:** Targets licences linked to organisations that are not marked as unlicensed (`is_unlicensed = FALSE`).
- **Licence Category Filter:** Specifically targets licences categorised under 'lcat_gv' (likely goods vehicles).
- **Expiry Date Filter:** Filters licences based on their expiry date being earlier than the current date minus the defined retention period.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### sp_populate_licence_with_pi_no_imp_not_unlicenced

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Summary:
- This procedure identifies goods vehicle licences involved in public inquiries but not impounding cases, which are not associated with unlicensed organisations, and whose expiry dates have passed beyond the retention period.

#### Record Selection Criteria for Deletion:
- **Entity:** `licence`
- **Public Inquiry Filter:** Selects licences that are involved in public inquiries.
- **Exclusion of Impounding Cases:** Excludes licences that are currently involved in any impounding cases, selecting only those with public inquiry cases.
- **Organisation Filter:** Targets licences linked to organisations that are not marked as unlicensed (`is_unlicensed = FALSE`).
- **Licence Category Filter:** Specifically targets licences categorised under 'lcat_gv' (likely goods vehicles).
- **Expiry Date Filter:** Filters licences based on their expiry date being earlier than the current date minus the retention period defined in the data retention rules.
12 changes: 12 additions & 0 deletions docs/app/data-retention/sp_populate_misc_fees.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### sp_populate_misc_fees

#### Parameters:
- `p_user_id INT`: User ID of the person executing the procedure.

#### Record Selection Criteria for Deletion:
- **Entity:** `fee`
- **Association Filters:** Targets fee records that are not associated with any licence, IRFO goods vehicle permit, IRFO PSV authorization, bus registration, application, IRHP application, or task, ensuring only miscellaneous fees with no current relevant entity links are selected.
- **Date Filter:** Filters fees based on the `last_modified_on` or `created_on` date being older than the current date minus the retention period defined in the retention rules. This identifies fees that have not been updated or relevant for a specified time period.

#### Summary:
- This procedure identifies miscellaneous fee records that are unlinked to any major operational entity and whose modification or creation date is older than the defined retention period.
Loading

0 comments on commit fdf9b1e

Please sign in to comment.