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>
(cherry picked from commit 4c82ff273b)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
Nick Clemens 2025-10-29 15:22:24 +00:00 committed by Jacob O'Mara
parent 4b0b03609c
commit 51d503cd4f
No known key found for this signature in database
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 $toBranch (@branchcodes) {
next if $toBranch eq $branchcode;
my $isSet = not $input->param( $code . "_" . $toBranch );
if ($isSet) {
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

@ -96,7 +96,9 @@
></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
type="checkbox"
class="cb cb[% codes_loo.code | html %]"