Bugzilla – Attachment 99956 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), 8.55 KB, created by
Nick Clemens (kidclamp)
on 2020-03-02 17:22:33 UTC
(
hide
)
Description:
Bug 23695: Alter transferbook to take a hash of params and specify from_branch
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-03-02 17:22:33 UTC
Size:
8.55 KB
patch
obsolete
>From 66ed2fc9c32b2ad67b4a84a4bb73f7608e1ec620 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 >--- > circ/branchtransfers.pl | 10 ++++---- > .../prog/en/modules/circ/branchtransfers.tt | 11 +++++++++ > t/db_dependent/Circulation.t | 28 +++++++++++++++++++++- > 3 files changed, 44 insertions(+), 5 deletions(-) > >diff --git a/circ/branchtransfers.pl b/circ/branchtransfers.pl >index a8446ae11c..7524bb7a2a 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,19 +127,19 @@ defined $barcode and $barcode =~ s/^\s*|\s*$//g; # FIXME: barcodeInputFilter > # warn "barcode : $barcode"; > if ($barcode) { > >+ my $item = Koha::Items->find({ barcode => $barcode }); >+ $frombranchcd = $item->holdingbranch if $frombranchcd eq "current_holding"; > ( $transferred, $messages ) = > transferbook({ >- from_branch => C4::Context->userenv->{'branch'}, >+ from_branch => $frombranchcd, > to_branch => $tobranchcd, > barcode => $barcode, > ignore_reserves => $ignoreRs > }); >- my $item = Koha::Items->find({ barcode => $barcode }); > $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; >@@ -150,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 ); > } >@@ -240,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 15e3700023..713465089f 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 ); > >@@ -3015,6 +3015,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 { >-- >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