Commit graph

114 commits

Author SHA1 Message Date
Juerd Waalboer
ef5babd3df More compact display for repeated products
Might revert later
2023-01-30 03:59:42 +01:00
Juerd Waalboer
f479060576 Fix bug: ->changed is getter only, not a setter 2023-01-19 05:24:50 +01:00
Juerd Waalboer
16d530ae16 Allow hook_prompt to mutate the prompt, like before, and use that
This functionality was accidentally broken by eed0db78

Also: ignore readline terminal sequence (\x01...\x02) in detection of ">"
2023-01-19 03:04:35 +01:00
Juerd Waalboer
5b0c85d770 Refactor read_products and its callers
- Promote to public function since it's used in other plugins anyway
- Move resolving of addons to read_products (print errors immediately)
- Cache product list based on mtime; mostly to reduce the amount of spam
  from errors as performance was never an issue.
- Cache product object in cart entry, so statiegeld_tokens plugin
  doesn't have to do the lookup all over again.
2023-01-17 20:28:35 +01:00
Juerd Waalboer
dbb11b5898 Document hook_checkout_prepare 2023-01-16 04:00:20 +01:00
Juerd Waalboer
6180bf6ea5 Add new hook_checkout_prepare, rollback earlier change of hook_checkout
In hindsight, it was a bad idea to allow manipulating the cart (entries)
in hook_checkout, because that hook is used by the `log` plugin. You now
get unused entries in the log.

Although that plugin should maybe have used hook_checkout_done, existing
log file readers (including scripts) and custom plugins may depend on
the CHECKOUT items in the log being before the BALANCE items.
2023-01-16 03:52:00 +01:00
Juerd Waalboer
11ca0a86b2 Allow cart manipulation during hook_checkout 2023-01-16 03:05:03 +01:00
Juerd Waalboer
6089e212dc Release locks on abort
Fixes deadlock if hook_checkout returns ABORT.

One of these days I want to implement the abort mechanism through
exceptions, even though that means handling it explicitly in more
places. Or maybe *because* that means handling it explicitly in more
places.
2023-01-16 01:17:33 +01:00
Juerd Waalboer
094fbcb1db Fix bug/warning
Apparently nobody uses "return ABORT;" in a hook, because it emitted an
ugly warning. main::abort() takes a list, so destructuring the message
to a scalar was wrong.
2023-01-16 00:51:42 +01:00
Juerd Waalboer
d4c6c1be35 Replace add_info() with extra parameter for add_contra()
add_info was a thing that grew organically to account for hidden
contras, but just wasn't right. The assumption was that if the
contra account is hidden, the contra itself should be hidden from
view - the sign of the amount would be wrong anyway.

The correct approach, however, would of course to flip the sign so it
matches the user's perspective, and to add a separate description string
to display to the user.
2023-01-05 20:46:46 +01:00
Juerd Waalboer
7c05b3108c New feature: percentage addons (discounts etc) 2023-01-05 19:42:34 +01:00
Juerd Waalboer
a444512bf1 Enable Perl warnings for plugins 2022-12-25 05:39:15 +01:00
Juerd Waalboer
da523f8daa v3.6: products overhaul
New features, new documentation.
2022-12-25 05:32:00 +01:00
Juerd Waalboer
b9c91c0054 Formatting
One more character so values >= 100.00 don't mess up the columns, at
least up to 999.99. I hope nobody's actually parsing the logs with fixed
character offsets.
2022-12-13 21:39:57 +01:00
Juerd Waalboer
4613a14a9f pager: don't scroll down for non-log
+ some code moved around in TextEditor
2022-11-01 04:48:49 +01:00
Juerd Waalboer
900539af5a Use internal pager + new command "log"
No pager for "shame" because Curses::UI::TextEditor doesn't do color. If
it doesn't fit on the screen, you have bigger problems anyway.
2022-11-01 04:34:16 +01:00
Juerd Waalboer
922f8dc8f6 Ensure unique transaction IDs
Long overdue :)
2022-10-31 19:00:20 +01:00
Juerd Waalboer
44d17e6ae0 Remove redundant checks
Signatures already do arity-checking.
2022-10-31 16:37:19 +01:00
Juerd Waalboer
45f12a9354 Fix saving files in text editor
It stored the old content, so effectively not changing the file.

I don't really understand why *this* was the version I committed,
because I was sure I tested it and it worked :)
2022-09-06 23:48:55 +02:00
Juerd Waalboer
042db97ea8 editor: only ask to save if anything's changed; print status 2022-08-30 20:57:41 +02:00
Juerd Waalboer
43a1990974 bump to v3.5; add built-in editor 2022-08-30 20:45:01 +02:00
Juerd Waalboer
22ca2ec61e Implement global advisory lock 2022-08-29 17:50:12 +02:00
Juerd Waalboer
c9ef624d82 Update error message 2022-06-12 22:49:33 +02:00
Juerd Waalboer
65566349f6 Prepare for future removal of support for unbalanced transactions
Don't worry, that won't happen for at least months. First we'll just log
warnings for a while.
2022-06-12 21:49:22 +02:00
Juerd Waalboer
8f43f326b1 typo 2022-06-12 02:34:34 +02:00
Juerd Waalboer
4ed3479ade Make undo/skim line up nicer in recent transactions view 2022-06-12 02:31:52 +02:00
Juerd Waalboer
76ef79b9ee Suppress warning when -cash does not yet exist 2022-06-12 02:31:29 +02:00
Juerd Waalboer
3a07b8eadb Use string amounts for balance
Doesn't change anything in practice
2022-06-12 02:17:44 +02:00
Juerd Waalboer
064841c25e Add cash box tracking with new plugin "cash" 2022-06-11 21:16:47 +02:00
Juerd Waalboer
681db369e7 New command: skim, for adjusting the amount in the cashbox
Generally intended for board members only, so not listed in "help".
2022-06-11 20:02:42 +02:00
Juerd Waalboer
441bf05fde Bump to v3.4; make all transactions balanced using hidden accounts
See UPGRADING.md for details.
2022-06-11 18:51:26 +02:00
Juerd Waalboer
f84a69372a Hide contras of hidden users
For future "behind the scenes" actual bookkeeping
2022-06-11 17:17:53 +02:00
Juerd Waalboer
ccae71021a Get 'cash' working again
Now implemented via a hidden user called '-cash'.

This also introduces the concept of hidden accounts, that begin with '+' or
'-', for result accounts and balance accounts. Future versions can further
use this for more detailed bookkeeping. The idea behind the sign is that
'-' accounts should be inverted to get the intuitive value. So if the account
'-cash' has -13.37, that means there should be +13.37 in the cash box (or,
well, once the rest of this is implemented and the initial values are then set
correctly.)
2022-06-11 16:58:20 +02:00
Juerd Waalboer
f262bce57c Split "help" into "help" and "help2"; ditch pager 2022-06-11 16:31:44 +02:00
Juerd Waalboer
a7a5f14e0c 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.)
2022-06-04 02:41:17 +02:00
Juerd Waalboer
e71df9b092 Warn from 19.84 instead of 13.37
This should probably not be hardcoded, but revbank currently has no
configuration mechanism.
2022-04-12 19:39:14 +02:00
Juerd Waalboer
ec521aef7d Fix cosmetic issue 2021-12-03 18:28:01 +01:00
Juerd Waalboer
eed0db7897 Cleanup: use subroutine signatures, remove deprecated methods.
The signatures feature has been "experimental" since Perl 5.20 (May 2014), but
expected to stay. After 8 years I'm ready to take the risk :)

Have added Perl v5.28 (June 2018) as the minimum requirement, even though the
current revbank should work with 5.20, to see if this bothers any users. Perl
v5.28 is in Debian "buster", which is now oldstable.
2021-12-03 18:00:34 +01:00
Juerd Waalboer
1661661ffd Use amount object directly internally,
instead of relying on operator overloading, but keep the ones where direct use
would result in overly messy code.
2021-12-03 03:23:16 +01:00
Juerd Waalboer
58f49cbffb Restore forced + sign in accounts file (harmless bug) 2021-12-03 02:55:25 +01:00
Juerd Waalboer
9cda968d53 Document ABORT constant as possible return value from hook
This feature was introduced way back in commit add31004.
2021-12-03 01:49:25 +01:00
Juerd Waalboer
6850ed22be Remove requirement for dummy command method in hook-only plugins 2021-12-03 01:49:11 +01:00
Juerd Waalboer
cf8ce7dc52 Document parse_amount 2021-12-02 23:12:13 +01:00
Juerd Waalboer
38a0229899 Ditch floating point numbers, use cents instead; bump version to 3.2 2021-12-02 22:18:06 +01:00
Juerd Waalboer
ea5d8bd8b5 Merge branch 'master' of github.com:Juerd/revbank 2020-03-01 06:17:27 +01:00
Juerd Waalboer
f7a7a19d8d Fix #7 2020-03-01 06:16:08 +01:00
Wouter
4315f1ecb5
Fix the name of hook_checkout_done in Plugins.pod 2020-02-28 21:29:12 +01:00
Juerd Waalboer
464a6db78c Whitespace tweaks (newlines)
Consistency: empty line before each prompt, but not after.
2019-11-06 19:13:12 +01:00
Juerd Waalboer
32e84f3725 Fix that 'changed' would return true just because the attribute existed :)
Another option would have been to implement 'delete_attribute'.
2019-11-06 17:43:31 +01:00
Juerd Waalboer
bb8c52b593 Do provide final cart when no pending cart was ever shown... 2019-11-06 06:13:18 +01:00