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

(-)a/t/db_dependent/Circulation/ReturnClaims.t (-1 / +41 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 4;
20
use Test::More tests => 5;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 143-148 subtest 'Test Koha::Checkout::claim_returned, mark as returned' => sub { Link Here
143
    is( $checkout2->id, $checkout->id, "Checkout was found in the old_issues table");
143
    is( $checkout2->id, $checkout->id, "Checkout was found in the old_issues table");
144
};
144
};
145
145
146
subtest 'Test Koha::Checkout::claim_returned, should refund a previous lost fee if refund_lost_fee is set' => sub {
147
    plan tests => 4;
148
149
    t::lib::Mocks::mock_preference( 'ClaimReturnedLostValue',  1 );
150
    t::lib::Mocks::mock_preference( 'MarkLostItemsAsReturned', q{claim_returned} );
151
    my $item       = $builder->build_sample_item;
152
    my $itemnumber = $item->itemnumber;
153
    my $patron     = $builder->build_object( { class => 'Koha::Patrons' } );
154
    my $checkout   = AddIssue( $patron, $item->barcode );
155
156
    my $line = Koha::Account::Line->new(
157
        {
158
            borrowernumber    => $patron->borrowernumber,
159
            itemnumber        => $itemnumber,
160
            debit_type_code   => "LOST",
161
            status            => "NULL",
162
            amount            => 10,
163
            amountoutstanding => 10,
164
            interface         => 'commandline',
165
        }
166
    )->store;
167
168
    my $claim = $checkout->claim_returned(
169
        {
170
            created_by      => $patron->borrowernumber,
171
            notes           => "Test note",
172
            refund_lost_fee => 1
173
        }
174
    );
175
176
    my $updated_line = Koha::Account::Lines->find( { accountlines_id => $line->accountlines_id } );
177
    is( $updated_line->amountoutstanding + 0, 0,       "Line amount outstanding is 0" );
178
    is( $updated_line->status,                'FOUND', "Line has been struck off as 'FOUND'" );
179
180
    my $credit =
181
        Koha::Account::Lines->find( { borrowernumber => $patron->borrowernumber, credit_type_code => 'LOST_FOUND' } );
182
    is( $credit->amount + 0,  -10,                      "Credit amount is 10" );
183
    is( $credit->description, "Item found $itemnumber", "Credit has been marked as relating to the item being found" );
184
};
185
146
subtest 'Test Koha::Checkout::claim_returned should not update the itemlost status if it is already set' => sub {
186
subtest 'Test Koha::Checkout::claim_returned should not update the itemlost status if it is already set' => sub {
147
    plan tests => 2;
187
    plan tests => 2;
148
188
(-)a/t/db_dependent/api/v1/return_claims.t (-1 / +3 lines)
Lines 72-77 subtest 'claim_returned() tests' => sub { Link Here
72
        "//$userid:$password@/api/v1/return_claims" => json => {
72
        "//$userid:$password@/api/v1/return_claims" => json => {
73
            item_id         => $item->itemnumber,
73
            item_id         => $item->itemnumber,
74
            charge_lost_fee => Mojo::JSON->false,
74
            charge_lost_fee => Mojo::JSON->false,
75
            refund_lost_fee => Mojo::JSON->false,
75
            created_by      => $librarian->id,
76
            created_by      => $librarian->id,
76
            notes           => "This is a test note."
77
            notes           => "This is a test note."
77
        }
78
        }
Lines 88-93 subtest 'claim_returned() tests' => sub { Link Here
88
            "//$userid:$password@/api/v1/return_claims" => json => {
89
            "//$userid:$password@/api/v1/return_claims" => json => {
89
                item_id         => $item->itemnumber,
90
                item_id         => $item->itemnumber,
90
                charge_lost_fee => Mojo::JSON->false,
91
                charge_lost_fee => Mojo::JSON->false,
92
                refund_lost_fee => Mojo::JSON->false,
91
                created_by      => $librarian->id,
93
                created_by      => $librarian->id,
92
                notes           => "This is a test note."
94
                notes           => "This is a test note."
93
            }
95
            }
Lines 101-106 subtest 'claim_returned() tests' => sub { Link Here
101
        "//$userid:$password@/api/v1/return_claims" => json => {
103
        "//$userid:$password@/api/v1/return_claims" => json => {
102
            item_id         => $item->itemnumber,
104
            item_id         => $item->itemnumber,
103
            charge_lost_fee => Mojo::JSON->false,
105
            charge_lost_fee => Mojo::JSON->false,
106
            refund_lost_fee => Mojo::JSON->false,
104
            created_by      => $librarian->id,
107
            created_by      => $librarian->id,
105
            notes           => "This is a test note."
108
            notes           => "This is a test note."
106
        }
109
        }
107
- 

Return to bug 33292