5 use Test::More tests => 2;
10 use Koha::DateUtils qw( dt_from_string );
12 use t::lib::TestBuilder;
15 our $dbh = C4::Context->dbh;
16 $dbh->{AutoCommit} = 0;
17 $dbh->{RaiseError} = 1;
19 $dbh->do(q|DELETE FROM issues|);
21 my $builder = t::lib::TestBuilder->new();
23 my $branch = $builder->build(
29 my $category = $builder->build(
35 my $patron = $builder->build(
39 categorycode => $category->{categorycode},
40 branchcode => $branch->{branchcode},
45 my $biblio = $builder->build(
49 branchcode => $branch->{branchcode},
54 my $item = $builder->build(
58 biblionumber => $biblio->{biblionumber},
59 homebranch => $branch->{branchcode},
60 holdingbranch => $branch->{branchcode},
61 replacementprice => '5.00',
66 subtest 'Test basic functionality' => sub {
69 my $rule = $builder->schema->resultset('Issuingrule')->find({
74 $rule->delete if $rule;
75 my $issuingrule = $builder->build(
77 source => 'Issuingrule',
87 overduefinescap => undef,
88 cap_fine_to_replacement_price => 0,
93 my $start_dt = DateTime->new(
99 my $end_dt = DateTime->new(
105 my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
107 is( $amount, 29, 'Amount is calculated correctly' );
112 subtest 'Test cap_fine_to_replacement_price' => sub {
114 my $issuingrule = $builder->build(
116 source => 'Issuingrule',
122 lengthunit => 'days',
126 overduefinescap => undef,
127 cap_fine_to_replacement_price => 1,
132 my $start_dt = DateTime->new(
138 my $end_dt = DateTime->new(
144 my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
146 is( $amount, '5.00', 'Amount is calculated correctly' );
152 $dbh->do(q|DELETE FROM issuingrules|);