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

(-)a/Koha/REST/V1/Checkouts.pm (-2 / +13 lines)
Lines 23-28 use C4::Auth qw( haspermission ); Link Here
23
use C4::Context;
23
use C4::Context;
24
use C4::Circulation;
24
use C4::Circulation;
25
use Koha::Checkouts;
25
use Koha::Checkouts;
26
use Koha::Old::Checkouts;
26
27
27
use Try::Tiny;
28
use Try::Tiny;
28
29
Lines 42-49 List Koha::Checkout objects Link Here
42
43
43
sub list {
44
sub list {
44
    my $c = shift->openapi->valid_input or return;
45
    my $c = shift->openapi->valid_input or return;
46
    my $checked_in = $c->validation->param('checked_in');
45
    try {
47
    try {
46
        my $checkouts_set = Koha::Checkouts->new;
48
        my $checkouts_set;
49
        if ( $checked_in ) {
50
            $checkouts_set = Koha::Old::Checkouts->new;
51
        } else {
52
            $checkouts_set = Koha::Checkouts->new;
53
        }
47
        my $checkouts = $c->objects->search( $checkouts_set, \&_to_model, \&_to_api );
54
        my $checkouts = $c->objects->search( $checkouts_set, \&_to_model, \&_to_api );
48
        return $c->render( status => 200, openapi => $checkouts );
55
        return $c->render( status => 200, openapi => $checkouts );
49
    } catch {
56
    } catch {
Lines 70-76 get one checkout Link Here
70
sub get {
77
sub get {
71
    my $c = shift->openapi->valid_input or return;
78
    my $c = shift->openapi->valid_input or return;
72
79
73
    my $checkout = Koha::Checkouts->find( $c->validation->param('checkout_id') );
80
    my $checkout_id = $c->validation->param('checkout_id');
81
    my $checkout = Koha::Checkouts->find( $checkout_id );
82
    $checkout = Koha::Old::Checkouts->find( $checkout_id )
83
        unless ($checkout);
74
84
75
    unless ($checkout) {
85
    unless ($checkout) {
76
        return $c->render(
86
        return $c->render(
Lines 206-211 our $to_model_mapping = { Link Here
206
    last_renewed_date => 'lastreneweddate',
216
    last_renewed_date => 'lastreneweddate',
207
    checkout_date     => 'issuedate',
217
    checkout_date     => 'issuedate',
208
    note_date         => 'notedate',
218
    note_date         => 'notedate',
219
    checked_in        => undef,
209
};
220
};
210
221
211
1;
222
1;
(-)a/Koha/Schema/Result/OldIssue.pm (+5 lines)
Lines 236-241 __PACKAGE__->belongs_to( Link Here
236
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-07-23 13:51:40
236
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-07-23 13:51:40
237
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1f688Osvh/sxg2P/qffZ2g
237
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1f688Osvh/sxg2P/qffZ2g
238
238
239
__PACKAGE__->add_columns(
240
    '+auto_renew'      => { is_boolean => 1 },
241
    '+onsite_checkout' => { is_boolean => 1 }
242
);
243
239
__PACKAGE__->belongs_to(
244
__PACKAGE__->belongs_to(
240
    "borrower",
245
    "borrower",
241
    "Koha::Schema::Result::Borrower",
246
    "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 6-11 Link Here
6
      "tags": ["patrons", "checkouts"],
6
      "tags": ["patrons", "checkouts"],
7
      "parameters": [{
7
      "parameters": [{
8
        "$ref": "../parameters.json#/patron_id_qp"
8
        "$ref": "../parameters.json#/patron_id_qp"
9
      },{
10
        "name": "checked_in",
11
        "in": "query",
12
        "description": "By default, only current checkout are returned, when this is true, all checkouts (current and checked in) are returned as result.",
13
        "type": "boolean"
9
      }],
14
      }],
10
      "produces": [
15
      "produces": [
11
        "application/json"
16
        "application/json"
12
- 

Return to bug 17005