Skip to content

Commit

Permalink
[Bexley] Only show active GGW subs from Agile
Browse files Browse the repository at this point in the history
  • Loading branch information
davea committed Feb 18, 2025
1 parent 9960a54 commit 4d73445
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions perllib/FixMyStreet/Cobrand/Bexley/Garden.pm
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,26 @@ sub lookup_subscription_for_uprn {
};


my ( $customer, $contract );

Check warning on line 48 in perllib/FixMyStreet/Cobrand/Bexley/Garden.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Garden.pm#L48

Added line #L48 was not covered by tests

my $results = $self->agile->CustomerSearch($uprn);

Check warning on line 50 in perllib/FixMyStreet/Cobrand/Bexley/Garden.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Garden.pm#L50

Added line #L50 was not covered by tests
return undef unless $results && $results->{Customers};
my $customer = $results->{Customers}[0];
return undef unless $customer && $customer->{ServiceContracts};
my $contract = $customer->{ServiceContracts}[0];
return unless $contract;

# find the first 'ACTIVATED' Customer with an 'ACTIVE' contract
my $customers = $results->{Customers} || [];
OUTER: for ( @$customers ) {

Check warning on line 54 in perllib/FixMyStreet/Cobrand/Bexley/Garden.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Garden.pm#L53-L54

Added lines #L53 - L54 were not covered by tests
next unless $_->{CustomertStatus} eq 'ACTIVATED'; # CustomertStatus (sic) options seem to be ACTIVATED/INACTIVE
my $contracts = $_->{ServiceContracts} || [];

Check warning on line 56 in perllib/FixMyStreet/Cobrand/Bexley/Garden.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Garden.pm#L56

Added line #L56 was not covered by tests
next unless $contracts;
$customer = $_;
for ( @$contracts ) {

Check warning on line 59 in perllib/FixMyStreet/Cobrand/Bexley/Garden.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Garden.pm#L58-L59

Added lines #L58 - L59 were not covered by tests
next unless $_->{ServiceContractStatus} eq 'ACTIVE'; # Options seem to be ACTIVE/NOACTIVE
$contract = $_;

Check warning on line 61 in perllib/FixMyStreet/Cobrand/Bexley/Garden.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Garden.pm#L61

Added line #L61 was not covered by tests
# use the first matching customer/contract
last OUTER if $customer && $contract;
}
}

return unless $customer && $contract;

# XXX should maybe sort by CreatedDate rather than assuming first is OK
$sub->{cost} = try {
Expand Down

0 comments on commit 4d73445

Please sign in to comment.