Skip to content
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
5 changes: 4 additions & 1 deletion cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ requires 'JSON';
requires 'MIME::Base64';
requires 'CatalystX::AuthenCookie';
requires 'Catalyst::Plugin::StackTrace';
requires 'DBD::Pg';
requires 'DBD::Pg', 3.18.0;
requires 'DateTime::Format::Pg';
requires 'List::Util';
requires 'Mojo::Base';
Expand All @@ -44,3 +44,6 @@ requires 'Email::Sender::Transport::SMTP';
requires 'DBIx::Class::EasyFixture';
requires 'Time::HiRes';
requires 'Date::Holidays::GB';
requires 'Test::More';
requires 'Test::Exception';
requires 'DBIx::Class::InflateColumn::Boolean';
Binary file added docs/diagrams/bank_import_activity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions docs/diagrams/bank_import_activity.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@startuml

:Download latest OFX file;
:Rename OFX file to today's date;
:Copy OFX file to Access Server;
:Find date of most recent DB Transaction;
:Subtract 2 days just in case;
:Find all OFX files newer than date picked;
:Load each file;
while(Get payment from file)
if (Amount is > 0) then (check name)
if (Name contains sm) then (find member)
if (Numerical id is a Person id) then (import)
if (Already imported - \nmatch on date/amount/person?) then (no)
:Insert new transaction into DB;
else (yes)
stop
endif
else (no)
stop
endif
else (no)
stop
endif
else (no)
stop
endif
endwhile
stop
@enduml
Binary file added docs/diagrams/extend_membership_activity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions docs/diagrams/extend_membership_activity.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@startuml
skinparam ConditionEndStyle hline

start
while (Get Member from DB)
:Find current expiry date if any;
if (Expiry date exists and\nIs in the next $OVERLAP days) then (yes)
if (Expiry date) then (no)
if (Voucher code) then (yes)
:Set voucher start-date to now;
endif
->continue;
endif
->continue;
:Get current balance (sum of all Transactions);
if ((NEW) Member is donor) then (yes)
:Load previous tier information;
if (Made Donor less than 1 month ago and\nCurrent balance enough for old tier) then (yes)
:Reset tier to old tier;
endif
endif
if (Current balance < fees) then (yes)
if ((NEW) Has previously paid anything and\nActually expired and\nBalance is > 0 and\nNot donor tier and\nChosen amount less than default tier fee) then (yes)
:Store current tier and payment amount;
:Switch tier to donor and payment amount to 0;
:Send email announcing donor switch;
break
else (no)
:Log "balance not enough";
break
endif
if (Expiry date and\nExpired between 5 days ago and 1 month ago) then (yes)
:Send "reminder_email" email;
endif
endif
if (Expiry date) then (no)
:Send email "first_payment";
endif
->continue;
if (Expiry date and\nExpiry date is before now) then (yes)
:Force send email "rejoin_payment";
:Delete any previous "reminder_email" communication;
endif
if (No Expiry date or\n Expiry date is before now) then (yes)
:Set Expiry date to today
:Extra days is $overlap days;
endif
->continue;
:Enable Door access (in case of returning pre-covid member);
:Transaction Amount = membership fees
:Calculate new Expiry date (old one + 1 month + overlap days);
if (Current balance > fee * 12 * 0.9) then (yes)
:Recalulcate new Expiry date (old one + 12 months + overlap days);
:Transaction Amount = membership fees * 12 * 0.9;
endif
->no;
:Create negative Transaction for Transaction Amount;
:Create Dues entry (Amount, paid on, expiry date);
endif
endwhile
:Repeat if more members;
stop
@enduml
15 changes: 9 additions & 6 deletions lib/AccessSystem/API/Controller/Root.pm
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,13 @@ sub verify: Chained('base') :PathPart('verify') :Args(0) {
person => { name => $result->{person}->name },
inductor => $result->{person}->allowed->first->is_admin,
access => 1,
beep => $result->{beep} || 0,
cache => $result->{person}->tier->restrictions->{'times'} ? 0 : 1,
colour => $result->{person}->door_colour_to_code || 0x01,
}
);
} elsif($result) {
# Found Tool and Person but not allowed in some way:
$c->stash(
json => {
access => 0,
Expand Down Expand Up @@ -943,14 +945,15 @@ sub get_dues: Chained('base'): PathPart('get_dues'): Args(0) {
my $tier = $c->req->params->{tier} || 3;

$c->log->debug(Data::Dumper::Dumper($c->req->params));
my $dummy_dues = $c->model('AccessDB::Person')->get_dummy_dues($tier, $dob, $concession);
# $c->log->debug("Vals: $dob $concession $other_hackspace Result: ", $new_person->dues);
my $new_person = $c->model('AccessDB::Person')->new_result({});
$new_person->tier_id($tier);
$new_person->dob($dob) if $dob;
$new_person->concessionary_rate_override($concession);
# my $new_person = $c->model('AccessDB::Person')->new_result({});
# $new_person->tier_id($tier);
# $new_person->dob($dob) if $dob;
# $new_person->concessionary_rate_override($concession);

$c->log->debug("Vals: $dob $concession Result: ", $new_person->dues);
$c->response->body($new_person->dues / 100);
$c->log->debug("Vals: $dob $concession Result: ", $dummy_dues);
$c->response->body($dummy_dues / 100);
}

sub register: Chained('base'): PathPart('register'): Args(0) {
Expand Down
109 changes: 49 additions & 60 deletions lib/AccessSystem/Form/Person.pm
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,35 @@ has_field email => field_add_defaults {
required => 'Please enter an email we can use to contact you',
},
unique_message => "That email address is already registered, did you do submit twice?",
help_string => 'An email address we can contact you on. Your membership payment details will be sent to it.',
help_string => 'An email address we can contact you on. Your membership/donor payment details will be sent to it.',
};

has_field address => field_add_defaults {
type => 'TextArea',
label => 'Address *',
required => 1,
rows => 6,
maxlength => 1024,
wrapper_attr => { id => 'field-address', },
tags => { no_errors => 1 },
messages => {
required => 'Please enter your full street address',
},
help_string => 'As it would appear on an envelope, required by the gov for the membership register.',
};

# Display 3 tier choices as big buttons?
has_field tier => field_add_defaults {
type => 'Select',
required => 1,
active_column => 'in_use',
label_column => 'display_name_and_price',
widget => 'RadioGroup',
messages => {
required => 'Please choose a payment tier',
},
wrapper_attr => { id => 'field-tier', class => 'payment' },
help_string => 'Not resident in Swindon, and a member of a space elsewhere?<br/>Access weekends and Wednesday nights only<br/>Access 24/7 365 days a year<br/>Full access, sponsoring member<br/>Send donations only, not a member of the company',
};

has_field opt_in => field_add_defaults {
Expand Down Expand Up @@ -175,7 +203,7 @@ has_field dob => field_add_defaults {
end_date => DateTime->now->clone()->subtract(years => 17)->ymd,
start_date => DateTime->now->clone()->subtract(years => 120)->ymd,
required => 1,
wrapper_attr => { id => 'field-dob', class => 'payment' },
wrapper_attr => { id => 'field-dob', class => 'payment donor_hide' },
tags => { no_errors => 1 },
messages => {
required => 'Please enter your date of birth',
Expand All @@ -184,39 +212,19 @@ has_field dob => field_add_defaults {
help_string => 'YYYY-MM, only Year/Month accuracy is required. We use this to ensure that you are old enough to be an adult member, or if you are eligible for senior (65) concessions.',
};

has_field address => field_add_defaults {
type => 'TextArea',
label => 'Address *',
required => 1,
rows => 6,
maxlength => 1024,
wrapper_attr => { id => 'field-address', },
tags => { no_errors => 1 },
messages => {
required => 'Please enter your full street address',
},
help_string => 'As it would appear on an envelope, for the membership register.',
};

# has_field 'vehicles' => field_add_defaults {
# type => 'Repeatable',
# };

# has_field 'vehicles.plate_reg' => field_add_defaults {
has_field 'plate_reg' => field_add_defaults {
type => 'Text',
label => 'Car Reg Plate',
required => 0,
maxlength => 7,
wrapper_attr => { id => 'field-plate-reg', },
wrapper_attr => { id => 'field-plate-reg', class => 'donor_hide'},
tags => { no_errors => 1 },
messages => {
required => 'Please enter your car licence plate string (max 7 chars)',
},
help_string => 'The car park has number plate recognition, enter your plate for us to automatically add you to the system. If not entered you will need to manually check in every visit.',
help_string => '(Optional) Car park has no parking rules but this may change (again).',
};
# has_field 'vehicles.person' => ( type => 'Hidden' );
# has_field 'vehicles.person_id' => ( type => 'PrimaryKey' );

has_field how_found_us => field_add_defaults {
type => 'Select',
Expand All @@ -240,6 +248,7 @@ has_field associated_button => (
type => 'Button',
value => 'Change/Show Associated Accounts',
label => '',
wrapper_attr => { class => 'donor_hide' },
element_attr => { style => 'background-color: #eabf83;' },
);

Expand All @@ -255,17 +264,17 @@ has_field github_user => field_add_defaults {
help_string => '(Optional) A github username, this will allow us to give you access to our code repositories and wiki.',
};

has_field telegram_username => field_add_defaults {
type => 'Text',
required => 0,
maxlength => 255,
wrapper_attr => { id => 'field-telegram-username', class => 'associated associated_hide', style => "display:none"},
tags => { no_errors => 1 },
messages => {
required => 'Please enter a telegram screen name',
},
help_string => '(Optional) Your Telegram username, used to tag you by a bot (for inductions etc)',
};
# has_field telegram_username => field_add_defaults {
# type => 'Text',
# required => 0,
# maxlength => 255,
# wrapper_attr => { id => 'field-telegram-username', class => 'associated associated_hide', style => "display:none"},
# tags => { no_errors => 1 },
# messages => {
# required => 'Please enter a telegram screen name',
# },
# help_string => '(Optional) Your Telegram username, used to tag you by a bot (for inductions etc)',
# };

has_field google_id => field_add_defaults {
type => 'Text',
Expand All @@ -279,24 +288,11 @@ has_field google_id => field_add_defaults {
help_string => '(Optional) Your google account email address, (even if the same as your usual email address) - this will be used for access to our Google Drive documents.',
};

# Display 3 tier choices as big buttons?
has_field tier => field_add_defaults {
type => 'Select',
required => 1,
active_column => 'in_use',
label_column => 'display_name_and_price',
widget => 'RadioGroup',
messages => {
required => 'Please choose a payment tier',
},
wrapper_attr => { id => 'field-tier', class => 'payment' },
help_string => 'Not resident in Swindon, and a member of a space elsewhere?<br/>Access weekends and Wednesday nights only<br/>Access 24/7 365 days a year<br/>Full access, sponsoring member',
};

has_field payment_button => (
type => 'Button',
value => 'Change/Show More Payment Options',
label => '',
wrapper_attr => { class => 'donor_hide' },
element_attr => { style => 'background-color: #eabf83;' },
);

Expand All @@ -321,15 +317,6 @@ has_field concessionary_rate_override => field_add_defaults {
help_string => 'Do you qualify for our reduced payment rate? Choose what best matches your situation, please show documentation to a director to prove your status.',
};

# has_field member_of_other_hackspace => field_add_defaults {
# type => 'Checkbox',
# required => 0,
# wrapper_attr => { id => 'field-member-of-other-hackspace', class => 'payment payment_hide', style => "display:none" },
# tags => { no_errors => 1},
# label => 'I am mainly a member of another hackspace/makerspace',
# help_string => 'Just visiting or only in Swindon part of the year? If you are a member of another hackspace somewhere, you can join us for only &pound;5/month.',
# };

has_field payment_override => field_add_defaults {
type => 'Money',
# currency_symbol => '&pound;',
Expand All @@ -348,6 +335,7 @@ has_field door_colour => field_add_defaults {
required => 0,
label => 'Entry Colour',
default => 'green',
wrapper_attr => { class => 'donor_hide' },
options => [
{ value => 'green', label => 'Green', attributes => { class => 'door_colour' }, checked => 1 },
{ value => 'white', label => 'White', attributes => { class => 'door_colour' } },
Expand All @@ -364,6 +352,7 @@ has_field door_colour => field_add_defaults {
has_field voucher_code => field_add_defaults {
type => 'Text',
required => 0,
wrapper_attr => { class => 'donor_hide' },
label => 'Voucher Code',
wrapper_attr => { id => 'field-voucher-code', class => 'payment_hide', style => "display:none" },
help_string => 'If you have a voucher, enter the code, or location you got it, here.',
Expand All @@ -374,7 +363,7 @@ has_field membership_guide => field_add_defaults {
type => 'Checkbox',
required => 1,
label => 'I have read and agree to comply with the Membership Guide *',
wrapper_attr => { id => 'field-membership-guide', },
wrapper_attr => { id => 'field-membership-guide', class => 'donor_hide'},
tags => { no_errors => 1 },
messages => {
required => 'Please read and agree to the Membership Guide',
Expand All @@ -386,7 +375,7 @@ has_field health_and_safety => field_add_defaults {
type => 'Checkbox',
required => 1,
label => 'I have read and agree to comply with the Health & Safety Policy *',
wrapper_attr => { id => 'field-health-safety', },
wrapper_attr => { id => 'field-health-safety', class => 'donor_hide' },
tags => { no_errors => 1 },
messages => {
required => 'Please read and agree to the Health & Safety Policy',
Expand Down
3 changes: 2 additions & 1 deletion lib/AccessSystem/Schema/Result/Allowed.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use warnings;

use base 'DBIx::Class::Core';

__PACKAGE__->load_components(qw/InflateColumn::DateTime TimeStamp UUIDColumns/);
__PACKAGE__->load_components(qw/InflateColumn::DateTime TimeStamp UUIDColumns InflateColumn::Boolean/);

__PACKAGE__->table('allowed');

Expand All @@ -28,6 +28,7 @@ __PACKAGE__->add_columns(
pending_acceptance => {
data_type => 'boolean',
default_value => 'true',
is_boolean => 1,
},
accepted_on => {
data_type => 'datetime',
Expand Down
Loading