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

(-)a/C4/Circulation.pm (-23 / +4 lines)
Lines 789-808 sub CanBookBeIssued { Link Here
789
    my $patron_unblessed = $patron->unblessed;
789
    my $patron_unblessed = $patron->unblessed;
790
790
791
    my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_unblessed, $patron_unblessed) );
791
    my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_unblessed, $patron_unblessed) );
792
    #
793
    # DUE DATE is OK ? -- should already have checked.
794
    #
795
    if ($duedate && ref $duedate ne 'DateTime') {
796
        $duedate = dt_from_string($duedate);
797
    }
798
    my $now = dt_from_string();
799
    unless ( $duedate ) {
800
        my $issuedate = $now->clone();
801
802
        $duedate = CalcDateDue( $issuedate, $effective_itemtype, $circ_library->branchcode, $patron_unblessed );
803
792
804
        # Offline circ calls AddIssue directly, doesn't run through here
793
    my $now = dt_from_string();
805
        #  So issuingimpossible should be ok.
794
    $duedate ||= CalcDateDue( $now->clone(), $effective_itemtype, $circ_library->branchcode, $patron_unblessed );
795
    if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now
796
         $needsconfirmation{INVALID_DATE} = output_pref($duedate);
806
    }
797
    }
807
798
808
    my $fees = Koha::Charges::Fees->new(
799
    my $fees = Koha::Charges::Fees->new(
Lines 814-829 sub CanBookBeIssued { Link Here
814
        }
805
        }
815
    );
806
    );
816
807
817
    if ($duedate) {
818
        my $today = $now->clone();
819
        $today->truncate( to => 'minute');
820
        if (DateTime->compare($duedate,$today) == -1 ) { # duedate cannot be before now
821
            $needsconfirmation{INVALID_DATE} = output_pref($duedate);
822
        }
823
    } else {
824
            $issuingimpossible{INVALID_DATE} = output_pref($duedate);
825
    }
826
827
    #
808
    #
828
    # BORROWER STATUS
809
    # BORROWER STATUS
829
    #
810
    #
(-)a/Koha/Illrequest.pm (-1 / +1 lines)
Lines 1222-1228 sub check_out { Link Here
1222
            scalar $target_item->barcode
1222
            scalar $target_item->barcode
1223
        );
1223
        );
1224
        if ($params->{duedate} && length $params->{duedate} > 0) {
1224
        if ($params->{duedate} && length $params->{duedate} > 0) {
1225
            push @issue_args, $params->{duedate};
1225
            push @issue_args, dt_from_string($params->{duedate});
1226
        }
1226
        }
1227
        # Check if we can check out
1227
        # Check if we can check out
1228
        my ( $error, $confirm, $alerts, $messages ) =
1228
        my ( $error, $confirm, $alerts, $messages ) =
(-)a/circ/circulation.pl (-2 / +3 lines)
Lines 197-204 my ($datedue,$invalidduedate); Link Here
197
197
198
my $duedatespec_allow = C4::Context->preference('SpecifyDueDate');
198
my $duedatespec_allow = C4::Context->preference('SpecifyDueDate');
199
if( $onsite_checkout && !$duedatespec_allow ) {
199
if( $onsite_checkout && !$duedatespec_allow ) {
200
    $datedue = output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
200
    $datedue = dt_from_string()->truncate(to => 'day');
201
    $datedue .= ' 23:59:00';
201
    $datedue->set_hour(23);
202
    $datedue->set_minute(59);
202
} elsif( $duedatespec_allow ) {
203
} elsif( $duedatespec_allow ) {
203
    if ( $duedatespec ) {
204
    if ( $duedatespec ) {
204
        $datedue = eval { dt_from_string( $duedatespec ) };
205
        $datedue = eval { dt_from_string( $duedatespec ) };
(-)a/t/db_dependent/Circulation.t (-5 / +4 lines)
Lines 3832-3840 subtest 'CanBookBeIssued | is_overdue' => sub { Link Here
3832
        }
3832
        }
3833
    );
3833
    );
3834
3834
3835
    my $now   = dt_from_string;
3835
    my $now   = dt_from_string()->truncate( to => 'day' );
3836
    my $five_days_go = output_pref({ dt => $now->clone->add( days => 5 ), dateonly => 1});
3836
    my $five_days_go = $now->clone->add( days => 5 );
3837
    my $ten_days_go  = output_pref({ dt => $now->clone->add( days => 10), dateonly => 1 });
3837
    my $ten_days_go  = $now->clone->add( days => 10);
3838
    my $library = $builder->build( { source => 'Branch' } );
3838
    my $library = $builder->build( { source => 'Branch' } );
3839
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
3839
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
3840
3840
Lines 3846-3852 subtest 'CanBookBeIssued | is_overdue' => sub { Link Here
3846
3846
3847
    my $issue = AddIssue( $patron->unblessed, $item->barcode, $five_days_go ); # date due was 10d ago
3847
    my $issue = AddIssue( $patron->unblessed, $item->barcode, $five_days_go ); # date due was 10d ago
3848
    my $actualissue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } );
3848
    my $actualissue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } );
3849
    is( output_pref({ str => $actualissue->date_due, dateonly => 1}), $five_days_go, "First issue works");
3849
    is( output_pref({ str => $actualissue->date_due, dateonly => 1}), output_pref({ str => $five_days_go, dateonly => 1}), "First issue works");
3850
    my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron,$item->barcode,$ten_days_go, undef, undef, undef);
3850
    my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron,$item->barcode,$ten_days_go, undef, undef, undef);
3851
    is( $needsconfirmation->{RENEW_ISSUE}, 1, "This is a renewal");
3851
    is( $needsconfirmation->{RENEW_ISSUE}, 1, "This is a renewal");
3852
    is( $needsconfirmation->{TOO_MANY}, undef, "Not too many, is a renewal");
3852
    is( $needsconfirmation->{TOO_MANY}, undef, "Not too many, is a renewal");
3853
- 

Return to bug 30947