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

(-)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 = DateTime->today;
38
my $period_end = dt_from_string('2000-01-05');
39
my $period_end = DateTime->today->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 = DateTime->today->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 = DateTime->today->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 = DateTime->today->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 / +18 lines)
Lines 11-19 use Modern::Perl; Link Here
11
use Test::More tests => 43;
11
use Test::More tests => 43;
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 188-193 $library2 = $builder->build({ Link Here
188
$library3 = $builder->build({
188
$library3 = $builder->build({
189
    source => 'Branch',
189
    source => 'Branch',
190
});
190
});
191
192
$schema->resultset('DiscreteCalendar')->search({
193
    branchcode  =>'DFLT'
194
})->update_all({
195
    isopened    => 1,
196
    holidaytype => '',
197
    note        => '',
198
    openhour    => '08:00:00',
199
    closehour   => '16:00:00'
200
});
201
202
Koha::DiscreteCalendar->new( branchcode => 'DFLT' )->add_new_branch('DFLT', $library1->{branchcode});
203
Koha::DiscreteCalendar->new( branchcode => 'DFLT' )->add_new_branch('DFLT', $library2->{branchcode});
204
Koha::DiscreteCalendar->new( branchcode => 'DFLT' )->add_new_branch('DFLT', $library3->{branchcode});
205
191
@branchcodes = ( $library1->{branchcode}, $library2->{branchcode}, $library3->{branchcode} );
206
@branchcodes = ( $library1->{branchcode}, $library2->{branchcode}, $library3->{branchcode} );
192
207
193
my $borrower1 = $builder->build({
208
my $borrower1 = $builder->build({
Lines 301-316 is( $holds_queue->[1]->{cardnumber}, $borrower2->{cardnumber}, "Holds queue fill Link Here
301
# have 1 row in the holds queue
316
# have 1 row in the holds queue
302
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 1);
317
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 1);
303
my $today = dt_from_string();
318
my $today = dt_from_string();
304
C4::Calendar->new( branchcode => $branchcodes[0] )->insert_single_holiday(
305
    day         => $today->day(),
306
    month       => $today->month(),
307
    year        => $today->year(),
308
    title       => "$today",
309
    description => "$today",
310
);
311
# If the test below is removed, aother tests using the holiday will fail. For some reason if we call is_holiday now
319
# If the test below is removed, aother tests using the holiday will fail. For some reason if we call is_holiday now
312
# the holiday will get set in cache correctly, but not if we let C4::HoldsQueue call is_holiday instead.
320
# the holiday will get set in cache correctly, but not if we let C4::HoldsQueue call is_holiday instead.
313
is( Koha::Calendar->new( branchcode => $branchcodes[0] )->is_holiday( $today ), 1, 'Is today a holiday for pickup branch' );
321
Koha::DiscreteCalendar->new( branchcode => $branchcodes[0] )->edit_holiday("Today", '', "E", '', '', $today, $today);
322
is( Koha::DiscreteCalendar->new( branchcode => $branchcodes[0] )->is_holiday( $today ), 1, 'Is today a holiday for pickup branch' );
314
C4::HoldsQueue::CreateQueue();
323
C4::HoldsQueue::CreateQueue();
315
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
324
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
316
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" );
325
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" );
317
- 

Return to bug 17015