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 unless $item_rs;
46 return Koha::Item->_new_from_dbic( $item_rs );
51 my $account_lines = $checkout->account_lines;
53 Return the checked out account_lines
59 my $account_lines_rs = $self->_result->account_lines;
60 return Koha::Account::Lines->_new_from_dbic( $account_lines_rs );
65 my $library = $checkout->library;
67 Return the library in which the transaction took place. Might return I<undef>.
73 my $library_rs = $self->_result->library;
74 return unless $library_rs;
75 return Koha::Library->_new_from_dbic( $library_rs );
80 my $patron = $checkout->patron
82 Return the patron for who the checkout has been done
88 my $patron_rs = $self->_result->patron;
89 return unless $patron_rs;
90 return Koha::Patron->_new_from_dbic( $patron_rs );
95 my $issuer = $checkout->issuer
97 Return the patron by whom the checkout was done
103 my $issuer_rs = $self->_result->issuer;
104 return unless $issuer_rs;
105 return Koha::Patron->_new_from_dbic( $issuer_rs );
110 my $renewals = $checkout->renewals;
112 Return a Koha::Checkouts::Renewals set attached to this checkout
118 my $renewals_rs = $self->_result->renewals;
119 return unless $renewals_rs;
120 return Koha::Checkouts::Renewals->_new_from_dbic( $renewals_rs );
125 $checkout->anonymize();
127 Anonymize the given I<Koha::Old::Checkout> object.
134 my $anonymous_id = C4::Context->preference('AnonymousPatron');
136 Koha::Exceptions::SysPref::NotSet->throw( syspref => 'AnonymousPatron' )
137 unless $anonymous_id;
139 return $self->update( { borrowernumber => $anonymous_id } );
142 =head3 to_api_mapping
144 This method returns the mapping for representing a Koha::Old::Checkout object
151 issue_id => 'checkout_id',
152 borrowernumber => 'patron_id',
153 itemnumber => 'item_id',
154 date_due => 'due_date',
155 branchcode => 'library_id',
156 returndate => 'checkin_date',
157 lastreneweddate => 'last_renewed_date',
158 issuedate => 'checkout_date',
159 notedate => 'note_date',
160 noteseen => 'note_seen',
164 =head2 Internal methods