Skip to content

Commit

Permalink
[Bexley] Show current payment on GGW subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
davea committed Feb 9, 2025
1 parent 68673fb commit af8001d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions perllib/FixMyStreet/Cobrand/Bexley/Garden.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package FixMyStreet::Cobrand::Bexley::Garden;
use DateTime::Format::Strptime;
use Integrations::Agile;
use FixMyStreet::App::Form::Waste::Garden::Cancel::Bexley;
use Try::Tiny;

use Moo::Role;
with 'FixMyStreet::Roles::Cobrand::SCP',
Expand Down Expand Up @@ -49,6 +50,11 @@ sub garden_current_subscription {
return undef unless $customer && $customer->{ServiceContracts};
my $contract = $customer->{ServiceContracts}[0];
return unless $contract;
# XXX should maybe sort by CreatedDate rather than assuming first is OK
my $cost = try {
my ($payment) = grep { $_->{PaymentStatus} eq 'Paid' } @{ $contract->{Payments} };
return $payment->{Amount};
};

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L55 - L57 were not covered by tests

my $parser
= DateTime::Format::Strptime->new( pattern => '%d/%m/%Y %H:%M' );
Expand All @@ -64,6 +70,7 @@ sub garden_current_subscription {
= $customer->{CustomerExternalReference};
$srv->{end_date} = $end_date;
$srv->{garden_bins} = $contract->{WasteContainerQuantity};
$srv->{garden_cost} = $cost;

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

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Garden.pm#L72-L73

Added lines #L72 - L73 were not covered by tests
return $srv;
}
}
Expand Down

0 comments on commit af8001d

Please sign in to comment.