View | Details | Raw Unified | Return to bug 28530
Collapse All | Expand All

(-)a/Koha/Library/FloatLimits.pm (+29 lines)
Lines 37-42 Koha::Library::FloatLimits - Koha Library::FloatLimit object set class Link Here
37
37
38
=head3 lowest_ratio_library
38
=head3 lowest_ratio_library
39
39
40
    my $library = Koha::Library::FloatLimits->lowest_ratio_library(
41
        $item, $branchcode, $from_branch
42
    );
43
44
Determines the optimal library to transfer an item to based on float limit ratios.
45
46
This method calculates the ratio of current items to float limits for each library
47
with configured float limits for the item's type. It considers items currently at
48
the branch, items in transit to/from the branch, and respects library group
49
restrictions if the item's return policy is set to 'returnbylibrarygroup'.
50
51
The method returns the library with the lowest ratio (most need for this item type),
52
with preference given to the current branch in case of ties. Returns undef if no
53
suitable transfer destination is found or if branch transfer limits prevent the
54
transfer.
55
56
=over 4
57
58
=item * $item - Koha::Item object to be transferred
59
60
=item * $branchcode - branchcode of the return/checkin location
61
62
=item * $from_branch - (optional) branchcode where item was previously held, used for
63
adjusting item counts during the calculation
64
65
=back
66
67
Returns: Koha::Library object of the destination branch, or undef if no transfer needed
68
40
=cut
69
=cut
41
70
42
sub lowest_ratio_library {
71
sub lowest_ratio_library {
(-)a/installer/data/mysql/atomicupdate/bug_28530.pl (+1 lines)
Lines 29-34 return { Link Here
29
                `itemtype` varchar(10) NOT NULL,
29
                `itemtype` varchar(10) NOT NULL,
30
                `float_limit` int(11) NULL DEFAULT NULL,
30
                `float_limit` int(11) NULL DEFAULT NULL,
31
                PRIMARY KEY (`branchcode`,`itemtype`),
31
                PRIMARY KEY (`branchcode`,`itemtype`),
32
                KEY `itemtype_idx` (`itemtype`),
32
                CONSTRAINT `library_float_limits_ibfk_bc` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
33
                CONSTRAINT `library_float_limits_ibfk_bc` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
33
                CONSTRAINT `library_float_limits_ibfk_it` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
34
                CONSTRAINT `library_float_limits_ibfk_it` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
34
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
35
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
(-)a/installer/data/mysql/kohastructure.sql (-1 / +1 lines)
Lines 6896-6901 CREATE TABLE `library_float_limits` ( Link Here
6896
  `itemtype` varchar(10) NOT NULL,
6896
  `itemtype` varchar(10) NOT NULL,
6897
  `float_limit` int(11) NULL DEFAULT NULL,
6897
  `float_limit` int(11) NULL DEFAULT NULL,
6898
  PRIMARY KEY (`branchcode`,`itemtype`),
6898
  PRIMARY KEY (`branchcode`,`itemtype`),
6899
  KEY `itemtype_idx` (`itemtype`),
6899
  CONSTRAINT `library_float_limits_ibfk_bc` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
6900
  CONSTRAINT `library_float_limits_ibfk_bc` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
6900
  CONSTRAINT `library_float_limits_ibfk_it` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
6901
  CONSTRAINT `library_float_limits_ibfk_it` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
6901
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
6902
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
6902
- 

Return to bug 28530