aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/Cobrand/Bromley.pm20
-rw-r--r--perllib/Integrations/Echo.pm11
-rw-r--r--t/cobrand/bromley.t26
3 files changed, 56 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm
index 1e1212d7b..4b1406316 100644
--- a/perllib/FixMyStreet/Cobrand/Bromley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bromley.pm
@@ -527,6 +527,7 @@ sub bin_services_for_address {
my $open = $self->_parse_open_events($events);
my @out;
+ my %task_ref_to_row;
foreach (@$result) {
next unless $_->{ServiceTasks};
@@ -555,8 +556,26 @@ sub bin_services_for_address {
last => $schedules->{last},
next => $schedules->{next},
};
+ if ($row->{last}) {
+ my $ref = join(',', @{$row->{last}{ref}});
+ $task_ref_to_row{$ref} = $row;
+ }
push @out, $row;
}
+ if (%task_ref_to_row) {
+ my $tasks = $echo->GetTasks(map { $_->{last}{ref} } values %task_ref_to_row);
+ foreach (@$tasks) {
+ my $ref = join(',', @{$_->{Ref}{Value}{anyType}});
+ my $completed = construct_bin_date($_->{CompletedDate});
+ my $state = $_->{State}{Name} || '';
+ my $resolution = $_->{Resolution}{Name} || '';
+
+ my $row = $task_ref_to_row{$ref};
+ $row->{last}{state} = $state;
+ $row->{last}{completed} = $completed;
+ $row->{last}{resolution} = $resolution;
+ }
+ }
return \@out;
}
@@ -622,6 +641,7 @@ sub _parse_schedules {
$max_last = {
date => $d,
ordinal => ordinal($d->day),
+ ref => $last->{Ref}{Value}{anyType},
};
}
}
diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm
index 9a5b65ec2..c9eab0cfc 100644
--- a/perllib/Integrations/Echo.pm
+++ b/perllib/Integrations/Echo.pm
@@ -91,7 +91,12 @@ sub GetTasks {
return [
{ Ref => { Value => { anyType => [ 123, 456 ] } }, CompletedDate => undef },
- { Ref => { Value => { anyType => [ 234, 567 ] } }, CompletedDate => { DateTime => '2020-05-27T10:00:00Z' } },
+ {
+ Ref => { Value => { anyType => [ 234, 567 ] } },
+ State => { Name => 'Completed' },
+ Resolution => { Name => 'Wrong Bin Out' },
+ CompletedDate => { DateTime => '2020-05-27T10:00:00Z' }
+ },
{ Ref => { Value => { anyType => [ 345, 678 ] } }, CompletedDate => undef },
{ Ref => { Value => { anyType => [ 456, 789 ] } }, CompletedDate => undef },
] if $self->sample_data;
@@ -176,6 +181,7 @@ sub GetServiceUnitsForObject {
},
LastInstance => {
CurrentScheduledDate => { DateTime => '2020-05-27T00:00:00Z' },
+ Ref => { Value => { anyType => [ 123, 456 ] } },
},
} },
} },
@@ -194,6 +200,7 @@ sub GetServiceUnitsForObject {
},
LastInstance => {
CurrentScheduledDate => { DateTime => '2020-05-27T00:00:00Z' },
+ Ref => { Value => { anyType => [ 234, 567 ] } },
},
} },
} },
@@ -212,6 +219,7 @@ sub GetServiceUnitsForObject {
},
LastInstance => {
CurrentScheduledDate => { DateTime => '2020-05-20T00:00:00Z' },
+ Ref => { Value => { anyType => [ 345, 678 ] } },
},
} },
} },
@@ -235,6 +243,7 @@ sub GetServiceUnitsForObject {
},
LastInstance => {
CurrentScheduledDate => { DateTime => '2020-05-18T00:00:00Z' },
+ Ref => { Value => { anyType => [ 456, 789 ] } },
},
} ] },
} },
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index bb43890a2..3578f10fb 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -278,6 +278,32 @@ subtest 'test open enquiries' => sub {
restore_time();
};
+subtest 'test reporting before/after completion' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'bromley',
+ COBRAND_FEATURES => {
+ echo => { bromley => { sample_data => 1 } },
+ waste => { bromley => 1 }
+ },
+ }, 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_contains('Report a paper & cardboard collection as missed');
+ set_fixed_time('2020-05-28T12:00:00Z');
+ $mech->get_ok('/waste/uprn/12345');
+ $mech->content_contains('Report a paper & cardboard collection as missed');
+ set_fixed_time('2020-05-29T12:00:00Z');
+ $mech->get_ok('/waste/uprn/12345');
+ $mech->content_contains('Report a paper & cardboard collection as missed');
+ set_fixed_time('2020-05-30T12:00:00Z');
+ $mech->get_ok('/waste/uprn/12345');
+ $mech->content_lacks('Report a paper & cardboard collection as missed');
+ };
+ restore_time();
+};
+
subtest 'test waste max-per-day' => sub {
FixMyStreet::override_config {
ALLOWED_COBRANDS => 'bromley',