From 2d418257638001f8dba45e5232126acaced9c93b Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Sat, 21 Oct 2023 08:56:31 +0000 Subject: [PATCH] Bug 33887: (QA follow-up) Perltidy and fix some formatting issues Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- Koha/Checkouts.pm | 30 ++++++++++++------- .../data/mysql/atomicupdate/bug_33887.pl | 14 +++++---- .../admin/preferences/circulation.pref | 2 +- t/db_dependent/Koha/Checkouts.t | 22 ++++++++------ 4 files changed, 43 insertions(+), 25 deletions(-) diff --git a/Koha/Checkouts.pm b/Koha/Checkouts.pm index 65cb7f0581..377b817ca8 100644 --- a/Koha/Checkouts.pm +++ b/Koha/Checkouts.pm @@ -67,32 +67,41 @@ sub calculate_dropbox_date { 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 +109,7 @@ sub automatic_checkin { } } + =head3 type =cut diff --git a/installer/data/mysql/atomicupdate/bug_33887.pl b/installer/data/mysql/atomicupdate/bug_33887.pl index 3ffd66537d..1a3f5f56ee 100755 --- a/installer/data/mysql/atomicupdate/bug_33887.pl +++ b/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'"; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index d2079bf1ed..5cb207d3f0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/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 diff --git a/t/db_dependent/Koha/Checkouts.t b/t/db_dependent/Koha/Checkouts.t index 1554b4d827..60c977acc7 100755 --- a/t/db_dependent/Koha/Checkouts.t +++ b/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; -- 2.39.5