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.)
This commit is contained in:
parent
f262bce57c
commit
ccae71021a
6 changed files with 27 additions and 4 deletions
|
@ -36,13 +36,14 @@ sub create($username) {
|
|||
print {$fh} "$username 0.00 $now\n" or die $!;
|
||||
close $fh or die $!;
|
||||
RevBank::Plugins::call_hooks("user_created", $username);
|
||||
return $username;
|
||||
}
|
||||
|
||||
sub update($username, $delta, $transaction_id) {
|
||||
open my $in, 'revbank.accounts' or die $!;
|
||||
open my $out, ">.revbank.$$" or die $!;
|
||||
my $old;
|
||||
my $new;
|
||||
my $old = RevBank::Amount->new(0);
|
||||
my $new = RevBank::Amount->new(0);
|
||||
while (defined (my $line = readline $in)) {
|
||||
my @a = split " ", $line;
|
||||
if (lc $a[0] eq lc $username) {
|
||||
|
@ -82,6 +83,10 @@ sub parse_user($username) {
|
|||
return $users->{ lc $username }->[0];
|
||||
}
|
||||
|
||||
sub is_hidden($username) {
|
||||
return $username =~ /^[-+]/;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue