Kyle M Hall
f86816220e
Right now, Koha only charges fines at the end of a given charge period. For example, let us assume a circulation rule has a charge period of one week ( 7 days ) and a fine of $5. This means that an item can be overdue for 6 days without accruing a fine. Koha should allow circulation rules to be configured to place the charge at the start of the end of the charge period so the library can decide when the fine should accrue. Test Plan: 1) Apply this patch 2) Run updatedatabase.pl 3) prove t/db_dependent/Circulation_Issuingrule.t 4) prove t/db_dependent/Circulation.t 5) prove t/db_dependent/Fines.t 6) Ensure you can still create/edit circulation rules Edit: I removed the DBIx changes after a couple minutes fighting with them. Will regenerate as usual in a RM followup / Tomas Signed-off-by: Daniel Grobani <dgrobani@samuelmerritt.edu> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
56 lines
1.8 KiB
Perl
56 lines
1.8 KiB
Perl
#!/usr/bin/perl
|
|
|
|
use Modern::Perl;
|
|
|
|
use C4::Context;
|
|
use C4::Overdues;
|
|
use Koha::Database;
|
|
use Koha::DateUtils;
|
|
|
|
use Test::More tests => 5;
|
|
|
|
#Start transaction
|
|
my $dbh = C4::Context->dbh;
|
|
my $schema = Koha::Database->new()->schema();
|
|
|
|
$dbh->{RaiseError} = 1;
|
|
$dbh->{AutoCommit} = 0;
|
|
|
|
$dbh->do(q|DELETE FROM issuingrules|);
|
|
|
|
my $issuingrule = $schema->resultset('Issuingrule')->create(
|
|
{
|
|
categorycode => '*',
|
|
itemtype => '*',
|
|
branchcode => '*',
|
|
fine => 1,
|
|
finedays => 0,
|
|
chargeperiod => 7,
|
|
chargeperiod_charge_at => 0,
|
|
lengthunit => 'days',
|
|
issuelength => 1,
|
|
}
|
|
);
|
|
|
|
ok( $issuingrule, 'Issuing rule created' );
|
|
|
|
my $period_start = dt_from_string('2000-01-01');
|
|
my $period_end = dt_from_string('2000-01-05');
|
|
|
|
my ( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end );
|
|
is( $fine, 0, '4 days overdue, charge period 7 days, charge at end of interval gives fine of $0' );
|
|
|
|
$period_end = dt_from_string('2000-01-10');
|
|
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end );
|
|
is( $fine, 1, '9 days overdue, charge period 7 days, charge at end of interval gives fine of $1' );
|
|
|
|
# Test charging fine at the *beginning* of each charge period
|
|
$issuingrule->update( { chargeperiod_charge_at => 1 } );
|
|
|
|
$period_end = dt_from_string('2000-01-05');
|
|
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end );
|
|
is( $fine, 1, '4 days overdue, charge period 7 days, charge at start of interval gives fine of $1' );
|
|
|
|
$period_end = dt_from_string('2000-01-10');
|
|
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end );
|
|
is( $fine, 2, '9 days overdue, charge period 7 days, charge at start of interval gives fine of $2' );
|