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

(-)a/C4/Circulation.pm (-6 / +6 lines)
Lines 44-50 use Koha::Account; Link Here
44
use Koha::AuthorisedValues;
44
use Koha::AuthorisedValues;
45
use Koha::Biblioitems;
45
use Koha::Biblioitems;
46
use Koha::DateUtils;
46
use Koha::DateUtils;
47
use Koha::Calendar;
47
use Koha::DiscreteCalendar;
48
use Koha::Checkouts;
48
use Koha::Checkouts;
49
use Koha::IssuingRules;
49
use Koha::IssuingRules;
50
use Koha::Items;
50
use Koha::Items;
Lines 1198-1204 sub checkHighHolds { Link Here
1198
1198
1199
        my $issuedate = DateTime->now( time_zone => C4::Context->tz() );
1199
        my $issuedate = DateTime->now( time_zone => C4::Context->tz() );
1200
1200
1201
        my $calendar = Koha::Calendar->new( branchcode => $branch );
1201
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
1202
1202
1203
        my $itype = $item_object->effective_itemtype;
1203
        my $itype = $item_object->effective_itemtype;
1204
        my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branch, $borrower );
1204
        my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branch, $borrower );
Lines 2132-2138 sub MarkIssueReturned { Link Here
2132
    my $query = 'UPDATE issues SET returndate=';
2132
    my $query = 'UPDATE issues SET returndate=';
2133
    my @bind;
2133
    my @bind;
2134
    if ($dropbox_branch) {
2134
    if ($dropbox_branch) {
2135
        my $calendar = Koha::Calendar->new( branchcode => $dropbox_branch );
2135
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $dropbox_branch );
2136
        my $dropboxdate = $calendar->addDate( DateTime->now( time_zone => C4::Context->tz), -1 );
2136
        my $dropboxdate = $calendar->addDate( DateTime->now( time_zone => C4::Context->tz), -1 );
2137
        $query .= ' ? ';
2137
        $query .= ' ? ';
2138
        push @bind, $dropboxdate->strftime('%Y-%m-%d %H:%M');
2138
        push @bind, $dropboxdate->strftime('%Y-%m-%d %H:%M');
Lines 2256-2262 sub _debar_user_on_return { Link Here
2256
            my $new_debar_dt;
2256
            my $new_debar_dt;
2257
            # Use the calendar or not to calculate the debarment date
2257
            # Use the calendar or not to calculate the debarment date
2258
            if ( C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed' ) {
2258
            if ( C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed' ) {
2259
                my $calendar = Koha::Calendar->new(
2259
                my $calendar = Koha::DiscreteCalendar->new(
2260
                    branchcode => $branchcode,
2260
                    branchcode => $branchcode,
2261
                    days_mode  => 'Calendar'
2261
                    days_mode  => 'Calendar'
2262
                );
2262
                );
Lines 3486-3492 sub CalcDateDue { Link Here
3486
        else { # days
3486
        else { # days
3487
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3487
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3488
        }
3488
        }
3489
        my $calendar = Koha::Calendar->new( branchcode => $branch );
3489
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
3490
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3490
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3491
        if ($loanlength->{lengthunit} eq 'days') {
3491
        if ($loanlength->{lengthunit} eq 'days') {
3492
            $datedue->set_hour(23);
3492
            $datedue->set_hour(23);
Lines 3525-3531 sub CalcDateDue { Link Here
3525
            }
3525
            }
3526
        }
3526
        }
3527
        if ( C4::Context->preference('useDaysMode') ne 'Days' ) {
3527
        if ( C4::Context->preference('useDaysMode') ne 'Days' ) {
3528
          my $calendar = Koha::Calendar->new( branchcode => $branch );
3528
          my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
3529
          if ( $calendar->is_holiday($datedue) ) {
3529
          if ( $calendar->is_holiday($datedue) ) {
3530
              # Don't return on a closed day
3530
              # Don't return on a closed day
3531
              $datedue = $calendar->prev_open_day( $datedue );
3531
              $datedue = $calendar->prev_open_day( $datedue );
(-)a/C4/HoldsQueue.pm (-4 / +4 lines)
Lines 30-36 use C4::Members; Link Here
30
use C4::Biblio;
30
use C4::Biblio;
31
use Koha::DateUtils;
31
use Koha::DateUtils;
32
use Koha::Patrons;
32
use Koha::Patrons;
33
33
use Koha::DiscreteCalendar;
34
use List::Util qw(shuffle);
34
use List::Util qw(shuffle);
35
use List::MoreUtils qw(any);
35
use List::MoreUtils qw(any);
36
use Data::Dumper;
36
use Data::Dumper;
Lines 77-83 sub TransportCostMatrix { Link Here
77
        };
77
        };
78
78
79
        if ( C4::Context->preference("HoldsQueueSkipClosed") ) {
79
        if ( C4::Context->preference("HoldsQueueSkipClosed") ) {
80
            $calendars->{$from} ||= Koha::Calendar->new( branchcode => $from );
80
            $calendars->{$from} ||= Koha::DiscreteCalendar->new( branchcode => $from );
81
            $transport_cost_matrix{$to}{$from}{disable_transfer} ||=
81
            $transport_cost_matrix{$to}{$from}{disable_transfer} ||=
82
              $calendars->{$from}->is_holiday( $today );
82
              $calendars->{$from}->is_holiday( $today );
83
        }
83
        }
Lines 206-212 sub CreateQueue { Link Here
206
        $total_requests        += scalar(@$hold_requests);
206
        $total_requests        += scalar(@$hold_requests);
207
        $total_available_items += scalar(@$available_items);
207
        $total_available_items += scalar(@$available_items);
208
208
209
        my $item_map = MapItemsToHoldRequests($hold_requests, $available_items, $branches_to_use, $transport_cost_matrix);
209
       my $item_map = MapItemsToHoldRequests($hold_requests, $available_items, $branches_to_use, $transport_cost_matrix);
210
        $item_map  or next;
210
        $item_map  or next;
211
        my $item_map_size = scalar(keys %$item_map)
211
        my $item_map_size = scalar(keys %$item_map)
212
          or next;
212
          or next;
Lines 742-748 sub load_branches_to_pull_from { Link Here
742
    my $today = dt_from_string();
742
    my $today = dt_from_string();
743
    if ( C4::Context->preference('HoldsQueueSkipClosed') ) {
743
    if ( C4::Context->preference('HoldsQueueSkipClosed') ) {
744
        @branches_to_use = grep {
744
        @branches_to_use = grep {
745
            !Koha::Calendar->new( branchcode => $_ )
745
            !Koha::DiscreteCalendar->new( branchcode => $_ )
746
              ->is_holiday( $today )
746
              ->is_holiday( $today )
747
        } @branches_to_use;
747
        } @branches_to_use;
748
    }
748
    }
(-)a/C4/Overdues.pm (-2 / +3 lines)
Lines 34-39 use C4::Accounts; Link Here
34
use C4::Log; # logaction
34
use C4::Log; # logaction
35
use C4::Debug;
35
use C4::Debug;
36
use Koha::DateUtils;
36
use Koha::DateUtils;
37
use Koha::DiscreteCalendar;
37
use Koha::Account::Lines;
38
use Koha::Account::Lines;
38
use Koha::Account::Offsets;
39
use Koha::Account::Offsets;
39
use Koha::IssuingRules;
40
use Koha::IssuingRules;
Lines 298-304 sub get_chargeable_units { Link Here
298
    my $charge_duration;
299
    my $charge_duration;
299
    if ($unit eq 'hours') {
300
    if ($unit eq 'hours') {
300
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
301
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
301
            my $calendar = Koha::Calendar->new( branchcode => $branchcode );
302
            my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
302
            $charge_duration = $calendar->hours_between( $date_due, $date_returned );
303
            $charge_duration = $calendar->hours_between( $date_due, $date_returned );
303
        } else {
304
        } else {
304
            $charge_duration = $date_returned->delta_ms( $date_due );
305
            $charge_duration = $date_returned->delta_ms( $date_due );
Lines 310-316 sub get_chargeable_units { Link Here
310
    }
311
    }
311
    else { # days
312
    else { # days
312
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
313
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
313
            my $calendar = Koha::Calendar->new( branchcode => $branchcode );
314
            my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
314
            $charge_duration = $calendar->days_between( $date_due, $date_returned );
315
            $charge_duration = $calendar->days_between( $date_due, $date_returned );
315
        } else {
316
        } else {
316
            $charge_duration = $date_returned->delta_days( $date_due );
317
            $charge_duration = $date_returned->delta_days( $date_due );
(-)a/C4/Reserves.pm (-2 / +2 lines)
Lines 38-44 use C4::Log; Link Here
38
38
39
use Koha::Biblios;
39
use Koha::Biblios;
40
use Koha::DateUtils;
40
use Koha::DateUtils;
41
use Koha::Calendar;
41
use Koha::DiscreteCalendar;
42
use Koha::Database;
42
use Koha::Database;
43
use Koha::Hold;
43
use Koha::Hold;
44
use Koha::Old::Hold;
44
use Koha::Old::Hold;
Lines 814-820 sub CancelExpiredReserves { Link Here
814
    my $holds = Koha::Holds->search( $params );
814
    my $holds = Koha::Holds->search( $params );
815
815
816
    while ( my $hold = $holds->next ) {
816
    while ( my $hold = $holds->next ) {
817
        my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
817
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $hold->branchcode );
818
818
819
        next if !$cancel_on_holidays && $calendar->is_holiday( $today );
819
        next if !$cancel_on_holidays && $calendar->is_holiday( $today );
820
820
(-)a/Koha/Hold.pm (-4 / +4 lines)
Lines 25-38 use Data::Dumper qw(Dumper); Link Here
25
25
26
use C4::Context qw(preference);
26
use C4::Context qw(preference);
27
use C4::Log;
27
use C4::Log;
28
28
use Koha::DiscreteCalendar;
29
use Koha::DateUtils qw(dt_from_string output_pref);
29
use Koha::DateUtils qw(dt_from_string output_pref);
30
use Koha::Patrons;
30
use Koha::Patrons;
31
use Koha::Biblios;
31
use Koha::Biblios;
32
use Koha::Items;
32
use Koha::Items;
33
use Koha::Libraries;
33
use Koha::Libraries;
34
use Koha::Old::Holds;
34
use Koha::Old::Holds;
35
use Koha::Calendar;
35
use Koha::DiscreteCalendar;
36
36
37
use base qw(Koha::Object);
37
use base qw(Koha::Object);
38
38
Lines 62-68 sub age { Link Here
62
    my $age;
62
    my $age;
63
63
64
    if ( $use_calendar ) {
64
    if ( $use_calendar ) {
65
        my $calendar = Koha::Calendar->new( branchcode => $self->branchcode );
65
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $self->branchcode );
66
        $age = $calendar->days_between( dt_from_string( $self->reservedate ), $today );
66
        $age = $calendar->days_between( dt_from_string( $self->reservedate ), $today );
67
    }
67
    }
68
    else {
68
    else {
Lines 164-170 sub set_waiting { Link Here
164
164
165
    my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
165
    my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
166
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
166
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
167
    my $calendar = Koha::Calendar->new( branchcode => $self->branchcode );
167
    my $calendar = Koha::DiscreteCalendar->new( branchcode => $self->branchcode );
168
168
169
    my $expirationdate = $today->clone;
169
    my $expirationdate = $today->clone;
170
    $expirationdate->add(days => $max_pickup_delay);
170
    $expirationdate->add(days => $max_pickup_delay);
(-)a/circ/returns.pl (-2 / +3 lines)
Lines 47-53 use C4::Koha; # FIXME : is it still useful ? Link Here
47
use C4::RotatingCollections;
47
use C4::RotatingCollections;
48
use Koha::AuthorisedValues;
48
use Koha::AuthorisedValues;
49
use Koha::DateUtils;
49
use Koha::DateUtils;
50
use Koha::Calendar;
50
use Koha::DiscreteCalendar;
51
use Koha::Checkouts;
51
use Koha::BiblioFrameworks;
52
use Koha::BiblioFrameworks;
52
use Koha::Holds;
53
use Koha::Holds;
53
use Koha::Items;
54
use Koha::Items;
Lines 203-209 my $dropboxmode = $query->param('dropboxmode'); Link Here
203
my $dotransfer  = $query->param('dotransfer');
204
my $dotransfer  = $query->param('dotransfer');
204
my $canceltransfer = $query->param('canceltransfer');
205
my $canceltransfer = $query->param('canceltransfer');
205
my $dest = $query->param('dest');
206
my $dest = $query->param('dest');
206
my $calendar    = Koha::Calendar->new( branchcode => $userenv_branch );
207
my $calendar    = Koha::DiscreteCalendar->new( branchcode => $userenv_branch );
207
#dropbox: get last open day (today - 1)
208
#dropbox: get last open day (today - 1)
208
my $today       = DateTime->now( time_zone => C4::Context->tz());
209
my $today       = DateTime->now( time_zone => C4::Context->tz());
209
my $dropboxdate = $calendar->addDate($today, -1);
210
my $dropboxdate = $calendar->addDate($today, -1);
(-)a/installer/data/mysql/updatedatabase.pl (-2 / +2 lines)
Lines 14353-14359 if( CheckVersion( $DBversion ) ) { Link Here
14353
14353
14354
$DBversion = '16.12.00.032';
14354
$DBversion = '16.12.00.032';
14355
if( CheckVersion( $DBversion ) ) {
14355
if( CheckVersion( $DBversion ) ) {
14356
    require Koha::Calendar;
14356
    require Koha::DiscreteCalendar;
14357
    require Koha::Holds;
14357
    require Koha::Holds;
14358
14358
14359
    $dbh->do(q{
14359
    $dbh->do(q{
Lines 14372-14378 if( CheckVersion( $DBversion ) ) { Link Here
14372
14372
14373
        my $expirationdate = dt_from_string($hold->waitingdate);
14373
        my $expirationdate = dt_from_string($hold->waitingdate);
14374
        if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
14374
        if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
14375
            my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
14375
            my $calendar = Koha::DiscreteCalendar->new( branchcode => $hold->branchcode );
14376
            $expirationdate = $calendar->days_forward( $expirationdate, $max_pickup_delay );
14376
            $expirationdate = $calendar->days_forward( $expirationdate, $max_pickup_delay );
14377
        } else {
14377
        } else {
14378
            $expirationdate->add( days => $max_pickup_delay );
14378
            $expirationdate->add( days => $max_pickup_delay );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (+5 lines)
Lines 81-86 Link Here
81
    <dd>Define days when the library is closed</dd>
81
    <dd>Define days when the library is closed</dd>
82
    [% END %]
82
    [% END %]
83
83
84
    [% IF ( CAN_user_tools_edit_calendar ) %]
85
    <dt><a href="/cgi-bin/koha/tools/discrete_calendar.pl">Discrete Calendar</a></dt>
86
    <dd>Define days when the library is closed</dd>
87
    [% END %]
88
84
    [% IF ( CAN_user_tools_manage_csv_profiles ) %]
89
    [% IF ( CAN_user_tools_manage_csv_profiles ) %]
85
    <dt><a href="/cgi-bin/koha/tools/csv-profiles.pl">CSV profiles</a></dt>
90
    <dt><a href="/cgi-bin/koha/tools/csv-profiles.pl">CSV profiles</a></dt>
86
	<dd>Manage CSV export profiles</dd>
91
	<dd>Manage CSV export profiles</dd>
(-)a/misc/cronjobs/fines.pl (-2 / +2 lines)
Lines 36-42 use Getopt::Long; Link Here
36
use Carp;
36
use Carp;
37
use File::Spec;
37
use File::Spec;
38
38
39
use Koha::Calendar;
39
use Koha::DiscreteCalendar;
40
use Koha::DateUtils;
40
use Koha::DateUtils;
41
use C4::Log;
41
use C4::Log;
42
42
Lines 176-182 EOM Link Here
176
sub set_holiday {
176
sub set_holiday {
177
    my ( $branch, $dt ) = @_;
177
    my ( $branch, $dt ) = @_;
178
178
179
    my $calendar = Koha::Calendar->new( branchcode => $branch );
179
    my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
180
    return $calendar->is_holiday($dt);
180
    return $calendar->is_holiday($dt);
181
}
181
}
182
182
(-)a/misc/cronjobs/holds/cancel_unfilled_holds.pl (-1 / +1 lines)
Lines 31-37 use Pod::Usage; Link Here
31
use C4::Reserves;
31
use C4::Reserves;
32
use C4::Log;
32
use C4::Log;
33
use Koha::Holds;
33
use Koha::Holds;
34
use Koha::Calendar;
34
use Koha::DiscreteCalendar;
35
use Koha::DateUtils;
35
use Koha::DateUtils;
36
use Koha::Libraries;
36
use Koha::Libraries;
37
37
(-)a/misc/cronjobs/overdue_notices.pl (-11 / +7 lines)
Lines 40-46 use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes parse_overdues_lette Link Here
40
use C4::Log;
40
use C4::Log;
41
use Koha::Patron::Debarments qw(AddUniqueDebarment);
41
use Koha::Patron::Debarments qw(AddUniqueDebarment);
42
use Koha::DateUtils;
42
use Koha::DateUtils;
43
use Koha::Calendar;
43
use Koha::DiscreteCalendar;
44
use Koha::Libraries;
44
use Koha::Libraries;
45
use Koha::Acquisition::Currencies;
45
use Koha::Acquisition::Currencies;
46
use Koha::Patrons;
46
use Koha::Patrons;
Lines 444-452 elsif ( defined $text_filename ) { Link Here
444
}
444
}
445
445
446
foreach my $branchcode (@branches) {
446
foreach my $branchcode (@branches) {
447
    my $calendar;
448
    if ( C4::Context->preference('OverdueNoticeCalendar') ) {
447
    if ( C4::Context->preference('OverdueNoticeCalendar') ) {
449
        $calendar = Koha::Calendar->new( branchcode => $branchcode );
448
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
450
        if ( $calendar->is_holiday($date_to_run) ) {
449
        if ( $calendar->is_holiday($date_to_run) ) {
451
            next;
450
            next;
452
        }
451
        }
Lines 547-559 END_SQL Link Here
547
                my $days_between;
546
                my $days_between;
548
                if ( C4::Context->preference('OverdueNoticeCalendar') )
547
                if ( C4::Context->preference('OverdueNoticeCalendar') )
549
                {
548
                {
550
                    $days_between =
549
                    my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
551
                      $calendar->days_between( dt_from_string($data->{date_due}),
550
                    $days_between = $calendar->days_between( dt_from_string($data->{date_due}), $date_to_run );
552
                        $date_to_run );
553
                }
551
                }
554
                else {
552
                else {
555
                    $days_between =
553
                    $days_between = $date_to_run->delta_days( dt_from_string($data->{date_due}) );
556
                      $date_to_run->delta_days( dt_from_string($data->{date_due}) );
557
                }
554
                }
558
                $days_between = $days_between->in_units('days');
555
                $days_between = $days_between->in_units('days');
559
                if ($triggered) {
556
                if ($triggered) {
Lines 629-637 END_SQL Link Here
629
                my $exceededPrintNoticesMaxLines = 0;
626
                my $exceededPrintNoticesMaxLines = 0;
630
                while ( my $item_info = $sth2->fetchrow_hashref() ) {
627
                while ( my $item_info = $sth2->fetchrow_hashref() ) {
631
                    if ( C4::Context->preference('OverdueNoticeCalendar') ) {
628
                    if ( C4::Context->preference('OverdueNoticeCalendar') ) {
632
                        $days_between =
629
                        my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
633
                          $calendar->days_between(
630
                        $days_between = $calendar->days_between( dt_from_string( $item_info->{date_due} ), $date_to_run );
634
                            dt_from_string( $item_info->{date_due} ), $date_to_run );
635
                    }
631
                    }
636
                    else {
632
                    else {
637
                        $days_between =
633
                        $days_between =
(-)a/misc/cronjobs/staticfines.pl (-2 / +2 lines)
Lines 40-46 use Date::Calc qw/Date_to_Days/; Link Here
40
use C4::Context;
40
use C4::Context;
41
use C4::Circulation;
41
use C4::Circulation;
42
use C4::Overdues;
42
use C4::Overdues;
43
use C4::Calendar qw();    # don't need any exports from Calendar
43
use Koha::DiscreteCalendar qw();    # don't need any exports from Calendar
44
use C4::Biblio;
44
use C4::Biblio;
45
use C4::Debug;            # supplying $debug and $cgi_debug
45
use C4::Debug;            # supplying $debug and $cgi_debug
46
use C4::Log;
46
use C4::Log;
Lines 176-182 for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) { Link Here
176
176
177
    my $calendar;
177
    my $calendar;
178
    unless ( defined( $calendars{$branchcode} ) ) {
178
    unless ( defined( $calendars{$branchcode} ) ) {
179
        $calendars{$branchcode} = C4::Calendar->new( branchcode => $branchcode );
179
        $calendars{$branchcode} = Koha::DiscreteCalendar->new( branchcode => $branchcode );
180
    }
180
    }
181
    $calendar = $calendars{$branchcode};
181
    $calendar = $calendars{$branchcode};
182
    my $isHoliday = $calendar->isHoliday( $tday, $tmonth, $tyear );
182
    my $isHoliday = $calendar->isHoliday( $tday, $tmonth, $tyear );
(-)a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl (-2 / +2 lines)
Lines 35-41 use C4::Context; Link Here
35
use C4::Items;
35
use C4::Items;
36
use C4::Letters;
36
use C4::Letters;
37
use C4::Overdues;
37
use C4::Overdues;
38
use Koha::Calendar;
38
use Koha::DiscreteCalendar;
39
use Koha::DateUtils;
39
use Koha::DateUtils;
40
use Koha::Patrons;
40
use Koha::Patrons;
41
41
Lines 301-307 sub GetWaitingHolds { Link Here
301
    $sth->execute();
301
    $sth->execute();
302
    my @results;
302
    my @results;
303
    while ( my $issue = $sth->fetchrow_hashref() ) {
303
    while ( my $issue = $sth->fetchrow_hashref() ) {
304
        my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'} );
304
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $issue->{'site'} );
305
305
306
        my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' );
306
        my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' );
307
        my $pickup_date = $waiting_date->clone->add( days => $pickupdelay );
307
        my $pickup_date = $waiting_date->clone->add( days => $pickupdelay );
(-)a/t/db_dependent/Circulation/CalcFine.t (-22 / +4 lines)
Lines 102-118 subtest 'Test basic functionality' => sub { Link Here
102
        }
102
        }
103
    );
103
    );
104
104
105
    my $start_dt = DateTime->new(
105
    my $start_dt = DateTime->today;
106
        year       => 2000,
106
    my $end_dt = DateTime->today->add(days => 29);
107
        month      => 1,
108
        day        => 1,
109
    );
110
111
    my $end_dt = DateTime->new(
112
        year       => 2000,
113
        month      => 1,
114
        day        => 30,
115
    );
116
107
117
    my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
108
    my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
118
109
Lines 143-159 subtest 'Test cap_fine_to_replacement_price' => sub { Link Here
143
        }
134
        }
144
    );
135
    );
145
136
146
    my $start_dt = DateTime->new(
137
    my $start_dt = DateTime->today;
147
        year       => 2000,
138
    my $end_dt = DateTime->today->add(days => 29);
148
        month      => 1,
149
        day        => 1,
150
    );
151
152
    my $end_dt = DateTime->new(
153
        year       => 2000,
154
        month      => 1,
155
        day        => 30,
156
    );
157
139
158
    my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
140
    my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
159
141
(-)a/t/db_dependent/Fines.t (-5 / +6 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use DateTime;
4
5
5
use C4::Context;
6
use C4::Context;
6
use C4::Overdues;
7
use C4::Overdues;
Lines 34-56 my $issuingrule = $schema->resultset('Issuingrule')->create( Link Here
34
35
35
ok( $issuingrule, 'Issuing rule created' );
36
ok( $issuingrule, 'Issuing rule created' );
36
37
37
my $period_start = dt_from_string('2000-01-01');
38
my $period_start = dt_from_string;
38
my $period_end = dt_from_string('2000-01-05');
39
my $period_end = dt_from_string->add(days => 4);
39
40
40
my ( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
41
my ( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
41
is( $fine, 0, '4 days overdue, charge period 7 days, charge at end of interval gives fine of $0' );
42
is( $fine, 0, '4 days overdue, charge period 7 days, charge at end of interval gives fine of $0' );
42
43
43
$period_end = dt_from_string('2000-01-10');
44
$period_end = dt_from_string->add(days => 9);
44
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
45
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
45
is( $fine, 1, '9 days overdue, charge period 7 days, charge at end of interval gives fine of $1' );
46
is( $fine, 1, '9 days overdue, charge period 7 days, charge at end of interval gives fine of $1' );
46
47
47
# Test charging fine at the *beginning* of each charge period
48
# Test charging fine at the *beginning* of each charge period
48
$issuingrule->update( { chargeperiod_charge_at => 1 } );
49
$issuingrule->update( { chargeperiod_charge_at => 1 } );
49
50
50
$period_end = dt_from_string('2000-01-05');
51
$period_end = dt_from_string->add(days => 4);
51
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
52
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
52
is( $fine, 1, '4 days overdue, charge period 7 days, charge at start of interval gives fine of $1' );
53
is( $fine, 1, '4 days overdue, charge period 7 days, charge at start of interval gives fine of $1' );
53
54
54
$period_end = dt_from_string('2000-01-10');
55
$period_end = dt_from_string->add(days => 9);
55
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
56
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
56
is( $fine, 2, '9 days overdue, charge period 7 days, charge at start of interval gives fine of $2' );
57
is( $fine, 2, '9 days overdue, charge period 7 days, charge at start of interval gives fine of $2' );
(-)a/t/db_dependent/HoldsQueue.t (-10 / +25 lines)
Lines 11-19 use Modern::Perl; Link Here
11
use Test::More tests => 44;
11
use Test::More tests => 44;
12
use Data::Dumper;
12
use Data::Dumper;
13
13
14
use C4::Calendar;
15
use C4::Context;
14
use C4::Context;
16
use C4::Members;
15
use C4::Members;
16
use Koha::DiscreteCalendar;
17
use Koha::Database;
17
use Koha::Database;
18
use Koha::DateUtils;
18
use Koha::DateUtils;
19
use Koha::Items;
19
use Koha::Items;
Lines 189-194 $library2 = $builder->build({ Link Here
189
$library3 = $builder->build({
189
$library3 = $builder->build({
190
    source => 'Branch',
190
    source => 'Branch',
191
});
191
});
192
193
$schema->resultset('DiscreteCalendar')->search({
194
    branchcode  =>''
195
})->update_all({
196
    is_opened    => 1,
197
    holiday_type => '',
198
    note        => '',
199
    open_hour    => '08:00:00',
200
    close_hour   => '16:00:00'
201
});
202
203
Koha::DiscreteCalendar->new( branchcode => '' )->add_new_branch('', $library1->{branchcode});
204
Koha::DiscreteCalendar->new( branchcode => '' )->add_new_branch('', $library2->{branchcode});
205
Koha::DiscreteCalendar->new( branchcode => '' )->add_new_branch('', $library3->{branchcode});
206
192
@branchcodes = ( $library1->{branchcode}, $library2->{branchcode}, $library3->{branchcode} );
207
@branchcodes = ( $library1->{branchcode}, $library2->{branchcode}, $library3->{branchcode} );
193
208
194
my $borrower1 = $builder->build({
209
my $borrower1 = $builder->build({
Lines 302-317 is( $holds_queue->[1]->{cardnumber}, $borrower2->{cardnumber}, "Holds queue fill Link Here
302
# have 1 row in the holds queue
317
# have 1 row in the holds queue
303
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 1);
318
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 1);
304
my $today = dt_from_string();
319
my $today = dt_from_string();
305
C4::Calendar->new( branchcode => $branchcodes[0] )->insert_single_holiday(
320
306
    day         => $today->day(),
307
    month       => $today->month(),
308
    year        => $today->year(),
309
    title       => "$today",
310
    description => "$today",
311
);
312
# If the test below is removed, aother tests using the holiday will fail. For some reason if we call is_holiday now
321
# If the test below is removed, aother tests using the holiday will fail. For some reason if we call is_holiday now
313
# the holiday will get set in cache correctly, but not if we let C4::HoldsQueue call is_holiday instead.
322
# the holiday will get set in cache correctly, but not if we let C4::HoldsQueue call is_holiday instead.
314
is( Koha::Calendar->new( branchcode => $branchcodes[0] )->is_holiday( $today ), 1, 'Is today a holiday for pickup branch' );
323
Koha::DiscreteCalendar->new( branchcode => $branchcodes[0] )->edit_holiday({
324
    title        => "Today",
325
    holiday_type => "E",
326
    start_date   => $today,
327
    end_date     => $today
328
});
329
330
is( Koha::DiscreteCalendar->new( branchcode => $branchcodes[0] )->is_holiday( $today ), 1, 'Is today a holiday for pickup branch' );
315
C4::HoldsQueue::CreateQueue();
331
C4::HoldsQueue::CreateQueue();
316
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
332
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
317
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" );
333
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" );
318
- 

Return to bug 17015