|
Lines 18-24
Link Here
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
use utf8; |
19 |
use utf8; |
| 20 |
|
20 |
|
| 21 |
use Test::More tests => 123; |
21 |
use Test::More tests => 40; |
|
|
22 |
use Test::MockModule; |
| 22 |
|
23 |
|
| 23 |
use Data::Dumper; |
24 |
use Data::Dumper; |
| 24 |
use DateTime; |
25 |
use DateTime; |
|
Lines 43-48
use Koha::Subscriptions;
Link Here
|
| 43 |
use Koha::Account::Lines; |
44 |
use Koha::Account::Lines; |
| 44 |
use Koha::Account::Offsets; |
45 |
use Koha::Account::Offsets; |
| 45 |
|
46 |
|
|
|
47 |
sub set_userenv { |
| 48 |
my ( $library ) = @_; |
| 49 |
t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} }); |
| 50 |
} |
| 51 |
|
| 52 |
sub str { |
| 53 |
my ( $error, $question, $alert ) = @_; |
| 54 |
my $s; |
| 55 |
$s = %$error ? ' (error: ' . join( ' ', keys %$error ) . ')' : ''; |
| 56 |
$s .= %$question ? ' (question: ' . join( ' ', keys %$question ) . ')' : ''; |
| 57 |
$s .= %$alert ? ' (alert: ' . join( ' ', keys %$alert ) . ')' : ''; |
| 58 |
return $s; |
| 59 |
} |
| 60 |
|
| 61 |
sub test_debarment_on_checkout { |
| 62 |
my ($params) = @_; |
| 63 |
my $item = $params->{item}; |
| 64 |
my $library = $params->{library}; |
| 65 |
my $patron = $params->{patron}; |
| 66 |
my $due_date = $params->{due_date} || dt_from_string; |
| 67 |
my $return_date = $params->{return_date} || dt_from_string; |
| 68 |
my $expected_expiration_date = $params->{expiration_date}; |
| 69 |
|
| 70 |
$expected_expiration_date = output_pref( |
| 71 |
{ |
| 72 |
dt => $expected_expiration_date, |
| 73 |
dateformat => 'sql', |
| 74 |
dateonly => 1, |
| 75 |
} |
| 76 |
); |
| 77 |
my @caller = caller; |
| 78 |
my $line_number = $caller[2]; |
| 79 |
AddIssue( $patron, $item->{barcode}, $due_date ); |
| 80 |
|
| 81 |
my ( undef, $message ) = AddReturn( $item->{barcode}, $library->{branchcode}, undef, undef, $return_date ); |
| 82 |
is( $message->{WasReturned} && exists $message->{Debarred}, 1, 'AddReturn must have debarred the patron' ) |
| 83 |
or diag('AddReturn returned message ' . Dumper $message ); |
| 84 |
my $debarments = Koha::Patron::Debarments::GetDebarments( |
| 85 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
| 86 |
is( scalar(@$debarments), 1, 'Test at line ' . $line_number ); |
| 87 |
|
| 88 |
is( $debarments->[0]->{expiration}, |
| 89 |
$expected_expiration_date, 'Test at line ' . $line_number ); |
| 90 |
Koha::Patron::Debarments::DelUniqueDebarment( |
| 91 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
| 92 |
}; |
| 93 |
|
| 46 |
my $schema = Koha::Database->schema; |
94 |
my $schema = Koha::Database->schema; |
| 47 |
$schema->storage->txn_begin; |
95 |
$schema->storage->txn_begin; |
| 48 |
my $builder = t::lib::TestBuilder->new; |
96 |
my $builder = t::lib::TestBuilder->new; |
|
Lines 214-221
$dbh->do(
Link Here
|
| 214 |
); |
262 |
); |
| 215 |
|
263 |
|
| 216 |
my ( $reused_itemnumber_1, $reused_itemnumber_2 ); |
264 |
my ( $reused_itemnumber_1, $reused_itemnumber_2 ); |
| 217 |
{ |
265 |
subtest "CanBookBeRenewed tests" => sub { |
| 218 |
# CanBookBeRenewed tests |
266 |
plan tests => 68; |
|
|
267 |
|
| 219 |
C4::Context->set_preference('ItemsDeniedRenewal',''); |
268 |
C4::Context->set_preference('ItemsDeniedRenewal',''); |
| 220 |
# Generate test biblio |
269 |
# Generate test biblio |
| 221 |
my $biblio = $builder->build_sample_biblio(); |
270 |
my $biblio = $builder->build_sample_biblio(); |
|
Lines 485-491
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
| 485 |
is ($new_log_size, $old_log_size + 1, 'renew log successfully added'); |
534 |
is ($new_log_size, $old_log_size + 1, 'renew log successfully added'); |
| 486 |
|
535 |
|
| 487 |
my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } ); |
536 |
my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } ); |
| 488 |
is( $fines->count, 2 ); |
537 |
is( $fines->count, 2, 'AddRenewal left both fines' ); |
| 489 |
is( $fines->next->accounttype, 'F', 'Fine on renewed item is closed out properly' ); |
538 |
is( $fines->next->accounttype, 'F', 'Fine on renewed item is closed out properly' ); |
| 490 |
is( $fines->next->accounttype, 'F', 'Fine on renewed item is closed out properly' ); |
539 |
is( $fines->next->accounttype, 'F', 'Fine on renewed item is closed out properly' ); |
| 491 |
$fines->delete(); |
540 |
$fines->delete(); |
|
Lines 883-892
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
| 883 |
LostItem( $item_3->itemnumber, 'test', 0 ); |
932 |
LostItem( $item_3->itemnumber, 'test', 0 ); |
| 884 |
my $accountline = Koha::Account::Lines->find( { itemnumber => $item_3->itemnumber } ); |
933 |
my $accountline = Koha::Account::Lines->find( { itemnumber => $item_3->itemnumber } ); |
| 885 |
is( $accountline->issue_id, $checkout->id, "Issue id added for lost replacement fee charge" ); |
934 |
is( $accountline->issue_id, $checkout->id, "Issue id added for lost replacement fee charge" ); |
| 886 |
} |
935 |
}; |
|
|
936 |
|
| 937 |
subtest "GetUpcomingDueIssues" => sub { |
| 938 |
plan tests => 12; |
| 887 |
|
939 |
|
| 888 |
{ |
|
|
| 889 |
# GetUpcomingDueIssues tests |
| 890 |
my $branch = $library2->{branchcode}; |
940 |
my $branch = $library2->{branchcode}; |
| 891 |
|
941 |
|
| 892 |
#Create another record |
942 |
#Create another record |
|
Lines 964-972
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
| 964 |
$upcoming_dues = C4::Circulation::GetUpcomingDueIssues(); |
1014 |
$upcoming_dues = C4::Circulation::GetUpcomingDueIssues(); |
| 965 |
is ( scalar ( @$upcoming_dues), 2, "days_in_advance is 7 in GetUpcomingDueIssues if not provided" ); |
1015 |
is ( scalar ( @$upcoming_dues), 2, "days_in_advance is 7 in GetUpcomingDueIssues if not provided" ); |
| 966 |
|
1016 |
|
| 967 |
} |
1017 |
}; |
| 968 |
|
1018 |
|
| 969 |
{ |
1019 |
subtest "Bug 13841 - Do not create new 0 amount fines" => sub { |
| 970 |
my $branch = $library2->{branchcode}; |
1020 |
my $branch = $library2->{branchcode}; |
| 971 |
|
1021 |
|
| 972 |
my $biblio = $builder->build_sample_biblio(); |
1022 |
my $biblio = $builder->build_sample_biblio(); |
|
Lines 1006-1014
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
| 1006 |
my $count = $hr->{count}; |
1056 |
my $count = $hr->{count}; |
| 1007 |
|
1057 |
|
| 1008 |
is ( $count, 0, "Calling UpdateFine on non-existant fine with an amount of 0 does not result in an empty fine" ); |
1058 |
is ( $count, 0, "Calling UpdateFine on non-existant fine with an amount of 0 does not result in an empty fine" ); |
| 1009 |
} |
1059 |
}; |
| 1010 |
|
1060 |
|
| 1011 |
{ |
1061 |
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { |
| 1012 |
$dbh->do('DELETE FROM issues'); |
1062 |
$dbh->do('DELETE FROM issues'); |
| 1013 |
$dbh->do('DELETE FROM items'); |
1063 |
$dbh->do('DELETE FROM items'); |
| 1014 |
$dbh->do('DELETE FROM issuingrules'); |
1064 |
$dbh->do('DELETE FROM issuingrules'); |
|
Lines 1094-1100
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
| 1094 |
|
1144 |
|
| 1095 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1145 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
| 1096 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower can not renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled but the only available item is notforloan' ); |
1146 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower can not renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled but the only available item is notforloan' ); |
| 1097 |
} |
1147 |
}; |
| 1098 |
|
1148 |
|
| 1099 |
{ |
1149 |
{ |
| 1100 |
# Don't allow renewing onsite checkout |
1150 |
# Don't allow renewing onsite checkout |
|
Lines 1218-1224
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
| 1218 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1268 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
| 1219 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1269 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
| 1220 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1270 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
| 1221 |
is( $error->{branch_to_return}, $holdingbranch->{branchcode} ); |
1271 |
is( $error->{branch_to_return}, $holdingbranch->{branchcode}, 'branch_to_return matched holdingbranch' ); |
| 1222 |
## Can be issued from holdinbranch |
1272 |
## Can be issued from holdinbranch |
| 1223 |
set_userenv($holdingbranch); |
1273 |
set_userenv($holdingbranch); |
| 1224 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1274 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
|
Lines 1229-1235
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
| 1229 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1279 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
| 1230 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1280 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
| 1231 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1281 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
| 1232 |
is( $error->{branch_to_return}, $holdingbranch->{branchcode} ); |
1282 |
is( $error->{branch_to_return}, $holdingbranch->{branchcode}, 'branch_to_return matches holdingbranch' ); |
| 1233 |
|
1283 |
|
| 1234 |
# AllowReturnToBranch == homebranch |
1284 |
# AllowReturnToBranch == homebranch |
| 1235 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' ); |
1285 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' ); |
|
Lines 1243-1255
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
| 1243 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1293 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
| 1244 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1294 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
| 1245 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1295 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
| 1246 |
is( $error->{branch_to_return}, $homebranch->{branchcode} ); |
1296 |
is( $error->{branch_to_return}, $homebranch->{branchcode}, 'branch_to_return matches homebranch' ); |
| 1247 |
## Cannot be issued from holdinbranch |
1297 |
## Cannot be issued from holdinbranch |
| 1248 |
set_userenv($otherbranch); |
1298 |
set_userenv($otherbranch); |
| 1249 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
1299 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); |
| 1250 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
1300 |
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); |
| 1251 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
1301 |
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); |
| 1252 |
is( $error->{branch_to_return}, $homebranch->{branchcode} ); |
1302 |
is( $error->{branch_to_return}, $homebranch->{branchcode}, 'branch_to_return matches homebranch' ); |
| 1253 |
|
1303 |
|
| 1254 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
1304 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
| 1255 |
}; |
1305 |
}; |
|
Lines 1288-1329
subtest 'AddIssue & AllowReturnToBranch' => sub {
Link Here
|
| 1288 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); |
1338 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); |
| 1289 |
## Can be issued from homebranch |
1339 |
## Can be issued from homebranch |
| 1290 |
set_userenv($homebranch); |
1340 |
set_userenv($homebranch); |
| 1291 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue ); |
1341 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from homebranch'); |
| 1292 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1342 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
| 1293 |
## Can be issued from holdinbranch |
1343 |
## Can be issued from holdinbranch |
| 1294 |
set_userenv($holdingbranch); |
1344 |
set_userenv($holdingbranch); |
| 1295 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue ); |
1345 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from holdingbranch'); |
| 1296 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1346 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
| 1297 |
## Can be issued from another branch |
1347 |
## Can be issued from another branch |
| 1298 |
set_userenv($otherbranch); |
1348 |
set_userenv($otherbranch); |
| 1299 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue ); |
1349 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from otherbranch'); |
| 1300 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1350 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
| 1301 |
|
1351 |
|
| 1302 |
# AllowReturnToBranch == holdinbranch |
1352 |
# AllowReturnToBranch == holdinbranch |
| 1303 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'holdingbranch' ); |
1353 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'holdingbranch' ); |
| 1304 |
## Cannot be issued from homebranch |
1354 |
## Cannot be issued from homebranch |
| 1305 |
set_userenv($homebranch); |
1355 |
set_userenv($homebranch); |
| 1306 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '' ); |
1356 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - holdingbranch | Cannot be issued from homebranch'); |
| 1307 |
## Can be issued from holdingbranch |
1357 |
## Can be issued from holdingbranch |
| 1308 |
set_userenv($holdingbranch); |
1358 |
set_userenv($holdingbranch); |
| 1309 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue ); |
1359 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - holdingbranch | Can be issued from holdingbranch'); |
| 1310 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1360 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
| 1311 |
## Cannot be issued from another branch |
1361 |
## Cannot be issued from another branch |
| 1312 |
set_userenv($otherbranch); |
1362 |
set_userenv($otherbranch); |
| 1313 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '' ); |
1363 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - holdingbranch | Cannot be issued from otherbranch'); |
| 1314 |
|
1364 |
|
| 1315 |
# AllowReturnToBranch == homebranch |
1365 |
# AllowReturnToBranch == homebranch |
| 1316 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' ); |
1366 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' ); |
| 1317 |
## Can be issued from homebranch |
1367 |
## Can be issued from homebranch |
| 1318 |
set_userenv($homebranch); |
1368 |
set_userenv($homebranch); |
| 1319 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue ); |
1369 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - homebranch | Can be issued from homebranch' ); |
| 1320 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
1370 |
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue |
| 1321 |
## Cannot be issued from holdinbranch |
1371 |
## Cannot be issued from holdinbranch |
| 1322 |
set_userenv($holdingbranch); |
1372 |
set_userenv($holdingbranch); |
| 1323 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '' ); |
1373 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - homebranch | Cannot be issued from holdingbranch' ); |
| 1324 |
## Cannot be issued from another branch |
1374 |
## Cannot be issued from another branch |
| 1325 |
set_userenv($otherbranch); |
1375 |
set_userenv($otherbranch); |
| 1326 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '' ); |
1376 |
is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - homebranch | Cannot be issued from otherbranch' ); |
| 1327 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
1377 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
| 1328 |
}; |
1378 |
}; |
| 1329 |
|
1379 |
|
|
Lines 2772-2786
subtest 'AddReturn should clear items.onloan for unissued items' => sub {
Link Here
|
| 2772 |
is( $item->onloan, undef, 'AddReturn did clear items.onloan' ); |
2822 |
is( $item->onloan, undef, 'AddReturn did clear items.onloan' ); |
| 2773 |
}; |
2823 |
}; |
| 2774 |
|
2824 |
|
| 2775 |
$schema->storage->txn_rollback; |
|
|
| 2776 |
C4::Context->clear_syspref_cache(); |
| 2777 |
$cache->clear_from_cache('single_holidays'); |
| 2778 |
|
2825 |
|
| 2779 |
subtest 'AddRenewal and AddIssuingCharge tests' => sub { |
2826 |
subtest 'AddRenewal and AddIssuingCharge tests' => sub { |
| 2780 |
|
2827 |
|
| 2781 |
plan tests => 10; |
2828 |
plan tests => 10; |
| 2782 |
|
2829 |
|
| 2783 |
$schema->storage->txn_begin; |
|
|
| 2784 |
|
2830 |
|
| 2785 |
my $issuing_charges = 15; |
2831 |
my $issuing_charges = 15; |
| 2786 |
my $title = 'A title'; |
2832 |
my $title = 'A title'; |
|
Lines 2860-2873
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
| 2860 |
is( $line->accounttype, 'Rent', 'Fine on renewed item is closed out properly' ); |
2906 |
is( $line->accounttype, 'Rent', 'Fine on renewed item is closed out properly' ); |
| 2861 |
is( $line->description, "Renewal of Rental Item $title $barcode", 'AddRenewal set a hardcoded description for the accountline' ); |
2907 |
is( $line->description, "Renewal of Rental Item $title $barcode", 'AddRenewal set a hardcoded description for the accountline' ); |
| 2862 |
|
2908 |
|
| 2863 |
$schema->storage->txn_rollback; |
|
|
| 2864 |
}; |
2909 |
}; |
| 2865 |
|
2910 |
|
| 2866 |
subtest 'ProcessOfflinePayment() tests' => sub { |
2911 |
subtest 'ProcessOfflinePayment() tests' => sub { |
| 2867 |
|
2912 |
|
| 2868 |
plan tests => 3; |
2913 |
plan tests => 3; |
| 2869 |
|
2914 |
|
| 2870 |
$schema->storage->txn_begin; |
|
|
| 2871 |
|
2915 |
|
| 2872 |
my $amount = 123; |
2916 |
my $amount = 123; |
| 2873 |
|
2917 |
|
|
Lines 2883-2937
subtest 'ProcessOfflinePayment() tests' => sub {
Link Here
|
| 2883 |
my $line = $lines->next; |
2927 |
my $line = $lines->next; |
| 2884 |
is( $line->amount+0, $amount * -1, 'amount picked from params' ); |
2928 |
is( $line->amount+0, $amount * -1, 'amount picked from params' ); |
| 2885 |
|
2929 |
|
| 2886 |
$schema->storage->txn_rollback; |
|
|
| 2887 |
}; |
2930 |
}; |
| 2888 |
|
2931 |
|
| 2889 |
|
2932 |
|
| 2890 |
|
2933 |
$schema->storage->txn_rollback; |
| 2891 |
sub set_userenv { |
2934 |
C4::Context->clear_syspref_cache(); |
| 2892 |
my ( $library ) = @_; |
2935 |
$cache->clear_from_cache('single_holidays'); |
| 2893 |
t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} }); |
|
|
| 2894 |
} |
| 2895 |
|
| 2896 |
sub str { |
| 2897 |
my ( $error, $question, $alert ) = @_; |
| 2898 |
my $s; |
| 2899 |
$s = %$error ? ' (error: ' . join( ' ', keys %$error ) . ')' : ''; |
| 2900 |
$s .= %$question ? ' (question: ' . join( ' ', keys %$question ) . ')' : ''; |
| 2901 |
$s .= %$alert ? ' (alert: ' . join( ' ', keys %$alert ) . ')' : ''; |
| 2902 |
return $s; |
| 2903 |
} |
| 2904 |
|
| 2905 |
sub test_debarment_on_checkout { |
| 2906 |
my ($params) = @_; |
| 2907 |
my $item = $params->{item}; |
| 2908 |
my $library = $params->{library}; |
| 2909 |
my $patron = $params->{patron}; |
| 2910 |
my $due_date = $params->{due_date} || dt_from_string; |
| 2911 |
my $return_date = $params->{return_date} || dt_from_string; |
| 2912 |
my $expected_expiration_date = $params->{expiration_date}; |
| 2913 |
|
| 2914 |
$expected_expiration_date = output_pref( |
| 2915 |
{ |
| 2916 |
dt => $expected_expiration_date, |
| 2917 |
dateformat => 'sql', |
| 2918 |
dateonly => 1, |
| 2919 |
} |
| 2920 |
); |
| 2921 |
my @caller = caller; |
| 2922 |
my $line_number = $caller[2]; |
| 2923 |
AddIssue( $patron, $item->{barcode}, $due_date ); |
| 2924 |
|
| 2925 |
my ( undef, $message ) = AddReturn( $item->{barcode}, $library->{branchcode}, |
| 2926 |
undef, undef, $return_date ); |
| 2927 |
is( $message->{WasReturned} && exists $message->{Debarred}, 1, 'AddReturn must have debarred the patron' ) |
| 2928 |
or diag('AddReturn returned message ' . Dumper $message ); |
| 2929 |
my $debarments = Koha::Patron::Debarments::GetDebarments( |
| 2930 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
| 2931 |
is( scalar(@$debarments), 1, 'Test at line ' . $line_number ); |
| 2932 |
|
| 2933 |
is( $debarments->[0]->{expiration}, |
| 2934 |
$expected_expiration_date, 'Test at line ' . $line_number ); |
| 2935 |
Koha::Patron::Debarments::DelUniqueDebarment( |
| 2936 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
| 2937 |
} |
| 2938 |
- |
|
|