Import from revbank fork
This commit is contained in:
commit
30c55d21de
6 changed files with 152 additions and 0 deletions
26
bitlair_3dprint
Normal file
26
bitlair_3dprint
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#!perl
|
||||||
|
|
||||||
|
HELP "3dprint <gram>" => "3D-print filament afrekenen";
|
||||||
|
|
||||||
|
use Scalar::Util qw(looks_like_number);
|
||||||
|
|
||||||
|
sub command :Tab(3dprint) ($self, $cart, $command, @) {
|
||||||
|
return NEXT if $command ne '3dprint';
|
||||||
|
|
||||||
|
return "Gewicht in gram, inclusief supports en purges", \&gram;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub gram($self, $cart, $input, @) {
|
||||||
|
looks_like_number($input) and $input == int($input) or return REJECT, "Invalid number!";
|
||||||
|
my $gram = int($input);
|
||||||
|
return REJECT, "$input: Invalid amount." if $gram <= 0;
|
||||||
|
|
||||||
|
my $beneficiary = "3dprinter";
|
||||||
|
my $amount = 0.10 + $gram * 0.03;
|
||||||
|
|
||||||
|
$cart
|
||||||
|
->add(-$amount, "Given to $beneficiary ($gram g)")
|
||||||
|
->add_contra($beneficiary, +$amount, "Received from \$you (${gram} g)");
|
||||||
|
|
||||||
|
return ACCEPT;
|
||||||
|
}
|
17
bitlair_bigmoney
Normal file
17
bitlair_bigmoney
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#!perl
|
||||||
|
|
||||||
|
sub command :Tab(bigmoney) {
|
||||||
|
my ($self, $cart, $command) = @_;
|
||||||
|
|
||||||
|
return NEXT if $command ne "bigmoney";
|
||||||
|
|
||||||
|
my @list = sort {
|
||||||
|
(split " ", $b)[1] <=> (split " ", $a)[1]
|
||||||
|
} grep {
|
||||||
|
not RevBank::Users::is_hidden($_)
|
||||||
|
} slurp("accounts");
|
||||||
|
|
||||||
|
print join "", @list[0..9];
|
||||||
|
|
||||||
|
return ACCEPT;
|
||||||
|
}
|
27
bitlair_deposit_methods
Normal file
27
bitlair_deposit_methods
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#!perl
|
||||||
|
|
||||||
|
sub hook_deposit_methods($class, $message, $hash, @) {
|
||||||
|
$$message = <<"END";
|
||||||
|
|
||||||
|
Selecteer één van de volgende:
|
||||||
|
|
||||||
|
'iban': Abort en ga naar >>> https://deposit.bitlair.nl <<<
|
||||||
|
'cash': Contant geld in de kas
|
||||||
|
'reimburse': Declaraties van aankopen waar je van tevoren toestemming voor hebt gekregen
|
||||||
|
-> Stuur een scan van het bonnetje naar treasury\@bitlair.nl en vermeld dat je het bedrag via Revbank hebt geclaimed
|
||||||
|
-> Gebruik dit niet voor declaraties van meer dan 20 EUR
|
||||||
|
'other': Iets anders, geef een beschrijving op
|
||||||
|
END
|
||||||
|
|
||||||
|
%$hash = (
|
||||||
|
cash => { description => "Deposit (Cash)" },
|
||||||
|
other => { description => "Deposit (%s)", prompts => [ "Description" ] },
|
||||||
|
reimburse => {
|
||||||
|
description => "Reimbursement (%s, approval: %s)",
|
||||||
|
prompts => [
|
||||||
|
"Please provide a short description",
|
||||||
|
"Which board member gave approval?",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
19
bitlair_mqtt
Normal file
19
bitlair_mqtt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#!perl
|
||||||
|
|
||||||
|
use Cwd ();
|
||||||
|
use Net::MQTT::Simple;
|
||||||
|
|
||||||
|
my $mqtt = Net::MQTT::Simple->new("mqtt.bitlair.nl");
|
||||||
|
|
||||||
|
sub command { NEXT }
|
||||||
|
|
||||||
|
sub hook_checkout {
|
||||||
|
my ($class, $cart, $user, $transaction_id) = @_;
|
||||||
|
|
||||||
|
my @entries = $cart->entries('product_id') or return;
|
||||||
|
|
||||||
|
for my $entry (@entries) {
|
||||||
|
$mqtt->publish("bitlair/pos/product" => $entry->{description})
|
||||||
|
for 1..$entry->quantity;
|
||||||
|
}
|
||||||
|
}
|
15
bitlair_nomunnie
Normal file
15
bitlair_nomunnie
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#!perl
|
||||||
|
|
||||||
|
use IO::Socket::IP;
|
||||||
|
use Net::MQTT::Simple "mqtt.bitlair.nl";
|
||||||
|
|
||||||
|
sub command { NEXT }
|
||||||
|
|
||||||
|
sub hook_user_balance {
|
||||||
|
my ($class, $user, $old, $delta, $new, $transaction_id) = @_;
|
||||||
|
|
||||||
|
return if $new >= -13.37;
|
||||||
|
return if RevBank::Users::is_hidden($user);
|
||||||
|
|
||||||
|
publish "bitlair/bank/shame" => "NO MUNNIE?";
|
||||||
|
}
|
48
bitlair_saldo
Normal file
48
bitlair_saldo
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#!perl
|
||||||
|
|
||||||
|
use POSIX qw(strftime);
|
||||||
|
|
||||||
|
sub _box(@lines) {
|
||||||
|
print(
|
||||||
|
"#" x 79, "\n",
|
||||||
|
(map { sprintf("## %-73s ##\n", $_) } @lines),
|
||||||
|
"#" x 79, "\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub hook_checkout_done($class, $cart, $account, $transaction_id, @) {
|
||||||
|
defined $account or return; # hacks like 'undo' don't have an acting user
|
||||||
|
RevBank::Accounts::is_hidden($account) and return;
|
||||||
|
|
||||||
|
my $balance = RevBank::Accounts::balance($account) or return;
|
||||||
|
my $since = RevBank::Accounts::since($account);
|
||||||
|
|
||||||
|
if ($balance < -13.37) {
|
||||||
|
_box(
|
||||||
|
"Hoi $account,",
|
||||||
|
"",
|
||||||
|
"Je saldo is $balance en dus lager dan toegestaan.",
|
||||||
|
"",
|
||||||
|
"Saldo aanvullen kan via https://deposit.bitlair.nl",
|
||||||
|
"",
|
||||||
|
"Bedankt!",
|
||||||
|
"-- Het bestuur",
|
||||||
|
);
|
||||||
|
} elsif (
|
||||||
|
defined $since
|
||||||
|
and $since =~ /^-\@(.*)/
|
||||||
|
and $1 lt strftime('%Y-%m-%d_%H:%M:%S', localtime(time() - 14 * 86400))
|
||||||
|
) {
|
||||||
|
_box(
|
||||||
|
"Hoi $account,",
|
||||||
|
"",
|
||||||
|
"Je staat al sinds $1 negatief, dus meer dan 2 weken. Deelnemers",
|
||||||
|
"mogen rood staan, maar niet langdurig.",
|
||||||
|
"",
|
||||||
|
"Saldo aanvullen kan via https://deposit.bitlair.nl",
|
||||||
|
"",
|
||||||
|
"Bedankt!",
|
||||||
|
"-- Het bestuur",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue