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.
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
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>
+ $schema->storage->txn_rollback; + Koha::Plugins::Methods->delete; That does not look good.
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.
We'll come back here after 31894, I propose.
Working here now
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>
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>
Here I left the get_from_storage. The comment gets attention on bug 32107.
Pushed to master for 22.11. Nice work everyone, thanks!
Please update https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks!