Lines 2088-2094
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2088 |
is( scalar(@$debarments), 1 ); |
2088 |
is( scalar(@$debarments), 1 ); |
2089 |
$expected_expiration = output_pref( |
2089 |
$expected_expiration = output_pref( |
2090 |
{ |
2090 |
{ |
2091 |
dt => $now->clone->add( days => ( 5 - 1 ) * 2 + ( 10 - 1 ) * 2 ), |
2091 |
dt => $now->clone->add( days => ( 10 - 1 ) * 2 ), |
2092 |
dateformat => 'sql', |
2092 |
dateformat => 'sql', |
2093 |
dateonly => 1 |
2093 |
dateonly => 1 |
2094 |
} |
2094 |
} |
Lines 2097-2103
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2097 |
}; |
2097 |
}; |
2098 |
|
2098 |
|
2099 |
subtest 'AddReturn + suspension_chargeperiod' => sub { |
2099 |
subtest 'AddReturn + suspension_chargeperiod' => sub { |
2100 |
plan tests => 24; |
2100 |
plan tests => 26; |
2101 |
|
2101 |
|
2102 |
my $library = $builder->build( { source => 'Branch' } ); |
2102 |
my $library = $builder->build( { source => 'Branch' } ); |
2103 |
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
2103 |
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
Lines 2136-2141
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2136 |
# We want to charge 2 days every day, without grace |
2136 |
# We want to charge 2 days every day, without grace |
2137 |
# With 5 days of overdue: 5 * Z |
2137 |
# With 5 days of overdue: 5 * Z |
2138 |
my $expected_expiration = $now->clone->add( days => ( 5 * 2 ) / 1 ); |
2138 |
my $expected_expiration = $now->clone->add( days => ( 5 * 2 ) / 1 ); |
|
|
2139 |
Koha::Patron::Debarments::AddUniqueDebarment( { |
2140 |
borrowernumber => $patron->{borrowernumber}, |
2141 |
type => 'SUSPENSION', |
2142 |
expiration => $expected_expiration } ); |
2139 |
test_debarment_on_checkout( |
2143 |
test_debarment_on_checkout( |
2140 |
{ |
2144 |
{ |
2141 |
item => $item_1, |
2145 |
item => $item_1, |
Lines 2159-2164
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2159 |
); |
2163 |
); |
2160 |
|
2164 |
|
2161 |
$expected_expiration = $now->clone->add( days => floor( 5 * 2 ) / 2 ); |
2165 |
$expected_expiration = $now->clone->add( days => floor( 5 * 2 ) / 2 ); |
|
|
2166 |
Koha::Patron::Debarments::AddUniqueDebarment( { |
2167 |
borrowernumber => $patron->{borrowernumber}, |
2168 |
type => 'SUSPENSION', |
2169 |
expiration => $expected_expiration } ); |
2162 |
test_debarment_on_checkout( |
2170 |
test_debarment_on_checkout( |
2163 |
{ |
2171 |
{ |
2164 |
item => $item_1, |
2172 |
item => $item_1, |
Lines 2183-2188
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2183 |
} |
2191 |
} |
2184 |
); |
2192 |
); |
2185 |
$expected_expiration = $now->clone->add( days => floor( ( ( 5 - 1 ) / 3 ) * 2 ) ); |
2193 |
$expected_expiration = $now->clone->add( days => floor( ( ( 5 - 1 ) / 3 ) * 2 ) ); |
|
|
2194 |
Koha::Patron::Debarments::AddUniqueDebarment( { |
2195 |
borrowernumber => $patron->{borrowernumber}, |
2196 |
type => 'SUSPENSION', |
2197 |
expiration => $expected_expiration } ); |
2186 |
test_debarment_on_checkout( |
2198 |
test_debarment_on_checkout( |
2187 |
{ |
2199 |
{ |
2188 |
item => $item_1, |
2200 |
item => $item_1, |
Lines 2222-2227
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2222 |
); |
2234 |
); |
2223 |
# With 5 days of overdue, only 4 (x finedays=2) days must charged (one was an holiday) |
2235 |
# With 5 days of overdue, only 4 (x finedays=2) days must charged (one was an holiday) |
2224 |
$expected_expiration = $now->clone->add( days => floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) ); |
2236 |
$expected_expiration = $now->clone->add( days => floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) ); |
|
|
2237 |
Koha::Patron::Debarments::AddUniqueDebarment( { |
2238 |
borrowernumber => $patron->{borrowernumber}, |
2239 |
type => 'SUSPENSION', |
2240 |
expiration => $expected_expiration } ); |
2225 |
test_debarment_on_checkout( |
2241 |
test_debarment_on_checkout( |
2226 |
{ |
2242 |
{ |
2227 |
item => $item_1, |
2243 |
item => $item_1, |
Lines 2244-2249
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2244 |
|
2260 |
|
2245 |
# Same as above, but we should skip D+2 |
2261 |
# Same as above, but we should skip D+2 |
2246 |
$expected_expiration = $now->clone->add( days => floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) + 1 ); |
2262 |
$expected_expiration = $now->clone->add( days => floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) + 1 ); |
|
|
2263 |
Koha::Patron::Debarments::AddUniqueDebarment( { |
2264 |
borrowernumber => $patron->{borrowernumber}, |
2265 |
type => 'SUSPENSION', |
2266 |
expiration => $expected_expiration } ); |
2247 |
test_debarment_on_checkout( |
2267 |
test_debarment_on_checkout( |
2248 |
{ |
2268 |
{ |
2249 |
item => $item_1, |
2269 |
item => $item_1, |
Lines 2264-2269
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2264 |
description => 'holidayDesc on expiration date' |
2284 |
description => 'holidayDesc on expiration date' |
2265 |
); |
2285 |
); |
2266 |
# Expiration date will be the day after |
2286 |
# Expiration date will be the day after |
|
|
2287 |
Koha::Patron::Debarments::AddUniqueDebarment( { |
2288 |
borrowernumber => $patron->{borrowernumber}, |
2289 |
type => 'SUSPENSION', |
2290 |
expiration => $expected_expiration->clone->add( days => 1 ) } ); |
2267 |
test_debarment_on_checkout( |
2291 |
test_debarment_on_checkout( |
2268 |
{ |
2292 |
{ |
2269 |
item => $item_1, |
2293 |
item => $item_1, |
Lines 2274-2279
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2274 |
} |
2298 |
} |
2275 |
); |
2299 |
); |
2276 |
|
2300 |
|
|
|
2301 |
Koha::Patron::Debarments::AddUniqueDebarment( { |
2302 |
borrowernumber => $patron->{borrowernumber}, |
2303 |
type => 'SUSPENSION', |
2304 |
expiration => $now->clone->add(days => 5 + (5 * 2 - 1) ) } ); |
2277 |
test_debarment_on_checkout( |
2305 |
test_debarment_on_checkout( |
2278 |
{ |
2306 |
{ |
2279 |
item => $item_1, |
2307 |
item => $item_1, |
Lines 2284-2289
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2284 |
} |
2312 |
} |
2285 |
); |
2313 |
); |
2286 |
|
2314 |
|
|
|
2315 |
Koha::Patron::Debarments::AddUniqueDebarment( { |
2316 |
borrowernumber => $patron->{borrowernumber}, |
2317 |
type => 'SUSPENSION', |
2318 |
expiration => $now->clone->add(days => 5 + (4 * 2 - 1) ) } ); |
2287 |
test_debarment_on_checkout( |
2319 |
test_debarment_on_checkout( |
2288 |
{ |
2320 |
{ |
2289 |
item => $item_1, |
2321 |
item => $item_1, |
Lines 2295-2300
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2295 |
} |
2327 |
} |
2296 |
); |
2328 |
); |
2297 |
|
2329 |
|
|
|
2330 |
# Debarred message when finesdays = 0 |
2331 |
|
2332 |
Koha::CirculationRules->set_rules( |
2333 |
{ |
2334 |
categorycode => undef, |
2335 |
branchcode => undef, |
2336 |
itemtype => undef, |
2337 |
rules => { |
2338 |
finedays => 0, |
2339 |
suspension_chargeperiod => 1, |
2340 |
} |
2341 |
} |
2342 |
); |
2343 |
|
2344 |
Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber}, type => 'MANUAL', expiration => $now->clone->add(days => 10) } ); |
2345 |
|
2346 |
AddIssue( $patron, $item_1->barcode, $now->clone->add(days => 1) ); |
2347 |
|
2348 |
my ( undef, $message ) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now->clone->subtract(days => 1) ); |
2349 |
is( $message->{WasReturned} && exists $message->{PrevDebarred}, 1, 'Previously debarred message for AddReturn when not overdue' ); |
2350 |
|
2351 |
AddIssue( $patron, $item_1->barcode, $now->clone->add(days => 1) ); |
2352 |
|
2353 |
( undef, $message ) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now->clone->add(days => 5) ); |
2354 |
is( $message->{WasReturned} && exists $message->{PrevDebarred}, 1, 'Previously debarred message for AddReturn when overdue' ); |
2355 |
|
2356 |
Koha::Patron::Debarments::DelUniqueDebarment( |
2357 |
{ borrowernumber => $patron->{borrowernumber}, type => 'MANUAL' } ); |
2358 |
|
2298 |
}; |
2359 |
}; |
2299 |
|
2360 |
|
2300 |
subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub { |
2361 |
subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub { |
2301 |
- |
|
|