|
Lines 27-33
use C4::Overdues qw(UpdateFine);
Link Here
|
| 27 |
use Koha::DateUtils; |
27 |
use Koha::DateUtils; |
| 28 |
use Koha::Database; |
28 |
use Koha::Database; |
| 29 |
|
29 |
|
| 30 |
use Test::More tests => 61; |
30 |
use Test::More tests => 65; |
| 31 |
|
31 |
|
| 32 |
BEGIN { |
32 |
BEGIN { |
| 33 |
use_ok('C4::Circulation'); |
33 |
use_ok('C4::Circulation'); |
|
Lines 37-44
my $dbh = C4::Context->dbh;
Link Here
|
| 37 |
my $schema = Koha::Database->new()->schema(); |
37 |
my $schema = Koha::Database->new()->schema(); |
| 38 |
|
38 |
|
| 39 |
# Start transaction |
39 |
# Start transaction |
| 40 |
$dbh->{AutoCommit} = 0; |
|
|
| 41 |
$dbh->{RaiseError} = 1; |
40 |
$dbh->{RaiseError} = 1; |
|
|
41 |
$schema->storage->txn_begin(); |
| 42 |
|
42 |
|
| 43 |
# Start with a clean slate |
43 |
# Start with a clean slate |
| 44 |
$dbh->do('DELETE FROM issues'); |
44 |
$dbh->do('DELETE FROM issues'); |
|
Lines 594-599
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 594 |
is ( $count, 0, "Calling UpdateFine on non-existant fine with an amount of 0 does not result in an empty fine" ); |
594 |
is ( $count, 0, "Calling UpdateFine on non-existant fine with an amount of 0 does not result in an empty fine" ); |
| 595 |
} |
595 |
} |
| 596 |
|
596 |
|
| 597 |
$dbh->rollback; |
597 |
{ |
|
|
598 |
$dbh->do('DELETE FROM issues'); |
| 599 |
$dbh->do('DELETE FROM items'); |
| 600 |
$dbh->do('DELETE FROM issuingrules'); |
| 601 |
$dbh->do( |
| 602 |
q{ |
| 603 |
INSERT INTO issuingrules ( categorycode, branchcode, itemtype, reservesallowed, maxissueqty, issuelength, lengthunit, renewalsallowed, renewalperiod, |
| 604 |
norenewalbefore, auto_renew, fine, chargeperiod ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) |
| 605 |
}, |
| 606 |
{}, |
| 607 |
'*', '*', '*', 25, |
| 608 |
20, 14, 'days', |
| 609 |
1, 7, |
| 610 |
'', 0, |
| 611 |
.10, 1 |
| 612 |
); |
| 613 |
my $biblio = MARC::Record->new(); |
| 614 |
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' ); |
| 615 |
|
| 616 |
my $barcode1 = '1234'; |
| 617 |
my ( undef, undef, $itemnumber1 ) = AddItem( |
| 618 |
{ |
| 619 |
homebranch => 'MPL', |
| 620 |
holdingbranch => 'MPL', |
| 621 |
barcode => $barcode1, |
| 622 |
}, |
| 623 |
$biblionumber |
| 624 |
); |
| 625 |
my $barcode2 = '4321'; |
| 626 |
my ( undef, undef, $itemnumber2 ) = AddItem( |
| 627 |
{ |
| 628 |
homebranch => 'MPL', |
| 629 |
holdingbranch => 'MPL', |
| 630 |
barcode => $barcode2, |
| 631 |
}, |
| 632 |
$biblionumber |
| 633 |
); |
| 634 |
|
| 635 |
my $borrowernumber1 = AddMember( |
| 636 |
firstname => 'Kyle', |
| 637 |
surname => 'Hall', |
| 638 |
categorycode => 'S', |
| 639 |
branchcode => 'MPL', |
| 640 |
); |
| 641 |
my $borrowernumber2 = AddMember( |
| 642 |
firstname => 'Chelsea', |
| 643 |
surname => 'Hall', |
| 644 |
categorycode => 'S', |
| 645 |
branchcode => 'MPL', |
| 646 |
); |
| 647 |
|
| 648 |
my $borrower1 = GetMember( borrowernumber => $borrowernumber1 ); |
| 649 |
my $borrower2 = GetMember( borrowernumber => $borrowernumber2 ); |
| 650 |
|
| 651 |
my $issue = AddIssue( $borrower1, $barcode1 ); |
| 652 |
|
| 653 |
my ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber2, $itemnumber1 ); |
| 654 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with no hold on the record' ); |
| 655 |
|
| 656 |
AddReserve( |
| 657 |
'MPL', $borrowernumber2, $biblionumber, |
| 658 |
'a', '', 1, undef, undef, '', |
| 659 |
undef, undef, undef |
| 660 |
); |
| 661 |
|
| 662 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber2, $itemnumber1 ); |
| 663 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record' ); |
| 664 |
|
| 665 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1"); |
| 666 |
C4::Context->set_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
| 667 |
|
| 668 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber2, $itemnumber1 ); |
| 669 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled' ); |
| 670 |
|
| 671 |
diag("Setting item not checked out to be not for loan but holdable"); |
| 672 |
ModItem({ notforloan => -1 }, $biblionumber, $itemnumber2); |
| 673 |
|
| 674 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber2, $itemnumber1 ); |
| 675 |
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' ); |
| 676 |
} |
| 598 |
|
677 |
|
|
|
678 |
$schema->storage->txn_rollback(); |
| 599 |
1; |
679 |
1; |
| 600 |
- |
|
|