|
Lines 2412-2425
subtest 'is_patron_inside_charge_limits() tests' => sub {
Link Here
|
| 2412 |
)->store; |
2412 |
)->store; |
| 2413 |
|
2413 |
|
| 2414 |
my $patron_borrowing_status; |
2414 |
my $patron_borrowing_status; |
| 2415 |
$patron_borrowing_status = $patron->is_patron_inside_charge_limits( { patron => $patron } ); |
2415 |
$patron_borrowing_status = $patron->is_patron_inside_charge_limits(); |
| 2416 |
|
2416 |
|
| 2417 |
is( $patron_borrowing_status->{noissuescharge}->{charge}, 11, "Only patron's fines are reported in total" ); |
2417 |
is( $patron_borrowing_status->{noissuescharge}->{charge}, 11, "Only patron's fines are reported in total" ); |
| 2418 |
is( $patron_borrowing_status->{noissuescharge}->{limit}, 10, "Limit correctly identified at category level" ); |
2418 |
is( $patron_borrowing_status->{noissuescharge}->{limit}, 10, "Limit correctly identified at category level" ); |
| 2419 |
is( $patron_borrowing_status->{noissuescharge}->{overlimit}, 1, "Patron is over the charge limit" ); |
2419 |
is( $patron_borrowing_status->{noissuescharge}->{overlimit}, 1, "Patron is over the charge limit" ); |
| 2420 |
|
2420 |
|
| 2421 |
$patron->category->noissuescharge(undef); |
2421 |
$patron->category->noissuescharge(undef); |
| 2422 |
$patron_borrowing_status = $patron->is_patron_inside_charge_limits( { patron => $patron } ); |
2422 |
$patron_borrowing_status = $patron->is_patron_inside_charge_limits(); |
| 2423 |
is( $patron_borrowing_status->{noissuescharge}->{limit}, 50, "Limit correctly identified at global syspref level" ); |
2423 |
is( $patron_borrowing_status->{noissuescharge}->{limit}, 50, "Limit correctly identified at global syspref level" ); |
| 2424 |
is( $patron_borrowing_status->{noissuescharge}->{charge}, 11, "Charges correctly identified" ); |
2424 |
is( $patron_borrowing_status->{noissuescharge}->{charge}, 11, "Charges correctly identified" ); |
| 2425 |
is( $patron_borrowing_status->{noissuescharge}->{overlimit}, 0, "Patron is within the charge limit" ); |
2425 |
is( $patron_borrowing_status->{noissuescharge}->{overlimit}, 0, "Patron is within the charge limit" ); |
|
Lines 2432-2438
subtest 'is_patron_inside_charge_limits() tests' => sub {
Link Here
|
| 2432 |
is( $patron_borrowing_status->{NoIssuesChargeGuarantees}->{overlimit}, 1, "Patron is over the charge limit" ); |
2432 |
is( $patron_borrowing_status->{NoIssuesChargeGuarantees}->{overlimit}, 1, "Patron is over the charge limit" ); |
| 2433 |
|
2433 |
|
| 2434 |
$patron->category->noissueschargeguarantees(12); |
2434 |
$patron->category->noissueschargeguarantees(12); |
| 2435 |
$patron_borrowing_status = $patron->is_patron_inside_charge_limits( { patron => $patron } ); |
2435 |
$patron_borrowing_status = $patron->is_patron_inside_charge_limits(); |
| 2436 |
is( |
2436 |
is( |
| 2437 |
$patron_borrowing_status->{NoIssuesChargeGuarantees}->{limit}, 12, |
2437 |
$patron_borrowing_status->{NoIssuesChargeGuarantees}->{limit}, 12, |
| 2438 |
"Limit correctly identified at patron category level" |
2438 |
"Limit correctly identified at patron category level" |
|
Lines 2441-2452
subtest 'is_patron_inside_charge_limits() tests' => sub {
Link Here
|
| 2441 |
is( $patron_borrowing_status->{NoIssuesChargeGuarantees}->{overlimit}, 0, "Patron is inside the charge limit" ); |
2441 |
is( $patron_borrowing_status->{NoIssuesChargeGuarantees}->{overlimit}, 0, "Patron is inside the charge limit" ); |
| 2442 |
|
2442 |
|
| 2443 |
is( |
2443 |
is( |
| 2444 |
$patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{limit}, 0, |
2444 |
$patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{limit}, undef, |
| 2445 |
"Limit correctly identified as not set at either patron category or global syspref level" |
2445 |
"Limit correctly identified as not set at either patron category or global syspref level" |
| 2446 |
); |
2446 |
); |
| 2447 |
is( |
2447 |
is( |
| 2448 |
$patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{charge}, 22.22, |
2448 |
$patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{charge}, 0, |
| 2449 |
"Charges correctly identified" |
2449 |
"Charges ignored as there is no limit set at either patron category or global syspref level" |
| 2450 |
); |
2450 |
); |
| 2451 |
is( |
2451 |
is( |
| 2452 |
$patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{overlimit}, 0, |
2452 |
$patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{overlimit}, 0, |
|
Lines 2455-2461
subtest 'is_patron_inside_charge_limits() tests' => sub {
Link Here
|
| 2455 |
|
2455 |
|
| 2456 |
$patron->category->noissueschargeguarantorswithguarantees(23); |
2456 |
$patron->category->noissueschargeguarantorswithguarantees(23); |
| 2457 |
t::lib::Mocks::mock_preference( 'NoIssuesChargeGuarantorsWithGuarantees', 20 ); |
2457 |
t::lib::Mocks::mock_preference( 'NoIssuesChargeGuarantorsWithGuarantees', 20 ); |
| 2458 |
$patron_borrowing_status = $patron->is_patron_inside_charge_limits( { patron => $patron } ); |
2458 |
$patron_borrowing_status = $patron->is_patron_inside_charge_limits(); |
| 2459 |
is( |
2459 |
is( |
| 2460 |
$patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{limit}, 23, |
2460 |
$patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{limit}, 23, |
| 2461 |
"Limit correctly identified at patron category level" |
2461 |
"Limit correctly identified at patron category level" |
|
Lines 2470-2477
subtest 'is_patron_inside_charge_limits() tests' => sub {
Link Here
|
| 2470 |
); |
2470 |
); |
| 2471 |
|
2471 |
|
| 2472 |
$patron->category->noissueschargeguarantorswithguarantees(undef); |
2472 |
$patron->category->noissueschargeguarantorswithguarantees(undef); |
| 2473 |
t::lib::Mocks::mock_preference( 'NoIssuesChargeGuarantorsWithGuarantees', 20 ); |
2473 |
$patron_borrowing_status = $patron->is_patron_inside_charge_limits(); |
| 2474 |
$patron_borrowing_status = $patron->is_patron_inside_charge_limits( { patron => $patron } ); |
|
|
| 2475 |
is( |
2474 |
is( |
| 2476 |
$patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{limit}, 20, |
2475 |
$patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{limit}, 20, |
| 2477 |
"Limit correctly defaults to global syspref" |
2476 |
"Limit correctly defaults to global syspref" |
|
Lines 2482-2488
subtest 'is_patron_inside_charge_limits() tests' => sub {
Link Here
|
| 2482 |
); |
2481 |
); |
| 2483 |
is( |
2482 |
is( |
| 2484 |
$patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{overlimit}, 1, |
2483 |
$patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{overlimit}, 1, |
| 2485 |
"Patron is inside the charge limit" |
2484 |
"Patron is over the charge limit" |
| 2486 |
); |
2485 |
); |
| 2487 |
|
2486 |
|
| 2488 |
$schema->storage->txn_rollback; |
2487 |
$schema->storage->txn_rollback; |