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

(-)a/C4/Circulation.pm (+1 lines)
Lines 1539-1544 sub AddIssue { Link Here
1539
        # check if we just renew the issue.
1539
        # check if we just renew the issue.
1540
        if ( $actualissue and $actualissue->borrowernumber eq $borrower->{'borrowernumber'}
1540
        if ( $actualissue and $actualissue->borrowernumber eq $borrower->{'borrowernumber'}
1541
                and not $switch_onsite_checkout ) {
1541
                and not $switch_onsite_checkout ) {
1542
1542
            $datedue = AddRenewal(
1543
            $datedue = AddRenewal(
1543
                $borrower->{'borrowernumber'},
1544
                $borrower->{'borrowernumber'},
1544
                $item_object->itemnumber,
1545
                $item_object->itemnumber,
(-)a/Koha/Illbackends/FreeForm (+1 lines)
Line 0 Link Here
1
Subproject commit 71409f3f23d195cc9cb1a34a1adc59518e9ea0f6
(-)a/Koha/REST/V1/Checkouts.pm (-2 / +1 lines)
Lines 25-31 use Encode; Link Here
25
25
26
use C4::Auth qw( haspermission );
26
use C4::Auth qw( haspermission );
27
use C4::Context;
27
use C4::Context;
28
use C4::Circulation qw( AddIssue AddRenewal );
28
use C4::Circulation qw( AddIssue AddRenewal CanBookBeRenewed );
29
use Koha::Checkouts;
29
use Koha::Checkouts;
30
use Koha::Old::Checkouts;
30
use Koha::Old::Checkouts;
31
31
Lines 272-278 sub delete { Link Here
272
272
273
    my $body      = $c->validation->param('body');
273
    my $body      = $c->validation->param('body');
274
    my $item_id   = $body->{item_id};
274
    my $item_id   = $body->{item_id};
275
276
    return try {
275
    return try {
277
        my $item = Koha::Items->find($item_id);
276
        my $item = Koha::Items->find($item_id);
278
        unless ($item) {
277
        unless ($item) {
(-)a/api/v1/swagger/paths/checkouts.yaml (-3 / +9 lines)
Lines 124-138 Link Here
124
      permissions:
124
      permissions:
125
        circulate: circulate_remaining_permissions
125
        circulate: circulate_remaining_permissions
126
  delete:
126
  delete:
127
    x-mojo-to: Checkout#delete
127
    x-mojo-to: Checkouts#delete
128
    operationId: deletecheckout
128
    operationId: deletecheckout
129
    tags:
129
    tags:
130
      - checkouts
130
      - checkouts
131
      - items
131
      - items
132
    summary: Check in an item
132
    summary: Check in an item
133
    parameters:
133
    parameters:
134
      - $ref: "../swagger.yaml#/parameters/item_id_pp"
134
      - name: body
135
      - $ref: "../swagger.yaml#/parameters/library_id_qp"
135
        in: body
136
        description: A JSON object containing information about the checkout
137
        required: true
138
        schema:
139
          $ref: "../swagger.yaml#/definitions/checkout"
140
    consumes:
141
      - application/json
136
    produces:
142
    produces:
137
      - application/json
143
      - application/json
138
    responses:
144
    responses:
(-)a/api/v1/swagger/swagger.yaml (-2 lines)
Lines 199-206 paths: Link Here
199
    $ref: "./paths/checkouts.yaml#/~1checkouts~1{checkout_id}~1renewal"
199
    $ref: "./paths/checkouts.yaml#/~1checkouts~1{checkout_id}~1renewal"
200
  "/checkouts/availability":
200
  "/checkouts/availability":
201
    $ref: "./paths/checkouts.yaml#/~1checkouts~1availability"
201
    $ref: "./paths/checkouts.yaml#/~1checkouts~1availability"
202
  "/checkouts/{item_id}":
203
    $ref: "./paths/checkouts.yaml#/~1checkouts~1{item_id}"
204
  /circulation-rules/kinds:
202
  /circulation-rules/kinds:
205
    $ref: ./paths/circulation-rules.yaml#/~1circulation-rules~1kinds
203
    $ref: ./paths/circulation-rules.yaml#/~1circulation-rules~1kinds
206
  /cities:
204
  /cities:
(-)a/t/db_dependent/api/v1/checkouts.t (-13 / +19 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 101;
20
use Test::More tests => 102;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Mojo;
22
use Test::Mojo;
23
use t::lib::Mocks;
23
use t::lib::Mocks;
Lines 253-258 subtest 'get_availability' => sub { Link Here
253
    my $patron = $builder->build_object(
253
    my $patron = $builder->build_object(
254
        {
254
        {
255
            class => 'Koha::Patrons',
255
            class => 'Koha::Patrons',
256
256
            value => { flags => 0 }
257
            value => { flags => 0 }
257
        }
258
        }
258
    );
259
    );
Lines 325-330 subtest 'get_availability' => sub { Link Here
325
    )->status_is(200)->json_is( '/blockers' => {} )
326
    )->status_is(200)->json_is( '/blockers' => {} )
326
      ->json_is( '/confirms' => { confirm1 => 1, confirm2 => 'please' } )
327
      ->json_is( '/confirms' => { confirm1 => 1, confirm2 => 'please' } )
327
      ->json_is( '/warnings' => {} )
328
      ->json_is( '/warnings' => {} )
329
328
      ->json_is( '/confirmation_token' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb25maXJtMSI6MSwiY29uZmlybTIiOjF9.4QBpITwnIGOAfohyKjaFDoeBWnGmQTdyJrPn9pavArw' );
330
      ->json_is( '/confirmation_token' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb25maXJtMSI6MSwiY29uZmlybTIiOjF9.4QBpITwnIGOAfohyKjaFDoeBWnGmQTdyJrPn9pavArw' );
329
331
330
    $schema->storage->txn_rollback;
332
    $schema->storage->txn_rollback;
Lines 349-354 subtest 'add checkout' => sub { Link Here
349
        {
351
        {
350
            class => 'Koha::Patrons',
352
            class => 'Koha::Patrons',
351
            value => { flags => 0 }
353
            value => { flags => 0 }
354
352
        }
355
        }
353
    );
356
    );
354
    my $unauth_password = 'thePassword000';
357
    my $unauth_password = 'thePassword000';
Lines 362-367 subtest 'add checkout' => sub { Link Here
362
    my $item1    = $builder->build_sample_item;
365
    my $item1    = $builder->build_sample_item;
363
    my $item1_id = $item1->id;
366
    my $item1_id = $item1->id;
364
367
368
    my $item2    = $builder->build_sample_item;
369
    my $item2_id = $item2->id;
370
365
    my %issuingimpossible = ();
371
    my %issuingimpossible = ();
366
    my %needsconfirmation = ();
372
    my %needsconfirmation = ();
367
    my %alerts            = ();
373
    my %alerts            = ();
Lines 399-406 subtest 'add checkout' => sub { Link Here
399
405
400
    my $token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb25maXJtMSI6MSwiY29uZmlybTIiOjF9.4QBpITwnIGOAfohyKjaFDoeBWnGmQTdyJrPn9pavArw";
406
    my $token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb25maXJtMSI6MSwiY29uZmlybTIiOjF9.4QBpITwnIGOAfohyKjaFDoeBWnGmQTdyJrPn9pavArw";
401
    $t->post_ok(
407
    $t->post_ok(
408
402
        "//$userid:$password@/api/v1/checkouts?confirmation=$token" => json => {
409
        "//$userid:$password@/api/v1/checkouts?confirmation=$token" => json => {
403
            item_id            => $item1_id,
410
            item_id            => $item2_id,
404
            patron_id          => $patron_id
411
            patron_id          => $patron_id
405
        }
412
        }
406
    )->status_is(201)->or(sub { diag $t->tx->res->body });
413
    )->status_is(201)->or(sub { diag $t->tx->res->body });
Lines 411-417 subtest 'add checkout' => sub { Link Here
411
418
412
subtest 'delete checkout' => sub {
419
subtest 'delete checkout' => sub {
413
420
414
    plan tests => 4;
421
    plan tests => 11;
415
422
416
    $schema->storage->txn_begin;
423
    $schema->storage->txn_begin;
417
    my $librarian = $builder->build_object(
424
    my $librarian = $builder->build_object(
Lines 435-470 subtest 'delete checkout' => sub { Link Here
435
        { password => $unauth_password, skip_validattion => 1 } );
442
        { password => $unauth_password, skip_validattion => 1 } );
436
    my $unauth_userid = $patron->userid;
443
    my $unauth_userid = $patron->userid;
437
444
438
    my $branch = $builder->build_sample_branch;
445
    my $branch     = $builder->build_object( { class => 'Koha::Libraries' } );
439
    my $library_id = $branch->id;
446
    my $library_id = $branch->id;
440
    my $item1    = $builder->build_sample_item;
447
    my $item1      = $builder->build_sample_item;
441
    my $item1_id = $item1->id;
448
    my $item1_id   = $item1->id;
442
443
449
444
    $t->delete_ok(
450
    $t->delete_ok(
445
        "//$unauth_userid:$unauth_password@/api/v1/checkouts" => json =>
451
        "//$unauth_userid:$unauth_password@/api/v1/checkouts" => json =>
446
          { item_id => $item1_id, library_id => $library_id } )->status_is(403)
452
          { item_id => $item1_id, library_id => $library_id } )->status_is(403)
447
      ->json_is(
453
      ->json_is(
448
        {
454
        {
449
            error => "checkin not allowed",
455
            error => "Authorization failure. Missing required permission(s).",
450
            required_permissions =>
456
            required_permissions =>
451
              { circulate => "circulate_remaining_permissions" }
457
              { circulate => "circulate_remaining_permissions" }
452
        }
458
        }
453
      );
459
      );
454
460
455
    $t->delete_ok( "//$userid:$password@/api/v1/checkouts" => json =>
461
    $t->delete_ok( "//$userid:$password@/api/v1/checkouts" => json =>
456
          { item_id => $item1_id, patron_id => $library_id } )->status_is(400)
462
          { item_id => $item1_id, library_id => $library_id } )->status_is(400)
457
      ->json_is(
463
      ->json_is(
458
        '/error' => 'Item not checked out' );
464
        '/error' => 'Item not checked out' );
459
465
460
    AddIssue( $patron, $item1->barcode );
466
    AddIssue( $patron->unblessed, $item1->barcode );
461
    $t->delete_ok( "//$userid:$password@/api/v1/checkouts" => json =>
467
    $t->delete_ok( "//$userid:$password@/api/v1/checkouts" => json =>
462
          { item_id => $item1_id, patron_id => $library_id } )->status_is(201);
468
          { item_id => $item1_id, library_id => $library_id } )->status_is(201);
463
469
464
    $item1->delete;
470
    $item1->delete;
465
    $t->delete_ok( "//$userid:$password@/api/v1/checkouts/" => json =>
471
    $t->delete_ok( "//$userid:$password@/api/v1/checkouts/" => json =>
466
            { item_id => $item1_id, patron_id => $library_id } )->status_is(409)
472
            { item_id => $item1_id, library_id => $library_id } )->status_is(409)
467
      ->json_is(
473
      ->json_is(
468
        '/error' => 'Item not found' );
474
        '/error' => 'Item not found' );
475
469
    $schema->storage->txn_rollback;
476
    $schema->storage->txn_rollback;
470
};
477
};
471
- 

Return to bug 24401