Skip to content

Commit

Permalink
WIP [Bexley][WW] Allow user to request new containers
Browse files Browse the repository at this point in the history
  • Loading branch information
nephila-nacrea committed Sep 12, 2024
1 parent 2460d7d commit 6619f11
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 1 deletion.
37 changes: 37 additions & 0 deletions perllib/FixMyStreet/App/Form/Waste/Request/Bexley.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package FixMyStreet::App::Form::Waste::Request::Bexley;

use utf8;
use HTML::FormHandler::Moose;
extends 'FixMyStreet::App::Form::Waste::Request';

has_page replacement => (
fields => ['request_reason', 'continue'],
title => 'Reason for request',
next => 'about_you',
);

has_field request_reason => (
type => 'Select',
widget => 'RadioGroup',
required => 1,
label => 'Why do you need new bins?',
);

# TODO Different for MDR-SACK properties
sub options_request_reason {
my $form = shift;
my @options = (

Check warning on line 23 in perllib/FixMyStreet/App/Form/Waste/Request/Bexley.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/App/Form/Waste/Request/Bexley.pm#L22-L23

Added lines #L22 - L23 were not covered by tests
'My existing bin is too small or big',
'My existing bin is damaged',
'My existing bin has gone missing',
'I have moved into a new development',
);
return map { { label => $_, value => $_ } } @options;

Check warning on line 29 in perllib/FixMyStreet/App/Form/Waste/Request/Bexley.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/App/Form/Waste/Request/Bexley.pm#L29

Added line #L29 was not covered by tests
}

# TODO
# Number of residents?
# Check for existing requests for a given container.
# Message to user if failed delivery, direct them to enquiry form.

1;
116 changes: 115 additions & 1 deletion perllib/FixMyStreet/Cobrand/Bexley/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use Integrations::Whitespace;
use DateTime;
use DateTime::Format::W3CDTF;
use FixMyStreet;
use FixMyStreet::App::Form::Waste::Request::Bexley;
use FixMyStreet::Template;
use Sort::Key::Natural qw(natkeysort_inplace);

Expand All @@ -46,11 +47,19 @@ use constant WORKING_DAYS_WINDOW => 3;
C<0001-01-01T00:00:00> represents an undefined date in Whitespace.
=cut

use constant WHITESPACE_UNDEF_DATE => '0001-01-01T00:00:00';

=item * CONTAINER_REQUEST_MAX
We only allow customer to request 1 container per container type
=back
=cut

use constant WHITESPACE_UNDEF_DATE => '0001-01-01T00:00:00';
use constant CONTAINER_REQUEST_MAX => 1;

sub waste_fetch_events {
my ( $self, $params ) = @_;
Expand Down Expand Up @@ -220,6 +229,82 @@ sub look_up_property {
};
}

# Maps a container (ServiceItemID) to a ServiceID for delivery
sub container_to_delivery_mapping {
return {
21 => 272,

Check warning on line 235 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L235

Added line #L235 was not covered by tests
22 => 273, # RES-180
23 => 274,
799 => 328,
800 => 329,
801 => 330,
802 => 331,
789 => 324,
790 => 325,
791 => 326,
792 => 327,
17 => 243,
33 => 224,
701 => 235,

591 => 216, # Lids

# Not mentioned by Bexley
# FO-23 - Food 23 ltr Caddy - 'Brown Caddy'
33 => 224,

# TODO What about collections?
# We need to raise a worksheet for delivery of new bin AND a worksheet
# for collection of old bin, at the same time?
};
}

sub options_for_container_requests {
my ( $self, $property, $services ) = @_;

Check warning on line 263 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L263

Added line #L263 was not covered by tests

# TODO Direct communal properties to email form
return {} if $property->{is_communal};

return { 'MDR-SACK' => [ 'MDR-SACK' ] } if $property->{above_shop};

my $options = {};
for (@$services) {
warn "====\n\t" . $_->{round_schedule} . ' : ' . $_->{service_id} . ' : ' . $_->{service_name} . "\n====";

Check warning on line 272 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L270-L272

Added lines #L270 - L272 were not covered by tests

if ( $_->{round_schedule} =~ /BOX/ ) {
$options->{ $_->{service_id} } = {
'PG-55' => 'White recycling box',

Check warning on line 276 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L276

Added line #L276 was not covered by tests
'PC-55' => 'Blue recycling box',
};
} elsif ( $_->{round_schedule} =~ /RES/ ) {
$options->{ $_->{service_id} } = {
'RES-140' => 'Green wheelie bin 140L',

Check warning on line 281 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L281

Added line #L281 was not covered by tests
'RES-180' => 'Green wheelie bin 180L',
'RES-240' => 'Green wheelie bin 240L',
};
} elsif (
$_->{round_schedule} =~ /PG/
|| $_->{service_id} =~ /^PG-/
) {
$options->{ $_->{service_id} } = {
'PG-140' => 'White lidded wheelie bin 140L',

Check warning on line 290 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L290

Added line #L290 was not covered by tests
'PG-180' => 'White lidded wheelie bin 180L',
'PG-240' => 'White lidded wheelie bin 240L',
};
}
# etc...

# TODO Box lids
# TODO
# Multiple box lids can be requested. (Up to 5).
# Multiple food boxes(?) can be requested. (Up to 3).
# TODO/CHECKME
#
}

return $options;

Check warning on line 305 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L305

Added line #L305 was not covered by tests
}

sub bin_services_for_address {
my $self = shift;
my $property = shift;
Expand Down Expand Up @@ -366,6 +451,8 @@ sub bin_services_for_address {
},
assisted_collection => $assisted_collection,
uprn => $uprn,
request_containers => [ $service->{ServiceItemName} ],

Check warning on line 454 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L454

Added line #L454 was not covered by tests
request_max => CONTAINER_REQUEST_MAX,
};

if ($last_dt) {
Expand Down Expand Up @@ -440,6 +527,9 @@ sub bin_services_for_address {

@site_services_filtered = $self->service_sort(@site_services_filtered);

$property->{options_for_container_requests} =
$self->options_for_container_requests($property,\@site_services_filtered);

Check warning on line 531 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L531

Added line #L531 was not covered by tests

return \@site_services_filtered;
}

Expand Down Expand Up @@ -1220,4 +1310,28 @@ sub get_in_cab_logs_reason_prefix {
return '';
}

# For new container requests

sub waste_request_form_first_next {
return 'replacement';

Check warning on line 1316 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L1316

Added line #L1316 was not covered by tests
}

sub waste_munge_request_data {
my ($self, $id, $data) = @_;

Check warning on line 1320 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L1320

Added line #L1320 was not covered by tests

my $c = $self->{c};
my $service = $c->stash->{services}{$id};

Check warning on line 1323 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L1322-L1323

Added lines #L1322 - L1323 were not covered by tests

my $service_name = $service->{service_name};
my $service_item_name = $service->{service_id};
my $uprn = $service->{uprn};
my $reason = $data->{request_reason} || '';

Check warning on line 1328 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L1325-L1328

Added lines #L1325 - L1328 were not covered by tests

$data->{title} = "Request new $service_name";
$data->{detail} = "Reason: $reason";
$c->set_param('uprn', $uprn);
$c->set_param( 'service_item_name', $service->{service_id} );

Check warning on line 1333 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L1330-L1333

Added lines #L1330 - L1333 were not covered by tests
# $c->set_param('service_id', $id);
}

1;
17 changes: 17 additions & 0 deletions templates/web/base/waste/bin_days.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@
<h1 class="govuk-heading-xl">Your bin days</h1>
[% END %]

[% IF c.cobrand.moniker == 'bexley' %]
[% FOR group IN property.options_for_container_requests.keys %]
[% FOR id IN property.options_for_container_requests.$group.keys %]
<div>
<ul>
<li>
ID: [% id %]
</li>
<li>
Type: [% property.options_for_container_requests.$group.$id %]
</li>
</ul>
</div>
[% END %]
[% END %]
[% END %]

[% TRY %][% PROCESS waste/_service_navigation_bar.html %][% CATCH file %][% END %]
[% INCLUDE 'waste/_address_display.html' %]
[% TRY %][% PROCESS waste/_rotation_schedule.html %][% CATCH file %][% END %]
Expand Down

0 comments on commit 6619f11

Please sign in to comment.