Skip to content

Commit

Permalink
Merge branch 'brent-food-waste-caddy-delay-notice' into commercial-st…
Browse files Browse the repository at this point in the history
…aging
  • Loading branch information
neprune committed Jan 16, 2025
2 parents 6d9a3ee + de294b9 commit b42225f
Show file tree
Hide file tree
Showing 29 changed files with 424 additions and 415 deletions.
10 changes: 3 additions & 7 deletions perllib/FixMyStreet/App/Controller/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1205,9 +1205,8 @@ sub garden : Chained('garden_setup') : Args(0) {
$c->stash->{next_month_cost} = $c->cobrand->garden_waste_cost_pa_in_one_month($c->stash->{per_bin_cost});

$c->stash->{first_page} = 'intro';
my $service = $c->cobrand->garden_service_id;
$c->stash->{garden_form_data} = {
max_bins => $c->stash->{quantity_max}->{$service}
max_bins => $c->cobrand->waste_garden_maximum
};
$c->stash->{form_class} = 'FixMyStreet::App::Form::Waste::Garden';
$c->cobrand->call_hook('waste_garden_subscribe_form_setup');
Expand Down Expand Up @@ -1242,9 +1241,7 @@ sub garden_modify : Chained('garden_setup') : Args(0) {

$c->forward('get_original_sub', ['user']);

my $service_id = $c->cobrand->garden_service_id;
my $max_bins = $c->stash->{quantity_max}->{$service_id};

my $max_bins = $c->cobrand->waste_garden_maximum;
my $payment_method = 'credit_card';
if ( $c->stash->{orig_sub} ) {
my $orig_sub = $c->stash->{orig_sub};
Expand Down Expand Up @@ -1316,8 +1313,7 @@ sub garden_renew : Chained('garden_setup') : Args(0) {
} else {
$c->stash->{first_page} = 'intro';
}
my $service_id = $c->cobrand->garden_service_id;
my $max_bins = $c->stash->{quantity_max}->{$service_id};
my $max_bins = $c->cobrand->waste_garden_maximum;
$c->stash->{garden_form_data} = {
max_bins => $max_bins,
bins => $service->{garden_bins},
Expand Down
4 changes: 2 additions & 2 deletions perllib/FixMyStreet/Cobrand/Bexley/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,9 @@ sub _open_reports {
sub _recent_collections {
my ( $self, $property ) = @_;

# Get collections for the last 21 days
# Get collections for the last 30 days
my $dt_today = DateTime->today( time_zone => FixMyStreet->local_time_zone );
my $dt_from = $dt_today->clone->subtract( days => 21 );
my $dt_from = $dt_today->clone->subtract( days => 30 );

# TODO GetCollectionByUprnAndDatePlus would be preferable as it supports
# an end date, but Bexley's live API does not seem to support it. So we
Expand Down
157 changes: 2 additions & 155 deletions perllib/FixMyStreet/Cobrand/Brent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ use FixMyStreet::App::Form::Waste::Garden::Sacks::Renew;
with 'FixMyStreet::Roles::Open311Multi';
with 'FixMyStreet::Roles::Cobrand::OpenUSRN';
with 'FixMyStreet::Roles::Cobrand::Echo';
with 'FixMyStreet::Roles::Cobrand::SCP';
use Integrations::Paye;
with 'FixMyStreet::Roles::Cobrand::SCP',
'FixMyStreet::Roles::Cobrand::Paye';

# Brent covers some of the areas around it so that it can handle near-boundary reports
sub council_area_id { return [2488, 2505, 2489, 2487]; } # 2505 Camden, 2489 Barnet, 2487 Harrow
Expand Down Expand Up @@ -893,155 +893,6 @@ status of reports

sub prevent_questionnaire_updating_status { 1 };

=head2 Staff payments
If a staff member is making a payment, then instead of using SCP, we redirect
to Paye. We also need to check the completed payment against the same source.
=cut

around waste_cc_get_redirect_url => sub {
my ($orig, $self, $c, $back) = @_;

if ($c->stash->{is_staff}) {
my $payment = Integrations::Paye->new({
config => $self->feature('payment_gateway')
});

my $p = $c->stash->{report};
my $uprn = $p->get_extra_field_value('uprn');

my $amount = $p->get_extra_field_value( 'pro_rata' );
unless ($amount) {
$amount = $p->get_extra_field_value( 'payment' );
}
my $admin_fee = $p->get_extra_field_value('admin_fee');

my $redirect_id = mySociety::AuthToken::random_token();
$p->set_extra_metadata('redirect_id', $redirect_id);
$p->update;

my $backUrl = $c->uri_for_action("/waste/$back", [ $c->stash->{property}{id} ]) . '';
my $address = $c->stash->{property}{address};
my @parts = split ',', $address;

my @items = ({
amount => $amount,
reference => $payment->config->{customer_ref},
description => $p->title,
lineId => $self->waste_cc_payment_line_item_ref($p),
});
if ($admin_fee) {
push @items, {
amount => $admin_fee,
reference => $payment->config->{customer_ref_admin_fee},
description => 'Admin fee',
lineId => $self->waste_cc_payment_admin_fee_line_item_ref($p),
};
}
my $result = $payment->pay({
returnUrl => $c->uri_for('pay_complete', $p->id, $redirect_id ) . '',
backUrl => $backUrl,
ref => $self->waste_cc_payment_sale_ref($p),
request_id => $p->id,
description => $p->title,
name => $p->name,
email => $p->user->email,
uprn => $uprn,
address1 => shift @parts,
address2 => shift @parts,
country => 'UK',
postcode => pop @parts,
items => \@items,
staff => $c->stash->{staff_payments_allowed} eq 'cnp',
});

if ( $result ) {
$c->stash->{xml} = $result;

# GET back
# requestId - should match above
# apnReference - transaction Ref, used later for query
# transactionState - InProgress
# invokeResult/status - Success/...
# invokeResult/redirectUrl - what is says
# invokeResult/errorDetails - what it says
if ( $result->{transactionState} eq 'InProgress' &&
$result->{invokeResult}->{status} eq 'Success' ) {

$p->set_extra_metadata('apnReference', $result->{apnReference});
$p->update;

my $redirect = $result->{invokeResult}->{redirectUrl};
$redirect .= "?apnReference=$result->{apnReference}";
return $redirect;
} else {
# XXX - should this do more?
my $error = $result->{invokeResult}->{status};
$c->stash->{error} = $error;
return undef;
}
} else {
return undef;
}
return;
}

return $self->$orig($c, $back);
};

around garden_cc_check_payment_status => sub {
my ($orig, $self, $c, $p) = @_;

if (my $apn = $p->get_extra_metadata('apnReference')) {
my $payment = Integrations::Paye->new({
config => $self->feature('payment_gateway')
});

my $resp = $payment->query({
request_id => $p->id,
apnReference => $apn,
});

if ($resp->{transactionState} eq 'Complete') {
if ($resp->{paymentResult}->{status} eq 'Success') {
my $auth_details
= $resp->{paymentResult}{paymentDetails}{authDetails};
$p->update_extra_metadata(
authCode => $auth_details->{authCode},
continuousAuditNumber => $resp->{paymentResult}{paymentDetails}{payments}{paymentSummary}{continuousAuditNumber},
);
$p->update_extra_field({ name => 'payment_method', value => 'csc' });
$p->update;

my $ref = $auth_details->{uniqueAuthId};
return $ref;
} else {
$c->stash->{error} = $resp->{paymentResult}->{status};
return undef;
}
} else {
$c->stash->{error} = $resp->{transactionState};
return undef;
}
}

return $self->$orig($c, $p);
};

=head2 waste_check_staff_payment_permissions
Staff can make payments via a PAYE endpoint.
=cut

sub waste_check_staff_payment_permissions {
my $self = shift;
my $c = $self->{c};
return unless $c->stash->{is_staff};
$c->stash->{staff_payments_allowed} = 'paye-api';
}

=head2 waste_event_state_map
State map for Echo states - not actually waste only as Echo
Expand Down Expand Up @@ -1472,8 +1323,6 @@ sub waste_munge_request_form_data {
=cut

sub waste_auto_confirm_report { 1 }
sub waste_staff_choose_payment_method { 0 }
sub waste_cheque_payments { 0 }

sub garden_service_id { 317 }
use constant GARDEN_WASTE_PAID_COLLECTION_BIN => 1;
Expand Down Expand Up @@ -1620,8 +1469,6 @@ sub apply_garden_waste_discount {
return @discounted;
}

sub garden_waste_new_bin_admin_fee { 0 }

sub bulky_collection_time { { hours => 7, minutes => 0 } }
sub bulky_cancellation_cutoff_time { { hours => 23, minutes => 59 } }
sub bulky_cancel_by_update { 1 }
Expand Down
4 changes: 0 additions & 4 deletions perllib/FixMyStreet/Cobrand/Bromley.pm
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,6 @@ sub waste_on_the_day_criteria {
}

sub waste_staff_choose_payment_method { 0 }
sub waste_cheque_payments { 0 }

sub waste_event_state_map {
return {
Expand All @@ -677,7 +676,6 @@ sub garden_service_id { 545 }
sub garden_service_name { 'Green Garden Waste collection service' }
sub garden_subscription_type_field { 'Subscription_Type' }
sub garden_subscription_container_field { 'Subscription_Details_Container_Type' }
sub garden_subscription_email_renew_reminder_opt_in { 0 }
sub garden_echo_container_name { 'LBB - GW Container' }
sub garden_due_days { 48 }

Expand Down Expand Up @@ -989,8 +987,6 @@ sub garden_waste_renewal_cost_pa {
return $cost;
}

sub garden_waste_new_bin_admin_fee { 0 }

sub waste_payment_ref_council_code { "LBB" }

sub waste_cc_payment_line_item_ref {
Expand Down
23 changes: 20 additions & 3 deletions perllib/FixMyStreet/Cobrand/Kingston.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use parent 'FixMyStreet::Cobrand::UKCouncils';

use utf8;
use Moo;
with 'FixMyStreet::Roles::Cobrand::Waste';
with 'FixMyStreet::Roles::Cobrand::KingstonSutton';
with 'FixMyStreet::Roles::Cobrand::SCP';
with 'FixMyStreet::Roles::Cobrand::Waste',
'FixMyStreet::Roles::Cobrand::KingstonSutton',
'FixMyStreet::Roles::Cobrand::SCP';

use Lingua::EN::Inflect qw( NUMWORDS );

Expand Down Expand Up @@ -122,6 +122,23 @@ sub garden_waste_renewal_sacks_cost_pa {
return $self->_get_cost('ggw_sacks_cost_renewal', $end_date);
}

sub garden_waste_new_bin_admin_fee {
my ($self, $new_bins) = @_;
$new_bins ||= 0;

my $per_new_bin_first_cost = $self->_get_cost('ggw_new_bin_first_cost');
my $per_new_bin_cost = $self->_get_cost('ggw_new_bin_cost');

my $cost = 0;
if ($new_bins > 0) {
$cost += $per_new_bin_first_cost;
if ($new_bins > 1) {
$cost += $per_new_bin_cost * ($new_bins - 1);
}
}
return $cost;
}

sub waste_request_single_radio_list { 0 }

=head2 bin_request_form_extra_fields
Expand Down
7 changes: 3 additions & 4 deletions perllib/FixMyStreet/Cobrand/Merton/Waste.pm
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package FixMyStreet::Cobrand::Merton::Waste;

use Moo::Role;
with 'FixMyStreet::Roles::Cobrand::Waste';
with 'FixMyStreet::Roles::Cobrand::SLWP';
with 'FixMyStreet::Roles::Cobrand::Adelante';
with 'FixMyStreet::Roles::Cobrand::Waste',
'FixMyStreet::Roles::Cobrand::SLWP',
'FixMyStreet::Roles::Cobrand::Adelante';

use FixMyStreet::App::Form::Waste::Report::Merton;
use FixMyStreet::App::Form::Waste::Request::Merton;
Expand Down Expand Up @@ -168,7 +168,6 @@ sub _closed_event {
}

sub garden_collection_time { '6:00am' }
sub garden_waste_new_bin_admin_fee { 0 }

sub waste_renewal_bins_wanted_disabled { 1 }

Expand Down
6 changes: 6 additions & 0 deletions perllib/FixMyStreet/Cobrand/Shropshire.pm
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ sub default_map_zoom { 6 }

sub send_questionnaires { 0 }

=item * Add display_name as an extra contact field
=cut

sub contact_extra_fields { [ 'display_name' ] }

=item * We restrict use of the contact form to abuse reports only.
=back
Expand Down
6 changes: 3 additions & 3 deletions perllib/FixMyStreet/Cobrand/Sutton.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use parent 'FixMyStreet::Cobrand::UKCouncils';

use utf8;
use Moo;
with 'FixMyStreet::Roles::Cobrand::Waste';
with 'FixMyStreet::Roles::Cobrand::KingstonSutton';
with 'FixMyStreet::Roles::Cobrand::SCP';
with 'FixMyStreet::Roles::Cobrand::Waste',
'FixMyStreet::Roles::Cobrand::KingstonSutton',
'FixMyStreet::Roles::Cobrand::SCP';

use Digest::SHA qw(sha1_hex);
use Encode qw(encode_utf8);
Expand Down
Loading

0 comments on commit b42225f

Please sign in to comment.