|
Lines 30-36
use C4::Accounts;
Link Here
|
| 30 |
use C4::Context; |
30 |
use C4::Context; |
| 31 |
use Koha::Account::Lines; |
31 |
use Koha::Account::Lines; |
| 32 |
use Koha::Account::Offsets; |
32 |
use Koha::Account::Offsets; |
|
|
33 |
use Koha::Checkouts; |
| 33 |
use Koha::DateUtils qw( output_pref ); |
34 |
use Koha::DateUtils qw( output_pref ); |
|
|
35 |
use Koha::Items; |
| 34 |
use Koha::Libraries; |
36 |
use Koha::Libraries; |
| 35 |
use Koha::Recalls; |
37 |
use Koha::Recalls; |
| 36 |
use Koha::Logger; |
38 |
use Koha::Logger; |
|
Lines 55-60
BEGIN {
Link Here
|
| 55 |
GetOverdueMessageTransportTypes |
57 |
GetOverdueMessageTransportTypes |
| 56 |
parse_overdues_letter |
58 |
parse_overdues_letter |
| 57 |
GetIssuesIteminfo |
59 |
GetIssuesIteminfo |
|
|
60 |
branch_for_fee_context |
| 58 |
); |
61 |
); |
| 59 |
} |
62 |
} |
| 60 |
|
63 |
|
|
Lines 327-332
sub CalcFine {
Link Here
|
| 327 |
return ( $amount, $units_minus_grace, $chargeable_units ); |
330 |
return ( $amount, $units_minus_grace, $chargeable_units ); |
| 328 |
} |
331 |
} |
| 329 |
|
332 |
|
|
|
333 |
# Resolve which branch’s rules control a fee, honoring CircControl/LostChargesControl and HomeOrHoldingBranch. |
| 334 |
|
| 335 |
sub branch_for_fee_context { |
| 336 |
my (%args) = @_; |
| 337 |
|
| 338 |
my $fee_type = $args{fee_type} // 'OVERDUE'; |
| 339 |
|
| 340 |
my $control_pref = |
| 341 |
$fee_type eq 'LOST' || $fee_type eq 'PROCESSING' |
| 342 |
? C4::Context->preference('LostChargesControl') |
| 343 |
: C4::Context->preference('CircControl'); |
| 344 |
my $hoh_pref = C4::Context->preference('HomeOrHoldingBranch') // 'home'; |
| 345 |
my $use_holding = ( $hoh_pref =~ /holding/i ) ? 1 : 0; |
| 346 |
|
| 347 |
my $patron_branch = eval { $args{patron}->branchcode } // $args{patron}->{branchcode}; |
| 348 |
my $issuing_branch = eval { $args{issue}->branchcode } // $args{issue}->{branchcode}; |
| 349 |
my $item_home = eval { $args{item}->homebranch } // $args{item}->{homebranch}; |
| 350 |
my $item_holding = eval { $args{item}->holdingbranch } // $args{item}->{holdingbranch}; |
| 351 |
my $item_branch = $use_holding ? ( $item_holding // $item_home ) : $item_home; |
| 352 |
|
| 353 |
return |
| 354 |
( $control_pref && $control_pref eq 'PatronLibrary' ) ? $patron_branch |
| 355 |
: ( $control_pref && $control_pref eq 'PickupLibrary' ) ? ( $issuing_branch // $patron_branch // $item_branch ) |
| 356 |
: $item_branch; |
| 357 |
} |
| 358 |
|
| 330 |
=head2 get_chargeable_units |
359 |
=head2 get_chargeable_units |
| 331 |
|
360 |
|
| 332 |
get_chargeable_units($unit, $start_date_ $end_date, $branchcode); |
361 |
get_chargeable_units($unit, $start_date_ $end_date, $branchcode); |
|
Lines 651-656
sub UpdateFine {
Link Here
|
| 651 |
my $desc = $letter ? $letter->{content} : sprintf( "Item %s - due %s", $itemnum, output_pref($due) ); |
680 |
my $desc = $letter ? $letter->{content} : sprintf( "Item %s - due %s", $itemnum, output_pref($due) ); |
| 652 |
|
681 |
|
| 653 |
my $account = Koha::Account->new( { patron_id => $borrowernumber } ); |
682 |
my $account = Koha::Account->new( { patron_id => $borrowernumber } ); |
|
|
683 |
|
| 684 |
# Resolve the branch that controlled this OVERDUE fee |
| 685 |
my $patron_obj = Koha::Patrons->find($borrowernumber); |
| 686 |
my $item_obj = Koha::Items->find($itemnum); |
| 687 |
my $issue_obj = Koha::Checkouts->find($issue_id); # issuing branch if CircControl=PickupLibrary |
| 688 |
my $rule_branch = branch_for_fee_context( |
| 689 |
fee_type => 'OVERDUE', |
| 690 |
patron => $patron_obj, |
| 691 |
item => $item_obj, |
| 692 |
issue => $issue_obj, |
| 693 |
); |
| 694 |
|
| 654 |
$accountline = $account->add_debit( |
695 |
$accountline = $account->add_debit( |
| 655 |
{ |
696 |
{ |
| 656 |
amount => $amount, |
697 |
amount => $amount, |
|
Lines 658-664
sub UpdateFine {
Link Here
|
| 658 |
note => undef, |
699 |
note => undef, |
| 659 |
user_id => undef, |
700 |
user_id => undef, |
| 660 |
interface => C4::Context->interface, |
701 |
interface => C4::Context->interface, |
| 661 |
library_id => undef, #FIXME: Should we grab the checkout or circ-control branch here perhaps? |
702 |
library_id => $rule_branch, # record the branch used to calculate the fee |
| 662 |
type => 'OVERDUE', |
703 |
type => 'OVERDUE', |
| 663 |
item_id => $itemnum, |
704 |
item_id => $itemnum, |
| 664 |
issue_id => $issue_id, |
705 |
issue_id => $issue_id, |