Bug 27851: Add Koha::Old::Checkouts->filter_by_todays_checkins
The logic for this code is handled at two different places (and in 2 different ways). Better to centralize and provide tests Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
6161fc1186
commit
d6e65d4f99
|
|
@ -18,10 +18,28 @@ package Koha::Old::Checkouts;
|
|||
use Modern::Perl;
|
||||
|
||||
use Koha::Database;
|
||||
use Koha::DateUtils qw( dt_from_string );
|
||||
use Koha::Old::Checkout;
|
||||
|
||||
use base qw(Koha::Objects);
|
||||
|
||||
sub filter_by_todays_checkins {
|
||||
my ( $self ) = @_;
|
||||
|
||||
my $dtf = Koha::Database->new->schema->storage->datetime_parser;
|
||||
my $today = dt_from_string;
|
||||
my $today_start = $today->clone->set( hour => 0, minute => 0, second => 0 );
|
||||
my $today_end = $today->clone->set( hour => 23, minute => 59, second => 59 );
|
||||
$today_start = $dtf->format_datetime( $today_start );
|
||||
$today_end = $dtf->format_datetime( $today_end );
|
||||
return $self->search({
|
||||
returndate => {
|
||||
'>=' => $today_start,
|
||||
'<=' => $today_end,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
sub _type {
|
||||
return 'OldIssue';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue