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

(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 944-952 sub CanBookBeIssued { Link Here
944
    # CHECKPREVCHECKOUT: CHECK IF ITEM HAS EVER BEEN LENT TO PATRON
944
    # CHECKPREVCHECKOUT: CHECK IF ITEM HAS EVER BEEN LENT TO PATRON
945
    #
945
    #
946
    my $patron = Koha::Patrons->find($borrower->{borrowernumber});
946
    my $patron = Koha::Patrons->find($borrower->{borrowernumber});
947
    my $wantsCheckPrevCheckout = $patron->wantsCheckPrevCheckout;
947
    my $wants_check = $patron->wants_check_for_previous_checkout;
948
    $needsconfirmation{PREVISSUE} = 1
948
    $needsconfirmation{PREVISSUE} = 1
949
        if ($wantsCheckPrevCheckout and $patron->doCheckPrevCheckout($item));
949
        if ($wants_check and $patron->do_check_for_previous_checkout($item));
950
950
951
    #
951
    #
952
    # ITEM CHECKING
952
    # ITEM CHECKING
(-)a/Koha/Patron.pm (-6 / +6 lines)
Lines 100-114 sub siblings { Link Here
100
    );
100
    );
101
}
101
}
102
102
103
=head3 wantsCheckPrevCheckout
103
=head3 wants_check_for_previous_checkout
104
104
105
    $wantsCheckPrevCheckout = $patron->wantsCheckPrevCheckout;
105
    $wants_check = $patron->wantsCheckPrevCheckout;
106
106
107
Return 1 if Koha needs to perform PrevIssue checking, else 0.
107
Return 1 if Koha needs to perform PrevIssue checking, else 0.
108
108
109
=cut
109
=cut
110
110
111
sub wantsCheckPrevCheckout {
111
sub wants_check_for_previous_checkout {
112
    my ( $self ) = @_;
112
    my ( $self ) = @_;
113
    my $syspref = C4::Context->preference("checkPrevCheckout");
113
    my $syspref = C4::Context->preference("checkPrevCheckout");
114
114
Lines 134-149 sub wantsCheckPrevCheckout { Link Here
134
    }
134
    }
135
}
135
}
136
136
137
=head3 doCheckPrevCheckout
137
=head3 do_check_for_previous_checkout
138
138
139
    $checkPrevCheckout = $patron->doCheckPrevCheckout($item);
139
    $do_check = $patron->do_check_for_previous_checkout($item);
140
140
141
Return 1 if the bib associated with $ITEM has previously been checked out to
141
Return 1 if the bib associated with $ITEM has previously been checked out to
142
$PATRON, 0 otherwise.
142
$PATRON, 0 otherwise.
143
143
144
=cut
144
=cut
145
145
146
sub doCheckPrevCheckout {
146
sub do_check_for_previous_checkout {
147
    my ( $self, $item ) = @_;
147
    my ( $self, $item ) = @_;
148
148
149
    # Find all items for bib and extract item numbers.
149
    # Find all items for bib and extract item numbers.
(-)a/t/db_dependent/Patron/CheckPrevCheckout.t (-17 / +16 lines)
Lines 54-60 C4::Context->set_userenv(@USERENV); Link Here
54
BAIL_OUT("No userenv") unless C4::Context->userenv;
54
BAIL_OUT("No userenv") unless C4::Context->userenv;
55
55
56
56
57
# wantsCheckPrevCheckout
57
# wants_check_for_previous_checkout
58
58
59
# We expect the following result matrix:
59
# We expect the following result matrix:
60
#
60
#
Lines 203-209 map { Link Here
203
            });
203
            });
204
            my $patron = Koha::Patrons->find($kpatron->{borrowernumber});
204
            my $patron = Koha::Patrons->find($kpatron->{borrowernumber});
205
            is(
205
            is(
206
                $patron->wantsCheckPrevCheckout, $_->{result},
206
                $patron->wants_check_for_previous_checkout, $_->{result},
207
                "Predicate with syspref " . $syspref . ", cat " . $code
207
                "Predicate with syspref " . $syspref . ", cat " . $code
208
                    . ", patron " . $_->{setting}
208
                    . ", patron " . $_->{setting}
209
              );
209
              );
Lines 211-217 map { Link Here
211
    } @{$_->{categories}};
211
    } @{$_->{categories}};
212
} @{$mappings};
212
} @{$mappings};
213
213
214
# doCheckPrevCheckout
214
# do_check_for_previous_checkout
215
215
216
# We want to test:
216
# We want to test:
217
# - DESCRIPTION [RETURNVALUE (0/1)]
217
# - DESCRIPTION [RETURNVALUE (0/1)]
Lines 254-260 sub test_it { Link Here
254
    map {
254
    map {
255
        my $patron = Koha::Patrons->find($_->{patron}->{borrowernumber});
255
        my $patron = Koha::Patrons->find($_->{patron}->{borrowernumber});
256
        is(
256
        is(
257
            $patron->doCheckPrevCheckout($_->{item}),
257
            $patron->do_check_for_previous_checkout($_->{item}),
258
            $_->{result}, $stage . ": " . $_->{msg}
258
            $_->{result}, $stage . ": " . $_->{msg}
259
        );
259
        );
260
    } @{$mapping};
260
    } @{$mapping};
Lines 358-377 test_it($cpvPmappings, "PostReturn"); Link Here
358
358
359
# Finally test C4::Circulation::CanBookBeIssued
359
# Finally test C4::Circulation::CanBookBeIssued
360
360
361
# We have already tested ->wantsCheckPrevCheckout and ->doCheckPrevCheckout,
361
# We have already tested ->wants_check_for_previous_checkout and
362
# so all that remains to be tested is whetherthe different combinational
362
# ->do_check_for_previous_checkout, so all that remains to be tested is
363
# outcomes of the above return values in CanBookBeIssued result in the
363
# whetherthe different combinational outcomes of the above return values in
364
# approriate $needsconfirmation.
364
# CanBookBeIssued result in the approriate $needsconfirmation.
365
365
366
# We want to test:
366
# We want to test:
367
# - DESCRIPTION [RETURNVALUE (0/1)]
367
# - DESCRIPTION [RETURNVALUE (0/1)]
368
# - patron, !wantsCheckPrevCheckout, !doCheckPrevCheckout
368
# - patron, !wants_check_for_previous_checkout, !do_check_for_previous_checkout
369
#   [!$issuingimpossible,!$needsconfirmation->{PREVISSUE}]
369
#   [!$issuingimpossible,!$needsconfirmation->{PREVISSUE}]
370
# - patron, wantsCheckPrevCheckout, !doCheckPrevCheckout
370
# - patron, wants_check_for_previous_checkout, !do_check_for_previous_checkout
371
#   [!$issuingimpossible,!$needsconfirmation->{PREVISSUE}]
371
#   [!$issuingimpossible,!$needsconfirmation->{PREVISSUE}]
372
# - patron, !wantsCheckPrevCheckout, doCheckPrevCheckout
372
# - patron, !wants_check_for_previous_checkout, do_check_for_previous_checkout
373
#   [!$issuingimpossible,!$needsconfirmation->{PREVISSUE}]
373
#   [!$issuingimpossible,!$needsconfirmation->{PREVISSUE}]
374
# - patron, wantsCheckPrevCheckout, doCheckPrevCheckout
374
# - patron, wants_check_for_previous_checkout, do_check_for_previous_checkout
375
#   [!$issuingimpossible,$needsconfirmation->{PREVISSUE}]
375
#   [!$issuingimpossible,$needsconfirmation->{PREVISSUE}]
376
376
377
# Needs:
377
# Needs:
Lines 410-435 my $CBBI_mappings = [ Link Here
410
        syspref => 'hardno',
410
        syspref => 'hardno',
411
        item    => $new_item,
411
        item    => $new_item,
412
        result  => undef,
412
        result  => undef,
413
        msg     => "patron, !wantsCheckPrevCheckout, !doCheckPrevCheckout"
413
        msg     => "patron, !wants_check_for_previous_checkout, !do_check_for_previous_checkout"
414
414
415
    },
415
    },
416
    {
416
    {
417
        syspref => 'hardyes',
417
        syspref => 'hardyes',
418
        item    => $new_item,
418
        item    => $new_item,
419
        result  => undef,
419
        result  => undef,
420
        msg     => "patron, wantsCheckPrevCheckout, !doCheckPrevCheckout"
420
        msg     => "patron, wants_check_for_previous_checkout, !do_check_for_previous_checkout"
421
    },
421
    },
422
    {
422
    {
423
        syspref => 'hardno',
423
        syspref => 'hardno',
424
        item    => $prev_item,
424
        item    => $prev_item,
425
        result  => undef,
425
        result  => undef,
426
        msg     => "patron, !wantsCheckPrevCheckout, doCheckPrevCheckout"
426
        msg     => "patron, !wants_check_for_previous_checkout, do_check_for_previous_checkout"
427
    },
427
    },
428
    {
428
    {
429
        syspref => 'hardyes',
429
        syspref => 'hardyes',
430
        item    => $prev_item,
430
        item    => $prev_item,
431
        result  => 1,
431
        result  => 1,
432
        msg     => "patron, wantsCheckPrevCheckout, doCheckPrevCheckout"
432
        msg     => "patron, wants_check_for_previous_checkout, do_check_for_previous_checkout"
433
    },
433
    },
434
];
434
];
435
435
436
- 

Return to bug 6906