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 1200-1206 sub checkHighHolds { Link Here
1200
1200
1201
        my $issuedate = DateTime->now( time_zone => C4::Context->tz() );
1201
        my $issuedate = DateTime->now( time_zone => C4::Context->tz() );
1202
1202
1203
        my $calendar = Koha::Calendar->new( branchcode => $branch );
1203
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
1204
1204
1205
        my $itype = $item_object->effective_itemtype;
1205
        my $itype = $item_object->effective_itemtype;
1206
        my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branch, $borrower );
1206
        my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branch, $borrower );
Lines 2249-2255 sub _debar_user_on_return { Link Here
2249
            my $new_debar_dt;
2249
            my $new_debar_dt;
2250
            # Use the calendar or not to calculate the debarment date
2250
            # Use the calendar or not to calculate the debarment date
2251
            if ( C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed' ) {
2251
            if ( C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed' ) {
2252
                my $calendar = Koha::Calendar->new(
2252
                my $calendar = Koha::DiscreteCalendar->new(
2253
                    branchcode => $branchcode,
2253
                    branchcode => $branchcode,
2254
                    days_mode  => 'Calendar'
2254
                    days_mode  => 'Calendar'
2255
                );
2255
                );
Lines 3519-3525 sub CalcDateDue { Link Here
3519
        else { # days
3519
        else { # days
3520
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3520
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3521
        }
3521
        }
3522
        my $calendar = Koha::Calendar->new( branchcode => $branch );
3522
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
3523
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3523
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3524
        if ($loanlength->{lengthunit} eq 'days') {
3524
        if ($loanlength->{lengthunit} eq 'days') {
3525
            $datedue->set_hour(23);
3525
            $datedue->set_hour(23);
Lines 3558-3564 sub CalcDateDue { Link Here
3558
            }
3558
            }
3559
        }
3559
        }
3560
        if ( C4::Context->preference('useDaysMode') ne 'Days' ) {
3560
        if ( C4::Context->preference('useDaysMode') ne 'Days' ) {
3561
          my $calendar = Koha::Calendar->new( branchcode => $branch );
3561
          my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
3562
          if ( $calendar->is_holiday($datedue) ) {
3562
          if ( $calendar->is_holiday($datedue) ) {
3563
              # Don't return on a closed day
3563
              # Don't return on a closed day
3564
              $datedue = $calendar->prev_open_day( $datedue );
3564
              $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 294-300 sub get_chargeable_units { Link Here
294
    my $charge_duration;
295
    my $charge_duration;
295
    if ($unit eq 'hours') {
296
    if ($unit eq 'hours') {
296
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
297
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
297
            my $calendar = Koha::Calendar->new( branchcode => $branchcode );
298
            my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
298
            $charge_duration = $calendar->hours_between( $date_due, $date_returned );
299
            $charge_duration = $calendar->hours_between( $date_due, $date_returned );
299
        } else {
300
        } else {
300
            $charge_duration = $date_returned->delta_ms( $date_due );
301
            $charge_duration = $date_returned->delta_ms( $date_due );
Lines 306-312 sub get_chargeable_units { Link Here
306
    }
307
    }
307
    else { # days
308
    else { # days
308
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
309
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
309
            my $calendar = Koha::Calendar->new( branchcode => $branchcode );
310
            my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
310
            $charge_duration = $calendar->days_between( $date_due, $date_returned );
311
            $charge_duration = $calendar->days_between( $date_due, $date_returned );
311
        } else {
312
        } else {
312
            $charge_duration = $date_returned->delta_days( $date_due );
313
            $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 845-851 sub CancelExpiredReserves { Link Here
845
    my $holds = Koha::Holds->search( $params );
845
    my $holds = Koha::Holds->search( $params );
846
846
847
    while ( my $hold = $holds->next ) {
847
    while ( my $hold = $holds->next ) {
848
        my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
848
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $hold->branchcode );
849
849
850
        next if !$cancel_on_holidays && $calendar->is_holiday( $today );
850
        next if !$cancel_on_holidays && $calendar->is_holiday( $today );
851
851
(-)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 Koha::Exceptions::Hold;
37
use Koha::Exceptions::Hold;
38
38
Lines 64-70 sub age { Link Here
64
    my $age;
64
    my $age;
65
65
66
    if ( $use_calendar ) {
66
    if ( $use_calendar ) {
67
        my $calendar = Koha::Calendar->new( branchcode => $self->branchcode );
67
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $self->branchcode );
68
        $age = $calendar->days_between( dt_from_string( $self->reservedate ), $today );
68
        $age = $calendar->days_between( dt_from_string( $self->reservedate ), $today );
69
    }
69
    }
70
    else {
70
    else {
Lines 178-184 sub set_waiting { Link Here
178
178
179
    my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
179
    my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
180
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
180
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
181
    my $calendar = Koha::Calendar->new( branchcode => $self->branchcode );
181
    my $calendar = Koha::DiscreteCalendar->new( branchcode => $self->branchcode );
182
182
183
    my $expirationdate = $today->clone;
183
    my $expirationdate = $today->clone;
184
    $expirationdate->add(days => $max_pickup_delay);
184
    $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 14347-14353 if( CheckVersion( $DBversion ) ) { Link Here
14347
14347
14348
$DBversion = '16.12.00.032';
14348
$DBversion = '16.12.00.032';
14349
if( CheckVersion( $DBversion ) ) {
14349
if( CheckVersion( $DBversion ) ) {
14350
    require Koha::Calendar;
14350
    require Koha::DiscreteCalendar;
14351
    require Koha::Holds;
14351
    require Koha::Holds;
14352
14352
14353
    $dbh->do(q{
14353
    $dbh->do(q{
Lines 14366-14372 if( CheckVersion( $DBversion ) ) { Link Here
14366
14366
14367
        my $expirationdate = dt_from_string($hold->waitingdate);
14367
        my $expirationdate = dt_from_string($hold->waitingdate);
14368
        if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
14368
        if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
14369
            my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
14369
            my $calendar = Koha::DiscreteCalendar->new( branchcode => $hold->branchcode );
14370
            $expirationdate = $calendar->days_forward( $expirationdate, $max_pickup_delay );
14370
            $expirationdate = $calendar->days_forward( $expirationdate, $max_pickup_delay );
14371
        } else {
14371
        } else {
14372
            $expirationdate->add( days => $max_pickup_delay );
14372
            $expirationdate->add( days => $max_pickup_delay );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (+5 lines)
Lines 89-94 Link Here
89
    <dd>Define days when the library is closed</dd>
89
    <dd>Define days when the library is closed</dd>
90
    [% END %]
90
    [% END %]
91
91
92
    [% IF ( CAN_user_tools_edit_calendar ) %]
93
    <dt><a href="/cgi-bin/koha/tools/discrete_calendar.pl">Discrete Calendar</a></dt>
94
    <dd>Define days when the library is closed</dd>
95
    [% END %]
96
92
    [% IF ( CAN_user_tools_manage_csv_profiles ) %]
97
    [% IF ( CAN_user_tools_manage_csv_profiles ) %]
93
    <dt><a href="/cgi-bin/koha/tools/csv-profiles.pl">CSV profiles</a></dt>
98
    <dt><a href="/cgi-bin/koha/tools/csv-profiles.pl">CSV profiles</a></dt>
94
    <dd>Manage CSV export profiles</dd>
99
    <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 174-180 EOM Link Here
174
sub set_holiday {
174
sub set_holiday {
175
    my ( $branch, $dt ) = @_;
175
    my ( $branch, $dt ) = @_;
176
176
177
    my $calendar = Koha::Calendar->new( branchcode => $branch );
177
    my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
178
    return $calendar->is_holiday($dt);
178
    return $calendar->is_holiday($dt);
179
}
179
}
180
180
(-)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 31-53 my $issuingrule = $schema->resultset('Issuingrule')->create( Link Here
31
32
32
ok( $issuingrule, 'Issuing rule created' );
33
ok( $issuingrule, 'Issuing rule created' );
33
34
34
my $period_start = dt_from_string('2000-01-01');
35
my $period_start = dt_from_string;
35
my $period_end = dt_from_string('2000-01-05');
36
my $period_end = dt_from_string->add(days => 4);
36
37
37
my ( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
38
my ( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
38
is( $fine, 0, '4 days overdue, charge period 7 days, charge at end of interval gives fine of $0' );
39
is( $fine, 0, '4 days overdue, charge period 7 days, charge at end of interval gives fine of $0' );
39
40
40
$period_end = dt_from_string('2000-01-10');
41
$period_end = dt_from_string->add(days => 9);
41
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
42
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
42
is( $fine, 1, '9 days overdue, charge period 7 days, charge at end of interval gives fine of $1' );
43
is( $fine, 1, '9 days overdue, charge period 7 days, charge at end of interval gives fine of $1' );
43
44
44
# Test charging fine at the *beginning* of each charge period
45
# Test charging fine at the *beginning* of each charge period
45
$issuingrule->update( { chargeperiod_charge_at => 1 } );
46
$issuingrule->update( { chargeperiod_charge_at => 1 } );
46
47
47
$period_end = dt_from_string('2000-01-05');
48
$period_end = dt_from_string->add(days => 4);
48
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
49
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
49
is( $fine, 1, '4 days overdue, charge period 7 days, charge at start of interval gives fine of $1' );
50
is( $fine, 1, '4 days overdue, charge period 7 days, charge at start of interval gives fine of $1' );
50
51
51
$period_end = dt_from_string('2000-01-10');
52
$period_end = dt_from_string->add(days => 9);
52
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
53
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
53
is( $fine, 2, '9 days overdue, charge period 7 days, charge at start of interval gives fine of $2' );
54
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