Bitlair changes
This commit is contained in:
parent
3600e2b6db
commit
fc410035ca
13 changed files with 133 additions and 13 deletions
|
@ -72,7 +72,7 @@ sub hook_account_balance($class, $account, $old, $delta, $new, @) {
|
||||||
my $sign = $delta->cents >= 0 ? '+' : '-';
|
my $sign = $delta->cents >= 0 ? '+' : '-';
|
||||||
my $rood = $new->cents < 0 ? '31;' : '';
|
my $rood = $new->cents < 0 ? '31;' : '';
|
||||||
my $abs = $delta->abs;
|
my $abs = $delta->abs;
|
||||||
my $warn = $new->cents < -2300 ? " \e[5;1m(!!)\e[0m" : "";
|
my $warn = $new->cents < -1337 ? " \e[5;1m(!!)\e[0m" : "";
|
||||||
|
|
||||||
$_ = $_->string("+") for $old, $new;
|
$_ = $_->string("+") for $old, $new;
|
||||||
printf "New balance for $account: $old $sign $abs = \e[${rood}1m$new\e[0m$warn\n",
|
printf "New balance for $account: $old $sign $abs = \e[${rood}1m$new\e[0m$warn\n",
|
||||||
|
|
26
plugins/bitlair_3dprint
Normal file
26
plugins/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
plugins/bitlair_bigmoney
Normal file
17
plugins/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("revbank.accounts");
|
||||||
|
|
||||||
|
print join "", @list[0..9];
|
||||||
|
|
||||||
|
return ACCEPT;
|
||||||
|
}
|
19
plugins/bitlair_git
Normal file
19
plugins/bitlair_git
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#!perl
|
||||||
|
|
||||||
|
use Cwd ();
|
||||||
|
|
||||||
|
sub command { NEXT }
|
||||||
|
|
||||||
|
sub hook_checkout_done {
|
||||||
|
my ($class, $cart, $username, $transaction_id) = @_;
|
||||||
|
|
||||||
|
my @cart_printed = map { "\n-> $_" } map { $_->as_printable } $cart->entries;
|
||||||
|
|
||||||
|
my $fn = "/tmp/revbank$$.commit";
|
||||||
|
open my $fh, ">", $fn or warn $!;
|
||||||
|
print $fh "$username ($transaction_id)\n@cart_printed";
|
||||||
|
close $fh or warn $!;
|
||||||
|
|
||||||
|
my $output = `(cp revbank.accounts revbank.market revbank.products ~/data.git/ && cd ~/data.git/ && git commit -a -F $fn) 2>&1`;
|
||||||
|
warn "Meh, gitfaal: $output" if $?;
|
||||||
|
}
|
19
plugins/bitlair_mqtt
Normal file
19
plugins/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
plugins/bitlair_nomunnie
Normal file
15
plugins/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?";
|
||||||
|
}
|
|
@ -37,6 +37,10 @@ sub amount :Tab(13.37,42) ($self, $cart, $input, @) {
|
||||||
sub how :Tab(&how_tab) ($self, $cart, $input, @) {
|
sub how :Tab(&how_tab) ($self, $cart, $input, @) {
|
||||||
my %methods = %{ $self->{deposit_methods} };
|
my %methods = %{ $self->{deposit_methods} };
|
||||||
|
|
||||||
|
if ($input eq "iban") {
|
||||||
|
return ABORT, "\nBank transactions now go via iDeal:\n\n >>> https://deposit.bitlair.nl <<<\n\n"
|
||||||
|
}
|
||||||
|
|
||||||
my $how = $self->{how} = $methods{$input}
|
my $how = $self->{how} = $methods{$input}
|
||||||
or return REJECT, "'$input' is not a valid answer.";
|
or return REJECT, "'$input' is not a valid answer.";
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
use IPC::Open2 qw(open2);
|
use IPC::Open2 qw(open2);
|
||||||
use List::Util qw(sum);
|
use List::Util qw(sum);
|
||||||
|
|
||||||
my $iban = "NL99ABCD1234567890";
|
my $iban = "NL89RABO0111741386";
|
||||||
my $beneficiary = "Account Name";
|
my $beneficiary = "Stichting Bitlair";
|
||||||
|
|
||||||
sub hook_checkout($class, $cart, $account, $transaction_id, @) {
|
sub hook_checkout($class, $cart, $account, $transaction_id, @) {
|
||||||
my @entries = $cart->entries("is_deposit");
|
my @entries = $cart->entries("is_deposit");
|
||||||
|
@ -57,6 +57,8 @@ sub hook_checkout($class, $cart, $account, $transaction_id, @) {
|
||||||
$lines[3] =~ s/$/ EPC QR codes. N26 also works./;
|
$lines[3] =~ s/$/ EPC QR codes. N26 also works./;
|
||||||
$lines[5] =~ s/$/ For manual transfers, use this/;
|
$lines[5] =~ s/$/ For manual transfers, use this/;
|
||||||
$lines[6] =~ s/$/ IBAN: $iban/;
|
$lines[6] =~ s/$/ IBAN: $iban/;
|
||||||
|
$lines[7] =~ s/$/ Benificiary: $beneficiary/;
|
||||||
|
$lines[8] =~ s/$/ Description: Deposit $user/;
|
||||||
|
|
||||||
print @lines;
|
print @lines;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,11 @@ sub hook_deposit_methods($class, $message, $hash, @) {
|
||||||
|
|
||||||
Please type one of the following:
|
Please type one of the following:
|
||||||
|
|
||||||
'iban': IBAN transfer (NL 69 ABNA 0431 1582 07)
|
'iban': Deprecated. Abort and go to https://deposit.bitlair.nl instead
|
||||||
'cash': Cash in the cash box
|
'cash': Cash in the cash box
|
||||||
'reimburse': Reimbursement of expenses agreed upon in advance
|
'reimburse': Reimbursement of expenses agreed upon in advance
|
||||||
Note: we require an invoice or receipt with this exact amount!
|
Note #1: we require an invoice or receipt with this exact amount!
|
||||||
|
Note #2: please do not use this plugin for amounts >20 EUR
|
||||||
'other': Provide a manual description
|
'other': Provide a manual description
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
8
plugins/revspace_cokeurl
Normal file
8
plugins/revspace_cokeurl
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# Accept the odd QR-codes on Coke (and Fanta, etc.) cans, as they also contain the EAN.
|
||||||
|
|
||||||
|
# For this plugin to be useful, it needs to be BEFORE "users" in "revbank.plugins".
|
||||||
|
|
||||||
|
sub command {
|
||||||
|
$_[2] =~ s@^https?://(coke|fanta)url.com/q/srn@@gi; # input is actually a mutable string
|
||||||
|
return NEXT;
|
||||||
|
}
|
|
@ -3,7 +3,7 @@ use LWP::UserAgent;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
|
||||||
my $ua = LWP::UserAgent->new(agent => "revbank");
|
my $ua = LWP::UserAgent->new(agent => "revbank");
|
||||||
my $backend_url = "https://deposit.revspace.nl/mollie.php";
|
my $backend_url = "https://deposit.bitlair.nl/revbank_plugin_backend";
|
||||||
|
|
||||||
sub backend_call($hash) {
|
sub backend_call($hash) {
|
||||||
#$hash->{test} = 1; # use mollie test environment
|
#$hash->{test} = 1; # use mollie test environment
|
||||||
|
|
|
@ -17,7 +17,7 @@ sub hook_checkout_done($class, $cart, $account, $transaction_id, @) {
|
||||||
my $balance = RevBank::Accounts::balance($account) or return;
|
my $balance = RevBank::Accounts::balance($account) or return;
|
||||||
my $since = RevBank::Accounts::since($account);
|
my $since = RevBank::Accounts::since($account);
|
||||||
|
|
||||||
if ($balance < -22.00) {
|
if ($balance < -13.37) {
|
||||||
_box(
|
_box(
|
||||||
"Hoi $account,",
|
"Hoi $account,",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -9,31 +9,32 @@ beep_terminal
|
||||||
#cash_drawer
|
#cash_drawer
|
||||||
idle
|
idle
|
||||||
#json
|
#json
|
||||||
nomoney
|
#nomoney
|
||||||
repeat
|
repeat
|
||||||
deduplicate # wants to be after 'repeat'
|
deduplicate # wants to be after 'repeat'
|
||||||
restart
|
restart
|
||||||
sighup
|
sighup
|
||||||
sigint
|
sigint
|
||||||
#stock
|
stock
|
||||||
#vat # configure before using
|
#vat # configure before using
|
||||||
#warnings
|
#warnings
|
||||||
window_title
|
window_title
|
||||||
|
bitlair_git
|
||||||
|
|
||||||
# Then, specific commands:
|
# Then, specific commands:
|
||||||
|
|
||||||
adduser_note
|
adduser_note
|
||||||
adduser
|
adduser
|
||||||
#cash # cash tracking also requires deposit_methods to make sense
|
cash # cash tracking also requires deposit_methods to make sense
|
||||||
deposit
|
deposit
|
||||||
#deposit_methods # Extra options for 'deposit'. Edit/configure first!
|
deposit_methods # Extra options for 'deposit'. Edit/configure first!
|
||||||
#deposit_iban_qr # QR code display, edit/configure first! (needs qrencode(1))
|
deposit_iban_qr # QR code display, edit/configure first! (needs qrencode(1))
|
||||||
dinnerbonus
|
dinnerbonus
|
||||||
edit
|
edit
|
||||||
give
|
give
|
||||||
grandtotal
|
grandtotal
|
||||||
help
|
help
|
||||||
#skim # cash tracking also requires deposit_methods to make sense
|
skim # cash tracking also requires deposit_methods to make sense
|
||||||
split
|
split
|
||||||
take
|
take
|
||||||
tail
|
tail
|
||||||
|
@ -44,6 +45,7 @@ withdraw
|
||||||
|
|
||||||
# Then, plugins that apply heuristics
|
# Then, plugins that apply heuristics
|
||||||
|
|
||||||
|
revspace_cokeurl
|
||||||
#statiegeld # wants to be before 'products'; matches product IDs
|
#statiegeld # wants to be before 'products'; matches product IDs
|
||||||
#statiegeld_tokens
|
#statiegeld_tokens
|
||||||
products # matches product IDs (barcodes)
|
products # matches product IDs (barcodes)
|
||||||
|
@ -53,3 +55,10 @@ users # matches usernames
|
||||||
regex_gtin # matches GTINs in URLs and element strings
|
regex_gtin # matches GTINs in URLs and element strings
|
||||||
url # matches other URLs
|
url # matches other URLs
|
||||||
#deprecated_raw # matches amounts
|
#deprecated_raw # matches amounts
|
||||||
|
|
||||||
|
bitlair_bigmoney
|
||||||
|
bitlair_mqtt
|
||||||
|
bitlair_nomunnie
|
||||||
|
bitlair_3dprint
|
||||||
|
revspace_saldo
|
||||||
|
revspace_mollie
|
||||||
|
|
Loading…
Add table
Reference in a new issue