revbank/plugins/adduser
Juerd Waalboer ccae71021a Get 'cash' working again
Now implemented via a hidden user called '-cash'.

This also introduces the concept of hidden accounts, that begin with '+' or
'-', for result accounts and balance accounts. Future versions can further
use this for more detailed bookkeeping. The idea behind the sign is that
'-' accounts should be inverted to get the intuitive value. So if the account
'-cash' has -13.37, that means there should be +13.37 in the cash box (or,
well, once the rest of this is implemented and the initial values are then set
correctly.)
2022-06-11 16:58:20 +02:00

31 lines
759 B
Perl

#!perl
HELP1 "adduser <name>" => "Create an account";
sub command :Tab(adduser) ($self, $cart, $command, @) {
$command eq 'adduser' or return NEXT;
if ($cart->size) {
return ABORT, "Create the account *before* scanning things.";
}
return "Name for the new account", \&username;
}
sub username($self, $cart, $name, @) {
return REJECT, "Sorry, whitespace is not allowed."
if $name =~ /\s/;
return REJECT, "Sorry, invalid first character."
if $name =~ /^[-+*]/;
return REJECT, "That's too numeric to be a user name."
if defined parse_amount($name);
return REJECT, "That name already exists."
if defined parse_user($name);
RevBank::Users::create( $name );
return ACCEPT;
}