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

26
bitlair_3dprint Normal file
View 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;
}