From 96547e86468c9825a0efdf1d54cac675142d7e3b Mon Sep 17 00:00:00 2001 From: abrahamdennis <148991960+abrahamdennis@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:19:31 +0000 Subject: [PATCH] PO-127 Abraham added more table scripts for Discovery plus in opal fines (#73) * PO-127 Abraham added more table scripts for Discvery plus in opal fines * Update suppressions.xml --------- Co-authored-by: Sabah u Din Irfan --- config/owasp/suppressions.xml | 7 +- .../V20231203_008__business_units.sql | 33 ++++ .../V20231203_009__business_unit_id_seq.sql | 15 ++ .../db/migration/V20231203_010__courts.sql | 72 +++++++ .../migration/V20231203_011__court_id_seq.sql | 15 ++ .../db/migration/V20231203_012__results.sql | 68 +++++++ .../V20231203_013__result_id_seq.sql | 15 ++ .../db/migration/V20231204_014__enforcers.sql | 60 ++++++ .../V20231204_015__enforcer_id_seq.sql | 15 ++ .../V20231204_016__local_justice_areas.sql | 34 ++++ ...0231204_017__local_justice_area_id_seq.sql | 15 ++ .../V20231204_018__defendants_accounts.sql | 176 ++++++++++++++++++ ...20231204_019__defendant_account_id_seq.sql | 15 ++ .../db/migration/V20231204_020__parties.sql | 58 ++++++ .../migration/V20231204_021__party_id_seq.sql | 15 ++ ...0231204_022__defendant_account_parties.sql | 52 ++++++ ...04_023__defendant_account_party_id_seq.sql | 15 ++ .../V20231204_024__defendant_transactions.sql | 64 +++++++ ...1204_025__defendant_transaction_id_seq.sql | 15 ++ .../V20231204_026__debtor_detail.sql | 76 ++++++++ .../V20231204_027__debtor_detail_id_seq.sql | 15 ++ .../V20231204_028__payment_terms.sql | 56 ++++++ .../V20231204_029__payment_terms_id_seq.sql | 15 ++ .../db/migration/V20231204_030__tills.sql | 40 ++++ .../migration/V20231204_031__till_id_seq.sql | 15 ++ .../V20231205_032__fixed_penalty_offences.sql | 46 +++++ .../db/migration/V20231205_033__notes.sql | 20 ++ .../migration/V20231205_034__payments_in.sql | 58 ++++++ .../V20231205_035__payment_in_id_seq.sql | 15 ++ .../db/migration/V20231205_036__documents.sql | 36 ++++ .../V20231205_037__document_id_seq.sql | 15 ++ .../V20231205_038__document_instances.sql | 34 ++++ ...20231205_039__document_instance_id_seq.sql | 15 ++ .../V20231205_040__account_transfers.sql | 74 ++++++++ ...V20231205_041__account_transfer_id_seq.sql | 15 ++ .../migration/V20231205_042__mis_debtors.sql | 58 ++++++ .../V20231205_043__mis_debtor_id_seq.sql | 15 ++ .../migration/V20231205_044__enforcements.sql | 88 +++++++++ .../V20231205_045__enforcement_id_seq.sql | 15 ++ .../db/migration/V20231206_046__prisons.sql | 48 +++++ .../V20231206_047__prison_id_seq.sql | 15 ++ ...231206_048__committal_warrant_progress.sql | 66 +++++++ 42 files changed, 1608 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/db/migration/V20231203_008__business_units.sql create mode 100644 src/main/resources/db/migration/V20231203_009__business_unit_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231203_010__courts.sql create mode 100644 src/main/resources/db/migration/V20231203_011__court_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231203_012__results.sql create mode 100644 src/main/resources/db/migration/V20231203_013__result_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231204_014__enforcers.sql create mode 100644 src/main/resources/db/migration/V20231204_015__enforcer_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231204_016__local_justice_areas.sql create mode 100644 src/main/resources/db/migration/V20231204_017__local_justice_area_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231204_018__defendants_accounts.sql create mode 100644 src/main/resources/db/migration/V20231204_019__defendant_account_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231204_020__parties.sql create mode 100644 src/main/resources/db/migration/V20231204_021__party_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231204_022__defendant_account_parties.sql create mode 100644 src/main/resources/db/migration/V20231204_023__defendant_account_party_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231204_024__defendant_transactions.sql create mode 100644 src/main/resources/db/migration/V20231204_025__defendant_transaction_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231204_026__debtor_detail.sql create mode 100644 src/main/resources/db/migration/V20231204_027__debtor_detail_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231204_028__payment_terms.sql create mode 100644 src/main/resources/db/migration/V20231204_029__payment_terms_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231204_030__tills.sql create mode 100644 src/main/resources/db/migration/V20231204_031__till_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231205_032__fixed_penalty_offences.sql create mode 100644 src/main/resources/db/migration/V20231205_033__notes.sql create mode 100644 src/main/resources/db/migration/V20231205_034__payments_in.sql create mode 100644 src/main/resources/db/migration/V20231205_035__payment_in_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231205_036__documents.sql create mode 100644 src/main/resources/db/migration/V20231205_037__document_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231205_038__document_instances.sql create mode 100644 src/main/resources/db/migration/V20231205_039__document_instance_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231205_040__account_transfers.sql create mode 100644 src/main/resources/db/migration/V20231205_041__account_transfer_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231205_042__mis_debtors.sql create mode 100644 src/main/resources/db/migration/V20231205_043__mis_debtor_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231205_044__enforcements.sql create mode 100644 src/main/resources/db/migration/V20231205_045__enforcement_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231206_046__prisons.sql create mode 100644 src/main/resources/db/migration/V20231206_047__prison_id_seq.sql create mode 100644 src/main/resources/db/migration/V20231206_048__committal_warrant_progress.sql diff --git a/config/owasp/suppressions.xml b/config/owasp/suppressions.xml index 19daaae90..0a0a0525b 100644 --- a/config/owasp/suppressions.xml +++ b/config/owasp/suppressions.xml @@ -5,7 +5,12 @@ - + + + Need a Spring boot update to fix + CVE-2023-6378 + + diff --git a/src/main/resources/db/migration/V20231203_008__business_units.sql b/src/main/resources/db/migration/V20231203_008__business_units.sql new file mode 100644 index 000000000..0c6ba3388 --- /dev/null +++ b/src/main/resources/db/migration/V20231203_008__business_units.sql @@ -0,0 +1,33 @@ +/** +* CGI OPAL Program +* +* MODULE : business_units.sql +* +* DESCRIPTION : Creates the BUSINESS_UNITS table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 03/12/2023 A Dennis 1.0 PO-127 Creates the BUSINESS_UNITS table for the Fines model +* +**/ +CREATE TABLE business_units +( + business_unit_id smallint not null +,business_unit_name varchar(200) not null +,business_unit_code varchar(4) +,business_unit_type varchar(20) not null +,account_number_prefix varchar(2) +,parent_business_unit_id smallint +,CONSTRAINT business_unit_id_pk PRIMARY KEY + ( + business_unit_id + ) +); +COMMENT ON COLUMN business_units.business_unit_id IS 'Unique ID of this record'; +COMMENT ON COLUMN business_units.business_unit_name IS 'Business Unit name'; +COMMENT ON COLUMN business_units.business_unit_code IS 'Business unit code'; +COMMENT ON COLUMN business_units.business_unit_type IS 'Area or Accounting Division'; +COMMENT ON COLUMN business_units.account_number_prefix IS 'Accounting division code that appears before account numbers'; +COMMENT ON COLUMN business_units.parent_business_unit_id IS 'ID of the business unit that is the parent for this one'; diff --git a/src/main/resources/db/migration/V20231203_009__business_unit_id_seq.sql b/src/main/resources/db/migration/V20231203_009__business_unit_id_seq.sql new file mode 100644 index 000000000..2ff39a73c --- /dev/null +++ b/src/main/resources/db/migration/V20231203_009__business_unit_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : business_unit_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table BUSINESS_UNITS. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 03/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table BUSINESS_UNITS +* +**/ +CREATE SEQUENCE IF NOT EXISTS business_unit_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY business_units.business_unit_id; diff --git a/src/main/resources/db/migration/V20231203_010__courts.sql b/src/main/resources/db/migration/V20231203_010__courts.sql new file mode 100644 index 000000000..32b20324e --- /dev/null +++ b/src/main/resources/db/migration/V20231203_010__courts.sql @@ -0,0 +1,72 @@ +/** +* CGI OPAL Program +* +* MODULE : courts.sql +* +* DESCRIPTION : Creates the COURTS table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 03/12/2023 A Dennis 1.0 PO-127 Creates the COURTS table for the Fines model +* +**/ +CREATE TABLE courts +( + court_id bigint not null +,business_unit_id smallint not null +,court_code smallint not null +,parent_court_id bigint +,name varchar(35) not null +,name_cy varchar(35) +,address_line_1 varchar(35) +,address_line_2 varchar(35) +,address_line_3 varchar(35) +,address_line_1_cy varchar(35) +,address_line_2_cy varchar(35) +,address_line_3_cy varchar(35) +,postcode varchar(8) +,local_justice_area_id smallint not null +,national_court_code varchar(7) +,CONSTRAINT court_id_pk PRIMARY KEY + ( + court_id + ) +); + +ALTER TABLE courts +ADD CONSTRAINT crt_business_unit_id_fk FOREIGN KEY +( + business_unit_id +) +REFERENCES business_units +( + business_unit_id +); + +ALTER TABLE courts +ADD CONSTRAINT crt_parent_court_id_fk FOREIGN KEY +( + parent_court_id +) +REFERENCES courts +( + court_id +); + +COMMENT ON COLUMN courts.court_id IS 'Unique ID of this record'; +COMMENT ON COLUMN courts.business_unit_id IS 'ID of the relating till to which this till belongs'; +COMMENT ON COLUMN courts.court_code IS 'Court code unique within the business unit'; +COMMENT ON COLUMN courts.parent_court_id IS 'ID of parent court for enforcement/admin purposes'; +COMMENT ON COLUMN courts.name IS 'Court name'; +COMMENT ON COLUMN courts.name_cy IS 'Court name in welsh'; +COMMENT ON COLUMN courts.address_line_1 IS 'Court address line 1'; +COMMENT ON COLUMN courts.address_line_2 IS 'Court address line 2'; +COMMENT ON COLUMN courts.address_line_3 IS 'Court address line 3, not stored in legacy GoB'; +COMMENT ON COLUMN courts.address_line_1_cy IS 'Court address line 1 in welsh'; +COMMENT ON COLUMN courts.address_line_2_cy IS 'Court address line 2 in welsh'; +COMMENT ON COLUMN courts.address_line_3_cy IS 'Court address line 3 in welsh, not stored in legacy GoB'; +COMMENT ON COLUMN courts.postcode IS 'Court postcode, not stored in legacy GoB'; +COMMENT ON COLUMN courts.local_justice_area_id IS 'Local justice area ID'; +COMMENT ON COLUMN courts.national_court_code IS 'National court location code (OU code). New field for future development with Common Platform'; diff --git a/src/main/resources/db/migration/V20231203_011__court_id_seq.sql b/src/main/resources/db/migration/V20231203_011__court_id_seq.sql new file mode 100644 index 000000000..f0eea552b --- /dev/null +++ b/src/main/resources/db/migration/V20231203_011__court_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : court_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table COURTS. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 03/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table COURTS +* +**/ +CREATE SEQUENCE IF NOT EXISTS court_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY courts.court_id; diff --git a/src/main/resources/db/migration/V20231203_012__results.sql b/src/main/resources/db/migration/V20231203_012__results.sql new file mode 100644 index 000000000..646f141b7 --- /dev/null +++ b/src/main/resources/db/migration/V20231203_012__results.sql @@ -0,0 +1,68 @@ +/** +* CGI OPAL Program +* +* MODULE : results.sql +* +* DESCRIPTION : Creates the RESULTS table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 03/12/2023 A Dennis 1.0 PO-127 Creates the RESULTS table for the Fines model +* +**/ +CREATE TABLE results +( + result_id varchar(6) not null +,result_title varchar(50) not null +,result_title_cy varchar(50) not null +,result_type varchar(10) not null +,active boolean not null +,imposition boolean not null +,imposition_category varchar(30) +,imposition_allocation_priority smallint +,imposition_accruing boolean +,imposition_creditor varchar(10) +,enforcement boolean not null +,enforcement_override boolean not null +,further_enforcement_warn boolean not null +,further_enforcement_disallow boolean not null +,enforcement_hold boolean not null +,requires_enforcer boolean not null +,generates_hearing boolean not null +,collection_order boolean not null +,extend_ttp_disallow boolean not null +,extend_ttp_preserve_last_enf boolean not null +,prevent_payment_card boolean not null +,lists_monies boolean not null +,user_entries json +,CONSTRAINT result_id_pk PRIMARY KEY + ( + result_id + ) +); + +COMMENT ON COLUMN results.result_id IS 'Unique ID of this result'; +COMMENT ON COLUMN results.result_title IS 'Result title'; +COMMENT ON COLUMN results.result_title_cy IS 'Result title'; +COMMENT ON COLUMN results.result_type IS 'Indicates if this is an acutal result or just an action. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.active IS 'Indicates if this result can be applied to new accounts. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.imposition IS 'Indicates if this result creates an imposition. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.imposition_category IS 'Financial category that monies for this imposition are reported under. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.imposition_allocation_priority IS 'Determines the order in which monies received are allocated to this impsition with respect to other impositions on the same account. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.imposition_accruing IS 'Indicates if this result is an imposition that accrues with time. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.imposition_creditor IS 'Indicates the creditor to be used for the imposition. Can be either Central (Central Fund Account), DPP (Crown Prosection Service), !DPP (a creditor other than DPP) or Any (any creditor). New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.enforcement IS 'Indicates if this result is an enforcement result. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.enforcement_override IS 'Indicates if this result can be used as an enforcement override. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.further_enforcement_warn IS 'Indicates if a warning should be issued when applying an enforcement action while this is the last enforcement on the account. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.further_enforcement_disallow IS 'Indicates if the system should prevent applying an enforcement action while this is the last enforcement on the account. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.enforcement_hold IS 'Indicates if this action places a hold on enforcement which requires it to be explicity removed to continue further enforcement on the account. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.requires_enforcer IS 'Indicates if this result requires the user to also specify an enforcer. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.generates_hearing IS 'Indicates if applying this action should attempt to schedule an enforcement hearing for the account debtor. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.collection_order IS 'Indicates if this result is a collection order result. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.extend_ttp_disallow IS 'Indicates if this result should prevent extension of payment terms. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.extend_ttp_preserve_last_enf IS 'Indicates if this should be preserved as the last enforcement on an account after extending payment instead of clearing it. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.prevent_payment_card IS 'Indicates if this result should prevent requesting a payment card if it is the last enforcement on an account. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.lists_monies IS 'this result cause the account to be reported on List Monies Under Warrant if a payment is received while this is the last enforcement action on the account. New field. Hard-coded in legacy GoB'; +COMMENT ON COLUMN results.user_entries IS 'The parameters required to be input by the user when applyig this result. New field. Hard-coded in legacy GoB'; diff --git a/src/main/resources/db/migration/V20231203_013__result_id_seq.sql b/src/main/resources/db/migration/V20231203_013__result_id_seq.sql new file mode 100644 index 000000000..41d4ec70f --- /dev/null +++ b/src/main/resources/db/migration/V20231203_013__result_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : result_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table RESULTS. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 03/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table RESULTS +* +**/ +CREATE SEQUENCE IF NOT EXISTS result_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY results.result_id; diff --git a/src/main/resources/db/migration/V20231204_014__enforcers.sql b/src/main/resources/db/migration/V20231204_014__enforcers.sql new file mode 100644 index 000000000..5af4e7094 --- /dev/null +++ b/src/main/resources/db/migration/V20231204_014__enforcers.sql @@ -0,0 +1,60 @@ +/** +* CGI OPAL Program +* +* MODULE : enforcers.sql +* +* DESCRIPTION : Creates the ENFORCERS table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 04/12/2023 A Dennis 1.0 PO-127 Creates the ENFORCERS table for the Fines model +* +**/ +CREATE TABLE enforcers +( + enforcer_id bigint not null +,business_unit_id smallint not null +,enforcer_code smallint not null +,name varchar(35) not null +,name_cy varchar(35) +,address_line_1 varchar(35) +,address_line_2 varchar(35) +,address_line_3 varchar(35) +,address_line_1_cy varchar(35) +,address_line_2_cy varchar(35) +,address_line_3_cy varchar(35) +,postcode varchar(8) +,warrant_reference_sequence varchar(20) +,warrant_register_sequence integer +,CONSTRAINT enforcer_id_pk PRIMARY KEY + ( + enforcer_id + ) +); + +ALTER TABLE enforcers +ADD CONSTRAINT enf_business_unit_id_fk FOREIGN KEY +( + business_unit_id +) +REFERENCES business_units +( + business_unit_id +); + +COMMENT ON COLUMN enforcers.enforcer_id IS 'Unique ID of this record'; +COMMENT ON COLUMN enforcers.business_unit_id IS 'ID of the relating till to which this till belongs'; +COMMENT ON COLUMN enforcers.enforcer_code IS 'Enforcer code unique within the business unit'; +COMMENT ON COLUMN enforcers.name IS 'Enforcer name'; +COMMENT ON COLUMN enforcers.name_cy IS 'Enforcer name in welsh'; +COMMENT ON COLUMN enforcers.address_line_1 IS 'Enforcer address line 1'; +COMMENT ON COLUMN enforcers.address_line_2 IS 'Enforcer address line 2'; +COMMENT ON COLUMN enforcers.address_line_3 IS 'Enforcer address line 3'; +COMMENT ON COLUMN enforcers.address_line_1_cy IS 'Enforcer address line 1 in welsh'; +COMMENT ON COLUMN enforcers.address_line_2_cy IS 'Enforcer address line 2 in welsh'; +COMMENT ON COLUMN enforcers.address_line_3_cy IS 'Enforcer address line 3 in welsh'; +COMMENT ON COLUMN enforcers.postcode IS 'Enforcer postcode'; +COMMENT ON COLUMN enforcers.warrant_reference_sequence IS 'Last generated warrant reference for this enforcer'; +COMMENT ON COLUMN enforcers.warrant_register_sequence IS 'Last generated warrant register serial number for this enforcer'; diff --git a/src/main/resources/db/migration/V20231204_015__enforcer_id_seq.sql b/src/main/resources/db/migration/V20231204_015__enforcer_id_seq.sql new file mode 100644 index 000000000..979eccc53 --- /dev/null +++ b/src/main/resources/db/migration/V20231204_015__enforcer_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : enforcer_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table ENFORCERS. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 04/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table ENFORCERS +* +**/ +CREATE SEQUENCE IF NOT EXISTS enforcer_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY enforcers.enforcer_id; diff --git a/src/main/resources/db/migration/V20231204_016__local_justice_areas.sql b/src/main/resources/db/migration/V20231204_016__local_justice_areas.sql new file mode 100644 index 000000000..4f7a94bd7 --- /dev/null +++ b/src/main/resources/db/migration/V20231204_016__local_justice_areas.sql @@ -0,0 +1,34 @@ +/** +* CGI OPAL Program +* +* MODULE : local_justice_areas.sql +* +* DESCRIPTION : Creates the LOCAL_JUSTICE_AREAS table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 04/12/2023 A Dennis 1.0 PO-127 Creates the LOCAL_JUSTICE_AREAS table for the Fines model +* +**/ +CREATE TABLE local_justice_areas +( + local_justice_area_id smallint not null +,name varchar(35) not null +,address_line_1 varchar(35) not null +,address_line_2 varchar(35) +,address_line_3 varchar(35) +,postcode varchar(8) +,CONSTRAINT local_justice_area_id_pk PRIMARY KEY + ( + local_justice_area_id + ) +); + +COMMENT ON COLUMN local_justice_areas.local_justice_area_id IS 'Unique ID of this record'; +COMMENT ON COLUMN local_justice_areas.name IS 'LJA name'; +COMMENT ON COLUMN local_justice_areas.address_line_1 IS 'LJA address line 1'; +COMMENT ON COLUMN local_justice_areas.address_line_2 IS 'LJA address line 2'; +COMMENT ON COLUMN local_justice_areas.address_line_3 IS 'LJA address line 3'; +COMMENT ON COLUMN local_justice_areas.postcode IS 'LJA postcode'; diff --git a/src/main/resources/db/migration/V20231204_017__local_justice_area_id_seq.sql b/src/main/resources/db/migration/V20231204_017__local_justice_area_id_seq.sql new file mode 100644 index 000000000..301cd7122 --- /dev/null +++ b/src/main/resources/db/migration/V20231204_017__local_justice_area_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : local_justice_area_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table LOCAL_JUSTICE_AREAS. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 04/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table LOCAL_JUSTICE_AREAS +* +**/ +CREATE SEQUENCE IF NOT EXISTS local_justice_area_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY local_justice_areas.local_justice_area_id; diff --git a/src/main/resources/db/migration/V20231204_018__defendants_accounts.sql b/src/main/resources/db/migration/V20231204_018__defendants_accounts.sql new file mode 100644 index 000000000..7e832d2c8 --- /dev/null +++ b/src/main/resources/db/migration/V20231204_018__defendants_accounts.sql @@ -0,0 +1,176 @@ +/** +* CGI OPAL Program +* +* MODULE : defendant_accounts.sql +* +* DESCRIPTION : Modify the DEFENDANT_ACCOUNTS table to add foreign keys +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 05/12/2023 A Dennis 1.0 Modify the DEFENDANT_ACCOUNTS table to add foreign keys +* +**/ + +-- DROP and recreate the DEFENDANT_ACCOUNTS table since NULL columns and foreign key relations are now known. Also some column names have changed in the data model +DROP TABLE IF EXISTS defendant_accounts; + +CREATE TABLE defendant_accounts +( + defendant_account_id bigint not null +,business_unit_id smallint not null +,account_number varchar(20) not null +,imposed_hearing_date timestamp +,imposing_court_id bigint +,amount_imposed decimal(18,2) not null +,amount_paid decimal(18,2) not null +,account_balance decimal(18,2) not null +,account_status varchar(2) not null +,completed_date timestamp +,enforcing_court_id bigint +,last_hearing_court_id bigint +,last_hearing_date timestamp +,last_movement_date timestamp +,last_changed_date timestamp +,last_enforcement varchar(6) +,originator_name varchar(50) +,originator_reference varchar(40) +,originator_type varchar(10) +,allow_writeoffs boolean +,allow_cheques boolean +,cheque_clearance_period smallint +,credit_trans_clearance_period smallint +,enf_override_result_id varchar(10) +,enf_override_enforcer_id bigint +,enf_override_tfo_lja_id smallint +,unit_fine_detail varchar(100) +,unit_fine_value decimal(18,2) +,collection_order boolean +,collection_order_date timestamp +,further_steps_notice_date timestamp +,confiscation_order_date timestamp +,fine_registration_date timestamp +,suspended_committal_date timestamp +,consolidated_account_type varchar(1) +,payment_card_requested boolean +,payment_card_requested_date timestamp +,payment_card_requested_by varchar(20) +,prosecutor_case_reference varchar(40) +,enforcement_case_status varchar(10) +,CONSTRAINT defendant_account_id_pk PRIMARY KEY + ( + defendant_account_id + ) +); + +ALTER TABLE defendant_accounts +ADD CONSTRAINT da_business_unit_id_fk FOREIGN KEY +( + business_unit_id +) +REFERENCES business_units +( + business_unit_id +); + +ALTER TABLE defendant_accounts +ADD CONSTRAINT da_imposing_court_id_fk FOREIGN KEY +( + imposing_court_id +) +REFERENCES courts +( + court_id +); + +ALTER TABLE defendant_accounts +ADD CONSTRAINT da_enforcing_court_id_fk FOREIGN KEY +( + enforcing_court_id +) +REFERENCES courts +( + court_id +); + +ALTER TABLE defendant_accounts +ADD CONSTRAINT da_last_hearing_court_id_fk FOREIGN KEY +( + last_hearing_court_id +) +REFERENCES courts +( + court_id +); + +ALTER TABLE defendant_accounts +ADD CONSTRAINT res_enf_override_result_id_fk FOREIGN KEY +( + enf_override_result_id +) +REFERENCES results +( + result_id +); + +ALTER TABLE defendant_accounts +ADD CONSTRAINT res_enf_override_enforcer_id_fk FOREIGN KEY +( + enf_override_enforcer_id +) +REFERENCES enforcers +( + enforcer_id +); + +ALTER TABLE defendant_accounts +ADD CONSTRAINT res_enf_override_tfo_lja_id_fk FOREIGN KEY +( + enf_override_tfo_lja_id +) +REFERENCES local_justice_areas +( + local_justice_area_id +); + +COMMENT ON COLUMN defendant_accounts.defendant_account_id IS 'Unique ID of this record'; +COMMENT ON COLUMN defendant_accounts.business_unit_id IS 'ID of the relating business unit'; +COMMENT ON COLUMN defendant_accounts.account_number IS 'Account number unique within the business unit'; +COMMENT ON COLUMN defendant_accounts.imposed_hearing_date IS 'Date the financial penalties were imposed by court'; +COMMENT ON COLUMN defendant_accounts.imposing_court_id IS 'ID of the court that imposed the financial penalties'; +COMMENT ON COLUMN defendant_accounts.amount_imposed IS 'The total amount of impositions against this account'; +COMMENT ON COLUMN defendant_accounts.amount_paid IS 'The total amount of payments received for this account'; +COMMENT ON COLUMN defendant_accounts.account_balance IS 'The balance outstanding on this account. Was not stored in Legacy GoB'; +COMMENT ON COLUMN defendant_accounts.account_status IS 'The status of the account. L (Live), C-(Completed), TO (Transfer Out Pending), TS (Transfer Out to NI/Scotland Pending), TA (Transfer Out Acknowledged), Consolidated (CS).'; +COMMENT ON COLUMN defendant_accounts.completed_date IS 'Date the account balance was cleared. Not set by GoB Consolidation as it duplicates the account elsewhere. Going forward new consolidation does not need to do this as it can link multiple accounts'; +COMMENT ON COLUMN defendant_accounts.enforcing_court_id IS 'ID of the court responsible for enforcing this account'; +COMMENT ON COLUMN defendant_accounts.last_hearing_court_id IS 'ID of the court where the last hearing relating to this account was heard'; +COMMENT ON COLUMN defendant_accounts.last_hearing_date IS 'The last date a case relating to this account was heard to court'; +COMMENT ON COLUMN defendant_accounts.last_movement_date IS 'The last date there was movement against this account. A movement is considered to be account creation, hearing validation, enforcement, or any change to the account status, paid amount of payment terms.'; +COMMENT ON COLUMN defendant_accounts.last_enforcement IS 'The last (or currently in force) enforcement action on this account. Not necessarily the most recent enforcement as some do not update this.'; +COMMENT ON COLUMN defendant_accounts.last_changed_date IS 'The date this account was last modified by Account Maintenance'; +COMMENT ON COLUMN defendant_accounts.originator_name IS 'The name of the court or system where the account came from'; +COMMENT ON COLUMN defendant_accounts.originator_reference IS 'The originator''s reference for this account. This could be the case reference or the trasferring courts reference.'; +COMMENT ON COLUMN defendant_accounts.originator_type IS 'How the account got loaded'; +COMMENT ON COLUMN defendant_accounts.allow_writeoffs IS 'Whether cheque payments are accepted for this account'; +COMMENT ON COLUMN defendant_accounts.allow_cheques IS 'Whether cheque payments are accepted for this account'; +COMMENT ON COLUMN defendant_accounts.cheque_clearance_period IS 'The number of days before cheque payments are considered cleared'; +COMMENT ON COLUMN defendant_accounts.credit_trans_clearance_period IS 'The number of days before creditor transfer payments are considered cleared'; +COMMENT ON COLUMN defendant_accounts.enf_override_result_id IS 'The enforcement result that will be applied if this account is enforcement by auto-enforcement'; +COMMENT ON COLUMN defendant_accounts.enf_override_enforcer_id IS 'The enforcer that will be allocated to enforcement override result'; +COMMENT ON COLUMN defendant_accounts.enf_override_tfo_lja_id IS 'The ID of the LJA the account will be transferred to if the override result is TFFOUT'; +COMMENT ON COLUMN defendant_accounts.unit_fine_detail IS 'Unit fine calculation information used to calculate the fine amount'; +COMMENT ON COLUMN defendant_accounts.unit_fine_value IS 'The unit value used in the fine amount calculation'; +COMMENT ON COLUMN defendant_accounts.collection_order IS 'Whether the account is a collection order'; +COMMENT ON COLUMN defendant_accounts.collection_order_date IS 'The date the collection order status last changed'; +COMMENT ON COLUMN defendant_accounts.further_steps_notice_date IS 'The date a Further Steps Notice was first issued for this account'; +COMMENT ON COLUMN defendant_accounts.confiscation_order_date IS 'The date a Confiscation Order was first issued for this account'; +COMMENT ON COLUMN defendant_accounts.fine_registration_date IS 'The date a Registration of Fine was first made for this account'; +COMMENT ON COLUMN defendant_accounts.suspended_committal_date IS 'Hearing date when a suspended committal (SC) enforcement result was applied to this account'; +COMMENT ON COLUMN defendant_accounts.consolidated_account_type IS 'If the account has been subject to a consolidation. Master or Child.'; +COMMENT ON COLUMN defendant_accounts.payment_card_requested IS 'Whether a payment card has been requested for this account'; +COMMENT ON COLUMN defendant_accounts.payment_card_requested_date IS 'The date a payment card was last request for this account'; +COMMENT ON COLUMN defendant_accounts.payment_card_requested_by IS 'The ID of the user that requested a payment card for this account'; +COMMENT ON COLUMN defendant_accounts.prosecutor_case_reference IS 'The reference from the prosecuting authority'; +COMMENT ON COLUMN defendant_accounts.enforcement_case_status IS 'Status of an enforcement case creation request to Common Platform'; diff --git a/src/main/resources/db/migration/V20231204_019__defendant_account_id_seq.sql b/src/main/resources/db/migration/V20231204_019__defendant_account_id_seq.sql new file mode 100644 index 000000000..e681819c4 --- /dev/null +++ b/src/main/resources/db/migration/V20231204_019__defendant_account_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : defendant_account_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table DEFENDANT_ACCOUNTS. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 05/12/2023 A Dennis 1.0 PO-39 Creates the Sequence to be used to generate the Primary key for the table DEFENDANT_ACCOUNTS +* +**/ +CREATE SEQUENCE IF NOT EXISTS defendant_account_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY defendant_accounts.defendant_account_id; diff --git a/src/main/resources/db/migration/V20231204_020__parties.sql b/src/main/resources/db/migration/V20231204_020__parties.sql new file mode 100644 index 000000000..efb9bbbbb --- /dev/null +++ b/src/main/resources/db/migration/V20231204_020__parties.sql @@ -0,0 +1,58 @@ +/** +* CGI OPAL Program +* +* MODULE : parties.sql +* +* DESCRIPTION : Creates the PARTIES table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 04/12/2023 A Dennis 1.0 PO-127 Creates the PARTIES table for the Fines model +* +**/ +CREATE TABLE parties +( + party_id bigint not null +,organisation boolean +,organisation_name varchar(80) +,surname varchar(50) +,forenames varchar(50) +,initials varchar(2) +,title varchar(20) +,address_line_1 varchar(35) +,address_line_2 varchar(35) +,address_line_3 varchar(35) +,address_line_4 varchar(35) +,address_line_5 varchar(35) +,postcode varchar(10) +,account_type varchar(20) +,birth_date timestamp +,age smallint +,national_insurance_number varchar(10) +,last_changed_date timestamp +,CONSTRAINT parties_pk PRIMARY KEY + ( + party_id + ) +); + +COMMENT ON COLUMN parties.party_id IS 'Unique ID of this record'; +COMMENT ON COLUMN parties.organisation IS 'Indicates if this party is an organisation or person'; +COMMENT ON COLUMN parties.organisation_name IS 'Organisation name. Null for persons.'; +COMMENT ON COLUMN parties.surname IS 'Person surname. Null for organisations. This will be the full name for parent/guardians but can be modified once GoB is decommissioned'; +COMMENT ON COLUMN parties.forenames IS 'Person forenames. Null for organisations.'; +COMMENT ON COLUMN parties.initials IS 'Person initials. Null for organisations.'; +COMMENT ON COLUMN parties.title IS 'Person title. Null for organisations.'; +COMMENT ON COLUMN parties.address_line_1 IS 'Address line 1'; +COMMENT ON COLUMN parties.address_line_2 IS 'Address line 2'; +COMMENT ON COLUMN parties.address_line_3 IS 'Address line 3'; +COMMENT ON COLUMN parties.address_line_4 IS 'Address line 4. New field to handle larger addresses to be used once GoB has been decommissioned'; +COMMENT ON COLUMN parties.address_line_5 IS 'Address line 5. New field to handle larger addresses to be used once GoB has been decommissioned'; +COMMENT ON COLUMN parties.postcode IS 'Postcode'; +COMMENT ON COLUMN parties.account_type IS 'The account type that the party is associated. We shouldn''t merge parties of different account types. We don''t want someone to amend a creditor and it affect defendant accounts if they are also a debtor. A party should not exist if no accounts exist.'; +COMMENT ON COLUMN parties.birth_date IS 'Person date of birth (only applies to an account party)'; +COMMENT ON COLUMN parties.age IS 'Person estimated if birth date not known (only applies to an account party)'; +COMMENT ON COLUMN parties.national_insurance_number IS 'Person national insurance number (only applies to an account party)'; +COMMENT ON COLUMN parties.last_changed_date IS 'Date this party was last changed in Account Maintenance.'; diff --git a/src/main/resources/db/migration/V20231204_021__party_id_seq.sql b/src/main/resources/db/migration/V20231204_021__party_id_seq.sql new file mode 100644 index 000000000..5eb10190f --- /dev/null +++ b/src/main/resources/db/migration/V20231204_021__party_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : party_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table PARTIES. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 04/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table PARTIES +* +**/ +CREATE SEQUENCE IF NOT EXISTS party_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY parties.party_id; diff --git a/src/main/resources/db/migration/V20231204_022__defendant_account_parties.sql b/src/main/resources/db/migration/V20231204_022__defendant_account_parties.sql new file mode 100644 index 000000000..0f95e6e1a --- /dev/null +++ b/src/main/resources/db/migration/V20231204_022__defendant_account_parties.sql @@ -0,0 +1,52 @@ +/** +* CGI OPAL Program +* +* MODULE : defendant_account_parties.sql +* +* DESCRIPTION : Creates the DEFENDANT_ACCOUNT_PARTIES table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 04/12/2023 A Dennis 1.0 PO-127 Creates the DEFENDANT_ACCOUNT_PARTIES table for the Fines model +* +**/ +CREATE TABLE defendant_account_parties +( + defendant_account_party_id bigint not null +,defendant_account_id bigint not null +,party_id bigint not null +,association_type varchar(30) not null +,debtor boolean not null +,CONSTRAINT defendant_account_parties_pk PRIMARY KEY + ( + defendant_account_party_id + ) +); + +ALTER TABLE defendant_account_parties +ADD CONSTRAINT dap_defendant_account_id_fk FOREIGN KEY +( + defendant_account_id +) +REFERENCES defendant_accounts +( + defendant_account_id +); + +ALTER TABLE defendant_account_parties +ADD CONSTRAINT dap_party_id_fk FOREIGN KEY +( + party_id +) +REFERENCES parties +( + party_id +); + +COMMENT ON COLUMN defendant_account_parties.defendant_account_party_id IS 'Unique ID of this record'; +COMMENT ON COLUMN defendant_account_parties.defendant_account_id IS 'ID of the defendant account'; +COMMENT ON COLUMN defendant_account_parties.party_id IS 'ID of the party associated '; +COMMENT ON COLUMN defendant_account_parties.association_type IS 'The party''s association type to the defendant account (Defendant or Parent/Guardian)'; +COMMENT ON COLUMN defendant_account_parties.debtor IS 'If this party is responsible for paying the account'; diff --git a/src/main/resources/db/migration/V20231204_023__defendant_account_party_id_seq.sql b/src/main/resources/db/migration/V20231204_023__defendant_account_party_id_seq.sql new file mode 100644 index 000000000..1eeff5416 --- /dev/null +++ b/src/main/resources/db/migration/V20231204_023__defendant_account_party_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : defendant_account_party_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table DEFENDANT_ACCOUNT_PARTIES. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 04/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table DEFENDANT_ACCOUNT_PARTIES +* +**/ +CREATE SEQUENCE IF NOT EXISTS defendant_account_party_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY defendant_account_parties.defendant_account_party_id; diff --git a/src/main/resources/db/migration/V20231204_024__defendant_transactions.sql b/src/main/resources/db/migration/V20231204_024__defendant_transactions.sql new file mode 100644 index 000000000..8e0c20393 --- /dev/null +++ b/src/main/resources/db/migration/V20231204_024__defendant_transactions.sql @@ -0,0 +1,64 @@ +/** +* CGI OPAL Program +* +* MODULE : defendant_transactions.sql +* +* DESCRIPTION : Creates the DEFENDANT_TRANSACTIONS table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 04/12/2023 A Dennis 1.0 PO-127 Creates the DEFENDANT_TRANSACTIONS table for the Fines model +* +**/ +CREATE TABLE defendant_transactions +( + defendant_transaction_id bigint not null +,defendant_account_id bigint not null +,posted_date timestamp not null +,posted_by varchar(20) +,transaction_type varchar(6) +,transaction_amount decimal(18,2) +,payment_method varchar(2) +,payment_reference varchar(10) +,text varchar(50) +,status varchar(1) +,status_date timestamp +,status_amount decimal(18,2) +,write_off_code varchar(6) +,associated_record_type varchar(30) +,associated_record_id varchar(30) +,imposed_amount decimal(18,2) +,CONSTRAINT defendant_transactions_pk PRIMARY KEY + ( + defendant_transaction_id + ) +); + +ALTER TABLE defendant_transactions +ADD CONSTRAINT dtr_defendant_account_id_fk FOREIGN KEY +( + defendant_account_id +) +REFERENCES defendant_accounts +( + defendant_account_id +); + +COMMENT ON COLUMN defendant_transactions.defendant_transaction_id IS 'Unique ID of this record'; +COMMENT ON COLUMN defendant_transactions.defendant_account_id IS 'ID of the account this record belongs to'; +COMMENT ON COLUMN defendant_transactions.posted_date IS 'The date the record was posted to the account'; +COMMENT ON COLUMN defendant_transactions.posted_by IS 'ID of user responsible for posting this record'; +COMMENT ON COLUMN defendant_transactions.transaction_type IS 'The code that determines the type of transaction'; +COMMENT ON COLUMN defendant_transactions.transaction_amount IS 'Transaction amount'; +COMMENT ON COLUMN defendant_transactions.payment_method IS 'The method of paying, NC (Notes & Coins), CQ (Cheque) CT (Credit Transfer), PO (Postal Order)'; +COMMENT ON COLUMN defendant_transactions.payment_reference IS 'Cheque of bacs payment reference'; +COMMENT ON COLUMN defendant_transactions.text IS 'Other information associated with this transaction such as a reason for creating it or a third-party name.'; +COMMENT ON COLUMN defendant_transactions.status IS 'Indicates if a transaction has been Reversed (R), partially-reversed (P), dishonoured (D), cancelled (X) or cleared/presented (C).'; +COMMENT ON COLUMN defendant_transactions.status_date IS 'Indicates the date the status was set, if known.'; +COMMENT ON COLUMN defendant_transactions.status_amount IS 'The applicable amount, if the status does not apply to the full transaction amount. For example, where this transaction has been partially reversed the amount, the amount reversed so far. Reversed should be TRUE if reversed_amount = amount.'; +COMMENT ON COLUMN defendant_transactions.write_off_code IS 'Code of write-off category applicable if this is a WRTOFF or TFO'; +COMMENT ON COLUMN defendant_transactions.associated_record_type IS 'Type of record that is identified by associated_record_id (suspense_transaction, imposition, cheque)'; +COMMENT ON COLUMN defendant_transactions.associated_record_id IS 'ID or other reference/number of an associated record. This could be the ID of a suspense transaction if this transaction is a transfer to or from suspense (FR-SUS, REPSUS, XFER, MADJ), or the ID of the affected imposition if this is a Reversal (REVPAY) or (DISHCQ). a reference number of a cheque, or BACS payment which may be deleted before this transaction, or any other third party reference.'; +COMMENT ON COLUMN defendant_transactions.imposed_amount IS 'Additional amount imposed by this transaction. Currently only applies to CONSOL.'; diff --git a/src/main/resources/db/migration/V20231204_025__defendant_transaction_id_seq.sql b/src/main/resources/db/migration/V20231204_025__defendant_transaction_id_seq.sql new file mode 100644 index 000000000..7251669d7 --- /dev/null +++ b/src/main/resources/db/migration/V20231204_025__defendant_transaction_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : defendant_transaction_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table DEFENDANT_TRANSACTIONS. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 04/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table DEFENDANT_TRANSACTIONS +* +**/ +CREATE SEQUENCE IF NOT EXISTS defendant_transaction_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY defendant_transactions.defendant_transaction_id; diff --git a/src/main/resources/db/migration/V20231204_026__debtor_detail.sql b/src/main/resources/db/migration/V20231204_026__debtor_detail.sql new file mode 100644 index 000000000..cf109dc5a --- /dev/null +++ b/src/main/resources/db/migration/V20231204_026__debtor_detail.sql @@ -0,0 +1,76 @@ +/** +* CGI OPAL Program +* +* MODULE : debtor_detail.sql +* +* DESCRIPTION : Creates the DEBTOR_DETAIL table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 04/12/2023 A Dennis 1.0 PO-127 Creates the DEBTOR_DETAIL table for the Fines model +* +**/ +CREATE TABLE debtor_detail +( + party_id bigint not null +,telephone_home varchar(35) +,telephone_business varchar(35) +,telephone_mobile varchar(35) +,email_1 varchar(80) +,email_2 varchar(80) +,vehicle_make varchar(30) +,vehicle_registration varchar(20) +,employer_name varchar(50) +,employer_address_line_1 varchar(35) +,employer_address_line_2 varchar(35) +,employer_address_line_3 varchar(35) +,employer_address_line_4 varchar(35) +,employer_address_line_5 varchar(35) +,employer_postcode varchar(10) +,employer_reference varchar(35) +,employer_telephone varchar(35) +,employer_email varchar(80) +,document_language varchar(2) +,document_language_date timestamp +,hearing_language varchar(2) +,hearing_language_date timestamp +,CONSTRAINT debtor_detail_pk PRIMARY KEY + ( + party_id + ) +); + +ALTER TABLE debtor_detail +ADD CONSTRAINT dd_party_id_fk FOREIGN KEY +( + party_id +) +REFERENCES parties +( + party_id +); + +COMMENT ON COLUMN debtor_detail.party_id IS 'Unique ID of this record'; +COMMENT ON COLUMN debtor_detail.telephone_home IS 'Home telephone number'; +COMMENT ON COLUMN debtor_detail.telephone_business IS 'Business telephone number'; +COMMENT ON COLUMN debtor_detail.telephone_mobile IS 'Mobile telephone number'; +COMMENT ON COLUMN debtor_detail.email_1 IS 'Primary email address'; +COMMENT ON COLUMN debtor_detail.email_2 IS 'Secondary email address'; +COMMENT ON COLUMN debtor_detail.vehicle_make IS 'Debtor asset vehicle make'; +COMMENT ON COLUMN debtor_detail.vehicle_registration IS 'Debtor asset vehicle registration'; +COMMENT ON COLUMN debtor_detail.employer_name IS 'Employer name'; +COMMENT ON COLUMN debtor_detail.employer_address_line_1 IS 'Employer address line 1'; +COMMENT ON COLUMN debtor_detail.employer_address_line_2 IS 'Employer address line 2'; +COMMENT ON COLUMN debtor_detail.employer_address_line_3 IS 'Employer address line 3'; +COMMENT ON COLUMN debtor_detail.employer_address_line_4 IS 'Employer address line 4'; +COMMENT ON COLUMN debtor_detail.employer_address_line_5 IS 'Employer address line 5'; +COMMENT ON COLUMN debtor_detail.employer_postcode IS 'Employer postcode'; +COMMENT ON COLUMN debtor_detail.employer_reference IS 'Employer reference number'; +COMMENT ON COLUMN debtor_detail.employer_telephone IS 'Employer telephone number'; +COMMENT ON COLUMN debtor_detail.employer_email IS 'Employer email address'; +COMMENT ON COLUMN debtor_detail.document_language IS 'Document language preference (CY or EN)'; +COMMENT ON COLUMN debtor_detail.document_language_date IS 'Document language preference effective date'; +COMMENT ON COLUMN debtor_detail.hearing_language IS 'Hearing language preference (CY or EN)'; +COMMENT ON COLUMN debtor_detail.hearing_language_date IS 'Hearing language preference effective date'; diff --git a/src/main/resources/db/migration/V20231204_027__debtor_detail_id_seq.sql b/src/main/resources/db/migration/V20231204_027__debtor_detail_id_seq.sql new file mode 100644 index 000000000..72f284fca --- /dev/null +++ b/src/main/resources/db/migration/V20231204_027__debtor_detail_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : debtor_detail_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table DEBTOR_DETAIL. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 04/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table DEBTOR_DETAIL +* +**/ +CREATE SEQUENCE IF NOT EXISTS debtor_detail_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY debtor_detail.party_id; diff --git a/src/main/resources/db/migration/V20231204_028__payment_terms.sql b/src/main/resources/db/migration/V20231204_028__payment_terms.sql new file mode 100644 index 000000000..99721d62d --- /dev/null +++ b/src/main/resources/db/migration/V20231204_028__payment_terms.sql @@ -0,0 +1,56 @@ +/** +* CGI OPAL Program +* +* MODULE : payment_terms.sql +* +* DESCRIPTION : Creates the PAYMENT_TERMS table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 04/12/2023 A Dennis 1.0 PO-127 Creates the PAYMENT_TERMS table for the Fines model +* +**/ +CREATE TABLE payment_terms +( + payment_terms_id bigint not null +,defendant_account_id bigint not null +,posted_date timestamp not null +,posted_by varchar(20) +,terms_type_code varchar(1) not null +,effective_date timestamp +,instalment_period varchar(1) +,instalment_amount decimal(18,2) +,instalment_lump_sum decimal(18,2) +,jail_days integer +,extension boolean +,account_balance decimal(18,2) +,CONSTRAINT payment_terms_pk PRIMARY KEY + ( + payment_terms_id + ) +); + +ALTER TABLE payment_terms +ADD CONSTRAINT pt_defendant_account_id_fk FOREIGN KEY +( + defendant_account_id +) +REFERENCES defendant_accounts +( + defendant_account_id +); + +COMMENT ON COLUMN payment_terms.payment_terms_id IS 'Unique ID of this record'; +COMMENT ON COLUMN payment_terms.defendant_account_id IS 'ID of the account this record belongs to'; +COMMENT ON COLUMN payment_terms.posted_date IS 'The date the record was posted to the account'; +COMMENT ON COLUMN payment_terms.posted_by IS 'ID of user responsible for posting this record'; +COMMENT ON COLUMN payment_terms.terms_type_code IS 'The terms type: By Date (B), Paid (P), Instalments (I)'; +COMMENT ON COLUMN payment_terms.effective_date IS 'the date when the full amount is due or when instalments start'; +COMMENT ON COLUMN payment_terms.instalment_period IS 'W (Week), M (Month), F (Fortnight) or NULL if not instalments'; +COMMENT ON COLUMN payment_terms.instalment_amount IS 'Amount due each period if paying by instalments'; +COMMENT ON COLUMN payment_terms.instalment_lump_sum IS 'An Initial lumpsum that is due before instalments start'; +COMMENT ON COLUMN payment_terms.jail_days IS 'Number of days in jail the defendant will spend in default of payment'; +COMMENT ON COLUMN payment_terms.extension IS 'If this is an extension to existing payment terms'; +COMMENT ON COLUMN payment_terms.account_balance IS 'Account balance at the time of posting thes terms'; diff --git a/src/main/resources/db/migration/V20231204_029__payment_terms_id_seq.sql b/src/main/resources/db/migration/V20231204_029__payment_terms_id_seq.sql new file mode 100644 index 000000000..3733a7ce2 --- /dev/null +++ b/src/main/resources/db/migration/V20231204_029__payment_terms_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : payment_terms_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table PAYMENT_TERMS. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 04/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table PAYMENT_TERMS +* +**/ +CREATE SEQUENCE IF NOT EXISTS payment_terms_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY payment_terms.payment_terms_id; diff --git a/src/main/resources/db/migration/V20231204_030__tills.sql b/src/main/resources/db/migration/V20231204_030__tills.sql new file mode 100644 index 000000000..87551a8c9 --- /dev/null +++ b/src/main/resources/db/migration/V20231204_030__tills.sql @@ -0,0 +1,40 @@ +/** +* CGI OPAL Program +* +* MODULE : tills.sql +* +* DESCRIPTION : Creates the TILLS table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 04/12/2023 A Dennis 1.0 PO-127 Creates the TILLS table for the Fines model +* +**/ +CREATE TABLE tills +( + till_id bigint not null +,business_unit_id smallint not null +,till_number smallint not null +,owned_by varchar(20) not null +,CONSTRAINT tills_pk PRIMARY KEY + ( + till_id + ) +); + +ALTER TABLE tills +ADD CONSTRAINT till_business_unit_id_fk FOREIGN KEY +( + business_unit_id +) +REFERENCES business_units +( + business_unit_id +); + +COMMENT ON COLUMN tills.till_id IS 'Unique ID of this record'; +COMMENT ON COLUMN tills.business_unit_id IS 'ID of the relating business unit'; +COMMENT ON COLUMN tills.till_number IS 'Till number unique within the business unit'; +COMMENT ON COLUMN tills.owned_by IS 'ID of the user that owns this till'; diff --git a/src/main/resources/db/migration/V20231204_031__till_id_seq.sql b/src/main/resources/db/migration/V20231204_031__till_id_seq.sql new file mode 100644 index 000000000..f77026121 --- /dev/null +++ b/src/main/resources/db/migration/V20231204_031__till_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : till_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table TILLS. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 04/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table TILLS +* +**/ +CREATE SEQUENCE IF NOT EXISTS till_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY tills.till_id; diff --git a/src/main/resources/db/migration/V20231205_032__fixed_penalty_offences.sql b/src/main/resources/db/migration/V20231205_032__fixed_penalty_offences.sql new file mode 100644 index 000000000..500447457 --- /dev/null +++ b/src/main/resources/db/migration/V20231205_032__fixed_penalty_offences.sql @@ -0,0 +1,46 @@ +/** +* CGI OPAL Program +* +* MODULE : fixed_penalty_offences.sql +* +* DESCRIPTION : Creates the FIXED_PENALTY_OFFENCES table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 04/12/2023 A Dennis 1.0 PO-127 Creates the FIXED_PENALTY_OFFENCES table for the Fines model +* +**/ +CREATE TABLE fixed_penalty_offences +( + defendant_account_id bigint not null +,ticket_number varchar(120) not null +,vehicle_registration varchar(10) +,offence_location varchar(30) +,notice_number varchar(10) +,issued_date timestamp +,licence_number varchar(20) +,CONSTRAINT fixed_penalty_offences_pk PRIMARY KEY + ( + defendant_account_id + ) +); + +ALTER TABLE fixed_penalty_offences +ADD CONSTRAINT fpo_defendant_account_id_fk FOREIGN KEY +( + defendant_account_id +) +REFERENCES defendant_accounts +( + defendant_account_id +); + +COMMENT ON COLUMN fixed_penalty_offences.defendant_account_id IS 'Unique ID of this record'; +COMMENT ON COLUMN fixed_penalty_offences.ticket_number IS 'Fixed penalty ticket number'; +COMMENT ON COLUMN fixed_penalty_offences.vehicle_registration IS 'Vehicle registration or NV for non-vehicle fixed penalties'; +COMMENT ON COLUMN fixed_penalty_offences.offence_location IS 'Place of offence'; +COMMENT ON COLUMN fixed_penalty_offences.notice_number IS 'Notice to owner/hirer number'; +COMMENT ON COLUMN fixed_penalty_offences.issued_date IS 'Date and time the ticket was issued'; +COMMENT ON COLUMN fixed_penalty_offences.licence_number IS 'The driver''s licence number'; diff --git a/src/main/resources/db/migration/V20231205_033__notes.sql b/src/main/resources/db/migration/V20231205_033__notes.sql new file mode 100644 index 000000000..332901dbb --- /dev/null +++ b/src/main/resources/db/migration/V20231205_033__notes.sql @@ -0,0 +1,20 @@ +/** +* CGI OPAL Program +* +* MODULE : notes.sql +* +* DESCRIPTION : Add not null to columns in NOTES table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 05/12/2023 A Dennis 1.0 PO-127 Add not null to columns in NOTES table for the Fines model +* +**/ + +ALTER TABLE notes +ALTER COLUMN note_type SET NOT NULL, +ALTER COLUMN associated_record_type SET NOT NULL, +ALTER COLUMN associated_record_id SET NOT NULL, +ALTER COLUMN note_text SET NOT NULL; \ No newline at end of file diff --git a/src/main/resources/db/migration/V20231205_034__payments_in.sql b/src/main/resources/db/migration/V20231205_034__payments_in.sql new file mode 100644 index 000000000..e02f78cb9 --- /dev/null +++ b/src/main/resources/db/migration/V20231205_034__payments_in.sql @@ -0,0 +1,58 @@ +/** +* CGI OPAL Program +* +* MODULE : payments_in.sql +* +* DESCRIPTION : Creates the PAYMENTS_IN table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 05/12/2023 A Dennis 1.0 PO-127 Creates the PAYMENTS_IN table for the Fines model +* +**/ +CREATE TABLE payments_in +( + payment_in_id bigint not null +,till_id smallint not null +,payment_amount decimal(18,2) not null +,payment_date timestamp not null +,payment_method varchar(2) not null +,destination_type varchar(1) not null +,allocation_type varchar(20) +,associated_record_type varchar(30) +,associated_record_id varchar(30) +,third_party_payer_name varchar(50) +,additional_information varchar(500) +,receipt boolean +,allocated boolean +,CONSTRAINT payments_in_pk PRIMARY KEY + ( + payment_in_id + ) +); + +ALTER TABLE payments_in +ADD CONSTRAINT pi_till_id_fk FOREIGN KEY +( + till_id +) +REFERENCES tills +( + till_id +); + +COMMENT ON COLUMN payments_in.payment_in_id IS 'Unique ID of this record'; +COMMENT ON COLUMN payments_in.till_id IS 'ID of the relating till to which this till belongs'; +COMMENT ON COLUMN payments_in.payment_amount IS 'Amount paid'; +COMMENT ON COLUMN payments_in.payment_date IS 'Date payment received'; +COMMENT ON COLUMN payments_in.payment_method IS 'Payment method'; +COMMENT ON COLUMN payments_in.destination_type IS 'Allocation destination: F (fines), S (Suspense), C (Court Fee)'; +COMMENT ON COLUMN payments_in.allocation_type IS 'Specific types for each allocation where an initial payment amount is split, for example, if an amount is overpaid.'; +COMMENT ON COLUMN payments_in.associated_record_type IS 'Type of record identified by associated_record_id. This could be a suspense item, court fee, miscellaneous account, defendant account or party'; +COMMENT ON COLUMN payments_in.associated_record_id IS 'ID or other reference/number of an associated record'; +COMMENT ON COLUMN payments_in.third_party_payer_name IS 'Name of payer if a third party'; +COMMENT ON COLUMN payments_in.additional_information IS 'Additional information stored against the payment'; +COMMENT ON COLUMN payments_in.receipt IS 'If a receipt was requested'; +COMMENT ON COLUMN payments_in.allocated IS 'If this payment has been allocation'; diff --git a/src/main/resources/db/migration/V20231205_035__payment_in_id_seq.sql b/src/main/resources/db/migration/V20231205_035__payment_in_id_seq.sql new file mode 100644 index 000000000..4bc82f9d5 --- /dev/null +++ b/src/main/resources/db/migration/V20231205_035__payment_in_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : payment_in_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table PAYMENTS_IN. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 05/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table PAYMENTS_IN +* +**/ +CREATE SEQUENCE IF NOT EXISTS payment_in_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY payments_in.payment_in_id; diff --git a/src/main/resources/db/migration/V20231205_036__documents.sql b/src/main/resources/db/migration/V20231205_036__documents.sql new file mode 100644 index 000000000..28d1612ba --- /dev/null +++ b/src/main/resources/db/migration/V20231205_036__documents.sql @@ -0,0 +1,36 @@ +/** +* CGI OPAL Program +* +* MODULE : documents.sql +* +* DESCRIPTION : Creates the DOCUMENTS table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 05/12/2023 A Dennis 1.0 PO-127 Creates the DOCUMENTS table for the Fines model +* +**/ +CREATE TABLE documents +( + document_id varchar(10) not null +,recipient varchar(4) not null +,document_language varchar(2) not null +,signature_source varchar(4) not null +,priority smallint not null +,header_type varchar(2) not null +,document_elements json not null +,CONSTRAINT documents_pk PRIMARY KEY + ( + document_id + ) +); + +COMMENT ON COLUMN documents.document_id IS 'Unique ID of this record'; +COMMENT ON COLUMN documents.recipient IS 'The type of party that this document will be addressed to'; +COMMENT ON COLUMN documents.document_language IS 'the language the document is written in'; +COMMENT ON COLUMN documents.signature_source IS 'Source of the document signature (Area, LJA or null)'; +COMMENT ON COLUMN documents.priority IS 'Determines the order of printing with respect to other documents in the same batch'; +COMMENT ON COLUMN documents.header_type IS 'The type of header output on the document (EO, A, MC, ME, MA, MF, AP or null)'; +COMMENT ON COLUMN documents.document_elements IS 'Details of the structured data items to be included in the document content'; diff --git a/src/main/resources/db/migration/V20231205_037__document_id_seq.sql b/src/main/resources/db/migration/V20231205_037__document_id_seq.sql new file mode 100644 index 000000000..48479c705 --- /dev/null +++ b/src/main/resources/db/migration/V20231205_037__document_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : document_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table DOCUMENTS. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 05/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table DOCUMENTS +* +**/ +CREATE SEQUENCE IF NOT EXISTS document_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY documents.document_id; diff --git a/src/main/resources/db/migration/V20231205_038__document_instances.sql b/src/main/resources/db/migration/V20231205_038__document_instances.sql new file mode 100644 index 000000000..dae535708 --- /dev/null +++ b/src/main/resources/db/migration/V20231205_038__document_instances.sql @@ -0,0 +1,34 @@ +/** +* CGI OPAL Program +* +* MODULE : document_instances.sql +* +* DESCRIPTION : Creates the DOCUMENT_INSTANCES table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 05/12/2023 A Dennis 1.0 PO-127 Creates the DOCUMENT_INSTANCES table for the Fines model +* +**/ +CREATE TABLE document_instances +( + document_instance_id bigint not null +,document_id bigint not null +,business_unit_id smallint not null +,generated_date timestamp not null +,generated_by varchar(20) not null +,content xml not null +,CONSTRAINT document_instances_pk PRIMARY KEY + ( + document_instance_id + ) +); + +COMMENT ON COLUMN document_instances.document_instance_id IS 'Unique ID for this record'; +COMMENT ON COLUMN document_instances.document_id IS 'ID of the report being generated'; +COMMENT ON COLUMN document_instances.business_unit_id IS 'ID of the business unit this report instance was generated for'; +COMMENT ON COLUMN document_instances.generated_date IS 'The date the document was generated'; +COMMENT ON COLUMN document_instances.generated_by IS 'ID of the user that generated this instance of the document'; +COMMENT ON COLUMN document_instances.content IS 'The structured document content'; diff --git a/src/main/resources/db/migration/V20231205_039__document_instance_id_seq.sql b/src/main/resources/db/migration/V20231205_039__document_instance_id_seq.sql new file mode 100644 index 000000000..8b1d6ba65 --- /dev/null +++ b/src/main/resources/db/migration/V20231205_039__document_instance_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : document_instance_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table DOCUMENT_INSTANCES. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 05/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table DOCUMENT_INSTANCES +* +**/ +CREATE SEQUENCE IF NOT EXISTS document_instance_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY document_instances.document_instance_id; diff --git a/src/main/resources/db/migration/V20231205_040__account_transfers.sql b/src/main/resources/db/migration/V20231205_040__account_transfers.sql new file mode 100644 index 000000000..494d52ea5 --- /dev/null +++ b/src/main/resources/db/migration/V20231205_040__account_transfers.sql @@ -0,0 +1,74 @@ +/** +* CGI OPAL Program +* +* MODULE : account_transfers.sql +* +* DESCRIPTION : Creates the ACCOUNT_TRANSFERS table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 05/12/2023 A Dennis 1.0 PO-127 Creates the ACCOUNT_TRANSFERS table for the Fines model +* +**/ +CREATE TABLE account_transfers +( + account_transfer_id bigint not null +,business_unit_id smallint not null +,defendant_account_id bigint not null +,initiated_date timestamp +,initiated_by varchar(20) +,printed_date timestamp +,printed_by varchar(20) +,document_instance_id bigint +,destination_lja_id smallint not null +,reason varchar(100) +,reminder_date timestamp +,CONSTRAINT account_transfers_pk PRIMARY KEY + ( + account_transfer_id + ) +); + +ALTER TABLE account_transfers +ADD CONSTRAINT at_defendant_account_id_fk FOREIGN KEY +( + defendant_account_id +) +REFERENCES defendant_accounts +( + defendant_account_id +); + +ALTER TABLE account_transfers +ADD CONSTRAINT at_document_instance_id_fk FOREIGN KEY +( + document_instance_id +) +REFERENCES document_instances +( + document_instance_id +); + +ALTER TABLE account_transfers +ADD CONSTRAINT at_local_justice_area_id_fk FOREIGN KEY +( + destination_lja_id +) +REFERENCES local_justice_areas +( + local_justice_area_id +); + +COMMENT ON COLUMN account_transfers.account_transfer_id IS 'Unique ID of this record'; +COMMENT ON COLUMN account_transfers.business_unit_id IS 'ID of the relating business unit'; +COMMENT ON COLUMN account_transfers.defendant_account_id IS 'Account Number being transferred out'; +COMMENT ON COLUMN account_transfers.initiated_date IS 'Date this transfer was initiated'; +COMMENT ON COLUMN account_transfers.initiated_by IS 'User generating the transfer Out'; +COMMENT ON COLUMN account_transfers.printed_date IS 'Date the TFO Enforcement Order was printed'; +COMMENT ON COLUMN account_transfers.printed_by IS 'ID of the user that printed the TFO Enforcement Order'; +COMMENT ON COLUMN account_transfers.document_instance_id IS 'ID of the TFFOUT Enforcement Order document'; +COMMENT ON COLUMN account_transfers.destination_lja_id IS 'Destination LJA code'; +COMMENT ON COLUMN account_transfers.reason IS 'Reason for the transfer out'; +COMMENT ON COLUMN account_transfers.reminder_date IS 'Date that a reminder is sent to the destination court to acknowledge receipt'; diff --git a/src/main/resources/db/migration/V20231205_041__account_transfer_id_seq.sql b/src/main/resources/db/migration/V20231205_041__account_transfer_id_seq.sql new file mode 100644 index 000000000..a0f259e96 --- /dev/null +++ b/src/main/resources/db/migration/V20231205_041__account_transfer_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : account_transfer_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table ACCOUNT_TRANSFERS. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 05/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table ACCOUNT_TRANSFERS +* +**/ +CREATE SEQUENCE IF NOT EXISTS account_transfer_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY account_transfers.account_transfer_id; diff --git a/src/main/resources/db/migration/V20231205_042__mis_debtors.sql b/src/main/resources/db/migration/V20231205_042__mis_debtors.sql new file mode 100644 index 000000000..ba270f668 --- /dev/null +++ b/src/main/resources/db/migration/V20231205_042__mis_debtors.sql @@ -0,0 +1,58 @@ +/** +* CGI OPAL Program +* +* MODULE : mis_debtors.sql +* +* DESCRIPTION : Creates the MIS_DEBTORS table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 05/12/2023 A Dennis 1.0 PO-127 Creates the MIS_DEBTORS table for the Fines model +* +**/ +CREATE TABLE mis_debtors +( + mis_debtor_id bigint not null +,business_unit_id smallint not null +,debtor_name varchar(100) not null +,account_category varchar(1) +,arrears_category varchar(1) +,account_number varchar(1) not null +,account_start_date timestamp not null +,terms_type varchar(1) not null +,instalment_amount decimal(18,2) +,lump_sum decimal(18,2) +,terms_date timestamp +,days_in_jail smallint +,date_last_movement timestamp +,last_enforcement varchar(6) +,arrears decimal(18,2) +,amount_imposed decimal(18,2) not null +,amount_paid decimal(18,2) not null +,amount_outstanding decimal(18,2) not null +,CONSTRAINT mis_debtors_pk PRIMARY KEY + ( + mis_debtor_id + ) +); + +COMMENT ON COLUMN mis_debtors.mis_debtor_id IS 'Unique ID of this record'; +COMMENT ON COLUMN mis_debtors.business_unit_id IS 'ID of the relating till to which this till belongs'; +COMMENT ON COLUMN mis_debtors.debtor_name IS 'Debtor full name'; +COMMENT ON COLUMN mis_debtors.account_category IS 'Account category'; +COMMENT ON COLUMN mis_debtors.arrears_category IS 'Arrears category'; +COMMENT ON COLUMN mis_debtors.account_number IS 'Account number'; +COMMENT ON COLUMN mis_debtors.account_start_date IS 'Account start date'; +COMMENT ON COLUMN mis_debtors.terms_type IS 'Terms type indicating if paying by a date or by instalments'; +COMMENT ON COLUMN mis_debtors.instalment_amount IS 'Instalment amount if applicable'; +COMMENT ON COLUMN mis_debtors.lump_sum IS 'Initial lump sum'; +COMMENT ON COLUMN mis_debtors.terms_date IS 'Pay-by date or instalments start date'; +COMMENT ON COLUMN mis_debtors.days_in_jail IS 'Days in jail if in default'; +COMMENT ON COLUMN mis_debtors.date_last_movement IS 'Date of last movement on the account'; +COMMENT ON COLUMN mis_debtors.last_enforcement IS 'Last enforcement action'; +COMMENT ON COLUMN mis_debtors.arrears IS 'arrears'; +COMMENT ON COLUMN mis_debtors.amount_imposed IS 'Amount imposed'; +COMMENT ON COLUMN mis_debtors.amount_paid IS 'Amount paid so far'; +COMMENT ON COLUMN mis_debtors.amount_outstanding IS 'Amount still to pay'; diff --git a/src/main/resources/db/migration/V20231205_043__mis_debtor_id_seq.sql b/src/main/resources/db/migration/V20231205_043__mis_debtor_id_seq.sql new file mode 100644 index 000000000..51aa30d72 --- /dev/null +++ b/src/main/resources/db/migration/V20231205_043__mis_debtor_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : mis_debtor_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table MIS_DEBTORS. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 05/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table MIS_DEBTORS +* +**/ +CREATE SEQUENCE IF NOT EXISTS mis_debtor_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY mis_debtors.mis_debtor_id; diff --git a/src/main/resources/db/migration/V20231205_044__enforcements.sql b/src/main/resources/db/migration/V20231205_044__enforcements.sql new file mode 100644 index 000000000..b22adfb58 --- /dev/null +++ b/src/main/resources/db/migration/V20231205_044__enforcements.sql @@ -0,0 +1,88 @@ +/** +* CGI OPAL Program +* +* MODULE : enforcements.sql +* +* DESCRIPTION : Creates the ENFORCEMENTS table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 05/12/2023 A Dennis 1.0 PO-127 Creates the ENFORCEMENTS table for the Fines model +* +**/ +CREATE TABLE enforcements +( + enforcement_id bigint not null +,defendant_account_id bigint not null +,posted_date timestamp not null +,posted_by varchar(20) +,result_id varchar(10) +,reason varchar(50) +,enforcer_id bigint +,jail_days integer +,warrant_reference varchar(20) +,case_reference varchar(40) +,hearing_date timestamp +,hearing_court_id bigint +,account_type varchar(20) +,CONSTRAINT enforcements_pk PRIMARY KEY + ( + enforcement_id + ) +); + +ALTER TABLE enforcements +ADD CONSTRAINT enf_defendant_account_id_fk FOREIGN KEY +( + defendant_account_id +) +REFERENCES defendant_accounts +( + defendant_account_id +); + +ALTER TABLE enforcements +ADD CONSTRAINT enf_result_id_fk FOREIGN KEY +( + result_id +) +REFERENCES results +( + result_id +); + +ALTER TABLE enforcements +ADD CONSTRAINT enf_enforcer_id_fk FOREIGN KEY +( + enforcer_id +) +REFERENCES enforcers +( + enforcer_id +); + +ALTER TABLE enforcements +ADD CONSTRAINT enf_hearing_court_id_fk FOREIGN KEY +( + hearing_court_id +) +REFERENCES courts +( + court_id +); + +COMMENT ON COLUMN enforcements.enforcement_id IS 'Unique ID of this record'; +COMMENT ON COLUMN enforcements.defendant_account_id IS 'ID of the account this record belongs to'; +COMMENT ON COLUMN enforcements.posted_date IS 'The date the record was posted to the account'; +COMMENT ON COLUMN enforcements.posted_by IS 'ID of user responsible for posting this record'; +COMMENT ON COLUMN enforcements.result_id IS 'The ID of the result imposed by the court that determines the type of imposition'; +COMMENT ON COLUMN enforcements.reason IS 'The reason for this enforcement action'; +COMMENT ON COLUMN enforcements.enforcer_id IS 'The enforcer/process server for this enforcement action'; +COMMENT ON COLUMN enforcements.jail_days IS 'only applies to SC/CW'; +COMMENT ON COLUMN enforcements.warrant_reference IS 'The reference number of the warrant generated from this action'; +COMMENT ON COLUMN enforcements.case_reference IS 'The reference number of the case generated from this action'; +COMMENT ON COLUMN enforcements.hearing_date IS 'The hearing date of the case generated from this action'; +COMMENT ON COLUMN enforcements.hearing_court_id IS 'The hearing court of the case generated from this action'; +COMMENT ON COLUMN enforcements.account_type IS 'The enforcement account type that auto-enforcement deemed this to be at the time of it applying this action'; diff --git a/src/main/resources/db/migration/V20231205_045__enforcement_id_seq.sql b/src/main/resources/db/migration/V20231205_045__enforcement_id_seq.sql new file mode 100644 index 000000000..cc8abaded --- /dev/null +++ b/src/main/resources/db/migration/V20231205_045__enforcement_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : enforcement_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table ENFORCEMENTS. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 05/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table ENFORCEMENTS +* +**/ +CREATE SEQUENCE IF NOT EXISTS enforcement_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY enforcements.enforcement_id; diff --git a/src/main/resources/db/migration/V20231206_046__prisons.sql b/src/main/resources/db/migration/V20231206_046__prisons.sql new file mode 100644 index 000000000..96c6765b1 --- /dev/null +++ b/src/main/resources/db/migration/V20231206_046__prisons.sql @@ -0,0 +1,48 @@ +/** +* CGI OPAL Program +* +* MODULE : prisons.sql +* +* DESCRIPTION : Creates the PRISONS table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 06/12/2023 A Dennis 1.0 PO-127 Creates the PRISONS table for the Fines model +* +**/ +CREATE TABLE prisons +( + prison_id bigint not null +,business_unit_id smallint not null +,prison_code varchar(4) not null +,name varchar(35) not null +,address_line_1 varchar(35) not null +,address_line_2 varchar(35) +,address_line_3 varchar(35) +,postcode varchar(8) +,CONSTRAINT prisons_pk PRIMARY KEY + ( + prison_id + ) +); + +ALTER TABLE prisons +ADD CONSTRAINT pri_business_unit_id_fk FOREIGN KEY +( + business_unit_id +) +REFERENCES business_units +( + business_unit_id +); + +COMMENT ON COLUMN prisons.prison_id IS 'Unique ID of this record'; +COMMENT ON COLUMN prisons.business_unit_id IS 'ID of the relating till to which this till belongs'; +COMMENT ON COLUMN prisons.prison_code IS 'Prison code unique within the business unit'; +COMMENT ON COLUMN prisons.name IS 'Prison name'; +COMMENT ON COLUMN prisons.address_line_1 IS 'Prison address line 1'; +COMMENT ON COLUMN prisons.address_line_2 IS 'Prison address line 2'; +COMMENT ON COLUMN prisons.address_line_3 IS 'Prison address line 3'; +COMMENT ON COLUMN prisons.postcode IS 'Prison postcode'; diff --git a/src/main/resources/db/migration/V20231206_047__prison_id_seq.sql b/src/main/resources/db/migration/V20231206_047__prison_id_seq.sql new file mode 100644 index 000000000..62fe3c079 --- /dev/null +++ b/src/main/resources/db/migration/V20231206_047__prison_id_seq.sql @@ -0,0 +1,15 @@ +/** +* OPAL Program +* +* MODULE : prison_id_seq.sql +* +* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table PRISONS. +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- +* 06/12/2023 A Dennis 1.0 PO-127 Creates the Sequence to be used to generate the Primary key for the table PRISONS +* +**/ +CREATE SEQUENCE IF NOT EXISTS prison_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY prisons.prison_id; diff --git a/src/main/resources/db/migration/V20231206_048__committal_warrant_progress.sql b/src/main/resources/db/migration/V20231206_048__committal_warrant_progress.sql new file mode 100644 index 000000000..b5316a326 --- /dev/null +++ b/src/main/resources/db/migration/V20231206_048__committal_warrant_progress.sql @@ -0,0 +1,66 @@ +/** +* CGI OPAL Program +* +* MODULE : committal_warrant_progress.sql +* +* DESCRIPTION : Creates the COMMITTAL_WARRANT_PROGRESS table for the Fines model +* +* VERSION HISTORY: +* +* Date Author Version Nature of Change +* ---------- ------- -------- ---------------------------------------------------------------------------- +* 06/12/2023 A Dennis 1.0 PO-127 Creates the COMMITTAL_WARRANT_PROGRESS table for the Fines model +* +**/ +CREATE TABLE committal_warrant_progress +( + defendant_account_id bigint not null +,enforcement_id bigint not null +,amount decimal(18,2) +,body_receipt_date timestamp +,certificate_part_a_date timestamp +,certificate_part_b_date timestamp +,prison_id bigint +,CONSTRAINT committal_warrant_progress_pk PRIMARY KEY + ( + defendant_account_id + ) +); + +ALTER TABLE committal_warrant_progress +ADD CONSTRAINT cwp_defendant_account_id_fk FOREIGN KEY +( + defendant_account_id +) +REFERENCES defendant_accounts +( + defendant_account_id +); + +ALTER TABLE committal_warrant_progress +ADD CONSTRAINT enf_enforcement_id_fk FOREIGN KEY +( + enforcement_id +) +REFERENCES enforcements +( + enforcement_id +); + +ALTER TABLE committal_warrant_progress +ADD CONSTRAINT enf_prison_id_fk FOREIGN KEY +( + prison_id +) +REFERENCES prisons +( + prison_id +); + +COMMENT ON COLUMN committal_warrant_progress.defendant_account_id IS 'Unique ID of this record'; +COMMENT ON COLUMN committal_warrant_progress.enforcement_id IS 'Associated CW enforcement ID containing CW date and warrant reference'; +COMMENT ON COLUMN committal_warrant_progress.amount IS 'Committal Warrant amount'; +COMMENT ON COLUMN committal_warrant_progress.body_receipt_date IS 'Committal Warrant date of body receipt'; +COMMENT ON COLUMN committal_warrant_progress.certificate_part_a_date IS 'Committal Warrant date of Certificate of Imprisonment Part A'; +COMMENT ON COLUMN committal_warrant_progress.certificate_part_b_date IS 'Committal Warrant date of Certificate of Imprisonment Part B'; +COMMENT ON COLUMN committal_warrant_progress.prison_id IS 'Unique identifier of prison committed to';