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

(-)a/C4/Circulation.pm (-7 / +4 lines)
Lines 2153-2173 sub _debar_user_on_return { Link Here
2153
      GetIssuingRule( $borrower->{categorycode}, $item->{itype}, $branchcode );
2153
      GetIssuingRule( $borrower->{categorycode}, $item->{itype}, $branchcode );
2154
    my $finedays = $issuingrule->{finedays};
2154
    my $finedays = $issuingrule->{finedays};
2155
    my $unit     = $issuingrule->{lengthunit};
2155
    my $unit     = $issuingrule->{lengthunit};
2156
    my $chargeable_units = C4::Overdues::get_chargeable_units($unit, $dt_due, $dt_today, $branchcode);
2157
2156
2158
    if ($finedays) {
2157
    if ($finedays) {
2159
2158
2160
        # finedays is in days, so hourly loans must multiply by 24
2161
        # thus 1 hour late equals 1 day suspension * finedays rate
2162
        $finedays = $finedays * 24 if ( $unit eq 'hours' );
2163
2164
        # grace period is measured in the same units as the loan
2159
        # grace period is measured in the same units as the loan
2165
        my $grace =
2160
        my $grace =
2166
          DateTime::Duration->new( $unit => $issuingrule->{firstremind} );
2161
          DateTime::Duration->new( $unit => $issuingrule->{firstremind} );
2167
2162
2168
        my $deltadays = DateTime::Duration->new(
2163
        my $deltadays = C4::Overdues::get_chargeable_units('days', $dt_due, $dt_today, $branchcode);
2169
            days => $chargeable_units
2164
        $deltadays = DateTime::Duration->new(
2165
            days => $deltadays,
2170
        );
2166
        );
2167
2171
        if ( $deltadays->subtract($grace)->is_positive() ) {
2168
        if ( $deltadays->subtract($grace)->is_positive() ) {
2172
            my $suspension_days = $deltadays * $finedays;
2169
            my $suspension_days = $deltadays * $finedays;
2173
2170
(-)a/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t (-2 / +21 lines)
Lines 1-5 Link Here
1
use Modern::Perl;
1
use Modern::Perl;
2
use Test::More tests => 2;
2
use Test::More tests => 3;
3
3
4
use MARC::Record;
4
use MARC::Record;
5
use MARC::Field;
5
use MARC::Field;
Lines 92-97 is( Link Here
92
);
92
);
93
DelDebarment( $debarments->[0]->{borrower_debarment_id} );
93
DelDebarment( $debarments->[0]->{borrower_debarment_id} );
94
94
95
# Test with lengthunit => 'hours'
96
$circulation_module->mock('GetIssuingRule', sub {
97
        return {
98
            firstremind => 0,
99
            finedays => 2,
100
            maxsuspensiondays => 100,
101
            lengthunit => 'hours',
102
        }
103
});
104
$daysafter10 = dt_from_string->add_duration(DateTime::Duration->new(days => 10));
105
AddIssue( $borrower, $barcode, $daysago20 );
106
AddReturn( $barcode, $branchcode );
107
$debarments = GetDebarments({borrowernumber => $borrower->{borrowernumber}});
108
is(
109
    $debarments->[0]->{expiration},
110
    output_pref({ dt => $daysafter40, dateformat => 'iso', dateonly => 1 }),
111
    'calculate suspension with lengthunit hours.'
112
);
113
DelDebarment( $debarments->[0]->{borrower_debarment_id} );
114
95
115
96
# C4::Context->userenv
116
# C4::Context->userenv
97
sub Mock_userenv {
117
sub Mock_userenv {
98
- 

Return to bug 14293