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

(-)a/C4/Circulation.pm (-23 / +4 lines)
Lines 794-813 sub CanBookBeIssued { Link Here
794
    my $patron_unblessed = $patron->unblessed;
794
    my $patron_unblessed = $patron->unblessed;
795
795
796
    my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_unblessed, $patron_unblessed) );
796
    my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_unblessed, $patron_unblessed) );
797
    #
798
    # DUE DATE is OK ? -- should already have checked.
799
    #
800
    if ($duedate && ref $duedate ne 'DateTime') {
801
        $duedate = dt_from_string($duedate);
802
    }
803
    my $now = dt_from_string();
804
    unless ( $duedate ) {
805
        my $issuedate = $now->clone();
806
807
        $duedate = CalcDateDue( $issuedate, $effective_itemtype, $circ_library->branchcode, $patron_unblessed );
808
797
809
        # Offline circ calls AddIssue directly, doesn't run through here
798
    my $now = dt_from_string();
810
        #  So issuingimpossible should be ok.
799
    $duedate ||= CalcDateDue( $now->clone(), $effective_itemtype, $circ_library->branchcode, $patron_unblessed );
800
    if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now
801
         $needsconfirmation{INVALID_DATE} = output_pref($duedate);
811
    }
802
    }
812
803
813
    my $fees = Koha::Charges::Fees->new(
804
    my $fees = Koha::Charges::Fees->new(
Lines 819-834 sub CanBookBeIssued { Link Here
819
        }
810
        }
820
    );
811
    );
821
812
822
    if ($duedate) {
823
        my $today = $now->clone();
824
        $today->truncate( to => 'minute');
825
        if (DateTime->compare($duedate,$today) == -1 ) { # duedate cannot be before now
826
            $needsconfirmation{INVALID_DATE} = output_pref($duedate);
827
        }
828
    } else {
829
            $issuingimpossible{INVALID_DATE} = output_pref($duedate);
830
    }
831
832
    #
813
    #
833
    # BORROWER STATUS
814
    # BORROWER STATUS
834
    #
815
    #
(-)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 196-203 my ($datedue,$invalidduedate); Link Here
196
196
197
my $duedatespec_allow = C4::Context->preference('SpecifyDueDate');
197
my $duedatespec_allow = C4::Context->preference('SpecifyDueDate');
198
if( $onsite_checkout && !$duedatespec_allow ) {
198
if( $onsite_checkout && !$duedatespec_allow ) {
199
    $datedue = output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
199
    $datedue = dt_from_string()->truncate(to => 'day');
200
    $datedue .= ' 23:59:00';
200
    $datedue->set_hour(23);
201
    $datedue->set_minute(59);
201
} elsif( $duedatespec_allow ) {
202
} elsif( $duedatespec_allow ) {
202
    if ( $duedatespec ) {
203
    if ( $duedatespec ) {
203
        $datedue = eval { dt_from_string( $duedatespec ) };
204
        $datedue = eval { dt_from_string( $duedatespec ) };
(-)a/t/db_dependent/Circulation.t (-5 / +4 lines)
Lines 3837-3845 subtest 'CanBookBeIssued | is_overdue' => sub { Link Here
3837
        }
3837
        }
3838
    );
3838
    );
3839
3839
3840
    my $now   = dt_from_string;
3840
    my $now   = dt_from_string()->truncate( to => 'day' );
3841
    my $five_days_go = output_pref({ dt => $now->clone->add( days => 5 ), dateonly => 1});
3841
    my $five_days_go = $now->clone->add( days => 5 );
3842
    my $ten_days_go  = output_pref({ dt => $now->clone->add( days => 10), dateonly => 1 });
3842
    my $ten_days_go  = $now->clone->add( days => 10);
3843
    my $library = $builder->build( { source => 'Branch' } );
3843
    my $library = $builder->build( { source => 'Branch' } );
3844
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
3844
    my $patron  = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
3845
3845
Lines 3851-3857 subtest 'CanBookBeIssued | is_overdue' => sub { Link Here
3851
3851
3852
    my $issue = AddIssue( $patron->unblessed, $item->barcode, $five_days_go ); # date due was 10d ago
3852
    my $issue = AddIssue( $patron->unblessed, $item->barcode, $five_days_go ); # date due was 10d ago
3853
    my $actualissue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } );
3853
    my $actualissue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } );
3854
    is( output_pref({ str => $actualissue->date_due, dateonly => 1}), $five_days_go, "First issue works");
3854
    is( output_pref({ str => $actualissue->date_due, dateonly => 1}), output_pref({ str => $five_days_go, dateonly => 1}), "First issue works");
3855
    my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron,$item->barcode,$ten_days_go, undef, undef, undef);
3855
    my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron,$item->barcode,$ten_days_go, undef, undef, undef);
3856
    is( $needsconfirmation->{RENEW_ISSUE}, 1, "This is a renewal");
3856
    is( $needsconfirmation->{RENEW_ISSUE}, 1, "This is a renewal");
3857
    is( $needsconfirmation->{TOO_MANY}, undef, "Not too many, is a renewal");
3857
    is( $needsconfirmation->{TOO_MANY}, undef, "Not too many, is a renewal");
3858
- 

Return to bug 30947