Skip to content

Commit 2c9d9c6

Browse files
committed
[Kingston][WW] bins not returned/spilled
This is mostly based on the Sutton code from #0cc3311cf5 with a few Kingston specific changes to add checkbox extra details to the bin not returned, plus an extra message for FAS properties for spillages. Fixes #5245 Fixes #5246
1 parent 13cc03e commit 2c9d9c6

9 files changed

Lines changed: 520 additions & 1 deletion

File tree

perllib/FixMyStreet/Cobrand/Kingston.pm

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,130 @@ sub admin_fee_cost {
623623
return $cost;
624624
}
625625

626+
627+
=head2 waste_munge_enquiry_form_pages
628+
629+
the bin not returned flow has some more complex setup depending on whether
630+
the property has an assisted collection or not, with an extra question,
631+
and showing/hiding different notices.
632+
633+
=cut
634+
635+
sub waste_munge_enquiry_form_pages {
636+
my ($self, $pages, $fields) = @_;
637+
my $c = $self->{c};
638+
my $category = $c->get_param('category');
639+
640+
# add the service to the main fields form page
641+
$pages->[1]{intro} = 'enquiry-intro.html';
642+
$pages->[1]{title} = _enquiry_nice_title($category);
643+
644+
return unless $category eq 'Bin not returned';;
645+
646+
my $assisted = $c->stash->{assisted_collection};
647+
if ($assisted) {
648+
# add extra first page with extra question
649+
$c->stash->{first_page} = 'now_returned';
650+
unshift @$pages, now_returned => {
651+
fields => [ 'now_returned', 'continue' ],
652+
intro => 'enquiry-intro.html',
653+
title => _enquiry_nice_title($category),
654+
next => 'enquiry',
655+
};
656+
push @$fields, now_returned => {
657+
type => 'Select',
658+
widget => 'RadioGroup',
659+
required => 1,
660+
label => 'has the container now been returned to the property?',
661+
options => [
662+
{ label => 'yes', value => 'yes' },
663+
{ label => 'no', value => 'no' },
664+
],
665+
};
666+
667+
# remove any non-assisted extra notices
668+
my @new;
669+
for (my $i=0; $i<@$fields; $i+=2) {
670+
if ($fields->[$i] !~ /^extra_notassisted/i) {
671+
push @new, $fields->[$i], $fields->[$i+1];
672+
}
673+
}
674+
@$fields = @new;
675+
$pages->[3]{fields} = [ grep { !/^extra_notassisted/i } @{$pages->[3]{fields}} ];
676+
$pages->[3]{update_field_list} = sub {
677+
my $form = shift;
678+
my $c = $form->c;
679+
my $data = $form->saved_data;
680+
my $returned = $data->{now_returned} || '';
681+
my $key = $returned eq 'no' ? 'extra_AssistedReturned' : 'extra_AssistedNotReturned';
682+
return {
683+
category => { default => $c->get_param('category') },
684+
service_id => { default => $c->get_param('service_id') },
685+
$key => { widget => 'Hidden' },
686+
}
687+
};
688+
} else {
689+
# remove any assisted extra notices
690+
my @new;
691+
for (my $i=0; $i<@$fields; $i+=2) {
692+
if ($fields->[$i] !~ /^extra_assisted/i) {
693+
push @new, $fields->[$i], $fields->[$i+1];
694+
}
695+
}
696+
@$fields = @new;
697+
$pages->[1]{fields} = [ grep { !/^extra_assisted/i } @{$pages->[1]{fields}} ];
698+
}
699+
}
700+
701+
sub _enquiry_nice_title {
702+
my $category = shift;
703+
if ($category eq 'Bin not returned') {
704+
$category = 'Wheelie bin, box or caddy not returned correctly after collection';
705+
} elsif ($category eq 'Waste spillage') {
706+
$category = 'Spillage during collection';
707+
} elsif ($category eq 'Complaint against time') {
708+
$category = 'Issue with collection';
709+
} elsif ($category eq 'Failure to Deliver Bags/Containers') {
710+
$category = 'Issue with delivery';
711+
}
712+
return $category;
713+
}
714+
715+
=head2 waste_munge_enquiry_data
716+
717+
Get the right data in place for the bin not returned / waste spillage / escalation categories.
718+
719+
=cut
720+
721+
sub waste_munge_enquiry_data {
722+
my ($self, $data) = @_;
723+
my $c = $self->{c};
724+
725+
my $address = $c->stash->{property}->{address};
726+
727+
$data->{title} = _enquiry_nice_title($data->{category});
728+
729+
my $detail = "";
730+
if ($data->{category} eq 'Bin not returned') {
731+
my $assisted = $c->stash->{assisted_collection};
732+
my $returned = $data->{now_returned} || '';
733+
if ($assisted && lc($returned) eq 'no') {
734+
$data->{extra_Notes} = '*** Property is on assisted list ***';
735+
}
736+
} elsif ($data->{category} eq 'Waste spillage') {
737+
$detail = $data->{extra_Notes} . "\n\n";
738+
}
739+
if ($data->{extra_details}) {
740+
my $extra = ref $data->{extra_details} ne '' ? join(', ', @{$data->{extra_details}}) : $data->{extra_details};
741+
my $nl = $data->{extra_Notes} ? "\n" : '';
742+
$data->{extra_Notes} .= $nl . "Details: " . $extra;
743+
}
744+
$detail .= $self->service_name_override({ ServiceId => $data->{service_id} }) . "\n\n";
745+
$detail .= $address;
746+
747+
$data->{detail} = $detail;
748+
}
749+
626750
=head2 Bulky waste collection
627751
628752
=over 4

perllib/FixMyStreet/Roles/Cobrand/SLWP2.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ sub waste_extra_service_info {
249249
}
250250
$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};
251251

252+
# detect flat above shop
252253
if ($service_id == $service_ids->{fas_refuse} || $service_id == $service_ids->{fas_mixed}) {
253254
$self->{c}->stash->{fas_property} = 1;
254255
}
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
[
2+
{
3+
"StartDate": { "DateTime": "2017-01-01T00:00:00Z" },
4+
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" },
5+
"Id": "1001",
6+
"ServiceTasks": {
7+
"ServiceTask": {
8+
"ServiceTaskSchedules": {
9+
"ServiceTaskSchedule": {
10+
"ScheduleDescription": "Monday every week",
11+
"LastInstance": {
12+
"Ref": { "Value": { "anyType": [ "23293043", "8318" ] } },
13+
"OriginalScheduledDate": { "DateTime": "2022-10-09T23:00:00Z" },
14+
"CurrentScheduledDate": { "DateTime": "2022-10-10T05:00:00Z" },
15+
"CompletedDate": { "DateTime": "2022-10-10T06:00:00Z" }
16+
},
17+
"NextInstance": {
18+
"Ref": { "Value": { "anyType": [ "23293043", "8325" ] } },
19+
"OriginalScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" },
20+
"CurrentScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" }
21+
},
22+
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" },
23+
"StartDate": { "DateTime": "2018-09-02T23:00:00Z" }
24+
}
25+
},
26+
"ScheduleDescription": "Every Monday",
27+
"TaskTypeId": "2242",
28+
"Id": "2001",
29+
"Data": {
30+
"ExtensibleDatum": [
31+
{
32+
"ChildData": {
33+
"ExtensibleDatum": [
34+
{ "DatatypeName": "Container Type", "Value": "6" },
35+
{ "Value": "1", "DatatypeName": "Quantity" }
36+
]
37+
},
38+
"DatatypeName": "Refuse Containers"
39+
}
40+
]
41+
},
42+
"TaskTypeName": "Collect Domestic Refuse Bag",
43+
"StartDate": { "DateTime": "2017-01-01T00:00:00Z" },
44+
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" }
45+
}
46+
},
47+
"ServiceName": "Domestic Refuse Collection",
48+
"ServiceUnitTypeId": "65",
49+
"ServiceId": "967"
50+
},
51+
{
52+
"ServiceTasks": {
53+
"ServiceTask": {
54+
"ScheduleDescription": "Every Monday",
55+
"TaskTypeId": "2246",
56+
"ServiceTaskSchedules": {
57+
"ServiceTaskSchedule": {
58+
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" },
59+
"StartDate": { "DateTime": "2020-06-08T23:00:00Z" },
60+
"NextInstance": {
61+
"CurrentScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" },
62+
"OriginalScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" },
63+
"Ref": { "Value": { "anyType": [ "29313385", "8325" ] } }
64+
},
65+
"LastInstance": {
66+
"Ref": { "Value": { "anyType": [ "29313385", "8318" ] } },
67+
"CurrentScheduledDate": { "DateTime": "2022-10-10T05:00:00Z" },
68+
"OriginalScheduledDate": { "DateTime": "2022-10-09T23:00:00Z" }
69+
},
70+
"ScheduleDescription": "Monday every week"
71+
}
72+
},
73+
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" },
74+
"StartDate": { "DateTime": "2017-01-01T00:00:00Z" },
75+
"Id": "2002",
76+
"TaskTypeName": "Collect Domestic Recycling Bag",
77+
"Data": {
78+
"ExtensibleDatum": [
79+
{
80+
"ChildData": {
81+
"ExtensibleDatum": [
82+
{ "DatatypeName": "Container Type", "Value": "18" },
83+
{ "DatatypeName": "Quantity", "Value": "1" }
84+
]
85+
},
86+
"DatatypeName": "Recycling Containers"
87+
}
88+
]
89+
}
90+
}
91+
},
92+
"Id": "1002",
93+
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" },
94+
"StartDate": { "DateTime": "2017-01-01T00:00:00Z" },
95+
"ServiceId": "971",
96+
"ServiceName": "Domestic Recycling Collection"
97+
},
98+
{
99+
"Id": "1003",
100+
"StartDate": { "DateTime": "2017-01-01T00:00:00Z" },
101+
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" },
102+
"ServiceId": "975",
103+
"ServiceName": "Domestic Recycling Collection",
104+
"ServiceUnitTypeId": "65",
105+
"ServiceTasks": {
106+
"ServiceTask": {
107+
"Data": {
108+
"ExtensibleDatum": [
109+
{
110+
"ChildData": {
111+
"ExtensibleDatum": [
112+
{ "DatatypeName": "Container Type", "Value": "17" },
113+
{ "Value": "1", "DatatypeName": "Quantity" }
114+
]
115+
},
116+
"DatatypeName": "Recycling Containers"
117+
}
118+
]
119+
},
120+
"ServiceTaskSchedules": {
121+
"ServiceTaskSchedule": {
122+
"ScheduleDescription": "Wednesday, Saturday every week",
123+
"LastInstance": {
124+
"Ref": { "Value": { "anyType": [ "23293043", "8318" ] } },
125+
"OriginalScheduledDate": { "DateTime": "2022-10-09T23:00:00Z" },
126+
"CurrentScheduledDate": { "DateTime": "2022-10-10T05:00:00Z" }
127+
},
128+
"NextInstance": {
129+
"Ref": { "Value": { "anyType": [ "23293043", "8325" ] } },
130+
"OriginalScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" },
131+
"CurrentScheduledDate": { "DateTime": "2022-10-16T23:00:00Z" }
132+
},
133+
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" },
134+
"StartDate": { "DateTime": "2018-09-02T23:00:00Z" }
135+
}
136+
},
137+
"ScheduleDescription": "Every Wednesday and Saturday",
138+
"TaskTypeId": "2246",
139+
"Id": "2001",
140+
"TaskTypeName": "Collect Domestic Refuse Bag",
141+
"StartDate": { "DateTime": "2017-01-01T00:00:00Z" },
142+
"EndDate": { "DateTime": "2050-01-01T00:00:00Z" }
143+
}
144+
}
145+
}
146+
]

0 commit comments

Comments
 (0)