Skip to content

Commit

Permalink
fixup! [Bexley][WW] GGW renewals
Browse files Browse the repository at this point in the history
  • Loading branch information
nephila-nacrea committed Feb 12, 2025
1 parent efd2fa1 commit c6d4685
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
25 changes: 22 additions & 3 deletions perllib/FixMyStreet/Cobrand/Bexley/Garden.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ sub lookup_subscription_for_uprn {
return undef unless $results && $results->{Customers};
my $customer = $results->{Customers}[0];
return undef unless $customer && $customer->{ServiceContracts};
my $contract = $customer->{ServiceContracts}[0];
# Assume there is only one active subscription
my ($contract) = grep {
$_->{ServiceContractStatus} eq 'ACTIVE'
|| $_->{ServiceContractStatus} eq 'PRECONTRACT'
} @{ $customer->{ServiceContracts} // [] };

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L55 was not covered by tests
return unless $contract;

# XXX should maybe sort by CreatedDate rather than assuming first is OK
Expand Down Expand Up @@ -165,6 +169,7 @@ sub waste_garden_sub_params {
} elsif ( $data->{title} =~ /Renew/ ) {
$c->set_param( 'type', 'renew' );
$c->set_param( 'customer_external_ref', $srv->{customer_external_ref} );
$c->set_param( 'total_containers', $data->{bins_wanted} );

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

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Garden.pm#L170-L172

Added lines #L170 - L172 were not covered by tests

}
}
Expand All @@ -187,8 +192,22 @@ sub waste_sub_due {
return $diff <= $self->garden_due_days;

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

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Garden.pm#L191-L192

Added lines #L191 - L192 were not covered by tests
}

# TODO
sub waste_sub_overdue { undef }
=head2 waste_sub_overdue
Returns true/false if now is past DATE.
=cut

sub waste_sub_overdue {
my ( $self, $date ) = @_;

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L202 was not covered by tests

my $now = DateTime->now->set_time_zone( FixMyStreet->local_time_zone )

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L204 was not covered by tests
->truncate( to => 'day' );
my $sub_end = DateTime::Format::W3CDTF->parse_datetime($date)

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L206 was not covered by tests
->truncate( to => 'day' );

return $now > $sub_end;

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L209 was not covered by tests
}

=item * You can order a maximum of five bins
Expand Down
1 change: 0 additions & 1 deletion perllib/FixMyStreet/Cobrand/Bexley/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ sub bin_services_for_address {
$property->{garden_current_subscription}
= $self->garden_current_subscription(\@site_services_filtered);


$self->_set_request_containers( $property, @site_services_filtered );

return \@site_services_filtered;
Expand Down
2 changes: 1 addition & 1 deletion templates/web/bexley/waste/garden/renew_bin_desc.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</div>
<div class="waste-service-hint__content">
<p>
TODO Bin description
140 litre or 240 litre brown wheelie bin
</p>
</div>
</div>

0 comments on commit c6d4685

Please sign in to comment.