Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 98; |
20 |
use Test::More tests => 105; |
21 |
|
21 |
|
22 |
use DateTime; |
22 |
use DateTime; |
23 |
|
23 |
|
Lines 50-55
$dbh->{RaiseError} = 1;
Link Here
|
50 |
|
50 |
|
51 |
# Start with a clean slate |
51 |
# Start with a clean slate |
52 |
$dbh->do('DELETE FROM issues'); |
52 |
$dbh->do('DELETE FROM issues'); |
|
|
53 |
$dbh->do('DELETE FROM borrowers'); |
53 |
|
54 |
|
54 |
my $library = $builder->build({ |
55 |
my $library = $builder->build({ |
55 |
source => 'Branch', |
56 |
source => 'Branch', |
Lines 259-267
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
259 |
$biblionumber |
260 |
$biblionumber |
260 |
); |
261 |
); |
261 |
|
262 |
|
262 |
|
|
|
263 |
|
264 |
|
265 |
# Create borrowers |
263 |
# Create borrowers |
266 |
my %renewing_borrower_data = ( |
264 |
my %renewing_borrower_data = ( |
267 |
firstname => 'John', |
265 |
firstname => 'John', |
Lines 1726-1732
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
1726 |
AddReturn( $item->{barcode}, $library->{branchcode}, undef, 1, undef, $five_days_ago ); |
1724 |
AddReturn( $item->{barcode}, $library->{branchcode}, undef, 1, undef, $five_days_ago ); |
1727 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue in dropbox mode' ); # FIXME? This is weird, the FU fine is created ( _CalculateAndUpdateFine > C4::Overdues::UpdateFine ) then remove later (in _FixOverduesOnReturn). Looks like it is a feature |
1725 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue in dropbox mode' ); # FIXME? This is weird, the FU fine is created ( _CalculateAndUpdateFine > C4::Overdues::UpdateFine ) then remove later (in _FixOverduesOnReturn). Looks like it is a feature |
1728 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
1726 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
|
|
1727 |
}; |
1728 |
|
1729 |
subtest '_FixAccountForLostAndReturned' => sub { |
1730 |
plan tests => 2; |
1731 |
|
1732 |
# Generate test biblio |
1733 |
my $biblio = MARC::Record->new(); |
1734 |
my $title = 'Koha for Dummies'; |
1735 |
$biblio->append_fields( |
1736 |
MARC::Field->new( '100', ' ', ' ', a => 'Hall, Daria' ), |
1737 |
MARC::Field->new( '245', ' ', ' ', a => $title ), |
1738 |
); |
1739 |
|
1740 |
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' ); |
1741 |
|
1742 |
my $barcode = 'KD123456789'; |
1743 |
my $branchcode = $library2->{branchcode}; |
1744 |
|
1745 |
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( |
1746 |
{ |
1747 |
homebranch => $branchcode, |
1748 |
holdingbranch => $branchcode, |
1749 |
barcode => $barcode, |
1750 |
replacementprice => 99.00, |
1751 |
itype => $itemtype |
1752 |
}, |
1753 |
$biblionumber |
1754 |
); |
1755 |
|
1756 |
my $patron = $builder->build( { source => 'Borrower' } ); |
1757 |
|
1758 |
my $accountline = Koha::Account::Line->new( |
1759 |
{ |
1760 |
borrowernumber => $patron->{borrowernumber}, |
1761 |
accounttype => 'L', |
1762 |
itemnumber => $itemnumber, |
1763 |
amount => 99.00, |
1764 |
amountoutstanding => 99.00, |
1765 |
} |
1766 |
)->store(); |
1767 |
|
1768 |
C4::Circulation::_FixAccountForLostAndReturned( $itemnumber, $patron->{borrowernumber} ); |
1769 |
|
1770 |
$accountline->_result()->discard_changes(); |
1771 |
|
1772 |
is( $accountline->amountoutstanding, '0.000000', 'Lost fee has no outstanding amount' ); |
1773 |
is( $accountline->accounttype, 'LR', 'Lost fee now has account type of LR ( Lost Returned )'); |
1774 |
}; |
1775 |
|
1776 |
subtest '_FixOverduesOnReturn' => sub { |
1777 |
plan tests => 6; |
1778 |
|
1779 |
# Generate test biblio |
1780 |
my $biblio = MARC::Record->new(); |
1781 |
my $title = 'Koha for Dummies'; |
1782 |
$biblio->append_fields( |
1783 |
MARC::Field->new( '100', ' ', ' ', a => 'Hall, Kylie' ), |
1784 |
MARC::Field->new( '245', ' ', ' ', a => $title ), |
1785 |
); |
1786 |
|
1787 |
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' ); |
1788 |
|
1789 |
my $barcode = 'KD987654321'; |
1790 |
my $branchcode = $library2->{branchcode}; |
1791 |
|
1792 |
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( |
1793 |
{ |
1794 |
homebranch => $branchcode, |
1795 |
holdingbranch => $branchcode, |
1796 |
barcode => $barcode, |
1797 |
replacementprice => 99.00, |
1798 |
itype => $itemtype |
1799 |
}, |
1800 |
$biblionumber |
1801 |
); |
1802 |
|
1803 |
my $patron = $builder->build( { source => 'Borrower' } ); |
1804 |
|
1805 |
## Start with basic call, should just close out the open fine |
1806 |
my $accountline = Koha::Account::Line->new( |
1807 |
{ |
1808 |
borrowernumber => $patron->{borrowernumber}, |
1809 |
accounttype => 'FU', |
1810 |
itemnumber => $itemnumber, |
1811 |
amount => 99.00, |
1812 |
amountoutstanding => 99.00, |
1813 |
lastincrement => 9.00, |
1814 |
} |
1815 |
)->store(); |
1816 |
|
1817 |
C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $itemnumber ); |
1818 |
|
1819 |
$accountline->_result()->discard_changes(); |
1820 |
|
1821 |
is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' ); |
1822 |
is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )'); |
1823 |
|
1824 |
|
1825 |
## Run again, with exemptfine enabled |
1826 |
$accountline->set( |
1827 |
{ |
1828 |
accounttype => 'FU', |
1829 |
amountoutstanding => 99.00, |
1830 |
} |
1831 |
)->store(); |
1832 |
|
1833 |
C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $itemnumber, 1 ); |
1834 |
|
1835 |
$accountline->_result()->discard_changes(); |
1836 |
|
1837 |
is( $accountline->amountoutstanding, '0.000000', 'Fine has been reduced to 0' ); |
1838 |
is( $accountline->accounttype, 'FFOR', 'Open fine ( account type FU ) has been set to fine forgiven ( account type FFOR )'); |
1839 |
|
1840 |
## Run again, with dropbox mode enabled |
1841 |
$accountline->set( |
1842 |
{ |
1843 |
accounttype => 'FU', |
1844 |
amountoutstanding => 99.00, |
1845 |
} |
1846 |
)->store(); |
1847 |
|
1848 |
C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $itemnumber, 0, 1 ); |
1849 |
|
1850 |
$accountline->_result()->discard_changes(); |
1729 |
|
1851 |
|
|
|
1852 |
is( $accountline->amountoutstanding, '90.000000', 'Fine has been reduced to 90' ); |
1853 |
is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )'); |
1730 |
}; |
1854 |
}; |
1731 |
|
1855 |
|
1732 |
sub set_userenv { |
1856 |
sub set_userenv { |
1733 |
- |
|
|