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

(-)a/t/db_dependent/Circulation/CalcDateDue.t (+2 lines)
Lines 26-31 my $issuelength = 10; Link Here
26
my $renewalperiod = 5;
26
my $renewalperiod = 5;
27
my $lengthunit = 'days';
27
my $lengthunit = 'days';
28
28
29
$builder->fill_discrete_calendar({ branchcode => $branchcode, start_date => '2013-01-01', days => 365 });
30
29
Koha::CirculationRules->search()->delete();
31
Koha::CirculationRules->search()->delete();
30
Koha::CirculationRules->set_rules(
32
Koha::CirculationRules->set_rules(
31
    {
33
    {
(-)a/t/db_dependent/Circulation/CalcFine.t (+1 lines)
Lines 28-33 my $branch = $builder->build( Link Here
28
        source => 'Branch',
28
        source => 'Branch',
29
    }
29
    }
30
);
30
);
31
$builder->fill_discrete_calendar({ branchcode => $branch->{branchcode}, start_date => '2000-01-01' });
31
32
32
my $category = $builder->build(
33
my $category = $builder->build(
33
    {
34
    {
(-)a/t/db_dependent/Circulation/maxsuspensiondays.t (+6 lines)
Lines 127-132 subtest "suspension_chargeperiod" => sub { Link Here
127
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
127
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
128
    my $item = $builder->build_sample_item;
128
    my $item = $builder->build_sample_item;
129
129
130
    $builder->fill_discrete_calendar({ branchcode => $patron->{branchcode}, days => 365 });
131
    $builder->fill_discrete_calendar({ branchcode => $item->homebranch, days => 365 });
132
130
    my $last_year = dt_from_string->clone->subtract( years => 1 );
133
    my $last_year = dt_from_string->clone->subtract( years => 1 );
131
    my $today = dt_from_string;
134
    my $today = dt_from_string;
132
    my $new_debar_dt = C4::Circulation::_calculate_new_debar_dt( $patron->unblessed, $item->unblessed, $last_year, $today );
135
    my $new_debar_dt = C4::Circulation::_calculate_new_debar_dt( $patron->unblessed, $item->unblessed, $last_year, $today );
Lines 153-158 subtest "maxsuspensiondays" => sub { Link Here
153
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
156
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
154
    my $item = $builder->build_sample_item;
157
    my $item = $builder->build_sample_item;
155
158
159
    $builder->fill_discrete_calendar({ branchcode => $patron->{branchcode}, days => 365 });
160
    $builder->fill_discrete_calendar({ branchcode => $item->homebranch, days => 365 });
161
156
    my $last_year = dt_from_string->clone->subtract( years => 1 );
162
    my $last_year = dt_from_string->clone->subtract( years => 1 );
157
    my $today = dt_from_string;
163
    my $today = dt_from_string;
158
    my $new_debar_dt = C4::Circulation::_calculate_new_debar_dt( $patron->unblessed, $item->unblessed, $last_year, $today );
164
    my $new_debar_dt = C4::Circulation::_calculate_new_debar_dt( $patron->unblessed, $item->unblessed, $last_year, $today );
(-)a/t/db_dependent/Fines.t (+5 lines)
Lines 7-12 use C4::Overdues qw( CalcFine ); Link Here
7
use Koha::Database;
7
use Koha::Database;
8
use Koha::DateUtils qw( dt_from_string );
8
use Koha::DateUtils qw( dt_from_string );
9
9
10
use t::lib::TestBuilder;
10
use Test::More tests => 5;
11
use Test::More tests => 5;
11
12
12
my $schema = Koha::Database->new->schema;
13
my $schema = Koha::Database->new->schema;
Lines 31-36 my $issuingrule = Koha::CirculationRules->set_rules( Link Here
31
    }
32
    }
32
);
33
);
33
34
35
my $builder = t::lib::TestBuilder->new();
36
$builder->fill_discrete_calendar({ branchcode => '' });
37
$builder->fill_discrete_calendar({ branchcode => '', start_date => '2000-01-01' });
38
34
ok( $issuingrule, 'Issuing rule created' );
39
ok( $issuingrule, 'Issuing rule created' );
35
40
36
my $period_start = dt_from_string('2000-01-01');
41
my $period_start = dt_from_string('2000-01-01');
(-)a/t/db_dependent/Hold.t (+1 lines)
Lines 77-82 my $hold = Koha::Hold->new( Link Here
77
);
77
);
78
$hold->store();
78
$hold->store();
79
79
80
$builder->fill_discrete_calendar({ branchcode => $branches[1]->{branchcode}, start_date => '2017-01-01', days => dt_from_string->delta_days( dt_from_string( '2017-01-01' ) )->in_units( 'days') });
80
my $b1_cal = Koha::DiscreteCalendar->new({ branchcode => $branches[1]->{branchcode} });
81
my $b1_cal = Koha::DiscreteCalendar->new({ branchcode => $branches[1]->{branchcode} });
81
my $holiday = dt_from_string('2017-01-02', 'iso');
82
my $holiday = dt_from_string('2017-01-02', 'iso');
82
$b1_cal->edit_holiday({
83
$b1_cal->edit_holiday({
(-)a/t/db_dependent/Holds/WaitingReserves.t (+1 lines)
Lines 35-40 $builder->build({ Link Here
35
    },
35
    },
36
});
36
});
37
37
38
$builder->fill_discrete_calendar({ branchcode => 'LIB1' });
38
my $calendar = Koha::DiscreteCalendar->new({ branchcode => 'LIB1' });
39
my $calendar = Koha::DiscreteCalendar->new({ branchcode => 'LIB1' });
39
40
40
$builder->build({
41
$builder->build({
(-)a/t/db_dependent/Reserves/CancelExpiredReserves.t (+1 lines)
Lines 81-86 subtest 'CancelExpiredReserves tests incl. holidays' => sub { Link Here
81
    });
81
    });
82
82
83
    Koha::Caches->get_instance()->flush_all();
83
    Koha::Caches->get_instance()->flush_all();
84
    $builder->fill_discrete_calendar({ branchcode => 'LIB1 '});
84
    my $calendar = Koha::DiscreteCalendar->new({ branchcode => 'LIB1' })->edit_holiday({
85
    my $calendar = Koha::DiscreteCalendar->new({ branchcode => 'LIB1' })->edit_holiday({
85
        title => "My holiday",
86
        title => "My holiday",
86
        holiday_type => $Koha::DiscreteCalendar::HOLIDAYS->{EXCEPTION},
87
        holiday_type => $Koha::DiscreteCalendar::HOLIDAYS->{EXCEPTION},
(-)a/t/lib/TestBuilder.pm (-2 / +31 lines)
Lines 6-12 use Koha::Database qw( schema ); Link Here
6
use C4::Biblio qw( AddBiblio );
6
use C4::Biblio qw( AddBiblio );
7
use Koha::Biblios qw( _type );
7
use Koha::Biblios qw( _type );
8
use Koha::Items qw( _type );
8
use Koha::Items qw( _type );
9
use Koha::DateUtils qw( dt_from_string );
9
use Koha::DateUtils qw( dt_from_string output_pref );
10
10
11
use Bytes::Random::Secure;
11
use Bytes::Random::Secure;
12
use Carp qw( carp );
12
use Carp qw( carp );
Lines 146-151 sub build { Link Here
146
          if scalar @{ $fk->{keys} } == 1
146
          if scalar @{ $fk->{keys} } == 1
147
    }
147
    }
148
148
149
    if ($source eq 'Branch') {
150
        $self->fill_discrete_calendar({ branchcode => $col_values->{branchcode} });
151
    }
152
149
    # store this record and return hashref
153
    # store this record and return hashref
150
    return $self->_storeColumnValues({
154
    return $self->_storeColumnValues({
151
        source => $source,
155
        source => $source,
Lines 210-215 sub build_sample_item { Link Here
210
    )->store->get_from_storage;
214
    )->store->get_from_storage;
211
}
215
}
212
216
217
sub fill_discrete_calendar {
218
    my ( $self, $args ) = @_;
219
220
    my $branchcode = $args->{branchcode} || '';
221
    my $start_date = ($args->{start_date}) ? dt_from_string($args->{start_date}) : DateTime->today();
222
    my $days = $args->{days} || 60;
223
224
    my $end_date = $start_date->clone();
225
    $start_date->add(days => 0 - $days);
226
    $end_date->add(days => $days);
227
228
    for (1; $start_date <= $end_date; $start_date->add(days => 1)) {
229
        my $data = {
230
            date       => output_pref( { dt => $start_date, dateformat => 'iso', dateonly => 1 }),
231
            branchcode => $branchcode,
232
            is_opened  => 1,
233
            open_hour  => "08:00:00",
234
            close_hour => "17:00:00",
235
        };
236
237
        $self->schema->resultset( "DiscreteCalendar" )->update_or_create( $data );
238
    }
239
240
    return
241
}
242
213
# ------------------------------------------------------------------------------
243
# ------------------------------------------------------------------------------
214
# Internal helper routines
244
# Internal helper routines
215
245
216
- 

Return to bug 17015