Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/AccessSystem/API/Controller/Root.pm
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,19 @@ sub verify: Chained('base') :PathPart('verify') :Args(0) {
my $result = $c->model('AccessDB::Person')->allowed_to_thing
($c->req->params->{token}, $c->req->params->{thing});
if($result && !$result->{error}) {
if($result->{beep}) {
# Send email now (else next automated one)
my $comm = $result->{person}->communications_rs->find({type => 'membership_fees_change'});
if ($comm) {
$self->emailer->send($comm);
}
}
$c->stash(
json => {
person => { name => $result->{person}->name },
inductor => $result->{person}->allowed->first->is_admin,
access => 1,
message => $result->{message} || '',
beep => $result->{beep} || 0,
cache => $result->{person}->tier->restrictions->{'times'} ? 0 : 1,
colour => $result->{person}->door_colour_to_code || 0x01,
Expand Down
32 changes: 23 additions & 9 deletions lib/AccessSystem/Schema/Result/Person.pm
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,11 @@ sub create_payment {
# If Donor tier and balance is now enough and only donor-ified after 1 month ago - revert
# (one month else they'll keep flipping in/out of donor)
if($self->is_donor) {
my $old_data = $self->confirmations->find({ token => 'old_tier'});
my $old_data = $self->confirmations->find({ token => $self->id . '_old_tier'});
if (!$old_data) {
warn "Can't find pre-donor tier data\n!";
return;
}
my $when = $dt_parser->parse_datetime($old_data->storage->{changed_on});
my $old_tier = $old_data->storage->{tier_id};
my $one_month_ago = $now->clone->subtract(months => 1);
Expand All @@ -585,7 +589,7 @@ sub create_payment {
if($current_bal < $self->dues) {
# Expanded for fees update 2025:
# If previously valid, and payment (intention) is less than dues (which have changed!)
# and actually expired (mid overlap), convert to donor-tier, fees to 0, store old tier/fees
# and actually expired (during overlap), convert to donor-tier, fees to 0, store old tier/fees
# this should happens before the reminder_email (which is not sent to donors)
if($valid_date
&& $valid_date->clone()->subtract(days => int($OVERLAP_DAYS / 2)) < $now
Expand All @@ -595,9 +599,10 @@ sub create_payment {
my $old_tier_id = $self->tier_id;
my $old_fees = $self->payment_override;
my $min_dues = $self->dues;
my $token = 'old_tier'; # findable!
my $token = $self->id . '_old_tier'; # findable!
# find_or_create in case it crashes during payment run(!)
$schema->txn_do(sub {
my $confirm = $self->confirmations->create({
my $confirm = $self->confirmations->find_or_create({
token => $token,
storage => {
tier_id => $old_tier_id,
Expand All @@ -610,7 +615,15 @@ sub create_payment {
payment_override => 0,
});
# Send an email (force renew):
$self->create_communication('Your Swindon Makerspace membership is now Donor Only', 'move_to_donation_tier', { current_balance => $current_bal, min_dues => $min_dues}, 1);
# But only if this is within a few months? if you have
# balance for years then.. sorry its a donation!
my $last_usage = $self->usage_by_date->search({}, { rows => 1 })->first;
if ($valid_date > $now->clone->subtract(months => 2)
&& $last_usage
&& $last_usage->accessed_date > $now->clone->subtract(months => 2)
) {
$self->create_communication('Your Swindon Makerspace membership is now Donor Only', 'move_to_donation_tier', { current_balance => $current_bal, min_dues => $min_dues}, 1);
}
});
warn "Member " . $self->bank_ref . " not covered fees, converted to Donor Tier";
return;
Expand Down Expand Up @@ -645,6 +658,10 @@ sub create_payment {
}
return;
}

# Donor tier members should not make "payments"
return if $self->is_donor;

if (!$valid_date) {
$self->create_communication('Your Swindon Makerspace membership has started', 'first_payment');
}
Expand All @@ -657,10 +674,7 @@ sub create_payment {
my $r_email = $self->communications_rs->find({type => 'reminder_email'});
$r_email->delete if $r_email;
}

# Donor tier members should not make "payments"
return if $self->is_donor;


# Only add $OVERLAP extra days if a first or renewal payment - these
# ensure member remains valid if standing order is not an
# exact month due to weekends and bank holidays
Expand Down
2 changes: 1 addition & 1 deletion lib/AccessSystem/Schema/ResultSet/Person.pm
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ sub allowed_to_thing {
return {
person => $person,
beep => $beep,
message => 'Fees have changed. Check email.',
message => 'Fees have changed. Check email.',
thing => $person->allowed->first->tool,
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[% WRAPPER layout.html.tt %]
<p>Dear [% member.name %],</p>

<p>Your membership has been moved to the donation tier.\n
<p>Your membership has been moved to the donation tier.<br/>
This is because our current membership fees have changed and you have not updated your payments to reflect this.<br/>
This donation tier does not have access to the space</p>

Expand Down
5 changes: 5 additions & 0 deletions sql/MembershipFees-2025-12.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
INSERT INTO tiers (name, description, price, in_use, concessions_allowed) values ('Donation Only', 'Making voluntary contributions to help support the Makerspace', 0, true, false);
UPDATE tiers SET price=600 where id=1;
UPDATE tiers SET price=1800 where id=2;
UPDATE tiers SET price=3000 where id=3;
UPDATE tiers SET price=4200 where id=4;