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

(-)a/C4/SIP/ILS/Patron.pm (-4 / +5 lines)
Lines 67-79 sub new { Link Here
67
    my $debarred  = $patron->is_debarred;
67
    my $debarred  = $patron->is_debarred;
68
    siplog( "LOG_DEBUG", "Debarred = %s : ", ( $debarred || 'undef' ) );    # Do we need more debug info here?
68
    siplog( "LOG_DEBUG", "Debarred = %s : ", ( $debarred || 'undef' ) );    # Do we need more debug info here?
69
    my $expired = 0;
69
    my $expired = 0;
70
    if ( $kp->{'dateexpiry'} && C4::Context->preference('NotifyBorrowerDeparture') ) {
70
    if ( $kp->{'dateexpiry'} ) {
71
        my ( $today_year,   $today_month,   $today_day )   = Today();
71
        my ( $today_year,   $today_month,   $today_day )   = Today();
72
        my ( $warning_year, $warning_month, $warning_day ) = split /-/, $kp->{'dateexpiry'};
72
        my ( $warning_year, $warning_month, $warning_day ) = split /-/, $kp->{'dateexpiry'};
73
        my $days_to_expiry = Date_to_Days( $warning_year, $warning_month, $warning_day ) -
73
        my $days_to_expiry = Date_to_Days( $warning_year, $warning_month, $warning_day ) -
74
            Date_to_Days( $today_year, $today_month, $today_day );
74
            Date_to_Days( $today_year, $today_month, $today_day );
75
        my $dt         = dt_from_string( $kp->{'dateexpiry'}, 'iso' );
75
        my $dt                      = dt_from_string( $kp->{'dateexpiry'}, 'iso' );
76
        my $dateexpiry = output_pref( { dt => $dt, dateonly => 1 } );
76
        my $dateexpiry              = output_pref( { dt => $dt, dateonly => 1 } );
77
        my $notifyBorrowerDeparture = C4::Context->preference('NotifyBorrowerDeparture') // 0;
77
        if ( $days_to_expiry < 0 ) {
78
        if ( $days_to_expiry < 0 ) {
78
79
79
            #borrower card has expired, warn the borrower
80
            #borrower card has expired, warn the borrower
Lines 82-88 sub new { Link Here
82
            }
83
            }
83
            $kp->{opacnote} .= "Your account has expired as of $dateexpiry";
84
            $kp->{opacnote} .= "Your account has expired as of $dateexpiry";
84
            $expired = 1;
85
            $expired = 1;
85
        } elsif ( $days_to_expiry < C4::Context->preference('NotifyBorrowerDeparture') ) {
86
        } elsif ( $days_to_expiry < $notifyBorrowerDeparture ) {
86
87
87
            # borrower card soon to expire, warn the borrower
88
            # borrower card soon to expire, warn the borrower
88
            if ( $kp->{opacnote} ) {
89
            if ( $kp->{opacnote} ) {
(-)a/t/db_dependent/SIP/Patron.t (-4 / +12 lines)
Lines 254-260 $schema->storage->txn_rollback; Link Here
254
254
255
subtest "Patron expiration tests" => sub {
255
subtest "Patron expiration tests" => sub {
256
256
257
    plan tests => 4;
257
    plan tests => 5;
258
258
259
    $schema->storage->txn_begin;
259
    $schema->storage->txn_begin;
260
    my $patron = $builder->build_object(
260
    my $patron = $builder->build_object(
Lines 297-309 subtest "Patron expiration tests" => sub { Link Here
297
        "A message is displayed when the card has expired and NotifyBorrowerDeparture is not disabled"
297
        "A message is displayed when the card has expired and NotifyBorrowerDeparture is not disabled"
298
    );
298
    );
299
299
300
    # Bug 38658 - SIP not marking patrons expired unless NotifyBorrowerDeparture has a positive value
300
    t::lib::Mocks::mock_preference( 'NotifyBorrowerDeparture', 0 );
301
    t::lib::Mocks::mock_preference( 'NotifyBorrowerDeparture', 0 );
301
    $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
302
    $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
302
    like(
303
    like(
303
        $sip_patron->screen_msg, qr/^Greetings from Koha. $/,
304
        $sip_patron->screen_msg, qr/Your account has expired as of/,
304
        "No message is displayed when the card has expired and NotifyBorrowerDeparture is disabled"
305
        "A message is displayed when the card has expired and NotifyBorrowerDeparture has a value of 0"
305
    );
306
    );
306
307
308
    t::lib::Mocks::mock_preference( 'NotifyBorrowerDeparture', undef );
309
    $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
310
    like(
311
        $sip_patron->screen_msg, qr/Your account has expired as of/,
312
        "A message is displayed when the card has expired and NotifyBorrowerDeparture has no value"
313
    );
314
315
307
    $schema->storage->txn_rollback;
316
    $schema->storage->txn_rollback;
308
317
309
};
318
};
310
- 

Return to bug 38658