Line 0
Link Here
|
|
|
1 |
package Koha::Checkout; |
2 |
|
3 |
# Copyright ByWater Solutions 2015 |
4 |
# |
5 |
# This file is part of Koha. |
6 |
# |
7 |
# Koha is free software; you can redistribute it and/or modify it under the |
8 |
# terms of the GNU General Public License as published by the Free Software |
9 |
# Foundation; either version 3 of the License, or (at your option) any later |
10 |
# version. |
11 |
# |
12 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
13 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
14 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
15 |
# |
16 |
# You should have received a copy of the GNU General Public License along |
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 |
|
20 |
use Modern::Perl; |
21 |
|
22 |
use Carp; |
23 |
|
24 |
use C4::Overdues qw( GetFine ); |
25 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
26 |
|
27 |
use Koha::Items; |
28 |
|
29 |
use base qw(Koha::Object); |
30 |
|
31 |
=head1 NAME |
32 |
|
33 |
Koha::Issue - Koha Checkout object class |
34 |
|
35 |
=head1 API |
36 |
|
37 |
=head2 Class Methods |
38 |
|
39 |
=cut |
40 |
|
41 |
=head3 is_overdue |
42 |
|
43 |
=cut |
44 |
|
45 |
sub is_overdue { |
46 |
my ($self) = @_; |
47 |
|
48 |
unless ( defined $self->{_is_overdue} ) { |
49 |
my $today = dt_from_string(); |
50 |
my $date_due = dt_from_string( $self->date_due ); |
51 |
|
52 |
$self->{_is_overdue} = DateTime->compare( $date_due, $today ) == -1; |
53 |
} |
54 |
|
55 |
return $self->{_is_overdue}; |
56 |
} |
57 |
|
58 |
=cut |
59 |
|
60 |
=head3 fine |
61 |
|
62 |
Returns the amount in fines owed for this checkout, if any |
63 |
|
64 |
=cut |
65 |
|
66 |
sub fine { |
67 |
my ($self) = @_; |
68 |
|
69 |
return GetFine( $self->itemnumber, $self->borrowernumber ); |
70 |
} |
71 |
|
72 |
=head3 is_from_today |
73 |
|
74 |
Returns true if this checkout was either created today, or the item was renewed today |
75 |
|
76 |
=cut |
77 |
|
78 |
sub is_from_today { |
79 |
my ($self) = @_; |
80 |
|
81 |
unless ( defined $self->{_is_from_today} ) { |
82 |
my $today = output_pref( { dt => dt_from_string, dateformat => 'iso', dateonly => 1 } ); |
83 |
|
84 |
$self->{_is_from_today} = ( |
85 |
substr( $self->issuedate, 0, 10 ) eq $today |
86 |
|| substr( $self->lastreneweddate, 0, 10 ) eq $today |
87 |
); |
88 |
} |
89 |
|
90 |
return $self->{_is_from_today}; |
91 |
} |
92 |
|
93 |
=head3 item |
94 |
|
95 |
=cut |
96 |
|
97 |
sub item { |
98 |
my ( $self ) = @_; |
99 |
|
100 |
$self->{_item} ||= Koha::Items->find( $self->itemnumber ); |
101 |
|
102 |
return $self->{_item}; |
103 |
} |
104 |
|
105 |
=head3 type |
106 |
|
107 |
=cut |
108 |
|
109 |
sub type { |
110 |
return 'Issue'; |
111 |
} |
112 |
|
113 |
=head1 AUTHOR |
114 |
|
115 |
Kyle M Hall <kyle@bywatersolutions.com> |
116 |
|
117 |
=cut |
118 |
|
119 |
1; |