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

(-)a/C4/Circulation.pm (-5 / +5 lines)
Lines 41-47 use C4::Koha qw( Link Here
41
    GetAuthValCode
41
    GetAuthValCode
42
    GetKohaAuthorisedValueLib
42
    GetKohaAuthorisedValueLib
43
);
43
);
44
use C4::Overdues qw(CalcFine UpdateFine);
44
use C4::Overdues qw(CalcFine UpdateFine get_chargeable_units);
45
use C4::RotatingCollections qw(GetCollectionItemBranches);
45
use C4::RotatingCollections qw(GetCollectionItemBranches);
46
use Algorithm::CheckDigits;
46
use Algorithm::CheckDigits;
47
47
Lines 2136-2151 sub _debar_user_on_return { Link Here
2136
    my ( $borrower, $item, $dt_due, $dt_today ) = @_;
2136
    my ( $borrower, $item, $dt_due, $dt_today ) = @_;
2137
2137
2138
    my $branchcode = _GetCircControlBranch( $item, $borrower );
2138
    my $branchcode = _GetCircControlBranch( $item, $borrower );
2139
    my $calendar = Koha::Calendar->new( branchcode => $branchcode );
2140
2141
    # $deltadays is a DateTime::Duration object
2142
    my $deltadays = $calendar->days_between( $dt_due, $dt_today );
2143
2139
2144
    my $circcontrol = C4::Context->preference('CircControl');
2140
    my $circcontrol = C4::Context->preference('CircControl');
2145
    my $issuingrule =
2141
    my $issuingrule =
2146
      GetIssuingRule( $borrower->{categorycode}, $item->{itype}, $branchcode );
2142
      GetIssuingRule( $borrower->{categorycode}, $item->{itype}, $branchcode );
2147
    my $finedays = $issuingrule->{finedays};
2143
    my $finedays = $issuingrule->{finedays};
2148
    my $unit     = $issuingrule->{lengthunit};
2144
    my $unit     = $issuingrule->{lengthunit};
2145
    my $chargeable_units = get_chargeable_units($unit, $dt_due, $dt_today, $branchcode);
2149
2146
2150
    if ($finedays) {
2147
    if ($finedays) {
2151
2148
Lines 2157-2162 sub _debar_user_on_return { Link Here
2157
        my $grace =
2154
        my $grace =
2158
          DateTime::Duration->new( $unit => $issuingrule->{firstremind} );
2155
          DateTime::Duration->new( $unit => $issuingrule->{firstremind} );
2159
2156
2157
        my $deltadays = DateTime::Duration->new(
2158
            days => $chargeable_units
2159
        );
2160
        if ( $deltadays->subtract($grace)->is_positive() ) {
2160
        if ( $deltadays->subtract($grace)->is_positive() ) {
2161
            my $suspension_days = $deltadays * $finedays;
2161
            my $suspension_days = $deltadays * $finedays;
2162
2162
(-)a/C4/Overdues.pm (-6 / +5 lines)
Lines 47-53 BEGIN { Link Here
47
        &AmountNotify
47
        &AmountNotify
48
        &UpdateFine
48
        &UpdateFine
49
        &GetFine
49
        &GetFine
50
        
50
        &get_chargeable_units
51
        &CheckItemNotify
51
        &CheckItemNotify
52
        &GetOverduesForBranch
52
        &GetOverduesForBranch
53
        &RemoveNotifyLine
53
        &RemoveNotifyLine
Lines 248-254 sub CalcFine { Link Here
248
    my $fine_unit = $data->{lengthunit};
248
    my $fine_unit = $data->{lengthunit};
249
    $fine_unit ||= 'days';
249
    $fine_unit ||= 'days';
250
250
251
    my $chargeable_units = _get_chargeable_units($fine_unit, $start_date, $end_date, $branchcode);
251
    my $chargeable_units = get_chargeable_units($fine_unit, $start_date, $end_date, $branchcode);
252
    my $units_minus_grace = $chargeable_units - $data->{firstremind};
252
    my $units_minus_grace = $chargeable_units - $data->{firstremind};
253
    my $amount = 0;
253
    my $amount = 0;
254
    if ($data->{'chargeperiod'}  && ($units_minus_grace > 0)  ) {
254
    if ($data->{'chargeperiod'}  && ($units_minus_grace > 0)  ) {
Lines 267-275 sub CalcFine { Link Here
267
}
267
}
268
268
269
269
270
=head2 _get_chargeable_units
270
=head2 get_chargeable_units
271
271
272
    _get_chargeable_units($unit, $start_date_ $end_date, $branchcode);
272
    get_chargeable_units($unit, $start_date_ $end_date, $branchcode);
273
273
274
return integer value of units between C<$start_date> and C<$end_date>, factoring in holidays for C<$branchcode>.
274
return integer value of units between C<$start_date> and C<$end_date>, factoring in holidays for C<$branchcode>.
275
275
Lines 281-287 C<$branchcode> is the branch whose calendar to use for finding holidays. Link Here
281
281
282
=cut
282
=cut
283
283
284
sub _get_chargeable_units {
284
sub get_chargeable_units {
285
    my ($unit, $date_due, $date_returned, $branchcode) = @_;
285
    my ($unit, $date_due, $date_returned, $branchcode) = @_;
286
286
287
    # If the due date is later than the return date
287
    # If the due date is later than the return date
288
- 

Return to bug 13909