1 package Koha::Old::Checkout;
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21 use Koha::Exceptions::SysPref;
24 use base qw(Koha::Object);
28 Koha::Old:Checkout - Koha checkout object for returned items
36 my $item = $checkout->item;
38 Return the checked out item
44 my $item_rs = $self->_result->item;
45 return Koha::Item->_new_from_dbic( $item_rs );
50 my $library = $checkout->library;
52 Return the library in which the transaction took place. Might return I<undef>.
58 my $library_rs = $self->_result->library;
59 return unless $library_rs;
60 return Koha::Library->_new_from_dbic( $library_rs );
65 my $patron = $checkout->patron
67 Return the patron for who the checkout has been done
73 my $patron_rs = $self->_result->patron;
74 return unless $patron_rs;
75 return Koha::Patron->_new_from_dbic( $patron_rs );
80 my $issuer = $checkout->issuer
82 Return the patron by whom the checkout was done
88 my $issuer_rs = $self->_result->issuer;
89 return unless $issuer_rs;
90 return Koha::Patron->_new_from_dbic( $issuer_rs );
95 my $renewals = $checkout->renewals;
97 Return a Koha::Checkouts::Renewals set attached to this checkout
103 my $renewals_rs = $self->_result->renewals;
104 return unless $renewals_rs;
105 return Koha::Checkouts::Renewals->_new_from_dbic( $renewals_rs );
110 $checkout->anonymize();
112 Anonymize the given I<Koha::Old::Checkout> object.
119 my $anonymous_id = C4::Context->preference('AnonymousPatron');
121 Koha::Exceptions::SysPref::NotSet->throw( syspref => 'AnonymousPatron' )
122 unless $anonymous_id;
124 return $self->update( { borrowernumber => $anonymous_id } );
127 =head3 to_api_mapping
129 This method returns the mapping for representing a Koha::Old::Checkout object
136 issue_id => 'checkout_id',
137 borrowernumber => 'patron_id',
138 itemnumber => 'item_id',
139 date_due => 'due_date',
140 branchcode => 'library_id',
141 returndate => 'checkin_date',
142 lastreneweddate => 'last_renewed_date',
143 issuedate => 'checkout_date',
144 notedate => 'note_date',
145 noteseen => 'note_seen',
149 =head2 Internal methods