Skip to content

Commit

Permalink
[Waste] Improve handling of refund flag function.
Browse files Browse the repository at this point in the history
This makes it easier for the summary page to show/not the refund text.
  • Loading branch information
dracos committed Sep 22, 2023
1 parent 0e781a1 commit 6c82861
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions perllib/FixMyStreet/App/Controller/Waste/Bulky.pm
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ sub cancel : Chained('setup') : Args(1) {
$c->stash->{cancelling_booking} = $collection;
$c->stash->{first_page} = 'intro';
$c->stash->{form_class} = 'FixMyStreet::App::Form::Waste::Bulky::Cancel';
$c->stash->{entitled_to_refund} = $c->cobrand->call_hook('bulky_can_refund');
$c->stash->{entitled_to_refund} = $c->cobrand->call_hook(bulky_can_refund => $collection);
$c->forward('form');
}

Expand Down Expand Up @@ -337,7 +337,7 @@ sub process_bulky_cancellation : Private {
# Was collection a free one? If so, reset 'FREE BULKY USED' on premises.
$c->cobrand->call_hook('unset_free_bulky_used');

if ( $c->cobrand->call_hook('bulky_can_refund') ) {
if ( $c->cobrand->call_hook(bulky_can_refund => $collection_report) ) {
$c->send_email(
'waste/bulky-refund-request.txt',
{ to => [
Expand Down
11 changes: 5 additions & 6 deletions perllib/FixMyStreet/Cobrand/Peterborough/Bulky.pm
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,18 @@ sub bulky_cancellation_report {
});
}

sub bulky_can_refund {
my $self = shift;
sub bulky_can_refund_collection {
my ($self, $p) = @_;
my $c = $self->{c};

# Skip refund eligibility check for bulky goods soft launch; just
# assume if a collection can be cancelled, it can be refunded
# (see https://3.basecamp.com/4020879/buckets/26662378/todos/5870058641)
return $self->within_bulky_cancel_window($c->stash->{cancelling_booking})
return $self->within_bulky_cancel_window($p)
if $self->bulky_enabled_staff_only;

return $c->stash->{cancelling_booking}
->get_extra_field_value('CHARGEABLE') ne 'FREE'
&& $self->within_bulky_refund_window($c->stash->{cancelling_booking});
return $p->get_extra_field_value('CHARGEABLE') ne 'FREE'
&& $self->within_bulky_refund_window($p);
}

# A cancellation made less than 24 hours before the collection is scheduled to
Expand Down
10 changes: 7 additions & 3 deletions perllib/FixMyStreet/Roles/CobrandBulkyWaste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,14 @@ sub _check_within_bulky_cancel_window {
}

sub bulky_can_refund {
my $self = shift;
my $c = $self->{c};
my ($self, $p) = @_;
return 1 unless $p;
return $self->bulky_can_refund_collection($p);
}

return $self->within_bulky_refund_window;
sub bulky_can_refund_collection {
my ($self, $p) = @_;
return $self->within_bulky_refund_window($p);
}

sub within_bulky_refund_window {
Expand Down
2 changes: 1 addition & 1 deletion templates/web/base/waste/bulky/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h3 class="summary-section--heading">Collection date</h3>
<span class="govuk-warning-text__assistive">Warning</span>
<p class="govuk-!-margin-bottom-3">You can cancel this booking till
[% cobrand.bulky_nice_cancellation_cutoff_date(data.chosen_date) %].</p>
[% UNLESS cobrand.call_hook('bulky_enabled_staff_only') %]
[% IF !cobrand.call_hook('bulky_enabled_staff_only') AND cobrand.bulky_can_refund %]
<p class="govuk-!-margin-bottom-0">You can get a refund if cancelled by [% cobrand.bulky_nice_collection_time %] on the day prior to your collection.</p>
[% END %]
</div>
Expand Down

0 comments on commit 6c82861

Please sign in to comment.