Bugzilla – Attachment 98942 Details for
Bug 23695
Items holdingbranch should be set to the originating library when generating a manual transfer
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23695: Alter transferbook to take a hash of params and specify from_branch
Bug-23695-Alter-transferbook-to-take-a-hash-of-par.patch (text/plain), 14.28 KB, created by
Nick Clemens
on 2020-02-14 13:46:09 UTC
(
hide
)
Description:
Bug 23695: Alter transferbook to take a hash of params and specify from_branch
Filename:
MIME Type:
Creator:
Nick Clemens
Created:
2020-02-14 13:46:09 UTC
Size:
14.28 KB
patch
obsolete
>From 5ad5798eb0e0104b2d187b602dfa8d303f3bd97f Mon Sep 17 00:00:00 2001 >From: Nick <nick@bywatersolutions.com> >Date: Mon, 30 Sep 2019 10:37:03 +0000 >Subject: [PATCH] Bug 23695: Alter transferbook to take a hash of params and > specify from_branch > >To test: > 1 - Go to Circulation->Transfer > 2 - Find an item from your branch and create a transfer to branch B > 3 - Note you can specify the origin and default is 'Item's holding library' > 4 - Confirm the item is marked as held at your current branch and is being transferred to B > 5 - Find an item from a third branch, branch C > 6 - Transfer that item to branch B from branch D > 7 - Confirm the item is held at branch D and is being transferred to B > 8 - prove -v t/db_dependent/Circulation.t > 9 - prove -v t/db_dependent/Koha/Items.t >10 - prove -v t/db_dependent/RotatingCollections.t >--- > C4/Circulation.pm | 18 +++++++--- > C4/RotatingCollections.pm | 7 +++- > circ/branchtransfers.pl | 15 +++++--- > .../prog/en/modules/circ/branchtransfers.tt | 11 ++++++ > t/db_dependent/Circulation.t | 41 +++++++++++++++++++--- > t/db_dependent/Koha/Items.t | 6 +++- > 6 files changed, 82 insertions(+), 16 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index dc12cd3352..53c21242a6 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -250,12 +250,17 @@ sub decode { > > =head2 transferbook > >- ($dotransfer, $messages, $iteminformation) = &transferbook($newbranch, >- $barcode, $ignore_reserves); >+ ($dotransfer, $messages, $iteminformation) = &transferbook({ >+ from_branch => $frombranch >+ to_branch => $tobranch, >+ barcode => $barcode, >+ ignore_reserves => $ignore_reserves >+ }); > > Transfers an item to a new branch. If the item is currently on loan, it is automatically returned before the actual transfer. > >-C<$newbranch> is the code for the branch to which the item should be transferred. >+C<$fbr> is the code for the branch initiating the transfer. >+C<$tbr> is the code for the branch to which the item should be transferred. > > C<$barcode> is the barcode of the item to be transferred. > >@@ -303,7 +308,11 @@ The item was eligible to be transferred. Barring problems communicating with the > =cut > > sub transferbook { >- my ( $tbr, $barcode, $ignoreRs ) = @_; >+ my $params = shift; >+ my $tbr = $params->{to_branch}; >+ my $fbr = $params->{from_branch}; >+ my $ignoreRs = $params->{ignore_reserves}; >+ my $barcode = $params->{barcode}; > my $messages; > my $dotransfer = 1; > my $item = Koha::Items->find( { barcode => $barcode } ); >@@ -318,7 +327,6 @@ sub transferbook { > my $itemnumber = $item->itemnumber; > # get branches of book... > my $hbr = $item->homebranch; >- my $fbr = $item->holdingbranch; > > # if using Branch Transfer Limits > if ( C4::Context->preference("UseBranchTransferLimits") == 1 ) { >diff --git a/C4/RotatingCollections.pm b/C4/RotatingCollections.pm >index 709eaf2164..8e6a560a7b 100644 >--- a/C4/RotatingCollections.pm >+++ b/C4/RotatingCollections.pm >@@ -446,7 +446,12 @@ sub TransferCollection { > while ( my $item = $sth->fetchrow_hashref ) { > my ($status) = CheckReserves( $item->{itemnumber} ); > my @transfers = C4::Circulation::GetTransfers( $item->{itemnumber} ); >- C4::Circulation::transferbook( $colBranchcode, $item->{barcode}, my $ignore_reserves = 1 ) unless ( $status eq 'Waiting' || @transfers ); >+ C4::Circulation::transferbook({ >+ from_branch => $item->holdingbranch, >+ to_branch => $colBranchcode, >+ barcode => $item->{barcode}, >+ ignore_reserves => 1 >+ }) unless ( $status eq 'Waiting' || @transfers ); > } > > return 1; >diff --git a/circ/branchtransfers.pl b/circ/branchtransfers.pl >index f65402d412..ae2c8f05c6 100755 >--- a/circ/branchtransfers.pl >+++ b/circ/branchtransfers.pl >@@ -80,6 +80,7 @@ my $setwaiting; > > my $request = $query->param('request') || ''; > my $borrowernumber = $query->param('borrowernumber') || 0; >+my $frombranchcd = $query->param('frombranchcd') || C4::Context->userenv->{'branch'}; > my $tobranchcd = $query->param('tobranchcd') || ''; > > my $ignoreRs = 0; >@@ -126,14 +127,19 @@ defined $barcode and $barcode =~ s/^\s*|\s*$//g; # FIXME: barcodeInputFilter > # warn "barcode : $barcode"; > if ($barcode) { > >- ( $transferred, $messages ) = >- transferbook( $tobranchcd, $barcode, $ignoreRs ); > my $item = Koha::Items->find({ barcode => $barcode }); >+ $frombranchcd = $item->holdingbranch if $frombranchcd eq "current_holding"; >+ ( $transferred, $messages ) = >+ transferbook({ >+ from_branch => $frombranchcd, >+ to_branch => $tobranchcd, >+ barcode => $barcode, >+ ignore_reserves => $ignoreRs >+ }); > $found = $messages->{'ResFound'}; > if ($transferred) { > my %item; > my $biblio = $item->biblio; >- my $frbranchcd = C4::Context->userenv->{'branch'}; > $item{'biblionumber'} = $item->biblionumber; > $item{'itemnumber'} = $item->itemnumber; > $item{'title'} = $biblio->title; >@@ -145,7 +151,7 @@ if ($barcode) { > $item{'location'} = $av->count ? $av->next->lib : ''; > $item{counter} = 0; > $item{barcode} = $barcode; >- $item{frombrcd} = $frbranchcd; >+ $item{frombrcd} = $frombranchcd; > $item{tobrcd} = $tobranchcd; > push( @trsfitemloop, \%item ); > } >@@ -235,6 +241,7 @@ $template->param( > itemnumber => $itemnumber, > barcode => $barcode, > biblionumber => $biblionumber, >+ frombranchcd => $frombranchcd, > tobranchcd => $tobranchcd, > reqmessage => $reqmessage, > cancelled => $cancelled, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt >index 4859333a3b..d270733310 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt >@@ -71,6 +71,7 @@ > <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" /> > <input type="hidden" name="borrowernumber" value="[% borrowernumber | html %]" /> > <input type="hidden" name="tobranchcd" value="[% tobranchcd | html %]" /> >+ <input type="hidden" name="frombranchcd" value="[% tobranchcd | html %]" /> > <input type="hidden" name="barcode" value="[% barcode | html %]" /> > <input type="hidden" name="request" value="KillReserved" /> > <input type="submit" value="Cancel" /> >@@ -127,6 +128,7 @@ > [% ELSE %] > <li>Collection code: <b>[% AuthorisedValues.GetByCode( 'CCODE', errmsgloo.code ) | html %]</b></li> > [% END %] >+ <li>Originating library: <b>[% Branches.GetName( errmsgloo.fbr ) | html %]</b></li> > <li>Destination library: <b>[% Branches.GetName( errmsgloo.tbr ) | html %]</b></li> > </ol> > </li> >@@ -150,6 +152,13 @@ > <legend>Transfer</legend> > <ol> > <li> >+ <label for="frombranchcd">Originating library: </label> >+ <select name="frombranchcd" id="frombranchcd"> >+ <option value="current_holding">Item's holding branch</option> >+ [% PROCESS options_for_libraries libraries => Branches.all( selected => '', unfiltered => 1) %] >+ </select> >+ </li> >+ <li> > <label for="tobranchcd">Destination library: </label> > <select name="tobranchcd" id="tobranchcd"> > [% PROCESS options_for_libraries libraries => Branches.all( selected => tobranchcd, unfiltered => 1) %] >@@ -181,6 +190,7 @@ > <th class="tf-itemcallnumber">Call number</th> > <th class="tf-itemtype">Item type</th> > <th class="tf-ccode">Collection code</th> >+ <th class="tf-origin">Origin</th> > <th class="tf-destination">Destination</th> > </tr> > [% FOREACH trsfitemloo IN trsfitemloop %] >@@ -192,6 +202,7 @@ > <td class="tf-itemcallnumber">[% trsfitemloo.itemcallnumber | html %]</td> > <td class="tf-itemtype">[% ItemTypes.GetDescription( trsfitemloo.itemtype ) | html %]</td> > <td class="tf-ccode">[% AuthorisedValues.GetByCode( 'CCODE', trsfitemloo.ccode ) | html %]</td> >+ <td class="tf-origin">[% Branches.GetName( trsfitemloo.frombrcd ) | html %]</td> > <td class="tf-destination">[% Branches.GetName( trsfitemloo.tobrcd ) | html %]</td> > </tr> > [% END %] >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 08822d765c..122050cfaf 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -18,7 +18,7 @@ > use Modern::Perl; > use utf8; > >-use Test::More tests => 46; >+use Test::More tests => 47; > use Test::MockModule; > use Test::Deep qw( cmp_deeply ); > >@@ -2954,7 +2954,7 @@ subtest 'Set waiting flag' => sub { > }; > > subtest 'Cancel transfers on lost items' => sub { >- plan tests => 5; >+ plan tests => 6; > my $library_1 = $builder->build( { source => 'Branch' } ); > my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } ); > my $library_2 = $builder->build( { source => 'Branch' } ); >@@ -2981,15 +2981,20 @@ subtest 'Cancel transfers on lost items' => sub { > my $do_transfer = 1; > my ( $res, $rr ) = AddReturn( $item->barcode, $library_1->{branchcode} ); > ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id ); >- C4::Circulation::transferbook( $library_2->{branchcode}, $item->barcode ); >+ C4::Circulation::transferbook({ >+ from_branch => $library_1->{branchcode}, >+ to_branch => $library_2->{branchcode}, >+ barcode => $item->barcode, >+ }); > my $hold = Koha::Holds->find( $reserve_id ); > is( $hold->found, 'T', 'Hold is in transit' ); > > #Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost > my ($datesent,$frombranch,$tobranch) = GetTransfers($item->itemnumber); >- is( $tobranch, $library_2->{branchcode}, 'The transfer record exists in the branchtransfers table'); >+ is( $frombranch, $library_1->{branchcode}, 'The transfer is generated from the correct library'); >+ is( $tobranch, $library_2->{branchcode}, 'The transfer is generated to the correct library'); > my $itemcheck = Koha::Items->find($item->itemnumber); >- is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Items holding branch is the transfers origin branch before it is marked as lost' ); >+ is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Items holding branch is the transfers origination branch before it is marked as lost' ); > > #Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch > ModItem( { itemlost => 1 }, $item->biblionumber, $item->itemnumber ); >@@ -2998,6 +3003,32 @@ subtest 'Cancel transfers on lost items' => sub { > is( $tobranch, undef, 'The transfer on the lost item has been deleted as the LostItemCancelOutstandingTransfer is enabled'); > $itemcheck = Koha::Items->find($item->itemnumber); > is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Lost item with cancelled hold has holding branch equallying the transfers source branch' ); >+ >+}; >+ >+subtest 'transferbook test' => sub { >+ plan tests => 5; >+ >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $item = $builder->build_sample_item(); >+ ok( $item->holdingbranch ne $library->branchcode && $item->homebranch ne $library->branchcode, "Item is not held or owned by library"); >+ C4::Circulation::transferbook({ >+ from_branch => $library->branchcode, >+ to_branch => $item->homebranch, >+ barcode => $item->barcode, >+ }); >+ my ($datesent,$from_branch,$to_branch) = GetTransfers($item->itemnumber); >+ is( $from_branch, $library->branchcode, 'The transfer is initiated from the specified branch, not the items home or holdingbranch'); >+ is( $to_branch, $item->homebranch, 'The transfer is initiated to the specified branch'); >+ C4::Circulation::transferbook({ >+ from_branch => $item->homebranch, >+ to_branch => $library->branchcode, >+ barcode => $item->barcode, >+ }); >+ ($datesent,$from_branch,$to_branch) = GetTransfers($item->itemnumber); >+ is( $from_branch, $item->homebranch, 'The transfer is initiated from the specified branch'); >+ is( $to_branch, $library->branchcode, 'The transfer is initiated to the specified branch'); >+ > }; > > subtest 'CanBookBeIssued | is_overdue' => sub { >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index 94d9a45714..f4553aefe8 100644 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -69,7 +69,11 @@ subtest 'get_transfer' => sub { > > my $library_to = $builder->build( { source => 'Branch' } ); > >- C4::Circulation::transferbook( $library_to->{branchcode}, $new_item_1->barcode ); >+ C4::Circulation::transferbook({ >+ from_branch => $new_item_1->holdingbranch, >+ to_branch => $library_to->{branchcode}, >+ barcode => $new_item_1->barcode, >+ }); > > $transfer = $new_item_1->get_transfer(); > is( ref($transfer), 'Koha::Item::Transfer', 'Koha::Item->get_transfer should return a Koha::Item::Transfers object' ); >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23695
:
93231
|
98942
|
99955
|
99956
|
100567
|
100568
|
101441
|
101442
|
101443
|
107463
|
107464
|
107465
|
108183
|
108184
|
108185
|
108186
|
108273
|
108495
|
111391
|
111394