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

(-)a/C4/Circulation.pm (-13 / +10 lines)
Lines 1837-1842 sub AddReturn { Link Here
1837
        undef $branch;
1837
        undef $branch;
1838
    }
1838
    }
1839
    $branch = C4::Context->userenv->{'branch'} unless $branch;  # we trust userenv to be a safe fallback/default
1839
    $branch = C4::Context->userenv->{'branch'} unless $branch;  # we trust userenv to be a safe fallback/default
1840
    $return_date //= dt_from_string();
1840
    my $messages;
1841
    my $messages;
1841
    my $patron;
1842
    my $patron;
1842
    my $doreturn       = 1;
1843
    my $doreturn       = 1;
Lines 1931-1938 sub AddReturn { Link Here
1931
    }
1932
    }
1932
1933
1933
    # case of a return of document (deal with issues and holdingbranch)
1934
    # case of a return of document (deal with issues and holdingbranch)
1934
    my $today = DateTime->now( time_zone => C4::Context->tz() );
1935
1936
    if ($doreturn) {
1935
    if ($doreturn) {
1937
        my $is_overdue;
1936
        my $is_overdue;
1938
        die "The item is not issed and cannot be returned" unless $issue; # Just in case...
1937
        die "The item is not issed and cannot be returned" unless $issue; # Just in case...
Lines 2023-2030 sub AddReturn { Link Here
2023
2022
2024
        if ( $issue and $issue->is_overdue ) {
2023
        if ( $issue and $issue->is_overdue ) {
2025
        # fix fine days
2024
        # fix fine days
2026
            $today = $return_date if $return_date;
2025
            my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item_unblessed, dt_from_string($issue->date_due), $return_date );
2027
            my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item_unblessed, dt_from_string($issue->date_due), $today );
2028
            if ($reminder){
2026
            if ($reminder){
2029
                $messages->{'PrevDebarred'} = $debardate;
2027
                $messages->{'PrevDebarred'} = $debardate;
2030
            } else {
2028
            } else {
Lines 2037-2043 sub AddReturn { Link Here
2037
             } else {
2035
             } else {
2038
                  my $borrower_debar_dt = dt_from_string( $patron->debarred );
2036
                  my $borrower_debar_dt = dt_from_string( $patron->debarred );
2039
                  $borrower_debar_dt->truncate(to => 'day');
2037
                  $borrower_debar_dt->truncate(to => 'day');
2040
                  my $today_dt = $today->clone()->truncate(to => 'day');
2038
                  my $today_dt = $return_date->clone()->truncate(to => 'day');
2041
                  if ( DateTime->compare( $borrower_debar_dt, $today_dt ) != -1 ) {
2039
                  if ( DateTime->compare( $borrower_debar_dt, $today_dt ) != -1 ) {
2042
                      $messages->{'PrevDebarred'} = $patron->debarred;
2040
                      $messages->{'PrevDebarred'} = $patron->debarred;
2043
                  }
2041
                  }
Lines 2192-2198 sub MarkIssueReturned { Link Here
2192
2190
2193
=head2 _debar_user_on_return
2191
=head2 _debar_user_on_return
2194
2192
2195
    _debar_user_on_return($borrower, $item, $datedue, today);
2193
    _debar_user_on_return($borrower, $item, $datedue, $returndate);
2196
2194
2197
C<$borrower> borrower hashref
2195
C<$borrower> borrower hashref
2198
2196
Lines 2200-2206 C<$item> item hashref Link Here
2200
2198
2201
C<$datedue> date due DateTime object
2199
C<$datedue> date due DateTime object
2202
2200
2203
C<$return_date> DateTime object representing the return time
2201
C<$returndate> DateTime object representing the return time
2204
2202
2205
Internal function, called only by AddReturn that calculates and updates
2203
Internal function, called only by AddReturn that calculates and updates
2206
 the user fine days, and debars them if necessary.
2204
 the user fine days, and debars them if necessary.
Lines 2213-2218 sub _debar_user_on_return { Link Here
2213
    my ( $borrower, $item, $dt_due, $return_date ) = @_;
2211
    my ( $borrower, $item, $dt_due, $return_date ) = @_;
2214
2212
2215
    my $branchcode = _GetCircControlBranch( $item, $borrower );
2213
    my $branchcode = _GetCircControlBranch( $item, $borrower );
2214
    $return_date //= dt_from_string();
2216
2215
2217
    my $circcontrol = C4::Context->preference('CircControl');
2216
    my $circcontrol = C4::Context->preference('CircControl');
2218
    my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
2217
    my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
Lines 2302-2322 sub _debar_user_on_return { Link Here
2302
2301
2303
=head2 _FixOverduesOnReturn
2302
=head2 _FixOverduesOnReturn
2304
2303
2305
   &_FixOverduesOnReturn($brn,$itm, $exemptfine, $dropboxmode);
2304
   &_FixOverduesOnReturn($borrowernumber, $itemnumber, $exemptfine);
2306
2305
2307
C<$brn> borrowernumber
2306
C<$borrowernumber> borrowernumber
2308
2307
2309
C<$itm> itemnumber
2308
C<$itemnumber> itemnumber
2310
2309
2311
C<$exemptfine> BOOL -- remove overdue charge associated with this issue. 
2310
C<$exemptfine> BOOL -- remove overdue charge associated with this issue. 
2312
C<$dropboxmode> BOOL -- remove lastincrement on overdue charge associated with this issue.
2313
2311
2314
Internal function
2312
Internal function
2315
2313
2316
=cut
2314
=cut
2317
2315
2318
sub _FixOverduesOnReturn {
2316
sub _FixOverduesOnReturn {
2319
    my ($borrowernumber, $item, $exemptfine ) = @_;
2317
    my ( $borrowernumber, $item, $exemptfine ) = @_;
2320
    unless( $borrowernumber ) {
2318
    unless( $borrowernumber ) {
2321
        warn "_FixOverduesOnReturn() not supplied valid borrowernumber";
2319
        warn "_FixOverduesOnReturn() not supplied valid borrowernumber";
2322
        return;
2320
        return;
2323
- 

Return to bug 14591