Bug 25711 - Add ability to define expiredpickup charge for patron category and item type
Summary: Add ability to define expiredpickup charge for patron category and item type
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: 20.05
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Peter Vashchuk
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-11 04:06 UTC by Minna Kivinen
Modified: 2020-08-19 18:23 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 25711: add ExpireReservesMaxPickUpDelayCharge to circulation rules (18.66 KB, patch)
2020-07-21 11:18 UTC, Peter Vashchuk
Details | Diff | Splinter Review
Bug 25711: add ExpireReservesMaxPickUpDelayCharge to circulation rules (18.36 KB, patch)
2020-07-27 09:33 UTC, Peter Vashchuk
Details | Diff | Splinter Review
Bug 25711: add ExpireReservesMaxPickUpDelayCharge to circulation rules (18.02 KB, patch)
2020-08-03 10:02 UTC, Peter Vashchuk
Details | Diff | Splinter Review
Bug 25711: add ExpireReservesMaxPickUpDelayCharge to circulation rules (17.50 KB, patch)
2020-08-05 15:48 UTC, Peter Vashchuk
Details | Diff | Splinter Review
Bug 25711: add ExpireReservesMaxPickUpDelayCharge to circulation rules (17.56 KB, patch)
2020-08-19 18:23 UTC, Andrew Nugged
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Minna Kivinen 2020-06-11 04:06:08 UTC
ExpireReservesMaxPickUpDelayCharge allows one charge to be applied to all holds that expire.

It would be better to have ability to define this charge in ciculation rules. There can be different charges for different types of materials for different patron categories.  

Related to this bug report:
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18195
Charge for expired holds per patron category
Comment 1 Peter Vashchuk 2020-07-21 11:18:25 UTC Comment hidden (obsolete)
Comment 2 Joonas Kylmälä 2020-07-24 10:36:21 UTC
Comment on attachment 107144 [details] [review]
Bug 25711: add ExpireReservesMaxPickUpDelayCharge to circulation rules

Review of attachment 107144 [details] [review]:
-----------------------------------------------------------------

In addition the the other comments, the expire_reserves_charge is missing from installer/data/mysql/kohastructure.sql.

::: Koha/Hold.pm
@@ +372,5 @@
>              C4::Reserves::_FixPriority({ biblionumber => $self->biblionumber });
>  
> +            my $item = $self->item;
> +
> +            my $controlbranch = C4::Context->preference('ReservesControlBranch');

This and the code below should use C4::Reserves::GetReservesControlBranch()

@@ +384,5 @@
> +
> +            my $rule = Koha::CirculationRules->get_effective_rule(
> +                {
> +                    categorycode => $self->borrower->categorycode,
> +                    itemtype     => $item ? $item->effective_itemtype : $self->biblio->itemtype,

Should use instead the syspref item-level_itypes

::: t/db_dependent/Holds/Holdfine.t
@@ +1,1 @@
> +#!/usr/bin/perl

License header and copyright info is missing.
Comment 3 Peter Vashchuk 2020-07-27 09:33:19 UTC Comment hidden (obsolete)
Comment 4 Andrew Nugged 2020-07-31 01:41:54 UTC
JavaScript edit form on smart-rules page wrong behavior spotted,
+1 small fix to come for not to allow inner <td> value to be transferred by JS as field value
Comment 5 Peter Vashchuk 2020-08-03 10:02:22 UTC Comment hidden (obsolete)
Comment 6 Peter Vashchuk 2020-08-05 15:48:09 UTC Comment hidden (obsolete)
Comment 7 Andrew Nugged 2020-08-19 18:23:59 UTC
Created attachment 108689 [details] [review]
Bug 25711: add ExpireReservesMaxPickUpDelayCharge to circulation rules

Add a feature that allows to define ExpireReservesMaxPickUpDelayCharge
in circulation rules per specific items/patron categories.
When value not found in circulation rules it uses global
ExpireReservesMaxPickUpDelayCharge, as it was before this smart-rules
feature was introduced.

To check the feature after applying the patch:
    1) Go to /cgi-bin/koha/admin/preferences.pl and set
ExpireReservesMaxPickUpDelay to allow.
    1) Go to /cgi-bin/koha/admin/smart-rules.pl circulation rules table
and notice the newly added "Expire reserve charge" row.
    2) In that row add numerical values to type/patron categories
that you will be using later to test this feature.
    3) Prepare an item for our next step, pick a biblio that has item
with the same item type you altered in smart rules and check it out.
    3) Place a hold on that item and set the expiration date as the
next day.
    4) Check in it after that.
    5) Do SQL request to change expiration date manually to "yesterday":
in "reserves" table, find the id of the hold that you placed and
"UPDATE reserves SET `expirationdate`='2020-07-19' WHERE
`reserve_id`=329;"
 Or alternatively:
    5) Wait for tomorrow, change server time or invent a time machine.
    6) Run cancel_expired_holds.pl cron job.
    7) Check that patron got charged in "accounting" left tab and
"transactions" upper tab: your patron should have debt of that amount
of fee you assigned in that rule
(/cgi-bin/koha/members/boraccount.pl?borrowernumber=...YourPatronID...)
    8) You can repeat this with other rules and different
numbers/biblio/item types to check that different fees apply according
to smart rules.
    9) If there's no matching smart rule or smart rule have an empty
string as a fee - global ExpireReservesMaxPickUpDelayCharge variable
value will be used.
   10) But in case if matching rule has zero ("0") as a value - that
allows to have no-fee smart-rule results, as a feature.

IMPORTANT:
Smart-rules filters only applied to item-level holds, when item-type
for items is known. If there's biblio-level hold, then again global
ExpireReservesMaxPickUpDelayCharge value will be used (as well global
one can be empty or zero).

Mentored-by: Andrew Nugged <nugged@gmail.com>