-
-
Notifications
You must be signed in to change notification settings - Fork 241
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
base: bexley-ww-ggw-cancel
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
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. |
d0cee9b
to
e8dfeed
Compare
004985b
to
4e5eb23
Compare
return undef unless $results && $results->{Customers}; | ||
my $customer = $results->{Customers}[0]; | ||
return undef unless $customer && $customer->{ServiceContracts}; | ||
my $contract = $results->{ServiceContracts}[0]; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
.
perllib/Integrations/Agile.pm
Outdated
@@ -65,4 +65,14 @@ sub IsAddressFree { | |||
); | |||
} | |||
|
|||
sub CustomerSearch { |
There was a problem hiding this comment.
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 }) { |
There was a problem hiding this comment.
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.
38ec8f8
to
6029fd1
Compare
4e5eb23
to
af8001d
Compare
|
||
my $uprn = $self->{c}->stash->{property}{uprn}; | ||
return undef unless $uprn; | ||
email => undef, |
There was a problem hiding this comment.
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({ |
There was a problem hiding this comment.
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}; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.)
353ed2f
to
df0cd37
Compare
[skip changelog]
For https://github.com/mysociety/societyworks/issues/4666