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

(-)a/t/db_dependent/SIP/Transaction.t (-2 / +77 lines)
Lines 4-10 Link Here
4
# Current state is very rudimentary. Please help to extend it!
4
# Current state is very rudimentary. Please help to extend it!
5
5
6
use Modern::Perl;
6
use Modern::Perl;
7
use Test::More tests => 18;
7
use Test::More tests => 19;
8
use Test::Warn;
8
use Test::Warn;
9
9
10
use Koha::Database;
10
use Koha::Database;
Lines 1243-1246 subtest do_checkout_with_recalls => sub { Link Here
1243
    is( $recall2->status, 'fulfilled', 'Recall is fulfilled by checked out item' );
1243
    is( $recall2->status, 'fulfilled', 'Recall is fulfilled by checked out item' );
1244
};
1244
};
1245
1245
1246
subtest do_checkout_with_IssuingInProcess => sub {
1247
    plan tests => 8;
1248
1249
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
1250
    my $patron  = $builder->build_object(
1251
        {
1252
            class => 'Koha::Patrons',
1253
            value => {
1254
                branchcode => $library->branchcode,
1255
            }
1256
        }
1257
    );
1258
    my $fine = $builder->build_object(
1259
        {
1260
            class => 'Koha::Account::Lines',
1261
            value => {
1262
                borrowernumber  => $patron->id, amount            => '4.000000', description => 'Manual',
1263
                debit_type_code => 'MANUAL',    amountoutstanding => '4.000000'
1264
            }
1265
        }
1266
    );
1267
1268
    t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } );
1269
    t::lib::Mocks::mock_preference( 'IssuingInProcess', 0 );
1270
    t::lib::Mocks::mock_preference( 'noissuescharge', 2 );
1271
1272
    my $item = $builder->build_sample_item(
1273
        {
1274
            library => $library->branchcode,
1275
        }
1276
    );
1277
1278
    my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
1279
    $itemtype->set( { rentalcharge => 2 } )->store;
1280
1281
    Koha::CirculationRules->set_rule(
1282
        {
1283
            branchcode   => undef,
1284
            categorycode => undef,
1285
            itemtype     => undef,
1286
            rule_name    => 'maxissueqty',
1287
            rule_value   => '10',
1288
        }
1289
    );
1290
1291
    my $sip_patron     = C4::SIP::ILS::Patron->new( $patron->cardnumber );
1292
    my $sip_item       = C4::SIP::ILS::Item->new( $item->barcode );
1293
    my $co_transaction = C4::SIP::ILS::Transaction::Checkout->new();
1294
    $co_transaction->fee_ack('Y');
1295
1296
    is( ref $co_transaction,                  "C4::SIP::ILS::Transaction::Checkout", "New transaction created" );
1297
    is( $co_transaction->patron($sip_patron), $sip_patron,                           "Patron assigned to transaction" );
1298
    is( $co_transaction->item($sip_item),     $sip_item,                             "Item assigned to transaction" );
1299
1300
    $co_transaction->do_checkout();
1301
    is( $patron->checkouts->count, 0, 'Checkout was not done due to fines exceeding noissuescharge at start of transaction, and IssuingInProcess disabled' );
1302
1303
    t::lib::Mocks::mock_preference( 'noissuescharge', 5 );
1304
    $co_transaction->do_checkout();
1305
    is( $patron->checkouts->count, 0, 'Checkout was not done due to fines exceeding noissuescharge if checkout made, and IssuingInProcess disabled' );
1306
1307
    t::lib::Mocks::mock_preference( 'IssuingInProcess', 1 );
1308
    t::lib::Mocks::mock_preference( 'noissuescharge', 2 );
1309
    $co_transaction->do_checkout();
1310
    is( $patron->checkouts->count, 0, 'Checkout was not done due to fines exceeding noissuescharge at start of transaction, with IssuingInProcess enabled' );
1311
1312
    t::lib::Mocks::mock_preference( 'noissuescharge', 5 );
1313
    t::lib::Mocks::mock_preference( 'AllFinesNeedOverride', 1 );
1314
    $co_transaction->do_checkout();
1315
    is( $patron->checkouts->count, 0, 'Checkout was not done due to fines and AllFinesNeedOverride enabled' );
1316
1317
    t::lib::Mocks::mock_preference( 'AllFinesNeedOverride', 0 );
1318
    $co_transaction->do_checkout();
1319
    is( $patron->checkouts->count, 1, 'Checkout done due to fines not exceeding noissuescharge at start of transaction and IssuingInProcess enabled' );
1320
};
1321
1246
$schema->storage->txn_rollback;
1322
$schema->storage->txn_rollback;
1247
- 

Return to bug 32602