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

(-)a/admin/branches.pl (-4 / +4 lines)
Lines 123-132 if ( $op eq 'add_form' ) { Link Here
123
                    my @close_times = $input->multi_param("close_time");
123
                    my @close_times = $input->multi_param("close_time");
124
124
125
                    foreach my $day ( @days ) {
125
                    foreach my $day ( @days ) {
126
                        if ( $open_times[$day] and $open_times[$day] eq '' ) {
126
                        if ( $open_times[$day] !~ /([0-9]{2}:[0-9]{2})/ ) {
127
                            $open_times[$day] = undef;
127
                            $open_times[$day] = undef;
128
                        }
128
                        }
129
                        if ( $close_times[$day] and $close_times[$day] eq '' ) {
129
                        if ( $close_times[$day] !~ /([0-9]{2}:[0-9]{2})/ ) {
130
                            $close_times[$day] = undef;
130
                            $close_times[$day] = undef;
131
                        }
131
                        }
132
132
Lines 176-185 if ( $op eq 'add_form' ) { Link Here
176
                    my @close_times = $input->multi_param("close_time");
176
                    my @close_times = $input->multi_param("close_time");
177
177
178
                    foreach my $day ( @days ) {
178
                    foreach my $day ( @days ) {
179
                        if ( $open_times[$day] and $open_times[$day] eq '' ) {
179
                        if ( $open_times[$day] !~ /([0-9]{2}:[0-9]{2})/ ) {
180
                            $open_times[$day] = undef;
180
                            $open_times[$day] = undef;
181
                        }
181
                        }
182
                        if ( $close_times[$day] and $close_times[$day] eq '' ) {
182
                        if ( $close_times[$day] !~ /([0-9]{2}:[0-9]{2})/ ) {
183
                            $close_times[$day] = undef;
183
                            $close_times[$day] = undef;
184
                        }
184
                        }
185
185
(-)a/t/db_dependent/Circulation/CalcDateDue.t (-10 / +10 lines)
Lines 352-364 Koha::CirculationRules->set_rules( Link Here
352
        rules        => {
352
        rules        => {
353
            issuelength   => 3, # loan period is 3 hours
353
            issuelength   => 3, # loan period is 3 hours
354
            lengthunit    => 'hours',
354
            lengthunit    => 'hours',
355
            daysmode      => '',
355
        }
356
        }
356
    }
357
    }
357
);
358
);
358
359
359
my $open = DateTime->now->subtract( hours => 4 )->hms;
360
my $open = DateTime->new( year => 2023, month => 5, day => 1, hour => 10 )->hms;
360
my $close = DateTime->now->add( hours => 2 )->hms;
361
my $close = DateTime->new( year => 2023, month => 5, day => 1, hour => 16 )->hms;
361
my $now = DateTime->now;
362
my $now = DateTime->new( year => 2023, month => 5, day => 1, hour => 14 );
362
363
363
foreach (0..6) {
364
foreach (0..6) {
364
    # library opened 4 hours ago and closes in 2 hours.
365
    # library opened 4 hours ago and closes in 2 hours.
Lines 371-387 t::lib::Mocks::mock_preference('ConsiderLibraryHoursWhenIssuing', 'close'); Link Here
371
# shorten loan period
372
# shorten loan period
372
373
373
$date = C4::Circulation::CalcDateDue( $now, $itemtype, $library1->{branchcode}, $borrower );
374
$date = C4::Circulation::CalcDateDue( $now, $itemtype, $library1->{branchcode}, $borrower );
374
my $expected_duetime = DateTime->now->add( hours => 2 );
375
my $expected_duetime = $now->clone->add( hours => 2 );
375
is( $date, $expected_duetime, "Loan period was shortened because ConsiderLibraryHoursWhenIssuing is set to close time" );
376
is( $date, $expected_duetime, "Loan period was shortened because ConsiderLibraryHoursWhenIssuing is set to close time" );
376
377
377
t::lib::Mocks::mock_preference('ConsiderLibraryHoursWhenIssuing', 'open');
378
t::lib::Mocks::mock_preference('ConsiderLibraryHoursWhenIssuing', 'open');
378
# extend loan period
379
# extend loan period
379
380
380
$date = C4::Circulation::CalcDateDue( $now, $itemtype, $library1->{branchcode}, $borrower );
381
$date = C4::Circulation::CalcDateDue( $now, $itemtype, $library1->{branchcode}, $borrower );
381
$expected_duetime = DateTime->now->add( days => 1 )->subtract( hours => 4 );
382
$expected_duetime = $now->clone->add( days => 1 )->subtract( hours => 4 );
382
is( $date, $expected_duetime, "Loan period was extended because ConsiderLibraryHoursWhenIssuing is set to open time" );
383
is( $date, $expected_duetime, "Loan period was extended because ConsiderLibraryHoursWhenIssuing is set to open time" );
383
384
384
my $holiday_tomorrow = DateTime->now->add( days => 1 );
385
my $holiday_tomorrow = $now->clone->add( days => 1 );
385
386
386
# consider calendar
387
# consider calendar
387
my $library1_calendar = C4::Calendar->new( branchcode => $library1->{branchcode} );
388
my $library1_calendar = C4::Calendar->new( branchcode => $library1->{branchcode} );
Lines 398-404 Koha::CirculationRules->set_rules( Link Here
398
        itemtype     => $itemtype,
399
        itemtype     => $itemtype,
399
        branchcode   => $library1->{branchcode},
400
        branchcode   => $library1->{branchcode},
400
        rules        => {
401
        rules        => {
401
            issuelength   => 13, # loan period must cross over into tomorrow
402
            issuelength   => 18, # loan period must cross over into tomorrow
402
            lengthunit    => 'hours',
403
            lengthunit    => 'hours',
403
        }
404
        }
404
    }
405
    }
Lines 409-422 t::lib::Mocks::mock_preference('ConsiderLibraryHoursWhenIssuing', 'close'); Link Here
409
# shorten loan period
410
# shorten loan period
410
411
411
$date = C4::Circulation::CalcDateDue( $now, $itemtype, $library1->{branchcode}, $borrower );
412
$date = C4::Circulation::CalcDateDue( $now, $itemtype, $library1->{branchcode}, $borrower );
412
$expected_duetime = DateTime->now->add( days => 2, hours => 2 );
413
$expected_duetime = $now->clone->add( days => 2, hours => 2 );
413
is( $date, $expected_duetime, "Loan period was shortened (but considers the holiday) because ConsiderLibraryHoursWhenIssuing is set to close time" );
414
is( $date, $expected_duetime, "Loan period was shortened (but considers the holiday) because ConsiderLibraryHoursWhenIssuing is set to close time" );
414
415
415
t::lib::Mocks::mock_preference('ConsiderLibraryHoursWhenIssuing', 'open');
416
t::lib::Mocks::mock_preference('ConsiderLibraryHoursWhenIssuing', 'open');
416
# extend loan period
417
# extend loan period
417
418
418
$date = C4::Circulation::CalcDateDue( $now, $itemtype, $library1->{branchcode}, $borrower );
419
$date = C4::Circulation::CalcDateDue( $now, $itemtype, $library1->{branchcode}, $borrower );
419
$expected_duetime = DateTime->now->add( days => 2 )->subtract( hours => 4 );
420
$expected_duetime = $now->clone->add( days => 2 )->subtract( hours => 4 );
420
is( $date, $expected_duetime, "Loan period was extended (but considers the holiday) because ConsiderLibraryHoursWhenIssuing is set to open time" );
421
is( $date, $expected_duetime, "Loan period was extended (but considers the holiday) because ConsiderLibraryHoursWhenIssuing is set to open time" );
421
422
422
$cache->clear_from_cache($key);
423
$cache->clear_from_cache($key);
423
- 

Return to bug 6796