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

(-)a/t/db_dependent/Circulation.t (-2 / +80 lines)
Lines 6188-6194 subtest 'Lost status does not change when preferences are set to 0' => sub { Link Here
6188
    )->store();
6188
    )->store();
6189
6189
6190
    # Test for UpdateItemLostStatusWhenPaid
6190
    # Test for UpdateItemLostStatusWhenPaid
6191
    t::lib::Mocks::mock_preference( 'UpdateItemLostStatusWhenPaid', 0 );
6191
    t::lib::Mocks::mock_preference( 'UpdateItemLostStatusWhenPaid',      0 );
6192
    t::lib::Mocks::mock_preference( 'UpdateItemWithdrawnStatusWhenPaid', 0 );
6192
6193
6193
    my $paymentLine = Koha::Account::Line->new(
6194
    my $paymentLine = Koha::Account::Line->new(
6194
        {
6195
        {
Lines 6316-6321 subtest 'Update lost item to authorized value on payment of balance' => sub { Link Here
6316
    }
6317
    }
6317
};
6318
};
6318
6319
6320
# Test for UpdateItemWithdrawnStatusWhenPaid
6321
subtest 'Update lost item to authorized value on payment of balance' => sub {
6322
    plan tests => 8;
6323
6324
    my $library = $builder->build_object( { class => "Koha::Libraries" } );
6325
    my $manager = $builder->build_object( { class => "Koha::Patrons" } );
6326
    t::lib::Mocks::mock_userenv( { patron => $manager, branchcode => $manager->branchcode } );
6327
6328
    my $biblio = $builder->build_sample_biblio;
6329
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
6330
6331
    my @prefs = (
6332
        { withdrawn => 0, paid => 0, writeoff => 0 },
6333
        { withdrawn => 0, paid => 1, writeoff => 0 },
6334
        { withdrawn => 0, paid => 1, writeoff => 1 },
6335
        { withdrawn => 0, paid => 0, writeoff => 1 },
6336
        { withdrawn => 1, paid => 0, writeoff => 0 },
6337
        { withdrawn => 1, paid => 1, writeoff => 0 },
6338
        { withdrawn => 1, paid => 1, writeoff => 1 },
6339
        { withdrawn => 1, paid => 0, writeoff => 1 }
6340
    );
6341
    foreach my $pref (@prefs) {
6342
        t::lib::Mocks::mock_preference( 'UpdateItemWithdrawnStatusWhenPaid', $pref->{withdrawn} );
6343
        t::lib::Mocks::mock_preference( 'UpdateItemLostStatusWhenPaid',      $pref->{paid} );
6344
        t::lib::Mocks::mock_preference( 'UpdateItemLostStatusWhenWriteoff',  $pref->{writeoff} );
6345
6346
        my $item = $builder->build_sample_item(
6347
            {
6348
                biblionumber     => $biblio->biblionumber,
6349
                library          => $library->branchcode,
6350
                replacementprice => 99,
6351
                itype            => $itemtype,
6352
                itemlost         => 1,
6353
            }
6354
        );
6355
6356
        my $debitCharge = Koha::Account::Line->new(
6357
            {
6358
                borrowernumber    => $patron->borrowernumber,
6359
                debit_type_code   => 'LOST',
6360
                status            => undef,
6361
                itemnumber        => $item->itemnumber,
6362
                amount            => 12,
6363
                amountoutstanding => 12,
6364
                interface         => 'something',
6365
            }
6366
        )->store();
6367
6368
        my $paymentLine = Koha::Account::Line->new(
6369
            {
6370
                borrowernumber    => $patron->borrowernumber,
6371
                credit_type_code  => 'CREDIT',
6372
                status            => undef,
6373
                itemnumber        => $item->itemnumber,
6374
                amountoutstanding => 0 - 12,
6375
                amount            => 0 - 12,
6376
                interface         => 'something',
6377
            }
6378
        )->store();
6379
6380
        my $offset = Koha::Account::Offset->new(
6381
            {
6382
                credit_id => $paymentLine->id,
6383
                debit_id  => $debitCharge->id,
6384
                type      => 'APPLY',
6385
                amount    => 0
6386
            }
6387
        )->store();
6388
6389
        $paymentLine->apply( { debits => [$debitCharge] } );
6390
6391
        is(
6392
            Koha::Items->find( $item->itemnumber )->withdrawn, $pref->{withdrawn},
6393
            "Payment should set withdrawn to status $pref->{withdrawn}"
6394
        );
6395
    }
6396
};
6397
6319
# Test for UpdateItemLostStatusWhenWriteOff
6398
# Test for UpdateItemLostStatusWhenWriteOff
6320
subtest 'Update lost item to authorized value on write-off of balance' => sub {
6399
subtest 'Update lost item to authorized value on write-off of balance' => sub {
6321
    plan tests => 5;
6400
    plan tests => 5;
6322
- 

Return to bug 41730