|
Lines 1352-1360
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1352 |
} |
1352 |
} |
| 1353 |
} |
1353 |
} |
| 1354 |
); |
1354 |
); |
| 1355 |
C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1'); |
1355 |
C4::Context->set_preference( 'OPACFineNoRenewalsBlockAutoRenew', '1' ); |
| 1356 |
C4::Context->set_preference('FineNoRenewals','10'); |
1356 |
C4::Context->set_preference( 'FineNoRenewals', '10' ); |
| 1357 |
C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','1'); |
1357 |
C4::Context->set_preference( 'OPACFineNoRenewalsIncludeCredit', '1' ); |
| 1358 |
my $fines_amount = 5; |
1358 |
my $fines_amount = 5; |
| 1359 |
my $account = Koha::Account->new( { patron_id => $renewing_borrowernumber } ); |
1359 |
my $account = Koha::Account->new( { patron_id => $renewing_borrowernumber } ); |
| 1360 |
$account->add_debit( |
1360 |
$account->add_debit( |
|
Lines 1366-1375
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1366 |
description => "Some fines" |
1366 |
description => "Some fines" |
| 1367 |
} |
1367 |
} |
| 1368 |
)->status('RETURNED')->store; |
1368 |
)->status('RETURNED')->store; |
| 1369 |
( $renewokay, $error ) = |
1369 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue ); |
| 1370 |
CanBookBeRenewed( $renewing_borrower_obj, $issue ); |
|
|
| 1371 |
is( $renewokay, 1, 'Renew, even if renewal is automatic' ); |
1370 |
is( $renewokay, 1, 'Renew, even if renewal is automatic' ); |
| 1372 |
is( $error, 'auto_renew', 'Can auto renew, FineNoRenewals=10, patron has 5' ); |
1371 |
is( $error, 'auto_renew', 'Can auto renew, FineNoRenewals=10, patron has 5' ); |
| 1373 |
|
1372 |
|
| 1374 |
$account->add_debit( |
1373 |
$account->add_debit( |
| 1375 |
{ |
1374 |
{ |
|
Lines 1380-1389
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1380 |
description => "Some fines" |
1379 |
description => "Some fines" |
| 1381 |
} |
1380 |
} |
| 1382 |
)->status('RETURNED')->store; |
1381 |
)->status('RETURNED')->store; |
| 1383 |
( $renewokay, $error ) = |
1382 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue ); |
| 1384 |
CanBookBeRenewed( $renewing_borrower_obj, $issue ); |
|
|
| 1385 |
is( $renewokay, 1, 'Renew, even if renewal is automatic' ); |
1383 |
is( $renewokay, 1, 'Renew, even if renewal is automatic' ); |
| 1386 |
is( $error, 'auto_renew', 'Can auto renew, FineNoRenewals=10, patron has 10' ); |
1384 |
is( $error, 'auto_renew', 'Can auto renew, FineNoRenewals=10, patron has 10' ); |
| 1387 |
|
1385 |
|
| 1388 |
$account->add_debit( |
1386 |
$account->add_debit( |
| 1389 |
{ |
1387 |
{ |
|
Lines 1394-1403
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1394 |
description => "Some fines" |
1392 |
description => "Some fines" |
| 1395 |
} |
1393 |
} |
| 1396 |
)->status('RETURNED')->store; |
1394 |
)->status('RETURNED')->store; |
| 1397 |
( $renewokay, $error ) = |
1395 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue ); |
| 1398 |
CanBookBeRenewed( $renewing_borrower_obj, $issue ); |
1396 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 1399 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1397 |
is( $error, 'auto_too_much_oweing', 'Cannot auto renew, FineNoRenewals=10, patron has 15' ); |
| 1400 |
is( $error, 'auto_too_much_oweing', 'Cannot auto renew, FineNoRenewals=10, patron has 15' ); |
|
|
| 1401 |
|
1398 |
|
| 1402 |
$account->add_credit( |
1399 |
$account->add_credit( |
| 1403 |
{ |
1400 |
{ |
|
Lines 1824-1830
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1824 |
"Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber" |
1821 |
"Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber" |
| 1825 |
); |
1822 |
); |
| 1826 |
|
1823 |
|
| 1827 |
t::lib::Mocks::mock_preference('FineNoRenewals', 0); |
1824 |
t::lib::Mocks::mock_preference( 'FineNoRenewals', 0 ); |
| 1828 |
|
1825 |
|
| 1829 |
# Recalls |
1826 |
# Recalls |
| 1830 |
t::lib::Mocks::mock_preference( 'UseRecalls', 1 ); |
1827 |
t::lib::Mocks::mock_preference( 'UseRecalls', 1 ); |
|
Lines 1904-1913
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1904 |
$recall->set_cancelled; |
1901 |
$recall->set_cancelled; |
| 1905 |
|
1902 |
|
| 1906 |
# Too much debt |
1903 |
# Too much debt |
| 1907 |
t::lib::Mocks::mock_preference('FineNoRenewals', 1); |
1904 |
t::lib::Mocks::mock_preference( 'FineNoRenewals', 1 ); |
| 1908 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1); |
1905 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_1 ); |
| 1909 |
is( $renewokay, 0, 'Cannot renew, too much debt and FineNoRenewals=1' ); |
1906 |
is( $renewokay, 0, 'Cannot renew, too much debt and FineNoRenewals=1' ); |
| 1910 |
is( $error, 'too_much_oweing', 'Cannot renew, debt not allowed (returned code is too_much_oweing)'); |
1907 |
is( $error, 'too_much_oweing', 'Cannot renew, debt not allowed (returned code is too_much_oweing)' ); |
| 1911 |
C4::Context->dbh->do("DELETE FROM accountlines"); |
1908 |
C4::Context->dbh->do("DELETE FROM accountlines"); |
| 1912 |
}; |
1909 |
}; |
| 1913 |
|
1910 |
|
| 1914 |
- |
|
|