<<

NAME

Koha::Checkin - Koha Checkin object class

API

Relations

item

    my $item = $checkin->item;

Returns the related Koha::Item object.

user

    my $user = $checkin->user;

Returns the Koha::Patron who processed the checkin.

library

    my $library = $checkin->library;

Returns the related Koha::Library object.

desk

    my $desk = $checkin->desk;

Returns the related Koha::Desk object, if set.

checkout

    my $checkout = $checkin->checkout;

Returns the related Koha::Old::Checkout object, if this checkin returned a checkout.

transfer

    my $transfer = $checkin->transfer;

Returns the related Koha::Item::Transfer object, if this checkin triggered a transfer.

hold

    my $hold = $checkin->hold;

Returns the related Koha::Hold object, if this checkin filled a hold.

recall

    my $recall = $checkin->recall;

Returns the related Koha::Recall object, if this checkin filled a recall.

restriction

    my $restriction = $checkin->restriction;

Returns the related Koha::Patron::Restriction object, if this checkin triggered a restriction.

claim

    my $claim = $checkin->claim;

Returns the related Koha::Checkouts::ReturnClaim object, if this checkin resolved a return claim.

debits

    my $debits = $checkin->debits;

Returns the debit Koha::Account::Debits linked to this checkin.

credits

    my $credits = $checkin->credits;

Returns the credit Koha::Account::Credits linked to this checkin.

Accessors

is_latest

    if ( $checkin->is_latest ) { ... }

Returns true if this is the latest checkin recorded for its item. Follow-up actions (setting a hold aside, confirming a transfer, etc.) only make sense for the latest checkin of an item: a later checkin means the item has circulated since.

pending_actions

    my $actions = $checkin->pending_actions;

Returns an arrayref with the names of the follow-up actions that can be offered for this checkin, matching the /checkins/{checkin_id}/* API endpoints:

action_tokens

    my $tokens = $checkin->action_tokens( { user => $patron } );

Returns a hashref with a signed token for each of the pending_actions, keyed by action name. Each token is tied to this checkin, the passed user (a Koha::Patron, the staff member) and the action, and expires after ACTION_TOKEN_EXPIRY_SECONDS.

check_action_token

    my $valid = $checkin->check_action_token(
        {
            action => 'hold_confirmation',
            user   => $patron,
            token  => $token,
        }
    );

Returns true if token was issued by action_tokens for this checkin, user and action, and has not expired.

Actions

confirm_hold

    $checkin->confirm_hold;

Sets the trapped hold to waiting, at the checkin's desk if any. If the pickup library differs from the checkin library, creates a transfer and sets it in transit.

Throws Koha::Exceptions::MissingParameter if there is no hold associated with this checkin.

Throws Koha::Exceptions::Checkin::HoldNotFound if the hold no longer exists (e.g. it was cancelled or filled in the meantime).

Throws Koha::Exceptions::Checkin::ItemCheckedOut if the item has been checked out again since the checkin (e.g. from another workstation). The hold is left pending and no transfer is created.

Returns the Koha::Checkin object for chaining.

cancel_hold

    $checkin->cancel_hold;
    $checkin->cancel_hold( { reason => 'PATRON_REQUEST', forgive_hold_fees => 1 } );

Cancels the hold associated with this checkin and clears the hold_id. The cancellation fee (ExpireReservesMaxPickUpDelayCharge) is charged unless forgive_hold_fees is passed.

Throws Koha::Exceptions::MissingParameter if there is no hold associated with this checkin.

Returns the Koha::Checkin object for chaining.

confirm_transfer

    $checkin->confirm_transfer;
    $checkin->confirm_transfer( { to_library_id => 'CPL', reason => 'ReturnToHome' } );

Sets the transfer associated with this checkin in transit (populates datesent).

If the checkin has no transfer yet (the item needs one but AutomaticItemReturn is disabled) and to_library_id is passed, a transfer to that library is requested with the passed reason (Manual by default) and set in transit.

Throws Koha::Exceptions::MissingParameter if there is no transfer associated with this checkin and no to_library_id is passed.

Throws Koha::Exceptions::Checkin::TransferFinished if the transfer has already arrived or has been cancelled.

Returns the Koha::Checkin object for chaining.

cancel_transfer

    $checkin->cancel_transfer;

Cancels the transfer associated with this checkin and clears the transfer_id.

If the item has a recall in transit, it reverts the recall transfer as well.

Throws Koha::Exceptions::MissingParameter if there is no transfer associated with this checkin.

Throws Koha::Exceptions::Checkin::TransferFinished if the transfer has already arrived or has been cancelled.

Returns the Koha::Checkin object for chaining.

replace_wrong_transfer

    $checkin->replace_wrong_transfer;

Called when the item was checked in at a library that is not the destination of its current transfer. Replaces that transfer with a new one, from the checkin library to the original destination, so the transfer reflects where the item actually is, and links it to this checkin.

Transfer limits are ignored: the item may not be allowed to be sent from this library, but it is (wrongly) here and that fact must be recorded.

Returns the Koha::Checkin object for chaining.

confirm_recall

    $checkin->confirm_recall;

Resolves the recall associated with this checkin. If the recall's pickup library is the same as the checkin library, sets the recall to waiting. Otherwise, starts a transfer to the pickup library.

Throws Koha::Exceptions::MissingParameter if there is no recall associated with this checkin.

Throws Koha::Exceptions::Checkin::TransferNotStarted if the transfer to the pickup library could not be started. The recall is left unchanged, and the exception carries the messages returned by C4::Circulation::transferbook.

Returns the Koha::Checkin object for chaining.

verify_bundle

    my $result = $checkin->verify_bundle(
        {
            verified_barcodes => \@barcodes,
            patron_id         => $patron_id,
        }
    );

Processes bundle verification after checkin. Verified items get their lost status cleared. Missing items (expected but not verified) are marked as lost using BundleLostValue. Unexpected items (verified but not in the bundle) are removed from the bundle.

All the changes are made in a single transaction.

When the checkin returned a checkout, patron_id is the patron the bundle was checked out to (taken before the return, as the stored checkout may already be anonymized). A return claim is recorded for each missing item and, if WhenLostChargeReplacementFee is enabled, the replacement fee is charged to that patron.

Returns a hashref with keys: verified, missing, unexpected.

Internal methods

_action_token_id

    my $id = $checkin->_action_token_id( $action, $user );

Returns the identifier signed in the action tokens.

to_api_mapping

_type

<<