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

(-)a/C4/Circulation.pm (-21 / +19 lines)
Lines 308-314 sub transferbook { Link Here
308
    my $messages;
308
    my $messages;
309
    my $dotransfer      = 1;
309
    my $dotransfer      = 1;
310
    my $itemnumber = GetItemnumberFromBarcode( $barcode );
310
    my $itemnumber = GetItemnumberFromBarcode( $barcode );
311
    my $issue      = GetItemIssue($itemnumber);
311
    my $issue      = Koha::Issues->find({ itemnumber => $itemnumber });
312
    my $biblio = GetBiblioFromItemNumber($itemnumber);
312
    my $biblio = GetBiblioFromItemNumber($itemnumber);
313
313
314
    # bad barcode..
314
    # bad barcode..
Lines 350-358 sub transferbook { Link Here
350
    }
350
    }
351
351
352
    # check if it is still issued to someone, return it...
352
    # check if it is still issued to someone, return it...
353
    if ($issue->{borrowernumber}) {
353
    if ( $issue ) {
354
        AddReturn( $barcode, $fbr );
354
        AddReturn( $barcode, $fbr );
355
        $messages->{'WasReturned'} = $issue->{borrowernumber};
355
        $messages->{'WasReturned'} = $issue->borrowernumber;
356
    }
356
    }
357
357
358
    # find reserves.....
358
    # find reserves.....
Lines 671-677 sub CanBookBeIssued { Link Here
671
    my $override_high_holds = $params->{override_high_holds} || 0;
671
    my $override_high_holds = $params->{override_high_holds} || 0;
672
672
673
    my $item = GetItem(GetItemnumberFromBarcode( $barcode ));
673
    my $item = GetItem(GetItemnumberFromBarcode( $barcode ));
674
    my $issue = GetItemIssue($item->{itemnumber});
674
    my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
675
	my $biblioitem = GetBiblioItemData($item->{biblioitemnumber});
675
	my $biblioitem = GetBiblioItemData($item->{biblioitemnumber});
676
	$item->{'itemtype'}=$item->{'itype'}; 
676
	$item->{'itemtype'}=$item->{'itype'}; 
677
    my $dbh             = C4::Context->dbh;
677
    my $dbh             = C4::Context->dbh;
Lines 829-837 sub CanBookBeIssued { Link Here
829
    #
829
    #
830
    my $switch_onsite_checkout =
830
    my $switch_onsite_checkout =
831
          C4::Context->preference('SwitchOnSiteCheckouts')
831
          C4::Context->preference('SwitchOnSiteCheckouts')
832
      and $issue->{onsite_checkout}
833
      and $issue
832
      and $issue
834
      and $issue->{borrowernumber} == $borrower->{'borrowernumber'} ? 1 : 0;
833
      and $issue->onsite_checkout
834
      and $issue->borrowernumber == $borrower->{'borrowernumber'} ? 1 : 0;
835
    my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } );
835
    my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } );
836
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
836
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
837
    if ( $toomany ) {
837
    if ( $toomany ) {
Lines 939-951 sub CanBookBeIssued { Link Here
939
    #
939
    #
940
    # CHECK IF BOOK ALREADY ISSUED TO THIS BORROWER
940
    # CHECK IF BOOK ALREADY ISSUED TO THIS BORROWER
941
    #
941
    #
942
    if ( $issue->{borrowernumber} && $issue->{borrowernumber} eq $borrower->{'borrowernumber'} ){
942
    if ( $issue && $issue->borrowernumber eq $borrower->{'borrowernumber'} ){
943
943
944
        # Already issued to current borrower.
944
        # Already issued to current borrower.
945
        # If it is an on-site checkout if it can be switched to a normal checkout
945
        # If it is an on-site checkout if it can be switched to a normal checkout
946
        # or ask whether the loan should be renewed
946
        # or ask whether the loan should be renewed
947
947
948
        if ( $issue->{onsite_checkout}
948
        if ( $issue->onsite_checkout
949
                and C4::Context->preference('SwitchOnSiteCheckouts') ) {
949
                and C4::Context->preference('SwitchOnSiteCheckouts') ) {
950
            $messages{ONSITE_CHECKOUT_WILL_BE_SWITCHED} = 1;
950
            $messages{ONSITE_CHECKOUT_WILL_BE_SWITCHED} = 1;
951
        } else {
951
        } else {
Lines 966-975 sub CanBookBeIssued { Link Here
966
            }
966
            }
967
        }
967
        }
968
    }
968
    }
969
    elsif ($issue->{borrowernumber}) {
969
    elsif ( $issue ) {
970
970
971
        # issued to someone else
971
        # issued to someone else
972
        my $currborinfo =    C4::Members::GetMember( borrowernumber => $issue->{borrowernumber} );
972
        my $currborinfo =    C4::Members::GetMember( borrowernumber => $issue->borrowernumber );
973
973
974
974
975
        my ( $can_be_returned, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} );
975
        my ( $can_be_returned, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} );
Lines 1299-1311 sub AddIssue { Link Here
1299
        my $branch = _GetCircControlBranch( $item, $borrower );
1299
        my $branch = _GetCircControlBranch( $item, $borrower );
1300
1300
1301
        # get actual issuing if there is one
1301
        # get actual issuing if there is one
1302
        my $actualissue = GetItemIssue( $item->{itemnumber} );
1302
        my $actualissue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
1303
1303
1304
        # get biblioinformation for this item
1304
        # get biblioinformation for this item
1305
        my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} );
1305
        my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} );
1306
1306
1307
        # check if we just renew the issue.
1307
        # check if we just renew the issue.
1308
        if ( $actualissue->{borrowernumber} eq $borrower->{'borrowernumber'}
1308
        if ( $actualissue and $actualissue->borrowernumber eq $borrower->{'borrowernumber'}
1309
                and not $switch_onsite_checkout ) {
1309
                and not $switch_onsite_checkout ) {
1310
            $datedue = AddRenewal(
1310
            $datedue = AddRenewal(
1311
                $borrower->{'borrowernumber'},
1311
                $borrower->{'borrowernumber'},
Lines 1317-1324 sub AddIssue { Link Here
1317
        }
1317
        }
1318
        else {
1318
        else {
1319
            # it's NOT a renewal
1319
            # it's NOT a renewal
1320
            if ( $actualissue->{borrowernumber}
1320
            if ( $actualissue and not $switch_onsite_checkout ) {
1321
                    and not $switch_onsite_checkout ) {
1322
                # This book is currently on loan, but not to the person
1321
                # This book is currently on loan, but not to the person
1323
                # who wants to borrow it now. mark it returned before issuing to the new borrower
1322
                # who wants to borrow it now. mark it returned before issuing to the new borrower
1324
                my ( $allowed, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} );
1323
                my ( $allowed, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} );
Lines 2984-2992 sub GetSoonestRenewDate { Link Here
2984
    my $dbh = C4::Context->dbh;
2983
    my $dbh = C4::Context->dbh;
2985
2984
2986
    my $item      = GetItem($itemnumber)      or return;
2985
    my $item      = GetItem($itemnumber)      or return;
2987
    my $itemissue = GetItemIssue($itemnumber) or return;
2986
    my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return;
2988
2987
2989
    $borrowernumber ||= $itemissue->{borrowernumber};
2988
    $borrowernumber ||= $itemissue->borrowernumber;
2990
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
2989
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
2991
      or return;
2990
      or return;
2992
2991
Lines 3005-3012 sub GetSoonestRenewDate { Link Here
3005
        and $issuing_rule->norenewalbefore ne "" )
3004
        and $issuing_rule->norenewalbefore ne "" )
3006
    {
3005
    {
3007
        my $soonestrenewal =
3006
        my $soonestrenewal =
3008
          $itemissue->{date_due}->clone()
3007
          dt_from_string( $itemissue->date_due )->subtract(
3009
          ->subtract(
3010
            $issuing_rule->lengthunit => $issuing_rule->norenewalbefore );
3008
            $issuing_rule->lengthunit => $issuing_rule->norenewalbefore );
3011
3009
3012
        if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date'
3010
        if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date'
Lines 3044-3052 sub GetLatestAutoRenewDate { Link Here
3044
    my $dbh = C4::Context->dbh;
3042
    my $dbh = C4::Context->dbh;
3045
3043
3046
    my $item      = GetItem($itemnumber)      or return;
3044
    my $item      = GetItem($itemnumber)      or return;
3047
    my $itemissue = GetItemIssue($itemnumber) or return;
3045
    my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return;
3048
3046
3049
    $borrowernumber ||= $itemissue->{borrowernumber};
3047
    $borrowernumber ||= $itemissue->borrowernumber;
3050
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
3048
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
3051
      or return;
3049
      or return;
3052
3050
Lines 3062-3068 sub GetLatestAutoRenewDate { Link Here
3062
    return if not $issuing_rule->no_auto_renewal_after
3060
    return if not $issuing_rule->no_auto_renewal_after
3063
               or $issuing_rule->no_auto_renewal_after eq '';
3061
               or $issuing_rule->no_auto_renewal_after eq '';
3064
3062
3065
    my $maximum_renewal_date = dt_from_string($itemissue->{issuedate});
3063
    my $maximum_renewal_date = dt_from_string($itemissue->issuedate);
3066
    $maximum_renewal_date->add(
3064
    $maximum_renewal_date->add(
3067
        $issuing_rule->lengthunit => $issuing_rule->no_auto_renewal_after
3065
        $issuing_rule->lengthunit => $issuing_rule->no_auto_renewal_after
3068
    );
3066
    );
(-)a/C4/ILSDI/Services.pm (-3 / +5 lines)
Lines 34-39 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;
38
use Koha::Issues;
37
39
38
use Koha::Libraries;
40
use Koha::Libraries;
39
41
Lines 579-590 sub RenewLoan { Link Here
579
    my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber );
581
    my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber );
580
    if ( $renewal[0] ) { AddRenewal( $borrowernumber, $itemnumber ); }
582
    if ( $renewal[0] ) { AddRenewal( $borrowernumber, $itemnumber ); }
581
583
582
    my $issue = GetItemIssue($itemnumber);
584
    my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; # FIXME should be handled
583
585
584
    # Hashref building
586
    # Hashref building
585
    my $out;
587
    my $out;
586
    $out->{'renewals'} = $issue->{'renewals'};
588
    $out->{'renewals'} = $issue->renewals;
587
    $out->{date_due}   = $issue->{date_due}->strftime('%Y-%m-%d %H:%S');
589
    $out->{date_due}   = dt_from_string($issue->date_due)->strftime('%Y-%m-%d %H:%S');
588
    $out->{'success'}  = $renewal[0];
590
    $out->{'success'}  = $renewal[0];
589
    $out->{'error'}    = $renewal[1];
591
    $out->{'error'}    = $renewal[1];
590
592
(-)a/C4/SIP/ILS/Item.pm (-4 / +4 lines)
Lines 22-28 use C4::Circulation; Link Here
22
use C4::Members;
22
use C4::Members;
23
use C4::Reserves;
23
use C4::Reserves;
24
use Koha::Database;
24
use Koha::Database;
25
25
use Koha::Checkouts;
26
26
27
=encoding UTF-8
27
=encoding UTF-8
28
28
Lines 93-103 sub new { Link Here
93
    $item->{sip_media_type} = $itemtype->sip_media_type() if $itemtype;
93
    $item->{sip_media_type} = $itemtype->sip_media_type() if $itemtype;
94
94
95
	# check if its on issue and if so get the borrower
95
	# check if its on issue and if so get the borrower
96
	my $issue = GetItemIssue($item->{'itemnumber'});
96
    my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
97
    if ($issue) {
97
    if ($issue) {
98
        $item->{due_date} = $issue->{date_due};
98
        $item->{due_date} = dt_from_string( $issue->date_due, 'sql' )->truncate( to => 'minute' );
99
    }
99
    }
100
	my $borrower = GetMember(borrowernumber=>$issue->{'borrowernumber'});
100
    my $borrower = $issue ? GetMember( borrowernumber => $issue->borrowernumber ) : {};
101
	$item->{patron} = $borrower->{'cardnumber'};
101
	$item->{patron} = $borrower->{'cardnumber'};
102
    my $reserves = GetReservesFromBiblionumber({ biblionumber => $item->{biblionumber} });
102
    my $reserves = GetReservesFromBiblionumber({ biblionumber => $item->{biblionumber} });
103
    $item->{hold_queue} = [ sort priority_sort @$reserves ];
103
    $item->{hold_queue} = [ sort priority_sort @$reserves ];
(-)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 / +4 lines)
Lines 32-37 use C4::Circulation; Link Here
32
use C4::Items;
32
use C4::Items;
33
use C4::Members;
33
use C4::Members;
34
use C4::Stats;
34
use C4::Stats;
35
use Koha::Checkouts;
35
use Koha::Upload;
36
use Koha::Upload;
36
37
37
use Date::Calc qw( Add_Delta_Days Date_to_Days );
38
use Date::Calc qw( Add_Delta_Days Date_to_Days );
Lines 191-197 sub _get_borrowernumber_from_barcode { Link Here
191
    my $item = GetBiblioFromItemNumber( undef, $barcode );
192
    my $item = GetBiblioFromItemNumber( undef, $barcode );
192
    return unless $item->{'itemnumber'};
193
    return unless $item->{'itemnumber'};
193
194
194
    my $issue = C4::Circulation::GetItemIssue( $item->{'itemnumber'} );
195
    my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
195
    return unless $issue->{'borrowernumber'};
196
    return unless $issue;
196
    return $issue->{'borrowernumber'};
197
    return $issue->borrowernumber;
197
}
198
}
(-)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::Upload;
38
use Koha::Upload;
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 249-259 sub kocIssueItem { Link Here
249
    my $branchcode = C4::Context->userenv->{branch};
250
    my $branchcode = C4::Context->userenv->{branch};
250
    my $borrower = GetMember( 'cardnumber'=>$circ->{ 'cardnumber' } );
251
    my $borrower = GetMember( 'cardnumber'=>$circ->{ 'cardnumber' } );
251
    my $item = GetBiblioFromItemNumber( undef, $circ->{ 'barcode' } );
252
    my $item = GetBiblioFromItemNumber( undef, $circ->{ 'barcode' } );
252
    my $issue = GetItemIssue( $item->{'itemnumber'} );
253
    my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
253
254
254
    if ( $issue->{ 'date_due' } ) { ## Item is currently checked out to another person.
255
    if ( $issue ) { ## Item is currently checked out to another person.
255
        #warn "Item Currently Issued.";
256
        #warn "Item Currently Issued.";
256
        my $issue = GetOpenIssue( $item->{'itemnumber'} );
257
        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)
257
258
258
        if ( $issue->{'borrowernumber'} eq $borrower->{'borrowernumber'} ) { ## Issued to this person already, renew it.
259
        if ( $issue->{'borrowernumber'} eq $borrower->{'borrowernumber'} ) { ## Issued to this person already, renew it.
259
            #warn "Item issued to this member already, renewing.";
260
            #warn "Item issued to this member already, renewing.";
Lines 397-403 sub _get_borrowernumber_from_barcode { Link Here
397
    my $item = GetBiblioFromItemNumber( undef, $barcode );
398
    my $item = GetBiblioFromItemNumber( undef, $barcode );
398
    return unless $item->{'itemnumber'};
399
    return unless $item->{'itemnumber'};
399
400
400
    my $issue = C4::Circulation::GetItemIssue( $item->{'itemnumber'} );
401
    my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
401
    return unless $issue->{'borrowernumber'};
402
    return unless $issue;
402
    return $issue->{'borrowernumber'};
403
    return $issue->borrowernumber;
403
}
404
}
(-)a/opac/opac-reserve.pl (-3 / +4 lines)
Lines 33-38 use C4::Members; Link Here
33
use C4::Overdues;
33
use C4::Overdues;
34
use C4::Debug;
34
use C4::Debug;
35
use Koha::DateUtils;
35
use Koha::DateUtils;
36
use Koha::Checkouts;
36
use Koha::Libraries;
37
use Koha::Libraries;
37
use Koha::Patrons;
38
use Koha::Patrons;
38
use Date::Calc qw/Today Date_to_Days/;
39
use Date::Calc qw/Today Date_to_Days/;
Lines 441-449 foreach my $biblioNum (@biblionumbers) { Link Here
441
442
442
        # If the item is currently on loan, we display its return date and
443
        # If the item is currently on loan, we display its return date and
443
        # change the background color.
444
        # change the background color.
444
        my $issues= GetItemIssue($itemNum);
445
        my $issue = Koha::Checkouts->find( { itemnumber => $itemNum } );
445
        if ( $issues->{'date_due'} ) {
446
        if ( $issue ) {
446
            $itemLoopIter->{dateDue} = output_pref({ dt => dt_from_string($issues->{date_due}, 'sql'), as_due_date => 1 });
447
            $itemLoopIter->{dateDue} = output_pref({ dt => dt_from_string($issue->date_due, 'sql'), as_due_date => 1 });
447
            $itemLoopIter->{backgroundcolor} = 'onloan';
448
            $itemLoopIter->{backgroundcolor} = 'onloan';
448
        }
449
        }
449
450
(-)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::Libraries;
48
use Koha::Libraries;
48
use Koha::Patrons;
49
use Koha::Patrons;
Lines 379-387 foreach my $biblionumber (@biblionumbers) { Link Here
379
		
380
		
380
            # if the item is currently on loan, we display its return date and
381
            # if the item is currently on loan, we display its return date and
381
            # change the background color
382
            # change the background color
382
            my $issues= GetItemIssue($itemnumber);
383
            my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } );
383
            if ( $issues->{'date_due'} ) {
384
            if ( $issue ) {
384
                $item->{date_due} = $issues->{date_due_sql};
385
                $item->{date_due} = $issue->date_due;
385
                $item->{backgroundcolor} = 'onloan';
386
                $item->{backgroundcolor} = 'onloan';
386
            }
387
            }
387
388
(-)a/t/db_dependent/Circulation.t (-1 / +2 lines)
Lines 36-41 use C4::Reserves; Link Here
36
use C4::Overdues qw(UpdateFine CalcFine);
36
use C4::Overdues qw(UpdateFine CalcFine);
37
use Koha::DateUtils;
37
use Koha::DateUtils;
38
use Koha::Database;
38
use Koha::Database;
39
use Koha::Checkouts;
39
use Koha::Subscriptions;
40
use Koha::Subscriptions;
40
41
41
my $schema = Koha::Database->schema;
42
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);
(-)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 100-109 t::lib::Mocks::mock_preference('SwitchOnSiteCheckouts', 1); Link Here
100
is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, 'If SwitchOnSiteCheckouts, switch the on-site checkout' );
101
is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, 'If SwitchOnSiteCheckouts, switch the on-site checkout' );
101
is( exists $impossible->{TOO_MANY}, '', 'If SwitchOnSiteCheckouts, switch the on-site checkout' );
102
is( exists $impossible->{TOO_MANY}, '', 'If SwitchOnSiteCheckouts, switch the on-site checkout' );
102
C4::Circulation::AddIssue( $patron, $item->{barcode}, undef, undef, undef, undef, { switch_onsite_checkout => 1 } );
103
C4::Circulation::AddIssue( $patron, $item->{barcode}, undef, undef, undef, undef, { switch_onsite_checkout => 1 } );
103
my $issue = C4::Circulation::GetItemIssue( $item->{itemnumber} );
104
my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
104
is( $issue->{onsite_checkout}, 0, 'The issue should have been switched to a regular checkout' );
105
is( $issue->onsite_checkout, 0, 'The issue should have been switched to a regular checkout' );
105
my $five_days_after = dt_from_string->add( days => 5 )->set( hour => 23, minute => 59, second => 0 );
106
my $five_days_after = dt_from_string->add( days => 5 )->set( hour => 23, minute => 59, second => 0 );
106
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' );
107
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' );
107
108
108
# Specific case
109
# Specific case
109
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
110
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