|
Lines 2224-2230
subtest '_Findgroupreserve in the context of hold groups' => sub {
Link Here
|
| 2224 |
}; |
2224 |
}; |
| 2225 |
|
2225 |
|
| 2226 |
subtest 'calculate_hold_fee() tests' => sub { |
2226 |
subtest 'calculate_hold_fee() tests' => sub { |
| 2227 |
plan tests => 12; |
2227 |
plan tests => 13; |
| 2228 |
|
2228 |
|
| 2229 |
$schema->storage->txn_begin; |
2229 |
$schema->storage->txn_begin; |
| 2230 |
|
2230 |
|
|
Lines 2372-2388
subtest 'calculate_hold_fee() tests' => sub {
Link Here
|
| 2372 |
$fee = $title_hold->calculate_hold_fee(); |
2372 |
$fee = $title_hold->calculate_hold_fee(); |
| 2373 |
is( $fee, 3.00, 'Title-level hold: empty strategy preference defaults to highest fee (3.00)' ); |
2373 |
is( $fee, 3.00, 'Title-level hold: empty strategy preference defaults to highest fee (3.00)' ); |
| 2374 |
|
2374 |
|
| 2375 |
# Test 8: No holdable items returns 0 |
2375 |
# Test 8: No holdable items (positive notforloan, e.g. "Staff Only") returns 0 |
| 2376 |
# Make all items not holdable |
2376 |
# Positive notforloan values block both loaning and holding |
| 2377 |
$item1->notforloan(1)->store; |
2377 |
$item1->notforloan(1)->store; |
| 2378 |
$item2->notforloan(1)->store; |
2378 |
$item2->notforloan(1)->store; |
| 2379 |
$item3->notforloan(1)->store; |
2379 |
$item3->notforloan(1)->store; |
| 2380 |
$item4->notforloan(1)->store; |
2380 |
$item4->notforloan(1)->store; |
| 2381 |
|
2381 |
|
| 2382 |
$fee = $title_hold->calculate_hold_fee(); |
2382 |
$fee = $title_hold->calculate_hold_fee(); |
| 2383 |
is( $fee, 0, 'Title-level hold: no holdable items returns 0 fee' ); |
2383 |
is( $fee, 0, 'Title-level hold: all items have positive notforloan (not holdable) returns 0 fee' ); |
|
|
2384 |
|
| 2385 |
# Test 9 (new): Items with negative notforloan (e.g. "Ordered") are holdable per |
| 2386 |
# Koha convention and should have their fee included in the calculation. |
| 2387 |
# notforloan < 0 means "not for loan but holdable" (see IsAvailableForItemLevelRequest). |
| 2388 |
$item2->notforloan(-1)->store; # Fee: 3.00, on order but holdable |
| 2389 |
$item3->notforloan(-1)->store; # Fee: 2.00, on order but holdable |
| 2390 |
|
| 2391 |
t::lib::Mocks::mock_preference( 'TitleHoldFeeStrategy', 'highest' ); |
| 2392 |
$fee = $title_hold->calculate_hold_fee(); |
| 2393 |
is( $fee, 3.00, 'Title-level hold: items with negative notforloan (on order, holdable) included in fee calculation' ); |
| 2394 |
|
| 2395 |
# Restore for remaining tests |
| 2396 |
$item2->notforloan(1)->store; |
| 2397 |
$item3->notforloan(1)->store; |
| 2384 |
|
2398 |
|
| 2385 |
# Test 9: Mix of holdable and non-holdable items (highest) |
2399 |
# Test 10: Mix of holdable and non-holdable items (highest) |
| 2386 |
# Make some items holdable again |
2400 |
# Make some items holdable again |
| 2387 |
$item2->notforloan(0)->store; # Fee: 3.00 |
2401 |
$item2->notforloan(0)->store; # Fee: 3.00 |
| 2388 |
$item3->notforloan(0)->store; # Fee: 2.00 |
2402 |
$item3->notforloan(0)->store; # Fee: 2.00 |
|
Lines 2391-2402
subtest 'calculate_hold_fee() tests' => sub {
Link Here
|
| 2391 |
$fee = $title_hold->calculate_hold_fee(); |
2405 |
$fee = $title_hold->calculate_hold_fee(); |
| 2392 |
is( $fee, 3.00, 'Title-level hold: highest strategy with mixed holdable items returns 3.00' ); |
2406 |
is( $fee, 3.00, 'Title-level hold: highest strategy with mixed holdable items returns 3.00' ); |
| 2393 |
|
2407 |
|
| 2394 |
# Test 10: Mix of holdable and non-holdable items (lowest) |
2408 |
# Test 11: Mix of holdable and non-holdable items (lowest) |
| 2395 |
t::lib::Mocks::mock_preference( 'TitleHoldFeeStrategy', 'lowest' ); |
2409 |
t::lib::Mocks::mock_preference( 'TitleHoldFeeStrategy', 'lowest' ); |
| 2396 |
$fee = $title_hold->calculate_hold_fee(); |
2410 |
$fee = $title_hold->calculate_hold_fee(); |
| 2397 |
is( $fee, 2.00, 'Title-level hold: lowest strategy with mixed holdable items returns 2.00' ); |
2411 |
is( $fee, 2.00, 'Title-level hold: lowest strategy with mixed holdable items returns 2.00' ); |
| 2398 |
|
2412 |
|
| 2399 |
# Test 11: Items with 0 fee |
2413 |
# Test 12 (was 11): Items with 0 fee |
| 2400 |
my $itemtype_free = $builder->build( { source => 'Itemtype' } ); |
2414 |
my $itemtype_free = $builder->build( { source => 'Itemtype' } ); |
| 2401 |
Koha::CirculationRules->set_rules( |
2415 |
Koha::CirculationRules->set_rules( |
| 2402 |
{ |
2416 |
{ |
|
Lines 2419-2425
subtest 'calculate_hold_fee() tests' => sub {
Link Here
|
| 2419 |
$fee = $title_hold->calculate_hold_fee(); |
2433 |
$fee = $title_hold->calculate_hold_fee(); |
| 2420 |
is( $fee, 0, 'Title-level hold: lowest strategy with free item returns 0' ); |
2434 |
is( $fee, 0, 'Title-level hold: lowest strategy with free item returns 0' ); |
| 2421 |
|
2435 |
|
| 2422 |
# Test 12: All items have same fee |
2436 |
# Test 13 (was 12): All items have same fee |
| 2423 |
# Set all holdable items to same fee |
2437 |
# Set all holdable items to same fee |
| 2424 |
Koha::CirculationRules->set_rules( |
2438 |
Koha::CirculationRules->set_rules( |
| 2425 |
{ |
2439 |
{ |
| 2426 |
- |
|
|