From a851d69714853479e998e66fb967a998419b9157 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 12 Dec 2024 10:34:02 +0000 Subject: [PATCH] Add waste_property_id function. Bexley uses the UPRN, not the property ID, so use this so that some things that add links to bin day pages can work more automatically. --- perllib/FixMyStreet/App/Controller/Waste.pm | 11 +++++----- .../FixMyStreet/App/Controller/Waste/Bulky.pm | 2 +- perllib/FixMyStreet/DB/Result/Problem.pm | 20 +++++++++++++++++++ .../FixMyStreet/Roles/Cobrand/DDProcessor.pm | 6 +++--- perllib/FixMyStreet/Roles/Cobrand/Echo.pm | 2 +- .../_council_reference_alert_update.html | 2 +- .../_council_reference_alert_update.txt | 2 +- .../email/default/waste/bulky-reminder.html | 2 +- .../email/default/waste/bulky-reminder.txt | 2 +- .../default/waste/other-reported-bulky.html | 2 +- .../default/waste/other-reported-bulky.txt | 2 +- .../_council_reference_alert_update.html | 2 +- .../_council_reference_alert_update.txt | 2 +- .../email/kingston/waste/bulky-reminder.html | 2 +- .../email/kingston/waste/bulky-reminder.txt | 2 +- .../_council_reference_alert_update.html | 2 +- .../_council_reference_alert_update.txt | 2 +- .../_council_reference_alert_update.html | 2 +- .../_council_reference_alert_update.txt | 2 +- .../web/base/admin/reports/_edit_waste.html | 4 ++-- .../web/base/waste/_button_show_upcoming.html | 2 +- .../report/_updates_disallowed_message.html | 2 +- .../waste/bulky/confirmation.html | 2 +- .../web/peterborough/waste/confirmation.html | 2 +- 24 files changed, 51 insertions(+), 30 deletions(-) diff --git a/perllib/FixMyStreet/App/Controller/Waste.pm b/perllib/FixMyStreet/App/Controller/Waste.pm index b0fd83fcffd..b74decaba34 100644 --- a/perllib/FixMyStreet/App/Controller/Waste.pm +++ b/perllib/FixMyStreet/App/Controller/Waste.pm @@ -89,7 +89,7 @@ sub index : Path : Args(0) { $c->stash->{continue_id} = $id; if (my $p = $c->cobrand->problems->search({ state => 'unconfirmed' })->find($id)) { if ($c->stash->{is_staff} && $c->stash->{waste_features}{bulky_retry_bookings}) { - my $property_id = $p->get_extra_field_value('property_id'); + my $property_id = $p->waste_property_id; my $saved_data = $c->cobrand->waste_reconstruct_bulky_data($p); $saved_data->{continue_id} = $id; my $saved_data_field = FixMyStreet::App::Form::Field::JSON->new(name => 'saved_data'); @@ -205,7 +205,7 @@ sub pay_retry : Path('pay_retry') : Args(0) { $c->forward('check_payment_redirect_id', [ $id, $token ]); my $p = $c->stash->{report}; - $c->stash->{property} = $c->cobrand->call_hook(look_up_property => $p->get_extra_field_value('property_id')); + $c->stash->{property} = $c->cobrand->call_hook(look_up_property => $p->waste_property_id); $c->forward('pay', [ 'bin_days' ]); } @@ -285,7 +285,7 @@ sub confirm_subscription : Private { my ($self, $c, $reference) = @_; my $p = $c->stash->{report}; - $c->stash->{property_id} = $p->get_extra_field_value('property_id'); + $c->stash->{property_id} = $p->waste_property_id; if ($p->category eq 'Bulky collection' || $p->category eq 'Small items collection') { $c->stash->{template} = 'waste/bulky/confirmation.html'; @@ -439,7 +439,7 @@ sub direct_debit_error : Path('dd_error') : Args(0) { if ( $id && $token ) { $c->forward('check_payment_redirect_id', [ $id, $token ]); my $p = $c->stash->{report}; - $c->stash->{property} = $c->cobrand->call_hook(look_up_property => $p->get_extra_field_value('property_id')); + $c->stash->{property} = $c->cobrand->call_hook(look_up_property => $p->waste_property_id); $c->forward('populate_dd_details'); } @@ -545,7 +545,7 @@ sub csc_payment_failed : Path('csc_payment_failed') : Args(0) { my $report = $c->model('DB::Problem')->find({ id => $id}); $c->stash->{report} = $report; - $c->stash->{property_id} = $report->get_extra_field_value('property_id'); + $c->stash->{property_id} = $report->waste_property_id; my $contributed_as = $report->get_extra_metadata('contributed_as') || ''; if ( $contributed_as ne 'anonymous_user' ) { @@ -1403,6 +1403,7 @@ sub get_original_sub : Private { my $p = $c->model('DB::Problem')->search({ category => 'Garden Subscription', title => ['Garden Subscription - New', 'Garden Subscription - Renew'], + # XXX Bexley does not store a property_id extra => { '@>' => encode_json({ "_fields" => [ { name => "property_id", value => $c->stash->{property}{id} } ] }) }, state => { '!=' => 'hidden' }, })->order_by('-id')->to_body($c->cobrand->body); diff --git a/perllib/FixMyStreet/App/Controller/Waste/Bulky.pm b/perllib/FixMyStreet/App/Controller/Waste/Bulky.pm index 8b3acec62ca..8491ebf11d1 100644 --- a/perllib/FixMyStreet/App/Controller/Waste/Bulky.pm +++ b/perllib/FixMyStreet/App/Controller/Waste/Bulky.pm @@ -186,7 +186,7 @@ sub view : Private { my $p = $c->stash->{problem}; $c->stash->{property} = { - id => $p->get_extra_field_value('property_id'), + id => $p->waste_property_id, address => $p->get_extra_metadata('property_address'), }; diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 96ece1476d5..1aa543756c0 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -1519,6 +1519,26 @@ sub create_related_things { =head2 Waste related activity +=head3 waste_property_id + +Return the property ID used in the URL of a bin day page. This is usually +property_id on the report, but could be the UPRN (e.g. Bexley). + +=cut + +sub waste_property_id { + my $self = shift; + return $self->get_extra_field_value('uprn') if $self->cobrand eq 'bexley'; + return $self->get_extra_field_value('property_id'); +} + +=head3 waste_confirm_payment + +This is called when a payment has been confirmed in order to record the +payment, perhaps send an email, add a payment confirmation update for +already-sent bulky collections, cancel a previous collection if an amendment, +and so on. + =cut sub waste_confirm_payment { diff --git a/perllib/FixMyStreet/Roles/Cobrand/DDProcessor.pm b/perllib/FixMyStreet/Roles/Cobrand/DDProcessor.pm index 62eed07903f..9aa952349a3 100644 --- a/perllib/FixMyStreet/Roles/Cobrand/DDProcessor.pm +++ b/perllib/FixMyStreet/Roles/Cobrand/DDProcessor.pm @@ -147,7 +147,7 @@ sub waste_reconcile_direct_debits { $p = $cur; } if ( $p ) { - my $service = $self->waste_get_current_garden_sub( $p->get_extra_field_value('property_id') ); + my $service = $self->waste_get_current_garden_sub( $p->waste_property_id ); my $quantity; if ($service) { $quantity = $self->waste_get_sub_quantity($service); @@ -244,7 +244,7 @@ sub waste_reconcile_direct_debits { if ( $r ) { $self->log("processing matched report " . $r->id); - my $service = $self->waste_get_current_garden_sub( $r->get_extra_field_value('property_id') ); + my $service = $self->waste_get_current_garden_sub( $r->waste_property_id ); # if there's not a service then it's fine as it's already been cancelled if ( $service ) { $r->set_extra_metadata('dd_date', $payment->date); @@ -301,7 +301,7 @@ sub _duplicate_waste_report { payment_method => 'direct_debit', $self->garden_subscription_container_field => $report->get_extra_field_value($self->garden_subscription_container_field), service_id => $report->get_extra_field_value('service_id'), - property_id => $report->get_extra_field_value('property_id'), + property_id => $report->waste_property_id, }; diff --git a/perllib/FixMyStreet/Roles/Cobrand/Echo.pm b/perllib/FixMyStreet/Roles/Cobrand/Echo.pm index e0cf076d6cb..088f5457095 100644 --- a/perllib/FixMyStreet/Roles/Cobrand/Echo.pm +++ b/perllib/FixMyStreet/Roles/Cobrand/Echo.pm @@ -1062,7 +1062,7 @@ sub clear_cached_lookups_bulky_slots { sub bulky_refetch_slots { my ($self, $row, $verbose) = @_; - my $property_id = $row->get_extra_field_value('property_id'); + my $property_id = $row->waste_property_id; my $date = $self->collection_date($row); my $guid = $row->get_extra_field_value('GUID'); my $window = $self->_bulky_collection_window(); diff --git a/templates/email/bromley/_council_reference_alert_update.html b/templates/email/bromley/_council_reference_alert_update.html index f1a66a46b10..81111d42eaa 100644 --- a/templates/email/bromley/_council_reference_alert_update.html +++ b/templates/email/bromley/_council_reference_alert_update.html @@ -1,4 +1,4 @@ [% IF problem.cobrand_data == 'waste' %] - [% SET property_id = problem.get_extra_field_value('property_id') %] + [% SET property_id = problem.waste_property_id %] Check your bin collections day [% END %] diff --git a/templates/email/bromley/_council_reference_alert_update.txt b/templates/email/bromley/_council_reference_alert_update.txt index 785addcf6db..4ad3c70aee0 100644 --- a/templates/email/bromley/_council_reference_alert_update.txt +++ b/templates/email/bromley/_council_reference_alert_update.txt @@ -1,4 +1,4 @@ [% IF problem.cobrand_data == 'waste' %] - [% SET property_id = problem.get_extra_field_value('property_id') %] + [% SET property_id = problem.waste_property_id %] Check your bin collections day: https://recyclingservices.bromley.gov.uk/waste[% IF property_id %]/[% property_id %][% END %] [% END %] diff --git a/templates/email/default/waste/bulky-reminder.html b/templates/email/default/waste/bulky-reminder.html index 76a20c3f67e..21940b57f2a 100644 --- a/templates/email/default/waste/bulky-reminder.html +++ b/templates/email/default/waste/bulky-reminder.html @@ -8,7 +8,7 @@ PROCESS '_email_settings.html'; INCLUDE '_email_top.html'; -property_id_uri = report.get_extra_field_value('property_id') | uri; +property_id_uri = report.waste_property_id | uri; cancel_url = cobrand.base_url _ '/waste/' _ property_id_uri _ '/' _ bulky_cancel_url _ '/' _ report.id; %] diff --git a/templates/email/default/waste/bulky-reminder.txt b/templates/email/default/waste/bulky-reminder.txt index 1984eed4df6..5802ee0c533 100644 --- a/templates/email/default/waste/bulky-reminder.txt +++ b/templates/email/default/waste/bulky-reminder.txt @@ -42,7 +42,7 @@ If you wish to cancel your booking, please call 01733 74 74 74. If you wish to cancel your booking, please visit: - [% cobrand.base_url %]/waste/[% report.get_extra_field_value('property_id') | uri %]/[% bulky_cancel_url %]/[% report.id %] + [% cobrand.base_url %]/waste/[% report.waste_property_id | uri %]/[% bulky_cancel_url %]/[% report.id %] [% IF days == 1 %] You may still be able to cancel your booking. diff --git a/templates/email/default/waste/other-reported-bulky.html b/templates/email/default/waste/other-reported-bulky.html index 33c8e009f7d..ba69184b718 100644 --- a/templates/email/default/waste/other-reported-bulky.html +++ b/templates/email/default/waste/other-reported-bulky.html @@ -8,7 +8,7 @@ PROCESS '_email_settings.html'; INCLUDE '_email_top.html'; -property_id_uri = report.get_extra_field_value('property_id') | uri; +property_id_uri = report.waste_property_id | uri; cancel_url = cobrand.base_url _ '/waste/' _ property_id_uri _ '/' _ bulky_cancel_url _ '/' _ report.id; %] diff --git a/templates/email/default/waste/other-reported-bulky.txt b/templates/email/default/waste/other-reported-bulky.txt index 1cb0cf8d05f..1327a99cda7 100644 --- a/templates/email/default/waste/other-reported-bulky.txt +++ b/templates/email/default/waste/other-reported-bulky.txt @@ -47,7 +47,7 @@ If you wish to cancel your booking, please call 01733 74 74 74. If you wish to cancel your booking, please visit: - [% cobrand.base_url %]/waste/[% report.get_extra_field_value('property_id') | uri %]/[% bulky_cancel_url %]/[% report.id %] + [% cobrand.base_url %]/waste/[% report.waste_property_id | uri %]/[% bulky_cancel_url %]/[% report.id %] [% END ~%] diff --git a/templates/email/kingston/_council_reference_alert_update.html b/templates/email/kingston/_council_reference_alert_update.html index e80c13d8536..70978e8396e 100644 --- a/templates/email/kingston/_council_reference_alert_update.html +++ b/templates/email/kingston/_council_reference_alert_update.html @@ -1,4 +1,4 @@ [% IF problem.cobrand_data == 'waste' %] - [% SET property_id = problem.get_extra_field_value('property_id') %] + [% SET property_id = problem.waste_property_id %] Check your bin collections day [% END %] diff --git a/templates/email/kingston/_council_reference_alert_update.txt b/templates/email/kingston/_council_reference_alert_update.txt index 4f436ca19f1..99e11b84cfc 100644 --- a/templates/email/kingston/_council_reference_alert_update.txt +++ b/templates/email/kingston/_council_reference_alert_update.txt @@ -1,4 +1,4 @@ [% IF problem.cobrand_data == 'waste' %] - [% SET property_id = problem.get_extra_field_value('property_id') %] + [% SET property_id = problem.waste_property_id %] Check your bin collections day: https://waste-services.kingston.gov.uk/waste[% IF property_id %]/[% property_id %][% END %] [% END %] diff --git a/templates/email/kingston/waste/bulky-reminder.html b/templates/email/kingston/waste/bulky-reminder.html index a9eaf403bc5..220e2d1e78d 100644 --- a/templates/email/kingston/waste/bulky-reminder.html +++ b/templates/email/kingston/waste/bulky-reminder.html @@ -7,7 +7,7 @@ PROCESS '_email_settings.html'; INCLUDE '_email_top.html'; -property_id_uri = report.get_extra_field_value('property_id') | uri; +property_id_uri = report.waste_property_id | uri; cancel_url = cobrand.base_url _ '/waste/' _ property_id_uri _ '/' _ bulky_cancel_url _ '/' _ report.id; %] diff --git a/templates/email/kingston/waste/bulky-reminder.txt b/templates/email/kingston/waste/bulky-reminder.txt index 9f50f3ec69b..4fcb60980b1 100644 --- a/templates/email/kingston/waste/bulky-reminder.txt +++ b/templates/email/kingston/waste/bulky-reminder.txt @@ -9,7 +9,7 @@ END; [% PROCESS 'waste/_bulky_data.html'; -property_id_uri = report.get_extra_field_value('property_id') | uri; +property_id_uri = report.waste_property_id | uri; cancel_url = cobrand.base_url _ '/waste/' _ property_id_uri _ '/' _ bulky_cancel_url _ '/' _ report.id; ~%] diff --git a/templates/email/merton/_council_reference_alert_update.html b/templates/email/merton/_council_reference_alert_update.html index 2f5ae213fb0..ea7387892aa 100644 --- a/templates/email/merton/_council_reference_alert_update.html +++ b/templates/email/merton/_council_reference_alert_update.html @@ -1,4 +1,4 @@ [% IF problem.cobrand_data == 'waste' %] - [% SET property_id = problem.get_extra_field_value('property_id') %] + [% SET property_id = problem.waste_property_id %] Check your bin collections day [% END %] diff --git a/templates/email/merton/_council_reference_alert_update.txt b/templates/email/merton/_council_reference_alert_update.txt index 96dc1028656..10d35ed0312 100644 --- a/templates/email/merton/_council_reference_alert_update.txt +++ b/templates/email/merton/_council_reference_alert_update.txt @@ -1,4 +1,4 @@ [% IF problem.cobrand_data == 'waste' %] - [% SET property_id = problem.get_extra_field_value('property_id') %] + [% SET property_id = problem.waste_property_id %] Check your bin collections day: https://recycling-services.merton.gov.uk/waste[% IF property_id %]/[% property_id %][% END %] [% END %] diff --git a/templates/email/sutton/_council_reference_alert_update.html b/templates/email/sutton/_council_reference_alert_update.html index f2e937452a1..1d494be76d0 100644 --- a/templates/email/sutton/_council_reference_alert_update.html +++ b/templates/email/sutton/_council_reference_alert_update.html @@ -1,4 +1,4 @@ [% IF problem.cobrand_data == 'waste' %] - [% SET property_id = problem.get_extra_field_value('property_id') %] + [% SET property_id = problem.waste_property_id %] Check your bin collections day [% END %] diff --git a/templates/email/sutton/_council_reference_alert_update.txt b/templates/email/sutton/_council_reference_alert_update.txt index a716dc9118d..c6441092c39 100644 --- a/templates/email/sutton/_council_reference_alert_update.txt +++ b/templates/email/sutton/_council_reference_alert_update.txt @@ -1,4 +1,4 @@ [% IF problem.cobrand_data == 'waste' %] - [% SET property_id = problem.get_extra_field_value('property_id') %] + [% SET property_id = problem.waste_property_id %] Check your bin collections day: https://waste-services.sutton.gov.uk/waste[% IF property_id %]/[% property_id %][% END %] [% END %] diff --git a/templates/web/base/admin/reports/_edit_waste.html b/templates/web/base/admin/reports/_edit_waste.html index 11ae4d41603..83685b7b3ea 100644 --- a/templates/web/base/admin/reports/_edit_waste.html +++ b/templates/web/base/admin/reports/_edit_waste.html @@ -85,8 +85,8 @@ [% IF problem.get_extra_field_value('uprn') %]
  • UPRN: [% problem.get_extra_field_value('uprn') %] [% END %] - [% IF problem.get_extra_field_value('property_id') %] -
  • Property ID: [% problem.get_extra_field_value('property_id') %] + [% IF problem.waste_property_id %] +
  • Property ID: [% problem.waste_property_id %] [% END %] [% IF problem.get_extra_field_value('service_id') %]
  • Service ID: [% problem.get_extra_field_value('service_id') %] diff --git a/templates/web/base/waste/_button_show_upcoming.html b/templates/web/base/waste/_button_show_upcoming.html index b3319867f2a..e77faf755a2 100644 --- a/templates/web/base/waste/_button_show_upcoming.html +++ b/templates/web/base/waste/_button_show_upcoming.html @@ -6,6 +6,6 @@

    [% # sometimes we have the property on the stash, sometimes it's just the report (e.g. token confirmation) - property_id = property.id OR report.get_extra_field_value('property_id') %] + property_id = property.id OR report.waste_property_id %] [% button_text %]

    diff --git a/templates/web/fixmystreet-uk-councils/report/_updates_disallowed_message.html b/templates/web/fixmystreet-uk-councils/report/_updates_disallowed_message.html index 1db39cca8fa..47c121d996c 100644 --- a/templates/web/fixmystreet-uk-councils/report/_updates_disallowed_message.html +++ b/templates/web/fixmystreet-uk-councils/report/_updates_disallowed_message.html @@ -1,5 +1,5 @@ [% IF disallowed == 'waste'; - SET property_id = problem.get_extra_field_value('property_id'); + SET property_id = problem.waste_property_id; %]

    See your bin collections. diff --git a/templates/web/peterborough/waste/bulky/confirmation.html b/templates/web/peterborough/waste/bulky/confirmation.html index b053b993eae..1bb90c141bf 100644 --- a/templates/web/peterborough/waste/bulky/confirmation.html +++ b/templates/web/peterborough/waste/bulky/confirmation.html @@ -28,7 +28,7 @@

    Collection booked

    We have sent you an email confirming this booking.

    Can’t find our email? Check your spam folder.

    [% END %] - Go back home + Go back home diff --git a/templates/web/peterborough/waste/confirmation.html b/templates/web/peterborough/waste/confirmation.html index 6272098248b..80c4837987a 100644 --- a/templates/web/peterborough/waste/confirmation.html +++ b/templates/web/peterborough/waste/confirmation.html @@ -82,7 +82,7 @@

    [% # sometimes we have the property on the stash, sometimes it's just the report (e.g. token confirmation) - property_id = property.id OR report.get_extra_field_value('property_id') %] + property_id = property.id OR report.waste_property_id %] Show upcoming bin days