Lines 1985-1991
subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub {
Link Here
|
1985 |
|
1985 |
|
1986 |
|
1986 |
|
1987 |
subtest 'AddReturn | is_overdue' => sub { |
1987 |
subtest 'AddReturn | is_overdue' => sub { |
1988 |
plan tests => 5; |
1988 |
plan tests => 7; |
1989 |
|
1989 |
|
1990 |
t::lib::Mocks::mock_preference('CalculateFinesOnReturn', 1); |
1990 |
t::lib::Mocks::mock_preference('CalculateFinesOnReturn', 1); |
1991 |
t::lib::Mocks::mock_preference('finesMode', 'production'); |
1991 |
t::lib::Mocks::mock_preference('finesMode', 'production'); |
Lines 1997-2002
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
1997 |
t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode }); |
1997 |
t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode }); |
1998 |
|
1998 |
|
1999 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
1999 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
|
|
2000 |
my $item_type = $builder->build_object( |
2001 |
{ class => 'Koha::ItemTypes', |
2002 |
value => { |
2003 |
notforloan => undef, |
2004 |
rentalcharge => 0, |
2005 |
defaultreplacecost => undef, |
2006 |
processfee => 0, |
2007 |
rentalcharge_daily => 0, |
2008 |
} |
2009 |
} |
2010 |
); |
2000 |
my $item = $builder->build( |
2011 |
my $item = $builder->build( |
2001 |
{ |
2012 |
{ |
2002 |
source => 'Item', |
2013 |
source => 'Item', |
Lines 2007-2012
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2007 |
itemlost => 0, |
2018 |
itemlost => 0, |
2008 |
withdrawn => 0, |
2019 |
withdrawn => 0, |
2009 |
biblionumber => $biblioitem->{biblionumber}, |
2020 |
biblionumber => $biblioitem->{biblionumber}, |
|
|
2021 |
replacementprice => 7, |
2022 |
itype => $item_type->itemtype |
2010 |
} |
2023 |
} |
2011 |
} |
2024 |
} |
2012 |
); |
2025 |
); |
Lines 2025-2030
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2025 |
); |
2038 |
); |
2026 |
$rule->store(); |
2039 |
$rule->store(); |
2027 |
|
2040 |
|
|
|
2041 |
my $now = dt_from_string; |
2028 |
my $one_day_ago = dt_from_string->subtract( days => 1 ); |
2042 |
my $one_day_ago = dt_from_string->subtract( days => 1 ); |
2029 |
my $five_days_ago = dt_from_string->subtract( days => 5 ); |
2043 |
my $five_days_ago = dt_from_string->subtract( days => 5 ); |
2030 |
my $ten_days_ago = dt_from_string->subtract( days => 10 ); |
2044 |
my $ten_days_ago = dt_from_string->subtract( days => 10 ); |
Lines 2059-2064
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2059 |
AddReturn( $item->{barcode}, $library->{branchcode}, $five_days_ago ); |
2073 |
AddReturn( $item->{barcode}, $library->{branchcode}, $five_days_ago ); |
2060 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue in dropbox mode' ); # FIXME? This is weird, the OVERDUE fine is created ( _CalculateAndUpdateFine > C4::Overdues::UpdateFine ) then remove later (in _FixOverduesOnReturn). Looks like it is a feature |
2074 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue in dropbox mode' ); # FIXME? This is weird, the OVERDUE fine is created ( _CalculateAndUpdateFine > C4::Overdues::UpdateFine ) then remove later (in _FixOverduesOnReturn). Looks like it is a feature |
2061 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2075 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
|
|
2076 |
|
2077 |
# Checkout an item 10 days ago |
2078 |
my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago |
2079 |
# Fake fines cronjob on this checkout |
2080 |
my ( $fine ) = CalcFine( $item , $patron->categorycode, $library->{branchcode}, $ten_days_ago, $now ); |
2081 |
UpdateFine({ issue_id => $issue->issue_id, itemnumber => $item->{itemnumber}, borrowernumber => $patron->borrowernumber, amount => $fine, due => output_pref($ten_days_ago) }); |
2082 |
is( int($patron->account->balance()),10, "Overdue fine of 10 days overdue"); |
2083 |
# Fake longoverdue with charge and not marking returned |
2084 |
LostItem( $item->{itemnumber}, 'cronjob',0 ); |
2085 |
is( int($patron->account->balance()),17, "Lost fine of 7 plus 10 days overdue"); |
2086 |
# Now we return it today |
2087 |
AddReturn( $item->{barcode}, $library->{branchcode} ); |
2088 |
is( int($patron->account->balance()),17, "Should have a single 10 days overdue fine and lost charge"); |
2089 |
|
2062 |
}; |
2090 |
}; |
2063 |
|
2091 |
|
2064 |
subtest '_FixAccountForLostAndReturned' => sub { |
2092 |
subtest '_FixAccountForLostAndReturned' => sub { |
2065 |
- |
|
|