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

(-)a/Koha/REST/V1/Checkouts.pm (-2 / +13 lines)
Lines 25-30 use C4::Context; Link Here
25
use C4::Circulation;
25
use C4::Circulation;
26
use Koha::Checkouts;
26
use Koha::Checkouts;
27
use Koha::IssuingRules;
27
use Koha::IssuingRules;
28
use Koha::Old::Checkouts;
28
29
29
use Try::Tiny;
30
use Try::Tiny;
30
31
Lines 44-51 List Koha::Checkout objects Link Here
44
45
45
sub list {
46
sub list {
46
    my $c = shift->openapi->valid_input or return;
47
    my $c = shift->openapi->valid_input or return;
48
    my $checked_in = $c->validation->param('checked_in');
47
    try {
49
    try {
48
        my $checkouts_set = Koha::Checkouts->new;
50
        my $checkouts_set;
51
        if ( $checked_in ) {
52
            $checkouts_set = Koha::Old::Checkouts->new;
53
        } else {
54
            my $checkouts_set = Koha::Checkouts->new;
55
        }
49
        my $checkouts = $c->objects->search( $checkouts_set, \&_to_model, \&_to_api );
56
        my $checkouts = $c->objects->search( $checkouts_set, \&_to_model, \&_to_api );
50
        return $c->render( status => 200, openapi => $checkouts );
57
        return $c->render( status => 200, openapi => $checkouts );
51
    } catch {
58
    } catch {
Lines 72-78 get one checkout Link Here
72
sub get {
79
sub get {
73
    my $c = shift->openapi->valid_input or return;
80
    my $c = shift->openapi->valid_input or return;
74
81
75
    my $checkout = Koha::Checkouts->find( $c->validation->param('checkout_id') );
82
    my $checkout_id = $c->validation->param('checkout_id');
83
    my $checkout = Koha::Checkouts->find( $checkout_id );
84
    $checkout = Koha::Old::Checkouts->find( $checkout_id )
85
        unless ($checkout);
76
86
77
    unless ($checkout) {
87
    unless ($checkout) {
78
        return $c->render(
88
        return $c->render(
Lines 251-256 our $to_model_mapping = { Link Here
251
    last_renewed_date => 'lastreneweddate',
261
    last_renewed_date => 'lastreneweddate',
252
    checkout_date     => 'issuedate',
262
    checkout_date     => 'issuedate',
253
    note_date         => 'notedate',
263
    note_date         => 'notedate',
264
    checked_in        => undef,
254
};
265
};
255
266
256
1;
267
1;
(-)a/Koha/Schema/Result/OldIssue.pm (+5 lines)
Lines 237-242 __PACKAGE__->belongs_to( Link Here
237
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-04-10 19:55:44
237
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-04-10 19:55:44
238
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:E2N2paWcCHg916100ry+2A
238
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:E2N2paWcCHg916100ry+2A
239
239
240
__PACKAGE__->add_columns(
241
    '+auto_renew'      => { is_boolean => 1 },
242
    '+onsite_checkout' => { is_boolean => 1 }
243
);
244
240
__PACKAGE__->belongs_to(
245
__PACKAGE__->belongs_to(
241
    "borrower",
246
    "borrower",
242
    "Koha::Schema::Result::Borrower",
247
    "Koha::Schema::Result::Borrower",
(-)a/api/v1/swagger/definitions/checkout.json (-1 / +1 lines)
Lines 23-29 Link Here
23
    },
23
    },
24
    "checkin_date": {
24
    "checkin_date": {
25
      "type": ["string", "null"],
25
      "type": ["string", "null"],
26
      "format": "date",
26
      "format": "date-time",
27
      "description": "Date the item was returned"
27
      "description": "Date the item was returned"
28
    },
28
    },
29
    "last_renewed_date": {
29
    "last_renewed_date": {
(-)a/api/v1/swagger/paths/checkouts.json (-1 / +5 lines)
Lines 10-15 Link Here
10
        "$ref": "../parameters.json#/page"
10
        "$ref": "../parameters.json#/page"
11
      }, {
11
      }, {
12
        "$ref": "../parameters.json#/per_page"
12
        "$ref": "../parameters.json#/per_page"
13
      },{
14
        "name": "checked_in",
15
        "in": "query",
16
        "description": "By default, current checkouts are returned, when this is true then checked in checkouts are returned as result.",
17
        "type": "boolean"
13
      }],
18
      }],
14
      "produces": [
19
      "produces": [
15
        "application/json"
20
        "application/json"
16
- 

Return to bug 17005