Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bexley] [Waste] WIP show existing subscription info #5346

Draft
wants to merge 5 commits into
base: bexley-ww-ggw-cancel
Choose a base branch
from

Conversation

davea
Copy link
Member

@davea davea commented Jan 28, 2025

Copy link

codecov bot commented Jan 28, 2025

Codecov Report

Attention: Patch coverage is 94.87179% with 2 lines in your changes missing coverage. Please review.

Project coverage is 82.44%. Comparing base (71b7645) to head (df0cd37).

Files with missing lines Patch % Lines
perllib/FixMyStreet/Cobrand/Bexley/Garden.pm 94.44% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                   Coverage Diff                    @@
##           bexley-ww-ggw-cancel    #5346      +/-   ##
========================================================
+ Coverage                 82.41%   82.44%   +0.02%     
========================================================
  Files                       420      420              
  Lines                     33018    33042      +24     
  Branches                   5291     5294       +3     
========================================================
+ Hits                      27213    27241      +28     
+ Misses                     4246     4242       -4     
  Partials                   1559     1559              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@davea davea force-pushed the bexley-ww-ggw-show-existing branch from 004985b to 4e5eb23 Compare February 4, 2025 12:13
return undef unless $results && $results->{Customers};
my $customer = $results->{Customers}[0];
return undef unless $customer && $customer->{ServiceContracts};
my $contract = $results->{ServiceContracts}[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be $customer->{ServiceContracts}[0].

@@ -30,14 +35,27 @@ sub garden_current_subscription {
my $uprn = $self->{c}->stash->{property}{uprn};
return undef unless $uprn;

my $is_free = $self->agile->IsAddressFree($uprn);
return undef if $is_free->{IsFree} eq 'True';
my $results = $self->agile->CustomerSearch($uprn);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we mentioned doing a check against the current subscription that is in the DB and making sure the customer email & external_id match the Customer and ServiceContract returned from Agile.
I'm not sure if it would be better to do this match as part of your PR, as strictly speaking it's not necessary to get cancellation working (am also worried about me making too many changes on my PR that then mess with your work here). I think get_original_sub() in Controller/Waste.pm needs updating so it searches on Bexley's uprn field as well as property_id.

@@ -65,4 +65,14 @@ sub IsAddressFree {
);
}

sub CustomerSearch {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this 🙏 I've copied it over to my cancellation PR.


# Agile says there is a subscription; now get service data from
# Whitespace
my $services = $self->{c}->stash->{services};
map { my $srv = $services->{$_}; return $srv if $srv }
@{ $self->garden_service_ids };
for my $id (@{ $self->garden_service_ids }) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's something that needs solving right now, but I am not sure of the best way to handle the Whitespace/Agile split; e.g. if we have Agile data for the contract but not Whitespace. Perhaps how we're doing it now will suffice 🤔

In my cancellation PR I have extended the agile_only bit below to include a couple more fields like customer_external_ref and end_date (I think this can be used as the 'DueDate' required by the cancel call, but I'll need to check that with Luis). I guess I should add those to the Whitespace $srv data here as well.

@nephila-nacrea nephila-nacrea force-pushed the bexley-ww-ggw-cancel branch 5 times, most recently from 38ec8f8 to 6029fd1 Compare February 6, 2025 11:14
@davea davea force-pushed the bexley-ww-ggw-show-existing branch from 4e5eb23 to af8001d Compare February 9, 2025 21:21

my $uprn = $self->{c}->stash->{property}{uprn};
return undef unless $uprn;
email => undef,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you ever populate email?

$sub->{bins_count} = $contract->{WasteContainerQuantity};

my $c = $self->{c};
my $p = $c->model('DB::Problem')->search({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may need to change get_original_sub in Controller/Waste as well (or special-case it so it calls this subroutine for Bexley, to get the 'row' bit).
The current Waste code for other cobrands makes use of both get_original_sub and garden_current_subscription, looks like the former is for DB lookup and the latter for getting the garden service from the list of services...? I don't know if we should be keeping this distinction here.

$srv->{end_date} = $sub->{end_date};
$srv->{garden_bins} = $sub->{bins_count};
$srv->{garden_cost} = $sub->{cost};
$self->{c}->stash->{orig_sub} = $sub->{row};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be set in lookup_subscription_for_uprn, at the $sub->{row} = $p if $p; bit?

= $customer->{CustomerExternalReference};
$srv->{end_date} = $end_date;
if ( my $srv = $service_ids->{$_} ) {
my $sub = $self->lookup_subscription_for_uprn($uprn);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can pull this out of the loop and then you don't need to call it a second time below.

};
push @$services, $service;
$self->{c}->stash->{property}{garden_current_subscription} = $service;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure you need this line if it is already set Cobrand/Bexley/Waste.pm below. (Or, perhaps better to get rid of it there and keep it here? But you may still need to call garden_current_subscription, but not assign it to anything.)

@davea davea force-pushed the bexley-ww-ggw-show-existing branch from 353ed2f to df0cd37 Compare February 14, 2025 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants