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

(-)a/Koha/Checkout.pm (-4 / +29 lines)
Lines 344-353 sub claim_returned { Link Here
344
=head2 branch_for_fee_context
344
=head2 branch_for_fee_context
345
345
346
my $branchcode = Koha::Checkout->branch_for_fee_context(
346
my $branchcode = Koha::Checkout->branch_for_fee_context(
347
        fee_type => 'OVERDUE' | 'LOST' | 'PROCESSING',
347
    fee_type => 'OVERDUE' | 'LOST' | 'PROCESSING',
348
        );
348
    patron   => $patron_obj,  # Koha::Patron object or hashref
349
    item     => $item_obj,    # Koha::Item object or hashref
350
    issue    => $issue_obj,   # Koha::Checkout object or hashref (optional)
351
);
352
353
Determines which branch's rules should apply to a fee based on system preferences
354
and available context.
355
356
For LOST/PROCESSING fees, honors LostChargesControl preference:
357
- PatronLibrary: Uses patron's home branch
358
- PickupLibrary: Uses checkout branch (falls back to patron, then item)
359
- ItemHomeLibrary: Uses item's home or holding branch (per HomeOrHoldingBranch pref)
360
361
For OVERDUE fees, honors CircControl preference (same values as above).
349
362
350
Determines which branch’s rules should apply to a fee based on system preferences and available context. For LOST/PROCESSING it honors LostChargesControl; for OVERDUE it honors CircControl. It also respects HomeOrHoldingBranch when choosing the item’s branch. Returns a branchcode (string) or undef if it cannot be determined.
363
B<Parameters:>
364
- fee_type: 'OVERDUE', 'LOST', or 'PROCESSING' (defaults to 'OVERDUE')
365
- patron: Koha::Patron object or hashref with branchcode
366
- item: Koha::Item object or hashref with homebranch/holdingbranch
367
- issue: Koha::Checkout object or hashref with branchcode (optional)
368
369
B<Returns:> A branchcode (string) or C<undef> if no branch can be determined.
370
371
B<Note:> Returning C<undef> is acceptable - calling code should handle this gracefully.
372
When passed to Koha::Account->add_debit as library_id, undef indicates no specific
373
branch context is available for the fee.
351
374
352
=cut
375
=cut
353
376
Lines 384-389 sub branch_for_fee_context { Link Here
384
        : ( defined $control_pref && $control_pref eq 'PickupLibrary' )
407
        : ( defined $control_pref && $control_pref eq 'PickupLibrary' )
385
        ? ( $issuing_branch // $patron_branch // $item_branch )
408
        ? ( $issuing_branch // $patron_branch // $item_branch )
386
        : $item_branch;    # ItemLibrary (default)
409
        : $item_branch;    # ItemLibrary (default)
410
411
    # May return undef if no branch context is available - this is acceptable
412
    # and handled gracefully by Koha::Account->add_debit
387
    return $resolved;
413
    return $resolved;
388
}
414
}
389
415
390
- 

Return to bug 35612