Commit graph

7 commits

Author SHA1 Message Date
Juerd Waalboer
5e8f905a7d Silence warnings for single-field line in revbank.products 2025-01-04 06:55:29 +01:00
Juerd Waalboer
55892c236b Add hook_product_changed, hook_product_deleted 2024-12-29 02:43:28 +01:00
Juerd Waalboer
02c9db1ddf Don't die when addon doesn't exist 2024-12-26 05:26:28 +01:00
Juerd Waalboer
33f5cc1b21 Products.pm: Document #OPAQUE and read_products 2024-12-26 03:34:34 +01:00
Juerd Waalboer
b22ac11476 read_products: do calculate total_price for alias of addon
There was a bug with the example product defined as:

    +smk,matekrat  1.50@+statiegeld  "..."

Only the id `+smk` was considered, and no total price was calculated. This
broke the accessible id `matekrat`. The fix is to consider the keys of
the products in the hash, instead of the `id` field.
2024-12-26 03:13:19 +01:00
Juerd Waalboer
b22cc4c997 Move price calculation from products plugin to RevBank::Products
- Adds price tag calculation. Addons tagged #OPAQUE are excluded from the
price tag.
- BREAKING CHANGE: instead of abusing $product->{price} for a percent,
$product->{percent} is no longer a boolean but the actual percent, so
$product->{price} is the calculated amount.

The total price of a product is now calculated in two places, once when
reading the product list, and once as the result of adding the entry and
its contras when adding the product. Although this involves some
duplication and the sums are calculated in different ways, it hinges on
the existing assertion to make sure that the entry is balanced to ensure
that both sums are the same. Because of that, this code duplication
actually strengthens the integrity.
2024-12-26 01:36:55 +01:00
Juerd Waalboer
7c5431fba4 Move read_products() from plugin to core
Additional changes:
- Parametrized $filename and $default_contra
- Add ->{config} to product hashes, which is the re-serialized config line
2024-12-25 23:43:03 +01:00