diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Bromley.pm | 13 | ||||
-rw-r--r-- | perllib/Integrations/Echo.pm | 29 |
2 files changed, 32 insertions, 10 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm index f80bdaa12..fc41eae28 100644 --- a/perllib/FixMyStreet/Cobrand/Bromley.pm +++ b/perllib/FixMyStreet/Cobrand/Bromley.pm @@ -695,10 +695,21 @@ sub _parse_schedules { my $last = $schedule->{LastInstance}; $d = construct_bin_date($last->{CurrentScheduledDate}); - if ($d && (!$max_last || $d > $max_last->{date})) { + # It is possible the last instance for this schedule has been rescheduled to + # be in the future. If so, we should treat it like it is a next instance. + if ($d && $d->strftime("%F") gt $today && (!$min_next || $d < $min_next->{date})) { + my $last_changed = $last->{CurrentScheduledDate}{DateTime} ne $last->{OriginalScheduledDate}{DateTime}; + $min_next = { + date => $d, + ordinal => ordinal($d->day), + changed => $last_changed, + }; + } elsif ($d && (!$max_last || $d > $max_last->{date})) { + my $last_changed = $last->{CurrentScheduledDate}{DateTime} ne $last->{OriginalScheduledDate}{DateTime}; $max_last = { date => $d, ordinal => ordinal($d->day), + changed => $last_changed, ref => $last->{Ref}{Value}{anyType}, }; } diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm index 28dd1e9bc..bf4b453e6 100644 --- a/perllib/Integrations/Echo.pm +++ b/perllib/Integrations/Echo.pm @@ -89,25 +89,31 @@ sub GetTasks { push @refs, \%a; } - return [ - { + if ($self->sample_data) { + my %lookup = map { $_->[0] . ',' . $_->[1] => 1 } @_; + my $data = []; + push @$data, { Ref => { Value => { anyType => [ 123, 456 ] } }, State => { Name => 'Completed' }, Resolution => { Ref => { Value => { anyType => 187 } }, Name => 'Wrong Bin Out' }, TaskTypeId => 3216, CompletedDate => { DateTime => '2020-05-27T10:00:00Z' } - }, - { + } if $lookup{"123,456"}; + push @$data, { Ref => { Value => { anyType => [ 234, 567 ] } }, State => { Name => 'Outstanding' }, CompletedDate => undef - }, - { + } if $lookup{"234,567"}; + push @$data, { Ref => { Value => { anyType => [ 345, 678 ] } }, State => { Name => 'Not Completed' } - }, - { Ref => { Value => { anyType => [ 456, 789 ] } }, CompletedDate => undef }, - ] if $self->sample_data; + } if $lookup{"345,678"}; + push @$data, { + Ref => { Value => { anyType => [ 456, 789 ] } }, + CompletedDate => undef + } if $lookup{"456,789"}; + return $data; + } # This creates XML of the form <taskRefs><ObjectRef>...</ObjectRef><ObjectRef>...</ObjectRef>...</taskRefs> # uncoverable statement @@ -188,6 +194,7 @@ sub GetServiceUnitsForObject { OriginalScheduledDate => { DateTime => '2020-06-03T00:00:00Z' }, }, LastInstance => { + OriginalScheduledDate => { DateTime => '2020-05-27T00:00:00Z' }, CurrentScheduledDate => { DateTime => '2020-05-27T00:00:00Z' }, Ref => { Value => { anyType => [ 123, 456 ] } }, }, @@ -207,6 +214,7 @@ sub GetServiceUnitsForObject { OriginalScheduledDate => { DateTime => '2020-06-10T00:00:00Z' }, }, LastInstance => { + OriginalScheduledDate => { DateTime => '2020-05-27T00:00:00Z' }, CurrentScheduledDate => { DateTime => '2020-05-27T00:00:00Z' }, Ref => { Value => { anyType => [ 234, 567 ] } }, }, @@ -226,6 +234,7 @@ sub GetServiceUnitsForObject { OriginalScheduledDate => { DateTime => '2020-06-03T00:00:00Z' }, }, LastInstance => { + OriginalScheduledDate => { DateTime => '2020-05-18T00:00:00Z' }, CurrentScheduledDate => { DateTime => '2020-05-20T00:00:00Z' }, Ref => { Value => { anyType => [ 345, 678 ] } }, }, @@ -241,6 +250,7 @@ sub GetServiceUnitsForObject { ServiceTaskSchedules => { ServiceTaskSchedule => [ { EndDate => { DateTime => '2020-01-01T00:00:00Z' }, LastInstance => { + OriginalScheduledDate => { DateTime => '2019-12-31T00:00:00Z' }, CurrentScheduledDate => { DateTime => '2019-12-31T00:00:00Z' }, }, }, { @@ -250,6 +260,7 @@ sub GetServiceUnitsForObject { OriginalScheduledDate => { DateTime => '2020-06-01T00:00:00Z' }, }, LastInstance => { + OriginalScheduledDate => { DateTime => '2020-05-18T00:00:00Z' }, CurrentScheduledDate => { DateTime => '2020-05-18T00:00:00Z' }, Ref => { Value => { anyType => [ 456, 789 ] } }, }, |