|
Lines 4-10
Link Here
|
| 4 |
# Current state is very rudimentary. Please help to extend it! |
4 |
# Current state is very rudimentary. Please help to extend it! |
| 5 |
|
5 |
|
| 6 |
use Modern::Perl; |
6 |
use Modern::Perl; |
| 7 |
use Test::More tests => 16; |
7 |
use Test::More tests => 17; |
| 8 |
|
8 |
|
| 9 |
use Koha::Database; |
9 |
use Koha::Database; |
| 10 |
use t::lib::TestBuilder; |
10 |
use t::lib::TestBuilder; |
|
Lines 439-444
subtest do_checkin => sub {
Link Here
|
| 439 |
}; |
439 |
}; |
| 440 |
}; |
440 |
}; |
| 441 |
|
441 |
|
|
|
442 |
subtest do_checkout_with_fine_override => sub { |
| 443 |
plan tests => 5; |
| 444 |
|
| 445 |
my $mockILS = Test::MockObject->new; |
| 446 |
my $server = { ils => $mockILS }; |
| 447 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 448 |
my $institution = { |
| 449 |
id => $library->id, |
| 450 |
implementation => "ILS", |
| 451 |
policy => { |
| 452 |
checkin => "true", |
| 453 |
renewal => "true", |
| 454 |
checkout => "true", |
| 455 |
timeout => 100, |
| 456 |
retries => 5, |
| 457 |
} |
| 458 |
}; |
| 459 |
my $ils = C4::SIP::ILS->new($institution); |
| 460 |
my $item = $builder->build_sample_item( |
| 461 |
{ |
| 462 |
library => $library->branchcode, |
| 463 |
} |
| 464 |
); |
| 465 |
|
| 466 |
my $fines_patron = $builder->build_object( |
| 467 |
{ |
| 468 |
class => 'Koha::Patrons', |
| 469 |
value => { |
| 470 |
branchcode => $library->branchcode, |
| 471 |
} |
| 472 |
} |
| 473 |
); |
| 474 |
my $fee1 = $builder->build( |
| 475 |
{ |
| 476 |
source => 'Accountline', |
| 477 |
value => { |
| 478 |
borrowernumber => $fines_patron->borrowernumber, |
| 479 |
amountoutstanding => 4, |
| 480 |
} |
| 481 |
} |
| 482 |
); |
| 483 |
|
| 484 |
$server->{account}->{override_fine_on_checkout} = 0; |
| 485 |
$server->{account}->{show_outstanding_amount} = 0; |
| 486 |
my $circ = $ils->checkout($fines_patron->cardnumber, $item->barcode, undef, undef, $server->{account}); |
| 487 |
is( $circ->{screen_msg}, 'Outstanding fines block issue', |
| 488 |
"Checkout is blocked when the amount is under noissuecharge and override_fine_on_checkout is disabled" ); |
| 489 |
|
| 490 |
$server->{account}->{override_fine_on_checkout} = 0; |
| 491 |
$server->{account}->{show_outstanding_amount} = 1; |
| 492 |
$circ = $ils->checkout($fines_patron->cardnumber, $item->barcode, undef, undef, $server->{account}); |
| 493 |
is( $circ->{screen_msg}, 'Outstanding fines block issue - You owe $4.00.', |
| 494 |
"Checkout is blocked and the amount is displayed when it is under noissuecharge and override_fine_on_checkout is disabled" ); |
| 495 |
|
| 496 |
$server->{account}->{override_fine_on_checkout} = 1; |
| 497 |
$server->{account}->{show_outstanding_amount} = 0; |
| 498 |
$circ = $ils->checkout($fines_patron->cardnumber, $item->barcode, undef, undef, $server->{account}); |
| 499 |
is( $circ->{screen_msg}, 'You have outstanding fines', |
| 500 |
"Checkout is allowed when the amount is under noissuecharge and override_fine_on_checkout is enabled" ); |
| 501 |
|
| 502 |
$circ = $ils->checkin( $item->barcode, C4::SIP::Sip::timestamp, undef, $library->branchcode ); |
| 503 |
|
| 504 |
$server->{account}->{override_fine_on_checkout} = 1; |
| 505 |
$server->{account}->{show_outstanding_amount} = 1; |
| 506 |
$circ = $ils->checkout($fines_patron->cardnumber, $item->barcode, undef, undef, $server->{account}); |
| 507 |
is( $circ->{screen_msg}, 'You have outstanding fines - You owe $4.00.', |
| 508 |
"Checkout is allowed and the amount is displayed when it is under noissuecharge and override_fine_on_checkout is enabled" ); |
| 509 |
|
| 510 |
$circ = $ils->checkin( $item->barcode, C4::SIP::Sip::timestamp, undef, $library->branchcode ); |
| 511 |
|
| 512 |
$fee1 = $builder->build( |
| 513 |
{ |
| 514 |
source => 'Accountline', |
| 515 |
value => { |
| 516 |
borrowernumber => $fines_patron->borrowernumber, |
| 517 |
amountoutstanding => 4, |
| 518 |
} |
| 519 |
} |
| 520 |
); |
| 521 |
|
| 522 |
$server->{account}->{override_fine_on_checkout} = 1; |
| 523 |
$server->{account}->{show_outstanding_amount} = 0; |
| 524 |
$circ = $ils->checkout($fines_patron->cardnumber, $item->barcode, undef, undef, $server->{account}); |
| 525 |
is( $circ->{screen_msg}, 'Patron has fines', |
| 526 |
"Checkout is blocked when amount is over noissuecharge and override_fine_on_checkout is enabled" ); |
| 527 |
}; |
| 528 |
|
| 442 |
subtest do_checkout_with_patron_blocked => sub { |
529 |
subtest do_checkout_with_patron_blocked => sub { |
| 443 |
plan tests => 4; |
530 |
plan tests => 4; |
| 444 |
|
531 |
|
| 445 |
- |
|
|