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

(-)a/C4/SIP/ILS/Transaction/Hold.pm (-13 / +18 lines)
Lines 7-13 use Modern::Perl; Link Here
7
7
8
use C4::SIP::ILS::Transaction;
8
use C4::SIP::ILS::Transaction;
9
9
10
use C4::Reserves qw( CalculatePriority AddReserve ModReserve );
10
use C4::Reserves qw( CalculatePriority AddReserve ModReserve CanItemBeReserved );
11
use Koha::Holds;
11
use Koha::Holds;
12
use Koha::Patrons;
12
use Koha::Patrons;
13
use Koha::Items;
13
use Koha::Items;
Lines 61-78 sub do_hold { Link Here
61
        return $self;
61
        return $self;
62
    }
62
    }
63
63
64
    my $priority = C4::Reserves::CalculatePriority($item->biblionumber);
64
    my $canReserve = CanItemBeReserved($patron, $item, $branch);
65
    AddReserve(
65
    if ($canReserve->{status} eq 'OK') {
66
        {
66
        my $priority = C4::Reserves::CalculatePriority($item->biblionumber);
67
            priority       => $priority,
67
        AddReserve(
68
            branchcode     => $branch,
68
            {
69
            borrowernumber => $patron->borrowernumber,
69
                priority       => $priority,
70
            biblionumber   => $item->biblionumber
70
                branchcode     => $branch,
71
        }
71
                borrowernumber => $patron->borrowernumber,
72
    );
72
                biblionumber   => $item->biblionumber
73
73
            }
74
    # unfortunately no meaningful return value
74
        );
75
    $self->ok(1);
75
76
        $self->ok(1);
77
    } else {
78
        $self->ok(0);
79
    }
80
76
    return $self;
81
    return $self;
77
}
82
}
78
83
(-)a/t/db_dependent/SIP/ILS.t (-1 / +8 lines)
Lines 74-80 is( $ils->test_cardnumber_compare( 'A1234', 'b1234' ), Link Here
74
subtest add_hold => sub {
74
subtest add_hold => sub {
75
    plan tests => 4;
75
    plan tests => 4;
76
76
77
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
77
    my $library = $builder->build_object(
78
        {
79
            class => 'Koha::Libraries',
80
            value => {
81
                pickup_location => 1
82
            }
83
        }
84
    );
78
    my $patron = $builder->build_object(
85
    my $patron = $builder->build_object(
79
        {
86
        {
80
            class => 'Koha::Patrons',
87
            class => 'Koha::Patrons',
(-)a/t/db_dependent/SIP/Transaction.t (-3 / +64 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 => 12;
7
use Test::More tests => 13;
8
8
9
use Koha::Database;
9
use Koha::Database;
10
use t::lib::TestBuilder;
10
use t::lib::TestBuilder;
Lines 212-218 subtest cancel_hold => sub { Link Here
212
subtest do_hold => sub {
212
subtest do_hold => sub {
213
    plan tests => 8;
213
    plan tests => 8;
214
214
215
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
215
    my $library = $builder->build_object(
216
        {
217
            class => 'Koha::Libraries',
218
            value => {
219
                pickup_location => 1
220
            }
221
        }
222
    );
216
    my $patron_1 = $builder->build_object(
223
    my $patron_1 = $builder->build_object(
217
        {
224
        {
218
            class => 'Koha::Patrons',
225
            class => 'Koha::Patrons',
Lines 271-276 subtest do_hold => sub { Link Here
271
    is( $THE_hold->branchcode, $patron_2->branchcode, 'Hold placed from SIP should have the branchcode set' );
278
    is( $THE_hold->branchcode, $patron_2->branchcode, 'Hold placed from SIP should have the branchcode set' );
272
};
279
};
273
280
281
subtest "Placing holds via SIP check CanItemBeReserved" => sub {
282
    plan tests => 4;
283
284
    my $library = $builder->build_object(
285
        {
286
            class => 'Koha::Libraries',
287
            value => {
288
                pickup_location => 0
289
            }
290
        }
291
    );
292
    my $patron_1 = $builder->build_object(
293
        {
294
            class => 'Koha::Patrons',
295
            value => {
296
                branchcode => $library->branchcode,
297
            }
298
        }
299
    );
300
    my $patron_2 = $builder->build_object(
301
        {
302
            class => 'Koha::Patrons',
303
            value => {
304
                branchcode   => $library->branchcode,
305
                categorycode => $patron_1->categorycode,
306
            }
307
        }
308
    );
309
310
    t::lib::Mocks::mock_userenv(
311
        { branchcode => $library->branchcode, flags => 1 } );
312
313
    my $item = $builder->build_sample_item(
314
        {
315
            library => $library->branchcode,
316
        }
317
    );
318
319
    my $sip_patron  = C4::SIP::ILS::Patron->new( $patron_2->cardnumber );
320
    my $sip_item    = C4::SIP::ILS::Item->new( $item->barcode );
321
    my $transaction = C4::SIP::ILS::Transaction::Hold->new();
322
    is(
323
        ref $transaction,
324
        "C4::SIP::ILS::Transaction::Hold",
325
        "New transaction created"
326
    );
327
    is( $transaction->patron($sip_patron),
328
        $sip_patron, "Patron assigned to transaction" );
329
    is( $transaction->item($sip_item),
330
        $sip_item, "Item assigned to transaction" );
331
    my $hold = $transaction->do_hold();
332
333
    is( $transaction->ok, 0, "Hold was not allowed" );
334
};
335
274
subtest do_checkin => sub {
336
subtest do_checkin => sub {
275
    plan tests => 12;
337
    plan tests => 12;
276
338
277
- 

Return to bug 29094