use Modern::Perl;
use utf8;
-use Test::More tests => 128;
+use Test::More tests => 130;
use Test::MockModule;
use Data::Dumper;
{
amount => $fines_amount,
interface => 'test',
- type => 'fine',
+ type => 'overdue',
item_id => $item_to_auto_renew->{itemnumber},
description => "Some fines"
}
{
amount => $fines_amount,
interface => 'test',
- type => 'fine',
+ type => 'overdue',
item_id => $item_to_auto_renew->{itemnumber},
description => "Some fines"
}
{
amount => $fines_amount,
interface => 'test',
- type => 'fine',
+ type => 'overdue',
item_id => $item_to_auto_renew->{itemnumber},
description => "Some fines"
}
is( $line->issue_id, $issue->id, 'Account line issue id matches' );
my $offset = Koha::Account::Offsets->search({ debit_id => $line->id })->next();
- is( $offset->type, 'Fine', 'Account offset type is Fine' );
+ is( $offset->type, 'OVERDUE', 'Account offset type is Fine' );
is( $offset->amount, '15.000000', 'Account offset amount is 15.00' );
t::lib::Mocks::mock_preference('WhenLostForgiveFine','0');
my $library = $builder->build( { source => 'Branch' } );
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
+ my $manager = $builder->build_object({ class => "Koha::Patrons" });
+ t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
my $biblioitem = $builder->build( { source => 'Biblioitem' } );
my $item = $builder->build(
);
my $manual_debit_amount = 80;
- $account->add_debit( { amount => $manual_debit_amount, type => 'fine', interface =>'test' } );
+ $account->add_debit( { amount => $manual_debit_amount, type => 'overdue', interface =>'test' } );
is( $account->balance, $manual_debit_amount + $replacement_amount - $payment_amount, 'Manual debit applied' );
};
subtest '_FixOverduesOnReturn' => sub {
- plan tests => 6;
+ plan tests => 9;
+
+ my $manager = $builder->build_object({ class => "Koha::Patrons" });
+ t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
my $biblio = $builder->build_sample_biblio({ author => 'Hall, Kylie' });
is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' );
is( $accountline->status, 'RETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status RETURNED )');
-
## Run again, with exemptfine enabled
$accountline->set(
{
is( $accountline->status, 'FORGIVEN', 'Open fine ( account type OVERDUE ) has been set to fine forgiven ( status FORGIVEN )');
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" );
is( $offset->amount, '-99.000000', "Amount of offset is correct" );
+ my $credit = $offset->credit;
+ is( ref $credit, "Koha::Account::Line", "Found matching credit for fine forgiveness" );
+ is( $credit->amount, '-99.000000', "Credit amount is set correctly" );
+ is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" );
};
subtest 'Set waiting flag' => sub {