1 package Koha
::Checkout
;
3 # Copyright ByWater Solutions 2015
4 # Copyright 2016 Koha Development Team
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
27 use Koha
::Checkouts
::ReturnClaims
;
32 use base
qw(Koha::Object);
36 Koha::Checkout - Koha Checkout object class
46 my $is_overdue = $checkout->is_overdue( [ $reference_dt ] );
48 Return 1 if the checkout is overdue.
50 A reference date can be passed, in this case it will be used, otherwise today
51 will be the reference date.
56 my ( $self, $dt ) = @_;
57 $dt ||= DateTime
->now( time_zone
=> C4
::Context
->tz );
59 DateTime
->compare( dt_from_string
( $self->date_due, 'sql' ), $dt ) == -1
67 my $item = $checkout->item;
69 Return the checked out item
75 my $item_rs = $self->_result->item;
76 return Koha
::Item
->_new_from_dbic( $item_rs );
81 my $patron = $checkout->patron
83 Return the patron for who the checkout has been done
89 my $patron_rs = $self->_result->borrower;
90 return Koha
::Patron
->_new_from_dbic( $patron_rs );
95 This method returns the mapping for representing a Koha::Checkout object
102 issue_id
=> 'checkout_id',
103 borrowernumber
=> 'patron_id',
104 itemnumber
=> 'item_id',
105 date_due
=> 'due_date',
106 branchcode
=> 'library_id',
107 returndate
=> 'checkin_date',
108 lastreneweddate
=> 'last_renewed_date',
109 issuedate
=> 'checkout_date',
110 notedate
=> 'note_date',
114 =head3 claim_returned
116 my $return_claim = $checkout->claim_returned();
121 my ( $self, $params ) = @_;
123 my $charge_lost_fee = $params->{charge_lost_fee
};
126 $self->_result->result_source->schema->txn_do(
128 my $claim = Koha
::Checkouts
::ReturnClaim
->new(
130 issue_id
=> $self->id,
131 itemnumber
=> $self->itemnumber,
132 borrowernumber
=> $self->borrowernumber,
133 notes
=> $params->{notes
},
134 created_by
=> $params->{created_by
},
135 created_on
=> dt_from_string
,
139 my $ClaimReturnedLostValue = C4
::Context
->preference('ClaimReturnedLostValue');
140 $self->item->itemlost($ClaimReturnedLostValue)->store;
142 my $ClaimReturnedChargeFee = C4
::Context
->preference('ClaimReturnedChargeFee');
144 $ClaimReturnedChargeFee eq 'charge' ?
1
145 : $ClaimReturnedChargeFee eq 'no_charge' ?
0
146 : $charge_lost_fee; # $ClaimReturnedChargeFee eq 'ask'
147 C4
::Circulation
::LostItem
( $self->itemnumber, 'claim_returned' ) if $charge_lost_fee;
154 if ( $_->isa('Koha::Exceptions::Exception') ) {
159 Koha
::Exceptions
::Exception
->throw( "Unhandled exception" );
164 =head2 Internal methods
176 Kyle M Hall <kyle@bywatersolutions.com>
178 Jonathan Druart <jonathan.druart@bugs.koha-community.org>