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

(-)a/Koha/Checkout.pm (-1 / +1 lines)
Lines 26-32 use Try::Tiny; Link Here
26
26
27
use Koha::Checkouts::ReturnClaims;
27
use Koha::Checkouts::ReturnClaims;
28
use Koha::Database;
28
use Koha::Database;
29
use Koha::DateUtils;
29
use Koha::DateUtils qw(dt_from_string);
30
use Koha::Items;
30
use Koha::Items;
31
use Koha::Libraries;
31
use Koha::Libraries;
32
32
(-)a/Koha/Old/Checkout.pm (-2 / +64 lines)
Lines 18-25 package Koha::Old::Checkout; Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Koha::Database;
20
use Koha::Database;
21
use Koha::DateUtils qw(dt_from_string);
21
22
22
use base qw(Koha::Checkout);
23
use base qw(Koha::Object);
23
24
24
=head1 NAME
25
=head1 NAME
25
26
Lines 54-60 Return the patron for who the checkout has been done Link Here
54
sub patron {
55
sub patron {
55
    my ( $self ) = @_;
56
    my ( $self ) = @_;
56
    my $patron_rs = $self->_result->borrower;
57
    my $patron_rs = $self->_result->borrower;
57
    return unless $patron_rs;
58
    return Koha::Patron->_new_from_dbic( $patron_rs );
58
    return Koha::Patron->_new_from_dbic( $patron_rs );
59
}
59
}
60
60
Lines 79-84 sub to_api_mapping { Link Here
79
    };
79
    };
80
}
80
}
81
81
82
=head3 claim_returned
83
84
my $return_claim = $checkout->claim_returned();
85
86
=cut
87
88
sub claim_returned {
89
    my ( $self, $params ) = @_;
90
91
    my $charge_lost_fee = $params->{charge_lost_fee};
92
93
    try {
94
        $self->_result->result_source->schema->txn_do(
95
            sub {
96
                my $claim = Koha::Checkouts::ReturnClaim->new(
97
                    {
98
                        issue_id       => $self->id,
99
                        itemnumber     => $self->itemnumber,
100
                        borrowernumber => $self->borrowernumber,
101
                        notes          => $params->{notes},
102
                        created_by     => $params->{created_by},
103
                        created_on     => dt_from_string,
104
                    }
105
                )->store();
106
107
                my $ClaimReturnedLostValue = C4::Context->preference('ClaimReturnedLostValue');
108
                C4::Items::ModItem( { itemlost => $ClaimReturnedLostValue }, undef, $self->itemnumber );
109
110
                my $ClaimReturnedChargeFee = C4::Context->preference('ClaimReturnedChargeFee');
111
                $charge_lost_fee =
112
                    $ClaimReturnedChargeFee eq 'charge'    ? 1
113
                : $ClaimReturnedChargeFee eq 'no_charge' ? 0
114
                :   $charge_lost_fee;    # $ClaimReturnedChargeFee eq 'ask'
115
                C4::Circulation::LostItem( $self->itemnumber, 'claim_returned' ) if $charge_lost_fee;
116
117
                return $claim;
118
            }
119
        );
120
    }
121
    catch {
122
        if ( $_->isa('Koha::Exceptions::Exception') ) {
123
            $_->rethrow();
124
        }
125
        else {
126
            # ?
127
            Koha::Exceptions::Exception->throw( "Unhandled exception" );
128
        }
129
    };
130
}
131
132
=head3 library
133
134
my $library = $checkout->library;
135
136
=cut
137
138
sub library {
139
    my ($self) = @_;
140
141
    my $library_rs = $self->_result->branch;
142
    return Koha::Library->_new_from_dbic( $library_rs );
143
}
82
=head2 Internal methods
144
=head2 Internal methods
83
145
84
=head3 _type
146
=head3 _type
(-)a/Koha/Old/Checkouts.pm (-1 / +1 lines)
Lines 20-26 use Modern::Perl; Link Here
20
use Koha::Database;
20
use Koha::Database;
21
use Koha::Old::Checkout;
21
use Koha::Old::Checkout;
22
22
23
use base qw(Koha::Checkouts);
23
use base qw(Koha::Objects);
24
24
25
sub _type {
25
sub _type {
26
    return 'OldIssue';
26
    return 'OldIssue';
(-)a/Koha/Schema/Result/OldIssue.pm (-11 / +34 lines)
Lines 233-248 __PACKAGE__->belongs_to( Link Here
233
  },
233
  },
234
);
234
);
235
235
236
__PACKAGE__->belongs_to(
237
  "branch",
238
  "Koha::Schema::Result::Branch",
239
  { branchcode => "branchcode" },
240
  {
241
    is_deferrable => 1,
242
    join_type     => "LEFT",
243
  },
244
);
245
246
236
247
# 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
248
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:E2N2paWcCHg916100ry+2A
238
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:E2N2paWcCHg916100ry+2A
Lines 252-257 __PACKAGE__->add_columns( Link Here
252
    '+onsite_checkout' => { is_boolean => 1 }
242
    '+onsite_checkout' => { is_boolean => 1 }
253
);
243
);
254
244
245
=head2 borrower
246
247
Type: belongs_to
248
249
Related object: L<Koha::Schema::Result::Borrower>
250
251
=cut
252
255
__PACKAGE__->belongs_to(
253
__PACKAGE__->belongs_to(
256
    "borrower",
254
    "borrower",
257
    "Koha::Schema::Result::Borrower",
255
    "Koha::Schema::Result::Borrower",
Lines 259-264 __PACKAGE__->belongs_to( Link Here
259
    { join_type => "LEFT", on_delete => "CASCADE", on_update => "CASCADE" },
257
    { join_type => "LEFT", on_delete => "CASCADE", on_update => "CASCADE" },
260
);
258
);
261
259
260
=head2 item
261
262
Type: belongs_to
263
264
Related object: L<Koha::Schema::Result::Item>
265
266
=cut
267
262
__PACKAGE__->belongs_to(
268
__PACKAGE__->belongs_to(
263
  "item",
269
  "item",
264
  "Koha::Schema::Result::Item",
270
  "Koha::Schema::Result::Item",
Lines 271-276 __PACKAGE__->belongs_to( Link Here
271
  },
277
  },
272
);
278
);
273
279
280
=head2 branch
281
282
Type: belongs_to
283
284
Related object: L<Koha::Schema::Result::Branch>
285
286
=cut
287
288
__PACKAGE__->belongs_to(
289
  "branch",
290
  "Koha::Schema::Result::Branch",
291
  { branchcode => "branchcode" },
292
  {
293
    is_deferrable => 1,
294
    join_type     => "LEFT",
295
  },
296
);
297
274
sub koha_object_class {
298
sub koha_object_class {
275
    'Koha::Old::Checkout';
299
    'Koha::Old::Checkout';
276
}
300
}
277
- 

Return to bug 15985