Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 100; |
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 1739-1745
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
1739 |
AddReturn( $item->{barcode}, $library->{branchcode}, undef, 1, undef, $five_days_ago ); |
1737 |
AddReturn( $item->{barcode}, $library->{branchcode}, undef, 1, undef, $five_days_ago ); |
1740 |
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 |
1738 |
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 |
1741 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
1739 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
|
|
1740 |
}; |
1741 |
|
1742 |
subtest '_FixAccountForLostAndReturned' => sub { |
1743 |
plan tests => 2; |
1744 |
|
1745 |
# Generate test biblio |
1746 |
my $biblio = MARC::Record->new(); |
1747 |
my $title = 'Koha for Dummies'; |
1748 |
$biblio->append_fields( |
1749 |
MARC::Field->new( '100', ' ', ' ', a => 'Hall, Daria' ), |
1750 |
MARC::Field->new( '245', ' ', ' ', a => $title ), |
1751 |
); |
1752 |
|
1753 |
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' ); |
1754 |
|
1755 |
my $barcode = 'KD123456789'; |
1756 |
my $branchcode = $library2->{branchcode}; |
1757 |
|
1758 |
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( |
1759 |
{ |
1760 |
homebranch => $branchcode, |
1761 |
holdingbranch => $branchcode, |
1762 |
barcode => $barcode, |
1763 |
replacementprice => 99.00, |
1764 |
itype => $itemtype |
1765 |
}, |
1766 |
$biblionumber |
1767 |
); |
1768 |
|
1769 |
my $patron = $builder->build( { source => 'Borrower' } ); |
1770 |
|
1771 |
my $accountline = Koha::Account::Line->new( |
1772 |
{ |
1773 |
borrowernumber => $patron->{borrowernumber}, |
1774 |
accounttype => 'L', |
1775 |
itemnumber => $itemnumber, |
1776 |
amount => 99.00, |
1777 |
amountoutstanding => 99.00, |
1778 |
} |
1779 |
)->store(); |
1780 |
|
1781 |
C4::Circulation::_FixAccountForLostAndReturned( $itemnumber, $patron->{borrowernumber} ); |
1782 |
|
1783 |
$accountline->_result()->discard_changes(); |
1784 |
|
1785 |
is( $accountline->amountoutstanding, '0.000000', 'Lost fee has no outstanding amount' ); |
1786 |
is( $accountline->accounttype, 'LR', 'Lost fee now has account type of LR ( Lost Returned )'); |
1787 |
}; |
1788 |
|
1789 |
subtest '_FixOverduesOnReturn' => sub { |
1790 |
plan tests => 6; |
1791 |
|
1792 |
# Generate test biblio |
1793 |
my $biblio = MARC::Record->new(); |
1794 |
my $title = 'Koha for Dummies'; |
1795 |
$biblio->append_fields( |
1796 |
MARC::Field->new( '100', ' ', ' ', a => 'Hall, Kylie' ), |
1797 |
MARC::Field->new( '245', ' ', ' ', a => $title ), |
1798 |
); |
1799 |
|
1800 |
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' ); |
1801 |
|
1802 |
my $barcode = 'KD987654321'; |
1803 |
my $branchcode = $library2->{branchcode}; |
1804 |
|
1805 |
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( |
1806 |
{ |
1807 |
homebranch => $branchcode, |
1808 |
holdingbranch => $branchcode, |
1809 |
barcode => $barcode, |
1810 |
replacementprice => 99.00, |
1811 |
itype => $itemtype |
1812 |
}, |
1813 |
$biblionumber |
1814 |
); |
1815 |
|
1816 |
my $patron = $builder->build( { source => 'Borrower' } ); |
1817 |
|
1818 |
## Start with basic call, should just close out the open fine |
1819 |
my $accountline = Koha::Account::Line->new( |
1820 |
{ |
1821 |
borrowernumber => $patron->{borrowernumber}, |
1822 |
accounttype => 'FU', |
1823 |
itemnumber => $itemnumber, |
1824 |
amount => 99.00, |
1825 |
amountoutstanding => 99.00, |
1826 |
lastincrement => 9.00, |
1827 |
} |
1828 |
)->store(); |
1829 |
|
1830 |
C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $itemnumber ); |
1831 |
|
1832 |
$accountline->_result()->discard_changes(); |
1833 |
|
1834 |
is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' ); |
1835 |
is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )'); |
1836 |
|
1837 |
|
1838 |
## Run again, with exemptfine enabled |
1839 |
$accountline->set( |
1840 |
{ |
1841 |
accounttype => 'FU', |
1842 |
amountoutstanding => 99.00, |
1843 |
} |
1844 |
)->store(); |
1845 |
|
1846 |
C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $itemnumber, 1 ); |
1847 |
|
1848 |
$accountline->_result()->discard_changes(); |
1849 |
|
1850 |
is( $accountline->amountoutstanding, '0.000000', 'Fine has been reduced to 0' ); |
1851 |
is( $accountline->accounttype, 'FFOR', 'Open fine ( account type FU ) has been set to fine forgiven ( account type FFOR )'); |
1852 |
|
1853 |
## Run again, with dropbox mode enabled |
1854 |
$accountline->set( |
1855 |
{ |
1856 |
accounttype => 'FU', |
1857 |
amountoutstanding => 99.00, |
1858 |
} |
1859 |
)->store(); |
1860 |
|
1861 |
C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $itemnumber, 0, 1 ); |
1862 |
|
1863 |
$accountline->_result()->discard_changes(); |
1742 |
|
1864 |
|
|
|
1865 |
is( $accountline->amountoutstanding, '90.000000', 'Fine has been reduced to 90' ); |
1866 |
is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )'); |
1743 |
}; |
1867 |
}; |
1744 |
|
1868 |
|
1745 |
sub set_userenv { |
1869 |
sub set_userenv { |
1746 |
- |
|
|