Bug 32187 - (Bug 24161 follow-up) With IndependentBranches on a non superlibrarian librarian is not able to track late orders
Summary: (Bug 24161 follow-up) With IndependentBranches on a non superlibrarian librar...
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: unspecified
Hardware: All All
: P3 major
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on: 24161
Blocks:
  Show dependency treegraph
 
Reported: 2022-11-13 14:58 UTC by Janusz Kaczmarek
Modified: 2023-06-23 06:34 UTC (History)
2 users (show)

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


Attachments
Bug 32187: DB changes (2.31 KB, patch)
2022-11-15 09:10 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 32187: Correct join on borrowers in Koha::Acq::Orders->filter_by_late (1.49 KB, patch)
2022-11-15 09:10 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Janusz Kaczmarek 2022-11-13 14:58:38 UTC
With IndependentBranches a non superlibrarian librarian is not able to track late orders. 

To reproduce: have an installation of Koha with IndependentBranches on.  Be a librarian without superlibrarian rights.  Try to generate the report about late orders (.../cgi-bin/koha/acqui/lateorders.pl).  You should get an error 500 page.  In log you should find something like:

... DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Unknown column 'branchcode' in 'where clause' at /usr/share/koha/lib/Koha/Objects.pm line 417: /usr/share/koha/intranet/cgi-bin/acqui/lateorders.pl, referer: ...

This is due to:

            (
                C4::Context->preference('IndependentBranches')
                  && !C4::Context->IsSuperLibrarian
                ? ( 'borrower.branchcode' => C4::Context->userenv->{branch} )
                : ()
            ),

from Koha/Acquisition/Orders::filter_by_lates  (line ~128)

Changing borrower.branchcode into borrowers.branchcode (borrowerS -- missing 's' at the end) does not correct the issue.

The borrower.branchcode was to substitue the C4::Acquisition::GetLateOrders function, but something went wrong...

The problem was found in 21.11, but it seems that it is still present in the master (as of November 12th, 2022).

Unfortunately, I'm not able to fix it at the moment.  Jonathan, would you be able...?
Comment 1 Jonathan Druart 2022-11-15 09:10:14 UTC
Created attachment 143894 [details] [review]
Bug 32187: DB changes
Comment 2 Jonathan Druart 2022-11-15 09:10:19 UTC
Created attachment 143895 [details] [review]
Bug 32187: Correct join on borrowers in Koha::Acq::Orders->filter_by_late
Comment 3 Jonathan Druart 2022-11-15 09:11:00 UTC
I am not able to continue right now.

What's missing:
1. Unit tests
2. atomic update (that will need a bit of cleaning on aqbasket.authorisedby before we create the FK)