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

(-)a/C4/Circulation.pm (-5 / +5 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 1195-1201 sub checkHighHolds { Link Here
1195
1195
1196
        my $issuedate = DateTime->now( time_zone => C4::Context->tz() );
1196
        my $issuedate = DateTime->now( time_zone => C4::Context->tz() );
1197
1197
1198
        my $calendar = Koha::Calendar->new( branchcode => $branch );
1198
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
1199
1199
1200
        my $itype = $item_object->effective_itemtype;
1200
        my $itype = $item_object->effective_itemtype;
1201
        my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branch, $borrower );
1201
        my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branch, $borrower );
Lines 2126-2132 sub MarkIssueReturned { Link Here
2126
    my $query = 'UPDATE issues SET returndate=';
2126
    my $query = 'UPDATE issues SET returndate=';
2127
    my @bind;
2127
    my @bind;
2128
    if ($dropbox_branch) {
2128
    if ($dropbox_branch) {
2129
        my $calendar = Koha::Calendar->new( branchcode => $dropbox_branch );
2129
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $dropbox_branch );
2130
        my $dropboxdate = $calendar->addDate( DateTime->now( time_zone => C4::Context->tz), -1 );
2130
        my $dropboxdate = $calendar->addDate( DateTime->now( time_zone => C4::Context->tz), -1 );
2131
        $query .= ' ? ';
2131
        $query .= ' ? ';
2132
        push @bind, $dropboxdate->strftime('%Y-%m-%d %H:%M');
2132
        push @bind, $dropboxdate->strftime('%Y-%m-%d %H:%M');
Lines 3480-3486 sub CalcDateDue { Link Here
3480
        else { # days
3480
        else { # days
3481
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3481
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3482
        }
3482
        }
3483
        my $calendar = Koha::Calendar->new( branchcode => $branch );
3483
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
3484
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3484
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3485
        if ($loanlength->{lengthunit} eq 'days') {
3485
        if ($loanlength->{lengthunit} eq 'days') {
3486
            $datedue->set_hour(23);
3486
            $datedue->set_hour(23);
Lines 3519-3525 sub CalcDateDue { Link Here
3519
            }
3519
            }
3520
        }
3520
        }
3521
        if ( C4::Context->preference('useDaysMode') ne 'Days' ) {
3521
        if ( C4::Context->preference('useDaysMode') ne 'Days' ) {
3522
          my $calendar = Koha::Calendar->new( branchcode => $branch );
3522
          my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
3523
          if ( $calendar->is_holiday($datedue) ) {
3523
          if ( $calendar->is_holiday($datedue) ) {
3524
              # Don't return on a closed day
3524
              # Don't return on a closed day
3525
              $datedue = $calendar->prev_open_day( $datedue );
3525
              $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 293-299 sub get_chargeable_units { Link Here
293
    my $charge_duration;
294
    my $charge_duration;
294
    if ($unit eq 'hours') {
295
    if ($unit eq 'hours') {
295
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
296
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
296
            my $calendar = Koha::Calendar->new( branchcode => $branchcode );
297
            my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
297
            $charge_duration = $calendar->hours_between( $date_due, $date_returned );
298
            $charge_duration = $calendar->hours_between( $date_due, $date_returned );
298
        } else {
299
        } else {
299
            $charge_duration = $date_returned->delta_ms( $date_due );
300
            $charge_duration = $date_returned->delta_ms( $date_due );
Lines 305-311 sub get_chargeable_units { Link Here
305
    }
306
    }
306
    else { # days
307
    else { # days
307
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
308
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
308
            my $calendar = Koha::Calendar->new( branchcode => $branchcode );
309
            my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
309
            $charge_duration = $calendar->days_between( $date_due, $date_returned );
310
            $charge_duration = $calendar->days_between( $date_due, $date_returned );
310
        } else {
311
        } else {
311
            $charge_duration = $date_returned->delta_days( $date_due );
312
            $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 770-776 sub CancelExpiredReserves { Link Here
770
    my $holds = Koha::Holds->search( $params );
770
    my $holds = Koha::Holds->search( $params );
771
771
772
    while ( my $hold = $holds->next ) {
772
    while ( my $hold = $holds->next ) {
773
        my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
773
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $hold->branchcode );
774
774
775
        next if !$cancel_on_holidays && $calendar->is_holiday( $today );
775
        next if !$cancel_on_holidays && $calendar->is_holiday( $today );
776
776
(-)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 202-208 my $dropboxmode = $query->param('dropboxmode'); Link Here
202
my $dotransfer  = $query->param('dotransfer');
203
my $dotransfer  = $query->param('dotransfer');
203
my $canceltransfer = $query->param('canceltransfer');
204
my $canceltransfer = $query->param('canceltransfer');
204
my $dest = $query->param('dest');
205
my $dest = $query->param('dest');
205
my $calendar    = Koha::Calendar->new( branchcode => $userenv_branch );
206
my $calendar    = Koha::DiscreteCalendar->new( branchcode => $userenv_branch );
206
#dropbox: get last open day (today - 1)
207
#dropbox: get last open day (today - 1)
207
my $today       = DateTime->now( time_zone => C4::Context->tz());
208
my $today       = DateTime->now( time_zone => C4::Context->tz());
208
my $dropboxdate = $calendar->addDate($today, -1);
209
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 79-84 Link Here
79
    <dd>Define days when the library is closed</dd>
79
    <dd>Define days when the library is closed</dd>
80
    [% END %]
80
    [% END %]
81
81
82
    [% IF ( CAN_user_tools_edit_calendar ) %]
83
    <dt><a href="/cgi-bin/koha/tools/discrete_calendar.pl">Discrete Calendar</a></dt>
84
    <dd>Define days when the library is closed</dd>
85
    [% END %]
86
82
    [% IF ( CAN_user_tools_manage_csv_profiles ) %]
87
    [% IF ( CAN_user_tools_manage_csv_profiles ) %]
83
    <dt><a href="/cgi-bin/koha/tools/csv-profiles.pl">CSV profiles</a></dt>
88
    <dt><a href="/cgi-bin/koha/tools/csv-profiles.pl">CSV profiles</a></dt>
84
	<dd>Manage CSV export profiles</dd>
89
	<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
40
41
sub usage {
41
sub usage {
Lines 294-300 sub GetWaitingHolds { Link Here
294
    $sth->execute();
294
    $sth->execute();
295
    my @results;
295
    my @results;
296
    while ( my $issue = $sth->fetchrow_hashref() ) {
296
    while ( my $issue = $sth->fetchrow_hashref() ) {
297
        my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'} );
297
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $issue->{'site'} );
298
298
299
        my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' );
299
        my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' );
300
        my $pickup_date = $waiting_date->clone->add( days => $pickupdelay );
300
        my $pickup_date = $waiting_date->clone->add( days => $pickupdelay );
(-)a/t/db_dependent/Circulation/CalcFine.t (-22 / +4 lines)
Lines 90-106 subtest 'Test basic functionality' => sub { Link Here
90
        }
90
        }
91
    );
91
    );
92
92
93
    my $start_dt = DateTime->new(
93
    my $start_dt = DateTime->today;
94
        year       => 2000,
94
    my $end_dt = DateTime->today->add(days => 29);
95
        month      => 1,
96
        day        => 1,
97
    );
98
99
    my $end_dt = DateTime->new(
100
        year       => 2000,
101
        month      => 1,
102
        day        => 30,
103
    );
104
95
105
    my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
96
    my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
106
97
Lines 129-145 subtest 'Test cap_fine_to_replacement_price' => sub { Link Here
129
        }
120
        }
130
    );
121
    );
131
122
132
    my $start_dt = DateTime->new(
123
    my $start_dt = DateTime->today;
133
        year       => 2000,
124
    my $end_dt = DateTime->today->add(days => 29);
134
        month      => 1,
135
        day        => 1,
136
    );
137
138
    my $end_dt = DateTime->new(
139
        year       => 2000,
140
        month      => 1,
141
        day        => 30,
142
    );
143
125
144
    my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
126
    my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
145
127
(-)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