Bug 33887: (QA follow-up) Perltidy and fix some formatting issues

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Katrin Fischer 2023-10-21 08:56:31 +00:00 committed by Tomas Cohen Arazi
parent 89d15333be
commit 2d41825763
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
4 changed files with 43 additions and 25 deletions

View file

@ -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

View file

@ -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'";

View file

@ -983,7 +983,7 @@ Circulation:
1: "Allow"
0: "Don't allow"
- holds to be automatically filled after being automatically checked in.
- '<br><strong>NOTE:</strong> This system preference requires the <code>misc/cronjobs/automatic_checkin.pl</code> cronjob. Ask your system administrator to schedule it.<br>'
- '<br><strong>NOTE:</strong> This system preference requires the <code>misc/cronjobs/automatic_checkin.pl</code> cronjob. Ask your system administrator to schedule it.'
Patron restrictions:
-
- pref: PatronRestrictionTypes

View file

@ -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;