Skip to content

Commit

Permalink
Merge branch 'bexley-end-of-round' into commercial-staging
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismytton committed May 14, 2024
2 parents 5d70e38 + ff883b7 commit b8592ef
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
17 changes: 7 additions & 10 deletions perllib/FixMyStreet/Cobrand/Bexley/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -461,21 +461,18 @@ sub can_report_missed {
my $now_dt
= DateTime->now( time_zone => FixMyStreet->local_time_zone );

# For collections with prefix RCY- or PG- we need to check if the last
# collection was made over WORKING_DAYS_WINDOW ago because some
# collections are weekly and some fortnightly, but they share a round
# code prefix.
if ( $service->{round} =~ /^RCY-/ or $service->{round} =~ /^PG-/ ) {
return 0 if $last_expected_collection_dt < $min_dt;
}
# We need to check if the last collection was made over
# WORKING_DAYS_WINDOW ago because some collections are weekly and some
# fortnightly, but they share a round code prefix.
return 0 if $last_expected_collection_dt < $min_dt && !$service->{next}{is_today};

return ( $log_for_round->{date} < $now_dt
&& $log_for_round->{date} >= $min_dt ) ? 1 : 0
if $log_for_round;

$service->{last}{is_delayed} = 1
if $last_expected_collection_dt < $today_dt
&& $last_expected_collection_dt >= $min_dt;
$service->{last}{is_delayed} =
($last_expected_collection_dt < $today_dt && $last_expected_collection_dt >= $min_dt)
|| ($service->{next}{is_today} && $now_dt->hour >= 17) ? 1 : 0;
}

# At this point, missed report is not allowed because
Expand Down
15 changes: 15 additions & 0 deletions t/app/controller/waste_bexley.t
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,18 @@ FixMyStreet::override_config {
service_id => 'FO-23',
round => 'RCY-R1',
round_schedule => 'RCY-R1 Mon',
next => {
is_today => 1,
},
},
# Had a collection earlier today
'FO-140' => {
service_id => 'FO-140',
round => 'RCY-R2',
round_schedule => 'RCY-R2 Mon',
next => {
is_today => 1,
},
},
# Collection due last working day but it did not happen
'RES-180' => {
Expand Down Expand Up @@ -548,6 +554,8 @@ FixMyStreet::override_config {
'RES-R4 Fri' => DateTime->today->subtract( days => 3 ), # RES-240
'GDN-R1 Tue' => DateTime->today->subtract( days => 6 ), # GA-240
'RCY-R2 Mon PG Wk 2' => DateTime->today->subtract( days => 7 ), # PG-240
'RCY-R1 Mon' => DateTime->today->subtract( days => 14 ), # FO-23
'RCY-R2 Mon' => DateTime->today->subtract( days => 14 ), # FO-140
},
};

Expand Down Expand Up @@ -620,6 +628,13 @@ FixMyStreet::override_config {

is $cobrand->can_report_missed( $property, $services{'PG-240'} ), 0,
'cannot report missed collection against service whose round was collected more than 3 working days ago';
ok !$services{'PG-240'}{last}{is_delayed}, 'not marked delayed';

# After 5pm, so FO-23 is now considered delayed
set_fixed_time('2024-04-22T16:00:00'); # Monday, 17:00 BST
is $cobrand->can_report_missed( $property, $services{'FO-23'} ), 0,
'cannot report missed collection after 5pm against service due today that has not been collected';
ok $services{'FO-23'}{last}{is_delayed}, 'marked delayed';

# Put time back to previous value
set_fixed_time('2024-03-31T01:00:00'); # March 31st, 02:00 BST
Expand Down

0 comments on commit b8592ef

Please sign in to comment.