<<

NAME

Koha::Hold - Koha Hold object class

API

Class methods

age

returns the number of days since a hold was placed, optionally using the calendar

my $age = $hold->age( $use_calendar );

suspend_hold

my $hold = $hold->suspend_hold( $suspend_until );

resume

my $hold = $hold->resume();

delete

$hold->delete();

move_hold

$hold->move_hold();

cleanup_hold_group

    $self->cleanup_hold_group;

Dissociates the last hold from a group if it is the only one remaining and no history exists. If no active holds remain and no history exists, the group is deleted. Groups with history are kept to preserve the hold_group_id reference in old_reserves.

set_as_hold_group_target

$self->set_as_hold_group_target;

Sets this hold and its' hold group's target

remove_as_hold_group_target

$self->remove_as_hold_group_target;

Removes this hold as the target of its hold group if it is currently set as such, and if the DisplayAddHoldGroups system preference is enabled.

is_hold_group_target

$self->is_hold_group_target;

Returns whether this hold is its hold group target

set_transfer

set_waiting

is_pickup_location_valid

    if ($hold->is_pickup_location_valid({ library_id => $library->id }) ) {
        ...
    }

Returns a boolean representing if the passed pickup location is valid for the hold. It throws a Koha::Exceptions::_MissingParameter if the library_id parameter is not passed.

set_pickup_location

    $hold->set_pickup_location(
        {
            library_id => $library->id,
          [ force   => 0|1 ]
        }
    );

Updates the hold pickup location. It throws a Koha::Exceptions::Hold::InvalidPickupLocation if the passed pickup location is not valid.

Note: It is up to the caller to verify if AllowHoldPolicyOverride is set when setting the force parameter.

set_processing

$hold->set_processing;

Mark the hold as in processing.

is_found

Returns true if hold is waiting, in transit or in processing

is_waiting

Returns true if hold is a waiting hold

is_in_transit

Returns true if hold is a in_transit hold

is_in_processing

Returns true if hold is a in_processing hold

is_cancelable_from_opac

Returns true if hold is a cancelable hold

Holds may be only canceled if they are not found.

This is used from the OPAC.

cancellation_requestable_from_opac

    if ( $hold->cancellation_requestable_from_opac ) { ... }

Returns a boolean representing if a cancellation request can be placed on the hold from the OPAC. It targets holds that cannot be cancelled from the OPAC (see the is_cancelable_from_opac method above), but for which circulation rules allow requesting cancellation.

Throws a Koha::Exceptions::InvalidStatus exception with the following invalid_status values:

'hold_not_waiting': the hold is expected to be waiting and it is not.
'no_item_linked': the waiting hold doesn't have an item properly linked.

is_at_destination

Returns true if hold is waiting and the hold's pickup branch matches the hold item's holding branch

biblio

Returns the related Koha::Biblio object for this hold

patron

Returns the related Koha::Patron object for this hold

iso18626_request

Returns the related Koha::ILL::ISO18626::Request object for this hold

iso18626_attach_hold_and_biblio

Adds iso18626 request relationship to this hold and respective biblio

item

Returns the related Koha::Item object for this Hold

item_type

Returns the related Koha::ItemType object for this hold

item_group

Returns the related Koha::Biblio::ItemGroup object for this Hold

branch

Returns the related Koha::Library object for this hold

DEPRECATED

pickup_library

Returns the related Koha::Library object for this hold

desk

Returns the related Koha::Desk object for this Hold

borrower

Returns the related Koha::Patron object for this Hold

is_suspended

my $bool = $hold->is_suspended();

item_level_holds_count

Returns the number (count) of item-level holds for this hold's biblionumber and patron

add_cancellation_request

    my $cancellation_request = $hold->add_cancellation_request({ [ creation_date => $creation_date ] });

Adds a cancellation request to the hold. Returns the generated Koha::Hold::CancellationRequest object.

cancellation_requests

    my $cancellation_requests = $hold->cancellation_requests;

Returns related a Koha::Hold::CancellationRequests resultset.

cancellation_requested

    if ( $hold->cancellation_requested ) { ... }

Returns true if a cancellation request has been placed for the hold.

cancel

my $cancel_hold = $hold->cancel( { [ charge_cancel_fee => 1||0, ] [ cancellation_reason => $cancellation_reason, ] [ skip_holds_queue => 1||0 ] [ skip_hold_group_cleanup => 1||0 ] } );

Cancel a hold: - The hold will be moved to the old_reserves table with a priority=0 - The priority of other holds will be updated - The patron will be charge (see ExpireReservesMaxPickUpDelayCharge) if the charge_cancel_fee parameter is set - The canceled hold will have the cancellation reason added to old_reserves.cancellation_reason if one is passed in - a CANCEL HOLDS log will be done if the pref HoldsLog is on

fill

    $hold->fill({ [ item_id => $item->id ] });

This method marks the hold as filled. It effectively moves it to old_reserves. The optional item_id parameter is used to set the information about the item that filled the hold.

revert_found

    $hold->revert_found();

Reverts any 'found' hold back to a regular hold with a priority of 1. This method can revert holds in 'waiting' (W), 'in transit' (T), or 'in processing' (P) status.

For waiting holds, the desk_id is also cleared since the hold is no longer waiting at a specific desk. For in transit and in processing holds, desk_id remains unchanged (typically NULL as these statuses don't set desk_id).

sub change_type

    $hold->change_type                # to record level
    $hold->change_type( $itemnumber ) # to item level

Changes hold type between record and item level holds, only if record has exactly one hold for a patron. This is because Koha expects all holds for a patron on a record to be alike.

progress_iso18626_request

    $hold->progress_iso18626_request( $action, $iso18626_payload );

Process and update the associated ISO18626 request based on a specific hold action.

$action

Required string. The hold-related event trigger (e.g., 'hold_created' or 'hold_cancelled').

$iso18626_payload

Required hashref. Contains data for the ISO18626 message, such as expectedDeliveryDate, messageInfoNote, or reasonUnfilled.

store

Override base store method to set default expirationdate for holds.

_set_default_expirationdate

    $hold->_set_default_expirationdate;

Internal method to set the default expiration date based on DefaultHoldExpirationdatePeriod and DefaultHoldExpirationdateUnitOfTime system preferences.

hold_group

    my $hold_group = $hold->hold_group;
    my $hold_group_id = $hold_group->id if $hold_group;

Return the Koha::HoldGroup object of a hold if part of a hold group

calculate_hold_fee

    my $fee = $hold->calculate_hold_fee();

Calculate the hold fee for this hold using circulation rules. Returns the fee amount as a decimal.

should_charge

    my $should_charge = $hold->should_charge($stage);

Returns true if the hold fee should be charged at the given stage based on HoldFeeMode preference and current hold state.

Stage can be: - 'placement': When the hold is first placed - 'collection': When the hold is filled/collected

charge_hold_fee

    $hold->charge_hold_fee({ amount => $fee });

Charge the patron for the hold fee.

_calculate_title_hold_fee

    my $fee = $hold->_calculate_title_hold_fee();

Calculate the hold fee for a title-level hold using the TitleHoldFeeStrategy system preference to determine which fee to charge when items have different fees.

_get_most_common_fee

Helper method to find the most frequently occurring fee in a list.

_should_charge_not_always_mode

Helper method to implement the 'not_always' HoldFeeMode logic. Returns true if a fee should be charged in not_always mode.

_move_to_old

my $is_moved = $hold->_move_to_old;

Move a hold to the old_reserve table following the same pattern as Koha::Patron->move_to_deleted

to_api_mapping

This method returns the mapping for representing a Koha::Hold object on the API.

can_update_pickup_location_opac

    my $can_update_pickup_location_opac = $hold->can_update_pickup_location_opac;

Returns if a hold can change pickup location from opac

strings_map

Returns a map of column name to string representations including the string.

Internal methods

_type

AUTHORS

Kyle M Hall <kyle@bywatersolutions.com> Jonathan Druart <jonathan.druart@bugs.koha-community.org> Martin Renvoize <martin.renvoize@ptfs-europe.com>

<<