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
            $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 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, current checkouts are returned, when this is true then checked in checkouts are returned as result.",
13
        "type": "boolean"
9
      }],
14
      }],
10
      "produces": [
15
      "produces": [
11
        "application/json"
16
        "application/json"
12
- 

Return to bug 17005