|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 102; |
20 |
use Test::More tests => 104; |
| 21 |
|
21 |
|
| 22 |
use DateTime; |
22 |
use DateTime; |
| 23 |
|
23 |
|
|
Lines 257-265
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 257 |
$biblionumber |
257 |
$biblionumber |
| 258 |
); |
258 |
); |
| 259 |
|
259 |
|
| 260 |
|
|
|
| 261 |
|
| 262 |
|
| 263 |
# Create borrowers |
260 |
# Create borrowers |
| 264 |
my %renewing_borrower_data = ( |
261 |
my %renewing_borrower_data = ( |
| 265 |
firstname => 'John', |
262 |
firstname => 'John', |
|
Lines 1644-1649
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
| 1644 |
is( $debarments->[0]->{expiration}, $expected_expiration ); |
1641 |
is( $debarments->[0]->{expiration}, $expected_expiration ); |
| 1645 |
}; |
1642 |
}; |
| 1646 |
|
1643 |
|
|
|
1644 |
subtest '_FixAccountForLostAndReturned' => sub { |
| 1645 |
plan tests => 2; |
| 1646 |
|
| 1647 |
# Generate test biblio |
| 1648 |
my $biblio = MARC::Record->new(); |
| 1649 |
my $title = 'Koha for Dummies'; |
| 1650 |
$biblio->append_fields( |
| 1651 |
MARC::Field->new( '100', ' ', ' ', a => 'Hall, Daria' ), |
| 1652 |
MARC::Field->new( '245', ' ', ' ', a => $title ), |
| 1653 |
); |
| 1654 |
|
| 1655 |
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' ); |
| 1656 |
|
| 1657 |
my $barcode = 'KD123456789'; |
| 1658 |
my $branchcode = $library2->{branchcode}; |
| 1659 |
|
| 1660 |
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( |
| 1661 |
{ |
| 1662 |
homebranch => $branchcode, |
| 1663 |
holdingbranch => $branchcode, |
| 1664 |
barcode => $barcode, |
| 1665 |
replacementprice => 99.00, |
| 1666 |
itype => $itemtype |
| 1667 |
}, |
| 1668 |
$biblionumber |
| 1669 |
); |
| 1670 |
|
| 1671 |
my $patron = $builder->build( { source => 'Borrower' } ); |
| 1672 |
|
| 1673 |
my $accountline = Koha::Account::Line->new( |
| 1674 |
{ |
| 1675 |
borrowernumber => $patron->{borrowernumber}, |
| 1676 |
accounttype => 'L', |
| 1677 |
itemnumber => $itemnumber, |
| 1678 |
amount => 99.00, |
| 1679 |
amountoutstanding => 99.00, |
| 1680 |
} |
| 1681 |
)->store(); |
| 1682 |
|
| 1683 |
C4::Circulation::_FixAccountForLostAndReturned( $itemnumber, $patron->{borrowernumber} ); |
| 1684 |
|
| 1685 |
$accountline->_result()->discard_changes(); |
| 1686 |
|
| 1687 |
is( $accountline->amountoutstanding, '0.000000', 'Lost fee has no outstanding amount' ); |
| 1688 |
is( $accountline->accounttype, 'LR', 'Lost fee now has account type of LR ( Lost Returned )'); |
| 1689 |
}; |
| 1690 |
|
| 1691 |
subtest '_FixOverduesOnReturn' => sub { |
| 1692 |
plan tests => 6; |
| 1693 |
|
| 1694 |
# Generate test biblio |
| 1695 |
my $biblio = MARC::Record->new(); |
| 1696 |
my $title = 'Koha for Dummies'; |
| 1697 |
$biblio->append_fields( |
| 1698 |
MARC::Field->new( '100', ' ', ' ', a => 'Hall, Kylie' ), |
| 1699 |
MARC::Field->new( '245', ' ', ' ', a => $title ), |
| 1700 |
); |
| 1701 |
|
| 1702 |
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' ); |
| 1703 |
|
| 1704 |
my $barcode = 'KD987654321'; |
| 1705 |
my $branchcode = $library2->{branchcode}; |
| 1706 |
|
| 1707 |
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( |
| 1708 |
{ |
| 1709 |
homebranch => $branchcode, |
| 1710 |
holdingbranch => $branchcode, |
| 1711 |
barcode => $barcode, |
| 1712 |
replacementprice => 99.00, |
| 1713 |
itype => $itemtype |
| 1714 |
}, |
| 1715 |
$biblionumber |
| 1716 |
); |
| 1717 |
|
| 1718 |
my $patron = $builder->build( { source => 'Borrower' } ); |
| 1719 |
|
| 1720 |
## Start with basic call, should just close out the open fine |
| 1721 |
my $accountline = Koha::Account::Line->new( |
| 1722 |
{ |
| 1723 |
borrowernumber => $patron->{borrowernumber}, |
| 1724 |
accounttype => 'FU', |
| 1725 |
itemnumber => $itemnumber, |
| 1726 |
amount => 99.00, |
| 1727 |
amountoutstanding => 99.00, |
| 1728 |
lastincrement => 9.00, |
| 1729 |
} |
| 1730 |
)->store(); |
| 1731 |
|
| 1732 |
C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $itemnumber ); |
| 1733 |
|
| 1734 |
$accountline->_result()->discard_changes(); |
| 1735 |
|
| 1736 |
is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' ); |
| 1737 |
is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )'); |
| 1738 |
|
| 1739 |
|
| 1740 |
## Run again, with exemptfine enabled |
| 1741 |
$accountline->set( |
| 1742 |
{ |
| 1743 |
accounttype => 'FU', |
| 1744 |
amountoutstanding => 99.00, |
| 1745 |
} |
| 1746 |
)->store(); |
| 1747 |
|
| 1748 |
C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $itemnumber, 1 ); |
| 1749 |
|
| 1750 |
$accountline->_result()->discard_changes(); |
| 1751 |
|
| 1752 |
is( $accountline->amountoutstanding, '0.000000', 'Fine has been reduced to 0' ); |
| 1753 |
is( $accountline->accounttype, 'FFOR', 'Open fine ( account type FU ) has been set to fine forgiven ( account type FFOR )'); |
| 1754 |
|
| 1755 |
## Run again, with dropbox mode enabled |
| 1756 |
$accountline->set( |
| 1757 |
{ |
| 1758 |
accounttype => 'FU', |
| 1759 |
amountoutstanding => 99.00, |
| 1760 |
} |
| 1761 |
)->store(); |
| 1762 |
|
| 1763 |
C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $itemnumber, 0, 1 ); |
| 1764 |
|
| 1765 |
$accountline->_result()->discard_changes(); |
| 1766 |
|
| 1767 |
is( $accountline->amountoutstanding, '90.000000', 'Fine has been reduced to 90' ); |
| 1768 |
is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )'); |
| 1769 |
}; |
| 1770 |
|
| 1647 |
sub set_userenv { |
1771 |
sub set_userenv { |
| 1648 |
my ( $library ) = @_; |
1772 |
my ( $library ) = @_; |
| 1649 |
C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, $library->{branchname}, '', '', ''); |
1773 |
C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, $library->{branchname}, '', '', ''); |
| 1650 |
- |
|
|