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

(-)a/C4/Circulation.pm (-7 / +4 lines)
Lines 2236-2256 sub _debar_user_on_return { Link Here
2236
    );
2236
    );
2237
    my $finedays = $issuing_rule ? $issuing_rule->finedays : undef;
2237
    my $finedays = $issuing_rule ? $issuing_rule->finedays : undef;
2238
    my $unit     = $issuing_rule ? $issuing_rule->lengthunit : undef;
2238
    my $unit     = $issuing_rule ? $issuing_rule->lengthunit : undef;
2239
    my $chargeable_units = C4::Overdues::get_chargeable_units($unit, $dt_due, $return_date, $branchcode);
2240
2239
2241
    if ($finedays) {
2240
    if ($finedays) {
2242
2241
2243
        # finedays is in days, so hourly loans must multiply by 24
2244
        # thus 1 hour late equals 1 day suspension * finedays rate
2245
        $finedays = $finedays * 24 if ( $unit eq 'hours' );
2246
2247
        # grace period is measured in the same units as the loan
2242
        # grace period is measured in the same units as the loan
2248
        my $grace =
2243
        my $grace =
2249
          DateTime::Duration->new( $unit => $issuing_rule->firstremind );
2244
          DateTime::Duration->new( $unit => $issuing_rule->firstremind );
2250
2245
2251
        my $deltadays = DateTime::Duration->new(
2246
        my $deltadays = C4::Overdues::get_chargeable_units('days', $dt_due, $return_date, $branchcode);
2252
            days => $chargeable_units
2247
        $deltadays = DateTime::Duration->new(
2248
            days => $deltadays,
2253
        );
2249
        );
2250
2254
        if ( $deltadays->subtract($grace)->is_positive() ) {
2251
        if ( $deltadays->subtract($grace)->is_positive() ) {
2255
            my $suspension_days = $deltadays * $finedays;
2252
            my $suspension_days = $deltadays * $finedays;
2256
2253
(-)a/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t (-2 / +30 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 101-104 is( Link Here
101
);
101
);
102
DelDebarment( $debarments->[0]->{borrower_debarment_id} );
102
DelDebarment( $debarments->[0]->{borrower_debarment_id} );
103
103
104
# Test with lengthunit => 'hours'
105
Koha::IssuingRules->search->delete;
106
$builder->build(
107
    {
108
        source => 'Issuingrule',
109
        value  => {
110
            categorycode => '*',
111
            itemtype     => '*',
112
            branchcode   => '*',
113
            firstremind  => 0,
114
            finedays     => 2,
115
            lengthunit   => 'hours',
116
            suspension_chargeperiod => 1,
117
            maxsuspensiondays => 100,
118
        }
119
    }
120
);
121
122
$daysafter10 = dt_from_string->add_duration(DateTime::Duration->new(days => 10));
123
AddIssue( $borrower, $barcode, $daysago20 );
124
AddReturn( $barcode, $branchcode );
125
$debarments = GetDebarments({borrowernumber => $borrower->{borrowernumber}});
126
is(
127
    $debarments->[0]->{expiration},
128
    output_pref({ dt => $daysafter40, dateformat => 'iso', dateonly => 1 }),
129
    'calculate suspension with lengthunit hours.'
130
);
131
DelDebarment( $debarments->[0]->{borrower_debarment_id} );
132
104
$schema->storage->txn_rollback;
133
$schema->storage->txn_rollback;
105
- 

Return to bug 14293