@@ -, +, @@
issues
---
Koha/Checkouts.pm | 31 +++++++++++++------
.../data/mysql/atomicupdate/bug_33887.pl | 14 ++++++---
.../admin/preferences/circulation.pref | 2 +-
t/db_dependent/Koha/Checkouts.t | 22 +++++++------
4 files changed, 44 insertions(+), 25 deletions(-)
--- a/Koha/Checkouts.pm
+++ a/Koha/Checkouts.pm
@@ -63,36 +63,46 @@ sub calculate_dropbox_date {
return $dropbox_date;
}
+
=head3 automatic_checkin
my $automatic_checkins = Koha::Checkouts->automatic_checkin()
-Checks in every due issue which itemtype has automatic_checkin enabled. Also if the AutoCheckinAutoFill sys. pref. is enabled, the item is trapped for the next patron.
+Checks in every due issue which itemtype has automatic_checkin enabled. Also if the AutoCheckinAutoFill system preference is enabled, the item is trapped for the next patron.
=cut
sub automatic_checkin {
- my ($self, $params) = @_;
+ my ( $self, $params ) = @_;
my $current_date = dt_from_string;
- my $dtf = Koha::Database->new->schema->storage->datetime_parser;
+ my $dtf = Koha::Database->new->schema->storage->datetime_parser;
my $due_checkouts = $self->search(
{ date_due => { '<=' => $dtf->format_datetime($current_date) } },
- { prefetch => 'item'}
+ { prefetch => 'item' }
);
my $autofill_next = C4::Context->preference('AutomaticCheckinAutoFill');
while ( my $checkout = $due_checkouts->next ) {
if ( $checkout->item->itemtype->automatic_checkin ) {
- my ( undef, $messages) = C4::Circulation::AddReturn($checkout->item->barcode, $checkout->branchcode, undef, dt_from_string($checkout->date_due) );
- if ( $autofill_next ){
- if ( $messages->{ResFound} ){
+ my ( undef, $messages ) = C4::Circulation::AddReturn(
+ $checkout->item->barcode, $checkout->branchcode, undef,
+ dt_from_string( $checkout->date_due )
+ );
+ if ($autofill_next) {
+ if ( $messages->{ResFound} ) {
my $is_transfer = $checkout->branchcode ne $messages->{ResFound}->{branchcode};
- C4::Reserves::ModReserveAffect($checkout->item->itemnumber, $checkout->borrowernumber, $is_transfer, $messages->{ResFound}->{reserve_id}, $checkout->{desk_id}, 0);
- if( $is_transfer ){
- C4::Items::ModItemTransfer($checkout->item->itemnumber,$checkout->branchcode, $messages->{ResFound}->{branchcode},"Reserve");
+ C4::Reserves::ModReserveAffect(
+ $checkout->item->itemnumber, $checkout->borrowernumber,
+ $is_transfer, $messages->{ResFound}->{reserve_id}, $checkout->{desk_id}, 0
+ );
+ if ($is_transfer) {
+ C4::Items::ModItemTransfer(
+ $checkout->item->itemnumber, $checkout->branchcode,
+ $messages->{ResFound}->{branchcode}, "Reserve"
+ );
}
}
}
@@ -100,6 +110,7 @@ sub automatic_checkin {
}
}
+
=head3 type
=cut
--- a/installer/data/mysql/atomicupdate/bug_33887.pl
+++ a/installer/data/mysql/atomicupdate/bug_33887.pl
@@ -1,14 +1,18 @@
use Modern::Perl;
return {
- bug_number => "33887",
+ bug_number => "33887",
description => "Automatically fill the next hold with a automatic check in.",
- up => sub {
+ up => sub {
my ($args) = @_;
- my ($dbh, $out) = @$args{qw(dbh out)};
+ my ( $dbh, $out ) = @$args{qw(dbh out)};
+
# Do you stuffs here
- $dbh->do(q{
- INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('AutomaticCheckinAutoFill', '0', NULL,'Automatically fill the next hold with an automatic checkin cronjob.', 'YesNo') });
+ $dbh->do(
+ q{
+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('AutomaticCheckinAutoFill', '0', NULL,'Automatically fill the next hold with an automatic checkin cronjob.', 'YesNo') }
+ );
+
# Print useful stuff here
# sysprefs
say $out "Added new system preference 'AutomaticCheckinAutoFill'";
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
@@ -983,7 +983,7 @@ Circulation:
1: "Allow"
0: "Don't allow"
- holds to be automatically filled after being automatically checked in.
- - '
NOTE: This system preference requires the misc/cronjobs/automatic_checkin.pl
cronjob. Ask your system administrator to schedule it.
'
+ - '
NOTE: This system preference requires the misc/cronjobs/automatic_checkin.pl
cronjob. Ask your system administrator to schedule it.'
Patron restrictions:
-
- pref: PatronRestrictionTypes
--- a/t/db_dependent/Koha/Checkouts.t
+++ a/t/db_dependent/Koha/Checkouts.t
@@ -421,7 +421,8 @@ subtest 'automatic_checkin' => sub {
}
)->store;
- my $patron_2 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $patron->branchcode} } );
+ my $patron_2 =
+ $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $patron->branchcode } } );
my $reserveid = AddReserve(
{
branchcode => $patron->branchcode,
@@ -431,12 +432,12 @@ subtest 'automatic_checkin' => sub {
}
);
- t::lib::Mocks::mock_preference('AutomaticCheckinAutoFill', '0');
+ t::lib::Mocks::mock_preference( 'AutomaticCheckinAutoFill', '0' );
Koha::Checkouts->automatic_checkin;
- my $reserve = Koha::Holds->find( $reserveid );
+ my $reserve = Koha::Holds->find($reserveid);
- is( $reserve->found, undef, "Hold was not filled when AutomaticCheckinAutoFill disabled");
+ is( $reserve->found, undef, "Hold was not filled when AutomaticCheckinAutoFill disabled" );
my $checkout_3_due_ac = Koha::Checkout->new(
{
@@ -446,12 +447,12 @@ subtest 'automatic_checkin' => sub {
date_due => $today
}
)->store;
- t::lib::Mocks::mock_preference('AutomaticCheckinAutoFill', '1');
+ t::lib::Mocks::mock_preference( 'AutomaticCheckinAutoFill', '1' );
Koha::Checkouts->automatic_checkin;
$reserve->discard_changes;
- is( $reserve->found, 'W', "Hold was filled when AutomaticCheckinAutoFill enabled");
+ is( $reserve->found, 'W', "Hold was filled when AutomaticCheckinAutoFill enabled" );
my $checkout_2_odue_ac = Koha::Checkout->new(
{
@@ -461,7 +462,7 @@ subtest 'automatic_checkin' => sub {
date_due => $today
}
)->store;
- my $branch2 = $builder->build_object({ class=> "Koha::Libraries" });
+ my $branch2 = $builder->build_object( { class => "Koha::Libraries" } );
my $reserve2id = AddReserve(
{
branchcode => $branch2->branchcode,
@@ -472,8 +473,11 @@ subtest 'automatic_checkin' => sub {
);
Koha::Checkouts->automatic_checkin;
- my $reserve2 = Koha::Holds->find( $reserve2id );
- is( $reserve2->found, 'T', "Hold was filled when AutomaticCheckinAutoFill enabled and transfer was initiated when branches didn't match");
+ my $reserve2 = Koha::Holds->find($reserve2id);
+ is(
+ $reserve2->found, 'T',
+ "Hold was filled when AutomaticCheckinAutoFill enabled and transfer was initiated when branches didn't match"
+ );
};
$schema->storage->txn_rollback;
--