New plugin: "unlisted"

Lets the user provide a description for deducting arbitrary amounts.
This commit is contained in:
Juerd Waalboer 2018-08-03 00:58:19 +02:00
parent 5c16008038
commit 997917ae82

22
plugins/unlisted Executable file
View file

@ -0,0 +1,22 @@
#!perl
HELP "unlisted" => "Buy unlisted product (manual entry)";
sub command :Tab(unlisted) {
my ($self, $cart, $command) = @_;
$command eq 'unlisted' or return NEXT;
return "Amount to deduct from your account", \&amount;
}
sub amount {
my ($self, $cart, $arg) = @_;
$self->{amount} = parse_amount($arg) or return REJECT, "Invalid amount.";
return "Please provide a short description", \&description;
}
sub description {
my ($self, $cart, $desc) = @_;
$cart->add(undef, -$self->{amount}, $desc);
return ACCEPT;
}