From 9c64cf0bea2a90097e8e3fc1229536b44ad30f4c Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Wed, 14 Jun 2023 15:58:04 +0000 Subject: [PATCH] Bug 33500: Account for RecordLocalUseOnReturn To test: 1. Turn on RecordLocalUseOnReturn 2. prove -v /kohadevbox/koha/t/db_dependent/Circulation.t 3. Tests fail. 4. Apply patch 5. prove -v /kohadevbox/koha/t/db_dependent/Circulation.t 6. Tests pass. Signed-off-by: Sam Lau --- C4/Circulation.pm | 2 ++ t/db_dependent/Circulation.t | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 4fdc525330..3fbae5a058 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2114,6 +2114,8 @@ sub AddReturn { if (C4::Context->preference("RecordLocalUseOnReturn")) { $messages->{'LocalUse'} = 1; $stat_type = 'localuse'; + } else { + $messages->{'LocalUse'} = 0; } } diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 3cd4ded868..4896d7be0b 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -5803,12 +5803,13 @@ subtest 'Tests for BlockReturnOfWithdrawnItems' => sub { plan tests => 1; t::lib::Mocks::mock_preference('BlockReturnOfWithdrawnItems', 1); + my $RecordLocalUseOnReturn = C4::Context->preference('RecordLocalUseOnReturn') ? 1 : 0; my $item = $builder->build_sample_item(); $item->withdrawn(1)->itemlost(1)->store; my @return = AddReturn( $item->barcode, $item->homebranch, 0, undef ); is_deeply( \@return, - [ 0, { NotIssued => $item->barcode, withdrawn => 1 }, undef, {} ], "Item returned as withdrawn, no other messages"); + [ 0, { NotIssued => $item->barcode, withdrawn => 1, LocalUse => $RecordLocalUseOnReturn }, undef, {} ], "Item returned as withdrawn, no other messages"); }; subtest 'Tests for transfer not in transit' => sub { @@ -5819,6 +5820,7 @@ subtest 'Tests for transfer not in transit' => sub { # These tests are to ensure a 'pending' transfer, generated by # stock rotation, will be advanced when checked in + my $RecordLocalUseOnReturn = C4::Context->preference('RecordLocalUseOnReturn') ? 1 : 0; my $item = $builder->build_sample_item(); my $transfer = $builder->build_object({ class => 'Koha::Item::Transfers', value => { itemnumber => $item->id, @@ -5829,7 +5831,7 @@ subtest 'Tests for transfer not in transit' => sub { my @return = AddReturn( $item->barcode, $item->homebranch, 0, undef ); is_deeply( \@return, - [ 0, { WasTransfered => $transfer->tobranch, TransferTrigger => 'StockrotationRepatriation', NotIssued => $item->barcode }, undef, {} ], "Item is reported to have been transferred"); + [ 0, { WasTransfered => $transfer->tobranch, TransferTrigger => 'StockrotationRepatriation', NotIssued => $item->barcode, LocalUse => $RecordLocalUseOnReturn }, undef, {} ], "Item is reported to have been transferred"); $transfer->discard_changes; ok( $transfer->datesent, 'The datesent field is populated, i.e. transfer is initiated'); -- 2.30.2