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(
26 chargeperiod_charge_at => 0,
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' );