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

(-)a/Koha/REST/V1/Checkouts.pm (-1 / +19 lines)
Lines 189-194 sub add { Link Here
189
    my $item_id   = $body->{item_id};
189
    my $item_id   = $body->{item_id};
190
    my $patron_id = $body->{patron_id};
190
    my $patron_id = $body->{patron_id};
191
    my $onsite    = $body->{onsite_checkout};
191
    my $onsite    = $body->{onsite_checkout};
192
    my $barcode   = $body->{external_id};
192
193
193
    if ( $c->stash('is_public')
194
    if ( $c->stash('is_public')
194
        && !C4::Context->preference('OpacTrustedCheckout') )
195
        && !C4::Context->preference('OpacTrustedCheckout') )
Lines 203-209 sub add { Link Here
203
    }
204
    }
204
205
205
    return try {
206
    return try {
206
        my $item = Koha::Items->find($item_id);
207
208
        unless ($item_id or $barcode){
209
            return $c->render(
210
                status  => 400,
211
                openapi => {
212
                    error      => 'Missing or wrong parameters',
213
                    error_code => 'MISSING_OR_WRONG_PARAMETERS',
214
                }
215
            );
216
        }
217
218
        my $item;
219
        if ($item_id){
220
            $item = Koha::Items->find($item_id);
221
        }
222
        if ($barcode){
223
             $item = Koha::Items->find({ barcode => $barcode });
224
        }
207
        unless ($item) {
225
        unless ($item) {
208
            return $c->render(
226
            return $c->render(
209
                status  => 409,
227
                status  => 409,
(-)a/api/v1/swagger/definitions/checkout.yaml (-1 / +5 lines)
Lines 11-17 properties: Link Here
11
    type:
11
    type:
12
      - integer
12
      - integer
13
      - "null"
13
      - "null"
14
    description: internal identifier of checked out item
14
  external_id:
15
    type:
16
      - string
17
      - "null"
18
    description: other identifier of checked out item f.e. barcode
15
  due_date:
19
  due_date:
16
    type: string
20
    type: string
17
    format: date-time
21
    format: date-time
(-)a/t/db_dependent/api/v1/checkouts.t (-4 / +8 lines)
Lines 439-445 subtest 'get_availability' => sub { Link Here
439
439
440
subtest 'add checkout' => sub {
440
subtest 'add checkout' => sub {
441
441
442
    plan tests => 10;
442
    plan tests => 12;
443
443
444
    $schema->storage->txn_begin;
444
    $schema->storage->txn_begin;
445
    my $librarian = $builder->build_object(
445
    my $librarian = $builder->build_object(
Lines 465-472 subtest 'add checkout' => sub { Link Here
465
465
466
    my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode};
466
    my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode};
467
467
468
    my $item1    = $builder->build_sample_item;
468
    my $item1         = $builder->build_sample_item;
469
    my $item1_id = $item1->id;
469
    my $item1_id      = $item1->id;
470
    my $item1_barcode = $item1->barcode;
470
471
471
    my %issuingimpossible = ();
472
    my %issuingimpossible = ();
472
    my %needsconfirmation = ();
473
    my %needsconfirmation = ();
Lines 491-496 subtest 'add checkout' => sub { Link Here
491
    $t->post_ok( "//$userid:$password@/api/v1/checkouts" => json => { item_id => $item1_id, patron_id => $patron_id } )
492
    $t->post_ok( "//$userid:$password@/api/v1/checkouts" => json => { item_id => $item1_id, patron_id => $patron_id } )
492
        ->status_is(201);
493
        ->status_is(201);
493
494
495
    $t->post_ok( "//$userid:$password@/api/v1/checkouts" => json => { external_id => $item1_barcode, patron_id => $patron_id } )
496
        ->status_is(201);
497
498
494
    # Needs confirm
499
    # Needs confirm
495
    %needsconfirmation = ( confirm1 => 1, confirm2 => 'please' );
500
    %needsconfirmation = ( confirm1 => 1, confirm2 => 'please' );
496
    $t->post_ok(
501
    $t->post_ok(
497
- 

Return to bug 37253