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

(-)a/C4/Circulation.pm (-2 / +3 lines)
Lines 2250-2255 sub _debar_user_on_return { Link Here
2250
                'lengthunit',
2250
                'lengthunit',
2251
                'firstremind',
2251
                'firstremind',
2252
                'maxsuspensiondays',
2252
                'maxsuspensiondays',
2253
                'suspension_chargeperiod',
2253
            ]
2254
            ]
2254
        }
2255
        }
2255
    );
2256
    );
Lines 2291-2300 sub _debar_user_on_return { Link Here
2291
                }
2292
                }
2292
            }
2293
            }
2293
2294
2294
            if ( $issuing_rule->suspension_chargeperiod > 1 ) {
2295
            if ( $issuing_rule->{suspension_chargeperiod} > 1 ) {
2295
                # No need to / 1 and do not consider / 0
2296
                # No need to / 1 and do not consider / 0
2296
                $suspension_days = DateTime::Duration->new(
2297
                $suspension_days = DateTime::Duration->new(
2297
                    days => floor( $suspension_days->in_units('days') / $issuing_rule->suspension_chargeperiod )
2298
                    days => floor( $suspension_days->in_units('days') / $issuing_rule->{suspension_chargeperiod} )
2298
                );
2299
                );
2299
            }
2300
            }
2300
2301
(-)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 2089-2095 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2089
2089
2090
    # We want to charge 2 days every 2 days, without grace
2090
    # We want to charge 2 days every 2 days, without grace
2091
    # With 5 days of overdue: (5 * 2) / 2
2091
    # With 5 days of overdue: (5 * 2) / 2
2092
    $rule->suspension_chargeperiod(2)->store;
2092
    Koha::CirculationRules->set_rule(
2093
        {
2094
            categorycode => undef,
2095
            branchcode   => undef,
2096
            itemtype     => undef,
2097
            rule_name    => 'suspension_chargeperiod',
2098
            rule_value   => '2',
2099
        }
2100
    );
2101
2093
    $expected_expiration = dt_from_string->add( days => floor( 5 * 2 ) / 2 );
2102
    $expected_expiration = dt_from_string->add( days => floor( 5 * 2 ) / 2 );
2094
    test_debarment_on_checkout(
2103
    test_debarment_on_checkout(
2095
        {
2104
        {
Lines 2103-2110 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2103
2112
2104
    # We want to charge 2 days every 3 days, with 1 day of grace
2113
    # We want to charge 2 days every 3 days, with 1 day of grace
2105
    # With 5 days of overdue: ((5-1) / 3 ) * 2
2114
    # With 5 days of overdue: ((5-1) / 3 ) * 2
2106
    $rule->suspension_chargeperiod(3)->store;
2115
    Koha::CirculationRules->set_rules(
2107
    $rule->firstremind(1)->store;
2116
        {
2117
            categorycode => undef,
2118
            branchcode   => undef,
2119
            itemtype     => undef,
2120
            rules        => {
2121
                suspension_chargeperiod => 3,
2122
                firstremind             => 1,
2123
            }
2124
        }
2125
    );
2108
    $expected_expiration = dt_from_string->add( days => floor( ( ( 5 - 1 ) / 3 ) * 2 ) );
2126
    $expected_expiration = dt_from_string->add( days => floor( ( ( 5 - 1 ) / 3 ) * 2 ) );
2109
    test_debarment_on_checkout(
2127
    test_debarment_on_checkout(
2110
        {
2128
        {
Lines 2118-2126 subtest 'AddReturn + suspension_chargeperiod' => sub { Link Here
2118
2136
2119
    # Use finesCalendar to know if holiday must be skipped to calculate the due date
2137
    # Use finesCalendar to know if holiday must be skipped to calculate the due date
2120
    # We want to charge 2 days every days, with 0 day of grace (to not burn brains)
2138
    # We want to charge 2 days every days, with 0 day of grace (to not burn brains)
2121
    $rule->finedays(2)->store;
2139
    Koha::CirculationRules->set_rules(
2122
    $rule->suspension_chargeperiod(1)->store;
2140
        {
2123
    $rule->firstremind(0)->store;
2141
            categorycode => undef,
2142
            branchcode   => undef,
2143
            itemtype     => undef,
2144
            rules        => {
2145
                finedays                => 2,
2146
                suspension_chargeperiod => 1,
2147
                firstremind             => 0,
2148
            }
2149
        }
2150
    );
2124
    t::lib::Mocks::mock_preference('finesCalendar', 'noFinesWhenClosed');
2151
    t::lib::Mocks::mock_preference('finesCalendar', 'noFinesWhenClosed');
2125
2152
2126
    # Adding a holiday 2 days ago
2153
    # Adding a holiday 2 days ago
Lines 2297-2303 subtest 'AddReturn | is_overdue' => sub { Link Here
2297
    );
2324
    );
2298
2325
2299
    Koha::CirculationRules->search->delete;
2326
    Koha::CirculationRules->search->delete;
2300
    my $rule = Koha::CirculationRules->set_rules(
2327
    Koha::CirculationRules->set_rules(
2301
        {
2328
        {
2302
            categorycode => undef,
2329
            categorycode => undef,
2303
            itemtype     => undef,
2330
            itemtype     => undef,
2304
- 

Return to bug 18936