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

(-)a/t/db_dependent/Koha/Account/Lines.t (-5 / +16 lines)
Lines 22-28 use Modern::Perl; Link Here
22
use Test::More tests => 8;
22
use Test::More tests => 8;
23
use Test::Exception;
23
use Test::Exception;
24
24
25
use C4::Circulation qw/AddIssue AddReturn/;
25
use C4::Circulation qw/AddIssue AddReturn MarkIssueReturned/;
26
use Koha::Account;
26
use Koha::Account;
27
use Koha::Account::Lines;
27
use Koha::Account::Lines;
28
use Koha::Account::Offsets;
28
use Koha::Account::Offsets;
Lines 294-302 subtest 'apply() tests' => sub { Link Here
294
    $schema->storage->txn_rollback;
294
    $schema->storage->txn_rollback;
295
};
295
};
296
296
297
subtest 'Keep account info when related patron, staff or item is deleted' => sub {
297
subtest 'Keep account info when related patron, staff, item or issue is deleted' => sub {
298
298
299
    plan tests => 3;
299
    plan tests => 4;
300
300
301
    $schema->storage->txn_begin;
301
    $schema->storage->txn_begin;
302
302
Lines 309-326 subtest 'Keep account info when related patron, staff or item is deleted' => sub Link Here
309
            value => { itemnumber => $item->itemnumber }
309
            value => { itemnumber => $item->itemnumber }
310
        }
310
        }
311
    );
311
    );
312
    my $issue_id = $issue->id;
312
    my $line = Koha::Account::Line->new(
313
    my $line = Koha::Account::Line->new(
313
    {
314
    {
314
        borrowernumber => $patron->borrowernumber,
315
        borrowernumber => $patron->borrowernumber,
315
        manager_id     => $staff->borrowernumber,
316
        manager_id     => $staff->borrowernumber,
316
        itemnumber     => $item->itemnumber,
317
        itemnumber     => $item->itemnumber,
318
        issue_id       => $issue_id,
319
        old_issue_id   => undef,
317
        accounttype    => "OVERDUE",
320
        accounttype    => "OVERDUE",
318
        status         => "RETURNED",
321
        status         => "RETURNED",
319
        amount         => 10,
322
        amount         => 10,
320
        interface      => 'commandline',
323
        interface      => 'commandline',
321
    })->store;
324
    })->store;
322
325
323
    $issue->delete;
326
    MarkIssueReturned($patron->borrowernumber, $item->itemnumber, undef, 0 );
327
    $line = $line->get_from_storage;
328
    is( $line->issue_id, undef, "The account line should not be deleted when the related issue is archived");
329
    is( $line->old_issue_id, $issue_id, "The account line link to the archived issue");
330
331
    my $old_issue = Koha::Old::Checkouts->find($issue_id);
332
    $old_issue->delete;
333
    $line = $line->get_from_storage;
334
    is( $line->old_issue_id, $issue_id, "The account line should not be deleted when the related old_issue is delete");
335
324
    $item->delete;
336
    $item->delete;
325
    $line = $line->get_from_storage;
337
    $line = $line->get_from_storage;
326
    is( $line->itemnumber, undef, "The account line should not be deleted when the related item is delete");
338
    is( $line->itemnumber, undef, "The account line should not be deleted when the related item is delete");
327
- 

Return to bug 22421