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

(-)a/t/db_dependent/Koha/Account/Line.t (-2 / +53 lines)
Lines 175-181 subtest 'is_credit() and is_debit() tests' => sub { Link Here
175
175
176
subtest 'apply() tests' => sub {
176
subtest 'apply() tests' => sub {
177
177
178
    plan tests => 30;
178
    plan tests => 31;
179
179
180
    $schema->storage->txn_begin;
180
    $schema->storage->txn_begin;
181
181
Lines 362-367 subtest 'apply() tests' => sub { Link Here
362
    is( $messages[0]->payload->{due_date}, 1, 'due_date key in payload' );
362
    is( $messages[0]->payload->{due_date}, 1, 'due_date key in payload' );
363
    is( $messages[0]->payload->{success}, 1, "'success' key in payload" );
363
    is( $messages[0]->payload->{success}, 1, "'success' key in payload" );
364
364
365
    t::lib::Mocks::mock_preference( 'MarkLostItemsAsReturned', 'onpayment');
366
    my $loser  = $builder->build_object( { class => 'Koha::Patrons' } );
367
    my $loser_account = $loser->account;
368
369
    my $lost_item = $builder->build_sample_item();
370
    my $lost_checkout = Koha::Checkout->new(
371
        {
372
            borrowernumber => $loser->id,
373
            itemnumber     => $lost_item->id,
374
            date_due       => $five_weeks_ago,
375
            branchcode     => $library->id,
376
            issuedate      => $seven_weeks_ago
377
        }
378
    )->store();
379
380
    $lost_item->itemlost(1)->store;
381
    my $processing_fee = Koha::Account::Line->new(
382
        {
383
            issue_id       => $lost_checkout->id,
384
            borrowernumber => $loser->id,
385
            itemnumber     => $lost_item->id,
386
            branchcode     => $library->id,
387
            date           => \'NOW()',
388
            debit_type_code => 'PROCESSING',
389
            status         => undef,
390
            interface      => 'intranet',
391
            amount => '15',
392
            amountoutstanding => '15',
393
        }
394
    )->store();
395
    my $lost_fee = Koha::Account::Line->new(
396
        {
397
            issue_id       => $lost_checkout->id,
398
            borrowernumber => $loser->id,
399
            itemnumber     => $lost_item->id,
400
            branchcode     => $library->id,
401
            date           => \'NOW()',
402
            debit_type_code => 'LOST',
403
            status         => undef,
404
            interface      => 'intranet',
405
            amount => '12.63',
406
            amountoutstanding => '12.63',
407
        }
408
    )->store();
409
    my $pay_lost = $loser_account->add_credit({ amount => 27.630000, user_id => $loser->id, interface => 'intranet' });
410
    my $pay_lines = [ $processing_fee, $lost_fee ];
411
    $pay_lost->apply( { debits => $pay_lines, offset_type => 'Credit applied' } );
412
413
    is( $loser->checkouts->next, undef, "Item has been returned");
414
415
416
365
    $schema->storage->txn_rollback;
417
    $schema->storage->txn_rollback;
366
};
418
};
367
419
368
- 

Return to bug 28482