Plugin for funding cooking supplies

Has been in use at revspace for quite a while now.
This commit is contained in:
Juerd Waalboer 2017-04-24 21:47:39 +02:00
parent 714b337ae2
commit 0ca37f34d8

30
plugins/dinnerbonus Normal file
View file

@ -0,0 +1,30 @@
#!perl
HELP "dinnerbonus" => "Add fee for cooking supplies";
sub command :Tab(kookbonus,dinnerbonus) {
my ($self, $cart, $command) = @_;
my $bonus = 1.00;
$command eq 'kookbonus' or $command eq 'dinnerbonus'
or return NEXT;
my @users = grep !/^\$you$/, map $_->{user}, $cart->select_items
or return REJECT, "$command requires a pending transaction.";
for my $user (@users) {
$cart->add( $user, -$bonus, "Kookbonus by \$you" );
}
my $users = join '/', @users;
$cart->add(
"kookpotje",
scalar @users * $bonus,
"Kookbonus from $users by \$you"
);
return ACCEPT;
}