revbank/UPGRADING.md
Juerd Waalboer fffb2d72e9 Fix deduplication bug, refactor deduplication to own plugin
(Bumps version to 3.8 because admins should update the plugin list.)

Deduplication didn't work on quantified additions, i.e. if you added
"20x clubmate" when there was already clubmate in the cart, it would add
just ONE item, and have a lingering message that the next thing would be
multiplied by 20.

This old bug was especially annoying if there is a barcode "20x
clubmate" to scan 20 bottles (which is the size of a crate), and this is
repeated.

The fix also uncovered another bug: newly added entries were selected
too early. There are two hooks, hook_add_entry and hook_added_entry, and
of course the selection should happen in between, not before the former.
No entry in UPGRADING.md, because I think it is extremely unlikely that
any plugin author will have used the selection feature yet, which is
very new.
2023-02-12 17:53:14 +01:00

234 lines
8.9 KiB
Markdown

# (2023-02-12) RevBank 3.8
## Update your `revbank.plugins`
Deduplication is moved from individual plugins to a plugin that does that. If
you want to keep deduplication of cart items, and you probably do want that,
add `deduplicate` to `revbank.plugins` just below `repeat`.
# (2022-12-25) RevBank 3.6
## Update your `revbank.plugins`
The `edit` command is now in its own plugin, so that it can be disabled (this
has been requested several times). To keep the ability to edit the products
list from within RevBank, add `edit` to `revbank.plugins`.
## Check your `revbank.products`
There's new syntax for `revbank.products`: addons. Check that your lines don't
have `+foo` at the end, where `foo` can be anything.
Also check that you don't have any product ids that start with `+`; those can
no longer be entered as this syntax now has special semantics.
So these don't work as before:
example_id 1.00 Example product +something
+something 1.00 Product id that starts with plus
example,+alias 1.00 Alias that starts with plus
These will keep working as they were:
example_id1 1.00 Example product+something
example_id2 1.00 Example product + something
more_stuff 1.00 Example product with +something but not at the end
bbq 1.00 3+ pieces of meat
## New features in `products` plugin
There are several new features that you may wish to take advantage of. By
combining the new features, powerful things can be done that previously
required custom plugins.
The syntax for `revbank.products` has become complex. Please refer to the new
documentation in [products.pod](plugins/products.pod) for details.
### Negative prices (add money to account)
Support for non-positive prices was requested several times over the years and
has now finally been implemented.
It's now possible to have a product with a negative amount, which when "bought"
will cause the user to receive money instead of spending it.
### Product addons
It is now possible to add products to products, which is done by specifying
`+foo` at the end of a product description, where `foo` is the id of another
product. This can be used for surcharges and discounts, or for bundles of
products that can also be bought individually.
### Explicit contra accounts
By default, products sold via the `products` plugin, are accounted on the
`+sales/products` contra account. This can now be overridden by specifying
`@accountname` after the price in `revbank.products`. For example,
`1.00@+sales/products/specificcategory`. While this will mess up your tidy
columns, you may be able to get rid of a bunch of custom plugins now.
When the specified contra account is a regular account (does not start with `+`
or `-`), this works similar to the `market` plugin, but without any commission
for the organization.
## Pfand plugin: gone
The `pfand` plugin, that was originally written as a proof-of-concept demo, has
been removed without deprecation cycle. To my knowledge, nobody uses this
plugin. If you did use it, just grab the old version from git. Please let me
know about your usecase!
The introduction of beverage container deposits in The Netherlands has
triggered reevaluation, and several things about that plugin were wrong,
including the condescending comments that bottle deposits for small bottles
would be crazy or wouldn't make sense in a self-service environment. RevBank
was too limited to support it properly, but I think current RevBank fulfills
all requirements for making a better, proper pfand plugin.
## Perl warnings are now enabled for plugins
If you get Perl warnings from a plugin, and don't want to fix the issues with
the code (or disagree with the warning), just add "no warnings;" to the top of
the plugin file. However, the warnings are often indicative of suboptimal code
that is ground for improvement!
Most warnings will be about unitialized (undefined) values. Some guidance for
Perl newbies: you can test whether something is defined with `if
(defined($foo)) { ... }`, or provide a default value with `$foo // "example
default value"`.
# (2022-08-30) RevBank 3.5
RevBank now has a simple built-in text editor for products and market;
rationale in lib/RevBank/TextArea.pod.
This comes with a new dependency, the perl module Curses::UI (debian:
libcurses-ui-perl).
# (2022-06-11) RevBank 3.4
RevBank now has built-in hidden accounts and balanced transactions. These
accounts will be made automatically, and hidden from the user interface.
## Update external scripts
If you have scripts that parse `.revbank.log` or `revbank.products`, you may
want to ignore all accounts that start with `-` or `+`.
## User account names that are now invalid
In the hopefully very unlikely event that you have existing user accounts that
start with `-` or `+`, those will have to be renamed manually, as such accounts
are no longer accessible.
## Updating custom plugins (optional for now)
For your custom plugins, you may want to add `->add_contra` calls to every
`$cart->add` call that does not already have them. Unbalanced transactions will
probably be deprecated in a future version.
## New feature: cashbox tracking
The new `cash` plugin will display messages about how much the cash box should
hold, whenever someone withdraws or does a cash deposit. For that to make
sense, this requires the `deposit_methods` plugin to be enabled, and to have
a `"cash"` deposit method.
When adding the `cash` plugin in `revbank.plugins`, make sure it is listed
_before_ `stock` if you have that one too. And you probably want to enable
the `skim` plugin too, which introduces the (hidden) commands `skim` and
`unskim` which can be used to keep the cash box data synchronised when someone
(probably a board member) skims it.
# (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!
Test your custom plugins. If they don't emit warnings about floating point
numbers, or if you don't care about warnings, then no changes are required.
RevBank no longer uses floating point numbers for amounts. Instead, there
are now RevBank::Amount objects, which internally store an integer number
of cents, but externally stringify to formatted numbers with 2 decimal places.
To create such an object, use `parse_amount` as per usual.
Formatting no longer requires `sprintf %.2f`, just use `%s` instead.
Using an amount as a floating point number will now emit warnings in some
cases, to alert you to the fact that this may result in rounding errors.
To convert an amount to a floating point number without a warning, use
`$amount->float`. To convert a floating point number to an amount without a
warning, use `RevBank::Amount->new_from_float($float)`.
Most hard-coded uses of floats are safe enough and transparently supported
through overloaded operators, but if there are more than 2 decimal places, the
operation will be disallowed.
# (2019-11-05) RevBank 3
The following features were removed:
- plugins `nyan` and `game`
Please remove these from your `revbank.plugins` configuration file.
- creating new accounts with `deposit`
Use `adduser` instead.
## Update your custom plugins!
### Method `$cart->is_multi_user`
Method has been removed.
### Method `$cart->delete($user, $index)`
Method has been removed.
Delete a specific entry, as returned by `$cart->entries`, instead.
### Hooks `add` and `added`
Use `add_entry` and `added_entry` instead, which gets a RevBank::Cart::Entry
object, instead.
Note that the new "entries", unlike old "items", can have a `quantity` other
than 1.
### Method `$cart->add(undef, ...)`
### Method `$cart->add($user, ...)`
The `add` method now always creates an entry from the perspective of the
current user, and returns a RevBank::Cart::Entry object to which "contras" can
be added with `add_contra`. The contras can be used for counteracting a value
with an operation on another account.
To upgrade a plugin that does a single `add` with `undef` as the first
argument, simply remove the `undef, `. When multiple items were added that
belong together, consider using `add_contra` for the subsequent lines; see the
`take` and `give` plugins for examples.
### Method `$cart->select_items`
Use `entries` instead, which takes the same kind of argument. Note that
entries work slightly differently: they can have a quantity and attached contra
entries. Attributes are now accessed through the `has_attribute` and
`attribute` methods, instead of directly manipulating the hash.