This repository was archived by the owner on Aug 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,25 @@ sub create($account) {
80
80
return $account ;
81
81
}
82
82
83
+ sub delete ($account ) {
84
+ die " No such account" if RevBank::Accounts::is_special $account ;
85
+
86
+ my $user_found = 0;
87
+ rewrite $filename , sub ($line ) {
88
+ my @a = split " " , $line ;
89
+ if (lc $a [0] ne lc $account ) {
90
+ return $line ;
91
+ }
92
+ if ($a [1] != 0) {
93
+ die " Account $account still has balance" ;
94
+ }
95
+ $user_found = 1;
96
+ return " " ;
97
+ };
98
+
99
+ die " No such account" if not $user_found ;
100
+ }
101
+
83
102
sub update ($account , $delta , $transaction_id ) {
84
103
$account = assert_account($account );
85
104
Original file line number Diff line number Diff line change @@ -126,6 +126,12 @@ Creates an account with that name and a balance of zero. The name must not alrea
126
126
127
127
After updating the file, calls the C<account_created> hook with the account name.
128
128
129
+ =head3 delete($name)
130
+
131
+ Deletes an account.
132
+
133
+ Special accounts may not be deleted via this method. The account must have a balance of 0.00.
134
+
129
135
=head3 update($name, $delta, $transaction_id)
130
136
131
137
Given the relative change (C<$delta>), updates the user balance for an account.
You can’t perform that action at this time.
0 commit comments