diff --git a/perllib/FixMyStreet/App/Controller/Waste/Bulky.pm b/perllib/FixMyStreet/App/Controller/Waste/Bulky.pm index b955d40b223..da059e7d405 100644 --- a/perllib/FixMyStreet/App/Controller/Waste/Bulky.pm +++ b/perllib/FixMyStreet/App/Controller/Waste/Bulky.pm @@ -204,7 +204,15 @@ sub add_cancellation_report : Private { $c->cobrand->call_hook( "waste_munge_bulky_cancellation_data", \%data ); - $c->forward( '/waste/add_report', [ \%data ] ) or return; + if ($c->cobrand->bulky_cancel_by_update) { + $collection_report->add_to_comments({ + text => 'Booking cancelled by customer', + user => $collection_report->user, + extra => { bulky_cancellation => 1 }, + }); + } else { + $c->forward( '/waste/add_report', [ \%data ] ) or return; + } } sub process_bulky_cancellation : Private { diff --git a/perllib/FixMyStreet/Cobrand/Peterborough/Bulky.pm b/perllib/FixMyStreet/Cobrand/Peterborough/Bulky.pm index 9c79c6bc45a..80c09a8ed6d 100644 --- a/perllib/FixMyStreet/Cobrand/Peterborough/Bulky.pm +++ b/perllib/FixMyStreet/Cobrand/Peterborough/Bulky.pm @@ -232,12 +232,12 @@ sub bulky_cancellation_report { # A cancelled collection will have a corresponding cancellation report # linked via external_id / ORIGINAL_SR_NUMBER - return FixMyStreet::DB->resultset('Problem')->find( - { extra => { - '@>' => encode_json({ _fields => [ { name => 'ORIGINAL_SR_NUMBER', value => $original_sr_number } ] }) - }, + return $self->problems->find({ + category => 'Bulky cancel', + extra => { + '@>' => encode_json({ _fields => [ { name => 'ORIGINAL_SR_NUMBER', value => $original_sr_number } ] }) }, - ); + }); } sub bulky_can_refund { diff --git a/perllib/FixMyStreet/Roles/CobrandBulkyWaste.pm b/perllib/FixMyStreet/Roles/CobrandBulkyWaste.pm index 6d2120b15c8..93af3405e2a 100644 --- a/perllib/FixMyStreet/Roles/CobrandBulkyWaste.pm +++ b/perllib/FixMyStreet/Roles/CobrandBulkyWaste.pm @@ -85,6 +85,17 @@ requires 'collection_date'; requires '_bulky_refund_cutoff_date'; requires 'bulky_free_collection_available'; +sub bulky_cancel_by_update { 0 } + +sub bulky_is_cancelled { + my ($self, $p) = @_; + if ($self->bulky_cancel_by_update) { + return $p->comments->find({ extra => { '@>' => '{"bulky_cancellation":1}' } }); + } else { + return $self->bulky_cancellation_report($p); + } +} + sub bulky_items_extra { my $self = shift; @@ -344,17 +355,15 @@ sub bulky_reminders { my $r3 = $report->get_extra_metadata('reminder_3'); next if $r1; # No reminders left to do - my $date = $self->collection_date($report); + my $dt = $self->collection_date($report); # Shouldn't happen, but better to be safe. - next unless $date; - - my $dt = $self->_bulky_date_to_dt($date); + next unless $dt; # If booking has been cancelled (or somehow the collection date has # already passed) then mark this report as done so we don't see it # again tomorrow. - my $cancelled = $self->bulky_cancellation_report($report); + my $cancelled = $self->bulky_is_cancelled($report); if ( $cancelled || $dt < $now) { $report->set_extra_metadata(reminder_1 => 1); $report->set_extra_metadata(reminder_3 => 1); diff --git a/templates/web/base/waste/bulky/summary.html b/templates/web/base/waste/bulky/summary.html index 1cf2d0a5dc8..66c526acee9 100644 --- a/templates/web/base/waste/bulky/summary.html +++ b/templates/web/base/waste/bulky/summary.html @@ -45,8 +45,8 @@
This collection has been cancelled. - [% IF cobrand.bulky_can_view_cancellation(problem) %] - View cancellation report. + [% IF NOT cobrand.bulky_cancel_by_update AND cobrand.bulky_can_view_cancellation(problem) %] + View cancellation report. [% END %]