Bug 41131: Don't allow limiting transfers from/to a single branch

We say that you cannot limit transfers internally within a branch, but
it seems we do allow you to, and don't show you when we do

To test:
1 - Go to Admin->Library transfer limits
2 - On a branches page, uncheck the box for that branch
    e.g. don't allow FIC to transfer to CPL from CPL
3 - Save
4 - Note the box is still checked
5 - Check the DB
    SELECT * FROM branch_transfer_limits;
6 - There is a line to/from CPL!
7 - Apply patches
8 - updatedatabase
9 - Repeat 5 - the line is deleted!
10 - Try to create the rule again, not the box is now disabled
11 - Be sneaky, enable the box, uncheck it and save, no rule created
12 - Be sneaky, edit the HMTL for another button to make it limiting CPL to CPL, save, no rule created
13 - Sign off

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2025-10-29 15:22:24 +00:00 committed by Lucas Gass
parent 017b157b7d
commit 4c82ff273b
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
3 changed files with 23 additions and 1 deletions

View File

@ -65,6 +65,7 @@ if ( $input->param('updateLimits') && $op eq 'cud-update' ) {
foreach my $code (@codes) { foreach my $code (@codes) {
foreach my $toBranch (@branchcodes) { foreach my $toBranch (@branchcodes) {
next if $toBranch eq $branchcode;
my $isSet = not $input->param( $code . "_" . $toBranch ); my $isSet = not $input->param( $code . "_" . $toBranch );
if ($isSet) { if ($isSet) {
CreateBranchTransferLimit( $toBranch, $branchcode, $code ); CreateBranchTransferLimit( $toBranch, $branchcode, $code );

View File

@ -0,0 +1,19 @@
use Modern::Perl;
use Koha::Installer::Output qw(say_warning say_success say_info);
return {
bug_number => "41131",
description => "Delete transfer limits that are from a branch to the same branch",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
# Do you stuffs here
$dbh->do(
q{
DELETE FROM branch_transfer_limits WHERE toBranch = fromBranch;
}
);
say $out "Removed nonsensical transfer limits that prevent a branch transferring to itself";
},
};

View File

@ -97,7 +97,9 @@
></td ></td
> >
<td> <td>
[% IF ( to_branch_loo.isChecked ) %] [% IF ( to_branch_loo.toBranch == branchcode ) %]
<input type="checkbox" checked="checked" disabled="disabled" />
[% ELSIF ( to_branch_loo.isChecked ) %]
<input <input
type="checkbox" type="checkbox"
class="cb cb[% codes_loo.code | html %]" class="cb cb[% codes_loo.code | html %]"