From e9ea05f5efef6ad754ee72b4a32c097d9a869ca6 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 7 Jan 2025 14:17:11 +0000 Subject: [PATCH] Bug 24401: (QA follow-up) Tidy and spelling Signed-off-by: Nick Clemens --- Koha/REST/V1/Checkouts.pm | 29 ++++++++++--------- t/db_dependent/api/v1/checkin.t | 49 ++++++++++++++------------------- 2 files changed, 34 insertions(+), 44 deletions(-) diff --git a/Koha/REST/V1/Checkouts.pm b/Koha/REST/V1/Checkouts.pm index 7e979251324..6761515e4be 100644 --- a/Koha/REST/V1/Checkouts.pm +++ b/Koha/REST/V1/Checkouts.pm @@ -314,6 +314,7 @@ sub add { }; } + =head3 checkin Check in a checked out item via item_id or barcode @@ -345,8 +346,7 @@ sub checkin { my $item; if ($item_id) { $item = Koha::Items->find($item_id); - } - else { + } else { $item = Koha::Items->find( { barcode => $barcode } ); } @@ -368,25 +368,25 @@ sub checkin { return $c->render( status => 409, openapi => { - error => - 'Item id and external id belong to different items', + error => 'Item id and external id belong to different items', error_code => 'ITEM_ID_NOT_MATCHING_EXTERNAL_ID', } ); } - my ( $returned, $return_messages ) = - C4::Circulation::AddReturn( $item->barcode, $library_id, - $exemptfine ); + my ( $returned, $return_messages ) = C4::Circulation::AddReturn( + $item->barcode, $library_id, + $exemptfine + ); my $response = { returned => $returned, messages => $return_messages }; - if ($return_messages->{BadBarcode}){ - $response->{error} = 'Item not found.'; - return $c->render( - status => 409, - openapi => $response - ); + if ( $return_messages->{BadBarcode} ) { + $response->{error} = 'Item not found.'; + return $c->render( + status => 409, + openapi => $response + ); } unless ($returned) { @@ -402,8 +402,7 @@ sub checkin { openapi => $response ); - } - catch { + } catch { $c->unhandled_exception($_); }; } diff --git a/t/db_dependent/api/v1/checkin.t b/t/db_dependent/api/v1/checkin.t index 5c00ebbec8a..d0178f68ad2 100755 --- a/t/db_dependent/api/v1/checkin.t +++ b/t/db_dependent/api/v1/checkin.t @@ -61,18 +61,16 @@ my $patron = $builder->build_object( } ); my $unauth_password = 'thePassword000'; -$patron->set_password( - { password => $unauth_password, skip_validattion => 1 } ); +$patron->set_password( { password => $unauth_password, skip_validattion => 1 } ); my $unauth_userid = $patron->userid; my $patron_id = $patron->borrowernumber; my $item1 = $builder->build_sample_item; my $item1_id = $item1->id; -my $itemtype = $builder->build( { source => 'Itemtype' } )->{itemtype}; -my $biblio_2 = $builder->build_sample_biblio; -my $item_2 = $builder->build_sample_item( - { biblionumber => $biblio_2->biblionumber, itype => $itemtype } ); +my $itemtype = $builder->build( { source => 'Itemtype' } )->{itemtype}; +my $biblio_2 = $builder->build_sample_biblio; +my $item_2 = $builder->build_sample_item( { biblionumber => $biblio_2->biblionumber, itype => $itemtype } ); my $item_2_barcode = $item_2->barcode; my $item_2_id = $item_2->id; @@ -146,31 +144,25 @@ my $reserve_id = C4::Reserves::AddReserve( ); # empty checkin -$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => {} ) - ->status_is(400); +$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => {} )->status_is(400); -# checkin on unknow item id -$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => - { item_id => $non_existent_item_id } )->status_is(404) - ->json_is( { error => 'Item not found', error_code => 'ITEM_NOT_FOUND' } ); +# checkin on unknown item id +$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => { item_id => $non_existent_item_id } )->status_is(404) + ->json_is( { error => 'Item not found', error_code => 'ITEM_NOT_FOUND' } ); -# checkin with unknow barcode -$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => - { external_id => $non_existent_item_barcode } )->status_is(404) - ->json_is( { error => 'Item not found', error_code => 'ITEM_NOT_FOUND' } ); +# checkin with unknown barcode +$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => { external_id => $non_existent_item_barcode } ) + ->status_is(404)->json_is( { error => 'Item not found', error_code => 'ITEM_NOT_FOUND' } ); # not isued -$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => - { item_id => $not_issued_item_id, library_id => $branchcode } ) - ->status_is(403)->json_is( '/returned' => 0 ) - ->json_has( '/messages' => { NotIssued => $not_issued_item_barcode } ); +$t->post_ok( + "//$userid:$password@/api/v1/checkin" => json => { item_id => $not_issued_item_id, library_id => $branchcode } ) + ->status_is(403)->json_is( '/returned' => 0 )->json_has( '/messages' => { NotIssued => $not_issued_item_barcode } ); # checkin okay -$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => - { item_id => $item1_id, library_id => $branchcode } )->status_is(201) - ->json_is( '/returned' => 1 ) - ->json_has( - '/messages' => { TransferTrigger => 'ReturnToHome', WasReturned => '1' } ); +$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => { item_id => $item1_id, library_id => $branchcode } ) + ->status_is(201)->json_is( '/returned' => 1 ) + ->json_has( '/messages' => { TransferTrigger => 'ReturnToHome', WasReturned => '1' } ); #mismatch of item_id and barcode when both given $t->post_ok( @@ -182,11 +174,10 @@ $t->post_ok( )->status_is(409); # reserved item -$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => - { item_id => $item_2_id, library_id => $branchcode } )->status_is(201) - ->json_is( '/returned' => 1 )->json_has( +$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => { item_id => $item_2_id, library_id => $branchcode } ) + ->status_is(201)->json_is( '/returned' => 1 )->json_has( '/messages' => { WasReturned => '1' }, '/ResFound' => { "ResFound" => "Reserved" } - ); + ); $schema->storage->txn_rollback; -- 2.39.5