Bug 28959: Add virtualshelves.public as a boolean
[koha.git] / Koha / Old / Checkout.pm
1 package Koha::Old::Checkout;
2
3 # This file is part of Koha.
4 #
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.
9 #
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.
14 #
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>.
17
18 use Modern::Perl;
19
20 use Koha::Database;
21 use Koha::Libraries;
22
23 use base qw(Koha::Object);
24
25 =head1 NAME
26
27 Koha::Old:Checkout - Koha checkout object for returned items
28
29 =head1 API
30
31 =head2 Class methods
32
33 =head3 item
34
35 my $item = $checkout->item;
36
37 Return the checked out item
38
39 =cut
40
41 sub item {
42     my ( $self ) = @_;
43     my $item_rs = $self->_result->item;
44     return Koha::Item->_new_from_dbic( $item_rs );
45 }
46
47 =head3 library
48
49 my $library = $checkout->library;
50
51 Return the library in which the transaction took place. Might return I<undef>.
52
53 =cut
54
55 sub library {
56     my ( $self ) = @_;
57     my $library_rs = $self->_result->library;
58     return unless $library_rs;
59     return Koha::Library->_new_from_dbic( $library_rs );
60 }
61
62 =head3 patron
63
64 my $patron = $checkout->patron
65
66 Return the patron for who the checkout has been done
67
68 =cut
69
70 sub patron {
71     my ( $self ) = @_;
72     my $patron_rs = $self->_result->patron;
73     return unless $patron_rs;
74     return Koha::Patron->_new_from_dbic( $patron_rs );
75 }
76
77 =head3 issuer
78
79 my $issuer = $checkout->issuer
80
81 Return the patron by whom the checkout was done
82
83 =cut
84
85 sub issuer {
86     my ( $self ) = @_;
87     my $issuer_rs = $self->_result->issuer;
88     return unless $issuer_rs;
89     return Koha::Patron->_new_from_dbic( $issuer_rs );
90 }
91
92 =head3 to_api_mapping
93
94 This method returns the mapping for representing a Koha::Old::Checkout object
95 on the API.
96
97 =cut
98
99 sub to_api_mapping {
100     return {
101         issue_id        => 'checkout_id',
102         borrowernumber  => 'patron_id',
103         itemnumber      => 'item_id',
104         date_due        => 'due_date',
105         branchcode      => 'library_id',
106         returndate      => 'checkin_date',
107         lastreneweddate => 'last_renewed_date',
108         issuedate       => 'checkout_date',
109         notedate        => 'note_date',
110         noteseen        => 'note_seen',
111     };
112 }
113
114 =head2 Internal methods
115
116 =head3 _type
117
118 =cut
119
120 sub _type {
121     return 'OldIssue';
122 }
123
124 1;