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

(-)a/C4/Circulation.pm (-2 / +3 lines)
Lines 2248-2253 sub _debar_user_on_return { Link Here
2248
                'lengthunit',
2248
                'lengthunit',
2249
                'firstremind',
2249
                'firstremind',
2250
                'maxsuspensiondays',
2250
                'maxsuspensiondays',
2251
                'suspension_chargeperiod',
2251
            ]
2252
            ]
2252
        }
2253
        }
2253
    );
2254
    );
Lines 2289-2298 sub _debar_user_on_return { Link Here
2289
                }
2290
                }
2290
            }
2291
            }
2291
2292
2292
            if ( $issuing_rule->suspension_chargeperiod > 1 ) {
2293
            if ( $issuing_rule->{suspension_chargeperiod} > 1 ) {
2293
                # No need to / 1 and do not consider / 0
2294
                # No need to / 1 and do not consider / 0
2294
                $suspension_days = DateTime::Duration->new(
2295
                $suspension_days = DateTime::Duration->new(
2295
                    days => floor( $suspension_days->in_units('days') / $issuing_rule->suspension_chargeperiod )
2296
                    days => floor( $suspension_days->in_units('days') / $issuing_rule->{suspension_chargeperiod} )
2296
                );
2297
                );
2297
            }
2298
            }
2298
2299
(-)a/Koha/CirculationRules.pm (+3 lines)
Lines 148-153 our $RULE_KINDS = { Link Here
148
    reservesallowed => {
148
    reservesallowed => {
149
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
149
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
150
    },
150
    },
151
    suspension_chargeperiod => {
152
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
153
    },
151
    # Not included (deprecated?):
154
    # Not included (deprecated?):
152
    #   * accountsent
155
    #   * accountsent
153
    #   * reservecharge
156
    #   * reservecharge
(-)a/t/db_dependent/Circulation.t (-8 / +34 lines)
Lines 2044-2050 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2044
2044
2045
    # We want to charge 2 days every 2 days, without grace
2045
    # We want to charge 2 days every 2 days, without grace
2046
    # With 5 days of overdue: (5 * 2) / 2
2046
    # With 5 days of overdue: (5 * 2) / 2
2047
    $rule->suspension_chargeperiod(2)->store;
2047
    Koha::CirculationRules->set_rule(
2048
        {
2049
            categorycode => undef,
2050
            branchcode   => undef,
2051
            itemtype     => undef,
2052
            rule_name    => 'suspension_chargeperiod',
2053
            rule_value   => '2',
2054
        }
2055
    );
2056
2048
    $expected_expiration = dt_from_string->add( days => floor( 5 * 2 ) / 2 );
2057
    $expected_expiration = dt_from_string->add( days => floor( 5 * 2 ) / 2 );
2049
    test_debarment_on_checkout(
2058
    test_debarment_on_checkout(
2050
        {
2059
        {
Lines 2058-2065 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2058
2067
2059
    # We want to charge 2 days every 3 days, with 1 day of grace
2068
    # We want to charge 2 days every 3 days, with 1 day of grace
2060
    # With 5 days of overdue: ((5-1) / 3 ) * 2
2069
    # With 5 days of overdue: ((5-1) / 3 ) * 2
2061
    $rule->suspension_chargeperiod(3)->store;
2070
    Koha::CirculationRules->set_rules(
2062
    $rule->firstremind(1)->store;
2071
        {
2072
            categorycode => undef,
2073
            branchcode   => undef,
2074
            itemtype     => undef,
2075
            rules        => {
2076
                suspension_chargeperiod => 3,
2077
                firstremind             => 1,
2078
            }
2079
        }
2080
    );
2063
    $expected_expiration = dt_from_string->add( days => floor( ( ( 5 - 1 ) / 3 ) * 2 ) );
2081
    $expected_expiration = dt_from_string->add( days => floor( ( ( 5 - 1 ) / 3 ) * 2 ) );
2064
    test_debarment_on_checkout(
2082
    test_debarment_on_checkout(
2065
        {
2083
        {
Lines 2073-2081 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2073
2091
2074
    # Use finesCalendar to know if holiday must be skipped to calculate the due date
2092
    # Use finesCalendar to know if holiday must be skipped to calculate the due date
2075
    # We want to charge 2 days every days, with 0 day of grace (to not burn brains)
2093
    # We want to charge 2 days every days, with 0 day of grace (to not burn brains)
2076
    $rule->finedays(2)->store;
2094
    Koha::CirculationRules->set_rules(
2077
    $rule->suspension_chargeperiod(1)->store;
2095
        {
2078
    $rule->firstremind(0)->store;
2096
            categorycode => undef,
2097
            branchcode   => undef,
2098
            itemtype     => undef,
2099
            rules        => {
2100
                finedays                => 2,
2101
                suspension_chargeperiod => 1,
2102
                firstremind             => 0,
2103
            }
2104
        }
2105
    );
2079
    t::lib::Mocks::mock_preference('finesCalendar', 'noFinesWhenClosed');
2106
    t::lib::Mocks::mock_preference('finesCalendar', 'noFinesWhenClosed');
2080
2107
2081
    # Adding a holiday 2 days ago
2108
    # Adding a holiday 2 days ago
Lines 2222-2228 subtest 'AddReturn | is_overdue' => sub { Link Here
2222
    )->unblessed;
2249
    )->unblessed;
2223
2250
2224
    Koha::CirculationRules->search->delete;
2251
    Koha::CirculationRules->search->delete;
2225
    my $rule = Koha::CirculationRules->set_rules(
2252
    Koha::CirculationRules->set_rules(
2226
        {
2253
        {
2227
            categorycode => undef,
2254
            categorycode => undef,
2228
            itemtype     => undef,
2255
            itemtype     => undef,
2229
- 

Return to bug 18936