From a7a5f14e0c07dd4e5cdcd4fa780096423f568326 Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Sat, 4 Jun 2022 02:30:16 +0200 Subject: [PATCH] Introduce 'withdraw', remove "withdrawal or unlisted" feature. This should have been done much earlier, but wasn't done for nostalgic reasons. To new users, it didn't make sense that you could just enter an amount, and revbank would just accept that as "withdrawal or unlisted product". It existed for backwards compatibility with the very first revbank version, which didn't have a product list, and which was not yet used with a barcode scanner. You would simply enter the amount and your name, and there were no further statistics. Nowadays, there are statistics that are messed up if you don't use the product codes. And some people were looking for a withdrawal command, and try 'take' as that seems closest to it, but which instead transfers money to another account. Additionally, some texts were changed for improved clarity. ("Enter username to pay", when withdrawing, was confusing: one expects money back, not to pay more.) --- UPGRADING.md | 15 +++++++++++++++ lib/RevBank/Messages.pm | 5 +++-- plugins/unlisted | 4 ++-- plugins/withdraw | 22 +++++++++++++++++----- revbank | 2 +- 5 files changed, 38 insertions(+), 10 deletions(-) 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", );