Bug 36506: Use new rules in C4::Accounts

This seems to be the only place processing fee is used, in chargelostitem

This patch uses get_effective_rule_value, falling back to 0 if no rule.

We also respect the new system preference, LostChargesControl, introduced in bug 39802

To test:
 1 - Apply patch, updatedatabase, restart all
 2 - Set a default/all branches  processing rule for Books itemtype to 5
 3 - Set a rule for branch 1 to 1
 4 - Set a rule for branch 2 to 2
 5 - Set a rule for branch 3 to 3
 6 - Set a rule for branch 4 to 4
 7 - Set LostChargesControl to 'library the patron is from'
 8 - Check out a Books item from a different branch to a patron from branch 1
 9 - Mark item lost, confirm processing fee is charged as 1
10 - Check out out a Books item from a different branch to a patron from branch 5
11 - Mark item lost, confirm processing fee is 5
12 - Set LostChargesControl to 'library you are logged in at'
13 - Check out a Books item from a different branch to a patron from branch 1
14 - Ensure you are logged in at branch 2
15 - Mark item lost, confirm processing fee is 2
16 - Set LostChargesControl to 'the library the item is from'
17 - Set HomeOrHoldingBranch to 'homebranch'
18 - Still at branch 2, check out a books item from branch 3 to a patron of branch 1, this ensure holdingbranch is not 3
19 - Mark item lost, confirm processing fee is 3
20 - Set HomeOrHoldingBranch to 'holdingbranch'
21 - Ensure you are logged in at branch 4
22 - Checkout an item from branch 1 to a patron from a different branch
23 - Mark item lost, confirm processing fee is 4
24 - Test other combos as you see fit
25 - Sign off!

Sponsored-by: The Main Library Alliance <https://www.mainlib.org/>
Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2025-10-01 19:52:18 +00:00 committed by Lucas Gass
parent f4634ee1c8
commit 2b5f89788d
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 26 additions and 4 deletions

View File

@ -66,11 +66,33 @@ FIXME : if no replacement price, borrower just doesn't get charged?
sub chargelostitem {
my $dbh = C4::Context->dbh();
my ( $borrowernumber, $itemnumber, $replacementprice, $description ) = @_;
my $item = Koha::Items->find($itemnumber);
my $itype = $item->itemtype;
my $patron = Koha::Patrons->find($borrowernumber);
my $item = Koha::Items->find($itemnumber);
my $itype = $item->itemtype;
$replacementprice //= 0;
my $defaultreplacecost = $itype->defaultreplacecost;
my $processfee = $itype->processfee;
my $defaultreplacecost = $itype->defaultreplacecost;
my $lost_control_pref = C4::Context->preference('LostChargesControl');
my $lost_control_branch;
if ( $lost_control_pref eq 'PatronLibrary' ) {
$lost_control_branch = $patron->branchcode;
} elsif ( $lost_control_pref eq 'PickupLibrary' ) {
$lost_control_branch = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
} else { # $lost_control_pref eq 'ItemHomeLibrary'
$lost_control_branch =
( C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' )
? $item->homebranch
: $item->holdingbranch;
}
my $processfee = Koha::CirculationRules->get_effective_rule_value(
{
rule_name => "lost_item_processing_fee",
categorycode => undef,
itemtype => $itype->itemtype,
branchcode => $lost_control_branch
}
) // 0;
my $usedefaultreplacementcost = C4::Context->preference("useDefaultReplacementCost");
my $processingfeenote = C4::Context->preference("ProcessingFeeNote");