Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions perllib/FixMyStreet/Cobrand/Kingston.pm
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,41 @@ sub admin_fee_cost {
return $cost;
}

=head2 waste_munge_enquiry_data

Get the right data in place for the bin not returned / waste spillage / escalation categories.

=cut

sub waste_munge_enquiry_data {
my ($self, $data) = @_;
my $c = $self->{c};

my $address = $c->stash->{property}->{address};

$data->{title} = _enquiry_nice_title($data->{category});

my $detail = "";
if ($data->{category} eq 'Bin not returned') {
my $assisted = $c->stash->{assisted_collection};
my $returned = $data->{now_returned} || '';
if ($assisted && lc($returned) eq 'no') {
$data->{extra_Notes} = '*** Property is on assisted list ***';
}
} elsif ($data->{category} eq 'Waste spillage') {
$detail = $data->{extra_Notes} . "\n\n";
}
if ($data->{extra_details}) {
my $extra = ref $data->{extra_details} ne '' ? join(', ', @{$data->{extra_details}}) : $data->{extra_details};
my $nl = $data->{extra_Notes} ? "\n" : '';
$data->{extra_Notes} .= $nl . "Details: " . $extra;
}
$detail .= $self->service_name_override({ ServiceId => $data->{service_id} }) . "\n\n";
$detail .= $address;

$data->{detail} = $detail;
}

=head2 Bulky waste collection

=over 4
Expand Down
89 changes: 1 addition & 88 deletions perllib/FixMyStreet/Cobrand/Sutton.pm
Original file line number Diff line number Diff line change
Expand Up @@ -700,93 +700,6 @@ sub request_cost {
}
}

=head2 waste_munge_enquiry_form_pages

The Bin not returned flow has some more complex setup depending on whether
the property has an assisted collection or not, with an extra question,
and showing/hiding different notices.

=cut

sub waste_munge_enquiry_form_pages {
my ($self, $pages, $fields) = @_;
my $c = $self->{c};
my $category = $c->get_param('category');

# Add the service to the main fields form page
$pages->[1]{intro} = 'enquiry-intro.html';
$pages->[1]{title} = _enquiry_nice_title($category);

return unless $category eq 'Bin not returned';;

my $assisted = $c->stash->{assisted_collection};
if ($assisted) {
# Add extra first page with extra question
$c->stash->{first_page} = 'now_returned';
unshift @$pages, now_returned => {
fields => [ 'now_returned', 'continue' ],
intro => 'enquiry-intro.html',
title => _enquiry_nice_title($category),
next => 'enquiry',
};
push @$fields, now_returned => {
type => 'Select',
widget => 'RadioGroup',
required => 1,
label => 'Has the container now been returned to the property?',
options => [
{ label => 'Yes', value => 'Yes' },
{ label => 'No', value => 'No' },
],
};

# Remove any non-assisted extra notices
my @new;
for (my $i=0; $i<@$fields; $i+=2) {
if ($fields->[$i] !~ /^extra_NotAssisted/) {
push @new, $fields->[$i], $fields->[$i+1];
}
}
@$fields = @new;
$pages->[3]{fields} = [ grep { !/^extra_NotAssisted/ } @{$pages->[3]{fields}} ];
$pages->[3]{update_field_list} = sub {
my $form = shift;
my $c = $form->c;
my $data = $form->saved_data;
my $returned = $data->{now_returned} || '';
my $key = $returned eq 'No' ? 'extra_AssistedReturned' : 'extra_AssistedNotReturned';
return {
category => { default => $c->get_param('category') },
service_id => { default => $c->get_param('service_id') },
$key => { widget => 'Hidden' },
}
};
} else {
# Remove any assisted extra notices
my @new;
for (my $i=0; $i<@$fields; $i+=2) {
if ($fields->[$i] !~ /^extra_Assisted/) {
push @new, $fields->[$i], $fields->[$i+1];
}
}
@$fields = @new;
$pages->[1]{fields} = [ grep { !/^extra_Assisted/ } @{$pages->[1]{fields}} ];
}
}

sub _enquiry_nice_title {
my $category = shift;
if ($category eq 'Bin not returned') {
$category = 'Wheelie bin, box or caddy not returned correctly after collection';
} elsif ($category eq 'Waste spillage') {
$category = 'Spillage during collection';
} elsif ($category eq 'Complaint against time') {
$category = 'Issue with collection';
} elsif ($category eq 'Failure to Deliver Bags/Containers') {
$category = 'Issue with delivery';
}
return $category;
}

=head2 waste_munge_enquiry_data

Expand All @@ -806,7 +719,7 @@ sub waste_munge_enquiry_data {
if ($data->{category} eq 'Bin not returned') {
my $assisted = $c->stash->{assisted_collection};
my $returned = $data->{now_returned} || '';
if ($assisted && $returned eq 'No') {
if ($assisted && lc($returned) eq 'no') {
$data->{extra_Notes} = '*** Property is on assisted list ***';
}
} elsif ($data->{category} eq 'Waste spillage') {
Expand Down
87 changes: 87 additions & 0 deletions perllib/FixMyStreet/Roles/Cobrand/KingstonSutton.pm
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,93 @@ sub waste_report_form_first_next {
};
}

=head2 waste_munge_enquiry_form_pages

the bin not returned flow has some more complex setup depending on whether
the property has an assisted collection or not, with an extra question,
and showing/hiding different notices.

=cut

sub waste_munge_enquiry_form_pages {
my ($self, $pages, $fields) = @_;
my $c = $self->{c};
my $category = $c->get_param('category');

# add the service to the main fields form page
$pages->[1]{intro} = 'enquiry-intro.html';
$pages->[1]{title} = _enquiry_nice_title($category);

return unless $category eq 'Bin not returned';;

my $assisted = $c->stash->{assisted_collection};
if ($assisted) {
# add extra first page with extra question
$c->stash->{first_page} = 'now_returned';
unshift @$pages, now_returned => {
fields => [ 'now_returned', 'continue' ],
intro => 'enquiry-intro.html',
title => _enquiry_nice_title($category),
next => 'enquiry',
};
push @$fields, now_returned => {
type => 'Select',
widget => 'RadioGroup',
required => 1,
label => 'has the container now been returned to the property?',
options => [
{ label => 'Yes', value => 'yes' },
{ label => 'No', value => 'no' },
],
};

# remove any non-assisted extra notices
my @new;
for (my $i=0; $i<@$fields; $i+=2) {
if ($fields->[$i] !~ /^extra_notassisted/i) {
push @new, $fields->[$i], $fields->[$i+1];
}
}
@$fields = @new;
$pages->[3]{fields} = [ grep { !/^extra_notassisted/i } @{$pages->[3]{fields}} ];
$pages->[3]{update_field_list} = sub {
my $form = shift;
my $c = $form->c;
my $data = $form->saved_data;
my $returned = $data->{now_returned} || '';
my $key = lc($returned) eq 'no' ? 'extra_AssistedReturned' : 'extra_AssistedNotReturned';
return {
category => { default => $c->get_param('category') },
service_id => { default => $c->get_param('service_id') },
$key => { widget => 'Hidden' },
}
};
} else {
# remove any assisted extra notices
my @new;
for (my $i=0; $i<@$fields; $i+=2) {
if ($fields->[$i] !~ /^extra_assisted/i) {
push @new, $fields->[$i], $fields->[$i+1];
}
}
@$fields = @new;
$pages->[1]{fields} = [ grep { !/^extra_assisted/i } @{$pages->[1]{fields}} ];
}
}

sub _enquiry_nice_title {
my $category = shift;
if ($category eq 'Bin not returned') {
$category = 'Wheelie bin, box or caddy not returned correctly after collection';
} elsif ($category eq 'Waste spillage') {
$category = 'Spillage during collection';
} elsif ($category eq 'Complaint against time') {
$category = 'Issue with collection';
} elsif ($category eq 'Failure to Deliver Bags/Containers') {
$category = 'Issue with delivery';
}
return $category;
}

=head2 waste_cc_payment_line_item_ref

Expand Down
1 change: 1 addition & 0 deletions perllib/FixMyStreet/Roles/Cobrand/SLWP2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ sub waste_extra_service_info {
}
$self->{c}->stash->{communal_property} = 1 if $service_id == $service_ids->{communal_refuse} || $service_id == $service_ids->{communal_food} || $service_id == $service_ids->{communal_paper} || $service_id == $service_ids->{communal_mixed};

# detect flat above shop
if ($service_id == $service_ids->{fas_refuse} || $service_id == $service_ids->{fas_mixed}) {
$self->{c}->stash->{fas_property} = 1;
}
Expand Down
146 changes: 146 additions & 0 deletions t/app/controller/waste_kingston_4499005.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
[
{
"StartDate": { "DateTime": "2017-01-01T00:00:00Z" },
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" },
"Id": "1001",
"ServiceTasks": {
"ServiceTask": {
"ServiceTaskSchedules": {
"ServiceTaskSchedule": {
"ScheduleDescription": "Monday every week",
"LastInstance": {
"Ref": { "Value": { "anyType": [ "23293043", "8318" ] } },
"OriginalScheduledDate": { "DateTime": "2022-10-09T23:00:00Z" },
"CurrentScheduledDate": { "DateTime": "2022-10-10T05:00:00Z" },
"CompletedDate": { "DateTime": "2022-10-10T06:00:00Z" }
},
"NextInstance": {
"Ref": { "Value": { "anyType": [ "23293043", "8325" ] } },
"OriginalScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" },
"CurrentScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" }
},
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" },
"StartDate": { "DateTime": "2018-09-02T23:00:00Z" }
}
},
"ScheduleDescription": "Every Monday",
"TaskTypeId": "2242",
"Id": "2001",
"Data": {
"ExtensibleDatum": [
{
"ChildData": {
"ExtensibleDatum": [
{ "DatatypeName": "Container Type", "Value": "6" },
{ "Value": "1", "DatatypeName": "Quantity" }
]
},
"DatatypeName": "Refuse Containers"
}
]
},
"TaskTypeName": "Collect Domestic Refuse Bag",
"StartDate": { "DateTime": "2017-01-01T00:00:00Z" },
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" }
}
},
"ServiceName": "Domestic Refuse Collection",
"ServiceUnitTypeId": "65",
"ServiceId": "967"
},
{
"ServiceTasks": {
"ServiceTask": {
"ScheduleDescription": "Every Monday",
"TaskTypeId": "2246",
"ServiceTaskSchedules": {
"ServiceTaskSchedule": {
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" },
"StartDate": { "DateTime": "2020-06-08T23:00:00Z" },
"NextInstance": {
"CurrentScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" },
"OriginalScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" },
"Ref": { "Value": { "anyType": [ "29313385", "8325" ] } }
},
"LastInstance": {
"Ref": { "Value": { "anyType": [ "29313385", "8318" ] } },
"CurrentScheduledDate": { "DateTime": "2022-10-10T05:00:00Z" },
"OriginalScheduledDate": { "DateTime": "2022-10-09T23:00:00Z" }
},
"ScheduleDescription": "Monday every week"
}
},
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" },
"StartDate": { "DateTime": "2017-01-01T00:00:00Z" },
"Id": "2002",
"TaskTypeName": "Collect Domestic Recycling Bag",
"Data": {
"ExtensibleDatum": [
{
"ChildData": {
"ExtensibleDatum": [
{ "DatatypeName": "Container Type", "Value": "18" },
{ "DatatypeName": "Quantity", "Value": "1" }
]
},
"DatatypeName": "Recycling Containers"
}
]
}
}
},
"Id": "1002",
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" },
"StartDate": { "DateTime": "2017-01-01T00:00:00Z" },
"ServiceId": "971",
"ServiceName": "Domestic Recycling Collection"
},
{
"Id": "1003",
"StartDate": { "DateTime": "2017-01-01T00:00:00Z" },
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" },
"ServiceId": "975",
"ServiceName": "Domestic Recycling Collection",
"ServiceUnitTypeId": "65",
"ServiceTasks": {
"ServiceTask": {
"Data": {
"ExtensibleDatum": [
{
"ChildData": {
"ExtensibleDatum": [
{ "DatatypeName": "Container Type", "Value": "17" },
{ "Value": "1", "DatatypeName": "Quantity" }
]
},
"DatatypeName": "Recycling Containers"
}
]
},
"ServiceTaskSchedules": {
"ServiceTaskSchedule": {
"ScheduleDescription": "Wednesday, Saturday every week",
"LastInstance": {
"Ref": { "Value": { "anyType": [ "23293043", "8318" ] } },
"OriginalScheduledDate": { "DateTime": "2022-10-09T23:00:00Z" },
"CurrentScheduledDate": { "DateTime": "2022-10-10T05:00:00Z" }
},
"NextInstance": {
"Ref": { "Value": { "anyType": [ "23293043", "8325" ] } },
"OriginalScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" },
"CurrentScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" }
},
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" },
"StartDate": { "DateTime": "2018-09-02T23:00:00Z" }
}
},
"ScheduleDescription": "Every Wednesday and Saturday",
"TaskTypeId": "2246",
"Id": "2001",
"TaskTypeName": "Collect Domestic Refuse Bag",
"StartDate": { "DateTime": "2017-01-01T00:00:00Z" },
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" }
}
}
}
]
Loading
Loading