aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorM Somerville <matthew-github@dracos.co.uk>2020-10-19 16:39:45 +0100
committerM Somerville <matthew-github@dracos.co.uk>2020-11-11 10:36:47 +0000
commit3f70d1f0b4d543072eda2d1b59092a5b9e6b3253 (patch)
treee7435af200b8687bfec0a9a8772888e9b2c07abb
parent22b89e27ac4368bcc4e288bd1fe2faf53f13ac9e (diff)
[Bromley] Handle today’s collection better.
If task is outstanding and before 5pm, show it as next collection and in progress. Allow reporting after 5pm.
-rw-r--r--perllib/FixMyStreet/Cobrand/Bromley.pm16
-rw-r--r--perllib/Integrations/Echo.pm1
-rw-r--r--t/cobrand/bromley.t13
-rw-r--r--templates/web/base/waste/bin_days.html2
4 files changed, 28 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm
index 93dd35539..f80bdaa12 100644
--- a/perllib/FixMyStreet/Cobrand/Bromley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bromley.pm
@@ -612,9 +612,21 @@ sub bin_services_for_address {
$row->{last}{completed} = $completed;
$row->{last}{resolution} = $resolution;
$row->{report_allowed} = within_working_days($row->{last}{date}, 2);
- if (!$completed && $row->{last}{date}->ymd eq $now->ymd) {
- $row->{report_allowed} = 0;
+
+ # Special handling if last instance is today
+ if ($row->{last}{date}->ymd eq $now->ymd) {
+ # If it's before 5pm and outstanding, show it as in progress
+ if ($state eq 'Outstanding' && $now->hour < 17) {
+ $row->{next} = $row->{last};
+ $row->{next}{state} = 'In progress';
+ delete $row->{last};
+ }
+ if (!$completed && $now->hour < 17) {
+ $row->{report_allowed} = 0;
+ }
}
+
+ # If the task is ended and could not be done, do not allow reporting
if ($state eq 'Not Completed' || ($state eq 'Completed' && $_->{Resolution}{Name} eq 'Excess Waste')) {
$row->{report_allowed} = 0;
$row->{report_locked_out} = 1;
diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm
index 0216240da..28dd1e9bc 100644
--- a/perllib/Integrations/Echo.pm
+++ b/perllib/Integrations/Echo.pm
@@ -99,6 +99,7 @@ sub GetTasks {
},
{
Ref => { Value => { anyType => [ 234, 567 ] } },
+ State => { Name => 'Outstanding' },
CompletedDate => undef
},
{
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index 3b01d308f..fb34f1b6d 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -288,8 +288,17 @@ FixMyStreet::override_config {
subtest 'test reporting before/after completion' => sub {
set_fixed_time('2020-05-27T11:00:00Z');
$mech->get_ok('/waste/uprn/12345');
- $mech->content_contains('(completed at 10:00am)');
- $mech->content_contains('Wrong Bin Out');
+ $mech->content_like(qr/Refuse collection.*?Last collection<\/dt>\s*<dd[^>]*>\s*Wednesday, 27th May\s+\(completed at 10:00am\)\s*<p>\s*Wrong Bin Out/s);
+ $mech->content_like(qr/Paper &amp; Cardboard.*?Next collection<\/dt>\s*<dd[^>]*>\s*Wednesday, 27th May\s+\(in progress\)/s);
+ $mech->follow_link_ok({ text => 'Report a problem with a paper & cardboard collection' });
+ $mech->content_lacks('Waste spillage');
+
+ set_fixed_time('2020-05-27T19:00:00Z');
+ $mech->get_ok('/waste/uprn/12345');
+ $mech->content_like(qr/Refuse collection.*?Last collection<\/dt>\s*<dd[^>]*>\s*Wednesday, 27th May\s+\(completed at 10:00am\)\s*<p>\s*Wrong Bin Out/s);
+ $mech->content_like(qr/Paper &amp; Cardboard.*?Last collection<\/dt>\s*<dd[^>]*>\s*Wednesday, 27th May\s*<\/dd>/s);
+ $mech->follow_link_ok({ text => 'Report a problem with a paper & cardboard collection' });
+ $mech->content_contains('Waste spillage');
};
subtest 'test template creation' => sub {
diff --git a/templates/web/base/waste/bin_days.html b/templates/web/base/waste/bin_days.html
index 12f965e5f..da55c57fb 100644
--- a/templates/web/base/waste/bin_days.html
+++ b/templates/web/base/waste/bin_days.html
@@ -41,6 +41,7 @@
[% IF unit.next %]
[% date.format(unit.next.date) | replace('~~~', unit.next.ordinal) %]
[% IF unit.next.changed %](this collection has been adjusted from its usual time)[% END %]
+ [% IF unit.next.state == 'In progress' %](in progress)[% END %]
[% ELSE %]
<i>None</i>
[% END %]
@@ -51,6 +52,7 @@
<dd class="govuk-summary-list__value">
[% IF unit.last %]
[% date.format(unit.last.date) | replace('~~~', unit.last.ordinal) %]
+ [% IF unit.last.state == 'In progress' %](in progress)[% END %]
[% IF unit.last.completed %](completed at [% date.format(unit.last.completed, '%l:%M%p') | lower ~%])[% END ~%]
[% IF unit.last.resolution %][% unit.last.resolution | staff_html_markup({ is_body_user => 1 }) %][% END ~%]
[% ELSE %]