Bug 28664: (follow-up) Throw exception if debt if VOID

This patch adds an exception when an attempt is made to refund against a
VOID debit.

Test plan
1) Run the included unit test

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Martin Renvoize 2024-06-27 16:55:55 +01:00 committed by Katrin Fischer
parent a47474e3d7
commit b18664ec45
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
2 changed files with 28 additions and 1 deletions

View File

@ -497,6 +497,10 @@ sub reduce {
Koha::Exceptions::Account::IsNotDebit->throw(
error => 'Account line ' . $self->id . 'is a payout' );
}
if ( $self->debit_type_code eq 'VOID' ) {
Koha::Exceptions::Account::IsNotDebit->throw(
error => 'Account line ' . $self->id . 'is void' );
}
# Check for mandatory parameters
my @mandatory = ( 'interface', 'reduction_type', 'amount' );

View File

@ -1071,7 +1071,7 @@ subtest "payout() tests" => sub {
subtest "reduce() tests" => sub {
plan tests => 34;
plan tests => 35;
$schema->storage->txn_begin;
@ -1254,6 +1254,29 @@ subtest "reduce() tests" => sub {
'Koha::Exceptions::Account::IsNotDebit',
'->reduce() cannot be used on a payout debit';
# Throw exception if attempting to reduce a voided debt
my $payment = Koha::Account::Line->new(
{
borrowernumber => $borrower->borrowernumber,
amount => -20,
amountoutstanding => -20,
interface => 'commandline',
credit_type_code => 'CREDIT'
}
)->store();
my $void = $payment->void(
{
interface => 'intranet',
staff_id => $staff->borrowernumber,
branch => $branchcode,
}
);
throws_ok {
$void->reduce($reduce_params);
}
'Koha::Exceptions::Account::IsNotDebit',
'->reduce() cannot be used on a void debit';
$schema->storage->txn_rollback;
};