Skip to content

Commit

Permalink
[Waste] [Bulky] Add way to cancel by update.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Sep 12, 2023
1 parent 2a42cd4 commit 64b2680
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
10 changes: 9 additions & 1 deletion perllib/FixMyStreet/App/Controller/Waste/Bulky.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions perllib/FixMyStreet/Cobrand/Peterborough/Bulky.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
19 changes: 14 additions & 5 deletions perllib/FixMyStreet/Roles/CobrandBulkyWaste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions templates/web/base/waste/bulky/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ <h2 class="govuk-heading-l govuk-!-margin-bottom-5">Booking Summary</h2>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds govuk-!-margin-bottom-5">
[% IF problem %]
[% cancellation_report = cobrand.bulky_cancellation_report(problem) %]
[% IF cancellation_report %]
[% cancelled = cobrand.bulky_is_cancelled(problem) %]
[% IF cancelled %]
<div class="govuk-warning-text due" style="padding:1em">
<div class="govuk-warning-text__img">
<span class="govuk-warning-text__icon" aria-hidden="true">!</span>
Expand All @@ -55,8 +55,8 @@ <h2 class="govuk-heading-l govuk-!-margin-bottom-5">Booking Summary</h2>
<span class="govuk-warning-text__assistive">Notification of cancellation</span>
<p class="govuk-!-margin-bottom-0">
This collection has been cancelled.
[% IF cobrand.bulky_can_view_cancellation(problem) %]
<a href="/report/[% cancellation_report.id %]">View cancellation report.</a>
[% IF NOT cobrand.bulky_cancel_by_update AND cobrand.bulky_can_view_cancellation(problem) %]
<a href="/report/[% cancelled.id %]">View cancellation report.</a>
[% END %]
</p>
</div>
Expand Down

0 comments on commit 64b2680

Please sign in to comment.