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

(-)a/admin/branches.pl (-4 / +4 lines)
Lines 125-134 if ( $op eq 'add_form' ) { Link Here
125
                    my @close_times = $input->multi_param("close_time");
125
                    my @close_times = $input->multi_param("close_time");
126
126
127
                    foreach my $day ( @days ) {
127
                    foreach my $day ( @days ) {
128
                        if ( $open_times[$day] and $open_times[$day] eq '' ) {
128
                        if ( $open_times[$day] !~ /([0-9]{2}:[0-9]{2})/ ) {
129
                            $open_times[$day] = undef;
129
                            $open_times[$day] = undef;
130
                        }
130
                        }
131
                        if ( $close_times[$day] and $close_times[$day] eq '' ) {
131
                        if ( $close_times[$day] !~ /([0-9]{2}:[0-9]{2})/ ) {
132
                            $close_times[$day] = undef;
132
                            $close_times[$day] = undef;
133
                        }
133
                        }
134
134
Lines 178-187 if ( $op eq 'add_form' ) { Link Here
178
                    my @close_times = $input->multi_param("close_time");
178
                    my @close_times = $input->multi_param("close_time");
179
179
180
                    foreach my $day ( @days ) {
180
                    foreach my $day ( @days ) {
181
                        if ( $open_times[$day] and $open_times[$day] eq '' ) {
181
                        if ( $open_times[$day] !~ /([0-9]{2}:[0-9]{2})/ ) {
182
                            $open_times[$day] = undef;
182
                            $open_times[$day] = undef;
183
                        }
183
                        }
184
                        if ( $close_times[$day] and $close_times[$day] eq '' ) {
184
                        if ( $close_times[$day] !~ /([0-9]{2}:[0-9]{2})/ ) {
185
                            $close_times[$day] = undef;
185
                            $close_times[$day] = undef;
186
                        }
186
                        }
187
187
(-)a/t/db_dependent/Circulation/CalcDateDue.t (-10 / +10 lines)
Lines 368-380 Koha::CirculationRules->set_rules( Link Here
368
        rules        => {
368
        rules        => {
369
            issuelength   => 3, # loan period is 3 hours
369
            issuelength   => 3, # loan period is 3 hours
370
            lengthunit    => 'hours',
370
            lengthunit    => 'hours',
371
            daysmode      => '',
371
        }
372
        }
372
    }
373
    }
373
);
374
);
374
375
375
my $open = DateTime->now->subtract( hours => 4 )->hms;
376
my $open = DateTime->new( year => 2023, month => 5, day => 1, hour => 10 )->hms;
376
my $close = DateTime->now->add( hours => 2 )->hms;
377
my $close = DateTime->new( year => 2023, month => 5, day => 1, hour => 16 )->hms;
377
my $now = DateTime->now;
378
my $now = DateTime->new( year => 2023, month => 5, day => 1, hour => 14 );
378
379
379
foreach (0..6) {
380
foreach (0..6) {
380
    # library opened 4 hours ago and closes in 2 hours.
381
    # library opened 4 hours ago and closes in 2 hours.
Lines 387-403 t::lib::Mocks::mock_preference('ConsiderLibraryHoursInCirculation', 'close'); Link Here
387
# shorten loan period
388
# shorten loan period
388
389
389
$date = C4::Circulation::CalcDateDue( $now, $itemtype, $library1->{branchcode}, $borrower );
390
$date = C4::Circulation::CalcDateDue( $now, $itemtype, $library1->{branchcode}, $borrower );
390
my $expected_duetime = DateTime->now->add( hours => 2 );
391
my $expected_duetime = $now->clone->add( hours => 2 );
391
is( $date, $expected_duetime, "Loan period was shortened because ConsiderLibraryHoursInCirculation is set to close time" );
392
is( $date, $expected_duetime, "Loan period was shortened because ConsiderLibraryHoursInCirculation is set to close time" );
392
393
393
t::lib::Mocks::mock_preference('ConsiderLibraryHoursWhenIssuing', 'open');
394
t::lib::Mocks::mock_preference('ConsiderLibraryHoursWhenIssuing', 'open');
394
# extend loan period
395
# extend loan period
395
396
396
$date = C4::Circulation::CalcDateDue( $now, $itemtype, $library1->{branchcode}, $borrower );
397
$date = C4::Circulation::CalcDateDue( $now, $itemtype, $library1->{branchcode}, $borrower );
397
$expected_duetime = DateTime->now->add( days => 1 )->subtract( hours => 4 );
398
$expected_duetime = $now->clone->add( days => 1 )->subtract( hours => 4 );
398
is( $date, $expected_duetime, "Loan period was extended because ConsiderLibraryHoursInCirculation is set to open time" );
399
is( $date, $expected_duetime, "Loan period was extended because ConsiderLibraryHoursInCirculation is set to open time" );
399
400
400
my $holiday_tomorrow = DateTime->now->add( days => 1 );
401
my $holiday_tomorrow = $now->clone->add( days => 1 );
401
402
402
# consider calendar
403
# consider calendar
403
my $library1_calendar = C4::Calendar->new( branchcode => $library1->{branchcode} );
404
my $library1_calendar = C4::Calendar->new( branchcode => $library1->{branchcode} );
Lines 414-420 Koha::CirculationRules->set_rules( Link Here
414
        itemtype     => $itemtype,
415
        itemtype     => $itemtype,
415
        branchcode   => $library1->{branchcode},
416
        branchcode   => $library1->{branchcode},
416
        rules        => {
417
        rules        => {
417
            issuelength   => 13, # loan period must cross over into tomorrow
418
            issuelength   => 18, # loan period must cross over into tomorrow
418
            lengthunit    => 'hours',
419
            lengthunit    => 'hours',
419
        }
420
        }
420
    }
421
    }
Lines 425-438 t::lib::Mocks::mock_preference('ConsiderLibraryHoursInCirculation', 'close'); Link Here
425
# shorten loan period
426
# shorten loan period
426
427
427
$date = C4::Circulation::CalcDateDue( $now, $itemtype, $library1->{branchcode}, $borrower );
428
$date = C4::Circulation::CalcDateDue( $now, $itemtype, $library1->{branchcode}, $borrower );
428
$expected_duetime = DateTime->now->add( days => 2, hours => 2 );
429
$expected_duetime = $now->clone->add( days => 2, hours => 2 );
429
is( $date, $expected_duetime, "Loan period was shortened (but considers the holiday) because ConsiderLibraryHoursInCirculation is set to close time" );
430
is( $date, $expected_duetime, "Loan period was shortened (but considers the holiday) because ConsiderLibraryHoursInCirculation is set to close time" );
430
431
431
t::lib::Mocks::mock_preference( 'ConsiderLibraryHoursInCirculation', 'open' );
432
t::lib::Mocks::mock_preference( 'ConsiderLibraryHoursInCirculation', 'open' );
432
# extend loan period
433
# extend loan period
433
434
434
$date = C4::Circulation::CalcDateDue( $now, $itemtype, $library1->{branchcode}, $borrower );
435
$date = C4::Circulation::CalcDateDue( $now, $itemtype, $library1->{branchcode}, $borrower );
435
$expected_duetime = DateTime->now->add( days => 2 )->subtract( hours => 4 );
436
$expected_duetime = $now->clone->add( days => 2 )->subtract( hours => 4 );
436
is( $date, $expected_duetime, "Loan period was extended (but considers the holiday) because ConsiderLibraryHoursInCirculation is set to open time" );
437
is( $date, $expected_duetime, "Loan period was extended (but considers the holiday) because ConsiderLibraryHoursInCirculation is set to open time" );
437
438
438
$cache->clear_from_cache($key);
439
$cache->clear_from_cache($key);
439
- 

Return to bug 6796