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

(-)a/C4/Circulation.pm (-7 / +4 lines)
Lines 2231-2251 sub _debar_user_on_return { Link Here
2231
    );
2231
    );
2232
    my $finedays = $issuing_rule ? $issuing_rule->finedays : undef;
2232
    my $finedays = $issuing_rule ? $issuing_rule->finedays : undef;
2233
    my $unit     = $issuing_rule ? $issuing_rule->lengthunit : undef;
2233
    my $unit     = $issuing_rule ? $issuing_rule->lengthunit : undef;
2234
    my $chargeable_units = C4::Overdues::get_chargeable_units($unit, $dt_due, $return_date, $branchcode);
2235
2234
2236
    if ($finedays) {
2235
    if ($finedays) {
2237
2236
2238
        # finedays is in days, so hourly loans must multiply by 24
2239
        # thus 1 hour late equals 1 day suspension * finedays rate
2240
        $finedays = $finedays * 24 if ( $unit eq 'hours' );
2241
2242
        # grace period is measured in the same units as the loan
2237
        # grace period is measured in the same units as the loan
2243
        my $grace =
2238
        my $grace =
2244
          DateTime::Duration->new( $unit => $issuing_rule->firstremind );
2239
          DateTime::Duration->new( $unit => $issuing_rule->firstremind );
2245
2240
2246
        my $deltadays = DateTime::Duration->new(
2241
        my $deltadays = C4::Overdues::get_chargeable_units('days', $dt_due, $return_date, $branchcode);
2247
            days => $chargeable_units
2242
        $deltadays = DateTime::Duration->new(
2243
            days => $deltadays,
2248
        );
2244
        );
2245
2249
        if ( $deltadays->subtract($grace)->is_positive() ) {
2246
        if ( $deltadays->subtract($grace)->is_positive() ) {
2250
            my $suspension_days = $deltadays * $finedays;
2247
            my $suspension_days = $deltadays * $finedays;
2251
2248
(-)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-106 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
134
106
# C4::Context->userenv
135
# C4::Context->userenv
107
- 

Return to bug 14293