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

(-)a/C4/Circulation.pm (-21 / +19 lines)
Lines 307-313 sub transferbook { Link Here
307
    my $messages;
307
    my $messages;
308
    my $dotransfer      = 1;
308
    my $dotransfer      = 1;
309
    my $itemnumber = GetItemnumberFromBarcode( $barcode );
309
    my $itemnumber = GetItemnumberFromBarcode( $barcode );
310
    my $issue      = GetItemIssue($itemnumber);
310
    my $issue      = Koha::Checkouts->find({ itemnumber => $itemnumber });
311
    my $biblio = GetBiblioFromItemNumber($itemnumber);
311
    my $biblio = GetBiblioFromItemNumber($itemnumber);
312
312
313
    # bad barcode..
313
    # bad barcode..
Lines 349-357 sub transferbook { Link Here
349
    }
349
    }
350
350
351
    # check if it is still issued to someone, return it...
351
    # check if it is still issued to someone, return it...
352
    if ($issue->{borrowernumber}) {
352
    if ( $issue ) {
353
        AddReturn( $barcode, $fbr );
353
        AddReturn( $barcode, $fbr );
354
        $messages->{'WasReturned'} = $issue->{borrowernumber};
354
        $messages->{'WasReturned'} = $issue->borrowernumber;
355
    }
355
    }
356
356
357
    # find reserves.....
357
    # find reserves.....
Lines 674-680 sub CanBookBeIssued { Link Here
674
    my $override_high_holds = $params->{override_high_holds} || 0;
674
    my $override_high_holds = $params->{override_high_holds} || 0;
675
675
676
    my $item = GetItem(GetItemnumberFromBarcode( $barcode ));
676
    my $item = GetItem(GetItemnumberFromBarcode( $barcode ));
677
    my $issue = GetItemIssue($item->{itemnumber});
677
    my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
678
	my $biblioitem = GetBiblioItemData($item->{biblioitemnumber});
678
	my $biblioitem = GetBiblioItemData($item->{biblioitemnumber});
679
	$item->{'itemtype'}=$item->{'itype'}; 
679
	$item->{'itemtype'}=$item->{'itype'}; 
680
    my $dbh             = C4::Context->dbh;
680
    my $dbh             = C4::Context->dbh;
Lines 832-840 sub CanBookBeIssued { Link Here
832
    #
832
    #
833
    my $switch_onsite_checkout = (
833
    my $switch_onsite_checkout = (
834
          C4::Context->preference('SwitchOnSiteCheckouts')
834
          C4::Context->preference('SwitchOnSiteCheckouts')
835
      and $issue->{onsite_checkout}
836
      and $issue
835
      and $issue
837
      and $issue->{borrowernumber} == $borrower->{'borrowernumber'} ? 1 : 0 );
836
      and $issue->onsite_checkout
837
      and $issue->borrowernumber == $borrower->{'borrowernumber'} ? 1 : 0 );
838
    my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } );
838
    my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } );
839
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
839
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
840
    if ( $toomany ) {
840
    if ( $toomany ) {
Lines 941-953 sub CanBookBeIssued { Link Here
941
    #
941
    #
942
    # CHECK IF BOOK ALREADY ISSUED TO THIS BORROWER
942
    # CHECK IF BOOK ALREADY ISSUED TO THIS BORROWER
943
    #
943
    #
944
    if ( $issue->{borrowernumber} && $issue->{borrowernumber} eq $borrower->{'borrowernumber'} ){
944
    if ( $issue && $issue->borrowernumber eq $borrower->{'borrowernumber'} ){
945
945
946
        # Already issued to current borrower.
946
        # Already issued to current borrower.
947
        # If it is an on-site checkout if it can be switched to a normal checkout
947
        # If it is an on-site checkout if it can be switched to a normal checkout
948
        # or ask whether the loan should be renewed
948
        # or ask whether the loan should be renewed
949
949
950
        if ( $issue->{onsite_checkout}
950
        if ( $issue->onsite_checkout
951
                and C4::Context->preference('SwitchOnSiteCheckouts') ) {
951
                and C4::Context->preference('SwitchOnSiteCheckouts') ) {
952
            $messages{ONSITE_CHECKOUT_WILL_BE_SWITCHED} = 1;
952
            $messages{ONSITE_CHECKOUT_WILL_BE_SWITCHED} = 1;
953
        } else {
953
        } else {
Lines 968-977 sub CanBookBeIssued { Link Here
968
            }
968
            }
969
        }
969
        }
970
    }
970
    }
971
    elsif ($issue->{borrowernumber}) {
971
    elsif ( $issue ) {
972
972
973
        # issued to someone else
973
        # issued to someone else
974
        my $currborinfo =    C4::Members::GetMember( borrowernumber => $issue->{borrowernumber} );
974
        my $currborinfo =    C4::Members::GetMember( borrowernumber => $issue->borrowernumber );
975
975
976
976
977
        my ( $can_be_returned, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} );
977
        my ( $can_be_returned, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} );
Lines 1304-1316 sub AddIssue { Link Here
1304
        my $branch = _GetCircControlBranch( $item, $borrower );
1304
        my $branch = _GetCircControlBranch( $item, $borrower );
1305
1305
1306
        # get actual issuing if there is one
1306
        # get actual issuing if there is one
1307
        my $actualissue = GetItemIssue( $item->{itemnumber} );
1307
        my $actualissue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
1308
1308
1309
        # get biblioinformation for this item
1309
        # get biblioinformation for this item
1310
        my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} );
1310
        my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} );
1311
1311
1312
        # check if we just renew the issue.
1312
        # check if we just renew the issue.
1313
        if ( $actualissue->{borrowernumber} eq $borrower->{'borrowernumber'}
1313
        if ( $actualissue and $actualissue->borrowernumber eq $borrower->{'borrowernumber'}
1314
                and not $switch_onsite_checkout ) {
1314
                and not $switch_onsite_checkout ) {
1315
            $datedue = AddRenewal(
1315
            $datedue = AddRenewal(
1316
                $borrower->{'borrowernumber'},
1316
                $borrower->{'borrowernumber'},
Lines 1322-1329 sub AddIssue { Link Here
1322
        }
1322
        }
1323
        else {
1323
        else {
1324
            # it's NOT a renewal
1324
            # it's NOT a renewal
1325
            if ( $actualissue->{borrowernumber}
1325
            if ( $actualissue and not $switch_onsite_checkout ) {
1326
                    and not $switch_onsite_checkout ) {
1327
                # This book is currently on loan, but not to the person
1326
                # This book is currently on loan, but not to the person
1328
                # who wants to borrow it now. mark it returned before issuing to the new borrower
1327
                # who wants to borrow it now. mark it returned before issuing to the new borrower
1329
                my ( $allowed, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} );
1328
                my ( $allowed, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} );
Lines 3037-3045 sub GetSoonestRenewDate { Link Here
3037
    my $dbh = C4::Context->dbh;
3036
    my $dbh = C4::Context->dbh;
3038
3037
3039
    my $item      = GetItem($itemnumber)      or return;
3038
    my $item      = GetItem($itemnumber)      or return;
3040
    my $itemissue = GetItemIssue($itemnumber) or return;
3039
    my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return;
3041
3040
3042
    $borrowernumber ||= $itemissue->{borrowernumber};
3041
    $borrowernumber ||= $itemissue->borrowernumber;
3043
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
3042
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
3044
      or return;
3043
      or return;
3045
3044
Lines 3058-3065 sub GetSoonestRenewDate { Link Here
3058
        and $issuing_rule->norenewalbefore ne "" )
3057
        and $issuing_rule->norenewalbefore ne "" )
3059
    {
3058
    {
3060
        my $soonestrenewal =
3059
        my $soonestrenewal =
3061
          $itemissue->{date_due}->clone()
3060
          dt_from_string( $itemissue->date_due )->subtract(
3062
          ->subtract(
3063
            $issuing_rule->lengthunit => $issuing_rule->norenewalbefore );
3061
            $issuing_rule->lengthunit => $issuing_rule->norenewalbefore );
3064
3062
3065
        if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date'
3063
        if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date'
Lines 3097-3105 sub GetLatestAutoRenewDate { Link Here
3097
    my $dbh = C4::Context->dbh;
3095
    my $dbh = C4::Context->dbh;
3098
3096
3099
    my $item      = GetItem($itemnumber)      or return;
3097
    my $item      = GetItem($itemnumber)      or return;
3100
    my $itemissue = GetItemIssue($itemnumber) or return;
3098
    my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return;
3101
3099
3102
    $borrowernumber ||= $itemissue->{borrowernumber};
3100
    $borrowernumber ||= $itemissue->borrowernumber;
3103
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
3101
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
3104
      or return;
3102
      or return;
3105
3103
Lines 3120-3126 sub GetLatestAutoRenewDate { Link Here
3120
3118
3121
    my $maximum_renewal_date;
3119
    my $maximum_renewal_date;
3122
    if ( $issuing_rule->no_auto_renewal_after ) {
3120
    if ( $issuing_rule->no_auto_renewal_after ) {
3123
        $maximum_renewal_date = dt_from_string($itemissue->{issuedate});
3121
        $maximum_renewal_date = dt_from_string($itemissue->issuedate);
3124
        $maximum_renewal_date->add(
3122
        $maximum_renewal_date->add(
3125
            $issuing_rule->lengthunit => $issuing_rule->no_auto_renewal_after
3123
            $issuing_rule->lengthunit => $issuing_rule->no_auto_renewal_after
3126
        );
3124
        );
(-)a/C4/ILSDI/Services.pm (-3 / +5 lines)
Lines 34-41 use CGI qw ( -utf8 ); Link Here
34
use DateTime;
34
use DateTime;
35
use C4::Auth;
35
use C4::Auth;
36
use C4::Members::Attributes qw(GetBorrowerAttributes);
36
use C4::Members::Attributes qw(GetBorrowerAttributes);
37
use Koha::DateUtils;
37
38
38
use Koha::Biblios;
39
use Koha::Biblios;
40
use Koha::Checkouts;
39
use Koha::Libraries;
41
use Koha::Libraries;
40
42
41
=head1 NAME
43
=head1 NAME
Lines 581-592 sub RenewLoan { Link Here
581
    my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber );
583
    my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber );
582
    if ( $renewal[0] ) { AddRenewal( $borrowernumber, $itemnumber ); }
584
    if ( $renewal[0] ) { AddRenewal( $borrowernumber, $itemnumber ); }
583
585
584
    my $issue = GetItemIssue($itemnumber);
586
    my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; # FIXME should be handled
585
587
586
    # Hashref building
588
    # Hashref building
587
    my $out;
589
    my $out;
588
    $out->{'renewals'} = $issue->{'renewals'};
590
    $out->{'renewals'} = $issue->renewals;
589
    $out->{date_due}   = $issue->{date_due}->strftime('%Y-%m-%d %H:%S');
591
    $out->{date_due}   = dt_from_string($issue->date_due)->strftime('%Y-%m-%d %H:%S');
590
    $out->{'success'}  = $renewal[0];
592
    $out->{'success'}  = $renewal[0];
591
    $out->{'error'}    = $renewal[1];
593
    $out->{'error'}    = $renewal[1];
592
594
(-)a/C4/SIP/ILS/Item.pm (-4 / +4 lines)
Lines 23-29 use C4::Members; Link Here
23
use C4::Reserves;
23
use C4::Reserves;
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::Biblios;
25
use Koha::Biblios;
26
26
use Koha::Checkouts;
27
27
28
=encoding UTF-8
28
=encoding UTF-8
29
29
Lines 88-98 sub new { Link Here
88
    $item->{sip_media_type} = $itemtype->sip_media_type() if $itemtype;
88
    $item->{sip_media_type} = $itemtype->sip_media_type() if $itemtype;
89
89
90
	# check if its on issue and if so get the borrower
90
	# check if its on issue and if so get the borrower
91
	my $issue = GetItemIssue($item->{'itemnumber'});
91
    my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
92
    if ($issue) {
92
    if ($issue) {
93
        $item->{due_date} = $issue->{date_due};
93
        $item->{due_date} = dt_from_string( $issue->date_due, 'sql' )->truncate( to => 'minute' );
94
    }
94
    }
95
	my $borrower = GetMember(borrowernumber=>$issue->{'borrowernumber'});
95
    my $borrower = $issue ? GetMember( borrowernumber => $issue->borrowernumber ) : {};
96
	$item->{patron} = $borrower->{'cardnumber'};
96
	$item->{patron} = $borrower->{'cardnumber'};
97
    my $biblio = Koha::Biblios->find( $item->{biblionumber } );
97
    my $biblio = Koha::Biblios->find( $item->{biblionumber } );
98
    my $holds = $biblio->current_holds->unblessed;
98
    my $holds = $biblio->current_holds->unblessed;
(-)a/C4/SIP/ILS/Transaction.pm (-4 / +4 lines)
Lines 8-15 use Carp; Link Here
8
use strict;
8
use strict;
9
use warnings;
9
use warnings;
10
use C4::Context;
10
use C4::Context;
11
use C4::Circulation qw( GetItemIssue );
12
use Koha::DateUtils;
11
use Koha::DateUtils;
12
use Koha::Checkouts;
13
13
14
my %fields = (
14
my %fields = (
15
	ok            => 0,
15
	ok            => 0,
Lines 45-53 sub duedatefromissue { Link Here
45
    } # renew from AddIssue ??
45
    } # renew from AddIssue ??
46
    else {
46
    else {
47
        # need to reread the issue to get due date
47
        # need to reread the issue to get due date
48
        $iss = GetItemIssue($itemnum);
48
        $iss = Koha::Checkouts->find( { itemnumber => $itemnum } );
49
        if ($iss && $iss->{date_due} ) {
49
        if ($iss && $iss->date_due ) {
50
            $due_dt = dt_from_string( $iss->{date_due} );
50
            $due_dt = dt_from_string( $iss->date_due, 'sql' );
51
        }
51
        }
52
    }
52
    }
53
    return $due_dt;
53
    return $due_dt;
(-)a/offline_circ/enqueue_koc.pl (-3 / +5 lines)
Lines 33-38 use C4::Items; Link Here
33
use C4::Members;
33
use C4::Members;
34
use C4::Stats;
34
use C4::Stats;
35
use Koha::UploadedFiles;
35
use Koha::UploadedFiles;
36
use Koha::Checkouts;
37
use Koha::Upload;
36
38
37
use Date::Calc qw( Add_Delta_Days Date_to_Days );
39
use Date::Calc qw( Add_Delta_Days Date_to_Days );
38
40
Lines 192-198 sub _get_borrowernumber_from_barcode { Link Here
192
    my $item = GetBiblioFromItemNumber( undef, $barcode );
194
    my $item = GetBiblioFromItemNumber( undef, $barcode );
193
    return unless $item->{'itemnumber'};
195
    return unless $item->{'itemnumber'};
194
196
195
    my $issue = C4::Circulation::GetItemIssue( $item->{'itemnumber'} );
197
    my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
196
    return unless $issue->{'borrowernumber'};
198
    return unless $issue;
197
    return $issue->{'borrowernumber'};
199
    return $issue->borrowernumber;
198
}
200
}
(-)a/offline_circ/process_koc.pl (-6 / +7 lines)
Lines 37-42 use C4::Stats; Link Here
37
use C4::BackgroundJob;
37
use C4::BackgroundJob;
38
use Koha::UploadedFiles;
38
use Koha::UploadedFiles;
39
use Koha::Account;
39
use Koha::Account;
40
use Koha::Checkouts;
40
use Koha::Patrons;
41
use Koha::Patrons;
41
42
42
use Date::Calc qw( Add_Delta_Days Date_to_Days );
43
use Date::Calc qw( Add_Delta_Days Date_to_Days );
Lines 250-260 sub kocIssueItem { Link Here
250
    my $branchcode = C4::Context->userenv->{branch};
251
    my $branchcode = C4::Context->userenv->{branch};
251
    my $borrower = GetMember( 'cardnumber'=>$circ->{ 'cardnumber' } );
252
    my $borrower = GetMember( 'cardnumber'=>$circ->{ 'cardnumber' } );
252
    my $item = GetBiblioFromItemNumber( undef, $circ->{ 'barcode' } );
253
    my $item = GetBiblioFromItemNumber( undef, $circ->{ 'barcode' } );
253
    my $issue = GetItemIssue( $item->{'itemnumber'} );
254
    my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
254
255
255
    if ( $issue->{ 'date_due' } ) { ## Item is currently checked out to another person.
256
    if ( $issue ) { ## Item is currently checked out to another person.
256
        #warn "Item Currently Issued.";
257
        #warn "Item Currently Issued.";
257
        my $issue = GetOpenIssue( $item->{'itemnumber'} );
258
        my $issue = GetOpenIssue( $item->{'itemnumber'} ); # FIXME Hum? That does not make sense, if it's in the issue table, the issue is open (i.e. returndate is null)
258
259
259
        if ( $issue->{'borrowernumber'} eq $borrower->{'borrowernumber'} ) { ## Issued to this person already, renew it.
260
        if ( $issue->{'borrowernumber'} eq $borrower->{'borrowernumber'} ) { ## Issued to this person already, renew it.
260
            #warn "Item issued to this member already, renewing.";
261
            #warn "Item issued to this member already, renewing.";
Lines 398-404 sub _get_borrowernumber_from_barcode { Link Here
398
    my $item = GetBiblioFromItemNumber( undef, $barcode );
399
    my $item = GetBiblioFromItemNumber( undef, $barcode );
399
    return unless $item->{'itemnumber'};
400
    return unless $item->{'itemnumber'};
400
401
401
    my $issue = C4::Circulation::GetItemIssue( $item->{'itemnumber'} );
402
    my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
402
    return unless $issue->{'borrowernumber'};
403
    return unless $issue;
403
    return $issue->{'borrowernumber'};
404
    return $issue->borrowernumber;
404
}
405
}
(-)a/opac/opac-reserve.pl (-3 / +4 lines)
Lines 36-41 use Koha::AuthorisedValues; Link Here
36
use Koha::DateUtils;
36
use Koha::DateUtils;
37
use Koha::Items;
37
use Koha::Items;
38
use Koha::ItemTypes;
38
use Koha::ItemTypes;
39
use Koha::Checkouts;
39
use Koha::Libraries;
40
use Koha::Libraries;
40
use Koha::Patrons;
41
use Koha::Patrons;
41
use Date::Calc qw/Today Date_to_Days/;
42
use Date::Calc qw/Today Date_to_Days/;
Lines 465-473 foreach my $biblioNum (@biblionumbers) { Link Here
465
466
466
        # If the item is currently on loan, we display its return date and
467
        # If the item is currently on loan, we display its return date and
467
        # change the background color.
468
        # change the background color.
468
        my $issues= GetItemIssue($itemNum);
469
        my $issue = Koha::Checkouts->find( { itemnumber => $itemNum } );
469
        if ( $issues->{'date_due'} ) {
470
        if ( $issue ) {
470
            $itemLoopIter->{dateDue} = output_pref({ dt => dt_from_string($issues->{date_due}, 'sql'), as_due_date => 1 });
471
            $itemLoopIter->{dateDue} = output_pref({ dt => dt_from_string($issue->date_due, 'sql'), as_due_date => 1 });
471
            $itemLoopIter->{backgroundcolor} = 'onloan';
472
            $itemLoopIter->{backgroundcolor} = 'onloan';
472
        }
473
        }
473
474
(-)a/reserve/request.pl (-3 / +4 lines)
Lines 43-48 use C4::Utils::DataTables::Members; Link Here
43
use C4::Members;
43
use C4::Members;
44
use C4::Search;		# enabled_staff_search_views
44
use C4::Search;		# enabled_staff_search_views
45
use Koha::DateUtils;
45
use Koha::DateUtils;
46
use Koha::Checkouts;
46
use Koha::Holds;
47
use Koha::Holds;
47
use Koha::Items;
48
use Koha::Items;
48
use Koha::ItemTypes;
49
use Koha::ItemTypes;
Lines 383-391 foreach my $biblionumber (@biblionumbers) { Link Here
383
		
384
		
384
            # if the item is currently on loan, we display its return date and
385
            # if the item is currently on loan, we display its return date and
385
            # change the background color
386
            # change the background color
386
            my $issues= GetItemIssue($itemnumber);
387
            my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } );
387
            if ( $issues->{'date_due'} ) {
388
            if ( $issue ) {
388
                $item->{date_due} = $issues->{date_due_sql};
389
                $item->{date_due} = $issue->date_due;
389
                $item->{backgroundcolor} = 'onloan';
390
                $item->{backgroundcolor} = 'onloan';
390
            }
391
            }
391
392
(-)a/t/db_dependent/Circulation.t (-2 / +3 lines)
Lines 34-39 use C4::Overdues qw(UpdateFine CalcFine); Link Here
34
use Koha::DateUtils;
34
use Koha::DateUtils;
35
use Koha::Database;
35
use Koha::Database;
36
use Koha::IssuingRules;
36
use Koha::IssuingRules;
37
use Koha::Checkouts;
37
use Koha::Subscriptions;
38
use Koha::Subscriptions;
38
39
39
my $schema = Koha::Database->schema;
40
my $schema = Koha::Database->schema;
Lines 313-319 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
313
    is (defined $issue2, 1, "Item 2 checked out, due date: " . $issue2->date_due());
314
    is (defined $issue2, 1, "Item 2 checked out, due date: " . $issue2->date_due());
314
315
315
316
316
    my $borrowing_borrowernumber = GetItemIssue($itemnumber)->{borrowernumber};
317
    my $borrowing_borrowernumber = Koha::Checkouts->find( { itemnumber => $itemnumber } )->borrowernumber;
317
    is ($borrowing_borrowernumber, $renewing_borrowernumber, "Item checked out to $renewing_borrower->{firstname} $renewing_borrower->{surname}");
318
    is ($borrowing_borrowernumber, $renewing_borrowernumber, "Item checked out to $renewing_borrower->{firstname} $renewing_borrower->{surname}");
318
319
319
    my ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber, 1);
320
    my ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber, 1);
Lines 1396-1402 subtest 'MultipleReserves' => sub { Link Here
1396
    my $issue = AddIssue( $renewing_borrower, $barcode1);
1397
    my $issue = AddIssue( $renewing_borrower, $barcode1);
1397
    my $datedue = dt_from_string( $issue->date_due() );
1398
    my $datedue = dt_from_string( $issue->date_due() );
1398
    is (defined $issue->date_due(), 1, "item 1 checked out");
1399
    is (defined $issue->date_due(), 1, "item 1 checked out");
1399
    my $borrowing_borrowernumber = GetItemIssue($itemnumber1)->{borrowernumber};
1400
    my $borrowing_borrowernumber = Koha::Checkouts->find({ itemnumber => $itemnumber1 })->borrowernumber;
1400
1401
1401
    my %reserving_borrower_data1 = (
1402
    my %reserving_borrower_data1 = (
1402
        firstname =>  'Katrin',
1403
        firstname =>  'Katrin',
(-)a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t (-3 / +4 lines)
Lines 26-31 use C4::Context; Link Here
26
26
27
use Koha::DateUtils qw( dt_from_string );
27
use Koha::DateUtils qw( dt_from_string );
28
use Koha::Database;
28
use Koha::Database;
29
use Koha::Checkouts;
29
30
30
use t::lib::TestBuilder;
31
use t::lib::TestBuilder;
31
use t::lib::Mocks;
32
use t::lib::Mocks;
Lines 106-115 t::lib::Mocks::mock_preference('SwitchOnSiteCheckouts', 1); Link Here
106
is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, 'If SwitchOnSiteCheckouts, switch the on-site checkout' );
107
is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, 'If SwitchOnSiteCheckouts, switch the on-site checkout' );
107
is( exists $impossible->{TOO_MANY}, '', 'If SwitchOnSiteCheckouts, switch the on-site checkout' );
108
is( exists $impossible->{TOO_MANY}, '', 'If SwitchOnSiteCheckouts, switch the on-site checkout' );
108
C4::Circulation::AddIssue( $patron, $item->{barcode}, undef, undef, undef, undef, { switch_onsite_checkout => 1 } );
109
C4::Circulation::AddIssue( $patron, $item->{barcode}, undef, undef, undef, undef, { switch_onsite_checkout => 1 } );
109
my $issue = C4::Circulation::GetItemIssue( $item->{itemnumber} );
110
my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
110
is( $issue->{onsite_checkout}, 0, 'The issue should have been switched to a regular checkout' );
111
is( $issue->onsite_checkout, 0, 'The issue should have been switched to a regular checkout' );
111
my $five_days_after = dt_from_string->add( days => 5 )->set( hour => 23, minute => 59, second => 0 );
112
my $five_days_after = dt_from_string->add( days => 5 )->set( hour => 23, minute => 59, second => 0 );
112
is( $issue->{date_due}, $five_days_after, 'The date_due should have been set depending on the circ rules when the on-site checkout has been switched' );
113
is( dt_from_string($issue->date_due, 'sql'), $five_days_after, 'The date_due should have been set depending on the circ rules when the on-site checkout has been switched' );
113
114
114
# Specific case
115
# Specific case
115
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
116
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
(-)a/t/db_dependent/Circulation/issue.t (-8 / +1 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 33;
20
use Test::More tests => 32;
21
use DateTime::Duration;
21
use DateTime::Duration;
22
22
23
use t::lib::Mocks;
23
use t::lib::Mocks;
Lines 45-51 can_ok( Link Here
45
      AddReturn
45
      AddReturn
46
      GetBiblioIssues
46
      GetBiblioIssues
47
      GetIssuingCharges
47
      GetIssuingCharges
48
      GetItemIssue
49
      GetOpenIssue
48
      GetOpenIssue
50
      GetRenewCount
49
      GetRenewCount
51
      GetUpcomingDueIssues
50
      GetUpcomingDueIssues
Lines 234-244 ok( $stat, "Bug 17781 - 'Improper branchcode set during renewal' still fixed" ); Link Here
234
#Test GetBiblioIssues
233
#Test GetBiblioIssues
235
is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" );
234
is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" );
236
235
237
#Test GetItemIssue
238
#FIXME : As the issues are not correctly added in the database, these tests don't work correctly
239
is(GetItemIssue,undef,"Without parameter GetItemIssue returns undef");
240
#is(GetItemIssue($item_id1),{},"Item1's issues");
241
242
#Test GetOpenIssue
236
#Test GetOpenIssue
243
is( GetOpenIssue(), undef, "Without parameter GetOpenIssue returns undef" );
237
is( GetOpenIssue(), undef, "Without parameter GetOpenIssue returns undef" );
244
is( GetOpenIssue(-1), undef,
238
is( GetOpenIssue(-1), undef,
245
- 

Return to bug 17680