|
Lines 1972-1978
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
| 1972 |
}; |
1972 |
}; |
| 1973 |
|
1973 |
|
| 1974 |
subtest '_FixAccountForLostAndReturned' => sub { |
1974 |
subtest '_FixAccountForLostAndReturned' => sub { |
| 1975 |
plan tests => 2; |
1975 |
plan tests => 11; |
| 1976 |
|
1976 |
|
| 1977 |
# Generate test biblio |
1977 |
# Generate test biblio |
| 1978 |
my $title = 'Koha for Dummies'; |
1978 |
my $title = 'Koha for Dummies'; |
|
Lines 1992-2002
subtest '_FixAccountForLostAndReturned' => sub {
Link Here
|
| 1992 |
$biblionumber |
1992 |
$biblionumber |
| 1993 |
); |
1993 |
); |
| 1994 |
|
1994 |
|
| 1995 |
my $patron = $builder->build( { source => 'Borrower' } ); |
1995 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 1996 |
|
1996 |
|
| 1997 |
my $accountline = Koha::Account::Line->new( |
1997 |
my $accountline = Koha::Account::Line->new( |
| 1998 |
{ |
1998 |
{ |
| 1999 |
borrowernumber => $patron->{borrowernumber}, |
1999 |
borrowernumber => $patron->borrowernumber, |
| 2000 |
accounttype => 'L', |
2000 |
accounttype => 'L', |
| 2001 |
itemnumber => $itemnumber, |
2001 |
itemnumber => $itemnumber, |
| 2002 |
amount => 99.00, |
2002 |
amount => 99.00, |
|
Lines 2004-2015
subtest '_FixAccountForLostAndReturned' => sub {
Link Here
|
| 2004 |
} |
2004 |
} |
| 2005 |
)->store(); |
2005 |
)->store(); |
| 2006 |
|
2006 |
|
| 2007 |
C4::Circulation::_FixAccountForLostAndReturned( $itemnumber, $patron->{borrowernumber} ); |
2007 |
C4::Circulation::_FixAccountForLostAndReturned( $itemnumber, $patron->borrowernumber ); |
| 2008 |
|
2008 |
|
| 2009 |
$accountline->_result()->discard_changes(); |
2009 |
$accountline->_result()->discard_changes(); |
| 2010 |
|
2010 |
|
| 2011 |
is( $accountline->amountoutstanding, '0.000000', 'Lost fee has no outstanding amount' ); |
2011 |
is( $accountline->amountoutstanding, '0.000000', 'Lost fee has no outstanding amount' ); |
| 2012 |
is( $accountline->accounttype, 'LR', 'Lost fee now has account type of LR ( Lost Returned )'); |
2012 |
is( $accountline->accounttype, 'LR', 'Lost fee now has account type of LR ( Lost Returned )' ); |
|
|
2013 |
is( $patron->account->balance, 0, 'Account balance should be 0 after return of lost item' ); |
| 2014 |
|
| 2015 |
# Tests for only if unpaid |
| 2016 |
## Unpaid |
| 2017 |
$accountline->delete(); |
| 2018 |
$accountline = Koha::Account::Line->new( |
| 2019 |
{ |
| 2020 |
borrowernumber => $patron->borrowernumber, |
| 2021 |
accounttype => 'L', |
| 2022 |
itemnumber => $itemnumber, |
| 2023 |
amount => 99.00, |
| 2024 |
amountoutstanding => 99.00, |
| 2025 |
} |
| 2026 |
)->store(); |
| 2027 |
|
| 2028 |
C4::Circulation::_FixAccountForLostAndReturned( $itemnumber, $patron->borrowernumber, undef, 1 ); |
| 2029 |
|
| 2030 |
$accountline->_result()->discard_changes(); |
| 2031 |
|
| 2032 |
is( $accountline->amountoutstanding, '0.000000', 'Lost fee has no outstanding amount, with skip_paid = 1 and unpaid' ); |
| 2033 |
is( $accountline->accounttype, 'LR', 'Lost fee now has account type of LR ( Lost Returned ), with skip_paid = 1 and unpaid'); |
| 2034 |
is( $patron->account->balance, 0, 'Account balance should be 0 after return of unpaid lost item' ); |
| 2035 |
|
| 2036 |
## Paid |
| 2037 |
$accountline->delete(); |
| 2038 |
$accountline = Koha::Account::Line->new( |
| 2039 |
{ |
| 2040 |
borrowernumber => $patron->borrowernumber, |
| 2041 |
accounttype => 'L', |
| 2042 |
itemnumber => $itemnumber, |
| 2043 |
amount => 99.00, |
| 2044 |
amountoutstanding => 0.00, |
| 2045 |
} |
| 2046 |
)->store(); |
| 2047 |
|
| 2048 |
C4::Circulation::_FixAccountForLostAndReturned( $itemnumber, $patron->borrowernumber, undef, 1 ); |
| 2049 |
|
| 2050 |
$accountline->_result()->discard_changes(); |
| 2051 |
|
| 2052 |
is( $accountline->amountoutstanding, '0.000000', 'Lost fee still has outstanding amount of 0, with skip_paid = 1 and already paid' ); |
| 2053 |
is( $accountline->accounttype, 'L', 'Lost fee now has account type of L ( Lost ), with skip_paid = 1 and already paid'); |
| 2054 |
is( $patron->account->balance, 0, 'Account balance should be 0 after return of partially paid lost item' ); |
| 2055 |
|
| 2056 |
## Partially paid |
| 2057 |
$accountline->delete(); |
| 2058 |
$accountline = Koha::Account::Line->new( |
| 2059 |
{ |
| 2060 |
borrowernumber => $patron->borrowernumber, |
| 2061 |
accounttype => 'L', |
| 2062 |
itemnumber => $itemnumber, |
| 2063 |
amount => 99.00, |
| 2064 |
amountoutstanding => 33.00, |
| 2065 |
} |
| 2066 |
)->store(); |
| 2067 |
|
| 2068 |
C4::Circulation::_FixAccountForLostAndReturned( $itemnumber, $patron->borrowernumber, undef, 1 ); |
| 2069 |
|
| 2070 |
$accountline->_result()->discard_changes(); |
| 2071 |
|
| 2072 |
is( $accountline->amountoutstanding, '0.000000', 'Lost fee has no outstanding amount, with skip_paid = 1 and partially paid' ); |
| 2073 |
is( $accountline->accounttype, 'LR', 'Lost fee now has account type of L ( Lost ), with skip_paid = 1 and partially paid'); |
| 2013 |
}; |
2074 |
}; |
| 2014 |
|
2075 |
|
| 2015 |
subtest '_FixOverduesOnReturn' => sub { |
2076 |
subtest '_FixOverduesOnReturn' => sub { |