Bug 22884: Show separator between 440 and 490 fields
[koha.git] / t / db_dependent / Fines.t
blob7a0ede44c478d71a8004118985410807255be282
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 my $schema = Koha::Database->new->schema;
13 $schema->storage->txn_begin;
14 my $dbh = C4::Context->dbh;
16 $dbh->do(q|DELETE FROM issuingrules|);
18 my $issuingrule = $schema->resultset('Issuingrule')->create(
20 categorycode => '*',
21 itemtype => '*',
22 branchcode => '*',
23 fine => 1,
24 finedays => 0,
25 chargeperiod => 7,
26 chargeperiod_charge_at => 0,
27 lengthunit => 'days',
28 issuelength => 1,
32 ok( $issuingrule, 'Issuing rule created' );
34 my $period_start = dt_from_string('2000-01-01');
35 my $period_end = dt_from_string('2000-01-05');
37 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' );
40 $period_end = dt_from_string('2000-01-10');
41 ( $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' );
44 # Test charging fine at the *beginning* of each charge period
45 $issuingrule->update( { chargeperiod_charge_at => 1 } );
47 $period_end = dt_from_string('2000-01-05');
48 ( $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' );
51 $period_end = dt_from_string('2000-01-10');
52 ( $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' );