Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Door "pending" status on payment #90

Merged
merged 1 commit into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions lib/AccessSystem/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ our $VERSION = '15.0';

__PACKAGE__->load_namespaces();

sub the_door {
my ($self) = @_;

return $self->resultset('Tool')->find({ name => 'The Door'});
}

1;
13 changes: 13 additions & 0 deletions lib/AccessSystem/Schema/Result/Person.pm
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,13 @@ sub create_payment {
return;
}
if (!$valid_date) {
$self->update_door_access();
$self->create_communication('Your Swindon Makerspace membership has started', 'first_payment');
}

if($valid_date && $valid_date < $now) {
# renewed payments
$self->update_door_access();
$self->create_communication('Your Swindon Makerspace membership has restarted', 'rejoin_payment');
}
# Only add $OVERLAP extra days if a first or renewal payment - these
Expand Down Expand Up @@ -719,4 +721,15 @@ sub door_colour_to_code {
return undef;
}

sub update_door_access {
my ($self) = @_;

# This entry should exist, but covid policy may have removed it..
my $door = $self->result_source->schema->the_door();
my $door_allowed = $self->allowed->find_or_create({ tool_id => $door->id });
if($door_allowed->pending_acceptance eq 'true') {
$door_allowed->update({ pending_acceptance => 'false', accepted_on => DateTime->now()});
}
}

1;