8
0
Fork 0

Import from revbank fork

This commit is contained in:
polyfloyd 2025-05-07 00:20:31 +02:00
commit 30c55d21de
6 changed files with 152 additions and 0 deletions

48
bitlair_saldo Normal file
View 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",
);
}
}