Bug 18917: Use font-awesome buttons for CSV profiles
[koha.git] / t / db_dependent / Fines.t
blob1f273bacb721d418125ca455b73a4b6aa5ffca58
1 #!/usr/bin/perl
3 use Modern::Perl;
5 use C4::Context;
6 use C4::Overdues;
7 use Koha::Database;
8 use Koha::DateUtils;
10 use Test::More tests => 5;
12 #Start transaction
13 my $dbh = C4::Context->dbh;
14 my $schema = Koha::Database->new()->schema();
16 $dbh->{RaiseError} = 1;
17 $dbh->{AutoCommit} = 0;
19 $dbh->do(q|DELETE FROM issuingrules|);
21 my $issuingrule = $schema->resultset('Issuingrule')->create(
23 categorycode => '*',
24 itemtype => '*',
25 branchcode => '*',
26 fine => 1,
27 finedays => 0,
28 chargeperiod => 7,
29 chargeperiod_charge_at => 0,
30 lengthunit => 'days',
31 issuelength => 1,
35 ok( $issuingrule, 'Issuing rule created' );
37 my $period_start = dt_from_string('2000-01-01');
38 my $period_end = dt_from_string('2000-01-05');
40 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' );
43 $period_end = dt_from_string('2000-01-10');
44 ( $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' );
47 # Test charging fine at the *beginning* of each charge period
48 $issuingrule->update( { chargeperiod_charge_at => 1 } );
50 $period_end = dt_from_string('2000-01-05');
51 ( $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' );
54 $period_end = dt_from_string('2000-01-10');
55 ( $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' );