Bug 31895 - New account hook when adding credit
Summary: New account hook when adding credit
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Plugin architecture (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Stefan Berndtsson
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks: 31734 31896
  Show dependency treegraph
 
Reported: 2022-10-20 16:41 UTC by Stefan Berndtsson
Modified: 2023-06-08 22:32 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This patch adds a new hook "after_account_action" with the action "add_credit". This is triggered when a credit is added via for example PAYMENT or WRITEOFF.
Version(s) released in:
22.11.00


Attachments
Bug 31895: New after_account_action hook (4.72 KB, patch)
2022-10-20 16:42 UTC, Stefan Berndtsson
Details | Diff | Splinter Review
Bug 31895: New after_account_action hook (4.77 KB, patch)
2022-10-20 18:48 UTC, David Nind
Details | Diff | Splinter Review
Bug 31895: New after_account_action hook (4.87 KB, patch)
2022-10-28 07:53 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 31895: (QA follow-up) Rollback change, add comment (1.86 KB, patch)
2022-10-28 07:53 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Berndtsson 2022-10-20 16:41:21 UTC
This patch adds a new hook "after_account_action" with the action "add_credit". This is triggered when a credit is added via for example PAYMENT or WRITEOFF.

This is consistent with when UpdateStats is called so that a plugin can be used to log the same kind of data as the normal statistics.
Comment 1 Stefan Berndtsson 2022-10-20 16:42:00 UTC
Created attachment 142266 [details] [review]
Bug 31895: New after_account_action hook

Hooks added:
after_account_action with new action add_credit

How to test:
Run tests in t/db_dependent/Koha/Plugins/Account_hooks.t

Sponsored by: Gothenburg University Library
Comment 2 David Nind 2022-10-20 18:48:00 UTC
Created attachment 142277 [details] [review]
Bug 31895: New after_account_action hook

Hooks added:
after_account_action with new action add_credit

How to test:
Run tests in t/db_dependent/Koha/Plugins/Account_hooks.t

Sponsored by: Gothenburg University Library

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 Marcel de Rooy 2022-10-21 06:52:02 UTC
+    $schema->storage->txn_rollback;
+    Koha::Plugins::Methods->delete;

That does not look good.
Comment 4 Stefan Berndtsson 2022-10-21 08:59:08 UTC
I'm unclear about this one. I agree it looks strange. It comes from all other files. Holds_hooks.t, Circulation_hooks.t, Patron.t Barcode_transform_hooks.t and so on all have it in this order. I don't know why.

I can change it easily of course, so it's not a big deal. There is also some unfixed traling whitespace in this one still remaining that I haven't updated yet.

If I should swap the order of those two lines, I'll do that and fix whitespace at the same time.
Comment 5 Marcel de Rooy 2022-10-25 14:56:41 UTC
We'll come back here after 31894, I propose.
Comment 6 Marcel de Rooy 2022-10-28 07:44:51 UTC
Working here now
Comment 7 Marcel de Rooy 2022-10-28 07:53:37 UTC
Created attachment 142748 [details] [review]
Bug 31895: New after_account_action hook

Hooks added:
after_account_action with new action add_credit

How to test:
Run tests in t/db_dependent/Koha/Plugins/Account_hooks.t

Sponsored by: Gothenburg University Library

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 8 Marcel de Rooy 2022-10-28 07:53:41 UTC
Created attachment 142749 [details] [review]
Bug 31895: (QA follow-up) Rollback change, add comment

Rollback should really be the last statement.
I am leaving get_from_storage here, but add a comment that it seems
unneeded at this moment. The Koha::Account::Offset->new and
C4::Stats::UpdateStats wont change the line.. But since the distance
in code is becoming a bit larger, I wont complain.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 9 Marcel de Rooy 2022-11-04 09:16:24 UTC
Here I left the get_from_storage. The comment gets attention on bug 32107.
Comment 10 Tomás Cohen Arazi 2022-11-07 14:20:48 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 11 Katrin Fischer 2022-11-09 10:33:24 UTC
Please update https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks!