View | Details | Raw Unified | Return to bug 22877
Collapse All | Expand All

(-)a/t/db_dependent/Circulation.t (-2 / +29 lines)
Lines 1980-1986 subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub { Link Here
1980
1980
1981
1981
1982
subtest 'AddReturn | is_overdue' => sub {
1982
subtest 'AddReturn | is_overdue' => sub {
1983
    plan tests => 5;
1983
    plan tests => 7;
1984
1984
1985
    t::lib::Mocks::mock_preference('CalculateFinesOnReturn', 1);
1985
    t::lib::Mocks::mock_preference('CalculateFinesOnReturn', 1);
1986
    t::lib::Mocks::mock_preference('finesMode', 'production');
1986
    t::lib::Mocks::mock_preference('finesMode', 'production');
Lines 1992-1997 subtest 'AddReturn | is_overdue' => sub { Link Here
1992
    t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
1992
    t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
1993
1993
1994
    my $biblioitem = $builder->build( { source => 'Biblioitem' } );
1994
    my $biblioitem = $builder->build( { source => 'Biblioitem' } );
1995
    my $item_type          = $builder->build_object(
1996
        {   class => 'Koha::ItemTypes',
1997
            value => {
1998
                notforloan         => undef,
1999
                rentalcharge       => 0,
2000
                defaultreplacecost => undef,
2001
                processfee         => 0,
2002
                rentalcharge_daily => 0,
2003
            }
2004
        }
2005
    );
1995
    my $item = $builder->build(
2006
    my $item = $builder->build(
1996
        {
2007
        {
1997
            source => 'Item',
2008
            source => 'Item',
Lines 2002-2007 subtest 'AddReturn | is_overdue' => sub { Link Here
2002
                itemlost      => 0,
2013
                itemlost      => 0,
2003
                withdrawn     => 0,
2014
                withdrawn     => 0,
2004
                biblionumber  => $biblioitem->{biblionumber},
2015
                biblionumber  => $biblioitem->{biblionumber},
2016
                replacementprice => 7,
2017
                itype         => $item_type->itemtype
2005
            }
2018
            }
2006
        }
2019
        }
2007
    );
2020
    );
Lines 2020-2025 subtest 'AddReturn | is_overdue' => sub { Link Here
2020
    );
2033
    );
2021
    $rule->store();
2034
    $rule->store();
2022
2035
2036
    my $now   = dt_from_string;
2023
    my $one_day_ago   = dt_from_string->subtract( days => 1 );
2037
    my $one_day_ago   = dt_from_string->subtract( days => 1 );
2024
    my $five_days_ago = dt_from_string->subtract( days => 5 );
2038
    my $five_days_ago = dt_from_string->subtract( days => 5 );
2025
    my $ten_days_ago  = dt_from_string->subtract( days => 10 );
2039
    my $ten_days_ago  = dt_from_string->subtract( days => 10 );
Lines 2054-2059 subtest 'AddReturn | is_overdue' => sub { Link Here
2054
    AddReturn( $item->{barcode}, $library->{branchcode}, $five_days_ago );
2068
    AddReturn( $item->{barcode}, $library->{branchcode}, $five_days_ago );
2055
    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
2069
    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
2056
    Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete;
2070
    Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete;
2071
2072
    # Checkout an item 10 days ago
2073
    my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago
2074
    # Fake fines cronjob on this checkout
2075
    my ( $fine ) = CalcFine( $item , $patron->categorycode, $library->{branchcode}, $ten_days_ago, $now );
2076
    UpdateFine({ issue_id => $issue->issue_id, itemnumber => $item->{itemnumber}, borrowernumber => $patron->borrowernumber, amount => $fine, due => output_pref($ten_days_ago) });
2077
    is( int($patron->account->balance()),10, "Overdue fine of 10 days overdue");
2078
    # Fake longoverdue with charge and not marking returned
2079
    LostItem( $item->{itemnumber}, 'cronjob',0 );
2080
    is( int($patron->account->balance()),17, "Lost fine of 7 plus 10 days overdue");
2081
    # Now we return it today
2082
    AddReturn( $item->{barcode}, $library->{branchcode} );
2083
    is( int($patron->account->balance()),17, "Should have a single 10 days overdue fine and lost charge");
2084
2057
};
2085
};
2058
2086
2059
subtest '_FixAccountForLostAndReturned' => sub {
2087
subtest '_FixAccountForLostAndReturned' => sub {
2060
- 

Return to bug 22877