Skip to content

Commit

Permalink
[Bexley][WW] GGW renewals
Browse files Browse the repository at this point in the history
  • Loading branch information
nephila-nacrea committed Feb 11, 2025
1 parent 6029fd1 commit 868c89d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 9 deletions.
53 changes: 44 additions & 9 deletions perllib/FixMyStreet/Cobrand/Bexley/Garden.pm
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,35 @@ sub garden_current_subscription {
= DateTime::Format::Strptime->new( pattern => '%d/%m/%Y %H:%M' );
my $end_date = $parser->parse_datetime( $contract->{EndDate} );

my $garden_due = $self->waste_sub_due($end_date);

my %garden_args = (
customer_external_ref => $customer->{CustomerExternalReference},
end_date => $end_date,
garden_bins => $contract->{WasteContainerQuantity},
garden_due => $garden_due,


payment_code => $contract->{Payments}[0]{RefNumber},
);

# Agile says there is a subscription; now get service data from
# Whitespace
my $services = $self->{c}->stash->{services};
for ( @{ $self->garden_service_ids } ) {
if ( my $srv = $services->{$_} ) {
$srv->{customer_external_ref}
= $customer->{CustomerExternalReference};
$srv->{end_date} = $end_date;
$srv->{$_} = $garden_args{$_} for keys %garden_args;

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L74 was not covered by tests
return $srv;
}
}

return {
agile_only => 1,
customer_external_ref => $customer->{CustomerExternalReference},
end_date => $end_date,
%garden_args,
};
}

# TODO This is a placeholder
sub get_current_garden_bins { 1 }
sub get_current_garden_bins { shift->garden_current_subscription->{garden_bins} }

sub waste_cancel_asks_staff_for_user_details { 1 }

Expand All @@ -86,10 +94,9 @@ sub waste_garden_sub_params {
my ( $self, $data, $type ) = @_;

my $c = $self->{c};
my $srv = $self->garden_current_subscription;

if ( $data->{category} eq 'Cancel Garden Subscription' ) {
my $srv = $self->garden_current_subscription;

my $parser = DateTime::Format::Strptime->new( pattern => '%d/%m/%Y' );
my $due_date_str = $parser->format_datetime( $srv->{end_date} );

Expand All @@ -100,9 +107,37 @@ sub waste_garden_sub_params {
$c->set_param( 'customer_external_ref', $srv->{customer_external_ref} );
$c->set_param( 'due_date', $due_date_str );
$c->set_param( 'reason', $reason );

} elsif ( $data->{title} =~ /Renew/ ) {
$c->set_param( 'type', 'renew' );
$c->set_param( 'customer_external_ref', $srv->{customer_external_ref} );

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

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Garden.pm#L112-L113

Added lines #L112 - L113 were not covered by tests

}
}

# sub garden_renew_category { 'Renew Garden Subscription' }

sub garden_due_days { 42 }

=head2 waste_sub_due
Returns true/false if now is less than garden_due_days before DATE.
=cut

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

my $now = DateTime->now->set_time_zone( FixMyStreet->local_time_zone );
my $sub_end = DateTime::Format::W3CDTF->parse_datetime($date);

my $diff = $now->delta_days($sub_end)->in_units('days');
return $diff <= $self->garden_due_days;
}

# TODO
sub waste_sub_overdue { undef }

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L139 was not covered by tests

=item * You can order a maximum of five bins
=cut
Expand Down
10 changes: 10 additions & 0 deletions templates/web/bexley/waste/garden/renew_bin_desc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="waste-service-hint-banner">
<div class="waste-service-hint-banner__image">
<img src="/i/waste-containers/bexley/garden-waste-brown-bin.png" alt="">
</div>
<div class="waste-service-hint__content">
<p>
TODO Bin description
</p>
</div>
</div>

0 comments on commit 868c89d

Please sign in to comment.