Skip to content

Commit

Permalink
[Waste] Add separate first garden bin cost.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Jan 10, 2025
1 parent 96aa17f commit 8088185
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 4 deletions.
7 changes: 5 additions & 2 deletions perllib/FixMyStreet/App/Controller/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,8 @@ sub garden : Chained('garden_setup') : Args(0) {
$c->detach('property_redirect') if $c->stash->{waste_features}->{garden_new_disabled};
$c->detach('property_redirect') if $c->cobrand->garden_current_subscription;

$c->stash->{per_bin_cost} = $c->cobrand->garden_waste_cost_pa;
$c->stash->{per_bin_cost} = $c->cobrand->garden_waste_subsequent_cost_pa;
$c->stash->{per_bin_first_cost} = $c->cobrand->garden_waste_first_cost_pa;
$c->stash->{per_sack_cost} = $c->cobrand->garden_waste_sacks_cost_pa;
$c->stash->{next_month_cost} = $c->cobrand->garden_waste_cost_pa_in_one_month($c->stash->{per_bin_cost});

Expand All @@ -1222,7 +1223,8 @@ sub garden_modify : Chained('garden_setup') : Args(0) {

$c->detach( '/auth/redirect' ) unless $c->user_exists;

$c->stash->{per_bin_cost} = $c->cobrand->garden_waste_cost_pa;
$c->stash->{per_bin_cost} = $c->cobrand->garden_waste_subsequent_cost_pa;
$c->stash->{per_bin_first_cost} = $c->cobrand->garden_waste_first_cost_pa;

if ($c->stash->{slwp_garden_sacks} && $service->{garden_container} == 28) { # SLWP Sack
if ($c->cobrand->moniker eq 'kingston') {
Expand Down Expand Up @@ -1320,6 +1322,7 @@ sub garden_renew : Chained('garden_setup') : Args(0) {
end_date => $service->{end_date},
};

# TODO first_cost Bexley GGW
$c->stash->{per_bin_renewal_cost} = $c->cobrand->garden_waste_renewal_cost_pa($service->{end_date});
$c->stash->{per_sack_renewal_cost} = $c->cobrand->garden_waste_renewal_sacks_cost_pa($service->{end_date});

Expand Down
2 changes: 2 additions & 0 deletions perllib/FixMyStreet/App/Form/Waste/Garden.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ sub details_update_fields {
$c->stash->{cost_pa},
$c->stash->{cost_now_admin},
$c->stash->{per_bin_cost},
$c->stash->{per_bin_first_cost},
$c->stash->{per_new_bin_cost},
$c->stash->{per_new_bin_first_cost},
) =
$c->cobrand->apply_garden_waste_discount(
$c->stash->{cost_pa},
$c->stash->{cost_now_admin},
$c->stash->{per_bin_cost},
$c->stash->{per_bin_first_cost},
$c->stash->{per_new_bin_cost},
$c->stash->{per_new_bin_first_cost},
);
Expand Down
4 changes: 4 additions & 0 deletions perllib/FixMyStreet/Roles/Cobrand/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ sub garden_waste_cost_pa {
return $cost;
}

# Same cost no matter the quantity
sub garden_waste_first_cost_pa { $_[0]->garden_waste_cost_pa }
sub garden_waste_subsequent_cost_pa { $_[0]->garden_waste_cost_pa }

# Same as full cost
sub waste_get_pro_rata_cost {
my ($self, $bins, $end) = @_;
Expand Down
2 changes: 2 additions & 0 deletions templates/web/base/waste/garden/modify.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
<div class="cost-pa__total js-bin-costs"
[% IF form.saved_data.apply_discount %]
data-per_bin_cost="[% c.cobrand.apply_garden_waste_discount(per_bin_cost) %]"
data-per_bin_first_cost="[% c.cobrand.apply_garden_waste_discount(per_bin_first_cost) %]"
data-per_new_bin_first_cost="[% c.cobrand.apply_garden_waste_discount(per_new_bin_first_cost) %]"
data-per_new_bin_cost="[% c.cobrand.apply_garden_waste_discount(per_new_bin_cost) %]"
data-pro_rata_bin_cost="[% c.cobrand.apply_garden_waste_discount(garden_form_data.pro_rata_bin_cost) %]"
[% ELSE %]
data-per_bin_cost="[% per_bin_cost %]"
data-per_bin_first_cost="[% per_bin_first_cost %]"
data-per_new_bin_first_cost="[% per_new_bin_first_cost %]"
data-per_new_bin_cost="[% per_new_bin_cost %]"
data-pro_rata_bin_cost="[% garden_form_data.pro_rata_bin_cost %]"
Expand Down
2 changes: 2 additions & 0 deletions templates/web/base/waste/garden/renew.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
<div class="cost-pa__total js-bin-costs"
[% IF form.saved_data.apply_discount %]
data-per_bin_cost="[% c.cobrand.apply_garden_waste_discount(per_bin_renewal_cost) %]"
data-per_bin_first_cost="[% c.cobrand.apply_garden_waste_discount(per_bin_renewal_first_cost) %]"
data-per_new_bin_first_cost="[% c.cobrand.apply_garden_waste_discount(per_new_bin_first_cost) %]"
data-per_new_bin_cost="[% c.cobrand.apply_garden_waste_discount(per_new_bin_cost) %]"
[% ELSE %]
data-per_bin_cost="[% per_bin_renewal_cost %]"
data-per_bin_first_cost="[% per_bin_renewal_first_cost %]"
data-per_new_bin_first_cost="[% per_new_bin_first_cost %]"
data-per_new_bin_cost="[% per_new_bin_cost %]"
[% END %]
Expand Down
1 change: 1 addition & 0 deletions templates/web/base/waste/garden/subscribe_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<div class="cost-pa__total js-bin-costs"
data-per_bin_cost="[% per_bin_cost %]"
data-per_bin_first_cost="[% per_bin_first_cost %]"
data-per_new_bin_first_cost="[% per_new_bin_first_cost %]"
data-per_new_bin_cost="[% per_new_bin_cost %]"
>
Expand Down
5 changes: 3 additions & 2 deletions web/js/waste.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ $(function() {

var costs = $('.js-bin-costs'),
cost = costs.data('per_bin_cost') / 100,
first_cost = costs.data('per_bin_first_cost') / 100,
per_new_bin_first_cost = costs.data('per_new_bin_first_cost') / 100,
per_new_bin_cost = costs.data('per_new_bin_cost') / 100,
pro_rata_bin_cost = costs.data('pro_rata_bin_cost') / 100;
function bin_cost_new() {
var total_bins = parseInt($('#bins_wanted').val() || 0);
var existing_bins = parseInt($('#current_bins').val() || 0);
var new_bins = total_bins - existing_bins;
var total_per_year = total_bins * cost;
var total_per_year = (total_bins-1) * cost + first_cost;
var admin_fee = 0;
if (new_bins > 0 && per_new_bin_first_cost) {
admin_fee += per_new_bin_first_cost;
Expand All @@ -42,7 +43,7 @@ $(function() {
var existing_bins = parseInt($('#current_bins').val() || 0);
var new_bins = total_bins - existing_bins;
var pro_rata_cost = 0;
var total_per_year = total_bins * cost;
var total_per_year = (total_bins-1) * cost + first_cost;
var admin_fee = 0;
var new_bin_text = new_bins == 1 ? 'bin' : 'bins';
$('#new_bin_text').text(new_bin_text);
Expand Down

0 comments on commit 8088185

Please sign in to comment.