Skip to content

Commit

Permalink
Release3 (#782)
Browse files Browse the repository at this point in the history
* hotfix/JM-8219 Update to utilisation report for deferred jurors (#777)

* hotfix/JM-8219

* Update V2_36__util_report_updates_deferrals.sql

* task/JM-8220 update to main utilisation report function (#776)

* task/JM-8220 update to main utilisation report function

* updating script name and tests

* task/JM-8224 Able to Defer/Postpone a Juror after checking them in (#781)

* task/JM-8224 Able to Defer/Postpone a Juror after checking them in

* updates to address more use cases

* updating tests

* task JM-7747a switch from loc name to loc court name (#784)

* Task/jm 7747a (#785)

* task JM-7747a switch from loc name to loc court name

* JM - 7747a amend failing tests

* task JM-7747a fix failing test

* Task/jm 7747a (#786)

* task JM-7747a switch from loc name to loc court name

* JM - 7747a amend failing tests

* task JM-7747a fix failing test

* update court_location loc court name

* JM-7885 - Update write_printfiles db function (#787)

* renamed flyway to match existing script casing

* task/JM-8136 (#783)

* task/JM-8136

* update to make fada deletion use loc_code as well

* updates to trial deletion housekeeping script

* updates to scripts following review

* Update V2_44__housekeeping_owner_restrict_list.sql

* Update V2_44__housekeeping_owner_restrict_list.sql

* Update V2_43__housekeeping_trial_deletion_update.sql

* Update V2_43__housekeeping_trial_deletion_update.sql

addressing issue found in testing

* Update V2_43__housekeeping_trial_deletion_update.sql

* Update V2_43__housekeeping_trial_deletion_update.sql

fixing issue from testing

* Update V2_43__housekeeping_trial_deletion_update.sql

---------

Co-authored-by: EPatterson1 <[email protected]>
Co-authored-by: Christopher Powell (CGI) <[email protected]>
  • Loading branch information
3 people authored Oct 24, 2024
1 parent 880d0aa commit dc64da4
Show file tree
Hide file tree
Showing 27 changed files with 913 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
import static uk.gov.hmcts.juror.api.moj.enumeration.PoolUtilisationDescription.CONFIRMED;
import static uk.gov.hmcts.juror.api.moj.enumeration.PoolUtilisationDescription.NEEDED;
import static uk.gov.hmcts.juror.api.moj.enumeration.PoolUtilisationDescription.SURPLUS;
Expand Down Expand Up @@ -1097,6 +1098,21 @@ void courtUserChangeDateActivePool() {
});
}

@Test
void courtUserChangeDateActivePoolAlreadyCheckedIn() {
final String courtJwt = createJwt(COURT_USER, OWNER_415);

httpHeaders.set(HttpHeaders.AUTHORIZATION, courtJwt);
DeferralReasonRequestDto deferralReasonRequestDto = createDeferralReasonRequestDtoToActivePool(null);
RequestEntity<DeferralReasonRequestDto> requestEntity =
new RequestEntity<>(deferralReasonRequestDto,
httpHeaders, POST, URI.create(URL_PREFIX + JUROR_555555560));
ResponseEntity<DeferralReasonRequestDto> response = template.exchange(requestEntity,
DeferralReasonRequestDto.class);
assertThat(response.getStatusCode()).as("Expect the status to be unprocessable entity")
.isEqualTo(UNPROCESSABLE_ENTITY);
}

private void verifyActivePoolOldRecordChangeDate(JurorPool jurorPool, String poolNumber) {
assertThat(jurorPool.getPoolNumber()).isNotEqualTo(poolNumber);
assertThat(jurorPool.getStatus().getStatusDesc()).isEqualTo("Deferred");
Expand Down Expand Up @@ -1605,6 +1621,19 @@ void bureauPostponeJurorPoolNumberDoesNotExist() {
.isEqualTo(NOT_FOUND);
}

@Test
@Sql({"/db/mod/truncate.sql", "/db/DeferralMaintenanceController_postponeJuror.sql"})
void courtPostponeJurorAlreadyCheckedIn() {
setHeaders(COURT_USER, OWNER_415, UserType.COURT);

ResponseEntity<MojException.BadRequest> response = template.exchange(new RequestEntity<>(
createProcessJurorPostponementRequestDto(Collections.singletonList(JUROR_555555560)),
httpHeaders, POST, URI.create(URL)), MojException.BadRequest.class);

assertThat(response.getStatusCode()).as("Expect the status to be unprocessable entity")
.isEqualTo(UNPROCESSABLE_ENTITY);
}

@Test
void courtPostponeJurorNoJurorsInRequest() {
setHeaders(COURT_USER, OWNER_415, UserType.COURT);
Expand Down Expand Up @@ -1679,4 +1708,4 @@ protected String createJwt(String login, String owner, UserType userType) {
.owner(owner)
.build());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,27 @@ public void grant_Deferral_unhappyPath_deferred_before() {
.isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY);
}

@Test
@Sql({"/db/mod/truncate.sql", "/db/DeferralRequestController_createInitialPoolRecords.sql"})
public void grant_Deferral_unhappyPath_appearances_exist() {
String jurorNumber = "222222222";
String deferralReason = "B";

DeferralRequestDto requestDto = createGrantDeferralDecisionDto(jurorNumber, deferralReason);
httpHeaders.set(HttpHeaders.AUTHORIZATION, createJwtCourt("COURT_USER", Set.of(), "415"));

requestDto.setAllowMultipleDeferrals(false);
ResponseEntity<DeferralRequestDto> response =
restTemplate.exchange(new RequestEntity<>(requestDto, httpHeaders, HttpMethod.PUT,
URI.create("/api/v1/moj/deferral-response/juror/"
+ jurorNumber)),
DeferralRequestDto.class);

assertThat(response.getStatusCode())
.as("Expect the HTTP PUT request to be OK")
.isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY);
}

@Test
@Sql({"/db/mod/truncate.sql", "/db/DeferralRequestController_createInitialPoolRecords.sql"})
public void grant_Deferral_Unhappy_MissingDate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ private void verifyJurorAndThirdPartyDetails(JurorDetailsResponseDto jurorDetail
.isEqualTo("Responded");
assertThat(jurorDetails.getCommonDetails().getCourtName())
.as("Expect the Juror record to be in Chichester Crown Court")
.isEqualTo("THE CROWN COURT AT CHICHESTER");
.isEqualTo("LEWES SITTING AT CHICHESTER");
assertThat(thirdParty.getThirdPartyFName())
.as("Expect the third party first name to be TPFIRSTNAME")
.isEqualTo("TPFIRSTNAME");
Expand Down Expand Up @@ -952,7 +952,7 @@ private void verifyResponse(JurorDetailsResponseDto jurorDetails) {
.isEqualTo("Responded");
assertThat(jurorDetails.getCommonDetails().getCourtName())
.as("Expect the Juror record to be in Chichester Crown Court")
.isEqualTo("THE CROWN COURT AT CHICHESTER");
.isEqualTo("LEWES SITTING AT CHICHESTER");
assertThat(jurorDetails.getThirdParty())
.as("Expect the Juror third party details to be null")
.isEqualTo(null);
Expand Down Expand Up @@ -3378,6 +3378,7 @@ private void validateHappyResponse(ResponseEntity<JurorAttendanceDetailsResponse
assertThat(jurorAttendanceDetailsResponseDto.getData().size()).isEqualTo(5);

assertThat(jurorAttendanceDetailsResponseDto.getAttendances()).isEqualTo(3);
assertThat(jurorAttendanceDetailsResponseDto.isHasAppearances()).isEqualTo(true);
assertThat(jurorAttendanceDetailsResponseDto.getAbsences()).isEqualTo(1);
assertThat(jurorAttendanceDetailsResponseDto.getNonAttendances()).isEqualTo(1);
assertThat(jurorAttendanceDetailsResponseDto.getNextDate()).isEqualTo(LocalDate.now().minusDays(4));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,24 @@ void viewDailyUtilisationHappy() {
assertThat(day).isNotNull();
assertThat(day.getDate()).isEqualTo(LocalDate.parse("2024-05-09", DateTimeFormatter.ISO_LOCAL_DATE));
assertThat(day.getJurorWorkingDays()).isEqualTo(21);
assertThat(day.getSittingDays()).isEqualTo(12);
assertThat(day.getAttendanceDays()).isEqualTo(13);
assertThat(day.getNonAttendanceDays()).isEqualTo(8);
assertThat(Math.round(day.getUtilisation())).isEqualTo(Math.round(57.14));
assertThat(day.getSittingDays()).isEqualTo(16);
assertThat(day.getAttendanceDays()).isEqualTo(17);
assertThat(day.getNonAttendanceDays()).isEqualTo(4);
assertThat(Math.round(day.getUtilisation())).isEqualTo(Math.round(76.19));

// validate the weekly totals for the week
assertThat(week.getWeeklyTotalJurorWorkingDays()).isEqualTo(98);
assertThat(week.getWeeklyTotalSittingDays()).isEqualTo(52);
assertThat(week.getWeeklyTotalAttendanceDays()).isEqualTo(56);
assertThat(week.getWeeklyTotalNonAttendanceDays()).isEqualTo(42);
assertThat(Math.round(week.getWeeklyTotalUtilisation())).isEqualTo(Math.round(53.06));
assertThat(week.getWeeklyTotalSittingDays()).isEqualTo(68);
assertThat(week.getWeeklyTotalAttendanceDays()).isEqualTo(72);
assertThat(week.getWeeklyTotalNonAttendanceDays()).isEqualTo(26);
assertThat(Math.round(week.getWeeklyTotalUtilisation())).isEqualTo(Math.round(69.39));

// validate the overall totals
assertThat(tableData.getOverallTotalJurorWorkingDays()).isEqualTo(221);
assertThat(tableData.getOverallTotalSittingDays()).isEqualTo(52);
assertThat(tableData.getOverallTotalAttendanceDays()).isEqualTo(68);
assertThat(tableData.getOverallTotalNonAttendanceDays()).isEqualTo(153);
assertThat(Math.round(tableData.getOverallTotalUtilisation())).isEqualTo(Math.round(23.52));
assertThat(tableData.getOverallTotalSittingDays()).isEqualTo(104);
assertThat(tableData.getOverallTotalAttendanceDays()).isEqualTo(120);
assertThat(tableData.getOverallTotalNonAttendanceDays()).isEqualTo(101);
assertThat(Math.round(tableData.getOverallTotalUtilisation())).isEqualTo(Math.round(47.06));

}

Expand Down Expand Up @@ -221,9 +221,9 @@ void viewDailyUtilisationJurorsHappy() {

// validate the totals
assertThat(tableData.getTotalJurorWorkingDays()).isEqualTo(21);
assertThat(tableData.getTotalSittingDays()).isEqualTo(12);
assertThat(tableData.getTotalAttendanceDays()).isEqualTo(13);
assertThat(tableData.getTotalNonAttendanceDays()).isEqualTo(8);
assertThat(tableData.getTotalSittingDays()).isEqualTo(16);
assertThat(tableData.getTotalAttendanceDays()).isEqualTo(17);
assertThat(tableData.getTotalNonAttendanceDays()).isEqualTo(4);

}

Expand Down Expand Up @@ -305,17 +305,17 @@ void generateMonthlyUtilisationReportHappy() {
MonthlyUtilisationReportResponse.TableData.Month month = tableData.getMonths().get(0);
assertThat(month.getMonth()).isEqualTo("May 2024");
assertThat(month.getJurorWorkingDays()).isEqualTo(457);
assertThat(month.getSittingDays()).isEqualTo(52);
assertThat(month.getAttendanceDays()).isEqualTo(56);
assertThat(month.getNonAttendanceDays()).isEqualTo(401);
assertThat(Math.round(month.getUtilisation())).isEqualTo(Math.round(11.38));
assertThat(month.getSittingDays()).isEqualTo(260);
assertThat(month.getAttendanceDays()).isEqualTo(264);
assertThat(month.getNonAttendanceDays()).isEqualTo(193);
assertThat(Math.round(month.getUtilisation())).isEqualTo(Math.round(56.89));

// validate the totals - should be as per the month
assertThat(tableData.getTotalJurorWorkingDays()).isEqualTo(457);
assertThat(tableData.getTotalSittingDays()).isEqualTo(52);
assertThat(tableData.getTotalAttendanceDays()).isEqualTo(56);
assertThat(tableData.getTotalNonAttendanceDays()).isEqualTo(401);
assertThat(Math.round(tableData.getTotalUtilisation())).isEqualTo(Math.round(11.38));
assertThat(tableData.getTotalSittingDays()).isEqualTo(260);
assertThat(tableData.getTotalAttendanceDays()).isEqualTo(264);
assertThat(tableData.getTotalNonAttendanceDays()).isEqualTo(193);
assertThat(Math.round(tableData.getTotalUtilisation())).isEqualTo(Math.round(56.89));

LocalDate may2024 = LocalDate.parse("2024-05-01");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,20 @@ delete from juror_mod.pool;

-- Pool 415220401 requested 2 jurors for TIMESTAMP'2023-05-30 00:00:00.000000', 4 already supplied (2 surplus) - active with the buruea
INSERT INTO JUROR_MOD.POOL (OWNER, POOL_NO, RETURN_DATE, TOTAL_NO_REQUIRED, NO_REQUESTED, POOL_TYPE, LOC_CODE, NEW_REQUEST, LAST_UPDATE)
VALUES ('400', '415220401', TIMESTAMP'2023-05-30 00:00:00.000000', 2, 2, 'CRO','415', 'N', TIMESTAMP'2022-02-02 09:22:09.0');
VALUES ('400', '415220401', TIMESTAMP'2023-05-30 00:00:00.000000', 2, 2, 'CRO','415', 'N', TIMESTAMP'2022-02-02 09:22:09.0'),
('415', '415220402', current_date, 2, 2, 'CRO','415', 'N', current_date);


-- Pool 767220401 requested 5 jurors for TIMESTAMP'2023-05-30 00:00:00.000000', 0 already supplied (5 still needed) - active with the buruea
INSERT INTO JUROR_MOD.POOL (OWNER, POOL_NO, RETURN_DATE, TOTAL_NO_REQUIRED, NO_REQUESTED, POOL_TYPE, LOC_CODE, NEW_REQUEST, LAST_UPDATE)
VALUES ('400', '767220401', TIMESTAMP'2023-05-30 00:00:00.000000', 5, 5, 'CRO','767', 'N', TIMESTAMP'2022-02-02 09:22:09.0');

VALUES ('400', '767220401', TIMESTAMP'2023-05-30 00:00:00.000000', 5, 5, 'CRO','767', 'N', TIMESTAMP'2022-02-02 09:22:09.0'),
-- Pool 415220502 requested 4 jurors for TIMESTAMP'2023-06-01 00:00:00.000000', 2 already supplied (2 needed) - active with the buruea
INSERT INTO JUROR_MOD.POOL (OWNER, POOL_NO, RETURN_DATE, TOTAL_NO_REQUIRED, NO_REQUESTED, POOL_TYPE, LOC_CODE, NEW_REQUEST, LAST_UPDATE) VALUES
('400', '415220502', TIMESTAMP'2023-06-01 00:00:00.000000', 4, 4, 'CRO', '415', 'N', TIMESTAMP'2022-03-02 09:22:09.0');

INSERT INTO JUROR_MOD.POOL (OWNER, POOL_NO, RETURN_DATE, TOTAL_NO_REQUIRED, NO_REQUESTED, POOL_TYPE, LOC_CODE, NEW_REQUEST, LAST_UPDATE) VALUES
('400', '416220502', TIMESTAMP'2023-06-01 00:00:00.000000', 3, 3, 'CRO', '416', 'N', TIMESTAMP'2022-03-02 09:22:09.0');

('400', '415220502', TIMESTAMP'2023-06-01 00:00:00.000000', 4, 4, 'CRO', '415', 'N', TIMESTAMP'2022-03-02 09:22:09.0'),
('400', '416220502', TIMESTAMP'2023-06-01 00:00:00.000000', 3, 3, 'CRO', '416', 'N', TIMESTAMP'2022-03-02 09:22:09.0'),
-- Pool 415220503 requested 4 jurors for TIMESTAMP'2023-06-12 00:00:00.000000', none currently supplied (4 needed) - active with the buruea
INSERT INTO JUROR_MOD.POOL (OWNER, POOL_NO, RETURN_DATE, TOTAL_NO_REQUIRED, NO_REQUESTED, POOL_TYPE, LOC_CODE, NEW_REQUEST, LAST_UPDATE) VALUES
('400', '415220503', TIMESTAMP'2023-06-12 00:00:00.000000', 4, 4, 'CRO', '415', 'N', TIMESTAMP'2022-03-02 09:22:09.0');

('400', '415220503', TIMESTAMP'2023-06-12 00:00:00.000000', 4, 4, 'CRO', '415', 'N', TIMESTAMP'2022-03-02 09:22:09.0'),
-- Pool 415220504 requested 4 jurors for TIMESTAMP'2023-06-12 00:00:00.000000', none currently supplied (4 needed) - active with the court
INSERT INTO JUROR_MOD.POOL (OWNER, POOL_NO, RETURN_DATE, TOTAL_NO_REQUIRED, NO_REQUESTED, POOL_TYPE, LOC_CODE, NEW_REQUEST, LAST_UPDATE) VALUES
('415', '415220504', TIMESTAMP'2023-06-12 00:00:00.000000', 4, 4, 'CRO', '415', 'N', TIMESTAMP'2022-03-02 09:22:09.0');
('415', '415220504', TIMESTAMP'2023-06-12 00:00:00.000000', 4, 4, 'CRO', '415', 'N', TIMESTAMP'2022-03-02 09:22:09.0');

-- Create juror records associated with DEFER_DBF records
INSERT INTO juror_mod.juror (juror_number,poll_number,last_name,first_name,dob,address_line_1,address_line_2,postcode,responded,user_edtq,no_def_pos,notifications,notes) VALUES
Expand All @@ -44,7 +38,9 @@ INSERT INTO juror_mod.juror (juror_number,poll_number,last_name,first_name,dob,a
('555555556','540','LNAMEFIVEFOURZERO','FNAMEFIVEFOURZERO','1990-07-25 00:00:00','540 STREET NAME','ANYTOWN','CH1 2AN','Y','BUREAU_USER_1',0,0,NULL),
('555555557','540','LNAMEFIVEFOURZERO','FNAMEFIVEFOURZERO','1990-07-25 00:00:00','540 STREET NAME','ANYTOWN','CH1 2AN','Y','BUREAU_USER_1',0,0,NULL),
('555555558','540','LNAMEFIVEFOURZERO','FNAMEFIVEFOURZERO','1990-07-25 00:00:00','540 STREET NAME','ANYTOWN','CH1 2AN','Y','BUREAU_USER_1',0,0,NULL),
('555555559','540','LNAMEFIVEFOURZERO','FNAMEFIVEFOURZERO','1990-07-25 00:00:00','540 STREET NAME','ANYTOWN','CH1 2AN','Y','BUREAU_USER_1',0,0,NULL);
('555555559','540','LNAMEFIVEFOURZERO','FNAMEFIVEFOURZERO','1990-07-25 00:00:00','540 STREET NAME','ANYTOWN','CH1 2AN','Y','BUREAU_USER_1',0,0,NULL),
('555555560','540','LNAMEFIVEFOURZERO','FNAMEFIVEFOURZERO','1990-07-25 00:00:00','540 STREET NAME','ANYTOWN','CH1 2AN','Y','BUREAU_USER_1',0,0,NULL);


INSERT INTO juror_mod.juror_pool ("owner",juror_number,pool_number,user_edtq,status,is_active,pool_seq,"location",on_call) VALUES
('400','555555551','415220401','BUREAU_USER_1',1,'Y','0109','415','N'),
Expand All @@ -55,4 +51,13 @@ INSERT INTO juror_mod.juror_pool ("owner",juror_number,pool_number,user_edtq,sta
('400','555555556','415220502','BUREAU_USER_1',11,'Y','0109','415','N'),
('400','555555557','415220504','BUREAU_USER_1',1,'Y','0109','415','N'),
('415','555555558','415220401','BUREAU_USER_1',1,'Y','0109','415','N'),
('415','555555559','415220401','BUREAU_USER_1',1,'Y','0109','415','N');
('415','555555559','415220401','BUREAU_USER_1',1,'Y','0109','415','N'),
('415','555555560','415220402','COURT_USER_1',1,'Y','0109','415','N');


-- add appearance values for cert of attendance values
INSERT INTO juror_mod.appearance (attendance_date,juror_number,pool_number,loc_code,time_in,time_out,
travel_time,appearance_stage, loss_of_earnings_paid, childcare_total_paid, misc_total_paid, non_attendance, no_show,
attendance_type)
VALUES
(current_date,'555555560','415220402','415','09:30:00',NULL,'01:12','CHECKED_IN', null, null, null, false, false, NULL);
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,21 @@ INSERT INTO juror_mod.juror (juror_number, last_name, first_name, dob, address_l
('555555558', 'LNAMEFIVEFOURZERO', 'FNAMEFIVEFOURZERO', TIMESTAMP '1990-07-25 00:00:00.000000', '540 STREET NAME',
'ANYTOWN', 'CH1 2AN', true),
('555555559', 'LNAMEFIVEFOURZERO', 'FNAMEFIVEFOURZERO', TIMESTAMP '1990-07-25 00:00:00.000000', '540 STREET NAME',
'ANYTOWN', 'CH1 2AN', true),
('555555560', 'LNAMEFIVEFOURZERO', 'FNAMEFIVEFOURZERO', TIMESTAMP '1990-07-25 00:00:00.000000', '540 STREET NAME',
'ANYTOWN', 'CH1 2AN', true);

INSERT INTO juror_mod.juror_pool (owner, juror_number, pool_number, status, is_active) VALUES
('400', '555555551', '415220401', 2, true),
('400', '555555552', '415220401', 2, true),
('400', '555555557', '415220503', 2, true),
('400', '555555558', '415220401', 2, true),
('415', '555555559', '222222222', 2, true);
('415', '555555559', '222222222', 2, true),
('415', '555555560', '222222222', 2, true);

-- add appearance values for cert of attendance values
INSERT INTO juror_mod.appearance (attendance_date,juror_number,pool_number,loc_code,time_in,time_out,
travel_time,appearance_stage, loss_of_earnings_paid, childcare_total_paid, misc_total_paid, non_attendance, no_show,
attendance_type)
VALUES
(current_date,'555555560','222222222','415','09:30:00',NULL,'01:12','CHECKED_IN', null, null, null, false, false, NULL);
Loading

0 comments on commit dc64da4

Please sign in to comment.