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

(-)a/C4/Circulation.pm (+3 lines)
Lines 2175-2180 sub MarkIssueReturned { Link Here
2175
    $schema->txn_do(sub {
2175
    $schema->txn_do(sub {
2176
        $dbh->do( $query, undef, @bind );
2176
        $dbh->do( $query, undef, @bind );
2177
2177
2178
        my $original_issue_id = $issue_id;
2178
        my $id_already_exists = $dbh->selectrow_array(
2179
        my $id_already_exists = $dbh->selectrow_array(
2179
            q|SELECT COUNT(*) FROM old_issues WHERE issue_id = ?|,
2180
            q|SELECT COUNT(*) FROM old_issues WHERE issue_id = ?|,
2180
            undef, $issue_id
2181
            undef, $issue_id
Lines 2191-2196 sub MarkIssueReturned { Link Here
2191
2192
2192
        $dbh->do(q|INSERT INTO old_issues SELECT * FROM issues WHERE issue_id = ?|, undef, $issue_id);
2193
        $dbh->do(q|INSERT INTO old_issues SELECT * FROM issues WHERE issue_id = ?|, undef, $issue_id);
2193
2194
2195
        $dbh->do(q|UPDATE accountlines SET issue_id = ? WHERE issue_id = ?|, undef, $issue_id, $original_issue_id);
2196
2194
        # anonymise patron checkout immediately if $privacy set to 2 and AnonymousPatron is set to a valid borrowernumber
2197
        # anonymise patron checkout immediately if $privacy set to 2 and AnonymousPatron is set to a valid borrowernumber
2195
        if ( $privacy == 2) {
2198
        if ( $privacy == 2) {
2196
            $dbh->do(q|UPDATE old_issues SET borrowernumber=? WHERE issue_id = ?|, undef, $anonymouspatron, $issue_id);
2199
            $dbh->do(q|UPDATE old_issues SET borrowernumber=? WHERE issue_id = ?|, undef, $anonymouspatron, $issue_id);
(-)a/t/db_dependent/Circulation/Returns.t (-3 / +5 lines)
Lines 296-303 subtest 'Handle ids duplication' => sub { Link Here
296
296
297
    my ($doreturn, $messages, $new_checkout, $borrower) = AddReturn( $item->{barcode}, undef, undef, undef, dt_from_string );
297
    my ($doreturn, $messages, $new_checkout, $borrower) = AddReturn( $item->{barcode}, undef, undef, undef, dt_from_string );
298
298
299
    my $account_lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber, issue_id => $new_checkout->{issue_id} });
299
    my $account_lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber, issue_id => $original_checkout->issue_id });
300
    is( $account_lines->count, 1, 'One account line should exist on new issue_id' );
300
    is( $account_lines->count, 0, 'No account lines should exist on old issue_id' );
301
302
    $account_lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber, issue_id => $new_checkout->{issue_id} });
303
    is( $account_lines->count, 2, 'Two account lines should exist on new issue_id' );
301
304
302
    isnt( $original_checkout->issue_id, $new_checkout->{issue_id}, 'AddReturn should return the issue with the new issue_id' );
305
    isnt( $original_checkout->issue_id, $new_checkout->{issue_id}, 'AddReturn should return the issue with the new issue_id' );
303
    isnt( $old_checkout->itemnumber, $item->{itemnumber}, 'If an item is checked-in, it should be moved to old_issues even if the issue_id already existed in the table' );
306
    isnt( $old_checkout->itemnumber, $item->{itemnumber}, 'If an item is checked-in, it should be moved to old_issues even if the issue_id already existed in the table' );
304
- 

Return to bug 18651