diff --git a/UPGRADING.md b/UPGRADING.md index 2971c5e..30d7ed8 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,3 +1,18 @@ +# (2022-06-04) RevBank 3.3 + +Raw amounts without a command are no longer supported. There was already an +explicit command for unlisted products, `unlisted`, and for withdrawals there +is now the new command `withdraw`. An explanatory message guides users who +use the old style towards the new commands. + +This change makes it possible for treasurers to more accurately deduce the +intention of a revbank transaction. + +When upgrading, make sure the `unlisted` plugin is installed in +`revbank.plugins`. Without it, the instruction text presented when someone +enters an amount is wrong and the functionality for paying for unlisted +products is lost. + # (2021-12-02) RevBank 3.2 ## Update your custom plugins! diff --git a/lib/RevBank/Messages.pm b/lib/RevBank/Messages.pm index b21f984..5f2c692 100644 --- a/lib/RevBank/Messages.pm +++ b/lib/RevBank/Messages.pm @@ -33,9 +33,10 @@ sub hook_cart_changed($class, $cart, @) { if (not $cart->entries('refuse_checkout')) { my $sum = $cart->sum; - my $what = $sum->cents > 0 ? "add" : "pay"; + my $what = $sum->cents > 0 ? "add" : $cart->entries('is_withdrawal') ? "deduct" : "pay"; + my $dir = $sum->cents > 0 ? "to" : "from"; my $abs = $sum->abs; - say "Enter username to $what $abs; type 'abort' to abort."; + say "Enter username to $what $abs $dir your account; type 'abort' to abort."; } } diff --git a/plugins/unlisted b/plugins/unlisted index 24b4873..81f112f 100644 --- a/plugins/unlisted +++ b/plugins/unlisted @@ -6,7 +6,7 @@ sub command :Tab(unlisted,donate) ($self, $cart, $command, @) { $command eq 'unlisted' or $command eq 'donate' or return NEXT; $self->{command} = $command; - return "Amount to deduct from your account", \&amount; + return "Price", \&amount; } sub amount($self, $cart, $arg, @) { @@ -21,7 +21,7 @@ sub amount($self, $cart, $arg, @) { } sub description($self, $cart, $desc, @) { - $cart->add(-$self->{amount}, $desc); + $cart->add(-$self->{amount}, "Unlisted: $desc"); return ACCEPT; } diff --git a/plugins/withdraw b/plugins/withdraw index af791b3..6b40e35 100644 --- a/plugins/withdraw +++ b/plugins/withdraw @@ -1,12 +1,24 @@ #!perl -HELP "" => "Withdraw or enter price manually"; +HELP "withdraw " => "Withdraw from your account"; -sub command($self, $cart, $command, @) { - my $amount = parse_amount($command); - defined $amount or return NEXT; +sub command :Tab(withdraw) ($self, $cart, $command, @) { + if (defined parse_amount($command)) { + warn "Note: raw amounts for withdrawal or unlisted products are no longer supported.\n\n"; + warn "Please use the 'withdraw' command to take money out of your revbank account, or\n"; + warn "the 'unlisted' command to pay for an unlisted product.\n\n"; + } - $cart->add(-$amount, "Withdrawal or unlisted product", + $command eq 'withdraw' or return NEXT; + + return "Amount to withdraw from your account", \&amount; +} + +sub amount($self, $cart, $arg, @) { + my $amount = parse_amount($arg); + defined $amount or return REJECT, "Invalid amount"; + + $cart->add(-$amount, "Withdrawal", { is_withdrawal => 1 }); return ACCEPT; diff --git a/revbank b/revbank index b591116..1e59b40 100755 --- a/revbank +++ b/revbank @@ -18,7 +18,7 @@ use RevBank::Global; use RevBank::Messages; use RevBank::Cart; -our $VERSION = "3.2"; +our $VERSION = "3.3"; our %HELP = ( "abort" => "Abort the current transaction", );