diff --git a/perllib/FixMyStreet/App/Controller/Waste.pm b/perllib/FixMyStreet/App/Controller/Waste.pm index 9f14bc38442..0624b8b6926 100644 --- a/perllib/FixMyStreet/App/Controller/Waste.pm +++ b/perllib/FixMyStreet/App/Controller/Waste.pm @@ -36,8 +36,8 @@ has index_template => ( my %GARDEN_IDS = ( merton => { bin240 => 26, bin140 => 27, sack => 28 }, - kingston => { bin240 => 26, bin140 => 27, sack => 28 }, - sutton => { bin240 => 26, bin140 => 27, sack => 28 }, + kingston => { bin240 => 39, bin140 => 37, sack => 36 }, + sutton => { bin240 => 39, bin140 => 37, sack => 36 }, ); lock_hash(%GARDEN_IDS); @@ -1361,9 +1361,10 @@ sub process_garden_cancellation : Private { my $now = DateTime->now->set_time_zone(FixMyStreet->local_time_zone); my $end_date_field = $c->cobrand->call_hook(alternative_backend_field_names => 'Subscription_End_Date') || 'Subscription_End_Date'; - $c->set_param($end_date_field, $now->ymd); + $c->set_param($end_date_field, $now->dmy('/')); my $service = $c->cobrand->garden_current_subscription; + # Not actually used by Kingston/Sutton if (!$c->stash->{slwp_garden_sacks} || $service->{garden_container} == $GARDEN_IDS{$c->cobrand->moniker}{bin240} || $service->{garden_container} == $GARDEN_IDS{$c->cobrand->moniker}{bin140}) { my $bin_count = $c->cobrand->get_current_garden_bins; $data->{new_bins} = $bin_count * -1; @@ -1459,6 +1460,7 @@ sub process_garden_modification : Private { my $service = $c->cobrand->garden_current_subscription; my $costs = WasteWorks::Costs->new({ cobrand => $c->cobrand, discount => $data->{apply_discount} }); if ($c->stash->{slwp_garden_sacks} && $service->{garden_container} == $GARDEN_IDS{$c->cobrand->moniker}{sack}) { # SLWP Sack + # This must be Kingston $data->{bins_wanted} = 1; $data->{new_bins} = 1; $payment = $costs->sacks($data->{bins_wanted}); diff --git a/perllib/FixMyStreet/App/Form/Waste/Bulky/Shared.pm b/perllib/FixMyStreet/App/Form/Waste/Bulky/Shared.pm index cfa1e0d10d3..1bd4776a5c7 100644 --- a/perllib/FixMyStreet/App/Form/Waste/Bulky/Shared.pm +++ b/perllib/FixMyStreet/App/Form/Waste/Bulky/Shared.pm @@ -49,7 +49,6 @@ has_page location => ( $fields->{location} = { required => 1 }; } if ($form->c->cobrand->moniker eq 'kingston' || $form->c->cobrand->moniker eq 'sutton') { - $fields->{location}{label} = 'Please tell us where you will place the items for collection (include any access codes the crew will need)'; $fields->{location}{tags}{hint} = 'For example, ‘On the driveway’'; } diff --git a/perllib/FixMyStreet/App/Form/Waste/Garden/Modify.pm b/perllib/FixMyStreet/App/Form/Waste/Garden/Modify.pm index 52b04600364..39d8747d70b 100644 --- a/perllib/FixMyStreet/App/Form/Waste/Garden/Modify.pm +++ b/perllib/FixMyStreet/App/Form/Waste/Garden/Modify.pm @@ -124,10 +124,19 @@ has_field task => ( label => 'What do you want to do?', required => 1, widget => 'RadioGroup', - options => [ - { value => 'modify', label => 'Increase or reduce the number of bins in your subscription' }, - { value => 'cancel', label => 'Cancel your garden waste subscription' }, - ], + options_method => sub { + my $self = shift; + my $form = $self->form; + my $c = $form->c; + my @options; + if ($c->cobrand->moniker eq 'kingston' || $c->cobrand->moniker eq 'sutton' || $c->cobrand->moniker eq 'brent') { + push @options, { value => 'modify', label => 'Increase the number of bins in your subscription' }; + } else { + push @options, { value => 'modify', label => 'Increase or reduce the number of bins in your subscription' }; + } + push @options, { value => 'cancel', label => 'Cancel your garden waste subscription' }; + return \@options; + }, ); has_field current_bins => ( @@ -181,4 +190,20 @@ has_field submit => ( order => 999, ); +sub validate { + my $self = shift; + my $cobrand = $self->{c}->cobrand->moniker; + + if ($cobrand eq 'kingston' || $cobrand eq 'sutton' || $cobrand eq 'brent') { + unless ( $self->field('current_bins')->is_inactive ) { + my $total = $self->field('bins_wanted')->value; + my $current = $self->field('current_bins')->value; + $self->add_form_error('You can only increase the number of bins') + if $total <= $current; + } + } + + $self->next::method(); +} + 1; diff --git a/perllib/FixMyStreet/App/Form/Waste/Garden/Sacks/Choice.pm b/perllib/FixMyStreet/App/Form/Waste/Garden/Sacks/Choice.pm index be6af63b808..cedce715143 100644 --- a/perllib/FixMyStreet/App/Form/Waste/Garden/Sacks/Choice.pm +++ b/perllib/FixMyStreet/App/Form/Waste/Garden/Sacks/Choice.pm @@ -3,6 +3,7 @@ package FixMyStreet::App::Form::Waste::Garden::Sacks::Choice; use utf8; use HTML::FormHandler::Moose::Role; +# Used by Merton only, below, to default the container choice use constant CONTAINER_GARDEN_BIN => 26; use constant CONTAINER_GARDEN_BIN_140 => 27; use constant CONTAINER_GARDEN_SACK => 28; diff --git a/perllib/FixMyStreet/App/Form/Waste/Request/Kingston.pm b/perllib/FixMyStreet/App/Form/Waste/Request/Kingston.pm index 6a5ffc8dbd4..96fd613cab2 100644 --- a/perllib/FixMyStreet/App/Form/Waste/Request/Kingston.pm +++ b/perllib/FixMyStreet/App/Form/Waste/Request/Kingston.pm @@ -18,7 +18,7 @@ use utf8; use HTML::FormHandler::Moose; extends 'FixMyStreet::App::Form::Waste::Request'; -use constant CONTAINER_REFUSE_240 => 2; +use constant CONTAINER_REFUSE_240 => 3; =head2 About you @@ -40,7 +40,7 @@ has_page about_you => ( my $total_paid_quantity = 0; foreach (@services) { my ($id) = /container-(.*)/; - my $quantity = $data->{"quantity-$id"}; + my $quantity = $data->{"quantity-$id"} or next; my $names = $c->stash->{containers}; if ($names->{$id} !~ /bag|sack|food/i) { $total_paid_quantity += $quantity; @@ -74,15 +74,21 @@ has_page how_many_exchange => ( fields => ['how_many_exchange', 'continue'], title => 'Black bin size change request', intro => 'request/intro.html', + post_process => sub { + my $form = shift; + my $data = $form->saved_data; + if ($data) { + my $how_many = $data->{"how_many_exchange"} || ''; + return if $how_many eq 'less5' || $how_many eq '7more'; + $form->c->cobrand->waste_exchange_bin_setup_data($data, CONTAINER_REFUSE_240); + } + }, next => sub { my $data = shift; my $how_many = $data->{"how_many_exchange"}; if ($how_many eq 'less5' || $how_many eq '7more') { return 'biggest_bin_allowed'; } - $data->{'container-' . CONTAINER_REFUSE_240} = 1; - $data->{'quantity-' . CONTAINER_REFUSE_240} = 1; - $data->{'removal-' . CONTAINER_REFUSE_240} = 1; return 'about_you'; }, ); diff --git a/perllib/FixMyStreet/Cobrand/Kingston.pm b/perllib/FixMyStreet/Cobrand/Kingston.pm index 3cb6ce01c32..f7cd245dae6 100644 --- a/perllib/FixMyStreet/Cobrand/Kingston.pm +++ b/perllib/FixMyStreet/Cobrand/Kingston.pm @@ -5,6 +5,7 @@ use utf8; use Moo; with 'FixMyStreet::Roles::Cobrand::Waste', 'FixMyStreet::Roles::Cobrand::KingstonSutton', + 'FixMyStreet::Roles::Cobrand::SLWP2', 'FixMyStreet::Roles::Cobrand::SCP'; use Lingua::EN::Inflect qw( NUMWORDS ); @@ -16,40 +17,39 @@ sub council_name { return 'Kingston upon Thames Council'; } sub council_url { return 'kingston'; } sub admin_user_domain { 'kingston.gov.uk' } -my %TASK_IDS = ( - domestic_refuse => 2238, - domestic_food => 2239, - domestic_paper => 2240, - domestic_mixed => 2241, - domestic_refuse_bag => 2242, - communal_refuse => 2243, - domestic_mixed_bag => 2246, - garden => 2247, - communal_food => 2248, - communal_paper => 2249, - communal_mixed => 2250, - domestic_paper_bag => 2632, - schedule2_mixed => 3571, - schedule2_refuse => 3576, - deliver_refuse_bags => 2256, - deliver_recycling_bags => 2257, +my %SERVICE_IDS = ( + domestic_refuse => 966, # 4394 + communal_refuse => 969, # 4407 + fas_refuse => 967, # 4395 + domestic_mixed => 970, # 4390 + communal_mixed => 973, # 4397 + fas_mixed => 971, # 4391 + domestic_paper => 974, # 4388 + communal_paper => 977, # 4396 + fas_paper => 975, # 4402 + domestic_food => 980, # 4389 + communal_food => 983, # 4403 + garden => 979, # 4410 + schedule2_refuse => 968, # 4409 + schedule2_mixed => 972, # 4398 + deliver_bags => 987, # 4427 4432 ); -lock_hash(%TASK_IDS); +lock_hash(%SERVICE_IDS); my %CONTAINERS = ( refuse_140 => 1, - refuse_180 => 35, - refuse_240 => 2, - refuse_360 => 3, - recycling_box => 16, - recycling_240 => 12, - paper_240 => 19, - paper_140 => 36, - food_indoor => 23, - food_outdoor => 24, - garden_240 => 26, - garden_140 => 27, - garden_sack => 28, + refuse_180 => 2, + refuse_240 => 3, + refuse_360 => 4, + recycling_box => 12, + recycling_240 => 15, + paper_240 => 27, + paper_140 => 26, + food_indoor => 43, + food_outdoor => 46, + garden_240 => 39, + garden_140 => 37, + garden_sack => 36, ); lock_hash(%CONTAINERS); @@ -62,15 +62,13 @@ sub waste_check_staff_payment_permissions { $c->stash->{staff_payments_allowed} = 'paye'; } -has lpi_value => ( is => 'ro', default => 'KINGSTON UPON THAMES' ); - sub waste_payment_ref_council_code { "RBK" } sub garden_collection_time { '6:30am' } sub waste_quantity_max { return ( - $TASK_IDS{garden} => 5, # Garden waste maximum + $SERVICE_IDS{garden} => 5, # Garden waste maximum ); } @@ -112,17 +110,17 @@ sub image_for_unit { my $service_id = $unit->{service_id}; my $images = { - $TASK_IDS{domestic_refuse} => svg_container_bin('wheelie', '#333333'), # refuse - $TASK_IDS{domestic_food} => "$base/caddy-brown-large", # food - $TASK_IDS{domestic_paper} => svg_container_bin("wheelie", '#767472', '#00A6D2', 1), # paper and card - $TASK_IDS{domestic_mixed} => svg_container_bin("wheelie", '#41B28A'), # dry mixed - $TASK_IDS{domestic_refuse_bag} => svg_container_sack('stripe', '#E83651'), # domestic refuse bag - $TASK_IDS{communal_refuse} => svg_container_bin('communal', '#767472', '#333333'), # Communal refuse - $TASK_IDS{domestic_mixed_bag} => svg_container_sack('stripe', '#4f4cf0'), # domestic recycling bag - $TASK_IDS{communal_food} => svg_container_bin('wheelie', '#8B5E3D'), # Communal food - $TASK_IDS{communal_paper} => svg_container_bin("communal", '#767472', '#00A6D2'), # Communal paper - $TASK_IDS{communal_mixed} => svg_container_bin('communal', '#41B28A'), # Communal recycling - $TASK_IDS{domestic_paper_bag} => svg_container_sack('normal', '#d8d8d8'), # domestic paper bag + $SERVICE_IDS{domestic_refuse} => svg_container_bin('wheelie', '#333333'), # refuse + $SERVICE_IDS{domestic_food} => "$base/caddy-brown-large", # food + $SERVICE_IDS{domestic_paper} => svg_container_bin("wheelie", '#767472', '#00A6D2', 1), # paper and card + $SERVICE_IDS{domestic_mixed} => svg_container_bin("wheelie", '#41B28A'), # dry mixed + $SERVICE_IDS{fas_refuse} => svg_container_sack('stripe', '#E83651'), # domestic refuse bag + $SERVICE_IDS{communal_refuse} => svg_container_bin('communal', '#767472', '#333333'), # Communal refuse + $SERVICE_IDS{fas_mixed} => svg_container_sack('stripe', '#4f4cf0'), # domestic recycling bag + $SERVICE_IDS{communal_food} => svg_container_bin('wheelie', '#8B5E3D'), # Communal food + $SERVICE_IDS{communal_paper} => svg_container_bin("communal", '#767472', '#00A6D2'), # Communal paper + $SERVICE_IDS{communal_mixed} => svg_container_bin('communal', '#41B28A'), # Communal recycling + $SERVICE_IDS{fas_paper} => svg_container_sack('normal', '#d8d8d8'), # domestic paper bag }; return $images->{$service_id}; } @@ -142,33 +140,21 @@ sub waste_containers { }; return { %$black_bins, - 4 => 'Refuse Blue Sack', - 5 => 'Refuse Black Sack', - 6 => 'Refuse Red Stripe Bag', - 18 => 'Mixed Recycling Blue Striped Bag', - 29 => 'Recycling Single Use Bag', - 21 => 'Paper & Card Reusable Bag', - 22 => 'Paper Sacks', - 30 => 'Paper & Card Recycling Clear Bag', - 7 => 'Communal Refuse bin (240L)', - 8 => 'Communal Refuse bin (360L)', - 9 => 'Communal Refuse bin (660L)', - 10 => 'Communal Refuse bin (1100L)', - 11 => 'Communal Refuse Chamberlain', - 33 => 'Communal Refuse bin (140L)', - 34 => 'Communal Refuse bin (1280L)', - 14 => 'Communal Recycling bin (660L)', - 15 => 'Communal Recycling bin (1100L)', - 25 => 'Communal Food bin (240L)', + 10 => 'Refuse Red Stripe Bag', + 22 => 'Mixed Recycling Blue Striped Bag', + 34 => 'Paper & Card Recycling Clear Bag', + 8 => 'Communal Refuse bin (1100L)', + 20 => 'Communal Recycling bin (1100L)', + 51 => 'Communal Food bin (240L)', $CONTAINERS{recycling_240} => 'Recycling bin (240L)', - 13 => 'Recycling bin (360L)', - 20 => 'Paper recycling bin (360L)', - 31 => 'Paper 55L Box', + 16 => 'Recycling bin (360L)', + 28 => 'Paper recycling bin (360L)', + 32 => 'Communal Paper bin (1100L)', $CONTAINERS{recycling_240} => 'Green recycling bin (240L)', - 13 => 'Green recycling bin (360L)', + 16 => 'Green recycling bin (360L)', $CONTAINERS{recycling_box} => 'Green recycling box (55L)', $CONTAINERS{paper_240} => 'Blue lid paper and cardboard bin (240L)', - 20 => 'Blue lid paper and cardboard bin (360L)', + 28 => 'Blue lid paper and cardboard bin (360L)', $CONTAINERS{food_indoor} => 'Food waste bin (kitchen)', $CONTAINERS{food_outdoor} => 'Food waste bin (outdoor)', $CONTAINERS{paper_140} => 'Blue lid paper and cardboard bin (180L)', @@ -188,22 +174,21 @@ sub service_name_override { my ($self, $service) = @_; my %service_name_override = ( - $TASK_IDS{domestic_refuse} => 'Non-recyclable Refuse', - $TASK_IDS{domestic_food} => 'Food waste', - $TASK_IDS{domestic_paper} => 'Paper and card', - $TASK_IDS{domestic_mixed} => 'Mixed recycling', - $TASK_IDS{domestic_refuse_bag} => 'Non-recyclable Refuse', - $TASK_IDS{communal_refuse} => 'Non-recyclable Refuse', - $TASK_IDS{domestic_mixed_bag} => 'Mixed recycling', - $TASK_IDS{garden} => 'Garden Waste', - $TASK_IDS{communal_food} => 'Food waste', - $TASK_IDS{communal_paper} => 'Paper and card', - $TASK_IDS{communal_mixed} => 'Mixed recycling', - $TASK_IDS{domestic_paper_bag} => 'Paper and card', - $TASK_IDS{schedule2_mixed} => 'Mixed recycling', - $TASK_IDS{schedule2_refuse} => 'Non-recyclable Refuse', - $TASK_IDS{deliver_refuse_bags} => '', - $TASK_IDS{deliver_recycling_bags} => '', + $SERVICE_IDS{domestic_refuse} => 'Non-recyclable Refuse', + $SERVICE_IDS{domestic_food} => 'Food waste', + $SERVICE_IDS{domestic_paper} => 'Paper and card', + $SERVICE_IDS{domestic_mixed} => 'Mixed recycling', + $SERVICE_IDS{fas_refuse} => 'Non-recyclable Refuse', + $SERVICE_IDS{communal_refuse} => 'Non-recyclable Refuse', + $SERVICE_IDS{fas_mixed} => 'Mixed recycling', + $SERVICE_IDS{garden} => 'Garden Waste', + $SERVICE_IDS{communal_food} => 'Food waste', + $SERVICE_IDS{communal_paper} => 'Paper and card', + $SERVICE_IDS{communal_mixed} => 'Mixed recycling', + $SERVICE_IDS{fas_paper} => 'Paper and card', + $SERVICE_IDS{schedule2_mixed} => 'Mixed recycling', + $SERVICE_IDS{schedule2_refuse} => 'Non-recyclable Refuse', + $SERVICE_IDS{deliver_bags} => '', ); return $service_name_override{$service->{ServiceId}} // ''; @@ -250,9 +235,9 @@ sub waste_munge_request_form_fields { } if ($id == $CONTAINERS{refuse_180}) { - $c->stash->{current_refuse_bin} = 180; + $c->stash->{current_refuse_bin} = $id; } elsif ($id == $CONTAINERS{refuse_240}) { - $c->stash->{current_refuse_bin} = 240; + $c->stash->{current_refuse_bin} = $id; @radio_options = ( { value => $CONTAINERS{refuse_180}, label => 'Smaller black rubbish bin', @@ -266,7 +251,7 @@ sub waste_munge_request_form_fields { }, ); } elsif ($id == $CONTAINERS{refuse_360}) { - $c->stash->{current_refuse_bin} = 360; + $c->stash->{current_refuse_bin} = $id; @radio_options = ( { value => $CONTAINERS{refuse_180}, label => '180L black rubbish bin ‘standard’', @@ -315,9 +300,7 @@ sub waste_request_form_first_next { $c->res->redirect($c->stash->{waste_features}{large_refuse_application_form} . '?uprn=' . $uprn); $c->detach; } else { - $data->{"container-$choice"} = 1; - $data->{"quantity-$choice"} = 1; - $data->{"removal-$choice"} = 1; + $self->waste_exchange_bin_setup_data($data, $choice); } return 'about_you'; }; @@ -325,6 +308,20 @@ sub waste_request_form_first_next { return 'removals'; } +# Set up container/quantity/removal for the form/summary page, +# but set replace to be used by the data munging +sub waste_exchange_bin_setup_data { + my ($self, $data, $choice) = @_; + my $c = $self->{c}; + my $bin = $c->stash->{current_refuse_bin}; + $data->{"container-$choice"} = 1; + $data->{"quantity-$choice"} = 1; + $data->{"replace-$choice"} = $bin; + $data->{"container-$bin"} = 1; + $data->{"removal-$bin"} = 1; + $data->{"replace-$bin"} = -1; # So it is ignored +} + =head2 waste_munge_request_form_pages We have a separate removal page, asking which bins need to be removed. @@ -335,7 +332,7 @@ sub waste_munge_request_form_pages { my ($self, $page_list, $field_list) = @_; my $c = $self->{c}; - if (($c->stash->{current_refuse_bin} || 0) == 180) { + if (($c->stash->{current_refuse_bin} || 0) == $CONTAINERS{refuse_180}) { $c->stash->{first_page} = 'how_many_exchange'; } @@ -424,7 +421,11 @@ sub waste_munge_request_form_data { my $to_remove = $data->{"removal-$id"} || 0; next unless $data->{$_} || ($id == $CONTAINERS{recycling_240} || $id == $CONTAINERS{recycling_box}); - if ($quantity - $to_remove > 0) { + if (my $replace = $data->{"replace-$id"}) { + if ($replace > -1) { + $new_data->{"container-$id-exchange"} = $replace; + } + } elsif ($quantity - $to_remove > 0) { $new_data->{"container-$id-deliver-$_"} = 1 for 1..($quantity-$to_remove); $new_data->{"container-$id-replace-$_"} = 1 @@ -455,18 +456,23 @@ sub waste_munge_request_data { my ($action_id, $reason_id); if ($action eq 'deliver') { $action_id = 1; # Deliver - $reason_id = 1; # Missing (or 4 New) + $reason_id = 1; # Missing } elsif ($action eq 'collect') { - $action_id = 2; # Collect - $reason_id = 3; # Change capacity + $action_id = 2; # Remove + $reason_id = 8; # Remove Containers } elsif ($action eq 'replace') { - $action_id = 3; # Replace - $reason_id = $c->get_param('exchange') ? 3 : 2; # Change capacity : Damaged + $action_id = '2::1'; # Replace + $reason_id = 4; # Damaged + } elsif ($action eq 'exchange') { + # $container_id is the new bin + $action_id = '2::1'; # Replace + my $old_bin = $data->{"container-$id"}; + $reason_id = $old_bin < $container_id ? 9 : 10; # Increase/Reduce Capacity } if ($action eq 'deliver') { $data->{title} = "Request $container delivery"; - } elsif ($action eq 'replace') { + } elsif ($action eq 'replace' || $action eq 'exchange') { $data->{title} = "Request $container replacement"; } else { $data->{title} = "Request $container collection"; @@ -482,10 +488,24 @@ sub waste_munge_request_data { } else { $c->set_param('Container_Type', $CONTAINERS{refuse_180}); } + } elsif ($action eq 'exchange') { + my $old_bin = $data->{"container-$id"}; + $c->set_param('Container_Type', join("::", $old_bin, $container_id)); } else { $c->set_param('Container_Type', $container_id); } + my $service_id; + my $services = $c->stash->{services}; + foreach my $s (keys %$services) { + my $containers = $services->{$s}{request_containers}; + foreach (@$containers) { + $service_id = $s if $_ eq $container_id; + } + } + $service_id = $SERVICE_IDS{domestic_refuse} if !$service_id && $action eq 'exchange'; + $c->set_param('service_id', $service_id); + my $costs = WasteWorks::Costs->new({ cobrand => $self }); if ($data->{payment}) { my $cost; @@ -547,4 +567,24 @@ sub bulky_allowed_property { sub bulky_collection_time { { hours => 6, minutes => 30 } } sub bulky_cancellation_cutoff_time { { hours => 6, minutes => 30, days_before => 0 } } +=head2 bulky_collection_window_start_date + +K&S have an 11pm cut-off for looking to book next day collections. + +=cut + +sub bulky_collection_window_start_date { + my ($self, $now) = @_; + my $start_date = $now->clone->truncate( to => 'day' )->add( days => 1 ); + # If past 11pm, push start date one day later + if ($now->hour >= 23) { + $start_date->add( days => 1 ); + } + return $start_date; +} + +sub bulky_location_text_prompt { + "Please tell us where you will place the items for collection (include any access codes the crew will need)"; +} + 1; diff --git a/perllib/FixMyStreet/Cobrand/Sutton.pm b/perllib/FixMyStreet/Cobrand/Sutton.pm index 61c30f1b7c7..82cff885c32 100644 --- a/perllib/FixMyStreet/Cobrand/Sutton.pm +++ b/perllib/FixMyStreet/Cobrand/Sutton.pm @@ -5,6 +5,7 @@ use utf8; use Moo; with 'FixMyStreet::Roles::Cobrand::Waste', 'FixMyStreet::Roles::Cobrand::KingstonSutton', + 'FixMyStreet::Roles::Cobrand::SLWP2', 'FixMyStreet::Roles::Cobrand::SCP'; use Digest::SHA qw(sha1_hex); @@ -17,42 +18,41 @@ sub council_name { return 'Sutton Council'; } sub council_url { return 'sutton'; } sub admin_user_domain { 'sutton.gov.uk' } -my %TASK_IDS = ( - domestic_refuse => 2238, - domestic_food => 2239, - domestic_paper => 2240, - domestic_mixed => 2241, - domestic_refuse_bag => 2242, - communal_refuse => 2243, - domestic_mixed_bag => 2246, - garden => 2247, - communal_food => 2248, - communal_paper => 2249, - communal_mixed => 2250, - domestic_paper_bag => 2632, - schedule2_mixed => 3571, - schedule2_refuse => 3576, - deliver_refuse_bags => 2256, - deliver_recycling_bags => 2257, +my %SERVICE_IDS = ( + domestic_refuse => 940, # 4394 + communal_refuse => 943, # 4407 + fas_refuse => 941, # 4395 + domestic_mixed => 944, # 4390 + communal_mixed => 947, # 4397 + fas_mixed => 945, # 4391 + domestic_paper => 948, # 4388 + communal_paper => 951, # 4396 + fas_paper => 949, # 4402 + domestic_food => 954, # 4389 + communal_food => 957, # 4403 + garden => 953, # 4410 + schedule2_refuse => 942, # 4409 + schedule2_mixed => 946, # 4398 + deliver_bags => 961, # 4427 4432 ); -lock_hash(%TASK_IDS); +lock_hash(%SERVICE_IDS); my %CONTAINERS = ( refuse_140 => 1, - refuse_180 => 35, - refuse_240 => 2, - refuse_360 => 3, - recycling_box => 16, - recycling_240 => 12, - recycling_blue_bag => 18, - paper_240 => 19, - paper_140 => 36, - paper_bag => 30, - food_indoor => 23, - food_outdoor => 24, - garden_240 => 26, - garden_140 => 27, - garden_sack => 28, + refuse_180 => 2, + refuse_240 => 3, + refuse_360 => 4, + recycling_box => 12, + recycling_240 => 15, + recycling_blue_bag => 22, + paper_240 => 27, + paper_140 => 26, + paper_bag => 34, + food_indoor => 43, + food_outdoor => 46, + garden_240 => 39, + garden_140 => 37, + garden_sack => 36, ); lock_hash(%CONTAINERS); @@ -89,8 +89,6 @@ sub waste_check_staff_payment_permissions { $c->stash->{staff_payments_allowed} = 'paye'; } -has lpi_value => ( is => 'ro', default => 'SUTTON' ); - sub waste_payment_ref_council_code { "LBS" } sub garden_collection_time { '6am' } @@ -99,7 +97,7 @@ sub waste_garden_allow_cancellation { 'staff' } sub waste_quantity_max { return ( - $TASK_IDS{garden} => 5, # Garden waste maximum + $SERVICE_IDS{garden} => 5, # Garden waste maximum ); } @@ -142,17 +140,17 @@ sub image_for_unit { return svg_container_bin('wheelie', '#8B5E3D'); } my $images = { - $TASK_IDS{domestic_refuse} => svg_container_bin('wheelie', '#8B5E3D'), - $TASK_IDS{domestic_food} => "$base/caddy-brown-large", - $TASK_IDS{domestic_paper} => svg_container_bin('wheelie', '#41B28A'), - $TASK_IDS{domestic_mixed} => "$base/box-green-mix", - $TASK_IDS{domestic_refuse_bag} => svg_container_sack('stripe', '#E83651'), - $TASK_IDS{communal_refuse} => svg_container_bin('communal', '#767472', '#333333'), - $TASK_IDS{domestic_mixed_bag} => svg_container_sack('stripe', '#4f4cf0'), - $TASK_IDS{communal_food} => svg_container_bin('wheelie', '#8B5E3D'), - $TASK_IDS{communal_paper} => svg_container_bin("wheelie", '#767472', '#00A6D2', 1), - $TASK_IDS{communal_mixed} => svg_container_bin('communal', '#41B28A'), - $TASK_IDS{domestic_paper_bag} => svg_container_sack('normal', '#d8d8d8'), + $SERVICE_IDS{domestic_refuse} => svg_container_bin('wheelie', '#8B5E3D'), + $SERVICE_IDS{domestic_food} => "$base/caddy-brown-large", + $SERVICE_IDS{domestic_paper} => svg_container_bin('wheelie', '#41B28A'), + $SERVICE_IDS{domestic_mixed} => "$base/box-green-mix", + $SERVICE_IDS{fas_refuse} => svg_container_sack('stripe', '#E83651'), + $SERVICE_IDS{communal_refuse} => svg_container_bin('communal', '#767472', '#333333'), + $SERVICE_IDS{fas_mixed} => svg_container_sack('stripe', '#4f4cf0'), + $SERVICE_IDS{communal_food} => svg_container_bin('wheelie', '#8B5E3D'), + $SERVICE_IDS{communal_paper} => svg_container_bin("wheelie", '#767472', '#00A6D2', 1), + $SERVICE_IDS{communal_mixed} => svg_container_bin('communal', '#41B28A'), + $SERVICE_IDS{fas_paper} => svg_container_sack('normal', '#d8d8d8'), }; return $images->{$service_id}; } @@ -160,28 +158,16 @@ sub image_for_unit { sub waste_containers { my $self = shift; return { - 4 => 'Refuse Blue Sack', - 5 => 'Refuse Black Sack', - 6 => 'Refuse Red Stripe Bag', - 18 => 'Mixed Recycling Blue Striped Bag', - 29 => 'Recycling Single Use Bag', - 21 => 'Paper & Card Reusable Bag', - 22 => 'Paper Sacks', - 30 => 'Paper & Card Recycling Clear Bag', - 7 => 'Communal Refuse bin (240L)', - 8 => 'Communal Refuse bin (360L)', - 9 => 'Communal Refuse bin (660L)', - 10 => 'Communal Refuse bin (1100L)', - 11 => 'Communal Refuse Chamberlain', - 33 => 'Communal Refuse bin (140L)', - 34 => 'Communal Refuse bin (1280L)', - 14 => 'Communal Recycling bin (660L)', - 15 => 'Communal Recycling bin (1100L)', - 25 => 'Communal Food bin (240L)', + 10 => 'Refuse Red Stripe Bag', + 22 => 'Mixed Recycling Blue Striped Bag', + 34 => 'Paper & Card Recycling Clear Bag', + 8 => 'Communal Refuse bin (1100L)', + 20 => 'Communal Recycling bin (1100L)', + 51 => 'Communal Food bin (240L)', $CONTAINERS{recycling_240} => 'Recycling bin (240L)', - 13 => 'Recycling bin (360L)', - 20 => 'Paper recycling bin (360L)', - 31 => 'Paper 55L Box', + 16 => 'Recycling bin (360L)', + 28 => 'Paper recycling bin (360L)', + 32 => 'Communal Paper bin (1100L)', $CONTAINERS{refuse_140} => 'Standard Brown General Waste Wheelie Bin (140L)', $CONTAINERS{refuse_240} => 'Larger Brown General Waste Wheelie Bin (240L)', $CONTAINERS{refuse_360} => 'Extra Large Brown General Waste Wheelie Bin (360L)', @@ -207,136 +193,26 @@ sub service_name_override { my ($self, $service) = @_; my %service_name_override = ( - $TASK_IDS{domestic_refuse} => 'Non-Recyclable Refuse', - $TASK_IDS{domestic_food} => 'Food Waste', - $TASK_IDS{domestic_paper} => 'Paper & Card', - $TASK_IDS{domestic_mixed} => 'Mixed Recycling (Cans, Plastics & Glass)', - $TASK_IDS{domestic_refuse_bag} => 'Non-Recyclable Refuse', - $TASK_IDS{communal_refuse} => 'Non-Recyclable Refuse', - $TASK_IDS{domestic_mixed_bag} => 'Mixed Recycling (Cans, Plastics & Glass)', - $TASK_IDS{garden} => 'Garden Waste', - $TASK_IDS{communal_food} => 'Food Waste', - $TASK_IDS{communal_paper} => 'Paper & Card', - $TASK_IDS{communal_mixed} => 'Mixed Recycling (Cans, Plastics & Glass)', - $TASK_IDS{domestic_paper_bag} => 'Paper & Card', - $TASK_IDS{schedule2_mixed} => 'Mixed Recycling (Cans, Plastics & Glass)', - $TASK_IDS{schedule2_refuse} => 'Non-Recyclable Refuse', - $TASK_IDS{deliver_refuse_bags} => '', - $TASK_IDS{deliver_recycling_bags} => '', + $SERVICE_IDS{domestic_refuse} => 'Non-Recyclable Refuse', + $SERVICE_IDS{domestic_food} => 'Food Waste', + $SERVICE_IDS{domestic_paper} => 'Paper & Card', + $SERVICE_IDS{domestic_mixed} => 'Mixed Recycling (Cans, Plastics & Glass)', + $SERVICE_IDS{fas_refuse} => 'Non-Recyclable Refuse', + $SERVICE_IDS{communal_refuse} => 'Non-Recyclable Refuse', + $SERVICE_IDS{fas_mixed} => 'Mixed Recycling (Cans, Plastics & Glass)', + $SERVICE_IDS{garden} => 'Garden Waste', + $SERVICE_IDS{communal_food} => 'Food Waste', + $SERVICE_IDS{communal_paper} => 'Paper & Card', + $SERVICE_IDS{communal_mixed} => 'Mixed Recycling', + $SERVICE_IDS{fas_paper} => 'Paper & Card', + $SERVICE_IDS{schedule2_mixed} => 'Mixed Recycling (Cans, Plastics & Glass)', + $SERVICE_IDS{schedule2_refuse} => 'Non-Recyclable Refuse', + $SERVICE_IDS{deliver_bags} => '', ); return $service_name_override{$service->{ServiceId}} // ''; } -sub waste_cc_munge_form_details { - my ($self, $c) = @_; - - $c->stash->{payment_amount} = $c->stash->{amount} * 100; - - my $url = $c->uri_for_action( - '/waste/pay_complete', [ - $c->stash->{report}->id, - $c->stash->{report}->get_extra_metadata('redirect_id') - ]); - - $c->stash->{redirect_url} = $url; - - my ($pspid, $sha_passphrase); - if ($c->stash->{report}->category eq 'Bulky collection') { - $sha_passphrase = $c->stash->{payment_details}->{sha_passphrase_bulky}; - $pspid = $c->stash->{payment_details}->{pspid_bulky}; - } else { - $sha_passphrase = $c->stash->{payment_details}->{sha_passphrase}; - $pspid = $c->stash->{payment_details}->{pspid}; - } - $c->stash->{pspid} = $pspid; - - my $form_params = { - 'PSPID' => $pspid, - 'ORDERID' => $c->stash->{reference}, - 'AMOUNT' => $c->stash->{payment_amount}, - 'CURRENCY' => 'GBP', - 'LANGUAGE' => 'en_GB', - 'CN' => $c->stash->{first_name} . " " . $c->stash->{last_name}, - 'EMAIL' => $c->stash->{email}, - 'OWNERZIP' => $c->stash->{postcode}, - 'OWNERADDRESS' => $c->stash->{address1}, - 'OWNERCTY' => 'UK', - 'OWNERTOWN' => $c->stash->{town}, - 'OWNERTELNO' => $c->stash->{phone}, - 'ACCEPTURL' => $url, - 'DECLINEURL' => $url, - 'EXCEPTIONURL' => $url, - 'CANCELURL' => $url, - }; - - my $sha = $self->garden_waste_generate_sig( $form_params, $sha_passphrase ); - $c->stash->{cc_sha} = $sha; -} - -sub garden_waste_generate_sig { - my ($self, $params, $passphrase) = @_; - - my $str = ""; - for my $param ( sort { uc($a) cmp uc($b) } keys %$params ) { - next unless defined $params->{$param} && length $params->{$param}; # Want any 0s - $str .= uc($param) . "=" . encode_utf8($params->{$param}) . $passphrase; - } - - my $sha = sha1_hex( $str ); - return uc $sha; -} - -sub waste_cc_has_redirect { - my ($self, $p) = @_; - return 1 if $p->category eq 'Request new container'; - return 0; -} - -around garden_cc_check_payment_status => sub { - my ($orig, $self, $c, $p) = @_; - - if ($p->category eq 'Request new container') { - # Call the SCP role code - return $self->$orig($c, $p); - } - - # Otherwise, the EPDQ code - - my $passphrase; - if ($p->category eq 'Bulky collection') { - $passphrase = $self->feature('payment_gateway')->{sha_out_passphrase_bulky}; - } else { - $passphrase = $self->feature('payment_gateway')->{sha_out_passphrase}; - } - - if ( $passphrase ) { - my $sha = $c->get_param('SHASIGN'); - - my %params = %{$c->req->params}; - delete $params{SHASIGN}; - my $check = $self->garden_waste_generate_sig( \%params, $passphrase ); - if ( $check ne $sha ) { - $c->stash->{error} = "Failed security check"; - return undef; - } - } - - my $status = $c->get_param('STATUS'); - if ( $status == 9 ) { - return $c->get_param('PAYID'); - } else { - my $error = "Unknown error"; - if ( $status == 1 ) { - $error = "Payment cancelled"; - } elsif ( $status == 2 ) { - $error = "Payment declined"; - } - $c->stash->{error} = $error; - return undef; - } -}; - sub waste_request_single_radio_list { 1 } =head2 waste_munge_request_form_fields @@ -433,37 +309,52 @@ sub waste_munge_request_data { my $reason = $data->{request_reason} || ''; my $nice_reason = $c->stash->{label_for_field}->($form, 'request_reason', $reason); + my $service_id; + my $services = $c->stash->{services}; + foreach my $s (keys %$services) { + my $containers = $services->{$s}{request_containers}; + foreach (@$containers) { + $service_id = $s if $_ eq $id; + } + } + $c->set_param('service_id', $service_id); + my ($action_id, $reason_id); + my $id_to_remove; if ($reason eq 'damaged') { - $action_id = 3; # Replace - $reason_id = 2; # Damaged + $action_id = '2::1'; # Remove/Deliver + $reason_id = '4::4'; # Damaged + $id_to_remove = $id; } elsif ($reason eq 'missing') { $action_id = 1; # Deliver $reason_id = 1; # Missing } elsif ($reason eq 'new_build') { $action_id = 1; # Deliver - $reason_id = 4; # New + $reason_id = 6; # New Property } elsif ($reason eq 'more') { $action_id = 1; # Deliver - $reason_id = 3; # Change capacity + $reason_id = 9; # Increase capacity } elsif ($reason eq 'change_capacity') { - $action_id = '2::1'; - $reason_id = '3::3'; + $action_id = '2::1'; # Remove/Deliver if ($id == $CONTAINERS{refuse_140}) { - $id = $CONTAINERS{refuse_240} . '::' . $CONTAINERS{refuse_140}; + $reason_id = '10::10'; # Reduce Capacity + $id_to_remove = $CONTAINERS{refuse_240}; } elsif ($id == $CONTAINERS{refuse_240}) { - if ($c->stash->{quantities}{+$CONTAINERS{refuse_360}}) { - $id = $CONTAINERS{refuse_360} . '::' . $CONTAINERS{refuse_240}; + if ($c->stash->{quantities}{$CONTAINERS{refuse_360}}) { + $reason_id = '10::10'; # Reduce Capacity + $id_to_remove = $CONTAINERS{refuse_360}; } else { - $id = $CONTAINERS{refuse_140} . '::' . $CONTAINERS{refuse_240}; + $reason_id = '9::9'; # Increase Capacity + $id_to_remove = $CONTAINERS{refuse_140}; } } elsif ($id == $CONTAINERS{paper_240}) { - $id = $CONTAINERS{paper_140} . '::' . $CONTAINERS{paper_240}; + $reason_id = '9::9'; # Increase Capacity + $id_to_remove = $CONTAINERS{paper_140}; } } else { # No reason, must be a bag $action_id = 1; # Deliver - $reason_id = 3; # Change capacity + $reason_id = 9; # Increase capacity $nice_reason = "Additional bag required"; } @@ -474,8 +365,14 @@ sub waste_munge_request_data { } else { $data->{title} = "Request new $container"; } - $data->{detail} = "Quantity: $quantity\n\n$address"; + $data->{detail} = $address; $data->{detail} .= "\n\nReason: $nice_reason" if $nice_reason; + $data->{detail} .= "\n\n1x $container to deliver"; + if ($id_to_remove) { + my $container_removed = $c->stash->{containers}{$id_to_remove}; + $data->{detail} .= "\n\n1x $container_removed to collect"; + $id = $id_to_remove . '::' . $id if $id_to_remove != $id; + } $c->set_param('Action', join('::', ($action_id) x $quantity)); $c->set_param('Reason', join('::', ($reason_id) x $quantity)); @@ -531,4 +428,24 @@ sub bulky_allowed_property { sub bulky_collection_time { { hours => 6, minutes => 0 } } sub bulky_cancellation_cutoff_time { { hours => 6, minutes => 0, days_before => 0 } } +=head2 bulky_collection_window_start_date + +K&S have an 11pm cut-off for looking to book next day collections. + +=cut + +sub bulky_collection_window_start_date { + my ($self, $now) = @_; + my $start_date = $now->clone->truncate( to => 'day' )->add( days => 1 ); + # If past 11pm, push start date one day later + if ($now->hour >= 23) { + $start_date->add( days => 1 ); + } + return $start_date; +} + +sub bulky_location_text_prompt { + "Please tell us where you will place the items for collection (the bulky waste collection crews are different to the normal round collection crews and will not know any access codes to your property, so please include access codes here if appropriate)"; +} + 1; diff --git a/perllib/FixMyStreet/Roles/Cobrand/Echo.pm b/perllib/FixMyStreet/Roles/Cobrand/Echo.pm index 2a35ed39aa7..ad271fd668a 100644 --- a/perllib/FixMyStreet/Roles/Cobrand/Echo.pm +++ b/perllib/FixMyStreet/Roles/Cobrand/Echo.pm @@ -238,7 +238,8 @@ sub bin_services_for_address { $garden = 1; $garden_due = $self->waste_sub_due($schedules->{end_date}); $garden_overdue = $schedules if $_->{expired}; - my $data = Integrations::Echo::force_arrayref($servicetask->{Data}, 'ExtensibleDatum'); + my $data_obj = $self->moniker eq 'sutton' || $self->moniker eq 'kingston' ? $_->{Service} : $servicetask; + my $data = Integrations::Echo::force_arrayref($data_obj->{Data}, 'ExtensibleDatum'); foreach (@$data) { next unless $_->{DatatypeName} eq $self->garden_echo_container_name; ($garden_bins, $garden_sacks, $garden_cost, $garden_container) = $self->garden_container_data_extract($_, $containers, $quantities, $schedules); diff --git a/perllib/FixMyStreet/Roles/Cobrand/KingstonSutton.pm b/perllib/FixMyStreet/Roles/Cobrand/KingstonSutton.pm index 834ce8b970d..d5f1d0aba83 100644 --- a/perllib/FixMyStreet/Roles/Cobrand/KingstonSutton.pm +++ b/perllib/FixMyStreet/Roles/Cobrand/KingstonSutton.pm @@ -9,7 +9,6 @@ FixMyStreet::Roles::Cobrand::KingstonSutton - shared code for Kingston and Sutto package FixMyStreet::Roles::Cobrand::KingstonSutton; use Moo::Role; -with 'FixMyStreet::Roles::Cobrand::SLWP'; use FixMyStreet::App::Form::Waste::Garden::Sacks; use FixMyStreet::App::Form::Waste::Garden::Sacks::Renew; @@ -181,22 +180,6 @@ sub waste_cc_payment_sale_ref { return "GGW" . $p->get_extra_field_value('uprn'); } -=head2 bulky_collection_window_start_date - -K&S have an 11pm cut-off for looking to book next day collections. - -=cut - -sub bulky_collection_window_start_date { - my ($self, $now) = @_; - my $start_date = $now->clone->truncate( to => 'day' )->add( days => 1 ); - # If past 11pm, push start date one day later - if ($now->hour >= 23) { - $start_date->add( days => 1 ); - } - return $start_date; -} - =head2 Dashboard export The CSV export includes all reports, including unconfirmed and hidden, and is @@ -262,9 +245,9 @@ sub dashboard_export_problems_add_columns { payment => $fields{payment}, pro_rata => $fields{pro_rata}, admin_fee => $fields{admin_fee}, - container => $fields{Subscription_Details_Containers}, + container => $fields{Paid_Container_Type} || $fields{Subscription_Details_Containers}, current_bins => $fields{current_containers}, - quantity => $fields{Subscription_Details_Quantity}, + quantity => $fields{Paid_Container_Quantity} || $fields{Subscription_Details_Quantity}, }; }); } diff --git a/perllib/FixMyStreet/Roles/Cobrand/SLWP.pm b/perllib/FixMyStreet/Roles/Cobrand/SLWP.pm index e69d2acaf14..fb63d78eaeb 100644 --- a/perllib/FixMyStreet/Roles/Cobrand/SLWP.pm +++ b/perllib/FixMyStreet/Roles/Cobrand/SLWP.pm @@ -745,5 +745,4 @@ sub bulky_location_photo_prompt { 'Help us by attaching a photo of where the items will be left for collection.'; } - 1; diff --git a/perllib/FixMyStreet/Roles/Cobrand/SLWP2.pm b/perllib/FixMyStreet/Roles/Cobrand/SLWP2.pm new file mode 100644 index 00000000000..714d0865c6f --- /dev/null +++ b/perllib/FixMyStreet/Roles/Cobrand/SLWP2.pm @@ -0,0 +1,711 @@ +=head1 NAME + +FixMyStreet::Roles::Cobrand::SLWP2 - shared code for Kingston and Sutton WasteWorks, new Echo + +=head1 DESCRIPTION + +=cut + +package FixMyStreet::Roles::Cobrand::SLWP2; + +use Moo::Role; +with 'FixMyStreet::Roles::Cobrand::Echo'; +with 'FixMyStreet::Roles::Cobrand::BulkyWaste'; + +use Integrations::Echo; +use Hash::Util qw(lock_hash); +use JSON::MaybeXS; +use LWP::Simple; +use MIME::Base64; + +sub waste_staff_choose_payment_method { 1 } +around waste_cheque_payments => sub { + my ($orig, $self) = @_; + return $self->{c}->stash->{staff_payments_allowed}; +}; + +sub waste_event_state_map { + return { + New => { New => 'confirmed' }, + Pending => { + Unallocated => 'investigating', + #'Allocated to Crew' => 'action scheduled', + #Accepted => 'action scheduled', + }, + Closed => { + Closed => 'fixed - council', + Completed => 'fixed - council', + 'Not Completed' => 'unable to fix', + 'Partially Completed' => 'closed', + Rejected => 'closed', + }, + Cancelled => { + Cancelled => 'cancelled', + }, + }; +} + +my %SERVICE_IDS = ( + kingston => { + domestic_refuse => 966, # 4394 + communal_refuse => 969, # 4407 + fas_refuse => 967, # 4395 + domestic_mixed => 970, # 4390 + communal_mixed => 973, # 4397 + fas_mixed => 971, # 4391 + domestic_paper => 974, # 4388 + communal_paper => 977, # 4396 + fas_paper => 975, # 4402 + domestic_food => 980, # 4389 + communal_food => 983, # 4403 + garden => 979, # 4410 + bulky => 986, # 4536 + schedule2_refuse => 968, # 4409 + schedule2_mixed => 972, # 4398 + }, + sutton => { + domestic_refuse => 940, # 4394 + communal_refuse => 943, # 4407 + fas_refuse => 941, # 4395 + domestic_mixed => 944, # 4390 + communal_mixed => 947, # 4397 + fas_mixed => 945, # 4391 + domestic_paper => 948, # 4388 + communal_paper => 951, # 4396 + fas_paper => 949, # 4402 + domestic_food => 954, # 4389 + communal_food => 957, # 4403 + garden => 953, # 4410 + bulky => 960, # 4536 + schedule2_refuse => 942, # 4409 + schedule2_mixed => 946, # 4398 + } +); +lock_hash(%SERVICE_IDS); + +my %EVENT_TYPE_IDS = ( + missed => 3145, + missed_assisted => 3146, + request => 3129, + garden_add => 3159, + garden_amend => 3163, + bulky => 3130, +); +lock_hash(%EVENT_TYPE_IDS); + +my %CONTAINERS = ( + refuse_140 => 1, + refuse_180 => 2, + refuse_240 => 3, + refuse_360 => 4, + recycling_box => 12, + recycling_240 => 15, + recycling_blue_bag => 22, + paper_240 => 27, + paper_140 => 26, + food_indoor => 43, + food_outdoor => 46, + garden_240 => 39, + garden_140 => 37, + garden_sack => 36, +); +lock_hash(%CONTAINERS); + +my %GARDEN_CONTAINER_IDS = ( + subscription => { + bin240 => 1, + bin140 => 2, + sack => 4, + }, + delivery => { + bin240 => 2, + bin140 => 3, + sack => 5, + }, +); +lock_hash(%GARDEN_CONTAINER_IDS); + +my %GARDEN_QUANTITIES = ( + subscription => { + 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, + sack => 11, + }, + # IDs in Echo for this are one more than the quantity being requested + delivery => { + 1 => 2, 2 => 3, 3 => 4, 4 => 5, 5 => 6, 6 => 7, 7 => 8, 8 => 9, 9 => 10, 10 => 11, + sack => 12, + }, +); + +sub garden_service_id { $SERVICE_IDS{$_[0]->moniker}{garden} } + +sub waste_service_to_containers { () } + +sub garden_subscription_event_id { $EVENT_TYPE_IDS{garden_add} } + +sub waste_show_garden_modify { + my ($self, $unit) = @_; + return 1 if $self->moniker eq 'kingston'; + return $unit->{garden_sacks} ? 0 : 1; +} + +sub waste_relevant_serviceunits { + my ($self, $result) = @_; + my @rows; + my $service_ids = $SERVICE_IDS{$self->moniker}; + foreach (@$result) { + my $servicetask = $self->_get_current_service_task($_) or next; + + $self->{c}->stash->{schedule2_property} = 1 if $_->{ServiceId} == $service_ids->{schedule2_refuse} || $_->{ServiceId} == $service_ids->{schedule2_mixed}; + + my $service_name = $self->service_name_override({ ServiceId => $_->{ServiceId} }); + next unless $service_name; + + push @rows, { + Id => $_->{Id}, + ServiceId => $_->{ServiceId}, + ServiceTask => $servicetask, + Service => $_, + Schedules => _parse_schedules($servicetask), + }; + } + return @rows; +} + +sub waste_extra_service_info_all_results { + my ($self, $property, $result) = @_; + + my $cfg = $self->feature('echo'); + my $service_ids = $SERVICE_IDS{$self->moniker}; + + if (!(@$result && grep { $_->{ServiceId} == $service_ids->{garden} } @$result)) { + # No garden collection possible + $self->{c}->stash->{waste_features}->{garden_disabled} = 1; + } + + if (@$result && $cfg->{bulky_service_id} && grep { $_->{ServiceId} == $cfg->{bulky_service_id} } @$result) { + $property->{has_bulky_service} = 1; + } + + $property->{has_no_services} = scalar @$result == 0; + + foreach (@$result) { + my $data = Integrations::Echo::force_arrayref($_->{Data}, 'ExtensibleDatum'); + foreach (@$data) { + $self->{c}->stash->{assisted_collection} = 1 if $_->{DatatypeName} eq "Assisted Collection" && $_->{Value}; + } + } +} + +sub waste_extra_service_info { + my ($self, $property, @rows) = @_; + my $service_ids = $SERVICE_IDS{$self->moniker}; + + foreach (@rows) { + my $service_id = $_->{ServiceId}; + if ($service_id == $service_ids->{fas_refuse}) { + $self->{c}->stash->{slwp_garden_sacks} = 1; + } elsif ($service_id == $service_ids->{domestic_refuse}) { + $property->{domestic_refuse_bin} = 1; + } + $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}; + + # Check for time-banded property + my $schedules = $_->{Schedules}; + if ($self->moniker eq 'sutton' && $schedules->{next}{schedule}) { + my $round_group_name = $schedules->{next}{schedule}{Allocation}{RoundGroupName} || ''; + $self->{c}->stash->{property_time_banded} = 1 if $round_group_name eq "SF Night Time Economy"; + } + + } +} + +sub waste_service_containers { + my ($self, $service) = @_; + my $service_ids = $SERVICE_IDS{$self->moniker}; + + my $waste_containers_no_request = $self->_waste_containers_no_request; + + my $unit = $service->{Service}; + my $service_id = $service->{ServiceId}; + my $service_name = $self->service_name_override($service); + my $schedules = $service->{Schedules}; + + my $data = Integrations::Echo::force_arrayref($unit->{Data}, 'ExtensibleDatum'); + my ($containers, $request_max); + foreach (@$data) { + next 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}; + my $moredata = Integrations::Echo::force_arrayref($_->{ChildData}, 'ExtensibleDatum'); + my ($container, $quantity) = (0, 0); + foreach (@$moredata) { + $container = $_->{Value} if $_->{DatatypeName} eq 'Container Type'; + $quantity = $_->{Value} if $_->{DatatypeName} eq 'Container Quantity'; + } + + next if $waste_containers_no_request->{$container}; + + next if $container == $CONTAINERS{recycling_blue_bag} && $schedules->{description} !~ /fortnight|every other/; # Blue stripe bag on a weekly collection + + if ($container && $quantity) { + push @$containers, $container; + next if $container == $CONTAINERS{garden_sack}; + + $self->{c}->stash->{quantities}->{$container} = $quantity; + + if ($self->moniker eq 'kingston') { + if ($container == $CONTAINERS{food_outdoor} || $container == $CONTAINERS{paper_240} || $container == $CONTAINERS{recycling_240}) { + $request_max->{$container} = 3; + } elsif ($container == $CONTAINERS{recycling_box}) { + $request_max->{$container} = 5; + } else { + $request_max->{$container} = 1; + } + } else { + # The most you can request is one + $request_max->{$container} = 1; + } + + if ($self->moniker eq 'sutton') { + if ($container == $CONTAINERS{refuse_140} || $container == $CONTAINERS{refuse_360}) { + push @$containers, $CONTAINERS{refuse_240}; + $request_max->{+$CONTAINERS{refuse_240}} = 1; + } elsif ($container == $CONTAINERS{refuse_240}) { + push @$containers, $CONTAINERS{refuse_140}; + $request_max->{+$CONTAINERS{refuse_140}} = 1; + } elsif ($container == $CONTAINERS{paper_140}) { + $request_max->{+$CONTAINERS{paper_240}} = 1; + # Swap 140 for 240 in container list + @$containers = map { $_ == $CONTAINERS{paper_140} ? $CONTAINERS{paper_240} : $_ } @$containers; + } + } + } + } + + if ($service_name =~ /Food/ && !$self->{c}->stash->{quantities}->{+$CONTAINERS{food_indoor}}) { + # Can always request a food caddy + push @$containers, $CONTAINERS{food_indoor}; # Food waste bin (kitchen) + $request_max->{+$CONTAINERS{food_indoor}} = 1; + } + if ($self->moniker eq 'kingston' && grep { $_ == $CONTAINERS{recycling_box} } @$containers) { + # Can request a bin if you have a box + push @$containers, $CONTAINERS{recycling_240}; + $request_max->{+$CONTAINERS{recycling_240}} = 3; + } + + return ($containers, $request_max); +} + +sub missed_event_types { return { + $EVENT_TYPE_IDS{request} => 'request', + $EVENT_TYPE_IDS{missed} => 'missed', + $EVENT_TYPE_IDS{missed_assisted} => 'missed', + $EVENT_TYPE_IDS{bulky} => 'bulky', +} } + +sub waste_munge_report_data { + my ($self, $id, $data) = @_; + + my $c = $self->{c}; + + my $booking_report; + if ($c->get_param('original_booking_id')) { + $booking_report = FixMyStreet::DB->resultset("Problem")->find({ id => $c->get_param('original_booking_id') }); + }; + my $address = $c->stash->{property}->{address}; + my $cfg = $self->feature('echo'); + my $service = $c->stash->{services}{$id}{service_name}; + if ($id == $cfg->{bulky_service_id}) { + $service = 'bulky collection'; + } + if ($c->get_param('additional') && $c->stash->{is_staff}) { + $data->{category} = 'Request additional collection'; + $data->{title} = "Request additional $service collection"; + } else { + if ($c->stash->{assisted_collection}) { + $data->{category} = 'Report missed assisted collection'; + } + $data->{title} = "Report missed $service"; + } + $data->{detail} = "$data->{title}\n\n$address"; + if ($booking_report) { + $c->set_param('Exact_Location', $booking_report->get_extra_field_value('Exact_Location')); + $c->set_param('Original_Event_ID', $booking_report->external_id); + } + $c->set_param('Notes', $data->{extra_detail}) if $data->{extra_detail}; + $c->set_param('service_id', $id); +} + +# Garden waste + +sub garden_service_name { 'garden waste collection service' } +sub garden_echo_container_name { 'Container Details' } + +sub garden_container_data_extract { + my ($self, $data, $containers, $quantities, $schedules) = @_; + # Assume garden will only have one container data + my $garden_container = $containers->[0]; + my $costs = WasteWorks::Costs->new({ cobrand => $self }); + # Have to pass end date in because we're currently creating the services stash + if ($garden_container == $CONTAINERS{garden_sack}) { + my $garden_cost = $costs->sacks_renewal(1, $schedules->{end_date}) / 100; + return (undef, 1, $garden_cost, $garden_container); + } else { + my $garden_bins = $quantities->{$containers->[0]}; + my $garden_cost = $costs->bins_renewal($garden_bins, $schedules->{end_date}) / 100; + return ($garden_bins, 0, $garden_cost, $garden_container); + } +} + +# We don't have overdue renewals here +sub waste_sub_overdue { 0 } + +sub alternative_backend_field_names { + my ($self, $field) = @_; + my %alternative_name = ( + 'Subscription_End_Date' => 'End_Date', + ); + return $alternative_name{$field}; +} + +sub waste_garden_sub_params { + my ($self, $data, $type) = @_; + my $c = $self->{c}; + + my $service = $self->garden_current_subscription; + my $choice = $data->{container_choice} || ''; + my $existing = $service ? $service->{garden_container} : undef; + $existing = $data->{transfer_bin_type} if $data->{transfer_bin_type}; + my ($container_sub, $container_deliver); + if ($choice) { + $container_sub = $GARDEN_CONTAINER_IDS{subscription}{$choice}; + $container_deliver = $GARDEN_CONTAINER_IDS{delivery}{$choice}; + } elsif ($existing) { + my $key = { + $CONTAINERS{garden_sack} => 'sack', + $CONTAINERS{garden_140} => 'bin140', + $CONTAINERS{garden_240} => 'bin240', + }->{$existing}; + $container_sub = $GARDEN_CONTAINER_IDS{subscription}{$key}; + $container_deliver = $GARDEN_CONTAINER_IDS{delivery}{$key}; + } + $container_sub ||= $GARDEN_CONTAINER_IDS{subscription}{bin240}; + $container_deliver ||= $GARDEN_CONTAINER_IDS{delivery}{bin240}; + + $c->set_param('Paid_Container_Type', $container_sub); + if ($container_sub == $GARDEN_CONTAINER_IDS{subscription}{sack}) { + $c->set_param('Paid_Container_Quantity', $GARDEN_QUANTITIES{subscription}{sack}); + } elsif ($data->{bins_wanted}) { + $c->set_param('Paid_Container_Quantity', $GARDEN_QUANTITIES{subscription}{$data->{bins_wanted}}); + } + + if ( $data->{new_bins} && $data->{new_bins} > 0) { + $c->set_param('Container_Type', $container_deliver); + if ($container_deliver == $GARDEN_CONTAINER_IDS{delivery}{sack}) { + $c->set_param('Quantity', $GARDEN_QUANTITIES{delivery}{sack}); + } else { + my $num = abs($data->{new_bins}); + $c->set_param('Quantity', $GARDEN_QUANTITIES{delivery}{$num}); + } + } +} + +sub waste_garden_mod_params { + my ($self, $data) = @_; + my $c = $self->{c}; + + my $service = $self->garden_current_subscription; + my $existing = $service->{garden_container}; + if ($existing != $CONTAINERS{garden_sack}) { + $data->{category} = 'Amend Garden Subscription'; + my $key = { + $CONTAINERS{garden_140} => 'bin140', + $CONTAINERS{garden_240} => 'bin240', + }->{$existing}; + my $container_sub = $GARDEN_CONTAINER_IDS{subscription}{$key}; + my $container_deliver = $GARDEN_CONTAINER_IDS{delivery}{$key}; + + $c->set_param('Additional_Collection_Container_Type', $container_sub); + $c->set_param('Additional_Container_Quantity', $GARDEN_QUANTITIES{subscription}{$data->{new_bins}}); + $c->set_param('Container_Ordered_Type', $container_deliver); + $c->set_param('Container_Ordered_Quantity', $GARDEN_QUANTITIES{delivery}{$data->{new_bins}}); + } +} + +sub waste_garden_subscribe_form_setup { + my ($self) = @_; + my $c = $self->{c}; + if ($c->stash->{slwp_garden_sacks}) { + $c->stash->{form_class} = 'FixMyStreet::App::Form::Waste::Garden::Sacks'; + } +} + +sub waste_garden_renew_form_setup { + my ($self) = @_; + my $c = $self->{c}; + if ($c->stash->{slwp_garden_sacks}) { + $c->stash->{form_class} = 'FixMyStreet::App::Form::Waste::Garden::Sacks::Renew'; + my $service = $c->cobrand->garden_current_subscription; + $c->stash->{first_page} = 'sacks_choice'; + } +} + +=item * When a garden subscription is sent to Echo, we include payment details + +=cut + +sub open311_extra_data_include { + my ($self, $row, $h) = @_; + + my $open311_only = [ + #{ name => 'email', value => $row->user->email } + ]; + + if ( $row->category eq 'Garden Subscription' ) { + if ( $row->get_extra_metadata('contributed_as') && $row->get_extra_metadata('contributed_as') eq 'anonymous_user' ) { + push @$open311_only, { name => 'contributed_as', value => 'anonymous_user' }; + } + + my $ref = $row->get_extra_field_value('PaymentCode') || $row->get_extra_metadata('chequeReference'); + push @$open311_only, { name => 'Transaction_Number', value => $ref } if $ref; + + my $payment = $row->get_extra_field_value('pro_rata') || $row->get_extra_field_value('payment'); + my $admin_fee = $row->get_extra_field_value('admin_fee'); + $payment += $admin_fee if $admin_fee; + if ($payment) { + my $amount = sprintf( '%.2f', $payment / 100 ); + push @$open311_only, { name => 'Payment_Amount', value => $amount }; + } + } + + return $open311_only; +} + +=item * If Echo errors, we try and deal with standard issues - a renewal on an expired subscription, or a duplicate event + +=cut + +sub open311_post_send { + my ($self, $row, $h, $sender) = @_; + my $error = $sender->error; + my $db = FixMyStreet::DB->schema->storage; + $db->txn_do(sub { + my $row2 = FixMyStreet::DB->resultset('Problem')->search({ id => $row->id }, { for => \'UPDATE' })->single; + if ($error =~ /Cannot renew this property, a new request is required/ && $row2->title eq "Garden Subscription - Renew") { + # Was created as a renewal, but due to DD delay has now expired. Switch to new subscription + $row2->title("Garden Subscription - New"); + $row2->update_extra_field({ name => "Request_Type", value => $self->waste_subscription_types->{New} }); + $row2->update; + $row->discard_changes; + } elsif ($error =~ /Missed Collection event already open for the property/) { + $row2->state('duplicate'); + $row2->update; + $row->discard_changes; + } elsif ($error =~ /Selected reservations expired|Invalid reservation reference/) { + $self->bulky_refetch_slots($row2); + $row->discard_changes; + } elsif ($error =~ /Duplicate Event! Original eventID: (\d+)/) { + my $id = $1; + my $cfg = $self->feature('echo'); + my $echo = Integrations::Echo->new(%$cfg); + my $event = $echo->GetEvent($id, 'Id'); + $row2->external_id($event->{Guid}); + $sender->success(1); + $row2->update; + $row->discard_changes; + } + }); +} + +=item * Look for completion photos on updates, and ignore "Not Completed" without a resolution code + +=cut + +sub open311_waste_update_extra { + my ($self, $cfg, $event) = @_; + + # Could have got here with a full event (pull) or subset (push) + if (!$event->{Data}) { + $event = $cfg->{echo}->GetEvent($event->{Guid}); + } + my $data = Integrations::Echo::force_arrayref($event->{Data}, 'ExtensibleDatum'); + my @media; + foreach (@$data) { + if ($_->{DatatypeName} eq 'Post Collection Photo' || $_->{DatatypeName} eq 'Pre Collection Photo') { + my $value = decode_base64($_->{Value}); + my $type = FixMyStreet::PhotoStorage->detect_type($value); + push @media, "data:image/$type,$value"; + } + } + + my $override_status; + my $event_type = $cfg->{event_types}{$event->{EventTypeId}}; + my $state_id = $event->{EventStateId}; + my $resolution_id = $event->{ResolutionCodeId} || ''; + my $description = $event_type->{states}{$state_id}{name} || ''; + if ($description eq 'Not Completed' && !$resolution_id) { + $override_status = ""; + } + + return ( + @media ? ( media_url => \@media ) : (), + defined $override_status ? (status => $override_status ) : (), + ); +} + +=head2 Bulky waste collection + +SLWP looks 8 weeks ahead for collection dates, and cancels by sending an +update, not a new report. It sends the event to the backend before collecting +payment, and does not refund on cancellations. It has a hard-coded list of +property types allowed to book collections. + +=cut + +sub waste_bulky_missed_blocked_codes { + return { + # Partially completed + 12399 => { + 507 => 'Not all items presented', + 380 => 'Some items too heavy', + }, + # Completed + 12400 => { + 606 => 'More items presented than booked', + }, + # Not Completed + 12401 => { + 460 => 'Nothing out', + 379 => 'Item not as described', + 100 => 'No access', + 212 => 'Too heavy', + 473 => 'Damage on site', + 234 => 'Hazardous waste', + }, + }; +} + +sub bulky_collection_window_days { 56 } + +sub bulky_cancel_by_update { 1 } +sub bulky_send_before_payment { 1 } +sub bulky_show_location_field_mandatory { 1 } + +sub bulky_can_refund { 0 } + +sub bulky_allowed_property { + my ( $self, $property ) = @_; + + return if $property->{has_no_services}; + my $cfg = $self->feature('echo'); + + my $type = $property->{type_id} || 0; + my $valid_type = grep { $_ == $type } @{ $cfg->{bulky_address_types} || [] }; + my $domestic_farm = $type != 7 || $property->{domestic_refuse_bin}; + return $self->bulky_enabled && $valid_type && $domestic_farm; +} + +sub collection_date { + my ($self, $p) = @_; + return $self->_bulky_date_to_dt($p->get_extra_field_value('Collection_Date_-_Bulky_Items') || $p->get_extra_field_value('Collection_Date')); +} + +sub bulky_free_collection_available { 0 } + +sub bulky_hide_later_dates { 1 } + +=head2 Sending to Echo + +We use the reserved slot GUID and reference, +and the provided date/location information. +Items are sent through with their notes as individual entries + +=cut + +sub waste_munge_bulky_data { + my ($self, $data) = @_; + + my $c = $self->{c}; + my ($date, $ref, $expiry) = split(";", $data->{chosen_date}); + + my $guid_key = $self->council_url . ":echo:bulky_event_guid:" . $c->stash->{property}->{id}; + $data->{extra_GUID} = $self->{c}->waste_cache_get($guid_key); + $data->{extra_reservation} = $ref; + + $data->{title} = "Bulky goods collection"; + $data->{detail} = "Address: " . $c->stash->{property}->{address}; + $data->{category} = "Bulky collection"; + $data->{'extra_Collection_Date_-_Bulky_Items'} = $date; + $data->{extra_Exact_Location} = $data->{location}; + + my $first_date = $self->{c}->session->{first_date_returned}; + $first_date = DateTime::Format::W3CDTF->parse_datetime($first_date); + my $dt = DateTime::Format::W3CDTF->parse_datetime($date); + $data->{'extra_First_Date_Offered_-_Bulky'} = $first_date->strftime("%d/%m/%Y"); + + my @items_list = @{ $self->bulky_items_master_list }; + my %items = map { $_->{name} => $_->{bartec_id} } @items_list; + + my @notes; + my @ids; + my @photos; + + my $max = $self->bulky_items_maximum; + for (1..$max) { + if (my $item = $data->{"item_$_"}) { + push @notes, $data->{"item_notes_$_"} || ''; + push @ids, $items{$item}; + push @photos, $data->{"item_photos_$_"} || ''; + }; + } + $data->{'extra_TEM_-_Bulky_Collection_Description'} = join("::", @notes); + $data->{'extra_TEM_-_Bulky_Collection_Item'} = join("::", @ids); + $data->{extra_Image} = join("::", @photos); + $self->bulky_total_cost($data); +} + +sub waste_reconstruct_bulky_data { + my ($self, $p) = @_; + + my $saved_data = { + "chosen_date" => $p->get_extra_field_value('Collection_Date_-_Bulky_Items') || $p->get_extra_field_value('Collection_Date'), + "location" => $p->get_extra_field_value('Exact_Location'), + "location_photo" => $p->get_extra_metadata("location_photo"), + }; + + my @fields = split /::/, $p->get_extra_field_value('TEM_-_Bulky_Collection_Item') || $p->get_extra_field_value('Bulky_Collection_Bulky_Items'); + my @notes = split /::/, $p->get_extra_field_value('TEM_-_Bulky_Collection_Description') || $p->get_extra_field_value('Bulky_Collection_Notes'); + for my $id (1..@fields) { + $saved_data->{"item_$id"} = $p->get_extra_metadata("item_$id"); + $saved_data->{"item_notes_$id"} = $notes[$id-1]; + $saved_data->{"item_photo_$id"} = $p->get_extra_metadata("item_photo_$id"); + } + + $saved_data->{name} = $p->name; + $saved_data->{email} = $p->user->email; + $saved_data->{phone} = $p->phone_waste; + + return $saved_data; +} + +=head2 suppress_report_sent_email + +For Bulky Waste reports, we want to send the email after payment has been confirmed, so we +suppress the email here. + +=cut + +sub suppress_report_sent_email { + my ($self, $report) = @_; + + if ($report->cobrand_data eq 'waste' && $report->category eq 'Bulky collection') { + return 1; + } + + return 0; +} + +sub bulky_location_photo_prompt { + 'Help us by attaching a photo of where the items will be left for collection.'; +} + +1; diff --git a/t/app/controller/waste.t b/t/app/controller/waste.t index c6b651076c6..36cbfe0c5b9 100644 --- a/t/app/controller/waste.t +++ b/t/app/controller/waste.t @@ -291,8 +291,8 @@ FixMyStreet::override_config { $mech->get_ok('/waste/12345/request'); $mech->submit_form_ok({ with_fields => { 'container-9' => 1, 'quantity-9' => 2, 'container-10' => 1, 'quantity-10' => 1 } }); $mech->submit_form_ok({ with_fields => { name => "Test McTest", email => $user->email } }); - $mech->content_like(qr{Outside Food Waste Container\s*]*>\s*1\s*}); - $mech->content_like(qr{Kitchen Caddy\s*]*>\s*2\s*}); + $mech->content_like(qr{Outside Food Waste Container\s*]*>\s*1 to deliver\s*}); + $mech->content_like(qr{Kitchen Caddy\s*]*>\s*2 to deliver\s*}); $mech->submit_form_ok({ with_fields => { process => 'summary' } }); $mech->content_contains('Now check your email'); my $link = $mech->get_link_from_email; # Only one email sent, this also checks @@ -1824,7 +1824,7 @@ FixMyStreet::override_config { )->order_by('-id')->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('Subscription_End_Date'), '2021-03-09', 'cancel date set to current date'; + is $new_report->get_extra_field_value('Subscription_End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->get_extra_field_value('Container_Instruction_Action'), 2, 'correct container request action'; is $new_report->get_extra_field_value('Container_Instruction_Quantity'), 1, 'correct container request count'; is $new_report->state, 'confirmed', 'report confirmed'; @@ -2140,7 +2140,7 @@ FixMyStreet::override_config { my $new_report = FixMyStreet::DB->resultset('Problem')->order_by('-id')->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('Subscription_End_Date'), '2021-03-09', 'cancel date set to current date'; + is $new_report->get_extra_field_value('Subscription_End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->get_extra_field_value('Container_Instruction_Action'), 2, 'correct container request action'; is $new_report->get_extra_field_value('Container_Instruction_Quantity'), 1, 'correct container request count'; is $new_report->state, 'confirmed', 'report confirmed'; @@ -2655,7 +2655,7 @@ FixMyStreet::override_config { )->order_by('-id')->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('Subscription_End_Date'), '2021-03-09', 'cancel date set to current date'; + is $new_report->get_extra_field_value('Subscription_End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->get_extra_field_value('Container_Instruction_Action'), 2, 'correct container request action'; is $new_report->get_extra_field_value('Container_Instruction_Quantity'), 1, 'correct container request count'; is $new_report->state, 'confirmed', 'report confirmed'; diff --git a/t/app/controller/waste_brent_garden.t b/t/app/controller/waste_brent_garden.t index 08eff81a2a6..adbb0c41944 100644 --- a/t/app/controller/waste_brent_garden.t +++ b/t/app/controller/waste_brent_garden.t @@ -593,7 +593,7 @@ FixMyStreet::override_config { { user_id => $user->id }, )->order_by('-id')->first; - is $new_report->get_extra_field_value('End_Date'), '2021-03-09', 'cancel date set to current date'; + is $new_report->get_extra_field_value('End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; is $new_report->state, 'confirmed', 'report confirmed'; @@ -662,11 +662,6 @@ FixMyStreet::override_config { 'container_quantity' => 2, cost => 10000, }, - { - 'bins_wanted' => 1, - 'container_type' => '', - 'container_quantity' => '', - }, ) { subtest 'check modifying Green Garden Waste as staff' => sub { $mech->log_in_ok($staff_user->email); @@ -693,19 +688,22 @@ FixMyStreet::override_config { bin_type => undef, ref_type => 'apn', ); - if ($test->{bins_wanted} > 2) { - is $mech->res->previous->code, 302, 'payments issues a redirect'; - is $mech->res->previous->header('Location'), 'http://paye.example.org/faq?apnReference=4ab5f886-de7d-4f5b-bbd8-42151a5deb82', "redirects to payment gateway"; - is $sent_params->{items}[0]{amount}, $test->{cost}, 'correct amount used'; - check_extra_data_pre_confirm($report, %check); - } else { - check_extra_data_pre_confirm($report, %check, state => 'confirmed', payment_method => 'csc'); - } + is $mech->res->previous->code, 302, 'payments issues a redirect'; + is $mech->res->previous->header('Location'), 'http://paye.example.org/faq?apnReference=4ab5f886-de7d-4f5b-bbd8-42151a5deb82', "redirects to payment gateway"; + is $sent_params->{items}[0]{amount}, $test->{cost}, 'correct amount used'; + check_extra_data_pre_confirm($report, %check); $report->delete; }; }; + subtest 'check cannot modify to lower' => sub { + $mech->get_ok('/waste/12345/garden_modify'); + $mech->submit_form_ok({ with_fields => { task => 'modify' }}, 'Choose modify'); + $mech->submit_form_ok({ with_fields => { bins_wanted => 1 } }); + $mech->content_contains('only increase'); + }; + subtest 'check modifying Green Garden Waste not available for user' => sub { $mech->log_in_ok($user->email); set_fixed_time('2021-01-09T17:00:00Z'); # Before renewal is due so we can modify diff --git a/t/app/controller/waste_kands_bulky.t b/t/app/controller/waste_kands_bulky.t index e81989af694..a2a0265fb11 100644 --- a/t/app/controller/waste_kands_bulky.t +++ b/t/app/controller/waste_kands_bulky.t @@ -55,8 +55,8 @@ FixMyStreet::override_config { echo => { kingston => { bulky_address_types => [ 1, 7 ], - bulky_service_id => 413, - bulky_event_type_id => 1636, + bulky_service_id => 986, + bulky_event_type_id => 3130, url => 'http://example.org', nlpg => 'https://example.com/%s', }, @@ -67,30 +67,11 @@ FixMyStreet::override_config { hmac_id => '1234', scpID => '1234', company_name => 'rbk', - form_name => 'rbk_user_form', - staff_form_name => 'rbk_staff_form', customer_ref => 'customer-ref', bulky_customer_ref => 'customer-ref-bulky', } }, }, }, sub { - my $lwp = Test::MockModule->new('LWP::UserAgent'); - $lwp->mock( - 'get', - sub { - my ( $ua, $url ) = @_; - return $lwp->original('get')->(@_) unless $url =~ /example.com/; - my ( $uprn, $area ) = ( 1000000002, "KINGSTON UPON THAMES" ); - my $j - = '{ "results": [ { "LPI": { "UPRN": ' - . $uprn - . ', "LOCAL_CUSTODIAN_CODE_DESCRIPTION": "' - . $area - . '" } } ] }'; - return HTTP::Response->new( 200, 'OK', [], $j ); - } - ); - my $echo = Test::MockModule->new('Integrations::Echo'); $echo->mock( 'GetServiceUnitsForObject', sub { [{'ServiceId' => 2238}] } ); $echo->mock( 'GetTasks', sub { [] } ); @@ -111,8 +92,8 @@ FixMyStreet::override_config { ); $echo->mock('ReserveAvailableSlotsForEvent', sub { my ($self, $service, $event_type, $property, $guid, $start, $end) = @_; - is $service, 413; - is $event_type, 1636; + is $service, 986; + is $event_type, 3130; is $property, 12345; return [ { @@ -349,14 +330,6 @@ FixMyStreet::override_config { $mech->content_contains('Bob Marge', 'name shown'); $mech->content_contains('44 07 111 111 111', 'phone shown'); } - sub test_summary_submission { - # external redirects make Test::WWW::Mechanize unhappy so clone - # the mech for the redirect - my $mech2 = $mech->clone; - $mech2->submit_form_ok({ with_fields => { tandc => 1 } }); - is $mech2->res->previous->code, 302, 'payments issues a redirect'; - is $mech2->res->previous->header('Location'), "http://example.org/faq", "redirects to payment gateway"; - } subtest 'Summary page' => \&test_summary; @@ -409,7 +382,7 @@ FixMyStreet::override_config { }, ] } ); - subtest 'Summary submission' => \&test_summary_submission; + $mech->waste_submit_check({ with_fields => { tandc => 1 } }); }; my $catch_email; @@ -495,11 +468,10 @@ FixMyStreet::override_config { is $report->category, 'Bulky collection'; is $report->title, 'Bulky goods collection'; is $report->get_extra_field_value('uprn'), 1000000002; - is $report->get_extra_field_value('Collection_Date'), '2023-07-08T00:00:00'; - is $report->get_extra_field_value('Bulky_Collection_Bulky_Items'), '3::85::83'; + is $report->get_extra_field_value('Collection_Date_-_Bulky_Items'), '2023-07-08T00:00:00'; + is $report->get_extra_field_value('TEM_-_Bulky_Collection_Item'), '3::85::83'; is $report->get_extra_field_value('property_id'), '12345'; - is $report->get_extra_field_value('Customer_Selected_Date_Beyond_SLA?'), '0'; - is $report->get_extra_field_value('First_Date_Returned_to_Customer'), '08/07/2023'; + is $report->get_extra_field_value('First_Date_Offered_-_Bulky'), '08/07/2023'; like $report->get_extra_field_value('GUID'), qr/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/; is $report->get_extra_field_value('reservation'), 'reserve5=='; is $report->photo, '74e3362283b6ef0c48686fb0e161da4043bbcc97.jpeg'; @@ -667,7 +639,7 @@ FixMyStreet::override_config { $mech->content_lacks('Bulky waste collection'); $echo->mock( 'GetEventsForObject', sub { [ { Guid => 'a-guid', - EventTypeId => 1636, + EventTypeId => 3130, ResolvedDate => { DateTime => '2023-07-02T00:00:00Z' }, ResolutionCodeId => 232, EventStateId => 12400, @@ -678,7 +650,7 @@ FixMyStreet::override_config { $mech->content_lacks('Bulky waste collection'); $echo->mock( 'GetEventsForObject', sub { [ { Guid => 'a-guid', - EventTypeId => 1636, + EventTypeId => 3130, ResolvedDate => { DateTime => '2023-07-05T00:00:00Z' }, ResolutionCodeId => 232, EventStateId => 12400, @@ -702,7 +674,7 @@ FixMyStreet::override_config { $echo->mock( 'GetEventsForObject', sub { [ { Guid => 'a-guid', - EventTypeId => 1636, + EventTypeId => 3130, ResolvedDate => { DateTime => '2023-07-05T00:00:00Z' }, ResolutionCodeId => 379, EventStateId => 12401, @@ -714,13 +686,13 @@ FixMyStreet::override_config { $mech->content_lacks('Bulky waste collection'); $echo->mock( 'GetEventsForObject', sub { [ { Guid => 'a-guid', - EventTypeId => 1636, + EventTypeId => 3130, ResolvedDate => { DateTime => '2023-07-05T00:00:00Z' }, ResolutionCodeId => 100, EventStateId => 12401, }, { - EventTypeId => 1571, - ServiceId => 413, + EventTypeId => 3145, + ServiceId => 986, Guid => 'guid', EventDate => { DateTime => '2023-07-05T00:00:00Z' }, } ] } ); @@ -780,8 +752,8 @@ FixMyStreet::override_config { echo => { sutton => { bulky_address_types => [ 1, 7 ], - bulky_service_id => 413, - bulky_event_type_id => 1636, + bulky_service_id => 960, + bulky_event_type_id => 3130, url => 'http://example.org', nlpg => 'https://example.com/%s', }, @@ -792,31 +764,12 @@ FixMyStreet::override_config { hmac => '1234', hmac_id => '1234', company_name => 'lbs', - form_name => 'lbs_user_form', - staff_form_name => 'lbs_staff_form', customer_ref => 'customer-ref', bulky_customer_ref => 'customer-ref-bulky', }, }, } }, sub { - my $lwp = Test::MockModule->new('LWP::UserAgent'); - $lwp->mock( - 'get', - sub { - my ( $ua, $url ) = @_; - return $lwp->original('get')->(@_) unless $url =~ /example.com/; - my ( $uprn, $area ) = ( 1000000002, "SUTTON" ); - my $j - = '{ "results": [ { "LPI": { "UPRN": ' - . $uprn - . ', "LOCAL_CUSTODIAN_CODE_DESCRIPTION": "' - . $area - . '" } } ] }'; - return HTTP::Response->new( 200, 'OK', [], $j ); - } - ); - my $echo = Test::MockModule->new('Integrations::Echo'); $echo->mock( 'GetTasks', sub { [] } ); $echo->mock( 'GetEventsForObject', sub { [] } ); @@ -837,8 +790,8 @@ FixMyStreet::override_config { } ); $echo->mock('ReserveAvailableSlotsForEvent', sub { my ($self, $service, $event_type, $property, $guid, $start, $end) = @_; - is $service, 413; - is $event_type, 1636; + is $service, 960; + is $event_type, 3130; like $property, qr/1234[56]/; if ($property == 12345) { is $start, '2023-07-07'; @@ -883,7 +836,7 @@ FixMyStreet::override_config { $mech->content_lacks('Bulky Waste'); }; - $echo->mock( 'GetServiceUnitsForObject', sub { [{'ServiceId' => 2238}, {'ServiceId' => 413}] } ); + $echo->mock( 'GetServiceUnitsForObject', sub { [{'ServiceId' => 2238}, {'ServiceId' => 960}] } ); subtest 'Sutton specific Bulky Waste text' => sub { $mech->get_ok('/waste/12346/'); @@ -992,14 +945,12 @@ sub _contact_extra_data { { category => 'Bulky collection', email => '1636@test.com' }, { code => 'payment' }, { code => 'payment_method' }, - { code => 'Payment_Type' }, - { code => 'Collection_Date' }, - { code => 'Bulky_Collection_Bulky_Items' }, - { code => 'Bulky_Collection_Notes' }, + { code => 'Collection_Date_-_Bulky_Items' }, + { code => 'TEM_-_Bulky_Collection_Item' }, + { code => 'TEM_-_Bulky_Collection_Description' }, { code => 'Exact_Location' }, { code => 'GUID' }, { code => 'reservation' }, - { code => 'Customer_Selected_Date_Beyond_SLA?' }, - { code => 'First_Date_Returned_to_Customer' }, + { code => 'First_Date_Offered_-_Bulky' }, ); } diff --git a/t/app/controller/waste_kingston.t b/t/app/controller/waste_kingston.t index 153b7e4f33a..36a9bd9ad78 100644 --- a/t/app/controller/waste_kingston.t +++ b/t/app/controller/waste_kingston.t @@ -31,12 +31,10 @@ sub create_contact { } create_contact({ category => 'Garden Subscription', email => 'garden@example.com'}, - { code => 'Request_Type', required => 1, automated => 'hidden_field' }, - { code => 'Subscription_Details_Quantity', required => 1, automated => 'hidden_field' }, - { code => 'Subscription_Details_Containers', required => 1, automated => 'hidden_field' }, - { code => 'Bin_Delivery_Detail_Quantity', required => 1, automated => 'hidden_field' }, - { code => 'Bin_Delivery_Detail_Container', required => 1, automated => 'hidden_field' }, - { code => 'Bin_Delivery_Detail_Containers', required => 1, automated => 'hidden_field' }, + { code => 'Paid_Container_Quantity', required => 1, automated => 'hidden_field' }, + { code => 'Paid_Container_Type', required => 1, automated => 'hidden_field' }, + { code => 'Quantity', required => 1, automated => 'hidden_field' }, + { code => 'Container_Type', required => 1, automated => 'hidden_field' }, { code => 'current_containers', required => 1, automated => 'hidden_field' }, { code => 'new_containers', required => 1, automated => 'hidden_field' }, { code => 'payment', required => 1, automated => 'hidden_field' }, @@ -44,12 +42,20 @@ create_contact({ category => 'Garden Subscription', email => 'garden@example.com { code => 'pro_rata', required => 0, automated => 'hidden_field' }, { code => 'admin_fee', required => 0, automated => 'hidden_field' }, ); -create_contact({ category => 'Cancel Garden Subscription', email => 'garden_cancel@example.com'}, - { code => 'Bin_Delivery_Detail_Quantity', required => 1, automated => 'hidden_field' }, - { code => 'Bin_Delivery_Detail_Container', required => 1, automated => 'hidden_field' }, - { code => 'Bin_Delivery_Detail_Containers', required => 1, automated => 'hidden_field' }, - { code => 'Subscription_End_Date', required => 1, automated => 'hidden_field' }, +create_contact({ category => 'Amend Garden Subscription', email => 'garden@example.com'}, + { code => 'Additional_Container_Quantity', required => 1, automated => 'hidden_field' }, + { code => 'Additional_Collection_Container_Type', required => 1, automated => 'hidden_field' }, + { code => 'Container_Ordered_Quantity', required => 1, automated => 'hidden_field' }, + { code => 'Container_Ordered_Type', required => 1, automated => 'hidden_field' }, + { code => 'current_containers', required => 1, automated => 'hidden_field' }, + { code => 'new_containers', required => 1, automated => 'hidden_field' }, + { code => 'payment', required => 1, automated => 'hidden_field' }, { code => 'payment_method', required => 1, automated => 'hidden_field' }, + { code => 'pro_rata', required => 0, automated => 'hidden_field' }, + { code => 'admin_fee', required => 0, automated => 'hidden_field' }, +); +create_contact({ category => 'Cancel Garden Subscription', email => 'garden_cancel@example.com'}, + { code => 'End_Date', required => 1, automated => 'hidden_field' }, ); package SOAP::Result; @@ -61,11 +67,11 @@ package main; sub garden_waste_no_bins { return [ { Id => 1001, - ServiceId => 405, + ServiceId => 980, ServiceName => 'Food waste collection', ServiceTasks => { ServiceTask => { Id => 400, - TaskTypeId => 2238, + TaskTypeId => 4389, ServiceTaskSchedules => { ServiceTaskSchedule => [ { ScheduleDescription => 'every other Monday', StartDate => { DateTime => '2020-01-01T00:00:00Z' }, @@ -84,7 +90,7 @@ sub garden_waste_no_bins { }, { # Eligibility for garden waste, but no task Id => 1002, - ServiceId => 409, + ServiceId => 979, ServiceName => 'Garden waste collection', ServiceTasks => '' } ]; @@ -93,11 +99,11 @@ sub garden_waste_no_bins { sub garden_waste_only_refuse_sacks { return [ { Id => 1001, - ServiceId => 405, + ServiceId => 967, ServiceName => 'Refuse collection', ServiceTasks => { ServiceTask => { Id => 400, - TaskTypeId => 2242, + TaskTypeId => 4395, ServiceTaskSchedules => { ServiceTaskSchedule => [ { ScheduleDescription => 'every other Monday', StartDate => { DateTime => '2020-01-01T00:00:00Z' }, @@ -116,7 +122,7 @@ sub garden_waste_only_refuse_sacks { }, { # Eligibility for garden waste, but no task Id => 1002, - ServiceId => 409, + ServiceId => 979, ServiceName => 'Garden waste collection', ServiceTasks => '' } ]; @@ -152,25 +158,25 @@ sub garden_waste_two_bins { sub _garden_waste_service_units { my ($bin_count, $type) = @_; - my $bin_type_id = $type eq 'sack' ? 28 : 26; + my $bin_type_id = $type eq 'sack' ? 36 : 39; return [ { Id => 1002, - ServiceId => 409, + ServiceId => 979, ServiceName => 'Garden waste collection', + Data => { ExtensibleDatum => [ { + DatatypeName => 'Container Details', + ChildData => { ExtensibleDatum => [ { + DatatypeName => 'Container Quantity', + Value => $bin_count, + }, { + DatatypeName => 'Container Type', + Value => $bin_type_id, + } ] }, + } ] }, ServiceTasks => { ServiceTask => { Id => 405, - TaskTypeId => 2247, - Data => { ExtensibleDatum => [ { - DatatypeName => 'SLWP - Containers', - ChildData => { ExtensibleDatum => [ { - DatatypeName => 'Quantity', - Value => $bin_count, - }, { - DatatypeName => 'Container Type', - Value => $bin_type_id, - } ] }, - } ] }, + TaskTypeId => 4410, ServiceTaskSchedules => { ServiceTaskSchedule => [ { ScheduleDescription => 'every other Monday', StartDate => { DateTime => '2020-03-30T00:00:00Z' }, @@ -188,56 +194,6 @@ sub _garden_waste_service_units { } } } ]; } -FixMyStreet::override_config { - ALLOWED_COBRANDS => 'kingston', - MAPIT_URL => 'http://mapit.uk/', - COBRAND_FEATURES => { - echo => { kingston => { url => 'http://example.org', nlpg => 'https://example.com/%s' } }, - waste => { kingston => 1 }, - }, -}, sub { - my $lwp = Test::MockModule->new('LWP::UserAgent'); - $lwp->mock('get', sub { - my ($ua, $url) = @_; - return $lwp->original('get')->(@_) unless $url =~ /example.com/; - my ($uprn, $area) = (1000000002, "KINGSTON UPON THAMES"); - ($uprn, $area) = (1000000004, "SUTTON") if $url =~ /1000000004/; - my $j = '{ "results": [ { "LPI": { "UPRN": ' . $uprn . ', "LOCAL_CUSTODIAN_CODE_DESCRIPTION": "' . $area . '" } } ] }'; - return HTTP::Response->new(200, 'OK', [], $j); - }); - my $echo = Test::MockModule->new('Integrations::Echo'); - $echo->mock('GetEventsForObject', sub { [] }); - $echo->mock('FindPoints', sub { [ - { Description => '2 Example Street, Kingston, KT1 1AA', Id => '12345', SharedRef => { Value => { anyType => 1000000002 } } }, - { Description => '3 Example Street, Sutton, KT1 1AA', Id => '14345', SharedRef => { Value => { anyType => 1000000004 } } }, - ] }); - $echo->mock('GetPointAddress', sub { - my ($self, $id) = @_; - return { - Id => $id, - SharedRef => { Value => { anyType => $id == 14345 ? '1000000004' : '1000000002' } }, - PointType => 'PointAddress', - PointAddressType => { Name => 'House' }, - Coordinates => { GeoPoint => { Latitude => 51.408688, Longitude => -0.304465 } }, - Description => '2/3 Example Street, Sutton, KT1 1AA', - }; - }); - $echo->mock('GetServiceUnitsForObject', \&garden_waste_one_bin); - $echo->mock('GetTasks', sub { [] }); - mock_CancelReservedSlotsForEvent($echo); - - subtest 'Look up of address not in correct borough' => sub { - $mech->get_ok('/waste'); - $mech->submit_form_ok({ with_fields => { postcode => 'KT1 1AA' } }); - $mech->submit_form_ok({ with_fields => { address => '14345' } }); - $mech->content_contains('No address on record'); - $mech->get_ok('/waste'); - $mech->submit_form_ok({ with_fields => { postcode => 'KT1 1AA' } }); - $mech->submit_form_ok({ with_fields => { address => '12345' } }); - $mech->content_lacks('No address on record'); - }; -}; - my $UPLOAD_DIR = tempdir( CLEANUP => 1 ); FixMyStreet::override_config { ALLOWED_COBRANDS => 'kingston', @@ -634,7 +590,7 @@ FixMyStreet::override_config { my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); - check_extra_data_pre_confirm($new_report, type => 'Amend', quantity => 2); + check_amend_extra_data_pre_confirm($new_report); $mech->get_ok("/waste/pay_complete/$report_id/$token"); is $sent_params->{scpReference}, 12345, 'correct scpReference sent'; @@ -645,44 +601,11 @@ FixMyStreet::override_config { FixMyStreet::Script::Reports::send(); my @emails = $mech->get_email; my $body = $mech->get_text_body_from_email($emails[1]); - like $body, qr/Number of bin subscriptions: 2/; + like $body, qr/Number of additional bin subscriptions: 1/; like $body, qr/Bins to be delivered: 1/; like $body, qr/Total:.*?35.00/; }; - $echo->mock('GetServiceUnitsForObject', \&garden_waste_two_bins); - subtest 'check modify sub credit card payment reducing bin count' => sub { - set_fixed_time('2021-01-09T17:00:00Z'); # After sample data collection - $sent_params = undef; - - $mech->log_in_ok($user->email); - $mech->get_ok('/waste/12345/garden_modify'); - $mech->submit_form_ok({ with_fields => { task => 'modify' } }); - $mech->submit_form_ok({ with_fields => { current_bins => 2, bins_wanted => 1 } }); - $mech->content_contains('20.00'); - $mech->content_lacks('Continue to payment'); - $mech->content_contains('Confirm changes'); - $mech->submit_form_ok({ with_fields => { tandc => 1 } }); - $mech->content_like(qr#/waste/12345">Show upcoming#, "contains link to bin page"); - - my $new_report = FixMyStreet::DB->resultset('Problem')->search( - { user_id => $user->id }, - )->order_by('-id')->first; - - is $sent_params, undef, "no one off payment if reducing bin count"; - check_extra_data_pre_confirm($new_report, type => 'Amend', state => 'confirmed', action => 2); - is $new_report->state, 'confirmed', 'report confirmed'; - is $new_report->get_extra_field_value('payment'), '0', 'no payment if removing bins'; - is $new_report->get_extra_field_value('pro_rata'), '', 'no pro rata payment if removing bins'; - - $mech->clear_emails_ok; - FixMyStreet::Script::Reports::send(); - my @emails = $mech->get_email; - my $body = $mech->get_text_body_from_email($emails[1]); - like $body, qr/Number of bin subscriptions: 1/; - like $body, qr/Bins to be removed: 1/; - unlike $body, qr/Total:/; - }; $echo->mock('GetServiceUnitsForObject', \&garden_waste_one_bin); subtest 'renew credit card sub' => sub { @@ -798,7 +721,7 @@ FixMyStreet::override_config { my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); - check_extra_data_pre_confirm($new_report, type => 'Renew', action => 2); + check_extra_data_pre_confirm($new_report, type => 'Renew', new_bins => 0); $mech->get_ok("/waste/pay_complete/$report_id/$token"); is $sent_params->{scpReference}, 12345, 'correct scpReference sent'; @@ -843,10 +766,7 @@ FixMyStreet::override_config { )->order_by('-id')->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('Subscription_End_Date'), '2021-03-09', 'cancel date set to current date'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Container'), 26, 'correct container request bin type'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Containers'), 2, 'correct container request action'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Quantity'), 1, 'correct container request count'; + is $new_report->get_extra_field_value('End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->state, 'confirmed', 'report confirmed'; $mech->clear_emails_ok; @@ -949,7 +869,7 @@ FixMyStreet::override_config { is $sent_params->{items}[0]{amount}, 4100, 'correct amount used'; is $sent_params->{items}[1]{amount}, undef, 'correct amount used'; - check_extra_data_pre_confirm($new_report, bin_type => 28); + check_extra_data_pre_confirm($new_report, bin_type_sub => 4, bin_type_new => 5, quantity => 11, new_bins => 11); $mech->get('/waste/pay/xx/yyyyyyyyyyy'); ok !$mech->res->is_success(), "want a bad response"; @@ -1013,7 +933,7 @@ FixMyStreet::override_config { is $sent_params->{items}[1]{amount}, 1500, 'no admin fee'; my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); - check_extra_data_pre_confirm($new_report, type => 'Amend', quantity => 2); + check_amend_extra_data_pre_confirm($new_report); }; subtest 'refuse sacks, garden bin, cancelling' => sub { @@ -1026,10 +946,7 @@ FixMyStreet::override_config { )->order_by('-id')->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('Subscription_End_Date'), '2021-03-09', 'cancel date set to current date'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Container'), 26, 'correct container request bin type'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Containers'), 2, 'correct container request action'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Quantity'), 1, 'correct container request count'; + is $new_report->get_extra_field_value('End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->state, 'confirmed', 'report confirmed'; }; @@ -1059,7 +976,7 @@ FixMyStreet::override_config { my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); - check_extra_data_pre_confirm($new_report, type => 'Renew', bin_type => 28); + check_extra_data_pre_confirm($new_report, type => 'Renew', bin_type_sub => 4, bin_type_new => 5, quantity => 11, new_bins => 11); $mech->get_ok("/waste/pay_complete/$report_id/$token"); is $sent_params->{scpReference}, 12345, 'correct scpReference sent'; @@ -1085,7 +1002,7 @@ FixMyStreet::override_config { my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); - check_extra_data_pre_confirm($new_report, type => 'Amend', quantity => 1, bin_type => 28); + check_extra_data_pre_confirm($new_report, type => 'Amend', quantity => 1, bin_type_sub => 4, bin_type_new => 5, quantity => 11, new_bins => 11); $mech->get_ok("/waste/pay_complete/$report_id/$token"); is $sent_params->{scpReference}, 12345, 'correct scpReference sent'; @@ -1104,10 +1021,7 @@ FixMyStreet::override_config { )->order_by('-id')->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('Subscription_End_Date'), '2021-03-09', 'cancel date set to current date'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Container'), '', 'correct container request bin type'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Containers'), '', 'correct container request action'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Quantity'), '', 'correct container request count'; + is $new_report->get_extra_field_value('End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->state, 'confirmed', 'report confirmed'; }; @@ -1160,7 +1074,7 @@ FixMyStreet::override_config { ok $id, "confirmation page contains id"; my $report = FixMyStreet::DB->resultset("Problem")->find({ id => $id }); - check_extra_data_pre_confirm($report, type => 'Amend', quantity => 2, payment_method => 'csc', state => 'confirmed'); + check_amend_extra_data_pre_confirm($report, payment_method => 'csc', state => 'confirmed'); check_extra_data_post_confirm($report, LastPayMethod => 1); is $report->name, 'Test McTest', 'non staff user name'; @@ -1170,42 +1084,6 @@ FixMyStreet::override_config { $report->delete; # Otherwise next test sees this as latest }; - $echo->mock('GetServiceUnitsForObject', \&garden_waste_two_bins); - subtest 'check modify sub staff reducing bin count' => sub { - set_fixed_time('2021-01-09T17:00:00Z'); - - $mech->get_ok('/waste/12345/garden_modify'); - $mech->submit_form_ok({ with_fields => { task => 'modify' } }); - $mech->submit_form_ok({ with_fields => { - current_bins => 2, - bins_wanted => 1, - name => 'A user', - email => 'test@example.net', - } }); - $mech->content_contains('20.00'); - $mech->content_lacks('Continue to payment'); - $mech->content_contains('Confirm changes'); - $mech->submit_form_ok({ with_fields => { tandc => 1 } }); - $mech->content_like(qr#/waste/12345">Show upcoming#, "contains link to bin page"); - - $mech->content_lacks($staff_user->email); - - my $content = $mech->content; - my ($id) = ($content =~ m#reference number\s*
.*?(\d+)<#); - my $new_report = FixMyStreet::DB->resultset("Problem")->find({ id => $id }); - - is $new_report->category, 'Garden Subscription', 'correct category on report'; - is $new_report->title, 'Garden Subscription - Amend', 'correct title on report'; - is $new_report->get_extra_field_value('payment_method'), 'csc', 'correct payment method on report'; - is $new_report->state, 'confirmed', 'report confirmed'; - is $new_report->get_extra_field_value('Subscription_Details_Quantity'), 1, 'correct bin count'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Containers'), 2, 'correct container request action'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Quantity'), 1, 'correct container request count'; - is $new_report->get_extra_metadata('contributed_by'), $staff_user->id; - is $new_report->get_extra_metadata('contributed_as'), 'another_user'; - is $new_report->get_extra_field_value('payment'), '0', 'no payment if removing bins'; - is $new_report->get_extra_field_value('pro_rata'), '', 'no pro rata payment if removing bins'; - }; $echo->mock('GetServiceUnitsForObject', \&garden_waste_one_bin); subtest 'cancel staff sub' => sub { @@ -1217,7 +1095,7 @@ FixMyStreet::override_config { my $new_report = FixMyStreet::DB->resultset('Problem')->order_by('-id')->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('Subscription_End_Date'), '2021-03-09', 'cancel date set to current date'; + is $new_report->get_extra_field_value('End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->state, 'confirmed', 'report confirmed'; is $new_report->get_extra_metadata('contributed_by'), $staff_user->id; is $new_report->get_extra_metadata('contributed_as'), 'anonymous_user'; @@ -1315,7 +1193,7 @@ FixMyStreet::override_config { my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); - check_extra_data_pre_confirm($new_report, type => 'Amend', quantity => 2); + check_amend_extra_data_pre_confirm($new_report); $mech->get_ok("/waste/pay_complete/$report_id/$token"); is $sent_params->{scpReference}, 12345, 'correct scpReference sent'; @@ -1336,7 +1214,7 @@ FixMyStreet::override_config { )->order_by('-id')->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('Subscription_End_Date'), '2021-03-09', 'cancel date set to current date'; + is $new_report->get_extra_field_value('End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->state, 'confirmed', 'report confirmed'; }; @@ -1390,11 +1268,11 @@ FixMyStreet::override_config { $mech->content_contains('"a user"'); $mech->content_contains(1000000002); $mech->content_contains('a_user@example.net'); - $mech->content_contains('csc,54321,2000,,0,26,1,1'); # Method/ref/fee/fee/fee/bin/current/sub + $mech->content_contains('csc,54321,2000,,0,1,1,1'); # Method/ref/fee/fee/fee/bin/current/sub $mech->content_contains('"a user 2"'); $mech->content_contains('a_user_2@example.net'); $mech->content_contains('unconfirmed'); - $mech->content_contains('4000,,1500,26,1,2'); # Fee/fee/fee/bin/current/sub + $mech->content_contains('4000,,1500,1,1,2'); # Fee/fee/fee/bin/current/sub }; subtest 'check CSV pregeneration' => sub { @@ -1404,11 +1282,11 @@ FixMyStreet::override_config { $mech->content_contains('"a user"'); $mech->content_contains(1000000002); $mech->content_contains('a_user@example.net'); - $mech->content_contains('csc,54321,2000,,0,26,1,1'); # Method/ref/fee/fee/fee/bin/current/sub + $mech->content_contains('csc,54321,2000,,0,1,1,1'); # Method/ref/fee/fee/fee/bin/current/sub $mech->content_contains('"a user 2"'); $mech->content_contains('a_user_2@example.net'); $mech->content_contains('unconfirmed'); - $mech->content_contains('4000,,1500,26,1,2'); # Fee/fee/fee/bin/current/sub + $mech->content_contains('4000,,1500,1,1,2'); # Fee/fee/fee/bin/current/sub }; subtest 'check new sub price changes at fixed time' => sub { @@ -1654,8 +1532,8 @@ sub check_extra_data_pre_confirm { state => 'unconfirmed', quantity => 1, new_bins => 1, - action => 1, - bin_type => 26, + bin_type_sub => 1, + bin_type_new => 2, payment_method => 'credit_card', @_ ); @@ -1663,12 +1541,11 @@ sub check_extra_data_pre_confirm { is $report->category, 'Garden Subscription', 'correct category on report'; is $report->title, "Garden Subscription - $params{type}", 'correct title on report'; is $report->get_extra_field_value('payment_method'), $params{payment_method}, 'correct payment method on report'; - is $report->get_extra_field_value('Subscription_Details_Quantity'), $params{quantity}, 'correct bin count'; - is $report->get_extra_field_value('Subscription_Details_Containers'), $params{bin_type}, 'correct bin type'; + is $report->get_extra_field_value('Paid_Container_Quantity'), $params{quantity}, 'correct bin count'; + is $report->get_extra_field_value('Paid_Container_Type'), $params{bin_type_sub}, 'correct bin type'; if ($params{new_bins}) { - is $report->get_extra_field_value('Bin_Delivery_Detail_Container'), $params{bin_type}, 'correct container request bin type'; - is $report->get_extra_field_value('Bin_Delivery_Detail_Containers'), $params{action}, 'correct container request action'; - is $report->get_extra_field_value('Bin_Delivery_Detail_Quantity'), $params{new_bins}, 'correct container request count'; + is $report->get_extra_field_value('Container_Type'), $params{bin_type_new}, 'correct container request bin type'; + is $report->get_extra_field_value('Quantity'), $params{new_bins}+1, 'correct container request count'; } is $report->state, $params{state}, 'report state correct'; if ($params{state} eq 'unconfirmed') { @@ -1676,6 +1553,33 @@ sub check_extra_data_pre_confirm { } } +sub check_amend_extra_data_pre_confirm { + my $report = shift; + ok $report, "report passed to check_extra_data_pre_confirm"; + return unless $report; + + my %params = ( + state => 'unconfirmed', + quantity => 1, + new_bins => 1, + bin_type_sub => 1, + bin_type_new => 2, + payment_method => 'credit_card', + @_ + ); + $report->discard_changes; + is $report->category, 'Amend Garden Subscription', 'correct category on report'; + is $report->title, "Garden Subscription - Amend", 'correct title on report'; + is $report->get_extra_field_value('payment_method'), $params{payment_method}, 'correct payment method on report'; + is $report->get_extra_field_value('Additional_Container_Quantity'), $params{quantity}, 'correct bin count'; + is $report->get_extra_field_value('Additional_Collection_Container_Type'), $params{bin_type_sub}, 'correct bin type'; + if ($params{new_bins}) { + is $report->get_extra_field_value('Container_Ordered_Type'), $params{bin_type_new}, 'correct container request bin type'; + is $report->get_extra_field_value('Container_Ordered_Quantity'), $params{new_bins}+1, 'correct container request count - one more'; + } + is $report->state, $params{state}, 'report state correct'; +} + sub check_extra_data_post_confirm { my $report = shift; my %params = ( diff --git a/t/app/controller/waste_kingston_4443082.json b/t/app/controller/waste_kingston_4443082.json new file mode 100644 index 00000000000..08098b4b3c2 --- /dev/null +++ b/t/app/controller/waste_kingston_4443082.json @@ -0,0 +1,190 @@ +[ + { + "Data": { + "ExtensibleDatum": { + "Value": "Paper Recycling 240L ", + "DatatypeName": "Recycling Containers", + "ChildData": { + "ExtensibleDatum": [ + { "DatatypeName": "Container Type", "Value": "27" }, + { "DatatypeName": "Container Quantity", "Value": "1" } + ] + } + } + }, + "ServiceTasks": { + "ServiceTask": [ + { + "TaskTypeId": "4388", + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "ScheduleDescription": "Friday every other week", + "NextInstance": { + "CurrentScheduledDate": { "DateTime": "2022-09-15T23:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-15T23:00:00Z" } + }, + "LastInstance": { + "CurrentScheduledDate": { "DateTime": "2022-09-02T05:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-01T23:00:00Z" }, + "Ref": { "Value": { "anyType": [ "22239416", "8280" ] } }, + "CompletedDate": { "DateTime": "2022-09-02T06:17:01Z" } + }, + "StartDate": { "DateTime": "2018-09-02T23:00:00Z" }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" } + } + }, + "TaskIndicatorId": "33", + "Id": "2001", + "TaskTypeName": "Collect Domestic Paper", + "ScheduleDescription": "Every Friday fortnightly" + } + ] + }, + "ServiceName": "Domestic Paper Collection", + "ServiceId": "974", + "Id": "1001" + }, + { + "Data": { + "ExtensibleDatum": [ { + "ChildData": { + "ExtensibleDatum": [ + { "Value": "46", "DatatypeName": "Container Type" }, + { "Value": "1", "DatatypeName": "Container Quantity" } + ] + }, + "DatatypeName": "Food Containers", + "DatatypeId": "3955", + "Value": "Food Caddy 23L" + } ] + }, + "ServiceTasks": { + "ServiceTask": [ + { + "TaskTypeId": "4389", + "ServiceTaskSchedules": { + "ServiceTaskSchedule": [ + { + "LastInstance": { + "Ref": { "Value": { "anyType": [ "22244305", "8287" ] } }, + "OriginalScheduledDate": { "DateTime": "2022-09-08T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-09-09T05:00:00Z" }, + "CompletedDate": { "DateTime": "2022-09-09T05:42:38.93Z" } + }, + "StartDate": { "DateTime": "2018-09-02T23:00:00Z" }, + "NextInstance": null, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "ScheduleDescription": null + }, + { + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "StartDate": { "DateTime": "2018-09-02T23:00:00Z" }, + "LastInstance": null, + "NextInstance": { + "CurrentScheduledDate": { "DateTime": "2022-09-15T23:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-15T23:00:00Z" } + }, + "ScheduleDescription": "Friday every other week" + } + ] + }, + "TaskIndicatorId": "33", + "TaskTypeName": "Collect Domestic Food", + "Id": "2002", + "ScheduleDescription": "Every Friday" + } + ] + }, + "ServiceName": "Domestic Food Collection", + "ServiceId": "980", + "Id": "1002" + }, + { + "Data": { + "ExtensibleDatum": { + "DatatypeName": "Recycling Containers", + "DatatypeId": "3964", + "Value": "Recycling 55L Box", + "ChildData": { + "ExtensibleDatum": [ + { "Value": "12", "DatatypeName": "Container Type" }, + { "Value": "3", "DatatypeName": "Container Quantity" } + ] + } + } + }, + "ServiceTasks": { + "ServiceTask": [ + { + "TaskIndicatorId": "33", + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "ScheduleDescription": "Friday every other week", + "NextInstance": { + "CurrentScheduledDate": { "DateTime": "2022-09-22T23:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-22T23:00:00Z" } + }, + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" }, + "LastInstance": { + "CompletedDate": { "DateTime": "2022-09-09T05:52:03.367Z" }, + "Ref": { "Value": { "anyType": [ "17510905", "8287" ] } }, + "CurrentScheduledDate": { "DateTime": "2022-09-09T05:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-08T23:00:00Z" } + }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" } + } + }, + "TaskTypeId": "4390", + "ScheduleDescription": "Every Friday fortnightly", + "TaskTypeName": "Collect Domestic Recycling", + "Id": "2003" + } + ] + }, + "ServiceName": "Domestic Recycling Collection", + "ServiceId": "970", + "Id": "1003" + }, + { + "ServiceId": "966", + "ServiceName": "Domestic Refuse Collection", + "Id": "1004", + "Data": { + "ExtensibleDatum": { + "ChildData": { + "ExtensibleDatum": [ + { "Value": "3", "DatatypeName": "Container Type" }, + { "Value": "1", "DatatypeName": "Container Quantity" } + ] + }, + "DatatypeName": "Refuse Containers" + } + }, + "ServiceTasks": { + "ServiceTask": { + "ScheduleDescription": "Every Friday fortnightly", + "Id": "2004", + "TaskTypeName": "Collect Domestic Refuse Bin", + "TaskIndicatorId": "33", + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "ScheduleDescription": "Friday every other week", + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" }, + "LastInstance": { + "Ref": { "Value": { "anyType": [ "17430692", "8287" ] } }, + "CurrentScheduledDate": { "DateTime": "2022-09-09T05:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-08T23:00:00Z" }, + "CompletedDate": { "DateTime": "2022-09-09T08:19:22.76Z" } + }, + "NextInstance": { + "OriginalScheduledDate": { "DateTime": "2022-09-22T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-09-22T23:00:00Z" } + } + } + }, + "TaskTypeId": "4394" + } + } + } +] diff --git a/t/app/controller/waste_kingston_4471550.json b/t/app/controller/waste_kingston_4471550.json new file mode 100644 index 00000000000..23fe842ada3 --- /dev/null +++ b/t/app/controller/waste_kingston_4471550.json @@ -0,0 +1,137 @@ +[ + { + "Data": { + "ExtensibleDatum": { + "ChildData": { + "ExtensibleDatum": [ + { "DatatypeName": "Container Type", "Value": "10" }, + { "Value": "1", "DatatypeName": "Container Quantity" } + ] + }, + "DatatypeName": "Refuse Containers" + } + }, + "ServiceTasks": { + "ServiceTask": { + "Id": "2001", + "TaskTypeId": "4395", + "TaskTypeName": "Collect Domestic Refuse Bag", + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "StartDate": { "DateTime": "2018-09-02T23:00:00Z" }, + "NextInstance": { + "Ref": { "Value": { "anyType": [ "23285360", "8332" ] } }, + "CurrentScheduledDate": { "DateTime": "2022-10-23T23:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-10-23T23:00:00Z" } + }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "LastInstance": { + "Ref": { "Value": { "anyType": [ "23285360", "8318" ] } }, + "OriginalScheduledDate": { "DateTime": "2022-10-09T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-10-10T05:00:00Z" } + }, + "ScheduleDescription": "Monday every other week" + } + }, + "ScheduleDescription": "Every Monday fortnightly" + } + }, + "ServiceName": "Domestic Refuse Collection", + "ServiceId": "967", + "Id": "1001" + }, + { + "ServiceName": "FAS Paper Collection", + "ServiceId": "975", + "Id": "1003", + "Data": { + "ExtensibleDatum": { + "DatatypeName": "Recycling Containers", + "ChildData": { + "ExtensibleDatum": [ + { "Value": "34", "DatatypeName": "Container Type" }, + { "Value": "1", "DatatypeName": "Container Quantity" } + ] + } + } + }, + "ServiceTasks": { + "ServiceTask": [ + { + "Id": "2002", + "ScheduleDescription": "Every Monday fortnightly", + "TaskTypeId": "4402", + "TaskTypeName": "Collect Domestic Paper Bag", + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "ScheduleDescription": "Monday every other week", + "LastInstance": { + "OriginalScheduledDate": { "DateTime": "2022-10-09T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-10-10T05:00:00Z" }, + "Ref": { "Value": { "anyType": [ "22282336", "8318" ] } } + }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "NextInstance": { + "OriginalScheduledDate": { "DateTime": "2022-10-23T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-10-23T23:00:00Z" }, + "Ref": { "Value": { "anyType": [ "22282336", "8332" ] } } + }, + "StartDate": { "DateTime": "2018-09-02T23:00:00Z" } + } + }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" } + } + ] + } + }, + { + "ServiceName": "Domestic Recycling Collection", + "ServiceId": "971", + "Id": "1004", + "Data": { + "ExtensibleDatum": [ + { + "ChildData": { + "ExtensibleDatum": [ + { "DatatypeName": "Container Type", "Value": "22" }, + { "Value": "1", "DatatypeName": "Container Quantity" } + ] + }, + "DatatypeName": "Recycling Containers" + } + ] + }, + "ServiceTasks": { + "ServiceTask": [ + { + "ScheduleDescription": "Every Monday fortnightly", + "TaskTypeId": "4391", + "TaskTypeName": "Collect Domestic Recycling Bag", + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "NextInstance": { + "Ref": { "Value": { "anyType": [ "22252757", "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" }, + "LastInstance": { + "Ref": { "Value": { "anyType": [ "22252757", "8311" ] } }, + "OriginalScheduledDate": { "DateTime": "2022-10-02T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-10-03T05:00:00Z" } + }, + "ScheduleDescription": "Monday every other week" + } + }, + "Id": "2003", + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" } + } + ] + } + } +] diff --git a/t/app/controller/waste_kingston_r.t b/t/app/controller/waste_kingston_r.t index 25bcb4bf59a..b113180551b 100644 --- a/t/app/controller/waste_kingston_r.t +++ b/t/app/controller/waste_kingston_r.t @@ -12,11 +12,8 @@ END { FixMyStreet::App->log->enable('info'); } my $mech = FixMyStreet::TestMech->new; -my $bin_data = decode_json(path(__FILE__)->sibling('waste_4443082.json')->slurp_utf8); -# Kingston does not use 140L, set to 240L -$bin_data->[1]{ServiceTasks}{ServiceTask}{Data}{ExtensibleDatum}{ChildData}{ExtensibleDatum}[0]{Value} = '2'; - -my $kerbside_bag_data = decode_json(path(__FILE__)->sibling('waste_4471550.json')->slurp_utf8); +my $bin_data = decode_json(path(__FILE__)->sibling('waste_kingston_4443082.json')->slurp_utf8); +my $kerbside_bag_data = decode_json(path(__FILE__)->sibling('waste_kingston_4471550.json')->slurp_utf8); my $above_shop_data = decode_json(path(__FILE__)->sibling('waste_4499005.json')->slurp_utf8); my $params = { @@ -41,12 +38,13 @@ sub create_contact { $contact->update; } -create_contact({ category => 'Report missed collection', email => 'missed' }, 'Waste', +create_contact({ category => 'Report missed collection', email => '3145' }, 'Waste', { code => 'service_id', required => 1, automated => 'hidden_field' }, { code => 'fixmystreet_id', required => 1, automated => 'hidden_field' }, ); -create_contact({ category => 'Request new container', email => '1635' }, 'Waste', +create_contact({ category => 'Request new container', email => '3129' }, 'Waste', { code => 'uprn', required => 1, automated => 'hidden_field' }, + { code => 'service_id', required => 1, automated => 'hidden_field' }, { code => 'fixmystreet_id', required => 1, automated => 'hidden_field' }, { code => 'Container_Type', required => 1, automated => 'hidden_field' }, { code => 'Action', required => 1, automated => 'hidden_field' }, @@ -74,7 +72,7 @@ FixMyStreet::override_config { url => 'http://example.org/', } }, waste => { kingston => 1 }, - echo => { kingston => { bulky_service_id => 413 }}, + echo => { kingston => { bulky_service_id => 986 }}, payment_gateway => { kingston => { cc_url => 'http://example.com', request_replace_cost => 1800, @@ -95,7 +93,7 @@ FixMyStreet::override_config { set_fixed_time('2022-09-10T12:00:00Z'); $mech->get_ok('/waste/12345'); $mech->content_contains('2 Example Street, Kingston'); - $mech->content_contains('Every Friday fortnightly'); + $mech->content_contains('Friday every other week'); $mech->content_contains('Friday, 2nd September'); $mech->content_contains('Report a mixed recycling collection as missed'); }; @@ -127,23 +125,23 @@ FixMyStreet::override_config { }; foreach ( - { id => 19, name => 'Blue lid paper and cardboard bin (240L)' }, - { id => 16, name => 'Green recycling box (55L)' }, - { id => 2, name => 'Black rubbish bin', ordered => 35 }, - { id => 12, name => 'Green recycling bin (240L)' }, + { id => 27, name => 'Blue lid paper and cardboard bin (240L)', service => 974 }, + { id => 12, name => 'Green recycling box (55L)', service => 970 }, + { id => 3, name => 'Black rubbish bin', ordered => 2, service => 966 }, + { id => 15, name => 'Green recycling bin (240L)', service => 970 }, ) { subtest "Request a new $_->{name}" => sub { my $ordered = $_->{ordered} || $_->{id}; $mech->get_ok('/waste/12345/request'); - # 19 (1), 24 (1), 16 (1), 2 (1) + # 27 (1), 46 (1), 12 (1), 3 (1) $mech->content_unlike(qr/Blue lid paper.*Blue lid paper/s); $mech->submit_form_ok({ with_fields => { 'container-' . $_->{id} => 1, 'quantity-' . $_->{id} => 1 }}); - if ($_->{id} == 12 || $_->{id} == 16) { - $mech->submit_form_ok({ with_fields => { 'removal-12' => 0, 'removal-16' => 0 } }); + if ($_->{id} == 15 || $_->{id} == 12) { + $mech->submit_form_ok({ with_fields => { 'removal-15' => 0, 'removal-12' => 0 } }); } else { $mech->submit_form_ok({ with_fields => { 'removal-' . $_->{id} => 0 } }); } - if ($_->{id} == 2) { + if ($_->{id} == 3) { $mech->submit_form_ok({ with_fields => { 'how_many' => 'less5' }}); } $mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }}); @@ -164,6 +162,7 @@ FixMyStreet::override_config { is $report->get_extra_field_value('payment_method'), 'credit_card', 'correct payment method on report'; is $report->get_extra_field_value('Container_Type'), $ordered, 'correct bin type'; is $report->get_extra_field_value('Action'), 1, 'correct container request action'; + is $report->get_extra_field_value('service_id'), $_->{service}; is $report->state, 'unconfirmed', 'report not confirmed'; is $report->get_extra_metadata('scpReference'), '12345', 'correct scp reference on report'; @@ -177,26 +176,26 @@ FixMyStreet::override_config { } subtest "Request a new green bin when you do not have a box" => sub { - # Switch the one 16 entry to a 12 - $bin_data->[0]{ServiceTasks}{ServiceTask}[3]{Data}{ExtensibleDatum}{ChildData}{ExtensibleDatum}[0]{Value} = '12'; + # Switch the one 12 entry to a 15 + $bin_data->[2]{Data}{ExtensibleDatum}{ChildData}{ExtensibleDatum}[0]{Value} = '15'; $mech->get_ok('/waste/12345/request'); - $mech->submit_form_ok({ with_fields => { 'container-12' => 1, 'quantity-12' => 1 }}); - $bin_data->[0]{ServiceTasks}{ServiceTask}[3]{Data}{ExtensibleDatum}{ChildData}{ExtensibleDatum}[0]{Value} = '16'; + $mech->submit_form_ok({ with_fields => { 'container-15' => 1, 'quantity-15' => 1 }}); + $bin_data->[2]{Data}{ExtensibleDatum}{ChildData}{ExtensibleDatum}[0]{Value} = '12'; }; subtest 'Request new containers' => sub { $mech->get_ok('/waste/12345/request'); - # Missing 2, Damaged 19, Damaged+missing 16, two missing 24 + # Missing 3, Damaged 27, Damaged+missing 12, two missing 46 $mech->content_contains('Only three are allowed per property'); - $mech->submit_form_ok({ with_fields => { 'container-2' => 1, 'container-19' => 1, 'container-16' => 1, 'quantity-16' => 2, 'quantity-24' => 2, 'container-24' => 1, 'quantity-19' => 1 }}); - $mech->submit_form_ok({ with_fields => { 'removal-2' => 0, 'removal-19' => 1, 'removal-16' => 1, 'removal-12' => 1, 'removal-24' => 0 } }); + $mech->submit_form_ok({ with_fields => { 'container-3' => 1, 'container-27' => 1, 'container-12' => 1, 'quantity-12' => 2, 'quantity-46' => 2, 'container-46' => 1, 'quantity-27' => 1 }}); + $mech->submit_form_ok({ with_fields => { 'removal-3' => 0, 'removal-27' => 1, 'removal-12' => 1, 'removal-15' => 1, 'removal-46' => 0 } }); $mech->submit_form_ok({ with_fields => { 'how_many' => '5more' }}); $mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }}); $mech->content_contains('Continue to payment'); - $mech->content_like(qr/Food waste bin \(outdoor\)<\/dt>\s*]*>\s*2\s*<\/dd>/); + $mech->content_like(qr/Food waste bin \(outdoor\)<\/dt>\s*]*>\s*2 to deliver\s*<\/dd>/); $mech->content_like(qr/Green recycling box \(55L\)<\/dt>\s*]*>\s*2\s+to deliver,\s+1 to remove\s*<\/dd>/); - $mech->content_like(qr/Black rubbish bin<\/dt>\s*]*>\s*1\s*<\/dd>/); + $mech->content_like(qr/Black rubbish bin<\/dt>\s*]*>\s*1 to deliver\s*<\/dd>/); $mech->content_like(qr/Blue lid paper and cardboard bin \(240L\)<\/dt>\s*]*>\s*1\s+to deliver,\s+1 to remove\s*<\/dd>/); $mech->content_like(qr/Green recycling bin \(240L\)<\/dt>\s*]*>\s*1 to remove\s*<\/dd>/); @@ -213,33 +212,38 @@ FixMyStreet::override_config { is $report->get_extra_field_value('uprn'), 1000000002; is $report->detail, "2 Example Street, Kingston, KT1 1AA"; is $report->category, 'Request new container'; - is $report->title, 'Request Green recycling bin (240L) collection'; - is $report->get_extra_field_value('payment'), '', 'correct payment'; + is $report->title, 'Request Green recycling box (55L) delivery'; + is $report->get_extra_field_value('payment'), '1800', 'correct payment'; is $report->get_extra_field_value('payment_method'), 'credit_card', 'correct payment method on report'; is $report->get_extra_field_value('Container_Type'), 12, 'correct bin type'; - is $report->get_extra_field_value('Action'), 2, 'correct container request action'; + is $report->get_extra_field_value('Action'), 1, 'correct container request action'; + is $report->get_extra_field_value('service_id'), 970; is $report->state, 'unconfirmed', 'report not confirmed'; is $report->get_extra_metadata('scpReference'), '12345', 'correct scp reference on report'; - my $sent_count = 0; + my $sent_count = 1; foreach (@{ $report->get_extra_metadata('grouped_ids') }) { my $report = FixMyStreet::DB->resultset("Problem")->find($_); is $report->get_extra_field_value('uprn'), 1000000002; - if ($report->title =~ /^Request Green recycling box/) { - is $report->get_extra_field_value('Container_Type'), 16, 'correct bin type'; - if ($report->title =~ /delivery/) { - is $report->get_extra_field_value('payment'), 1800, 'correct payment'; - } else { - is $report->get_extra_field_value('payment'), 900, 'correct payment'; - } + if ($report->title eq 'Request Green recycling bin (240L) collection') { + is $report->get_extra_field_value('Container_Type'), 15, 'correct bin type'; + is $report->get_extra_field_value('service_id'), 970; + is $report->get_extra_field_value('payment'), '', 'correct payment'; + } elsif ($report->title =~ /^Request Green recycling box/) { + is $report->get_extra_field_value('Container_Type'), 12, 'correct bin type'; + is $report->get_extra_field_value('service_id'), 970; + is $report->get_extra_field_value('payment'), 900, 'correct payment'; } elsif ($report->title eq 'Request Black rubbish bin delivery') { - is $report->get_extra_field_value('Container_Type'), 2, 'correct bin type'; + is $report->get_extra_field_value('Container_Type'), 3, 'correct bin type'; + is $report->get_extra_field_value('service_id'), 966; is $report->get_extra_field_value('payment'), 900, 'correct payment'; } elsif ($report->title eq 'Request Food waste bin (outdoor) delivery') { - is $report->get_extra_field_value('Container_Type'), 24, 'correct bin type'; + is $report->get_extra_field_value('Container_Type'), 46, 'correct bin type'; + is $report->get_extra_field_value('service_id'), 980; is $report->get_extra_field_value('payment'), "", 'correct payment'; } elsif ($report->title eq 'Request Blue lid paper and cardboard bin (240L) replacement') { - is $report->get_extra_field_value('Container_Type'), 19, 'correct bin type'; + is $report->get_extra_field_value('Container_Type'), 27, 'correct bin type'; + is $report->get_extra_field_value('service_id'), 974; is $report->get_extra_field_value('payment'), 900, 'correct payment'; } else { is $report->title, 'BAD'; @@ -248,13 +252,15 @@ FixMyStreet::override_config { is $report->category, 'Request new container'; is $report->get_extra_field_value('payment_method'), 'credit_card', 'correct payment method on report'; if ($report->title =~ /replacement$/) { - is $report->get_extra_field_value('Action'), 3, 'correct container request action'; + is $report->get_extra_field_value('Action'), '2::1', 'correct container request action'; + } elsif ($report->title =~ /collection$/) { + is $report->get_extra_field_value('Action'), 2, 'correct container request action'; } else { is $report->get_extra_field_value('Action'), 1, 'correct container request action'; } is $report->state, 'confirmed', 'report confirmed'; is $report->get_extra_metadata('scpReference'), undef, 'only original report has SCP ref'; - next if $report->title =~ /Food/; + next if $report->title =~ /Food|collection/; is $pay_params->{items}[$sent_count]{description}, $report->title; is $pay_params->{items}[$sent_count]{lineId}, 'RBK-CCH-' . $report->id . '-Bob Marge'; is $pay_params->{items}[$sent_count]{amount}, $sent_count == 0 ? 1800 : 900; @@ -265,8 +271,8 @@ FixMyStreet::override_config { my $req = Open311->test_req_used; my $cgi = CGI::Simple->new($req->content); # Not sure which one will have been sent last - like $cgi->param('attribute[Action]'), qr/^[1-3]$/; - like $cgi->param('attribute[Reason]'), qr/^[1-3]$/; + like $cgi->param('attribute[Action]'), qr/^(1|2|2::1)$/; + like $cgi->param('attribute[Reason]'), qr/^[148]$/; }; subtest 'Request refuse exchange' => sub { @@ -275,35 +281,41 @@ FixMyStreet::override_config { $mech->follow_link_ok({ text => 'Request a larger/smaller refuse container' }); $mech->content_contains('Smaller black rubbish bin'); $mech->content_contains('Larger black rubbish bin'); - $mech->submit_form_ok({ with_fields => { 'container-capacity-change' => 3 } }); + $mech->submit_form_ok({ with_fields => { 'container-capacity-change' => 4 } }); is $mech->uri->path_query, '/faq?refuse-application?uprn=1000000002'; }; subtest '180L, small household' => sub { - $bin_data->[1]{ServiceTasks}{ServiceTask}{Data}{ExtensibleDatum}{ChildData}{ExtensibleDatum}[0]{Value} = '35'; + $bin_data->[3]{Data}{ExtensibleDatum}{ChildData}{ExtensibleDatum}[0]{Value} = '2'; $mech->get_ok('/waste/12345/request?exchange=1'); $mech->submit_form_ok({ with_fields => { 'how_many_exchange' => 'less5' }}); $mech->content_contains('You already have the biggest sized bin allowed.'); }; subtest '180L, very large household' => sub { - $bin_data->[1]{ServiceTasks}{ServiceTask}{Data}{ExtensibleDatum}{ChildData}{ExtensibleDatum}[0]{Value} = '35'; + $bin_data->[3]{Data}{ExtensibleDatum}{ChildData}{ExtensibleDatum}[0]{Value} = '2'; $mech->get_ok('/waste/12345/request?exchange=1'); $mech->submit_form_ok({ with_fields => { 'how_many_exchange' => '7more' }}); $mech->content_contains('you can apply for more capacity'); }; + my %names = ( + 1 => 'Black rubbish bin (140L)', + 2 => 'Black rubbish bin (180L)', + 3 => 'Black rubbish bin (240L)', + 4 => 'Black rubbish bin (360L)', + ); foreach ( - { has => 2, id => 35, name => "Black rubbish bin (180L)" }, # 240L going smaller - { has => 35, id => 2, name => "Black rubbish bin (240L)" }, # 180L, 5 or 6 people - { has => 3, id => 35, name => "Black rubbish bin (180L)" }, # 360L going smaller - { has => 3, id => 2, name => "Black rubbish bin (240L)" }, # 360L going smaller + { has => 3, id => 2 }, # 240L going smaller + { has => 2, id => 3 }, # 180L, 5 or 6 people + { has => 4, id => 2 }, # 360L going smaller + { has => 4, id => 3 }, # 360L going smaller ) { - subtest "Has a $_->{has}, ordering a $_->{name}" => sub { - $bin_data->[1]{ServiceTasks}{ServiceTask}{Data}{ExtensibleDatum}{ChildData}{ExtensibleDatum}[0]{Value} = $_->{has}; + subtest "Has a $names{$_->{has}}, ordering a $names{$_->{id}}" => sub { + $bin_data->[3]{Data}{ExtensibleDatum}{ChildData}{ExtensibleDatum}[0]{Value} = $_->{has}; $mech->get_ok('/waste/12345/request?exchange=1'); - if ($_->{has} == 2) { + if ($_->{has} == 3) { $mech->content_contains('Smaller black rubbish bin'); $mech->content_contains('Larger black rubbish bin'); } - if ($_->{has} == 35) { + if ($_->{has} == 2) { $mech->submit_form_ok({ with_fields => { 'how_many_exchange' => '5or6' }}); } else { $mech->submit_form_ok({ with_fields => { 'container-capacity-change' => $_->{id} } }); @@ -320,29 +332,29 @@ FixMyStreet::override_config { is $report->get_extra_field_value('uprn'), 1000000002; is $report->detail, "2 Example Street, Kingston, KT1 1AA"; is $report->category, 'Request new container'; - is $report->title, "Request $_->{name} replacement"; + is $report->title, "Request $names{$_->{id}} replacement"; is $report->get_extra_field_value('payment'), 1800, 'correct payment'; is $report->get_extra_field_value('payment_method'), 'credit_card', 'correct payment method on report'; - is $report->get_extra_field_value('Container_Type'), $_->{id}, 'correct bin type'; - is $report->get_extra_field_value('Action'), 3, 'correct container request action'; - is $report->state, 'unconfirmed', 'report not confirmed'; + is $report->get_extra_field_value('Container_Type'), "$_->{has}::$_->{id}", 'correct bin type'; + is $report->get_extra_field_value('Action'), '2::1', 'correct container request action'; is $report->get_extra_metadata('scpReference'), '12345', 'correct scp reference on report'; + is $report->get_extra_field_value('service_id'), 966; FixMyStreet::Script::Reports::send(); my $req = Open311->test_req_used; my $cgi = CGI::Simple->new($req->content); - is $cgi->param('attribute[Action]'), '3'; - is $cgi->param('attribute[Reason]'), '3'; + is $cgi->param('attribute[Action]'), '2::1'; + is $cgi->param('attribute[Reason]'), $_->{has} < $_->{id} ? 9 : 10; }; } }; # Reset back to 240L - $bin_data->[1]{ServiceTasks}{ServiceTask}{Data}{ExtensibleDatum}{ChildData}{ExtensibleDatum}[0]{Value} = '2'; + $bin_data->[3]{Data}{ExtensibleDatum}{ChildData}{ExtensibleDatum}[0]{Value} = '3'; subtest 'Request bins from front page' => sub { $mech->get_ok('/waste/12345'); $mech->submit_form_ok({ form_number => 7 }); - $mech->content_contains('name="container-2" value="1"'); + $mech->content_contains('name="container-3" value="1"'); $mech->content_contains('Blue lid paper and cardboard bin'); $mech->content_contains('Green recycling box'); $mech->content_contains('Food waste bin (outdoor)'); @@ -355,7 +367,7 @@ FixMyStreet::override_config { $mech->content_contains('Non-recyclable Refuse'); $mech->content_lacks('Paper and card'); - $mech->submit_form_ok({ with_fields => { 'service-2239' => 1 } }); + $mech->submit_form_ok({ with_fields => { 'service-980' => 1 } }); $mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }}); $mech->submit_form_ok({ with_fields => { process => 'summary' } }); $mech->content_contains('Thank you for reporting a missed collection'); @@ -372,13 +384,13 @@ FixMyStreet::override_config { $e->mock('GetEventsForObject', sub { [ { # Request - EventTypeId => 1635, + EventTypeId => 3129, Data => { ExtensibleDatum => [ { Value => 2, DatatypeName => 'Source' }, { ChildData => { ExtensibleDatum => [ { Value => 1, DatatypeName => 'Action' }, - { Value => 16, DatatypeName => 'Container Type' }, + { Value => 12, DatatypeName => 'Container Type' }, ] }, }, ] }, @@ -387,17 +399,17 @@ FixMyStreet::override_config { $mech->content_contains('A mixed recycling container request has been made'); $mech->content_contains('Report a mixed recycling collection as missed'); $mech->get_ok('/waste/12345/request'); - $mech->content_like(qr/name="container-16" value="1"[^>]+disabled/s); # green + $mech->content_like(qr/name="container-12" value="1"[^>]+disabled/s); # green $e->mock('GetEventsForObject', sub { [ { # Request - EventTypeId => 1635, + EventTypeId => 3129, Data => { ExtensibleDatum => [ { Value => 2, DatatypeName => 'Source' }, { ChildData => { ExtensibleDatum => [ { Value => 1, DatatypeName => 'Action' }, - { Value => 23, DatatypeName => 'Container Type' }, + { Value => 43, DatatypeName => 'Container Type' }, ] }, }, ] }, @@ -405,28 +417,22 @@ FixMyStreet::override_config { $mech->get_ok('/waste/12345'); $mech->content_contains('A food waste container request has been made'); $mech->get_ok('/waste/12345/request'); - $mech->content_like(qr/name="container-23" value="1"[^>]+disabled/s); # indoor - $mech->content_like(qr/name="container-24" value="1"[^>]+>/s); # outdoor + $mech->content_like(qr/name="container-43" value="1"[^>]+disabled/s); # indoor + $mech->content_like(qr/name="container-46" value="1"[^>]+>/s); # outdoor $e->mock('GetEventsForObject', sub { [ { - EventTypeId => 1566, + EventTypeId => 3145, EventDate => { DateTime => "2022-09-10T17:00:00Z" }, - ServiceId => 408, - Data => { ExtensibleDatum => [ - { Value => 1, DatatypeName => 'Container Mix' }, - ] }, + ServiceId => 970, } ] }); $mech->get_ok('/waste/12345'); $mech->content_contains('A mixed recycling collection has been reported as missed'); $mech->content_contains('Request a mixed recycling container'); $e->mock('GetEventsForObject', sub { [ { - EventTypeId => 1566, + EventTypeId => 3145, EventDate => { DateTime => "2022-09-10T17:00:00Z" }, - ServiceId => 408, - Data => { ExtensibleDatum => { - Value => 1, DatatypeName => 'Paper' - } }, + ServiceId => 974, } ] }); $mech->get_ok('/waste/12345'); $mech->content_contains('A paper and card collection has been reported as missed'); @@ -441,8 +447,8 @@ FixMyStreet::override_config { }; subtest 'Fortnightly collection can request a blue stripe bag' => sub { $mech->get_ok('/waste/12345/request'); - $mech->submit_form_ok({ with_fields => { 'container-18' => 1 }}); - $mech->submit_form_ok({ with_fields => { 'removal-18' => 0 } }); + $mech->submit_form_ok({ with_fields => { 'container-22' => 1 }}); + $mech->submit_form_ok({ with_fields => { 'removal-22' => 0 } }); $mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }}); $mech->submit_form_ok({ with_fields => { process => 'summary' } }); $mech->content_contains('request has been sent'); @@ -455,7 +461,7 @@ FixMyStreet::override_config { subtest 'Weekly collection cannot request a blue stripe bag' => sub { $e->mock('GetServiceUnitsForObject', sub { $above_shop_data }); $mech->get_ok('/waste/12345/request'); - $mech->content_lacks('"container-18" value="1"'); + $mech->content_lacks('"container-22" value="1"'); $e->mock('GetServiceUnitsForObject', sub { $bin_data }); }; diff --git a/t/app/controller/waste_merton_garden.t b/t/app/controller/waste_merton_garden.t index dbb1d54fc27..43eea0d7576 100644 --- a/t/app/controller/waste_merton_garden.t +++ b/t/app/controller/waste_merton_garden.t @@ -794,7 +794,7 @@ FixMyStreet::override_config { )->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('End_Date'), '2021-03-09', 'cancel date set to current date'; + is $new_report->get_extra_field_value('End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->get_extra_field_value('Bin_Detail_Container'), 26, 'correct container request bin type'; is $new_report->get_extra_field_value('Bin_Detail_Type'), 2, 'correct container request action'; is $new_report->get_extra_field_value('Bin_Detail_Quantity'), 1, 'correct container request count'; @@ -998,7 +998,7 @@ FixMyStreet::override_config { )->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('End_Date'), '2021-03-09', 'cancel date set to current date'; + is $new_report->get_extra_field_value('End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->get_extra_field_value('Bin_Detail_Container'), 26, 'correct container request bin type'; is $new_report->get_extra_field_value('Bin_Detail_Type'), 2, 'correct container request action'; is $new_report->get_extra_field_value('Bin_Detail_Quantity'), 1, 'correct container request count'; @@ -1067,7 +1067,7 @@ FixMyStreet::override_config { )->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('End_Date'), '2021-03-09', 'cancel date set to current date'; + is $new_report->get_extra_field_value('End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->get_extra_field_value('Bin_Detail_Container'), '', 'correct container request bin type'; is $new_report->get_extra_field_value('Bin_Detail_Type'), '', 'correct container request action'; is $new_report->get_extra_field_value('Bin_Detail_Quantity'), '', 'correct container request count'; @@ -1307,7 +1307,7 @@ FixMyStreet::override_config { )->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('End_Date'), '2021-03-09', 'cancel date set to current date'; + is $new_report->get_extra_field_value('End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->state, 'confirmed', 'report confirmed'; is $new_report->get_extra_metadata('contributed_by'), $staff_user->id; is $new_report->get_extra_metadata('contributed_as'), 'another_user'; @@ -1421,7 +1421,7 @@ FixMyStreet::override_config { )->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('End_Date'), '2021-03-09', 'cancel date set to current date'; + is $new_report->get_extra_field_value('End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->state, 'confirmed', 'report confirmed'; }; diff --git a/t/app/controller/waste_sutton_4443082.json b/t/app/controller/waste_sutton_4443082.json new file mode 100644 index 00000000000..7185a1392b4 --- /dev/null +++ b/t/app/controller/waste_sutton_4443082.json @@ -0,0 +1,190 @@ +[ + { + "Data": { + "ExtensibleDatum": { + "Value": "Paper Recycling 240L ", + "DatatypeName": "Recycling Containers", + "ChildData": { + "ExtensibleDatum": [ + { "DatatypeName": "Container Type", "Value": "27" }, + { "DatatypeName": "Container Quantity", "Value": "1" } + ] + } + } + }, + "ServiceTasks": { + "ServiceTask": [ + { + "TaskTypeId": "4388", + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "ScheduleDescription": "Friday every other week", + "NextInstance": { + "CurrentScheduledDate": { "DateTime": "2022-09-15T23:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-15T23:00:00Z" } + }, + "LastInstance": { + "CurrentScheduledDate": { "DateTime": "2022-09-02T05:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-01T23:00:00Z" }, + "Ref": { "Value": { "anyType": [ "22239416", "8280" ] } }, + "CompletedDate": { "DateTime": "2022-09-02T06:17:01Z" } + }, + "StartDate": { "DateTime": "2018-09-02T23:00:00Z" }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" } + } + }, + "TaskIndicatorId": "33", + "Id": "2001", + "TaskTypeName": "Collect Domestic Paper", + "ScheduleDescription": "Every Friday fortnightly" + } + ] + }, + "ServiceName": "Domestic Paper Collection", + "ServiceId": "948", + "Id": "1001" + }, + { + "Data": { + "ExtensibleDatum": [ { + "ChildData": { + "ExtensibleDatum": [ + { "Value": "46", "DatatypeName": "Container Type" }, + { "Value": "1", "DatatypeName": "Container Quantity" } + ] + }, + "DatatypeName": "Food Containers", + "DatatypeId": "3955", + "Value": "Food Caddy 23L" + } ] + }, + "ServiceTasks": { + "ServiceTask": [ + { + "TaskTypeId": "4389", + "ServiceTaskSchedules": { + "ServiceTaskSchedule": [ + { + "LastInstance": { + "Ref": { "Value": { "anyType": [ "22244305", "8287" ] } }, + "OriginalScheduledDate": { "DateTime": "2022-09-08T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-09-09T05:00:00Z" }, + "CompletedDate": { "DateTime": "2022-09-09T05:42:38.93Z" } + }, + "StartDate": { "DateTime": "2018-09-02T23:00:00Z" }, + "NextInstance": null, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "ScheduleDescription": null + }, + { + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "StartDate": { "DateTime": "2018-09-02T23:00:00Z" }, + "LastInstance": null, + "NextInstance": { + "CurrentScheduledDate": { "DateTime": "2022-09-15T23:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-15T23:00:00Z" } + }, + "ScheduleDescription": "Friday every other week" + } + ] + }, + "TaskIndicatorId": "33", + "TaskTypeName": "Collect Domestic Food", + "Id": "2002", + "ScheduleDescription": "Every Friday" + } + ] + }, + "ServiceName": "Domestic Food Collection", + "ServiceId": "954", + "Id": "1002" + }, + { + "Data": { + "ExtensibleDatum": { + "DatatypeName": "Recycling Containers", + "DatatypeId": "3964", + "Value": "Recycling 55L Box", + "ChildData": { + "ExtensibleDatum": [ + { "Value": "12", "DatatypeName": "Container Type" }, + { "Value": "3", "DatatypeName": "Container Quantity" } + ] + } + } + }, + "ServiceTasks": { + "ServiceTask": [ + { + "TaskIndicatorId": "33", + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "ScheduleDescription": "Friday every other week", + "NextInstance": { + "CurrentScheduledDate": { "DateTime": "2022-09-22T23:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-22T23:00:00Z" } + }, + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" }, + "LastInstance": { + "CompletedDate": { "DateTime": "2022-09-09T05:52:03.367Z" }, + "Ref": { "Value": { "anyType": [ "17510905", "8287" ] } }, + "CurrentScheduledDate": { "DateTime": "2022-09-09T05:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-08T23:00:00Z" } + }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" } + } + }, + "TaskTypeId": "4390", + "ScheduleDescription": "Every Friday fortnightly", + "TaskTypeName": "Collect Domestic Recycling", + "Id": "2003" + } + ] + }, + "ServiceName": "Domestic Recycling Collection", + "ServiceId": "944", + "Id": "1003" + }, + { + "ServiceId": "940", + "ServiceName": "Domestic Refuse Collection", + "Id": "1004", + "Data": { + "ExtensibleDatum": { + "ChildData": { + "ExtensibleDatum": [ + { "Value": "1", "DatatypeName": "Container Type" }, + { "Value": "1", "DatatypeName": "Container Quantity" } + ] + }, + "DatatypeName": "Refuse Containers" + } + }, + "ServiceTasks": { + "ServiceTask": { + "ScheduleDescription": "Every Friday fortnightly", + "Id": "2004", + "TaskTypeName": "Collect Domestic Refuse Bin", + "TaskIndicatorId": "33", + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "ScheduleDescription": "Friday every other week", + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" }, + "LastInstance": { + "Ref": { "Value": { "anyType": [ "17430692", "8287" ] } }, + "CurrentScheduledDate": { "DateTime": "2022-09-09T05:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-08T23:00:00Z" }, + "CompletedDate": { "DateTime": "2022-09-09T08:19:22.76Z" } + }, + "NextInstance": { + "OriginalScheduledDate": { "DateTime": "2022-09-22T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-09-22T23:00:00Z" } + } + } + }, + "TaskTypeId": "4394" + } + } + } +] diff --git a/t/app/controller/waste_sutton_4443082_140.json b/t/app/controller/waste_sutton_4443082_140.json new file mode 100644 index 00000000000..53e95c39944 --- /dev/null +++ b/t/app/controller/waste_sutton_4443082_140.json @@ -0,0 +1,190 @@ +[ + { + "Data": { + "ExtensibleDatum": { + "Value": "Paper Recycling 240L ", + "DatatypeName": "Recycling Containers", + "ChildData": { + "ExtensibleDatum": [ + { "DatatypeName": "Container Type", "Value": "26" }, + { "DatatypeName": "Container Quantity", "Value": "1" } + ] + } + } + }, + "ServiceTasks": { + "ServiceTask": [ + { + "TaskTypeId": "4388", + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "ScheduleDescription": "Friday every other week", + "NextInstance": { + "CurrentScheduledDate": { "DateTime": "2022-09-15T23:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-15T23:00:00Z" } + }, + "LastInstance": { + "CurrentScheduledDate": { "DateTime": "2022-09-02T05:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-01T23:00:00Z" }, + "Ref": { "Value": { "anyType": [ "22239416", "8280" ] } }, + "CompletedDate": { "DateTime": "2022-09-02T06:17:01Z" } + }, + "StartDate": { "DateTime": "2018-09-02T23:00:00Z" }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" } + } + }, + "TaskIndicatorId": "33", + "Id": "2001", + "TaskTypeName": "Collect Domestic Paper", + "ScheduleDescription": "Every Friday fortnightly" + } + ] + }, + "ServiceName": "Domestic Paper Collection", + "ServiceId": "948", + "Id": "1001" + }, + { + "Data": { + "ExtensibleDatum": [ { + "ChildData": { + "ExtensibleDatum": [ + { "Value": "46", "DatatypeName": "Container Type" }, + { "Value": "1", "DatatypeName": "Container Quantity" } + ] + }, + "DatatypeName": "Food Containers", + "DatatypeId": "3955", + "Value": "Food Caddy 23L" + } ] + }, + "ServiceTasks": { + "ServiceTask": [ + { + "TaskTypeId": "4389", + "ServiceTaskSchedules": { + "ServiceTaskSchedule": [ + { + "LastInstance": { + "Ref": { "Value": { "anyType": [ "22244305", "8287" ] } }, + "OriginalScheduledDate": { "DateTime": "2022-09-08T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-09-09T05:00:00Z" }, + "CompletedDate": { "DateTime": "2022-09-09T05:42:38.93Z" } + }, + "StartDate": { "DateTime": "2018-09-02T23:00:00Z" }, + "NextInstance": null, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "ScheduleDescription": null + }, + { + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "StartDate": { "DateTime": "2018-09-02T23:00:00Z" }, + "LastInstance": null, + "NextInstance": { + "CurrentScheduledDate": { "DateTime": "2022-09-15T23:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-15T23:00:00Z" } + }, + "ScheduleDescription": "Friday every other week" + } + ] + }, + "TaskIndicatorId": "33", + "TaskTypeName": "Collect Domestic Food", + "Id": "2002", + "ScheduleDescription": "Every Friday" + } + ] + }, + "ServiceName": "Domestic Food Collection", + "ServiceId": "954", + "Id": "1002" + }, + { + "Data": { + "ExtensibleDatum": { + "DatatypeName": "Recycling Containers", + "DatatypeId": "3964", + "Value": "Recycling 55L Box", + "ChildData": { + "ExtensibleDatum": [ + { "Value": "12", "DatatypeName": "Container Type" }, + { "Value": "3", "DatatypeName": "Container Quantity" } + ] + } + } + }, + "ServiceTasks": { + "ServiceTask": [ + { + "TaskIndicatorId": "33", + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "ScheduleDescription": "Friday every other week", + "NextInstance": { + "CurrentScheduledDate": { "DateTime": "2022-09-22T23:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-22T23:00:00Z" } + }, + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" }, + "LastInstance": { + "CompletedDate": { "DateTime": "2022-09-09T05:52:03.367Z" }, + "Ref": { "Value": { "anyType": [ "17510905", "8287" ] } }, + "CurrentScheduledDate": { "DateTime": "2022-09-09T05:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-08T23:00:00Z" } + }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" } + } + }, + "TaskTypeId": "4390", + "ScheduleDescription": "Every Friday fortnightly", + "TaskTypeName": "Collect Domestic Recycling", + "Id": "2003" + } + ] + }, + "ServiceName": "Domestic Recycling Collection", + "ServiceId": "944", + "Id": "1003" + }, + { + "ServiceId": "940", + "ServiceName": "Domestic Refuse Collection", + "Id": "1004", + "Data": { + "ExtensibleDatum": { + "ChildData": { + "ExtensibleDatum": [ + { "Value": "1", "DatatypeName": "Container Type" }, + { "Value": "1", "DatatypeName": "Container Quantity" } + ] + }, + "DatatypeName": "Refuse Containers" + } + }, + "ServiceTasks": { + "ServiceTask": { + "ScheduleDescription": "Every Friday fortnightly", + "Id": "2004", + "TaskTypeName": "Collect Domestic Refuse Bin", + "TaskIndicatorId": "33", + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "ScheduleDescription": "Friday every other week", + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" }, + "LastInstance": { + "Ref": { "Value": { "anyType": [ "17430692", "8287" ] } }, + "CurrentScheduledDate": { "DateTime": "2022-09-09T05:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-09-08T23:00:00Z" }, + "CompletedDate": { "DateTime": "2022-09-09T08:19:22.76Z" } + }, + "NextInstance": { + "OriginalScheduledDate": { "DateTime": "2022-09-22T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-09-22T23:00:00Z" } + } + } + }, + "TaskTypeId": "4394" + } + } + } +] diff --git a/t/app/controller/waste_sutton_4471550.json b/t/app/controller/waste_sutton_4471550.json new file mode 100644 index 00000000000..5a312fb323a --- /dev/null +++ b/t/app/controller/waste_sutton_4471550.json @@ -0,0 +1,137 @@ +[ + { + "Data": { + "ExtensibleDatum": { + "ChildData": { + "ExtensibleDatum": [ + { "DatatypeName": "Container Type", "Value": "10" }, + { "Value": "1", "DatatypeName": "Container Quantity" } + ] + }, + "DatatypeName": "Refuse Containers" + } + }, + "ServiceTasks": { + "ServiceTask": { + "Id": "2001", + "TaskTypeId": "4395", + "TaskTypeName": "Collect Domestic Refuse Bag", + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "StartDate": { "DateTime": "2018-09-02T23:00:00Z" }, + "NextInstance": { + "Ref": { "Value": { "anyType": [ "23285360", "8332" ] } }, + "CurrentScheduledDate": { "DateTime": "2022-10-23T23:00:00Z" }, + "OriginalScheduledDate": { "DateTime": "2022-10-23T23:00:00Z" } + }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "LastInstance": { + "Ref": { "Value": { "anyType": [ "23285360", "8318" ] } }, + "OriginalScheduledDate": { "DateTime": "2022-10-09T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-10-10T05:00:00Z" } + }, + "ScheduleDescription": "Monday every other week" + } + }, + "ScheduleDescription": "Every Monday fortnightly" + } + }, + "ServiceName": "Domestic Refuse Collection", + "ServiceId": "941", + "Id": "1001" + }, + { + "ServiceName": "FAS Paper Collection", + "ServiceId": "949", + "Id": "1003", + "Data": { + "ExtensibleDatum": { + "DatatypeName": "Recycling Containers", + "ChildData": { + "ExtensibleDatum": [ + { "Value": "34", "DatatypeName": "Container Type" }, + { "Value": "1", "DatatypeName": "Container Quantity" } + ] + } + } + }, + "ServiceTasks": { + "ServiceTask": [ + { + "Id": "2002", + "ScheduleDescription": "Every Monday fortnightly", + "TaskTypeId": "4402", + "TaskTypeName": "Collect Domestic Paper Bag", + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "ScheduleDescription": "Monday every other week", + "LastInstance": { + "OriginalScheduledDate": { "DateTime": "2022-10-09T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-10-10T05:00:00Z" }, + "Ref": { "Value": { "anyType": [ "22282336", "8318" ] } } + }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "NextInstance": { + "OriginalScheduledDate": { "DateTime": "2022-10-23T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-10-23T23:00:00Z" }, + "Ref": { "Value": { "anyType": [ "22282336", "8332" ] } } + }, + "StartDate": { "DateTime": "2018-09-02T23:00:00Z" } + } + }, + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" } + } + ] + } + }, + { + "ServiceName": "Domestic Recycling Collection", + "ServiceId": "945", + "Id": "1004", + "Data": { + "ExtensibleDatum": [ + { + "ChildData": { + "ExtensibleDatum": [ + { "DatatypeName": "Container Type", "Value": "22" }, + { "Value": "1", "DatatypeName": "Container Quantity" } + ] + }, + "DatatypeName": "Recycling Containers" + } + ] + }, + "ServiceTasks": { + "ServiceTask": [ + { + "ScheduleDescription": "Every Monday fortnightly", + "TaskTypeId": "4391", + "TaskTypeName": "Collect Domestic Recycling Bag", + "ServiceTaskSchedules": { + "ServiceTaskSchedule": { + "NextInstance": { + "Ref": { "Value": { "anyType": [ "22252757", "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" }, + "LastInstance": { + "Ref": { "Value": { "anyType": [ "22252757", "8311" ] } }, + "OriginalScheduledDate": { "DateTime": "2022-10-02T23:00:00Z" }, + "CurrentScheduledDate": { "DateTime": "2022-10-03T05:00:00Z" } + }, + "ScheduleDescription": "Monday every other week" + } + }, + "Id": "2003", + "EndDate": { "DateTime": "2050-01-01T00:00:00Z" }, + "StartDate": { "DateTime": "2017-01-01T00:00:00Z" } + } + ] + } + } +] diff --git a/t/app/controller/waste_sutton_garden.t b/t/app/controller/waste_sutton_garden.t index ef845cf3304..03cb8b5737c 100644 --- a/t/app/controller/waste_sutton_garden.t +++ b/t/app/controller/waste_sutton_garden.t @@ -29,12 +29,10 @@ sub create_contact { } create_contact({ category => 'Garden Subscription', email => 'garden@example.com'}, - { code => 'Request_Type', required => 1, automated => 'hidden_field' }, - { code => 'Subscription_Details_Quantity', required => 1, automated => 'hidden_field' }, - { code => 'Subscription_Details_Containers', required => 1, automated => 'hidden_field' }, - { code => 'Bin_Delivery_Detail_Quantity', required => 1, automated => 'hidden_field' }, - { code => 'Bin_Delivery_Detail_Container', required => 1, automated => 'hidden_field' }, - { code => 'Bin_Delivery_Detail_Containers', required => 1, automated => 'hidden_field' }, + { code => 'Paid_Container_Quantity', required => 1, automated => 'hidden_field' }, + { code => 'Paid_Container_Type', required => 1, automated => 'hidden_field' }, + { code => 'Quantity', required => 1, automated => 'hidden_field' }, + { code => 'Container_Type', required => 1, automated => 'hidden_field' }, { code => 'current_containers', required => 1, automated => 'hidden_field' }, { code => 'new_containers', required => 1, automated => 'hidden_field' }, { code => 'payment', required => 1, automated => 'hidden_field' }, @@ -42,14 +40,20 @@ create_contact({ category => 'Garden Subscription', email => 'garden@example.com { code => 'pro_rata', required => 0, automated => 'hidden_field' }, { code => 'admin_fee', required => 0, automated => 'hidden_field' }, ); -create_contact({ category => 'Cancel Garden Subscription', email => 'garden_cancel@example.com'}, - { code => 'Bin_Delivery_Detail_Quantity', required => 1, automated => 'hidden_field' }, - { code => 'Bin_Delivery_Detail_Container', required => 1, automated => 'hidden_field' }, - { code => 'Bin_Delivery_Detail_Containers', required => 1, automated => 'hidden_field' }, - { code => 'Subscription_End_Date', required => 1, automated => 'hidden_field' }, +create_contact({ category => 'Amend Garden Subscription', email => 'garden@example.com'}, + { code => 'Additional_Container_Quantity', required => 1, automated => 'hidden_field' }, + { code => 'Additional_Collection_Container_Type', required => 1, automated => 'hidden_field' }, + { code => 'Container_Ordered_Quantity', required => 1, automated => 'hidden_field' }, + { code => 'Container_Ordered_Type', required => 1, automated => 'hidden_field' }, + { code => 'current_containers', required => 1, automated => 'hidden_field' }, + { code => 'new_containers', required => 1, automated => 'hidden_field' }, + { code => 'payment', required => 1, automated => 'hidden_field' }, { code => 'payment_method', required => 1, automated => 'hidden_field' }, - { code => 'dd_contact_id', required => 0, automated => 'hidden_field' }, - { code => 'dd_mandate_id', required => 0, automated => 'hidden_field' }, + { code => 'pro_rata', required => 0, automated => 'hidden_field' }, + { code => 'admin_fee', required => 0, automated => 'hidden_field' }, +); +create_contact({ category => 'Cancel Garden Subscription', email => 'garden_cancel@example.com'}, + { code => 'End_Date', required => 1, automated => 'hidden_field' }, ); package SOAP::Result; @@ -61,21 +65,21 @@ package main; sub garden_waste_no_bins { return [ { Id => 1001, - ServiceId => 405, + ServiceId => 954, ServiceName => 'Food waste collection', + Data => { ExtensibleDatum => [ { + DatatypeName => 'Container Details', + ChildData => { ExtensibleDatum => [ { + DatatypeName => 'Container Quantity', + Value => 1, + }, { + DatatypeName => 'Container Type', + Value => 46, + } ] }, + } ] }, ServiceTasks => { ServiceTask => { Id => 400, - TaskTypeId => 2239, - Data => { ExtensibleDatum => [ { - DatatypeName => 'SLWP - Containers', - ChildData => { ExtensibleDatum => [ { - DatatypeName => 'Quantity', - Value => 1, - }, { - DatatypeName => 'Container Type', - Value => 24, - } ] }, - } ] }, + TaskTypeId => 4389, ServiceTaskSchedules => { ServiceTaskSchedule => [ { ScheduleDescription => 'every other Monday', StartDate => { DateTime => '2020-01-01T00:00:00Z' }, @@ -94,7 +98,7 @@ sub garden_waste_no_bins { }, { # Eligibility for garden waste, but no task Id => 1002, - ServiceId => 409, + ServiceId => 953, ServiceName => 'Garden waste collection', ServiceTasks => '' } ]; @@ -115,21 +119,21 @@ sub garden_waste_two_bins { sub garden_waste_only_refuse_sacks { return [ { Id => 1001, - ServiceId => 405, + ServiceId => 941, ServiceName => 'Refuse collection', + Data => { ExtensibleDatum => [ { + DatatypeName => 'Container Details', + ChildData => { ExtensibleDatum => [ { + DatatypeName => 'Container Quantity', + Value => 1, + }, { + DatatypeName => 'Container Type', + Value => 1, + } ] }, + } ] }, ServiceTasks => { ServiceTask => { Id => 400, - TaskTypeId => 2242, - Data => { ExtensibleDatum => [ { - DatatypeName => 'SLWP - Containers', - ChildData => { ExtensibleDatum => [ { - DatatypeName => 'Quantity', - Value => 1, - }, { - DatatypeName => 'Container Type', - Value => 1, - } ] }, - } ] }, + TaskTypeId => 4395, ServiceTaskSchedules => { ServiceTaskSchedule => [ { ScheduleDescription => 'every other Monday', StartDate => { DateTime => '2020-01-01T00:00:00Z' }, @@ -148,7 +152,7 @@ sub garden_waste_only_refuse_sacks { }, { # Eligibility for garden waste, but no task Id => 1002, - ServiceId => 409, + ServiceId => 953, ServiceName => 'Garden waste collection', ServiceTasks => '' } ]; @@ -173,25 +177,25 @@ sub garden_waste_bin_with_refuse_sacks { sub _garden_waste_service_units { my ($bin_count, $type) = @_; - my $bin_type_id = $type eq 'sack' ? 28 : 26; + my $bin_type_id = $type eq 'sack' ? 36 : 39; return [ { Id => 1002, - ServiceId => 409, + ServiceId => 953, ServiceName => 'Garden waste collection', + Data => { ExtensibleDatum => [ { + DatatypeName => 'Container Details', + ChildData => { ExtensibleDatum => [ { + DatatypeName => 'Container Quantity', + Value => $bin_count, + }, { + DatatypeName => 'Container Type', + Value => $bin_type_id, + } ] }, + } ] }, ServiceTasks => { ServiceTask => { Id => 405, - TaskTypeId => 2247, - Data => { ExtensibleDatum => [ { - DatatypeName => 'SLWP - Containers', - ChildData => { ExtensibleDatum => [ { - DatatypeName => 'Quantity', - Value => $bin_count, - }, { - DatatypeName => 'Container Type', - Value => $bin_type_id, - } ] }, - } ] }, + TaskTypeId => 4410, ServiceTaskSchedules => { ServiceTaskSchedule => [ { ScheduleDescription => 'every other Monday', StartDate => { DateTime => '2020-03-30T00:00:00Z' }, @@ -209,31 +213,12 @@ sub _garden_waste_service_units { } } } ]; } -# don't do this per request as it includes the generated on the fly token -# so changes for each run -subtest "check signature generation" => sub { - my $cobrand = FixMyStreet::Cobrand::Sutton->new; - - my $params = { - AMOUNT => 2000, - ORDERID => 123456, - CN => "Matthew O’Neill", - EMAIL => 'user@example.org', - }; - - my $passphrase = "12345abcde"; - - my $sha = $cobrand->garden_waste_generate_sig($params, $passphrase); - - is $sha, "06BB8BCD34670AE7BDBC054D23B84B30DFDEBABA", "correct signature generated"; -}; - subtest "check garden waste container images" => sub { my $cobrand = FixMyStreet::Cobrand::Sutton->new; # Test garden waste bin image my $bin_unit = { - garden_container => 26, # Garden waste bin + garden_container => 39, # Garden waste bin }; my $bin_image = $cobrand->image_for_unit($bin_unit); is_deeply $bin_image, { @@ -246,7 +231,7 @@ subtest "check garden waste container images" => sub { # Test garden waste sack image my $sack_unit = { - garden_container => 28, # Garden waste sack + garden_container => 36, # Garden waste sack }; my $sack_image = $cobrand->image_for_unit($sack_unit); is_deeply $sack_image, { @@ -256,56 +241,7 @@ subtest "check garden waste container images" => sub { }, "garden waste sack shows as cream colored sack"; }; -FixMyStreet::override_config { - ALLOWED_COBRANDS => 'sutton', - MAPIT_URL => 'http://mapit.uk/', - COBRAND_FEATURES => { - echo => { sutton => { url => 'http://example.org', nlpg => 'https://example.com/%s' } }, - waste => { sutton => 1 }, - }, -}, sub { - my $lwp = Test::MockModule->new('LWP::UserAgent'); - $lwp->mock('get', sub { - my ($ua, $url) = @_; - return $lwp->original('get')->(@_) unless $url =~ /example.com/; - my ($uprn, $area) = (1000000002, "SUTTON"); - ($uprn, $area) = (1000000004, "KINGSTON UPON THAMES") if $url =~ /1000000004/; - my $j = '{ "results": [ { "LPI": { "UPRN": ' . $uprn . ', "LOCAL_CUSTODIAN_CODE_DESCRIPTION": "' . $area . '" } } ] }'; - return HTTP::Response->new(200, 'OK', [], $j); - }); - my $echo = Test::MockModule->new('Integrations::Echo'); - $echo->mock('GetEventsForObject', sub { [] }); - $echo->mock('GetTasks', sub { [] }); - $echo->mock('FindPoints', sub { [ - { Description => '2 Example Street, Sutton, SM2 5HF', Id => '12345', SharedRef => { Value => { anyType => 1000000002 } } }, - { Description => '3 Example Street, Kingston, SM2 5HF', Id => '14345', SharedRef => { Value => { anyType => 1000000004 } } }, - ] }); - $echo->mock('GetPointAddress', sub { - my ($self, $id) = @_; - return { - Id => $id, - SharedRef => { Value => { anyType => $id == 14345 ? '1000000004' : '1000000002' } }, - PointType => 'PointAddress', - PointAddressType => { Name => 'House' }, - Coordinates => { GeoPoint => { Latitude => 51.354679, Longitude => -0.183895 } }, - Description => '2/3 Example Street, Sutton, SM2 5HF', - }; - }); - $echo->mock('GetServiceUnitsForObject', \&garden_waste_one_bin); - mock_CancelReservedSlotsForEvent($echo); - - subtest 'Look up of address not in correct borough' => sub { - $mech->get_ok('/waste'); - $mech->submit_form_ok({ with_fields => { postcode => 'SM2 5HF' } }); - $mech->submit_form_ok({ with_fields => { address => '14345' } }); - $mech->content_contains('No address on record'); - $mech->get_ok('/waste'); - $mech->submit_form_ok({ with_fields => { postcode => 'SM2 5HF' } }); - $mech->submit_form_ok({ with_fields => { address => '12345' } }); - $mech->content_lacks('No address on record'); - }; -}; - +my $sent_params = {}; FixMyStreet::override_config { ALLOWED_COBRANDS => 'sutton', MAPIT_URL => 'http://mapit.uk/', @@ -340,7 +276,7 @@ FixMyStreet::override_config { scpID => '1234', company_name => 'rbk', form_name => 'rbk_user_form', - epdq_url => 'http://example.org/cc_submit', + cc_url => 'http://example.org', sha_passphrase => 'XYZ123', } }, }, @@ -355,9 +291,7 @@ FixMyStreet::override_config { $p->update_extra_field({ name => 'property_id', value => '12345' }); $p->update; - my $sent_params = {}; - my $call_params = {}; - + my ($scp) = shared_scp_mocks(); my $echo = Test::MockModule->new('Integrations::Echo'); $echo->mock('GetEventsForObject', sub { [] }); $echo->mock('GetTasks', sub { [] }); @@ -518,13 +452,12 @@ FixMyStreet::override_config { name => 'Test McTest', email => 'test@example.net' } }); - $mech->submit_form_ok({ with_fields => { tandc => 1 } }); - my $form = $mech->form_name("cc_form"); + $mech->waste_submit_check({ with_fields => { tandc => 1 } }); - my ( $token, $new_report, $report_id ) = get_report_from_redirect( $form->value("ACCEPTURL") ); + my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); - is $form->value('ORDERID'), 'LBS-' . $new_report->id . '-' . '1000000002'; - is $form->value("AMOUNT"), 2000, 'correct amount used'; + is $sent_params->{items}[0]{lineId}, 'LBS-GGW-' . $new_report->id . '-Test McTest-GW Sub'; + is $sent_params->{items}[0]{amount}, 2000, 'correct amount used'; check_extra_data_pre_confirm($new_report); $mech->get('/waste/pay/xx/yyyyyyyyyyy'); @@ -568,11 +501,9 @@ FixMyStreet::override_config { $mech->content_contains('Test McTest'); $mech->content_contains('£20.00'); $mech->submit_form_ok({ with_fields => { tandc => 1 } }); - my $form = $mech->form_name("cc_form"); - my ( $token, $new_report, $report_id ) = get_report_from_redirect( $form->value("ACCEPTURL") ); - - is $form->value("AMOUNT"), 2000, 'correct amount used'; + my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); + is $sent_params->{items}[0]{amount}, 2000, 'correct amount used'; check_extra_data_pre_confirm($new_report, new_bins => 0); $mech->get_ok("/waste/pay_complete/$report_id/$token?STATUS=9&PAYID=54321"); @@ -601,11 +532,9 @@ FixMyStreet::override_config { $mech->content_contains('Test McTest'); $mech->content_contains('£20.00'); $mech->submit_form_ok({ with_fields => { tandc => 1 } }); - my $form = $mech->form_name("cc_form"); - - my ( $token, $new_report, $report_id ) = get_report_from_redirect( $form->value("ACCEPTURL") ); - is $form->value("AMOUNT"), 2000, 'correct amount used'; + my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); + is $sent_params->{items}[0]{amount}, 2000, 'correct amount used'; check_extra_data_pre_confirm($new_report, new_bins => 0); $mech->get_ok("/waste/pay_complete/$report_id/$token?STATUS=9&PAYID=54321"); @@ -633,6 +562,11 @@ FixMyStreet::override_config { $mech->content_contains('3 bins'); $mech->content_contains('60.00'); $mech->content_contains('20.00'); + $mech->back; + $mech->submit_form_ok({ with_fields => { current_bins => 2, bins_wanted => 1 } }); + $mech->content_contains('only increase'); + $mech->submit_form_ok({ with_fields => { current_bins => 2, bins_wanted => 2 } }); + $mech->content_contains('only increase'); }; subtest 'check modify sub credit card payment' => sub { $mech->get_ok('/waste/12345/garden_modify'); @@ -645,12 +579,11 @@ FixMyStreet::override_config { $mech->content_contains('20.00'); $mech->submit_form_ok({ with_fields => { current_bins => 1, bins_wanted => 2 } }); $mech->submit_form_ok({ with_fields => { tandc => 1 } }); - my $form = $mech->form_name("cc_form"); - is $form->value("AMOUNT"), 2000, 'correct amount used'; - my ( $token, $new_report, $report_id ) = get_report_from_redirect( $form->value("ACCEPTURL") ); + is $sent_params->{items}[0]{amount}, 2000, 'correct amount used'; + my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); - check_extra_data_pre_confirm($new_report, type => 'Amend', quantity => 2); + check_amend_extra_data_pre_confirm($new_report); $mech->get_ok("/waste/pay_complete/$report_id/$token?STATUS=9&PAYID=54321"); check_extra_data_post_confirm($new_report); @@ -660,45 +593,11 @@ FixMyStreet::override_config { FixMyStreet::Script::Reports::send(); my @emails = $mech->get_email; my $body = $mech->get_text_body_from_email($emails[1]); - like $body, qr/Number of bin subscriptions: 2/; + like $body, qr/Number of additional bin subscriptions: 1/; like $body, qr/Bins to be delivered: 1/; like $body, qr/Total:.*?20.00/; }; - $echo->mock('GetServiceUnitsForObject', \&garden_waste_two_bins); - subtest 'check modify sub credit card payment reducing bin count' => sub { - set_fixed_time('2021-01-09T17:00:00Z'); # After sample data collection - $sent_params = undef; - - $mech->log_in_ok($user->email); - $mech->get_ok('/waste/12345/garden_modify'); - $mech->submit_form_ok({ with_fields => { current_bins => 2, bins_wanted => 1 } }); - $mech->content_contains('20.00'); - $mech->content_lacks('Continue to payment'); - $mech->content_contains('Confirm changes'); - $mech->submit_form_ok({ with_fields => { tandc => 1 } }); - $mech->content_like(qr#/waste/12345">Show upcoming#, "contains link to bin page"); - - my $new_report = FixMyStreet::DB->resultset('Problem')->search( - { user_id => $user->id }, - )->order_by('-id')->first; - - is $sent_params, undef, "no one off payment if reducing bin count"; - check_extra_data_pre_confirm($new_report, type => 'Amend', state => 'confirmed', action => 2); - is $new_report->state, 'confirmed', 'report confirmed'; - is $new_report->get_extra_field_value('payment'), '0', 'no payment if removing bins'; - is $new_report->get_extra_field_value('pro_rata'), '', 'no pro rata payment if removing bins'; - - $mech->clear_emails_ok; - FixMyStreet::Script::Reports::send(); - my @emails = $mech->get_email; - my $body = $mech->get_text_body_from_email($emails[1]); - like $body, qr/Number of bin subscriptions: 1/; - like $body, qr/Bins to be removed: 1/; - unlike $body, qr/Total:/; - }; - $echo->mock('GetServiceUnitsForObject', \&garden_waste_one_bin); - subtest 'renew credit card sub' => sub { $mech->log_out_ok(); set_fixed_time('2021-03-09T17:00:00Z'); # After sample data collection @@ -727,11 +626,10 @@ FixMyStreet::override_config { payment_method => 'credit_card', } }); $mech->submit_form_ok({ with_fields => { tandc => 1 } }); - my $form = $mech->form_name("cc_form"); - is $form->value("AMOUNT"), 2000, 'correct amount used'; + is $sent_params->{items}[0]{amount}, 2000, 'correct amount used'; - my ( $token, $new_report, $report_id ) = get_report_from_redirect( $form->value("ACCEPTURL") ); + my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); check_extra_data_pre_confirm($new_report, type => 'Renew', new_bins => 0); @@ -768,12 +666,9 @@ FixMyStreet::override_config { } }); $mech->content_contains('40.00'); $mech->submit_form_ok({ with_fields => { tandc => 1 } }); - my $form = $mech->form_name("cc_form"); - - is $form->value("AMOUNT"), 4000, 'correct amount used'; - is $form->value("CN"), 'New McTest', 'Correct name'; + is $sent_params->{items}[0]{amount}, 4000, 'correct amount used'; - my ( $token, $new_report, $report_id ) = get_report_from_redirect( $form->value("ACCEPTURL") ); + my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); check_extra_data_pre_confirm($new_report, type => 'Renew', quantity => 2); @@ -806,13 +701,12 @@ FixMyStreet::override_config { } }); $mech->content_contains('20.00'); $mech->submit_form_ok({ with_fields => { tandc => 1 } }); - $form = $mech->form_name("cc_form"); - is $form->value("AMOUNT"), 2000, 'correct amount used'; + is $sent_params->{items}[0]{amount}, 2000, 'correct amount used'; - my ( $token, $new_report, $report_id ) = get_report_from_redirect( $form->value("ACCEPTURL") ); + my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); - check_extra_data_pre_confirm($new_report, type => 'Renew', action => 2); + check_extra_data_pre_confirm($new_report, type => 'Renew', new_bins => 0); $mech->get_ok("/waste/pay_complete/$report_id/$token?STATUS=9&PAYID=54321"); check_extra_data_post_confirm($new_report); @@ -862,10 +756,7 @@ FixMyStreet::override_config { )->order_by('-id')->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('Subscription_End_Date'), '2021-03-09', 'cancel date set to current date'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Container'), 26, 'correct container request bin type'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Containers'), 2, 'correct container request action'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Quantity'), 1, 'correct container request count'; + is $new_report->get_extra_field_value('End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->state, 'confirmed', 'report confirmed'; $mech->clear_emails_ok; @@ -912,11 +803,10 @@ FixMyStreet::override_config { email => 'test@example.net' } }); $mech->submit_form_ok({ with_fields => { tandc => 1 } }); - my $form = $mech->form_name("cc_form"); - is $form->value("AMOUNT"), 2000, 'correct amount used'; + is $sent_params->{items}[0]{amount}, 2000, 'correct amount used'; - my ( $token, $new_report, $report_id ) = get_report_from_redirect( $form->value("ACCEPTURL") ); + my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); check_extra_data_pre_confirm($new_report); @@ -959,13 +849,12 @@ FixMyStreet::override_config { email => 'test@example.net' } }); $mech->submit_form_ok({ with_fields => { tandc => 1 } }); - my $form = $mech->form_name("cc_form"); - is $form->value("AMOUNT"), 4100, 'correct amount used'; + is $sent_params->{items}[0]{amount}, 4100, 'correct amount used'; - my ( $token, $new_report, $report_id ) = get_report_from_redirect( $form->value("ACCEPTURL") ); + my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); - check_extra_data_pre_confirm($new_report, bin_type => 28); + check_extra_data_pre_confirm($new_report, bin_type_sub => 4, bin_type_new => 5, quantity => 11, new_bins => 11); $mech->get('/waste/pay/xx/yyyyyyyyyyy'); ok !$mech->res->is_success(), "want a bad response"; @@ -1004,9 +893,8 @@ FixMyStreet::override_config { $mech->content_contains('1 bin'); $mech->content_contains('20.00'); $mech->submit_form_ok({ with_fields => { tandc => 1 } }); - my $form = $mech->form_name("cc_form"); - is $form->value("AMOUNT"), 2000, 'correct amount used'; - my ( $token, $new_report, $report_id ) = get_report_from_redirect( $form->value("ACCEPTURL") ); + is $sent_params->{items}[0]{amount}, 2000, 'correct amount used'; + my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); check_extra_data_pre_confirm($new_report, type => 'Renew', new_bins => 0); }; @@ -1022,10 +910,9 @@ FixMyStreet::override_config { $mech->content_contains('bins_wanted'); $mech->submit_form_ok({ with_fields => { current_bins => 1, bins_wanted => 2, name => 'Test McTest' } }); $mech->submit_form_ok({ with_fields => { tandc => 1 } }); - my $form = $mech->form_name("cc_form"); - is $form->value("AMOUNT"), 2000, 'correct amount used'; - my ( $token, $new_report, $report_id ) = get_report_from_redirect( $form->value("ACCEPTURL") ); - check_extra_data_pre_confirm($new_report, type => 'Amend', quantity => 2); + is $sent_params->{items}[0]{amount}, 2000, 'correct amount used'; + my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); + check_amend_extra_data_pre_confirm($new_report); }; subtest 'refuse sacks, garden bin, cancelling' => sub { @@ -1039,10 +926,7 @@ FixMyStreet::override_config { )->order_by('-id')->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('Subscription_End_Date'), '2021-03-09', 'cancel date set to current date'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Container'), 26, 'correct container request bin type'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Containers'), 2, 'correct container request action'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Quantity'), 1, 'correct container request count'; + is $new_report->get_extra_field_value('End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->state, 'confirmed', 'report confirmed'; }; @@ -1068,10 +952,9 @@ FixMyStreet::override_config { payment_method => 'credit_card', } }); $mech->submit_form_ok({ with_fields => { tandc => 1 } }); - my $form = $mech->form_name("cc_form"); - is $form->value("AMOUNT"), 4100, 'correct amount used'; - my ( $token, $new_report, $report_id ) = get_report_from_redirect( $form->value("ACCEPTURL") ); - check_extra_data_pre_confirm($new_report, type => 'Renew', bin_type => 28); + is $sent_params->{items}[0]{amount}, 4100, 'correct amount used'; + my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); + check_extra_data_pre_confirm($new_report, type => 'Renew', bin_type_sub => 4, bin_type_new => 5, quantity => 11, new_bins => 11); $mech->get_ok("/waste/pay_complete/$report_id/$token?STATUS=9&PAYID=54321"); @@ -1100,10 +983,7 @@ FixMyStreet::override_config { )->order_by('-id')->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('Subscription_End_Date'), '2021-03-09', 'cancel date set to current date'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Container'), '', 'correct container request bin type'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Containers'), '', 'correct container request action'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Quantity'), '', 'correct container request count'; + is $new_report->get_extra_field_value('End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->state, 'confirmed', 'report confirmed'; }; @@ -1179,44 +1059,6 @@ FixMyStreet::override_config { $report->delete; # Otherwise next test sees this as latest }; - $echo->mock('GetServiceUnitsForObject', \&garden_waste_two_bins); - subtest 'check modify sub staff reducing bin count' => sub { - set_fixed_time('2021-01-09T17:00:00Z'); - - $mech->get_ok('/waste/12345/garden_modify'); - $mech->submit_form_ok({ with_fields => { task => 'modify' } }); - $mech->submit_form_ok({ with_fields => { - current_bins => 2, - bins_wanted => 1, - name => 'A user', - email => 'test@example.net', - } }); - $mech->content_contains('20.00'); - $mech->content_lacks('Continue to payment'); - $mech->content_contains('Confirm changes'); - $mech->submit_form_ok({ with_fields => { tandc => 1 } }); - $mech->content_like(qr#/waste/12345">Show upcoming#, "contains link to bin page"); - - $mech->content_lacks($staff_user->email); - - my $content = $mech->content; - my ($id) = ($content =~ m#reference number\s*
.*?(\d+)<#); - my $new_report = FixMyStreet::DB->resultset("Problem")->find({ id => $id }); - - is $new_report->category, 'Garden Subscription', 'correct category on report'; - is $new_report->title, 'Garden Subscription - Amend', 'correct title on report'; - is $new_report->get_extra_field_value('payment_method'), 'csc', 'correct payment method on report'; - is $new_report->state, 'confirmed', 'report confirmed'; - is $new_report->get_extra_field_value('Subscription_Details_Quantity'), 1, 'correct bin count'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Containers'), 2, 'correct container request action'; - is $new_report->get_extra_field_value('Bin_Delivery_Detail_Quantity'), 1, 'correct container request count'; - is $new_report->get_extra_metadata('contributed_by'), $staff_user->id; - is $new_report->get_extra_metadata('contributed_as'), 'another_user'; - is $new_report->get_extra_field_value('payment'), '0', 'no payment if removing bins'; - is $new_report->get_extra_field_value('pro_rata'), '', 'no pro rata payment if removing bins'; - }; - $echo->mock('GetServiceUnitsForObject', \&garden_waste_one_bin); - subtest 'cancel staff sub' => sub { set_fixed_time('2021-03-09T17:00:00Z'); # After sample data collection $mech->get_ok('/waste/12345/garden_cancel'); @@ -1225,7 +1067,7 @@ FixMyStreet::override_config { my $new_report = FixMyStreet::DB->resultset('Problem')->order_by('-id')->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('Subscription_End_Date'), '2021-03-09', 'cancel date set to current date'; + is $new_report->get_extra_field_value('End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->state, 'confirmed', 'report confirmed'; is $new_report->get_extra_metadata('contributed_by'), $staff_user->id; is $new_report->get_extra_metadata('contributed_as'), 'anonymous_user'; @@ -1318,13 +1160,12 @@ FixMyStreet::override_config { $mech->content_contains('40.00'); $mech->content_contains('20.00'); $mech->submit_form_ok({ with_fields => { tandc => 1 } }); - my $form = $mech->form_name("cc_form"); - is $form->value("AMOUNT"), 2000, 'correct amount used'; + is $sent_params->{items}[0]{amount}, 2000, 'correct amount used'; - my ( $token, $new_report, $report_id ) = get_report_from_redirect( $form->value("ACCEPTURL") ); + my ( $token, $new_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); - check_extra_data_pre_confirm($new_report, type => 'Amend', quantity => 2); + check_amend_extra_data_pre_confirm($new_report); $mech->get_ok("/waste/pay_complete/$report_id/$token?STATUS=9&PAYID=54321"); check_extra_data_post_confirm($new_report); @@ -1344,7 +1185,7 @@ FixMyStreet::override_config { )->order_by('-id')->first; is $new_report->category, 'Cancel Garden Subscription', 'correct category on report'; - is $new_report->get_extra_field_value('Subscription_End_Date'), '2021-03-09', 'cancel date set to current date'; + is $new_report->get_extra_field_value('End_Date'), '09/03/2021', 'cancel date set to current date'; is $new_report->state, 'confirmed', 'report confirmed'; }; @@ -1428,8 +1269,8 @@ sub check_extra_data_pre_confirm { state => 'unconfirmed', quantity => 1, new_bins => 1, - action => 1, - bin_type => 26, + bin_type_sub => 1, + bin_type_new => 2, payment_method => 'credit_card', @_ ); @@ -1437,12 +1278,38 @@ sub check_extra_data_pre_confirm { is $report->category, 'Garden Subscription', 'correct category on report'; is $report->title, "Garden Subscription - $params{type}", 'correct title on report'; is $report->get_extra_field_value('payment_method'), $params{payment_method}, 'correct payment method on report'; - is $report->get_extra_field_value('Subscription_Details_Quantity'), $params{quantity}, 'correct bin count'; - is $report->get_extra_field_value('Subscription_Details_Containers'), $params{bin_type}, 'correct bin type'; + is $report->get_extra_field_value('Paid_Container_Quantity'), $params{quantity}, 'correct bin count'; + is $report->get_extra_field_value('Paid_Container_Type'), $params{bin_type_sub}, 'correct bin type'; + if ($params{new_bins}) { + is $report->get_extra_field_value('Container_Type'), $params{bin_type_new}, 'correct container request bin type'; + is $report->get_extra_field_value('Quantity'), $params{new_bins}+1, 'correct container request count - one more'; + } + is $report->state, $params{state}, 'report state correct'; +} + +sub check_amend_extra_data_pre_confirm { + my $report = shift; + ok $report, "report passed to check_extra_data_pre_confirm"; + return unless $report; + + my %params = ( + state => 'unconfirmed', + quantity => 1, + new_bins => 1, + bin_type_sub => 1, + bin_type_new => 2, + payment_method => 'credit_card', + @_ + ); + $report->discard_changes; + is $report->category, 'Amend Garden Subscription', 'correct category on report'; + is $report->title, "Garden Subscription - Amend", 'correct title on report'; + is $report->get_extra_field_value('payment_method'), $params{payment_method}, 'correct payment method on report'; + is $report->get_extra_field_value('Additional_Container_Quantity'), $params{quantity}, 'correct bin count'; + is $report->get_extra_field_value('Additional_Collection_Container_Type'), $params{bin_type_sub}, 'correct bin type'; if ($params{new_bins}) { - is $report->get_extra_field_value('Bin_Delivery_Detail_Container'), $params{bin_type}, 'correct container request bin type'; - is $report->get_extra_field_value('Bin_Delivery_Detail_Containers'), $params{action}, 'correct container request action'; - is $report->get_extra_field_value('Bin_Delivery_Detail_Quantity'), $params{new_bins}, 'correct container request count'; + is $report->get_extra_field_value('Container_Ordered_Type'), $params{bin_type_new}, 'correct container request bin type'; + is $report->get_extra_field_value('Container_Ordered_Quantity'), $params{new_bins}+1, 'correct container request count - one more'; } is $report->state, $params{state}, 'report state correct'; } @@ -1467,4 +1334,37 @@ sub mock_CancelReservedSlotsForEvent { } ); } +sub shared_scp_mocks { + my $pay = Test::MockModule->new('Integrations::SCP'); + + $pay->mock(pay => sub { + my $self = shift; + $sent_params = shift; + return { + transactionState => 'IN_PROGRESS', + scpReference => '12345', + invokeResult => { + status => 'SUCCESS', + redirectUrl => 'http://example.org/faq' + } + }; + }); + $pay->mock(query => sub { + my $self = shift; + $sent_params = shift; + return { + transactionState => 'COMPLETE', + paymentResult => { + status => 'SUCCESS', + paymentDetails => { + paymentHeader => { + uniqueTranId => 54321 + } + } + } + }; + }); + return $pay; +} + done_testing; diff --git a/t/app/controller/waste_sutton_r.t b/t/app/controller/waste_sutton_r.t index 6984d4706d5..68cbd72f5c7 100644 --- a/t/app/controller/waste_sutton_r.t +++ b/t/app/controller/waste_sutton_r.t @@ -12,9 +12,9 @@ END { FixMyStreet::App->log->enable('info'); } my $mech = FixMyStreet::TestMech->new; -my $bin_data = decode_json(path(__FILE__)->sibling('waste_4443082.json')->slurp_utf8); -my $bin_140_data = decode_json(path(__FILE__)->sibling('waste_4443082_140.json')->slurp_utf8); -my $kerbside_bag_data = decode_json(path(__FILE__)->sibling('waste_4471550.json')->slurp_utf8); +my $bin_data = decode_json(path(__FILE__)->sibling('waste_sutton_4443082.json')->slurp_utf8); +my $bin_140_data = decode_json(path(__FILE__)->sibling('waste_sutton_4443082_140.json')->slurp_utf8); +my $kerbside_bag_data = decode_json(path(__FILE__)->sibling('waste_sutton_4471550.json')->slurp_utf8); my $above_shop_data = decode_json(path(__FILE__)->sibling('waste_4499005.json')->slurp_utf8); my $params = { @@ -48,8 +48,13 @@ create_contact({ category => 'Report missed collection', email => 'missed' }, 'W { code => 'service_id', required => 1, automated => 'hidden_field' }, { code => 'fixmystreet_id', required => 1, automated => 'hidden_field' }, ); -create_contact({ category => 'Request new container', email => '1635' }, 'Waste', +create_contact({ category => 'Report missed assisted collection', email => '3146' }, 'Waste', + { code => 'service_id', required => 1, automated => 'hidden_field' }, + { code => 'fixmystreet_id', required => 1, automated => 'hidden_field' }, +); +create_contact({ category => 'Request new container', email => '3129' }, 'Waste', { code => 'uprn', required => 1, automated => 'hidden_field' }, + { code => 'service_id', required => 1, automated => 'hidden_field' }, { code => 'fixmystreet_id', required => 1, automated => 'hidden_field' }, { code => 'Container_Type', required => 1, automated => 'hidden_field' }, { code => 'Action', required => 1, automated => 'hidden_field' }, @@ -70,7 +75,7 @@ FixMyStreet::override_config { url => 'http://example.org/', } }, waste => { sutton => 1 }, - echo => { sutton => { bulky_service_id => 413 }}, + echo => { sutton => { bulky_service_id => 960 }}, payment_gateway => { sutton => { cc_url => 'http://example.com', request_replace_cost => 500, @@ -88,7 +93,7 @@ FixMyStreet::override_config { set_fixed_time('2022-09-10T12:00:00Z'); $mech->get_ok('/waste/12345'); $mech->content_contains('2 Example Street, Sutton'); - $mech->content_contains('Every Friday fortnightly'); + $mech->content_contains('Friday every other week'); $mech->content_contains('Friday, 2nd September'); $mech->content_contains('Report a mixed recycling (cans, plastics & glass) collection as missed'); }; @@ -117,19 +122,17 @@ FixMyStreet::override_config { }; subtest 'Request a new bin' => sub { $mech->follow_link_ok( { text => 'Request a bin, box, caddy or bags' } ); - # 19 (1), 24 (1), 16 (1), 1 (1) + # 27 (1), 46 (1), 12 (1), 1 (1) # missing, new_build, more $mech->content_contains('The Council has continued to provide waste and recycling containers free for as long as possible', 'Intro text included'); $mech->content_contains('You can request a larger container if you meet the following criteria', 'Divider intro text included for container sizes'); - $mech->submit_form_ok({ with_fields => { 'container-choice' => 19 }}); + $mech->submit_form_ok({ with_fields => { 'container-choice' => 27 }}); $mech->submit_form_ok({ with_fields => { 'request_reason' => 'damaged' }}); $mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }}); $mech->content_contains('Continue to payment'); + $mech->content_contains('Damaged (1x to deliver, 1x to collect)'); - my $mech2 = $mech->clone; - $mech2->submit_form_ok({ with_fields => { process => 'summary' } }); - is $mech2->res->previous->code, 302, 'payments issues a redirect'; - is $mech2->res->previous->header('Location'), "http://example.org/faq", "redirects to payment gateway"; + $mech->waste_submit_check({ with_fields => { process => 'summary' } }); is $sent_params->{items}[0]{amount}, 500; my ( $token, $report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); @@ -139,13 +142,14 @@ FixMyStreet::override_config { $mech->content_contains('Containers typically arrive within 20 working days'); is $report->get_extra_field_value('uprn'), 1000000002; - is $report->detail, "Quantity: 1\n\n2 Example Street, Sutton, SM1 1AA\n\nReason: Damaged"; + is $report->detail, "2 Example Street, Sutton, SM1 1AA\n\nReason: Damaged\n\n1x Paper and Cardboard Green Wheelie Bin (240L) to deliver\n\n1x Paper and Cardboard Green Wheelie Bin (240L) to collect"; is $report->category, 'Request new container'; is $report->title, 'Request replacement Paper and Cardboard Green Wheelie Bin (240L)'; is $report->get_extra_field_value('payment'), 500, 'correct payment'; is $report->get_extra_field_value('payment_method'), 'credit_card', 'correct payment method on report'; - is $report->get_extra_field_value('Container_Type'), 19, 'correct bin type'; - is $report->get_extra_field_value('Action'), 3, 'correct container request action'; + is $report->get_extra_field_value('Container_Type'), 27, 'correct bin type'; + is $report->get_extra_field_value('Action'), '2::1', 'correct container request action'; + is $report->get_extra_field_value('service_id'), 948; is $report->state, 'unconfirmed', 'report not confirmed'; is $report->get_extra_metadata('scpReference'), '12345', 'correct scp reference on report'; @@ -155,14 +159,13 @@ FixMyStreet::override_config { }; subtest 'Request a larger bin than current' => sub { $mech->get_ok('/waste/12345/request'); - $mech->submit_form_ok({ with_fields => { 'container-choice' => 2 }}); + $mech->submit_form_ok({ with_fields => { 'container-choice' => 3 }}); $mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }}); $mech->content_contains('Continue to payment'); + $mech->content_like(qr/Standard Brown General Waste Wheelie Bin \(140L\)<\/dt>\s*
1x to collect<\/dd>/); + $mech->content_like(qr/Larger Brown General Waste Wheelie Bin \(240L\)<\/dt>\s*
1x to deliver<\/dd>/); - my $mech2 = $mech->clone; - $mech2->submit_form_ok({ with_fields => { process => 'summary' } }); - is $mech2->res->previous->code, 302, 'payments issues a redirect'; - is $mech2->res->previous->header('Location'), "http://example.org/faq", "redirects to payment gateway"; + $mech->waste_submit_check({ with_fields => { process => 'summary' } }); is $sent_params->{items}[0]{amount}, 1500; my ( $token, $report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); @@ -173,21 +176,21 @@ FixMyStreet::override_config { is $report->get_extra_field_value('uprn'), 1000000002; is $report->title, 'Request exchange for Larger Brown General Waste Wheelie Bin (240L)'; is $report->get_extra_field_value('payment'), 1500, 'correct payment'; - is $report->get_extra_field_value('Container_Type'), '1::2', 'correct bin type'; + is $report->get_extra_field_value('Container_Type'), '1::3', 'correct bin type'; is $report->get_extra_field_value('Action'), '2::1', 'correct container request action'; - is $report->get_extra_field_value('Reason'), '3::3', 'correct container request reason'; + is $report->get_extra_field_value('Reason'), '9::9', 'correct container request reason'; + is $report->get_extra_field_value('service_id'), 940; }; subtest 'Request a paper bin when having a 140L' => sub { $e->mock('GetServiceUnitsForObject', sub { $bin_140_data }); $mech->get_ok('/waste/12345/request'); - $mech->submit_form_ok({ with_fields => { 'container-choice' => 19 }}); + $mech->submit_form_ok({ with_fields => { 'container-choice' => 27 }}); $mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }}); $mech->content_contains('Continue to payment'); + $mech->content_like(qr/Paper and Cardboard Green Wheelie Bin \(140L\)<\/dt>\s*
1x to collect<\/dd>/); + $mech->content_like(qr/Paper and Cardboard Green Wheelie Bin \(240L\)<\/dt>\s*
1x to deliver<\/dd>/); - my $mech2 = $mech->clone; - $mech2->submit_form_ok({ with_fields => { process => 'summary' } }); - is $mech2->res->previous->code, 302, 'payments issues a redirect'; - is $mech2->res->previous->header('Location'), "http://example.org/faq", "redirects to payment gateway"; + $mech->waste_submit_check({ with_fields => { process => 'summary' } }); is $sent_params->{items}[0]{amount}, 1500; my ( $token, $report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} ); @@ -198,22 +201,24 @@ FixMyStreet::override_config { is $report->get_extra_field_value('uprn'), 1000000002; is $report->title, 'Request exchange for Paper and Cardboard Green Wheelie Bin (240L)'; is $report->get_extra_field_value('payment'), 1500, 'correct payment'; - is $report->get_extra_field_value('Container_Type'), '36::19', 'correct bin type'; + is $report->get_extra_field_value('Container_Type'), '26::27', 'correct bin type'; is $report->get_extra_field_value('Action'), '2::1', 'correct container request action'; - is $report->get_extra_field_value('Reason'), '3::3', 'correct container request reason'; + is $report->get_extra_field_value('Reason'), '9::9', 'correct container request reason'; + is $report->get_extra_field_value('service_id'), 948; $e->mock('GetServiceUnitsForObject', sub { $bin_data }); }; subtest 'Report a new recycling raises a bin delivery request' => sub { $mech->log_in_ok($user->email); $mech->get_ok('/waste/12345/request'); - $mech->submit_form_ok({ with_fields => { 'container-choice' => 16 } }); + $mech->submit_form_ok({ with_fields => { 'container-choice' => 12 } }); $mech->submit_form_ok({ with_fields => { 'request_reason' => 'missing' }}); $mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }}); + $mech->content_contains('Missing (1x to deliver)'); $mech->submit_form_ok({ with_fields => { process => 'summary' } }); $mech->content_contains('request has been sent'); my $report = FixMyStreet::DB->resultset("Problem")->order_by('-id')->first; is $report->get_extra_field_value('uprn'), 1000000002; - is $report->detail, "Quantity: 1\n\n2 Example Street, Sutton, SM1 1AA\n\nReason: Missing"; + is $report->detail, "2 Example Street, Sutton, SM1 1AA\n\nReason: Missing\n\n1x Mixed Recycling Green Box (55L) to deliver"; is $report->title, 'Request replacement Mixed Recycling Green Box (55L)'; }; @@ -224,7 +229,7 @@ FixMyStreet::override_config { $mech->content_contains('Non-Recyclable Refuse'); $mech->content_lacks('Paper & Card'); - $mech->submit_form_ok({ with_fields => { 'service-2239' => 1 } }); + $mech->submit_form_ok({ with_fields => { 'service-954' => 1 } }); $mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }}); $mech->submit_form_ok({ with_fields => { process => 'summary' } }); $mech->content_contains('Thank you for reporting a missed collection'); @@ -240,13 +245,13 @@ FixMyStreet::override_config { $e->mock('GetEventsForObject', sub { [ { # Request - EventTypeId => 1635, + EventTypeId => 3129, Data => { ExtensibleDatum => [ { Value => 2, DatatypeName => 'Source' }, { ChildData => { ExtensibleDatum => [ { Value => 1, DatatypeName => 'Action' }, - { Value => 16, DatatypeName => 'Container Type' }, + { Value => 12, DatatypeName => 'Container Type' }, ] }, }, ] }, @@ -255,17 +260,17 @@ FixMyStreet::override_config { $mech->content_contains('A mixed recycling (cans, plastics & glass) container request has been made'); $mech->content_contains('Report a mixed recycling (cans, plastics & glass) collection as missed'); $mech->get_ok('/waste/12345/request'); - $mech->content_like(qr/name="container-choice" value="16"\s+disabled/s); # green + $mech->content_like(qr/name="container-choice" value="12"\s+disabled/s); # green $e->mock('GetEventsForObject', sub { [ { # Request - EventTypeId => 1635, + EventTypeId => 3129, Data => { ExtensibleDatum => [ { Value => 2, DatatypeName => 'Source' }, { ChildData => { ExtensibleDatum => [ { Value => 1, DatatypeName => 'Action' }, - { Value => 23, DatatypeName => 'Container Type' }, + { Value => 43, DatatypeName => 'Container Type' }, ] }, }, ] }, @@ -273,28 +278,22 @@ FixMyStreet::override_config { $mech->get_ok('/waste/12345'); $mech->content_contains('A food waste container request has been made'); $mech->get_ok('/waste/12345/request'); - $mech->content_like(qr/name="container-choice" value="23"\s+disabled/s); # indoor - $mech->content_like(qr/name="container-choice" value="24"\s*>/s); # outdoor + $mech->content_like(qr/name="container-choice" value="43"\s+disabled/s); # indoor + $mech->content_like(qr/name="container-choice" value="46"\s*>/s); # outdoor $e->mock('GetEventsForObject', sub { [ { - EventTypeId => 1566, + EventTypeId => 3145, EventDate => { DateTime => "2022-09-10T17:00:00Z" }, - ServiceId => 408, - Data => { ExtensibleDatum => [ - { Value => 1, DatatypeName => 'Container Mix' }, - ] }, + ServiceId => 944, } ] }); $mech->get_ok('/waste/12345'); $mech->content_contains('A mixed recycling (cans, plastics & glass) collection has been reported as missed'); $mech->content_lacks('Request a mixed recycling (cans, plastics & glass) container'); $e->mock('GetEventsForObject', sub { [ { - EventTypeId => 1566, + EventTypeId => 3145, EventDate => { DateTime => "2022-09-10T17:00:00Z" }, - ServiceId => 408, - Data => { ExtensibleDatum => { - Value => 1, DatatypeName => 'Paper' - } }, + ServiceId => 948, } ] }); $mech->get_ok('/waste/12345'); $mech->content_contains('A paper & card collection has been reported as missed'); @@ -304,15 +303,12 @@ FixMyStreet::override_config { subtest 'No reporting if open request on service unit' => sub { $e->mock('GetEventsForObject', sub { my ($self, $type, $id) = @_; - return [] if $type eq 'PointAddress' || $id == 1002; - is $id, 1001; # recycling service unit + return [] if $type eq 'PointAddress' || $id == 1004; + like $id, qr/^100[1-3]$/; # recycling service unit return [ { - EventTypeId => 1566, + EventTypeId => 3145, EventDate => { DateTime => "2022-09-10T17:00:00Z" }, - ServiceId => 408, - Data => { ExtensibleDatum => [ - { Value => 1, DatatypeName => 'Container Mix' }, - ] }, + ServiceId => 944, } ] }); $mech->get_ok('/waste/12345'); @@ -325,7 +321,7 @@ FixMyStreet::override_config { $e->mock('GetEventsForObject', sub { [ { # Request - EventTypeId => 1635, + EventTypeId => 3129, Data => { ExtensibleDatum => [ { Value => 2, DatatypeName => 'Source' }, { @@ -341,13 +337,13 @@ FixMyStreet::override_config { $e->mock('GetEventsForObject', sub { [ { # Request - EventTypeId => 1635, + EventTypeId => 3129, Data => { ExtensibleDatum => [ { Value => 2, DatatypeName => 'Source' }, { ChildData => { ExtensibleDatum => [ { Value => 1, DatatypeName => 'Action' }, - { Value => 2, DatatypeName => 'Container Type' }, + { Value => 3, DatatypeName => 'Container Type' }, ] }, }, ] }, @@ -366,13 +362,13 @@ FixMyStreet::override_config { }; subtest 'Fortnightly collection can request a blue stripe bag' => sub { $mech->get_ok('/waste/12345/request'); - $mech->submit_form_ok({ with_fields => { 'container-choice' => 18 }}); + $mech->submit_form_ok({ with_fields => { 'container-choice' => 22 }}); $mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }}); $mech->submit_form_ok({ with_fields => { process => 'summary' } }); $mech->content_contains('request has been sent'); my $report = FixMyStreet::DB->resultset("Problem")->order_by('-id')->first; is $report->get_extra_field_value('uprn'), 1000000002; - is $report->detail, "Quantity: 1\n\n2 Example Street, Sutton, SM1 1AA\n\nReason: Additional bag required"; + is $report->detail, "2 Example Street, Sutton, SM1 1AA\n\nReason: Additional bag required\n\n1x Mixed Recycling Blue Striped Bag to deliver"; is $report->category, 'Request new container'; is $report->title, 'Request new Mixed Recycling Blue Striped Bag'; }; @@ -423,6 +419,15 @@ FixMyStreet::override_config { $e->mock('GetServiceUnitsForObject', sub { $dupe }); $mech->get_ok('/waste/12345'); $mech->content_contains('is set up for assisted collection'); + subtest 'Different category for assisted' => sub { + $mech->submit_form_ok({ with_fields => { 'service-954' => 1 } }); + $mech->submit_form_ok({ with_fields => { 'service-954' => 1 } }); + $mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }}); + $mech->submit_form_ok({ with_fields => { process => 'summary' } }); + $mech->content_contains('Thank you for reporting a missed collection'); + my $report = FixMyStreet::DB->resultset("Problem")->order_by('-id')->first; + is $report->category, 'Report missed assisted collection'; + }; $e->mock('GetServiceUnitsForObject', sub { $bin_data }); }; diff --git a/templates/email/default/other-reported.html b/templates/email/default/other-reported.html index e8176d3e796..3c66cabe6d0 100644 --- a/templates/email/default/other-reported.html +++ b/templates/email/default/other-reported.html @@ -1,4 +1,4 @@ -[% IF report.category == 'Garden Subscription' OR report.category == 'Cancel Garden Subscription' ~%] +[% IF report.category == 'Garden Subscription' OR report.category == 'Cancel Garden Subscription' OR report.category == 'Amend Garden Subscription' ~%] [% PROCESS 'waste/other-reported-garden.html' ~%] [% ELSIF report.category == 'Bulky collection' ~%] [% PROCESS 'waste/other-reported-bulky.html' ~%] diff --git a/templates/email/default/other-reported.txt b/templates/email/default/other-reported.txt index c89bdb8edb2..3cb4a1c019c 100644 --- a/templates/email/default/other-reported.txt +++ b/templates/email/default/other-reported.txt @@ -1,4 +1,4 @@ -[% IF report.category == 'Garden Subscription' OR report.category == 'Cancel Garden Subscription' ~%] +[% IF report.category == 'Garden Subscription' OR report.category == 'Cancel Garden Subscription' OR report.category == 'Amend Garden Subscription' ~%] [% PROCESS 'waste/other-reported-garden.txt' ~%] [% ELSIF report.category == 'Bulky collection' ~%] [% PROCESS 'waste/other-reported-bulky.txt' ~%] diff --git a/templates/email/default/waste/_garden_data.html b/templates/email/default/waste/_garden_data.html index 970896a354f..9339604f01d 100644 --- a/templates/email/default/waste/_garden_data.html +++ b/templates/email/default/waste/_garden_data.html @@ -9,10 +9,25 @@ IF container; SET sacks = (container == 28); SET quantity = report.get_extra_field_value('Subscription_Details_Quantity'); + ELSE; + SET container = report.get_extra_field_value('Paid_Container_Type'); + IF container; + SET sacks = (container == 4); + SET quantity = report.get_extra_field_value('Paid_Container_Quantity'); + END; END; END; SET new_bins = report.get_extra_field_value('new_containers') || 0; +SET container = report.get_extra_field_value('Additional_Collection_Container_Type'); +IF container; + SET additional_quantity = report.get_extra_field_value('Additional_Container_Quantity'); +END; + +IF cobrand.moniker == 'sutton'; SET sack_quant = 1; +ELSIF cobrand.moniker == 'kingston'; SET sack_quant = 1; +ELSE; SET sack_quant = quantity; END; + SET pro_rata = report.get_extra_field_value('pro_rata'); SET payment = report.get_extra_field_value('payment'); SET admin_fee = report.get_extra_field_value('admin_fee'); diff --git a/templates/email/default/waste/other-reported-garden.html b/templates/email/default/waste/other-reported-garden.html index 6a8e1fac207..5bfcbb20833 100644 --- a/templates/email/default/waste/other-reported-garden.html +++ b/templates/email/default/waste/other-reported-garden.html @@ -47,13 +47,19 @@ [% IF quantity ~%]

[% IF sacks ~%] - Garden waste sack collection: [% quantity %] [% nget('roll', 'rolls', quantity) %] + Garden waste sack collection: [% sack_quant %] [% nget('roll', 'rolls', sack_quant) %] [% ELSE ~%] Number of bin subscriptions: [% quantity %] [% END ~%]

[% END %] +[% IF additional_quantity ~%] +

+ Number of additional bin subscriptions: [% additional_quantity %] +

+[% END %] + [% IF new_bins > 0 AND NOT sacks ~%]

Bins to be delivered: [% new_bins %] diff --git a/templates/email/default/waste/other-reported-garden.txt b/templates/email/default/waste/other-reported-garden.txt index ee97905d157..ab820c271e6 100644 --- a/templates/email/default/waste/other-reported-garden.txt +++ b/templates/email/default/waste/other-reported-garden.txt @@ -38,12 +38,16 @@ You have signed up for: [% IF quantity ~%] [% IF sacks ~%] -Garden waste sack collection: [% quantity %] [% nget('roll', 'rolls', quantity) %] +Garden waste sack collection: [% sack_quant %] [% nget('roll', 'rolls', sack_quant) %] [% ELSE ~%] Number of bin subscriptions: [% quantity %] [% END ~%] [% END %] +[% IF additional_quantity ~%] +Number of additional bin subscriptions: [% additional_quantity %] +[% END %] + [% IF new_bins > 0 AND NOT sacks ~%] Bins to be delivered: [% new_bins %] [% ELSIF new_bins < 0 AND NOT sacks ~%] diff --git a/templates/email/default/waste/other-reported.html b/templates/email/default/waste/other-reported.html index 6fcbf1879d4..8f04b86b36c 100644 --- a/templates/email/default/waste/other-reported.html +++ b/templates/email/default/waste/other-reported.html @@ -1,4 +1,3 @@ -[% is_missed_collection = report.category == 'Report missed collection' %] [% email_summary = "Thanks for logging your report"; diff --git a/templates/web/base/admin/reports/_edit_waste.html b/templates/web/base/admin/reports/_edit_waste.html index 83685b7b3ea..3c70706fd4b 100644 --- a/templates/web/base/admin/reports/_edit_waste.html +++ b/templates/web/base/admin/reports/_edit_waste.html @@ -171,6 +171,20 @@

Subscription information

[% END %] +[% IF (c.cobrand.moniker == 'sutton' || c.cobrand.moniker == 'kingston') AND problem.get_extra_field_value('Paid_Container_Type') %] +

Subscription information

+
    +[% INCLUDE show_fields fields=[ + [ 'Subscription container', 'Paid_Container_Type' ], + [ 'Subscription quantity', 'Paid_Container_Quantity' ], + [ 'Delivery container', 'Container_Type' ], + [ 'Delivery quantity', 'Quantity' ], + [ 'Current containers', 'current_containers' ], + [' New containers', 'new_containers' ], +] %] +
+[% END %] + [% IF c.cobrand.moniker == 'brent' %] [% IF problem.get_extra_field_value('Container_Request_Container_Type') %]

Request information

diff --git a/templates/web/base/waste/confirmation.html b/templates/web/base/waste/confirmation.html index 1a1acbf1e70..de00751723c 100644 --- a/templates/web/base/waste/confirmation.html +++ b/templates/web/base/waste/confirmation.html @@ -5,7 +5,7 @@ ELSE; title = 'Your container request has been sent'; END; -ELSIF report.category == 'Report missed collection'; +ELSIF report.category == 'Report missed collection' OR report.category == 'Report missed assisted collection'; title = 'Thank you for reporting a missed collection'; ELSIF report.category == 'Request additional collection'; title = 'Your additional collection has been requested'; diff --git a/templates/web/base/waste/summary_request.html b/templates/web/base/waste/summary_request.html index 9958eb4d159..f8769c94d52 100644 --- a/templates/web/base/waste/summary_request.html +++ b/templates/web/base/waste/summary_request.html @@ -8,6 +8,7 @@ [% BLOCK answers %] [% FOR container IN data.keys.grep('^container-') %] [% NEXT UNLESS data.$container %] + [% NEXT IF container == 'container-capacity-change' # Kingston %] [% IF container == 'container-choice' %] [% SET container_id = data.item('container-choice') %] [% ELSE %] @@ -20,12 +21,10 @@
[% containers.$container_id %]
[% IF c.cobrand.moniker == 'brent' %]
[% label_for_field(form, 'request_reason', data.request_reason) %]
- [% ELSIF c.cobrand.moniker == 'sutton' %] -
[% data.request_reason.ucfirst %]
[% ELSE %]
- [% data.$quantity_key %] - [% ' to deliver, ' IF data.$quantity_key AND data.$removal_key %] + [% IF data.$quantity_key %][% data.$quantity_key %] to deliver[% END %] + [%~ ', ' IF data.$quantity_key AND data.$removal_key %] [% IF data.$removal_key %][% data.$removal_key %] to remove[% END %]
[% END %] diff --git a/templates/web/kingston/waste/_more_services_sidebar.html b/templates/web/kingston/waste/_more_services_sidebar.html index 7898cfe1f73..1f6900160e2 100644 --- a/templates/web/kingston/waste/_more_services_sidebar.html +++ b/templates/web/kingston/waste/_more_services_sidebar.html @@ -12,7 +12,7 @@

More services

[% IF any_request_allowed %]
  • Request a new/replacement container
  • [% END %] - [% IF services.2238 %] + [% IF services.966 %]
  • Request a larger/smaller refuse container
  • [% END %] [% IF show_garden_subscribe %] diff --git a/templates/web/kingston/waste/garden/subscribe_confirm.html b/templates/web/kingston/waste/garden/subscribe_confirm.html index ab4d1c49be7..0355e87daef 100644 --- a/templates/web/kingston/waste/garden/subscribe_confirm.html +++ b/templates/web/kingston/waste/garden/subscribe_confirm.html @@ -34,9 +34,9 @@

    What happens next?

    --> -[% SET container = report.get_extra_field_value('Subscription_Details_Containers') %] +[% SET container = report.get_extra_field_value('Paid_Container_Type') %] [% SET new_bins = report.get_extra_field_value('new_containers') %] -[% IF container == 28 %] +[% IF container == 4 %] [% SET container_str = 'sacks' %] [% ELSE %] [% SET container_str = nget('bin', 'bins', new_bins) %] diff --git a/templates/web/sutton/waste/cc_form.html b/templates/web/sutton/waste/cc_form.html deleted file mode 100644 index b67343c6241..00000000000 --- a/templates/web/sutton/waste/cc_form.html +++ /dev/null @@ -1,25 +0,0 @@ -
    - - - - - - - - - - - - - - - - - - - - -
    - -
    -
    diff --git a/templates/web/sutton/waste/garden/subscribe_confirm.html b/templates/web/sutton/waste/garden/subscribe_confirm.html index 544d2d26bfa..1438a5c953f 100644 --- a/templates/web/sutton/waste/garden/subscribe_confirm.html +++ b/templates/web/sutton/waste/garden/subscribe_confirm.html @@ -34,9 +34,9 @@

    What happens next?

    --> -[% SET container = report.get_extra_field_value('Subscription_Details_Containers') %] +[% SET container = report.get_extra_field_value('Paid_Container_Type') %] [% SET new_bins = report.get_extra_field_value('new_containers') %] -[% IF container == 28 %] +[% IF container == 4 %] [% SET container_str = 'sacks' %] [% ELSE %] [% SET container_str = nget('bin', 'bins', new_bins) %] diff --git a/templates/web/sutton/waste/summary_request.html b/templates/web/sutton/waste/summary_request.html new file mode 100644 index 00000000000..204e9f8c628 --- /dev/null +++ b/templates/web/sutton/waste/summary_request.html @@ -0,0 +1,48 @@ +[% +title = 'Submit container request'; +thing = 'container request'; +summary_title = 'Container requests'; +step1 = first_page; +%] + +[% BLOCK row %] +
    +
    [% key %]
    +
    [% value %]
    +
    +[% END %] + +[% BLOCK answers %] + [% SET container_id = data.item('container-choice') %] + + [% IF data.request_reason == 'change_capacity'; + # Work out the removed container (matching code in Sutton.pm) + IF container_id == 1; + SET remove_container = containers.3; + ELSIF container_id == 3; + IF c.stash.quantities.4; + SET remove_container = containers.4; + ELSE; + SET remove_container = containers.1; + END; + ELSIF container_id == 27; + SET remove_container = containers.26; + END; + INCLUDE row key=remove_container value='1x to collect'; + INCLUDE row key=containers.$container_id value='1x to deliver'; + ELSIF data.request_reason == 'damaged'; + INCLUDE row key=containers.$container_id value='Damaged (1x to deliver, 1x to collect)'; + ELSE; + SET reason = data.request_reason.ucfirst.replace('_', ' '); + INCLUDE row key=containers.$container_id value=reason _ ' (1x to deliver)'; + END %] + + [% IF data.payment %] +
    +
    Administration/delivery charge
    +
    £[% tprintf( '%.2f', data.payment / 100 ) %]
    +
    + [% END %] +[% END %] + +[% PROCESS waste/summary.html %]