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

(-)a/t/db_dependent/Circulation.t (-1 / +152 lines)
Lines 6795-6800 subtest 'Test CanBookBeIssued param ignore_reserves (Bug 35322)' => sub { Link Here
6795
6795
6796
};
6796
};
6797
6797
6798
subtest 'NoRefundOnLostFinesPaidAge' => sub {
6799
    plan tests => 2;
6800
6801
    t::lib::Mocks::mock_preference( 'BlockReturnOfLostItems', 0 );
6802
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
6803
    my $patron  = $builder->build_object(
6804
        {
6805
            class => 'Koha::Patrons',
6806
            value => { categorycode => $patron_category->{categorycode} }
6807
        }
6808
    );
6809
6810
    my $biblionumber = $builder->build_sample_biblio(
6811
        {
6812
            branchcode => $library->branchcode,
6813
        }
6814
    )->biblionumber;
6815
6816
    Koha::CirculationRules->search->delete;
6817
    Koha::CirculationRules->set_rules(
6818
        {
6819
            categorycode => undef,
6820
            itemtype     => undef,
6821
            branchcode   => undef,
6822
            rules        => {
6823
                issuelength => 14,
6824
                lengthunit  => 'days',
6825
            }
6826
        }
6827
    );
6828
    $builder->build(
6829
        {
6830
            source => 'CirculationRule',
6831
            value  => {
6832
                branchcode   => undef,
6833
                categorycode => undef,
6834
                itemtype     => undef,
6835
                rule_name    => 'lostreturn',
6836
                rule_value   => 'refund'
6837
            }
6838
        }
6839
    );
6840
6841
    my $item = $builder->build_sample_item(
6842
        {
6843
            biblionumber => $biblionumber,
6844
            library      => $library->branchcode,
6845
        }
6846
    );
6847
    my $lost_on = dt_from_string->subtract( days => 5 )->date;
6848
    my $issue   = AddIssue( $patron, $item->barcode );
6849
    LostItem( $item->itemnumber, 'cli', 0 );
6850
    $item->_result->itemlost(1);
6851
    $item->_result->itemlost_on($lost_on);
6852
    $item->_result->update();
6853
6854
    my $debit = Koha::Account::Line->new(
6855
        {
6856
            borrowernumber    => $patron->id,
6857
            date              => '1970-01-01 14:00:01',
6858
            amount            => 5,
6859
            amountoutstanding => 0,
6860
            interface         => 'commandline',
6861
            debit_type_code   => 'LOST',
6862
            itemnumber        => $item->itemnumber
6863
        }
6864
    )->store();
6865
    my $credit = Koha::Account::Line->new(
6866
        {
6867
            borrowernumber    => $patron->id,
6868
            date              => '1970-01-01 14:00:01',
6869
            amountoutstanding => 0,
6870
            amount            => -5,
6871
6872
            interface        => 'commandline',
6873
            credit_type_code => 'PAYMENT'
6874
        }
6875
    )->store();
6876
    my $offset = Koha::Account::Offset->new(
6877
        {
6878
            credit_id  => $credit->id,
6879
            debit_id   => $debit->id,
6880
            type       => 'APPLY',
6881
            amount     => -5,
6882
            created_on => '1971-01-01 14:00:01'
6883
        }
6884
    )->store();
6885
6886
    t::lib::Mocks::mock_preference( 'NoRefundOnLostFinesPaidAge', undef );
6887
    my ( $return, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string );
6888
6889
    is( $patron->account->balance, -5, 'Lost fine has been refunded' );
6890
6891
    my $patron2 = $builder->build_object(
6892
        {
6893
            class => 'Koha::Patrons',
6894
            value => { categorycode => $patron_category->{categorycode} }
6895
        }
6896
    );
6897
    my $item2 = $builder->build_sample_item(
6898
        {
6899
            biblionumber => $biblionumber,
6900
            library      => $library->branchcode,
6901
        }
6902
    );
6903
    my $lost_on2 = dt_from_string->subtract( days => 5 )->date;
6904
    my $issue2   = AddIssue( $patron2, $item2->barcode );
6905
    LostItem( $item2->itemnumber, 'cli', 0 );
6906
    $item2->_result->itemlost(1);
6907
    $item2->_result->itemlost_on($lost_on2);
6908
    $item2->_result->update();
6909
6910
    my $debit2 = Koha::Account::Line->new(
6911
        {
6912
            borrowernumber    => $patron2->id,
6913
            date              => '1970-01-01 14:00:01',
6914
            amount            => 5,
6915
            amountoutstanding => 0,
6916
            interface         => 'commandline',
6917
            debit_type_code   => 'LOST',
6918
            itemnumber        => $item2->itemnumber
6919
        }
6920
    )->store();
6921
    my $credit2 = Koha::Account::Line->new(
6922
        {
6923
            borrowernumber    => $patron2->id,
6924
            date              => '1970-01-01 14:00:01',
6925
            amount            => -5,
6926
            amountoutstanding => 0,
6927
            interface         => 'commandline',
6928
            credit_type_code  => 'PAYMENT'
6929
        }
6930
    )->store();
6931
    my $offset2 = Koha::Account::Offset->new(
6932
        {
6933
            credit_id  => $credit2->id,
6934
            debit_id   => $debit2->id,
6935
            type       => 'APPLY',
6936
            amount     => -5,
6937
            created_on => '1971-01-01 14:00:01'
6938
        }
6939
    )->store();
6940
6941
    t::lib::Mocks::mock_preference( 'NoRefundOnLostFinesPaidAge', 5 );
6942
    my ( $return2, $messages2 ) = AddReturn( $item2->barcode, $library->branchcode, undef, dt_from_string );
6943
6944
    is(
6945
        $patron2->account->balance, 0,
6946
        'Lost fine has not been refunded as it is older than NoRefundOnLostFinesPaidAge'
6947
    );
6948
};
6949
6798
6950
6799
$schema->storage->txn_rollback;
6951
$schema->storage->txn_rollback;
6800
C4::Context->clear_syspref_cache();
6952
C4::Context->clear_syspref_cache();
6801
- 

Return to bug 28575