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

(-)a/Koha/Account/Line.pm (+12 lines)
Lines 21-26 use Carp; Link Here
21
21
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::Items;
23
use Koha::Items;
24
use Koha::Checkouts;
24
25
25
use base qw(Koha::Object);
26
use base qw(Koha::Object);
26
27
Lines 46-51 sub item { Link Here
46
    return Koha::Item->_new_from_dbic( $rs );
47
    return Koha::Item->_new_from_dbic( $rs );
47
}
48
}
48
49
50
=head3 checkout
51
52
Return the checkout linked to this account line if exists
53
54
=cut
55
56
sub checkout {
57
    my ($self) = @_;
58
    return Koha::Checkouts->find( $self->issue_id ) || Koha::Old::Checkouts->find( $self->issue_id );
59
}
60
49
=head3 _type
61
=head3 _type
50
62
51
=cut
63
=cut
(-)a/Koha/Old/Checkout.pm (-1 / +1 lines)
Lines 19-25 use Modern::Perl; Link Here
19
19
20
use Koha::Database;
20
use Koha::Database;
21
21
22
use base qw(Koha::Object);
22
use base qw(Koha::Checkout);
23
23
24
sub _type {
24
sub _type {
25
    return 'OldIssue';
25
    return 'OldIssue';
(-)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::Objects);
23
use base qw(Koha::Checkouts);
24
24
25
sub _type {
25
sub _type {
26
    return 'OldIssue';
26
    return 'OldIssue';
(-)a/Koha/Schema/Result/OldIssue.pm (+10 lines)
Lines 225-230 __PACKAGE__->belongs_to( Link Here
225
  },
225
  },
226
);
226
);
227
227
228
__PACKAGE__->belongs_to(
229
  "branch",
230
  "Koha::Schema::Result::Branch",
231
  { branchcode => "branchcode" },
232
  {
233
    is_deferrable => 1,
234
    join_type     => "LEFT",
235
  },
236
);
237
228
238
229
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:54
239
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:54
230
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:RKLeDDEz22G5BU/ZAl7QLA
240
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:RKLeDDEz22G5BU/ZAl7QLA
(-)a/members/pay.pl (-3 / +3 lines)
Lines 129-142 sub add_accounts_to_template { Link Here
129
    my $total = $patron->account->balance;
129
    my $total = $patron->account->balance;
130
    my $account_lines = Koha::Account::Lines->search({ borrowernumber => $borrowernumber, amountoutstanding => { '!=' => 0 } }, { order_by => ['accounttype'] });
130
    my $account_lines = Koha::Account::Lines->search({ borrowernumber => $borrowernumber, amountoutstanding => { '!=' => 0 } }, { order_by => ['accounttype'] });
131
    my @accounts;
131
    my @accounts;
132
    while ( my $account_line = $account_lines->next ) {
132
    while ( my $a = $account_lines->next ) {
133
        $account_line = $account_line->unblessed;
133
        my $account_line = $a->unblessed;
134
        if ( $account_line->{itemnumber} ) {
134
        if ( $account_line->{itemnumber} ) {
135
            my $item = Koha::Items->find( $account_line->{itemnumber} );
135
            my $item = Koha::Items->find( $account_line->{itemnumber} );
136
            my $biblio = $item->biblio;
136
            my $biblio = $item->biblio;
137
            $account_line->{biblionumber} = $biblio->biblionumber;
137
            $account_line->{biblionumber} = $biblio->biblionumber;
138
            $account_line->{title}        = $biblio->title;
138
            $account_line->{title}        = $biblio->title;
139
            $account_line->{checkout}     = Koha::Checkouts->find($accountline->{issue_id});
139
            $account_line->{checkout}     = $a->checkout;
140
        }
140
        }
141
        push @accounts, $account_line;
141
        push @accounts, $account_line;
142
    }
142
    }
(-)a/t/db_dependent/Koha/Account/Lines.t (-2 / +36 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 1;
22
use Test::More tests => 2;
23
23
24
use Koha::Account::Lines;
24
use Koha::Account::Lines;
25
use Koha::Items;
25
use Koha::Items;
Lines 60-65 subtest 'item' => sub { Link Here
60
        is( $line->itemnumber, $account_line_item->itemnumber, 'Koha::Account::Line->item should return the correct item' );
60
        is( $line->itemnumber, $account_line_item->itemnumber, 'Koha::Account::Line->item should return the correct item' );
61
};
61
};
62
62
63
subtest 'checkout' => sub {
64
        plan tests => 1;
65
66
        my $library = $builder->build( { source => 'Branch' } );
67
        my $biblioitem = $builder->build( { source => 'Biblioitem' } );
68
        my $patron = $builder->build( { source => 'Borrower' } );
69
        my $item = Koha::Item->new(
70
        {
71
            biblionumber     => $biblioitem->{biblionumber},
72
            biblioitemnumber => $biblioitem->{biblioitemnumber},
73
            homebranch       => $library->{branchcode},
74
            holdingbranch    => $library->{branchcode},
75
            barcode          => 'some_barcode_13',
76
            itype            => 'BK',
77
        })->store;
78
79
        my $checkout  = Koha::Checkout->new(
80
            {   borrowernumber => $patron->{borrowernumber},
81
                itemnumber     => $item->itemnumber,
82
                branchcode     => $library->{branchcode},
83
            }
84
        )->store;
85
86
        my $line = Koha::Account::Line->new(
87
        {
88
            borrowernumber => $patron->{borrowernumber},
89
            itemnumber     => $item->itemnumber,
90
            issue_id       => $checkout->id,
91
            accounttype    => "F",
92
            amount         => 10,
93
        })->store;
94
95
        is( $line->checkout->id, $checkout->id, 'Koha::Account::Line->checkout should return the correct checkout' );
96
};
97
63
$schema->storage->txn_rollback;
98
$schema->storage->txn_rollback;
64
99
65
1;
100
1;
66
- 

Return to bug 15985