Bug 35721 - Replace ModItemTransfer calls in circ/returns.pl
Summary: Replace ModItemTransfer calls in circ/returns.pl
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Martin Renvoize (ashimema)
QA Contact: Marcel de Rooy
URL:
Keywords: roadmap_24_11
Depends on: 34972 35100
Blocks: 25754 28294
  Show dependency treegraph
 
Reported: 2024-01-08 09:48 UTC by Martin Renvoize (ashimema)
Modified: 2024-11-14 14:40 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00
Circulation function:


Attachments
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl (1.66 KB, patch)
2024-01-08 12:56 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl (2.23 KB, patch)
2024-01-08 14:48 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl (2.32 KB, patch)
2024-01-08 14:56 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl (2.32 KB, patch)
2024-01-08 16:33 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl (2.37 KB, patch)
2024-01-08 22:02 UTC, David Nind
Details | Diff | Splinter Review
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl (2.37 KB, patch)
2024-01-09 13:16 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl (2.42 KB, patch)
2024-06-28 16:20 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl (2.47 KB, patch)
2024-06-28 16:21 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl (2.47 KB, patch)
2024-10-15 14:27 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl (2.47 KB, patch)
2024-10-21 11:42 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 35721: Replace newly introduced ModItemTransfer calls (1.86 KB, patch)
2024-10-21 11:42 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 35721: Replace newly introduced ModItemTransfer calls (1.96 KB, patch)
2024-10-25 12:42 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl (2.52 KB, patch)
2024-10-25 13:29 UTC, Phil Ringnalda
Details | Diff | Splinter Review
Bug 35721: Replace newly introduced ModItemTransfer calls (2.01 KB, patch)
2024-10-25 13:29 UTC, Phil Ringnalda
Details | Diff | Splinter Review
Bug 35721: (QA follow-up) replace find() with pickup_library() (982 bytes, patch)
2024-10-25 14:23 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl (2.62 KB, patch)
2024-11-01 07:47 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 35721: Replace newly introduced ModItemTransfer calls (2.10 KB, patch)
2024-11-01 07:47 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 35721: (QA follow-up) replace find() with pickup_library() (1.04 KB, patch)
2024-11-01 07:47 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize (ashimema) 2024-01-08 09:48:36 UTC
ModItemTransfer is slowly getting removed and replaced by calls to the relevant Koha::Item and Koha::Item::Transfer methods.
Comment 1 Martin Renvoize (ashimema) 2024-01-08 12:56:51 UTC Comment hidden (obsolete)
Comment 2 Martin Renvoize (ashimema) 2024-01-08 14:48:41 UTC Comment hidden (obsolete)
Comment 3 Martin Renvoize (ashimema) 2024-01-08 14:56:51 UTC Comment hidden (obsolete)
Comment 4 Martin Renvoize (ashimema) 2024-01-08 16:33:38 UTC Comment hidden (obsolete)
Comment 5 David Nind 2024-01-08 22:02:03 UTC
Created attachment 160665 [details] [review]
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl

This patch replaces the call to ModItemTransfer in circ/returns.pl with
a call to Koha::Item->request_transfer and
Koha::Item::Transfer->transit.

Test plan
1) Set 'AutomaticItemReturn' to "Don't"
2) Check an item in at a location other than it's 'home' or 'holding'
   branch
3) Note you should be asked a about returning the item to another branch
4) Opting to not proceed should NOT result in a row in the
   branchtransfers table
5) Option to proceed (either with a print slip or just 'OK') should
   result in a branchtransfer from the current checkin branch to the
home or holding branch depending on the circulation rules.
5a) The item should be marked as immediately in transit in, i.e. the
   'datesent' set to today.

Signed-off-by: David Nind <david@davidnind.com>
Comment 6 Martin Renvoize (ashimema) 2024-01-09 13:16:09 UTC Comment hidden (obsolete)
Comment 7 Marcel de Rooy 2024-04-18 12:17:00 UTC
Dep does not apply.
Comment 8 Martin Renvoize (ashimema) 2024-06-28 16:20:31 UTC
Created attachment 168279 [details] [review]
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl

This patch replaces the call to ModItemTransfer in circ/returns.pl with
a call to Koha::Item->request_transfer and
Koha::Item::Transfer->transit.

Test plan
1) Set 'AutomaticItemReturn' to "Don't"
2) Check an item in at a location other than it's 'home' or 'holding'
   branch
3) Note you should be asked a about returning the item to another branch
4) Opting to not proceed should NOT result in a row in the
   branchtransfers table
5) Option to proceed (either with a print slip or just 'OK') should
   result in a branchtransfer from the current checkin branch to the
home or holding branch depending on the circulation rules.
5a) The item should be marked as immediately in transit in, i.e. the
   'datesent' set to today.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 9 Martin Renvoize (ashimema) 2024-06-28 16:21:19 UTC
Created attachment 168280 [details] [review]
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl

This patch replaces the call to ModItemTransfer in circ/returns.pl with
a call to Koha::Item->request_transfer and
Koha::Item::Transfer->transit.

Test plan
1) Set 'AutomaticItemReturn' to "Don't"
2) Check an item in at a location other than it's 'home' or 'holding'
   branch
3) Note you should be asked a about returning the item to another branch
4) Opting to not proceed should NOT result in a row in the
   branchtransfers table
5) Option to proceed (either with a print slip or just 'OK') should
   result in a branchtransfer from the current checkin branch to the
home or holding branch depending on the circulation rules.
5a) The item should be marked as immediately in transit in, i.e. the
   'datesent' set to today.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 10 Martin Renvoize (ashimema) 2024-10-15 14:27:23 UTC
Created attachment 172777 [details] [review]
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl

This patch replaces the call to ModItemTransfer in circ/returns.pl with
a call to Koha::Item->request_transfer and
Koha::Item::Transfer->transit.

Test plan
1) Set 'AutomaticItemReturn' to "Don't"
2) Check an item in at a location other than it's 'home' or 'holding'
   branch
3) Note you should be asked a about returning the item to another branch
4) Opting to not proceed should NOT result in a row in the
   branchtransfers table
5) Option to proceed (either with a print slip or just 'OK') should
   result in a branchtransfer from the current checkin branch to the
home or holding branch depending on the circulation rules.
5a) The item should be marked as immediately in transit in, i.e. the
   'datesent' set to today.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 11 Martin Renvoize (ashimema) 2024-10-15 14:27:43 UTC
What's another rebase between old friends aye...
Comment 12 Marcel de Rooy 2024-10-15 14:54:18 UTC
(In reply to Martin Renvoize (ashimema) from comment #11)
> What's another rebase between old friends aye...

Trying to get here soon
Comment 13 Marcel de Rooy 2024-10-18 06:18:41 UTC
-use C4::Items qw( ModItemTransfer );

Please grep for ModItemTransfer in this script again. We have multiple calls here left.
Comment 14 Martin Renvoize (ashimema) 2024-10-21 10:52:04 UTC
Looks like bug 34972 added two new occurrences.. I'll work on re-removing them again here now
Comment 15 Martin Renvoize (ashimema) 2024-10-21 11:42:39 UTC
Created attachment 173043 [details] [review]
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl

This patch replaces the call to ModItemTransfer in circ/returns.pl with
a call to Koha::Item->request_transfer and
Koha::Item::Transfer->transit.

Test plan
1) Set 'AutomaticItemReturn' to "Don't"
2) Check an item in at a location other than it's 'home' or 'holding'
   branch
3) Note you should be asked a about returning the item to another branch
4) Opting to not proceed should NOT result in a row in the
   branchtransfers table
5) Option to proceed (either with a print slip or just 'OK') should
   result in a branchtransfer from the current checkin branch to the
home or holding branch depending on the circulation rules.
5a) The item should be marked as immediately in transit in, i.e. the
   'datesent' set to today.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 16 Martin Renvoize (ashimema) 2024-10-21 11:42:42 UTC
Created attachment 173044 [details] [review]
Bug 35721: Replace newly introduced ModItemTransfer calls
Comment 17 Marcel de Rooy 2024-10-25 07:12:56 UTC
 FAIL   circ/returns.pl
   FAIL   valid
                Global symbol "$reserve" requires explicit package name (did you forget to declare "my $reserve"?)
                circ/returns.pl had compilation errors.

Please change to NSO after fixing. This needs to be tested.
Comment 18 Martin Renvoize (ashimema) 2024-10-25 12:42:12 UTC
Created attachment 173356 [details] [review]
Bug 35721: Replace newly introduced ModItemTransfer calls
Comment 19 Martin Renvoize (ashimema) 2024-10-25 12:43:14 UTC
Corrected.. main moved again.

Back to NSO as requested..
Comment 20 Phil Ringnalda 2024-10-25 13:29:20 UTC
Created attachment 173359 [details] [review]
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl

This patch replaces the call to ModItemTransfer in circ/returns.pl with
a call to Koha::Item->request_transfer and
Koha::Item::Transfer->transit.

Test plan
1) Set 'AutomaticItemReturn' to "Don't"
2) Check an item in at a location other than it's 'home' or 'holding'
   branch
3) Note you should be asked a about returning the item to another branch
4) Opting to not proceed should NOT result in a row in the
   branchtransfers table
5) Option to proceed (either with a print slip or just 'OK') should
   result in a branchtransfer from the current checkin branch to the
home or holding branch depending on the circulation rules.
5a) The item should be marked as immediately in transit in, i.e. the
   'datesent' set to today.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Comment 21 Phil Ringnalda 2024-10-25 13:29:23 UTC
Created attachment 173360 [details] [review]
Bug 35721: Replace newly introduced ModItemTransfer calls

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Comment 22 Kyle M Hall (khall) 2024-10-25 14:23:52 UTC
Created attachment 173370 [details] [review]
Bug 35721: (QA follow-up) replace find() with pickup_library()
Comment 23 Katrin Fischer 2024-10-28 13:58:54 UTC
Which road map item does this relate to? (just wondering spotting this on dashboard)
Comment 24 Martin Renvoize (ashimema) 2024-10-31 12:50:23 UTC
(In reply to Katrin Fischer from comment #23)
> Which road map item does this relate to? (just wondering spotting this on
> dashboard)

It's been carried from roadmap to roadmap for years.. if it's not in this next release I give up.
Comment 25 Marcel de Rooy 2024-10-31 13:22:53 UTC
(In reply to Martin Renvoize (ashimema) from comment #24)
> (In reply to Katrin Fischer from comment #23)
> > Which road map item does this relate to? (just wondering spotting this on
> > dashboard)
> 
> It's been carried from roadmap to roadmap for years.. if it's not in this
> next release I give up.

Looking tomorrow
Comment 26 Marcel de Rooy 2024-11-01 07:28:19 UTC
Looking here now
Comment 27 Marcel de Rooy 2024-11-01 07:47:52 UTC
Created attachment 173853 [details] [review]
Bug 35721: ModItemTransfer -> Koha::Item->request_transfer - returns.pl

This patch replaces the call to ModItemTransfer in circ/returns.pl with
a call to Koha::Item->request_transfer and
Koha::Item::Transfer->transit.

Test plan
1) Set 'AutomaticItemReturn' to "Don't"
2) Check an item in at a location other than it's 'home' or 'holding'
   branch
3) Note you should be asked a about returning the item to another branch
4) Opting to not proceed should NOT result in a row in the
   branchtransfers table
5) Option to proceed (either with a print slip or just 'OK') should
   result in a branchtransfer from the current checkin branch to the
home or holding branch depending on the circulation rules.
5a) The item should be marked as immediately in transit in, i.e. the
   'datesent' set to today.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 28 Marcel de Rooy 2024-11-01 07:47:54 UTC
Created attachment 173854 [details] [review]
Bug 35721: Replace newly introduced ModItemTransfer calls

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 29 Marcel de Rooy 2024-11-01 07:47:56 UTC
Created attachment 173855 [details] [review]
Bug 35721: (QA follow-up) replace find() with pickup_library()

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 30 Marcel de Rooy 2024-11-01 07:48:15 UTC
QA comment coming
Comment 31 Marcel de Rooy 2024-11-01 07:48:55 UTC
Passing QA but this still raises questions with me. Not completely confident that this will work in some edge cases:

     my $transferitem = $query->param('transferitem');
+    my $item = Koha::Items->find( $transferitem );
+    my $transfer = $item->request_transfer({ to => $tobranch, reason => $trigger });
No blocker for now, but this looks like a potential crash. Query param not found in items? Boom.
Another thing: see the other calls too. Why dont you add enqueue (or replace) here ? Could this potentially throw an exception?

-            ModItemTransfer( $itemnumber, $userenv_branch, $diffBranchSend, 'Reserve' );
+            my $tobranch = Koha::Libraries->find( $hold->branchcode );
-            my $tobranch = Koha::Libraries->find( $hold->branchcode );
+            my $tobranch = $hold->pickup_library();
Why dont you use diffBranchSend here ?
my $diffBranchReturned = $query->param('diffBranch');
my $diffBranchSend = ($userenv_branch ne $diffBranchReturned) ? $diffBranchReturned : undef;
template: 2x <input type="hidden" name="diffBranch" value="[% destbranch | html %]" />
script:         destbranch     => $reserve->{'branchcode'},
Looks like we first pass the reserve branchcode, we get it back and we do not use it but look it up again?

@@ -170,8 +170,13 @@ +            my $transfer = $item->request_transfer( { to => $tobranch, reason => 'Reserve', enqueue => 1 } );
request_transfer has:
frombranch    => $self->holdingbranch
original call had userenv_branch instead of item holding branch: ModItemTransfer( $itemnumber, $userenv_branch, $diffBranchSend, 'Reserve' )
Question: When does this make a difference? Since we are returning an item, arent we receiving it at userenv branch?
Same for the @@ -612,7 +617,10 @@ change
Comment 32 Emily Lamancusa (emlam) 2024-11-01 18:29:44 UTC
I can answer that last one...I chose to use $userenv_branch rather than the item's holding branch in that spot on bug 34972 because I felt it made the code easier to follow, but in practice it won't make a difference unless we introduce a bug somewhere else. We've already called AddReturn by the time we reach that part of the code, so the item's holding branch would already have been set to the userenv branch by that point.
Comment 33 Katrin Fischer 2024-11-07 16:33:36 UTC
Pushed for 24.11!

Well done everyone, thank you!