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

(-)a/C4/SIP/ILS/Patron.pm (-5 / +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} ) {
Lines 794-797 __END__ Link Here
794
    {itemlist}    ref-to-array: list of available items
795
    {itemlist}    ref-to-array: list of available items
795
796
796
=cut
797
=cut
797
(-)a/t/db_dependent/SIP/Patron.t (-4 / +11 lines)
Lines 266-272 $schema->storage->txn_rollback; Link Here
266
266
267
subtest "Patron expiration tests" => sub {
267
subtest "Patron expiration tests" => sub {
268
268
269
    plan tests => 4;
269
    plan tests => 5;
270
270
271
    $schema->storage->txn_begin;
271
    $schema->storage->txn_begin;
272
    my $patron = $builder->build_object(
272
    my $patron = $builder->build_object(
Lines 309-319 subtest "Patron expiration tests" => sub { Link Here
309
        "A message is displayed when the card has expired and NotifyBorrowerDeparture is not disabled"
309
        "A message is displayed when the card has expired and NotifyBorrowerDeparture is not disabled"
310
    );
310
    );
311
311
312
    # Bug 38658 - SIP not marking patrons expired unless NotifyBorrowerDeparture has a positive value
312
    t::lib::Mocks::mock_preference( 'NotifyBorrowerDeparture', 0 );
313
    t::lib::Mocks::mock_preference( 'NotifyBorrowerDeparture', 0 );
313
    $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
314
    $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
314
    like(
315
    like(
315
        $sip_patron->screen_msg, qr/^Greetings from Koha. $/,
316
        $sip_patron->screen_msg, qr/Your account has expired as of/,
316
        "No message is displayed when the card has expired and NotifyBorrowerDeparture is disabled"
317
        "A message is displayed when the card has expired and NotifyBorrowerDeparture has a value of 0"
318
    );
319
320
    t::lib::Mocks::mock_preference( 'NotifyBorrowerDeparture', undef );
321
    $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
322
    like(
323
        $sip_patron->screen_msg, qr/Your account has expired as of/,
324
        "A message is displayed when the card has expired and NotifyBorrowerDeparture has no value"
317
    );
325
    );
318
326
319
    $schema->storage->txn_rollback;
327
    $schema->storage->txn_rollback;
320
- 

Return to bug 38658