Lines 1199-1214
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
1199 |
my $patron_1 = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); |
1199 |
my $patron_1 = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); |
1200 |
my $patron_2 = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); |
1200 |
my $patron_2 = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); |
1201 |
|
1201 |
|
1202 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
1202 |
my $item = $builder->build_sample_item( |
1203 |
my $item = $builder->build( |
1203 |
{ |
1204 |
{ source => 'Item', |
1204 |
homebranch => $homebranch->{branchcode}, |
1205 |
value => { |
1205 |
holdingbranch => $holdingbranch->{branchcode}, |
1206 |
homebranch => $homebranch->{branchcode}, |
|
|
1207 |
holdingbranch => $holdingbranch->{branchcode}, |
1208 |
biblionumber => $biblioitem->{biblionumber} |
1209 |
} |
1210 |
} |
1206 |
} |
1211 |
); |
1207 |
)->unblessed; |
1212 |
|
1208 |
|
1213 |
set_userenv($holdingbranch); |
1209 |
set_userenv($holdingbranch); |
1214 |
|
1210 |
|
Lines 1290-1308
subtest 'AddIssue & AllowReturnToBranch' => sub {
Link Here
|
1290 |
my $patron_1 = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
1286 |
my $patron_1 = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
1291 |
my $patron_2 = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
1287 |
my $patron_2 = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
1292 |
|
1288 |
|
1293 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
1289 |
my $item = $builder->build_sample_item( |
1294 |
my $item = $builder->build( |
1290 |
{ |
1295 |
{ source => 'Item', |
1291 |
homebranch => $homebranch->{branchcode}, |
1296 |
value => { |
1292 |
holdingbranch => $holdingbranch->{branchcode}, |
1297 |
homebranch => $homebranch->{branchcode}, |
|
|
1298 |
holdingbranch => $holdingbranch->{branchcode}, |
1299 |
notforloan => 0, |
1300 |
itemlost => 0, |
1301 |
withdrawn => 0, |
1302 |
biblionumber => $biblioitem->{biblionumber} |
1303 |
} |
1304 |
} |
1293 |
} |
1305 |
); |
1294 |
)->unblessed; |
1306 |
|
1295 |
|
1307 |
set_userenv($holdingbranch); |
1296 |
set_userenv($holdingbranch); |
1308 |
|
1297 |
|
Lines 1359-1385
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
Link Here
|
1359 |
|
1348 |
|
1360 |
my $library = $builder->build( { source => 'Branch' } ); |
1349 |
my $library = $builder->build( { source => 'Branch' } ); |
1361 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); |
1350 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); |
1362 |
|
1351 |
my $item_1 = $builder->build_sample_item( |
1363 |
my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); |
1352 |
{ |
1364 |
my $item_1 = $builder->build( |
1353 |
library => $library->{branchcode}, |
1365 |
{ source => 'Item', |
|
|
1366 |
value => { |
1367 |
homebranch => $library->{branchcode}, |
1368 |
holdingbranch => $library->{branchcode}, |
1369 |
biblionumber => $biblioitem_1->{biblionumber} |
1370 |
} |
1371 |
} |
1354 |
} |
1372 |
); |
1355 |
)->unblessed; |
1373 |
my $biblioitem_2 = $builder->build( { source => 'Biblioitem' } ); |
1356 |
my $item_2 = $builder->build_sample_item( |
1374 |
my $item_2 = $builder->build( |
1357 |
{ |
1375 |
{ source => 'Item', |
1358 |
library => $library->{branchcode}, |
1376 |
value => { |
|
|
1377 |
homebranch => $library->{branchcode}, |
1378 |
holdingbranch => $library->{branchcode}, |
1379 |
biblionumber => $biblioitem_2->{biblionumber} |
1380 |
} |
1381 |
} |
1359 |
} |
1382 |
); |
1360 |
)->unblessed; |
1383 |
|
1361 |
|
1384 |
my ( $error, $question, $alerts ); |
1362 |
my ( $error, $question, $alerts ); |
1385 |
|
1363 |
|
Lines 1432-1448
subtest 'CanBookBeIssued + Statistic patrons "X"' => sub {
Link Here
|
1432 |
} |
1410 |
} |
1433 |
} |
1411 |
} |
1434 |
); |
1412 |
); |
1435 |
my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); |
1413 |
my $item_1 = $builder->build_sample_item( |
1436 |
my $item_1 = $builder->build( |
|
|
1437 |
{ |
1414 |
{ |
1438 |
source => 'Item', |
1415 |
library => $library->{branchcode}, |
1439 |
value => { |
|
|
1440 |
homebranch => $library->branchcode, |
1441 |
holdingbranch => $library->branchcode, |
1442 |
biblionumber => $biblioitem_1->{biblionumber} |
1443 |
} |
1444 |
} |
1416 |
} |
1445 |
); |
1417 |
)->unblessed; |
1446 |
|
1418 |
|
1447 |
my ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_1->{barcode} ); |
1419 |
my ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_1->{barcode} ); |
1448 |
is( $error->{STATS}, 1, '"Error" flag "STATS" must be set if CanBookBeIssued is called with a statistic patron (category_type=X)' ); |
1420 |
is( $error->{STATS}, 1, '"Error" flag "STATS" must be set if CanBookBeIssued is called with a statistic patron (category_type=X)' ); |
Lines 1548-1573
subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub {
Link Here
|
1548 |
my $library = $builder->build( { source => 'Branch' } ); |
1520 |
my $library = $builder->build( { source => 'Branch' } ); |
1549 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); |
1521 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); |
1550 |
|
1522 |
|
1551 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
1523 |
my $biblionumber = $builder->build_sample_biblio( |
1552 |
my $biblionumber = $biblioitem->{biblionumber}; |
1524 |
{ |
1553 |
my $item_1 = $builder->build( |
1525 |
branchcode => $library->{branchcode}, |
1554 |
{ source => 'Item', |
|
|
1555 |
value => { |
1556 |
homebranch => $library->{branchcode}, |
1557 |
holdingbranch => $library->{branchcode}, |
1558 |
biblionumber => $biblionumber, |
1559 |
} |
1560 |
} |
1526 |
} |
1561 |
); |
1527 |
)->biblionumber; |
1562 |
my $item_2 = $builder->build( |
1528 |
my $item_1 = $builder->build_sample_item( |
1563 |
{ source => 'Item', |
1529 |
{ |
1564 |
value => { |
1530 |
biblionumber => $biblionumber, |
1565 |
homebranch => $library->{branchcode}, |
1531 |
library => $library->{branchcode}, |
1566 |
holdingbranch => $library->{branchcode}, |
|
|
1567 |
biblionumber => $biblionumber, |
1568 |
} |
1569 |
} |
1532 |
} |
1570 |
); |
1533 |
)->unblessed; |
|
|
1534 |
|
1535 |
my $item_2 = $builder->build_sample_item( |
1536 |
{ |
1537 |
biblionumber => $biblionumber, |
1538 |
library => $library->{branchcode}, |
1539 |
} |
1540 |
)->unblessed; |
1571 |
|
1541 |
|
1572 |
my ( $error, $question, $alerts ); |
1542 |
my ( $error, $question, $alerts ); |
1573 |
my $issue = AddIssue( $patron->unblessed, $item_1->{barcode}, dt_from_string->add( days => 1 ) ); |
1543 |
my $issue = AddIssue( $patron->unblessed, $item_1->{barcode}, dt_from_string->add( days => 1 ) ); |
Lines 1600-1633
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
1600 |
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
1570 |
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
1601 |
|
1571 |
|
1602 |
# Add 2 items |
1572 |
# Add 2 items |
1603 |
my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); |
1573 |
my $biblionumber = $builder->build_sample_biblio( |
1604 |
my $item_1 = $builder->build( |
|
|
1605 |
{ |
1574 |
{ |
1606 |
source => 'Item', |
1575 |
branchcode => $library->{branchcode}, |
1607 |
value => { |
|
|
1608 |
homebranch => $library->{branchcode}, |
1609 |
holdingbranch => $library->{branchcode}, |
1610 |
notforloan => 0, |
1611 |
itemlost => 0, |
1612 |
withdrawn => 0, |
1613 |
biblionumber => $biblioitem_1->{biblionumber} |
1614 |
} |
1615 |
} |
1576 |
} |
1616 |
); |
1577 |
)->biblionumber; |
1617 |
my $biblioitem_2 = $builder->build( { source => 'Biblioitem' } ); |
1578 |
my $item_1 = $builder->build_sample_item( |
1618 |
my $item_2 = $builder->build( |
|
|
1619 |
{ |
1579 |
{ |
1620 |
source => 'Item', |
1580 |
biblionumber => $biblionumber, |
1621 |
value => { |
1581 |
library => $library->{branchcode}, |
1622 |
homebranch => $library->{branchcode}, |
|
|
1623 |
holdingbranch => $library->{branchcode}, |
1624 |
notforloan => 0, |
1625 |
itemlost => 0, |
1626 |
withdrawn => 0, |
1627 |
biblionumber => $biblioitem_2->{biblionumber} |
1628 |
} |
1629 |
} |
1582 |
} |
1630 |
); |
1583 |
)->unblessed; |
|
|
1584 |
my $item_2 = $builder->build_sample_item( |
1585 |
{ |
1586 |
biblionumber => $biblionumber, |
1587 |
library => $library->{branchcode}, |
1588 |
} |
1589 |
)->unblessed; |
1631 |
|
1590 |
|
1632 |
# And the issuing rule |
1591 |
# And the issuing rule |
1633 |
Koha::IssuingRules->search->delete; |
1592 |
Koha::IssuingRules->search->delete; |
Lines 1725-1745
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
1725 |
my $library = $builder->build( { source => 'Branch' } ); |
1684 |
my $library = $builder->build( { source => 'Branch' } ); |
1726 |
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
1685 |
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
1727 |
|
1686 |
|
1728 |
# Add 2 items |
1687 |
my $biblionumber = $builder->build_sample_biblio( |
1729 |
my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); |
|
|
1730 |
my $item_1 = $builder->build( |
1731 |
{ |
1688 |
{ |
1732 |
source => 'Item', |
1689 |
branchcode => $library->{branchcode}, |
1733 |
value => { |
|
|
1734 |
homebranch => $library->{branchcode}, |
1735 |
holdingbranch => $library->{branchcode}, |
1736 |
notforloan => 0, |
1737 |
itemlost => 0, |
1738 |
withdrawn => 0, |
1739 |
biblionumber => $biblioitem_1->{biblionumber} |
1740 |
} |
1741 |
} |
1690 |
} |
1742 |
); |
1691 |
)->biblionumber; |
|
|
1692 |
my $item_1 = $builder->build_sample_item( |
1693 |
{ |
1694 |
biblionumber => $biblionumber, |
1695 |
library => $library->{branchcode}, |
1696 |
} |
1697 |
)->unblessed; |
1743 |
|
1698 |
|
1744 |
# And the issuing rule |
1699 |
# And the issuing rule |
1745 |
Koha::IssuingRules->search->delete; |
1700 |
Koha::IssuingRules->search->delete; |
Lines 1892-1911
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
1892 |
my $library = $builder->build( { source => 'Branch' } ); |
1847 |
my $library = $builder->build( { source => 'Branch' } ); |
1893 |
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
1848 |
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
1894 |
|
1849 |
|
1895 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
1850 |
my $item = $builder->build_sample_item( |
1896 |
my $item = $builder->build( |
|
|
1897 |
{ |
1851 |
{ |
1898 |
source => 'Item', |
1852 |
library => $library->{branchcode}, |
1899 |
value => { |
|
|
1900 |
homebranch => $library->{branchcode}, |
1901 |
holdingbranch => $library->{branchcode}, |
1902 |
notforloan => 0, |
1903 |
itemlost => 0, |
1904 |
withdrawn => 0, |
1905 |
biblionumber => $biblioitem->{biblionumber}, |
1906 |
} |
1907 |
} |
1853 |
} |
1908 |
); |
1854 |
)->unblessed; |
1909 |
|
1855 |
|
1910 |
Koha::IssuingRules->search->delete; |
1856 |
Koha::IssuingRules->search->delete; |
1911 |
my $rule = Koha::IssuingRule->new( |
1857 |
my $rule = Koha::IssuingRule->new( |
Lines 2417-2442
subtest 'Set waiting flag' => sub {
Link Here
|
2417 |
my $library_2 = $builder->build( { source => 'Branch' } ); |
2363 |
my $library_2 = $builder->build( { source => 'Branch' } ); |
2418 |
my $patron_2 = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode}, categorycode => $patron_category->{categorycode} } } ); |
2364 |
my $patron_2 = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode}, categorycode => $patron_category->{categorycode} } } ); |
2419 |
|
2365 |
|
2420 |
my $biblio = $builder->build( { source => 'Biblio' } ); |
2366 |
my $item = $builder->build_sample_item( |
2421 |
my $biblioitem = $builder->build( { source => 'Biblioitem', value => { biblionumber => $biblio->{biblionumber} } } ); |
|
|
2422 |
|
2423 |
my $item = $builder->build( |
2424 |
{ |
2367 |
{ |
2425 |
source => 'Item', |
2368 |
library => $library_1->{branchcode}, |
2426 |
value => { |
|
|
2427 |
homebranch => $library_1->{branchcode}, |
2428 |
holdingbranch => $library_1->{branchcode}, |
2429 |
notforloan => 0, |
2430 |
itemlost => 0, |
2431 |
withdrawn => 0, |
2432 |
biblionumber => $biblioitem->{biblionumber}, |
2433 |
} |
2434 |
} |
2369 |
} |
2435 |
); |
2370 |
)->unblessed; |
2436 |
|
2371 |
|
2437 |
set_userenv( $library_2 ); |
2372 |
set_userenv( $library_2 ); |
2438 |
my $reserve_id = AddReserve( |
2373 |
my $reserve_id = AddReserve( |
2439 |
$library_2->{branchcode}, $patron_2->{borrowernumber}, $biblioitem->{biblionumber}, |
2374 |
$library_2->{branchcode}, $patron_2->{borrowernumber}, $item->{biblionumber}, |
2440 |
'', 1, undef, undef, '', undef, $item->{itemnumber}, |
2375 |
'', 1, undef, undef, '', undef, $item->{itemnumber}, |
2441 |
); |
2376 |
); |
2442 |
|
2377 |
|
Lines 2542-2561
subtest 'CanBookBeIssued | is_overdue' => sub {
Link Here
|
2542 |
my $library = $builder->build( { source => 'Branch' } ); |
2477 |
my $library = $builder->build( { source => 'Branch' } ); |
2543 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); |
2478 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); |
2544 |
|
2479 |
|
2545 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
2480 |
my $item = $builder->build_sample_item( |
2546 |
my $item = $builder->build( |
|
|
2547 |
{ |
2481 |
{ |
2548 |
source => 'Item', |
2482 |
library => $library->{branchcode}, |
2549 |
value => { |
|
|
2550 |
homebranch => $library->{branchcode}, |
2551 |
holdingbranch => $library->{branchcode}, |
2552 |
notforloan => 0, |
2553 |
itemlost => 0, |
2554 |
withdrawn => 0, |
2555 |
biblionumber => $biblioitem->{biblionumber}, |
2556 |
} |
2557 |
} |
2483 |
} |
2558 |
); |
2484 |
)->unblessed; |
2559 |
|
2485 |
|
2560 |
my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $five_days_go ); # date due was 10d ago |
2486 |
my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $five_days_go ); # date due was 10d ago |
2561 |
my $actualissue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); |
2487 |
my $actualissue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); |
Lines 2700-2728
subtest 'CanBookBeIssued | item-level_itypes=biblio' => sub {
Link Here
|
2700 |
my $library = $builder->build( { source => 'Branch' } ); |
2626 |
my $library = $builder->build( { source => 'Branch' } ); |
2701 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } )->store; |
2627 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } )->store; |
2702 |
|
2628 |
|
2703 |
my $itemtype = $builder->build( |
2629 |
my $item = $builder->build_sample_item( |
2704 |
{ |
2630 |
{ |
2705 |
source => 'Itemtype', |
2631 |
library => $library->{branchcode}, |
2706 |
value => { notforloan => undef, } |
|
|
2707 |
} |
2632 |
} |
2708 |
); |
2633 |
); |
2709 |
|
2634 |
|
2710 |
my $biblioitem = $builder->build( { source => 'Biblioitem', value => { itemtype => $itemtype->{itemtype} } } ); |
|
|
2711 |
my $item = $builder->build_object( |
2712 |
{ |
2713 |
class => 'Koha::Items', |
2714 |
value => { |
2715 |
homebranch => $library->{branchcode}, |
2716 |
holdingbranch => $library->{branchcode}, |
2717 |
notforloan => 0, |
2718 |
itemlost => 0, |
2719 |
withdrawn => 0, |
2720 |
biblionumber => $biblioitem->{biblionumber}, |
2721 |
biblioitemnumber => $biblioitem->{biblioitemnumber}, |
2722 |
} |
2723 |
} |
2724 |
)->store; |
2725 |
|
2726 |
my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef ); |
2635 |
my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef ); |
2727 |
is_deeply( $needsconfirmation, {}, 'Item can be issued to this patron' ); |
2636 |
is_deeply( $needsconfirmation, {}, 'Item can be issued to this patron' ); |
2728 |
is_deeply( $issuingimpossible, {}, 'Item can be issued to this patron' ); |
2637 |
is_deeply( $issuingimpossible, {}, 'Item can be issued to this patron' ); |
Lines 2742-2764
subtest 'CanBookBeIssued | notforloan' => sub {
Link Here
|
2742 |
value => { notforloan => undef, } |
2651 |
value => { notforloan => undef, } |
2743 |
} |
2652 |
} |
2744 |
); |
2653 |
); |
2745 |
|
2654 |
my $item = $builder->build_sample_item( |
2746 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
|
|
2747 |
my $item = $builder->build_object( |
2748 |
{ |
2655 |
{ |
2749 |
class => 'Koha::Items', |
2656 |
library => $library->{branchcode}, |
2750 |
value => { |
2657 |
itype => $itemtype->{itemtype}, |
2751 |
homebranch => $library->{branchcode}, |
|
|
2752 |
holdingbranch => $library->{branchcode}, |
2753 |
notforloan => 0, |
2754 |
itemlost => 0, |
2755 |
withdrawn => 0, |
2756 |
itype => $itemtype->{itemtype}, |
2757 |
biblionumber => $biblioitem->{biblionumber}, |
2758 |
biblioitemnumber => $biblioitem->{biblioitemnumber}, |
2759 |
} |
2760 |
} |
2658 |
} |
2761 |
)->store; |
2659 |
); |
|
|
2660 |
$item->biblioitem->itemtype($itemtype->{itemtype})->store; |
2762 |
|
2661 |
|
2763 |
my ( $issuingimpossible, $needsconfirmation ); |
2662 |
my ( $issuingimpossible, $needsconfirmation ); |
2764 |
|
2663 |
|
Lines 2843-2849
subtest 'AddReturn should clear items.onloan for unissued items' => sub {
Link Here
|
2843 |
plan tests => 1; |
2742 |
plan tests => 1; |
2844 |
|
2743 |
|
2845 |
t::lib::Mocks::mock_preference( "AllowReturnToBranch", 'anywhere' ); |
2744 |
t::lib::Mocks::mock_preference( "AllowReturnToBranch", 'anywhere' ); |
2846 |
my $item = $builder->build_object({ class => 'Koha::Items', value => { onloan => '2018-01-01' }}); |
2745 |
my $item = $builder->build_sample_item( |
|
|
2746 |
{ |
2747 |
onloan => '2018-01-01', |
2748 |
} |
2749 |
); |
2750 |
|
2847 |
AddReturn( $item->barcode, $item->homebranch ); |
2751 |
AddReturn( $item->barcode, $item->homebranch ); |
2848 |
$item->discard_changes; # refresh |
2752 |
$item->discard_changes; # refresh |
2849 |
is( $item->onloan, undef, 'AddReturn did clear items.onloan' ); |
2753 |
is( $item->onloan, undef, 'AddReturn did clear items.onloan' ); |