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

(-)a/C4/Circulation.pm (-3 / +2 lines)
Lines 2640-2648 sub MarkIssueReturned { Link Here
2640
        my $old_checkout = Koha::Old::Checkout->new($issue->unblessed)->store;
2640
        my $old_checkout = Koha::Old::Checkout->new($issue->unblessed)->store;
2641
2641
2642
        # Update accountlines
2642
        # Update accountlines
2643
        my $accountlines =
2643
        my $accountlines = Koha::Account::Lines->search( { issue_id => $issue->issue_id } );
2644
          Koha::Account::Lines->search( { issue_id => $issue->issue_id } );
2644
        $accountlines->update( { old_issue_id => $issue->issue_id, issue_id => undef } );
2645
        $accountlines->update({ old_issue_id => $issue->issue_id, issue_id => undef });
2646
2645
2647
        # anonymise patron checkout immediately if $privacy set to 2 and AnonymousPatron is set to a valid borrowernumber
2646
        # anonymise patron checkout immediately if $privacy set to 2 and AnonymousPatron is set to a valid borrowernumber
2648
        if ( $privacy && $privacy == 2) {
2647
        if ( $privacy && $privacy == 2) {
(-)a/Koha/Account/Line.pm (-3 / +10 lines)
Lines 91-100 Return the checkout linked to this account line if exists Link Here
91
91
92
sub checkout {
92
sub checkout {
93
    my ($self) = @_;
93
    my ($self) = @_;
94
    return unless $self->issue_id;
95
94
96
    return Koha::Checkouts->find( $self->issue_id )
95
    my $result;
97
      || Koha::Old::Checkouts->find( $self->issue_id );
96
    if ( $self->issue_id ) {
97
        my $issue_rs = $self->_result->issue;
98
        $result = Koha::Checkout->_new_from_dbic($issue_rs) if $issue_rs;
99
    } elsif ( $self->old_issue_id ) {
100
        my $old_issue_rs = $self->_result->old_issue;
101
        $result = Koha::Old::Checkout->_new_from_dbic($old_issue_rs) if $old_issue_rs;
102
    }
103
104
    return $result;
98
}
105
}
99
106
100
=head3 library
107
=head3 library
(-)a/t/db_dependent/Koha/Account/Line.t (-11 / +19 lines)
Lines 706-712 subtest 'adjust() tests' => sub { Link Here
706
};
706
};
707
707
708
subtest 'checkout() tests' => sub {
708
subtest 'checkout() tests' => sub {
709
    plan tests => 6;
709
    plan tests => 7;
710
710
711
    $schema->storage->txn_begin;
711
    $schema->storage->txn_begin;
712
712
Lines 718-731 subtest 'checkout() tests' => sub { Link Here
718
    t::lib::Mocks::mock_userenv({ branchcode => $library->branchcode });
718
    t::lib::Mocks::mock_userenv({ branchcode => $library->branchcode });
719
    my $checkout = AddIssue( $patron, $item->barcode );
719
    my $checkout = AddIssue( $patron, $item->barcode );
720
720
721
    my $line = $account->add_debit({
721
    my $line = $account->add_debit(
722
        amount    => 10,
722
        {
723
        interface => 'commandline',
723
            amount       => 10,
724
        item_id   => $item->itemnumber,
724
            interface    => 'commandline',
725
        issue_id  => $checkout->issue_id,
725
            item_id      => $item->itemnumber,
726
        type      => 'OVERDUE',
726
            issue_id     => $checkout->issue_id,
727
        status    => 'UNRETURNED'
727
            old_issue_id => undef,
728
    });
728
            type         => 'OVERDUE',
729
            status       => 'UNRETURNED'
730
        }
731
    );
729
732
730
    my $line_checkout = $line->checkout;
733
    my $line_checkout = $line->checkout;
731
    is( ref($line_checkout), 'Koha::Checkout', 'Result type is correct' );
734
    is( ref($line_checkout), 'Koha::Checkout', 'Result type is correct' );
Lines 743-751 subtest 'checkout() tests' => sub { Link Here
743
    is( ref($old_line_checkout), 'Koha::Old::Checkout', 'Result type is correct' );
746
    is( ref($old_line_checkout), 'Koha::Old::Checkout', 'Result type is correct' );
744
    is( $old_line_checkout->issue_id, $old_checkout->issue_id, 'Koha::Account::Line->checkout should return the correct old_checkout' );
747
    is( $old_line_checkout->issue_id, $old_checkout->issue_id, 'Koha::Account::Line->checkout should return the correct old_checkout' );
745
748
746
    $line->issue_id(undef)->store;
749
    $old_line_checkout->delete;
750
    $line->discard_changes; #NOTE: discard_changes refreshes the whole resultset, get_from_storage only refreshes the unjoined row
747
    is( $line->checkout, undef, 'Koha::Account::Line->checkout should return undef if no checkout linked' );
751
    is( $line->checkout, undef, 'Koha::Account::Line->checkout should return undef if no checkout linked' );
748
752
753
    $line->old_issue_id(undef)->store;
754
    $line->discard_changes; #NOTE: discard_changes refreshes the whole resultset, get_from_storage only refreshes the unjoined row
755
    is( $line->checkout, undef, 'Koha::Account::Line->checkout should return undef if no checkout linked' );
756
757
749
    $schema->storage->txn_rollback;
758
    $schema->storage->txn_rollback;
750
};
759
};
751
760
752
- 

Return to bug 22421